@framefields/node-compositor 0.0.0-stage → 2.0.3
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/.turbo/turbo-build.log +22 -0
- package/.turbo/turbo-test.log +21 -0
- package/CHANGELOG.md +34 -0
- package/LICENCE +202 -0
- package/SKILL.md +370 -0
- package/dist/index-B0ir9Z7o.d.mts +139 -0
- package/dist/index-B0ir9Z7o.d.mts.map +1 -0
- package/dist/index.d.mts +230 -0
- package/dist/index.d.mts.map +1 -0
- package/dist/index.mjs +674 -0
- package/dist/index.mjs.map +1 -0
- package/dist/renderer.d.mts +2 -0
- package/dist/renderer.mjs +3 -0
- package/dist/renderers-DoYYCzgA.mjs +3326 -0
- package/dist/renderers-DoYYCzgA.mjs.map +1 -0
- package/package.json +51 -3
- package/src/index.ts +2 -0
- package/src/renderers/audio-processor.ts +123 -0
- package/src/renderers/container-bg.test.ts +22 -0
- package/src/renderers/container-bg.ts +15 -0
- package/src/renderers/index.ts +9 -0
- package/src/renderers/transform.test.ts +120 -0
- package/src/renderers/transform.ts +101 -0
- package/src/renderers/transform3d.test.ts +290 -0
- package/src/renderers/transform3d.ts +428 -0
- package/src/renderers/webgpu-renderer.ts +4038 -0
- package/src/shared/audio-reactive.test.ts +224 -0
- package/src/shared/bezier-solver.test.ts +92 -0
- package/src/shared/bezier-solver.ts +257 -0
- package/src/shared/compiler.test.ts +1309 -0
- package/src/shared/compiler.ts +996 -0
- package/src/shared/config.ts +44 -0
- package/src/shared/index.ts +3 -0
- package/src/shared/kinetic-typography.test.ts +138 -0
- package/src/shared/presets.test.ts +217 -0
- package/src/shared/presets.ts +644 -0
- package/src/shared/processor.ts +105 -0
- package/tsconfig.json +13 -0
- package/tsdown.config.ts +13 -0
- package/README.md +0 -3
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* processCompositor v2 — doc → render tree (spec: SKILL.md).
|
|
3
|
+
*
|
|
4
|
+
* The composition duration is derived from the tree itself: the max
|
|
5
|
+
* `startFrame + durationFrames` over nodes, with media nodes falling back
|
|
6
|
+
* to their bound source duration. Media nodes bind their graph sources by
|
|
7
|
+
* `inputHandleId`. Everything else is `compositorToProgram` — one
|
|
8
|
+
* constructor, no layer bookkeeping, no implicit "render all inputs".
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
import {
|
|
12
|
+
collectMediaBindings,
|
|
13
|
+
compositorToProgram,
|
|
14
|
+
type LayoutNode,
|
|
15
|
+
} from "@framefields/compositions/program";
|
|
16
|
+
import {
|
|
17
|
+
DEFAULT_DURATION_MS,
|
|
18
|
+
getActiveMediaMetadata,
|
|
19
|
+
type VirtualMediaData,
|
|
20
|
+
} from "@framefields/core";
|
|
21
|
+
import type { CompositorNodeConfig } from "./config.js";
|
|
22
|
+
|
|
23
|
+
function mediaDurationFrames(
|
|
24
|
+
vm: VirtualMediaData | undefined,
|
|
25
|
+
fps: number,
|
|
26
|
+
): number | undefined {
|
|
27
|
+
if (vm?.operation?.dataType === "Image") return undefined;
|
|
28
|
+
const ms = vm ? getActiveMediaMetadata(vm)?.durationMs : undefined;
|
|
29
|
+
if (!ms || ms <= 0) return undefined;
|
|
30
|
+
return Math.max(1, Math.round((ms / 1000) * fps));
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
function computeCompositionDurationFrames(
|
|
34
|
+
config: CompositorNodeConfig,
|
|
35
|
+
mediaByHandle: Map<string, VirtualMediaData>,
|
|
36
|
+
fps: number,
|
|
37
|
+
): number {
|
|
38
|
+
let frames = 0;
|
|
39
|
+
const walk = (nodes: LayoutNode[]) => {
|
|
40
|
+
for (const n of nodes) {
|
|
41
|
+
let dur =
|
|
42
|
+
typeof n.durationFrames === "number" &&
|
|
43
|
+
Number.isFinite(n.durationFrames) &&
|
|
44
|
+
n.durationFrames > 0
|
|
45
|
+
? Math.round(n.durationFrames)
|
|
46
|
+
: undefined;
|
|
47
|
+
const startFrame =
|
|
48
|
+
typeof n.startFrame === "number" &&
|
|
49
|
+
Number.isFinite(n.startFrame) &&
|
|
50
|
+
n.startFrame >= 0
|
|
51
|
+
? Math.round(n.startFrame)
|
|
52
|
+
: 0;
|
|
53
|
+
const vm =
|
|
54
|
+
n.kind === "media" ? mediaByHandle.get(n.inputHandleId) : undefined;
|
|
55
|
+
const limit = mediaDurationFrames(vm, fps);
|
|
56
|
+
const isCaption = vm?.operation?.dataType === "Caption";
|
|
57
|
+
|
|
58
|
+
if (isCaption && limit !== undefined && limit > 0) {
|
|
59
|
+
dur = limit;
|
|
60
|
+
} else if (dur !== undefined) {
|
|
61
|
+
if (limit !== undefined && limit > 0) {
|
|
62
|
+
dur = Math.min(dur, limit);
|
|
63
|
+
}
|
|
64
|
+
} else {
|
|
65
|
+
dur = limit ?? Math.round((DEFAULT_DURATION_MS / 1000) * fps);
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
frames = Math.max(frames, startFrame + dur);
|
|
69
|
+
if ("children" in n && n.children) walk(n.children);
|
|
70
|
+
}
|
|
71
|
+
};
|
|
72
|
+
walk(config.layout);
|
|
73
|
+
return Math.max(1, frames);
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
export function processCompositor(
|
|
77
|
+
config: CompositorNodeConfig,
|
|
78
|
+
mediaByHandle: Map<string, VirtualMediaData>,
|
|
79
|
+
isVideoMode: boolean,
|
|
80
|
+
signalsByHandle?: Map<string, any>,
|
|
81
|
+
): VirtualMediaData {
|
|
82
|
+
const fps = config.fps ?? 24;
|
|
83
|
+
const durationFrames = isVideoMode
|
|
84
|
+
? computeCompositionDurationFrames(config, mediaByHandle, fps)
|
|
85
|
+
: undefined;
|
|
86
|
+
const durationMs =
|
|
87
|
+
durationFrames !== undefined ? (durationFrames / fps) * 1000 : undefined;
|
|
88
|
+
|
|
89
|
+
const signalsObj: Record<string, any> = {};
|
|
90
|
+
if (signalsByHandle) {
|
|
91
|
+
for (const [key, val] of signalsByHandle.entries()) {
|
|
92
|
+
signalsObj[key] = val;
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
return compositorToProgram(config, {
|
|
97
|
+
isVideoMode,
|
|
98
|
+
fps,
|
|
99
|
+
...(durationMs !== undefined && { durationMs }),
|
|
100
|
+
resolveMedia: (inputHandleId) => mediaByHandle.get(inputHandleId),
|
|
101
|
+
signals: signalsObj,
|
|
102
|
+
});
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
export { collectMediaBindings };
|
package/tsconfig.json
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
{
|
|
2
|
+
"extends": "@framefields/tsconfig/node-library.json",
|
|
3
|
+
"compilerOptions": {
|
|
4
|
+
"baseUrl": ".",
|
|
5
|
+
"lib": ["ES2022", "ESNext", "DOM", "DOM.Iterable"],
|
|
6
|
+
"paths": {
|
|
7
|
+
"@/*": ["./src/*"]
|
|
8
|
+
},
|
|
9
|
+
"experimentalDecorators": true,
|
|
10
|
+
"emitDecoratorMetadata": true
|
|
11
|
+
},
|
|
12
|
+
"include": ["src"]
|
|
13
|
+
}
|
package/tsdown.config.ts
ADDED
package/README.md
DELETED