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

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,8 @@ interface EntityPayloadByKind {
192
192
  }
193
193
  interface EntityStoreSnapshot {
194
194
  revision: number;
195
+ /** Fixed identity outlet of the project's one AudioScript; null only before initialization (revision 0). */
196
+ audioScriptEntityId: string | null;
195
197
  entities: SandboxEntity[];
196
198
  relations: SandboxRelation[];
197
199
  }
@@ -576,7 +578,9 @@ interface EditApi {
576
578
  insertCaptionClip(input: InsertCaptionClipInput): ClipEntityId;
577
579
  }
578
580
  interface TimelineApi {
579
- snapshot(): EntityStoreSnapshot;
581
+ snapshot(): EntityStoreSnapshot & {
582
+ audioScriptEntityId: string;
583
+ };
580
584
  }
581
585
  interface SandboxCheckpoint {
582
586
  readonly index: number;
@@ -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
  });
@@ -1559,6 +1560,10 @@ var EntitySandbox = class {
1559
1560
  ensureFoundation(timelinePayload = {}) {
1560
1561
  const foundation = ensureEditorFoundation(toDslRows(this.state), this.idFactory, timelinePayload);
1561
1562
  this.appendResourceRows(foundation.rows);
1563
+ if (this.state.audioScriptEntityId === null) this.state.audioScriptEntityId = foundation.audioScriptEntityId;
1564
+ }
1565
+ get audioScriptEntityId() {
1566
+ return this.state.audioScriptEntityId;
1562
1567
  }
1563
1568
  rollbackTo(index) {
1564
1569
  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}`);
@@ -1572,7 +1577,13 @@ var EntitySandbox = class {
1572
1577
  buildPlan() {
1573
1578
  const rows = toDslRows(this.state);
1574
1579
  decodeEntityRelationRows(rows, numericMarkerComparators);
1575
- assertCanonicalEditorResources(rows);
1580
+ if (this.state.revision !== 0 || rows.entities.length !== 0 || this.commands.length !== 0) {
1581
+ assertCanonicalEditorResources(rows);
1582
+ readDocumentAudioScript({
1583
+ rows,
1584
+ audioScriptEntityId: this.state.audioScriptEntityId
1585
+ });
1586
+ }
1576
1587
  const currentEntityIds = new Set(this.state.entities.map((entity) => entity.entity_id));
1577
1588
  const currentRelationIds = new Set(this.state.relations.map((relation) => relation.relation_id));
1578
1589
  return {
@@ -1705,6 +1716,10 @@ var EntitySandbox = class {
1705
1716
  }
1706
1717
  const entityId = input.entity_id ?? this.idFactory("entity");
1707
1718
  assertTrimmed(entityId, "entity_id");
1719
+ if (input.entity_kind === "audio-script") {
1720
+ const existing = this.state.entities.find((entity) => entity.entity_kind === "audio-script");
1721
+ if (existing !== void 0 && existing.entity_id !== entityId) throw new Error(`Editor requires exactly one AudioScript; edit ${existing.entity_id} instead of creating ${entityId}`);
1722
+ }
1708
1723
  const entity = {
1709
1724
  entity_id: entityId,
1710
1725
  entity_kind: input.entity_kind,
@@ -1933,10 +1948,12 @@ var EntitySandbox = class {
1933
1948
  apply(command, enforceIdentity) {
1934
1949
  switch (command.kind) {
1935
1950
  case "create-entity": {
1951
+ if (command.entity.entity_kind === "audio-script" && this.state.entities.some((entity) => entity.entity_kind === "audio-script")) throw new Error("The project AudioScript already exists; edit its segments instead");
1936
1952
  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
1953
  const original = this.original.entities.find((entity) => entity.entity_id === command.entity.entity_id);
1938
1954
  if (enforceIdentity && original != null && original.entity_kind !== command.entity.entity_kind) throw new Error(`Entity id "${command.entity.entity_id}" was originally kind "${original.entity_kind}" and cannot be recreated as "${command.entity.entity_kind}"`);
1939
1955
  this.state.entities.push(clone(command.entity));
1956
+ if (command.entity.entity_kind === "audio-script" && this.state.audioScriptEntityId === null) this.state.audioScriptEntityId = command.entity.entity_id;
1940
1957
  return;
1941
1958
  }
1942
1959
  case "update-entity": {
@@ -1951,6 +1968,7 @@ var EntitySandbox = class {
1951
1968
  return;
1952
1969
  }
1953
1970
  case "delete-entity": {
1971
+ if (this.state.entities.find((entity) => entity.entity_id === command.entity_id)?.entity_kind === "audio-script") throw new Error("The document AudioScript is a fixed project identity and cannot be deleted");
1954
1972
  const index = this.state.entities.findIndex((entity) => entity.entity_id === command.entity_id);
1955
1973
  if (index < 0) throw new Error(`Entity id "${command.entity_id}" does not exist`);
1956
1974
  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 +2388,4 @@ function replayJournalSync(adapter, journal) {
2370
2388
  //#endregion
2371
2389
  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
2390
 
2373
- //# sourceMappingURL=script-session-1eqBGegp.mjs.map
2391
+ //# sourceMappingURL=script-session-B2UQ1W_y.mjs.map