@mengine/medeo-tool 1.3.1-alpha.6 → 1.3.1-alpha.8

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.
@@ -192,6 +192,7 @@ interface EntityPayloadByKind {
192
192
  }
193
193
  interface EntityStoreSnapshot {
194
194
  revision: number;
195
+ audioScriptEntityId: string | null;
195
196
  entities: SandboxEntity[];
196
197
  relations: SandboxRelation[];
197
198
  }
@@ -548,6 +549,8 @@ interface VoiceoverTakeResult {
548
549
  }
549
550
  /** Timeline writes accept existing media Entity ids, never Memota asset ids or URLs. */
550
551
  interface EditApi {
552
+ /** Select the document AudioScript, or clear the optional association with null. */
553
+ setDocumentAudioScript(entityId: string | null): void;
551
554
  insertClip(input: InsertClipInput): ClipEntityId;
552
555
  insertPlacedClip(input: InsertPlacedClipInput): ClipEntityId;
553
556
  updateClipMarker(input: UpdateClipMarkerInput): void;
@@ -1,4 +1,4 @@
1
- import { SchemaValidator, SemanticEditor, assertCanonicalEditorResources, createEditSandbox, effectiveVideoClipDurationMs, ensureEditorFoundation, fromVideoDocument, importMediaAsset, solveVideoDocument, speedOf } from "@mengine/medeo-client";
1
+ import { SchemaValidator, SemanticEditor, assertCanonicalEditorResources, createEditSandbox, effectiveVideoClipDurationMs, ensureEditorFoundation, fromVideoDocument, importMediaAsset, readDocumentAudioScript, solveVideoDocument, speedOf } from "@mengine/medeo-client";
2
2
  //#region src/document/compact-projection.ts
3
3
  const DEFAULT_TEXT_PREVIEW_LENGTH = 24;
4
4
  /** Kind tag shown in the first column (`video_clip` → `clip`). */
@@ -1539,6 +1539,7 @@ var EntitySandbox = class {
1539
1539
  constructor(options) {
1540
1540
  this.original = cloneSnapshot(options.state ?? {
1541
1541
  revision: 0,
1542
+ audioScriptEntityId: null,
1542
1543
  entities: [],
1543
1544
  relations: []
1544
1545
  });
@@ -1560,6 +1561,15 @@ var EntitySandbox = class {
1560
1561
  const foundation = ensureEditorFoundation(toDslRows(this.state), this.idFactory, timelinePayload);
1561
1562
  this.appendResourceRows(foundation.rows);
1562
1563
  }
1564
+ get audioScriptEntityId() {
1565
+ return this.state.audioScriptEntityId;
1566
+ }
1567
+ setDocumentAudioScript(audioScriptEntityId) {
1568
+ this.record({
1569
+ kind: "set-document-audio-script",
1570
+ audioScriptEntityId
1571
+ });
1572
+ }
1563
1573
  rollbackTo(index) {
1564
1574
  if (!Number.isInteger(index) || index < 0 || index > this.commands.length) throw new Error(`rollbackTo: entity checkpoint index ${index} is past journal length ${this.commands.length}`);
1565
1575
  const prefix = this.commands.slice(0, index);
@@ -1573,6 +1583,10 @@ var EntitySandbox = class {
1573
1583
  const rows = toDslRows(this.state);
1574
1584
  decodeEntityRelationRows(rows, numericMarkerComparators);
1575
1585
  assertCanonicalEditorResources(rows);
1586
+ readDocumentAudioScript({
1587
+ rows,
1588
+ audioScriptEntityId: this.state.audioScriptEntityId
1589
+ });
1576
1590
  const currentEntityIds = new Set(this.state.entities.map((entity) => entity.entity_id));
1577
1591
  const currentRelationIds = new Set(this.state.relations.map((relation) => relation.relation_id));
1578
1592
  return {
@@ -1586,6 +1600,9 @@ var EntitySandbox = class {
1586
1600
  renderPreview() {
1587
1601
  const lines = [`Entity plan: base_revision=${this.original.revision} commands=${this.commands.length} entities=${this.state.entities.length} relations=${this.state.relations.length}`];
1588
1602
  for (const command of this.commands) switch (command.kind) {
1603
+ case "set-document-audio-script":
1604
+ lines.push(`~ document audioScriptEntityId=${command.audioScriptEntityId}`);
1605
+ break;
1589
1606
  case "create-entity":
1590
1607
  lines.push(`+ entity ${command.entity.entity_id} kind=${command.entity.entity_kind}`);
1591
1608
  break;
@@ -1932,6 +1949,13 @@ var EntitySandbox = class {
1932
1949
  }
1933
1950
  apply(command, enforceIdentity) {
1934
1951
  switch (command.kind) {
1952
+ case "set-document-audio-script":
1953
+ readDocumentAudioScript({
1954
+ rows: toDslRows(this.state),
1955
+ audioScriptEntityId: command.audioScriptEntityId
1956
+ });
1957
+ this.state.audioScriptEntityId = command.audioScriptEntityId;
1958
+ return;
1935
1959
  case "create-entity": {
1936
1960
  if (enforceIdentity && this.state.entities.some((entity) => entity.entity_id === command.entity.entity_id)) throw new Error(`Entity id "${command.entity.entity_id}" already exists`);
1937
1961
  const original = this.original.entities.find((entity) => entity.entity_id === command.entity.entity_id);
@@ -1951,6 +1975,7 @@ var EntitySandbox = class {
1951
1975
  return;
1952
1976
  }
1953
1977
  case "delete-entity": {
1978
+ if (this.state.audioScriptEntityId === command.entity_id) throw new Error("Clear or switch the document AudioScript association before deleting its entity");
1954
1979
  const index = this.state.entities.findIndex((entity) => entity.entity_id === command.entity_id);
1955
1980
  if (index < 0) throw new Error(`Entity id "${command.entity_id}" does not exist`);
1956
1981
  const incidentRelationIds = this.state.relations.filter((relation) => relation.endpoint_0_entity_id === command.entity_id || relation.endpoint_1_entity_id === command.entity_id).map((relation) => relation.relation_id).sort();
@@ -2370,4 +2395,4 @@ function replayJournalSync(adapter, journal) {
2370
2395
  //#endregion
2371
2396
  export { createRelationId as a, renderPreview as c, createEntityId as i, renderCompactProjection as l, EntitySandbox as n, isMediaAssetVariantKind as o, toDslRows as r, collectAffectedPartIds as s, EditSandboxSession as t };
2372
2397
 
2373
- //# sourceMappingURL=script-session-1eqBGegp.mjs.map
2398
+ //# sourceMappingURL=script-session-C2uQHYt4.mjs.map