@mengine/medeo-client 1.2.1-alpha.5 → 1.2.1-alpha.6

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/index.d.ts CHANGED
@@ -1,4 +1,5 @@
1
- import { $ as VideoDocumentSchemaVersion, A as assertValidVideoDocument, B as BgmPart, C as index_d_exports, D as VideoDocumentMirrorSchema, E as VideoDocumentDraft, F as SpeechHostMap, G as SpeechPart, H as DEFAULT_UNIT_TIME_MS, I as buildSpeechHostMap, J as TrackItem, K as Timeline, L as derivePositionFromAbs, M as InitialDocumentFacts, N as buildInitialVideoDocument, O as videoDocumentMirrorSchema, P as DerivedItemPosition, Q as VideoDocument, R as fromVideoDocument, S as ValidationError, T as TrackItemDraft, U as PartKind, V as CaptionPart, W as PartUnion, X as VIDEO_DOCUMENT_SCHEMA_VERSION, Y as TrackItemTimePosition, Z as VideoClipPart, _ as PlannedSemanticOpKind, a as MirrorVideoDocumentOptions, at as CaptionPart$1, b as SchemaValidator, c as CommitOptions, ct as SpeedShift, d as SemanticEditor, dt as TrackItem$1, et as VideoDocumentValidationIssue, f as SemanticOpInput, g as ImplementedSemanticOpKind, h as IMPLEMENTED_SEMANTIC_OP_KINDS, i as MirrorVideoDocumentAdapter, it as Attachment, j as validateVideoDocument, k as VideoDocumentValidationError, l as OpActor, lt as Timeline$1, m as TransactAudit, n as videoDocumentSchema, nt as VideoDraft, o as createMirrorVideoDocument, ot as CaptionStyle, p as SemanticOpName, q as Track, r as readVideoDocumentFromDraft, rt as VideoDraftPartUnion, s as createMirrorVideoDocumentAdapter, st as PartAggregation, t as partUnionSchema, tt as VideoDocumentValidationIssueCode, u as SemanticDocumentAdapter, ut as Track$1, v as SemanticOpKind, w as TrackDraft, x as SnapshotReadable, y as isImplementedSemanticOpKind, z as toVideoDocument } from "./index-DpD_SncO.js";
1
+ import { t as index_d_exports } from "./index-InEWX9rk.js";
2
+ import { $ as Track, A as TrackDraft, B as DerivedItemPosition, C as SemanticOpKind, D as ValidationError, E as SnapshotReadable, F as VideoDocumentValidationError, G as toVideoDocument, H as buildSpeechHostMap, I as assertValidVideoDocument, J as DEFAULT_UNIT_TIME_MS, K as BgmPart, L as validateVideoDocument, M as VideoDocumentDraft, N as VideoDocumentMirrorSchema, O as PartIdFactory, P as videoDocumentMirrorSchema, Q as Timeline, R as InitialDocumentFacts, S as PlannedSemanticOpKind, T as SchemaValidator, U as derivePositionFromAbs, V as SpeechHostMap, W as fromVideoDocument, X as PartUnion, Y as PartKind, Z as SpeechPart, _ as SemanticOpInput, _t as Timeline$1, a as PlainMemoryAdapter, at as VideoDocumentSchemaVersion, b as IMPLEMENTED_SEMANTIC_OP_KINDS, c as MirrorVideoDocumentAdapter, ct as VideoDraft, d as createMirrorVideoDocumentAdapter, dt as speedOf, et as TrackItem, f as writeVideoDocumentToDraft, ft as Attachment, g as SemanticEditor, gt as SpeedShift, h as SemanticDocumentAdapter, ht as PartAggregation, i as JournalEntry, it as VideoDocument, j as TrackItemDraft, k as generatePartId, l as MirrorVideoDocumentOptions, lt as VideoDraftPartUnion, m as OpActor, mt as CaptionStyle, n as videoDocumentSchema, nt as VIDEO_DOCUMENT_SCHEMA_VERSION, o as PlainMemoryAdapterOptions, ot as VideoDocumentValidationIssue, p as CommitOptions, pt as CaptionPart$1, q as CaptionPart, r as readVideoDocumentFromDraft, rt as VideoClipPart, s as createPlainMemoryAdapter, st as VideoDocumentValidationIssueCode, t as partUnionSchema, tt as TrackItemTimePosition, u as createMirrorVideoDocument, ut as effectiveVideoClipDurationMs, v as SemanticOpName, vt as Track$1, w as isImplementedSemanticOpKind, x as ImplementedSemanticOpKind, y as TransactAudit, yt as TrackItem$1, z as buildInitialVideoDocument } from "./index-BO2fSUKi.js";
2
3
  import { PeerID } from "loro-crdt";
