pixi-effects 0.19.0 → 0.20.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 (69) hide show
  1. package/CHANGELOG.md +31 -0
  2. package/README.md +6 -6
  3. package/ai/SKILL.md +1 -0
  4. package/ai/chat-template.html +3 -3
  5. package/ai/reference/cheatsheet.md +7 -6
  6. package/ai/reference/pitfalls.md +5 -0
  7. package/ai/reference/recipes.md +52 -0
  8. package/ai/template.html +5 -5
  9. package/ai/tools/check.mjs +15 -3
  10. package/dist/{Base-B4WbUJO2.d.ts → Base-CzfLGoDr.d.ts} +9 -1
  11. package/dist/{Base-i88XXaiP.d.cts → Base-wYJQ2g5Q.d.cts} +9 -1
  12. package/dist/Composition-6PA4C4TV.js +5 -0
  13. package/dist/{Composition-QBKEEJBV.js.map → Composition-6PA4C4TV.js.map} +1 -1
  14. package/dist/Composition-LL2XXU5N.cjs +14 -0
  15. package/dist/{Composition-KYNPRWK3.cjs.map → Composition-LL2XXU5N.cjs.map} +1 -1
  16. package/dist/Controller.cjs +2 -2
  17. package/dist/Controller.d.cts +2 -2
  18. package/dist/Controller.d.ts +2 -2
  19. package/dist/Controller.js +1 -1
  20. package/dist/{Movie-8IrqL3kO.d.ts → Movie-CBxGH5ms.d.ts} +8 -2
  21. package/dist/{Movie-CpmdNadg.d.cts → Movie-CzzJw8A-.d.cts} +8 -2
  22. package/dist/Presenter.cjs +2 -2
  23. package/dist/Presenter.d.cts +2 -2
  24. package/dist/Presenter.d.ts +2 -2
  25. package/dist/Presenter.js +1 -1
  26. package/dist/{chunk-YRXTKOV5.js → chunk-DQHXVNOI.js} +282 -23
  27. package/dist/chunk-DQHXVNOI.js.map +1 -0
  28. package/dist/{chunk-CTZRFSVU.cjs → chunk-FFYA3UBU.cjs} +144 -37
  29. package/dist/chunk-FFYA3UBU.cjs.map +1 -0
  30. package/dist/{chunk-DKGG7WD4.js → chunk-MNM56B3X.js} +6 -3
  31. package/dist/chunk-MNM56B3X.js.map +1 -0
  32. package/dist/{chunk-VTBT6NNE.cjs → chunk-NO26HWR7.cjs} +294 -30
  33. package/dist/chunk-NO26HWR7.cjs.map +1 -0
  34. package/dist/{chunk-B3YB2TNY.js → chunk-TSPMKV2F.js} +120 -13
  35. package/dist/chunk-TSPMKV2F.js.map +1 -0
  36. package/dist/{chunk-UQBGW5DO.cjs → chunk-WTRKDIKH.cjs} +6 -3
  37. package/dist/chunk-WTRKDIKH.cjs.map +1 -0
  38. package/dist/index.cjs +213 -90
  39. package/dist/index.cjs.map +1 -1
  40. package/dist/index.d.cts +4 -4
  41. package/dist/index.d.ts +4 -4
  42. package/dist/index.js +154 -31
  43. package/dist/index.js.map +1 -1
  44. package/dist/loader.css +1 -1
  45. package/dist/{music-4HDFULNR.js → music-CFEC7HKL.js} +3 -3
  46. package/dist/{music-4HDFULNR.js.map → music-CFEC7HKL.js.map} +1 -1
  47. package/dist/{music-3OF5C6X5.cjs → music-UAN7DXK4.cjs} +7 -7
  48. package/dist/{music-3OF5C6X5.cjs.map → music-UAN7DXK4.cjs.map} +1 -1
  49. package/dist/{sfx-MZJZXYY3.cjs → sfx-EX4PUBMV.cjs} +8 -8
  50. package/dist/{sfx-MZJZXYY3.cjs.map → sfx-EX4PUBMV.cjs.map} +1 -1
  51. package/dist/{sfx-S37DDC66.js → sfx-U3GM2MED.js} +3 -3
  52. package/dist/{sfx-S37DDC66.js.map → sfx-U3GM2MED.js.map} +1 -1
  53. package/dist/three.cjs +6 -6
  54. package/dist/three.d.cts +2 -2
  55. package/dist/three.d.ts +2 -2
  56. package/dist/three.js +2 -2
  57. package/dist/{types-bzLJ7aUx.d.ts → types-YmUaViL1.d.cts} +24 -0
  58. package/dist/{types-bzLJ7aUx.d.cts → types-YmUaViL1.d.ts} +24 -0
  59. package/docs/dsl.md +22 -0
  60. package/llms-full.txt +87 -6
  61. package/package.json +3 -1
  62. package/dist/Composition-KYNPRWK3.cjs +0 -14
  63. package/dist/Composition-QBKEEJBV.js +0 -5
  64. package/dist/chunk-B3YB2TNY.js.map +0 -1
  65. package/dist/chunk-CTZRFSVU.cjs.map +0 -1
  66. package/dist/chunk-DKGG7WD4.js.map +0 -1
  67. package/dist/chunk-UQBGW5DO.cjs.map +0 -1
  68. package/dist/chunk-VTBT6NNE.cjs.map +0 -1
  69. package/dist/chunk-YRXTKOV5.js.map +0 -1
