@vune-ui/animation 0.1.20

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 (68) hide show
  1. package/ARCHITECTURE.md +470 -0
  2. package/CHANGELOG.md +88 -0
  3. package/LICENSE +21 -0
  4. package/PERFORMANCE.md +151 -0
  5. package/README.md +630 -0
  6. package/dist/index.d.ts +474 -0
  7. package/dist/src/canvas/index.d.ts +15 -0
  8. package/dist/src/canvas/index.js +67 -0
  9. package/dist/src/constraints/index.d.ts +33 -0
  10. package/dist/src/constraints/index.js +346 -0
  11. package/dist/src/core/bezier.js +51 -0
  12. package/dist/src/core/composition.js +17 -0
  13. package/dist/src/core/controls.js +22 -0
  14. package/dist/src/core/default-engine.js +20 -0
  15. package/dist/src/core/easing.js +58 -0
  16. package/dist/src/core/engine.js +1031 -0
  17. package/dist/src/core/frame-budget.js +30 -0
  18. package/dist/src/core/index.d.ts +43 -0
  19. package/dist/src/core/index.js +17 -0
  20. package/dist/src/core/js-spring-batch.js +57 -0
  21. package/dist/src/core/kinetics.js +140 -0
  22. package/dist/src/core/math.js +20 -0
  23. package/dist/src/core/motion-value.js +53 -0
  24. package/dist/src/core/planner.js +72 -0
  25. package/dist/src/core/specs.js +70 -0
  26. package/dist/src/dom/index.d.ts +41 -0
  27. package/dist/src/dom/index.js +364 -0
  28. package/dist/src/gesture/index.d.ts +66 -0
  29. package/dist/src/gesture/index.js +376 -0
  30. package/dist/src/index.js +53 -0
  31. package/dist/src/interpolate/color.js +223 -0
  32. package/dist/src/interpolate/css.d.ts +13 -0
  33. package/dist/src/interpolate/css.js +34 -0
  34. package/dist/src/interpolate/index.d.ts +13 -0
  35. package/dist/src/interpolate/index.js +55 -0
  36. package/dist/src/interpolate/transform.js +247 -0
  37. package/dist/src/layout/index.d.ts +56 -0
  38. package/dist/src/layout/index.js +485 -0
  39. package/dist/src/material/index.d.ts +9 -0
  40. package/dist/src/material/index.js +70 -0
  41. package/dist/src/path/index.d.ts +37 -0
  42. package/dist/src/path/index.js +527 -0
  43. package/dist/src/render/frame-batcher.js +52 -0
  44. package/dist/src/scroll/index.d.ts +55 -0
  45. package/dist/src/scroll/index.js +233 -0
  46. package/dist/src/timeline/index.d.ts +147 -0
  47. package/dist/src/timeline/index.js +849 -0
  48. package/dist/src/transition/index.d.ts +88 -0
  49. package/dist/src/transition/index.js +369 -0
  50. package/dist/src/wasm/index.d.ts +29 -0
  51. package/dist/src/wasm/index.js +8 -0
  52. package/dist/src/wasm/loader.js +55 -0
  53. package/dist/src/wasm/shared-wasm-spring-batch.js +52 -0
  54. package/dist/src/wasm/wasm-spring-batch.js +52 -0
  55. package/dist/src/webgl/index.d.ts +22 -0
  56. package/dist/src/webgl/index.js +94 -0
  57. package/dist/src/webgpu/index.d.ts +35 -0
  58. package/dist/src/webgpu/index.js +73 -0
  59. package/dist/src/webgpu/spring-batch.js +218 -0
  60. package/dist/src/worker/index.d.ts +17 -0
  61. package/dist/src/worker/index.js +1 -0
  62. package/dist/src/worker/shared-spring-worker.js +218 -0
  63. package/dist/src/worker/shared-worker.js +75 -0
  64. package/dist/wasm/kernel-scalar.wasm +0 -0
  65. package/dist/wasm/kernel-shared-scalar.wasm +0 -0
  66. package/dist/wasm/kernel-shared-simd.wasm +0 -0
  67. package/dist/wasm/kernel-simd.wasm +0 -0
  68. package/package.json +113 -0
