@aicut/core 0.5.0 → 0.6.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.
@@ -1,5 +1,5 @@
1
- import { L as Locale } from '../i18n-B-DFWgKe.cjs';
2
- import { b as Theme } from '../types-CHplD9V5.cjs';
1
+ import { L as Locale } from '../i18n-B24k4XVG.cjs';
2
+ import { b as Theme } from '../types-CmS-UIEr.cjs';
3
3
 
4
4
  /**
5
5
  * Lighting-editor-specific string keys. Kept in a SEPARATE interface
@@ -1,5 +1,5 @@
1
- import { L as Locale } from '../i18n-B-DFWgKe.js';
2
- import { b as Theme } from '../types-CHplD9V5.js';
1
+ import { L as Locale } from '../i18n-B24k4XVG.js';
2
+ import { b as Theme } from '../types-CmS-UIEr.js';
3
3
 
4
4
  /**
5
5
  * Lighting-editor-specific string keys. Kept in a SEPARATE interface
@@ -1,4 +1,4 @@
1
- import { mergeLocale, applyTheme } from '../chunk-CCDON7CU.js';
1
+ import { mergeLocale, applyTheme } from '../chunk-H6AY6NW4.js';
2
2
 
3
3
  // src/lighting/presets.ts
4
4
  var PRESET_DIRECTIONS = {
@@ -1,5 +1,74 @@
1
1
  'use strict';
2
2
 
3
+ // src/keyframes/types.ts
4
+ var IDENTITY_TRANSFORM = {
5
+ panX: 0,
6
+ panY: 0,
7
+ scale: 1
8
+ };
9
+
10
+ // src/keyframes/interpolate.ts
11
+ function applyEasing(t, easing) {
12
+ switch (easing) {
13
+ case "linear":
14
+ return t;
15
+ case "easeIn":
16
+ return t * t * t;
17
+ case "easeOut": {
18
+ const u = 1 - t;
19
+ return 1 - u * u * u;
20
+ }
21
+ case "easeInOut":
22
+ return t < 0.5 ? 4 * t * t * t : 1 - Math.pow(-2 * t + 2, 3) / 2;
23
+ }
24
+ }
25
+ function defaultFor(prop) {
26
+ return prop === "scale" ? 1 : 0;
27
+ }
28
+ function staticValue(clip, prop) {
29
+ const v = clip[prop];
30
+ return v ?? defaultFor(prop);
31
+ }
32
+ function keyframesForProp(kfs, prop) {
33
+ const out = [];
34
+ for (const k of kfs) if (k.prop === prop) out.push(k);
35
+ out.sort((a, b) => a.time - b.time);
36
+ return out;
37
+ }
38
+ function interpolateProp(clip, prop, localMs) {
39
+ if (!clip.keyframes || clip.keyframes.length === 0) {
40
+ return staticValue(clip, prop);
41
+ }
42
+ const arr = keyframesForProp(clip.keyframes, prop);
43
+ if (arr.length === 0) return staticValue(clip, prop);
44
+ if (arr.length === 1) return arr[0].value;
45
+ const first = arr[0];
46
+ const last = arr[arr.length - 1];
47
+ if (localMs <= first.time) return first.value;
48
+ if (localMs >= last.time) return last.value;
49
+ for (let i = 0; i < arr.length - 1; i += 1) {
50
+ const a = arr[i];
51
+ const b = arr[i + 1];
52
+ if (localMs >= a.time && localMs <= b.time) {
53
+ if (b.time === a.time) return a.value;
54
+ const rawT = (localMs - a.time) / (b.time - a.time);
55
+ const eased = applyEasing(rawT, a.easing ?? "linear");
56
+ return a.value + (b.value - a.value) * eased;
57
+ }
58
+ }
59
+ return last.value;
60
+ }
61
+ function getEffectiveTransform(clip, localMs) {
62
+ if ((!clip.keyframes || clip.keyframes.length === 0) && clip.panX === void 0 && clip.panY === void 0 && clip.scale === void 0) {
63
+ return IDENTITY_TRANSFORM;
64
+ }
65
+ return {
66
+ panX: interpolateProp(clip, "panX", localMs),
67
+ panY: interpolateProp(clip, "panY", localMs),
68
+ scale: interpolateProp(clip, "scale", localMs)
69
+ };
70
+ }
71
+
3
72
  // ../../node_modules/.pnpm/mp4box@2.4.1/node_modules/mp4box/dist/rolldown-runtime-w6R9maHv.mjs
4
73
  var __defProp = Object.defineProperty;
5
74
  var __exportAll = (all, no_symbols) => {
@@ -10120,6 +10189,10 @@ var WebCodecsEngine = class {
10120
10189
  lastFrameTs = 0;
10121
10190
  decodedFramesTotal = 0;
10122
10191
  destroyed = false;
10192
+ /** Output frame rect (fixed bounds, no transform) in CSS pixels. */
10193
+ lastOutputRect = null;
10194
+ /** Post-transform content rect in CSS pixels. */
10195
+ lastFrameRect = null;
10123
10196
  onTimeUpdate;