package/dist/index.d.cts CHANGED
@@ -1,7 +1,7 @@
1
- export { A as AudioInspectOptions, a as AudioReport, b as AudioSourceReport, C as ContactSheetOptions, F as FontReport, c as FrameEvent, I as InspectOptions, d as InspectReport, e as IssueGroup, L as LayerInfo, f as LoaderOption, M as MotionBlurOptions, g as MotionBlurSpec, h as Movie, i as MovieErrorEvent, j as MovieOptions, O as OnionSkinOptions, P as ProgressEvent, R as RenderOptions, k as ReviewOptions, l as ReviewReport, S as SnapshotOptions, m as SoundMeasure, n as StopEvent, o as StopImage, p as StopImagesOptions, T as TimelineData, q as TimelineHtmlOptions, r as TimelineRow, s as TimelineSvgOptions, t as TimelineTransition, V as VolumeEvent, u as dismissLoader, v as failLoader, w as resolveLoader } from './Movie-CpmdNadg.cjs';
2
- import { S as SequenceSpec, C as CompositionShape, I as ImageSequenceSpec, a as CameraSequenceSpec, K as Keyframe, T as TextSequenceSpec, M as MusicOptions, P as Props, b as TransitionSpec, c as CompositionSpec, d as SequenceCommon } from './types-bzLJ7aUx.cjs';
3
- export { A as ArcShapeSpec, e as AssetSpec, f as AudioAssetSpec, g as AudioMusicSpec, h as AudioSequenceSpec, i as AudioSfxSpec, j as ChromaKeyFilterSpec, k as CircleShapeSpec, l as CompositionSequenceSpec, m as CrossfadeTransition, n as CustomFilterSpec, D as DipTransition, o as DissolveTransition, E as EllipseShapeSpec, p as Expr, F as FilterSpec, G as GradientSpec, q as IrisTransition, L as LineShapeSpec, r as MusicDrum, s as MusicDrums, t as MusicInstrument, u as MusicLevel, v as MusicTrack, N as NullSequenceSpec, w as PathShapeSpec, x as PolygonShapeSpec, y as PropValue, R as RectShapeSpec, z as SfxKnobs, B as SfxOptions, H as SfxPreset, J as SfxVoice, O as ShapeSequenceSpec, Q as SlideTransition, U as Stop, V as StopSpec, W as TransitionCommon, X as VideoSequenceSpec, Y as WipeTransition, Z as ZoomTransition, _ as normalizeStops, $ as pictureStops } from './types-bzLJ7aUx.cjs';
4
- import { S as Sequence } from './Base-i88XXaiP.cjs';
1
+ export { A as AudioInspectOptions, a as AudioReport, b as AudioSourceReport, C as ContactSheetOptions, F as FontReport, c as FrameEvent, I as InspectOptions, d as InspectReport, e as IssueGroup, L as LayerInfo, f as LoaderOption, M as MotionBlurOptions, g as MotionBlurSpec, h as Movie, i as MovieErrorEvent, j as MovieOptions, O as OnionSkinOptions, P as ProgressEvent, R as RenderOptions, k as ReviewOptions, l as ReviewReport, S as SnapshotOptions, m as SoundMeasure, n as StopEvent, o as StopImage, p as StopImagesOptions, T as TimelineData, q as TimelineHtmlOptions, r as TimelineRow, s as TimelineSvgOptions, t as TimelineTransition, V as VolumeEvent, u as dismissLoader, v as failLoader, w as resolveLoader } from './Movie-CzzJw8A-.cjs';
2
+ import { S as SequenceSpec, C as CompositionShape, I as ImageSequenceSpec, a as CameraSequenceSpec, K as Keyframe, T as TextSequenceSpec, M as MusicOptions, P as Props, b as TransitionSpec, c as CompositionSpec, d as SequenceCommon } from './types-YmUaViL1.cjs';
3
+ export { A as ArcShapeSpec, e as AssetSpec, f as AudioAssetSpec, g as AudioMusicSpec, h as AudioSequenceSpec, i as AudioSfxSpec, j as ChromaKeyFilterSpec, k as CircleShapeSpec, l as CompositionSequenceSpec, m as CrossfadeTransition, n as CustomFilterSpec, D as DipTransition, o as DissolveTransition, E as EllipseShapeSpec, p as Expr, F as FilterSpec, G as GradientSpec, q as IrisTransition, L as LineShapeSpec, r as MusicDrum, s as MusicDrums, t as MusicInstrument, u as MusicLevel, v as MusicTrack, N as NullSequenceSpec, w as PathShapeSpec, x as PolygonShapeSpec, y as PropValue, R as RectShapeSpec, z as SfxKnobs, B as SfxOptions, H as SfxPreset, J as SfxVoice, O as ShapeSequenceSpec, Q as SlideTransition, U as Stop, V as StopSpec, W as TransitionCommon, X as VideoSequenceSpec, Y as WipeTransition, Z as ZoomTransition, _ as normalizeStops, $ as pictureStops } from './types-YmUaViL1.cjs';
4
+ import { S as Sequence } from './Base-wYJQ2g5Q.cjs';
5
5
  import 'pixi.js';
