@mun-ui/animation 0.0.0-stage → 0.2.1
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/ARCHITECTURE.md +470 -0
- package/CHANGELOG.md +88 -0
- package/LICENSE +21 -0
- package/PERFORMANCE.md +151 -0
- package/README.md +635 -2
- package/dist/index.d.ts +474 -0
- package/dist/src/canvas/index.d.ts +15 -0
- package/dist/src/canvas/index.js +93 -0
- package/dist/src/constraints/index.d.ts +33 -0
- package/dist/src/constraints/index.js +346 -0
- package/dist/src/core/bezier.js +51 -0
- package/dist/src/core/composition.js +17 -0
- package/dist/src/core/controls.js +22 -0
- package/dist/src/core/default-engine.js +20 -0
- package/dist/src/core/easing.js +58 -0
- package/dist/src/core/engine.js +1031 -0
- package/dist/src/core/frame-budget.js +30 -0
- package/dist/src/core/index.d.ts +43 -0
- package/dist/src/core/index.js +17 -0
- package/dist/src/core/js-spring-batch.js +57 -0
- package/dist/src/core/kinetics.js +140 -0
- package/dist/src/core/math.js +20 -0
- package/dist/src/core/motion-value.js +53 -0
- package/dist/src/core/planner.js +72 -0
- package/dist/src/core/specs.js +70 -0
- package/dist/src/dom/index.d.ts +41 -0
- package/dist/src/dom/index.js +364 -0
- package/dist/src/gesture/index.d.ts +66 -0
- package/dist/src/gesture/index.js +376 -0
- package/dist/src/index.js +53 -0
- package/dist/src/interpolate/color.js +223 -0
- package/dist/src/interpolate/css.d.ts +13 -0
- package/dist/src/interpolate/css.js +34 -0
- package/dist/src/interpolate/index.d.ts +13 -0
- package/dist/src/interpolate/index.js +55 -0
- package/dist/src/interpolate/transform.js +247 -0
- package/dist/src/layout/index.d.ts +56 -0
- package/dist/src/layout/index.js +485 -0
- package/dist/src/material/index.d.ts +9 -0
- package/dist/src/material/index.js +70 -0
- package/dist/src/path/index.d.ts +37 -0
- package/dist/src/path/index.js +527 -0
- package/dist/src/render/frame-batcher.js +52 -0
- package/dist/src/rendering-quality/index.d.ts +28 -0
- package/dist/src/rendering-quality/index.js +284 -0
- package/dist/src/rendering-quality/probe.js +132 -0
- package/dist/src/scroll/index.d.ts +55 -0
- package/dist/src/scroll/index.js +233 -0
- package/dist/src/timeline/index.d.ts +147 -0
- package/dist/src/timeline/index.js +849 -0
- package/dist/src/transition/index.d.ts +88 -0
- package/dist/src/transition/index.js +369 -0
- package/dist/src/wasm/index.d.ts +29 -0
- package/dist/src/wasm/index.js +8 -0
- package/dist/src/wasm/loader.js +55 -0
- package/dist/src/wasm/shared-wasm-spring-batch.js +52 -0
- package/dist/src/wasm/wasm-spring-batch.js +52 -0
- package/dist/src/webgl/index.d.ts +22 -0
- package/dist/src/webgl/index.js +94 -0
- package/dist/src/webgpu/index.d.ts +35 -0
- package/dist/src/webgpu/index.js +73 -0
- package/dist/src/webgpu/spring-batch.js +218 -0
- package/dist/src/worker/index.d.ts +17 -0
- package/dist/src/worker/index.js +1 -0
- package/dist/src/worker/shared-spring-worker.js +218 -0
- package/dist/src/worker/shared-worker.js +75 -0
- package/dist/wasm/kernel-scalar.wasm +0 -0
- package/dist/wasm/kernel-shared-scalar.wasm +0 -0
- package/dist/wasm/kernel-shared-simd.wasm +0 -0
- package/dist/wasm/kernel-simd.wasm +0 -0
- package/package.json +114 -3
|
@@ -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
|
|
Binary file
|
|
Binary file
|
package/package.json
CHANGED
|
@@ -1,6 +1,117 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mun-ui/animation",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"description": "
|
|
3
|
+
"version": "0.2.1",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"description": "Renderer-agnostic Mün 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
|
+
"./rendering-quality": {
|
|
11
|
+
"types": "./dist/src/rendering-quality/index.d.ts",
|
|
12
|
+
"import": "./dist/src/rendering-quality/index.js"
|
|
13
|
+
},
|
|
14
|
+
".": {
|
|
15
|
+
"types": "./dist/index.d.ts",
|
|
16
|
+
"import": "./dist/src/index.js"
|
|
17
|
+
},
|
|
18
|
+
"./core": {
|
|
19
|
+
"types": "./dist/src/core/index.d.ts",
|
|
20
|
+
"import": "./dist/src/core/index.js"
|
|
21
|
+
},
|
|
22
|
+
"./dom": {
|
|
23
|
+
"types": "./dist/src/dom/index.d.ts",
|
|
24
|
+
"import": "./dist/src/dom/index.js"
|
|
25
|
+
},
|
|
26
|
+
"./interpolate": {
|
|
27
|
+
"types": "./dist/src/interpolate/index.d.ts",
|
|
28
|
+
"import": "./dist/src/interpolate/index.js"
|
|
29
|
+
},
|
|
30
|
+
"./interpolate/css": {
|
|
31
|
+
"types": "./dist/src/interpolate/css.d.ts",
|
|
32
|
+
"import": "./dist/src/interpolate/css.js"
|
|
33
|
+
},
|
|
34
|
+
"./layout": {
|
|
35
|
+
"types": "./dist/src/layout/index.d.ts",
|
|
36
|
+
"import": "./dist/src/layout/index.js"
|
|
37
|
+
},
|
|
38
|
+
"./worker": {
|
|
39
|
+
"types": "./dist/src/worker/index.d.ts",
|
|
40
|
+
"import": "./dist/src/worker/index.js"
|
|
41
|
+
},
|
|
42
|
+
"./wasm": {
|
|
43
|
+
"types": "./dist/src/wasm/index.d.ts",
|
|
44
|
+
"import": "./dist/src/wasm/index.js"
|
|
45
|
+
},
|
|
46
|
+
"./path": {
|
|
47
|
+
"types": "./dist/src/path/index.d.ts",
|
|
48
|
+
"import": "./dist/src/path/index.js"
|
|
49
|
+
},
|
|
50
|
+
"./material": {
|
|
51
|
+
"types": "./dist/src/material/index.d.ts",
|
|
52
|
+
"import": "./dist/src/material/index.js"
|
|
53
|
+
},
|
|
54
|
+
"./gesture": {
|
|
55
|
+
"types": "./dist/src/gesture/index.d.ts",
|
|
56
|
+
"import": "./dist/src/gesture/index.js"
|
|
57
|
+
},
|
|
58
|
+
"./timeline": {
|
|
59
|
+
"types": "./dist/src/timeline/index.d.ts",
|
|
60
|
+
"import": "./dist/src/timeline/index.js"
|
|
61
|
+
},
|
|
62
|
+
"./transition": {
|
|
63
|
+
"types": "./dist/src/transition/index.d.ts",
|
|
64
|
+
"import": "./dist/src/transition/index.js"
|
|
65
|
+
},
|
|
66
|
+
"./scroll": {
|
|
67
|
+
"types": "./dist/src/scroll/index.d.ts",
|
|
68
|
+
"import": "./dist/src/scroll/index.js"
|
|
69
|
+
},
|
|
70
|
+
"./constraints": {
|
|
71
|
+
"types": "./dist/src/constraints/index.d.ts",
|
|
72
|
+
"import": "./dist/src/constraints/index.js"
|
|
73
|
+
},
|
|
74
|
+
"./canvas": {
|
|
75
|
+
"types": "./dist/src/canvas/index.d.ts",
|
|
76
|
+
"import": "./dist/src/canvas/index.js"
|
|
77
|
+
},
|
|
78
|
+
"./webgl": {
|
|
79
|
+
"types": "./dist/src/webgl/index.d.ts",
|
|
80
|
+
"import": "./dist/src/webgl/index.js"
|
|
81
|
+
},
|
|
82
|
+
"./webgpu": {
|
|
83
|
+
"types": "./dist/src/webgpu/index.d.ts",
|
|
84
|
+
"import": "./dist/src/webgpu/index.js"
|
|
85
|
+
}
|
|
86
|
+
},
|
|
87
|
+
"dependencies": {
|
|
88
|
+
"@mun-ui/execution": "0.2.1"
|
|
89
|
+
},
|
|
90
|
+
"engines": {
|
|
91
|
+
"node": ">=20.19.0"
|
|
92
|
+
},
|
|
93
|
+
"files": [
|
|
94
|
+
"dist",
|
|
95
|
+
"README.md",
|
|
96
|
+
"ARCHITECTURE.md",
|
|
97
|
+
"PERFORMANCE.md",
|
|
98
|
+
"CHANGELOG.md"
|
|
99
|
+
],
|
|
100
|
+
"scripts": {
|
|
101
|
+
"build": "node scripts/build.mjs",
|
|
102
|
+
"build:wasm": "bash wasm/build.sh && node scripts/snapshot-wasm.mjs",
|
|
103
|
+
"test": "pnpm run build && pnpm run test:full && pnpm run typecheck",
|
|
104
|
+
"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",
|
|
105
|
+
"test:full": "node --test test/*.test.mjs",
|
|
106
|
+
"typecheck": "tsc -p tsconfig.types.json",
|
|
107
|
+
"bench": "node bench/springs.mjs",
|
|
108
|
+
"bench:worker": "node bench/worker-springs.mjs",
|
|
109
|
+
"bench:path": "node bench/path.mjs",
|
|
110
|
+
"bench:gestures": "node bench/gestures.mjs",
|
|
111
|
+
"bench:timeline": "node bench/timeline.mjs",
|
|
112
|
+
"bench:transitions": "node bench/transitions.mjs",
|
|
113
|
+
"bench:constraints": "node bench/constraints.mjs",
|
|
114
|
+
"bench:scroll": "node bench/scroll.mjs",
|
|
115
|
+
"bench:renderers": "node bench/renderers.mjs"
|
|
116
|
+
}
|
|
6
117
|
}
|