@motion-script/web 0.1.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.
- package/README.md +47 -0
- package/dist/audio/player.d.ts +43 -0
- package/dist/audio/player.d.ts.map +1 -0
- package/dist/audio/player.js +165 -0
- package/dist/audio/player.js.map +1 -0
- package/dist/effects/bloom.d.ts +19 -0
- package/dist/effects/bloom.d.ts.map +1 -0
- package/dist/effects/bloom.js +64 -0
- package/dist/effects/bloom.js.map +1 -0
- package/dist/effects/blur.d.ts +8 -0
- package/dist/effects/blur.d.ts.map +1 -0
- package/dist/effects/blur.js +12 -0
- package/dist/effects/blur.js.map +1 -0
- package/dist/effects/bulge-pinch.d.ts +20 -0
- package/dist/effects/bulge-pinch.d.ts.map +1 -0
- package/dist/effects/bulge-pinch.js +86 -0
- package/dist/effects/bulge-pinch.js.map +1 -0
- package/dist/effects/chromatic-aberration.d.ts +19 -0
- package/dist/effects/chromatic-aberration.d.ts.map +1 -0
- package/dist/effects/chromatic-aberration.js +59 -0
- package/dist/effects/chromatic-aberration.js.map +1 -0
- package/dist/effects/effect.d.ts +32 -0
- package/dist/effects/effect.d.ts.map +1 -0
- package/dist/effects/effect.js +22 -0
- package/dist/effects/effect.js.map +1 -0
- package/dist/effects/grayscale.d.ts +12 -0
- package/dist/effects/grayscale.d.ts.map +1 -0
- package/dist/effects/grayscale.js +31 -0
- package/dist/effects/grayscale.js.map +1 -0
- package/dist/effects/index.d.ts +13 -0
- package/dist/effects/index.d.ts.map +1 -0
- package/dist/effects/index.js +13 -0
- package/dist/effects/index.js.map +1 -0
- package/dist/effects/pixelate.d.ts +23 -0
- package/dist/effects/pixelate.d.ts.map +1 -0
- package/dist/effects/pixelate.js +37 -0
- package/dist/effects/pixelate.js.map +1 -0
- package/dist/effects/registry.d.ts +17 -0
- package/dist/effects/registry.d.ts.map +1 -0
- package/dist/effects/registry.js +56 -0
- package/dist/effects/registry.js.map +1 -0
- package/dist/effects/sksl-cache.d.ts +6 -0
- package/dist/effects/sksl-cache.d.ts.map +1 -0
- package/dist/effects/sksl-cache.js +21 -0
- package/dist/effects/sksl-cache.js.map +1 -0
- package/dist/effects/sksl-layer.d.ts +30 -0
- package/dist/effects/sksl-layer.d.ts.map +1 -0
- package/dist/effects/sksl-layer.js +82 -0
- package/dist/effects/sksl-layer.js.map +1 -0
- package/dist/effects/texture.d.ts +31 -0
- package/dist/effects/texture.d.ts.map +1 -0
- package/dist/effects/texture.js +66 -0
- package/dist/effects/texture.js.map +1 -0
- package/dist/effects/vintage.d.ts +20 -0
- package/dist/effects/vintage.d.ts.map +1 -0
- package/dist/effects/vintage.js +47 -0
- package/dist/effects/vintage.js.map +1 -0
- package/dist/effects/zoom.d.ts +20 -0
- package/dist/effects/zoom.d.ts.map +1 -0
- package/dist/effects/zoom.js +65 -0
- package/dist/effects/zoom.js.map +1 -0
- package/dist/exporter.d.ts +24 -0
- package/dist/exporter.d.ts.map +1 -0
- package/dist/exporter.js +177 -0
- package/dist/exporter.js.map +1 -0
- package/dist/fills/conic-gradient.d.ts +12 -0
- package/dist/fills/conic-gradient.d.ts.map +1 -0
- package/dist/fills/conic-gradient.js +44 -0
- package/dist/fills/conic-gradient.js.map +1 -0
- package/dist/fills/filters/alpha.d.ts +9 -0
- package/dist/fills/filters/alpha.d.ts.map +1 -0
- package/dist/fills/filters/alpha.js +21 -0
- package/dist/fills/filters/alpha.js.map +1 -0
- package/dist/fills/filters/blur.d.ts +9 -0
- package/dist/fills/filters/blur.d.ts.map +1 -0
- package/dist/fills/filters/blur.js +12 -0
- package/dist/fills/filters/blur.js.map +1 -0
- package/dist/fills/filters/color-adjustment.d.ts +14 -0
- package/dist/fills/filters/color-adjustment.d.ts.map +1 -0
- package/dist/fills/filters/color-adjustment.js +147 -0
- package/dist/fills/filters/color-adjustment.js.map +1 -0
- package/dist/fills/filters/color-matrix.d.ts +9 -0
- package/dist/fills/filters/color-matrix.d.ts.map +1 -0
- package/dist/fills/filters/color-matrix.js +14 -0
- package/dist/fills/filters/color-matrix.js.map +1 -0
- package/dist/fills/filters/curves.d.ts +9 -0
- package/dist/fills/filters/curves.d.ts.map +1 -0
- package/dist/fills/filters/curves.js +89 -0
- package/dist/fills/filters/curves.js.map +1 -0
- package/dist/fills/filters/exposure.d.ts +9 -0
- package/dist/fills/filters/exposure.d.ts.map +1 -0
- package/dist/fills/filters/exposure.js +22 -0
- package/dist/fills/filters/exposure.js.map +1 -0
- package/dist/fills/filters/filter.d.ts +17 -0
- package/dist/fills/filters/filter.d.ts.map +1 -0
- package/dist/fills/filters/filter.js +16 -0
- package/dist/fills/filters/filter.js.map +1 -0
- package/dist/fills/filters/grayscale.d.ts +9 -0
- package/dist/fills/filters/grayscale.d.ts.map +1 -0
- package/dist/fills/filters/grayscale.js +25 -0
- package/dist/fills/filters/grayscale.js.map +1 -0
- package/dist/fills/filters/registry.d.ts +16 -0
- package/dist/fills/filters/registry.d.ts.map +1 -0
- package/dist/fills/filters/registry.js +50 -0
- package/dist/fills/filters/registry.js.map +1 -0
- package/dist/fills/gradient-cache.d.ts +29 -0
- package/dist/fills/gradient-cache.d.ts.map +1 -0
- package/dist/fills/gradient-cache.js +57 -0
- package/dist/fills/gradient-cache.js.map +1 -0
- package/dist/fills/handler.d.ts +49 -0
- package/dist/fills/handler.d.ts.map +1 -0
- package/dist/fills/handler.js +172 -0
- package/dist/fills/handler.js.map +1 -0
- package/dist/fills/image.d.ts +34 -0
- package/dist/fills/image.d.ts.map +1 -0
- package/dist/fills/image.js +91 -0
- package/dist/fills/image.js.map +1 -0
- package/dist/fills/linear-gradient.d.ts +12 -0
- package/dist/fills/linear-gradient.d.ts.map +1 -0
- package/dist/fills/linear-gradient.js +48 -0
- package/dist/fills/linear-gradient.js.map +1 -0
- package/dist/fills/noise.d.ts +11 -0
- package/dist/fills/noise.d.ts.map +1 -0
- package/dist/fills/noise.js +82 -0
- package/dist/fills/noise.js.map +1 -0
- package/dist/fills/radial-gradient.d.ts +9 -0
- package/dist/fills/radial-gradient.d.ts.map +1 -0
- package/dist/fills/radial-gradient.js +43 -0
- package/dist/fills/radial-gradient.js.map +1 -0
- package/dist/fills/registry.d.ts +10 -0
- package/dist/fills/registry.d.ts.map +1 -0
- package/dist/fills/registry.js +34 -0
- package/dist/fills/registry.js.map +1 -0
- package/dist/fills/renderer.d.ts +24 -0
- package/dist/fills/renderer.d.ts.map +1 -0
- package/dist/fills/renderer.js +5 -0
- package/dist/fills/renderer.js.map +1 -0
- package/dist/fills/solid.d.ts +7 -0
- package/dist/fills/solid.d.ts.map +1 -0
- package/dist/fills/solid.js +13 -0
- package/dist/fills/solid.js.map +1 -0
- package/dist/fills/stripe.d.ts +7 -0
- package/dist/fills/stripe.d.ts.map +1 -0
- package/dist/fills/stripe.js +85 -0
- package/dist/fills/stripe.js.map +1 -0
- package/dist/fills/video.d.ts +6 -0
- package/dist/fills/video.d.ts.map +1 -0
- package/dist/fills/video.js +14 -0
- package/dist/fills/video.js.map +1 -0
- package/dist/font-style.d.ts +23 -0
- package/dist/font-style.d.ts.map +1 -0
- package/dist/font-style.js +34 -0
- package/dist/font-style.js.map +1 -0
- package/dist/getter.d.ts +9 -0
- package/dist/getter.d.ts.map +1 -0
- package/dist/getter.js +26 -0
- package/dist/getter.js.map +1 -0
- package/dist/index.d.ts +9 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +11 -0
- package/dist/index.js.map +1 -0
- package/dist/master-clock.d.ts +42 -0
- package/dist/master-clock.d.ts.map +1 -0
- package/dist/master-clock.js +134 -0
- package/dist/master-clock.js.map +1 -0
- package/dist/measure-scope.d.ts +14 -0
- package/dist/measure-scope.d.ts.map +1 -0
- package/dist/measure-scope.js +29 -0
- package/dist/measure-scope.js.map +1 -0
- package/dist/render-context.d.ts +107 -0
- package/dist/render-context.d.ts.map +1 -0
- package/dist/render-context.js +940 -0
- package/dist/render-context.js.map +1 -0
- package/dist/shapes/alpha-contour.d.ts +27 -0
- package/dist/shapes/alpha-contour.d.ts.map +1 -0
- package/dist/shapes/alpha-contour.js +330 -0
- package/dist/shapes/alpha-contour.js.map +1 -0
- package/dist/shapes/base.d.ts +46 -0
- package/dist/shapes/base.d.ts.map +1 -0
- package/dist/shapes/base.js +95 -0
- package/dist/shapes/base.js.map +1 -0
- package/dist/shapes/boolean.d.ts +28 -0
- package/dist/shapes/boolean.d.ts.map +1 -0
- package/dist/shapes/boolean.js +90 -0
- package/dist/shapes/boolean.js.map +1 -0
- package/dist/shapes/ellipse.d.ts +32 -0
- package/dist/shapes/ellipse.d.ts.map +1 -0
- package/dist/shapes/ellipse.js +50 -0
- package/dist/shapes/ellipse.js.map +1 -0
- package/dist/shapes/image.d.ts +66 -0
- package/dist/shapes/image.d.ts.map +1 -0
- package/dist/shapes/image.js +214 -0
- package/dist/shapes/image.js.map +1 -0
- package/dist/shapes/index.d.ts +67 -0
- package/dist/shapes/index.d.ts.map +1 -0
- package/dist/shapes/index.js +297 -0
- package/dist/shapes/index.js.map +1 -0
- package/dist/shapes/line.d.ts +25 -0
- package/dist/shapes/line.d.ts.map +1 -0
- package/dist/shapes/line.js +87 -0
- package/dist/shapes/line.js.map +1 -0
- package/dist/shapes/mask.d.ts +28 -0
- package/dist/shapes/mask.d.ts.map +1 -0
- package/dist/shapes/mask.js +106 -0
- package/dist/shapes/mask.js.map +1 -0
- package/dist/shapes/paragraph-layout.d.ts +64 -0
- package/dist/shapes/paragraph-layout.d.ts.map +1 -0
- package/dist/shapes/paragraph-layout.js +156 -0
- package/dist/shapes/paragraph-layout.js.map +1 -0
- package/dist/shapes/path.d.ts +29 -0
- package/dist/shapes/path.d.ts.map +1 -0
- package/dist/shapes/path.js +71 -0
- package/dist/shapes/path.js.map +1 -0
- package/dist/shapes/polygon.d.ts +33 -0
- package/dist/shapes/polygon.d.ts.map +1 -0
- package/dist/shapes/polygon.js +86 -0
- package/dist/shapes/polygon.js.map +1 -0
- package/dist/shapes/polygram.d.ts +34 -0
- package/dist/shapes/polygram.d.ts.map +1 -0
- package/dist/shapes/polygram.js +90 -0
- package/dist/shapes/polygram.js.map +1 -0
- package/dist/shapes/rect.d.ts +41 -0
- package/dist/shapes/rect.d.ts.map +1 -0
- package/dist/shapes/rect.js +111 -0
- package/dist/shapes/rect.js.map +1 -0
- package/dist/shapes/richtext.d.ts +28 -0
- package/dist/shapes/richtext.d.ts.map +1 -0
- package/dist/shapes/richtext.js +32 -0
- package/dist/shapes/richtext.js.map +1 -0
- package/dist/shapes/shape-handler.d.ts +79 -0
- package/dist/shapes/shape-handler.d.ts.map +1 -0
- package/dist/shapes/shape-handler.js +304 -0
- package/dist/shapes/shape-handler.js.map +1 -0
- package/dist/shapes/text.d.ts +13 -0
- package/dist/shapes/text.d.ts.map +1 -0
- package/dist/shapes/text.js +67 -0
- package/dist/shapes/text.js.map +1 -0
- package/dist/shapes/trim.d.ts +10 -0
- package/dist/shapes/trim.d.ts.map +1 -0
- package/dist/shapes/trim.js +49 -0
- package/dist/shapes/trim.js.map +1 -0
- package/dist/storage-adapter.d.ts +56 -0
- package/dist/storage-adapter.d.ts.map +1 -0
- package/dist/storage-adapter.js +188 -0
- package/dist/storage-adapter.js.map +1 -0
- package/dist/stroke/index.d.ts +34 -0
- package/dist/stroke/index.d.ts.map +1 -0
- package/dist/stroke/index.js +360 -0
- package/dist/stroke/index.js.map +1 -0
- package/dist/stroke/stroke-handler.d.ts +45 -0
- package/dist/stroke/stroke-handler.d.ts.map +1 -0
- package/dist/stroke/stroke-handler.js +371 -0
- package/dist/stroke/stroke-handler.js.map +1 -0
- package/dist/video/extract.d.ts +54 -0
- package/dist/video/extract.d.ts.map +1 -0
- package/dist/video/extract.js +192 -0
- package/dist/video/extract.js.map +1 -0
- package/dist/video/extract.worker.d.ts +50 -0
- package/dist/video/extract.worker.d.ts.map +1 -0
- package/dist/video/extract.worker.js +224 -0
- package/dist/video/extract.worker.js.map +1 -0
- package/package.json +57 -0
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Abstract base for CanvasKit effect renderers.
|
|
3
|
+
*
|
|
4
|
+
* Subclasses implement `makeImageFilter` using either built-in CanvasKit filters
|
|
5
|
+
* (ImageFilter.MakeBlur, ColorFilter.MakeMatrix, etc.) or custom SkSL shaders
|
|
6
|
+
* via CanvasKit.RuntimeEffect.Make(sksl).
|
|
7
|
+
*
|
|
8
|
+
* The returned ImageFilter is applied as a saveLayer paint wrapping the node's
|
|
9
|
+
* draw calls, so it composites the entire node before applying the filter.
|
|
10
|
+
*/
|
|
11
|
+
export class CanvasKitEffect {
|
|
12
|
+
type;
|
|
13
|
+
constructor(type) {
|
|
14
|
+
this.type = type;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Clean up any persistent CanvasKit objects (e.g. cached RuntimeEffect).
|
|
18
|
+
* Called when the draw context is disposed.
|
|
19
|
+
*/
|
|
20
|
+
dispose() { }
|
|
21
|
+
}
|
|
22
|
+
//# sourceMappingURL=effect.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"effect.js","sourceRoot":"","sources":["../../src/effects/effect.ts"],"names":[],"mappings":"AAGA;;;;;;;;;GASG;AACH,MAAM,OAAgB,eAAe;IACxB,IAAI,CAAS;IAEtB,YAAY,IAAY;QACpB,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;IACrB,CAAC;IAaD;;;OAGG;IACH,OAAO,KAAW,CAAC;CACtB"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { CanvasKit } from "@motion-script/canvaskit";
|
|
2
|
+
import { CanvasKitEffect } from "./effect";
|
|
3
|
+
import { type GrayScaleEffect } from "@motion-script/core";
|
|
4
|
+
/**
|
|
5
|
+
* Desaturation via a single colour-matrix ImageFilter, lerped between identity
|
|
6
|
+
* (amount=0) and full BT.709 luminance grayscale (amount=1).
|
|
7
|
+
*/
|
|
8
|
+
export declare class GrayscaleCanvasKitEffect extends CanvasKitEffect<GrayScaleEffect> {
|
|
9
|
+
constructor();
|
|
10
|
+
makeImageFilter(effect: GrayScaleEffect, ck: CanvasKit): any;
|
|
11
|
+
}
|
|
12
|
+
//# sourceMappingURL=grayscale.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"grayscale.d.ts","sourceRoot":"","sources":["../../src/effects/grayscale.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,0BAA0B,CAAC;AAC1D,OAAO,EAAE,eAAe,EAAE,MAAM,UAAU,CAAC;AAC3C,OAAO,EAAE,KAAK,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAO3D;;;GAGG;AACH,qBAAa,wBAAyB,SAAQ,eAAe,CAAC,eAAe,CAAC;;IAK1E,eAAe,CAAC,MAAM,EAAE,eAAe,EAAE,EAAE,EAAE,SAAS,GAAG,GAAG;CAkB/D"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { CanvasKitEffect } from "./effect";
|
|
2
|
+
// ITU-R BT.709 luminance weights
|
|
3
|
+
const LR = 0.2126;
|
|
4
|
+
const LG = 0.7152;
|
|
5
|
+
const LB = 0.0722;
|
|
6
|
+
/**
|
|
7
|
+
* Desaturation via a single colour-matrix ImageFilter, lerped between identity
|
|
8
|
+
* (amount=0) and full BT.709 luminance grayscale (amount=1).
|
|
9
|
+
*/
|
|
10
|
+
export class GrayscaleCanvasKitEffect extends CanvasKitEffect {
|
|
11
|
+
constructor() {
|
|
12
|
+
super("grayscale");
|
|
13
|
+
}
|
|
14
|
+
makeImageFilter(effect, ck) {
|
|
15
|
+
const a = Math.max(0, Math.min(1, effect.amount));
|
|
16
|
+
// 4×5 row-major color matrix (Skia format):
|
|
17
|
+
// [R'] = [r0..r4] * [R, G, B, A, 1]
|
|
18
|
+
// Interpolates between identity (a=0) and full luminance grayscale (a=1).
|
|
19
|
+
const matrix = [
|
|
20
|
+
1 - a + a * LR, a * LG, a * LB, 0, 0,
|
|
21
|
+
a * LR, 1 - a + a * LG, a * LB, 0, 0,
|
|
22
|
+
a * LR, a * LG, 1 - a + a * LB, 0, 0,
|
|
23
|
+
0, 0, 0, 1, 0,
|
|
24
|
+
];
|
|
25
|
+
const colorFilter = ck.ColorFilter.MakeMatrix(matrix);
|
|
26
|
+
const imageFilter = ck.ImageFilter.MakeColorFilter(colorFilter, null);
|
|
27
|
+
colorFilter.delete();
|
|
28
|
+
return imageFilter;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
//# sourceMappingURL=grayscale.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"grayscale.js","sourceRoot":"","sources":["../../src/effects/grayscale.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,eAAe,EAAE,MAAM,UAAU,CAAC;AAG3C,iCAAiC;AACjC,MAAM,EAAE,GAAG,MAAM,CAAC;AAClB,MAAM,EAAE,GAAG,MAAM,CAAC;AAClB,MAAM,EAAE,GAAG,MAAM,CAAC;AAElB;;;GAGG;AACH,MAAM,OAAO,wBAAyB,SAAQ,eAAgC;IAC1E;QACI,KAAK,CAAC,WAAW,CAAC,CAAC;IACvB,CAAC;IAED,eAAe,CAAC,MAAuB,EAAE,EAAa;QAClD,MAAM,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC;QAElD,4CAA4C;QAC5C,oCAAoC;QACpC,0EAA0E;QAC1E,MAAM,MAAM,GAAG;YACX,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,EAAE,EAAE,CAAC,EAAE,CAAC;YACpC,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,EAAE,EAAE,CAAC,EAAE,CAAC;YACpC,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,EAAE,EAAE,CAAC,EAAE,CAAC;YACpC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC;SAChB,CAAC;QAEF,MAAM,WAAW,GAAG,EAAE,CAAC,WAAW,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC;QACtD,MAAM,WAAW,GAAG,EAAE,CAAC,WAAW,CAAC,eAAe,CAAC,WAAW,EAAE,IAAI,CAAC,CAAC;QACtE,WAAW,CAAC,MAAM,EAAE,CAAC;QACrB,OAAO,WAAW,CAAC;IACvB,CAAC;CACJ"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/** CanvasKit-backed implementations of @motion-script/core's scene effects (post-processing image filters). */
|
|
2
|
+
export { CanvasKitEffect } from "./effect";
|
|
3
|
+
export { CanvasKitEffectRegistry } from "./registry";
|
|
4
|
+
export { BlurCanvasKitEffect } from "./blur";
|
|
5
|
+
export { GrayscaleCanvasKitEffect } from "./grayscale";
|
|
6
|
+
export { PixelateCanvasKitEffect } from "./pixelate";
|
|
7
|
+
export { TextureCanvasKitEffect } from "./texture";
|
|
8
|
+
export { BloomCanvasKitEffect } from "./bloom";
|
|
9
|
+
export { VintageCanvasKitEffect } from "./vintage";
|
|
10
|
+
export { ChromaticAberrationCanvasKitEffect } from "./chromatic-aberration";
|
|
11
|
+
export { SkSLLayerEffect } from "./sksl-layer";
|
|
12
|
+
export { getOrCompileSkSL, disposeSkSLCache } from "./sksl-cache";
|
|
13
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/effects/index.ts"],"names":[],"mappings":"AAAA,+GAA+G;AAC/G,OAAO,EAAE,eAAe,EAAE,MAAM,UAAU,CAAC;AAC3C,OAAO,EAAE,uBAAuB,EAAE,MAAM,YAAY,CAAC;AACrD,OAAO,EAAE,mBAAmB,EAAE,MAAM,QAAQ,CAAC;AAC7C,OAAO,EAAE,wBAAwB,EAAE,MAAM,aAAa,CAAC;AACvD,OAAO,EAAE,uBAAuB,EAAE,MAAM,YAAY,CAAC;AACrD,OAAO,EAAE,sBAAsB,EAAE,MAAM,WAAW,CAAC;AACnD,OAAO,EAAE,oBAAoB,EAAE,MAAM,SAAS,CAAC;AAC/C,OAAO,EAAE,sBAAsB,EAAE,MAAM,WAAW,CAAC;AACnD,OAAO,EAAE,kCAAkC,EAAE,MAAM,wBAAwB,CAAC;AAC5E,OAAO,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAC/C,OAAO,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/** CanvasKit-backed implementations of @motion-script/core's scene effects (post-processing image filters). */
|
|
2
|
+
export { CanvasKitEffect } from "./effect";
|
|
3
|
+
export { CanvasKitEffectRegistry } from "./registry";
|
|
4
|
+
export { BlurCanvasKitEffect } from "./blur";
|
|
5
|
+
export { GrayscaleCanvasKitEffect } from "./grayscale";
|
|
6
|
+
export { PixelateCanvasKitEffect } from "./pixelate";
|
|
7
|
+
export { TextureCanvasKitEffect } from "./texture";
|
|
8
|
+
export { BloomCanvasKitEffect } from "./bloom";
|
|
9
|
+
export { VintageCanvasKitEffect } from "./vintage";
|
|
10
|
+
export { ChromaticAberrationCanvasKitEffect } from "./chromatic-aberration";
|
|
11
|
+
export { SkSLLayerEffect } from "./sksl-layer";
|
|
12
|
+
export { getOrCompileSkSL, disposeSkSLCache } from "./sksl-cache";
|
|
13
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/effects/index.ts"],"names":[],"mappings":"AAAA,+GAA+G;AAC/G,OAAO,EAAE,eAAe,EAAE,MAAM,UAAU,CAAC;AAC3C,OAAO,EAAE,uBAAuB,EAAE,MAAM,YAAY,CAAC;AACrD,OAAO,EAAE,mBAAmB,EAAE,MAAM,QAAQ,CAAC;AAC7C,OAAO,EAAE,wBAAwB,EAAE,MAAM,aAAa,CAAC;AACvD,OAAO,EAAE,uBAAuB,EAAE,MAAM,YAAY,CAAC;AACrD,OAAO,EAAE,sBAAsB,EAAE,MAAM,WAAW,CAAC;AACnD,OAAO,EAAE,oBAAoB,EAAE,MAAM,SAAS,CAAC;AAC/C,OAAO,EAAE,sBAAsB,EAAE,MAAM,WAAW,CAAC;AACnD,OAAO,EAAE,kCAAkC,EAAE,MAAM,wBAAwB,CAAC;AAC5E,OAAO,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAC/C,OAAO,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { CanvasKit } from "@motion-script/canvaskit";
|
|
2
|
+
import { CanvasKitEffect } from "./effect";
|
|
3
|
+
import { type PixelateEffect } from "@motion-script/core";
|
|
4
|
+
export declare class PixelateCanvasKitEffect extends CanvasKitEffect<PixelateEffect> {
|
|
5
|
+
constructor();
|
|
6
|
+
/**
|
|
7
|
+
* Pixelation via two MakeMatrixTransform passes:
|
|
8
|
+
* 1. Downsample with nearest-neighbor (every Nth pixel sampled → coarse grid)
|
|
9
|
+
* 2. Upsample with nearest-neighbor (each coarse pixel blown up to an NxN block)
|
|
10
|
+
*
|
|
11
|
+
* horizontalBlocks / verticalBlocks are amounts in 0-1.
|
|
12
|
+
* 0 → blockSize = 1 (no pixelation)
|
|
13
|
+
* 1 → blockSize = MAX (one block large enough to cover most nodes)
|
|
14
|
+
*
|
|
15
|
+
* Mapping is exponential so small amounts read as visibly chunky without
|
|
16
|
+
* jumping straight to mush. MAX is capped well below the surface dimensions
|
|
17
|
+
* because at extreme blockSizes the two matrix transforms sample far outside
|
|
18
|
+
* the layer's drawn content (which is anchored at the layer origin, not
|
|
19
|
+
* centered) and the chain produces a fully-transparent result.
|
|
20
|
+
*/
|
|
21
|
+
makeImageFilter(effect: PixelateEffect, ck: CanvasKit, _width: number, _height: number): any;
|
|
22
|
+
}
|
|
23
|
+
//# sourceMappingURL=pixelate.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pixelate.d.ts","sourceRoot":"","sources":["../../src/effects/pixelate.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,0BAA0B,CAAC;AAC1D,OAAO,EAAE,eAAe,EAAE,MAAM,UAAU,CAAC;AAC3C,OAAO,EAAE,KAAK,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAE1D,qBAAa,uBAAwB,SAAQ,eAAe,CAAC,cAAc,CAAC;;IAKxE;;;;;;;;;;;;;;OAcG;IACH,eAAe,CAAC,MAAM,EAAE,cAAc,EAAE,EAAE,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,GAAG;CA2B/F"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { CanvasKitEffect } from "./effect";
|
|
2
|
+
export class PixelateCanvasKitEffect extends CanvasKitEffect {
|
|
3
|
+
constructor() {
|
|
4
|
+
super("pixelate");
|
|
5
|
+
}
|
|
6
|
+
/**
|
|
7
|
+
* Pixelation via two MakeMatrixTransform passes:
|
|
8
|
+
* 1. Downsample with nearest-neighbor (every Nth pixel sampled → coarse grid)
|
|
9
|
+
* 2. Upsample with nearest-neighbor (each coarse pixel blown up to an NxN block)
|
|
10
|
+
*
|
|
11
|
+
* horizontalBlocks / verticalBlocks are amounts in 0-1.
|
|
12
|
+
* 0 → blockSize = 1 (no pixelation)
|
|
13
|
+
* 1 → blockSize = MAX (one block large enough to cover most nodes)
|
|
14
|
+
*
|
|
15
|
+
* Mapping is exponential so small amounts read as visibly chunky without
|
|
16
|
+
* jumping straight to mush. MAX is capped well below the surface dimensions
|
|
17
|
+
* because at extreme blockSizes the two matrix transforms sample far outside
|
|
18
|
+
* the layer's drawn content (which is anchored at the layer origin, not
|
|
19
|
+
* centered) and the chain produces a fully-transparent result.
|
|
20
|
+
*/
|
|
21
|
+
makeImageFilter(effect, ck, _width, _height) {
|
|
22
|
+
const MAX_BLOCK = 256;
|
|
23
|
+
const hAmount = Math.max(0, Math.min(1, effect.horizontalBlocks));
|
|
24
|
+
const vAmount = Math.max(0, Math.min(1, effect.verticalBlocks));
|
|
25
|
+
const blockW = Math.max(1, Math.pow(MAX_BLOCK, hAmount));
|
|
26
|
+
const blockH = Math.max(1, Math.pow(MAX_BLOCK, vAmount));
|
|
27
|
+
const nearest = { filter: ck.FilterMode.Nearest };
|
|
28
|
+
// Step 1: output(x,y) = layer(x * blockW, y * blockH) — coarse subsampling
|
|
29
|
+
const step1 = ck.ImageFilter.MakeMatrixTransform([1 / blockW, 0, 0, 0, 1 / blockH, 0, 0, 0, 1], nearest, null);
|
|
30
|
+
// Step 2: output(x,y) = step1(x / blockW, y / blockH) — nearest-neighbor upscale
|
|
31
|
+
// Pixels 0..blockW-1 all round to step1(0) → same block color.
|
|
32
|
+
const step2 = ck.ImageFilter.MakeMatrixTransform([blockW, 0, 0, 0, blockH, 0, 0, 0, 1], nearest, step1);
|
|
33
|
+
step1.delete();
|
|
34
|
+
return step2;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
//# sourceMappingURL=pixelate.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pixelate.js","sourceRoot":"","sources":["../../src/effects/pixelate.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,eAAe,EAAE,MAAM,UAAU,CAAC;AAG3C,MAAM,OAAO,uBAAwB,SAAQ,eAA+B;IACxE;QACI,KAAK,CAAC,UAAU,CAAC,CAAC;IACtB,CAAC;IAED;;;;;;;;;;;;;;OAcG;IACH,eAAe,CAAC,MAAsB,EAAE,EAAa,EAAE,MAAc,EAAE,OAAe;QAClF,MAAM,SAAS,GAAG,GAAG,CAAC;QACtB,MAAM,OAAO,GAAG,IAAI,CA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./effect";
|
|
3
|
+
import { type SceneEffect as IEffect } from "@motion-script/core";
|
|
4
|
+
export declare class CanvasKitEffectRegistry {
|
|
5
|
+
private static registry;
|
|
6
|
+
static register(effect: CanvasKitEffect): void;
|
|
7
|
+
static get(type: string): CanvasKitEffect | undefined;
|
|
8
|
+
static has(type: string): boolean;
|
|
9
|
+
static makeImageFilter(effect: IEffect, ck: CanvasKit, width: number, height: number): any;
|
|
10
|
+
/**
|
|
11
|
+
* Compose all effects into a single ImageFilter chain applied in array order
|
|
12
|
+
* (index 0 is innermost — applied first to the layer content).
|
|
13
|
+
*/
|
|
14
|
+
static composeFilters(effects: IEffect[], ck: CanvasKit, width: number, height: number): any | null;
|
|
15
|
+
static disposeAll(): void;
|
|
16
|
+
}
|
|
17
|
+
//# sourceMappingURL=registry.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"registry.d.ts","sourceRoot":"","sources":["../../src/effects/registry.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,0BAA0B,CAAC;AAC1D,OAAO,EAAE,eAAe,EAAE,MAAM,UAAU,CAAC;AAC3C,OAAO,EAAE,KAAK,WAAW,IAAI,OAAO,EAAE,MAAM,qBAAqB,CAAC;AASlE,qBAAa,uBAAuB;IAChC,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAsC;IAE7D,MAAM,CAAC,QAAQ,CAAC,MAAM,EAAE,eAAe,GAAG,IAAI;IAI9C,MAAM,CAAC,GAAG,CAAC,IAAI,EAAE,MAAM,GAAG,eAAe,GAAG,SAAS;IAIrD,MAAM,CAAC,GAAG,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO;IAIjC,MAAM,CAAC,eAAe,CAAC,MAAM,EAAE,OAAO,EAAE,EAAE,EAAE,SAAS,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,GAAG;IAM1F;;;OAGG;IACH,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,OAAO,EAAE,EAAE,EAAE,EAAE,SAAS,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,GAAG,GAAG,IAAI;IAYnG,MAAM,CAAC,UAAU,IAAI,IAAI;CAK5B"}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { BlurCanvasKitEffect } from "./blur";
|
|
2
|
+
import { GrayscaleCanvasKitEffect } from "./grayscale";
|
|
3
|
+
import { PixelateCanvasKitEffect } from "./pixelate";
|
|
4
|
+
import { TextureCanvasKitEffect } from "./texture";
|
|
5
|
+
import { BloomCanvasKitEffect } from "./bloom";
|
|
6
|
+
import { VintageCanvasKitEffect } from "./vintage";
|
|
7
|
+
import { ChromaticAberrationCanvasKitEffect } from "./chromatic-aberration";
|
|
8
|
+
import { SkSLLayerEffect } from "./sksl-layer";
|
|
9
|
+
export class CanvasKitEffectRegistry {
|
|
10
|
+
static registry = new Map();
|
|
11
|
+
static register(effect) {
|
|
12
|
+
this.registry.set(effect.type, effect);
|
|
13
|
+
}
|
|
14
|
+
static get(type) {
|
|
15
|
+
return this.registry.get(type);
|
|
16
|
+
}
|
|
17
|
+
static has(type) {
|
|
18
|
+
return this.registry.has(type);
|
|
19
|
+
}
|
|
20
|
+
static makeImageFilter(effect, ck, width, height) {
|
|
21
|
+
const handler = this.registry.get(effect.type);
|
|
22
|
+
if (!handler)
|
|
23
|
+
return null;
|
|
24
|
+
return handler.makeImageFilter(effect, ck, width, height);
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Compose all effects into a single ImageFilter chain applied in array order
|
|
28
|
+
* (index 0 is innermost — applied first to the layer content).
|
|
29
|
+
*/
|
|
30
|
+
static composeFilters(effects, ck, width, height) {
|
|
31
|
+
let composed = null;
|
|
32
|
+
for (const effect of effects) {
|
|
33
|
+
const filter = this.makeImageFilter(effect, ck, width, height);
|
|
34
|
+
if (filter == null)
|
|
35
|
+
continue;
|
|
36
|
+
composed = composed === null
|
|
37
|
+
? filter
|
|
38
|
+
: ck.ImageFilter.MakeCompose(filter, composed);
|
|
39
|
+
}
|
|
40
|
+
return composed;
|
|
41
|
+
}
|
|
42
|
+
static disposeAll() {
|
|
43
|
+
for (const handler of this.registry.values()) {
|
|
44
|
+
handler.dispose();
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
CanvasKitEffectRegistry.register(new BlurCanvasKitEffect());
|
|
49
|
+
CanvasKitEffectRegistry.register(new GrayscaleCanvasKitEffect());
|
|
50
|
+
CanvasKitEffectRegistry.register(new PixelateCanvasKitEffect());
|
|
51
|
+
CanvasKitEffectRegistry.register(new TextureCanvasKitEffect());
|
|
52
|
+
CanvasKitEffectRegistry.register(new BloomCanvasKitEffect());
|
|
53
|
+
CanvasKitEffectRegistry.register(new VintageCanvasKitEffect());
|
|
54
|
+
CanvasKitEffectRegistry.register(new ChromaticAberrationCanvasKitEffect());
|
|
55
|
+
CanvasKitEffectRegistry.register(new SkSLLayerEffect());
|
|
56
|
+
//# sourceMappingURL=registry.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"registry.js","sourceRoot":"","sources":["../../src/effects/registry.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,mBAAmB,EAAE,MAAM,QAAQ,CAAC;AAC7C,OAAO,EAAE,wBAAwB,EAAE,MAAM,aAAa,CAAC;AACvD,OAAO,EAAE,uBAAuB,EAAE,MAAM,YAAY,CAAC;AACrD,OAAO,EAAE,sBAAsB,EAAE,MAAM,WAAW,CAAC;AACnD,OAAO,EAAE,oBAAoB,EAAE,MAAM,SAAS,CAAC;AAC/C,OAAO,EAAE,sBAAsB,EAAE,MAAM,WAAW,CAAC;AACnD,OAAO,EAAE,kCAAkC,EAAE,MAAM,wBAAwB,CAAC;AAC5E,OAAO,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAC/C,MAAM,OAAO,uBAAuB;IACxB,MAAM,CAAC,QAAQ,GAAG,IAAI,GAAG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,UAAU;QACb,KAAK,MAAM,OAAO,IAAI,IAAI,CAAC,QAAQ,CAAC,MAAM,EAAE,EAAE,CAAC;YAC3C,OAAO,CAAC,OAAO,EAAE,CAAC;QACtB,CAAC;IACL,CAAC;;AAEL,uBAAuB,CAAC,QAAQ,CAAC,IAAI,mBAAmB,EAAE,CAAC,CAAC;AAC5D,uBAAuB,CAAC,QAAQ,CAAC,IAAI,wBAAwB,EAAE,CAAC,CAAC;AACjE,uBAAuB,CAAC,QAAQ,CAAC,IAAI,uBAAuB,EAAE,CAAC,CAAC;AAChE,uBAAuB,CAAC,QAAQ,CAAC,IAAI,sBAAsB,EAAE,CAAC,CAAC;AAC/D,uBAAuB,CAAC,QAAQ,CAAC,IAAI,oBAAoB,EAAE,CAAC,CAAC;AAC7D,uBAAuB,CAAC,QAAQ,CAAC,IAAI,sBAAsB,EAAE,CAAC,CAAC;AAC/D,uBAAuB,CAAC,QAAQ,CAAC,IAAI,kCAAkC,EAAE,CAAC,CAAC;AAC3E,uBAAuB,CAAC,QAAQ,CAAC,IAAI,eAAe,EAAE,CAAC,CAAC"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { CanvasKit, RuntimeEffect } from "@motion-script/canvaskit";
|
|
2
|
+
/** Compile-and-cache a RuntimeEffect by shader source; returns the cached instance on repeat calls. */
|
|
3
|
+
export declare function getOrCompileSkSL(shader: string, ck: CanvasKit): RuntimeEffect | null;
|
|
4
|
+
/** Delete every cached RuntimeEffect's GPU resources and clear the cache (draw context teardown). */
|
|
5
|
+
export declare function disposeSkSLCache(): void;
|
|
6
|
+
//# sourceMappingURL=sksl-cache.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sksl-cache.d.ts","sourceRoot":"","sources":["../../src/effects/sksl-cache.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AAKzE,uGAAuG;AACvG,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,MAAM,EAAE,EAAE,EAAE,SAAS,GAAG,aAAa,GAAG,IAAI,CAQpF;AAED,qGAAqG;AACrG,wBAAgB,gBAAgB,IAAI,IAAI,CAGvC"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
// Keyed by shader source so identical SkSL across effects/instances compiles once.
|
|
2
|
+
const cache = new Map();
|
|
3
|
+
/** Compile-and-cache a RuntimeEffect by shader source; returns the cached instance on repeat calls. */
|
|
4
|
+
export function getOrCompileSkSL(shader, ck) {
|
|
5
|
+
const cached = cache.get(shader);
|
|
6
|
+
if (cached)
|
|
7
|
+
return cached;
|
|
8
|
+
const effect = ck.RuntimeEffect.Make(shader, (err) => {
|
|
9
|
+
console.warn("[SkSL] Compilation error:", err);
|
|
10
|
+
});
|
|
11
|
+
if (effect)
|
|
12
|
+
cache.set(shader, effect);
|
|
13
|
+
return effect ?? null;
|
|
14
|
+
}
|
|
15
|
+
/** Delete every cached RuntimeEffect's GPU resources and clear the cache (draw context teardown). */
|
|
16
|
+
export function disposeSkSLCache() {
|
|
17
|
+
for (const effect of cache.values())
|
|
18
|
+
effect.delete();
|
|
19
|
+
cache.clear();
|
|
20
|
+
}
|
|
21
|
+
//# sourceMappingURL=sksl-cache.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sksl-cache.js","sourceRoot":"","sources":["../../src/effects/sksl-cache.ts"],"names":[],"mappings":"AAEA,mFAAmF;AACnF,MAAM,KAAK,GAAG,IAAI,GAAG,EAAyB,CAAC;AAE/C,uGAAuG;AACvG,MAAM,UAAU,gBAAgB,CAAC,MAAc,EAAE,EAAa;IAC1D,MAAM,MAAM,GAAG,KAAK,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;IACjC,IAAI,MAAM;QAAE,OAAO,MAAM,CAAC;IAC1B,MAAM,MAAM,GAAG,EAAE,CAAC,aAAa,CAAC,IAAI,CAAC,MAAM,EAAE,CAAC,GAAG,EAAE,EAAE;QACjD,OAAO,CAAC,IAAI,CAAC,2BAA2B,EAAE,GAAG,CAAC,CAAC;IACnD,CAAC,CAAC,CAAC;IACH,IAAI,MAAM;QAAE,KAAK,CAAC,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACtC,OAAO,MAAM,IAAI,IAAI,CAAC;AAC1B,CAAC;AAED,qGAAqG;AACrG,MAAM,UAAU,gBAAgB;IAC5B,KAAK,MAAM,MAAM,IAAI,KAAK,CAAC,MAAM,EAAE;QAAE,MAAM,CAAC,MAAM,EAAE,CAAC;IACrD,KAAK,CAAC,KAAK,EAAE,CAAC;AAClB,CAAC"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import type { CanvasKit } from "@motion-script/canvaskit";
|
|
2
|
+
import type { SkSLEffect } from "@motion-script/core";
|
|
3
|
+
import { CanvasKitEffect } from "./effect";
|
|
4
|
+
/**
|
|
5
|
+
* Layer-mode custom SkSL effect.
|
|
6
|
+
*
|
|
7
|
+
* The shader generates colour from position/uniforms and is composed onto the
|
|
8
|
+
* node's layer via `ImageFilter.MakeBlend(blendMode, source, shaderFilter)`.
|
|
9
|
+
*
|
|
10
|
+
* - `background = null` → the node's layer content (dynamic source)
|
|
11
|
+
* - `foreground = MakeShader(compiledShader)` → the shader output
|
|
12
|
+
*
|
|
13
|
+
* The default blend mode is Screen, which adds the shader output to the layer
|
|
14
|
+
* additively. Use `effect.blendMode` to override (e.g. `'multiply'`, `'srcOver'`).
|
|
15
|
+
*
|
|
16
|
+
* SkSL contract for layer-mode shaders:
|
|
17
|
+
* ```glsl
|
|
18
|
+
* uniform float u_myParam; // uniforms in declaration order
|
|
19
|
+
*
|
|
20
|
+
* vec4 main(vec2 fragCoord) {
|
|
21
|
+
* // generate overlay colour from position / uniforms
|
|
22
|
+
* return vec4(r, g, b, a);
|
|
23
|
+
* }
|
|
24
|
+
* ```
|
|
25
|
+
*/
|
|
26
|
+
export declare class SkSLLayerEffect extends CanvasKitEffect<SkSLEffect> {
|
|
27
|
+
constructor();
|
|
28
|
+
makeImageFilter(effect: SkSLEffect, ck: CanvasKit): any;
|
|
29
|
+
}
|
|
30
|
+
//# sourceMappingURL=sksl-layer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sksl-layer.d.ts","sourceRoot":"","sources":["../../src/effects/sksl-layer.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,0BAA0B,CAAC;AAC1D,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AACtD,OAAO,EAAE,eAAe,EAAE,MAAM,UAAU,CAAC;AAG3C;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,qBAAa,eAAgB,SAAQ,eAAe,CAAC,UAAU,CAAC;;IAK5D,eAAe,CAAC,MAAM,EAAE,UAAU,EAAE,EAAE,EAAE,SAAS,GAAG,GAAG;CAwB1D"}
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import { CanvasKitEffect } from "./effect";
|
|
2
|
+
import { getOrCompileSkSL } from "./sksl-cache";
|
|
3
|
+
/**
|
|
4
|
+
* Layer-mode custom SkSL effect.
|
|
5
|
+
*
|
|
6
|
+
* The shader generates colour from position/uniforms and is composed onto the
|
|
7
|
+
* node's layer via `ImageFilter.MakeBlend(blendMode, source, shaderFilter)`.
|
|
8
|
+
*
|
|
9
|
+
* - `background = null` → the node's layer content (dynamic source)
|
|
10
|
+
* - `foreground = MakeShader(compiledShader)` → the shader output
|
|
11
|
+
*
|
|
12
|
+
* The default blend mode is Screen, which adds the shader output to the layer
|
|
13
|
+
* additively. Use `effect.blendMode` to override (e.g. `'multiply'`, `'srcOver'`).
|
|
14
|
+
*
|
|
15
|
+
* SkSL contract for layer-mode shaders:
|
|
16
|
+
* ```glsl
|
|
17
|
+
* uniform float u_myParam; // uniforms in declaration order
|
|
18
|
+
*
|
|
19
|
+
* vec4 main(vec2 fragCoord) {
|
|
20
|
+
* // generate overlay colour from position / uniforms
|
|
21
|
+
* return vec4(r, g, b, a);
|
|
22
|
+
* }
|
|
23
|
+
* ```
|
|
24
|
+
*/
|
|
25
|
+
export class SkSLLayerEffect extends CanvasKitEffect {
|
|
26
|
+
constructor() {
|
|
27
|
+
super("sksl");
|
|
28
|
+
}
|
|
29
|
+
makeImageFilter(effect, ck) {
|
|
30
|
+
// Backdrop-mode SkSL is handled by beginBackdropSkSL in the render context.
|
|
31
|
+
if (effect.mode !== "layer")
|
|
32
|
+
return null;
|
|
33
|
+
const rte = getOrCompileSkSL(effect.shader, ck);
|
|
34
|
+
if (!rte)
|
|
35
|
+
return null;
|
|
36
|
+
const flat = effect.uniforms.flatMap((u) => typeof u.value === "number" ? [u.value] : u.value);
|
|
37
|
+
const shader = rte.makeShader(flat);
|
|
38
|
+
const shaderIF = ck.ImageFilter.MakeShader(shader);
|
|
39
|
+
shader.delete();
|
|
40
|
+
const blendModeName = effect.blendMode ?? "screen";
|
|
41
|
+
const blendMode = resolveBlendMode(ck, blendModeName);
|
|
42
|
+
// Blend the shader output onto the layer source.
|
|
43
|
+
// background = null → source; foreground = shader filter
|
|
44
|
+
const result = ck.ImageFilter.MakeBlend(blendMode, null, shaderIF);
|
|
45
|
+
shaderIF.delete();
|
|
46
|
+
return result;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
function resolveBlendMode(ck, name) {
|
|
50
|
+
const map = {
|
|
51
|
+
srcOver: ck.BlendMode.SrcOver,
|
|
52
|
+
src: ck.BlendMode.Src,
|
|
53
|
+
dst: ck.BlendMode.Dst,
|
|
54
|
+
dstOver: ck.BlendMode.DstOver,
|
|
55
|
+
srcIn: ck.BlendMode.SrcIn,
|
|
56
|
+
dstIn: ck.BlendMode.DstIn,
|
|
57
|
+
srcOut: ck.BlendMode.SrcOut,
|
|
58
|
+
dstOut: ck.BlendMode.DstOut,
|
|
59
|
+
srcATop: ck.BlendMode.SrcATop,
|
|
60
|
+
dstATop: ck.BlendMode.DstATop,
|
|
61
|
+
xor: ck.BlendMode.Xor,
|
|
62
|
+
plus: ck.BlendMode.Plus,
|
|
63
|
+
modulate: ck.BlendMode.Modulate,
|
|
64
|
+
screen: ck.BlendMode.Screen,
|
|
65
|
+
overlay: ck.BlendMode.Overlay,
|
|
66
|
+
darken: ck.BlendMode.Darken,
|
|
67
|
+
lighten: ck.BlendMode.Lighten,
|
|
68
|
+
colorDodge: ck.BlendMode.ColorDodge,
|
|
69
|
+
colorBurn: ck.BlendMode.ColorBurn,
|
|
70
|
+
hardLight: ck.BlendMode.HardLight,
|
|
71
|
+
softLight: ck.BlendMode.SoftLight,
|
|
72
|
+
difference: ck.BlendMode.Difference,
|
|
73
|
+
exclusion: ck.BlendMode.Exclusion,
|
|
74
|
+
multiply: ck.BlendMode.Multiply,
|
|
75
|
+
hue: ck.BlendMode.Hue,
|
|
76
|
+
saturation: ck.BlendMode.Saturation,
|
|
77
|
+
color: ck.BlendMode.Color,
|
|
78
|
+
luminosity: ck.BlendMode.Luminosity,
|
|
79
|
+
};
|
|
80
|
+
return map[name] ?? ck.BlendMode.Screen;
|
|
81
|
+
}
|
|
82
|
+
//# sourceMappingURL=sksl-layer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sksl-layer.js","sourceRoot":"","sources":["../../src/effects/sksl-layer.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,eAAe,EAAE,MAAM,UAAU,CAAC;AAC3C,OAAO,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAEhD;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,MAAM,OAAO,eAAgB,SAAQ,eAA2B;IAC5D;QACI,KAAK,CAAC,MAAM,CAAC,CAAC;IAClB,CAAC;IAED,eAAe,CAAC,MAAkB,EAAE,EAAa;QAC7C,4EAA4E;QAC5E,IAAI,MAAM,CAAC,IAAI,KAAK,OAAO;YAAE,OAAO,IAAI,CAAC;QAEzC,MAAM,GAAG,GAAG,gBAAgB,CAAC,MAAM,CAAC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ffect } from "./effect";
|
|
3
|
+
import { type TextureEffect } from "@motion-script/core";
|
|
4
|
+
export declare class TextureCanvasKitEffect extends CanvasKitEffect<TextureEffect> {
|
|
5
|
+
constructor();
|
|
6
|
+
/**
|
|
7
|
+
* Figma-style "texture" spatter: the node's silhouette keeps a solid core that
|
|
8
|
+
* dissolves *gradually* into scattered grain toward its edge — the grain density
|
|
9
|
+
* thins with distance, sparse at the outer reach and dense near the interior.
|
|
10
|
+
*
|
|
11
|
+
* This mirrors the reference fragment shader, whose dissolve compares per-pixel
|
|
12
|
+
* noise against a density that ramps with distance from the shape edge. This
|
|
13
|
+
* CanvasKit build can't feed the dynamic layer into a RuntimeEffect as a child
|
|
14
|
+
* shader, so the same graded result is assembled from source-reading filters:
|
|
15
|
+
*
|
|
16
|
+
* 1. `ramp` = MakeBlur(spread) softens the silhouette into a smooth alpha
|
|
17
|
+
* gradient at the edge — the distance-graded density `t` from the shader.
|
|
18
|
+
* 2. `scattered` = MakeDisplacementMap pushes that *soft ramp* around by fractal
|
|
19
|
+
* noise. Because the input is a gradient (not a hard edge), each grain's
|
|
20
|
+
* survival depends on the local ramp height → density that thins with
|
|
21
|
+
* distance, instead of a uniform-density band.
|
|
22
|
+
* 3. A steep alpha contrast curve (A' = 3·A − 1) resolves the chewed gradient
|
|
23
|
+
* into crisp grain specks while preserving the graded falloff.
|
|
24
|
+
*
|
|
25
|
+
* Param mapping (mirrors the reference shader's controls):
|
|
26
|
+
* radius → spread: how far the dissolve reaches inward from the edge.
|
|
27
|
+
* size.x / size.y → grain cell size; larger = chunkier grain (lower frequency).
|
|
28
|
+
*/
|
|
29
|
+
makeImageFilter(effect: TextureEffect, ck: CanvasKit): any;
|
|
30
|
+
}
|
|
31
|
+
//# sourceMappingURL=texture.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"texture.d.ts","sourceRoot":"","sources":["../../src/effects/texture.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,0BAA0B,CAAC;AAC1D,OAAO,EAAE,eAAe,EAAE,MAAM,UAAU,CAAC;AAC3C,OAAO,EAAE,KAAK,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAEzD,qBAAa,sBAAuB,SAAQ,eAAe,CAAC,aAAa,CAAC;;IAKtE;;;;;;;;;;;;;;;;;;;;;;OAsBG;IACH,eAAe,CAAC,MAAM,EAAE,aAAa,EAAE,EAAE,EAAE,SAAS,GAAG,GAAG;CA+C7D"}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { CanvasKitEffect } from "./effect";
|
|
2
|
+
export class TextureCanvasKitEffect extends CanvasKitEffect {
|
|
3
|
+
constructor() {
|
|
4
|
+
super("texture");
|
|
5
|
+
}
|
|
6
|
+
/**
|
|
7
|
+
* Figma-style "texture" spatter: the node's silhouette keeps a solid core that
|
|
8
|
+
* dissolves *gradually* into scattered grain toward its edge — the grain density
|
|
9
|
+
* thins with distance, sparse at the outer reach and dense near the interior.
|
|
10
|
+
*
|
|
11
|
+
* This mirrors the reference fragment shader, whose dissolve compares per-pixel
|
|
12
|
+
* noise against a density that ramps with distance from the shape edge. This
|
|
13
|
+
* CanvasKit build can't feed the dynamic layer into a RuntimeEffect as a child
|
|
14
|
+
* shader, so the same graded result is assembled from source-reading filters:
|
|
15
|
+
*
|
|
16
|
+
* 1. `ramp` = MakeBlur(spread) softens the silhouette into a smooth alpha
|
|
17
|
+
* gradient at the edge — the distance-graded density `t` from the shader.
|
|
18
|
+
* 2. `scattered` = MakeDisplacementMap pushes that *soft ramp* around by fractal
|
|
19
|
+
* noise. Because the input is a gradient (not a hard edge), each grain's
|
|
20
|
+
* survival depends on the local ramp height → density that thins with
|
|
21
|
+
* distance, instead of a uniform-density band.
|
|
22
|
+
* 3. A steep alpha contrast curve (A' = 3·A − 1) resolves the chewed gradient
|
|
23
|
+
* into crisp grain specks while preserving the graded falloff.
|
|
24
|
+
*
|
|
25
|
+
* Param mapping (mirrors the reference shader's controls):
|
|
26
|
+
* radius → spread: how far the dissolve reaches inward from the edge.
|
|
27
|
+
* size.x / size.y → grain cell size; larger = chunkier grain (lower frequency).
|
|
28
|
+
*/
|
|
29
|
+
makeImageFilter(effect, ck) {
|
|
30
|
+
const grainX = Math.max(1, effect.size.x);
|
|
31
|
+
const grainY = Math.max(1, effect.size.y);
|
|
32
|
+
const spread = Math.max(0, effect.radius);
|
|
33
|
+
// No spread → nothing to dissolve; let the layer through untouched.
|
|
34
|
+
if (spread <= 0)
|
|
35
|
+
return null;
|
|
36
|
+
// Grain frequency is the inverse of grain size, clamped to the range Skia's
|
|
37
|
+
// fractal noise accepts. Axes are independent so size can stretch the grain.
|
|
38
|
+
const fx = Math.min(0.9, Math.max(0.02, 1 / grainX));
|
|
39
|
+
const fy = Math.min(0.9, Math.max(0.02, 1 / grainY));
|
|
40
|
+
// 1. Soft distance ramp: blur the silhouette so its alpha gradients across
|
|
41
|
+
// the spread zone (high inside → 0 outside).
|
|
42
|
+
const sigma = spread / 2;
|
|
43
|
+
const ramp = ck.ImageFilter.MakeBlur(sigma, sigma, ck.TileMode.Decal, null);
|
|
44
|
+
// 2. Scatter the ramp by fractal noise; displacing a gradient yields grain
|
|
45
|
+
// whose density follows the local ramp height.
|
|
46
|
+
const noiseShader = ck.Shader.MakeFractalNoise(fx, fy, 4, 0, 0, 0);
|
|
47
|
+
const displacement = ck.ImageFilter.MakeShader(noiseShader);
|
|
48
|
+
noiseShader.delete();
|
|
49
|
+
const scattered = ck.ImageFilter.MakeDisplacementMap(ck.ColorChannel.Red, ck.ColorChannel.Green, spread, displacement, ramp);
|
|
50
|
+
ramp.delete();
|
|
51
|
+
displacement.delete();
|
|
52
|
+
// 3. Contrast the chewed gradient into crisp grain: A' = clamp(3·A − 1).
|
|
53
|
+
// RGB rows are identity so the source colour is preserved.
|
|
54
|
+
const contrast = ck.ColorFilter.MakeMatrix([
|
|
55
|
+
1, 0, 0, 0, 0,
|
|
56
|
+
0, 1, 0, 0, 0,
|
|
57
|
+
0, 0, 1, 0, 0,
|
|
58
|
+
0, 0, 0, 3, -1,
|
|
59
|
+
]);
|
|
60
|
+
const filter = ck.ImageFilter.MakeColorFilter(contrast, scattered);
|
|
61
|
+
contrast.delete();
|
|
62
|
+
scattered.delete();
|
|
63
|
+
return filter;
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
//# sourceMappingURL=texture.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"texture.js","sourceRoot":"","sources":["../../src/effects/texture.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,eAAe,EAAE,MAAM,UAAU,CAAC;AAG3C,MAAM,OAAO,sBAAuB,SAAQ,eAA8B;IACtE;QACI,KAAK,CAAC,SAAS,CAAC,CAAC;IACrB,CAAC;IAED;;;;;;;;;;;;;;;;;;;;;;OAsBG;IACH,eAAe,CAAC,MAAqB,EAAE,EAAa;QAChD,MAAM,MAAM,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;QAC1C,MAAM,MAAM,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;QAC1C,MAAM,MAAM,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,MAAM,CAAC,MAAM,CAAC,CAAC;QAE1C,oEAAoE;QACpE,IAAI,MAAM,IAAI,CAAC;YAAE,OAAO,IAAI,CAAC;QAE7B,4EAA4E;QAC5E,6EAA6E;QAC7E,MAAM,EAAE,GAAG,IAAI,CAAC,GAAG,CAAC,GAAG,EAAE,IAAI,CAAC,GAAG,CAAC,IAAI,EAAE,CAAC,GAAG,MAAM,CAAC,CAAC,CAAC;QACrD,MAAM,EAAE,GAAG,IAAI,CAAC,GAAG,CAAC,GAAG,EAAE,IAAI,CAAC,GAAG,CAAC,IAAI,EAAE,CAAC,GAAG,MAAM,CAAC,CAAC,CAAC;Q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AClB,SAAS,CAAC,MAAM,EAAE,CAAC;QACnB,OAAO,MAAM,CAAC;IAClB,CAAC;CACJ"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { CanvasKit } from "@motion-script/canvaskit";
|
|
2
|
+
import type { VintageEffect } from "@motion-script/core";
|
|
3
|
+
import { CanvasKitEffect } from "./effect";
|
|
4
|
+
/**
|
|
5
|
+
* Vintage / film-look colour grading effect.
|
|
6
|
+
*
|
|
7
|
+
* Interpolates between the identity matrix and a sepia+desaturate matrix by
|
|
8
|
+
* `amount`, then shifts the colour temperature via `warmth`. Applied as a
|
|
9
|
+
* single colour-matrix ImageFilter so it composes cheaply with other effects.
|
|
10
|
+
*
|
|
11
|
+
* Sepia reference (ITU-R BT.601 luma weights for desaturation):
|
|
12
|
+
* R' = 0.393R + 0.769G + 0.189B
|
|
13
|
+
* G' = 0.349R + 0.686G + 0.168B
|
|
14
|
+
* B' = 0.272R + 0.534G + 0.131B
|
|
15
|
+
*/
|
|
16
|
+
export declare class VintageCanvasKitEffect extends CanvasKitEffect<VintageEffect> {
|
|
17
|
+
constructor();
|
|
18
|
+
makeImageFilter(effect: VintageEffect, ck: CanvasKit): any;
|
|
19
|
+
}
|
|
20
|
+
//# sourceMappingURL=vintage.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"vintage.d.ts","sourceRoot":"","sources":["../../src/effects/vintage.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,0BAA0B,CAAC;AAC1D,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACzD,OAAO,EAAE,eAAe,EAAE,MAAM,UAAU,CAAC;AAE3C;;;;;;;;;;;GAWG;AACH,qBAAa,sBAAuB,SAAQ,eAAe,CAAC,aAAa,CAAC;;IAKtE,eAAe,CAAC,MAAM,EAAE,aAAa,EAAE,EAAE,EAAE,SAAS,GAAG,GAAG;CAiC7D"}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { CanvasKitEffect } from "./effect";
|
|
2
|
+
/**
|
|
3
|
+
* Vintage / film-look colour grading effect.
|
|
4
|
+
*
|
|
5
|
+
* Interpolates between the identity matrix and a sepia+desaturate matrix by
|
|
6
|
+
* `amount`, then shifts the colour temperature via `warmth`. Applied as a
|
|
7
|
+
* single colour-matrix ImageFilter so it composes cheaply with other effects.
|
|
8
|
+
*
|
|
9
|
+
* Sepia reference (ITU-R BT.601 luma weights for desaturation):
|
|
10
|
+
* R' = 0.393R + 0.769G + 0.189B
|
|
11
|
+
* G' = 0.349R + 0.686G + 0.168B
|
|
12
|
+
* B' = 0.272R + 0.534G + 0.131B
|
|
13
|
+
*/
|
|
14
|
+
export class VintageCanvasKitEffect extends CanvasKitEffect {
|
|
15
|
+
constructor() {
|
|
16
|
+
super("vintage");
|
|
17
|
+
}
|
|
18
|
+
makeImageFilter(effect, ck) {
|
|
19
|
+
if (effect.amount <= 0 && effect.warmth === 0)
|
|
20
|
+
return null;
|
|
21
|
+
const a = Math.max(0, Math.min(1, effect.amount));
|
|
22
|
+
const w = Math.max(-1, Math.min(1, effect.warmth));
|
|
23
|
+
// Lerp between identity and sepia per channel.
|
|
24
|
+
const lerp = (identity, sepia) => identity + (sepia - identity) * a;
|
|
25
|
+
// Sepia values
|
|
26
|
+
const sr = [0.393, 0.769, 0.189];
|
|
27
|
+
const sg = [0.349, 0.686, 0.168];
|
|
28
|
+
const sb = [0.272, 0.534, 0.131];
|
|
29
|
+
// Warmth shifts R up / B down (positive) or R down / B up (negative).
|
|
30
|
+
const warmR = w > 0 ? w * 0.15 : 0;
|
|
31
|
+
const warmB = w < 0 ? -w * 0.15 : 0;
|
|
32
|
+
const coolR = w < 0 ? -w * 0.05 : 0;
|
|
33
|
+
const coolB = w > 0 ? w * 0.05 : 0;
|
|
34
|
+
// prettier-ignore
|
|
35
|
+
const matrix = [
|
|
36
|
+
lerp(1, sr[0]), lerp(0, sr[1]), lerp(0, sr[2]), 0, warmR - coolR,
|
|
37
|
+
lerp(0, sg[0]), lerp(1, sg[1]), lerp(0, sg[2]), 0, 0,
|
|
38
|
+
lerp(0, sb[0]), lerp(0, sb[1]), lerp(1, sb[2]), 0, -warmB + coolB,
|
|
39
|
+
0, 0, 0, 1, 0,
|
|
40
|
+
];
|
|
41
|
+
const cf = ck.ColorFilter.MakeMatrix(matrix);
|
|
42
|
+
const result = ck.ImageFilter.MakeColorFilter(cf, null);
|
|
43
|
+
cf.delete();
|
|
44
|
+
return result;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
//# sourceMappingURL=vintage.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"vintage.js","sourceRoot":"","sources":["../../src/effects/vintage.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,eAAe,EAAE,MAAM,UAAU,CAAC;AAE3C;;;;;;;;;;;GAWG;AACH,MAAM,OAAO,sBAAuB,SAAQ,eAA8B;IACtE;QACI,KAAK,CAAC,SAAS,CAAC,CAAC;IACrB,CAAC;IAED,eAAe,CAAC,MAAqB,EAAE,EAAa;QAChD,IAAI,MAAM,CAAC,MAAM,IAAI,CAAC,IAAI,MAAM,CAAC,MAAM,KAAK,CAAC;YAAE,OAAO,IAAI,CAAC;QAE3D,MAAM,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC;QAClD,MAAM,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC;QAEnD,+CAA+C;QAC/C,MAAM,IAAI,GAAG,CAAC,QAAgB,EAAE,KAAa,EAAE,EAAE,CAAC,QAAQ,GAAG,CAAC,KAAK,GAAG,QAAQ,CAAC,GAAG,CAAC,CAAC;QAEpF,eAAe;QACf,M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