@motionscript/sdk 0.1.0-alpha.5 → 0.1.0-alpha.7

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 CHANGED
@@ -1,5 +1,45 @@
1
1
  # @motionscript/sdk
2
2
 
3
+ ## 0.1.0-alpha.7
4
+
5
+ ### Minor Changes
6
+
7
+ - 737f7d0: What was left of the class authoring system is gone. Each piece existed to write or extend a node class, and a node type is a component now; no built-in, kit or host used them.
8
+
9
+ Removed from `@motionscript/core`:
10
+
11
+ - the registration functions `property`, `node`, `command` and `withdraw`, and the thirteen typed property helpers (`fillProperty`, `strokeProperty`, `shadowProperty`, `effectsProperty`, `colorProperty`, `cornerRadiusProperty`, `cornerStyleProperty`, `pathProperty`, `insetsProperty`, `alignmentProperty`, `vector2Property`, `sizeProperty`, `textProperty`) with their `AttributePropOptions` type. A component declares its entries with `Types`. `getPropertyMeta`, `getNodeDescriptor`, `getCommandMeta` and the metadata types stay;
12
+ - `TextSelection`, `TextSelectionHost`, `TextSelectionProps`, `TextRange`, `SelectionOverrides` and `normalizeRanges`: the component `Text` has no selection API, so nothing could make one. Style a range with `runs`;
13
+ - `AudioScope` and the `declareAudio` hook on `Node`: sound plays from commands (`timeline.sound`). `busPathOf` and `busPathTo` take a function answering a node's span instead of an `AudioScope`;
14
+ - the `Node.tick` hook and the `Node2D` hooks `beforeRender`, `afterRender`, `renderStroke`, `clipPathSelf`, `resolveSizeInput` and `constraints`, which only a subclass could reach;
15
+ - `NodeTypeRecord.withdrawn` and `CommandMeta.withdrawn`. `PropertyMeta.withdrawn` stays, deprecated: nothing sets it.
16
+
17
+ Removed from `@motionscript/core/component`, and so from `@motionscript/sdk/component` and `@motionscript/charts/kit`, which re-export it: the seekable composition `at`, `hold`, `sequence` and `together`, with the `Seekable` and `Placed` types. A component command returns timeline pieces.
18
+
19
+ Removed from `@motionscript/sdk`: `TextSelection`, `TextSelectionProps`, `TextRange`, `SelectionOverrides`, `AudioScope` and `AudioClip`.
20
+
21
+ ## 0.1.0-alpha.6
22
+
23
+ ### Minor Changes
24
+
25
+ - 163b708: Node types are components: one spec object handed to `component2d`, `component3d` or `componentAudio`, with no classes, decorators or JSX.
26
+
27
+ - **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.
28
+ - **Building nodes in code** uses calls: `Rect({ fill: 'tomato', children: [Text({ text: 'Hi' })] })`, or `new Rect({...})` for the node itself.
29
+ - **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:
30
+ - `SurfacePlot3d.valueAt` and `FunctionPlot.valueAt` are now the functions `surfaceValueAt` and `curveValue`.
31
+ - A system's `coordinates` is replaced by `planeMap`/`axesMap`/`systemMap`.
32
+ - `PieChart.isSelected` is replaced by `isSliceSelected`.
33
+ - `ItemGrid` is a kit module (`ItemGrid.isGrid`, `ItemGrid.define`), not a base class.
34
+ - **The sdk no longer exports the class surface:**
35
+ - the decorators: `node`, `property` and every `*Property`, `command`, `withdraw`, `driveCommand`;
36
+ - the authoring bases: `PaintNode`, `ShapeNode`, `TextBase`, `Mesh3DBase`, `Canvas3DBase` and the `*Base` geometry classes;
37
+ - `asCommand`, `compose`, `drive` and `declarePaints` from `@motionscript/sdk/component`;
38
+ - the `jsx-runtime` and `jsx-dev-runtime` subpaths.
39
+ - `Node`, `Node2D`, `Node3D` and `NodeAudio` remain as types.
40
+ - **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.
41
+ - 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`).
42
+
3
43
  ## 0.1.0-alpha.5
4
44
 
5
45
  ### Patch Changes
package/README.md CHANGED
@@ -1,13 +1,13 @@
1
1
  # @motionscript/sdk
2
2
 
3
- **Motion Script** is a TypeScript/JSX framework for making videos with code.
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, runtime,
10
- layout, and JSX runtime) behind a single import.
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 node class registered with the engine
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
- - **Animation**: commands (`to`, `set`, `variableTo`/`variableSet` and a node's
71
- own `@command` methods), each placed at a time, easing (`linear`, `easeIn`,
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`, the `@property` decorator.
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: seekable entrances (`at`, `sequence`,
85
- `together`, `hold`, `compose`, `drive`, and `asCommand` to return one from a
86
- `@command()` method), `declarePaints`, number formatting and the
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
- ## JSX
122
+ ## Writing a node type
122
123
 