6
6
  import 'gsap';
7
7
 
package/dist/index.d.ts CHANGED
@@ -1,7 +1,7 @@
1
- export { A as AudioInspectOptions, a as AudioReport, b as AudioSourceReport, C as ContactSheetOptions, F as FontReport, c as FrameEvent, I as InspectOptions, d as InspectReport, e as IssueGroup, L as LayerInfo, f as LoaderOption, M as MotionBlurOptions, g as MotionBlurSpec, h as Movie, i as MovieErrorEvent, j as MovieOptions, O as OnionSkinOptions, P as ProgressEvent, R as RenderOptions, k as ReviewOptions, l as ReviewReport, S as SnapshotOptions, m as SoundMeasure, n as StopEvent, o as StopImage, p as StopImagesOptions, T as TimelineData, q as TimelineHtmlOptions, r as TimelineRow, s as TimelineSvgOptions, t as TimelineTransition, V as VolumeEvent, u as dismissLoader, v as failLoader, w as resolveLoader } from './Movie-8IrqL3kO.js';
2
- import { S as SequenceSpec, C as CompositionShape, I as ImageSequenceSpec, a as CameraSequenceSpec, K as Keyframe, T as TextSequenceSpec, M as MusicOptions, P as Props, b as TransitionSpec, c as CompositionSpec, d as SequenceCommon } from './types-bzLJ7aUx.js';
3
- export { A as ArcShapeSpec, e as AssetSpec, f as AudioAssetSpec, g as AudioMusicSpec, h as AudioSequenceSpec, i as AudioSfxSpec, j as ChromaKeyFilterSpec, k as CircleShapeSpec, l as CompositionSequenceSpec, m as CrossfadeTransition, n as CustomFilterSpec, D as DipTransition, o as DissolveTransition, E as EllipseShapeSpec, p as Expr, F as FilterSpec, G as GradientSpec, q as IrisTransition, L as LineShapeSpec, r as MusicDrum, s as MusicDrums, t as MusicInstrument, u as MusicLevel, v as MusicTrack, N as NullSequenceSpec, w as PathShapeSpec, x as PolygonShapeSpec, y as PropValue, R as RectShapeSpec, z as SfxKnobs, B as SfxOptions, H as SfxPreset, J as SfxVoice, O as ShapeSequenceSpec, Q as SlideTransition, U as Stop, V as StopSpec, W as TransitionCommon, X as VideoSequenceSpec, Y as WipeTransition, Z as ZoomTransition, _ as normalizeStops, $ as pictureStops } from './types-bzLJ7aUx.js';
4
- import { S as Sequence } from './Base-B4WbUJO2.js';
1
+ export { A as AudioInspectOptions, a as AudioReport, b as AudioSourceReport, C as ContactSheetOptions, F as FontReport, c as FrameEvent, I as InspectOptions, d as InspectReport, e as IssueGroup, L as LayerInfo, f as LoaderOption, M as MotionBlurOptions, g as MotionBlurSpec, h as Movie, i as MovieErrorEvent, j as MovieOptions, O as OnionSkinOptions, P as ProgressEvent, R as RenderOptions, k as ReviewOptions, l as ReviewReport, S as SnapshotOptions, m as SoundMeasure, n as StopEvent, o as StopImage, p as StopImagesOptions, T as TimelineData, q as TimelineHtmlOptions, r as TimelineRow, s as TimelineSvgOptions, t as TimelineTransition, V as VolumeEvent, u as dismissLoader, v as failLoader, w as resolveLoader } from './Movie-CBxGH5ms.js';
2
+ import { S as SequenceSpec, C as CompositionShape, I as ImageSequenceSpec, a as CameraSequenceSpec, K as Keyframe, T as TextSequenceSpec, M as MusicOptions, P as Props, b as TransitionSpec, c as CompositionSpec, d as SequenceCommon } from './types-YmUaViL1.js';
3
+ export { A as ArcShapeSpec, e as AssetSpec, f as AudioAssetSpec, g as AudioMusicSpec, h as AudioSequenceSpec, i as AudioSfxSpec, j as ChromaKeyFilterSpec, k as CircleShapeSpec, l as CompositionSequenceSpec, m as CrossfadeTransition, n as CustomFilterSpec, D as DipTransition, o as DissolveTransition, E as EllipseShapeSpec, p as Expr, F as FilterSpec, G as GradientSpec, q as IrisTransition, L as LineShapeSpec, r as MusicDrum, s as MusicDrums, t as MusicInstrument, u as MusicLevel, v as MusicTrack, N as NullSequenceSpec, w as PathShapeSpec, x as PolygonShapeSpec, y as PropValue, R as RectShapeSpec, z as SfxKnobs, B as SfxOptions, H as SfxPreset, J as SfxVoice, O as ShapeSequenceSpec, Q as SlideTransition, U as Stop, V as StopSpec, W as TransitionCommon, X as VideoSequenceSpec, Y as WipeTransition, Z as ZoomTransition, _ as normalizeStops, $ as pictureStops } from './types-YmUaViL1.js';
4
+ import { S as Sequence } from './Base-CzfLGoDr.js';
5
5
  import 'pixi.js';
