@agrhub/engine-pixi 0.0.0-stage → 1.3.3

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 (93) hide show
  1. package/LICENSE +47 -0
  2. package/NOTICE.md +19 -0
  3. package/README.md +6 -2
  4. package/dist/animation/block-reveal-animation.d.ts +33 -0
  5. package/dist/animation/easings.d.ts +4 -0
  6. package/dist/animation/gsap-animation.d.ts +32 -0
  7. package/dist/animation/index.d.ts +9 -0
  8. package/dist/animation/keyframe-animation.d.ts +11 -0
  9. package/dist/animation/mask-animation.d.ts +145 -0
  10. package/dist/animation/pixi-animation-utils.d.ts +10 -0
  11. package/dist/animation/registry.d.ts +11 -0
  12. package/dist/animation/types.d.ts +205 -0
  13. package/dist/animation/wipe-animation.d.ts +53 -0
  14. package/dist/clips/audio-clip.d.ts +122 -0
  15. package/dist/clips/backdrop-clip.d.ts +56 -0
  16. package/dist/clips/base-clip.d.ts +150 -0
  17. package/dist/clips/base-text-clip.d.ts +228 -0
  18. package/dist/clips/caption-clip.d.ts +129 -0
  19. package/dist/clips/clip-registry.d.ts +56 -0
  20. package/dist/clips/effect-clip.d.ts +37 -0
  21. package/dist/clips/iclip.d.ts +231 -0
  22. package/dist/clips/image-clip.d.ts +116 -0
  23. package/dist/clips/index.d.ts +20 -0
  24. package/dist/clips/placeholder-clip.d.ts +22 -0
  25. package/dist/clips/shape-clip.d.ts +59 -0
  26. package/dist/clips/text-clip.d.ts +148 -0
  27. package/dist/clips/transition-clip.d.ts +41 -0
  28. package/dist/clips/video-clip.d.ts +215 -0
  29. package/dist/compositor/audio-mixer.d.ts +8 -0
  30. package/dist/compositor/av-encoder.d.ts +17 -0
  31. package/dist/compositor/clip-style-renderer.d.ts +23 -0
  32. package/dist/compositor/compositor-renderer.d.ts +29 -0
  33. package/dist/compositor/effect-manager.d.ts +28 -0
  34. package/dist/compositor/scheduler.d.ts +8 -0
  35. package/dist/compositor/transition-manager.d.ts +45 -0
  36. package/dist/compositor.d.ts +157 -0
  37. package/dist/effect/constant/index.d.ts +566 -0
  38. package/dist/effect/effect.d.ts +9 -0
  39. package/dist/effect/glsl/custom-glsl.d.ts +1043 -0
  40. package/dist/effect/glsl/gl-effect.d.ts +38 -0
  41. package/dist/effect/interface/index.d.ts +25 -0
  42. package/dist/effect/types.d.ts +26 -0
  43. package/dist/effect/vertex.d.ts +1 -0
  44. package/dist/event-emitter.d.ts +55 -0
  45. package/dist/filters/outline-filter.d.ts +28 -0
  46. package/dist/index.d.ts +27 -0
  47. package/dist/index.es.js +16038 -0
  48. package/dist/index.es.js.map +1 -0
  49. package/dist/index.umd.cjs +3335 -0
  50. package/dist/index.umd.cjs.map +1 -0
  51. package/dist/json-serialization.d.ts +310 -0
  52. package/dist/mp4-utils/index.d.ts +31 -0
  53. package/dist/mp4-utils/mp4box-utils.d.ts +44 -0
  54. package/dist/mp4-utils/sample-transform.d.ts +26 -0
  55. package/dist/sprite/base-sprite.d.ts +255 -0
  56. package/dist/sprite/pixi-sprite-renderer.d.ts +68 -0
  57. package/dist/standalone/index.es.js +94023 -0
  58. package/dist/standalone/index.es.js.map +1 -0
  59. package/dist/studio/history-manager.d.ts +46 -0
  60. package/dist/studio/resource-manager.d.ts +53 -0
  61. package/dist/studio/selection-manager.d.ts +66 -0
  62. package/dist/studio/timeline-model.d.ts +117 -0
  63. package/dist/studio/transport.d.ts +44 -0
  64. package/dist/studio-bridge.d.ts +50 -0
  65. package/dist/studio.d.ts +527 -0
  66. package/dist/transformer/handle.d.ts +17 -0
  67. package/dist/transformer/snapping.d.ts +45 -0
  68. package/dist/transformer/transformer.d.ts +38 -0
  69. package/dist/transformer/wireframe.d.ts +5 -0
  70. package/dist/transition/fragment.d.ts +1 -0
  71. package/dist/transition/glsl/custom-glsl.d.ts +231 -0
  72. package/dist/transition/glsl/gl-transition.d.ts +42 -0
  73. package/dist/transition/transition.d.ts +6 -0
  74. package/dist/transition/types.d.ts +29 -0
  75. package/dist/transition/uniforms.d.ts +35 -0
  76. package/dist/transition/vertex.d.ts +1 -0
  77. package/dist/utils/asset-manager.d.ts +15 -0
  78. package/dist/utils/audio-codec-detector.d.ts +39 -0
  79. package/dist/utils/audio.d.ts +81 -0
  80. package/dist/utils/chromakey.d.ts +24 -0
  81. package/dist/utils/color-adjustment.d.ts +53 -0
  82. package/dist/utils/color.d.ts +17 -0
  83. package/dist/utils/common.d.ts +7 -0
  84. package/dist/utils/dom.d.ts +48 -0
  85. package/dist/utils/effect.d.ts +1 -0
  86. package/dist/utils/fonts.d.ts +21 -0
  87. package/dist/utils/index.d.ts +6 -0
  88. package/dist/utils/log.d.ts +27 -0
  89. package/dist/utils/media-cache.d.ts +45 -0
  90. package/dist/utils/stream-utils.d.ts +4 -0
  91. package/dist/utils/video.d.ts +16 -0
  92. package/dist/utils/worker-timer.d.ts +1 -0
  93. package/package.json +63 -3
