Add .gitignore to exclude all node packages and lock files
This commit is contained in:
Generated
Vendored
+4
@@ -0,0 +1,4 @@
|
||||
import React from 'react';
|
||||
type ReactChildArray = ReturnType<typeof React.Children.toArray>;
|
||||
export declare const flattenChildren: (children: React.ReactNode) => ReactChildArray;
|
||||
export {};
|
||||
Generated
Vendored
+19
@@ -0,0 +1,19 @@
|
||||
"use strict";
|
||||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.flattenChildren = void 0;
|
||||
const react_1 = __importDefault(require("react"));
|
||||
const flattenChildren = (children) => {
|
||||
const childrenArray = react_1.default.Children.toArray(children);
|
||||
return childrenArray.reduce((flatChildren, child) => {
|
||||
if (child.type === react_1.default.Fragment) {
|
||||
return flatChildren.concat((0, exports.flattenChildren)(child.props
|
||||
.children));
|
||||
}
|
||||
flatChildren.push(child);
|
||||
return flatChildren;
|
||||
}, []);
|
||||
};
|
||||
exports.flattenChildren = flattenChildren;
|
||||
+23
@@ -0,0 +1,23 @@
|
||||
import type { FC, PropsWithChildren } from 'react';
|
||||
import React from 'react';
|
||||
import type { LayoutAndStyle, SequenceProps } from '../Sequence.js';
|
||||
import { ENABLE_V5_BREAKING_CHANGES } from '../v5-flag.js';
|
||||
type SeriesSequenceProps = PropsWithChildren<{
|
||||
readonly durationInFrames: number;
|
||||
readonly offset?: number;
|
||||
readonly className?: string;
|
||||
} & Pick<SequenceProps, 'layout' | 'name'> & LayoutAndStyle>;
|
||||
declare const SeriesSequence: React.ForwardRefExoticComponent<SeriesSequenceProps & React.RefAttributes<HTMLDivElement>>;
|
||||
type V4Props = {
|
||||
children: React.ReactNode;
|
||||
};
|
||||
type V5Props = SequenceProps;
|
||||
type SeriesProps = true extends typeof ENABLE_V5_BREAKING_CHANGES ? V5Props : V4Props;
|
||||
/**
|
||||
* @description with this component, you can easily stitch together scenes that should play sequentially after another.
|
||||
* @see [Documentation](https://www.remotion.dev/docs/series)
|
||||
*/
|
||||
declare const Series: FC<SeriesProps> & {
|
||||
Sequence: typeof SeriesSequence;
|
||||
};
|
||||
export { Series };
|
||||
+74
@@ -0,0 +1,74 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.Series = void 0;
|
||||
const jsx_runtime_1 = require("react/jsx-runtime");
|
||||
const react_1 = require("react");
|
||||
const Sequence_js_1 = require("../Sequence.js");
|
||||
const enable_sequence_stack_traces_js_1 = require("../enable-sequence-stack-traces.js");
|
||||
const v5_flag_js_1 = require("../v5-flag.js");
|
||||
const validate_duration_in_frames_js_1 = require("../validation/validate-duration-in-frames.js");
|
||||
const flatten_children_js_1 = require("./flatten-children.js");
|
||||
const is_inside_series_js_1 = require("./is-inside-series.js");
|
||||
const SeriesSequenceRefForwardingFunction = ({ children }, _ref) => {
|
||||
(0, is_inside_series_js_1.useRequireToBeInsideSeries)();
|
||||
// Discard ref
|
||||
return (0, jsx_runtime_1.jsx)(is_inside_series_js_1.IsNotInsideSeriesProvider, { children: children });
|
||||
};
|
||||
const SeriesSequence = (0, react_1.forwardRef)(SeriesSequenceRefForwardingFunction);
|
||||
/**
|
||||
* @description with this component, you can easily stitch together scenes that should play sequentially after another.
|
||||
* @see [Documentation](https://www.remotion.dev/docs/series)
|
||||
*/
|
||||
const Series = (props) => {
|
||||
const childrenValue = (0, react_1.useMemo)(() => {
|
||||
let startFrame = 0;
|
||||
const flattenedChildren = (0, flatten_children_js_1.flattenChildren)(props.children);
|
||||
return react_1.Children.map(flattenedChildren, (child, i) => {
|
||||
var _a;
|
||||
const castedChild = child;
|
||||
if (typeof castedChild === 'string') {
|
||||
// Don't throw if it's just some accidential whitespace
|
||||
if (castedChild.trim() === '') {
|
||||
return null;
|
||||
}
|
||||
throw new TypeError(`The <Series /> component only accepts a list of <Series.Sequence /> components as its children, but you passed a string "${castedChild}"`);
|
||||
}
|
||||
if (castedChild.type !== SeriesSequence) {
|
||||
throw new TypeError(`The <Series /> component only accepts a list of <Series.Sequence /> components as its children, but got ${castedChild} instead`);
|
||||
}
|
||||
const debugInfo = `index = ${i}, duration = ${castedChild.props.durationInFrames}`;
|
||||
if (!(castedChild === null || castedChild === void 0 ? void 0 : castedChild.props.children)) {
|
||||
throw new TypeError(`A <Series.Sequence /> component (${debugInfo}) was detected to not have any children. Delete it to fix this error.`);
|
||||
}
|
||||
const durationInFramesProp = castedChild.props.durationInFrames;
|
||||
const { durationInFrames, children: _children, from, name, ...passedProps } = castedChild.props; // `from` is not accepted and must be filtered out if used in JS
|
||||
if (i !== flattenedChildren.length - 1 ||
|
||||
durationInFramesProp !== Infinity) {
|
||||
(0, validate_duration_in_frames_js_1.validateDurationInFrames)(durationInFramesProp, {
|
||||
component: `of a <Series.Sequence /> component`,
|
||||
allowFloats: true,
|
||||
});
|
||||
}
|
||||
const offset = (_a = castedChild.props.offset) !== null && _a !== void 0 ? _a : 0;
|
||||
if (Number.isNaN(offset)) {
|
||||
throw new TypeError(`The "offset" property of a <Series.Sequence /> must not be NaN, but got NaN (${debugInfo}).`);
|
||||
}
|
||||
if (!Number.isFinite(offset)) {
|
||||
throw new TypeError(`The "offset" property of a <Series.Sequence /> must be finite, but got ${offset} (${debugInfo}).`);
|
||||
}
|
||||
if (offset % 1 !== 0) {
|
||||
throw new TypeError(`The "offset" property of a <Series.Sequence /> must be finite, but got ${offset} (${debugInfo}).`);
|
||||
}
|
||||
const currentStartFrame = startFrame + offset;
|
||||
startFrame += durationInFramesProp + offset;
|
||||
return ((0, jsx_runtime_1.jsx)(Sequence_js_1.Sequence, { name: name || '<Series.Sequence>', from: currentStartFrame, durationInFrames: durationInFramesProp, ...passedProps, ref: castedChild.ref, children: child }));
|
||||
});
|
||||
}, [props.children]);
|
||||
if (v5_flag_js_1.ENABLE_V5_BREAKING_CHANGES) {
|
||||
return ((0, jsx_runtime_1.jsx)(is_inside_series_js_1.IsInsideSeriesContainer, { children: (0, jsx_runtime_1.jsx)(Sequence_js_1.Sequence, { ...props, children: childrenValue }) }));
|
||||
}
|
||||
return (0, jsx_runtime_1.jsx)(is_inside_series_js_1.IsInsideSeriesContainer, { children: childrenValue });
|
||||
};
|
||||
exports.Series = Series;
|
||||
Series.Sequence = SeriesSequence;
|
||||
(0, enable_sequence_stack_traces_js_1.addSequenceStackTraces)(SeriesSequence);
|
||||
Generated
Vendored
+9
@@ -0,0 +1,9 @@
|
||||
import React from 'react';
|
||||
export declare const IsInsideSeriesContext: React.Context<boolean>;
|
||||
export declare const IsInsideSeriesContainer: React.FC<{
|
||||
readonly children: React.ReactNode;
|
||||
}>;
|
||||
export declare const IsNotInsideSeriesProvider: React.FC<{
|
||||
readonly children: React.ReactNode;
|
||||
}>;
|
||||
export declare const useRequireToBeInsideSeries: () => void;
|
||||
Generated
Vendored
+54
@@ -0,0 +1,54 @@
|
||||
"use strict";
|
||||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
var desc = Object.getOwnPropertyDescriptor(m, k);
|
||||
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
||||
desc = { enumerable: true, get: function() { return m[k]; } };
|
||||
}
|
||||
Object.defineProperty(o, k2, desc);
|
||||
}) : (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
o[k2] = m[k];
|
||||
}));
|
||||
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
||||
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
||||
}) : function(o, v) {
|
||||
o["default"] = v;
|
||||
});
|
||||
var __importStar = (this && this.__importStar) || (function () {
|
||||
var ownKeys = function(o) {
|
||||
ownKeys = Object.getOwnPropertyNames || function (o) {
|
||||
var ar = [];
|
||||
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
||||
return ar;
|
||||
};
|
||||
return ownKeys(o);
|
||||
};
|
||||
return function (mod) {
|
||||
if (mod && mod.__esModule) return mod;
|
||||
var result = {};
|
||||
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
||||
__setModuleDefault(result, mod);
|
||||
return result;
|
||||
};
|
||||
})();
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.useRequireToBeInsideSeries = exports.IsNotInsideSeriesProvider = exports.IsInsideSeriesContainer = exports.IsInsideSeriesContext = void 0;
|
||||
const jsx_runtime_1 = require("react/jsx-runtime");
|
||||
const react_1 = __importStar(require("react"));
|
||||
exports.IsInsideSeriesContext = (0, react_1.createContext)(false);
|
||||
const IsInsideSeriesContainer = ({ children }) => {
|
||||
return ((0, jsx_runtime_1.jsx)(exports.IsInsideSeriesContext.Provider, { value: true, children: children }));
|
||||
};
|
||||
exports.IsInsideSeriesContainer = IsInsideSeriesContainer;
|
||||
const IsNotInsideSeriesProvider = ({ children }) => {
|
||||
return ((0, jsx_runtime_1.jsx)(exports.IsInsideSeriesContext.Provider, { value: false, children: children }));
|
||||
};
|
||||
exports.IsNotInsideSeriesProvider = IsNotInsideSeriesProvider;
|
||||
const useRequireToBeInsideSeries = () => {
|
||||
const isInsideSeries = react_1.default.useContext(exports.IsInsideSeriesContext);
|
||||
if (!isInsideSeries) {
|
||||
throw new Error('This component must be inside a <Series /> component.');
|
||||
}
|
||||
};
|
||||
exports.useRequireToBeInsideSeries = useRequireToBeInsideSeries;
|
||||
Reference in New Issue
Block a user