@mengine/medeo-client 1.3.1-alpha.10 → 1.3.1-alpha.11

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.
@@ -3487,7 +3487,7 @@ function entityContent(doc, key) {
3487
3487
  }
3488
3488
  function bases(map) {
3489
3489
  const links = requireMap(map, "bases");
3490
- return links.keys().sort((a, b) => Number(a) - Number(b)).map((key) => String(links.get(key)));
3490
+ return links.keys().sort((a, b) => a < b ? -1 : a > b ? 1 : 0).map((key) => String(links.get(key)));
3491
3491
  }
3492
3492
  function owned(payload) {
3493
3493
  const { baseEntityIds: _bases, ...fields } = payload;
@@ -3561,7 +3561,7 @@ function readEntityDocument(doc, allowSelectionConflicts = false) {
3561
3561
  });
3562
3562
  }
3563
3563
  const project = {};
3564
- for (const [key, value] of Object.entries(section(doc, "project").toJSON())) {
3564
+ for (const [key, value] of Object.entries(section(doc, "attachments").toJSON())) {
3565
3565
  if (typeof value !== "string") throw new Error(`Invalid project attachment ${key}`);
3566
3566
  project[key] = currentId(doc, value, ids);
3567
3567
  }
@@ -3608,6 +3608,7 @@ var LoroEntityDocument = class LoroEntityDocument {
3608
3608
  "origins",
3609
3609
  "relations",
3610
3610
  "project",
3611
+ "attachments",
3611
3612
  "ordering"
3612
3613
  ]) root(doc).ensureMergeableMap(name);
