@mengine/medeo-client 1.3.1-alpha.3 → 1.3.1-alpha.5
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.
|
@@ -1102,13 +1102,13 @@ function zodPath(path) {
|
|
|
1102
1102
|
//#endregion
|
|
1103
1103
|
//#region src/document/projection.ts
|
|
1104
1104
|
/**
|
|
1105
|
-
* Projection between
|
|
1106
|
-
*
|
|
1105
|
+
* Projection between authoritative `VideoDocument` and compatible content
|
|
1106
|
+
* layouts (RFC 02 §5/§7). Both directions live here:
|
|
1107
1107
|
*
|
|
1108
1108
|
* - `toVideoDocument` ingests a `VideoDraft`, deriving each item's `position`
|
|
1109
1109
|
* from the legacy absolute layout + aggregations; derived values (abs time,
|
|
1110
1110
|
* `part_aggregations`, total duration) are dropped.
|
|
1111
|
-
* - `fromVideoDocument` solves a `VideoDocument`
|
|
1111
|
+
* - `fromVideoDocument` solves a `VideoDocument` into `VideoDraftContent` via the
|
|
1112
1112
|
* timeline-core cascade, re-deriving exactly those values.
|
|
1113
1113
|
*
|
|
1114
1114
|
* Business validation lives in `validation.ts`; `fromVideoDocument` asserts a
|
|
@@ -1248,8 +1248,8 @@ function deriveItem(item, isMain, speechHost, partLibrary) {
|
|
|
1248
1248
|
};
|
|
1249
1249
|
}
|
|
1250
1250
|
/**
|
|
1251
|
-
* Project
|
|
1252
|
-
*
|
|
1251
|
+
* Project `VideoDocument` into `VideoDraftContent`, solving each item's
|
|
1252
|
+
* absolute position, the `part_aggregations`, and
|
|
1253
1253
|
* the total duration via the timeline-core cascade.
|
|
1254
1254
|
*
|
|
1255
1255
|
* The read-view is a compatibility contract, and the IDL declares
|
|
@@ -615,12 +615,9 @@ type VideoDraftPartUnion = {
|
|
|
615
615
|
};
|
|
616
616
|
};
|
|
617
617
|
/**
|
|
618
|
-
*
|
|
619
|
-
*
|
|
620
|
-
*
|
|
621
|
-
* authoritative parts with the derived `duration_ms` re-injected (reference/17 §7)
|
|
622
|
-
* plus the engine extensions (`media_duration_ms`, the looser `SpeedShift`). This
|
|
623
|
-
* is the intentional superset over the IDL `VideoDraft` (see the extensions note).
|
|
618
|
+
* Legacy Draft import shape. It allows omitted durations and engine extensions
|
|
619
|
+
* so existing fixtures and migrations can state only the facts they have.
|
|
620
|
+
* Projection returns the narrower `VideoDraftContent` contract instead.
|
|
624
621
|
*/
|
|
625
622
|
type VideoDraft = Omit<VideoDraft$1, 'part_library' | 'video_creation_settings'> & {
|
|
626
623
|
part_library: Record<string, VideoDraftPartUnion> | undefined;
|
|
@@ -631,7 +628,39 @@ type VideoDraft = Omit<VideoDraft$1, 'part_library' | 'video_creation_settings'>
|
|
|
631
628
|
* identity, settings, thumbnail and revision counters are assembled by Director;
|
|
632
629
|
* keeping an explicit field list prevents new business DTO fields entering here.
|
|
633
630
|
*/
|
|
634
|
-
type VideoDraftContent = Pick<VideoDraft, 'timeline' | 'main_track' | 'above_main_tracks' | 'below_main_tracks' | 'part_aggregations'
|
|
631
|
+
type VideoDraftContent = Pick<VideoDraft, 'timeline' | 'main_track' | 'above_main_tracks' | 'below_main_tracks' | 'part_aggregations'> & {
|
|
632
|
+
part_library: Record<string, VideoDraftContentPartUnion> | undefined;
|
|
633
|
+
};
|
|
634
|
+
/** Projection always states the duration field; legacy imports may omit it. */
|
|
635
|
+
type VideoDraftContentPartUnion = {
|
|
636
|
+
video_clip: VideoClipPart & {
|
|
637
|
+
duration_ms: number | undefined;
|
|
638
|
+
};
|
|
639
|
+
speech?: never;
|
|
640
|
+
caption?: never;
|
|
641
|
+
bgm?: never;
|
|
642
|
+
} | {
|
|
643
|
+
video_clip?: never;
|
|
644
|
+
speech: SpeechPart & {
|
|
645
|
+
duration_ms: number | undefined;
|
|
646
|
+
};
|
|
647
|
+
caption?: never;
|
|
648
|
+
bgm?: never;
|
|
649
|
+
} | {
|
|
650
|
+
video_clip?: never;
|
|
651
|
+
speech?: never;
|
|
652
|
+
caption: CaptionPart & {
|
|
653
|
+
duration_ms: number | undefined;
|
|
654
|
+
};
|
|
655
|
+
bgm?: never;
|
|
656
|
+
} | {
|
|
657
|
+
video_clip?: never;
|
|
658
|
+
speech?: never;
|
|
659
|
+
caption?: never;
|
|
660
|
+
bgm: BgmPart & {
|
|
661
|
+
duration_ms: number | undefined;
|
|
662
|
+
};
|
|
663
|
+
};
|
|
635
664
|
/** Authoritative timeline: `duration_ms` is derived (= longest track), not stored. */
|
|
636
665
|
interface Timeline {
|
|
637
666
|
unit_time_ms: number | undefined;
|
|
@@ -682,13 +711,13 @@ interface VideoDocumentValidationIssue {
|
|
|
682
711
|
//#endregion
|
|
683
712
|
//#region src/document/projection.d.ts
|
|
684
713
|
/**
|
|
685
|
-
* Projection between
|
|
686
|
-
*
|
|
714
|
+
* Projection between authoritative `VideoDocument` and compatible content
|
|
715
|
+
* layouts (RFC 02 §5/§7). Both directions live here:
|
|
687
716
|
*
|
|
688
717
|
* - `toVideoDocument` ingests a `VideoDraft`, deriving each item's `position`
|
|
689
718
|
* from the legacy absolute layout + aggregations; derived values (abs time,
|
|
690
719
|
* `part_aggregations`, total duration) are dropped.
|
|
691
|
-
* - `fromVideoDocument` solves a `VideoDocument`
|
|
720
|
+
* - `fromVideoDocument` solves a `VideoDocument` into `VideoDraftContent` via the
|
|
692
721
|
* timeline-core cascade, re-deriving exactly those values.
|
|
693
722
|
*
|
|
694
723
|
* Business validation lives in `validation.ts`; `fromVideoDocument` asserts a
|
|
@@ -700,7 +729,7 @@ interface VideoDocumentValidationIssue {
|
|
|
700
729
|
* aggregations (RFC 02 §4/§5). Absolute time, `part_aggregations`, and total
|
|
701
730
|
* duration are dropped — they are re-derived by the projection.
|
|
702
731
|
*/
|
|
703
|
-
declare function toVideoDocument(draft: VideoDraftContent): VideoDocument;
|
|
732
|
+
declare function toVideoDocument(draft: Pick<VideoDraft, keyof VideoDraftContent>): VideoDocument;
|
|
704
733
|
/** speech/attachment part_id → its host video part_id + relative offset. */
|
|
705
734
|
type SpeechHostMap = Map<string, {
|
|
706
735
|
hostPartId: string;
|
|
@@ -740,8 +769,8 @@ interface DerivedItemPosition {
|
|
|
740
769
|
*/
|
|
741
770
|
declare function derivePositionFromAbs(partId: string, abs: number, isMain: boolean, speechHost: SpeechHostMap, partLibrary: Record<string, PartUnion | string | undefined>): DerivedItemPosition;
|
|
742
771
|
/**
|
|
743
|
-
* Project
|
|
744
|
-
*
|
|
772
|
+
* Project `VideoDocument` into `VideoDraftContent`, solving each item's
|
|
773
|
+
* absolute position, the `part_aggregations`, and
|
|
745
774
|
* the total duration via the timeline-core cascade.
|
|
746
775
|
*
|
|
747
776
|
* The read-view is a compatibility contract, and the IDL declares
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { $ as VideoDraft, A as assertValidVideoDocument, B as CaptionPart, C as index_d_exports, D as VideoDocumentMirrorSchema, E as VideoDocumentDraft, F as buildSpeechHostMap, G as Timeline, H as PartKind, I as derivePositionFromAbs, J as TrackItemTimePosition, K as Track, L as fromVideoDocument, M as buildInitialVideoDocument, N as DerivedItemPosition, O as videoDocumentMirrorSchema, P as SpeechHostMap, Q as VideoDocumentValidationIssueCode, R as toVideoDocument, S as ValidationError, T as TrackItemDraft, U as PartUnion, V as DEFAULT_UNIT_TIME_MS, W as SpeechPart, X as VideoDocument, Y as VideoClipPart, Z as VideoDocumentValidationIssue, _ as PlannedSemanticOpKind, a as MirrorVideoDocumentOptions, at as PartAggregation, b as SchemaValidator, c as CommitOptions, ct as Track$1, d as SemanticEditor, et as VideoDraftContent, f as SemanticOpInput, g as ImplementedSemanticOpKind, h as IMPLEMENTED_SEMANTIC_OP_KINDS, i as MirrorVideoDocumentAdapter, it as CaptionStyle, j as validateVideoDocument, k as VideoDocumentValidationError, l as OpActor, lt as TrackItem$1, m as TransactAudit, n as videoDocumentSchema, nt as Attachment, o as createMirrorVideoDocument, ot as SpeedShift, p as SemanticOpName, q as TrackItem, r as readVideoDocumentFromDraft, rt as CaptionPart$1, s as createMirrorVideoDocumentAdapter, st as Timeline$1, t as partUnionSchema, tt as VideoDraftPartUnion, u as SemanticDocumentAdapter, v as SemanticOpKind, w as TrackDraft, x as SnapshotReadable, y as isImplementedSemanticOpKind, z as BgmPart } from "./index-
|
|
1
|
+
import { $ as VideoDraft, A as assertValidVideoDocument, B as CaptionPart, C as index_d_exports, D as VideoDocumentMirrorSchema, E as VideoDocumentDraft, F as buildSpeechHostMap, G as Timeline, H as PartKind, I as derivePositionFromAbs, J as TrackItemTimePosition, K as Track, L as fromVideoDocument, M as buildInitialVideoDocument, N as DerivedItemPosition, O as videoDocumentMirrorSchema, P as SpeechHostMap, Q as VideoDocumentValidationIssueCode, R as toVideoDocument, S as ValidationError, T as TrackItemDraft, U as PartUnion, V as DEFAULT_UNIT_TIME_MS, W as SpeechPart, X as VideoDocument, Y as VideoClipPart, Z as VideoDocumentValidationIssue, _ as PlannedSemanticOpKind, a as MirrorVideoDocumentOptions, at as PartAggregation, b as SchemaValidator, c as CommitOptions, ct as Track$1, d as SemanticEditor, et as VideoDraftContent, f as SemanticOpInput, g as ImplementedSemanticOpKind, h as IMPLEMENTED_SEMANTIC_OP_KINDS, i as MirrorVideoDocumentAdapter, it as CaptionStyle, j as validateVideoDocument, k as VideoDocumentValidationError, l as OpActor, lt as TrackItem$1, m as TransactAudit, n as videoDocumentSchema, nt as Attachment, o as createMirrorVideoDocument, ot as SpeedShift, p as SemanticOpName, q as TrackItem, r as readVideoDocumentFromDraft, rt as CaptionPart$1, s as createMirrorVideoDocumentAdapter, st as Timeline$1, t as partUnionSchema, tt as VideoDraftPartUnion, u as SemanticDocumentAdapter, v as SemanticOpKind, w as TrackDraft, x as SnapshotReadable, y as isImplementedSemanticOpKind, z as BgmPart } from "./index-DdnuQf17.js";
|
|
2
2
|
import { PeerID } from "loro-crdt";
|
|
3
3
|
import { DocState } from "@mengine/sync";
|
|
4
4
|
import { BaseDocStorage, Connection, DocDiff, DocPushReceipt, DocSnapshotRecord, DocStorage, DocStorageOptions, DocUpdate, DocUpdateRecord } from "@mengine/storage";
|
|
@@ -405,8 +405,7 @@ declare class ManualSyncDoc {
|
|
|
405
405
|
* Fetches the snapshot up front rather than starting empty and converging: the
|
|
406
406
|
* agent's first act is to read the document, so there is no useful state before
|
|
407
407
|
* the snapshot lands. This also fails fast and loudly on a document that does
|
|
408
|
-
* not exist
|
|
409
|
-
* waiting forever for content that will never arrive.
|
|
408
|
+
* not exist or whose first snapshot is incomplete or invalid.
|
|
410
409
|
*/
|
|
411
410
|
static open(options: ManualSyncDocOptions): Promise<ManualSyncDoc>;
|
|
412
411
|
/** Current document read model (authoritative shape). */
|
package/dist/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { t as __exportAll } from "./chunk-D7D4PA-g.js";
|
|
2
|
-
import { A as partDurationMs, C as reassignSpeechesToVideoClipsByTime, D as syncAggregatedClipsTimePosition, E as resolveSpeechOverlapByShiftingVideos, F as recordEntries, I as videoDocumentMirrorSchema, L as base64ToBytes, M as DEFAULT_UNIT_TIME_MS, N as effectiveVideoClipDurationMs, O as TIMELINE_SKELETON_DURATION_MS, P as partUnionToDraft, R as bytesToBase64, S as fillMainTrackTimeGaps, T as resolveAllSpeechOverlaps, _ as findLaneTrack, a as buildInitialVideoDocument, b as cascadeAfterVideoClipChanges, c as fromVideoDocument, d as assertValidVideoDocument, f as validateVideoDocument, g as ensureLaneTrack, h as LANE_KINDS_IN_STACK_ORDER, i as readVideoDocumentFromDraft, j as safeDurationMs, k as isEmptyVideoClip, l as toVideoDocument, m as videoDocumentSchema, n as createMirrorVideoDocument, o as buildSpeechHostMap, p as partUnionSchema, r as createMirrorVideoDocumentAdapter, s as derivePositionFromAbs, t as MirrorVideoDocumentAdapter, u as VideoDocumentValidationError, v as laneTrackId, w as recalculateTimelineDuration, x as arrangeMainTrackSeamlessly, y as solveVideoDocument } from "./document-
|
|
2
|
+
import { A as partDurationMs, C as reassignSpeechesToVideoClipsByTime, D as syncAggregatedClipsTimePosition, E as resolveSpeechOverlapByShiftingVideos, F as recordEntries, I as videoDocumentMirrorSchema, L as base64ToBytes, M as DEFAULT_UNIT_TIME_MS, N as effectiveVideoClipDurationMs, O as TIMELINE_SKELETON_DURATION_MS, P as partUnionToDraft, R as bytesToBase64, S as fillMainTrackTimeGaps, T as resolveAllSpeechOverlaps, _ as findLaneTrack, a as buildInitialVideoDocument, b as cascadeAfterVideoClipChanges, c as fromVideoDocument, d as assertValidVideoDocument, f as validateVideoDocument, g as ensureLaneTrack, h as LANE_KINDS_IN_STACK_ORDER, i as readVideoDocumentFromDraft, j as safeDurationMs, k as isEmptyVideoClip, l as toVideoDocument, m as videoDocumentSchema, n as createMirrorVideoDocument, o as buildSpeechHostMap, p as partUnionSchema, r as createMirrorVideoDocumentAdapter, s as derivePositionFromAbs, t as MirrorVideoDocumentAdapter, u as VideoDocumentValidationError, v as laneTrackId, w as recalculateTimelineDuration, x as arrangeMainTrackSeamlessly, y as solveVideoDocument } from "./document-CkFhI8ir.js";
|
|
3
3
|
import { z } from "zod";
|
|
4
4
|
import { LoroDoc, VersionVector } from "loro-crdt";
|
|
5
5
|
import { ClientServerSynchronizer, DocManager } from "@mengine/sync";
|
|
@@ -2035,17 +2035,24 @@ var ManualSyncDoc = class ManualSyncDoc {
|
|
|
2035
2035
|
* Fetches the snapshot up front rather than starting empty and converging: the
|
|
2036
2036
|
* agent's first act is to read the document, so there is no useful state before
|
|
2037
2037
|
* the snapshot lands. This also fails fast and loudly on a document that does
|
|
2038
|
-
* not exist
|
|
2039
|
-
* waiting forever for content that will never arrive.
|
|
2038
|
+
* not exist or whose first snapshot is incomplete or invalid.
|
|
2040
2039
|
*/
|
|
2041
2040
|
static async open(options) {
|
|
2042
|
-
const doc = new LoroDoc();
|
|
2043
|
-
if (options.peerId != null) doc.setPeerId(options.peerId);
|
|
2044
2041
|
const response = await options.client.fetchSnapshot();
|
|
2045
|
-
doc
|
|
2046
|
-
|
|
2047
|
-
|
|
2048
|
-
|
|
2042
|
+
const doc = new LoroDoc();
|
|
2043
|
+
let manualSyncDoc;
|
|
2044
|
+
try {
|
|
2045
|
+
if (options.peerId != null) doc.setPeerId(options.peerId);
|
|
2046
|
+
if (doc.import(base64ToBytes(response.snapshot)).pending != null) throw new Error("Initial mengine snapshot has missing dependencies");
|
|
2047
|
+
manualSyncDoc = new ManualSyncDoc(options.client, doc);
|
|
2048
|
+
assertValidVideoDocument(manualSyncDoc.snapshot());
|
|
2049
|
+
manualSyncDoc.watermark = manualSyncDoc.serverVVFrom(response.version.server_vv) ?? doc.oplogVersion();
|
|
2050
|
+
return manualSyncDoc;
|
|
2051
|
+
} catch (error) {
|
|
2052
|
+
manualSyncDoc?.adapter.dispose();
|
|
2053
|
+
doc.free();
|
|
2054
|
+
throw error;
|
|
2055
|
+
}
|
|
2049
2056
|
}
|
|
2050
2057
|
/** Current document read model (authoritative shape). */
|
|
2051
2058
|
snapshot() {
|
package/dist/testing.d.ts
CHANGED
package/dist/testing.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { L as base64ToBytes, R as bytesToBase64, r as createMirrorVideoDocumentAdapter } from "./document-
|
|
1
|
+
import { L as base64ToBytes, R as bytesToBase64, r as createMirrorVideoDocumentAdapter } from "./document-CkFhI8ir.js";
|
|
2
2
|
import { t as classifyUpdate } from "./loro-relay-doc-cJSY-uau.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.
|
|
3
|
+
"version": "1.3.1-alpha.5",
|
|
4
4
|
"license": "UNLICENSED",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -25,9 +25,9 @@
|
|
|
25
25
|
"dependencies": {
|
|
26
26
|
"loro-mirror": "^2.2.0",
|
|
27
27
|
"zod": "^4.4.3",
|
|
28
|
-
"@mengine/
|
|
29
|
-
"@mengine/
|
|
30
|
-
"@mengine/
|
|
28
|
+
"@mengine/storage": "1.3.1-alpha.5",
|
|
29
|
+
"@mengine/sync": "1.3.1-alpha.5",
|
|
30
|
+
"@mengine/utils": "1.3.1-alpha.5"
|
|
31
31
|
},
|
|
32
32
|
"devDependencies": {
|
|
33
33
|
"@types/node": "^25.9.1",
|