@scenerok/sdk 0.9.0 → 0.10.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,28 +1,81 @@
1
1
  /**
2
- * Shared IR builder — appends SDK nodes onto an IRTimeline.
3
- * Used by @scenerok/sdk Timeline and (later) optionally by the VidScript compiler.
2
+ * IR lowering for SDK nodes — the TypeScript twin of the VidScript compiler's
3
+ * placement rules (`placeVidValue` in the platform's `src/parser/compiler-v2.ts`),
4
+ * so an SDK scene and the VidScript that says the same thing emit the same IR.
5
+ *
6
+ * A timeline records placements and lowers them in `toIR()`. Lowering late lets
7
+ * a nested timeline take its parent's canvas and share its id counter.
4
8
  */
5
9
  import { type IRTimeline } from './ir.js';
6
10
  import { type TimeInput } from './duration.js';
11
+ import { type TimeBase } from './frame-rate.js';
7
12
  import { type GridAreaRect, type GridSpec } from './grid.js';
8
- import type { Schedulable, TimelineOptions } from './types.js';
9
- export declare function resetIrBuilderIds(seed?: number): void;
13
+ import type { Schedulable, TimelineLike, TimelineOptions } from './types.js';
14
+ /** Canvas a timeline lowers onto when its options do not say. */
15
+ export interface Canvas {
16
+ width: number;
17
+ height: number;
18
+ fps: number;
19
+ }
20
+ /**
21
+ * The canvas `timeline()` uses when it gives no size: the host's (a VidScript
22
+ * import sets `globalThis.__scenerokCanvas` to the importing script's output),
23
+ * else 1080×1920 at 30 fps.
24
+ */
25
+ export declare function hostCanvas(): Canvas;
26
+ /** @deprecated Ids are numbered per `toIR()` call now; kept for compatibility. */
27
+ export declare function resetIrBuilderIds(_seed?: number): void;
10
28
  export interface IrBuilderState {
11
29
  ir: IRTimeline;
30
+ /** Visual playhead (seconds) after the last placed picture. */
12
31
  visualCursor: number;
13
32
  audioCursor: number;
14
33
  /** Named area rects (percent) from `timeline.grid(...)`; null until declared. */
15
34
  gridAreas: Map<string, GridAreaRect> | null;
35
+ /** Block boundaries snap to this frame grid, as VidScript's do. */
36
+ timeBase: TimeBase;
37
+ /** Shared across nested lowerings so ids are unique in the whole IR. */
38
+ ids: {
39
+ next: number;
40
+ };
16
41
  }
17
- export declare function createIrBuilder(options?: TimelineOptions): IrBuilderState;
18
- /** Declare or replace the timeline grid used by `area:` text placement. */
42
+ export declare function createIrBuilder(options?: TimelineOptions, canvas?: Canvas, ids?: {
43
+ next: number;
44
+ }): IrBuilderState;
45
+ /** Declare or replace the timeline grid used by `area:` placement. */
19
46
  export declare function setGrid(state: IrBuilderState, spec: GridSpec): Map<string, GridAreaRect>;
47
+ export declare function normalizeBlendMode(raw: string): string;
20
48
  /**
21
49
  * Post-pass: resolve fromId/toId for transition surfaces from neighboring clips.
22
50
  * Mirrors VidScript `bindTransitions` in compiler-v2.
23
51
  */
24
52
  export declare function bindTransitions(ir: IRTimeline, warnings?: string[]): void;
25
- export declare function scheduleAt(state: IrBuilderState, start: number, end: number, value: Schedulable): void;
26
- export declare function inferAutoDuration(value: Schedulable, explicit?: TimeInput): number;
53
+ /** A timeline's recorded placements, lowered by `lowerTimeline`. */
54
+ export interface TimelineRecord {
55
+ options: TimelineOptions;
56
+ grid: GridSpec | null;
57
+ entries: Array<{
58
+ start: number;
59
+ end: number;
60
+ value: Schedulable;
61
+ }>;
62
+ }
63
+ declare const RECORD: unique symbol;
64
+ export declare function timelineRecordOf(value: TimelineLike): TimelineRecord;
65
+ export { RECORD as TIMELINE_RECORD };
66
+ /** Lower a recorded timeline into a fresh builder on `canvas`. Transitions are not bound. */
67
+ export declare function lowerTimeline(record: TimelineRecord, canvas: Canvas, ids?: {
68
+ next: number;
69
+ }): IrBuilderState;
70
+ export interface ScheduleOptions {
71
+ /** Snap the window to the frame grid (default true; mattes reuse their host's window). */
72
+ snap?: boolean;
73
+ /** Advance the playheads (default true). */
74
+ advance?: boolean;
75
+ }
76
+ /** Lower one placement into `state.ir`. Returns where it ended. */
77
+ export declare function scheduleAt(state: IrBuilderState, rawStart: number, rawEnd: number, value: Schedulable, options?: ScheduleOptions): number;
78
+ /** The span `push` gives a value with no explicit duration. */
79
+ export declare function inferAutoDuration(value: Schedulable, explicit?: TimeInput, fps?: number): number;
27
80
  export declare function assertSchedulable(value: unknown): asserts value is Schedulable;
28
81
  //# sourceMappingURL=ir-builder.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"ir-builder.d.ts","sourceRoot":"","sources":["../src/ir-builder.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAWL,KAAK,UAAU,EAEhB,MAAM,SAAS,CAAC;AACjB,OAAO,EAAa,KAAK,SAAS,EAAE,MAAM,eAAe,CAAC;AAC1D,OAAO,EAIL,KAAK,YAAY,EACjB,KAAK,QAAQ,EACd,MAAM,WAAW,CAAC;AACnB,OAAO,KAAK,EAIV,WAAW,EAIX,eAAe,EAGhB,MAAM,YAAY,CAAC;AAKpB,wBAAgB,iBAAiB,CAAC,IAAI,SAAI,GAAG,IAAI,CAEhD;AA0GD,MAAM,WAAW,cAAc;IAC7B,EAAE,EAAE,UAAU,CAAC;IACf,YAAY,EAAE,MAAM,CAAC;IACrB,WAAW,EAAE,MAAM,CAAC;IACpB,iFAAiF;IACjF,SAAS,EAAE,GAAG,CAAC,MAAM,EAAE,YAAY,CAAC,GAAG,IAAI,CAAC;CAC7C;AAED,wBAAgB,eAAe,CAAC,OAAO,GAAE,eAAoB,GAAG,cAAc,CAqB7E;AAED,2EAA2E;AAC3E,wBAAgB,OAAO,CAAC,KAAK,EAAE,cAAc,EAAE,IAAI,EAAE,QAAQ,GAAG,GAAG,CAAC,MAAM,EAAE,YAAY,CAAC,CAIxF;AA2LD;;;GAGG;AACH,wBAAgB,eAAe,CAAC,EAAE,EAAE,UAAU,EAAE,QAAQ,GAAE,MAAM,EAAO,GAAG,IAAI,CAiD7E;AAmED,wBAAgB,UAAU,CACxB,KAAK,EAAE,cAAc,EACrB,KAAK,EAAE,MAAM,EACb,GAAG,EAAE,MAAM,EACX,KAAK,EAAE,WAAW,GACjB,IAAI,CA6BN;AAED,wBAAgB,iBAA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