motlab.js 0.0.0-stage → 0.1.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.
Files changed (108) hide show
  1. package/CHANGELOG.md +42 -0
  2. package/LICENSE +21 -0
  3. package/README.md +86 -2
  4. package/docs/stability.md +53 -0
  5. package/llms.txt +794 -0
  6. package/package.json +107 -6
  7. package/src/adapters/canvas.js +68 -0
  8. package/src/adapters/lottie.js +102 -0
  9. package/src/adapters/pixi.js +62 -0
  10. package/src/adapters/rapier.js +163 -0
  11. package/src/adapters/rive.js +316 -0
  12. package/src/adapters/three.js +81 -0
  13. package/src/addons/audio.js +422 -0
  14. package/src/addons/camera.js +319 -0
  15. package/src/addons/cel.js +498 -0
  16. package/src/addons/clone.js +299 -0
  17. package/src/addons/color.js +223 -0
  18. package/src/addons/deform.js +441 -0
  19. package/src/addons/dom.js +68 -0
  20. package/src/addons/edit.js +317 -0
  21. package/src/addons/fx.js +64 -0
  22. package/src/addons/game.js +106 -0
  23. package/src/addons/input.js +209 -0
  24. package/src/addons/machine.js +240 -0
  25. package/src/addons/media.js +581 -0
  26. package/src/addons/particles.js +179 -0
  27. package/src/addons/path.js +596 -0
  28. package/src/addons/physics.js +980 -0
  29. package/src/addons/player.js +170 -0
  30. package/src/addons/rig.js +851 -0
  31. package/src/addons/text.js +133 -0
  32. package/src/addons/trace.js +456 -0
  33. package/src/core/combinators.js +129 -0
  34. package/src/core/component.js +90 -0
  35. package/src/core/dmath.js +256 -0
  36. package/src/core/ease.js +136 -0
  37. package/src/core/guard.js +139 -0
  38. package/src/core/hash.js +74 -0
  39. package/src/core/markers.js +49 -0
  40. package/src/core/math.js +43 -0
  41. package/src/core/nodes.js +328 -0
  42. package/src/core/noise.js +340 -0
  43. package/src/core/path.js +295 -0
  44. package/src/core/rand.js +135 -0
  45. package/src/core/scene.js +678 -0
  46. package/src/core/simulate.js +289 -0
  47. package/src/core/spring.js +129 -0
  48. package/src/core/timeline.js +193 -0
  49. package/src/core/track.js +258 -0
  50. package/src/core/verify.js +208 -0
  51. package/src/core/version.js +2 -0
  52. package/src/index.js +19 -0
  53. package/src/renderer/canvas2d.js +950 -0
  54. package/src/renderer/pixels.js +57 -0
  55. package/src/renderer/svg.js +589 -0
  56. package/src/renderer/text-layout.js +80 -0
  57. package/src/renderer/webgl2.js +1331 -0
  58. package/types/adapters/canvas.d.ts +46 -0
  59. package/types/adapters/lottie.d.ts +45 -0
  60. package/types/adapters/pixi.d.ts +46 -0
  61. package/types/adapters/rapier.d.ts +116 -0
  62. package/types/adapters/rive.d.ts +62 -0
  63. package/types/adapters/three.d.ts +51 -0
  64. package/types/addons/audio.d.ts +124 -0
  65. package/types/addons/camera.d.ts +134 -0
  66. package/types/addons/cel.d.ts +215 -0
  67. package/types/addons/clone.d.ts +167 -0
  68. package/types/addons/color.d.ts +73 -0
  69. package/types/addons/deform.d.ts +112 -0
  70. package/types/addons/dom.d.ts +68 -0
  71. package/types/addons/edit.d.ts +293 -0
  72. package/types/addons/fx.d.ts +65 -0
  73. package/types/addons/game.d.ts +78 -0
  74. package/types/addons/input.d.ts +56 -0
  75. package/types/addons/machine.d.ts +111 -0
  76. package/types/addons/media.d.ts +117 -0
  77. package/types/addons/particles.d.ts +110 -0
  78. package/types/addons/path.d.ts +61 -0
  79. package/types/addons/physics.d.ts +265 -0
  80. package/types/addons/player.d.ts +48 -0
  81. package/types/addons/rig.d.ts +273 -0
  82. package/types/addons/text.d.ts +63 -0
  83. package/types/addons/trace.d.ts +110 -0
  84. package/types/core/combinators.d.ts +73 -0
  85. package/types/core/component.d.ts +50 -0
  86. package/types/core/dmath.d.ts +52 -0
  87. package/types/core/ease.d.ts +50 -0
  88. package/types/core/guard.d.ts +23 -0
  89. package/types/core/hash.d.ts +6 -0
  90. package/types/core/markers.d.ts +52 -0
  91. package/types/core/math.d.ts +38 -0
  92. package/types/core/nodes.d.ts +442 -0
  93. package/types/core/noise.d.ts +65 -0
  94. package/types/core/path.d.ts +82 -0
  95. package/types/core/rand.d.ts +47 -0
  96. package/types/core/scene.d.ts +189 -0
  97. package/types/core/simulate.d.ts +169 -0
  98. package/types/core/spring.d.ts +41 -0
  99. package/types/core/timeline.d.ts +86 -0
  100. package/types/core/track.d.ts +58 -0
  101. package/types/core/verify.d.ts +42 -0
  102. package/types/core/version.d.ts +2 -0
  103. package/types/index.d.ts +18 -0
  104. package/types/renderer/canvas2d.d.ts +184 -0
  105. package/types/renderer/pixels.d.ts +28 -0
  106. package/types/renderer/svg.d.ts +19 -0
  107. package/types/renderer/text-layout.d.ts +45 -0
  108. package/types/renderer/webgl2.d.ts +71 -0
