pixi-effects 0.6.0 → 0.8.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 (52) hide show
  1. package/CHANGELOG.md +29 -0
  2. package/README.md +18 -11
  3. package/ai/SKILL.md +1 -1
  4. package/ai/reference/cheatsheet.md +9 -1
  5. package/ai/template.html +4 -3
  6. package/ai/tools/check.mjs +14 -5
  7. package/ai/tools/render.mjs +202 -0
  8. package/ai/tools/view.mjs +269 -0
  9. package/dist/{Base-4vNLl4tH.d.cts → Base-CSIulyIq.d.cts} +1 -1
  10. package/dist/{Base-CD4AoT5-.d.ts → Base-DVgwyIUj.d.ts} +1 -1
  11. package/dist/Composition-CM62XJKT.cjs +14 -0
  12. package/dist/{Composition-Y5VZSDDP.cjs.map → Composition-CM62XJKT.cjs.map} +1 -1
  13. package/dist/Composition-RJDSQYTV.js +5 -0
  14. package/dist/{Composition-7SO5WYHU.js.map → Composition-RJDSQYTV.js.map} +1 -1
  15. package/dist/Controller.cjs +122 -20
  16. package/dist/Controller.cjs.map +1 -1
  17. package/dist/Controller.d.cts +45 -3
  18. package/dist/Controller.d.ts +45 -3
  19. package/dist/Controller.js +122 -21
  20. package/dist/Controller.js.map +1 -1
  21. package/dist/{Movie-Ch2SUI1h.d.ts → Movie-CQOhUmko.d.cts} +75 -2
  22. package/dist/{Movie-CADDBfpl.d.cts → Movie-HF3pSGjQ.d.ts} +75 -2
  23. package/dist/{chunk-KQM2ZZMK.cjs → chunk-AGMNSJJH.cjs} +175 -29
  24. package/dist/chunk-AGMNSJJH.cjs.map +1 -0
  25. package/dist/{chunk-7IJHJXDI.js → chunk-FNKSXBKB.js} +136 -10
  26. package/dist/chunk-FNKSXBKB.js.map +1 -0
  27. package/dist/{chunk-B2FTJLNB.js → chunk-O4AJYUPK.js} +3 -3
  28. package/dist/{chunk-B2FTJLNB.js.map → chunk-O4AJYUPK.js.map} +1 -1
  29. package/dist/{chunk-4AGJF5RK.cjs → chunk-PDBDDGG5.cjs} +21 -21
  30. package/dist/{chunk-4AGJF5RK.cjs.map → chunk-PDBDDGG5.cjs.map} +1 -1
  31. package/dist/index.cjs +255 -25
  32. package/dist/index.cjs.map +1 -1
  33. package/dist/index.d.cts +4 -4
  34. package/dist/index.d.ts +4 -4
  35. package/dist/index.js +248 -18
  36. package/dist/index.js.map +1 -1
  37. package/dist/three.cjs +6 -5
  38. package/dist/three.cjs.map +1 -1
  39. package/dist/three.d.cts +2 -2
  40. package/dist/three.d.ts +2 -2
  41. package/dist/three.js +2 -1
  42. package/dist/three.js.map +1 -1
  43. package/dist/{types-DrW9QeKU.d.ts → types-oJijbn-K.d.cts} +14 -1
  44. package/dist/{types-DrW9QeKU.d.cts → types-oJijbn-K.d.ts} +14 -1
  45. package/docs/api.md +57 -0
  46. package/docs/dsl.md +60 -1
  47. package/llms-full.txt +127 -3
  48. package/package.json +7 -4
  49. package/dist/Composition-7SO5WYHU.js +0 -4
  50. package/dist/Composition-Y5VZSDDP.cjs +0 -13
  51. package/dist/chunk-7IJHJXDI.js.map +0 -1
  52. package/dist/chunk-KQM2ZZMK.cjs.map +0 -1
@@ -1,8 +1,8 @@
1
+ import { suggestName } from './chunk-DKGG7WD4.js';
2
+ import * as PIXI from 'pixi.js';
1
3
  import { Rectangle, Container, Graphics, Assets, Texture, Sprite, Text, Filter, GlProgram, defaultFilterVert, GpuProgram, UniformGroup, FillGradient, Color, GraphicsPath } from 'pixi.js';
2
4
  import { gsap } from 'gsap';
3
5
 
4
- // src/sequences/Base.ts
5
-
6
6
  // src/expr/Parser.ts