10124
10197
  onEnded;
10125
10198
  onError;
@@ -10238,6 +10311,12 @@ var WebCodecsEngine = class {
10238
10311
  this.sources.clear();
10239
10312
  this.mount.remove();
10240
10313
  }
10314
+ getOutputFrameRect() {
10315
+ return this.lastOutputRect;
10316
+ }
10317
+ getFrameRect() {
10318
+ return this.lastFrameRect;
10319
+ }
10241
10320
  // --- internals -------------------------------------------------------
10242
10321
  syncSources() {
10243
10322
  const wantedVideoIds = new Set(
@@ -10539,12 +10618,40 @@ var WebCodecsEngine = class {
10539
10618
  if (chosenFrame) {
10540
10619
  const vw = chosenFrame.displayWidth || chosenFrame.codedWidth;
10541
10620
  const vh = chosenFrame.displayHeight || chosenFrame.codedHeight;
10542
- const scale = Math.min(cw / vw, ch / vh);
10543
- const dw = vw * scale;
10544
- const dh = vh * scale;
10545
- const dx = (cw - dw) / 2;
10546
- const dy = (ch - dh) / 2;
10547
- this.ctx.drawImage(chosenFrame, dx, dy, dw, dh);
10621
+ const baseScale = Math.min(cw / vw, ch / vh);
10622
+ const dw = vw * baseScale;
10623
+ const dh = vh * baseScale;
10624
+ const dpr = window.devicePixelRatio || 1;
10625
+ const t = getEffectiveTransform(clip, localMs);
10626
+ const outX = (cw - dw) / 2;
10627
+ const outY = (ch - dh) / 2;
10628
+ this.ctx.save();
10629
+ this.ctx.beginPath();
10630
+ this.ctx.rect(outX, outY, dw, dh);
10631
+ this.ctx.clip();
10632
+ this.ctx.translate(cw / 2 + t.panX * dpr, ch / 2 + t.panY * dpr);
10633
+ this.ctx.scale(t.scale, t.scale);
10634
+ this.ctx.drawImage(chosenFrame, -dw / 2, -dh / 2, dw, dh);
10635
+ this.ctx.restore();
10636
+ this.lastOutputRect = {
10637
+ x: outX / dpr,
10638
+ y: outY / dpr,
10639
+ w: dw / dpr,
10640
+ h: dh / dpr
10641
+ };
10642
+ const cssCx = cw / (2 * dpr) + t.panX;
10643
+ const cssCy = ch / (2 * dpr) + t.panY;
10644
+ const cssW = dw * t.scale / dpr;
10645
+ const cssH = dh * t.scale / dpr;
10646
+ this.lastFrameRect = {
10647
+ x: cssCx - cssW / 2,
10648
+ y: cssCy - cssH / 2,
10649
+ w: cssW,
10650
+ h: cssH
10651
+ };
10652
+ } else {
10653
+ this.lastFrameRect = null;
10654
+ this.lastOutputRect = null;
10548
10655
  }
10549
10656
  this.feedDecoder(src);
10550
10657
  }