@clypra-studio/engine 0.1.1 → 1.0.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 (41) hide show
  1. package/dist/TransitionDefinition-CC6oSTYB.d.cts +158 -0
  2. package/dist/TransitionDefinition-CC6oSTYB.d.ts +158 -0
  3. package/dist/chunk-4Y7ZSGHJ.js +2990 -0
  4. package/dist/chunk-4Y7ZSGHJ.js.map +1 -0
  5. package/dist/chunk-AUMNXFYQ.js +667 -0
  6. package/dist/chunk-AUMNXFYQ.js.map +1 -0
  7. package/dist/{chunk-CJRH4PAV.js → chunk-LGW5SSLZ.js} +292 -61
  8. package/dist/chunk-LGW5SSLZ.js.map +1 -0
  9. package/dist/{chunk-EVQAI3P3.js → chunk-S24UVNPZ.js} +5 -1
  10. package/dist/{chunk-EVQAI3P3.js.map → chunk-S24UVNPZ.js.map} +1 -1
  11. package/dist/{index-BWo6qV_z.d.cts → index-BP1N8Yg7.d.cts} +2 -2
  12. package/dist/{index-BWo6qV_z.d.ts → index-BP1N8Yg7.d.ts} +2 -2
  13. package/dist/index.cjs +3882 -1366
  14. package/dist/index.cjs.map +1 -1
  15. package/dist/index.d.cts +428 -3798
  16. package/dist/index.d.ts +428 -3798
  17. package/dist/index.js +1373 -1498
  18. package/dist/index.js.map +1 -1
  19. package/dist/textEffects/index.cjs.map +1 -1
  20. package/dist/textEffects/index.js +1 -1
  21. package/dist/transitions/index.cjs +2207 -3
  22. package/dist/transitions/index.cjs.map +1 -1
  23. package/dist/transitions/index.d.cts +54 -5
  24. package/dist/transitions/index.d.ts +54 -5
  25. package/dist/transitions/index.js +53 -3
  26. package/dist/v2/backends/index.cjs +246 -33
  27. package/dist/v2/backends/index.cjs.map +1 -1
  28. package/dist/v2/backends/index.d.cts +1 -1
  29. package/dist/v2/backends/index.d.ts +1 -1
  30. package/dist/v2/backends/index.js +1 -1
  31. package/dist/videoEffects/index.cjs +287 -62
  32. package/dist/videoEffects/index.cjs.map +1 -1
  33. package/dist/videoEffects/index.d.cts +31 -134
  34. package/dist/videoEffects/index.d.ts +31 -134
  35. package/dist/videoEffects/index.js +1 -1
  36. package/package.json +2 -2
  37. package/dist/chunk-5JOAEDIQ.js +0 -446
  38. package/dist/chunk-5JOAEDIQ.js.map +0 -1
  39. package/dist/chunk-CJRH4PAV.js.map +0 -1
  40. package/dist/chunk-QMRMNH52.js +0 -811
  41. package/dist/chunk-QMRMNH52.js.map +0 -1