6
6
  import 'gsap';
7
7
 
package/dist/index.js CHANGED
@@ -1,7 +1,7 @@
1
- import { CompositionSequence } from './chunk-B3YB2TNY.js';
2
- import { ensureFilterLibrary, homeDistance, DEFAULT_FOV, random, noise, flattenSvgPath, rand, DEG, resolveAt, checkEase, collectPropKeys } from './chunk-YRXTKOV5.js';
3
- export { noise, rand, random, registerSequenceType } from './chunk-YRXTKOV5.js';
4
- import { warnUnknownOptions, suggestName } from './chunk-DKGG7WD4.js';
1
+ import { CompositionSequence } from './chunk-TSPMKV2F.js';
2
+ import { ensureFilterLibrary, homeDistance, DEFAULT_FOV, random, noise, flattenSvgPath, rand, DEG, timeRemapOf, contentLength, resolveAt, checkEase, collectPropKeys } from './chunk-DQHXVNOI.js';
3
+ export { noise, rand, random, registerSequenceType } from './chunk-DQHXVNOI.js';
4
+ import { warnUnknownOptions, suggestName } from './chunk-MNM56B3X.js';
5
5
  import * as PIXI from 'pixi.js';
6
6
  import { extensions, CullerPlugin, Application, Container, Rectangle, Culler, CanvasTextMetrics, TextStyle, Assets, ExtensionType, Filter, UniformGroup, GpuProgram, GlProgram, defaultFilterVert } from 'pixi.js';
7
7
  import { gsap } from 'gsap';
@@ -65,6 +65,85 @@ async function loadAssetBundle(assets, audioContext) {
65
65
  return await Assets.loadBundle("pixi-effects");
66
66
  }
67
67
 
68
+ // src/core/audioRemap.ts
69
+ function gainAt(a, u) {
70
+ let prevT = a.start, prevV = a.initialVolume ?? 1;
71
+ if (u <= prevT) return prevV;
72
+ for (const kf of a.volumeKeyframes ?? []) {
73
+ if (u <= kf.time) return kf.time === prevT ? kf.value : prevV + (kf.value - prevV) * ((u - prevT) / (kf.time - prevT));
74
+ prevT = kf.time;
75
+ prevV = kf.value;
76
+ }
77
+ return prevV;
78
+ }
79
+ var CELL = 1 / 1e3;
80
+ function resampleThrough(a, left, right, srcRate, outRate, total) {
81
+ const nCell = Math.ceil(total / CELL) + 2;
82
+ const U = new Float64Array(nCell);
83
+ let first = -1, last = -1;
84
+ for (let k = 0; k < nCell; k++) {
85
+ const u = a.warp ? a.warp(k * CELL) : k * CELL;
86
+ U[k] = u;
87
+ if (Number.isFinite(u) && u >= a.start && u < a.end) {
88
+ if (first < 0) first = k;
89
+ last = k;
90
+ }
91
+ }
92
+ if (first < 0) return null;
93
+ const lo = Math.max(0, (first - 1) * CELL), hi = Math.min(total, (last + 2) * CELL);
94
+ const n = Math.max(1, Math.ceil((hi - lo) * outRate));
95
+ const L = new Float32Array(n), R = new Float32Array(n);
96
+ const dur = left.length / srcRate;
97
+ let prevPos = NaN;
98
+ for (let i = 0; i < n; i++) {
99
+ const T = lo + i / outRate;
100
+ const x = T / CELL, k = Math.min(Math.floor(x), nCell - 2), f = x - k;
101
+ const u0 = U[k], u1 = U[k + 1];
102
+ if (!(Number.isFinite(u0) && Number.isFinite(u1))) {
103
+ prevPos = NaN;
104
+ continue;
105
+ }
106
+ const u = u0 * (1 - f) + u1 * f;
107
+ if (u < a.start || u >= a.end) {
108
+ prevPos = NaN;
109
+ continue;
110
+ }
111
+ const raw = a.sourceMap ? a.sourceMap(u) : u - a.start;
112
+ let pos = raw;
113
+ if (a.loop) pos = (pos % dur + dur) % dur;
114
+ const rate = Number.isNaN(prevPos) ? 1 : Math.abs(raw - prevPos) * outRate;
115
+ prevPos = raw;
116
+ if (pos < 0 || pos >= dur) continue;
117
+ const g = gainAt(a, u) * Math.min(1, rate / 0.02);
118
+ const sp = pos * srcRate, j = Math.floor(sp), fr = sp - j, j1 = Math.min(j + 1, left.length - 1);
119
+ L[i] = (left[j] * (1 - fr) + left[j1] * fr) * g;
120
+ R[i] = (right[j] * (1 - fr) + right[j1] * fr) * g;
121
+ }
122
+ return { L, R, at: lo };
123
+ }
124
+ function playSpan(a, total) {
125
+ if (!a.warp) return { start: a.start, end: a.end };
126
+ let first = -1, last = -1;
127
+ const n = Math.ceil(total / CELL) + 1;
128
+ for (let k = 0; k <= n; k++) {
129
+ const u = a.warp(k * CELL);
130
+ if (Number.isFinite(u) && u >= a.start && u < a.end) {
131
+ if (first < 0) first = k;
132
+ last = k;
133
+ }
134
+ }
135
+ return first < 0 ? { start: total, end: total } : { start: first * CELL, end: (last + 1) * CELL };
136
+ }
137
+ function clockReach(a, total) {
138
+ let reach = -Infinity;
139
+ const n = Math.ceil(total / CELL) + 1;
140
+ for (let k = 0; k <= n; k++) {
141
+ const u = a.warp ? a.warp(k * CELL) : k * CELL;
142
+ if (Number.isFinite(u) && u > reach) reach = u;
143
+ }
144
+ return reach;
145
+ }
146
+
68
147
  // src/core/AudioMixer.ts
