@motionscript/sdk 0.1.0-alpha.5 → 0.1.0-alpha.6
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 +22 -0
- package/README.md +48 -31
- package/dist/browser/manifest.json +2 -4
- package/package.json +4 -12
- package/dist/browser/jsx-dev-runtime.js +0 -2
- package/dist/browser/jsx-dev-runtime.js.map +0 -7
- package/dist/browser/jsx-runtime.js +0 -2
- package/dist/browser/jsx-runtime.js.map +0 -7
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,27 @@
|
|
|
1
1
|
# @motionscript/sdk
|
|
2
2
|
|
|
3
|
+
## 0.1.0-alpha.6
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- 163b708: Node types are components: one spec object handed to `component2d`, `component3d` or `componentAudio`, with no classes, decorators or JSX.
|
|
8
|
+
|
|
9
|
+
- **Writing a node type.** A component is one object literal: `key`, `state` (literals and `Types`), `defaults`, `commands`, `children`, `allowedChildren`/`allowedParents`, `provide`, `load`, and its tree's own fields (`measure`, `layout`, `render` for 2D). Behaviour comes from modules you spread in and call: `Paint`, `Flow`, `Shapes`, `Typeface`, `TextLayout`, `Aim`, `Material`, `View3D`. ADR 0007 and the custom-node docs cover it.
|
|
10
|
+
- **Building nodes in code** uses calls: `Rect({ fill: 'tomato', children: [Text({ text: 'Hi' })] })`, or `new Rect({...})` for the node itself.
|
|
11
|
+
- **Every built-in and every kit node is a component**, under the same document key. Code that tested `instanceof` a class now uses the component's `.is`, or `instanceof X.node`. Changed members:
|
|
12
|
+
- `SurfacePlot3d.valueAt` and `FunctionPlot.valueAt` are now the functions `surfaceValueAt` and `curveValue`.
|
|
13
|
+
- A system's `coordinates` is replaced by `planeMap`/`axesMap`/`systemMap`.
|
|
14
|
+
- `PieChart.isSelected` is replaced by `isSliceSelected`.
|
|
15
|
+
- `ItemGrid` is a kit module (`ItemGrid.isGrid`, `ItemGrid.define`), not a base class.
|
|
16
|
+
- **The sdk no longer exports the class surface:**
|
|
17
|
+
- the decorators: `node`, `property` and every `*Property`, `command`, `withdraw`, `driveCommand`;
|
|
18
|
+
- the authoring bases: `PaintNode`, `ShapeNode`, `TextBase`, `Mesh3DBase`, `Canvas3DBase` and the `*Base` geometry classes;
|
|
19
|
+
- `asCommand`, `compose`, `drive` and `declarePaints` from `@motionscript/sdk/component`;
|
|
20
|
+
- the `jsx-runtime` and `jsx-dev-runtime` subpaths.
|
|
21
|
+
- `Node`, `Node2D`, `Node3D` and `NodeAudio` remain as types.
|
|
22
|
+
- **Editor metadata leaves the engine.** The kits no longer declare `parentKey`, `forkable`, `layout`, `seed`, `within`, `beside` or `closed`; a host keeps those in its own configs. `describe()` now reports `holds`, the trees a type takes children from, and the placement checks use it, so a 2D viewport of your own that takes 3D children places them.
|
|
23
|
+
- A command called from code with no argument runs, and a refused child is told what its parent takes (`allowedChildren`) or where it goes (`allowedParents`).
|
|
24
|
+
|
|
3
25
|
## 0.1.0-alpha.5
|
|
4
26
|
|
|
5
27
|
### Patch Changes
|
package/README.md
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
# @motionscript/sdk
|
|
2
2
|
|
|
3
|
-
**Motion Script** is a TypeScript
|
|
3
|
+
**Motion Script** is a TypeScript framework for making videos with code.
|
|
4
4
|
Describe animations as documents of nodes and commands, then preview
|
|
5
5
|
them live in the browser and export straight to MP4 — no timeline UI, no
|
|
6
6
|
keyframe panel, just a codebase you can version, review, and generate.
|
|
7
7
|
|
|
8
8
|
`@motionscript/sdk` is the flagship package: the authoring surface of
|
|
9
|
-
[`@motionscript/core`](https://github.com/motionscript-dev/motionscript/tree/main/packages/core) (the document model, scene graph,
|
|
10
|
-
|
|
9
|
+
[`@motionscript/core`](https://github.com/motionscript-dev/motionscript/tree/main/packages/core) (the document model, scene graph, layout,
|
|
10
|
+
and the factories a node type is written with) behind a single import.
|
|
11
11
|
|
|
12
12
|
## Getting started
|
|
13
13
|
|
|
@@ -20,7 +20,8 @@ npm install @motionscript/sdk @motionscript/core @motionscript/browser @motionsc
|
|
|
20
20
|
|
|
21
21
|
`@motionscript/core` is a peer dependency rather than a bundled one: the
|
|
22
22
|
backend and every component kit share the one copy your project installs,
|
|
23
|
-
because two copies of the engine in one module graph break class identity
|
|
23
|
+
because two copies of the engine in one module graph break class identity
|
|
24
|
+
(a component generates a class, and identity is per copy).
|
|
24
25
|
|
|
25
26
|
## Quick example
|
|
26
27
|
|
|
@@ -51,8 +52,8 @@ session.playback!.play();
|
|
|
51
52
|
|
|
52
53
|
A scene is data: nodes, and commands placed at times, so any frame can be asked
|
|
53
54
|
for directly and a seek costs the same in either direction. Custom drawing, and
|
|
54
|
-
anything JSON cannot express, belongs in a
|
|
55
|
-
and named by key. Flow layout,
|
|
55
|
+
anything JSON cannot express, belongs in a component registered with the engine
|
|
56
|
+
and named by key (see [Writing a node type](#writing-a-node-type)). Flow layout,
|
|
56
57
|
fills, gradients, filters, SkSL shader effects, paths, text, audio and 3D are
|
|
57
58
|
all supported. See the
|
|
58
59
|
[docs](https://motionscript.dev/docs) for the full feature set.
|
|
@@ -66,9 +67,15 @@ all supported. See the
|
|
|
66
67
|
`Polygram`, `MaskGroup`, `BooleanGroup`), text (`Text`,
|
|
67
68
|
`RichText`, `NumberNode`), structure (`Canvas2D`, `Canvas3D`, `Camera`), and
|
|
68
69
|
media (`Video`; images are a fill, `Fills.image`). Layout is the `flow` prop,
|
|
69
|
-
through `flowOps`.
|
|
70
|
-
|
|
71
|
-
|
|
70
|
+
through `flowOps`. Each is a component: call it to build one
|
|
71
|
+
(`Rect({ fill: 'red', children: [...] })`).
|
|
72
|
+
- **Components**: the factories `component2d`, `component3d` and
|
|
73
|
+
`componentAudio`, the `Types` a component's state is declared with,
|
|
74
|
+
`commandsFor`, `provides`, and the modules a component spreads in and calls:
|
|
75
|
+
`Paint`, `Flow`, `Shapes`, `Aim`, `Typeface`, `TextLayout`, `Material`,
|
|
76
|
+
`View3D`.
|
|
77
|
+
- **Animation**: commands (`to`, `set`, `variableTo`/`variableSet` and a node
|
|
78
|
+
type's own), each placed at a time, easing (`linear`, `easeIn`,
|
|
72
79
|
`easeOut`, `easeInOut`), and interpolation (`lerpNumber`).
|
|
73
80
|
- **Styling & effects**: `Fills`, `Effects`, `Adjustments`, `VideoAdjustments`,
|
|
74
81
|
`AudioFilters`, plus the `Stroke`/`Shadow`/`Corners` attribute types.
|
|
@@ -76,17 +83,11 @@ all supported. See the
|
|
|
76
83
|
next major.
|
|
77
84
|
- **Audio**: the `SoundNode` and `AudioBus` nodes.
|
|
78
85
|
- **Utilities**: `createRef`, `clamp`, `generateList`, `createContext`,
|
|
79
|
-
`Random
|
|
80
|
-
- **JSX runtime**: `@motionscript/sdk/jsx-runtime` and
|
|
81
|
-
`@motionscript/sdk/jsx-dev-runtime`, so a composite node can build its children
|
|
82
|
-
as TSX (see [JSX](#jsx)).
|
|
86
|
+
`Random`.
|
|
83
87
|
- **Component machinery**: `@motionscript/sdk/component`, what a component
|
|
84
|
-
package needs beyond the barrel:
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
orbit-camera lerps. It is a subpath because a scene author never needs it and
|
|
88
|
-
`hold` is a name on both sides: the barrel's is an audio curve, this one is a
|
|
89
|
-
seekable pause. A file that needs both aliases one.
|
|
88
|
+
package needs beyond the barrel: number formatting, text defaults, the named
|
|
89
|
+
shape outlines and the orbit-camera lerps. It is a subpath because a scene
|
|
90
|
+
author never needs it.
|
|
90
91
|
|
|
91
92
|
Component kits such as [`@motionscript/code`](https://github.com/motionscript-dev/motionscript/tree/main/packages/components/code) and
|
|
92
93
|
[`@motionscript/math`](https://github.com/motionscript-dev/motionscript/tree/main/packages/components/math) are not bundled here. They are
|
|
@@ -118,23 +119,39 @@ until core has been built. `src/tests/sdk-parity.test.ts` in core compares this
|
|
|
118
119
|
barrel's value names with core's `sdk/index.ts`; it fails when core's `dist/` is
|
|
119
120
|
stale or absent.
|
|
120
121
|
|
|
121
|
-
##
|
|
122
|
+
## Writing a node type
|
|
122
123
|
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
124
|
+
A node type is one object handed to a factory. `key` is its document key;
|
|
125
|
+
`state` its entries, plain values or `Types` builders, plus whatever modules it
|
|
126
|
+
spreads in; `commands` what it does on the timeline; `render` what it draws:
|
|
127
|
+
|
|
128
|
+
```ts
|
|
129
|
+
import { component2d, Graphics2D, Paint, Types } from '@motionscript/sdk';
|
|
130
|
+
import { createBrowserEngine } from '@motionscript/browser';
|
|
131
|
+
|
|
132
|
+
export const Gauge = component2d({
|
|
133
|
+
key: 'gauge',
|
|
134
|
+
state: { ...Paint.state, value: Types.number(0, { min: 0, max: 1 }) },
|
|
135
|
+
commands: { ...Paint.commands, fillUp: { args: ['value'] } },
|
|
136
|
+
render: (ctx, state) => Paint.draw(ctx, state, new Graphics2D().ellipse({
|
|
137
|
+
width: ctx.size.width, height: ctx.size.height, ratio: 0.75, startAngle: -90, sweep: 360 * state.value,
|
|
138
|
+
})),
|
|
139
|
+
});
|
|
140
|
+
|
|
141
|
+
const engine = await createBrowserEngine({ wasmUrl: '/canvaskit.wasm', nodes: [Gauge] });
|
|
142
|
+
```
|
|
143
|
+
|
|
144
|
+
The factory generates the node class, declares its key and writes its entries
|
|
145
|
+
and commands where the registry reads them, so a document can name `gauge`
|
|
146
|
+
once it is handed to an engine. Calling `Gauge({ value: 0.4 })` builds one in
|
|
147
|
+
code, typed by its entries. No decorators and no JSX are needed: a component
|
|
148
|
+
compiles with plain TypeScript. The guide is the
|
|
149
|
+
[custom node docs](https://motionscript.dev/docs/custom-node/introduction).
|
|
132
150
|
|
|
133
151
|
## Loading from a CDN
|
|
134
152
|
|
|
135
153
|
`dist/browser/` holds one ES module per export. Core is a peer, so the modules
|
|
136
|
-
leave `@motionscript/core/sdk
|
|
137
|
-
`/jsx/jsx-dev-runtime` as imports, and `dist/browser/manifest.json` maps each
|
|
154
|
+
leave `@motionscript/core/sdk` and `/component` as imports, and `dist/browser/manifest.json` maps each
|
|
138
155
|
export to its file and lists core under `peers`. An import map names
|
|
139
156
|
`@motionscript/sdk` (and its subpaths) and `@motionscript/core` (and its
|
|
140
157
|
subpaths) once, and every kit loaded beside them shares both.
|
|
@@ -1,11 +1,9 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@motionscript/sdk",
|
|
3
|
-
"version": "0.1.0-alpha.
|
|
3
|
+
"version": "0.1.0-alpha.6",
|
|
4
4
|
"exports": {
|
|
5
5
|
".": "dist/browser/index.js",
|
|
6
|
-
"./component": "dist/browser/component.js"
|
|
7
|
-
"./jsx-runtime": "dist/browser/jsx-runtime.js",
|
|
8
|
-
"./jsx-dev-runtime": "dist/browser/jsx-dev-runtime.js"
|
|
6
|
+
"./component": "dist/browser/component.js"
|
|
9
7
|
},
|
|
10
8
|
"peers": [
|
|
11
9
|
"@motionscript/core"
|
package/package.json
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@motionscript/sdk",
|
|
3
|
-
"version": "0.1.0-alpha.
|
|
3
|
+
"version": "0.1.0-alpha.6",
|
|
4
4
|
"type": "module",
|
|
5
|
-
"description": "The Motion Script authoring surface behind one import: document types,
|
|
5
|
+
"description": "The Motion Script authoring surface behind one import: document types, components and their modules, commands, styling, and the machinery component kits build on.",
|
|
6
6
|
"repository": {
|
|
7
7
|
"type": "git",
|
|
8
8
|
"url": "git+https://github.com/motionscript-dev/motionscript.git",
|
|
@@ -38,18 +38,10 @@
|
|
|
38
38
|
"./component": {
|
|
39
39
|
"types": "./dist/component.d.ts",
|
|
40
40
|
"default": "./dist/component.js"
|
|
41
|
-
},
|
|
42
|
-
"./jsx-runtime": {
|
|
43
|
-
"types": "./dist/jsx-runtime.d.ts",
|
|
44
|
-
"default": "./dist/jsx-runtime.js"
|
|
45
|
-
},
|
|
46
|
-
"./jsx-dev-runtime": {
|
|
47
|
-
"types": "./dist/jsx-dev-runtime.d.ts",
|
|
48
|
-
"default": "./dist/jsx-dev-runtime.js"
|
|
49
41
|
}
|
|
50
42
|
},
|
|
51
43
|
"peerDependencies": {
|
|
52
|
-
"@motionscript/core": "^0.1.0-alpha.
|
|
44
|
+
"@motionscript/core": "^0.1.0-alpha.6"
|
|
53
45
|
},
|
|
54
46
|
"devDependencies": {
|
|
55
47
|
"@types/node": "^25.6.2",
|
|
@@ -61,7 +53,7 @@
|
|
|
61
53
|
"typescript": "^6.0.3",
|
|
62
54
|
"typescript-eslint": "^8.48.0",
|
|
63
55
|
"vitest": "^4.1.5",
|
|
64
|
-
"@motionscript/core": "0.1.0-alpha.
|
|
56
|
+
"@motionscript/core": "0.1.0-alpha.6"
|
|
65
57
|
},
|
|
66
58
|
"scripts": {
|
|
67
59
|
"build": "eslint . && tsc -p tsconfig.build.json && tsc-alias -p tsconfig.build.json && node ../../scripts/build-browser.mjs",
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../src/jsx-dev-runtime.ts"],
|
|
4
|
-
"sourcesContent": ["export { jsxDEV, Fragment } from '@motionscript/core/jsx/jsx-dev-runtime';\r\nexport type { JSX } from '@motionscript/core/jsx/jsx-runtime';\r\n"],
|
|
5
|
-
"mappings": "AAAA,OAAS,UAAAA,EAAQ,YAAAC,MAAgB",
|
|
6
|
-
"names": ["jsxDEV", "Fragment"]
|
|
7
|
-
}
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../src/jsx-runtime.ts"],
|
|
4
|
-
"sourcesContent": ["export { jsx, jsxs, Fragment } from '@motionscript/core/jsx/jsx-runtime';\r\nexport type { JSX } from '@motionscript/core/jsx/jsx-runtime';\r\n"],
|
|
5
|
-
"mappings": "AAAA,OAAS,OAAAA,EAAK,QAAAC,EAAM,YAAAC,MAAgB",
|
|
6
|
-
"names": ["jsx", "jsxs", "Fragment"]
|
|
7
|
-
}
|