7
7
  var FUNCS = {
8
8
  min: Math.min,
@@ -696,6 +696,133 @@ var ChromaKeyFilter = class extends Filter {
696
696
  u[2] = rgb[2];
697
697
  }
698
698
  };
699
+ var CORE = { blur: "BlurFilter", noise: "NoiseFilter", alpha: "AlphaFilter" };
700
+ var CORE_TYPES = [...Object.keys(CORE), "colorMatrix"];
701
+ var LIBRARY_TYPES = [
702
+ "adjustment",
703
+ "advancedBloom",
704
+ "ascii",
705
+ "backdropBlur",
706
+ "bevel",
707
+ "bloom",
708
+ "bulgePinch",
709
+ "colorGradient",
710
+ "colorMap",
711
+ "colorOverlay",
712
+ "colorReplace",
713
+ "convolution",
714
+ "crossHatch",
715
+ "crt",
716
+ "dot",
717
+ "dropShadow",
718
+ "emboss",
719
+ "glitch",
720
+ "glow",
721
+ "godray",
722
+ "grayscale",
723
+ "hslAdjustment",
724
+ "kawaseBlur",
725
+ "motionBlur",
726
+ "multiColorReplace",
727
+ "oldFilm",
728
+ "outline",
729
+ "pixelate",
730
+ "radialBlur",
731
+ "reflection",
732
+ "rgbSplit",
733
+ "shockwave",
734
+ "simpleLightmap",
735
+ "simplexNoise",
736
+ "tiltShift",
737
+ "tiltShiftAxis",
738
+ "twist",
739
+ "zoomBlur"
740
+ ];
741
+ var FILTER_TYPES = [...CORE_TYPES, ...LIBRARY_TYPES];
742
+ var NOT_NAMED = /* @__PURE__ */ new Set(["custom", "chromaKey"]);
743
+ var lower = (s) => s.toLowerCase();
744
+ var isLibraryType = (t) => LIBRARY_TYPES.some((n) => lower(n) === lower(t));
745
+ var isCoreType = (t) => CORE_TYPES.some((n) => lower(n) === lower(t));
746
+ function isNamedFilterType(t) {
747
+ return !NOT_NAMED.has(t);
748
+ }
749
+ function unknownType(t) {
750
+ const guess = suggestName(t, FILTER_TYPES);
751
+ return new Error(`pixi-effects: unknown filter type "${t}"${guess ? ` \u2014 did you mean "${guess}"?` : ""} (valid: ${[...FILTER_TYPES, "chromaKey", "custom"].join(", ")})`);
752
+ }
753
+ var library = null;
754
+ function registerFilterLibrary(mod) {
755
+ library = /* @__PURE__ */ new Map();
756
+ for (const [key, value] of Object.entries(mod)) {
757
+ if (key.endsWith("Filter") && typeof value === "function") library.set(lower(key.slice(0, -"Filter".length)), value);
758
+ }
759
+ }
760
+ var MISSING = (type, why) => new Error(
761
+ `pixi-effects: the filter "${type}" comes from the pixi-filters package${why ? ` (${why})` : ""}. Add it to your import map ("pixi-filters": "https://esm.sh/pixi-filters@6.1.5?external=pixi.js") or run \`npm i pixi-filters\`.`
762
+ );
763
+ function needsFilterLibrary(spec) {
764
+ let needs = false;
765
+ const visit = (node) => {
766
+ if (!node || typeof node !== "object") return;
767
+ if (Array.isArray(node)) {
768
+ node.forEach(visit);
769
+ return;
770
+ }
771
+ const o = node;
772
+ if (Array.isArray(o.filters)) {
773
+ for (const f of o.filters) {
774
+ if (typeof f?.type !== "string" || !isNamedFilterType(f.type)) continue;
775
+ if (isLibraryType(f.type)) needs = true;
776
+ else if (!isCoreType(f.type)) throw unknownType(f.type);
777
+ }
778
+ }
779
+ for (const key of ["sequences", "mask"]) visit(o[key]);
780
+ };
781
+ visit(spec);
782
+ return needs;
783
+ }
784
+ async function ensureFilterLibrary(spec, load = () => import('pixi-filters')) {
785
+ if (!needsFilterLibrary(spec) || library) return;
786
+ try {
787
+ registerFilterLibrary(await load());
788
+ } catch (e) {
789
+ throw MISSING("(see the type in your filters)", e.message);
790
+ }
791
+ }
792
+ var SINGLE_VALUE = { pixelate: "size", emboss: "strength" };
793
+ var MATRIX_PRESETS = ["sepia", "grayscale", "negative", "polaroid", "technicolor", "vintage", "kodachrome", "browni"];
794
+ function colorMatrix(params) {
795
+ const f = new PIXI.ColorMatrixFilter();
796
+ const preset = params.preset;
797
+ if (preset !== void 0) {
798
+ if (!MATRIX_PRESETS.includes(preset)) {
799
+ const guess = suggestName(preset, MATRIX_PRESETS);
800
+ throw new Error(`pixi-effects: colorMatrix preset "${preset}" is not one of ${MATRIX_PRESETS.join(", ")}${guess ? ` \u2014 did you mean "${guess}"?` : ""}`);
801
+ }
802
+ f[preset === "grayscale" ? "desaturate" : preset].call(f);
803
+ }
804
+ if (Array.isArray(params.matrix)) f.matrix = params.matrix;
805
+ return f;
806
+ }
807
+ var GRADIENT_TYPES = ["linear", "radial", "conic"];
808
+ function colorGradientParams(params) {
809
+ const { gradientType, ...rest } = params;
810
+ if (gradientType === void 0) return rest;
811
+ const i = GRADIENT_TYPES.indexOf(String(gradientType));
812
+ if (i < 0) throw new Error(`pixi-effects: colorGradient gradientType "${gradientType}" is not one of linear, radial or conic`);
813
+ return { ...rest, type: i };
814
+ }
815
+ function createNamedFilter(type, params) {
816
+ if (lower(type) === "colormatrix") return colorMatrix(params);
817
+ const core = Object.entries(CORE).find(([k]) => lower(k) === lower(type));
818
+ if (core) return new PIXI[core[1]](params);
819
+ if (!isLibraryType(type)) throw unknownType(type);
820
+ const Ctor = library?.get(lower(type));
821
+ if (!Ctor) throw MISSING(type, library ? "not found in the loaded package" : "not loaded yet");
822
+ const single = SINGLE_VALUE[Object.keys(SINGLE_VALUE).find((k) => lower(k) === lower(type)) ?? ""];
823
+ if (single) return new Ctor(params[single]);
824
+ return new Ctor(lower(type) === "colorgradient" ? colorGradientParams(params) : params);
825
+ }
699
826
 