@@ -0,0 +1,75 @@
1
+ import { instantiateSharedSpringKernel } from '../wasm/loader.js';
2
+
3
+ let nodeParentPort = null;
4
+ try {
5
+ const nodeWorkers = ['node', 'worker_threads'].join(':');
6
+ ({ parentPort: nodeParentPort } = await import(/* @vite-ignore */ nodeWorkers));
7
+ } catch {}
8
+
9
+ const endpoint = nodeParentPort ?? globalThis;
10
+ const post = (message) => nodeParentPort ? nodeParentPort.postMessage(message) : globalThis.postMessage(message);
11
+ const listen = (handler) => {
12
+ if (nodeParentPort) nodeParentPort.on('message', handler);
13
+ else globalThis.onmessage = (event) => handler(event.data);
14
+ };
15
+
16
+ let control = null;
17
+ let controlFloat = null;
18
+ let exportsRef = null;
19
+ let ptrs = null;
20
+ let lastSequence = 0;
21
+ let running = false;
22
+ let atomicCompletion = false;
23
+
24
+ function runLoop() {
25
+ if (running) return;
26
+ running = true;
27
+ while (Atomics.load(control, 3) === 0) {
28
+ let sequence = Atomics.load(control, 0);
29
+ if (sequence === lastSequence) {
30
+ Atomics.wait(control, 0, lastSequence);
31
+ sequence = Atomics.load(control, 0);
32
+ if (Atomics.load(control, 3) !== 0) break;
33
+ if (sequence === lastSequence) continue;
34
+ }
35
+
36
+ const count = Atomics.load(control, 2);
37
+ const dtSeconds = controlFloat[4];
38
+ try {
39
+ exportsRef.step_springs(
40
+ ptrs.positions,
41
+ ptrs.velocities,
42
+ ptrs.targets,
43
+ ptrs.omegas,
44
+ ptrs.dampingRatios,
45
+ count,
46
+ dtSeconds,
47
+ );
48
+ Atomics.store(control, 5, 0);
49
+ } catch (error) {
50
+ Atomics.store(control, 5, 1);
51
+ post({ type: 'error', message: error?.message ?? String(error), stack: error?.stack });
52
+ }
53
+ lastSequence = sequence;
54
+ Atomics.store(control, 1, sequence);
55
+ Atomics.notify(control, 1);
56
+ if (!atomicCompletion) post({ type: 'done', sequence });
57
+ }
58
+ post({ type: 'stopped' });
59
+ }
60
+
61
+ listen(async (message) => {
62
+ if (message?.type !== 'init') return;
63
+ try {
64
+ const loaded = await instantiateSharedSpringKernel(message.memory, message.variant);
65
+ exportsRef = loaded.instance.exports;
66
+ ptrs = message.ptrs;
67
+ control = new Int32Array(message.controlBuffer);
68
+ controlFloat = new Float32Array(message.controlBuffer);
69
+ atomicCompletion = Boolean(message.atomicCompletion);
70
+ post({ type: 'ready', variant: loaded.variant, completion: atomicCompletion ? 'atomics-wait-async' : 'message' });
71
+ queueMicrotask(runLoop);
72
+ } catch (error) {
73
+ post({ type: 'error', message: error?.message ?? String(error), stack: error?.stack });
74
+ }
75
+ });
Binary file
Binary file
package/package.json ADDED
@@ -0,0 +1,113 @@
1
+ {
2
+ "name": "@vune-ui/animation",
3
+ "version": "0.1.20",
4
+ "type": "module",
5
+ "description": "Renderer-agnostic Vune animation runtime with JS/WASM/Worker execution, gestures, timelines, transitions, scroll linking, constraints, and GPU/canvas adapters.",
6
+ "sideEffects": false,
7
+ "main": "./dist/src/index.js",
8
+ "types": "./dist/index.d.ts",
9
+ "exports": {
10
+ ".": {
11
+ "types": "./dist/index.d.ts",
12
+ "import": "./dist/src/index.js"
13
+ },
14
+ "./core": {
15
+ "types": "./dist/src/core/index.d.ts",
16
+ "import": "./dist/src/core/index.js"
17
+ },
18
+ "./dom": {
19
+ "types": "./dist/src/dom/index.d.ts",
20
+ "import": "./dist/src/dom/index.js"
21
+ },
22
+ "./interpolate": {
23
+ "types": "./dist/src/interpolate/index.d.ts",
24
+ "import": "./dist/src/interpolate/index.js"
25
+ },
26
+ "./interpolate/css": {
27
+ "types": "./dist/src/interpolate/css.d.ts",
28
+ "import": "./dist/src/interpolate/css.js"
29
+ },
30
+ "./layout": {
31
+ "types": "./dist/src/layout/index.d.ts",
32
+ "import": "./dist/src/layout/index.js"
33
+ },
34
+ "./worker": {
35
+ "types": "./dist/src/worker/index.d.ts",
36
+ "import": "./dist/src/worker/index.js"
37
+ },
38
+ "./wasm": {
39
+ "types": "./dist/src/wasm/index.d.ts",
40
+ "import": "./dist/src/wasm/index.js"
41
+ },
42
+ "./path": {
43
+ "types": "./dist/src/path/index.d.ts",
44
+ "import": "./dist/src/path/index.js"
45
+ },
46
+ "./material": {
47
+ "types": "./dist/src/material/index.d.ts",
48
+ "import": "./dist/src/material/index.js"
49
+ },
50
+ "./gesture": {
51
+ "types": "./dist/src/gesture/index.d.ts",
52
+ "import": "./dist/src/gesture/index.js"
53
+ },
54
+ "./timeline": {
55
+ "types": "./dist/src/timeline/index.d.ts",
56
+ "import": "./dist/src/timeline/index.js"
57
+ },
58
+ "./transition": {
59
+ "types": "./dist/src/transition/index.d.ts",
60
+ "import": "./dist/src/transition/index.js"
61
+ },
62
+ "./scroll": {
63
+ "types": "./dist/src/scroll/index.d.ts",
64
+ "import": "./dist/src/scroll/index.js"
65
+ },
66
+ "./constraints": {
67
+ "types": "./dist/src/constraints/index.d.ts",
68
+ "import": "./dist/src/constraints/index.js"
69
+ },
70
+ "./canvas": {
71
+ "types": "./dist/src/canvas/index.d.ts",
72
+ "import": "./dist/src/canvas/index.js"
73
+ },
74
+ "./webgl": {
75
+ "types": "./dist/src/webgl/index.d.ts",
76
+ "import": "./dist/src/webgl/index.js"
77
+ },
78
+ "./webgpu": {
79
+ "types": "./dist/src/webgpu/index.d.ts",
80
+ "import": "./dist/src/webgpu/index.js"
81
+ }
82
+ },
83
+ "dependencies": {
84
+ "@vune-ui/execution": "0.1.20"
85
+ },
86
+ "engines": {
87
+ "node": ">=20.19.0"
88
+ },
89
+ "files": [
90
+ "dist",
91
+ "README.md",
92
+ "ARCHITECTURE.md",
93
+ "PERFORMANCE.md",
94
+ "CHANGELOG.md"
95
+ ],
96
+ "scripts": {
97
+ "build": "node scripts/build.mjs",
98
+ "build:wasm": "bash wasm/build.sh && node scripts/snapshot-wasm.mjs",
99
+ "test": "pnpm run build && pnpm run test:full && pnpm run typecheck",
100
+ "test:focused": "node --test test/motion-value.test.mjs test/spring.test.mjs test/timing.test.mjs test/interpolation.test.mjs test/layout.test.mjs test/material.test.mjs test/planner.test.mjs test/timeline.test.mjs test/transition.test.mjs test/gesture.test.mjs",
101
+ "test:full": "node --test test/*.test.mjs",
102
+ "typecheck": "tsc -p tsconfig.types.json",
103
+ "bench": "node bench/springs.mjs",
104
+ "bench:worker": "node bench/worker-springs.mjs",
105
+ "bench:path": "node bench/path.mjs",
106
+ "bench:gestures": "node bench/gestures.mjs",
107
+ "bench:timeline": "node bench/timeline.mjs",
108
+ "bench:transitions": "node bench/transitions.mjs",
109
+ "bench:constraints": "node bench/constraints.mjs",
110
+ "bench:scroll": "node bench/scroll.mjs",
111
+ "bench:renderers": "node bench/renderers.mjs"
112
+ }
113
+ }