@@ -0,0 +1,46 @@
1
+ import { Difference } from 'microdiff';
2
+ import { ClipJSON, ProjectJSON, StudioTrackJSON } from '../json-serialization';
3
+ export interface HistoryOptions {
4
+ maxSize?: number;
5
+ }
6
+ export interface HistoryState {
7
+ clips: Record<string, ClipJSON>;
8
+ tracks: StudioTrackJSON[];
9
+ settings: any;
10
+ }
11
+ export declare class HistoryManager {
12
+ private past;
13
+ private future;
14
+ private lastState;
15
+ private maxSize;
16
+ constructor(options?: HistoryOptions);
17
+ private projectToHistoryState;
18
+ /**
19
+ * Initialize history with the starting state
20
+ */
21
+ init(state: ProjectJSON): void;
22
+ /**
23
+ * Push a new state to history. Calculates the diff from the last state.
24
+ */
25
+ push(newState: ProjectJSON): void;
26
+ /**
27
+ * Undo the last action. Returns the patches and the new target state.
28
+ */
29
+ undo(currentState: ProjectJSON): {
30
+ patches: Difference[];
31
+ state: HistoryState;
32
+ } | null;
33
+ /**
34
+ * Redo the next action. Returns the patches and the new target state.
35
+ */
36
+ redo(currentState: ProjectJSON): {
37
+ patches: Difference[];
38
+ state: HistoryState;
39
+ } | null;
40
+ /**
41
+ * Apply patches to an object.
42
+ */
43
+ private applyPatches;
44
+ canUndo(): boolean;
45
+ canRedo(): boolean;
46
+ }
@@ -0,0 +1,53 @@
1
+ import { file } from 'opfs-tools';
2
+ export declare enum ResourceStatus {
3
+ PENDING = "pending",
4
+ LOADING = "loading",
5
+ COMPLETED = "completed",
6
+ FAILED = "failed"
7
+ }
8
+ export interface ResourceItem {
9
+ url: string;
10
+ status: ResourceStatus;
11
+ localFile?: ReturnType<typeof file>;
12
+ error?: Error;
13
+ }
14
+ /**
15
+ * ResourceManager handles asset preloading and caching in OPFS.
16
+ * It ensures that resources are downloaded only once and reused across sessions.
17
+ */
18
+ export declare class ResourceManager {
19
+ private resources;
20
+ private loadingPromises;
21
+ /**
22
+ * Preload a batch of URLs in parallel.
23
+ * @param urls Array of URLs to preload
24
+ */
25
+ preload(urls: string[]): Promise<void>;
26
+ /**
27
+ * Get a ReadableStream for the given URL. Backed by the shared media cache: concurrent and repeated
28
+ * requests for a URL share one download (memory LRU + OPFS).
29
+ */
30
+ static getReadableStream(url: string): Promise<ReadableStream<Uint8Array>>;
31
+ /**
32
+ * Get an ImageBitmap for the given URL (a new bitmap per call; the bytes are shared and cached).
33
+ */
34
+ static getImageBitmap(url: string): Promise<ImageBitmap>;
35
+ /**
36
+ * Load a single resource, using cache if available.
37
+ * @param url URL to load
38
+ */
39
+ loadResource(url: string): Promise<ResourceItem>;
40
+ /**
41
+ * Resolve a URL to its local OPFS file if available.
42
+ * @param url URL to resolve
43
+ */
44
+ resolve(url: string): Promise<ReturnType<typeof file> | string>;
45
+ /**
46
+ * Get the status of a specific resource.
47
+ */
48
+ getStatus(url: string): ResourceItem | undefined;
49
+ /**
50
+ * Clear instance state (not OPFS cache).
51
+ */
52
+ clear(): void;
53
+ }
@@ -0,0 +1,66 @@
1
+ import { Application, Container, Graphics } from 'pixi.js';
2
+ import { IClip } from '../clips/iclip';
3
+ import { Transformer } from '../transformer/transformer';
4
+ import { Studio } from '../studio';
5
+ export declare class SelectionManager {
6
+ private studio;
7
+ selectedClips: Set<IClip>;
8
+ activeTransformer: Transformer | null;
9
+ interactiveClips: Set<IClip>;
10
+ getSelection(): IClip[];
11
+ selectionGraphics: Graphics | null;
12
+ isDragSelecting: boolean;
13
+ private dragSelectionStart;
14
+ private isUpdatingTextRealtime;
15
+ private textClipResizedWidth;
16
+ private textClipResizeHandle;
17
+ private textClipResizedSx;
18
+ private textClipResizedSy;
19
+ private lastPointerDownTime;
20
+ private lastPointerDownClip;
21
+ constructor(studio: Studio);
22
+ init(app: Application, artboard: Container): void;
23
+ private onStagePointerDown;
24
+ private onStagePointerMove;
25
+ private onStagePointerUp;
26
+ /**
27
+ * Find clips that intersect with the given selection rectangle
28
+ */
29
+ private getIntersectingClips;
30
+ /**
31
+ * Update the transformer to show a preview of what will be selected
32
+ */
33
+ private updatePreviewSelection;
34
+ /**
35
+ * Update root.hitArea to match logical clip dimensions.
36
+ * Must be called after clip.width/height change (e.g. after text reflow or resize).
37
+ */
38
+ refreshClipHitArea(clip: IClip): void;
39
+ /**
40
+ * Setup sprite interactivity for click selection
41
+ */
42
+ setupSpriteInteractivity(clip: IClip): void;
43
+ /**
44
+ * Find the topmost clip (highest zIndex) at a given point
45
+ */
46
+ getTopmostClipAtPoint(globalPoint: {
47
+ x: number;
48
+ y: number;
49
+ }): IClip | null;
50
+ /**
51
+ * Select a clip and show transform controls
52
+ */
53
+ selectClip(clip: IClip, addToSelection?: boolean): void;
54
+ selectClipsByIds(ids: string[]): void;
55
+ setSelection(clips: IClip[]): void;
56
+ deselectClip(): void;
57
+ move(dx: number, dy: number): Promise<void>;
58
+ clear(): void;
59
+ recreateTransformer(): void;
60
+ private destroyTransformer;
61
+ private createTransformer;
62
+ private syncSelectedClipsTransformsRealtime;
63
+ private syncSelectedClipsTransforms;
64
+ private syncSpriteToClipProperties;
65
+ deleteSelected(): Promise<void>;
66
+ }
@@ -0,0 +1,117 @@
1
+ import { Studio, StudioTrack } from '../studio';
2
+ import { IClip } from '../clips/iclip';
3
+ import { ProjectJSON } from '../json-serialization';
4
+ export declare class TimelineModel {
5
+ private studio;
6
+ tracks: StudioTrack[];
7
+ clips: IClip[];
8
+ constructor(studio: Studio);
9
+ getTrackById(trackId: string): StudioTrack | undefined;
10
+ getClipById(clipId: string): IClip | undefined;
11
+ findTrackIdByClipId(clipId: string): string | undefined;
12
+ getTrackIndex(trackId: string): number;
13
+ /**
14
+ * Add a new track to the studio
15
+ */
16
+ addTrack(track: {
17
+ name: string;
18
+ type: string;
19
+ id?: string;
20
+ }, index?: number): StudioTrack;
21
+ /**
22
+ * Remove a track and all its clips
23
+ */
24
+ removeTrack(trackId: string): Promise<void>;
25
+ /**
26
+ * Move a track to a new index
27
+ */
28
+ moveTrack(trackId: string, newIndex: number): Promise<void>;
29
+ /**
30
+ * Set the order of tracks by ID
31
+ */
32
+ setTrackOrder(trackIds: string[]): Promise<void>;
33
+ /**
34
+ * Add a Transition clip at the join where the selected clip starts.
35
+ */
36
+ addTransition(transitionKey: string, duration?: number, fromClipId?: string | null, toClipId?: string | null, id?: string): Promise<void>;
37
+ /**
38
+ * Add a clip (or clips) to the studio
39
+ */
40
+ addClip(clipOrClips: IClip | IClip[], options?: {
41
+ trackId?: string;
42
+ audioSource?: string | File | Blob;
43
+ } | string | File | Blob): Promise<void>;
44
+ private normalizeAddClipOptions;
45
+ private prepareClipForTimeline;
46
+ private addClipToTrack;
47
+ private setupClipVisuals;
48
+ private emitAddClipEvents;
49
+ removeClip(clip: IClip, options?: {
50
+ permanent: boolean;
51
+ }): Promise<void>;
52
+ /**
53
+ * Remove multiple clips in a batch
54
+ */
55
+ removeClips(clips: IClip[], options?: {
56
+ permanent: boolean;
57
+ }): Promise<void>;
58
+ removeClipById(clipId: string): Promise<void>;
59
+ updateClip(clipId: string, updates: Partial<IClip>): Promise<void>;
60
+ updateClips(updates: {
61
+ id: string;
62
+ updates: Partial<IClip>;
63
+ }[]): Promise<void>;
64
+ /**
65
+ * Replace all clips with the same source with new clips generated by a factory.
66
+ * Useful for replacing placeholders with actual assets.
67
+ */
68
+ replaceClipsBySource(src: string, newClipFactory: (oldClip: IClip) => Promise<IClip>): Promise<void>;
69
+ private applyClipUpdate;
70
+ private updateTransformer;
71
+ /**
72
+ * Export current project state to JSON
73
+ */
74
+ exportToJSON(): ProjectJSON;
75
+ /**
76
+ * Load clips from JSON
77
+ */
78
+ loadFromJSON(json: ProjectJSON): Promise<void>;
79
+ /**
80
+ * Delete all currently selected clips
81
+ */
82
+ deleteSelected(): Promise<void>;
83
+ /**
84
+ * Duplicate all currently selected clips
85
+ */
86
+ duplicateSelected(): Promise<void>;
87
+ /**
88
+ * Split the selected clip at the given time or current time
89
+ */
90
+ splitSelected(splitTime?: number): Promise<void>;
91
+ /**
92
+ * Trim the selected clip from a specified time
93
+ * @param trimFromSeconds - Number of seconds to trim from the start of the clip
94
+ */
95
+ trimSelected(trimFromSeconds: number): Promise<void>;
96
+ updateSelected(updates: Partial<IClip>): Promise<void>;
97
+ setTracks(tracks: StudioTrack[]): Promise<void>;
98
+ /**
99
+ * Reconciles the tracks list with the available clips.
100
+ * 1. Filters each track's clipIds to only include IDs present in this.clips.
101
+ * 2. Removes any tracks that are then empty.
102
+ * This is used as a safety net to ensure no orphaned empty tracks or dangling references remain.
103
+ */
104
+ reconcileTracks(): void;
105
+ private ensureFontsForClips;
106
+ recalculateMaxDuration(): Promise<void>;
107
+ private setupPlaybackForClip;
108
+ private isPlaybackCapable;
109
+ clear(): Promise<void>;
110
+ /**
111
+ * Remove a time range from the entire timeline and shift subsequent content left.
112
+ * This is a ripple delete operation.
113
+ * @param fromUs Start time in microseconds
114
+ * @param toUs End time in microseconds
115
+ */
116
+ rippleDelete(fromUs: number, toUs: number): Promise<void>;
117
+ }
@@ -0,0 +1,44 @@
1
+ import { Studio } from '../studio';
2
+ import { IClip, IPlaybackCapable } from '../clips/iclip';
3
+ export interface PlaybackElementInfo {
4
+ element: HTMLVideoElement | HTMLAudioElement;
5
+ objectUrl?: string;
6
+ }
7
+ export declare class Transport {
8
+ private studio;
9
+ isPlaying: boolean;
10
+ currentTime: number;
11
+ maxDuration: number;
12
+ private playStartTime;
13
+ private playStartTimestamp;
14
+ private rafId;
15
+ playbackElements: Map<IClip<import('../sprite/base-sprite').BaseSpriteEvents>, PlaybackElementInfo>;
16
+ constructor(studio: Studio);
17
+ setMaxDuration(duration: number): void;
18
+ /**
19
+ * Start playback
20
+ */
21
+ play(): Promise<void>;
22
+ /**
23
+ * Pause playback
24
+ */
25
+ pause(): void;
26
+ /**
27
+ * Stop playback and reset to start
28
+ */
29
+ stop(): Promise<void>;
30
+ /**
31
+ * Seek to a specific time (in microseconds)
32
+ */
33
+ seek(time: number): Promise<void>;
34
+ /**
35
+ * Move to the next frame
36
+ */
37
+ frameNext(): Promise<void>;
38
+ /**
39
+ * Move to the previous frame
40
+ */
41
+ framePrev(): Promise<void>;
42
+ private renderLoop;
43
+ isPlaybackCapable(clip: any): clip is IPlaybackCapable;
44
+ }
@@ -0,0 +1,50 @@
1
+ import { Core } from '@agrhub/core';
2
+ import { Studio } from './studio';
3
+ /**
4
+ * StudioBridge - The "Reconciler" between Core and Studio.
5
+ * Driven by Core patches, applied strictly in order (see enqueue) so async clip creation from an
6
+ * older patch can never land after a newer rebuild.
7
+ */
8
+ export declare class StudioBridge {
9
+ private core;
10
+ private studio;
11
+ constructor(core: Core, studio: Studio);
12
+ /** Set while applying Core -> Studio changes, so Studio events they cause aren't echoed back */
13
+ private isSyncing;
14
+ private disposed;
15
+ /** Serialises all patch work (each step awaits the previous) */
16
+ private queue;
17
+ /** Bumped on full rebuilds: queued granular work from before a rebuild is skipped */
18
+ private generation;
19
+ /** A full rebuild is queued but hasn't started (further requests coalesce into it) */
20
+ private resyncQueued;
21
+ /** Latest requested seek while one is running (scrubbing: latest wins, nothing is dropped) */
22
+ private pendingSeek;
23
+ private seekRunning;
24
+ private unsubscribers;
25
+ private init;
26
+ /** Runs fn unless a sync is already in progress (prevents Core <-> Studio echo loops) */
27
+ private guarded;
28
+ private enqueue;
29
+ /** Full rebuild from Core state; requests made before it starts share that one rebuild */
30
+ private requestResync;
31
+ private requestSeek;
32
+ private syncSelectionToStudio;
33
+ private onCoreChange;
34
+ private handlePatches;
35
+ private getTrackCaptionConfig;
36
+ private buildClipContext;
37
+ private handleAddClip;
38
+ private handleRemoveClip;
39
+ private handleUpdateClip;
40
+ private syncInitialState;
41
+ private findTrackIdForClip;
42
+ /**
43
+ * Pre-load a font referenced by a clip's style.fontUrl (or top-level fontUrl).
44
+ * Must be called before jsonToClip() so document.fonts is populated when
45
+ * the Text constructor calls refreshText().
46
+ */
47
+ private ensureFontForClip;
48
+ private syncClipProperties;
49
+ dispose(): void;
50
+ }