123
- Configure TypeScript with `"jsx": "react-jsx"` and `"jsxImportSource":
124
- "@motionscript/sdk"` (`"react-jsxdev"` for the dev runtime), plus
125
- `"experimentalDecorators": true` for `@property` and `@node`. Only the automatic
126
- runtime exists: there is no `createElement` or `h`. An element is a node
127
- instance: `JSX.Element` is `Node`, `IntrinsicElements` is empty (no lowercase
128
- tag), and the tag must be a class (an arrow function throws `TypeError: type is
129
- not a constructor`). A fragment is an array at run time. `key` is written to the
130
- node's `key`, and `ref` takes a `createRef()`. Which children a node accepts is a
131
- run-time check, not a type, so annotate `const r: Node = <Rect />`, not `Rect`.
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`, `/component`, `/jsx/jsx-runtime` and
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,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/component.ts"],
4
- "sourcesContent": ["/**\r\n * `@motionscript/sdk/component` — what a component package needs beyond the\r\n * authoring barrel: seekable entrances (`at`, `sequence`, `together`, `hold`,\r\n * `compose`, `drive`, and `asCommand` to return one from a `@command()` method),\r\n * `declarePaints`, number formatting and the orbit-camera lerps.\r\n *\r\n * A subpath, not part of `.`, because a scene author never reaches for it and\r\n * one name collides: `hold` here is a seekable pause, where the barrel's `hold`\r\n * is an audio curve. The curation is `@motionscript/core/component`'s, for the\r\n * same reason `index.ts` passes through `@motionscript/core/sdk`.\r\n */\r\nexport * from \"@motionscript/core/component\";\r\n"],
5
- "mappings": "AAWA,WAAc",
4
+ "sourcesContent": ["/**\r\n * `@motionscript/sdk/component` — what a component package needs beyond the\r\n * authoring barrel: number formatting, text defaults, the named shape outlines\r\n * and the orbit-camera lerps.\r\n *\r\n * A subpath, not part of `.`, because a scene author never reaches for it. The\r\n * curation is `@motionscript/core/component`'s, for the same reason\r\n * `index.ts` passes through `@motionscript/core/sdk`.\r\n */\r\nexport * from \"@motionscript/core/component\";\r\n"],
5
+ "mappings": "AASA,WAAc",
6
6
  "names": []
7
7
  }
@@ -1,11 +1,9 @@
1
1
  {
2
2
  "name": "@motionscript/sdk",
3
- "version": "0.1.0-alpha.5",
3
+ "version": "0.1.0-alpha.7",
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"
@@ -1,13 +1,11 @@
1
1
  /**
2
2
  * `@motionscript/sdk/component` — what a component package needs beyond the
3
- * authoring barrel: seekable entrances (`at`, `sequence`, `together`, `hold`,
4
- * `compose`, `drive`, and `asCommand` to return one from a `@command()` method),
5
- * `declarePaints`, number formatting and the orbit-camera lerps.
3
+ * authoring barrel: number formatting, text defaults, the named shape outlines
4
+ * and the orbit-camera lerps.
6
5
  *
7
- * A subpath, not part of `.`, because a scene author never reaches for it and
8
- * one name collides: `hold` here is a seekable pause, where the barrel's `hold`
9
- * is an audio curve. The curation is `@motionscript/core/component`'s, for the
10
- * same reason `index.ts` passes through `@motionscript/core/sdk`.
6
+ * A subpath, not part of `.`, because a scene author never reaches for it. The
7
+ * curation is `@motionscript/core/component`'s, for the same reason
8
+ * `index.ts` passes through `@motionscript/core/sdk`.
11
9
  */
12
10
  export * from "@motionscript/core/component";
13
11
  //# sourceMappingURL=component.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"component.d.ts","sourceRoot":"","sources":["../src/component.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AACH,cAAc,8BAA8B,CAAC"}
1
+ {"version":3,"file":"component.d.ts","sourceRoot":"","sources":["../src/component.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,cAAc,8BAA8B,CAAC"}
package/dist/component.js CHANGED
@@ -1,13 +1,11 @@
1
1
  /**
2
2
  * `@motionscript/sdk/component` — what a component package needs beyond the
3
- * authoring barrel: seekable entrances (`at`, `sequence`, `together`, `hold`,
4
- * `compose`, `drive`, and `asCommand` to return one from a `@command()` method),
5
- * `declarePaints`, number formatting and the orbit-camera lerps.
3
+ * authoring barrel: number formatting, text defaults, the named shape outlines
4
+ * and the orbit-camera lerps.
6
5
  *
7
- * A subpath, not part of `.`, because a scene author never reaches for it and
8
- * one name collides: `hold` here is a seekable pause, where the barrel's `hold`
9
- * is an audio curve. The curation is `@motionscript/core/component`'s, for the
10
- * same reason `index.ts` passes through `@motionscript/core/sdk`.
6
+ * A subpath, not part of `.`, because a scene author never reaches for it. The
7
+ * curation is `@motionscript/core/component`'s, for the same reason
8
+ * `index.ts` passes through `@motionscript/core/sdk`.
11
9
  */
12
10
  export * from "@motionscript/core/component";
13
11
  //# sourceMappingURL=component.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"component.js","sourceRoot":"","sources":["../src/component.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AACH,cAAc,8BAA8B,CAAC","sourcesContent":["/**\r\n * `@motionscript/sdk/component` — what a component package needs beyond the\r\n * authoring barrel: seekable entrances (`at`, `sequence`, `together`, `hold`,\r\n * `compose`, `drive`, and `asCommand` to return one from a `@command()` method),\r\n * `declarePaints`, number formatting and the orbit-camera lerps.\r\n *\r\n * A subpath, not part of `.`, because a scene author never reaches for it and\r\n * one name collides: `hold` here is a seekable pause, where the barrel's `hold`\r\n * is an audio curve. The curation is `@motionscript/core/component`'s, for the\r\n * same reason `index.ts` passes through `@motionscript/core/sdk`.\r\n */\r\nexport * from \"@motionscript/core/component\";\r\n"]}
1
+ {"version":3,"file":"component.js","sourceRoot":"","sources":["../src/component.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,cAAc,8BAA8B,CAAC","sourcesContent":["/**\r\n * `@motionscript/sdk/component` — what a component package needs beyond the\r\n * authoring barrel: number formatting, text defaults, the named shape outlines\r\n * and the orbit-camera lerps.\r\n *\r\n * A subpath, not part of `.`, because a scene author never reaches for it. The\r\n * curation is `@motionscript/core/component`'s, for the same reason\r\n * `index.ts` passes through `@motionscript/core/sdk`.\r\n */\r\nexport * from \"@motionscript/core/component\";\r\n"]}
package/package.json CHANGED
@@ -1,8 +1,8 @@
1
1
  {
2
2
  "name": "@motionscript/sdk",
3
- "version": "0.1.0-alpha.5",
3
+ "version": "0.1.0-alpha.7",
4
4
  "type": "module",
5
- "description": "The Motion Script authoring surface behind one import: document types, nodes, commands, styling, the JSX runtime, and the machinery component kits build on.",
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.5"
44
+ "@motionscript/core": "^0.1.0-alpha.7"
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.5"
56
+ "@motionscript/core": "0.1.0-alpha.7"
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,2 +0,0 @@
1
- import{jsxDEV as m,Fragment as o}from"@motionscript/core/jsx/jsx-dev-runtime";export{o as Fragment,m as jsxDEV};
2
- //# sourceMappingURL=jsx-dev-runtime.js.map
@@ -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,2 +0,0 @@
1
- import{jsx as x,jsxs as e,Fragment as j}from"@motionscript/core/jsx/jsx-runtime";export{j as Fragment,x as jsx,e as jsxs};
2
- //# sourceMappingURL=jsx-runtime.js.map
@@ -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
- }