package/CHANGELOG.md ADDED
@@ -0,0 +1,42 @@
1
+ # Changelog
2
+
3
+ Changes are grouped as Added, Changed, Deprecated, Removed, Fixed and Experimental, and each release lists its date.
4
+ What counts as stable is set out in [docs/stability.md](docs/stability.md).
5
+
6
+ ## 0.1.0 - 2026-12-02
7
+
8
+ Initial pre-1.0 release.
9
+
10
+ ### Added
11
+
12
+ - The time model: keyframe tracks with easing and extrapolation, springs, time combinators, seeded `rand` and noise
13
+ that give the same numbers on every machine, and `dmath` for maths that must match across engines.
14
+ - Nodes, timelines, components (with layer prop support) and scenes, where every frame is a pure function of time, with
15
+ blend modes, mattes, time remapping and motion blur. A guard makes clock (`Date.now`, `new Date()`,
16
+ `performance.now`), `Math.random` and `crypto` randomness calls throw while a scene is evaluated.
17
+ - `verify`, which draws every frame in order and shuffled and reports what changed, and `verifyPixels` in each
18
+ renderer, which does the same for pixels.
19
+ - Canvas 2D and SVG renderers with `dispose()`, plus PNG, PNG sequence and sprite sheet export.
20
+ - Addons for colour (OKLab and OKLCH), paths, per-letter text animation, HTML elements and playback (with async render
21
+ and loop cue support).
22
+ - Cel animation: exposure sheets, drawing swaps, indexed palettes, Aseprite sprites, onion skin and light table.
23
+ - A multiplane camera with cuts, blends, follow and shake; cloners with fields and effectors; analytic particles.
24
+ - Skeletal rigs with IK, FABRIK, drivers, set driven keys and animation layers; keyforms, blend shapes, lattice warps
25
+ and skinning.
26
+ - Seekable simulations with snapshots and a bake cache, XPBD rigid body physics (with off-center joint anchors), and
27
+ state machines with logs.
28
+ - Music analysis with tempo and beat tracking, frame-exact MP4 footage through WebCodecs, and OpenTimelineIO-style
29
+ edits.
30
+ - Games played live with input recorded per tick (including timestamped pointer logs) and replayed exactly with any
31
+ camera.
32
+ - Type declarations made from the JSDoc, packed in `types/`.
33
+
34
+ ### Experimental
35
+
36
+ - A WebGL2 renderer with `dispose()` that runs layers, effects, transitions, meshes and instancing on the GPU. Shapes
37
+ and text are rasterized on the CPU, so its frames repeat exactly.
38
+ - The `mesh` and `transition` nodes, the `effects` prop, and the `fx` addon with glow, diffusion, grain and the
39
+ satsuei finishing pass.
40
+ - The `trace` addon, which turns scanned line art into vector outlines and fills its areas from a palette.
41
+ - Adapters for Rapier, Lottie, Rive, three.js, PixiJS and custom canvases, all with `dispose()`, taking the library you
42
+ install as an argument.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Stanyslaus Hary
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,3 +1,87 @@
1
- # Temporary Holding Version
1
+ # motlab.js
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.
3
+ JavaScript deterministic motion engine.
4
+
5
+ A scene is a tree of nodes whose properties are functions of time, so every frame is a pure function of `t`. The same
6
+ scene can be scrubbed in any order, verified frame by frame, rendered to Canvas 2D, WebGL2, SVG, PNG sequences or sprite
7
+ sheets, played live, or paired with a CLI renderer for MP4 video export. Zero runtime dependencies.
8
+
9
+ [API reference](llms.txt) | [Stability](docs/stability.md) | [Changelog](CHANGELOG.md) | [Contributing](CONTRIBUTING.md)
10
+
11
+ > Pre-1.0 release (`0.1.0`). The API may change before `1.0.0`.
12
+
13
+ ## Installation
14
+
15
+ ```sh
16
+ npm install motlab.js
17
+ ```
18
+
19
+ ## Usage
20
+
21
+ This draws a card that springs in and a title that fades up, and plays it in a loop.
22
+
23
+ ```js
24
+ import { scene, group, rect, text, track, ease, spring } from 'motlab.js'
25
+ import { canvas2d } from 'motlab.js/renderer/canvas2d'
26
+ import { player } from 'motlab.js/addons/player'
27
+
28
+ const pop = spring({ duration: 0.6, bounce: 0.3 })
29
+
30
+ const intro = scene({
31
+ duration: 3,
32
+ size: [1280, 720],
33
+ background: '#101826',
34
+ root: group({}, [
35
+ rect({ id: 'card', x: 640, y: 360, w: 360, h: 200, radius: 24, anchor: [180, 100], fill: '#e8613c', scale: pop }),
36
+ text({
37
+ id: 'title', text: 'Hello, motlab.js', x: 640, y: 372, align: 'center', font: '700 40px sans-serif', fill: '#ffffff',
38
+ opacity: track([[0.4, 0], [0.9, 1, ease.outCubic]]),
39
+ }),
40
+ ]),
41
+ })
42
+
43
+ const draw = canvas2d(document.querySelector('canvas'))
44
+ await draw.load(intro)
45
+ player(t => draw(intro.evaluate(t)), { duration: intro.duration }).play()
46
+ ```
47
+
48
+ `verify` draws every frame in order and shuffled, and reports anything that changed:
49
+
50
+ ```js
51
+ import { verify } from 'motlab.js'
52
+
53
+ verify(intro, { fps: 30 }) // { ok: true, frames: 90, mismatches: [], diffs: [] }
54
+ ```
55
+
56
+ ## Features
57
+
58
+ - Animation: keyframe tracks, easing and CSS cubic-bezier, springs, time combinators, wiggle, seeded `rand` and noise
59
+ that give the same numbers on every machine.
60
+ - Scenes: nodes, timelines, components, blend modes, mattes, time remapping, motion blur, image effects, transitions.
61
+ - Renderers: Canvas 2D, SVG and WebGL2, with PNG, PNG sequence and sprite sheet export.
62
+ - 2D animation: cel animation with exposure sheets and palettes, a multiplane camera, cloners, particles, skeletal rigs
63
+ with IK, keyforms, mesh deformation, and tracing scanned line art.
64
+ - Simulation: seekable simulations with snapshots, rigid body physics, state machines, and games with recorded input.
65
+ - Media: frame-exact MP4 footage through WebCodecs, music analysis with beat tracking, and timeline edits.
66
+ - Adapters for Rapier, Lottie, Rive, three.js and PixiJS.
67
+
68
+ ## Modules
69
+
70
+ | Import | Contents |
71
+ |---|---|
72
+ | `motlab.js` | The core: values, nodes, scenes, `verify`, `simulate` |
73
+ | `motlab.js/renderer/<name>` | `canvas2d`, `svg`, `webgl2` |
74
+ | `motlab.js/addons/<name>` | `color`, `path`, `text`, `dom`, `player`, `cel`, `camera`, `clone`, `particles`, `rig`, `deform`, `physics`, `machine`, `audio`, `media`, `edit`, `input`, `game`, `fx`, `trace` |
75
+ | `motlab.js/adapters/<name>` | `rapier`, `lottie`, `rive`, `three`, `pixi`, `canvas` |
76
+
77
+ Without a bundler, import the files directly (`./src/index.js`, `./src/addons/player.js`) or map `motlab.js` in an
78
+ import map. Each adapter takes its library as an argument, so install that library yourself.
79
+
80
+ ## Browser support
81
+
82
+ The core needs ES2022 modules. The WebGL2 renderer needs WebGL2, footage needs WebCodecs. Tested in Edge 158 and
83
+ Chromium 156; Firefox and Safari are not tested yet. Node 24 runs the core and the tests.
84
+
85
+ ## License
86
+
87
+ MIT
@@ -0,0 +1,53 @@
1
+ # Stability
2
+
3
+ During `0.x` pre-1.0 releases (starting at `0.1.0`), minor versions may change APIs and list every breaking change in
4
+ [CHANGELOG.md](../CHANGELOG.md).
5
+
6
+ From 1.0.0, motlab.js follows semantic versioning, and every public export is either stable or experimental. Public
7
+ means reachable through the package's exports: `motlab.js`, `motlab.js/renderer/*`, `motlab.js/addons/*` and
8
+ `motlab.js/adapters/*`. Files under `src/core/` that the entry point does not export are internal and can change at any
9
+ time.
10
+
11
+ ## Stable
12
+
13
+ A stable export keeps its name, its arguments and what it does for the whole of a major version. If one has to change,
14
+ the old form keeps working for at least one minor release, logs a deprecation warning once, and is listed under
15
+ "Deprecated" in [CHANGELOG.md](../CHANGELOG.md). It is removed only in the next major version.
16
+
17
+ What a stable export draws counts as behaviour. A scene built only from stable parts draws the same frames after a
18
+ minor or patch update. The one exception is a fix that makes a renderer do what its documentation already says, and
19
+ such a fix is listed under "Fixed".
20
+
21
+ Stable in 1.0:
22
+
23
+ - The time model and values: `track`, `key`, `ease`, `spring`, `step`, `loop`, `delay`, `speed`, `add`, `mul`, `map`,
24
+ `wiggle`, `rand`, `noise`, `at`, `clamp`, `lerp`, `prog`, `dmath`, `hash`.
25
+ - Nodes and scenes: `group`, `shape`, `rect`, `ellipse`, `text`, `image`, `video`, `draw`, `instances`, `STRIDE`,
26
+ `path`, `timeline`, `stagger`, `markers`, `component`, `scene`, overrides and the guard.
27
+ - Checking and simulating: `verify`, `simulate`, `prepare`, `memoryStore`, `inputTrack`.
28
+ - The Canvas 2D and SVG renderers.
29
+ - The addons `color`, `path`, `text`, `dom`, `player`, `cel`, `camera`, `clone`, `particles`, `rig`, `deform` (except
30
+ `gridMesh`), `physics`, `machine`, `audio`, `media`, `edit`, `input` and `game`.
31
+
32
+ ## Experimental
33
+
34
+ An experimental export can change or go away in any minor release. Every such change is listed under "Experimental" in
35
+ CHANGELOG.md, with what to do instead.
36
+
37
+ Experimental in 1.0:
38
+
39
+ - The exact shape of the display list that `scene.evaluate` returns. Renderers written outside motlab.js should expect
40
+ new item types and fields.
41
+ - The WebGL2 renderer.
42
+ - The `mesh` and `transition` nodes, the `effects` prop, `EFFECTS` and `TRANSITIONS`.
43
+ - The addons `fx` and `trace`, and `gridMesh` from `deform`.
44
+ - Every adapter: `rapier`, `lottie`, `rive`, `three`, `pixi` and `canvas`.
45
+
46
+ ## What stays the same across machines
47
+
48
+ Numbers do: `rand`, `noise`, `dmath`, the physics addon and the Rapier adapter's deterministic builds give the same
49
+ values on every machine and JavaScript engine.
50
+
51
+ Pixels stay the same from one draw to the next in the same browser on the same machine, which `verifyPixels` checks.
52
+ Between browsers, systems and GPUs, antialiasing and font rendering can differ slightly, and that is not a breaking
53
+ change.