@clypra-studio/engine 1.3.0 → 1.4.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 (47) hide show
  1. package/README.md +1 -1
  2. package/dist/{chunk-LT3HTJ3X.js → chunk-3UEOLDJJ.js} +5 -829
  3. package/dist/chunk-3UEOLDJJ.js.map +1 -0
  4. package/dist/{chunk-Y4FMAOTW.js → chunk-E6O6LZME.js} +266 -1004
  5. package/dist/chunk-E6O6LZME.js.map +1 -0
  6. package/dist/chunk-PU3Q4QI7.js +833 -0
  7. package/dist/chunk-PU3Q4QI7.js.map +1 -0
  8. package/dist/{index-D6GAXDBy.d.cts → index-C18SQ-y6.d.cts} +171 -37
  9. package/dist/{index-D6GAXDBy.d.ts → index-C18SQ-y6.d.ts} +171 -37
  10. package/dist/index.cjs +11149 -23528
  11. package/dist/index.cjs.map +1 -1
  12. package/dist/index.d.cts +2087 -7834
  13. package/dist/index.d.ts +2087 -7834
  14. package/dist/index.js +10059 -17971
  15. package/dist/index.js.map +1 -1
  16. package/dist/textEffects/index.cjs +259 -971
  17. package/dist/textEffects/index.cjs.map +1 -1
  18. package/dist/textEffects/index.d.cts +1 -1
  19. package/dist/textEffects/index.d.ts +1 -1
  20. package/dist/textEffects/index.js +1 -1
  21. package/dist/transitions/index.cjs +18 -2199
  22. package/dist/transitions/index.cjs.map +1 -1
  23. package/dist/transitions/index.d.cts +37 -53
  24. package/dist/transitions/index.d.ts +37 -53
  25. package/dist/transitions/index.js +3 -51
  26. package/dist/videoEffects/index.cjs +4 -835
  27. package/dist/videoEffects/index.cjs.map +1 -1
  28. package/dist/videoEffects/index.d.cts +9 -138
  29. package/dist/videoEffects/index.d.ts +9 -138
  30. package/dist/videoEffects/index.js +1 -15
  31. package/package.json +13 -16
  32. package/dist/TransitionDefinition-CQoSb4ZB.d.cts +0 -158
  33. package/dist/TransitionDefinition-CQoSb4ZB.d.ts +0 -158
  34. package/dist/chunk-FIJBB3MH.js +0 -2990
  35. package/dist/chunk-FIJBB3MH.js.map +0 -1
  36. package/dist/chunk-LT3HTJ3X.js.map +0 -1
  37. package/dist/chunk-RYA4KGDB.js +0 -690
  38. package/dist/chunk-RYA4KGDB.js.map +0 -1
  39. package/dist/chunk-Y4FMAOTW.js.map +0 -1
  40. package/dist/index-BdQ3oRT4.d.cts +0 -139
  41. package/dist/index-BdQ3oRT4.d.ts +0 -139
  42. package/dist/v2/backends/index.cjs +0 -693
  43. package/dist/v2/backends/index.cjs.map +0 -1
  44. package/dist/v2/backends/index.d.cts +0 -3
  45. package/dist/v2/backends/index.d.ts +0 -3
  46. package/dist/v2/backends/index.js +0 -8
  47. package/dist/v2/backends/index.js.map +0 -1
