@mengine/medeo-client 1.1.0 → 1.2.1-alpha.0

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,7 +1,8 @@
1
- import { $ as VideoDocumentValidationIssue, A as assertValidVideoDocument, B as BgmPart, C as index_d_exports, D as VideoDocumentMirrorSchema, E as VideoDocumentDraft, F as SpeechHostMap, G as Timeline, H as PartKind, I as buildSpeechHostMap, J as TrackItemTimePosition, K as Track, L as derivePositionFromAbs, M as InitialDocumentFacts, N as buildInitialVideoDocument, O as videoDocumentMirrorSchema, P as DerivedItemPosition, Q as VideoDocumentSchemaVersion, R as fromVideoDocument, S as ValidationError, T as TrackItemDraft, U as PartUnion, V as CaptionPart, W as SpeechPart, X as VideoClipPart, Y as VIDEO_DOCUMENT_SCHEMA_VERSION, Z as VideoDocument, _ as PlannedSemanticOpKind, a as MirrorVideoDocumentOptions, at as CaptionStyle, b as SchemaValidator, c as CommitOptions, ct as Timeline$1, d as SemanticEditor, et as VideoDocumentValidationIssueCode, f as SemanticOpInput, g as ImplementedSemanticOpKind, h as IMPLEMENTED_SEMANTIC_OP_KINDS, i as MirrorVideoDocumentAdapter, it as CaptionPart$1, j as validateVideoDocument, k as VideoDocumentValidationError, l as OpActor, lt as Track$1, m as TransactAudit, n as videoDocumentSchema, nt as VideoDraftPartUnion, o as createMirrorVideoDocument, ot as PartAggregation, p as SemanticOpName, q as TrackItem, r as readVideoDocumentFromDraft, rt as Attachment, s as createMirrorVideoDocumentAdapter, st as SpeedShift, t as partUnionSchema, tt as VideoDraft, u as SemanticDocumentAdapter, ut as TrackItem$1, v as SemanticOpKind, w as TrackDraft, x as SnapshotReadable, y as isImplementedSemanticOpKind, z as toVideoDocument } from "./index-BUKA3L7o.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
- import { BaseDocStorage, Connection, DocDiff, DocSnapshotRecord, DocStorage, DocStorageOptions, DocUpdate, DocUpdateRecord } from "@mengine/storage";
5
+ import { BaseDocStorage, Connection, DocDiff, DocPushReceipt, DocSnapshotRecord, DocStorage, DocStorageOptions, DocUpdate, DocUpdateRecord } from "@mengine/storage";
5
6
 
6
7
  //#region src/client/base64.d.ts
7
8
  declare function bytesToBase64(bytes: Uint8Array): string;
@@ -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). */
@@ -549,19 +540,24 @@ declare class MedeoHttpDocStorage implements DocStorage {
549
540
  getDoc(docId: string): Promise<DocSnapshotRecord | null>;
550
541
  getDocDiff(docId: string, knownVersion?: Uint8Array): Promise<DocDiff | null>;
551
542
  /**
552
- * Forward one update to the server.
543
+ * Forward one update to the server, returning what the server says it now holds.
544
+ *
545
+ * The returned `server_vv` is the server's own statement about itself, computed
546
+ * inside the write transaction. A caller tracking "what the remote has" can
547
+ * adopt it directly, which is strictly better than inferring that bound from
548
+ * the pushed blob: it also covers ops other peers wrote, so those stop being
549
+ * re-sent on every later push. `ack` and `duplicate` both carry it.
553
550
  *
554
- * The `DocStorage` contract returns `void`, so the server's verdict cannot be
555
- * the return value it is published on {@link subscribePushOutcome} instead,
556
- * for BOTH outcomes and failures. That channel is what makes the push
557
- * observable; previously the verdict was read and dropped, so a `duplicate`
558
- * (bytes contributed nothing) was indistinguishable from a successful write.
551
+ * The verdict itself stays on {@link subscribePushOutcome}, which reports
552
+ * failures too — a return value cannot. Previously the verdict was read and
553
+ * dropped, so a `duplicate` (bytes contributed nothing) was indistinguishable
554
+ * from a successful write.
559
555
  *
560
556
  * The error is still rethrown after being published: the synchronizer treats a
561
557
  * throw as "retry this cycle", and swallowing it here would strand the update.
562
558
  * Publishing is therefore additive observability, not error handling.
563
559
  */
564
- pushDocUpdate(update: DocUpdate, _origin: unknown): Promise<void>;
560
+ pushDocUpdate(update: DocUpdate, _origin: unknown): Promise<DocPushReceipt>;
565
561
  /**
566
562
  * Observe the server's verdict for every pushed update, including failures.
567
563
  *
@@ -708,6 +704,18 @@ declare class MengineDocSession {
708
704
  * step. The committed change drives DocManager's local-update push.
709
705
  */
710
706
  get editor(): SemanticEditor;
707
+ /**
708
+ * Opaque version token of the local oplog (base64 `VersionVector.encode`).
709
+ * Equality-comparable only: equal means no observed change (local or
710
+ * remote-arrived) since the token was taken. Throws when not started.
711
+ */
712
+ version(): string;
713
+ /**
714
+ * The live document adapter, exposed for journal replay (commit channel).
715
+ * Replaying through it still goes SemanticEditor → Loro → mengine-server —
716
+ * no write bypass. Typed by the narrow interface on purpose.
717
+ */
718
+ get documentAdapter(): SemanticDocumentAdapter;
711
719
  /** Current document snapshot (read model). */
712
720
  snapshot(): VideoDocument;
713
721
  /**
@@ -750,7 +758,7 @@ declare class MemoryDocStorage extends BaseDocStorage {
750
758
  readonly connection: Connection;
751
759
  private readonly entries;
752
760
  constructor(options?: DocStorageOptions);
753
- pushDocUpdate(update: DocUpdate, origin: unknown): Promise<void>;
761
+ pushDocUpdate(update: DocUpdate, origin: unknown): Promise<DocPushReceipt>;
754
762
  deleteDoc(docId: string): Promise<void>;
755
763
  protected getDocSnapshot(docId: string): Promise<DocSnapshotRecord | null>;
756
764
  protected setDocSnapshot(snapshot: DocSnapshotRecord): Promise<boolean>;
@@ -1059,4 +1067,4 @@ declare function hostForAbsMs(ranges: MainClipRange[], absMs: number): MainClipR
1059
1067
  */
1060
1068
  declare function relativePositionForAbs(ranges: MainClipRange[], absMs: number): TrackItemTimePosition;
1061
1069
  //#endregion
1062
- export { type Aggregation, type Attachment, type BgmPart, type CaptionPart, type CaptionStyle, type CommitOptions, 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, relativePositionForAbs, resolveAllSpeechOverlaps, resolveSpeechOverlapByShiftingVideos, safeDurationMs, index_d_exports as schemas, snapshotToPlain, solveVideoDocument, syncAggregatedClipsTimePosition, toVideoDocument, validateVideoDocument, videoDocumentMirrorSchema, videoDocumentSchema };
1070
+ 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 };