@bluepic/embed 0.6.29 → 0.6.30
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/dist/bluepic-embed.iife.js +105 -104
- package/dist/bluepic-embed.umd.js +105 -104
- package/dist/components/TemplateEditor/BxLiveTemplate.vue.d.ts +23 -0
- package/dist/components/TemplateEditor/BxTemplateEditor.vue.d.ts +160 -0
- package/dist/components/TemplateEditor/TemplateView.vue.d.ts +40 -0
- package/dist/embed/embed.d.ts +642 -2
- package/dist/main.cjs +51 -50
- package/dist/main.mjs +4314 -4015
- package/dist/style.css +1 -1
- package/dist/util/bxEmbed.d.ts +10 -0
- package/dist/util/exportMetrics.d.ts +57 -0
- package/dist/util/gif/exportGifLocal.d.ts +52 -1
- package/dist/util/gif/sandboxGif.d.ts +15 -0
- package/dist/util/video/exportVideoLocal.d.ts +37 -0
- package/package.json +2 -2
package/dist/util/bxEmbed.d.ts
CHANGED
|
@@ -29,6 +29,16 @@ export declare class EmbeddedController extends EventTarget {
|
|
|
29
29
|
get(name: string): Promise<unknown>;
|
|
30
30
|
set(name: string, value: string): boolean;
|
|
31
31
|
evaluate(func: Function, ...args: string[]): Promise<unknown>;
|
|
32
|
+
/**
|
|
33
|
+
* Renders one export frame inside the sandbox (core >= 0.6.5, after
|
|
34
|
+
* bx_export_begin) and resolves with its pixels, transferred without a copy.
|
|
35
|
+
*/
|
|
36
|
+
renderFrame(seconds: number): Promise<{
|
|
37
|
+
width: number;
|
|
38
|
+
height: number;
|
|
39
|
+
buffer: ArrayBuffer;
|
|
40
|
+
timings: Record<string, number>;
|
|
41
|
+
}>;
|
|
32
42
|
busy: boolean;
|
|
33
43
|
waiting: boolean;
|
|
34
44
|
lastDataSet: {
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Timing of a local GIF / video export, per phase and per frame.
|
|
3
|
+
*
|
|
4
|
+
* Measuring only — nothing here changes what an export does. Every export logs
|
|
5
|
+
* one summary line; a host (the benchmark in bench/gif-export) can also take
|
|
6
|
+
* the full record through `onMetrics`. See GIF_EXPORT_PERF_PLAN.md.
|
|
7
|
+
*/
|
|
8
|
+
export type FrameMetrics = {
|
|
9
|
+
/** Moving the sandbox to the frame's time and waiting until it is drawn. */
|
|
10
|
+
seekMs: number;
|
|
11
|
+
/** Getting the SVG out of the sandbox (clone, inline stepped frames, postMessage). */
|
|
12
|
+
snapshotMs: number;
|
|
13
|
+
/** exportSVGDocument: fonts, images, text → paths. */
|
|
14
|
+
exportDocMs: number;
|
|
15
|
+
/** Rasterising the exported SVG onto the canvas. */
|
|
16
|
+
rasterMs: number;
|
|
17
|
+
/** getImageData. */
|
|
18
|
+
readbackMs: number;
|
|
19
|
+
/** Waiting for the encoder to accept the frame. */
|
|
20
|
+
encodeWaitMs: number;
|
|
21
|
+
totalMs: number;
|
|
22
|
+
/** Sub-steps reported by the sandbox renderer (e.g. doc.textMs, doc.repackMs). */
|
|
23
|
+
detail?: Record<string, number>;
|
|
24
|
+
};
|
|
25
|
+
export type ExportMetrics = {
|
|
26
|
+
kind: 'gif' | 'video';
|
|
27
|
+
/** 'legacy' = snapshot + render on the host page (today's path). */
|
|
28
|
+
path: 'legacy' | 'sandbox';
|
|
29
|
+
/** How a frame's time reaches the sandbox: TIME (whole template) or only the GIF clock. */
|
|
30
|
+
seekMode?: 'time' | 'gif-clock' | 'none';
|
|
31
|
+
/** gifTimeline loopRule (core >= 0.6.5). */
|
|
32
|
+
loopRule?: string;
|
|
33
|
+
frames: number;
|
|
34
|
+
durationMs: number;
|
|
35
|
+
gifCount: number;
|
|
36
|
+
/** Before the first frame: capability check, timeline (incl. waiting for GIF downloads), stepping on. */
|
|
37
|
+
setupMs: number;
|
|
38
|
+
/** Click-to-first-frame (setup + first frame). */
|
|
39
|
+
firstFrameMs: number;
|
|
40
|
+
loopMs: number;
|
|
41
|
+
finishMs: number;
|
|
42
|
+
totalMs: number;
|
|
43
|
+
outputBytes: number;
|
|
44
|
+
encoder?: string;
|
|
45
|
+
frame: FrameMetrics[];
|
|
46
|
+
};
|
|
47
|
+
/** Filled in by BxLiveTemplate.render when a caller passes it. */
|
|
48
|
+
export type RenderMetrics = {
|
|
49
|
+
snapshotMs?: number;
|
|
50
|
+
exportDocMs?: number;
|
|
51
|
+
rasterMs?: number;
|
|
52
|
+
};
|
|
53
|
+
export declare const now: () => number;
|
|
54
|
+
export declare function median(values: number[]): number;
|
|
55
|
+
export declare function percentile(values: number[], p: number): number;
|
|
56
|
+
/** One line, e.g. `[GIF EXPORT] 65 frames in 9.8 s · setup 2.1 s · per frame median 104 ms (seek 6 · snapshot 20 · doc 51 · raster 22 · readback 3 · encode-wait 2) · 4.2 MB`. */
|
|
57
|
+
export declare function summarizeExport(m: ExportMetrics): string;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { type ExportMetrics, type RenderMetrics } from '../exportMetrics';
|
|
1
2
|
import { type GifExportTimeline, type SandboxEvaluator } from './sandboxGif';
|
|
2
3
|
/** The slice of BxLiveTemplate's API a GIF export needs. */
|
|
3
4
|
export type GifExportLiveTemplate = SandboxEvaluator & {
|
|
@@ -15,8 +16,47 @@ export type GifExportLiveTemplate = SandboxEvaluator & {
|
|
|
15
16
|
resultType: 'canvas';
|
|
16
17
|
externalCanvas: HTMLCanvasElement | null;
|
|
17
18
|
svgLoadWaitDelay?: number;
|
|
19
|
+
metrics?: RenderMetrics;
|
|
18
20
|
}): Promise<HTMLCanvasElement>;
|
|
21
|
+
/** Core >= 0.6.5: one frame rendered inside the sandbox (BxLiveTemplate). */
|
|
22
|
+
renderFrame?(seconds: number): Promise<SandboxFrame>;
|
|
23
|
+
/** The watermark as SVG markup for the sandbox renderer (BxLiveTemplate). */
|
|
24
|
+
watermarkOverlay?(width: number, height: number): string;
|
|
19
25
|
};
|
|
26
|
+
export type SandboxFrame = {
|
|
27
|
+
width: number;
|
|
28
|
+
height: number;
|
|
29
|
+
buffer: ArrayBuffer;
|
|
30
|
+
timings: Record<string, number>;
|
|
31
|
+
};
|
|
32
|
+
/**
|
|
33
|
+
* 'auto': render frames inside the sandbox when it can (core >= 0.6.5), else
|
|
34
|
+
* on this page. 'legacy': always on this page (comparisons, emergency switch).
|
|
35
|
+
*/
|
|
36
|
+
export type ExportRenderPath = 'auto' | 'legacy';
|
|
37
|
+
/** Opens a sandbox export session when the sandbox supports it and the caller allows it. */
|
|
38
|
+
export declare function openSandboxSession(liveTemplate: GifExportLiveTemplate, options: {
|
|
39
|
+
path?: ExportRenderPath;
|
|
40
|
+
watermark: boolean;
|
|
41
|
+
size?: {
|
|
42
|
+
width: number;
|
|
43
|
+
height: number;
|
|
44
|
+
};
|
|
45
|
+
}): Promise<boolean>;
|
|
46
|
+
/** Renders one frame in the sandbox and turns its timings into FrameMetrics fields. */
|
|
47
|
+
export declare function renderSandboxFrame(liveTemplate: GifExportLiveTemplate, seconds: number): Promise<{
|
|
48
|
+
frame: SandboxFrame;
|
|
49
|
+
metrics: {
|
|
50
|
+
seekMs: number;
|
|
51
|
+
snapshotMs: number;
|
|
52
|
+
exportDocMs: number;
|
|
53
|
+
rasterMs: number;
|
|
54
|
+
readbackMs: number;
|
|
55
|
+
detail: {
|
|
56
|
+
[k: string]: number;
|
|
57
|
+
};
|
|
58
|
+
};
|
|
59
|
+
}>;
|
|
20
60
|
/**
|
|
21
61
|
* Stepped GIF frames reach the rasterizer as data: URIs, and exportSVGDocument
|
|
22
62
|
* caches every image by its URL for the life of the page. Dropped after an
|
|
@@ -27,6 +67,7 @@ export type LocalGifExportResult = {
|
|
|
27
67
|
blob: Blob;
|
|
28
68
|
timeline: GifExportTimeline;
|
|
29
69
|
encoder: 'worker' | 'main-thread';
|
|
70
|
+
metrics: ExportMetrics;
|
|
30
71
|
};
|
|
31
72
|
/**
|
|
32
73
|
* Exports the live template as a GIF in the browser.
|
|
@@ -38,8 +79,18 @@ export type LocalGifExportResult = {
|
|
|
38
79
|
* a worker while the next frame renders. A template without animated GIFs —
|
|
39
80
|
* or on a core older than 0.6.3 — becomes a one-frame GIF.
|
|
40
81
|
*/
|
|
41
|
-
export declare function exportGifLocal(liveTemplate: GifExportLiveTemplate, options:
|
|
82
|
+
export declare function exportGifLocal(liveTemplate: GifExportLiveTemplate, options: Parameters<typeof exportGifLocalOnce>[1]): Promise<LocalGifExportResult>;
|
|
83
|
+
declare function exportGifLocalOnce(liveTemplate: GifExportLiveTemplate, options: {
|
|
42
84
|
watermark: boolean;
|
|
43
85
|
svgLoadWaitDelay?: number;
|
|
44
86
|
onProgress?: (progress: number) => void;
|
|
87
|
+
/** The full timing record (benchmarks); a summary is always logged. */
|
|
88
|
+
onMetrics?: (metrics: ExportMetrics) => void;
|
|
89
|
+
path?: ExportRenderPath;
|
|
90
|
+
/** Document size (for the watermark of the sandbox renderer). */
|
|
91
|
+
size?: {
|
|
92
|
+
width: number;
|
|
93
|
+
height: number;
|
|
94
|
+
};
|
|
45
95
|
}): Promise<LocalGifExportResult>;
|
|
96
|
+
export {};
|
|
@@ -35,3 +35,18 @@ export declare function readGifTimeline(sandbox: SandboxEvaluator): Promise<GifE
|
|
|
35
35
|
export declare function setGifStepping(sandbox: SandboxEvaluator, on: boolean): Promise<void>;
|
|
36
36
|
/** Moves the sandbox to `seconds` and resolves once every GIF shows its frame for it. */
|
|
37
37
|
export declare function seekSandboxTime(sandbox: SandboxEvaluator, seconds: number): Promise<void>;
|
|
38
|
+
/** Core >= 0.6.5: the sandbox can move only its GIFs, without touching TIME. */
|
|
39
|
+
export declare function sandboxSupportsGifSeek(sandbox: SandboxEvaluator): Promise<boolean>;
|
|
40
|
+
/**
|
|
41
|
+
* Moves only the GIFs to `seconds` and resolves once each shows its frame.
|
|
42
|
+
* For templates whose only motion is GIFs: setting TIME instead re-evaluates
|
|
43
|
+
* the whole template on every frame (GIF_EXPORT_PERF_PLAN F).
|
|
44
|
+
*/
|
|
45
|
+
export declare function seekSandboxGifs(sandbox: SandboxEvaluator, seconds: number): Promise<void>;
|
|
46
|
+
/** Core >= 0.6.5: the sandbox renders export frames itself (bx_export_begin / renderFrame / bx_export_end). */
|
|
47
|
+
export declare function sandboxSupportsFrameRenderer(sandbox: SandboxEvaluator): Promise<boolean>;
|
|
48
|
+
/** Opens an export session in the sandbox; resolves with whether the template animates itself. */
|
|
49
|
+
export declare function beginSandboxExport(sandbox: SandboxEvaluator, overlaySvg?: string): Promise<{
|
|
50
|
+
animated: boolean;
|
|
51
|
+
}>;
|
|
52
|
+
export declare function endSandboxExport(sandbox: SandboxEvaluator): Promise<void>;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { type ExportRenderPath, type GifExportLiveTemplate } from '../gif/exportGifLocal';
|
|
2
|
+
import { type ExportMetrics } from '../exportMetrics';
|
|
3
|
+
export type LocalVideoExportResult = {
|
|
4
|
+
blob: Blob;
|
|
5
|
+
/** What was actually encoded (a GIF-only template runs as long as its GIF loop). */
|
|
6
|
+
durationSeconds: number;
|
|
7
|
+
metrics: ExportMetrics;
|
|
8
|
+
};
|
|
9
|
+
/**
|
|
10
|
+
* Local MP4 export: renders every frame like a PNG export and hands it to the
|
|
11
|
+
* WebCodecs encoder (mediabunny). Moved out of useTemplateExport unchanged so
|
|
12
|
+
* the benchmark (bench/gif-export) measures the code users run.
|
|
13
|
+
*
|
|
14
|
+
* On a core >= 0.6.3 sandbox every frame seeks the sandbox directly and waits
|
|
15
|
+
* until it is drawn; the editor's timecode is left alone during the export and
|
|
16
|
+
* restored afterwards (it would otherwise reach the sandbox a second time
|
|
17
|
+
* through the editor's async data sync). Older sandboxes are driven through the
|
|
18
|
+
* timecode, as before.
|
|
19
|
+
*/
|
|
20
|
+
export declare function exportVideoLocal(liveTemplate: GifExportLiveTemplate, options: {
|
|
21
|
+
fps: number;
|
|
22
|
+
templateDurationSeconds: number;
|
|
23
|
+
watermark: boolean;
|
|
24
|
+
svgLoadWaitDelay?: number;
|
|
25
|
+
timecode: {
|
|
26
|
+
get(): number;
|
|
27
|
+
set(seconds: number): void;
|
|
28
|
+
};
|
|
29
|
+
onProgress?: (progress: number) => void;
|
|
30
|
+
onMetrics?: (metrics: ExportMetrics) => void;
|
|
31
|
+
path?: ExportRenderPath;
|
|
32
|
+
/** Document size (for the watermark of the sandbox renderer). */
|
|
33
|
+
size?: {
|
|
34
|
+
width: number;
|
|
35
|
+
height: number;
|
|
36
|
+
};
|
|
37
|
+
}): Promise<LocalVideoExportResult>;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bluepic/embed",
|
|
3
|
-
"version": "0.6.
|
|
3
|
+
"version": "0.6.30",
|
|
4
4
|
"description": "Bluepic embed sdk",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"sideEffects": false,
|
|
@@ -77,7 +77,7 @@
|
|
|
77
77
|
"zod": "4.1.12"
|
|
78
78
|
},
|
|
79
79
|
"dependencies": {
|
|
80
|
-
"@bluepic/raster": "^0.1.
|
|
80
|
+
"@bluepic/raster": "^0.1.14",
|
|
81
81
|
"@floating-ui/vue": "^1.1.9",
|
|
82
82
|
"@vicons/ionicons5": "^0.13.0",
|
|
83
83
|
"@vueuse/core": "^14.0.0",
|