@@ -24,9 +24,7 @@ __export(videoEffects_exports, {
24
24
  EffectEngine: () => EffectEngine,
25
25
  EffectGraph: () => EffectGraph,
26
26
  EffectRenderer: () => EffectRenderer,
27
- ExamplePixiEffects: () => example_exports,
28
27
  LightEffects: () => light_exports,
29
- PixiRenderer: () => PixiRenderer,
30
28
  addNoise: () => addNoise,
31
29
  blendColors: () => blendColors,
32
30
  clearCanvas: () => clearCanvas,
@@ -41,11 +39,6 @@ __export(videoEffects_exports, {
41
39
  getEffectsByCategory: () => getEffectsByCategory,
42
40
  getEffectsByCategoryForApi: () => getEffectsByCategoryForApi,
43
41
  hexToRgba: () => hexToRgba,
44
- isCanvas2DEffect: () => isCanvas2DEffect,
45
- isCompositeEffect: () => isCompositeEffect,
46
- isFilterEffect: () => isFilterEffect,
47
- isMotionEffect: () => isMotionEffect,
48
- isPixiEffect: () => isPixiEffect,
49
42
  rgbaToComponents: () => rgbaToComponents,
50
43
  searchEffects: () => searchEffects,
51
44
  searchEffectsForApi: () => searchEffectsForApi,
@@ -604,7 +597,7 @@ var EFFECTS_REGISTRY = {
604
597
  },
605
598
  tags: ["body", "segmentation", "glow"]
606
599
  },
607
- // PixiJS Video Filter Effects (Unified Registry Metadata)
600
+ // Native video filter effects (unified registry metadata)
608
601
  "light-leak": {
609
602
  id: "light-leak",
610
603
  name: "Light Leak",
@@ -1315,7 +1308,7 @@ function getEffectRenderer(id) {
1315
1308
  body_outline: renderBodyOutline,
1316
1309
  body_particles: renderBodyParticles,
1317
1310
  "body-segmentation-glow": renderBodySegmentationGlow,
1318
- // PixiJS variant fallbacks (supporting both kebab-case and underscore normalized variants)
1311
+ // Normalized aliases retained for existing saved projects.
1319
1312
  "light-leak": renderLightLeak,
1320
1313
  "lens-flare": renderLightLeak2,
1321
1314
  "lens_flare": renderLightLeak2,
@@ -1925,19 +1918,9 @@ var EffectGraph = class {
1925
1918
  const connected = this.connections.filter((conn) => conn.toNode === nodeId).map((conn) => conn.fromNode);
1926
1919
  return Array.from(/* @__PURE__ */ new Set([...deps, ...connected]));
1927
1920
  }
1928
- /**
1929
- * Returns only the PixiJS nodes in resolved order.
1930
- * Used by EffectRenderer to build the PixiJS filter + motion pipeline.
1931
- */
1932
- resolvePixi() {
1933
- return this.resolve().filter((n) => n.effect?.backend === "pixi");
1934
- }
1935
- /**
1936
- * Returns only the Canvas2D nodes in resolved order.
1937
- * Used by EffectRenderer for text effect overlays.
1938
- */
1921
+ /** Returns nodes that can execute in the browser-side authoring raster path. */
1939
1922
  resolveCanvas2D() {
1940
- return this.resolve().filter((n) => n.effect?.backend === "canvas2d");
1923
+ return this.resolve().filter((n) => n.effect?.backend !== "native");
1941
1924
  }
1942
1925
  get size() {
1943
1926
  return this.nodes.size;
@@ -2214,813 +2197,6 @@ function generateEffectsManifest() {
2214
2197
  };
2215
2198
  }
2216
2199
 
2217
- // src/videoEffects/EffectDefinition.ts
2218
- function isCanvas2DEffect(e) {
2219
- return e.backend === "canvas2d";
2220
- }
2221
- function isPixiEffect(e) {
2222
- return e.backend === "pixi";
2223
- }
2224
- function isFilterEffect(e) {
2225
- return isPixiEffect(e) && e.subtype === "filter";
2226
- }
2227
- function isMotionEffect(e) {
2228
- return isPixiEffect(e) && e.subtype === "motion";
2229
- }
2230
- function isCompositeEffect(e) {
2231
- return isPixiEffect(e) && e.subtype === "composite";
2232
- }
2233
-
2234
- // src/videoEffects/PixiRenderer.ts
2235
- var import_pixi = require("pixi.js");
2236
- var PixiRenderer = class {
2237
- app = null;
2238
- videoSprite = null;
2239
- transitionSprite = null;
2240
- _activeTransition = null;
2241
- fromRenderTexture = null;
2242
- toRenderTexture = null;
2243
- blitSprite = null;
2244
- _transitionFromTex = null;
2245
- _transitionToTex = null;
2246
- overlayContainer = null;
2247
- baseMediaContainer = null;
2248
- mounted = /* @__PURE__ */ new Map();
2249
- initialized = false;
2250
- initializing = false;
2251
- _activeSource = null;
2252
- _fitMode = "fit";
2253
- /**
2254
- * Initialize the PixiJS Application.
2255
- * Call once, reuse across effect changes.
2256
- *
2257
- * @param canvas The target HTMLCanvasElement (Studio preview or rasterizer offscreen canvas)
2258
- * @param width Canvas width in pixels
2259
- * @param height Canvas height in pixels
2260
- */
2261
- async init(canvas, width, height) {
2262
- if (this.initialized || this.initializing) return;
2263
- this.initializing = true;
2264
- canvas.addEventListener("webglcontextlost", (event) => {
2265
- event.preventDefault();
2266
- console.warn("[PixiRenderer] WebGL context lost \u2014 attempting recovery");
2267
- });
2268
- canvas.addEventListener("webglcontextrestored", () => {
2269
- console.log("[PixiRenderer] WebGL context restored");
2270
- });
2271
- const app = new import_pixi.Application();
2272
- try {
2273
- await app.init({
2274
- canvas,
2275
- width,
2276
- height,
2277
- backgroundAlpha: 0,
2278
- // transparent — composited over video below
2279
- antialias: true,
2280
- preference: "webgl",
2281
- // WebGL for production stability; swap to 'webgpu' later
2282
- resolution: typeof window !== "undefined" ? window.devicePixelRatio || 1 : 1,
2283
- autoDensity: true,
2284
- preserveDrawingBuffer: true,
2285
- // CRITICAL: disable the auto-render ticker.
2286
- // The compositor calls renderer.render() at the END of every composeFrame(),
2287
- // after all sprite states are finalized. If Pixi's own ticker fires between
2288
- // beginTextFrame() (which hides all sprites) and the awaited
2289
- // renderTextLayerBridged() / renderStickerLayerBridged() calls that re-show
2290
- // them, it renders a fully-invisible frame → visible blink of text and stickers.
2291
- autoStart: false
2292
- });
2293
- } catch (e) {
2294
- this.initializing = false;
2295
- throw e;
2296
- }
2297
- if (!this.initializing) {
2298
- app.destroy(true);
2299
- return;
2300
- }
2301
- this.app = app;
2302
- this.videoSprite = new import_pixi.Sprite();
2303
- this.videoSprite.width = width;
2304
- this.videoSprite.height = height;
2305
- this.transitionSprite = new import_pixi.Sprite();
2306
- this.transitionSprite.width = width;
2307
- this.transitionSprite.height = height;
2308
- this.transitionSprite.visible = false;
2309
- this.overlayContainer = new import_pixi.Container();
2310
- this.baseMediaContainer = new import_pixi.Container();
2311
- this.baseMediaContainer.sortableChildren = true;
2312
- this.app.stage.addChildAt(this.baseMediaContainer, 0);
2313
- this.app.stage.addChild(this.videoSprite);
2314
- this.app.stage.addChild(this.transitionSprite);
2315
- this.app.stage.addChild(this.overlayContainer);
2316
- this.initialized = true;
2317
- this.initializing = false;
2318
- }
2319
- setVideoSource(video) {
2320
- if (this._activeSource === video) {
2321
- this.resizeSprites();
2322
- return;
2323
- }
2324
- this._activeSource = video;
2325
- if (!this.videoSprite || !this.app) return;
2326
- const texture = import_pixi.Texture.from(video);
2327
- this.videoSprite.texture = texture;
2328
- this.resizeSprites();
2329
- }
2330
- setImageSource(image) {
2331
- if (this._activeSource === image) {
2332
- this.resizeSprites();
2333
- return;
2334
- }
2335
- this._activeSource = image;
2336
- if (!this.videoSprite || !this.app) return;
2337
- const texture = import_pixi.Texture.from(image);
2338
- this.videoSprite.texture = texture;
2339
- this.resizeSprites();
2340
- }
2341
- // -------------------------------------------------------------------------
2342
- // Effect lifecycle
2343
- // -------------------------------------------------------------------------
2344
- /**
2345
- * Mount a resolved set of PixiJS graph nodes.
2346
- * Builds filter chains and initialises motion effects.
2347
- * Previously mounted effects NOT in the new list are unmounted.
2348
- */
2349
- applyNodes(nodes, globalParams) {
2350
- if (!this.app || !this.videoSprite || !this.overlayContainer) {
2351
- throw new Error("[PixiRenderer] call init() before applyNodes()");
2352
- }
2353
- const incomingIds = new Set(nodes.map((n) => n.id));
2354
- for (const [id, mounted] of this.mounted) {
2355
- if (!incomingIds.has(id)) {
2356
- this._unmount(mounted);
2357
- this.mounted.delete(id);
2358
- }
2359
- }
2360
- const filterChain = [];
2361
- for (const node of nodes) {
2362
- const def = node.effect;
2363
- if (!isPixiEffect(def)) continue;
2364
- const params = globalParams?.get(node.id) ?? this._defaultParams(def);
2365
- if (this.mounted.has(node.id)) {
2366
- const m = this.mounted.get(node.id);
2367
- Object.assign(m.params, params);
2368
- Object.assign(m.ctx.params, params);
2369
- if (m.filters && m.definition.filterSpec?.updateUniforms) {
2370
- m.definition.filterSpec.updateUniforms(m.filters.length === 1 ? m.filters[0] : m.filters, m.params, 0);
2371
- }
2372
- if (m.filters) filterChain.push(...m.filters);
2373
- continue;
2374
- }
2375
- const ctx = {
2376
- app: this.app,
2377
- container: this.overlayContainer,
2378
- ticker: this.app.ticker,
2379
- params,
2380
- width: this.app.screen.width,
2381
- height: this.app.screen.height
2382
- };
2383
- let filters = null;
2384
- let tickerFn = void 0;
2385
- if ((isFilterEffect(def) || isCompositeEffect(def)) && def.filterSpec) {
2386
- const result = def.filterSpec.create(params);
2387
- filters = Array.isArray(result) ? result : [result];
2388
- filterChain.push(...filters);
2389
- if (def.filterSpec.updateUniforms) {
2390
- const spec = def.filterSpec;
2391
- const elapsed = { value: 0 };
2392
- tickerFn = (ticker) => {
2393
- elapsed.value += ticker.deltaMS;
2394
- if (filters) {
2395
- spec.updateUniforms(filters.length === 1 ? filters[0] : filters, params, elapsed.value);
2396
- }
2397
- };
2398
- this.app.ticker.add(tickerFn);
2399
- }
2400
- }
2401
- if ((isMotionEffect(def) || isCompositeEffect(def)) && def.mount) {
2402
- def.mount(ctx);
2403
- }
2404
- this.mounted.set(node.id, { node, definition: def, params, filters, ctx, tickerFn });
2405
- }
2406
- this.videoSprite.filters = filterChain.length > 0 ? filterChain : null;
2407
- }
2408
- /**
2409
- * Update multiple params on a mounted effect in one pass.
2410
- */
2411
- updateParams(nodeId, params) {
2412
- const m = this.mounted.get(nodeId);
2413
- if (!m) return;
2414
- Object.assign(m.params, params);
2415
- Object.assign(m.ctx.params, params);
2416
- if (m.filters && m.definition.filterSpec?.updateUniforms) {
2417
- m.definition.filterSpec.updateUniforms(m.filters.length === 1 ? m.filters[0] : m.filters, m.params, 0);
2418
- }
2419
- }
2420
- /**
2421
- * Force a render pass (required for static image previews after uniform changes).
2422
- */
2423
- render() {
2424
- if (!this.app) return;
2425
- this.app.renderer.render({ container: this.app.stage });
2426
- }
2427
- /**
2428
- * Update a single param on a mounted effect.
2429
- * Triggers uniform refresh and calls onParamChange lifecycle hook.
2430
- */
2431
- updateParam(nodeId, key, value) {
2432
- const m = this.mounted.get(nodeId);
2433
- if (!m) return;
2434
- m.params[key] = value;
2435
- m.ctx.params[key] = value;
2436
- if (m.filters && m.definition.filterSpec?.updateUniforms) {
2437
- m.definition.filterSpec.updateUniforms(m.filters.length === 1 ? m.filters[0] : m.filters, m.params, 0);
2438
- }
2439
- m.definition.onParamChange?.(m.ctx, key, value);
2440
- }
2441
- /**
2442
- * Capture the current rendered frame as an ImageData.
2443
- * Used by the Desktop rasterizer to extract pixels for FFmpeg.
2444
- */
2445
- captureFrame() {
2446
- if (!this.app) return null;
2447
- const canvas = this.app.canvas;
2448
- const ctx = canvas.getContext("2d");
2449
- if (!ctx) return null;
2450
- return ctx.getImageData(0, 0, canvas.width, canvas.height);
2451
- }
2452
- /**
2453
- * Resize the renderer (e.g. when project resolution changes).
2454
- */
2455
- resize(width, height) {
2456
- if (!this.app) return;
2457
- this.app.renderer.resize(width, height);
2458
- this.resizeSprites();
2459
- }
2460
- setFitMode(mode) {
2461
- if (this._fitMode === mode) return;
2462
- this._fitMode = mode;
2463
- this.resizeSprites();
2464
- }
2465
- resizeSprites() {
2466
- if (this.videoSprite && this.videoSprite.texture) {
2467
- this._resizeSprite(this.videoSprite, this.videoSprite.texture, this._fitMode);
2468
- }
2469
- if (this.transitionSprite) {
2470
- if (this._activeTransition) {
2471
- this.transitionSprite.width = this.app?.screen.width ?? 1280;
2472
- this.transitionSprite.height = this.app?.screen.height ?? 720;
2473
- this.transitionSprite.position.set(0, 0);
2474
- } else if (this.transitionSprite.texture) {
2475
- this._resizeSprite(this.transitionSprite, this.transitionSprite.texture, this._fitMode);
2476
- }
2477
- }
2478
- }
2479
- _getElementDimensions(texture) {
2480
- const sourceEl = this._activeSource;
2481
- if (sourceEl) {
2482
- const tagName = sourceEl.tagName;
2483
- if ((tagName === "VIDEO" || sourceEl.videoWidth !== void 0) && sourceEl.videoWidth > 0) {
2484
- return { width: sourceEl.videoWidth, height: sourceEl.videoHeight };
2485
- }
2486
- if ((tagName === "IMG" || sourceEl.naturalWidth !== void 0) && sourceEl.naturalWidth > 0) {
2487
- return { width: sourceEl.naturalWidth, height: sourceEl.naturalHeight };
2488
- }
2489
- if ((tagName === "CANVAS" || sourceEl.getContext !== void 0) && sourceEl.width > 0) {
2490
- return { width: sourceEl.width, height: sourceEl.height };
2491
- }
2492
- }
2493
- const resource = texture.source?.resource || texture.source?.source;
2494
- if (resource) {
2495
- const tagName = resource.tagName;
2496
- if ((tagName === "VIDEO" || resource.videoWidth !== void 0) && resource.videoWidth > 0) {
2497
- return { width: resource.videoWidth, height: resource.videoHeight };
2498
- }
2499
- if ((tagName === "IMG" || resource.naturalWidth !== void 0) && resource.naturalWidth > 0) {
2500
- return { width: resource.naturalWidth, height: resource.naturalHeight };
2501
- }
2502
- if ((tagName === "CANVAS" || resource.getContext !== void 0) && resource.width > 0) {
2503
- return { width: resource.width, height: resource.height };
2504
- }
2505
- }
2506
- if (texture.width > 0) {
2507
- return { width: texture.width, height: texture.height };
2508
- }
2509
- return { width: 1280, height: 720 };
2510
- }
2511
- _resizeSprite(sprite, texture, fitMode) {
2512
- if (!this.app) return;
2513
- const canvasWidth = this.app.screen.width;
2514
- const canvasHeight = this.app.screen.height;
2515
- const { width: texWidth, height: texHeight } = this._getElementDimensions(texture);
2516
- if (fitMode === "stretch") {
2517
- sprite.width = canvasWidth;
2518
- sprite.height = canvasHeight;
2519
- sprite.position.set(0, 0);
2520
- } else {
2521
- const scaleX = canvasWidth / texWidth;
2522
- const scaleY = canvasHeight / texHeight;
2523
- const scale = fitMode === "fit" ? Math.min(scaleX, scaleY) : Math.max(scaleX, scaleY);
2524
- sprite.width = texWidth * scale;
2525
- sprite.height = texHeight * scale;
2526
- sprite.position.set((canvasWidth - sprite.width) / 2, (canvasHeight - sprite.height) / 2);
2527
- }
2528
- }
2529
- /**
2530
- * Full teardown — unmounts all effects, destroys the PixiJS Application.
2531
- * Call when the editor session ends or the Studio workspace unmounts.
2532
- */
2533
- destroy() {
2534
- this.initializing = false;
2535
- for (const mounted of this.mounted.values()) {
2536
- this._unmount(mounted);
2537
- }
2538
- this.mounted.clear();
2539
- if (this.app) {
2540
- try {
2541
- const gl = this.app.renderer.gl;
2542
- this.app.destroy(true, { children: true, texture: true });
2543
- gl?.getExtension("WEBGL_lose_context")?.loseContext();
2544
- } catch (e) {
2545
- console.warn("Error destroying Pixi application:", e);
2546
- }
2547
- this.app = null;
2548
- }
2549
- this.videoSprite = null;
2550
- this.transitionSprite = null;
2551
- this.overlayContainer = null;
2552
- this.baseMediaContainer = null;
2553
- this.initialized = false;
2554
- this._activeTransition = null;
2555
- this._activeSource = null;
2556
- if (this.fromRenderTexture) {
2557
- this.fromRenderTexture.destroy(true);
2558
- this.fromRenderTexture = null;
2559
- }
2560
- if (this.toRenderTexture) {
2561
- this.toRenderTexture.destroy(true);
2562
- this.toRenderTexture = null;
2563
- }
2564
- if (this.blitSprite) {
2565
- this.blitSprite.destroy();
2566
- this.blitSprite = null;
2567
- }
2568
- }
2569
- // -------------------------------------------------------------------------
2570
- // Private helpers
2571
- // -------------------------------------------------------------------------
2572
- _unmount(m) {
2573
- if ((isMotionEffect(m.definition) || isCompositeEffect(m.definition)) && m.definition.unmount) {
2574
- m.definition.unmount(m.ctx);
2575
- }
2576
- if (m.tickerFn && this.app) {
2577
- this.app.ticker.remove(m.tickerFn);
2578
- }
2579
- if (m.filters) {
2580
- for (const f of m.filters) f.destroy();
2581
- }
2582
- }
2583
- _defaultParams(def) {
2584
- return Object.fromEntries(def.params.map((p) => [p.key, p.value]));
2585
- }
2586
- getApp() {
2587
- return this.app;
2588
- }
2589
- getVideoSprite() {
2590
- return this.videoSprite;
2591
- }
2592
- getTransitionSprite() {
2593
- return this.transitionSprite;
2594
- }
2595
- getBaseMediaContainer() {
2596
- return this.baseMediaContainer;
2597
- }
2598
- getOverlayContainer() {
2599
- return this.overlayContainer;
2600
- }
2601
- get isReady() {
2602
- return this.initialized;
2603
- }
2604
- _ensureRenderTextures(width, height) {
2605
- if (!this.fromRenderTexture || this.fromRenderTexture.width !== width || this.fromRenderTexture.height !== height) {
2606
- if (this.fromRenderTexture) this.fromRenderTexture.destroy(true);
2607
- this.fromRenderTexture = import_pixi.RenderTexture.create({ width, height });
2608
- }
2609
- if (!this.toRenderTexture || this.toRenderTexture.width !== width || this.toRenderTexture.height !== height) {
2610
- if (this.toRenderTexture) this.toRenderTexture.destroy(true);
2611
- this.toRenderTexture = import_pixi.RenderTexture.create({ width, height });
2612
- }
2613
- if (!this.blitSprite) {
2614
- this.blitSprite = new import_pixi.Sprite();
2615
- }
2616
- }
2617
- _blitTransitionFrames() {
2618
- if (!this.app || !this._transitionFromTex || !this._transitionToTex || !this.fromRenderTexture || !this.toRenderTexture || !this.blitSprite) {
2619
- return;
2620
- }
2621
- const currentFitMode = this._fitMode;
2622
- this.blitSprite.texture = this._transitionFromTex;
2623
- this._resizeSprite(this.blitSprite, this._transitionFromTex, currentFitMode);
2624
- this.app.renderer.render({
2625
- container: this.blitSprite,
2626
- target: this.fromRenderTexture,
2627
- clear: true
2628
- });
2629
- this.blitSprite.texture = this._transitionToTex;
2630
- this._resizeSprite(this.blitSprite, this._transitionToTex, currentFitMode);
2631
- this.app.renderer.render({
2632
- container: this.blitSprite,
2633
- target: this.toRenderTexture,
2634
- clear: true
2635
- });
2636
- this.blitSprite.texture = import_pixi.Texture.EMPTY;
2637
- }
2638
- mountTransition(definition, fromTexture, toTexture, params) {
2639
- if (!this.transitionSprite || !this.videoSprite || !this.app) return;
2640
- this._activeSource = null;
2641
- if (this._activeTransition?.filter) {
2642
- this._activeTransition.filter.destroy();
2643
- }
2644
- this._transitionFromTex = fromTexture;
2645
- this._transitionToTex = toTexture;
2646
- const canvasWidth = this.app.screen.width;
2647
- const canvasHeight = this.app.screen.height;
2648
- this._ensureRenderTextures(canvasWidth, canvasHeight);
2649
- this._blitTransitionFrames();
2650
- const fromRT = this.fromRenderTexture;
2651
- const toRT = this.toRenderTexture;
2652
- const originalFilterFrom = import_pixi.Filter.from;
2653
- import_pixi.Filter.from = function(options) {
2654
- if (options && options.resources) {
2655
- if (!options.resources.uFrom) {
2656
- options.resources.uFrom = fromRT.source;
2657
- }
2658
- if (!options.resources.uTo) {
2659
- options.resources.uTo = toRT.source;
2660
- }
2661
- }
2662
- return originalFilterFrom.call(this, options);
2663
- };
2664
- let filter;
2665
- try {
2666
- filter = definition.create(params);
2667
- } finally {
2668
- import_pixi.Filter.from = originalFilterFrom;
2669
- }
2670
- filter.resources.uFrom = fromRT.source;
2671
- filter.resources.uTo = toRT.source;
2672
- this.transitionSprite.texture = fromRT;
2673
- this.transitionSprite.filters = [filter];
2674
- this.transitionSprite.visible = true;
2675
- this.videoSprite.visible = false;
2676
- if (this.baseMediaContainer) {
2677
- this.baseMediaContainer.visible = false;
2678
- }
2679
- this._activeTransition = { definition, filter, params };
2680
- this.resizeSprites();
2681
- }
2682
- getActiveTransitionId() {
2683
- return this._activeTransition?.definition.id || null;
2684
- }
2685
- updateTransitionProgress(id, progress, params) {
2686
- if (!this._activeTransition) return;
2687
- if (params) {
2688
- this._activeTransition.params = params;
2689
- }
2690
- this._blitTransitionFrames();
2691
- this._activeTransition.definition.updateProgress(this._activeTransition.filter, progress, this._activeTransition.params);
2692
- }
2693
- unmountTransition() {
2694
- if (this.transitionSprite) {
2695
- this.transitionSprite.visible = false;
2696
- this.transitionSprite.filters = null;
2697
- }
2698
- if (this.videoSprite) {
2699
- this.videoSprite.visible = true;
2700
- }
2701
- if (this.baseMediaContainer) {
2702
- this.baseMediaContainer.visible = true;
2703
- }
2704
- if (this._activeTransition?.filter) {
2705
- this._activeTransition.filter.destroy();
2706
- }
2707
- this._activeTransition = null;
2708
- this._transitionFromTex = null;
2709
- this._transitionToTex = null;
2710
- }
2711
- };
2712
-
2713
- // src/videoEffects/example.ts
2714
- var example_exports = {};
2715
- __export(example_exports, {
2716
- NeonGlowEffect: () => NeonGlowEffect,
2717
- ParticleBurstEffect: () => ParticleBurstEffect,
2718
- VHSCompositeEffect: () => VHSCompositeEffect
2719
- });
2720
- var import_pixi2 = require("pixi.js");
2721
- var hexToRgb = (hex) => {
2722
- const r = parseInt(hex.slice(1, 3), 16) / 255;
2723
- const g = parseInt(hex.slice(3, 5), 16) / 255;
2724
- const b = parseInt(hex.slice(5, 7), 16) / 255;
2725
- return [r, g, b];
2726
- };
2727
- var hexToDec = (hex) => parseInt(hex.replace("#", ""), 16);
2728
- var DEFAULT_VERTEX_SHADER = `
2729
- in vec2 aPosition;
2730
- out vec2 vTextureCoord;
2731
-
2732
- uniform vec4 uInputSize;
2733
- uniform vec4 uOutputFrame;
2734
-
2735
- vec4 filterVertexPosition(void) {
2736
- vec2 position = aPosition * uOutputFrame.zw + uOutputFrame.xy;
2737
- return vec4(position * uInputSize.zw * 2.0 - 1.0, 0.0, 1.0);
2738
- }
2739
-
2740
- vec2 filterTextureCoord(void) {
2741
- return aPosition * (uOutputFrame.zw * uInputSize.xy);
2742
- }
2743
-
2744
- void main(void) {
2745
- gl_Position = filterVertexPosition();
2746
- vTextureCoord = filterTextureCoord();
2747
- }
2748
- `;
2749
- var NeonGlowEffect = {
2750
- backend: "pixi",
2751
- subtype: "filter",
2752
- id: "neon-glow",
2753
- name: "Neon Glow",
2754
- category: "neon",
2755
- description: "GPU chromatic aberration with pulsing glow. Zero CPU cost per frame.",
2756
- tags: ["glow", "neon", "chromatic", "aberration", "rgb"],
2757
- thumbnail: "https://clypra-worker-api.abdulkabirmusa.com/thumbnails/neon-glow.webp",
2758
- params: [
2759
- { key: "spread", label: "Spread", type: "range", value: 4, min: 0, max: 20, step: 0.5 },
2760
- { key: "strength", label: "Glow strength", type: "range", value: 0.6, min: 0, max: 1, step: 0.01 },
2761
- { key: "color", label: "Glow color", type: "color", value: "#7C6FFF" },
2762
- { key: "pulse", label: "Pulse", type: "toggle", value: true },
2763
- { key: "pulseSpeed", label: "Pulse speed", type: "range", value: 1.5, min: 0.1, max: 5, step: 0.1 }
2764
- ],
2765
- filterSpec: {
2766
- create(params) {
2767
- const fragment = `
2768
- in vec2 vTextureCoord;
2769
- out vec4 finalColor;
2770
-
2771
- uniform sampler2D uTexture;
2772
- uniform float uSpread;
2773
- uniform float uStrength;
2774
- uniform vec3 uGlowColor;
2775
- uniform float uTime;
2776
- uniform bool uPulse;
2777
- uniform float uPulseSpeed;
2778
-
2779
- void main(void) {
2780
- vec2 uv = vTextureCoord;
2781
-
2782
- // Chromatic aberration \u2014 shift R and B channels outward from center
2783
- vec2 dir = uv - 0.5;
2784
- float dist = length(dir) * uSpread * 0.01;
2785
- vec2 redUV = uv + dir * dist;
2786
- vec2 blueUV = uv - dir * dist;
2787
-
2788
- float r = texture(uTexture, redUV).r;
2789
- float g = texture(uTexture, uv).g;
2790
- float b = texture(uTexture, blueUV).b;
2791
- float a = texture(uTexture, uv).a;
2792
-
2793
- vec4 base = vec4(r, g, b, a);
2794
-
2795
- // Soft glow overlay \u2014 animated pulse
2796
- float pulse = uPulse
2797
- ? 0.5 + 0.5 * sin(uTime * uPulseSpeed * 6.28318)
2798
- : 1.0;
2799
- float glow = uStrength * pulse;
2800
-
2801
- // Additive blend of glow color onto base
2802
- vec3 glowContrib = uGlowColor * glow * base.a;
2803
- finalColor = vec4(base.rgb + glowContrib, base.a);
2804
- }
2805
- `;
2806
- const rgb = hexToRgb(params.color);
2807
- return import_pixi2.Filter.from({
2808
- gl: { vertex: DEFAULT_VERTEX_SHADER, fragment },
2809
- resources: {
2810
- uniforms: {
2811
- uSpread: { value: params.spread, type: "f32" },
2812
- uStrength: { value: params.strength, type: "f32" },
2813
- uGlowColor: { value: rgb, type: "vec3<f32>" },
2814
- uTime: { value: 0, type: "f32" },
2815
- uPulse: { value: params.pulse, type: "bool" },
2816
- uPulseSpeed: { value: params.pulseSpeed, type: "f32" }
2817
- }
2818
- }
2819
- });
2820
- },
2821
- updateUniforms(filter, params, elapsed) {
2822
- const uniforms = filter.resources?.uniforms?.uniforms;
2823
- if (!uniforms) return;
2824
- uniforms.uTime = elapsed / 1e3;
2825
- uniforms.uSpread = params.spread;
2826
- uniforms.uStrength = params.strength;
2827
- uniforms.uPulse = params.pulse;
2828
- uniforms.uPulseSpeed = params.pulseSpeed;
2829
- const hex = params.color;
2830
- uniforms.uGlowColor = hexToRgb(hex);
2831
- }
2832
- }
2833
- };
2834
- var ParticleBurstEffect = {
2835
- backend: "pixi",
2836
- subtype: "motion",
2837
- id: "particle-burst",
2838
- name: "Particle Burst",
2839
- category: "particle",
2840
- description: "Ticker-driven particle system. Emits from center, fades out on edges.",
2841
- tags: ["particle", "burst", "motion", "overlay"],
2842
- thumbnail: "https://clypra-worker-api.abdulkabirmusa.com/thumbnails/particle-burst.webp",
2843
- params: [
2844
- { key: "count", label: "Particle count", type: "range", value: 80, min: 10, max: 300, step: 10 },
2845
- { key: "speed", label: "Speed", type: "range", value: 2, min: 0.5, max: 8, step: 0.5 },
2846
- { key: "size", label: "Size", type: "range", value: 4, min: 1, max: 12, step: 1 },
2847
- { key: "color", label: "Particle color", type: "color", value: "#7C6FFF" },
2848
- { key: "fade", label: "Fade out", type: "toggle", value: true }
2849
- ],
2850
- mount(ctx) {
2851
- ctx._particleContainer = new import_pixi2.Container();
2852
- ctx.container.addChild(ctx._particleContainer);
2853
- const particles = [];
2854
- ctx._particles = particles;
2855
- const emit = () => {
2856
- const count = ctx.params.count;
2857
- while (particles.length < count) {
2858
- const angle = Math.random() * Math.PI * 2;
2859
- const speed = ctx.params.speed * (0.5 + Math.random());
2860
- const gfx = new import_pixi2.Graphics();
2861
- gfx.circle(0, 0, ctx.params.size);
2862
- gfx.fill({ color: hexToDec(ctx.params.color), alpha: 0.9 });
2863
- gfx.x = ctx.width / 2 + (Math.random() - 0.5) * ctx.width * 0.3;
2864
- gfx.y = ctx.height / 2 + (Math.random() - 0.5) * ctx.height * 0.3;
2865
- ctx._particleContainer.addChild(gfx);
2866
- const maxLife = 60 + Math.random() * 60;
2867
- particles.push({ gfx, vx: Math.cos(angle) * speed, vy: Math.sin(angle) * speed, life: maxLife, maxLife });
2868
- }
2869
- };
2870
- ctx._tickerFn = (ticker) => {
2871
- emit();
2872
- for (let i = particles.length - 1; i >= 0; i--) {
2873
- const p = particles[i];
2874
- p.gfx.x += p.vx;
2875
- p.gfx.y += p.vy;
2876
- p.life -= ticker.deltaTime;
2877
- if (ctx.params.fade) {
2878
- p.gfx.alpha = Math.max(0, p.life / p.maxLife);
2879
- }
2880
- if (p.life <= 0 || p.gfx.x < -20 || p.gfx.x > ctx.width + 20 || p.gfx.y < -20 || p.gfx.y > ctx.height + 20) {
2881
- p.life = p.maxLife;
2882
- p.gfx.x = ctx.width / 2 + (Math.random() - 0.5) * ctx.width * 0.3;
2883
- p.gfx.y = ctx.height / 2 + (Math.random() - 0.5) * ctx.height * 0.3;
2884
- p.gfx.alpha = 1;
2885
- }
2886
- }
2887
- };
2888
- ctx.ticker.add(ctx._tickerFn);
2889
- },
2890
- unmount(ctx) {
2891
- if (ctx._tickerFn) {
2892
- ctx.ticker.remove(ctx._tickerFn);
2893
- }
2894
- if (ctx._particleContainer) {
2895
- ctx.container.removeChild(ctx._particleContainer);
2896
- ctx._particleContainer.destroy({ children: true });
2897
- }
2898
- },
2899
- onParamChange(ctx, key, value) {
2900
- if (key === "color") {
2901
- for (const p of ctx._particles ?? []) {
2902
- p.gfx.clear();
2903
- p.gfx.circle(0, 0, ctx.params.size);
2904
- p.gfx.fill({ color: hexToDec(value), alpha: 0.9 });
2905
- }
2906
- }
2907
- }
2908
- };
2909
- var VHSCompositeEffect = {
2910
- backend: "pixi",
2911
- subtype: "composite",
2912
- id: "vhs-composite",
2913
- name: "VHS",
2914
- category: "retro",
2915
- description: "Classic VHS look: scanlines + noise shader with animated glitch band overlay.",
2916
- tags: ["vhs", "retro", "glitch", "scanlines", "noise", "composite"],
2917
- thumbnail: "https://clypra-worker-api.abdulkabirmusa.com/thumbnails/vhs-composite.webp",
2918
- params: [
2919
- { key: "noise", label: "Noise", type: "range", value: 0.08, min: 0, max: 0.3, step: 0.01 },
2920
- { key: "scanlines", label: "Scanlines", type: "toggle", value: true },
2921
- { key: "lineAlpha", label: "Line alpha", type: "range", value: 0.25, min: 0, max: 1, step: 0.05 },
2922
- { key: "hShift", label: "H-shift", type: "range", value: 3e-3, min: 0, max: 0.02, step: 1e-3 },
2923
- { key: "bandSpeed", label: "Band speed", type: "range", value: 1.2, min: 0.1, max: 5, step: 0.1 },
2924
- { key: "bandAlpha", label: "Band alpha", type: "range", value: 0.35, min: 0, max: 1, step: 0.05 }
2925
- ],
2926
- // ── Filter part ──────────────────────────────────────────────────────────
2927
- filterSpec: {
2928
- create(params) {
2929
- const fragment = `
2930
- in vec2 vTextureCoord;
2931
- out vec4 finalColor;
2932
-
2933
- uniform sampler2D uTexture;
2934
- uniform float uNoise;
2935
- uniform bool uScanlines;
2936
- uniform float uLineAlpha;
2937
- uniform float uHShift;
2938
- uniform float uTime;
2939
-
2940
- float rand(vec2 co) {
2941
- return fract(sin(dot(co, vec2(12.9898, 78.233))) * 43758.5453);
2942
- }
2943
-
2944
- void main(void) {
2945
- vec2 uv = vTextureCoord;
2946
-
2947
- // Horizontal shift on random bands
2948
- float bandY = floor(uv.y * 240.0) / 240.0;
2949
- float shift = (rand(vec2(bandY, floor(uTime * 15.0))) - 0.5) * uHShift;
2950
- uv.x += shift;
2951
-
2952
- vec4 color = texture(uTexture, clamp(uv, 0.0, 1.0));
2953
-
2954
- // Noise grain
2955
- float grain = rand(uv + uTime) * uNoise;
2956
- color.rgb += grain;
2957
-
2958
- // Scanlines
2959
- if (uScanlines) {
2960
- float line = step(0.5, fract(vTextureCoord.y * 240.0));
2961
- color.rgb = mix(color.rgb, color.rgb * 0.7, line * uLineAlpha);
2962
- }
2963
-
2964
- // Slight desaturation for the washed-out VHS look
2965
- float luma = dot(color.rgb, vec3(0.299, 0.587, 0.114));
2966
- color.rgb = mix(vec3(luma), color.rgb, 0.75);
2967
-
2968
- finalColor = color;
2969
- }
2970
- `;
2971
- return import_pixi2.Filter.from({
2972
- gl: { vertex: DEFAULT_VERTEX_SHADER, fragment },
2973
- resources: {
2974
- uniforms: {
2975
- uNoise: { value: params.noise, type: "f32" },
2976
- uScanlines: { value: params.scanlines, type: "bool" },
2977
- uLineAlpha: { value: params.lineAlpha, type: "f32" },
2978
- uHShift: { value: params.hShift, type: "f32" },
2979
- uTime: { value: 0, type: "f32" }
2980
- }
2981
- }
2982
- });
2983
- },
2984
- updateUniforms(filter, params, elapsed) {
2985
- const uniforms = filter.resources?.uniforms?.uniforms;
2986
- if (!uniforms) return;
2987
- uniforms.uTime = elapsed / 1e3;
2988
- uniforms.uNoise = params.noise;
2989
- uniforms.uScanlines = params.scanlines;
2990
- uniforms.uLineAlpha = params.lineAlpha;
2991
- uniforms.uHShift = params.hShift;
2992
- }
2993
- },
2994
- // ── Motion part (animated glitch band) ───────────────────────────────────
2995
- mount(ctx) {
2996
- const band = new import_pixi2.Graphics();
2997
- ctx._vhsBand = band;
2998
- ctx._bandY = Math.random() * ctx.height;
2999
- const draw = () => {
3000
- band.clear();
3001
- band.rect(0, ctx._bandY, ctx.width, 8);
3002
- band.fill({ color: 16777215, alpha: ctx.params.bandAlpha });
3003
- };
3004
- draw();
3005
- ctx.container.addChild(band);
3006
- ctx._tickerFn = (ticker) => {
3007
- ctx._bandY += ctx.params.bandSpeed * ticker.deltaTime;
3008
- if (ctx._bandY > ctx.height + 20) ctx._bandY = -20;
3009
- draw();
3010
- };
3011
- ctx.ticker.add(ctx._tickerFn);
3012
- },
3013
- unmount(ctx) {
3014
- if (ctx._tickerFn) ctx.ticker.remove(ctx._tickerFn);
3015
- if (ctx._vhsBand) {
3016
- ctx.container.removeChild(ctx._vhsBand);
3017
- ctx._vhsBand.destroy();
3018
- }
3019
- },
3020
- onParamChange(ctx, key) {
3021
- }
3022
- };
3023
-
3024
2200
  // src/videoEffects/renderers/camera/index.ts
3025
2201
  var camera_exports = {};
3026
2202
  __export(camera_exports, {
@@ -3080,9 +2256,7 @@ function renderDolly(ctx, params, intensity, time) {
3080
2256
  EffectEngine,
3081
2257
  EffectGraph,
3082
2258
  EffectRenderer,
3083
- ExamplePixiEffects,
3084
2259
  LightEffects,
3085
- PixiRenderer,
3086
2260
  addNoise,
3087
2261
  blendColors,
3088
2262
  clearCanvas,
@@ -3097,11 +2271,6 @@ function renderDolly(ctx, params, intensity, time) {
3097
2271
  getEffectsByCategory,
3098
2272
  getEffectsByCategoryForApi,
3099
2273
  hexToRgba,
3100
- isCanvas2DEffect,
3101
- isCompositeEffect,
3102
- isFilterEffect,
3103
- isMotionEffect,
3104
- isPixiEffect,
3105
2274
  rgbaToComponents,
3106
2275
  searchEffects,
3107
2276
  searchEffectsForApi,