@taole/giftstage 0.3.3 → 0.3.5
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.
- package/README.md +19 -5
- package/dist/core/gift-stage.d.ts +6 -1
- package/dist/core/render-manager.d.ts +9 -0
- package/dist/gift-stage.cjs +804 -462
- package/dist/gift-stage.es.js +6711 -5698
- package/dist/gpu/webgl2-backend.d.ts +1 -0
- package/dist/gpu/webgpu-backend.d.ts +4 -0
- package/dist/index.d.ts +1 -0
- package/dist/renderers/svga-batch-renderer.d.ts +8 -2
- package/dist/types/index.d.ts +26 -0
- package/dist/utils/clip-mesh.d.ts +7 -1
- package/dist/utils/svg-path-parser.d.ts +2 -0
- package/dist/utils/svga-clip-analysis.d.ts +37 -0
- package/dist/utils/svga-command-preparation.d.ts +13 -0
- package/dist/utils/svga-hybrid-command-data.d.ts +18 -0
- package/dist/utils/svga-hybrid-command-table.d.ts +9 -5
- package/dist/utils/svga-preparation-profile.d.ts +21 -0
- package/dist/utils/svga-work-scheduler.d.ts +3 -2
- package/dist/workers/svga-clip-worker-client.d.ts +5 -0
- package/dist/workers/svga-clip-worker.d.ts +9 -0
- package/dist/workers/svga-command-worker-client.d.ts +8 -0
- package/dist/workers/svga-command-worker.d.ts +27 -0
- package/package.json +82 -82
|
@@ -144,6 +144,7 @@ export declare class WebGL2Backend implements GPUBackend {
|
|
|
144
144
|
private recordSubmittedDraw;
|
|
145
145
|
private rejectSVGAFastPathDraw;
|
|
146
146
|
private initPrograms;
|
|
147
|
+
prepareParticleSpritePipelines(): void;
|
|
147
148
|
private ensureParticleSpriteProgram;
|
|
148
149
|
private makeProgramEntry;
|
|
149
150
|
/**
|
|
@@ -57,6 +57,8 @@ export declare class WebGPUBackend implements GPUBackend {
|
|
|
57
57
|
private buffers;
|
|
58
58
|
private textures;
|
|
59
59
|
private pipelines;
|
|
60
|
+
private particleSpritePreparations;
|
|
61
|
+
private particleSpritePreparationEpoch;
|
|
60
62
|
private sampler;
|
|
61
63
|
private uniformBuffer;
|
|
62
64
|
private texturedBindGroupLayout;
|
|
@@ -214,7 +216,9 @@ export declare class WebGPUBackend implements GPUBackend {
|
|
|
214
216
|
private ensureSVGAFrameTableMeshPipeline;
|
|
215
217
|
private ensureMotionSvgaPipeline;
|
|
216
218
|
private ensureParticlePipeline;
|
|
219
|
+
prepareParticleSpritePipelines(): Promise<void>;
|
|
217
220
|
private ensureParticleSpritePipeline;
|
|
221
|
+
private particleSpritePipelineDescriptor;
|
|
218
222
|
private createInstancedSvgaPipeline;
|
|
219
223
|
private createInstancedClipMaskPipeline;
|
|
220
224
|
private createVapInstancedPipeline;
|
package/dist/index.d.ts
CHANGED
|
@@ -34,3 +34,4 @@ export { WebCodecsMp4Playback } from './video/webcodecs-mp4-playback.js';
|
|
|
34
34
|
export type { WebCodecsMp4CreateOptions } from './video/webcodecs-mp4-playback.js';
|
|
35
35
|
export type { WebCodecsPlaybackHandle, GPUBackend, BackendOperationFailureReason, BackendOperationResult, GPUBufferHandle, GPUTextureHandle, TextureOpts, BufferUsage, DrawCommand, ShaderType, BackendType, ParentMotionMode, SVGADrawBatchMode, SVGAFrameEvaluation, SVGAFrameEvaluationStrategy, SVGAFrameTableBinding, SVGAFrameTableBindingBase, SVGAFrameTableCreateOptions, SVGAFrameTableState, SVGAFrameTimelineFallbackReason, SVGAFrameTimelinePath, SVGAFrameTimelineRenderInfo, SVGAFrameTimelineStrategy, SVGAFrameTimelineTransport, SVGARenderFallbackReason, SVGARenderInfo, SVGARenderPath, SVGARenderPathState, SVGARenderPathChangeInfo, GiftStageRuntimeDiagnosticType, GiftStageRuntimeDiagnosticEvent, GiftStageRuntimeDiagnostics, SVGAHybridCommandTable, SVGAHybridOperation, SVGAHybridOperationType, SVGATimelineDrawRun, WebGL2FrameTableBinding, WebGPUFrameTableBinding, GiftStageOptions, AddGiftOptions, GiftHandle, GiftSlot, GiftType, GiftObjectFit, GiftCoordinate, GiftState, GiftAnimationStep, GiftAnimationChain, SVGAMovieEntity, SVGAParams, SVGASpriteTable, SVGAAudio, SVGATransform, SVGAShape, VideoEntity, UVRect, FrameJobData, FlyAnimation, VAPConfig, VAPSrcItem, VAPFrameItem, VAPFrameObj, } from './types/index.js';
|
|
36
36
|
export type { GiftAssetLease, GiftAssetMetadata, GiftStageCapabilities, SVGAFrameTimelineCapabilities, GiftStagePlugin, GiftStagePluginHost, MountedGiftStagePlugin, MotionBindingOptions, MotionTrackDescriptor, MotionTrackLease, BallisticV1ParticleBatchDescriptor, ParticleAtlasDescriptor, ParticleAtlasHandle, ParticleBatchDescriptor, ParticleBatchEnvelope, ParticleBatchGroupHandle, ParticleBatchHandle, ParticleEnvelopeSegment, SpriteV2ParticleBatchDescriptor, PlaybackFrame, PlaybackScope, PlaybackScopeStartOptions, PlaybackScopeState, ReadonlyTableDescriptor, ReadonlyTableLease, } from './plugin/types.js';
|
|
37
|
+
export type { SVGAPreparationProfile, SVGAPreparationPhase, SVGAPreparationStageProfile } from './types/index.js';
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { SVGAClipAnalysisCache } from '../utils/svga-clip-analysis.js';
|
|
2
|
+
import { type SVGAPreparationRecorder } from '../utils/svga-preparation-profile.js';
|
|
1
3
|
import type { GPUBackend, GPUBufferHandle, GiftSlot, VideoEntity } from '../types/index.js';
|
|
2
4
|
/** Signals RenderManager to discard and replay the complete frame after a resource fallback. */
|
|
3
5
|
export declare class SVGAFastPathFrameReplayError extends Error {
|
|
@@ -32,6 +34,7 @@ export interface ClipMeshCache {
|
|
|
32
34
|
indexBuf?: GPUBufferHandle | null;
|
|
33
35
|
}
|
|
34
36
|
interface SVGAClipPrewarmOptions {
|
|
37
|
+
profile?: SVGAPreparationRecorder;
|
|
35
38
|
frameBudgetMs?: number;
|
|
36
39
|
workerTimeSliceMs?: number;
|
|
37
40
|
checkActive?: () => void;
|
|
@@ -78,9 +81,10 @@ export declare class SVGABatchRenderer {
|
|
|
78
81
|
/** Shared producers outlive individual addGift/preload subscribers. */
|
|
79
82
|
private clipMeshProducerController;
|
|
80
83
|
private clipMeshProducerTasks;
|
|
84
|
+
private clipResourceProducers;
|
|
81
85
|
private destroyed;
|
|
82
86
|
private clipMeshDestroyed;
|
|
83
|
-
|
|
87
|
+
readonly clipAnalysis: SVGAClipAnalysisCache;
|
|
84
88
|
/** Meshes with lazily created GPU buffers (released in destroy). */
|
|
85
89
|
private clipMeshesWithBuffers;
|
|
86
90
|
private clipMeshRefCounts;
|
|
@@ -258,7 +262,8 @@ export declare class SVGABatchRenderer {
|
|
|
258
262
|
/** Validates every immutable Hybrid mesh reference and retains its GPU buffers for this entity. */
|
|
259
263
|
retainHybridMeshes(backend: GPUBackend, entity: VideoEntity): void;
|
|
260
264
|
releaseHybridMeshes(backend: GPUBackend, entity: VideoEntity): void;
|
|
261
|
-
|
|
265
|
+
releaseClipPreparation(entity: Pick<VideoEntity, 'spriteTable'>): void;
|
|
266
|
+
private collectClipPathsSteps;
|
|
262
267
|
/**
|
|
263
268
|
* Ensures shared producers exist, then waits as the current subscriber. A subscriber signal
|
|
264
269
|
* never owns or cancels shared mesh production; it only detaches this caller's waiter.
|
|
@@ -284,6 +289,7 @@ export declare class SVGABatchRenderer {
|
|
|
284
289
|
private queueClipMeshBuild;
|
|
285
290
|
private scheduleClipMeshBuildFlush;
|
|
286
291
|
private flushPendingClipMeshBuilds;
|
|
292
|
+
hydrateClipMeshesCooperative(meshes: SVGAClipMeshMap | null | undefined, options?: SVGAClipPrewarmOptions): Promise<void>;
|
|
287
293
|
hydrateClipMeshes(meshes: SVGAClipMeshMap | null | undefined): void;
|
|
288
294
|
snapshotClipMeshes(entity: Pick<VideoEntity, 'spriteTable'>): SVGAClipMeshMap;
|
|
289
295
|
private canUseTimelinePath;
|
package/dist/types/index.d.ts
CHANGED
|
@@ -314,6 +314,8 @@ export interface GPUBackend {
|
|
|
314
314
|
createSVGAFrameTable?(packedData: Float32Array, options: SVGAFrameTableCreateOptions): SVGAFrameTableBinding;
|
|
315
315
|
/** Releases a frame table returned by `createSVGAFrameTable`. */
|
|
316
316
|
deleteSVGAFrameTable?(binding: SVGAFrameTableBinding): void;
|
|
317
|
+
/** Prepares sprite-v2 shaders before playback, without drawing or advancing a clock. */
|
|
318
|
+
prepareParticleSpritePipelines?(): void | Promise<void>;
|
|
317
319
|
createTexture(source: TexImageSource | ArrayBuffer, opts: TextureOpts): GPUTextureHandle;
|
|
318
320
|
/** Uninitialized RGBA texture (e.g. WebCodecs atlas backing store). */
|
|
319
321
|
createEmptyTexture(width: number, height: number, opts?: TextureOpts): GPUTextureHandle;
|
|
@@ -810,6 +812,10 @@ export interface GiftStageOptions {
|
|
|
810
812
|
* Default: true.
|
|
811
813
|
*/
|
|
812
814
|
svgaClipPrewarmInWorker?: boolean;
|
|
815
|
+
/** Build immutable GPU command/frame tables in a Worker. Defaults to true. */
|
|
816
|
+
svgaCommandTableInWorker?: boolean;
|
|
817
|
+
/** Optional per-resource preparation summary. Detailed sampling is disabled when absent. */
|
|
818
|
+
onSVGAPreparationProfile?: (profile: SVGAPreparationProfile) => void;
|
|
813
819
|
/** Called when a gift's selected SVGA rendering path changes. */
|
|
814
820
|
onSVGARenderPathChange?: (info: SVGARenderPathChangeInfo) => void;
|
|
815
821
|
/** Receives production runtime diagnostics. GiftStage does not upload these events. */
|
|
@@ -1152,3 +1158,23 @@ export interface GiftAnimationChain {
|
|
|
1152
1158
|
/** Cancel the active animation for this gift. */
|
|
1153
1159
|
cancel(): void;
|
|
1154
1160
|
}
|
|
1161
|
+
export type SVGAPreparationPhase = 'clip-prepare' | 'worker-queue' | 'input-copy' | 'command-build' | 'frame-pack' | 'validation' | 'gpu-submit';
|
|
1162
|
+
export interface SVGAPreparationStageProfile {
|
|
1163
|
+
/** Combined CPU execution across threads; excludes waits. */
|
|
1164
|
+
executionMs: number;
|
|
1165
|
+
mainThreadExecutionMs: number;
|
|
1166
|
+
workerExecutionMs: number;
|
|
1167
|
+
elapsedMs: number;
|
|
1168
|
+
maxSliceMs: number;
|
|
1169
|
+
slices: number;
|
|
1170
|
+
cacheHits: number;
|
|
1171
|
+
bytes: number;
|
|
1172
|
+
}
|
|
1173
|
+
export interface SVGAPreparationProfile {
|
|
1174
|
+
resourceId: number;
|
|
1175
|
+
executor: 'worker' | 'main-thread';
|
|
1176
|
+
fallbackReason?: string;
|
|
1177
|
+
status: 'complete' | 'canceled' | 'failed';
|
|
1178
|
+
elapsedMs: number;
|
|
1179
|
+
phases: Partial<Record<SVGAPreparationPhase, SVGAPreparationStageProfile>>;
|
|
1180
|
+
}
|
|
@@ -1,9 +1,10 @@
|
|
|
1
|
+
import { parseSvgPath } from './svg-path-parser.js';
|
|
1
2
|
export interface ClipMeshData {
|
|
2
3
|
vertices: Float32Array;
|
|
3
4
|
indices: Uint32Array;
|
|
4
5
|
}
|
|
5
|
-
/** Returns a stable validation failure, or null for a renderable triangle mesh. */
|
|
6
6
|
export declare function validateClipMeshData(mesh: ClipMeshData): string | null;
|
|
7
|
+
export declare function validateClipMeshDataSteps(mesh: ClipMeshData): Generator<void, string | null>;
|
|
7
8
|
export type ClipMeshTriangulator = (vertices: Float64Array, polygonStarts: Uint32Array) => Uint32Array | null;
|
|
8
9
|
export type ClipPathGeometryKind = 'empty' | 'fillable' | 'invalid';
|
|
9
10
|
/**
|
|
@@ -16,4 +17,9 @@ export type ClipPathGeometryKind = 'empty' | 'fillable' | 'invalid';
|
|
|
16
17
|
* validation remains authoritative for those genuinely malformed contours.
|
|
17
18
|
*/
|
|
18
19
|
export declare function classifyClipPathGeometry(clipPath: string): ClipPathGeometryKind;
|
|
20
|
+
/** Reuses flattened geometry when callers also inspect the path's bounds. */
|
|
21
|
+
export declare function classifyParsedClipPathGeometry(subPaths: ReturnType<typeof parseSvgPath>): ClipPathGeometryKind;
|
|
22
|
+
/** Checkpoints also bound work for a single large, collinear contour. */
|
|
23
|
+
export declare function classifyParsedClipPathGeometrySteps(subPaths: ReturnType<typeof parseSvgPath>): Generator<void, ClipPathGeometryKind>;
|
|
19
24
|
export declare function buildClipMeshFromPath(clipPath: string, triangulator?: ClipMeshTriangulator): ClipMeshData | null;
|
|
25
|
+
export declare function buildClipMeshFromParsedPath(subPaths: ReturnType<typeof parseSvgPath>, triangulator?: ClipMeshTriangulator): ClipMeshData | null;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import type { VideoEntity } from '../types/index.js';
|
|
2
|
+
import { type ClipPathGeometryKind } from './clip-mesh.js';
|
|
3
|
+
import { type parseSvgPath } from './svg-path-parser.js';
|
|
4
|
+
export interface ClipAnalysis {
|
|
5
|
+
kind: ClipPathGeometryKind;
|
|
6
|
+
localRect: {
|
|
7
|
+
x0: number;
|
|
8
|
+
y0: number;
|
|
9
|
+
x1: number;
|
|
10
|
+
y1: number;
|
|
11
|
+
} | null;
|
|
12
|
+
}
|
|
13
|
+
export declare function detectAxisAlignedClipRect(paths: ReturnType<typeof parseSvgPath>): {
|
|
14
|
+
x0: number;
|
|
15
|
+
y0: number;
|
|
16
|
+
x1: number;
|
|
17
|
+
y1: number;
|
|
18
|
+
} | null;
|
|
19
|
+
export declare function analyzeParsedClipSteps(points: ReturnType<typeof parseSvgPath>, blank?: boolean): Generator<void, ClipAnalysis>;
|
|
20
|
+
/** One Stage owns this small cache. Meshes and flattened points are not retained here. */
|
|
21
|
+
export declare class SVGAClipAnalysisCache {
|
|
22
|
+
private paths;
|
|
23
|
+
private tables;
|
|
24
|
+
private resourcePaths;
|
|
25
|
+
private pathUsers;
|
|
26
|
+
private released;
|
|
27
|
+
hits: number;
|
|
28
|
+
trackHits: boolean;
|
|
29
|
+
retain(table: VideoEntity['spriteTable'], path: string): void;
|
|
30
|
+
release(table: VideoEntity['spriteTable']): string[];
|
|
31
|
+
get(path: string): ClipAnalysis | undefined;
|
|
32
|
+
set(path: string, value: ClipAnalysis): void;
|
|
33
|
+
getByIndex(table: VideoEntity['spriteTable'], index: number): ClipAnalysis | undefined;
|
|
34
|
+
analyze(table: VideoEntity['spriteTable'], index: number): Generator<void, ClipAnalysis>;
|
|
35
|
+
clear(): void;
|
|
36
|
+
}
|
|
37
|
+
export declare function getStandaloneClipAnalysis(table: VideoEntity['spriteTable']): SVGAClipAnalysisCache;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { VideoEntity } from '../types/index.js';
|
|
2
|
+
import { type SVGAHybridCommandTableBuildOptions } from './svga-hybrid-command-table.js';
|
|
3
|
+
import { type SVGACommandInput } from './svga-hybrid-command-data.js';
|
|
4
|
+
import type { SVGACommandResult } from '../workers/svga-command-worker.js';
|
|
5
|
+
export interface SVGACommandPreparationOptions extends SVGAHybridCommandTableBuildOptions {
|
|
6
|
+
useWorker?: boolean;
|
|
7
|
+
workerTimeSliceMs?: number;
|
|
8
|
+
signal?: AbortSignal;
|
|
9
|
+
}
|
|
10
|
+
/** Transfer only dedicated copies, in at most 64 KiB copy operations. */
|
|
11
|
+
export declare function copySVGACommandInputSteps(input: SVGACommandInput): Generator<void, SVGACommandInput>;
|
|
12
|
+
export declare function validateSVGACommandResultSteps(result: SVGACommandResult, input: SVGACommandInput, hybrid: boolean): Generator<void, void>;
|
|
13
|
+
export declare function prepareSVGACommandTables(entity: VideoEntity, hybrid: boolean, options?: SVGACommandPreparationOptions): Promise<SVGACommandResult>;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { SVGAHybridCommandTable } from '../types/index.js';
|
|
2
|
+
/** Dedicated numeric snapshot; no paths, entity references or GPU handles. */
|
|
3
|
+
export interface SVGACommandInput {
|
|
4
|
+
frameCount: number;
|
|
5
|
+
spriteCount: number;
|
|
6
|
+
frameData: Float32Array;
|
|
7
|
+
shapesIndex: Int32Array;
|
|
8
|
+
clipPathIndex: Int32Array;
|
|
9
|
+
shapePresence: Uint8Array;
|
|
10
|
+
clipKinds: Uint8Array;
|
|
11
|
+
clipRects: Float64Array;
|
|
12
|
+
atlas: Float64Array;
|
|
13
|
+
}
|
|
14
|
+
/** FNV-1a over canonical numeric bytes; -0 and 0 have the same identity. */
|
|
15
|
+
export declare function hashScheduleNumber(hash: number, value: number): number;
|
|
16
|
+
/** All executors drain this same generator. Hashes only select exact-comparison buckets. */
|
|
17
|
+
export declare function buildSVGACommandDataSteps(input: SVGACommandInput, hashNumber?: typeof hashScheduleNumber): Generator<void, SVGAHybridCommandTable>;
|
|
18
|
+
export declare function packSVGAFrameDataSteps(data: Float32Array): Generator<void, Float32Array>;
|
|
@@ -1,12 +1,16 @@
|
|
|
1
1
|
import type { SVGAHybridCommandTable, VideoEntity } from '../types/index.js';
|
|
2
|
+
import { type SVGAClipAnalysisCache } from './svga-clip-analysis.js';
|
|
3
|
+
import { type SVGACommandInput } from './svga-hybrid-command-data.js';
|
|
4
|
+
import { type PreparationStepOptions } from './svga-preparation-profile.js';
|
|
2
5
|
export declare const SVGA_HYBRID_OP_TEXTURE = 0;
|
|
3
6
|
export declare const SVGA_HYBRID_OP_SHAPE = 1;
|
|
4
7
|
export declare const SVGA_HYBRID_OP_CLIP_WRITE = 2;
|
|
5
8
|
export declare const SVGA_HYBRID_OP_CLIP_TEST = 3;
|
|
6
9
|
export declare const SVGA_HYBRID_OP_CLIP_CLEAR = 4;
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
10
|
+
export interface SVGAHybridCommandTableBuildOptions extends PreparationStepOptions {
|
|
11
|
+
clipAnalysis?: SVGAClipAnalysisCache;
|
|
12
|
+
}
|
|
13
|
+
/** Input references remain on the main thread until explicitly copied for a Worker. */
|
|
14
|
+
export declare function prepareSVGACommandInputSteps(entity: VideoEntity, options?: SVGAHybridCommandTableBuildOptions): Generator<void, SVGACommandInput>;
|
|
12
15
|
export declare function buildSVGAHybridCommandTable(entity: VideoEntity): SVGAHybridCommandTable;
|
|
16
|
+
export declare function buildSVGAHybridCommandTableCooperative(entity: VideoEntity, options?: SVGAHybridCommandTableBuildOptions): Promise<SVGAHybridCommandTable>;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { SVGAPreparationPhase, SVGAPreparationProfile, SVGAPreparationStageProfile } from '../types/index.js';
|
|
2
|
+
export declare class SVGAPreparationRecorder {
|
|
3
|
+
readonly resourceId: number;
|
|
4
|
+
readonly started: number;
|
|
5
|
+
readonly phases: Partial<Record<SVGAPreparationPhase, SVGAPreparationStageProfile>>;
|
|
6
|
+
executor: SVGAPreparationProfile['executor'];
|
|
7
|
+
fallbackReason?: string;
|
|
8
|
+
constructor(resourceId: number);
|
|
9
|
+
phase(name: SVGAPreparationPhase): SVGAPreparationStageProfile;
|
|
10
|
+
record(name: SVGAPreparationPhase, duration: number, thread?: 'main' | 'worker'): void;
|
|
11
|
+
measure<T>(name: SVGAPreparationPhase, action: () => T): T;
|
|
12
|
+
finish(status: SVGAPreparationProfile['status']): SVGAPreparationProfile;
|
|
13
|
+
}
|
|
14
|
+
export interface PreparationStepOptions {
|
|
15
|
+
signal?: AbortSignal;
|
|
16
|
+
frameBudgetMs?: number;
|
|
17
|
+
checkActive?: () => void;
|
|
18
|
+
profile?: SVGAPreparationRecorder;
|
|
19
|
+
}
|
|
20
|
+
/** Record only execution slices, excluding rAF waits and competing tasks. */
|
|
21
|
+
export declare function runPreparationSteps<T>(steps: Generator<void, T>, options?: PreparationStepOptions, phase?: SVGAPreparationPhase): Promise<T>;
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
+
export type SVGAWorkerTaskPriority = 'foreground' | 'background';
|
|
1
2
|
/**
|
|
2
3
|
* SVGA parser, image decode, atlas and clip workers share this gate so they
|
|
3
4
|
* do not create a multi-core CPU burst while real-time media is active.
|
|
4
5
|
*/
|
|
5
6
|
export declare function configureSVGAWorkerTaskConcurrency(maxConcurrent?: number): void;
|
|
6
|
-
export declare function runSVGAWorkerTask<T>(task: () => Promise<T>, signal?: AbortSignal): Promise<T>;
|
|
7
|
-
export declare function acquireSVGAWorkerTask(signal?: AbortSignal): Promise<() => void>;
|
|
7
|
+
export declare function runSVGAWorkerTask<T>(task: () => Promise<T>, signal?: AbortSignal, priority?: SVGAWorkerTaskPriority): Promise<T>;
|
|
8
|
+
export declare function acquireSVGAWorkerTask(signal?: AbortSignal, priority?: SVGAWorkerTaskPriority): Promise<() => void>;
|
|
@@ -1,6 +1,11 @@
|
|
|
1
|
+
import { type SVGAPreparationRecorder } from '../utils/svga-preparation-profile.js';
|
|
2
|
+
import type { ClipAnalysis } from '../utils/svga-clip-analysis.js';
|
|
1
3
|
import { type ClipMeshData } from '../utils/clip-mesh.js';
|
|
2
4
|
export declare function canUseSVGAClipWorker(): boolean;
|
|
3
5
|
export declare function requestSVGAClipMeshesInWorker(paths: string[], options?: {
|
|
6
|
+
profile?: SVGAPreparationRecorder;
|
|
4
7
|
workerTimeSliceMs?: number;
|
|
5
8
|
signal?: AbortSignal;
|
|
9
|
+
frameBudgetMs?: number;
|
|
10
|
+
onAnalysis?: (path: string, analysis: ClipAnalysis) => void;
|
|
6
11
|
}): Promise<Map<string, ClipMeshData | null>>;
|
|
@@ -1,11 +1,14 @@
|
|
|
1
|
+
import { type ClipAnalysis } from '../utils/svga-clip-analysis.js';
|
|
1
2
|
export interface SVGAClipWorkerRequest {
|
|
2
3
|
type: 'build-svga-clip-meshes';
|
|
3
4
|
id: number;
|
|
4
5
|
paths: string[];
|
|
5
6
|
workerTimeSliceMs?: number;
|
|
7
|
+
profile?: boolean;
|
|
6
8
|
}
|
|
7
9
|
export interface SVGAClipWorkerEntry {
|
|
8
10
|
path: string;
|
|
11
|
+
analysis: ClipAnalysis;
|
|
9
12
|
vertices: Float32Array | null;
|
|
10
13
|
indices: Uint32Array | null;
|
|
11
14
|
}
|
|
@@ -14,4 +17,10 @@ export interface SVGAClipWorkerResponse {
|
|
|
14
17
|
id: number;
|
|
15
18
|
entries?: SVGAClipWorkerEntry[];
|
|
16
19
|
error?: string;
|
|
20
|
+
profile?: {
|
|
21
|
+
executionMs: number;
|
|
22
|
+
elapsedMs: number;
|
|
23
|
+
maxSliceMs: number;
|
|
24
|
+
slices: number;
|
|
25
|
+
};
|
|
17
26
|
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { SVGACommandResult } from './svga-command-worker.js';
|
|
2
|
+
import type { SVGACommandInput } from '../utils/svga-hybrid-command-data.js';
|
|
3
|
+
import type { PreparationStepOptions } from '../utils/svga-preparation-profile.js';
|
|
4
|
+
export interface CommandWorkerOptions extends PreparationStepOptions {
|
|
5
|
+
signal?: AbortSignal;
|
|
6
|
+
workerTimeSliceMs?: number;
|
|
7
|
+
}
|
|
8
|
+
export declare function requestSVGACommandTableInWorker(input: SVGACommandInput, hybrid: boolean, options: CommandWorkerOptions): Promise<SVGACommandResult>;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { type SVGACommandInput } from '../utils/svga-hybrid-command-data.js';
|
|
2
|
+
import type { SVGAHybridCommandTable } from '../types/index.js';
|
|
3
|
+
export interface SVGACommandResult {
|
|
4
|
+
commandTable?: SVGAHybridCommandTable;
|
|
5
|
+
packed: Float32Array;
|
|
6
|
+
}
|
|
7
|
+
export interface SVGACommandRequest {
|
|
8
|
+
type: 'start' | 'resume' | 'cancel';
|
|
9
|
+
id: number;
|
|
10
|
+
generation: number;
|
|
11
|
+
input?: SVGACommandInput;
|
|
12
|
+
hybrid?: boolean;
|
|
13
|
+
sliceMs?: number;
|
|
14
|
+
profile?: boolean;
|
|
15
|
+
}
|
|
16
|
+
export interface SVGACommandResponse {
|
|
17
|
+
id: number;
|
|
18
|
+
generation: number;
|
|
19
|
+
type: 'paused' | 'complete' | 'error';
|
|
20
|
+
result?: SVGACommandResult;
|
|
21
|
+
error?: string;
|
|
22
|
+
samples?: Array<{
|
|
23
|
+
phase: 'command-build' | 'frame-pack';
|
|
24
|
+
executionMs: number;
|
|
25
|
+
elapsedMs: number;
|
|
26
|
+
}>;
|
|
27
|
+
}
|
package/package.json
CHANGED
|
@@ -1,82 +1,82 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "@taole/giftstage",
|
|
3
|
-
"version": "0.3.
|
|
4
|
-
"description": "High-performance WebGPU/WebGL gift animation player unifying SVGA, VAP, AlphaVideo, and images",
|
|
5
|
-
"type": "module",
|
|
6
|
-
"main": "dist/gift-stage.cjs",
|
|
7
|
-
"module": "dist/gift-stage.es.js",
|
|
8
|
-
"types": "dist/public.d.ts",
|
|
9
|
-
"exports": {
|
|
10
|
-
".": {
|
|
11
|
-
"types": "./dist/public.d.ts",
|
|
12
|
-
"import": "./dist/gift-stage.es.js",
|
|
13
|
-
"require": "./dist/gift-stage.cjs"
|
|
14
|
-
}
|
|
15
|
-
},
|
|
16
|
-
"publishConfig": {
|
|
17
|
-
"access": "public",
|
|
18
|
-
"registry": "https://registry.npmjs.org/"
|
|
19
|
-
},
|
|
20
|
-
"files": [
|
|
21
|
-
"dist",
|
|
22
|
-
"!dist/**/*.map",
|
|
23
|
-
"!dist/bundle-report.*.html",
|
|
24
|
-
"!dist/fixtures/**"
|
|
25
|
-
],
|
|
26
|
-
"scripts": {
|
|
27
|
-
"dev": "vite",
|
|
28
|
-
"build": "tsc --noEmit && vite build && tsc -p tsconfig.build.json && node scripts/write-public-types.mjs",
|
|
29
|
-
"build:analyze": "tsc --noEmit && vite build --mode analyze-es && vite build --mode analyze-cjs && tsc -p tsconfig.build.json && node scripts/write-public-types.mjs",
|
|
30
|
-
"build:demo": "tsc --noEmit && vite build --config vite.demo.config.ts && node -e \"const fs=require('fs'); fs.mkdirSync('dist-demo/static',{recursive:true}); fs.copyFileSync('static/vap.min.js','dist-demo/static/vap.min.js');\"",
|
|
31
|
-
"build:wasm": "echo \"Requires: cargo install wasm-pack\" && cd wasm && wasm-pack build --target web --out-dir pkg",
|
|
32
|
-
"test": "vitest run",
|
|
33
|
-
"test:watch": "vitest",
|
|
34
|
-
"test:browser": "vitest run --browser.enabled --browser.name=chromium",
|
|
35
|
-
"test:e2e": "playwright test",
|
|
36
|
-
"test:perf": "node scripts/run-performance.mjs",
|
|
37
|
-
"test:real-assets": "node scripts/verify-real-svga-manifest.mjs",
|
|
38
|
-
"test:package": "npm run build && node scripts/check-package-contract.mjs",
|
|
39
|
-
"perf:record": "node scripts/run-performance.mjs --record",
|
|
40
|
-
"lint": "eslint src/ tests/",
|
|
41
|
-
"format": "prettier --write \"src/**/*.ts\" \"tests/**/*.ts\"",
|
|
42
|
-
"typecheck": "tsc --noEmit",
|
|
43
|
-
"dp": "node publish/deploy.mjs"
|
|
44
|
-
},
|
|
45
|
-
"devDependencies": {
|
|
46
|
-
"@playwright/test": "^1.50.0",
|
|
47
|
-
"@types/dom-webcodecs": "^0.1.11",
|
|
48
|
-
"@types/earcut": "^3.0.0",
|
|
49
|
-
"@types/node": "^25.6.0",
|
|
50
|
-
"@types/pngjs": "^6.0.5",
|
|
51
|
-
"@vitest/browser": "^3.0.0",
|
|
52
|
-
"eslint": "^9.0.0",
|
|
53
|
-
"fake-indexeddb": "^6.2.5",
|
|
54
|
-
"jsdom": "^24.1.3",
|
|
55
|
-
"playwright": "^1.50.0",
|
|
56
|
-
"pngjs": "^7.0.0",
|
|
57
|
-
"prettier": "^3.4.0",
|
|
58
|
-
"rollup-plugin-visualizer": "^7.0.1",
|
|
59
|
-
"typescript": "^5.7.0",
|
|
60
|
-
"typescript-eslint": "^8.68.0",
|
|
61
|
-
"vite": "^6.0.0",
|
|
62
|
-
"vite-plugin-wasm": "^3.4.0",
|
|
63
|
-
"vitest": "^3.0.0"
|
|
64
|
-
},
|
|
65
|
-
"keywords": [
|
|
66
|
-
"svga",
|
|
67
|
-
"vap",
|
|
68
|
-
"alpha-video",
|
|
69
|
-
"image",
|
|
70
|
-
"webgl",
|
|
71
|
-
"webgpu",
|
|
72
|
-
"animation",
|
|
73
|
-
"gift",
|
|
74
|
-
"transparent-video"
|
|
75
|
-
],
|
|
76
|
-
"license": "MIT",
|
|
77
|
-
"dependencies": {
|
|
78
|
-
"@webgpu/types": "^0.1.69",
|
|
79
|
-
"earcut": "^3.0.2",
|
|
80
|
-
"mp4box": "^2.3.0"
|
|
81
|
-
}
|
|
82
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "@taole/giftstage",
|
|
3
|
+
"version": "0.3.5",
|
|
4
|
+
"description": "High-performance WebGPU/WebGL gift animation player unifying SVGA, VAP, AlphaVideo, and images",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "dist/gift-stage.cjs",
|
|
7
|
+
"module": "dist/gift-stage.es.js",
|
|
8
|
+
"types": "dist/public.d.ts",
|
|
9
|
+
"exports": {
|
|
10
|
+
".": {
|
|
11
|
+
"types": "./dist/public.d.ts",
|
|
12
|
+
"import": "./dist/gift-stage.es.js",
|
|
13
|
+
"require": "./dist/gift-stage.cjs"
|
|
14
|
+
}
|
|
15
|
+
},
|
|
16
|
+
"publishConfig": {
|
|
17
|
+
"access": "public",
|
|
18
|
+
"registry": "https://registry.npmjs.org/"
|
|
19
|
+
},
|
|
20
|
+
"files": [
|
|
21
|
+
"dist",
|
|
22
|
+
"!dist/**/*.map",
|
|
23
|
+
"!dist/bundle-report.*.html",
|
|
24
|
+
"!dist/fixtures/**"
|
|
25
|
+
],
|
|
26
|
+
"scripts": {
|
|
27
|
+
"dev": "vite",
|
|
28
|
+
"build": "tsc --noEmit && vite build && tsc -p tsconfig.build.json && node scripts/write-public-types.mjs",
|
|
29
|
+
"build:analyze": "tsc --noEmit && vite build --mode analyze-es && vite build --mode analyze-cjs && tsc -p tsconfig.build.json && node scripts/write-public-types.mjs",
|
|
30
|
+
"build:demo": "tsc --noEmit && vite build --config vite.demo.config.ts && node -e \"const fs=require('fs'); fs.mkdirSync('dist-demo/static',{recursive:true}); fs.copyFileSync('static/vap.min.js','dist-demo/static/vap.min.js');\"",
|
|
31
|
+
"build:wasm": "echo \"Requires: cargo install wasm-pack\" && cd wasm && wasm-pack build --target web --out-dir pkg",
|
|
32
|
+
"test": "vitest run",
|
|
33
|
+
"test:watch": "vitest",
|
|
34
|
+
"test:browser": "vitest run --browser.enabled --browser.name=chromium",
|
|
35
|
+
"test:e2e": "playwright test",
|
|
36
|
+
"test:perf": "node scripts/run-performance.mjs",
|
|
37
|
+
"test:real-assets": "node scripts/verify-real-svga-manifest.mjs",
|
|
38
|
+
"test:package": "npm run build && node scripts/check-package-contract.mjs",
|
|
39
|
+
"perf:record": "node scripts/run-performance.mjs --record",
|
|
40
|
+
"lint": "eslint src/ tests/",
|
|
41
|
+
"format": "prettier --write \"src/**/*.ts\" \"tests/**/*.ts\"",
|
|
42
|
+
"typecheck": "tsc --noEmit",
|
|
43
|
+
"dp": "node publish/deploy.mjs"
|
|
44
|
+
},
|
|
45
|
+
"devDependencies": {
|
|
46
|
+
"@playwright/test": "^1.50.0",
|
|
47
|
+
"@types/dom-webcodecs": "^0.1.11",
|
|
48
|
+
"@types/earcut": "^3.0.0",
|
|
49
|
+
"@types/node": "^25.6.0",
|
|
50
|
+
"@types/pngjs": "^6.0.5",
|
|
51
|
+
"@vitest/browser": "^3.0.0",
|
|
52
|
+
"eslint": "^9.0.0",
|
|
53
|
+
"fake-indexeddb": "^6.2.5",
|
|
54
|
+
"jsdom": "^24.1.3",
|
|
55
|
+
"playwright": "^1.50.0",
|
|
56
|
+
"pngjs": "^7.0.0",
|
|
57
|
+
"prettier": "^3.4.0",
|
|
58
|
+
"rollup-plugin-visualizer": "^7.0.1",
|
|
59
|
+
"typescript": "^5.7.0",
|
|
60
|
+
"typescript-eslint": "^8.68.0",
|
|
61
|
+
"vite": "^6.0.0",
|
|
62
|
+
"vite-plugin-wasm": "^3.4.0",
|
|
63
|
+
"vitest": "^3.0.0"
|
|
64
|
+
},
|
|
65
|
+
"keywords": [
|
|
66
|
+
"svga",
|
|
67
|
+
"vap",
|
|
68
|
+
"alpha-video",
|
|
69
|
+
"image",
|
|
70
|
+
"webgl",
|
|
71
|
+
"webgpu",
|
|
72
|
+
"animation",
|
|
73
|
+
"gift",
|
|
74
|
+
"transparent-video"
|
|
75
|
+
],
|
|
76
|
+
"license": "MIT",
|
|
77
|
+
"dependencies": {
|
|
78
|
+
"@webgpu/types": "^0.1.69",
|
|
79
|
+
"earcut": "^3.0.2",
|
|
80
|
+
"mp4box": "^2.3.0"
|
|
81
|
+
}
|
|
82
|
+
}
|