@motionscript/react 0.0.0-stage → 0.1.0-alpha.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md ADDED
@@ -0,0 +1,5 @@
1
+ # @motionscript/react
2
+
3
+ ## 0.1.0-alpha.0
4
+
5
+ Initial release.
package/LICENSE ADDED
@@ -0,0 +1,201 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright [yyyy] [name of copyright owner]
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
package/README.md CHANGED
@@ -1,4 +1,105 @@
1
- # Temporary Holding Version
1
+ # @motionscript/react
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
4
- If no other versions are published within 30 days, this package and version will be deleted.
3
+ React bindings for [Motion Script](https://motionscript.dev): drop a scene into
4
+ your app and play it back on a `<canvas>` backed by Skia/CanvasKit.
5
+
6
+ ```tsx
7
+ import { useEffect, useState } from 'react';
8
+ import { createBrowserEngine } from '@motionscript/browser';
9
+ import { MotionStage, useMotionPlayer, usePlayhead, type Engine } from '@motionscript/react';
10
+ import doc from './scenes/my-scene.json';
11
+
12
+ export function App() {
13
+ const [engine, setEngine] = useState<Engine | null>(null);
14
+ useEffect(() => {
15
+ let cancelled = false;
16
+ createBrowserEngine().then(next => (cancelled ? next.dispose() : setEngine(next)));
17
+ return () => { cancelled = true; };
18
+ }, []);
19
+
20
+ const player = useMotionPlayer({ engine, document: doc, loop: true });
21
+ const frame = usePlayhead(player);
22
+
23
+ return (
24
+ <>
25
+ <MotionStage player={player} />
26
+ <button onClick={player.toggle}>{player.isPlaying ? 'Pause' : 'Play'}</button>
27
+ <input
28
+ type="range"
29
+ min={0}
30
+ max={player.totalFrames - 1}
31
+ value={frame}
32
+ onChange={e => player.seek(Number(e.target.value))}
33
+ />
34
+ </>
35
+ );
36
+ }
37
+ ```
38
+
39
+ ## What's in here
40
+
41
+ - **`useMotionPlayer`**: opens a session on an engine and gives you the
42
+ transport for it — `play`/`pause`/`seek`/`speed`/`mute`/`loop`, the duration,
43
+ build errors, and the editor surface (`getTreeState`, `pickNode`,
44
+ `setNodeOverride`, `getTrackSpans`, …). A new `document` is reconciled onto the
45
+ running session and the player keeps its place — the playhead stays put
46
+ (clamped if the timeline got shorter) and playback carries on. The session
47
+ patches only what the edit touched: a track whose clip is unchanged keeps its
48
+ tree, and a changed one is updated in place where it can be, so treat
49
+ documents as immutable and build the next one rather than mutating the last.
50
+ No DOM: it owns the timeline, not a canvas.
51
+ - **`MotionStage`**: a canvas bound to a player's session. It owns how the frame
52
+ is rasterized — `renderScale`, `surfaceSize`, `view`, `clipToFrame`,
53
+ `frameBackground` — and nothing about what is in it or when.
54
+ - **`usePlayhead`**: subscribes a component to the playhead. The frame moves at
55
+ clock rate, so keeping it out of the player's own state is what stops a host
56
+ re-rendering sixty-plus times a second — but only if you call it **as low in
57
+ the tree as it will go**. A component that subscribes re-renders on every
58
+ tick, and drags its children with it, so put it in the scrubber and the time
59
+ readout rather than in whatever renders the stage.
60
+
61
+ ### You own the engine
62
+
63
+ There is no provider. Build an engine yourself and pass it in — which is also
64
+ why nothing in this package imports a platform, so it works with
65
+ `@motionscript/browser`'s engine, a headless one, or a test double.
66
+
67
+ **Create it once and share it.** It holds CanvasKit and the exporter, so a
68
+ second engine is a second wasm module and a second GL stack. `engine` is
69
+ nullable precisely because building one is async: the player no-ops until it
70
+ arrives, which keeps the hook out of a conditional.
71
+
72
+ ### One player per timeline, one stage per player
73
+
74
+ Two `useMotionPlayer` calls give you two fully independent players — separate
75
+ playheads, clocks, audio devices and transports — sharing only the engine:
76
+
77
+ ```tsx
78
+ const before = useMotionPlayer({ engine, document: docA });
79
+ const after = useMotionPlayer({ engine, document: docB });
80
+ ```
81
+
82
+ A session drives **one** surface, so each player takes one `MotionStage`; a
83
+ second would take the surface from the first.
84
+
85
+ This package builds on [`@motionscript/core`](../core) (the scene graph and
86
+ animation runtime). A browser host will also want
87
+ [`@motionscript/browser`](../browser) for `createBrowserEngine`.
88
+
89
+ ## Usage
90
+
91
+ ```bash
92
+ npm install @motionscript/react
93
+ ```
94
+
95
+ See the [docs](https://motionscript.dev/docs) for the full feature set and API
96
+ reference.
97
+
98
+ ## Development
99
+
100
+ From the monorepo root:
101
+
102
+ ```bash
103
+ pnpm --filter @motionscript/react build
104
+ pnpm --filter @motionscript/react dev
105
+ ```
@@ -0,0 +1,2 @@
1
+ import{useCallback as z,useEffect as R,useMemo as ee,useRef as d,useState as u,useSyncExternalStore as te}from"react";import{isProjectDocument as re}from"@motionscript/core";import{jsx as G}from"react/jsx-runtime";function ne(){let n=0,r=new Set;return{subscribe(t){return r.add(t),()=>{r.delete(t)}},getSnapshot:()=>n,set(t){if(t!==n){n=t;for(let p of r)p()}}}}function fe(n){let{playhead:r}=n;return te(r.subscribe,r.getSnapshot,r.getSnapshot)}var oe={width:1920,height:1080},ce=60,se={discoveredTracks:0,totalTracks:0,complete:!1},_=[];function ae(n){return{discoveredTracks:n.tracks.filter(r=>r.discovered).length,totalTracks:n.tracks.length,complete:n.complete}}function ue(n,r){return n.discoveredTracks===r.discoveredTracks&&n.totalTracks===r.totalTracks&&n.complete===r.complete}function le(n,r){return n.length===r.length&&n.every((t,p)=>{let k=r[p];return t.trackId===k.trackId&&t.message===k.message&&t.nodeId===k.nodeId&&t.prop===k.prop&&t.stack===k.stack})}function J(n){let r=n.length===0?_:n.slice();return t=>le(t,r)?t:r}function me(n){let{engine:r,document:t,onFramePainted:p}=n,k=t&&re(t)?t:void 0,T=k?.viewport??n.viewport??r?.viewport??oe,v=k?.fps??n.fps??r?.fps??ce,[P,E]=u(T);(P.width!==T.width||P.height!==T.height)&&E(T);let f=t!==void 0,[y,S]=u(null),[l]=u(ne),[i,h]=u(!1),[x,N]=u(n.speed??1),[w,b]=u(n.muted??!1),[M,B]=u(n.loop??!1),[D,a]=u(!0),[m,C]=u(0),[O,A]=u(_),[K,Q]=u(se),$=Math.max(1,Math.round(m*v)),c=d(null),j=d(null),W=d(t),H=d(p),L=d(0),Y=d(M),F=d(v);R(()=>{H.current=p,Y.current=M,F.current=v});let[U,X]=u(t);t!==U&&(X(t),t===void 0&&(h(!1),C(0),O.length>0&&A(_)));let I=z(s=>{C(s.totalDuration),A(J(s.buildErrors));let e=ae(s.precomp);Q(o=>ue(o,e)?o:e)},[]),[V]=u(()=>s=>{let e=c.current;if(!e)return;let o=Math.max(0,Math.round(e.totalDuration*F.current)-1),g=Math.min(Math.max(0,Math.round(s)),o);l.set(g);let Z=++L.current;a(!0),e.seek(g).then(()=>{Z===L.current&&a(!1)})});R(()=>{if(!r||!t)return;let s=r.open({document:t,viewport:P,fps:v,onPrecompProgress:()=>I(s.controller)}),e=s.controller;return e.onRenderError=o=>A(J(o)),e.onFramePainted=o=>H.current?.(o),e.onTime(o=>{let g=Math.trunc(o*F.current);l.set(g),!(g<Math.round(e.totalDuration*F.current)-1)&&(Y.current?e.seekWhilePlaying(0):h(!1))}),c.current=e,j.current=s,W.current=t,S(s),I(e),a(!0),()=>{c.current=null,j.current=null,S(null),s.dispose()}},[r,f,P.width,P.height,v,I]),R(()=>{if(W.current===t)return;W.current=t;let s=j.current;if(!s||!t)return;let e=s.controller;s.replace(t),I(e);let o=Math.max(0,Math.round(e.totalDuration*F.current)-1);l.set(Math.min(l.getSnapshot(),o));let g=++L.current;a(!0),e.whenReplaced().then(()=>{g===L.current&&a(!1)})},[t,I,l]),R(()=>{let s=c.current;s&&(i?s.play(x):s.pause())},[y,i,x]),R(()=>{c.current?.setMuted(w)},[y,w]),R(()=>{V(l.getSnapshot())},[y,l,V]);let[q]=u(()=>{let s=e=>{h(!1),V(e)};return{playhead:l,play:()=>h(!0),pause:()=>h(!1),toggle:()=>h(e=>{let o=c.current;if(!e&&o){let g=Math.round(o.totalDuration*F.current)-1;l.getSnapshot()>=g&&o.seek(0)}return!e}),seek:s,step:e=>s(l.getSnapshot()+e),seekWhilePlaying:e=>c.current?.seekWhilePlaying(e),setSpeed:e=>N(e),setMuted:e=>b(e),setLoop:e=>B(e),screenshot:async()=>c.current?.screenshot()??void 0,repaint:()=>c.current?.repaint(),getTreeState:()=>c.current?.getTreeState()??null,getNodeProps:e=>c.current?.getNodeState(e)??null,getTrackSpans:()=>c.current?.spans??[],whenReplaced:async()=>{await c.current?.whenReplaced()},getNodeBox:e=>c.current?.getNodeBox(e)??null,getNodePropsAt:e=>c.current?.getNodePropsAt(e)??null,getNodeBoxes:()=>c.current?.getNodeBoxes()??[],projectNode3D:(e,o,g)=>c.current?.projectNode3D(e,o,g)??null,parentPlanePoint:(e,o)=>c.current?.parentPlanePoint(e,o)??null,getTextLayout:e=>c.current?.getTextLayout(e)??null,pickNode:(e,o)=>c.current?.pickNode(e,o)??null,setNodeOverride:(e,o)=>c.current?.setNodeOverride(e,o),clearNodeOverrides:e=>c.current?.clearNodeOverrides(e)}});return ee(()=>({...q,session:y,viewport:P,fps:v,isPlaying:i,speed:x,muted:w,loop:M,loading:D,duration:m,totalFrames:$,errors:O,precomp:K}),[q,y,P,v,i,x,w,M,D,m,$,O,K])}var ie=Object.freeze({zoom:1,x:0,y:0});function ge({player:n,renderScale:r=1,surfaceSize:t,view:p,clipToFrame:k,frameBackground:T,className:v,style:P}){let E=d(null),{session:f,viewport:y}=n,S=Math.max(1,Math.round((t?.width??y.width)*r)),l=Math.max(1,Math.round((t?.height??y.height)*r)),i=t&&p?p:ie,h=t&&p?y:null,x=t&&p?k??!0:!0,N=t&&p?T??"black":"black",w=d(i),b=d(h),M=d(x),B=d(N),D=d(null);return R(()=>{w.current=i,b.current=h,M.current=x,B.current=N,D.current=f?f.surface:null}),R(()=>{let a=E.current,m=D.current;!f||!a||!m||(m.pixelRatio=r,m.view=w.current,m.frame=b.current,m.clipToFrame=M.current,m.frameBackground=B.current,m.mount(a),f.controller.repaint())},[f,r,S,l]),R(()=>{let a=D.current;!f||!a||(a.view={zoom:i.zoom,x:i.x,y:i.y},a.frame=h,a.clipToFrame=x,a.frameBackground=N,f.controller.repaint())},[f,i.zoom,i.x,i.y,h?.width,h?.height,x,N]),G("div",{className:v,style:{position:"relative",width:"100%",height:"100%",...P},children:G("canvas",{ref:E,width:S,height:l,style:{display:f?"block":"none",...t?{position:"absolute",left:"50%",top:"50%",width:`${t.width}px`,height:`${t.height}px`,transform:"translate(-50%, -50%)"}:{width:"100%",height:"100%"}}})})}export{ge as MotionStage,me as useMotionPlayer,fe as usePlayhead};
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/ui/playhead.ts", "../../src/ui/use-motion-player.ts", "../../src/ui/stage.tsx"],
4
+ "sourcesContent": ["import { useSyncExternalStore } from \"react\";\n\n/**\n * The playhead, held outside React.\n *\n * A frame number written at clock rate through `useState` re-renders whoever\n * owns the player, and on a high-refresh display that is faster than the\n * project's own frame rate. Nothing in a render depends on it: the controller\n * paints straight onto the canvas and React is not involved. So the number\n * lives here, and only the components that actually display it subscribe.\n */\nexport interface PlayheadStore {\n subscribe(onChange: () => void): () => void;\n getSnapshot(): number;\n /** @internal — written by the player that owns this store. */\n set(frame: number): void;\n}\n\nexport function createPlayheadStore(): PlayheadStore {\n let frame = 0;\n const listeners = new Set<() => void>();\n return {\n subscribe(onChange) {\n listeners.add(onChange);\n return () => {\n listeners.delete(onChange);\n };\n },\n getSnapshot: () => frame,\n set(next) {\n if (next === frame) return;\n frame = next;\n for (const notify of listeners) notify();\n },\n };\n}\n\n/**\n * Subscribe *this* component to the playhead.\n *\n * Typed structurally rather than against `Player` so the store and the hook\n * that reads it don't import each other.\n */\nexport function usePlayhead(player: { playhead: PlayheadStore }): number {\n const { playhead } = player;\n return useSyncExternalStore(playhead.subscribe, playhead.getSnapshot, playhead.getSnapshot);\n}\n", "import { useCallback, useEffect, useMemo, useRef, useState } from \"react\";\n\nimport { isProjectDocument } from \"@motionscript/core\";\n\nimport type {\n BuildError,\n Engine,\n NodeBox,\n Node3DFrame,\n NodeOverride,\n NodeState,\n NodeTextLayout,\n PlaybackController,\n AssetTimelineResult,\n ProjectDocument,\n SceneDocument,\n Session,\n Size2D,\n TrackSpan,\n TreeState,\n Vector2,\n Vector3,\n} from \"@motionscript/core\";\n\nimport { createPlayheadStore, type PlayheadStore } from \"./playhead\";\n\n/** Used only when neither the document nor the engine says otherwise. */\nconst FALLBACK_VIEWPORT: Size2D = { width: 1920, height: 1080 };\nconst FALLBACK_FPS = 60;\n\n/**\n * How far background discovery has got. Only the tracks on frame 0 are\n * discovered before the player mounts; the rest stream in behind it (see\n * `AssetTimeline.runAsync`). The timeline's length never waits on it — every track\n * declares its own.\n */\nexport interface PrecompProgress {\n /** Tracks discovered so far. */\n discoveredTracks: number;\n /** Tracks in the project. */\n totalTracks: number;\n /** True once every track has been discovered. */\n complete: boolean;\n}\n\nconst INITIAL_PRECOMP: PrecompProgress = { discoveredTracks: 0, totalTracks: 0, complete: false };\nconst NO_ERRORS: BuildError[] = [];\n\nfunction precompProgressOf(result: AssetTimelineResult): PrecompProgress {\n return {\n discoveredTracks: result.tracks.filter(track => track.discovered).length,\n totalTracks: result.tracks.length,\n complete: result.complete,\n };\n}\n\nfunction samePrecomp(a: PrecompProgress, b: PrecompProgress): boolean {\n return a.discoveredTracks === b.discoveredTracks && a.totalTracks === b.totalTracks && a.complete === b.complete;\n}\n\nfunction sameErrors(a: readonly BuildError[], b: readonly BuildError[]): boolean {\n return a.length === b.length && a.every((error, i) => {\n const other = b[i];\n return error.trackId === other.trackId && error.message === other.message\n && error.nodeId === other.nodeId && error.prop === other.prop && error.stack === other.stack;\n });\n}\n\n/** A state updater that keeps the held errors when the report says the same thing. */\nfunction errorsFrom(reported: readonly BuildError[]): (held: BuildError[]) => BuildError[] {\n const next = reported.length === 0 ? NO_ERRORS : reported.slice();\n return held => (sameErrors(held, next) ? held : next);\n}\n\nexport interface MotionPlayerOptions {\n /**\n * The engine this player opens its session on.\n *\n * Nullable on purpose: building one is asynchronous\n * (`await createBrowserEngine(...)`), so a host holds it in state and it is\n * `null` for the first render or two. The player no-ops until it arrives,\n * which is what keeps the hook out of a conditional.\n *\n * **Create it once, and share it.** It holds CanvasKit and the exporter, so\n * a fresh one per render rebuilds the WebGL surface behind every player on\n * it. Identity-compared: a different engine is a different CanvasKit, and so\n * a full rebuild.\n */\n engine: Engine | null | undefined;\n /**\n * What to play. Nothing opens until there is one.\n *\n * A **project** document is the whole answer: it carries its own viewport,\n * fps, theme and tracks. A **scene** document (still or composition) is one\n * clip and carries none of that, so `viewport` and `fps` must come from here\n * or from the engine.\n *\n * Content-diffed, with identity as the fast path: a new document is reconciled\n * onto the running session, each track's built tree patched in place and\n * rebuilt only when its change cannot be patched. Treat documents as\n * immutable — an edit made in place to one the player already holds is not\n * seen.\n *\n * A new document keeps the player's place: the playhead stays where it was\n * (clamped when the timeline got shorter), and playback carries on if it was\n * running. Seek or pause yourself when a swap means \"start over\".\n */\n document?: ProjectDocument | SceneDocument;\n /** Overrides the engine's, for a source that carries none. */\n viewport?: Size2D;\n /** Overrides the engine's, for a source that carries none. */\n fps?: number;\n /** Initial playback rate. Change it later with {@link Player.setSpeed}. */\n speed?: number;\n /** Initial mute state. Change it later with {@link Player.setMuted}. */\n muted?: boolean;\n /** Initial loop state. Change it later with {@link Player.setLoop}. */\n loop?: boolean;\n /**\n * Called **synchronously**, on the same task as the draw, each time a frame\n * has been painted — whether by the clock, a seek, or a document swap.\n *\n * Not the playhead, which reports where the *clock* is. A seek is\n * asynchronous, so between the two there is a window in which the number has\n * moved and the canvas has not. Reach for this to keep an overlay — a\n * selection box, a caret, a handle — in step with the pixels, and keep the\n * listener cheap: it runs on the render loop, before the browser has had a\n * chance to composite.\n *\n * Read through a ref, so changing it costs nothing.\n */\n onFramePainted?: (frame: number) => void;\n}\n\n/**\n * One document, its transport, and the session driving it. No DOM.\n *\n * Hand it to a {@link MotionStage} to put pixels on screen. Two calls to\n * {@link useMotionPlayer} produce two of these with nothing shared but the\n * engine — separate playheads, clocks, audio devices and transports.\n */\nexport interface Player {\n /** The live session, or `null` before the engine and a document arrive. */\n readonly session: Session | null;\n /** The playhead, read with `usePlayhead(player)`. Stable for the hook's life. */\n readonly playhead: PlayheadStore;\n /** Resolved from the document, else the engine, else 1920×1080. */\n readonly viewport: Size2D;\n /** Resolved from the document, else the engine, else 60. */\n readonly fps: number;\n\n readonly isPlaying: boolean;\n readonly speed: number;\n readonly muted: boolean;\n readonly loop: boolean;\n /** True while a seek or a document swap is in flight. */\n readonly loading: boolean;\n /** The project's length, known from the document before any track is discovered. */\n readonly duration: number;\n /** {@link duration} in frames, floored at 1. */\n readonly totalFrames: number;\n readonly errors: BuildError[];\n readonly precomp: PrecompProgress;\n\n play(): void;\n pause(): void;\n toggle(): void;\n /** Seek while paused. Clamped to the timeline. */\n seek(frame: number): void;\n /** Seek relative to where the playhead is now. */\n step(delta: number): void;\n /** Seek without interrupting playback. */\n seekWhilePlaying(frame: number): void;\n setSpeed(speed: number): void;\n setMuted(muted: boolean): void;\n setLoop(loop: boolean): void;\n\n screenshot(): Promise<string | undefined>;\n /** Re-layout and repaint the current frame — no re-evaluation. */\n repaint(): void;\n\n getTreeState(): TreeState | null;\n getNodeProps(nodeId: string): NodeState | null;\n /** Where each track sits on the timeline, in document order. */\n getTrackSpans(): readonly TrackSpan[];\n /**\n * Resolves once the paint a document swap scheduled has landed. The swap\n * does not paint before its assets have loaded, so await this before\n * screenshotting or reading the tree.\n */\n whenReplaced(): Promise<void>;\n\n // ---- Direct manipulation ----------------------------------------------\n // Points are in viewport space — origin at the viewport centre, y-up, in\n // this player's `viewport` pixels.\n\n getNodeBox(path: string): NodeBox | null;\n getNodePropsAt(path: string): NodeState[\"properties\"] | null;\n getNodeBoxes(): NodeBox[];\n projectNode3D(\n path: string,\n parentPoints: readonly Vector3[],\n localPoints: readonly Vector3[],\n ): Node3DFrame | null;\n /**\n * Where `point` lands on the plane the node at `path` is positioned in, in\n * that plane's own y-up frame. Two answers differ by the `x`/`y` change that\n * moves the node between them — which a screen delta no longer is once the\n * node sits in a 2.5D space.\n */\n parentPlanePoint(path: string, point: Vector2): Vector2 | null;\n getTextLayout(path: string): NodeTextLayout | null;\n /** `tolerance` is grab-slop in scene units. */\n pickNode(point: Vector2, tolerance?: number): NodeBox | null;\n /** Layer transient props over a node without rebuilding its track. */\n setNodeOverride(path: string, props: NodeOverride): void;\n clearNodeOverrides(path?: string): void;\n}\n\n/**\n * Opens a session on `engine` and gives you the transport for it.\n *\n * ```tsx\n * const player = useMotionPlayer({ engine, document: doc, loop: true });\n * <MotionStage player={player} />\n * ```\n */\nexport function useMotionPlayer(options: MotionPlayerOptions): Player {\n const { engine, document, onFramePainted } = options;\n\n // Read straight off the document where it says so, else the caller's, else\n // the engine's. All plain JSON, so this resolves during render, before any\n // session exists — which is what lets a stage size its canvas on the first\n // pass rather than after a mount.\n const projectDoc = document && isProjectDocument(document) ? document : undefined;\n const resolvedViewport = projectDoc?.viewport ?? options.viewport ?? engine?.viewport ?? FALLBACK_VIEWPORT;\n const fps = projectDoc?.fps ?? options.fps ?? engine?.fps ?? FALLBACK_FPS;\n\n // Held by size: a host that rebuilds its document per edit rebuilds this\n // object with it, and a new one would hand every consumer a new `Player`.\n const [viewport, setViewport] = useState(resolvedViewport);\n if (viewport.width !== resolvedViewport.width || viewport.height !== resolvedViewport.height) {\n setViewport(resolvedViewport);\n }\n const hasDocument = document !== undefined;\n\n const [session, setSession] = useState<Session | null>(null);\n /** Created once; stable for the hook's life, so `usePlayhead` never resubscribes. */\n const [playhead] = useState(createPlayheadStore);\n\n const [isPlaying, setIsPlaying] = useState(false);\n const [speed, setSpeedState] = useState(options.speed ?? 1);\n const [muted, setMutedState] = useState(options.muted ?? false);\n const [loop, setLoopState] = useState(options.loop ?? false);\n const [loading, setLoading] = useState(true);\n const [duration, setDuration] = useState(0);\n const [errors, setErrors] = useState<BuildError[]>(NO_ERRORS);\n const [precomp, setPrecomp] = useState<PrecompProgress>(INITIAL_PRECOMP);\n\n const totalFrames = Math.max(1, Math.round(duration * fps));\n\n // Stable across renders so the action callbacks below never need rebuilding.\n const controllerRef = useRef<PlaybackController | null>(null);\n const sessionRef = useRef<Session | null>(null);\n const documentRef = useRef(document);\n const onFramePaintedRef = useRef(onFramePainted);\n /** Monotonic seek id; only the latest may clear the loading flag. */\n const seekTokenRef = useRef(0);\n /** Read by the tick handler, which is installed once and must see the latest. */\n const loopRef = useRef(loop);\n const fpsRef = useRef(fps);\n\n useEffect(() => {\n onFramePaintedRef.current = onFramePainted;\n loopRef.current = loop;\n fpsRef.current = fps;\n });\n\n // An edit keeps the transport and its errors — the reconcile effect below\n // re-reads both off the session, so an error the edit did not fix never\n // blinks out for a commit. Only losing the document stops it, during render\n // so nothing draws against a timeline that is gone.\n const [prevDocument, setPrevDocument] = useState(document);\n if (document !== prevDocument) {\n setPrevDocument(document);\n if (document === undefined) {\n setIsPlaying(false);\n setDuration(0);\n if (errors.length > 0) setErrors(NO_ERRORS);\n }\n }\n\n /**\n * Pull what the controller now knows: timeline length, errors, progress.\n * Runs on every swap, so it keeps whatever did not change — a fresh array or\n * object here is a new `Player` for every consumer on every edit.\n */\n const sync = useCallback((pc: PlaybackController) => {\n setDuration(pc.totalDuration);\n setErrors(errorsFrom(pc.buildErrors));\n const progress = precompProgressOf(pc.precomp);\n setPrecomp(held => (samePrecomp(held, progress) ? held : progress));\n }, []);\n\n /**\n * Move the playhead and repaint, with the loading flag the UI paces off.\n *\n * Created once so every caller — the transport, the reconcile effect and\n * the first paint after a session opens — shares one seek discipline.\n */\n const [seekTo] = useState(() => (frame: number) => {\n const pc = controllerRef.current;\n if (!pc) return;\n const last = Math.max(0, Math.round(pc.totalDuration * fpsRef.current) - 1);\n const clamped = Math.min(Math.max(0, Math.round(frame)), last);\n playhead.set(clamped);\n // Only the newest seek may report \"settled\". A superseded seek still\n // resolves — its generation guard bailed inside the controller — but it\n // never painted, so clearing the loading flag from it would tell the UI\n // a frame is ready while the newest is still in flight. Consumers pace\n // scrubbing off that edge.\n const token = ++seekTokenRef.current;\n setLoading(true);\n void pc.seek(clamped).then(() => {\n if (token === seekTokenRef.current) setLoading(false);\n });\n });\n\n useEffect(() => {\n if (!engine || !document) return;\n\n // `target` is omitted: the session opens unmounted, and a `MotionStage`\n // binds a canvas to it afterwards. That is what lets this hook own the\n // session without owning any DOM.\n const opened = engine.open({\n document,\n viewport,\n fps,\n // A track landing can surface a build error it threw.\n onPrecompProgress: () => sync(opened.controller),\n });\n\n const pc = opened.controller;\n pc.onRenderError = errs => setErrors(errorsFrom(errs));\n pc.onFramePainted = frame => onFramePaintedRef.current?.(frame);\n\n pc.onTime((t: number) => {\n const frame = Math.trunc(t * fpsRef.current);\n playhead.set(frame);\n\n // A document swap can change the timeline's length, so ask the\n // controller rather than trusting a duration captured when this\n // listener was installed.\n const last = Math.round(pc.totalDuration * fpsRef.current) - 1;\n if (frame < last) return;\n if (loopRef.current) pc.seekWhilePlaying(0);\n else setIsPlaying(false);\n });\n\n controllerRef.current = pc;\n sessionRef.current = opened;\n documentRef.current = document;\n setSession(opened);\n sync(pc);\n setLoading(true);\n\n return () => {\n controllerRef.current = null;\n sessionRef.current = null;\n setSession(null);\n // Disposes the controller and the render context together — the\n // session owns both.\n opened.dispose();\n };\n // `document` is deliberately absent — only whether there is one: a new\n // document is reconciled onto the live session by the effect below\n // rather than rebuilt into a new one. What remains genuinely does need a\n // rebuild — a different engine is a different CanvasKit, and a live\n // surface cannot change its size or rate (`Session.replace` refuses both).\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [engine, hasDocument, viewport.width, viewport.height, fps, sync]);\n\n // Reconcile a changed document onto the session already running. Skipped on\n // the pass that opens it, which was opened with this very document —\n // replacing it there would rediscover a timeline just discovered.\n useEffect(() => {\n if (documentRef.current === document) return;\n documentRef.current = document;\n const live = sessionRef.current;\n if (!live || !document) return;\n const pc = live.controller;\n live.replace(document);\n sync(pc);\n // No seek: `replace` already paints the current frame once its assets\n // load, clamped to the new length, and a running clock keeps ticking.\n const last = Math.max(0, Math.round(pc.totalDuration * fpsRef.current) - 1);\n playhead.set(Math.min(playhead.getSnapshot(), last));\n const token = ++seekTokenRef.current;\n setLoading(true);\n void pc.whenReplaced().then(() => {\n if (token === seekTokenRef.current) setLoading(false);\n });\n }, [document, sync, playhead]);\n\n useEffect(() => {\n const pc = controllerRef.current;\n if (!pc) return;\n if (isPlaying) pc.play(speed);\n else pc.pause();\n }, [session, isPlaying, speed]);\n\n useEffect(() => {\n controllerRef.current?.setMuted(muted);\n }, [session, muted]);\n\n // The one seek that isn't user-driven: park the new session on the frame\n // the playhead already holds, so a rebuild keeps its place.\n useEffect(() => {\n seekTo(playhead.getSnapshot());\n }, [session, playhead, seekTo]);\n\n // Built once and stable for the hook's life: every one reads the controller\n // through a ref, so a re-render never invalidates a handler a child holds —\n // which is what lets a transport subscribe its listeners a single time.\n const [actions] = useState<Omit<Player, keyof PlayerState>>(() => {\n // Scrubbing is a pause: a seek that left the clock running would be\n // overwritten by the next tick.\n const seek = (frame: number) => {\n setIsPlaying(false);\n seekTo(frame);\n };\n\n return {\n playhead,\n play: () => setIsPlaying(true),\n pause: () => setIsPlaying(false),\n toggle: () =>\n setIsPlaying(playing => {\n // Restarting from the end is what a play button means there.\n const pc = controllerRef.current;\n if (!playing && pc) {\n const last = Math.round(pc.totalDuration * fpsRef.current) - 1;\n if (playhead.getSnapshot() >= last) void pc.seek(0);\n }\n return !playing;\n }),\n seek,\n step: (delta: number) => seek(playhead.getSnapshot() + delta),\n seekWhilePlaying: (frame: number) => controllerRef.current?.seekWhilePlaying(frame),\n setSpeed: (next: number) => setSpeedState(next),\n setMuted: (next: boolean) => setMutedState(next),\n setLoop: (next: boolean) => setLoopState(next),\n\n screenshot: async () => controllerRef.current?.screenshot() ?? undefined,\n repaint: () => controllerRef.current?.repaint(),\n\n getTreeState: () => controllerRef.current?.getTreeState() ?? null,\n getNodeProps: (nodeId: string) => controllerRef.current?.getNodeState(nodeId) ?? null,\n getTrackSpans: () => controllerRef.current?.spans ?? [],\n whenReplaced: async () => {\n await controllerRef.current?.whenReplaced();\n },\n\n getNodeBox: (path: string) => controllerRef.current?.getNodeBox(path) ?? null,\n getNodePropsAt: (path: string) => controllerRef.current?.getNodePropsAt(path) ?? null,\n getNodeBoxes: () => controllerRef.current?.getNodeBoxes() ?? [],\n projectNode3D: (path, parentPoints, localPoints) =>\n controllerRef.current?.projectNode3D(path, parentPoints, localPoints) ?? null,\n parentPlanePoint: (path: string, point: Vector2) =>\n controllerRef.current?.parentPlanePoint(path, point) ?? null,\n getTextLayout: (path: string) => controllerRef.current?.getTextLayout(path) ?? null,\n pickNode: (point: Vector2, tolerance?: number) =>\n controllerRef.current?.pickNode(point, tolerance) ?? null,\n setNodeOverride: (path: string, props: NodeOverride) =>\n controllerRef.current?.setNodeOverride(path, props),\n clearNodeOverrides: (path?: string) => controllerRef.current?.clearNodeOverrides(path),\n };\n });\n\n return useMemo(\n () => ({\n ...actions,\n session,\n viewport,\n fps,\n isPlaying,\n speed,\n muted,\n loop,\n loading,\n duration,\n totalFrames,\n errors,\n precomp,\n }),\n [\n actions,\n session,\n viewport,\n fps,\n isPlaying,\n speed,\n muted,\n loop,\n loading,\n duration,\n totalFrames,\n errors,\n precomp,\n ],\n );\n}\n\n/** The fields the memo above supplies; everything else on `Player` is an action. */\ntype PlayerState = Pick<\n Player,\n | \"session\"\n | \"viewport\"\n | \"fps\"\n | \"isPlaying\"\n | \"speed\"\n | \"muted\"\n | \"loop\"\n | \"loading\"\n | \"duration\"\n | \"totalFrames\"\n | \"errors\"\n | \"precomp\"\n>;\n", "import { useEffect, useRef, type CSSProperties } from \"react\";\n\nimport type { EngineRenderContext, Size2D } from \"@motionscript/core\";\n\nimport type { Player } from \"./use-motion-player\";\n\n/**\n * The session's surface, with `mount` narrowed to a canvas.\n *\n * `core` compiles without the DOM lib, so `RenderSurface.mount` takes `unknown`\n * there. This is the narrowing that seam always assumed: it happens here, in\n * the one layer that genuinely has `HTMLCanvasElement`.\n */\ntype StageRenderContext = Omit<EngineRenderContext, \"mount\"> & {\n mount(canvas: HTMLCanvasElement): void;\n};\n\n/**\n * What every stage that doesn't ask for a view gets: the whole frame, 1:1.\n *\n * A shared frozen object rather than a literal, so the view effect's dependency\n * on its fields is stable across renders for the overwhelming majority of\n * stages, which never pass `view` at all.\n */\nconst IDENTITY_VIEW = Object.freeze({ zoom: 1, x: 0, y: 0 });\n\nexport interface MotionStageProps {\n /** The player whose session this stage draws. */\n player: Player;\n /**\n * Device pixels to rasterize per viewport unit. Defaults to `1`.\n *\n * **Not a zoom and not a crop.** The viewport stays the scene's logical\n * coordinate space; this only changes how many real pixels that space is\n * drawn into, and CSS scales the canvas back up to fill its box.\n *\n * The lever exists because a preview is usually displayed far smaller than\n * the project's output size: a 1920×1080 project in a 700px-wide panel\n * rasterizes roughly seven times the pixels anyone can see. `0.5` there is a\n * quarter of the fill, the shader work and the effect offscreens.\n *\n * Two things to know before animating it:\n *\n * - **Every change re-creates the Skia surface**, which drops the storage\n * adapter's texture-backed images (decoded video frames, 3D composites;\n * still images survive) and asks for a fresh GL context. Quantize to a few\n * steps and let it settle — never drive it from a resize observer.\n * - **Prefer scales that keep both dimensions whole.** `pixelRatio` is one\n * uniform number, so a scale that rounds differently on each axis shifts\n * the frame's centre by up to half a device pixel.\n *\n * A snapshot from `player.screenshot()` comes back at the surface's size, so\n * it is scaled too — render at `1` if you need full resolution out of it.\n */\n renderScale?: number;\n /**\n * The canvas's own size in CSS pixels, when it is **not** the frame.\n *\n * Omitted — the default — the canvas is the frame: sized `viewport ×\n * renderScale` and stretched over its box by CSS, which is what every\n * export, thumbnail and plain player wants.\n *\n * Supplied, together with {@link view}, the canvas becomes a *window* onto\n * the frame: it takes the size of the area it is shown in, `renderScale`\n * stops meaning \"fraction of the project's resolution\" and starts meaning\n * device pixels per CSS pixel, and only what is on screen is rasterized.\n * That is what lets an editor zoom in without going soft or paying for the\n * whole frame at the zoomed resolution.\n *\n * It re-creates the surface exactly as `renderScale` does, and wants the\n * same treatment: quantize it and let it settle.\n */\n surfaceSize?: Size2D;\n /**\n * A pan and zoom applied to the render itself. Requires {@link surfaceSize}.\n *\n * `zoom` multiplies scene units; `x`/`y` offset the frame's centre in CSS\n * pixels, positive `y` downwards — the same sign convention as a CSS\n * translate, so a preview can hand over the pan it was already computing.\n *\n * Changing it costs a repaint and nothing else: no surface, no textures, no\n * precomp. That is the point of it living here rather than in a CSS\n * transform, which cannot add resolution it was not rasterized with.\n */\n view?: { zoom: number; x: number; y: number };\n /**\n * Whether the frame's edge bounds what draws, rather than only where its own\n * backdrop goes. Requires {@link surfaceSize} and {@link view}. Defaults to\n * `true`.\n *\n * Off lets a node parked past the frame's edge rasterize into the rest of\n * the surface instead of being discarded — for a host that wants to show,\n * faded, what a node placed there while animating in or out.\n */\n clipToFrame?: boolean;\n /**\n * What the frame's backdrop is painted with. Defaults to `\"black\"`.\n *\n * `\"transparent\"` leaves the frame unpainted where nothing was drawn, so\n * whatever the host renders behind the canvas shows through — a\n * checkerboard, for an editor that has to distinguish \"no scene covers this\"\n * from \"a scene covers it in black\". Requires {@link surfaceSize} and\n * {@link view}, the same way {@link clipToFrame} does.\n */\n frameBackground?: \"black\" | \"transparent\";\n className?: string;\n style?: CSSProperties;\n}\n\n/**\n * A canvas bound to a {@link Player}'s session.\n *\n * The stage owns how the frame is rasterized — resolution, view, clipping — and\n * nothing about what is in it or when. A session drives **one** surface, so one\n * stage per player: a second would take the surface from the first.\n */\nexport function MotionStage({\n player,\n renderScale = 1,\n surfaceSize,\n view,\n clipToFrame,\n frameBackground,\n className,\n style,\n}: MotionStageProps) {\n const canvasRef = useRef<HTMLCanvasElement>(null);\n const { session, viewport } = player;\n\n /**\n * The canvas's backing store, in device pixels. `viewport × renderScale` in\n * the default case, where the canvas *is* the frame; with `surfaceSize` it\n * is the viewing area instead.\n *\n * Floored at 1 so a degenerate scale can't ask CanvasKit for a zero-sized\n * surface, which fails the surface creation outright.\n */\n const bufferWidth = Math.max(1, Math.round((surfaceSize?.width ?? viewport.width) * renderScale));\n const bufferHeight = Math.max(1, Math.round((surfaceSize?.height ?? viewport.height) * renderScale));\n\n /**\n * The view transform to draw with, and the frame to clip and anchor against.\n * Only meaningful together, so they resolve in one place: no `surfaceSize`\n * means the canvas is the frame, and both revert to identity.\n */\n const activeView = surfaceSize && view ? view : IDENTITY_VIEW;\n const activeFrame = surfaceSize && view ? viewport : null;\n const activeClipToFrame = surfaceSize && view ? (clipToFrame ?? true) : true;\n const activeFrameBackground = surfaceSize && view ? (frameBackground ?? \"black\") : \"black\";\n\n const viewRef = useRef(activeView);\n const frameRectRef = useRef(activeFrame);\n const clipToFrameRef = useRef(activeClipToFrame);\n const frameBackgroundRef = useRef(activeFrameBackground);\n /**\n * The live render context.\n *\n * Held here rather than reached through `player.session` at each use because\n * it is mutable external state — a Skia context whose knobs are written, not\n * a value derived from a prop — and writing through the prop is what the\n * immutability lint is there to catch everywhere it *isn't* one of these.\n */\n const ctxRef = useRef<StageRenderContext | null>(null);\n useEffect(() => {\n viewRef.current = activeView;\n frameRectRef.current = activeFrame;\n clipToFrameRef.current = activeClipToFrame;\n frameBackgroundRef.current = activeFrameBackground;\n ctxRef.current = session ? (session.surface as StageRenderContext) : null;\n });\n\n /**\n * Bind the surface, and rebuild it when the backing store changes.\n *\n * The order matters and is why this is an effect rather than a callback:\n * React has already written the canvas's new `width`/`height` by the time\n * effects run, and CanvasKit reads exactly those when it builds the surface\n * (`MakeOnScreenGLSurface(ctx, canvas.width, canvas.height)`). Mounting\n * before the resize would produce a surface of the previous size.\n *\n * `repaint()` afterwards because a new surface starts blank and the clock is\n * not necessarily running to fill it — a paused editor would otherwise show\n * black until something else moved.\n */\n useEffect(() => {\n const canvas = canvasRef.current;\n const ctx = ctxRef.current;\n if (!session || !canvas || !ctx) return;\n ctx.pixelRatio = renderScale;\n ctx.view = viewRef.current;\n ctx.frame = frameRectRef.current;\n ctx.clipToFrame = clipToFrameRef.current;\n ctx.frameBackground = frameBackgroundRef.current;\n // `mount` detaches the old surface first, which also drops the storage\n // adapter's texture-backed images — they belong to the surface that made\n // them. Video frames and 3D composites are re-uploaded on demand;\n // decoded still images are raster-backed and survive.\n ctx.mount(canvas);\n session.controller.repaint();\n }, [session, renderScale, bufferWidth, bufferHeight]);\n\n /**\n * Apply {@link MotionStageProps.view} — a repaint and nothing more.\n *\n * Depends on the fields rather than the object so a caller passing a fresh\n * `{zoom, x, y}` each render — which is every caller, since it comes from a\n * gesture — doesn't repaint on renders where the view didn't move.\n */\n useEffect(() => {\n const ctx = ctxRef.current;\n if (!session || !ctx) return;\n ctx.view = { zoom: activeView.zoom, x: activeView.x, y: activeView.y };\n ctx.frame = activeFrame;\n ctx.clipToFrame = activeClipToFrame;\n ctx.frameBackground = activeFrameBackground;\n session.controller.repaint();\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [\n session,\n activeView.zoom,\n activeView.x,\n activeView.y,\n activeFrame?.width,\n activeFrame?.height,\n activeClipToFrame,\n activeFrameBackground,\n ]);\n\n return (\n <div className={className} style={{ position: \"relative\", width: \"100%\", height: \"100%\", ...style }}>\n <canvas\n ref={canvasRef}\n // The backing store, in device pixels. CSS below stretches it\n // back over the whole box either way, so this is purely how much\n // gets rasterized.\n width={bufferWidth}\n height={bufferHeight}\n style={{\n display: session ? \"block\" : \"none\",\n ...(surfaceSize\n ? {\n // `surfaceSize` is the canvas's CSS size, so it is\n // honoured literally rather than stretched to the\n // box: it is quantized by its caller, which means\n // it is usually a little larger than the box and\n // rarely the same shape. Stretched, that\n // difference would land as a non-uniform scale — a\n // picture squashed on one axis, a far worse\n // artefact than the softness this arrangement\n // exists to remove.\n //\n // Centred, so the surface's midpoint is the box's\n // midpoint: `executePass` puts the scene origin at\n // the centre of the surface, so this is what makes\n // the frame land where the caller's layout says it\n // is. The spare pixels hang off all four edges and\n // are clipped by whatever is holding this.\n position: \"absolute\",\n left: \"50%\",\n top: \"50%\",\n width: `${surfaceSize.width}px`,\n height: `${surfaceSize.height}px`,\n transform: \"translate(-50%, -50%)\",\n }\n : { width: \"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AaQ,EAAaC,CAAY,CAAC,EASpDtC,EAAA,IAAgB,CACZ,IAAMiD,EAAMF,EAAO,QACf,CAAC1E,GAAW,CAAC4E,IACjBA,EAAI,KAAO,CAAE,KAAMV,EAAW,KAAM,EAAGA,EAAW,EAAG,EAAGA,EAAW,CAAE,EACrEU,EAAI,MAAQT,EACZS,EAAI,YAAcR,EAClBQ,EAAI,gBAAkBP,EACtBrE,EAAQ,WAAW,QAAQ,EAE/B,EAAG,CACCA,EACAkE,EAAW,KACXA,EAAW,EACXA,EAAW,EACXC,GAAa,MACbA,GAAa,OACbC,EACAC,CACJ,CAAC,EAGGQ,EAAC,MAAD,CAAgB,UAAAhB,EAAW,MAAO,CAAE,SAAU,WAAY,MAAO,OAAQ,OAAQ,OAAQ,GAAGC,CAAM,WAC9Fe,EAAC,SAAD,CACI,IAAKd,EAIL,MAAOC,EACP,OAAQC,EACR,MAAO,CACH,QAASjE,EAAU,QAAU,OAC7B,GAAIyD,EACE,CAiBI,SAAU,WACV,KAAM,MACN,IAAK,MACL,MAAO,GAAGA,EAAY,KAAA,KACtB,OAAQ,GAAGA,EAAY,MAAA,KACvB,UAAW,uBACf,EACA,CAAE,MAAO,OAAQ,OAAQ,MAAO,CAC1C,CACH,CAAA,CACA,CAAA,CAEb",
6
+ "names": ["createPlayheadStore", "frame", "listeners", "onChange", "next", "notify", "usePlayhead", "player", "playhead", "useSyncExternalStore", "FALLBACK_VIEWPORT", "FALLBACK_FPS", "INITIAL_PRECOMP", "NO_ERRORS", "precompProgressOf", "result", "track", "samePrecomp", "a", "b", "sameErrors", "error", "i", "other", "errorsFrom", "reported", "held", "useMotionPlayer", "options", "engine", "document", "onFramePainted", "projectDoc", "isProjectDocument", "resolvedViewport", "fps", "viewport", "setViewport", "useState", "hasDocument", "session", "setSession", "isPlaying", "setIsPlaying", "speed", "setSpeedState", "muted", "setMutedState", "loop", "setLoopState", "loading", "setLoading", "duration", "setDuration", "errors", "setErrors", "precomp", "setPrecomp", "totalFrames", "controllerRef", "useRef", "sessionRef", "documentRef", "onFramePaintedRef", "seekTokenRef", "loopRef", "fpsRef", "useEffect", "prevDocument", "setPrevDocument", "sync", "useCallback", "pc", "progress", "seekTo", "last", "clamped", "token", "opened", "errs", "t", "live", "actions", "seek", "playing", "delta", "nodeId", "path", "parentPoints", "localPoints", "point", "tolerance", "props", "useMemo", "IDENTITY_VIEW", "MotionStage", "renderScale", "surfaceSize", "view", "clipToFrame", "frameBackground", "className", "style", "canvasRef", "bufferWidth", "bufferHeight", "activeView", "activeFrame", "activeClipToFrame", "activeFrameBackground", "viewRef", "frameRectRef", "clipToFrameRef", "frameBackgroundRef", "ctxRef", "canvas", "ctx", "jsx"]
7
+ }
@@ -0,0 +1,13 @@
1
+ {
2
+ "name": "@motionscript/react",
3
+ "version": "0.1.0-alpha.0",
4
+ "exports": {
5
+ ".": "dist/browser/index.js"
6
+ },
7
+ "peers": [
8
+ "@motionscript/core",
9
+ "react",
10
+ "react-dom"
11
+ ],
12
+ "assets": {}
13
+ }
@@ -0,0 +1,8 @@
1
+ export { useMotionPlayer } from './ui/use-motion-player';
2
+ export type { MotionPlayerOptions, Player, PrecompProgress } from './ui/use-motion-player';
3
+ export { MotionStage } from './ui/stage';
4
+ export type { MotionStageProps } from './ui/stage';
5
+ export { usePlayhead } from './ui/playhead';
6
+ export type { PlayheadStore } from './ui/playhead';
7
+ export type { BuildError, Engine, Session } from '@motionscript/core';
8
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AASA,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AACzD,YAAY,EAAE,mBAAmB,EAAE,MAAM,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AAC3F,OAAO,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AACzC,YAAY,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AACnD,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC5C,YAAY,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AACnD,YAAY,EAAE,UAAU,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC"}