69
148
  async function mixdown(audios, totalDuration, sampleRate = 44100) {
70
149
  if (audios.length === 0) return null;
@@ -86,6 +165,18 @@ async function mixdown(audios, totalDuration, sampleRate = 44100) {
86
165
  for (const a of audios) {
87
166
  const buffer = bufferOf(a);
88
167
  if (!buffer) continue;
168
+ if (a.warp || a.sourceMap) {
169
+ const r = resampleThrough(a, buffer.getChannelData(0), buffer.numberOfChannels > 1 ? buffer.getChannelData(1) : buffer.getChannelData(0), buffer.sampleRate, sampleRate, totalDuration);
170
+ if (!r) continue;
171
+ const out = ctx.createBuffer(2, r.L.length, sampleRate);
172
+ out.getChannelData(0).set(r.L);
173
+ out.getChannelData(1).set(r.R);
174
+ const rendered = ctx.createBufferSource();
175
+ rendered.buffer = out;
176
+ rendered.connect(ctx.destination);
177
+ rendered.start(r.at);
178
+ continue;
179
+ }
89
180
  const begin = Math.max(0, a.start);
90
181
  const skipped = begin - a.start;
91
182
  if (skipped > 0) {
@@ -124,7 +215,7 @@ function limitMix(buffer, audios) {
124
215
  }
125
216
  const peakAt = peakIndex / buffer.sampleRate;
126
217
  if (peak > 1) {
127
- const playing = audios.filter((a) => a.start <= peakAt && peakAt < a.end).map((a) => a.layer ?? "an audio layer");
218
+ const playing = audios.map((a) => ({ a, ...playSpan(a, buffer.duration) })).filter((s) => s.start <= peakAt && peakAt < s.end).map((s) => s.a.layer ?? "an audio layer");
128
219
  console.warn(
129
220
  `pixi-effects: the audio mix peaks at ${peak.toFixed(2)} (${(20 * Math.log10(peak)).toFixed(1)} dBFS) at ${peakAt.toFixed(2)}s, so it was limited (it would distort). Playing there: ${[...new Set(playing)].join(", ")}. Lower their volume.`
130
221
  );
@@ -319,6 +410,13 @@ function measure(chans, sampleRate) {
319
410
  };
320
411
  }
321
412
  function analyzeAudio(mix, sources, stats, movieDuration, opts = {}) {
413
+ const warped = /* @__PURE__ */ new Map();
414
+ sources = sources.map((s) => {
415
+ if (!s.warp) return s;
416
+ const moved = { ...s, ...playSpan(s, movieDuration) };
417
+ warped.set(moved, { localEnd: s.end, reach: clockReach(s, movieDuration) });
418
+ return moved;
419
+ });
322
420
  if (!mix) {
323
421
  return {
324
422
  duration: movieDuration,
@@ -385,8 +483,15 @@ function analyzeAudio(mix, sources, stats, movieDuration, opts = {}) {
385
483
  } else if (ownDb < INAUDIBLE_DB || peakDb < INAUDIBLE_DB) {
386
484
  issues.push(`${layer} (${source}) is inaudible from ${s.start.toFixed(2)}s to ${s.end.toFixed(2)}s (its own peak ${ownDb} dBFS at volume ${topVolume}; mix peak there ${peakDb} dBFS) \u2014 check its volume`);
387
485
  }
388
- if (s.synth && s.end > movieDuration + 1e-6 && s.start < movieDuration) {
389
- issues.push(`${layer} (${source}) is cut off by the end of the movie at ${movieDuration}s (it runs to ${s.end.toFixed(2)}s)`);
486
+ const clock = warped.get(s);
487
+ if (s.synth && s.start < movieDuration) {
488
+ if (clock) {
489
+ if (clock.reach < clock.localEnd - 1e-3) {
490
+ issues.push(`${layer} (${source}) is cut off: its composition's clock only reaches ${clock.reach.toFixed(2)}s (the sound is ${clock.localEnd.toFixed(2)}s long), because the clock stops or the movie ends first \u2014 give the layer a shorter duration, or let the clock run on`);
491
+ }
492
+ } else if (s.end > movieDuration + 1e-6) {
493
+ issues.push(`${layer} (${source}) is cut off by the end of the movie at ${movieDuration}s (it runs to ${s.end.toFixed(2)}s)`);
494
+ }
390
495
  }
391
496
  return { layer, source, start: s.start, end: s.end, peakDb, sound };
392
497
  });
@@ -466,14 +571,20 @@ function inspectFonts(root) {
466
571
 
467
572
  // src/core/scenes.ts
468
573
  function namedScenes(rows) {
469
- return rows.filter((r) => r.depth === 0 && r.type === "composition" && !/[#×]/.test(r.name) && r.end - r.start >= 1).map((r) => ({ name: r.name, start: r.start, end: r.end }));
574
+ return rows.filter((r) => !r.local && r.depth === 0 && r.type === "composition" && !/[#×]/.test(r.name) && r.end - r.start >= 1).map((r) => ({ name: r.name, start: r.start, end: r.end }));
470
575
  }
471
576
 
472
577
  // src/core/timeFilters.ts
473
- function collectTimeFilters(seq, out = []) {
474
- for (const f of seq.filters ?? []) if (typeof f.setTime === "function") out.push(f);
475
- if (seq.maskSequence) collectTimeFilters(seq.maskSequence, out);
476
- for (const child of seq._children ?? []) collectTimeFilters(child, out);
578
+ function collectTimeFilters(seq, out = [], clock = null) {
579
+ for (const f of seq.filters ?? []) {
580
+ if (typeof f.setTime === "function") {
581
+ const tf = f;
582
+ out.push(clock ? { setTime: () => tf.setTime(clock()) } : tf);
583
+ }
584
+ }
585
+ if (seq.maskSequence) collectTimeFilters(seq.maskSequence, out, clock);
586
+ const own = seq.localClock?.() ?? clock;
587
+ for (const child of seq._children ?? []) collectTimeFilters(child, out, own);
477
588
  return out;
478
589
  }
479
590
 
@@ -498,11 +609,13 @@ var AT_HELP = "use seconds (3.5), a percentage (50%), a frame (f120) or a layer'
498
609
  function resolveAtList(list, ctx) {
499
610
  const { frameRate: fps, totalFrames, duration, rows } = ctx;
500
611
  const out = [], used = /* @__PURE__ */ new Set();
501
- const named = rows.flatMap((r) => r.parts && r.partNames ? r.partNames.map((name, i) => ({ name, start: r.parts[i].start, end: r.parts[i].end })) : [r]);
612
+ const named = rows.filter((r) => !r.local).flatMap((r) => r.parts && r.partNames ? r.partNames.map((name, i) => ({ name, start: r.parts[i].start, end: r.parts[i].end })) : [r]);
502
613
  for (const raw of String(list).split(",").map((s) => s.trim()).filter(Boolean)) {
503
614
  let frame, label, m;
504
615
  if (m = raw.match(/^(.+)@(start|mid|end)$/)) {
505
616
  const row = named.find((r) => r.name === m[1]);
617
+ const inside = row ? void 0 : rows.find((r) => r.local && r.name === m[1]);
618
+ if (inside) throw new Error(`--at "${raw}": layer "${m[1]}" is inside a time-remapped composition (${inside.local}), so its times are that composition's local seconds, not the movie's; name the composition (${inside.local.replace(/ (×.*|time keyframes)$/, "")}@${m[2]}) or give seconds`);
506
619
  if (!row) throw new Error(`--at "${raw}": no layer named "${m[1]}" (names: ${named.slice(0, 40).map((r) => r.name).join(", ")}${named.length > 40 ? ", \u2026" : ""})`);
507
620
  const t = m[2] === "start" ? row.start : m[2] === "mid" ? (row.start + row.end) / 2 : row.end - 1 / fps;
508
621
  frame = Math.round(t * fps);
@@ -599,7 +712,7 @@ function resolveRange(range2, ctx) {
599
712
  if (range2 === void 0) return { fromFrame: 0, toFrame: totalFrames, fromSec: 0, toSec: duration, partial: false };
600
713
  let from, to;
601
714
  if (typeof range2 === "string") {
602
- const rows = (ctx.rows ?? []).filter((r) => r.depth === 0).flatMap((r) => r.parts && r.partNames ? r.partNames.map((name, i) => ({ name, start: r.parts[i].start, end: r.parts[i].end })) : [r]);
715
+ const rows = (ctx.rows ?? []).filter((r) => r.depth === 0 && !r.local).flatMap((r) => r.parts && r.partNames ? r.partNames.map((name, i) => ({ name, start: r.parts[i].start, end: r.parts[i].end })) : [r]);
603
716
  const row = rows.find((r) => r.name === range2);
604
717
  if (!row) throw new Error(`pixi-effects: render({ range: "${range2}" }): no layer named "${range2}" at the top level (names: ${rows.slice(0, 40).map((r) => r.name).join(", ") || "none"}${rows.length > 40 ? ", \u2026" : ""})`);
605
718
  from = row.start;
@@ -1145,7 +1258,8 @@ function expandTransitions(spec) {
1145
1258
  }
1146
1259
  const transitions = out.transitions;
1147
1260
  const sequences = out.sequences ?? [];
1148
- const parentDuration = out.duration ?? Infinity;
1261
+ const remap = out.duration !== void 0 ? timeRemapOf(out) : null;
1262
+ const parentDuration = remap ? contentLength(remap, out.duration) : out.duration ?? Infinity;
1149
1263
  const compW = out.width;
1150
1264
  const compH = out.height;
1151
1265
  const threeDByName = new Set(sequences.filter((s) => s.name && s.threeD).map((s) => s.name));
@@ -1536,9 +1650,10 @@ function inspectScene(root, frame, time, canvas, opts = {}) {
1536
1650
  const scaledToNothing = /* @__PURE__ */ new Set();
1537
1651
  const walk2 = (comp, prefix, insideThreeD, parentVisible, parentScene, parentMoving = false, parentZero = false) => {
1538
1652
  const blending = /* @__PURE__ */ new Set();
1653
+ const now = comp.childTime(time);
1539
1654
  for (const w of transitionWindowsOf(comp.spec)) {
1540
- const start = (comp.absoluteStart ?? 0) + w.start, end = (comp.absoluteStart ?? 0) + w.end;
1541
- if (time >= start - 1e-9 && time <= end + 1e-9) {
1655
+ const start = comp.childBase + w.start, end = comp.childBase + w.end;
1656
+ if (now >= start - 1e-9 && now <= end + 1e-9) {
1542
1657
  blending.add(w.from);
1543
1658
  blending.add(w.to);
1544
1659
  }
@@ -1639,7 +1754,7 @@ function detailOf(seq) {
1639
1754
  if (s.music && typeof s.music === "object") return "music";
1640
1755
  return void 0;
1641
1756
  }
1642
- function walk(comp, parentStart, parentEnd, depth, prefix, rows, transitions) {
1757
+ function walk(comp, parentStart, parentEnd, depth, prefix, rows, transitions, local) {
1643
1758
  const entries = [];
1644
1759
  comp._children.forEach((seq, i) => {
1645
1760
  const name = seq.spec.name ?? `${seq.spec.type}#${i}`;
@@ -1647,15 +1762,18 @@ function walk(comp, parentStart, parentEnd, depth, prefix, rows, transitions) {
1647
1762
  const end = Math.min(parentEnd, seq.duration !== void 0 ? start + seq.duration : parentEnd);
1648
1763
  const span = end - start;
1649
1764
  const keys = (seq.spec.keyframes ?? []).map((kf) => round(start + resolveAt(kf.at, span))).sort((a, b) => a - b).slice(0, MAX_KEYS);
1650
- const row = { path: prefix + name, name, type: seq.spec.type, depth, start: round(start), end: round(end), keys, detail: detailOf(seq) };
1765
+ const row = { path: prefix + name, name, type: seq.spec.type, depth, start: round(start), end: round(end), keys, detail: detailOf(seq), ...local ? { local } : {} };
1651
1766
  const inner = [];
1652
1767
  const isComp = seq instanceof CompositionSequence;
1653
- if (isComp) walk(seq, start, end, depth + 1, prefix + name + "/", inner, transitions);
1768
+ if (isComp) {
1769
+ const label = seq.remapLabel();
1770
+ walk(seq, label ? 0 : start, label ? seq.contentSpan : end, depth + 1, prefix + name + "/", inner, transitions, label ? `${name} ${label}` : local);
1771
+ }
1654
1772
  entries.push({ row, inner, groupable: !isComp });
1655
1773
  });
1656
1774
  rows.push(...groupFamilies(entries));
1657
1775
  for (const w of transitionWindowsOf(comp.spec)) {
1658
- transitions.push({ from: prefix + w.from, to: prefix + w.to, start: round(parentStart + w.start), end: round(parentStart + w.end) });
1776
+ transitions.push({ from: prefix + w.from, to: prefix + w.to, start: round(parentStart + w.start), end: round(parentStart + w.end), ...local ? { local } : {} });
1659
1777
  }
1660
1778
  }
1661
1779
  function groupFamilies(entries) {
@@ -1696,7 +1814,8 @@ function groupFamilies(entries) {
1696
1814
  function collectTimeline(root, duration) {
1697
1815
  const rows = [];
1698
1816
  const transitions = [];
1699
- walk(root, 0, duration, 0, "", rows, transitions);
1817
+ const label = root.remapLabel();
1818
+ walk(root, 0, label ? root.contentSpan : duration, 0, "", rows, transitions, label ? `movie ${label}` : void 0);
1700
1819
  return { duration, rows, transitions };
1701
1820
  }
1702
1821
  var COLORS = {
@@ -1729,12 +1848,12 @@ function timelineSvg(data, opts = {}) {
1729
1848
  }
1730
1849
  if (Math.abs(data.duration % step) > 1e-9) out.push(`<text class="tick" x="${num(x(data.duration))}" y="${TOP - 12}" text-anchor="middle">${num(data.duration)} s</text>`);
1731
1850
  for (const t of data.transitions) {
1732
- out.push(`<g><title>transition ${esc(t.from)} \u2192 ${esc(t.to)} (${num(t.start)}\u2013${num(t.end)} s)</title><rect class="transition" x="${num(x(t.start))}" y="${TOP - 4}" width="${num(Math.max(2, x(t.end) - x(t.start)))}" height="${H - TOP - PAD + 4}"/></g>`);
1851
+ out.push(`<g><title>transition ${esc(t.from)} \u2192 ${esc(t.to)} (${num(t.start)}\u2013${num(t.end)} s${t.local ? `, local time of ${esc(t.local)}` : ""})</title><rect class="transition" x="${num(x(t.start))}" y="${TOP - 4}" width="${num(Math.max(2, x(t.end) - x(t.start)))}" height="${H - TOP - PAD + 4}"/></g>`);
1733
1852
  }
1734
1853
  data.rows.forEach((r, i) => {
1735
1854
  const y = TOP + i * ROW;
1736
1855
  const color = COLORS[r.type] ?? "#9aa7b8";
1737
- const tip = `${r.path} \xB7 ${r.type} \xB7 ${num(r.start)}\u2013${num(r.end)} s (${num(r.end - r.start)} s)${r.keys.length ? ` \xB7 ${r.keys.length} keyframe${r.keys.length > 1 ? "s" : ""}` : ""}${r.detail ? ` \xB7 ${r.detail}` : ""}`;
1856
+ const tip = `${r.path} \xB7 ${r.type} \xB7 ${num(r.start)}\u2013${num(r.end)} s (${num(r.end - r.start)} s)${r.keys.length ? ` \xB7 ${r.keys.length} keyframe${r.keys.length > 1 ? "s" : ""}` : ""}${r.detail ? ` \xB7 ${r.detail}` : ""}${r.local ? ` \xB7 local time of ${r.local}` : ""}`;
1738
1857
  out.push(`<g class="row" data-start="${num(r.start)}"><title>${esc(tip)}</title>`);
1739
1858
  out.push(`<rect class="band" x="${PAD}" y="${y}" width="${LABEL + CHART}" height="${ROW}" ${i % 2 ? 'fill-opacity=".05"' : 'fill-opacity="0"'}/>`);
1740
1859
  if (withLabels) out.push(`<text class="label" x="${PAD + 6 + r.depth * 14}" y="${y + 15}">${esc(r.name)}</text>`);
@@ -2291,9 +2410,11 @@ var Movie = class {
2291
2410
  async _awaitVideoFrames(t = this._timeOf(this.currentFrame)) {
2292
2411
  if (!this._rootSequence) return;
2293
2412
  const collected = [];
2294
- collectVideoSequences(this._rootSequence, collected);
2413
+ const clocks = /* @__PURE__ */ new Map();
2414
+ collectVideoSequences(this._rootSequence, collected, clocks);
2295
2415
  await Promise.all(collected.map((v) => {
2296
- const local = t - (v.absoluteStart ?? v.at);
2416
+ if (v.selfTimed) return v.awaitFrameAt(t);
2417
+ const local = (clocks.get(v)?.() ?? t) - (v.absoluteStart ?? v.at);
2297
2418
  if (local < 0 || local > (v.duration ?? 0)) return Promise.resolve();
2298
2419
  return v.awaitFrameAt(local);
2299
2420
  }));
@@ -2860,13 +2981,15 @@ function safeRun(fn) {
2860
2981
  console.warn("pixi-effects: cleanup step threw, continuing:", e);
2861
2982
  }
2862
2983
  }
2863
- function collectVideoSequences(seq, out) {
2984
+ function collectVideoSequences(seq, out, clocks, clock = null) {
2864
2985
  if (typeof seq.awaitFrameAt === "function") {
2865
2986
  out.push(seq);
2987
+ if (clock && clocks) clocks.set(seq, clock);
2866
2988
  }
2867
- if (seq.maskSequence) collectVideoSequences(seq.maskSequence, out);
2989
+ if (seq.maskSequence) collectVideoSequences(seq.maskSequence, out, clocks, clock);
2990
+ const own = seq.localClock?.() ?? clock;
2868
2991
  for (const child of seq._children ?? []) {
2869
- collectVideoSequences(child, out);
2992
+ collectVideoSequences(child, out, clocks, own);
2870
2993
  }
2871
2994
  }
2872
2995
  var BY = ["chars", "words", "lines"];
@@ -3785,7 +3908,7 @@ async function audioEnvelope(source, options = {}) {
3785
3908
 
3786
3909
  // src/audio/musicEnvelope.ts
3787
3910
  async function musicEnvelope(music, options = {}) {
3788
- const { resolveMusic, renderMusic, musicLength, musicBeatTimes, TempoMap } = await import('./music-4HDFULNR.js');
3911
+ const { resolveMusic, renderMusic, musicLength, musicBeatTimes, TempoMap } = await import('./music-CFEC7HKL.js');
3789
3912
  const messages = [];
3790
3913
  const m = resolveMusic(music, "musicEnvelope()", (msg) => messages.push(msg));
3791
3914
  if (!m) throw new Error(`pixi-effects: musicEnvelope(): ${messages.join(" ") || "the music has nothing to play"}`);
@@ -3798,7 +3921,7 @@ async function musicEnvelope(music, options = {}) {
3798
3921
 
3799
3922
  // src/audio/musicBuffer.ts
3800
3923
  async function musicBuffer(music, options = {}) {
3801
- const { resolveMusic, renderMusic, musicLength } = await import('./music-4HDFULNR.js');
3924
+ const { resolveMusic, renderMusic, musicLength } = await import('./music-CFEC7HKL.js');
3802
3925
  const messages = [];
3803
3926
  const m = resolveMusic(music, "musicBuffer()", (msg) => messages.push(msg));
3804
3927
  if (!m) throw new Error(`pixi-effects: musicBuffer(): ${messages.join(" ") || "the music has nothing to play"}`);