3
4
  import { DocState } from "@mengine/sync";
4
5
  import { BaseDocStorage, Connection, DocDiff, DocPushReceipt, DocSnapshotRecord, DocStorage, DocStorageOptions, DocUpdate, DocUpdateRecord } from "@mengine/storage";
@@ -177,33 +178,23 @@ interface MengineEventStreamOptions {
177
178
  }
178
179
  declare function readMengineEventStream(options: MengineEventStreamOptions): Promise<void>;
179
180
  //#endregion
180
- //#region src/editor/id-gen.d.ts
181
+ //#region src/editor/journal.d.ts
181
182
  /**
182
- * Part-id generation, aligned with the online ecosystem.
183
- *
184
- * The authoritative online producers — agent-harness (`@harness/shared`
185
- * `genObjId`) and director.v2 (`common/obj_id.py` `gen_obj_id`) — both mint part
186
- * ids as `` `${prefix}_${ulid()}` ``, and real captured drafts use exactly that
187
- * shape (`clip_…` / `spe_…` / `cap_…` / `bgm_…`, each a 26-char ULID). The engine
188
- * previously emitted `vc_<base36 timestamp><6 random>`, a different prefix AND a
189
- * different encoding — the sole cross-repo id divergence. This module removes it
190
- * by emitting the same `<prefix>_<ULID>` bytes.
191
- *
192
- * The ULID is generated inline (Crockford Base32, 48-bit time + 80-bit random)
193
- * rather than pulling the `ulid` npm package: the randomness class matches the
194
- * old generator (both `Math.random`-based) and it keeps `@mengine/medeo-client`
195
- * dependency-free for a purely mechanical id string. Part ids only need to be
196
- * unique and lexicographically time-sortable, which this satisfies.
183
+ * Wire a plain-memory adapter + editor that share a recording id factory, so
184
+ * every mutating transact lands in `journal` with ordered `generated_ids`.
197
185
  */
186
+ declare function createEditSandbox(document: VideoDocument, options?: PlainMemoryAdapterOptions): {
187
+ adapter: PlainMemoryAdapter;
188
+ editor: SemanticEditor;
189
+ journal: readonly JournalEntry[];
190
+ };
198
191
  /**
199
- * Online part-id semantic prefixes. `clip` (video clip) is the only value the
200
- * engine currently mints (see `addVideoClips`); the rest are declared so the
201
- * type documents the shared vocabulary and guards against reintroducing the old
202
- * `vc`/`sp`/`cp`/`bg` names. Speech/caption/bgm ids arrive pre-minted in op
203
- * payloads, so the engine never generates them itself.
192
+ * Re-drive `doc` from a recorded journal, forcing each entry's `generated_ids`
193
+ * through a queue-backed id factory. Never mints fresh ids: an empty queue on
194
+ * demand throws `unrecorded id`; leftover ids after an entry throws
195
+ * `unconsumed ids`. Legacy entries without `generated_ids` are treated as `[]`.
204
196
  */
205
- type PartIdPrefix = 'clip' | 'spe' | 'cap' | 'bgm' | 'ti';
206
- declare function generatePartId(prefix: PartIdPrefix): string;
197
+ declare function replayJournal(doc: SemanticDocumentAdapter, journal: readonly JournalEntry[]): Promise<void>;
207
198
  //#endregion
