pixi-effects 0.20.0 → 0.22.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/CHANGELOG.md +31 -0
- package/README.md +6 -6
- package/ai/SKILL.md +3 -3
- package/ai/chat-template.html +3 -3
- package/ai/reference/cheatsheet.md +7 -7
- package/ai/reference/pitfalls.md +8 -1
- package/ai/reference/recipes.md +55 -0
- package/ai/template.html +5 -5
- package/ai/tools/check.mjs +15 -4
- package/dist/{Base-wYJQ2g5Q.d.cts → Base-BzlPgd-D.d.cts} +1 -1
- package/dist/{Base-CzfLGoDr.d.ts → Base-gu-5X0Cv.d.ts} +1 -1
- package/dist/Composition-BK5SH6J7.cjs +16 -0
- package/dist/{Composition-LL2XXU5N.cjs.map → Composition-BK5SH6J7.cjs.map} +1 -1
- package/dist/Composition-Q5TVG3HM.js +7 -0
- package/dist/{Composition-6PA4C4TV.js.map → Composition-Q5TVG3HM.js.map} +1 -1
- package/dist/Controller.cjs +2 -2
- package/dist/Controller.d.cts +2 -2
- package/dist/Controller.d.ts +2 -2
- package/dist/Controller.js +1 -1
- package/dist/{Movie-CBxGH5ms.d.ts → Movie--_TJvdJa.d.ts} +3 -1
- package/dist/{Movie-CzzJw8A-.d.cts → Movie-DMxOoTdW.d.cts} +3 -1
- package/dist/Presenter.cjs +2 -2
- package/dist/Presenter.d.cts +2 -2
- package/dist/Presenter.d.ts +2 -2
- package/dist/Presenter.js +1 -1
- package/dist/blendModes-5E4G2ZZQ.cjs +94 -0
- package/dist/blendModes-5E4G2ZZQ.cjs.map +1 -0
- package/dist/blendModes-HCP5XTNP.js +90 -0
- package/dist/blendModes-HCP5XTNP.js.map +1 -0
- package/dist/chunk-BPTW7L25.cjs +275 -0
- package/dist/chunk-BPTW7L25.cjs.map +1 -0
- package/dist/{chunk-DQHXVNOI.js → chunk-DC4JPY6A.js} +108 -273
- package/dist/chunk-DC4JPY6A.js.map +1 -0
- package/dist/chunk-E7RONUZ7.js +268 -0
- package/dist/chunk-E7RONUZ7.js.map +1 -0
- package/dist/{chunk-NO26HWR7.cjs → chunk-IFZOI3JQ.cjs} +131 -295
- package/dist/chunk-IFZOI3JQ.cjs.map +1 -0
- package/dist/chunk-K4JVI5HK.cjs +143 -0
- package/dist/chunk-K4JVI5HK.cjs.map +1 -0
- package/dist/{chunk-FFYA3UBU.cjs → chunk-MHOO2CVU.cjs} +290 -62
- package/dist/chunk-MHOO2CVU.cjs.map +1 -0
- package/dist/{chunk-MNM56B3X.js → chunk-NHICCDTC.js} +13 -3
- package/dist/chunk-NHICCDTC.js.map +1 -0
- package/dist/{chunk-TSPMKV2F.js → chunk-UQDEDYVM.js} +261 -33
- package/dist/chunk-UQDEDYVM.js.map +1 -0
- package/dist/{chunk-WTRKDIKH.cjs → chunk-UZTKEYFP.cjs} +13 -3
- package/dist/chunk-UZTKEYFP.cjs.map +1 -0
- package/dist/chunk-YEPDQ7I3.js +132 -0
- package/dist/chunk-YEPDQ7I3.js.map +1 -0
- package/dist/index.cjs +72 -68
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +4 -4
- package/dist/index.d.ts +4 -4
- package/dist/index.js +11 -7
- package/dist/index.js.map +1 -1
- package/dist/loader.css +1 -1
- package/dist/{music-CFEC7HKL.js → music-FUN7N225.js} +3 -3
- package/dist/{music-CFEC7HKL.js.map → music-FUN7N225.js.map} +1 -1
- package/dist/{music-UAN7DXK4.cjs → music-GEAH2XCT.cjs} +7 -7
- package/dist/{music-UAN7DXK4.cjs.map → music-GEAH2XCT.cjs.map} +1 -1
- package/dist/{sfx-EX4PUBMV.cjs → sfx-2DYTYNYW.cjs} +8 -8
- package/dist/{sfx-EX4PUBMV.cjs.map → sfx-2DYTYNYW.cjs.map} +1 -1
- package/dist/{sfx-U3GM2MED.js → sfx-3IDAJ3UZ.js} +3 -3
- package/dist/{sfx-U3GM2MED.js.map → sfx-3IDAJ3UZ.js.map} +1 -1
- package/dist/three.cjs +7 -6
- package/dist/three.cjs.map +1 -1
- package/dist/three.d.cts +2 -2
- package/dist/three.d.ts +2 -2
- package/dist/three.js +3 -2
- package/dist/three.js.map +1 -1
- package/dist/{types-YmUaViL1.d.cts → types-DBbZVKGS.d.cts} +7 -4
- package/dist/{types-YmUaViL1.d.ts → types-DBbZVKGS.d.ts} +7 -4
- package/docs/dsl.md +82 -3
- package/llms-full.txt +155 -14
- package/package.json +1 -1
- package/dist/Composition-6PA4C4TV.js +0 -5
- package/dist/Composition-LL2XXU5N.cjs +0 -14
- package/dist/chunk-DQHXVNOI.js.map +0 -1
- package/dist/chunk-FFYA3UBU.cjs.map +0 -1
- package/dist/chunk-MNM56B3X.js.map +0 -1
- package/dist/chunk-NO26HWR7.cjs.map +0 -1
- package/dist/chunk-TSPMKV2F.js.map +0 -1
- package/dist/chunk-WTRKDIKH.cjs.map +0 -1
|
@@ -34,7 +34,17 @@ var COMMON_ALIASES = {
|
|
|
34
34
|
angle: "degrees",
|
|
35
35
|
playbackrate: "speed",
|
|
36
36
|
timescale: "speed",
|
|
37
|
-
rate: "speed"
|
|
37
|
+
rate: "speed",
|
|
38
|
+
// blend modes by the names other programs use
|
|
39
|
+
"linear-dodge": "add",
|
|
40
|
+
"linear dodge": "add",
|
|
41
|
+
lineardodge: "add",
|
|
42
|
+
linear_dodge: "add",
|
|
43
|
+
"plus-lighter": "add",
|
|
44
|
+
pluslighter: "add",
|
|
45
|
+
plus_lighter: "add",
|
|
46
|
+
luminance: "luminosity",
|
|
47
|
+
exclude: "exclusion"
|
|
38
48
|
};
|
|
39
49
|
function suggestName(name, valid) {
|
|
40
50
|
const n = name.toLowerCase();
|
|
@@ -63,5 +73,5 @@ function warnUnknownOptions(where, opts, valid) {
|
|
|
63
73
|
|
|
64
74
|
exports.suggestName = suggestName;
|
|
65
75
|
exports.warnUnknownOptions = warnUnknownOptions;
|
|
66
|
-
//# sourceMappingURL=chunk-
|
|
67
|
-
//# sourceMappingURL=chunk-
|
|
76
|
+
//# sourceMappingURL=chun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AE,MAAA,IAAU,GAAA;AACvD,IAAA,IAAI,CAAC,QAAQ,KAAA,GAAQ,IAAA,CAAK,OAAO,IAAA,GAAO,EAAE,GAAG,KAAA,EAAM;AAAA,EACrD;AACA,EAAA,OAAO,IAAA,GAAO,KAAK,CAAA,GAAI,IAAA;AACzB;AAMO,SAAS,kBAAA,CAAmB,KAAA,EAAe,IAAA,EAAiC,KAAA,EAAgC;AACjH,EAAA,IAAI,CAAC,IAAA,IAAQ,OAAO,IAAA,KAAS,QAAA,EAAU;AACvC,EAAA,KAAA,MAAW,GAAA,IAAO,MAAA,CAAO,IAAA,CAAK,IAAI,CAAA,EAAG;AACnC,IAAA,IAAI,KAAA,CAAM,QAAA,CAAS,GAAG,CAAA,EAAG;AACzB,IAAA,MAAM,KAAA,GAAQ,WAAA,CAAY,GAAA,EAAK,KAAK,CAAA;AACpC,IAAA,OAAA,CAAQ,KAAK,CAAA,cAAA,EAAiB,KAAK,CAAA,kBAAA,EAAqB,GAAG,IAAI,KAAA,GAAQ,CAAA,sBAAA,EAAoB,KAAK,CAAA,EAAA,CAAA,GAAO,EAAE,CAAA,SAAA,EAAY,KAAA,CAAM,IAAA,CAAK,IAAI,CAAC,CAAA,CAAA,CAAG,CAAA;AAAA,EAC1I;AACF","file":"chunk-UZTKEYFP.cjs","sourcesContent":["/** Edit distance, small inputs only. */\nfunction distance(a: string, b: string): number {\n const dp = Array.from({ length: a.length + 1 }, (_, i) => [i, ...Array(b.length).fill(0)] as number[]);\n for (let j = 1; j <= b.length; j++) dp[0]![j] = j;\n for (let i = 1; i <= a.length; i++) {\n for (let j = 1; j <= b.length; j++) {\n dp[i]![j] = Math.min(dp[i - 1]![j]! + 1, dp[i]![j - 1]! + 1, dp[i - 1]![j - 1]! + (a[i - 1] === b[j - 1] ? 0 : 1));\n // swapping two neighbouring letters (sacle / scale) counts as one slip\n if (i > 1 && j > 1 && a[i - 1] === b[j - 2] && a[i - 2] === b[j - 1]) dp[i]![j] = Math.min(dp[i]![j]!, dp[i - 2]![j - 2]! + 1);\n }\n }\n return dp[a.length]![b.length]!;\n}\n\nconst isSubsequence = (small: string, big: string): boolean => {\n let i = 0;\n for (const ch of big) if (i < small.length && ch === small[i]) i++;\n return i === small.length;\n};\n\n/** Names AI authors commonly guess, mapped to the real option (only suggested when the real option exists here). */\nconst COMMON_ALIASES: Record<string, string> = {\n fps: 'frameRate', framerate: 'frameRate', frame_rate: 'frameRate',\n bg: 'background', backgroundcolor: 'background', bgcolor: 'background',\n seconds: 'duration', length: 'duration', time: 'duration',\n w: 'width', h: 'height', cols: 'columns', sweep: 'degrees', angle: 'degrees',\n playbackrate: 'speed', timescale: 'speed', rate: 'speed',\n // blend modes by the names other programs use\n 'linear-dodge': 'add', 'linear dodge': 'add', lineardodge: 'add', linear_dodge: 'add', 'plus-lighter': 'add', pluslighter: 'add', plus_lighter: 'add',\n luminance: 'luminosity', exclude: 'exclusion',\n};\n\n/** The valid name an author most likely meant by `name` (alias, typo, abbreviation or case slip), or null. */\nexport function suggestName(name: string, valid: readonly string[]): string | null {\n const n = name.toLowerCase();\n const alias = COMMON_ALIASES[n];\n if (alias && valid.includes(alias)) return alias;\n let best: { v: string; score: number } | null = null;\n for (const v of valid) {\n const lv = v.toLowerCase();\n const d = distance(n, lv);\n const close = d <= Math.max(1, Math.floor(Math.min(n.length, lv.length) / 3));\n // an abbreviation (cols → columns) or a longer phrase containing the name (fadeIn → in)\n const abbreviation = (n.length >= 3 && isSubsequence(n, lv)) || (lv.length >= 2 && n.length > lv.length && n.includes(lv));\n if (!close && !abbreviation) continue;\n const score = close ? d : 3 + (lv.length - n.length) / 100; // typos first, then abbreviations\n if (!best || score < best.score) best = { v, score };\n }\n return best ? best.v : null;\n}\n\n/**\n * Unknown option keys are silently ignored by JavaScript, which is how a guessed name like `cols`\n * or `fps` quietly does nothing. Say so, and say what was probably meant.\n */\nexport function warnUnknownOptions(where: string, opts: object | undefined | null, valid: readonly string[]): void {\n if (!opts || typeof opts !== 'object') return;\n for (const key of Object.keys(opts)) {\n if (valid.includes(key)) continue;\n const guess = suggestName(key, valid);\n console.warn(`pixi-effects: ${where}: unknown option \"${key}\"${guess ? ` — did you mean \"${guess}\"?` : ''} (valid: ${valid.join(', ')})`);\n }\n}\n"]}
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
import { describeLayer } from './chunk-E7RONUZ7.js';
|
|
2
|
+
import { suggestName } from './chunk-NHICCDTC.js';
|
|
3
|
+
|
|
4
|
+
// src/core/blend.ts
|
|
5
|
+
var BASIC_BLEND_MODES = ["normal", "add", "screen", "multiply"];
|
|
6
|
+
var ADVANCED_BLEND_MODES = [
|
|
7
|
+
"overlay",
|
|
8
|
+
"soft-light",
|
|
9
|
+
"hard-light",
|
|
10
|
+
"color-dodge",
|
|
11
|
+
"color-burn",
|
|
12
|
+
"darken",
|
|
13
|
+
"lighten",
|
|
14
|
+
"difference",
|
|
15
|
+
"exclusion",
|
|
16
|
+
"hue",
|
|
17
|
+
"saturation",
|
|
18
|
+
"color",
|
|
19
|
+
"luminosity",
|
|
20
|
+
"linear-burn"
|
|
21
|
+
];
|
|
22
|
+
var BLEND_MODES = [...BASIC_BLEND_MODES, ...ADVANCED_BLEND_MODES];
|
|
23
|
+
function isAdvancedBlend(mode) {
|
|
24
|
+
return typeof mode === "string" && ADVANCED_BLEND_MODES.includes(mode);
|
|
25
|
+
}
|
|
26
|
+
function blendProblem(mode) {
|
|
27
|
+
if (typeof mode === "string" && BLEND_MODES.includes(mode)) return null;
|
|
28
|
+
const guess = typeof mode === "string" ? suggestName(mode, BLEND_MODES) : null;
|
|
29
|
+
const shown = typeof mode === "string" ? `"${mode}"` : String(mode);
|
|
30
|
+
return `blendMode ${shown} is not supported${guess ? `; did you mean "${guess}"?` : ""} (use ${BLEND_MODES.join(", ")})`;
|
|
31
|
+
}
|
|
32
|
+
function usesAdvancedBlend(spec) {
|
|
33
|
+
const visit = (n) => {
|
|
34
|
+
if (!n || typeof n !== "object") return false;
|
|
35
|
+
if (Array.isArray(n)) return n.some(visit);
|
|
36
|
+
const o = n;
|
|
37
|
+
return isAdvancedBlend(o.blendMode) || visit(o.sequences) || visit(o.mask);
|
|
38
|
+
};
|
|
39
|
+
return visit(spec);
|
|
40
|
+
}
|
|
41
|
+
var sayNow = (message, spec) => console.warn(`pixi-effects: ${describeLayer(spec)}: ${message}`);
|
|
42
|
+
function blendUnavailableMessage(mode) {
|
|
43
|
+
return `blendMode "${mode}" could not be set up (the blend filters are not registered); the layer is drawn normal`;
|
|
44
|
+
}
|
|
45
|
+
function applyBlendMode(spec, display, report = sayNow) {
|
|
46
|
+
const mode = spec.blendMode;
|
|
47
|
+
if (mode === void 0) return null;
|
|
48
|
+
const problem = blendProblem(mode);
|
|
49
|
+
if (problem) {
|
|
50
|
+
report(problem, spec);
|
|
51
|
+
return null;
|
|
52
|
+
}
|
|
53
|
+
if (isAdvancedBlend(mode) && !blendRegistered()) {
|
|
54
|
+
report(blendUnavailableMessage(mode), spec);
|
|
55
|
+
return null;
|
|
56
|
+
}
|
|
57
|
+
const filters = display.filters;
|
|
58
|
+
if (Array.isArray(filters) && filters.length > 0) {
|
|
59
|
+
if (isAdvancedBlend(mode)) {
|
|
60
|
+
const blend = blendFilterFor(mode);
|
|
61
|
+
if (!blend) {
|
|
62
|
+
report(blendUnavailableMessage(mode), spec);
|
|
63
|
+
return null;
|
|
64
|
+
}
|
|
65
|
+
display.filters = [...filters, blend];
|
|
66
|
+
return blend;
|
|
67
|
+
}
|
|
68
|
+
filters[filters.length - 1].blendMode = mode;
|
|
69
|
+
return null;
|
|
70
|
+
}
|
|
71
|
+
display.blendMode = mode;
|
|
72
|
+
return null;
|
|
73
|
+
}
|
|
74
|
+
var factory = null;
|
|
75
|
+
function setBlendFilterFactory(f) {
|
|
76
|
+
factory = f;
|
|
77
|
+
}
|
|
78
|
+
function blendRegistered() {
|
|
79
|
+
return factory !== null;
|
|
80
|
+
}
|
|
81
|
+
function blendFilterFor(mode) {
|
|
82
|
+
return isAdvancedBlend(mode) && factory ? factory(mode) : null;
|
|
83
|
+
}
|
|
84
|
+
async function enableAdvancedBlend(renderer) {
|
|
85
|
+
try {
|
|
86
|
+
const { registerBlendModes } = await import('./blendModes-HCP5XTNP.js');
|
|
87
|
+
registerBlendModes();
|
|
88
|
+
} catch (e) {
|
|
89
|
+
const why = e instanceof Error ? e.message : String(e);
|
|
90
|
+
console.warn(`pixi-effects: the blend filters could not be loaded (${why}); layers with an advanced blendMode are drawn normal. Serve the whole dist/ folder (the filters are the blendModes-*.js file next to index.js)`);
|
|
91
|
+
return;
|
|
92
|
+
}
|
|
93
|
+
const bb = renderer.backBuffer;
|
|
94
|
+
if (bb) bb.useBackBuffer = true;
|
|
95
|
+
}
|
|
96
|
+
var MANY_ADVANCED = 10;
|
|
97
|
+
function drawnLeaves(sequences) {
|
|
98
|
+
if (!Array.isArray(sequences)) return 0;
|
|
99
|
+
let n = 0;
|
|
100
|
+
for (const s of sequences) {
|
|
101
|
+
if (!s || s.type === "null" || s.type === "camera" || s.type === "audio") continue;
|
|
102
|
+
n += s.type === "composition" ? drawnLeaves(s.sequences) : 1;
|
|
103
|
+
}
|
|
104
|
+
return n;
|
|
105
|
+
}
|
|
106
|
+
function passesOf(l, span) {
|
|
107
|
+
const isComposition = l.type === "composition";
|
|
108
|
+
if (isAdvancedBlend(l.blendMode)) return isComposition ? Math.max(1, drawnLeaves(l.sequences)) : 1;
|
|
109
|
+
return isComposition && Array.isArray(l.sequences) ? maxConcurrentAdvanced(l.sequences, l.duration ?? span) : 0;
|
|
110
|
+
}
|
|
111
|
+
function maxConcurrentAdvanced(layers, span) {
|
|
112
|
+
const events = [];
|
|
113
|
+
for (const l of layers) {
|
|
114
|
+
const w = passesOf(l, span);
|
|
115
|
+
if (w === 0) continue;
|
|
116
|
+
const at = l.at ?? 0;
|
|
117
|
+
const end = l.duration === void 0 ? span : at + l.duration;
|
|
118
|
+
const start = Math.max(0, at);
|
|
119
|
+
if (end > start) events.push([start, w], [end, -w]);
|
|
120
|
+
}
|
|
121
|
+
events.sort((a, b) => a[0] - b[0] || a[1] - b[1]);
|
|
122
|
+
let now = 0, most = 0;
|
|
123
|
+
for (const [, d] of events) {
|
|
124
|
+
now += d;
|
|
125
|
+
most = Math.max(most, now);
|
|
126
|
+
}
|
|
127
|
+
return most;
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
export { MANY_ADVANCED, applyBlendMode, blendFilterFor, blendProblem, blendUnavailableMessage, enableAdvancedBlend, isAdvancedBlend, maxConcurrentAdvanced, setBlendFilterFactory, usesAdvancedBlend };
|
|
131
|
+
//# sourceMappingURL=chunk-YEPDQ7I3.js.map
|
|
132
|
+
//# sourceMappingURL=chunk-YEPDQ7I3.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/core/blend.ts"],"names":[],"mappings":";;;;AAIO,IAAM,iBAAA,GAAoB,CAAC,QAAA,EAAU,KAAA,EAAO,UAAU,UAAU,CAAA;AAEhE,IAAM,oBAAA,GAAuB;AAAA,EAClC,SAAA;AAAA,EAAW,YAAA;AAAA,EAAc,YAAA;AAAA,EAAc,aAAA;AAAA,EAAe,YAAA;AAAA,EAAc,QAAA;AAAA,EAAU,SAAA;AAAA,EAAW,YAAA;AAAA,EAAc,WAAA;AAAA,EACvG,KAAA;AAAA,EAAO,YAAA;AAAA,EAAc,OAAA;AAAA,EAAS,YAAA;AAAA,EAAc;AAC9C,CAAA;AAEO,IAAM,WAAA,GAAiC,CAAC,GAAG,iBAAA,EAAmB,GAAG,oBAAoB,CAAA;AAErF,SAAS,gBAAgB,IAAA,EAAwB;AACtD,EAAA,OAAO,OAAO,IAAA,KAAS,QAAA,IAAa,oBAAA,CAA2C,SAAS,IAAI,CAAA;AAC9F;AAGO,SAAS,aAAa,IAAA,EAA8B;AACzD,EAAA,IAAI,OAAO,IAAA,KAAS,QAAA,IAAY,YAAY,QAAA,CAAS,IAAI,GAAG,OAAO,IAAA;AACnE,EAAA,MAAM,QAAQ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AAA,GAAA,IAAO,CAAA;AAAG,IAAA,IAAA,GAAO,IAAA,CAAK,GAAA,CAAI,IAAA,EAAM,GAAG,CAAA;AAAA,EAAG;AACpE,EAAA,OAAO,IAAA;AACT","file":"chunk-YEPDQ7I3.js","sourcesContent":["import { describeLayer } from './lint';\nimport { suggestName } from './options';\n\n/** The modes Pixi draws itself (`add`, `screen`, `multiply`) and `normal`. */\nexport const BASIC_BLEND_MODES = ['normal', 'add', 'screen', 'multiply'] as const;\n/** The modes that need the backdrop: our own `BlendModeFilter`s (`src/filters/blendModes.ts`), loaded only when a movie uses one. */\nexport const ADVANCED_BLEND_MODES = [\n 'overlay', 'soft-light', 'hard-light', 'color-dodge', 'color-burn', 'darken', 'lighten', 'difference', 'exclusion',\n 'hue', 'saturation', 'color', 'luminosity', 'linear-burn',\n] as const;\n/** Every `blendMode` there is (the one table the warnings, the types and the docs check against). */\nexport const BLEND_MODES: readonly string[] = [...BASIC_BLEND_MODES, ...ADVANCED_BLEND_MODES];\n\nexport function isAdvancedBlend(mode: unknown): boolean {\n return typeof mode === 'string' && (ADVANCED_BLEND_MODES as readonly string[]).includes(mode);\n}\n\n/** Why `mode` is not a blend mode, with the likely name and the choices; null when it is one. */\nexport function blendProblem(mode: unknown): string | null {\n if (typeof mode === 'string' && BLEND_MODES.includes(mode)) return null;\n const guess = typeof mode === 'string' ? suggestName(mode, BLEND_MODES) : null;\n const shown = typeof mode === 'string' ? `\"${mode}\"` : String(mode);\n return `blendMode ${shown} is not supported${guess ? `; did you mean \"${guess}\"?` : ''} (use ${BLEND_MODES.join(', ')})`;\n}\n\n/** Does any layer of this composition (or one nested in it, or a mask layer) use an advanced blend? */\nexport function usesAdvancedBlend(spec: unknown): boolean {\n const visit = (n: unknown): boolean => {\n if (!n || typeof n !== 'object') return false;\n if (Array.isArray(n)) return n.some(visit);\n const o = n as Record<string, unknown>;\n return isAdvancedBlend(o.blendMode) || visit(o.sequences) || visit(o.mask);\n };\n return visit(spec);\n}\n\n/** What to say about a layer's blend mode: `Composition` collects these per build, so the same mistake in 300 particle layers is said once. */\nexport type BlendReport = (message: string, spec: { name?: string; type: string }) => void;\nconst sayNow: BlendReport = (message, spec) => console.warn(`pixi-effects: ${describeLayer(spec)}: ${message}`);\n\n/** The blend filters of an advanced mode were not registered (a movie registers them in `Movie.init`, or loading them failed): the layer is drawn normal. */\nexport function blendUnavailableMessage(mode: string): string {\n return `blendMode \"${mode}\" could not be set up (the blend filters are not registered); the layer is drawn normal`;\n}\n\n/**\n * Apply a layer's `blendMode` to its display object; an unknown mode, or an advanced mode while the blend filters are not registered, says so\n * and the layer is drawn normal. Returns the blend filter it added to the layer's filter chain (the caller destroys it with the layer), if any.\n */\nexport function applyBlendMode(\n spec: { blendMode?: string; name?: string; type: string },\n display: { blendMode?: unknown; filters?: unknown },\n report: BlendReport = sayNow,\n): BlendFilterLike | null {\n const mode = spec.blendMode;\n if (mode === undefined) return null;\n const problem = blendProblem(mode);\n if (problem) { report(problem, spec); return null; }\n if (isAdvancedBlend(mode) && !blendRegistered()) { report(blendUnavailableMessage(mode), spec); return null; }\n // A container's blend mode applies INSIDE a filter's offscreen pass (against transparent black: multiply gave\n // solid black) and not to the filtered result. With filters, the pass that draws onto the backdrop is the last\n // filter's, so the mode goes there; the container stays normal.\n const filters = display.filters;\n if (Array.isArray(filters) && filters.length > 0) {\n if (isAdvancedBlend(mode)) {\n // an advanced mode is a filter of its own (it reads the backdrop): it joins the chain as the last pass\n const blend = blendFilterFor(mode);\n if (!blend) { report(blendUnavailableMessage(mode), spec); return null; }\n display.filters = [...filters, blend];\n return blend;\n }\n (filters[filters.length - 1] as { blendMode?: unknown }).blendMode = mode;\n return null;\n }\n display.blendMode = mode;\n return null;\n}\n\n/** What blend.ts needs of a blend filter (the real ones are Pixi filters; tests use plain objects). */\nexport type BlendFilterLike = { blendMode?: unknown; destroy(): void };\nlet factory: ((mode: string) => BlendFilterLike | null) | null = null;\n\n/** `filters/blendModes.ts` hands its filter maker here when it registers, so this file never imports Pixi. */\nexport function setBlendFilterFactory(f: ((mode: string) => BlendFilterLike | null) | null): void {\n factory = f;\n}\n\n/** Are the blend filters registered (a movie that uses an advanced mode registers them in `Movie.init`)? */\nexport function blendRegistered(): boolean {\n return factory !== null;\n}\n\n/** A fresh blend filter for an advanced mode, or null when the blends are not registered (or the mode is not an advanced one). */\nexport function blendFilterFor(mode: string): BlendFilterLike | null {\n return isAdvancedBlend(mode) && factory ? factory(mode) : null;\n}\n\n/**\n * Called by `Movie.init` when a layer uses an advanced mode, and only then: loads our blend filters (a separate chunk), registers them on\n * the pixi the movie runs on, and on WebGL turns the back buffer on (an advanced blend reads what is already drawn; WebGPU copies the\n * backdrop by itself, and has no such switch). A movie that uses none never reaches this, so nothing about it changes.\n */\nexport async function enableAdvancedBlend(renderer: unknown): Promise<void> {\n try {\n const { registerBlendModes } = await import('../filters/blendModes');\n registerBlendModes();\n } catch (e) {\n // a page that serves dist/index.js without its chunk, a CDN hiccup: the movie still plays, its advanced blends drawn normal\n const why = e instanceof Error ? e.message : String(e);\n console.warn(`pixi-effects: the blend filters could not be loaded (${why}); layers with an advanced blendMode are drawn normal. Serve the whole dist/ folder (the filters are the blendModes-*.js file next to index.js)`);\n return;\n }\n const bb = (renderer as { backBuffer?: { useBackBuffer: boolean } }).backBuffer;\n if (bb) bb.useBackBuffer = true;\n}\n\n/** This many layers with an advanced blend on screen at once is slow: each is a full-frame pass (measured on WebGL: about 1.5–2 ms each at 1080p). */\nexport const MANY_ADVANCED = 10;\n\ntype Counted = { at?: number; duration?: number; blendMode?: unknown; type?: string; sequences?: unknown };\n\n/** The layers a composition draws (its children each blend one by one when it has a mode): null, camera and audio layers draw nothing; nested compositions are walked. */\nfunction drawnLeaves(sequences: unknown): number {\n if (!Array.isArray(sequences)) return 0;\n let n = 0;\n for (const s of sequences as Counted[]) {\n if (!s || s.type === 'null' || s.type === 'camera' || s.type === 'audio') continue;\n n += s.type === 'composition' ? drawnLeaves(s.sequences) : 1;\n }\n return n;\n}\n\n/**\n * The full-frame passes one layer costs while it is on screen: 1 for a layer with an advanced mode; for a composition with one, one for each\n * drawn layer inside it (its children inherit the mode and blend one by one); for a composition without, the most that its own layers add\n * at one instant (a card with three blends in it, on screen with four other cards, is twelve).\n */\nfunction passesOf(l: Counted, span: number): number {\n const isComposition = l.type === 'composition';\n if (isAdvancedBlend(l.blendMode)) return isComposition ? Math.max(1, drawnLeaves(l.sequences)) : 1;\n return isComposition && Array.isArray(l.sequences) ? maxConcurrentAdvanced(l.sequences as Counted[], l.duration ?? span) : 0;\n}\n\n/** The most full-frame advanced-blend passes on screen at one instant, from the layers' `at` and `duration` (a layer with no duration lasts to the end). */\nexport function maxConcurrentAdvanced(layers: ReadonlyArray<Counted>, span: number): number {\n const events: Array<[number, number]> = [];\n for (const l of layers) {\n const w = passesOf(l, span);\n if (w === 0) continue;\n const at = l.at ?? 0;\n const end = l.duration === undefined ? span : at + l.duration;\n const start = Math.max(0, at); // a negative `at` starts before the composition: only what is after 0 is on screen\n if (end > start) events.push([start, w], [end, -w]);\n }\n events.sort((a, b) => a[0] - b[0] || a[1] - b[1]); // at one instant, the layers that end go before the ones that start\n let now = 0, most = 0;\n for (const [, d] of events) { now += d; most = Math.max(most, now); }\n return most;\n}\n"]}
|