700
827
  // src/filters/index.ts
701
828
  var registry = {
@@ -714,10 +841,9 @@ function createFilter(spec) {
714
841
  named._name = spec.name;
715
842
  return named;
716
843
  }
717
- const Cls = registry[spec.type];
718
- if (!Cls) throw new Error(`pixi-effects: unknown filter type "${spec.type}"`);
719
- const { type: _t, name, ...params } = spec;
720
- const inst = new Cls(params);
844
+ const { type, name, ...params } = spec;
845
+ const Cls = registry[type];
846
+ const inst = Cls ? new Cls(params) : createNamedFilter(type, params);
721
847
  inst._name = name;
722
848
  return inst;
723
849
  }
@@ -2387,7 +2513,7 @@ function numOrZero(v, scope) {
2387
2513
  var _CompositionSequence = null;
2388
2514
  async function getCompositionSequence() {
2389
2515
  if (!_CompositionSequence) {
2390
- _CompositionSequence = (await import('./Composition-7SO5WYHU.js')).CompositionSequence;
2516
+ _CompositionSequence = (await import('./Composition-RJDSQYTV.js')).CompositionSequence;
2391
2517
  }
2392
2518
  return _CompositionSequence;
2393
2519
  }
@@ -2424,6 +2550,6 @@ async function buildSequenceTree(specs, parent, root) {
2424
2550
  return out;
2425
2551
  }
2426
2552
 
2427
- export { CameraSequence, DEFAULT_FOV, DEG, NEAR, Sequence, buildScope, buildSequenceTree, cameraBasis, collectPropKeys, describeLayer, evaluateExpr, homeCamera, homeDistance, lintText, lintTiming, projectLayer, registerSequenceType, resolveAt, summarizeWarnings };
2428
- //# sourceMappingURL=chunk-7IJHJXDI.js.map
2429
- //# sourceMappingURL=chunk-7IJHJXDI.js.map
2553
+ export { CameraSequence, DEFAULT_FOV, DEG, NEAR, Sequence, buildScope, buildSequenceTree, cameraBasis, collectPropKeys, describeLayer, ensureFilterLibrary, evaluateExpr, homeCamera, homeDistance, lintText, lintTiming, projectLayer, registerSequenceType, resolveAt, summarizeWarnings };
2554
+ //# sourceMappingURL=chunk-FNKSXBKB.js.map
2555
+ //# sourceMappingURL=chunk-FNKSXBKB.js.map