@motionscript/react 0.1.0-alpha.3 → 0.1.0-alpha.5
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 +84 -0
- package/LICENSE +201 -201
- package/NOTICE +48 -0
- package/README.md +145 -105
- package/dist/browser/index.js +1 -1
- package/dist/browser/index.js.map +4 -4
- package/dist/browser/manifest.json +3 -2
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/motionscript-react.js +123 -21
- package/dist/motionscript-react.js.map +1 -1
- package/dist/ui/stage.d.ts.map +1 -1
- package/dist/ui/use-engine.d.ts +39 -0
- package/dist/ui/use-engine.d.ts.map +1 -0
- package/dist/ui/use-motion-player.d.ts +27 -5
- package/dist/ui/use-motion-player.d.ts.map +1 -1
- package/package.json +14 -8
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { BuildError, Engine, NodeBox, Node3DFrame, NodeOverride, NodeState, NodeTextLayout, ProjectDocument,
|
|
1
|
+
import { BuildError, Engine, NodeBox, NodeHandle, Node3DFrame, NodeOverride, NodeState, NodeTextLayout, ProjectDocument, ReparentPlacement, VisualDocument, Session, Size2D, TrackSpan, TreeState, Vector2, Vector3 } from '@motionscript/core';
|
|
2
2
|
import { PlayheadStore } from './playhead';
|
|
3
3
|
/**
|
|
4
4
|
* How far background discovery has got. Only the tracks on frame 0 are
|
|
@@ -14,14 +14,16 @@ export interface PrecompProgress {
|
|
|
14
14
|
/** True once every track has been discovered. */
|
|
15
15
|
complete: boolean;
|
|
16
16
|
}
|
|
17
|
+
/** @internal Whether `session` was disposed by a player. Not exported from the package. */
|
|
18
|
+
export declare function isSessionDisposed(session: Session): boolean;
|
|
17
19
|
export interface MotionPlayerOptions {
|
|
18
20
|
/**
|
|
19
21
|
* The engine this player opens its session on.
|
|
20
22
|
*
|
|
21
23
|
* Nullable on purpose: building one is asynchronous
|
|
22
|
-
* (`await createBrowserEngine(...)`), so a host
|
|
23
|
-
* `null` for the first render or two. The player no-ops until it
|
|
24
|
-
* which is what keeps the hook out of a conditional.
|
|
24
|
+
* (`await createBrowserEngine(...)`), so a host gets it from {@link useEngine}
|
|
25
|
+
* and it is `null` for the first render or two. The player no-ops until it
|
|
26
|
+
* arrives, which is what keeps the hook out of a conditional.
|
|
25
27
|
*
|
|
26
28
|
* **Create it once, and share it.** It holds CanvasKit and the exporter, so
|
|
27
29
|
* a fresh one per render rebuilds the WebGL surface behind every player on
|
|
@@ -47,7 +49,7 @@ export interface MotionPlayerOptions {
|
|
|
47
49
|
* (clamped when the timeline got shorter), and playback carries on if it was
|
|
48
50
|
* running. Seek or pause yourself when a swap means "start over".
|
|
49
51
|
*/
|
|
50
|
-
document?: ProjectDocument |
|
|
52
|
+
document?: ProjectDocument | VisualDocument;
|
|
51
53
|
/** Overrides the engine's, for a source that carries none. */
|
|
52
54
|
viewport?: Size2D;
|
|
53
55
|
/** Overrides the engine's, for a source that carries none. */
|
|
@@ -118,6 +120,8 @@ export interface Player {
|
|
|
118
120
|
repaint(): void;
|
|
119
121
|
getTreeState(): TreeState | null;
|
|
120
122
|
getNodeProps(nodeId: string): NodeState | null;
|
|
123
|
+
/** The node's props before any command has acted on it: the same at every frame, and answered while it is off screen. */
|
|
124
|
+
getNodeInitialProps(nodeId: string): NodeState["properties"] | null;
|
|
121
125
|
/** Where each track sits on the timeline, in document order. */
|
|
122
126
|
getTrackSpans(): readonly TrackSpan[];
|
|
123
127
|
/**
|
|
@@ -137,6 +141,24 @@ export interface Player {
|
|
|
137
141
|
* node sits in a 2.5D space.
|
|
138
142
|
*/
|
|
139
143
|
parentPlanePoint(path: string, point: Vector2): Vector2 | null;
|
|
144
|
+
/**
|
|
145
|
+
* Where `point` lands in the coordinates the node at `path` positions its
|
|
146
|
+
* children in (a graph's units), or `null` when those are pixels: the
|
|
147
|
+
* `x`/`y` to give a node dropped or pasted there.
|
|
148
|
+
*/
|
|
149
|
+
childPlanePoint(path: string, point: Vector2): Vector2 | null;
|
|
150
|
+
/**
|
|
151
|
+
* What keeps the node at `path` looking as it does once it moves under the
|
|
152
|
+
* node at `parentPath`: `offsets` (`x`/`y` values it takes under its parent
|
|
153
|
+
* now) as the ones that put it at the same place there, and the turn to add
|
|
154
|
+
* and the factor to scale by. `null` when that parent arranges its children
|
|
155
|
+
* itself.
|
|
156
|
+
*/
|
|
157
|
+
reparentPlacement(path: string, parentPath: string, offsets: readonly Vector2[]): ReparentPlacement | null;
|
|
158
|
+
/** The points an editor may drag on the node at `path` (an arrow's ends), in viewport space. */
|
|
159
|
+
nodeHandles(path: string): NodeHandle[] | null;
|
|
160
|
+
/** The value of `prop` that puts its handle under `point`, or `null`. */
|
|
161
|
+
handleValue(path: string, prop: string, point: Vector2): Vector2 | null;
|
|
140
162
|
getTextLayout(path: string): NodeTextLayout | null;
|
|
141
163
|
/** `tolerance` is grab-slop in scene units. */
|
|
142
164
|
pickNode(point: Vector2, tolerance?: number): NodeBox | null;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-motion-player.d.ts","sourceRoot":"","sources":["../../src/ui/use-motion-player.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EACR,UAAU,EACV,MAAM,EACN,OAAO,EACP,WAAW,EACX,YAAY,EACZ,SAAS,EACT,cAAc,EAGd,eAAe,EACf,
|
|
1
|
+
{"version":3,"file":"use-motion-player.d.ts","sourceRoot":"","sources":["../../src/ui/use-motion-player.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EACR,UAAU,EACV,MAAM,EACN,OAAO,EACP,UAAU,EACV,WAAW,EACX,YAAY,EACZ,SAAS,EACT,cAAc,EAGd,eAAe,EACf,iBAAiB,EACjB,cAAc,EACd,OAAO,EACP,MAAM,EACN,SAAS,EACT,SAAS,EACT,OAAO,EACP,OAAO,EACV,MAAM,oBAAoB,CAAC;AAE5B,OAAO,EAAuB,KAAK,aAAa,EAAE,MAAM,YAAY,CAAC;AAErE;;;;;GAKG;AACH,MAAM,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gB,eAAe,CAAC,OAAO,EAAE,mBAAmB,GAAG,MAAM,CAiVpE"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@motionscript/react",
|
|
3
|
-
"version": "0.1.0-alpha.
|
|
3
|
+
"version": "0.1.0-alpha.5",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "React bindings for Motion Script.",
|
|
6
6
|
"repository": {
|
|
@@ -18,6 +18,7 @@
|
|
|
18
18
|
"access": "public"
|
|
19
19
|
},
|
|
20
20
|
"files": [
|
|
21
|
+
"NOTICE",
|
|
21
22
|
"dist",
|
|
22
23
|
"CHANGELOG.md",
|
|
23
24
|
"!dist/**/*.tsbuildinfo"
|
|
@@ -31,9 +32,9 @@
|
|
|
31
32
|
}
|
|
32
33
|
},
|
|
33
34
|
"peerDependencies": {
|
|
34
|
-
"react": "^
|
|
35
|
-
"react-dom": "^
|
|
36
|
-
"@motionscript/core": "^0.1.0-alpha.
|
|
35
|
+
"react": "^18.2.0 || ^19.0.0",
|
|
36
|
+
"react-dom": "^18.2.0 || ^19.0.0",
|
|
37
|
+
"@motionscript/core": "^0.1.0-alpha.5"
|
|
37
38
|
},
|
|
38
39
|
"devDependencies": {
|
|
39
40
|
"@eslint/js": "^9.39.1",
|
|
@@ -41,6 +42,8 @@
|
|
|
41
42
|
"@types/react": "^19.2.3",
|
|
42
43
|
"@types/react-dom": "^19.2.3",
|
|
43
44
|
"@vitejs/plugin-react": "^6.0.1",
|
|
45
|
+
"@vitest/browser": "4.1.7",
|
|
46
|
+
"@vitest/browser-playwright": "^4.1.7",
|
|
44
47
|
"eslint": "^9.39.4",
|
|
45
48
|
"eslint-plugin-react-hooks": "^7.0.1",
|
|
46
49
|
"eslint-plugin-react-refresh": "^0.4.24",
|
|
@@ -48,12 +51,14 @@
|
|
|
48
51
|
"globals": "^16.5.0",
|
|
49
52
|
"react-dom": "^19.2.3",
|
|
50
53
|
"typescript": "^6.0.3",
|
|
54
|
+
"playwright": "^1.60.0",
|
|
51
55
|
"typescript-eslint": "^8.48.0",
|
|
52
56
|
"vite": "^8.0.11",
|
|
53
57
|
"vite-plugin-dts": "5.0.0",
|
|
54
|
-
"
|
|
55
|
-
"@motionscript/
|
|
56
|
-
"@motionscript/
|
|
58
|
+
"vitest": "^4.1.5",
|
|
59
|
+
"@motionscript/core": "0.1.0-alpha.5",
|
|
60
|
+
"@motionscript/browser": "0.1.0-alpha.5",
|
|
61
|
+
"@motionscript/canvaskit": "0.1.0-alpha.5"
|
|
57
62
|
},
|
|
58
63
|
"scripts": {
|
|
59
64
|
"dev": "vite",
|
|
@@ -61,6 +66,7 @@
|
|
|
61
66
|
"lint": "eslint .",
|
|
62
67
|
"typecheck": "tsc -b --noEmit",
|
|
63
68
|
"clean": "rimraf --glob dist .turbo *.tsbuildinfo",
|
|
64
|
-
"preview": "vite preview"
|
|
69
|
+
"preview": "vite preview",
|
|
70
|
+
"test": "vitest run"
|
|
65
71
|
}
|
|
66
72
|
}
|