Import exported documents with durable root and reference remapping

This commit is contained in:
2026-11-09 18:07:56 +08:00
parent 3f7a063630
commit 2adc22a5d9
14 changed files with 54 additions and 23 deletions
+12 -1
View File
@@ -333,7 +333,7 @@ claim of constant-time full-frame updates or complete region-based drawing.
array, with byte cursors, bounded record payloads, structural depth limits and
abort/yield checks. It uses parserVersion 3 and can feed a host-managed generic
ImportRunner. It does not yet interpret the exported document envelope, and
ProjectEngine now accepts native record arrays through `imports.startJsonArray(bytes, canvasId)`; the file picker routes `.json` to it. Exported document envelopes are still unsupported.
ProjectEngine now accepts native record arrays through `imports.startJsonArray(bytes, canvasId)`; the file picker routes `.json` to it. Exported document envelopes use the separate `imports.startDocument` path described below.
A malformed structural tail ends with an explicit failure; previously emitted
records remain available. Empty source bytes reject, while `[]` is a valid empty
array. Array record errors are distinct from document schema/reference failures.
@@ -344,3 +344,14 @@ and commit boundary as NDJSON. Such roots use recovery envelope 14; readers acce
1–14 and reject 15. Downgrading an array-bearing image to 13 rejects. This changes
neither IndexedDB schema v4 nor the server wire protocol. Native array items have
the same `{kind,key,record}` schema as NDJSON; `$target` denotes the chosen canvas.
`imports.startDocument(bytes, canvasId)` accepts the toolbar's exported document
format v1. The JSON picker distinguishes object envelopes from record arrays.
Source canvas ownership and references map to fresh IDs; its root maps to the
explicit target, and tombstones are not copied into the target. The original
file/digest and parserVersion 4 persist; the ordinal cursor resumes against the
same indexed bytes. Document jobs use recovery v15 (readers accept 1–15, reject
16), without changing DB v4 or the wire protocol. Current resource-bearing records
report `import_resource_authorization_required`; other records can import with an
explicit partial result. This is not complete asset round-trip support. Preparation
still scans the envelope before progressive payload decoding and insertion.