@alpha2-sh/editor 0.4.6 → 0.5.1
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/browser/bridge.d.ts +15 -16
- package/dist/browser/bridge.js +393 -312
- package/dist/browser/extensions-worker.d.ts +12 -16
- package/dist/browser/extensions-worker.js +17 -24
- package/dist/browser/hash-worker.d.ts +4 -5
- package/dist/browser/hash-worker.js +7 -8
- package/dist/browser/jobs.d.ts +17 -19
- package/dist/browser/jobs.js +41 -28
- package/dist/browser/resources.d.ts +6 -11
- package/dist/browser/resources.js +5 -9
- package/dist/browser/runtime/assets.d.ts +52 -28
- package/dist/browser/runtime/assets.js +136 -45
- package/dist/browser/runtime/audio.d.ts +16 -11
- package/dist/browser/runtime/audio.js +102 -59
- package/dist/browser/runtime/budget.d.ts +4 -5
- package/dist/browser/runtime/budget.js +4 -5
- package/dist/browser/runtime/caption-fonts.d.ts +3 -7
- package/dist/browser/runtime/caption-fonts.js +4 -8
- package/dist/browser/runtime/engine.d.ts +44 -44
- package/dist/browser/runtime/engine.js +87 -64
- package/dist/browser/runtime/export-audio.d.ts +6 -6
- package/dist/browser/runtime/export-audio.js +8 -9
- package/dist/browser/runtime/exporter.d.ts +33 -66
- package/dist/browser/runtime/exporter.js +111 -137
- package/dist/browser/runtime/extension-import.d.ts +28 -35
- package/dist/browser/runtime/extension-import.js +36 -46
- package/dist/browser/runtime/fingerprint.d.ts +11 -14
- package/dist/browser/runtime/fingerprint.js +20 -24
- package/dist/browser/runtime/generators.d.ts +2 -3
- package/dist/browser/runtime/generators.js +5 -7
- package/dist/browser/runtime/locks.d.ts +5 -7
- package/dist/browser/runtime/locks.js +5 -7
- package/dist/browser/runtime/output.d.ts +7 -9
- package/dist/browser/runtime/output.js +17 -21
- package/dist/browser/runtime/preview-utils.js +10 -6
- package/dist/browser/runtime/proxies.d.ts +19 -19
- package/dist/browser/runtime/proxies.js +72 -51
- package/dist/browser/runtime/proxy-storage.d.ts +15 -19
- package/dist/browser/runtime/proxy-storage.js +20 -24
- package/dist/browser/runtime/sources.d.ts +23 -31
- package/dist/browser/runtime/sources.js +85 -103
- package/dist/browser/runtime/staging.d.ts +2 -6
- package/dist/browser/runtime/staging.js +7 -11
- package/dist/browser/runtime/still.d.ts +2 -6
- package/dist/browser/runtime/still.js +6 -12
- package/dist/browser/runtime/text.d.ts +14 -0
- package/dist/browser/runtime/text.js +27 -0
- package/dist/browser/runtime/wasm.d.ts +4 -5
- package/dist/browser/runtime/wasm.js +4 -5
- package/dist/browser/types.d.ts +244 -239
- package/dist/browser/worker.d.ts +10 -10
- package/dist/browser/worker.js +64 -22
- package/dist/core/captions.d.ts +8 -10
- package/dist/core/captions.js +10 -18
- package/dist/core/clip-time.d.ts +8 -10
- package/dist/core/clip-time.js +12 -15
- package/dist/core/commands.d.ts +46 -46
- package/dist/core/commands.js +38 -36
- package/dist/core/compositions.d.ts +78 -112
- package/dist/core/compositions.js +66 -94
- package/dist/core/document.d.ts +59 -92
- package/dist/core/document.js +65 -90
- package/dist/core/keyframes.d.ts +11 -12
- package/dist/core/keyframes.js +11 -13
- package/dist/core/presets.d.ts +14 -20
- package/dist/core/presets.js +12 -18
- package/dist/core/session.d.ts +26 -38
- package/dist/core/session.js +38 -53
- package/dist/core/text.d.ts +2 -3
- package/dist/core/text.js +2 -3
- package/dist/core/timeline-index.d.ts +2 -3
- package/dist/core/timeline-index.js +11 -7
- package/dist/core/transitions.js +4 -5
- package/dist/core/validated.d.ts +6 -7
- package/dist/core/validated.js +8 -11
- package/dist/native-client/index.d.ts +31 -32
- package/dist/native-client/index.js +40 -41
- package/dist/ports/index.d.ts +19 -20
- package/dist/react/index.d.ts +5 -6
- package/dist/react/index.js +5 -6
- package/package.json +4 -4
|
@@ -5,15 +5,15 @@ import { type ExportFailure } from "alpha2/export-failure";
|
|
|
5
5
|
import { ExportJob } from "../browser/jobs.js";
|
|
6
6
|
import type { BrowserExportOptions } from "../browser/types.js";
|
|
7
7
|
/**
|
|
8
|
-
* A file uploaded for a native export, usually
|
|
9
|
-
*
|
|
8
|
+
* A file uploaded for a native export, usually from the browser bridge's `nativeAssets`. The host
|
|
9
|
+
* reads media only from these uploads, never from a path the document names.
|
|
10
10
|
*/
|
|
11
11
|
export interface NativeAsset {
|
|
12
12
|
/** The source, resource or font id the file belongs to (for `frames`, the upload's own id). */
|
|
13
13
|
readonly id: string;
|
|
14
14
|
/**
|
|
15
|
-
* `proxies`: a proxy
|
|
16
|
-
*
|
|
15
|
+
* `proxies`: a proxy for source `id`, made from `madeFrom`. `frames`: one image sequence frame,
|
|
16
|
+
* the file at `locator`.
|
|
17
17
|
*/
|
|
18
18
|
readonly kind: "assets" | "effect-assets" | "caption-fonts" | "proxies" | "frames";
|
|
19
19
|
readonly blob: Blob;
|
|
@@ -23,9 +23,9 @@ export interface NativeAsset {
|
|
|
23
23
|
readonly locator?: string;
|
|
24
24
|
}
|
|
25
25
|
/**
|
|
26
|
-
* Export settings for a native job: the browser export's options
|
|
27
|
-
* host can encode. `container`, `videoCodec`
|
|
28
|
-
*
|
|
26
|
+
* Export settings for a native job: the browser export's options plus the MPEG-4 Part 2 codec the
|
|
27
|
+
* host can encode. An absent `container`, `videoCodec` or `audioCodec` takes the host's default, as
|
|
28
|
+
* in the browser.
|
|
29
29
|
*/
|
|
30
30
|
export interface NativeExportOptions extends Omit<BrowserExportOptions, "videoCodec"> {
|
|
31
31
|
readonly videoCodec?: BrowserExportOptions["videoCodec"] | "mpeg4-part2";
|
|
@@ -51,9 +51,9 @@ export type NativeArtifactStatus = {
|
|
|
51
51
|
readonly status: "missing" | "unreachable";
|
|
52
52
|
};
|
|
53
53
|
/**
|
|
54
|
-
* Asks the service whether
|
|
55
|
-
*
|
|
56
|
-
*
|
|
54
|
+
* Asks the service whether an artifact's `url` can still be downloaded, without downloading it.
|
|
55
|
+
* Never rejects: a network error is `unreachable`, a 404 is `missing`, and a 410 is `gone` with the
|
|
56
|
+
* service's reason (`expired` when it gives none).
|
|
57
57
|
*/
|
|
58
58
|
export declare function nativeArtifactStatus(url: string, request?: typeof fetch): Promise<NativeArtifactStatus>;
|
|
59
59
|
/** A native job's state as the service reports it. */
|
|
@@ -61,7 +61,7 @@ export interface NativeJobState {
|
|
|
61
61
|
readonly phase: "preparing" | "rendering" | "finalizing" | "publishing" | "completed" | "failed" | "cancelled";
|
|
62
62
|
/** The finished file, once `completed`. */
|
|
63
63
|
readonly artifact?: NativeArtifactDescriptor;
|
|
64
|
-
/**
|
|
64
|
+
/** Share done, from 0 to 1. */
|
|
65
65
|
readonly fraction: number;
|
|
66
66
|
readonly frames?: {
|
|
67
67
|
readonly completed: number;
|
|
@@ -72,9 +72,9 @@ export interface NativeJobState {
|
|
|
72
72
|
/** The host's classified failure, when `failed`. */
|
|
73
73
|
readonly failure?: ExportFailure;
|
|
74
74
|
/**
|
|
75
|
-
*
|
|
76
|
-
*
|
|
77
|
-
*
|
|
75
|
+
* Render cache report of the last attempt that finished rendering: `used` with its counts, or
|
|
76
|
+
* `unavailable` with the reason. `null` when the attempt rendered without one. Absent until an
|
|
77
|
+
* attempt reports.
|
|
78
78
|
*/
|
|
79
79
|
readonly resume?: {
|
|
80
80
|
readonly status: "used";
|
|
@@ -91,42 +91,41 @@ export interface NativeClientOptions {
|
|
|
91
91
|
readonly fetch?: typeof fetch;
|
|
92
92
|
}
|
|
93
93
|
/**
|
|
94
|
-
* A client for the native export service (`@alpha2-sh/node`'s HTTP host). Exports run
|
|
95
|
-
*
|
|
94
|
+
* A client for the native export service (`@alpha2-sh/node`'s HTTP host). Exports run with the
|
|
95
|
+
* editor's retry policy; each job uploads its assets once and reuses them across attempts.
|
|
96
96
|
*/
|
|
97
97
|
export declare function createNativeClient(options: NativeClientOptions): {
|
|
98
98
|
/** The service's `/health` report. Rejects when the service answers with an error status. */
|
|
99
99
|
capabilities(): Promise<Record<string, unknown>>;
|
|
100
100
|
/**
|
|
101
|
-
* Starts an export of `editor.document` on the service
|
|
102
|
-
*
|
|
103
|
-
*
|
|
104
|
-
*
|
|
105
|
-
*
|
|
101
|
+
* Starts an export of `editor.document` on the service. The document, `assets` and `settings`
|
|
102
|
+
* are captured now, so later edits do not reach the job. `assets` may be a function, called
|
|
103
|
+
* once per upload with the document and the attempt's signal. The range is the document's
|
|
104
|
+
* export range, else the whole timeline. Throws when the client is disposed, and an
|
|
105
|
+
* `EditorError` `invalid_frame_rate` for a `frameRate` the engine does not read.
|
|
106
106
|
*/
|
|
107
107
|
startExport(editor: Pick<EditorSnapshot, "document" | "revision">, assets: readonly NativeAsset[] | ((document: EditorDocument, signal: AbortSignal) => Promise<readonly NativeAsset[]>), settings?: NativeExportOptions): ExportJob;
|
|
108
108
|
/**
|
|
109
|
-
* What the service knows of job `id`, for a page that lost the job it started
|
|
110
|
-
*
|
|
111
|
-
*
|
|
109
|
+
* What the service knows of job `id`, for a reloaded page that lost the job it started: its
|
|
110
|
+
* state and, once complete, where to download its file. `null` when the service no longer has
|
|
111
|
+
* the job. Rejects on any other error status.
|
|
112
112
|
*/
|
|
113
113
|
jobState(id: string): Promise<(NativeJobState & {
|
|
114
114
|
readonly url?: string;
|
|
115
115
|
}) | null>;
|
|
116
116
|
/**
|
|
117
|
-
* Removes job `id` from the service
|
|
118
|
-
* a job
|
|
119
|
-
* {@link jobState}). Rejects when the service answers with an error status.
|
|
117
|
+
* Removes job `id` from the service, stopping its render and deleting its kept file. Meant for
|
|
118
|
+
* a job another page left behind (see {@link jobState}). Rejects on an error status.
|
|
120
119
|
*/
|
|
121
120
|
releaseJob(id: string): Promise<void>;
|
|
122
121
|
/** Cancels every running job and refuses new ones. Resolves once the cancellations settle. */
|
|
123
122
|
dispose(): Promise<void>;
|
|
124
123
|
/**
|
|
125
|
-
*
|
|
126
|
-
* cancelling
|
|
127
|
-
*
|
|
128
|
-
*
|
|
129
|
-
*
|
|
124
|
+
* Releases every running job and refuses new ones, for a page that is leaving, without
|
|
125
|
+
* cancelling renders already requested: those continue on the service and keep their files for
|
|
126
|
+
* a later page to find with {@link jobState}. Jobs still uploading are removed, since only this
|
|
127
|
+
* client could send the rest. Local jobs settle as cancelled; resolves once they do. A failed
|
|
128
|
+
* removal is left to the service's lease.
|
|
130
129
|
*/
|
|
131
130
|
detach(): Promise<void>;
|
|
132
131
|
};
|
|
@@ -2,9 +2,9 @@ import { compileEditorDocument, EditorError, sequenceEnd, } from "../core/docume
|
|
|
2
2
|
import { ExportFailureError } from "alpha2/export-failure";
|
|
3
3
|
import { ExportJob, requireExportFrameRate } from "../browser/jobs.js";
|
|
4
4
|
/**
|
|
5
|
-
* Asks the service whether
|
|
6
|
-
*
|
|
7
|
-
*
|
|
5
|
+
* Asks the service whether an artifact's `url` can still be downloaded, without downloading it.
|
|
6
|
+
* Never rejects: a network error is `unreachable`, a 404 is `missing`, and a 410 is `gone` with the
|
|
7
|
+
* service's reason (`expired` when it gives none).
|
|
8
8
|
*/
|
|
9
9
|
export async function nativeArtifactStatus(url, request = fetch) {
|
|
10
10
|
let response;
|
|
@@ -22,7 +22,7 @@ export async function nativeArtifactStatus(url, request = fetch) {
|
|
|
22
22
|
};
|
|
23
23
|
}
|
|
24
24
|
if (response.status === 410) {
|
|
25
|
-
// A HEAD
|
|
25
|
+
// A HEAD response has no body, so ask again for the reason.
|
|
26
26
|
const detail = (await request(url)
|
|
27
27
|
.then((full) => full.json())
|
|
28
28
|
.catch(() => ({})));
|
|
@@ -46,9 +46,9 @@ function nativeFailure(state, jobId) {
|
|
|
46
46
|
};
|
|
47
47
|
return new ExportFailureError({ ...failure, message, jobId });
|
|
48
48
|
}
|
|
49
|
-
/**
|
|
49
|
+
/** Consecutive failed status requests before an attempt gives up on the job. */
|
|
50
50
|
const STATUS_ATTEMPTS = 5;
|
|
51
|
-
/**
|
|
51
|
+
/** Status retry delay, doubled each time (0.25 s to 2 s). */
|
|
52
52
|
const STATUS_RETRY_MS = 250;
|
|
53
53
|
function delay(ms, signal) {
|
|
54
54
|
return new Promise((resolve, reject) => {
|
|
@@ -66,15 +66,15 @@ function delay(ms, signal) {
|
|
|
66
66
|
});
|
|
67
67
|
}
|
|
68
68
|
/**
|
|
69
|
-
* A client for the native export service (`@alpha2-sh/node`'s HTTP host). Exports run
|
|
70
|
-
*
|
|
69
|
+
* A client for the native export service (`@alpha2-sh/node`'s HTTP host). Exports run with the
|
|
70
|
+
* editor's retry policy; each job uploads its assets once and reuses them across attempts.
|
|
71
71
|
*/
|
|
72
72
|
export function createNativeClient(options) {
|
|
73
73
|
const request = options.fetch ?? fetch;
|
|
74
74
|
const base = options.baseUrl.replace(/\/$/, "");
|
|
75
75
|
const jobs = new Set();
|
|
76
76
|
let disposed = false;
|
|
77
|
-
// Set by `detach`:
|
|
77
|
+
// Set by `detach`: jobs whose render was requested are released, not removed.
|
|
78
78
|
let detached = false;
|
|
79
79
|
async function checked(path, init) {
|
|
80
80
|
const response = await request(`${base}${path}`, init);
|
|
@@ -88,11 +88,11 @@ export function createNativeClient(options) {
|
|
|
88
88
|
return (await checked("/health")).json();
|
|
89
89
|
},
|
|
90
90
|
/**
|
|
91
|
-
* Starts an export of `editor.document` on the service
|
|
92
|
-
*
|
|
93
|
-
*
|
|
94
|
-
*
|
|
95
|
-
*
|
|
91
|
+
* Starts an export of `editor.document` on the service. The document, `assets` and `settings`
|
|
92
|
+
* are captured now, so later edits do not reach the job. `assets` may be a function, called
|
|
93
|
+
* once per upload with the document and the attempt's signal. The range is the document's
|
|
94
|
+
* export range, else the whole timeline. Throws when the client is disposed, and an
|
|
95
|
+
* `EditorError` `invalid_frame_rate` for a `frameRate` the engine does not read.
|
|
96
96
|
*/
|
|
97
97
|
startExport(editor, assets, settings = {}) {
|
|
98
98
|
if (disposed)
|
|
@@ -103,13 +103,13 @@ export function createNativeClient(options) {
|
|
|
103
103
|
const capturedAssets = typeof assets === "function" ? assets : [...assets];
|
|
104
104
|
const id = crypto.randomUUID();
|
|
105
105
|
const path = `/jobs/${id}`;
|
|
106
|
-
// Shared by attempts
|
|
106
|
+
// Shared by attempts; an attempt starts over only when the service lost the job.
|
|
107
107
|
let captured = null;
|
|
108
|
-
// Whether the service holds a job to clean up
|
|
108
|
+
// Whether the service holds a job to clean up, from the acknowledged PUT on.
|
|
109
109
|
let allocated = false;
|
|
110
110
|
const acknowledged = new Set();
|
|
111
111
|
let uploaded = null;
|
|
112
|
-
// Whether a render was
|
|
112
|
+
// Whether a render was requested; the service may still run one from an earlier attempt.
|
|
113
113
|
let posted = false;
|
|
114
114
|
const lost = () => {
|
|
115
115
|
allocated = false;
|
|
@@ -118,13 +118,13 @@ export function createNativeClient(options) {
|
|
|
118
118
|
posted = false;
|
|
119
119
|
};
|
|
120
120
|
const allocate = async () => {
|
|
121
|
-
// Allocate without the cancellation signal
|
|
122
|
-
// before DELETE
|
|
121
|
+
// Allocate without the cancellation signal so a cancelled allocation is still acknowledged
|
|
122
|
+
// before DELETE and cannot leave an orphan job.
|
|
123
123
|
try {
|
|
124
124
|
await checked(path, { method: "PUT" });
|
|
125
125
|
}
|
|
126
126
|
catch (error) {
|
|
127
|
-
//
|
|
127
|
+
// The allocation's response was lost. The id is unique to this job, so a job there is it.
|
|
128
128
|
const existing = await request(`${base}${path}`).catch(() => null);
|
|
129
129
|
if (!existing?.ok)
|
|
130
130
|
throw error;
|
|
@@ -161,9 +161,9 @@ export function createNativeClient(options) {
|
|
|
161
161
|
};
|
|
162
162
|
};
|
|
163
163
|
/**
|
|
164
|
-
* The job's state.
|
|
165
|
-
*
|
|
166
|
-
*
|
|
164
|
+
* The job's state. Transient failures (network, a proxy's 502) are retried with backoff so a
|
|
165
|
+
* long render is not abandoned over one lost response. A 404 means the service lost the job
|
|
166
|
+
* and the next attempt starts over.
|
|
167
167
|
*/
|
|
168
168
|
const status = async (signal, attempt) => {
|
|
169
169
|
for (let failures = 1;; failures += 1) {
|
|
@@ -209,8 +209,8 @@ export function createNativeClient(options) {
|
|
|
209
209
|
if (diagnostics.length)
|
|
210
210
|
throw Error(diagnostics.map((d) => d.message).join("; "));
|
|
211
211
|
signal.throwIfAborted();
|
|
212
|
-
//
|
|
213
|
-
// while it runs).
|
|
212
|
+
// Follow a render an earlier attempt requested instead of requesting it again (the service
|
|
213
|
+
// refuses that while it runs). Request anew if it failed or never started.
|
|
214
214
|
const running = posted
|
|
215
215
|
? !["preparing", "failed"].includes((await status(signal, attempt)).phase)
|
|
216
216
|
: false;
|
|
@@ -227,7 +227,6 @@ export function createNativeClient(options) {
|
|
|
227
227
|
fonts: captured
|
|
228
228
|
.filter((a) => a.kind === "caption-fonts")
|
|
229
229
|
.map((a) => a.id),
|
|
230
|
-
// Each image sequence's frame uploads, in project order.
|
|
231
230
|
frames: Object.fromEntries(project.sources.flatMap((source) => source.provider?.format === "image_sequence"
|
|
232
231
|
? [
|
|
233
232
|
[
|
|
@@ -242,7 +241,7 @@ export function createNativeClient(options) {
|
|
|
242
241
|
.filter((a) => a.kind === "proxies")
|
|
243
242
|
.map((a) => [a.id, { madeFrom: a.madeFrom }])),
|
|
244
243
|
media: capturedSettings.media ?? "original",
|
|
245
|
-
//
|
|
244
|
+
// Retries keep less in flight; the host scales its own budgets.
|
|
246
245
|
...(attempt.profile.memoryScale < 1 || capturedSettings.memory
|
|
247
246
|
? {
|
|
248
247
|
memory: {
|
|
@@ -278,7 +277,8 @@ export function createNativeClient(options) {
|
|
|
278
277
|
const artifact = published;
|
|
279
278
|
if (!artifact)
|
|
280
279
|
throw Error("The native service finished without a file to download");
|
|
281
|
-
// The file stays on the service until released, so a failed download
|
|
280
|
+
// The file stays on the service until released, so a failed download can retry without a
|
|
281
|
+
// rerender.
|
|
282
282
|
return {
|
|
283
283
|
kind: "url",
|
|
284
284
|
url: `${base}${path}/artifact`,
|
|
@@ -292,8 +292,8 @@ export function createNativeClient(options) {
|
|
|
292
292
|
};
|
|
293
293
|
const job = new ExportJob(editor.revision, document, {
|
|
294
294
|
run: render,
|
|
295
|
-
//
|
|
296
|
-
// resolves only after the host exits and its files are removed.
|
|
295
|
+
// Clean up once the job settles, never between attempts (retries reuse the uploads).
|
|
296
|
+
// DELETE resolves only after the host exits and its files are removed.
|
|
297
297
|
async dispose({ ok }) {
|
|
298
298
|
if (ok || !allocated || (detached && posted))
|
|
299
299
|
return;
|
|
@@ -310,9 +310,9 @@ export function createNativeClient(options) {
|
|
|
310
310
|
return job;
|
|
311
311
|
},
|
|
312
312
|
/**
|
|
313
|
-
* What the service knows of job `id`, for a page that lost the job it started
|
|
314
|
-
*
|
|
315
|
-
*
|
|
313
|
+
* What the service knows of job `id`, for a reloaded page that lost the job it started: its
|
|
314
|
+
* state and, once complete, where to download its file. `null` when the service no longer has
|
|
315
|
+
* the job. Rejects on any other error status.
|
|
316
316
|
*/
|
|
317
317
|
async jobState(id) {
|
|
318
318
|
const response = await request(`${base}/jobs/${encodeURIComponent(id)}`);
|
|
@@ -326,9 +326,8 @@ export function createNativeClient(options) {
|
|
|
326
326
|
: state;
|
|
327
327
|
},
|
|
328
328
|
/**
|
|
329
|
-
* Removes job `id` from the service
|
|
330
|
-
* a job
|
|
331
|
-
* {@link jobState}). Rejects when the service answers with an error status.
|
|
329
|
+
* Removes job `id` from the service, stopping its render and deleting its kept file. Meant for
|
|
330
|
+
* a job another page left behind (see {@link jobState}). Rejects on an error status.
|
|
332
331
|
*/
|
|
333
332
|
async releaseJob(id) {
|
|
334
333
|
await checked(`/jobs/${encodeURIComponent(id)}`, { method: "DELETE" });
|
|
@@ -339,11 +338,11 @@ export function createNativeClient(options) {
|
|
|
339
338
|
await Promise.all([...jobs].map((job) => job.cancel()));
|
|
340
339
|
},
|
|
341
340
|
/**
|
|
342
|
-
*
|
|
343
|
-
* cancelling
|
|
344
|
-
*
|
|
345
|
-
*
|
|
346
|
-
*
|
|
341
|
+
* Releases every running job and refuses new ones, for a page that is leaving, without
|
|
342
|
+
* cancelling renders already requested: those continue on the service and keep their files for
|
|
343
|
+
* a later page to find with {@link jobState}. Jobs still uploading are removed, since only this
|
|
344
|
+
* client could send the rest. Local jobs settle as cancelled; resolves once they do. A failed
|
|
345
|
+
* removal is left to the service's lease.
|
|
347
346
|
*/
|
|
348
347
|
async detach() {
|
|
349
348
|
disposed = true;
|
package/dist/ports/index.d.ts
CHANGED
|
@@ -1,13 +1,11 @@
|
|
|
1
1
|
import type { Selection } from "alpha2/assets";
|
|
2
2
|
import type { ExportFailure } from "alpha2/export-failure";
|
|
3
|
-
import type { RetryProfile } from "alpha2/export-retry";
|
|
3
|
+
import type { AttemptRenderer, AttemptVideoEncoder, RetryProfile } from "alpha2/export-retry";
|
|
4
4
|
import type { Project } from "alpha2/project";
|
|
5
5
|
import type { EditorDocument, AssetDescriptor } from "../core/document.js";
|
|
6
6
|
/** Shows a project in a preview surface. Implemented by the browser bridge and native previews. */
|
|
7
7
|
export interface PreviewBridge {
|
|
8
|
-
/**
|
|
9
|
-
* Replaces the shown project. `revision` identifies this version and increases with every call.
|
|
10
|
-
*/
|
|
8
|
+
/** Replaces the shown project. `revision` increases with every call. */
|
|
11
9
|
replaceProject(project: Project, revision: number): Promise<void>;
|
|
12
10
|
/** Shows the frame at `tick` (timeline ticks). */
|
|
13
11
|
seek(tick: number): Promise<void>;
|
|
@@ -40,10 +38,10 @@ export interface AudioTransport {
|
|
|
40
38
|
/** An export job's progress, as its backends report it and `ExportJob.progress` holds it. */
|
|
41
39
|
export interface ExportProgress {
|
|
42
40
|
/**
|
|
43
|
-
*
|
|
44
|
-
*
|
|
45
|
-
*
|
|
46
|
-
*
|
|
41
|
+
* `rendering` counts frames; `finalizing` means every frame is encoded and the output is being
|
|
42
|
+
* flushed; `publishing` that the file is being made available; `downloading` that a native result
|
|
43
|
+
* is transferring to this browser. Only `completed` means the result exists, even at 100 % of
|
|
44
|
+
* frames.
|
|
47
45
|
*/
|
|
48
46
|
readonly phase: "preparing" | "rendering" | "finalizing" | "publishing" | "downloading" | "retrying" | "completed" | "cancelling" | "cancelled" | "failed";
|
|
49
47
|
/** The whole job's share done, from 0 to 1. */
|
|
@@ -95,28 +93,29 @@ export type ExportArtifact = ({
|
|
|
95
93
|
/** The file's length, when known. */
|
|
96
94
|
readonly bytes?: number;
|
|
97
95
|
/**
|
|
98
|
-
*
|
|
99
|
-
*
|
|
100
|
-
*
|
|
101
|
-
*
|
|
102
|
-
*
|
|
103
|
-
* decode in software (`kind: "software-unavailable"`).
|
|
96
|
+
* The exporter's run report: timings, `performance` (with `memory` and `output`), rates. A
|
|
97
|
+
* browser export adds `videoDecode` (the decode mode used), `videoConversion` (`engine` or
|
|
98
|
+
* `browser`), and `decodeFallbacks`. Those list, per source, frames read by element seeks instead
|
|
99
|
+
* of decoding (`kind: "element-seek"`, with reason, count and whether permanent), and sources
|
|
100
|
+
* that `videoDecode: "software"` could not decode in software (`kind: "software-unavailable"`).
|
|
104
101
|
*/
|
|
105
102
|
readonly report?: Readonly<Record<string, unknown>>;
|
|
106
103
|
};
|
|
107
104
|
/** One run of an export job: a fresh device or host process, from the job's pinned document. */
|
|
108
105
|
export interface ExportAttempt {
|
|
109
|
-
/**
|
|
110
|
-
* `<job id>/<number>`: what a backend tags this run's work with, so a late answer from an earlier
|
|
111
|
-
* one is told apart.
|
|
112
|
-
*/
|
|
106
|
+
/** `<job id>/<number>`, tagging this run's work so late answers from earlier runs are ignored. */
|
|
113
107
|
readonly id: string;
|
|
114
108
|
/** From 1. */
|
|
115
109
|
readonly number: number;
|
|
110
|
+
/** A backend scales its byte budgets by `profile.memoryScale`. */
|
|
111
|
+
readonly profile: RetryProfile;
|
|
116
112
|
/**
|
|
117
|
-
*
|
|
113
|
+
* `cpu` after the GPU hung on this export's own work (`DEVICE_HUNG`), when the retry policy says
|
|
114
|
+
* the backend has a CPU renderer.
|
|
118
115
|
*/
|
|
119
|
-
readonly
|
|
116
|
+
readonly renderer: AttemptRenderer;
|
|
117
|
+
/** The video encoder this run asks for: `software` after an encode failure. */
|
|
118
|
+
readonly videoEncoder: AttemptVideoEncoder;
|
|
120
119
|
/** Why the previous attempt failed, when this one is a retry. */
|
|
121
120
|
readonly previous?: ExportFailure;
|
|
122
121
|
}
|
package/dist/react/index.d.ts
CHANGED
|
@@ -13,16 +13,15 @@ export declare function EditorProvider({ editor, children, }: {
|
|
|
13
13
|
export declare function useEditor(): EditorSession;
|
|
14
14
|
/**
|
|
15
15
|
* Subscribes to one value derived from the session's snapshot; the component re-renders when it
|
|
16
|
-
* changes by `equal` (`Object.is` by default). Inline selectors are fine
|
|
17
|
-
* snapshot and an `equal` result keeps the previous
|
|
18
|
-
*
|
|
19
|
-
* in a loop. Throws without an {@link EditorProvider}.
|
|
16
|
+
* changes by `equal` (`Object.is` by default). Inline selectors are fine, even ones that build
|
|
17
|
+
* arrays or objects: the result is cached per snapshot and an `equal` result keeps the previous
|
|
18
|
+
* reference. Throws without an {@link EditorProvider}.
|
|
20
19
|
*/
|
|
21
20
|
export declare function useEditorSelector<T>(selector: (snapshot: EditorSnapshot) => T, equal?: (a: T, b: T) => boolean): T;
|
|
22
21
|
/**
|
|
23
22
|
* Shows `bridge`'s preview in a canvas filling a `div` (styled by `className` and `style`). The
|
|
24
|
-
* canvas is bound on mount and released on unmount
|
|
25
|
-
*
|
|
23
|
+
* canvas is bound on mount and released on unmount. `onReady` fires once it is bound; `onError`
|
|
24
|
+
* receives a bind or release failure.
|
|
26
25
|
*/
|
|
27
26
|
export declare function EditorPreview({ bridge, className, style, onReady, onError, }: {
|
|
28
27
|
bridge: BrowserBridge;
|
package/dist/react/index.js
CHANGED
|
@@ -16,10 +16,9 @@ export function useEditor() {
|
|
|
16
16
|
}
|
|
17
17
|
/**
|
|
18
18
|
* Subscribes to one value derived from the session's snapshot; the component re-renders when it
|
|
19
|
-
* changes by `equal` (`Object.is` by default). Inline selectors are fine
|
|
20
|
-
* snapshot and an `equal` result keeps the previous
|
|
21
|
-
*
|
|
22
|
-
* in a loop. Throws without an {@link EditorProvider}.
|
|
19
|
+
* changes by `equal` (`Object.is` by default). Inline selectors are fine, even ones that build
|
|
20
|
+
* arrays or objects: the result is cached per snapshot and an `equal` result keeps the previous
|
|
21
|
+
* reference. Throws without an {@link EditorProvider}.
|
|
23
22
|
*/
|
|
24
23
|
export function useEditorSelector(selector, equal = Object.is) {
|
|
25
24
|
const editor = useEditor();
|
|
@@ -46,8 +45,8 @@ export function useEditorSelector(selector, equal = Object.is) {
|
|
|
46
45
|
const bindings = new WeakMap();
|
|
47
46
|
/**
|
|
48
47
|
* Shows `bridge`'s preview in a canvas filling a `div` (styled by `className` and `style`). The
|
|
49
|
-
* canvas is bound on mount and released on unmount
|
|
50
|
-
*
|
|
48
|
+
* canvas is bound on mount and released on unmount. `onReady` fires once it is bound; `onError`
|
|
49
|
+
* receives a bind or release failure.
|
|
51
50
|
*/
|
|
52
51
|
export function EditorPreview({ bridge, className, style, onReady, onError, }) {
|
|
53
52
|
const host = useRef(null);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@alpha2-sh/editor",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.5.1",
|
|
4
4
|
"description": "Headless Project-based editing sessions and browser adapters for alpha2.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -57,14 +57,14 @@
|
|
|
57
57
|
}
|
|
58
58
|
},
|
|
59
59
|
"scripts": {
|
|
60
|
-
"build": "
|
|
60
|
+
"build": "node -e \"require('node:fs').rmSync('dist',{recursive:true,force:true})\" && tsc -p tsconfig.json"
|
|
61
61
|
},
|
|
62
62
|
"peerDependencies": {
|
|
63
|
-
"alpha2": "0.
|
|
63
|
+
"alpha2": "0.5.1",
|
|
64
64
|
"react": "^19.3.0"
|
|
65
65
|
},
|
|
66
66
|
"devDependencies": {
|
|
67
|
-
"alpha2": "0.
|
|
67
|
+
"alpha2": "0.5.1",
|
|
68
68
|
"react": "19.3.0",
|
|
69
69
|
"react-dom": "19.3.0",
|
|
70
70
|
"@types/react": "19.3.0",
|