UNPKG

3.3 kBJavaScriptView Raw
1"use strict";
2var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3 if (k2 === undefined) k2 = k;
4 Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
5}) : (function(o, m, k, k2) {
6 if (k2 === undefined) k2 = k;
7 o[k2] = m[k];
8}));
9var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
10 Object.defineProperty(o, "default", { enumerable: true, value: v });
11}) : function(o, v) {
12 o["default"] = v;
13});
14var __importStar = (this && this.__importStar) || function (mod) {
15 if (mod && mod.__esModule) return mod;
16 var result = {};
17 if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
18 __setModuleDefault(result, mod);
19 return result;
20};
21Object.defineProperty(exports, "__esModule", { value: true });
22exports.RemotionContextProvider = exports.useRemotionContexts = void 0;
23const jsx_runtime_1 = require("react/jsx-runtime");
24// This is used for when other reconcilers are being used
25// such as in React Three Fiber. All the contexts need to be passed again
26// for them to be useable
27const react_1 = __importStar(require("react"));
28const CompositionManager_1 = require("./CompositionManager");
29const nonce_1 = require("./nonce");
30const sequencing_1 = require("./sequencing");
31const timeline_position_state_1 = require("./timeline-position-state");
32function useRemotionContexts() {
33 const compositionManagerCtx = react_1.default.useContext(CompositionManager_1.CompositionManager);
34 const timelineContext = react_1.default.useContext(timeline_position_state_1.TimelineContext);
35 const setTimelineContext = react_1.default.useContext(timeline_position_state_1.SetTimelineContext);
36 const sequenceContext = react_1.default.useContext(sequencing_1.SequenceContext);
37 const nonceContext = react_1.default.useContext(nonce_1.NonceContext);
38 return (0, react_1.useMemo)(() => ({
39 compositionManagerCtx,
40 timelineContext,
41 setTimelineContext,
42 sequenceContext,
43 nonceContext,
44 }), [
45 compositionManagerCtx,
46 nonceContext,
47 sequenceContext,
48 setTimelineContext,
49 timelineContext,
50 ]);
51}
52exports.useRemotionContexts = useRemotionContexts;
53const RemotionContextProvider = (props) => {
54 const { children, contexts } = props;
55 return ((0, jsx_runtime_1.jsx)(nonce_1.NonceContext.Provider, Object.assign({ value: contexts.nonceContext }, { children: (0, jsx_runtime_1.jsx)(CompositionManager_1.CompositionManager.Provider, Object.assign({ value: contexts.compositionManagerCtx }, { children: (0, jsx_runtime_1.jsx)(timeline_position_state_1.TimelineContext.Provider, Object.assign({ value: contexts.timelineContext }, { children: (0, jsx_runtime_1.jsx)(timeline_position_state_1.SetTimelineContext.Provider, Object.assign({ value: contexts.setTimelineContext }, { children: (0, jsx_runtime_1.jsx)(sequencing_1.SequenceContext.Provider, Object.assign({ value: contexts.sequenceContext }, { children: children }), void 0) }), void 0) }), void 0) }), void 0) }), void 0));
56};
57exports.RemotionContextProvider = RemotionContextProvider;
58//# sourceMappingURL=wrap-remotion-context.js.map
\No newline at end of file