208
199
  //#region src/editor/snapshot-utils.d.ts
209
200
  /** Main-track item identity read from a raw snapshot (only `part_id` is needed). */
@@ -422,6 +413,16 @@ declare class ManualSyncDoc {
422
413
  editorPeerId(): PeerID;
423
414
  /** Current document projected to the legacy `VideoDraft` read shape. */
424
415
  draft(): VideoDraft;
416
+ /**
417
+ * Replay a deterministic sandbox journal into this document.
418
+ *
419
+ * The adapter stays private so callers cannot bypass the manual-sync
420
+ * lifecycle; journal replay is the one host-side operation that needs the
421
+ * adapter's transaction boundary and recorded id queue. Durability is still
422
+ * explicit: call {@link push} after replay and report success only from its
423
+ * verdict.
424
+ */
425
+ replayJournal(journal: readonly JournalEntry[]): Promise<void>;
425
426
  /**
426
427
  * Mark the document state the caller has just observed, for a later
427
428
  * {@link hasChangedSince}.
@@ -713,6 +714,18 @@ declare class MengineDocSession {
713
714
  * step. The committed change drives DocManager's local-update push.
714
715
  */
715
716
  get editor(): SemanticEditor;
717
+ /**
718
+ * Opaque version token of the local oplog (base64 `VersionVector.encode`).
719
+ * Equality-comparable only: equal means no observed change (local or
720
+ * remote-arrived) since the token was taken. Throws when not started.
721
+ */
722
+ version(): string;
723
+ /**
724
+ * The live document adapter, exposed for journal replay (commit channel).
725
+ * Replaying through it still goes SemanticEditor → Loro → mengine-server —
726
+ * no write bypass. Typed by the narrow interface on purpose.
727
+ */
728
+ get documentAdapter(): SemanticDocumentAdapter;
716
729
  /** Current document snapshot (read model). */
717
730
  snapshot(): VideoDocument;
718
731
  /**
@@ -853,15 +866,6 @@ declare function arrangeMainTrackSeamlessly(doc: TimelineDoc): void;
853
866
  * caption.abs = speech.abs + caption.start_ms
854
867
  */
855
868
  declare function syncAggregatedClipsTimePosition(doc: TimelineDoc): void;
856
- /**
857
- * Resolve authoritative `time_position` edges without inventing parents from
858
- * geometric overlap. Roots stay absolute/sequential; every anchored descendant
859
- * follows its declared parent, regardless of whether that parent is video, BGM,
860
- * or speech.
861
- */
862
- declare function resolveAnchoredClipsTimePosition(doc: TimelineDoc): void;
863
- /** Preserve the historical orphan fallback without re-parenting valid roots. */
864
- declare function recoverOrphanedSpeechAnchorsByTime(doc: TimelineDoc): void;
865
869
  /**
866
870
  * Reassign each speech to the video clip whose time range contains its start,
867
871
  * rebuilding `aggregations`. A speech before the first clip or after the last
@@ -927,8 +931,8 @@ type MakeEmptyPart = (durationMs: number) => {
927
931
  partId: string;
928
932
  };
929
933
  /**
930
- * The full solve pipeline: arrange → resolve declared parent edges →
931
- * resolve-overlap → fill-gaps → recalc. The single cascade the read-side projection runs; ops
934
+ * The full solve pipeline: arrange → sync → reassign → resolve-overlap →
935
+ * fill-gaps → recalc. The single cascade the read-side projection runs; ops
932
936
  * never call it (they write only facts — RFC 02 §7/§10).
933
937
  */
934
938
  declare function cascadeAfterVideoClipChanges(doc: TimelineDoc, makeEmptyPart: MakeEmptyPart): void;
@@ -1073,4 +1077,4 @@ declare function hostForAbsMs(ranges: MainClipRange[], absMs: number): MainClipR
1073
1077
  */
1074
1078
  declare function relativePositionForAbs(ranges: MainClipRange[], absMs: number): TrackItemTimePosition;
1075
1079
  //#endregion
1076
- export { type Aggregation, type Attachment, type BgmPart, type CaptionPart, type CaptionStyle, type CommitOptions, DEFAULT_UNIT_TIME_MS, type DerivedItemPosition, type DocStorageLike, type DocVersionMark, IMPLEMENTED_SEMANTIC_OP_KINDS, type ImplementedSemanticOpKind, type InitialDocumentFacts, LANE_KINDS_IN_STACK_ORDER, type LaneKind, type MainClipRange, type MakeEmptyPart, ManualSyncDoc, type ManualSyncDocOptions, MedeoHttpDocStorage, type MedeoHttpDocStorageOptions, MemoryDocStorage, MengineAckFailedError, type MengineAuditEntry, type MengineAuditResponse, MengineDocSession, type MengineDocSessionOptions, type MengineDocSessionUpdateEvent, type MengineDocumentVersion, type MengineEventStreamOptions, MengineHttpClient, type MengineHttpClientOptions, MengineHttpRequestError, MenginePushRejectedError, type MenginePushResponse, type MenginePushUpdateResponse, type MengineRejectedResponse, type MengineSnapshotResponse, type MengineSseUpdateEvent, type MengineSyncResponse, type MengineUpdateMeta, MirrorVideoDocumentAdapter, type MirrorVideoDocumentOptions, type OpActor, type PartAggregation, type PartKind, type PartUnion, type PlannedSemanticOpKind, type PullFailureReason, type PullResult, type PushOutcome, type PushOutcomeKind, type PushResult, type PushResultKind, SchemaValidator, type SemanticDocumentAdapter, SemanticEditor, type SemanticOpInput, type SemanticOpKind, type SemanticOpName, type SnapshotReadable, type SolvedVideoDocument, type SpeechHostMap, type SpeechPart, type SpeedShift, TIMELINE_SKELETON_DURATION_MS, type Timeline, type TimelineDoc, type TimelineItem, type Track, type TrackDraft, type TrackItem, type TrackItemDraft, type TrackItemTimePosition, type TransactAudit, VIDEO_DOCUMENT_SCHEMA_VERSION, ValidationError, type VideoClipPart, type VideoDocument, type VideoDocumentDraft, type VideoDocumentMirrorSchema, type VideoDocumentSchemaVersion, VideoDocumentValidationError, type VideoDocumentValidationIssue, type VideoDocumentValidationIssueCode, type VideoDraft, type CaptionPart$1 as VideoDraftCaptionPart, type VideoDraftPartUnion, type Timeline$1 as VideoDraftTimeline, type Track$1 as VideoDraftTrack, type TrackItem$1 as VideoDraftTrackItem, type WaitForServerAckOptions, arrangeMainTrackSeamlessly, assertValidVideoDocument, base64ToBytes, buildInitialVideoDocument, buildSpeechHostMap, bytesToBase64, cascadeAfterVideoClipChanges, createMirrorVideoDocument, createMirrorVideoDocumentAdapter, decodeDocVersionMark, derivePositionFromAbs, encodeDocVersionMark, ensureLaneTrack, fillMainTrackTimeGaps, findLaneTrack, fromVideoDocument, generatePartId, getAt, hostForAbsMs, isEmptyVideoClip, isImplementedSemanticOpKind, isMap, laneTrackId, mainTrackRanges, partDurationMs, partUnionSchema, readMainTrackItems, readMengineEventStream, readPart, readPartDurationMs, readVideoDocumentFromDraft, reassignSpeechesToVideoClipsByTime, recalculateTimelineDuration, recoverOrphanedSpeechAnchorsByTime, relativePositionForAbs, resolveAllSpeechOverlaps, resolveAnchoredClipsTimePosition, resolveSpeechOverlapByShiftingVideos, safeDurationMs, index_d_exports as schemas, snapshotToPlain, solveVideoDocument, syncAggregatedClipsTimePosition, toVideoDocument, validateVideoDocument, videoDocumentMirrorSchema, videoDocumentSchema };
1080
+ export { type Aggregation, type Attachment, type BgmPart, type CaptionPart, type CaptionStyle, type CommitOptions, DEFAULT_UNIT_TIME_MS, type DerivedItemPosition, type DocStorageLike, type DocVersionMark, IMPLEMENTED_SEMANTIC_OP_KINDS, type ImplementedSemanticOpKind, type InitialDocumentFacts, type JournalEntry, LANE_KINDS_IN_STACK_ORDER, type LaneKind, type MainClipRange, type MakeEmptyPart, ManualSyncDoc, type ManualSyncDocOptions, MedeoHttpDocStorage, type MedeoHttpDocStorageOptions, MemoryDocStorage, MengineAckFailedError, type MengineAuditEntry, type MengineAuditResponse, MengineDocSession, type MengineDocSessionOptions, type MengineDocSessionUpdateEvent, type MengineDocumentVersion, type MengineEventStreamOptions, MengineHttpClient, type MengineHttpClientOptions, MengineHttpRequestError, MenginePushRejectedError, type MenginePushResponse, type MenginePushUpdateResponse, type MengineRejectedResponse, type MengineSnapshotResponse, type MengineSseUpdateEvent, type MengineSyncResponse, type MengineUpdateMeta, MirrorVideoDocumentAdapter, type MirrorVideoDocumentOptions, type OpActor, type PartAggregation, type PartIdFactory, type PartKind, type PartUnion, PlainMemoryAdapter, type PlainMemoryAdapterOptions, type PlannedSemanticOpKind, type PullFailureReason, type PullResult, type PushOutcome, type PushOutcomeKind, type PushResult, type PushResultKind, SchemaValidator, type SemanticDocumentAdapter, SemanticEditor, type SemanticOpInput, type SemanticOpKind, type SemanticOpName, type SnapshotReadable, type SolvedVideoDocument, type SpeechHostMap, type SpeechPart, type SpeedShift, TIMELINE_SKELETON_DURATION_MS, type Timeline, type TimelineDoc, type TimelineItem, type Track, type TrackDraft, type TrackItem, type TrackItemDraft, type TrackItemTimePosition, type TransactAudit, VIDEO_DOCUMENT_SCHEMA_VERSION, ValidationError, type VideoClipPart, type VideoDocument, type VideoDocumentDraft, type VideoDocumentMirrorSchema, type VideoDocumentSchemaVersion, VideoDocumentValidationError, type VideoDocumentValidationIssue, type VideoDocumentValidationIssueCode, type VideoDraft, type CaptionPart$1 as VideoDraftCaptionPart, type VideoDraftPartUnion, type Timeline$1 as VideoDraftTimeline, type Track$1 as VideoDraftTrack, type TrackItem$1 as VideoDraftTrackItem, type WaitForServerAckOptions, arrangeMainTrackSeamlessly, assertValidVideoDocument, base64ToBytes, buildInitialVideoDocument, buildSpeechHostMap, bytesToBase64, cascadeAfterVideoClipChanges, createEditSandbox, createMirrorVideoDocument, createMirrorVideoDocumentAdapter, createPlainMemoryAdapter, decodeDocVersionMark, derivePositionFromAbs, effectiveVideoClipDurationMs, encodeDocVersionMark, ensureLaneTrack, fillMainTrackTimeGaps, findLaneTrack, fromVideoDocument, generatePartId, getAt, hostForAbsMs, isEmptyVideoClip, isImplementedSemanticOpKind, isMap, laneTrackId, mainTrackRanges, partDurationMs, partUnionSchema, readMainTrackItems, readMengineEventStream, readPart, readPartDurationMs, readVideoDocumentFromDraft, reassignSpeechesToVideoClipsByTime, recalculateTimelineDuration, relativePositionForAbs, replayJournal, resolveAllSpeechOverlaps, resolveSpeechOverlapByShiftingVideos, safeDurationMs, index_d_exports as schemas, snapshotToPlain, solveVideoDocument, speedOf, syncAggregatedClipsTimePosition, toVideoDocument, validateVideoDocument, videoDocumentMirrorSchema, videoDocumentSchema, writeVideoDocumentToDraft };