@mengine/medeo-tool 1.4.1-alpha.5 → 2.0.1-alpha.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 +9 -0
- package/dist/{entity-contract-DlmUSouB.d.mts → entity-contract-G4HxwNXl.d.mts} +2 -2
- package/dist/{entity-sandbox-TaUVT3on.mjs → entity-sandbox-DSFbfybl.mjs} +13 -4
- package/dist/entity-sandbox-DSFbfybl.mjs.map +1 -0
- package/dist/index.d.mts +7 -2
- package/dist/index.mjs +13 -7
- package/dist/index.mjs.map +1 -1
- package/dist/sandbox-api.d.mts +2 -2
- package/dist/worker-entry.d.mts +1 -1
- package/dist/worker-entry.mjs +98 -9
- package/dist/worker-entry.mjs.map +1 -1
- package/package.json +2 -2
- package/dist/entity-sandbox-TaUVT3on.mjs.map +0 -1
package/dist/index.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { C as UpdateEntityInput, S as UnlinkRelationInput, _ as LinkRelationInput, a as DeleteEntityInput, b as SandboxEntity, c as EntitySandboxCheckpoint, d as JsonObject, f as JsonPrimitive, g as LinkGeneratedRelationInput, h as KnownRelationKind, i as CreateEntityInput, l as EntityStoreSnapshot, m as KnownEntityKind, n as BusinessEntityFacade, o as EntityCommand, p as JsonValue, r as BusinessRelationFacade, s as EntityPlanState, t as AuthorableRelationKind, u as EntityUpdateInput, v as RelationUpdateInput, x as SandboxRelation, y as ResourceEntityKind } from "./entity-contract-
|
|
1
|
+
import { C as UpdateEntityInput, S as UnlinkRelationInput, _ as LinkRelationInput, a as DeleteEntityInput, b as SandboxEntity, c as EntitySandboxCheckpoint, d as JsonObject, f as JsonPrimitive, g as LinkGeneratedRelationInput, h as KnownRelationKind, i as CreateEntityInput, l as EntityStoreSnapshot, m as KnownEntityKind, n as BusinessEntityFacade, o as EntityCommand, p as JsonValue, r as BusinessRelationFacade, s as EntityPlanState, t as AuthorableRelationKind, u as EntityUpdateInput, v as RelationUpdateInput, x as SandboxRelation, y as ResourceEntityKind } from "./entity-contract-G4HxwNXl.mjs";
|
|
2
2
|
import { JournalEntry, ManualSyncDoc, MediaAssetFact, PartIdFactory, SemanticOpName, VideoDocument, VideoDraft } from "@mengine/medeo-client";
|
|
3
3
|
|
|
4
4
|
//#region src/document/compact-projection.d.ts
|
|
@@ -40,6 +40,8 @@ interface EntityAssetContent {
|
|
|
40
40
|
}
|
|
41
41
|
/** Host-only I/O. The sandbox supplies an Entity, never an arbitrary Asset query. */
|
|
42
42
|
type EntityAssetLoader = (docId: string, entity: SandboxEntity) => Promise<EntityAssetContent>;
|
|
43
|
+
/** Program-only initial resource creation; never exposed as a sandbox API. */
|
|
44
|
+
type EntityAssetWriter = (docId: string, entity: SandboxEntity, content: JsonValue) => Promise<EntityAssetContent>;
|
|
43
45
|
//#endregion
|
|
44
46
|
//#region src/entity/entity-sandbox.d.ts
|
|
45
47
|
type DomainIdFactory = (prefix: 'entity' | 'relation') => string;
|
|
@@ -88,6 +90,7 @@ interface ConsoleShim {
|
|
|
88
90
|
*/
|
|
89
91
|
interface RunEditScriptOptions {
|
|
90
92
|
loadEntityAsset?: (entity: SandboxEntity) => Promise<EntityAssetContent>;
|
|
93
|
+
writeEntityAsset?: (entity: SandboxEntity, content: EntityAssetContent['content']) => Promise<EntityAssetContent>;
|
|
91
94
|
document: VideoDocument;
|
|
92
95
|
baseVersion: string;
|
|
93
96
|
script: string;
|
|
@@ -395,6 +398,8 @@ interface CreateMedeoToolOptions {
|
|
|
395
398
|
/** Assemble optional Caption artifacts by immutable entity ID; never exposed to scripts. */
|
|
396
399
|
loadCaptionAssets?: CaptionAssetsLoader;
|
|
397
400
|
loadEntityAsset?: EntityAssetLoader;
|
|
401
|
+
/** Program-side persistence for immutable AudioScript resources. */
|
|
402
|
+
writeEntityAsset?: EntityAssetWriter;
|
|
398
403
|
fetchImpl?: typeof fetch;
|
|
399
404
|
/** @deprecated ManualSyncDoc has no SSE or reconnect loop. */
|
|
400
405
|
sseReconnectDelayMs?: number;
|
|
@@ -567,5 +572,5 @@ declare function materializeResources(options: EntityHttpClientOptions & {
|
|
|
567
572
|
loadGenerationFacts?: GenerationFactsLoader;
|
|
568
573
|
}, resources: readonly GeneratedResource[]): Promise<readonly string[]>;
|
|
569
574
|
//#endregion
|
|
570
|
-
export { type AssetGenerationFact, type AuthorableRelationKind, type BusinessEntityFacade, type BusinessRelationFacade, type CaptionAssetAssemblyOutcome, type CaptionAssetFact, type CaptionAssetsLoader, type ChangePlan, type CommitPlan, type CommitPlanOptions, type CommitPlanResult, type CompactProjectionOptions, type ConsoleShim, type CreateEntityInput, type CreateMedeoToolOptions, type DeleteEntityInput, type EditSandboxSessionOptions, type EditScriptResult, type EntityAssetContent, type EntityAssetLoader, type EntityCommand, type EntityCommitResult, type EntityPlanState, type EntitySandboxCheckpoint, type EntityStoreSnapshot, type EntityUpdateInput, type GeneratedResource, type GenerationFactsLoader, type GenerationSyncOutcome, type JsonObject, type JsonPrimitive, type JsonValue, type KnownEntityKind, type KnownRelationKind, type LinkGeneratedRelationInput, type LinkRelationInput, MEDEO_TOOL_DESCRIPTION, MEDEO_TOOL_NAME, MEDEO_TOOL_PARAMETERS, type MedeoCommitResult, type MedeoInitialDraft, type MedeoModelContext, type MedeoModelContextInput, type MedeoTool, type MedeoToolInput, type MedeoToolOp, type MedeoToolResult, type RelationUpdateInput, type ResourceEntityKind, type RunEditScriptOptions, type SandboxEntity, type SandboxRelation, type UnlinkRelationInput, type UpdateEntityInput, collectAffectedPartIds, commitPlan, createMedeoTool, materializeResources, renderCompactProjection, renderPreview, runEditScript };
|
|
575
|
+
export { type AssetGenerationFact, type AuthorableRelationKind, type BusinessEntityFacade, type BusinessRelationFacade, type CaptionAssetAssemblyOutcome, type CaptionAssetFact, type CaptionAssetsLoader, type ChangePlan, type CommitPlan, type CommitPlanOptions, type CommitPlanResult, type CompactProjectionOptions, type ConsoleShim, type CreateEntityInput, type CreateMedeoToolOptions, type DeleteEntityInput, type EditSandboxSessionOptions, type EditScriptResult, type EntityAssetContent, type EntityAssetLoader, type EntityAssetWriter, type EntityCommand, type EntityCommitResult, type EntityPlanState, type EntitySandboxCheckpoint, type EntityStoreSnapshot, type EntityUpdateInput, type GeneratedResource, type GenerationFactsLoader, type GenerationSyncOutcome, type JsonObject, type JsonPrimitive, type JsonValue, type KnownEntityKind, type KnownRelationKind, type LinkGeneratedRelationInput, type LinkRelationInput, MEDEO_TOOL_DESCRIPTION, MEDEO_TOOL_NAME, MEDEO_TOOL_PARAMETERS, type MedeoCommitResult, type MedeoInitialDraft, type MedeoModelContext, type MedeoModelContextInput, type MedeoTool, type MedeoToolInput, type MedeoToolOp, type MedeoToolResult, type RelationUpdateInput, type ResourceEntityKind, type RunEditScriptOptions, type SandboxEntity, type SandboxRelation, type UnlinkRelationInput, type UpdateEntityInput, collectAffectedPartIds, commitPlan, createMedeoTool, materializeResources, renderCompactProjection, renderPreview, runEditScript };
|
|
571
576
|
//# sourceMappingURL=index.d.mts.map
|
package/dist/index.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { c as isMediaAssetVariantKind, i as businessState, o as createEntityId, s as createRelationId, t as EntitySandbox } from "./entity-sandbox-
|
|
1
|
+
import { c as isMediaAssetVariantKind, i as businessState, o as createEntityId, s as createRelationId, t as EntitySandbox } from "./entity-sandbox-DSFbfybl.mjs";
|
|
2
2
|
import { LoroEntityDocument, ManualSyncDoc, MengineHttpClient, MengineHttpRequestError, ValidationError, base64ToBytes, bytesToBase64, compileEntityRows, createMirrorVideoDocument, createPlainMemoryAdapter, decodeDocVersionMark, effectiveVideoClipDurationMs, encodeDocVersionMark, ensureEditorFoundation, replayJournal, solveVideoDocument, speedOf, toVideoDocument } from "@mengine/medeo-client";
|
|
3
3
|
import { Worker } from "node:worker_threads";
|
|
4
4
|
import { createHash, randomUUID } from "node:crypto";
|
|
@@ -214,11 +214,14 @@ function runEditScript(options) {
|
|
|
214
214
|
armTimeout();
|
|
215
215
|
return;
|
|
216
216
|
}
|
|
217
|
-
if (message.t === "entity-asset") {
|
|
217
|
+
if (message.t === "entity-asset" || message.t === "write-entity-asset") {
|
|
218
218
|
(async () => {
|
|
219
219
|
try {
|
|
220
|
-
|
|
221
|
-
|
|
220
|
+
const result = message.t === "write-entity-asset" ? await (options.writeEntityAsset ?? (() => {
|
|
221
|
+
throw new Error("Entity Asset writer is unavailable");
|
|
222
|
+
}))(message.entity, message.content) : await (options.loadEntityAsset ?? (() => {
|
|
223
|
+
throw new Error("Entity Asset loader is unavailable");
|
|
224
|
+
}))(message.entity);
|
|
222
225
|
if (!settled) worker.postMessage({
|
|
223
226
|
t: "entity-asset-result",
|
|
224
227
|
requestId: message.requestId,
|
|
@@ -985,7 +988,7 @@ const ENTITY_EDIT_SANDBOX_API_DTS = [
|
|
|
985
988
|
"/** Stored own fields; a variant may obtain required content fields from its declared bases. */",
|
|
986
989
|
"export type StoredEntityPayload<K extends KnownEntityKind> =",
|
|
987
990
|
" | EntityPayloadByKind[K]",
|
|
988
|
-
" | (K extends 'caption' ? JsonObject & Pick<MediaAssetPayload, 'external'> : never)",
|
|
991
|
+
" | (K extends 'caption' | 'voice' ? JsonObject & Pick<MediaAssetPayload, 'external'> : never)",
|
|
989
992
|
" | (JsonObject &",
|
|
990
993
|
" Partial<EntityPayloadByKind[K]> & {",
|
|
991
994
|
" baseEntityIds: string[];",
|
|
@@ -1008,7 +1011,7 @@ const ENTITY_EDIT_SANDBOX_API_DTS = [
|
|
|
1008
1011
|
"}",
|
|
1009
1012
|
"export declare const entities: BusinessEntityFacade;",
|
|
1010
1013
|
"export declare const relations: BusinessRelationFacade;",
|
|
1011
|
-
"/** Resolve this Entity's attached resource through the host; await before using an uninitialized Caption. */",
|
|
1014
|
+
"/** Resolve this Entity's attached resource through the host; await before using an uninitialized Caption or Voice. */",
|
|
1012
1015
|
"export declare function rgetAssetFromEntity(entityId: string): Promise<EntityAssetContent>;",
|
|
1013
1016
|
"export declare function checkpoint(): EntitySandboxCheckpoint;",
|
|
1014
1017
|
"export declare function rollbackTo(cp: EntitySandboxCheckpoint): void;",
|
|
@@ -1048,7 +1051,9 @@ Generation tools return resource references. An asset id may be passed in an ent
|
|
|
1048
1051
|
|
|
1049
1052
|
Project initialization creates one current Timeline, the four standard Tracks and one attached AudioScript with segments:[]. A project may contain multiple independent complete AudioScripts (for example a generated script and an uploaded video transcript). The project AudioScript attachment selects only the panel view; it is not a singleton or membership constraint. Locate scripts with entities.list and choose the appropriate source. AudioScript owns independent multi-segment text; each can have multiple Caption variants. Caption and PhoneticScript compose it through baseEntityIds. Caption owns exactly one selection object ({segmentId,textRange?}), never an array or the legacy selections field. It selects one script segment or a contiguous substring, and owns only that selection's intrinsic timing and style; segmentId is a stable script-local identity, not an entity reference or transient array index; selection textRange is a half-open code-point range and can split display text without rewriting the script. PhoneticScript owns pronunciation/prosody; Voice is generated from it and related by phonetic-script-render(voice,phoneticScript). Speech and caption occupy separate Clips. Subtitles normally accompany sound; use source media or generate Voice from PhoneticScript when the request requires narration. Do not fabricate a sound resource.
|
|
1050
1053
|
|
|
1051
|
-
|
|
1054
|
+
For Speech resources, create a Voice with external:{system:'memota-speech',key:speechId}, then await rgetAssetFromEntity(voiceId) before linking its placement. The host supplies full extent and optional voice-library identity, and assembles physical storage facts internally. Read the visible fields through entities.get; never invent them or use a Speech ID as a Memota media ID. TTS Voice still requires its real PhoneticScript relation; resource loading does not invent script content.
|
|
1055
|
+
|
|
1056
|
+
Direct AudioScript creation saves its segments as a resource before publication. Its assembled segments remain readable and editable; committed text changes preserve native Loro operations and save a new immutable resource, automatically advancing the external reference. AudioScripts initialized through Caption resources keep inline segments without an additional script resource. Do not manage these resources yourself. AudioScript has no intrinsic time and cannot be Clip content. ASR input Audio/Video/Voice associates via audio-script-source(script,source). Its external annotation SequenceMarker associates via audio-script-marker(script,marker) and receives assigned segmentRanges, not references to another marker. Caption intrinsic timing and its Clip's display SequenceMarker are distinct. Move/stretch display by editing only the placement marker.
|
|
1052
1057
|
|
|
1053
1058
|
To place content, create a Clip and a SequenceMarker, then link track-clip(track,clip), clip-marker(clip,marker) and marker-content(marker,content). Existing track membership uses timeline-track(timeline,track). The editor has one track of each role: video_clip for Image/Video, speech for Voice, caption for Caption, bgm for Audio. Inspect factual media extents; never invent duration. Each placement is exactly one of Clip.order (sequential), Marker.targetRange (absolute) or clip-anchor(childClip,hostClip) plus Marker.anchorOffset. Marker.sourceRange selects source, duration describes playback/display. Whole milliseconds are required by this editor projection. Clip.volume is decibels (-60..20, 0 original). Image is unbounded/constant. Linear timeRemapping is {kind:'linear',rate:2,mode:'constant'}, with duration matching the rounded source span/rate. BGM can use durationPolicy:'timeline'. Nonlinear speed and multiple overlay tracks are unsupported. Caption visibility is the caption Track's hidden field. Caption style is its style map. Handle structural links explicitly when moving/deleting; there is no implicit cascade.
|
|
1054
1059
|
|
|
@@ -1656,6 +1661,7 @@ function createMedeoTool(options) {
|
|
|
1656
1661
|
baseVersion,
|
|
1657
1662
|
entityState,
|
|
1658
1663
|
loadEntityAsset: options.loadEntityAsset ? (entity) => options.loadEntityAsset(input.doc_id, entity) : void 0,
|
|
1664
|
+
writeEntityAsset: options.writeEntityAsset ? (entity, content) => options.writeEntityAsset(input.doc_id, entity, content) : void 0,
|
|
1659
1665
|
script: input.script,
|
|
1660
1666
|
...input.inputs !== void 0 ? { inputs: input.inputs } : {},
|
|
1661
1667
|
timeoutMs: input.timeout_ms ?? options.sandbox?.timeoutMs ?? 3e4,
|