@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 { M as Ms, P as Project } from '../../types-CHplD9V5.cjs';
2
- import { P as PlaybackEngine, a as PlaybackEngineOptions, b as PlaybackEngineFactory } from '../../types-DvKlxylu.cjs';
1
+ import { M as Ms, P as Project } from '../../types-CmS-UIEr.cjs';
2
+ import { P as PlaybackEngine, a as PlaybackEngineOptions, b as PlaybackEngineFactory } from '../../types-CjvRUPtZ.cjs';
3
3
 
4
4
  interface WebCodecsEngineOptions extends PlaybackEngineOptions {
5
5
  /**
@@ -40,6 +40,10 @@ declare class WebCodecsEngine implements PlaybackEngine {
40
40
  private lastFrameTs;
41
41
  private decodedFramesTotal;
42
42
  private destroyed;
43
+ /** Output frame rect (fixed bounds, no transform) in CSS pixels. */
44
+ private lastOutputRect;
45
+ /** Post-transform content rect in CSS pixels. */
46
+ private lastFrameRect;
43
47
  onTimeUpdate?: (ms: Ms) => void;
44
48
  onEnded?: () => void;
45
49
  onError?: (err: Error) => void;
@@ -53,6 +57,18 @@ declare class WebCodecsEngine implements PlaybackEngine {
53
57
  getTime(): Ms;
54
58
  seek(timeMs: Ms): void;
55
59
  destroy(): void;
60
+ getOutputFrameRect(): {
61
+ x: number;
62
+ y: number;
63
+ w: number;
64
+ h: number;
65
+ } | null;
66
+ getFrameRect(): {
67
+ x: number;
68
+ y: number;
69
+ w: number;
70
+ h: number;
71
+ } | null;
56
72
  private syncSources;
57
73
  private teardownSource;
58
74
  private onTrackReady;
@@ -1,5 +1,5 @@
1
- import { M as Ms, P as Project } from '../../types-CHplD9V5.js';
2
- import { P as PlaybackEngine, a as PlaybackEngineOptions, b as PlaybackEngineFactory } from '../../types-rwZx6FxE.js';
1
+ import { M as Ms, P as Project } from '../../types-CmS-UIEr.js';
2
+ import { P as PlaybackEngine, a as PlaybackEngineOptions, b as PlaybackEngineFactory } from '../../types-BbZjOQLz.js';
3
3
 
4
4
  interface WebCodecsEngineOptions extends PlaybackEngineOptions {
5
5
  /**
@@ -40,6 +40,10 @@ declare class WebCodecsEngine implements PlaybackEngine {
40
40
  private lastFrameTs;
41
41
  private decodedFramesTotal;
42
42
  private destroyed;
43
+ /** Output frame rect (fixed bounds, no transform) in CSS pixels. */
44
+ private lastOutputRect;
45
+ /** Post-transform content rect in CSS pixels. */
46
+ private lastFrameRect;
43
47
  onTimeUpdate?: (ms: Ms) => void;
44
48
  onEnded?: () => void;
45
49
  onError?: (err: Error) => void;
@@ -53,6 +57,18 @@ declare class WebCodecsEngine implements PlaybackEngine {
53
57
  getTime(): Ms;
54
58
  seek(timeMs: Ms): void;
55
59
  destroy(): void;
60
+ getOutputFrameRect(): {
61
+ x: number;
62
+ y: number;
63
+ w: number;
64
+ h: number;
65
+ } | null;
66
+ getFrameRect(): {
67
+ x: number;
68
+ y: number;
69
+ w: number;
70
+ h: number;
71
+ } | null;
56
72
  private syncSources;
57
73
  private teardownSource;
58
74
  private onTrackReady;
@@ -1,3 +1,5 @@
1
+ import { getEffectiveTransform } from '../../chunk-WTCK3XQ6.js';
2
+
1
3
  // ../../node_modules/.pnpm/mp4box@2.4.1/node_modules/mp4box/dist/rolldown-runtime-w6R9maHv.mjs
2
4
  var __defProp = Object.defineProperty;
3
5
  var __exportAll = (all, no_symbols) => {
@@ -10118,6 +10120,10 @@ var WebCodecsEngine = class {
10118
10120
  lastFrameTs = 0;
10119
10121
  decodedFramesTotal = 0;
10120
10122
  destroyed = false;
10123
+ /** Output frame rect (fixed bounds, no transform) in CSS pixels. */
10124
+ lastOutputRect = null;
10125
+ /** Post-transform content rect in CSS pixels. */
10126
+ lastFrameRect = null;
10121
10127
  onTimeUpdate;
10122
10128
  onEnded;
10123
10129
  onError;
@@ -10236,6 +10242,12 @@ var WebCodecsEngine = class {
10236
10242
  this.sources.clear();
10237
10243
  this.mount.remove();
10238
10244
  }
10245
+ getOutputFrameRect() {
10246
+ return this.lastOutputRect;
10247
+ }
10248
+ getFrameRect() {
10249
+ return this.lastFrameRect;
10250
+ }
10239
10251
  // --- internals -------------------------------------------------------
10240
10252
  syncSources() {
10241
10253
  const wantedVideoIds = new Set(
@@ -10537,12 +10549,40 @@ var WebCodecsEngine = class {
10537
10549
  if (chosenFrame) {
10538
10550
  const vw = chosenFrame.displayWidth || chosenFrame.codedWidth;
10539
10551
  const vh = chosenFrame.displayHeight || chosenFrame.codedHeight;
10540
- const scale = Math.min(cw / vw, ch / vh);
10541
- const dw = vw * scale;
10542
- const dh = vh * scale;
10543
- const dx = (cw - dw) / 2;
10544
- const dy = (ch - dh) / 2;
10545
- this.ctx.drawImage(chosenFrame, dx, dy, dw, dh);
10552
+ const baseScale = Math.min(cw / vw, ch / vh);
10553
+ const dw = vw * baseScale;
10554
+ const dh = vh * baseScale;
10555
+ const dpr = window.devicePixelRatio || 1;
10556
+ const t = getEffectiveTransform(clip, localMs);
10557
+ const outX = (cw - dw) / 2;
10558
+ const outY = (ch - dh) / 2;
10559
+ this.ctx.save();
10560
+ this.ctx.beginPath();
10561
+ this.ctx.rect(outX, outY, dw, dh);
10562
+ this.ctx.clip();
10563
+ this.ctx.translate(cw / 2 + t.panX * dpr, ch / 2 + t.panY * dpr);
10564
+ this.ctx.scale(t.scale, t.scale);
10565
+ this.ctx.drawImage(chosenFrame, -dw / 2, -dh / 2, dw, dh);
10566
+ this.ctx.restore();
10567
+ this.lastOutputRect = {
10568
+ x: outX / dpr,
10569
+ y: outY / dpr,
10570
+ w: dw / dpr,
10571
+ h: dh / dpr
10572
+ };
10573
+ const cssCx = cw / (2 * dpr) + t.panX;
10574
+ const cssCy = ch / (2 * dpr) + t.panY;
10575
+ const cssW = dw * t.scale / dpr;
10576
+ const cssH = dh * t.scale / dpr;
10577
+ this.lastFrameRect = {
10578
+ x: cssCx - cssW / 2,
10579
+ y: cssCy - cssH / 2,
10580
+ w: cssW,
10581
+ h: cssH
10582
+ };
10583
+ } else {
10584
+ this.lastFrameRect = null;
10585
+ this.lastOutputRect = null;
10546
10586
  }
10547
10587
  this.feedDecoder(src);
10548
10588
  }