@@ -0,0 +1,158 @@
1
+ import { Filter, Application, Container, Ticker, Texture } from 'pixi.js';
2
+
3
+ /**
4
+ * @clypra/engine — EffectDefinition
5
+ *
6
+ * Unified type system for all Clypra video effects.
7
+ * Supports two rendering backends:
8
+ * - 'canvas2d' → existing text/overlay effects (EffectEngine class pattern)
9
+ * - 'pixi' → new GPU-accelerated video/motion/filter effects (PixiJS)
10
+ *
11
+ * Both backends are consumed identically by EffectGraph and EffectRenderer.
12
+ * The Studio and Desktop Editor import from this single package — same code, same output.
13
+ */
14
+
15
+ type ParamType = 'range' | 'color' | 'toggle' | 'select' | 'text';
16
+ interface ParamSchema {
17
+ key: string;
18
+ label: string;
19
+ type: ParamType;
20
+ value: number | string | boolean;
21
+ min?: number;
22
+ max?: number;
23
+ step?: number;
24
+ options?: string[];
25
+ }
26
+ type ParamValues = Record<string, number | string | boolean>;
27
+ type EffectCategory = 'light' | 'glitch' | 'cinematic' | 'neon' | 'retro' | 'motion' | 'color' | 'blur' | 'distortion' | 'particle' | 'custom';
28
+ interface Canvas2DEngine {
29
+ /** Advance internal animation state by N steps */
30
+ advanceSteps(steps: number): void;
31
+ /** Draw one frame onto the provided context */
32
+ drawFrame(ctx: CanvasRenderingContext2D, ghostFrames?: ImageData[]): void;
33
+ }
34
+ type Canvas2DEngineConstructor = new (config: ParamValues) => Canvas2DEngine;
35
+ interface Canvas2DEffectDefinition {
36
+ backend: 'canvas2d';
37
+ id: string;
38
+ name: string;
39
+ category: EffectCategory;
40
+ description: string;
41
+ tags: string[];
42
+ thumbnail?: string;
43
+ /** Static param schema — parsed by Studio to build sliders */
44
+ params: ParamSchema[];
45
+ /** The engine class that renders this effect */
46
+ engineClass: Canvas2DEngineConstructor;
47
+ }
48
+ /**
49
+ * PixiJS effect subtypes:
50
+ *
51
+ * 'filter' — one or more GLSL shaders applied as a filter chain on a sprite/container.
52
+ * Pure GPU, no per-frame JS. Uniform values are updated from param changes.
53
+ *
54
+ * 'motion' — animated overlay managed via PixiJS Ticker. Particles, sweeps, pulses.
55
+ * Has full scene-graph access (can add/remove children).
56
+ *
57
+ * 'composite' — combines filter + motion in one effect (e.g. neon glow + particle burst).
58
+ */
59
+ type PixiEffectSubtype = 'filter' | 'motion' | 'composite';
60
+ /** Context passed to every PixiJS effect lifecycle method */
61
+ interface PixiEffectContext {
62
+ /** The PixiJS Application instance (shared, do not destroy) */
63
+ app: Application;
64
+ /** The container to attach overlays or receive filters */
65
+ container: Container;
66
+ /** PixiJS ticker — subscribe for per-frame updates */
67
+ ticker: Ticker;
68
+ /** Current param values (updated when user moves a slider) */
69
+ params: ParamValues;
70
+ /** Canvas dimensions */
71
+ width: number;
72
+ height: number;
73
+ }
74
+ /** A single PixiJS Filter definition (for 'filter' and 'composite' subtypes) */
75
+ interface PixiFilterSpec {
76
+ /**
77
+ * Factory that returns a configured PixiJS Filter.
78
+ * Called once on mount, and again when params change significantly.
79
+ * Import Filter types lazily inside the factory to keep the engine tree-shakeable.
80
+ */
81
+ create: (params: ParamValues) => Filter | Filter[];
82
+ /**
83
+ * Called every frame (if the filter has animated uniforms).
84
+ * Mutate filter.resources / uniforms here instead of re-creating the filter.
85
+ * Return false to skip uniform update this frame (for static filters).
86
+ */
87
+ updateUniforms?: (filter: Filter | Filter[], params: ParamValues, elapsed: number) => void;
88
+ }
89
+ interface PixiEffectDefinition {
90
+ backend: 'pixi';
91
+ subtype: PixiEffectSubtype;
92
+ id: string;
93
+ name: string;
94
+ category: EffectCategory;
95
+ description: string;
96
+ tags: string[];
97
+ thumbnail?: string;
98
+ /** Static param schema — same shape as Canvas2D, drives Studio sliders */
99
+ params: ParamSchema[];
100
+ /**
101
+ * Filter spec — required for 'filter' and 'composite' subtypes.
102
+ * For 'motion' only, omit this.
103
+ */
104
+ filterSpec?: PixiFilterSpec;
105
+ /**
106
+ * Lifecycle hooks for motion and composite subtypes.
107
+ * mount → called once when effect is activated (add sprites, subscribe ticker)
108
+ * unmount → called when effect is removed (clean up ALL resources — critical)
109
+ * update → called when param values change (slider moved)
110
+ */
111
+ mount?: (ctx: PixiEffectContext) => void;
112
+ unmount?: (ctx: PixiEffectContext) => void;
113
+ onParamChange?: (ctx: PixiEffectContext, key: string, value: ParamValues[string]) => void;
114
+ }
115
+ type EffectDefinition = Canvas2DEffectDefinition | PixiEffectDefinition;
116
+ declare function isCanvas2DEffect(e: EffectDefinition): e is Canvas2DEffectDefinition;
117
+ declare function isPixiEffect(e: EffectDefinition): e is PixiEffectDefinition;
118
+ declare function isFilterEffect(e: EffectDefinition): e is PixiEffectDefinition & {
119
+ subtype: 'filter';
120
+ };
121
+ declare function isMotionEffect(e: EffectDefinition): e is PixiEffectDefinition & {
122
+ subtype: 'motion';
123
+ };
124
+ declare function isCompositeEffect(e: EffectDefinition): e is PixiEffectDefinition & {
125
+ subtype: 'composite';
126
+ };
127
+
128
+ type GPUEffectTransitionCategory = 'geometric' | 'optical-distortion' | 'temporal' | 'particle-dissolve' | 'light-based' | 'depth-based' | 'physics-simulated';
129
+ interface TransitionContext {
130
+ /** Outgoing clip texture — sampled as uFrom in the shader */
131
+ fromTexture: Texture;
132
+ /** Incoming clip texture — sampled as uTo in the shader */
133
+ toTexture: Texture;
134
+ /** 0 at transition start, 1 at transition end — driven by the Studio timeline scrubber */
135
+ progress: number;
136
+ width: number;
137
+ height: number;
138
+ }
139
+ interface TransitionDefinition {
140
+ id: string;
141
+ name: string;
142
+ category: GPUEffectTransitionCategory;
143
+ description: string;
144
+ tags: string[];
145
+ thumbnail?: string;
146
+ /** Default duration in ms — used as the starting value in Studio, editable per-cut in Desktop */
147
+ defaultDurationMs: number;
148
+ params: ParamSchema[];
149
+ /** Called once — builds the dual-texture filter */
150
+ create(params: ParamValues): Filter;
151
+ /**
152
+ * Called every frame during the transition window.
153
+ * progress goes 0 → 1 over defaultDurationMs (or the user-set cut duration).
154
+ */
155
+ updateProgress(filter: Filter, progress: number, params: ParamValues): void;
156
+ }
157
+
158
+ export { type Canvas2DEffectDefinition as C, type EffectDefinition as E, type GPUEffectTransitionCategory as G, type PixiEffectDefinition as P, type TransitionContext as T, type Canvas2DEngine as a, type Canvas2DEngineConstructor as b, type ParamSchema as c, type ParamType as d, type ParamValues as e, type PixiEffectContext as f, type PixiEffectSubtype as g, type PixiFilterSpec as h, type TransitionDefinition as i, isCanvas2DEffect as j, isCompositeEffect as k, isFilterEffect as l, isMotionEffect as m, isPixiEffect as n };
@@ -0,0 +1,158 @@
1
+ import { Filter, Application, Container, Ticker, Texture } from 'pixi.js';
2
+
3
+ /**
4
+ * @clypra/engine — EffectDefinition
5
+ *
6
+ * Unified type system for all Clypra video effects.
7
+ * Supports two rendering backends:
8
+ * - 'canvas2d' → existing text/overlay effects (EffectEngine class pattern)
9
+ * - 'pixi' → new GPU-accelerated video/motion/filter effects (PixiJS)
10
+ *
11
+ * Both backends are consumed identically by EffectGraph and EffectRenderer.
12
+ * The Studio and Desktop Editor import from this single package — same code, same output.
13
+ */
14
+
15
+ type ParamType = 'range' | 'color' | 'toggle' | 'select' | 'text';
16
+ interface ParamSchema {
17
+ key: string;
18
+ label: string;
19
+ type: ParamType;
20
+ value: number | string | boolean;
21
+ min?: number;
22
+ max?: number;
23
+ step?: number;
24
+ options?: string[];
25
+ }
26
+ type ParamValues = Record<string, number | string | boolean>;
27
+ type EffectCategory = 'light' | 'glitch' | 'cinematic' | 'neon' | 'retro' | 'motion' | 'color' | 'blur' | 'distortion' | 'particle' | 'custom';
28
+ interface Canvas2DEngine {
29
+ /** Advance internal animation state by N steps */
30
+ advanceSteps(steps: number): void;
31
+ /** Draw one frame onto the provided context */
32
+ drawFrame(ctx: CanvasRenderingContext2D, ghostFrames?: ImageData[]): void;
33
+ }
34
+ type Canvas2DEngineConstructor = new (config: ParamValues) => Canvas2DEngine;
35
+ interface Canvas2DEffectDefinition {
36
+ backend: 'canvas2d';
37
+ id: string;
38
+ name: string;
39
+ category: EffectCategory;
40
+ description: string;
41
+ tags: string[];
42
+ thumbnail?: string;
43
+ /** Static param schema — parsed by Studio to build sliders */
44
+ params: ParamSchema[];
45
+ /** The engine class that renders this effect */
46
+ engineClass: Canvas2DEngineConstructor;
47
+ }
48
+ /**
49
+ * PixiJS effect subtypes:
50
+ *
51
+ * 'filter' — one or more GLSL shaders applied as a filter chain on a sprite/container.
52
+ * Pure GPU, no per-frame JS. Uniform values are updated from param changes.
53
+ *
54
+ * 'motion' — animated overlay managed via PixiJS Ticker. Particles, sweeps, pulses.
55
+ * Has full scene-graph access (can add/remove children).
56
+ *
57
+ * 'composite' — combines filter + motion in one effect (e.g. neon glow + particle burst).
58
+ */
59
+ type PixiEffectSubtype = 'filter' | 'motion' | 'composite';
60
+ /** Context passed to every PixiJS effect lifecycle method */
61
+ interface PixiEffectContext {
62
+ /** The PixiJS Application instance (shared, do not destroy) */
63
+ app: Application;
64
+ /** The container to attach overlays or receive filters */
65
+ container: Container;
66
+ /** PixiJS ticker — subscribe for per-frame updates */
67
+ ticker: Ticker;
68
+ /** Current param values (updated when user moves a slider) */
69
+ params: ParamValues;
70
+ /** Canvas dimensions */
71
+ width: number;
72
+ height: number;
73
+ }
74
+ /** A single PixiJS Filter definition (for 'filter' and 'composite' subtypes) */
75
+ interface PixiFilterSpec {
76
+ /**
77
+ * Factory that returns a configured PixiJS Filter.
78
+ * Called once on mount, and again when params change significantly.
79
+ * Import Filter types lazily inside the factory to keep the engine tree-shakeable.
80
+ */
81
+ create: (params: ParamValues) => Filter | Filter[];
82
+ /**
83
+ * Called every frame (if the filter has animated uniforms).
84
+ * Mutate filter.resources / uniforms here instead of re-creating the filter.
85
+ * Return false to skip uniform update this frame (for static filters).
86
+ */
87
+ updateUniforms?: (filter: Filter | Filter[], params: ParamValues, elapsed: number) => void;
88
+ }
89
+ interface PixiEffectDefinition {
90
+ backend: 'pixi';
91
+ subtype: PixiEffectSubtype;
92
+ id: string;
93
+ name: string;
94
+ category: EffectCategory;
95
+ description: string;
96
+ tags: string[];
97
+ thumbnail?: string;
98
+ /** Static param schema — same shape as Canvas2D, drives Studio sliders */
99
+ params: ParamSchema[];
100
+ /**
101
+ * Filter spec — required for 'filter' and 'composite' subtypes.
102
+ * For 'motion' only, omit this.
103
+ */
104
+ filterSpec?: PixiFilterSpec;
105
+ /**
106
+ * Lifecycle hooks for motion and composite subtypes.
107
+ * mount → called once when effect is activated (add sprites, subscribe ticker)
108
+ * unmount → called when effect is removed (clean up ALL resources — critical)
109
+ * update → called when param values change (slider moved)
110
+ */
111
+ mount?: (ctx: PixiEffectContext) => void;
112
+ unmount?: (ctx: PixiEffectContext) => void;
113
+ onParamChange?: (ctx: PixiEffectContext, key: string, value: ParamValues[string]) => void;
114
+ }
115
+ type EffectDefinition = Canvas2DEffectDefinition | PixiEffectDefinition;
116
+ declare function isCanvas2DEffect(e: EffectDefinition): e is Canvas2DEffectDefinition;
117
+ declare function isPixiEffect(e: EffectDefinition): e is PixiEffectDefinition;
118
+ declare function isFilterEffect(e: EffectDefinition): e is PixiEffectDefinition & {
119
+ subtype: 'filter';
120
+ };
121
+ declare function isMotionEffect(e: EffectDefinition): e is PixiEffectDefinition & {
122
+ subtype: 'motion';
123
+ };
124
+ declare function isCompositeEffect(e: EffectDefinition): e is PixiEffectDefinition & {
125
+ subtype: 'composite';
126
+ };
127
+
128
+ type GPUEffectTransitionCategory = 'geometric' | 'optical-distortion' | 'temporal' | 'particle-dissolve' | 'light-based' | 'depth-based' | 'physics-simulated';
129
+ interface TransitionContext {
130
+ /** Outgoing clip texture — sampled as uFrom in the shader */
131
+ fromTexture: Texture;
132
+ /** Incoming clip texture — sampled as uTo in the shader */
133
+ toTexture: Texture;
134
+ /** 0 at transition start, 1 at transition end — driven by the Studio timeline scrubber */
135
+ progress: number;
136
+ width: number;
137
+ height: number;
138
+ }
139
+ interface TransitionDefinition {
140
+ id: string;
141
+ name: string;
142
+ category: GPUEffectTransitionCategory;
143
+ description: string;
144
+ tags: string[];
145
+ thumbnail?: string;
146
+ /** Default duration in ms — used as the starting value in Studio, editable per-cut in Desktop */
147
+ defaultDurationMs: number;
148
+ params: ParamSchema[];
149
+ /** Called once — builds the dual-texture filter */
150
+ create(params: ParamValues): Filter;
151
+ /**
152
+ * Called every frame during the transition window.
153
+ * progress goes 0 → 1 over defaultDurationMs (or the user-set cut duration).
154
+ */
155
+ updateProgress(filter: Filter, progress: number, params: ParamValues): void;
156
+ }
157
+
158
+ export { type Canvas2DEffectDefinition as C, type EffectDefinition as E, type GPUEffectTransitionCategory as G, type PixiEffectDefinition as P, type TransitionContext as T, type Canvas2DEngine as a, type Canvas2DEngineConstructor as b, type ParamSchema as c, type ParamType as d, type ParamValues as e, type PixiEffectContext as f, type PixiEffectSubtype as g, type PixiFilterSpec as h, type TransitionDefinition as i, isCanvas2DEffect as j, isCompositeEffect as k, isFilterEffect as l, isMotionEffect as m, isPixiEffect as n };