3613
3614
  for (const row of rows.entities) apply(doc, {
@@ -3856,7 +3857,7 @@ function apply(doc, command) {
3856
3857
  map.ensureMergeableMap("changes");
3857
3858
  section(doc, "origins").set(row.entityId, row.entityId);
3858
3859
  writeObject(map.ensureMergeableMap("content"), {}, owned(row.payload));
3859
- writeBases(map, baseIds(row.payload));
3860
+ writeBases(doc, map, baseIds(row.payload));
3860
3861
  break;
3861
3862
  }
3862
3863
  case "write": {
@@ -3867,7 +3868,7 @@ function apply(doc, command) {
3867
3868
  writeObject(map.ensureMergeableMap("content"), before, after);
3868
3869
  map.ensureMergeableMap("changes").set(command.token, true);
3869
3870
  }
3870
- writeBases(map, baseIds(command.payload));
3871
+ writeBases(doc, map, baseIds(command.payload));
3871
3872
  break;
3872
3873
  }
3873
3874
  case "text": {
@@ -3916,16 +3917,19 @@ function apply(doc, command) {
3916
3917
  break;
3917
3918
  }
3918
3919
  case "attach":
3919
- section(doc, "project").set(command.slot, command.entityId);
3920
+ section(doc, "attachments").set(command.slot, command.entityId);
3920
3921
  break;
3921
3922
  }
3922
3923
  }
3923
- function writeBases(map, ids) {
3924
+ function writeBases(doc, map, ids) {
3924
3925
  const links = map.ensureMergeableMap("bases");
3925
- for (const key of links.keys()) if (Number(key) >= ids.length) links.delete(key);
3926
- ids.forEach((id, index) => {
3927
- if (links.get(String(index)) !== id) links.set(String(index), id);
3928
- });
3926
+ const wanted = new Map(ids.map((id) => {
3927
+ const origin = section(doc, "origins").get(id);
3928
+ return [typeof origin === "string" ? origin : [...currentIds(doc)].find(([, current]) => current === id)?.[0] ?? id, id];
3929
+ }));
3930
+ if (wanted.size !== ids.length) throw new Error("Duplicate base entity family");
3931
+ for (const key of links.keys()) if (!wanted.has(key)) links.delete(key);
3932
+ for (const [key, id] of wanted) if (links.get(key) === void 0) links.set(key, id);
3929
3933
  }
3930
3934
  /** Numeric sub-spans must not silently quote different text after a collaborative edit. */
3931
3935
  function selectionFingerprint(rows, id) {
@@ -3964,7 +3968,6 @@ function materialize(doc) {
3964
3968
  const previous = byId.get(row.entityId);
3965
3969
  if (isJsonObject(previous) && !equalJson(owned(previous), owned(next))) throw new Error("Immutable entity version collision");
3966
3970
  if (!equalJson(previous, next)) byId.set(row.entityId, next);
3967
- writeBases(workspace(doc, family(doc, row.entityId)), baseIds(row.payload));
3968
3971
  }
3969
3972
  const project = section(doc, "project");
3970
3973
  for (const [slot, id] of Object.entries(state.project)) if (project.get(slot) !== id) project.set(slot, id);
package/dist/index.d.ts CHANGED
@@ -592,7 +592,7 @@ interface EditorFoundation {
592
592
  readonly rows: EntityRelationRows;
593
593
  readonly timelineEntityId: string;
594
594
  readonly trackEntityIds: Readonly<Record<EditorTrackRole, string>>;
595
- /** Fixed identity of the project's one AudioScript, minted here when missing. */
595
+ /** Initial or current AudioScript content ID selected by the foundation. */
596
596
  readonly audioScriptEntityId: string;
597
597
  }
598
598
  /**
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- import { $ as reassignSpeechesToVideoClipsByTime, A as isJsonObject, B as VideoDocumentValidationError, C as assembleEntityContent, D as selectAudioScriptSegments, E as findComposedAudioScript, F as buildInitialVideoDocument, G as LANE_KINDS_IN_STACK_ORDER, H as validateVideoDocument, I as buildSpeechHostMap, J as laneTrackId, K as ensureLaneTrack, L as derivePositionFromAbs, M as createRelationId, N as hasSequence, O as updateEntityFields, P as isMediaAssetVariantKind, Q as fillMainTrackTimeGaps, R as fromVideoDocument, S as assembleCaptionContent, T as assembleScriptText, U as partUnionSchema, V as assertValidVideoDocument, W as videoDocumentSchema, X as cascadeAfterVideoClipChanges, Y as solveVideoDocument, Z as arrangeMainTrackSeamlessly, _ as EntityProjectionGraph, _t as bytesToBase64, a as applyEntityTimelineProjection, at as isEmptyVideoClip, b as decodeEntityRelationRows, c as writeVideoDocumentToDraft, ct as DEFAULT_UNIT_TIME_MS, d as LoroEntityDocument, dt as effectiveVideoClipDurationMs, et as recalculateTimelineDuration, f as LoroEntityDraft, ft as speedOf, g as projectEntityTimeline, gt as base64ToBytes, h as equalJson, ht as videoDocumentMirrorSchema, i as MirrorVideoDocumentAdapter, it as TIMELINE_SKELETON_DURATION_MS, j as createEntityId, k as variantBaseEntityIds, l as readVideoDocumentFromDraft, lt as ENTITY_TIMELINE_PROJECTION_SCHEMA_VERSION, m as entityOrderGroups, mt as recordEntries, n as createPlainMemoryAdapter, nt as resolveSpeechOverlapByShiftingVideos, o as createMirrorVideoDocument, ot as partDurationMs, p as readEntityDocument, pt as partUnionToDraft, q as findLaneTrack, r as generatePartId, rt as syncAggregatedClipsTimePosition, s as createMirrorVideoDocumentAdapter, st as safeDurationMs, t as PlainMemoryAdapter, tt as resolveAllSpeechOverlaps, u as LORO_ENTITY_SCHEMA, ut as VIDEO_DOCUMENT_SCHEMA_VERSION, v as resolveEntityTimelineLayout, w as assemblePhoneticScriptContent, x as ScriptCompositionError, y as EntityTimelineProjectionError, z as toVideoDocument } from "./document-BxWxPFTj.js";
1
+ import { $ as reassignSpeechesToVideoClipsByTime, A as isJsonObject, B as VideoDocumentValidationError, C as assembleEntityContent, D as selectAudioScriptSegments, E as findComposedAudioScript, F as buildInitialVideoDocument, G as LANE_KINDS_IN_STACK_ORDER, H as validateVideoDocument, I as buildSpeechHostMap, J as laneTrackId, K as ensureLaneTrack, L as derivePositionFromAbs, M as createRelationId, N as hasSequence, O as updateEntityFields, P as isMediaAssetVariantKind, Q as fillMainTrackTimeGaps, R as fromVideoDocument, S as assembleCaptionContent, T as assembleScriptText, U as partUnionSchema, V as assertValidVideoDocument, W as videoDocumentSchema, X as cascadeAfterVideoClipChanges, Y as solveVideoDocument, Z as arrangeMainTrackSeamlessly, _ as EntityProjectionGraph, _t as bytesToBase64, a as applyEntityTimelineProjection, at as isEmptyVideoClip, b as decodeEntityRelationRows, c as writeVideoDocumentToDraft, ct as DEFAULT_UNIT_TIME_MS, d as LoroEntityDocument, dt as effectiveVideoClipDurationMs, et as recalculateTimelineDuration, f as LoroEntityDraft, ft as speedOf, g as projectEntityTimeline, gt as base64ToBytes, h as equalJson, ht as videoDocumentMirrorSchema, i as MirrorVideoDocumentAdapter, it as TIMELINE_SKELETON_DURATION_MS, j as createEntityId, k as variantBaseEntityIds, l as readVideoDocumentFromDraft, lt as ENTITY_TIMELINE_PROJECTION_SCHEMA_VERSION, m as entityOrderGroups, mt as recordEntries, n as createPlainMemoryAdapter, nt as resolveSpeechOverlapByShiftingVideos, o as createMirrorVideoDocument, ot as partDurationMs, p as readEntityDocument, pt as partUnionToDraft, q as findLaneTrack, r as generatePartId, rt as syncAggregatedClipsTimePosition, s as createMirrorVideoDocumentAdapter, st as safeDurationMs, t as PlainMemoryAdapter, tt as resolveAllSpeechOverlaps, u as LORO_ENTITY_SCHEMA, ut as VIDEO_DOCUMENT_SCHEMA_VERSION, v as resolveEntityTimelineLayout, w as assemblePhoneticScriptContent, x as ScriptCompositionError, y as EntityTimelineProjectionError, z as toVideoDocument } from "./document-CkbNx-mi.js";
2
2
  import { addSpeechesInputSchema, addVideoClipsInputSchema, adjustBgmVolumeInputSchema, adjustSpeechVolumeInputSchema, adjustVideoClipDurationInputSchema, adjustVideoClipVolumeInputSchema, changeSpeechScriptInputSchema, changeSpeechVoiceInputSchema, deleteBgmInputSchema, deleteSpeechesInputSchema, deleteVideoClipsInputSchema, moveSpeechesInputSchema, moveVideoClipsByAnchorInputSchema, moveVideoClipsInputSchema, replaceVideoClipContentInputSchema, replaceVideoClipSequenceInputSchema, setBgmInputSchema, setCaptionStyleInputSchema, setCaptionVisibilityInputSchema, setVideoClipSpeedShiftInputSchema, t as schemas_exports } from "./schemas.js";
3
3
  import { LoroDoc, VersionVector } from "loro-crdt";
4
4
  import { ClientServerSynchronizer, DocManager } from "@mengine/sync";
@@ -358,10 +358,9 @@ function memotaLocator(value) {
358
358
  };
359
359
  }
360
360
  /**
361
- * The project AudioScript is a fixed structure identity, like the Timeline: at
362
- * most one may exist, and a missing one is minted atomically with empty
363
- * segments. Project initialization and legacy migration share this single
364
- * path, so both produce the same canonical structure.
361
+ * Bootstrap an empty script when the foundation has no candidate. Without an
362
+ * explicit project attachment, multiple candidates are ambiguous. Existing
363
+ * content IDs are reused here; Loro editing advances their immutable versions.
365
364
  */
366
365
  function ensureDocumentAudioScript(entities, idFactory) {
367
366
  const scripts = entities.filter((row) => row.entityKind === "audio-script");
package/dist/testing.js CHANGED
@@ -1,4 +1,4 @@
1
- import { _t as bytesToBase64, gt as base64ToBytes, s as createMirrorVideoDocumentAdapter, ut as VIDEO_DOCUMENT_SCHEMA_VERSION } from "./document-BxWxPFTj.js";
1
+ import { _t as bytesToBase64, gt as base64ToBytes, s as createMirrorVideoDocumentAdapter, ut as VIDEO_DOCUMENT_SCHEMA_VERSION } from "./document-CkbNx-mi.js";
2
2
  import { t as classifyUpdate } from "./loro-relay-doc-ssdYpuef.js";
3
3
  import { LoroDoc, VersionVector, encodeFrontiers } from "loro-crdt";
4
4
  //#region src/testing/in-memory-mengine-server.ts
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mengine/medeo-client",
3
- "version": "1.3.1-alpha.10",
3
+ "version": "1.3.1-alpha.11",
4
4
  "license": "UNLICENSED",
5
5
  "repository": {
6
6
  "type": "git",
@@ -28,9 +28,9 @@
28
28
  "immer": "^10.2.0",
29
29
  "loro-mirror": "^2.2.0",
30
30
  "zod": "^4.4.3",
31
- "@mengine/storage": "1.3.1-alpha.10",
32
- "@mengine/sync": "1.3.1-alpha.10",
33
- "@mengine/utils": "1.3.1-alpha.10"
31
+ "@mengine/storage": "1.3.1-alpha.11",
32
+ "@mengine/sync": "1.3.1-alpha.11",
33
+ "@mengine/utils": "1.3.1-alpha.11"
34
34
  },
35
35
  "devDependencies": {
36
36
  "@types/node": "^25.9.1",