plitejs 54.0.0-beta.2 → 54.0.0-beta.4
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/{internal/view/annotation-store-metrics.js → annotation-store-metrics-Ccjkef45.js} +1 -1
- package/dist/annotations/index.d.ts +1 -1
- package/dist/annotations/index.js +1 -1
- package/dist/authored/index.d.ts +596 -9
- package/dist/authored/index.js +18679 -4
- package/dist/{core/authored-veto.js → authored-veto-D_9wCJcK.js} +2 -2
- package/dist/{internal/browser-protocol.js → browser-protocol-pvt4HFF7.js} +1 -1
- package/dist/comparison-plan-DY_vuGPq.js +1338 -0
- package/dist/{diff/lib/comparison-types.d.ts → comparison-types-DdwE6mYq.d.ts} +11 -6
- package/dist/create-editor-CLQEkEZ1.js +1108 -0
- package/dist/diff/index.d.ts +31 -3
- package/dist/diff/index.js +1747 -1
- package/dist/dom/index.d.ts +2 -19
- package/dist/dom/index.js +2 -16
- package/dist/dom-CH2BXXj6.js +9220 -0
- package/dist/{core/same-result.js → editor-owner-C9rVbMTs.js} +77 -2
- package/dist/{core/editor-view-lifetime.js → editor-view-lifetime-GJKa_QGh.js} +1 -1
- package/dist/history/index.d.ts +169 -3
- package/dist/history/index.js +6717 -2
- package/dist/hyperscript/index.d.ts +1 -19
- package/dist/hyperscript/index.js +1 -8
- package/dist/{hyperscript/creators.js → hyperscript-CeT83ZLB.js} +134 -8
- package/dist/{annotations/store.d.ts → index-BWPcE4ac.d.ts} +27 -6
- package/dist/index-BXjLmx1n.d.ts +9827 -0
- package/dist/index-DVMNewDn.d.ts +1243 -0
- package/dist/index-Db-ktCTE.d.ts +1092 -0
- package/dist/index-Dq3Jlj8O.d.ts +119 -0
- package/dist/{yjs/core/plugin.d.ts → index-UrB4jAwl.d.ts} +88 -5
- package/dist/index.d.ts +2 -51
- package/dist/index.js +4 -34
- package/dist/internal/index.d.ts +2 -54
- package/dist/internal/index.js +156 -52
- package/dist/{internal/view/mapped-view-store.js → mapped-view-store-CbWqba_1.js} +2 -3
- package/dist/{core/native-grouping-input.js → native-grouping-input-DXNhlPHd.js} +2 -2
- package/dist/pagination/index.d.ts +1 -7
- package/dist/pagination/index.js +1 -693
- package/dist/pagination/react.d.ts +2 -4
- package/dist/pagination/react.js +436 -30
- package/dist/pagination-CBdYiOuR.js +1021 -0
- package/dist/plugin-SR3HTH0j.js +51505 -0
- package/dist/{react/range-geometry.js → range-geometry-CdltxcH6.js} +23 -18
- package/dist/{react/range-geometry.d.ts → range-geometry-Dwp2oyCc.d.ts} +2 -2
- package/dist/react/index.d.ts +5 -97
- package/dist/react/index.js +7 -72
- package/dist/react/virtualized.d.ts +2 -4
- package/dist/react/virtualized.js +146 -7
- package/dist/react-CN-iBh1z.js +1018 -0
- package/dist/{core/change/retraction.js → retraction-BmPJB9cE.js} +16 -4
- package/dist/src-B-zm0kz4.js +1511 -0
- package/dist/{internal/view/stable-id-mapped-source.js → store-51r4zpCR.js} +253 -3
- package/dist/testing/index.d.ts +182 -8
- package/dist/testing/index.js +95 -8
- package/dist/use-editor-dom-scope-uDJQ692F.js +28370 -0
- package/dist/yjs/index.d.ts +1 -4
- package/dist/yjs/index.js +1 -2
- package/dist/yjs/react/index.d.ts +25 -5
- package/dist/yjs/react/index.js +84 -3
- package/dist/yjs-IGE0Al3n.js +13416 -0
- package/package.json +1 -1
- package/dist/annotations/store.js +0 -244
- package/dist/authored/authored.d.ts +0 -116
- package/dist/authored/authored.js +0 -1271
- package/dist/authored/changes.js +0 -365
- package/dist/authored/comparison.d.ts +0 -41
- package/dist/authored/comparison.js +0 -270
- package/dist/authored/decision-window.js +0 -42
- package/dist/authored/decision.js +0 -306
- package/dist/authored/facts/admission.js +0 -388
- package/dist/authored/facts/compact.d.ts +0 -2
- package/dist/authored/facts/compact.js +0 -91
- package/dist/authored/facts/dependencies.d.ts +0 -5
- package/dist/authored/facts/dependencies.js +0 -66
- package/dist/authored/facts/editing.js +0 -12
- package/dist/authored/facts/facts.d.ts +0 -8
- package/dist/authored/facts/facts.js +0 -535
- package/dist/authored/facts/records.d.ts +0 -28
- package/dist/authored/facts/records.js +0 -226
- package/dist/authored/facts/settle.js +0 -529
- package/dist/authored/format.d.ts +0 -34
- package/dist/authored/format.js +0 -175
- package/dist/authored/ledger/book.js +0 -809
- package/dist/authored/ledger/cards.js +0 -223
- package/dist/authored/ledger/ledger.js +0 -830
- package/dist/authored/ledger/level.js +0 -1081
- package/dist/authored/ledger/links.js +0 -20
- package/dist/authored/ledger/pairs.js +0 -334
- package/dist/authored/ledger/places.js +0 -524
- package/dist/authored/ledger/preview-lens.js +0 -252
- package/dist/authored/ledger/projection.js +0 -163
- package/dist/authored/ledger/roots.js +0 -11
- package/dist/authored/ledger/runs.js +0 -480
- package/dist/authored/ledger/slots.js +0 -330
- package/dist/authored/ledger/work.js +0 -66
- package/dist/authored/refusal.d.ts +0 -33
- package/dist/authored/refusal.js +0 -188
- package/dist/authored/resolve-schema.js +0 -62
- package/dist/authored/tree/alignment.js +0 -456
- package/dist/authored/tree/carried.js +0 -205
- package/dist/authored/tree/command-values.js +0 -344
- package/dist/authored/tree/cuts.js +0 -320
- package/dist/authored/tree/grid.js +0 -49
- package/dist/authored/tree/halves.js +0 -120
- package/dist/authored/tree/holders.js +0 -345
- package/dist/authored/tree/holds.js +0 -135
- package/dist/authored/tree/layers.d.ts +0 -49
- package/dist/authored/tree/layers.js +0 -354
- package/dist/authored/tree/marks.d.ts +0 -136
- package/dist/authored/tree/marks.js +0 -263
- package/dist/authored/tree/proposed.js +0 -212
- package/dist/authored/tree/readiness.js +0 -545
- package/dist/authored/tree/record-completion.js +0 -423
- package/dist/authored/tree/record.js +0 -2908
- package/dist/authored/tree/reserves.js +0 -449
- package/dist/authored/tree/resolve.d.ts +0 -9
- package/dist/authored/tree/resolve.js +0 -1860
- package/dist/authored/tree/shown.js +0 -153
- package/dist/authored/tree/spare-lines.js +0 -119
- package/dist/authored/tree/spares.js +0 -61
- package/dist/authored/types.d.ts +0 -177
- package/dist/core/anchor-state.d.ts +0 -15
- package/dist/core/anchor-state.js +0 -792
- package/dist/core/anchor.d.ts +0 -34
- package/dist/core/anchor.js +0 -843
- package/dist/core/authored-document-capability.d.ts +0 -106
- package/dist/core/authored-document-capability.js +0 -6
- package/dist/core/authored-runtime.d.ts +0 -10
- package/dist/core/authored-runtime.js +0 -67
- package/dist/core/authored-veto.d.ts +0 -30
- package/dist/core/change/builder.d.ts +0 -546
- package/dist/core/change/builder.js +0 -1120
- package/dist/core/change/carried-projection.js +0 -1518
- package/dist/core/change/carried-run.d.ts +0 -26
- package/dist/core/change/carried-run.js +0 -251
- package/dist/core/change/carry-program.js +0 -537
- package/dist/core/change/classification.d.ts +0 -22
- package/dist/core/change/classification.js +0 -205
- package/dist/core/change/cross-rule.js +0 -238
- package/dist/core/change/cross.js +0 -577
- package/dist/core/change/document-change.d.ts +0 -137
- package/dist/core/change/document-change.js +0 -872
- package/dist/core/change/document-index.d.ts +0 -117
- package/dist/core/change/document-index.js +0 -542
- package/dist/core/change/draft-facts.js +0 -323
- package/dist/core/change/enclosure.d.ts +0 -12
- package/dist/core/change/enclosure.js +0 -272
- package/dist/core/change/join.js +0 -751
- package/dist/core/change/json.d.ts +0 -4
- package/dist/core/change/json.js +0 -26
- package/dist/core/change/lazy-root.d.ts +0 -1
- package/dist/core/change/lazy-root.js +0 -73
- package/dist/core/change/lineage.d.ts +0 -49
- package/dist/core/change/lineage.js +0 -390
- package/dist/core/change/mapping.d.ts +0 -31
- package/dist/core/change/mapping.js +0 -186
- package/dist/core/change/new-letters.d.ts +0 -14
- package/dist/core/change/new-letters.js +0 -139
- package/dist/core/change/range-association.js +0 -10
- package/dist/core/change/read-back.d.ts +0 -7
- package/dist/core/change/read-back.js +0 -7
- package/dist/core/change/record.d.ts +0 -59
- package/dist/core/change/record.js +0 -346
- package/dist/core/change/root-change.d.ts +0 -180
- package/dist/core/change/root-change.js +0 -3544
- package/dist/core/change/slice-facts.js +0 -89
- package/dist/core/change/text-splices.js +0 -98
- package/dist/core/change/tokens.d.ts +0 -97
- package/dist/core/change/tokens.js +0 -449
- package/dist/core/change/transform.d.ts +0 -36
- package/dist/core/change/transform.js +0 -97
- package/dist/core/change/wrap-fidelity.js +0 -295
- package/dist/core/change-events.js +0 -223
- package/dist/core/clone.js +0 -28
- package/dist/core/command-definition.d.ts +0 -25
- package/dist/core/command-definition.js +0 -48
- package/dist/core/command-document.d.ts +0 -4
- package/dist/core/command-document.js +0 -20
- package/dist/core/command-frame.js +0 -628
- package/dist/core/command-registry.d.ts +0 -36
- package/dist/core/command-registry.js +0 -283
- package/dist/core/commit-publication.js +0 -40
- package/dist/core/commit.d.ts +0 -26
- package/dist/core/commit.js +0 -686
- package/dist/core/composition-stamp.d.ts +0 -14
- package/dist/core/composition-stamp.js +0 -79
- package/dist/core/content-completion.d.ts +0 -4
- package/dist/core/content-completion.js +0 -343
- package/dist/core/content-landing.js +0 -124
- package/dist/core/content-slice-roots.js +0 -36
- package/dist/core/content-slice.d.ts +0 -38
- package/dist/core/content-slice.js +0 -253
- package/dist/core/content.js +0 -18
- package/dist/core/correction.js +0 -25
- package/dist/core/default-storage.js +0 -53
- package/dist/core/document-admission.d.ts +0 -4
- package/dist/core/document-admission.js +0 -64
- package/dist/core/document-change.d.ts +0 -3
- package/dist/core/document-recorder.d.ts +0 -6
- package/dist/core/document-recorder.js +0 -67
- package/dist/core/document-shape.d.ts +0 -68
- package/dist/core/document-shape.js +0 -173
- package/dist/core/document-view-read.d.ts +0 -16
- package/dist/core/document-view-read.js +0 -36
- package/dist/core/draft-track.d.ts +0 -3
- package/dist/core/draft-track.js +0 -90
- package/dist/core/editor-commands.d.ts +0 -99
- package/dist/core/editor-commands.js +0 -505
- package/dist/core/editor-lifecycle-api.d.ts +0 -8
- package/dist/core/editor-lifecycle-api.js +0 -219
- package/dist/core/editor-lifetime.js +0 -12
- package/dist/core/editor-owner.d.ts +0 -24
- package/dist/core/editor-owner.js +0 -78
- package/dist/core/editor-read-execution.d.ts +0 -6
- package/dist/core/editor-read-execution.js +0 -64
- package/dist/core/editor-read-runtime.js +0 -176
- package/dist/core/editor-reads.d.ts +0 -128
- package/dist/core/editor-reads.js +0 -63
- package/dist/core/editor-runtime.d.ts +0 -112
- package/dist/core/editor-runtime.js +0 -20
- package/dist/core/editor-schema.d.ts +0 -314
- package/dist/core/editor-schema.js +0 -2295
- package/dist/core/element-owned-root-index.d.ts +0 -4
- package/dist/core/element-owned-root-index.js +0 -353
- package/dist/core/get-content-slice.js +0 -118
- package/dist/core/get-fragment.js +0 -22
- package/dist/core/identity-owner.js +0 -697
- package/dist/core/import-content-slice.js +0 -26
- package/dist/core/initial-value.js +0 -87
- package/dist/core/insert-limit.js +0 -81
- package/dist/core/is-empty-element.js +0 -20
- package/dist/core/json-fingerprint.js +0 -16
- package/dist/core/landing.d.ts +0 -11
- package/dist/core/landing.js +0 -279
- package/dist/core/lifecycle-error.d.ts +0 -11
- package/dist/core/lifecycle-error.js +0 -68
- package/dist/core/listener-state.d.ts +0 -1
- package/dist/core/listener-state.js +0 -59
- package/dist/core/measured-sequence.d.ts +0 -43
- package/dist/core/measured-sequence.js +0 -404
- package/dist/core/missing-reference.js +0 -15
- package/dist/core/node-property-mutation.js +0 -10
- package/dist/core/node-selection.js +0 -85
- package/dist/core/node-write-veto.d.ts +0 -37
- package/dist/core/node-write-veto.js +0 -17
- package/dist/core/persisted-document.d.ts +0 -6
- package/dist/core/persisted-document.js +0 -39
- package/dist/core/persistent-map.js +0 -139
- package/dist/core/plain-text.d.ts +0 -32
- package/dist/core/plain-text.js +0 -92
- package/dist/core/plugin-dispatch.d.ts +0 -21
- package/dist/core/plugin-dispatch.js +0 -166
- package/dist/core/plugin-point.d.ts +0 -6
- package/dist/core/plugin-point.js +0 -21
- package/dist/core/plugin-registry.d.ts +0 -78
- package/dist/core/plugin-registry.js +0 -485
- package/dist/core/plugin-slot.d.ts +0 -23
- package/dist/core/plugin-slot.js +0 -30
- package/dist/core/plugin.d.ts +0 -125
- package/dist/core/plugin.js +0 -1485
- package/dist/core/prefix-occupant-join.js +0 -52
- package/dist/core/profiling.js +0 -18
- package/dist/core/property-validity.d.ts +0 -14
- package/dist/core/property-validity.js +0 -65
- package/dist/core/public-root.d.ts +0 -10
- package/dist/core/public-root.js +0 -50
- package/dist/core/public-state.d.ts +0 -191
- package/dist/core/public-state.js +0 -6772
- package/dist/core/read-definition.js +0 -22
- package/dist/core/read-registry.js +0 -127
- package/dist/core/record-store.d.ts +0 -12
- package/dist/core/record-store.js +0 -297
- package/dist/core/refusal.d.ts +0 -1
- package/dist/core/refusal.js +0 -40
- package/dist/core/representation.d.ts +0 -11
- package/dist/core/representation.js +0 -844
- package/dist/core/resolved-token-cursor.d.ts +0 -21
- package/dist/core/resolved-token-cursor.js +0 -294
- package/dist/core/root-entries.js +0 -121
- package/dist/core/root-ownership.d.ts +0 -19
- package/dist/core/root-ownership.js +0 -354
- package/dist/core/root-target.d.ts +0 -7
- package/dist/core/root-target.js +0 -281
- package/dist/core/same-result.d.ts +0 -18
- package/dist/core/schema-compiler.d.ts +0 -345
- package/dist/core/schema-compiler.js +0 -3166
- package/dist/core/schema-contribution-registry.d.ts +0 -12
- package/dist/core/schema-contribution-registry.js +0 -88
- package/dist/core/schema-definition.d.ts +0 -307
- package/dist/core/schema-definition.js +0 -628
- package/dist/core/schema-source.internal.d.ts +0 -49
- package/dist/core/schema-validation.d.ts +0 -11
- package/dist/core/schema-validation.js +0 -85
- package/dist/core/screen-reader-announcement.d.ts +0 -13
- package/dist/core/screen-reader-announcement.js +0 -17
- package/dist/core/selection-protocol.d.ts +0 -38
- package/dist/core/selection-protocol.js +0 -523
- package/dist/core/selection-state.js +0 -9
- package/dist/core/semantic-update-method.d.ts +0 -11
- package/dist/core/semantic-update-method.js +0 -26
- package/dist/core/set-root.d.ts +0 -3
- package/dist/core/set-root.js +0 -244
- package/dist/core/slice-end-matter.js +0 -77
- package/dist/core/slice-fit/compiled-slice-fitter.d.ts +0 -56
- package/dist/core/slice-fit/compiled-slice-fitter.js +0 -2087
- package/dist/core/slice-fit/fit-report.d.ts +0 -36
- package/dist/core/slice-fit/fit-report.js +0 -122
- package/dist/core/slice-fit/frontier.js +0 -98
- package/dist/core/slice-fit/origin.js +0 -57
- package/dist/core/slice-fit/provenance.d.ts +0 -30
- package/dist/core/slice-fit/provenance.js +0 -245
- package/dist/core/slice-identities.js +0 -21
- package/dist/core/slice-landing-types.d.ts +0 -61
- package/dist/core/slice-landing.js +0 -124
- package/dist/core/snapshot-index.d.ts +0 -13
- package/dist/core/snapshot-index.js +0 -860
- package/dist/core/state-field.d.ts +0 -12
- package/dist/core/state-field.js +0 -102
- package/dist/core/state-fields.js +0 -36
- package/dist/core/survival.js +0 -61
- package/dist/core/target-runtime.d.ts +0 -5
- package/dist/core/target-runtime.js +0 -42
- package/dist/core/transaction-values.d.ts +0 -47
- package/dist/core/transaction-values.js +0 -66
- package/dist/core/transfer-guard.js +0 -299
- package/dist/core/transfer-types.d.ts +0 -170
- package/dist/core/transfer.d.ts +0 -72
- package/dist/core/transfer.js +0 -655
- package/dist/core/tx-only.d.ts +0 -64
- package/dist/core/tx-only.js +0 -84
- package/dist/core/unique-values.js +0 -298
- package/dist/core/update-context.js +0 -28
- package/dist/core/update-policy.d.ts +0 -17
- package/dist/core/update-policy.js +0 -45
- package/dist/core/value-codec.d.ts +0 -35
- package/dist/core/value-codec.js +0 -240
- package/dist/core/view-carets.d.ts +0 -39
- package/dist/core/view-carets.js +0 -676
- package/dist/core/view-presentation.d.ts +0 -9
- package/dist/core/view-presentation.js +0 -70
- package/dist/core/work.d.ts +0 -192
- package/dist/core/work.js +0 -122
- package/dist/core/writable-text.js +0 -37
- package/dist/create-editor.d.ts +0 -187
- package/dist/create-editor.js +0 -281
- package/dist/diff/lib/compare.d.ts +0 -33
- package/dist/diff/lib/compare.js +0 -459
- package/dist/diff/lib/comparison-align.js +0 -324
- package/dist/diff/lib/comparison-index.js +0 -160
- package/dist/diff/lib/comparison-internal.js +0 -108
- package/dist/diff/lib/comparison-matcher.js +0 -1221
- package/dist/diff/lib/comparison-moves.js +0 -151
- package/dist/diff/lib/comparison-plan.js +0 -556
- package/dist/diff/lib/index.d.ts +0 -3
- package/dist/dom/dom-soft-line-end.d.ts +0 -3
- package/dist/dom/dom-soft-line-end.js +0 -295
- package/dist/dom/internal/index.d.ts +0 -15
- package/dist/dom/plugin/data-transfer-format.d.ts +0 -90
- package/dist/dom/plugin/data-transfer-format.js +0 -525
- package/dist/dom/plugin/dom-clipboard-runtime.d.ts +0 -50
- package/dist/dom/plugin/dom-clipboard-runtime.js +0 -482
- package/dist/dom/plugin/dom-coverage.d.ts +0 -140
- package/dist/dom/plugin/dom-coverage.js +0 -443
- package/dist/dom/plugin/dom-drag-scroll.js +0 -176
- package/dist/dom/plugin/dom-drag.d.ts +0 -54
- package/dist/dom/plugin/dom-drag.js +0 -507
- package/dist/dom/plugin/dom-editor.d.ts +0 -421
- package/dist/dom/plugin/dom-editor.js +0 -1316
- package/dist/dom/plugin/dom-event-range-targets.js +0 -39
- package/dist/dom/plugin/dom-geometry.d.ts +0 -11
- package/dist/dom/plugin/dom-geometry.js +0 -888
- package/dist/dom/plugin/dom-input-runtime.d.ts +0 -1
- package/dist/dom/plugin/dom-input-runtime.js +0 -571
- package/dist/dom/plugin/dom-integrity-observer.js +0 -436
- package/dist/dom/plugin/dom-node-path.js +0 -61
- package/dist/dom/plugin/dom-phase-scheduler.d.ts +0 -1
- package/dist/dom/plugin/dom-phase-scheduler.js +0 -284
- package/dist/dom/plugin/dom-root-runtime.d.ts +0 -10
- package/dist/dom/plugin/dom-root-runtime.js +0 -716
- package/dist/dom/plugin/dom-sync-mutation-ownership.d.ts +0 -1
- package/dist/dom/plugin/dom-sync-mutation-ownership.js +0 -120
- package/dist/dom/plugin/dom-text-flow-index.js +0 -396
- package/dist/dom/plugin/dom-text-freshness.js +0 -188
- package/dist/dom/plugin/dom-text-proofs.d.ts +0 -2
- package/dist/dom/plugin/dom-text-proofs.js +0 -350
- package/dist/dom/plugin/dom-view-caret.js +0 -28
- package/dist/dom/plugin/with-dom.d.ts +0 -53
- package/dist/dom/plugin/with-dom.js +0 -101
- package/dist/dom/utils/constants.d.ts +0 -5
- package/dist/dom/utils/constants.js +0 -5
- package/dist/dom/utils/diff-text.d.ts +0 -51
- package/dist/dom/utils/diff-text.js +0 -264
- package/dist/dom/utils/dom.d.ts +0 -104
- package/dist/dom/utils/dom.js +0 -257
- package/dist/dom/utils/drag-session.d.ts +0 -2
- package/dist/dom/utils/drag-session.js +0 -115
- package/dist/dom/utils/drop-indicator.d.ts +0 -18
- package/dist/dom/utils/drop-indicator.js +0 -36
- package/dist/dom/utils/environment.d.ts +0 -12
- package/dist/dom/utils/environment.js +0 -118
- package/dist/dom/utils/hotkey-match.d.ts +0 -36
- package/dist/dom/utils/hotkey-match.js +0 -208
- package/dist/dom/utils/hotkeys.d.ts +0 -32
- package/dist/dom/utils/hotkeys.js +0 -121
- package/dist/dom/utils/key.d.ts +0 -14
- package/dist/dom/utils/key.js +0 -18
- package/dist/dom/utils/plite-dom-markers.d.ts +0 -26
- package/dist/dom/utils/plite-dom-markers.js +0 -25
- package/dist/dom/utils/selection-writes.d.ts +0 -18
- package/dist/dom/utils/selection-writes.js +0 -63
- package/dist/dom/utils/weak-maps.d.ts +0 -2
- package/dist/dom/utils/weak-maps.js +0 -51
- package/dist/editor/above.js +0 -30
- package/dist/editor/add-mark.js +0 -79
- package/dist/editor/adjacent-character-point.js +0 -120
- package/dist/editor/after.js +0 -37
- package/dist/editor/before.js +0 -124
- package/dist/editor/block-void-break.js +0 -20
- package/dist/editor/correct-document.js +0 -225
- package/dist/editor/delete-backward.js +0 -64
- package/dist/editor/delete-forward.js +0 -11
- package/dist/editor/delete-fragment.js +0 -40
- package/dist/editor/edges.js +0 -5
- package/dist/editor/element-read-only.js +0 -35
- package/dist/editor/end.d.ts +0 -7
- package/dist/editor/end.js +0 -5
- package/dist/editor/exit-break.js +0 -51
- package/dist/editor/first.js +0 -8
- package/dist/editor/get-void.js +0 -9
- package/dist/editor/has-blocks.js +0 -6
- package/dist/editor/has-inlines.js +0 -6
- package/dist/editor/has-path.js +0 -5
- package/dist/editor/has-texts.js +0 -5
- package/dist/editor/insert-break.js +0 -77
- package/dist/editor/insert-default-child.js +0 -55
- package/dist/editor/insert-soft-break.js +0 -14
- package/dist/editor/insert-text.js +0 -83
- package/dist/editor/is-block.js +0 -5
- package/dist/editor/is-edge.js +0 -5
- package/dist/editor/is-editor.js +0 -13
- package/dist/editor/is-empty.js +0 -6
- package/dist/editor/is-end.js +0 -9
- package/dist/editor/is-start.js +0 -9
- package/dist/editor/last.js +0 -20
- package/dist/editor/leaf.js +0 -9
- package/dist/editor/levels.js +0 -21
- package/dist/editor/next.js +0 -46
- package/dist/editor/node.js +0 -9
- package/dist/editor/nodes.js +0 -106
- package/dist/editor/parent.js +0 -14
- package/dist/editor/path.js +0 -26
- package/dist/editor/point.js +0 -52
- package/dist/editor/positions.js +0 -322
- package/dist/editor/previous.js +0 -48
- package/dist/editor/project-range.js +0 -6
- package/dist/editor/range.js +0 -12
- package/dist/editor/remove-mark.js +0 -65
- package/dist/editor/should-merge-nodes-remove-prev-node.js +0 -11
- package/dist/editor/string.js +0 -35
- package/dist/editor/toggle-mark.js +0 -71
- package/dist/editor/unhang-range.js +0 -71
- package/dist/editor-runtime-view.d.ts +0 -33
- package/dist/editor-runtime-view.js +0 -788
- package/dist/history/history-carets.js +0 -127
- package/dist/history/history-character-map.js +0 -425
- package/dist/history/history-codec.js +0 -176
- package/dist/history/history-merge-policy.js +0 -164
- package/dist/history/history-plugin.d.ts +0 -71
- package/dist/history/history-plugin.js +0 -814
- package/dist/history/history-replay.js +0 -799
- package/dist/history/history-selection.js +0 -75
- package/dist/history/history-state.js +0 -1287
- package/dist/history/history.d.ts +0 -112
- package/dist/history/history.js +0 -29
- package/dist/hyperscript/creators.d.ts +0 -51
- package/dist/hyperscript/hyperscript.d.ts +0 -36
- package/dist/hyperscript/hyperscript.js +0 -66
- package/dist/hyperscript/tokens.d.ts +0 -31
- package/dist/hyperscript/tokens.js +0 -63
- package/dist/interfaces/decoration.d.ts +0 -35
- package/dist/interfaces/editor.d.ts +0 -2783
- package/dist/interfaces/editor.js +0 -348
- package/dist/interfaces/element.d.ts +0 -66
- package/dist/interfaces/element.js +0 -34
- package/dist/interfaces/index.d.ts +0 -13
- package/dist/interfaces/json.d.ts +0 -7
- package/dist/interfaces/location.d.ts +0 -50
- package/dist/interfaces/location.js +0 -26
- package/dist/interfaces/node.d.ts +0 -306
- package/dist/interfaces/node.js +0 -339
- package/dist/interfaces/path.d.ts +0 -118
- package/dist/interfaces/path.js +0 -116
- package/dist/interfaces/point.d.ts +0 -45
- package/dist/interfaces/point.js +0 -32
- package/dist/interfaces/range.d.ts +0 -80
- package/dist/interfaces/range.js +0 -85
- package/dist/interfaces/schema-validation.d.ts +0 -33
- package/dist/interfaces/schema.d.ts +0 -870
- package/dist/interfaces/selection.d.ts +0 -61
- package/dist/interfaces/selection.js +0 -106
- package/dist/interfaces/text.d.ts +0 -68
- package/dist/interfaces/text.js +0 -52
- package/dist/interfaces/transforms/node.d.ts +0 -222
- package/dist/interfaces/transforms/selection.d.ts +0 -48
- package/dist/interfaces/transforms/text.d.ts +0 -58
- package/dist/internal/browser-protocol.d.ts +0 -5
- package/dist/internal/document-range.d.ts +0 -9
- package/dist/internal/document-range.js +0 -31
- package/dist/internal/editor-options.d.ts +0 -37
- package/dist/internal/editor-options.js +0 -36
- package/dist/internal/fail-invariant.d.ts +0 -4
- package/dist/internal/fail-invariant.js +0 -6
- package/dist/internal/get-defined.js +0 -7
- package/dist/internal/law-check.js +0 -7
- package/dist/internal/range-text-marks.js +0 -31
- package/dist/internal/root-location.d.ts +0 -23
- package/dist/internal/root-location.js +0 -86
- package/dist/internal/text-run.d.ts +0 -13
- package/dist/internal/text-run.js +0 -44
- package/dist/internal/view/annotation-store-metrics.d.ts +0 -11
- package/dist/internal/view/view-source.d.ts +0 -20
- package/dist/pagination/page-composition.internal.js +0 -313
- package/dist/pagination/page-geometry.internal.js +0 -99
- package/dist/pagination/page-layout-engine-invalidation.internal.js +0 -20
- package/dist/pagination/page-mount-plan.js +0 -84
- package/dist/pagination/paged-view-lines.js +0 -163
- package/dist/range-projection.d.ts +0 -7
- package/dist/range-projection.js +0 -50
- package/dist/react/components/dom-coverage-boundary.d.ts +0 -14
- package/dist/react/components/dom-coverage-boundary.js +0 -143
- package/dist/react/components/editable-descendant-binding.js +0 -70
- package/dist/react/components/editable-dom-commit-fence.js +0 -107
- package/dist/react/components/editable-element-placement.d.ts +0 -2
- package/dist/react/components/editable-element-placement.js +0 -117
- package/dist/react/components/editable-external-text.js +0 -47
- package/dist/react/components/editable-node-equality.js +0 -25
- package/dist/react/components/editable-rendered-element.d.ts +0 -3
- package/dist/react/components/editable-rendered-element.js +0 -61
- package/dist/react/components/editable-text-blocks.d.ts +0 -192
- package/dist/react/components/editable-text-blocks.js +0 -896
- package/dist/react/components/editable-text-containers.d.ts +0 -3
- package/dist/react/components/editable-text-containers.js +0 -28
- package/dist/react/components/editable-text-flow.js +0 -1039
- package/dist/react/components/editable-text-pieces.d.ts +0 -7
- package/dist/react/components/editable-text-pieces.js +0 -193
- package/dist/react/components/editable-text.d.ts +0 -80
- package/dist/react/components/editable-text.js +0 -322
- package/dist/react/components/editable.d.ts +0 -35
- package/dist/react/components/editable.js +0 -406
- package/dist/react/components/editor-announcement-live-region.js +0 -113
- package/dist/react/components/plite-element.d.ts +0 -18
- package/dist/react/components/plite-element.js +0 -54
- package/dist/react/components/plite-leaf.d.ts +0 -18
- package/dist/react/components/plite-leaf.js +0 -21
- package/dist/react/components/plite-placeholder.d.ts +0 -19
- package/dist/react/components/plite-placeholder.js +0 -39
- package/dist/react/components/plite-spacer.js +0 -14
- package/dist/react/components/plite-text.d.ts +0 -23
- package/dist/react/components/plite-text.js +0 -32
- package/dist/react/components/plite-void-shell.js +0 -49
- package/dist/react/components/plite.d.ts +0 -45
- package/dist/react/components/plite.js +0 -297
- package/dist/react/components/text-string.js +0 -18
- package/dist/react/components/windowed-editable.internal.js +0 -51
- package/dist/react/components/zero-width-string.js +0 -26
- package/dist/react/context.js +0 -11
- package/dist/react/decoration-context.d.ts +0 -2
- package/dist/react/decoration-context.js +0 -22
- package/dist/react/decoration-source.d.ts +0 -11
- package/dist/react/decoration-source.js +0 -1030
- package/dist/react/dom-text-sync.d.ts +0 -24
- package/dist/react/dom-text-sync.js +0 -48
- package/dist/react/editable/android-composition.d.ts +0 -3
- package/dist/react/editable/android-composition.js +0 -496
- package/dist/react/editable/browser-handle.js +0 -515
- package/dist/react/editable/caret-engine.js +0 -681
- package/dist/react/editable/clipboard-input-strategy.js +0 -632
- package/dist/react/editable/composition-lease.d.ts +0 -3
- package/dist/react/editable/composition-lease.js +0 -350
- package/dist/react/editable/composition-state.js +0 -716
- package/dist/react/editable/content-root-boundaries.js +0 -79
- package/dist/react/editable/content-root-coordinate-navigation.js +0 -28
- package/dist/react/editable/content-root-navigation-actions.js +0 -190
- package/dist/react/editable/content-root-navigation.js +0 -819
- package/dist/react/editable/content-root-owner-target.js +0 -36
- package/dist/react/editable/content-root-owners.js +0 -191
- package/dist/react/editable/content-root-vertical-geometry.js +0 -60
- package/dist/react/editable/decoration-repair-bridge.js +0 -29
- package/dist/react/editable/dom-coverage-selection.js +0 -158
- package/dist/react/editable/dom-coverage-vertical-selection.js +0 -446
- package/dist/react/editable/dom-input-event.js +0 -14
- package/dist/react/editable/dom-repair-queue.d.ts +0 -7
- package/dist/react/editable/dom-repair-queue.js +0 -543
- package/dist/react/editable/dom-repair-text.js +0 -47
- package/dist/react/editable/editable-command-types.d.ts +0 -1
- package/dist/react/editable/editable-dom-runtime.d.ts +0 -66
- package/dist/react/editable/editable-dom-runtime.js +0 -1022
- package/dist/react/editable/editing-epoch-adapter.js +0 -46
- package/dist/react/editable/editing-kernel.d.ts +0 -7
- package/dist/react/editable/editing-kernel.js +0 -593
- package/dist/react/editable/external-text-binding.js +0 -43
- package/dist/react/editable/external-text-runtime.d.ts +0 -5
- package/dist/react/editable/external-text-runtime.js +0 -851
- package/dist/react/editable/history-focus.js +0 -71
- package/dist/react/editable/history-keyboard.d.ts +0 -4
- package/dist/react/editable/history-keyboard.js +0 -9
- package/dist/react/editable/input-controller.d.ts +0 -7
- package/dist/react/editable/input-controller.js +0 -175
- package/dist/react/editable/input-history.js +0 -21
- package/dist/react/editable/input-router.js +0 -742
- package/dist/react/editable/input-state.d.ts +0 -18
- package/dist/react/editable/input-state.js +0 -330
- package/dist/react/editable/input-target.js +0 -30
- package/dist/react/editable/install-browser-handle.d.ts +0 -12
- package/dist/react/editable/install-browser-handle.js +0 -18
- package/dist/react/editable/interaction-owner.js +0 -88
- package/dist/react/editable/keyboard-input-strategy.js +0 -730
- package/dist/react/editable/line-boundary.js +0 -37
- package/dist/react/editable/model-input-strategy.d.ts +0 -9
- package/dist/react/editable/model-input-strategy.js +0 -242
- package/dist/react/editable/model-selection-dom-preference.js +0 -11
- package/dist/react/editable/mutation-block-editing.js +0 -48
- package/dist/react/editable/mutation-controller.d.ts +0 -32
- package/dist/react/editable/mutation-controller.js +0 -632
- package/dist/react/editable/mutation-full-block-editing.d.ts +0 -2
- package/dist/react/editable/mutation-full-block-editing.js +0 -44
- package/dist/react/editable/mutation-history.d.ts +0 -3
- package/dist/react/editable/mutation-history.js +0 -146
- package/dist/react/editable/native-input-strategy.js +0 -86
- package/dist/react/editable/native-text-input-delta.js +0 -40
- package/dist/react/editable/placed-drag.js +0 -177
- package/dist/react/editable/plite-string-coordinate-placement.js +0 -46
- package/dist/react/editable/press-fence.d.ts +0 -2
- package/dist/react/editable/press-fence.js +0 -70
- package/dist/react/editable/projected-clipboard.js +0 -123
- package/dist/react/editable/projected-native-affordance.js +0 -30
- package/dist/react/editable/projected-selection-target.js +0 -13
- package/dist/react/editable/render-contract-monitor.d.ts +0 -3
- package/dist/react/editable/render-contract-monitor.js +0 -152
- package/dist/react/editable/root-interaction-controller.js +0 -1400
- package/dist/react/editable/root-interaction-dom-selection-replay.js +0 -40
- package/dist/react/editable/root-interaction-resolver.js +0 -116
- package/dist/react/editable/root-selector-sources.js +0 -90
- package/dist/react/editable/runtime-android-engine.js +0 -40
- package/dist/react/editable/runtime-before-input-events.js +0 -671
- package/dist/react/editable/runtime-browser-handle-events.js +0 -40
- package/dist/react/editable/runtime-clipboard-events.js +0 -169
- package/dist/react/editable/runtime-composition-events.js +0 -163
- package/dist/react/editable/runtime-drag-events.js +0 -136
- package/dist/react/editable/runtime-editor-api.d.ts +0 -20
- package/dist/react/editable/runtime-editor-api.js +0 -21
- package/dist/react/editable/runtime-event-engine.js +0 -213
- package/dist/react/editable/runtime-focus-mouse-events.js +0 -264
- package/dist/react/editable/runtime-input-events.js +0 -166
- package/dist/react/editable/runtime-kernel-trace.js +0 -185
- package/dist/react/editable/runtime-keyboard-events.js +0 -333
- package/dist/react/editable/runtime-live-state.js +0 -44
- package/dist/react/editable/runtime-mutation-state.js +0 -11
- package/dist/react/editable/runtime-repair-engine.js +0 -118
- package/dist/react/editable/runtime-root-engine.js +0 -244
- package/dist/react/editable/runtime-root-lifecycle.js +0 -118
- package/dist/react/editable/runtime-root-selection-export.js +0 -38
- package/dist/react/editable/runtime-root-selection-import.js +0 -54
- package/dist/react/editable/runtime-root-state.js +0 -62
- package/dist/react/editable/runtime-selection-engine.js +0 -260
- package/dist/react/editable/runtime-selection-state.js +0 -12
- package/dist/react/editable/runtime-target-bridge.js +0 -29
- package/dist/react/editable/schema-runtime-invalidation.js +0 -26
- package/dist/react/editable/selection-change-listener.js +0 -99
- package/dist/react/editable/selection-claim.d.ts +0 -3
- package/dist/react/editable/selection-claim.js +0 -398
- package/dist/react/editable/selection-controller.d.ts +0 -8
- package/dist/react/editable/selection-controller.js +0 -693
- package/dist/react/editable/selection-dom-range.js +0 -84
- package/dist/react/editable/selection-projected-dom.js +0 -156
- package/dist/react/editable/selection-reconciler.js +0 -630
- package/dist/react/editable/selection-runtime.js +0 -89
- package/dist/react/editable/selection-side-effect-policy.js +0 -20
- package/dist/react/editable/selection-triple-click.js +0 -48
- package/dist/react/editable/selection-void-target.js +0 -172
- package/dist/react/editable/set-root-endpoints.js +0 -75
- package/dist/react/editable/soft-line-end-delete.js +0 -106
- package/dist/react/editable/text-direction.js +0 -82
- package/dist/react/editable/typed-text.d.ts +0 -17
- package/dist/react/editable/typed-text.js +0 -89
- package/dist/react/editable/unread-press.d.ts +0 -2
- package/dist/react/editable/unread-press.js +0 -86
- package/dist/react/editable/view-caret-restore.js +0 -128
- package/dist/react/editable/view-lines.d.ts +0 -7
- package/dist/react/editable/view-lines.js +0 -166
- package/dist/react/external-text.d.ts +0 -131
- package/dist/react/history-step-views.d.ts +0 -4
- package/dist/react/history-step-views.js +0 -119
- package/dist/react/hooks/android-input-manager/android-input-manager.d.ts +0 -7
- package/dist/react/hooks/android-input-manager/android-input-manager.js +0 -716
- package/dist/react/hooks/android-input-manager/use-android-input-manager.js +0 -53
- package/dist/react/hooks/focus-plite-editable.js +0 -116
- package/dist/react/hooks/use-claim-editable-dom-commit.d.ts +0 -12
- package/dist/react/hooks/use-claim-editable-dom-commit.js +0 -31
- package/dist/react/hooks/use-drop-indicator.d.ts +0 -9
- package/dist/react/hooks/use-drop-indicator.js +0 -14
- package/dist/react/hooks/use-editable-clip.d.ts +0 -18
- package/dist/react/hooks/use-editable-clip.js +0 -31
- package/dist/react/hooks/use-editable-layout-pass.js +0 -53
- package/dist/react/hooks/use-editor-composing.d.ts +0 -7
- package/dist/react/hooks/use-editor-composing.js +0 -12
- package/dist/react/hooks/use-editor-context.d.ts +0 -10
- package/dist/react/hooks/use-editor-context.js +0 -18
- package/dist/react/hooks/use-editor-dom-scope.d.ts +0 -27
- package/dist/react/hooks/use-editor-dom-scope.js +0 -23
- package/dist/react/hooks/use-editor-focused.d.ts +0 -7
- package/dist/react/hooks/use-editor-focused.js +0 -12
- package/dist/react/hooks/use-editor-read-only.d.ts +0 -25
- package/dist/react/hooks/use-editor-read-only.js +0 -19
- package/dist/react/hooks/use-editor-runtime-state.d.ts +0 -18
- package/dist/react/hooks/use-editor-runtime-state.js +0 -38
- package/dist/react/hooks/use-editor-selection.d.ts +0 -10
- package/dist/react/hooks/use-editor-selection.js +0 -13
- package/dist/react/hooks/use-editor-selector.d.ts +0 -38
- package/dist/react/hooks/use-editor-selector.js +0 -265
- package/dist/react/hooks/use-editor-view-state.d.ts +0 -16
- package/dist/react/hooks/use-editor-view-state.js +0 -20
- package/dist/react/hooks/use-editor.d.ts +0 -26
- package/dist/react/hooks/use-editor.js +0 -27
- package/dist/react/hooks/use-element-path.d.ts +0 -7
- package/dist/react/hooks/use-element-path.js +0 -36
- package/dist/react/hooks/use-element-selected.d.ts +0 -26
- package/dist/react/hooks/use-element-selected.js +0 -91
- package/dist/react/hooks/use-element.d.ts +0 -13
- package/dist/react/hooks/use-element.js +0 -17
- package/dist/react/hooks/use-generic-selector.js +0 -91
- package/dist/react/hooks/use-hydrated.js +0 -12
- package/dist/react/hooks/use-isomorphic-layout-effect.js +0 -9
- package/dist/react/hooks/use-node-selector.d.ts +0 -40
- package/dist/react/hooks/use-node-selector.js +0 -102
- package/dist/react/hooks/use-plite-annotation-store.d.ts +0 -21
- package/dist/react/hooks/use-plite-annotation-store.js +0 -61
- package/dist/react/hooks/use-plite-annotations.d.ts +0 -9
- package/dist/react/hooks/use-plite-annotations.js +0 -16
- package/dist/react/hooks/use-plite-child-root.d.ts +0 -14
- package/dist/react/hooks/use-plite-child-root.js +0 -38
- package/dist/react/hooks/use-plite-content-root.d.ts +0 -21
- package/dist/react/hooks/use-plite-content-root.js +0 -26
- package/dist/react/hooks/use-plite-history.d.ts +0 -43
- package/dist/react/hooks/use-plite-history.js +0 -137
- package/dist/react/hooks/use-plite-node-ref.js +0 -513
- package/dist/react/hooks/use-plite-root-chrome.d.ts +0 -34
- package/dist/react/hooks/use-plite-root-chrome.js +0 -98
- package/dist/react/hooks/use-plite-runtime.d.ts +0 -86
- package/dist/react/hooks/use-plite-runtime.js +0 -433
- package/dist/react/hooks/use-runtime-focus-state.js +0 -37
- package/dist/react/hooks/use-selection-geometry.d.ts +0 -12
- package/dist/react/hooks/use-selection-geometry.js +0 -39
- package/dist/react/hooks/use-selection-view.d.ts +0 -14
- package/dist/react/hooks/use-selection-view.js +0 -14
- package/dist/react/hooks/use-state-field.d.ts +0 -26
- package/dist/react/hooks/use-state-field.js +0 -38
- package/dist/react/inactive-selection.js +0 -175
- package/dist/react/plugin/react-editor.d.ts +0 -20
- package/dist/react/plugin/react-editor.js +0 -6
- package/dist/react/plugin/with-react.d.ts +0 -108
- package/dist/react/plugin/with-react.js +0 -58
- package/dist/react/render-profiler.js +0 -20
- package/dist/react/root-key.js +0 -12
- package/dist/react/shell-runtime.js +0 -29
- package/dist/react/update-policy.d.ts +0 -10
- package/dist/react/update-policy.js +0 -15
- package/dist/react/utils/environment.js +0 -5
- package/dist/react/view-boundary-graph-core.d.ts +0 -1
- package/dist/react/view-boundary-graph-core.js +0 -208
- package/dist/react/view-boundary-graph.js +0 -105
- package/dist/react/view-selection-decoration.js +0 -97
- package/dist/react/view-selection.js +0 -184
- package/dist/react/viewport-boundary.js +0 -45
- package/dist/react/viewport-commands.d.ts +0 -1
- package/dist/react/viewport-commands.js +0 -17
- package/dist/react/viewport-plan.d.ts +0 -2
- package/dist/react/viewport-plan.js +0 -77
- package/dist/react/virtualized/use-virtualized-root-plan.js +0 -148
- package/dist/testing/createDataTransfer.d.ts +0 -4
- package/dist/testing/createDataTransfer.js +0 -13
- package/dist/testing/jsx.d.ts +0 -181
- package/dist/testing/jsx.js +0 -82
- package/dist/transforms-node/insert-nodes.js +0 -143
- package/dist/transforms-node/lift-nodes.js +0 -117
- package/dist/transforms-node/merge-nodes.js +0 -180
- package/dist/transforms-node/move-nodes.js +0 -58
- package/dist/transforms-node/remove-nodes.js +0 -86
- package/dist/transforms-node/replace-children.js +0 -117
- package/dist/transforms-node/set-nodes.js +0 -188
- package/dist/transforms-node/split-nodes.js +0 -258
- package/dist/transforms-node/unset-nodes.js +0 -10
- package/dist/transforms-node/unwrap-nodes.js +0 -182
- package/dist/transforms-node/wrap-nodes.js +0 -250
- package/dist/transforms-selection/collapse.js +0 -20
- package/dist/transforms-selection/deselect.js +0 -8
- package/dist/transforms-selection/move.js +0 -35
- package/dist/transforms-selection/select.js +0 -59
- package/dist/transforms-selection/set-point.js +0 -32
- package/dist/transforms-selection/set-selection.js +0 -52
- package/dist/transforms-text/delete-text-collapsed-path-targets.js +0 -102
- package/dist/transforms-text/delete-text-grid.js +0 -402
- package/dist/transforms-text/delete-text-inline-points.js +0 -82
- package/dist/transforms-text/delete-text-plan.js +0 -55
- package/dist/transforms-text/delete-text-removal.js +0 -153
- package/dist/transforms-text/delete-text-structural-cleanup.js +0 -130
- package/dist/transforms-text/delete-text-whole-blocks.js +0 -70
- package/dist/transforms-text/delete-text.js +0 -804
- package/dist/transforms-text/full-document-range.js +0 -12
- package/dist/transforms-text/insert-text.js +0 -314
- package/dist/types/types.d.ts +0 -13
- package/dist/utils/format-debug-value.d.ts +0 -8
- package/dist/utils/format-debug-value.js +0 -31
- package/dist/utils/get-default-insert-location.js +0 -19
- package/dist/utils/is-object.d.ts +0 -4
- package/dist/utils/is-object.js +0 -4
- package/dist/utils/match-path.js +0 -8
- package/dist/utils/node-keys.d.ts +0 -15
- package/dist/utils/node-keys.js +0 -179
- package/dist/utils/node-match.js +0 -9
- package/dist/utils/string.js +0 -283
- package/dist/yjs/core/addresses.js +0 -98
- package/dist/yjs/core/ancestor-properties.js +0 -56
- package/dist/yjs/core/attributes.js +0 -21
- package/dist/yjs/core/awareness-adapter.d.ts +0 -5
- package/dist/yjs/core/awareness-adapter.js +0 -399
- package/dist/yjs/core/awareness-relative-selection.js +0 -22
- package/dist/yjs/core/awareness.js +0 -25
- package/dist/yjs/core/binding.d.ts +0 -3
- package/dist/yjs/core/binding.js +0 -128
- package/dist/yjs/core/boundaries.js +0 -453
- package/dist/yjs/core/canonical-split.js +0 -130
- package/dist/yjs/core/change-bridge.js +0 -124
- package/dist/yjs/core/change-regions.js +0 -119
- package/dist/yjs/core/controller-registry.js +0 -70
- package/dist/yjs/core/controller.d.ts +0 -6
- package/dist/yjs/core/controller.js +0 -1282
- package/dist/yjs/core/document.js +0 -1499
- package/dist/yjs/core/editor-adapter.d.ts +0 -18
- package/dist/yjs/core/editor-adapter.js +0 -145
- package/dist/yjs/core/editor-only-roots.js +0 -53
- package/dist/yjs/core/editor-types.d.ts +0 -1
- package/dist/yjs/core/enclosures.js +0 -410
- package/dist/yjs/core/event-change-bridge.js +0 -3642
- package/dist/yjs/core/index.d.ts +0 -4
- package/dist/yjs/core/joined-lines.js +0 -81
- package/dist/yjs/core/joins.js +0 -587
- package/dist/yjs/core/json-equality.js +0 -31
- package/dist/yjs/core/keys.js +0 -29
- package/dist/yjs/core/letter-scripts.js +0 -449
- package/dist/yjs/core/new-letters.js +0 -300
- package/dist/yjs/core/path.js +0 -25
- package/dist/yjs/core/plugin.js +0 -206
- package/dist/yjs/core/record.js +0 -4
- package/dist/yjs/core/replacement.js +0 -165
- package/dist/yjs/core/retraction.js +0 -132
- package/dist/yjs/core/root-owners.js +0 -110
- package/dist/yjs/core/root-projection-index.js +0 -428
- package/dist/yjs/core/schema-metadata.js +0 -88
- package/dist/yjs/core/selection.js +0 -34
- package/dist/yjs/core/set-valued-attributes.js +0 -57
- package/dist/yjs/core/shared-effect-log.d.ts +0 -4
- package/dist/yjs/core/shared-effect-log.js +0 -674
- package/dist/yjs/core/text-runs.js +0 -1596
- package/dist/yjs/core/types.d.ts +0 -76
- package/dist/yjs/react/useYjs.d.ts +0 -25
- package/dist/yjs/react/useYjs.js +0 -85
|
@@ -1,1860 +0,0 @@
|
|
|
1
|
-
import { getDefined } from "../../internal/get-defined.js";
|
|
2
|
-
import { jsonEqual } from "../../core/change/json.js";
|
|
3
|
-
import { NO_RECORD_OPS, composeRecordOps, deriveValue, getValueRecords, withoutValueRoots } from "../../core/record-store.js";
|
|
4
|
-
import { valueRootNodes } from "../../core/change/document-change.js";
|
|
5
|
-
import { PathApi } from "../../interfaces/path.js";
|
|
6
|
-
import { handoverKeysOf, splitDroppedKeysOf } from "../../core/schema-compiler.js";
|
|
7
|
-
import { orphanedValueRoots, schemaHasContentRoots } from "../../core/root-ownership.js";
|
|
8
|
-
import { elementSplitOutput } from "../../core/default-storage.js";
|
|
9
|
-
import { readingCovered } from "../../core/property-validity.js";
|
|
10
|
-
import { gridHoldersOf, gridPartsOf, leftWithNoGridPart, survivalUnder } from "../../core/survival.js";
|
|
11
|
-
import { countLedgerWork } from "../ledger/work.js";
|
|
12
|
-
import { isEditingChange } from "../facts/editing.js";
|
|
13
|
-
import { copyKeyOf, decideKey, splitCopiesOf, splitHistoryOf, tipsWrittenValue } from "./layers.js";
|
|
14
|
-
import { AUTHORED_MARKS_KEY, followsOf, heldOf, isClaim, isPlaceChange, isStructureChange, readAuthoredMarks, readMembers, withMembers } from "./marks.js";
|
|
15
|
-
import { RESERVES, changeOfLink, incarnationOf, incarnationOfLink, landedOf, linkOf, putContexts, putLanded, reserveDropsOf, reserveNodesIn } from "../facts/records.js";
|
|
16
|
-
import { NO_FACTS, factsOf, isAccepted, isJoinAside, isRejected, standingClaimsOf } from "../facts/facts.js";
|
|
17
|
-
import { putRootSpares, slotKeyOf, sparesIn, takeSpare, withBuiltSpares } from "./spares.js";
|
|
18
|
-
import { cutsOf, joinRejectedCuts, joinedShell } from "./cuts.js";
|
|
19
|
-
import { createDependencies } from "../facts/dependencies.js";
|
|
20
|
-
import { coverStoredValues, heldNode, heldProps } from "./holds.js";
|
|
21
|
-
import { leftSupplies, supplies, verdictOf } from "./halves.js";
|
|
22
|
-
import { shownOf } from "./holders.js";
|
|
23
|
-
//#region src/authored/tree/resolve.ts
|
|
24
|
-
const isText = (node) => typeof node.text === "string";
|
|
25
|
-
const notSpare = (member) => member.kind !== "reserve";
|
|
26
|
-
/** @internal */
|
|
27
|
-
const acceptedOwnShape = (node) => {
|
|
28
|
-
const marks = readAuthoredMarks(node);
|
|
29
|
-
if (marks.some((mark) => mark.kind === "delete")) return "drop";
|
|
30
|
-
const joins = !isText(node) && marks.some((mark) => mark.kind === "join");
|
|
31
|
-
const unwraps = marks.some((mark) => mark.kind === "unwrap");
|
|
32
|
-
if (joins && unwraps || marks.some((mark) => mark.kind !== "insert" && mark.kind !== "format" && mark.kind !== "joined" && mark.kind !== "unwrap" && mark.kind !== "wrap" && !(mark.kind === "split" && mark.cut === void 0) && !(joins && mark.kind === "join"))) return "bail";
|
|
33
|
-
if (joins) return "mergeUp";
|
|
34
|
-
return unwraps ? "liftChildren" : "keep";
|
|
35
|
-
};
|
|
36
|
-
const nearest = (blocks, order) => {
|
|
37
|
-
const sorted = blocks.toSorted((left, right) => left.index - right.index);
|
|
38
|
-
return sorted.findLast(({ index }) => index < order) ?? sorted[0];
|
|
39
|
-
};
|
|
40
|
-
const isKeyedLink = (link) => JSON.parse(link).length > 2;
|
|
41
|
-
const isLive = (link, holder) => isKeyedLink(link) ? holder === "join" : holder !== "joined";
|
|
42
|
-
/**
|
|
43
|
-
* A keyed link is live while the nearest block holding its exact key, before
|
|
44
|
-
* the line or else the first after it, holds a join `isPending` accepts; a
|
|
45
|
-
* live link places its line with the nearest such join of its suggestion
|
|
46
|
-
* before the line, or else the first after it.
|
|
47
|
-
*/
|
|
48
|
-
const linksIn = (visit, claimsOf, isPending) => {
|
|
49
|
-
let holders;
|
|
50
|
-
const holdersIn = () => {
|
|
51
|
-
if (!holders) {
|
|
52
|
-
const byLink = /* @__PURE__ */ new Map();
|
|
53
|
-
const bySuggestion = /* @__PURE__ */ new Map();
|
|
54
|
-
visit((node, index) => {
|
|
55
|
-
for (const mark of claimsOf(node)) {
|
|
56
|
-
if (mark.kind !== "joined" && !(mark.kind === "join" && isPending(mark))) continue;
|
|
57
|
-
const block = {
|
|
58
|
-
index,
|
|
59
|
-
mark,
|
|
60
|
-
node
|
|
61
|
-
};
|
|
62
|
-
const key = linkOf(mark);
|
|
63
|
-
byLink.set(key, [...byLink.get(key) ?? [], block]);
|
|
64
|
-
if (mark.kind === "join") {
|
|
65
|
-
const suggestion = incarnationOf(mark);
|
|
66
|
-
bySuggestion.set(suggestion, [...bySuggestion.get(suggestion) ?? [], block]);
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
});
|
|
70
|
-
holders = {
|
|
71
|
-
byLink,
|
|
72
|
-
bySuggestion
|
|
73
|
-
};
|
|
74
|
-
}
|
|
75
|
-
return holders;
|
|
76
|
-
};
|
|
77
|
-
const holderOf = (link, order) => nearest(holdersIn().byLink.get(link) ?? [], order);
|
|
78
|
-
const suggestionJoinsOf = (link) => holdersIn().bySuggestion.get(incarnationOfLink(link)) ?? [];
|
|
79
|
-
const placementOf = (link, order) => isLive(link, holderOf(link, order)?.mark.kind) ? nearest(suggestionJoinsOf(link), order) : void 0;
|
|
80
|
-
return {
|
|
81
|
-
holderOf: (link, order) => holderOf(link, order) ?? null,
|
|
82
|
-
suggestionJoinsOf,
|
|
83
|
-
sourceOf: (links, order) => nearest([...links].flatMap((link) => placementOf(link, order) ?? []), order) ?? null
|
|
84
|
-
};
|
|
85
|
-
};
|
|
86
|
-
const placementLinksIn = (eachBlock, claimsOf, isPending) => {
|
|
87
|
-
const blocks = [];
|
|
88
|
-
const orders = /* @__PURE__ */ new Map();
|
|
89
|
-
const visit = (node) => {
|
|
90
|
-
orders.set(node, blocks.length);
|
|
91
|
-
if (isTextBlock(node)) blocks.push(node);
|
|
92
|
-
else node.children?.forEach(visit);
|
|
93
|
-
};
|
|
94
|
-
eachBlock(visit);
|
|
95
|
-
const links = linksIn((each) => blocks.forEach(each), claimsOf, isPending);
|
|
96
|
-
return (link, node) => links.sourceOf([link], getDefined(orders.get(node)));
|
|
97
|
-
};
|
|
98
|
-
const decidedJoinLeavesInPlace = (mark, rejected, decided) => (mark.kind === "join" || mark.kind === "joined") && (rejected(mark) || mark.kind === "joined" && decided(mark));
|
|
99
|
-
/**
|
|
100
|
-
* The keys, by incarnation, of the keyed joins and `joined` claims among an
|
|
101
|
-
* accept's `occurrences` that its resolution leaves no block holding. Such a
|
|
102
|
-
* join is complete, so an undo that brings its mark back leaves it dormant.
|
|
103
|
-
* Two blocks can hold one key, and one that still waits keeps it live.
|
|
104
|
-
*/
|
|
105
|
-
const completedJoinKeys = (occurrences, resolvedOf) => {
|
|
106
|
-
const held = /* @__PURE__ */ new Map();
|
|
107
|
-
for (const { mark, node } of occurrences) {
|
|
108
|
-
if (mark.kind !== "join" && mark.kind !== "joined" || !mark.key) continue;
|
|
109
|
-
const link = linkOf(mark);
|
|
110
|
-
const output = resolvedOf(node);
|
|
111
|
-
const entry = held.get(link) ?? {
|
|
112
|
-
incarnation: incarnationOf(mark),
|
|
113
|
-
key: mark.key,
|
|
114
|
-
stays: false
|
|
115
|
-
};
|
|
116
|
-
entry.stays ||= !!output && readAuthoredMarks(output).some((member) => (member.kind === "join" || member.kind === "joined") && linkOf(member) === link);
|
|
117
|
-
held.set(link, entry);
|
|
118
|
-
}
|
|
119
|
-
const completed = /* @__PURE__ */ new Map();
|
|
120
|
-
for (const { incarnation, key, stays } of held.values()) if (!stays) completed.set(incarnation, [...completed.get(incarnation) ?? [], key]);
|
|
121
|
-
return completed;
|
|
122
|
-
};
|
|
123
|
-
/** Whether `node` holds a join not set aside, so lands when accepted. */
|
|
124
|
-
const hasLiveJoinMark = (node, facts) => readAuthoredMarks(node).some((mark) => mark.kind === "join" && !isJoinAside(facts, mark));
|
|
125
|
-
/** @internal */
|
|
126
|
-
const claimsBreakBefore = (node) => readAuthoredMarks(node).some((mark) => mark.kind === "join" || mark.kind === "split" && mark.cut === void 0);
|
|
127
|
-
/** @internal */
|
|
128
|
-
const hasBoundaryMark = (node) => readAuthoredMarks(node).some((mark) => mark.kind === "join" || mark.kind === "split");
|
|
129
|
-
const deletesBeforeJoin = (mark, join) => mark.at <= join.at && !join.own.has(incarnationOf(mark));
|
|
130
|
-
/** The review children of a level that hold its prefix slots at the start. */
|
|
131
|
-
const startOccupants = (level, isInserted) => level.filter((node) => !isInserted(node));
|
|
132
|
-
/**
|
|
133
|
-
* The fate of prefix slot `slot`'s start occupant when `original`, as the
|
|
134
|
-
* review tree holds it, is the slot's candidate: kept when it is that occupant
|
|
135
|
-
* or an inserted node, joined when `contracted` start occupants before
|
|
136
|
-
* `original` leave it in the slot, as Editing reads a join's tokens, and
|
|
137
|
-
* otherwise displaced, so the decision builds a fresh element there and never
|
|
138
|
-
* promotes a later sibling.
|
|
139
|
-
*/
|
|
140
|
-
const slotFate = (start, slot, original, isInserted, contracted = () => false) => {
|
|
141
|
-
if (original === start[slot] || isInserted(original)) return "kept";
|
|
142
|
-
const at = start.indexOf(original, slot + 1);
|
|
143
|
-
return at !== -1 && at - start.slice(0, at).filter(contracted).length <= slot ? "joined" : "displaced";
|
|
144
|
-
};
|
|
145
|
-
/**
|
|
146
|
-
* The start occupants that leave no slot behind them, in Editing's order of
|
|
147
|
-
* events: one a join merged into an earlier block, at `joinedAt`, and one
|
|
148
|
-
* removed at `removedAt` from past the `slots` prefix slots, judged where it
|
|
149
|
-
* stood then, after the contractions before it. A removal from a prefix slot
|
|
150
|
-
* keeps its slot, which Editing fills afresh.
|
|
151
|
-
*/
|
|
152
|
-
const contractedStart = (start, slots, joinedAt, removedAt) => {
|
|
153
|
-
const contracted = /* @__PURE__ */ new Set();
|
|
154
|
-
const times = [];
|
|
155
|
-
for (const [index, node] of start.entries()) {
|
|
156
|
-
const joined = joinedAt(node);
|
|
157
|
-
const removed = joined === null ? removedAt(node) : null;
|
|
158
|
-
if (joined !== null) {
|
|
159
|
-
contracted.add(node);
|
|
160
|
-
times.push(joined);
|
|
161
|
-
} else if (removed !== null && index - times.filter((time) => time < removed).length >= slots) {
|
|
162
|
-
contracted.add(node);
|
|
163
|
-
times.push(removed);
|
|
164
|
-
}
|
|
165
|
-
}
|
|
166
|
-
return contracted;
|
|
167
|
-
};
|
|
168
|
-
const slotDecidingInsertions = (level, completed, completeHere, slots, isStart, isInserted) => {
|
|
169
|
-
const occupied = level.findIndex(isStart);
|
|
170
|
-
const front = new Set(level.slice(0, (occupied === -1 ? level.length : occupied) + slots));
|
|
171
|
-
const inserted = [...front].filter(isInserted);
|
|
172
|
-
if (inserted.length === 0) return [];
|
|
173
|
-
const without = completeHere(level.filter((node) => !front.has(node) || !isInserted(node)));
|
|
174
|
-
return prefixHead(completed, slots) === prefixHead(without, slots) ? [] : inserted;
|
|
175
|
-
};
|
|
176
|
-
/** The types completion puts in the first `slots` places, each it built marked. */
|
|
177
|
-
const prefixHead = ({ built, children }, slots) => children.slice(0, slots).map((node) => `${built.some((item) => item.node === node) ? "+" : ""}${typeOf(node)}`).join(",");
|
|
178
|
-
/** An element holding texts; one with no children holds no blocks, so it counts. */
|
|
179
|
-
const isTextBlock = (node) => {
|
|
180
|
-
const { children, text } = node ?? {};
|
|
181
|
-
return typeof text !== "string" && !!children && (children.length === 0 || children.some(isText));
|
|
182
|
-
};
|
|
183
|
-
const typeOf = (node) => typeof node.type === "string" ? node.type : null;
|
|
184
|
-
const withMarks = (node, marks) => {
|
|
185
|
-
const { [AUTHORED_MARKS_KEY]: _marks, ...rest } = node;
|
|
186
|
-
return marks.length > 0 ? {
|
|
187
|
-
...rest,
|
|
188
|
-
[AUTHORED_MARKS_KEY]: marks
|
|
189
|
-
} : rest;
|
|
190
|
-
};
|
|
191
|
-
const propsOf = (node) => {
|
|
192
|
-
const { children: _children, text: _text, ...props } = node;
|
|
193
|
-
return props;
|
|
194
|
-
};
|
|
195
|
-
/** @internal */
|
|
196
|
-
const removes = (mark, result) => mark.kind === "insert" && result === "reject" || mark.kind === "delete" && result === "accept";
|
|
197
|
-
/** @internal */
|
|
198
|
-
const mergesUp = (mark, result) => mark.kind === "join" && result === "accept" || mark.kind === "split" && result === "reject";
|
|
199
|
-
/**
|
|
200
|
-
* Whether rejecting `mark` takes away the element that carries it: an
|
|
201
|
-
* insertion's element, a split's second half or a wrap's wrapper.
|
|
202
|
-
*
|
|
203
|
-
* @internal
|
|
204
|
-
*/
|
|
205
|
-
const buildsElement = (mark) => removes(mark, "reject") || mergesUp(mark, "reject") || mark.kind === "wrap";
|
|
206
|
-
/**
|
|
207
|
-
* Whether some verdict on `mark` can change what completing a container
|
|
208
|
-
* builds: on the container, a type or structure change, which picks the
|
|
209
|
-
* content a build waits on; on a child, a removal `removes` decides, a merge
|
|
210
|
-
* `mergesUp` decides or another structure change a build waits on. A format
|
|
211
|
-
* tag on a child changes nothing a completion builds.
|
|
212
|
-
*
|
|
213
|
-
* @internal
|
|
214
|
-
*/
|
|
215
|
-
const changesBuild = (mark, on) => on === "container" ? isPlaceChange(mark) : removes(mark, "accept") || removes(mark, "reject") || mergesUp(mark, "accept") || mergesUp(mark, "reject") || isStructureChange(mark);
|
|
216
|
-
/**
|
|
217
|
-
* The claims that can change what completing a container builds: the
|
|
218
|
-
* container's own and each child's that `changesBuild` names, among those
|
|
219
|
-
* `isPending` keeps, and each pending join a child goes with, which takes
|
|
220
|
-
* the child out of the container when it lands. `claimsOf` reads a node's
|
|
221
|
-
* standing claims, decided ones included, since a follower's own claim can
|
|
222
|
-
* be decided while its join stays pending; `joinOf` gives the pending join
|
|
223
|
-
* a child's link names, as placement reads it, or null.
|
|
224
|
-
*
|
|
225
|
-
* @internal
|
|
226
|
-
*/
|
|
227
|
-
const buildClaimsOf = (container, children, claimsOf, isPending, joinOf) => [...container === null ? [] : claimsOf(container).filter((mark) => isPending(mark) && changesBuild(mark, "container")), ...children.flatMap((child) => claimsOf(child).flatMap((mark) => {
|
|
228
|
-
const follows = followsOf(mark);
|
|
229
|
-
const join = follows === void 0 ? null : joinOf(follows, child);
|
|
230
|
-
return [...isPending(mark) && changesBuild(mark, "child") ? [mark] : [], ...join ? [join] : []];
|
|
231
|
-
}))];
|
|
232
|
-
const joinKeysOf = (marks) => new Set(marks.flatMap((mark) => mark.kind === "join" ? [linkOf(mark)] : []));
|
|
233
|
-
const followerPassage = (children, claimsOf) => {
|
|
234
|
-
const blocks = textBlocksIn(children, []);
|
|
235
|
-
const firstHolders = /* @__PURE__ */ new Map();
|
|
236
|
-
const firstJoins = /* @__PURE__ */ new Map();
|
|
237
|
-
const firstIn = (found, key) => {
|
|
238
|
-
while (!found.has(key)) {
|
|
239
|
-
const next = blocks.next();
|
|
240
|
-
if (next.done) break;
|
|
241
|
-
countLedgerWork("joinScans");
|
|
242
|
-
for (const mark of claimsOf(next.value.node)) {
|
|
243
|
-
if (mark.kind !== "join" && mark.kind !== "joined") continue;
|
|
244
|
-
const link = linkOf(mark);
|
|
245
|
-
const suggestion = incarnationOf(mark);
|
|
246
|
-
if (!firstHolders.has(link)) firstHolders.set(link, {
|
|
247
|
-
kind: mark.kind,
|
|
248
|
-
path: next.value.path
|
|
249
|
-
});
|
|
250
|
-
if (mark.kind === "join" && !firstJoins.has(suggestion)) firstJoins.set(suggestion, next.value.path);
|
|
251
|
-
}
|
|
252
|
-
}
|
|
253
|
-
return found.get(key);
|
|
254
|
-
};
|
|
255
|
-
const followsAt = (path) => {
|
|
256
|
-
const keys = /* @__PURE__ */ new Set();
|
|
257
|
-
let level = children;
|
|
258
|
-
for (const index of path) {
|
|
259
|
-
const node = getDefined(level.at(index));
|
|
260
|
-
for (const mark of claimsOf(node)) {
|
|
261
|
-
const key = followsOf(mark);
|
|
262
|
-
if (key) keys.add(key);
|
|
263
|
-
}
|
|
264
|
-
level = node.children ?? [];
|
|
265
|
-
}
|
|
266
|
-
return keys;
|
|
267
|
-
};
|
|
268
|
-
return {
|
|
269
|
-
/** Whether the block at `path` or an element above it goes with a join. */
|
|
270
|
-
goesWithJoin: (path) => followsAt(path).size > 0,
|
|
271
|
-
passesOver: (path, keys) => {
|
|
272
|
-
if (keys.size === 0) return false;
|
|
273
|
-
const follows = followsAt(path);
|
|
274
|
-
if (follows.size === 0) return false;
|
|
275
|
-
const suggestions = new Set([...keys].map(incarnationOfLink));
|
|
276
|
-
return [...follows].some((key) => {
|
|
277
|
-
const suggestion = incarnationOfLink(key);
|
|
278
|
-
if (!suggestions.has(suggestion)) return false;
|
|
279
|
-
const first = firstIn(firstJoins, suggestion);
|
|
280
|
-
if (!first || !PathApi.isBefore(path, first)) return false;
|
|
281
|
-
return isLive(key, firstIn(firstHolders, key)?.kind);
|
|
282
|
-
});
|
|
283
|
-
}
|
|
284
|
-
};
|
|
285
|
-
};
|
|
286
|
-
const joinPassage = (children, claimsOf, survives) => ({
|
|
287
|
-
...followerPassage(children, claimsOf),
|
|
288
|
-
/**
|
|
289
|
-
* Whether the join on the text block at `path` stops before `from`: a
|
|
290
|
-
* surviving element that does not unwrap encloses the block and not
|
|
291
|
-
* `from`, which makes it the join's boundary.
|
|
292
|
-
*/
|
|
293
|
-
stopsBefore: (from, path) => {
|
|
294
|
-
const shared = PathApi.common(from, path).length;
|
|
295
|
-
let level = children;
|
|
296
|
-
for (const [depth, index] of path.slice(0, -1).entries()) {
|
|
297
|
-
const node = getDefined(level.at(index));
|
|
298
|
-
if (depth >= shared && survives(node) && !claimsOf(node).some((mark) => mark.kind === "unwrap")) return true;
|
|
299
|
-
level = node.children ?? [];
|
|
300
|
-
}
|
|
301
|
-
return false;
|
|
302
|
-
}
|
|
303
|
-
});
|
|
304
|
-
function* textBlocksIn(nodes, base) {
|
|
305
|
-
for (let index = 0; index < nodes.length; index += 1) {
|
|
306
|
-
const node = getDefined(nodes.at(index));
|
|
307
|
-
if (isText(node)) continue;
|
|
308
|
-
if (isTextBlock(node)) yield {
|
|
309
|
-
node,
|
|
310
|
-
path: [...base, index]
|
|
311
|
-
};
|
|
312
|
-
else yield* textBlocksIn(node.children ?? [], [...base, index]);
|
|
313
|
-
}
|
|
314
|
-
}
|
|
315
|
-
const textBlocksOf = (children) => {
|
|
316
|
-
const blocks = [];
|
|
317
|
-
const collect = (nodes, ancestors, base) => {
|
|
318
|
-
nodes.forEach((node, index) => {
|
|
319
|
-
const path = [...base, index];
|
|
320
|
-
if (isText(node)) return;
|
|
321
|
-
if (isTextBlock(node)) blocks.push({
|
|
322
|
-
ancestors,
|
|
323
|
-
node,
|
|
324
|
-
path
|
|
325
|
-
});
|
|
326
|
-
else collect(node.children ?? [], [...ancestors, node], path);
|
|
327
|
-
});
|
|
328
|
-
};
|
|
329
|
-
collect(children, [], []);
|
|
330
|
-
return blocks;
|
|
331
|
-
};
|
|
332
|
-
const cutIndexIn = (value, dependencies, schema) => {
|
|
333
|
-
const ownedRootsDropLate = !!schema && schemaHasContentRoots(schema.ownership);
|
|
334
|
-
let index;
|
|
335
|
-
const read = () => {
|
|
336
|
-
if (index) return index;
|
|
337
|
-
const fragments = /* @__PURE__ */ new Map();
|
|
338
|
-
const copies = /* @__PURE__ */ new Map();
|
|
339
|
-
const visit = (nodes, block, root) => {
|
|
340
|
-
for (const node of nodes) {
|
|
341
|
-
for (const tag of cutsOf(node)) {
|
|
342
|
-
if (tag.side === "end") {
|
|
343
|
-
fragments.set(tag.cut, {
|
|
344
|
-
block,
|
|
345
|
-
node,
|
|
346
|
-
root
|
|
347
|
-
});
|
|
348
|
-
continue;
|
|
349
|
-
}
|
|
350
|
-
const copied = splitCopiesOf(dependencies.marks(node), tag.change);
|
|
351
|
-
const entry = {
|
|
352
|
-
copied,
|
|
353
|
-
cut: tag,
|
|
354
|
-
right: {
|
|
355
|
-
block: block.node,
|
|
356
|
-
root
|
|
357
|
-
}
|
|
358
|
-
};
|
|
359
|
-
for (const key of copied) {
|
|
360
|
-
const list = copies.get(key);
|
|
361
|
-
if (list) list.push(entry);
|
|
362
|
-
else copies.set(key, [entry]);
|
|
363
|
-
}
|
|
364
|
-
}
|
|
365
|
-
if (node.children) visit(node.children, block, root);
|
|
366
|
-
}
|
|
367
|
-
};
|
|
368
|
-
for (const [root, children] of [["main", value.children], ...Object.entries(value.roots ?? {})]) for (const block of textBlocksOf(children)) visit(block.node.children ?? [], block, root);
|
|
369
|
-
index = {
|
|
370
|
-
copies,
|
|
371
|
-
fragments
|
|
372
|
-
};
|
|
373
|
-
return index;
|
|
374
|
-
};
|
|
375
|
-
return {
|
|
376
|
-
copiedFrom: (key) => read().copies.get(key) ?? [],
|
|
377
|
-
...ownedRootsDropLate ? {} : { leftOf: (cut) => read().fragments.get(cut) }
|
|
378
|
-
};
|
|
379
|
-
};
|
|
380
|
-
const pastFollowers = (children, from, claimsOf) => {
|
|
381
|
-
let end = from;
|
|
382
|
-
while (end < children.length && claimsOf(getDefined(children.at(end))).some((mark) => followsOf(mark) !== void 0)) end += 1;
|
|
383
|
-
return end;
|
|
384
|
-
};
|
|
385
|
-
const subtreesOf = (roots) => {
|
|
386
|
-
const nodes = /* @__PURE__ */ new WeakSet();
|
|
387
|
-
const add = (node) => {
|
|
388
|
-
nodes.add(node);
|
|
389
|
-
for (const child of node.children ?? []) add(child);
|
|
390
|
-
};
|
|
391
|
-
roots.forEach(add);
|
|
392
|
-
return nodes;
|
|
393
|
-
};
|
|
394
|
-
/**
|
|
395
|
-
* The landings phase two made, applied in order to a model of the stored
|
|
396
|
-
* elements, keeping each one that moves a block past a line the resolved
|
|
397
|
-
* tree shows, or out of an element it shows. A landing that passes only
|
|
398
|
-
* lines it does not show already shows where the stored order puts it, and
|
|
399
|
-
* so do all of them when the elements the tree shows keep their stored order
|
|
400
|
-
* and nesting.
|
|
401
|
-
*/
|
|
402
|
-
const placementsOf = (children, landings, shows) => {
|
|
403
|
-
if (landings.length === 0) return [];
|
|
404
|
-
const items = /* @__PURE__ */ new Map();
|
|
405
|
-
const top = {
|
|
406
|
-
children: [],
|
|
407
|
-
node: {},
|
|
408
|
-
parent: null
|
|
409
|
-
};
|
|
410
|
-
const build = (nodes, parent) => {
|
|
411
|
-
for (const node of nodes) {
|
|
412
|
-
if (isText(node)) continue;
|
|
413
|
-
const item = {
|
|
414
|
-
children: [],
|
|
415
|
-
node,
|
|
416
|
-
parent
|
|
417
|
-
};
|
|
418
|
-
items.set(node, item);
|
|
419
|
-
parent.children.push(item);
|
|
420
|
-
if (!isTextBlock(node)) build(node.children ?? [], item);
|
|
421
|
-
}
|
|
422
|
-
};
|
|
423
|
-
build(children, top);
|
|
424
|
-
const linesOf = (item) => item !== top && isTextBlock(item.node) ? [item] : item.children.flatMap(linesOf);
|
|
425
|
-
const holds = (outer, inner) => {
|
|
426
|
-
for (let at = inner; at; at = at.parent) if (at === outer) return true;
|
|
427
|
-
return false;
|
|
428
|
-
};
|
|
429
|
-
const outline = (item, into = []) => {
|
|
430
|
-
for (const child of item.children) {
|
|
431
|
-
const shown = shows(child.node);
|
|
432
|
-
if (shown) into.push(child.node);
|
|
433
|
-
outline(child, into);
|
|
434
|
-
if (shown) into.push(null);
|
|
435
|
-
}
|
|
436
|
-
return into;
|
|
437
|
-
};
|
|
438
|
-
const stored = outline(top);
|
|
439
|
-
const placements = [];
|
|
440
|
-
for (const placement of landings) {
|
|
441
|
-
const item = items.get(placement.node);
|
|
442
|
-
const target = items.get(placement.after);
|
|
443
|
-
if (!item || !target || holds(item, target) || holds(target, item)) continue;
|
|
444
|
-
const lines = linesOf(top);
|
|
445
|
-
const own = linesOf(item);
|
|
446
|
-
const first = own[0] ? lines.indexOf(own[0]) : -1;
|
|
447
|
-
const landing = lines.indexOf(getDefined(linesOf(target).at(-1))) + 1;
|
|
448
|
-
const from = getDefined(item.parent);
|
|
449
|
-
const into = getDefined(target.parent);
|
|
450
|
-
if (first === -1 || !((first < landing ? lines.slice(first + own.length, landing) : lines.slice(landing, first)).some((line) => shows(line.node)) || from !== into && from !== top && shows(from.node))) continue;
|
|
451
|
-
from.children.splice(from.children.indexOf(item), 1);
|
|
452
|
-
into.children.splice(into.children.indexOf(target) + 1, 0, item);
|
|
453
|
-
item.parent = into;
|
|
454
|
-
placements.push(placement);
|
|
455
|
-
}
|
|
456
|
-
const shown = outline(top);
|
|
457
|
-
return shown.length === stored.length && shown.every((node, index) => node === stored[index]) ? [] : placements;
|
|
458
|
-
};
|
|
459
|
-
/**
|
|
460
|
-
* The only implementation of accept and reject. Phase one finds, against the
|
|
461
|
-
* input document, where each accepted join or rejected split lands: it merges
|
|
462
|
-
* its block into the nearest preceding text block the decision keeps, never
|
|
463
|
-
* leaving a container the decision keeps. Phase two rebuilds the document:
|
|
464
|
-
* text goes when one of its insert marks is rejected or one of its delete
|
|
465
|
-
* marks is accepted, a block goes when its own mark says so and nothing
|
|
466
|
-
* inside it survives, and an accepted unwrap or rejected wrap lifts the
|
|
467
|
-
* block's children. Decided format marks keep or restore their values.
|
|
468
|
-
* Undecided marks stay.
|
|
469
|
-
*/
|
|
470
|
-
const resolveAuthoredChildren = (given, outcome, schema = null, root = "main", options = {}) => readingCovered({
|
|
471
|
-
cover: () => schema && coverStoredValues(schema.ownership, given),
|
|
472
|
-
read: () => getDefined(resolveIn(given, outcome, schema, root, options, null))
|
|
473
|
-
});
|
|
474
|
-
const lineHandover = (keys, decidedPropsOf) => {
|
|
475
|
-
const taken = /* @__PURE__ */ new Map();
|
|
476
|
-
const sources = /* @__PURE__ */ new Map();
|
|
477
|
-
const valuesOf = (node) => {
|
|
478
|
-
const passed = taken.get(node);
|
|
479
|
-
if (passed) return passed;
|
|
480
|
-
const props = decidedPropsOf(node);
|
|
481
|
-
return Object.fromEntries([...keys].flatMap((key) => Object.hasOwn(props, key) ? [[key, props[key]]] : []));
|
|
482
|
-
};
|
|
483
|
-
return {
|
|
484
|
-
keys,
|
|
485
|
-
takeFrom: (node, source) => {
|
|
486
|
-
sources.set(node, source);
|
|
487
|
-
},
|
|
488
|
-
pass: (node, line) => {
|
|
489
|
-
if (keys.size > 0) taken.set(line, valuesOf(sources.get(node) ?? node));
|
|
490
|
-
},
|
|
491
|
-
takenBy: (line) => taken.get(line),
|
|
492
|
-
apply: (props, values) => {
|
|
493
|
-
let next = null;
|
|
494
|
-
for (const key of keys) {
|
|
495
|
-
const has = Object.hasOwn(values, key);
|
|
496
|
-
if (has === Object.hasOwn(props, key) && (!has || jsonEqual(props[key], values[key]))) continue;
|
|
497
|
-
next ??= { ...props };
|
|
498
|
-
if (has) next[key] = values[key];
|
|
499
|
-
else delete next[key];
|
|
500
|
-
}
|
|
501
|
-
return next ?? props;
|
|
502
|
-
}
|
|
503
|
-
};
|
|
504
|
-
};
|
|
505
|
-
const resolveIn = (given, outcome, schema, root, options, probe) => {
|
|
506
|
-
const { facts = NO_FACTS, dependencies = createDependencies(facts), stores = false, withdraws = false, part, removed, site = [], cutIndex } = options;
|
|
507
|
-
const children = removed ? given.filter((node) => !removed.has(node)) : given;
|
|
508
|
-
const outcomeOf = typeof outcome === "string" ? () => outcome : outcome;
|
|
509
|
-
const pending = (node) => standingClaimsOf(node, facts, dependencies).filter((mark) => mark.kind !== "joined");
|
|
510
|
-
const isInserted = (node) => pending(node).some((mark) => mark.kind === "insert");
|
|
511
|
-
const keepsRejectedDeletion = (mark) => stores && !withdraws && mark.kind === "delete" && facts.insertedIncarnations().has(incarnationOf(mark));
|
|
512
|
-
const keptMembers = (node, pendingMarks, keeps, keepsSpares) => {
|
|
513
|
-
const pendingSet = new Set(pendingMarks);
|
|
514
|
-
const stored = readMembers(node);
|
|
515
|
-
const contextual = pendingMarks.filter((mark) => !stored.includes(mark));
|
|
516
|
-
const resting = contextual.filter((mark) => decisionOf(mark) === "keep");
|
|
517
|
-
const contextIntact = resting.length === contextual.length;
|
|
518
|
-
const kept = stored.flatMap((member) => {
|
|
519
|
-
if (member.kind === "held" || member.kind === "as") return stores ? [member] : [];
|
|
520
|
-
if (member.kind === "reserve") return stores && keepsSpares ? [member] : [];
|
|
521
|
-
if (member.kind === "in") return resting.length > 0 && contextIntact ? [member] : [];
|
|
522
|
-
if (isJoinAside(facts, member)) return stores ? [member] : [];
|
|
523
|
-
if (decidedJoinLeavesInPlace(member, (mark) => isRejected(facts, mark), (mark) => resultOf(mark) !== "keep")) return [];
|
|
524
|
-
if (member.kind !== "joined" && !pendingSet.has(member) || keeps(member)) return [member];
|
|
525
|
-
return resultOf(member) === "reject" && keepsRejectedDeletion(member) ? [heldOf(member)] : [];
|
|
526
|
-
});
|
|
527
|
-
if (resting.length === 0 || contextIntact && kept.some((member) => member.kind === "insert")) return kept;
|
|
528
|
-
return readMembers(dependencies.props(withMembers({}, kept), [...resting, ...kept.filter(isClaim)]));
|
|
529
|
-
};
|
|
530
|
-
const contentOf = (type) => schema?.content(type, root) ?? null;
|
|
531
|
-
const pools = /* @__PURE__ */ new Map();
|
|
532
|
-
const rootSpares = site.length === 0 ? facts.reserves(root) : [];
|
|
533
|
-
/** `container`'s pool, or the root's; `from` adds the spares a join merged. */
|
|
534
|
-
const poolOf = (container, from = container) => {
|
|
535
|
-
const key = container ?? pools;
|
|
536
|
-
let pool = pools.get(key);
|
|
537
|
-
if (!pool) {
|
|
538
|
-
pool = {
|
|
539
|
-
spares: container ? [...sparesIn(container)] : rootSpares.map((record) => ({
|
|
540
|
-
...record,
|
|
541
|
-
type: null
|
|
542
|
-
})),
|
|
543
|
-
used: /* @__PURE__ */ new Set()
|
|
544
|
-
};
|
|
545
|
-
pools.set(key, pool);
|
|
546
|
-
}
|
|
547
|
-
if (from && from !== container) {
|
|
548
|
-
for (const spare of sparesIn(from)) if (!pool.spares.includes(spare)) pool.spares.push(spare);
|
|
549
|
-
}
|
|
550
|
-
return pool;
|
|
551
|
-
};
|
|
552
|
-
const complete = (nodes, at, startLevel, occupant, listPart, pool, commit) => {
|
|
553
|
-
if (!schema?.complete) return {
|
|
554
|
-
built: [],
|
|
555
|
-
children: nodes.length === 0 && at.length > 0 && startLevel.some(isText) ? [{ text: "" }] : mergeTextsWithEqualProps(nodes),
|
|
556
|
-
taken: []
|
|
557
|
-
};
|
|
558
|
-
const tentative = new Set(pool.used);
|
|
559
|
-
const takenAt = /* @__PURE__ */ new Map();
|
|
560
|
-
const completion = schema.complete(nodes, at, root, occupant, listPart, pool.spares.length === 0 ? void 0 : (nodeType, slot) => {
|
|
561
|
-
const [parentType = null, ...outer] = at.map(typeOf);
|
|
562
|
-
const spare = takeSpare(pool.spares, parentType, nodeType, slot, tentative);
|
|
563
|
-
if (!spare) return null;
|
|
564
|
-
takenAt.set(slotKeyOf(slot), spare.key);
|
|
565
|
-
return heldNode(schema.ownership, spare.node, {
|
|
566
|
-
outerTypes: outer.flatMap((outerType) => outerType ?? []),
|
|
567
|
-
parentType,
|
|
568
|
-
root
|
|
569
|
-
});
|
|
570
|
-
});
|
|
571
|
-
const taken = completion.built.flatMap(({ slot }) => {
|
|
572
|
-
const key = takenAt.get(slotKeyOf(slot));
|
|
573
|
-
return key ? [key] : [];
|
|
574
|
-
});
|
|
575
|
-
if (commit) for (const key of taken) pool.used.add(key);
|
|
576
|
-
return {
|
|
577
|
-
...completion,
|
|
578
|
-
taken
|
|
579
|
-
};
|
|
580
|
-
};
|
|
581
|
-
const decided = /* @__PURE__ */ new Set();
|
|
582
|
-
const unstored = /* @__PURE__ */ new Set();
|
|
583
|
-
const waits = /* @__PURE__ */ new Set();
|
|
584
|
-
const landings = /* @__PURE__ */ new Map();
|
|
585
|
-
const diagnostics = [];
|
|
586
|
-
const origins = /* @__PURE__ */ new Map();
|
|
587
|
-
const touched = /* @__PURE__ */ new WeakSet();
|
|
588
|
-
const dirtyChildren = /* @__PURE__ */ new WeakMap();
|
|
589
|
-
let unplaceable = false;
|
|
590
|
-
const decisionOf = (mark) => isAccepted(facts, mark) ? "accept" : isRejected(facts, mark) ? "reject" : outcomeOf(mark.change);
|
|
591
|
-
const resultOf = (mark) => {
|
|
592
|
-
if (isAccepted(facts, mark)) return "accept";
|
|
593
|
-
const result = outcomeOf(mark.change);
|
|
594
|
-
if (result !== "keep") decided.add(mark.change);
|
|
595
|
-
return result;
|
|
596
|
-
};
|
|
597
|
-
const wait = (marks) => {
|
|
598
|
-
for (const mark of marks) if (decisionOf(mark) === "keep") waits.add(mark.change);
|
|
599
|
-
};
|
|
600
|
-
const waitOnPlaceChanges = (at) => {
|
|
601
|
-
for (const node of at) wait(pending(node).filter(isPlaceChange));
|
|
602
|
-
};
|
|
603
|
-
const subtreeMarks = (node) => [...pending(node), ...(node.children ?? []).flatMap(subtreeMarks)];
|
|
604
|
-
const retainedJoins = /* @__PURE__ */ new Set();
|
|
605
|
-
const retainedFollowers = /* @__PURE__ */ new Map();
|
|
606
|
-
const followerKeyOf = (mark) => JSON.stringify([
|
|
607
|
-
mark.kind,
|
|
608
|
-
incarnationOf(mark),
|
|
609
|
-
followsOf(mark)
|
|
610
|
-
]);
|
|
611
|
-
const retainFollowers = (node, marks) => {
|
|
612
|
-
if (marks.length === 0) return;
|
|
613
|
-
retainedFollowers.set(node, /* @__PURE__ */ new Set([...retainedFollowers.get(node) ?? [], ...marks.map(followerKeyOf)]));
|
|
614
|
-
};
|
|
615
|
-
const track = (node, original) => {
|
|
616
|
-
if (original) origins.set(node, original);
|
|
617
|
-
return node;
|
|
618
|
-
};
|
|
619
|
-
const ownRemovalMemo = /* @__PURE__ */ new WeakMap();
|
|
620
|
-
const ownMarkRemoves = (node) => {
|
|
621
|
-
let value = ownRemovalMemo.get(node);
|
|
622
|
-
if (value === void 0) {
|
|
623
|
-
value = pending(node).some((mark) => removes(mark, resultOf(mark)));
|
|
624
|
-
ownRemovalMemo.set(node, value);
|
|
625
|
-
}
|
|
626
|
-
return value;
|
|
627
|
-
};
|
|
628
|
-
const gridPart = schema ? gridPartsOf(schema.ownership) : () => false;
|
|
629
|
-
const takesWhole = (node) => ownMarkRemoves(node) && gridPart(node);
|
|
630
|
-
const decidedWholeByGridPart = (mark, above) => (mark.kind === "insert" || mark.kind === "delete") && above.some((ancestor) => gridPart(ancestor) && pending(ancestor).some((outer) => outer.kind === mark.kind && outer.change === mark.change));
|
|
631
|
-
const gridHolder = schema ? gridHoldersOf(schema.ownership) : () => false;
|
|
632
|
-
const { survives } = survivalUnder(ownMarkRemoves, gridPart);
|
|
633
|
-
const reading = {
|
|
634
|
-
accepted: (member) => isAccepted(facts, member),
|
|
635
|
-
landed: facts.landed,
|
|
636
|
-
outcome: (tag) => isRejected(facts, tag) ? "reject" : outcomeOf(tag.change),
|
|
637
|
-
output: elementSplitOutput(schema?.ownership ?? null)
|
|
638
|
-
};
|
|
639
|
-
const decidedPropsOf = (node) => decideFormats(propsOf(node), pending(node), reading)?.props ?? propsOf(node);
|
|
640
|
-
/** The place of a node under `chain`, its containers nearest first. */
|
|
641
|
-
const placeUnder = (chain) => {
|
|
642
|
-
const [parent = null, ...outer] = chain.map((node) => typeOf(decidedPropsOf(node)));
|
|
643
|
-
return {
|
|
644
|
-
outerTypes: outer.flatMap((type) => type ?? []),
|
|
645
|
-
parentType: parent,
|
|
646
|
-
root
|
|
647
|
-
};
|
|
648
|
-
};
|
|
649
|
-
/** One side of a cut, from the claims its verdict site already read. */
|
|
650
|
-
const halfOf = (node, claims, place) => {
|
|
651
|
-
const formats = decideFormats(propsOf(node), claims, reading);
|
|
652
|
-
const values = formats?.props ?? propsOf(node);
|
|
653
|
-
return {
|
|
654
|
-
decided: values,
|
|
655
|
-
splitHistory: splitHistoryOf(claims),
|
|
656
|
-
node,
|
|
657
|
-
pending: claims.filter((mark) => decisionOf(mark) === "keep"),
|
|
658
|
-
readsCopies: formats?.readsCopies ?? /* @__PURE__ */ new Set(),
|
|
659
|
-
props: schema ? heldProps(schema.ownership, values, {
|
|
660
|
-
...place,
|
|
661
|
-
text: false
|
|
662
|
-
}) : values
|
|
663
|
-
};
|
|
664
|
-
};
|
|
665
|
-
const pendingOf = typeof outcome === "string" ? null : (node) => pending(node).filter((mark) => decisionOf(mark) === "keep");
|
|
666
|
-
const valuesOf = (props) => {
|
|
667
|
-
const { [AUTHORED_MARKS_KEY]: _marks, ...values } = props;
|
|
668
|
-
return values;
|
|
669
|
-
};
|
|
670
|
-
const handover = lineHandover(schema ? handoverKeysOf(schema.ownership) : /* @__PURE__ */ new Set(), decidedPropsOf);
|
|
671
|
-
const splitDropped = schema ? splitDroppedKeysOf(schema.ownership) : /* @__PURE__ */ new Set();
|
|
672
|
-
const otherValuesOf = (props) => {
|
|
673
|
-
const values = valuesOf(props);
|
|
674
|
-
for (const key of splitDropped) delete values[key];
|
|
675
|
-
return values;
|
|
676
|
-
};
|
|
677
|
-
const probed = /* @__PURE__ */ new Map();
|
|
678
|
-
const probeUnder = (assignment, key, left, rightKeys) => {
|
|
679
|
-
const id = [...assignment].map(([change, action]) => `${action}:${change}`).join(" ");
|
|
680
|
-
const known = probed.get(key)?.get(id);
|
|
681
|
-
if (known) return known;
|
|
682
|
-
const run = {
|
|
683
|
-
key,
|
|
684
|
-
left,
|
|
685
|
-
rightKeys,
|
|
686
|
-
settled: void 0
|
|
687
|
-
};
|
|
688
|
-
resolveIn(given, (change) => assignment.get(change) ?? outcomeOf(change), schema, root, {
|
|
689
|
-
...options,
|
|
690
|
-
dependencies: createDependencies(facts),
|
|
691
|
-
facts
|
|
692
|
-
}, run);
|
|
693
|
-
const found = getDefined(run.settled);
|
|
694
|
-
probed.set(key, (probed.get(key) ?? /* @__PURE__ */ new Map()).set(id, found));
|
|
695
|
-
return found;
|
|
696
|
-
};
|
|
697
|
-
const joinKeeps = (key, halves, rightKeys) => {
|
|
698
|
-
const { left, right } = halves;
|
|
699
|
-
const fromLeft = leftSupplies(schema?.ownership ?? null, halves);
|
|
700
|
-
const later = Object.fromEntries([.../* @__PURE__ */ new Set([...Object.keys(valuesOf(left.decided)), ...Object.keys(valuesOf(right.decided))])].flatMap((name) => {
|
|
701
|
-
const from = fromLeft(name) ? left.decided : right.decided;
|
|
702
|
-
return Object.hasOwn(from, name) ? [[name, from[name]]] : [];
|
|
703
|
-
}));
|
|
704
|
-
return jsonEqual(valuesOf(decidedPropsOf(joinedShell(left.node, right.node, typeof key === "string" ? key : null, dependencies, (name) => !rightKeys.has(name)))), later);
|
|
705
|
-
};
|
|
706
|
-
const rightKeysOf = (halves) => {
|
|
707
|
-
const fromLeft = leftSupplies(schema?.ownership ?? null, halves);
|
|
708
|
-
return new Set([...Object.keys(propsOf(halves.right.node)), ...halves.right.pending.flatMap((mark) => mark.kind === "format" ? [mark.key] : [])].filter((name) => !fromLeft(name)));
|
|
709
|
-
};
|
|
710
|
-
const cutVerdict = (key, storedLeft, halves, around) => {
|
|
711
|
-
let rightKeys;
|
|
712
|
-
const undecided = (mark) => !decidedWholeByGridPart(mark, around.place);
|
|
713
|
-
const unheld = (half) => ({
|
|
714
|
-
...half,
|
|
715
|
-
pending: half.pending.filter(undecided)
|
|
716
|
-
});
|
|
717
|
-
const result = verdictOf(schema?.ownership ?? null, {
|
|
718
|
-
...halves,
|
|
719
|
-
left: unheld(halves.left),
|
|
720
|
-
right: unheld(halves.right)
|
|
721
|
-
}, around, {
|
|
722
|
-
pendingOf: pendingOf && ((node) => pendingOf(node).filter(undecided)),
|
|
723
|
-
probe: probe ? null : (assignment) => probeUnder(assignment, key, storedLeft, rightKeys ??= rightKeysOf(halves)),
|
|
724
|
-
survives
|
|
725
|
-
});
|
|
726
|
-
if (probe?.key === key) probe.settled = probe.left !== storedLeft ? { verdict: "apart" } : "verdict" in result && result.verdict === "together" && !joinKeeps(key, halves, probe.rightKeys) ? { waits: [] } : result;
|
|
727
|
-
if ("waits" in result) {
|
|
728
|
-
for (const change of result.waits) waits.add(change);
|
|
729
|
-
return "wait";
|
|
730
|
-
}
|
|
731
|
-
return result.verdict;
|
|
732
|
-
};
|
|
733
|
-
const contentMarksIn = (node) => [...ownMarkRemoves(node) ? [] : pending(node).filter((mark) => mark.kind === "insert" || mark.kind === "delete"), ...(node.children ?? []).flatMap(contentMarksIn)];
|
|
734
|
-
const structureOf = (node) => {
|
|
735
|
-
let editingJoin = false;
|
|
736
|
-
let join = false;
|
|
737
|
-
let unwrap = false;
|
|
738
|
-
for (const mark of pending(node)) {
|
|
739
|
-
const result = resultOf(mark);
|
|
740
|
-
if (mergesUp(mark, result)) {
|
|
741
|
-
join = true;
|
|
742
|
-
if (isEditingChange(mark.change)) editingJoin = true;
|
|
743
|
-
}
|
|
744
|
-
if (mark.kind === "unwrap" && result === "accept" || mark.kind === "wrap" && result === "reject") unwrap = true;
|
|
745
|
-
}
|
|
746
|
-
return {
|
|
747
|
-
editingJoin,
|
|
748
|
-
join,
|
|
749
|
-
unwrap
|
|
750
|
-
};
|
|
751
|
-
};
|
|
752
|
-
const outsideTakenPart = ({ ancestors }) => !ancestors.some(takesWhole);
|
|
753
|
-
const blocks = textBlocksOf(children).filter(outsideTakenPart);
|
|
754
|
-
const mergedInto = /* @__PURE__ */ new Map();
|
|
755
|
-
const mergedBlocks = /* @__PURE__ */ new Map();
|
|
756
|
-
const emptiedTargets = /* @__PURE__ */ new Set();
|
|
757
|
-
const standsFor = /* @__PURE__ */ new Map();
|
|
758
|
-
const standsIn = /* @__PURE__ */ new Set();
|
|
759
|
-
const lastIn = (links) => (node) => {
|
|
760
|
-
let current = node;
|
|
761
|
-
for (let next = links.get(current); next; next = links.get(current)) current = next;
|
|
762
|
-
return current;
|
|
763
|
-
};
|
|
764
|
-
const finalOf = lastIn(mergedInto);
|
|
765
|
-
const standingOf = lastIn(standsFor);
|
|
766
|
-
const keepsContent = (target, join) => {
|
|
767
|
-
const { liveContent: liveAt } = survivalUnder((node) => pending(node).some((mark) => removes(mark, resultOf(mark)) && (mark.kind !== "delete" || deletesBeforeJoin(mark, join))), gridPart);
|
|
768
|
-
return (target.children ?? []).some(liveAt) || (mergedBlocks.get(target) ?? []).some((block) => (block.children ?? []).some(liveAt));
|
|
769
|
-
};
|
|
770
|
-
const { liveContent: keptContent } = survivalUnder((node) => pending(node).some((mark) => removes(mark, decisionOf(mark)) || (mark.kind === "insert" || mark.kind === "delete") && decisionOf(mark) === "keep"), gridPart);
|
|
771
|
-
const joinOf = (node) => {
|
|
772
|
-
const marks = pending(node).filter((mark) => mergesUp(mark, resultOf(mark)));
|
|
773
|
-
return {
|
|
774
|
-
at: Math.min(...marks.map((mark) => mark.at)),
|
|
775
|
-
own: new Set(marks.map(incarnationOf))
|
|
776
|
-
};
|
|
777
|
-
};
|
|
778
|
-
const rejoinsSplit = (node) => pending(node).some((mark) => mark.kind === "split" && resultOf(mark) === "reject");
|
|
779
|
-
const rejectedSplitOf = (claims) => claims.some((mark) => mark.kind === "join" && resultOf(mark) === "accept") ? void 0 : claims.find((mark) => mark.kind === "split" && mark.cut === void 0 && resultOf(mark) === "reject");
|
|
780
|
-
const rejoined = /* @__PURE__ */ new Map();
|
|
781
|
-
/**
|
|
782
|
-
* The left half a rejected block split rejoins `into` with, or null when
|
|
783
|
-
* the halves stay apart or wait. `own` and `target` are the blocks'
|
|
784
|
-
* claims, which phase one already read.
|
|
785
|
-
*/
|
|
786
|
-
const rejoinOf = (cut, node, own, into, target, ancestors) => {
|
|
787
|
-
const chain = [...[...ancestors].reverse(), ...site];
|
|
788
|
-
const place = placeUnder(chain);
|
|
789
|
-
const left = halfOf(into, target, place);
|
|
790
|
-
const forced = own.some((mark) => mark.kind === "format" && mark.key === "type" && mark.change === cut.change) || !schema?.continuationType ? null : schema.continuationType({
|
|
791
|
-
...left.props,
|
|
792
|
-
children: into.children ?? []
|
|
793
|
-
}, (ancestors.at(-1)?.children ?? children).indexOf(node), chain, root);
|
|
794
|
-
return cutVerdict(node, into, {
|
|
795
|
-
change: cut.change,
|
|
796
|
-
forced,
|
|
797
|
-
left,
|
|
798
|
-
place,
|
|
799
|
-
right: halfOf(node, own, place)
|
|
800
|
-
}, {
|
|
801
|
-
between: [],
|
|
802
|
-
place: chain
|
|
803
|
-
}) === "together" ? left : null;
|
|
804
|
-
};
|
|
805
|
-
const landingOf = (node, into) => {
|
|
806
|
-
const rejoins = rejoinsSplit(node);
|
|
807
|
-
if (!rejoins && !ownMarkRemoves(into)) return {
|
|
808
|
-
merges: true,
|
|
809
|
-
reads: []
|
|
810
|
-
};
|
|
811
|
-
const reads = (into.children ?? []).some(keptContent) ? [] : (into.children ?? []).flatMap(contentMarksIn);
|
|
812
|
-
return !rejoins || keepsContent(into, joinOf(node)) ? {
|
|
813
|
-
merges: true,
|
|
814
|
-
reads
|
|
815
|
-
} : {
|
|
816
|
-
merges: false,
|
|
817
|
-
reads: [...reads, ...subtreeMarks(into)]
|
|
818
|
-
};
|
|
819
|
-
};
|
|
820
|
-
const emptyLines = /* @__PURE__ */ new Map();
|
|
821
|
-
const lineSpares = /* @__PURE__ */ new Map();
|
|
822
|
-
const landedSpares = /* @__PURE__ */ new Map();
|
|
823
|
-
const emptyLineOf = (host, outer) => {
|
|
824
|
-
let line = emptyLines.get(host);
|
|
825
|
-
if (line === void 0) {
|
|
826
|
-
const props = decidedPropsOf(host);
|
|
827
|
-
const refill = (contentOf(typeOf(props))?.prefix ?? 0) > 0 ? null : complete([], [{
|
|
828
|
-
...props,
|
|
829
|
-
children: []
|
|
830
|
-
}, ...outer], host.children ?? [], () => "kept", void 0, poolOf(host), false);
|
|
831
|
-
const built = refill?.children ?? [];
|
|
832
|
-
line = built.length === 1 && (built[0].children ?? []).every((child) => child.text === "") ? built[0] : null;
|
|
833
|
-
emptyLines.set(host, line);
|
|
834
|
-
if (line && refill) lineSpares.set(host, refill.taken);
|
|
835
|
-
}
|
|
836
|
-
return line;
|
|
837
|
-
};
|
|
838
|
-
const landLine = (host) => {
|
|
839
|
-
const pool = poolOf(host);
|
|
840
|
-
const landed = landedSpares.get(host) ?? /* @__PURE__ */ new Set();
|
|
841
|
-
for (const key of lineSpares.get(host) ?? []) {
|
|
842
|
-
pool.used.add(key);
|
|
843
|
-
landed.add(key);
|
|
844
|
-
}
|
|
845
|
-
landedSpares.set(host, landed);
|
|
846
|
-
};
|
|
847
|
-
const emptiedDepthOf = (ancestors) => {
|
|
848
|
-
const depth = ancestors.findLastIndex(survives);
|
|
849
|
-
const host = ancestors[depth];
|
|
850
|
-
return host && (structureOf(host).unwrap || !(host.children ?? []).some(survives)) ? depth : -1;
|
|
851
|
-
};
|
|
852
|
-
const emptiedPlaceOf = ({ ancestors, node }, depth, split) => {
|
|
853
|
-
const host = ancestors[depth];
|
|
854
|
-
if (structureOf(host).unwrap) return null;
|
|
855
|
-
const outer = [...ancestors.slice(0, depth).toReversed(), ...site];
|
|
856
|
-
const line = emptyLineOf(host, outer);
|
|
857
|
-
if (!line || pending(split).some((mark) => mark.kind === "format" && !splitDropped.has(mark.key)) || !jsonEqual(otherValuesOf(propsOf(line)), otherValuesOf(propsOf(split)))) return null;
|
|
858
|
-
const occupant = ancestors[depth + 1] ?? node;
|
|
859
|
-
const removal = [...(occupant.children ?? []).flatMap(contentMarksIn), ...cutsOf(occupant)];
|
|
860
|
-
const emptying = pending(host);
|
|
861
|
-
const refilling = outer.flatMap((item) => pending(item).filter((mark) => mark.kind === "insert" || isStructureChange(mark)));
|
|
862
|
-
return {
|
|
863
|
-
host,
|
|
864
|
-
line,
|
|
865
|
-
occupant,
|
|
866
|
-
reads: [
|
|
867
|
-
...removal,
|
|
868
|
-
...emptying,
|
|
869
|
-
...refilling
|
|
870
|
-
]
|
|
871
|
-
};
|
|
872
|
-
};
|
|
873
|
-
const holderClaims = (node) => [...pending(node), ...readAuthoredMarks(node).filter(({ kind }) => kind === "joined")];
|
|
874
|
-
const links = linksIn((each) => blocks.forEach(({ node }, index) => each(node, index)), holderClaims, () => true);
|
|
875
|
-
const followers = [];
|
|
876
|
-
const followerOrders = /* @__PURE__ */ new Map();
|
|
877
|
-
let lines = 0;
|
|
878
|
-
const collectFollowers = (nodes) => {
|
|
879
|
-
for (const node of nodes) {
|
|
880
|
-
if (isText(node)) continue;
|
|
881
|
-
const follows = new Set(pending(node).flatMap((mark) => {
|
|
882
|
-
const key = followsOf(mark);
|
|
883
|
-
return key ? [key] : [];
|
|
884
|
-
}));
|
|
885
|
-
if (follows.size > 0) {
|
|
886
|
-
followers.push({
|
|
887
|
-
follows,
|
|
888
|
-
node,
|
|
889
|
-
order: lines
|
|
890
|
-
});
|
|
891
|
-
followerOrders.set(node, lines);
|
|
892
|
-
}
|
|
893
|
-
if (isTextBlock(node)) lines += 1;
|
|
894
|
-
else collectFollowers(node.children ?? []);
|
|
895
|
-
}
|
|
896
|
-
};
|
|
897
|
-
collectFollowers(children);
|
|
898
|
-
const passage = joinPassage(children, holderClaims, survives);
|
|
899
|
-
const precedesJoin = ({ path }, keys) => followers.length > 0 && passage.passesOver(path, keys);
|
|
900
|
-
blocks.forEach(({ ancestors, node }, index) => {
|
|
901
|
-
const { editingJoin, join } = structureOf(node);
|
|
902
|
-
if (!join) return;
|
|
903
|
-
const waited = editingJoin || (node.children ?? []).some(keptContent) ? [] : contentMarksIn(node);
|
|
904
|
-
const land = (effect) => {
|
|
905
|
-
const waiting = waited.filter((mark) => !decidedWholeByGridPart(mark, ancestors));
|
|
906
|
-
if (waiting.some((mark) => decisionOf(mark) === "keep") && pending(node).some((mark) => mark.kind === "join" && isEditingChange(mark.change))) {
|
|
907
|
-
retainedJoins.add(node);
|
|
908
|
-
return;
|
|
909
|
-
}
|
|
910
|
-
wait(waiting);
|
|
911
|
-
effect?.();
|
|
912
|
-
};
|
|
913
|
-
if (!survives(node)) {
|
|
914
|
-
land();
|
|
915
|
-
return;
|
|
916
|
-
}
|
|
917
|
-
const boundary = [...ancestors].reverse().find((ancestor) => survives(ancestor) && !structureOf(ancestor).unwrap) ?? null;
|
|
918
|
-
let target = null;
|
|
919
|
-
const cutFrom = rejoinsSplit(node) ? new Set(pending(node).flatMap((mark) => mark.kind === "insert" ? [incarnationOf(mark)] : [])) : null;
|
|
920
|
-
const rejoins = (candidate) => {
|
|
921
|
-
const removing = pending(candidate).filter((mark) => removes(mark, resultOf(mark)));
|
|
922
|
-
return !!cutFrom && removing.length > 0 && removing.every((mark) => mark.kind === "insert" && cutFrom.has(incarnationOf(mark)));
|
|
923
|
-
};
|
|
924
|
-
const keys = new Set(pending(node).flatMap((mark) => mark.kind === "join" ? [linkOf(mark)] : []));
|
|
925
|
-
let seeksEmptied = !!cutFrom;
|
|
926
|
-
let emptied = null;
|
|
927
|
-
for (let previous = index - 1; previous >= 0; previous -= 1) {
|
|
928
|
-
const candidate = blocks[previous];
|
|
929
|
-
if (boundary && !candidate.ancestors.includes(boundary)) {
|
|
930
|
-
waited.push(...pending(boundary).filter((mark) => mark.kind === "unwrap" || mark.kind === "wrap"));
|
|
931
|
-
break;
|
|
932
|
-
}
|
|
933
|
-
if (emptiedTargets.has(candidate.node)) continue;
|
|
934
|
-
if (!survives(candidate.node) && !rejoins(candidate.node)) {
|
|
935
|
-
const depth = seeksEmptied ? emptiedDepthOf(candidate.ancestors) : -1;
|
|
936
|
-
if (depth >= 0) {
|
|
937
|
-
seeksEmptied = false;
|
|
938
|
-
emptied = emptiedPlaceOf(candidate, depth, node);
|
|
939
|
-
if (emptied) break;
|
|
940
|
-
}
|
|
941
|
-
continue;
|
|
942
|
-
}
|
|
943
|
-
if (precedesJoin(candidate, keys)) continue;
|
|
944
|
-
target = finalOf(candidate.node);
|
|
945
|
-
break;
|
|
946
|
-
}
|
|
947
|
-
const stand = (into) => land(() => {
|
|
948
|
-
emptiedTargets.add(into);
|
|
949
|
-
standsFor.set(into, node);
|
|
950
|
-
standsIn.add(node);
|
|
951
|
-
});
|
|
952
|
-
if (emptied) {
|
|
953
|
-
waited.push(...emptied.reads);
|
|
954
|
-
handover.takeFrom(emptied.occupant, emptied.line);
|
|
955
|
-
landLine(emptied.host);
|
|
956
|
-
stand(emptied.occupant);
|
|
957
|
-
return;
|
|
958
|
-
}
|
|
959
|
-
if (!target) {
|
|
960
|
-
land();
|
|
961
|
-
return;
|
|
962
|
-
}
|
|
963
|
-
const into = target;
|
|
964
|
-
const landing = landingOf(node, into);
|
|
965
|
-
const intoClaims = pending(into);
|
|
966
|
-
waited.push(...intoClaims.filter((mark) => CONTENT_AND_ENCLOSURE_KINDS.has(mark.kind)), ...landing.reads);
|
|
967
|
-
if (!landing.merges) {
|
|
968
|
-
stand(into);
|
|
969
|
-
return;
|
|
970
|
-
}
|
|
971
|
-
const own = pending(node);
|
|
972
|
-
const cut = rejectedSplitOf(own);
|
|
973
|
-
const left = cut && rejoinOf(cut, node, own, into, intoClaims, ancestors);
|
|
974
|
-
if (!cut) waited.push(...editingJoin ? own.filter(shapesMergedLine) : own);
|
|
975
|
-
else if (!left) {
|
|
976
|
-
land();
|
|
977
|
-
return;
|
|
978
|
-
}
|
|
979
|
-
land(() => {
|
|
980
|
-
if (left) rejoined.set(node, left);
|
|
981
|
-
mergedInto.set(node, into);
|
|
982
|
-
mergedBlocks.set(into, [...mergedBlocks.get(into) ?? [], node]);
|
|
983
|
-
});
|
|
984
|
-
});
|
|
985
|
-
if (probe && typeof probe.key !== "string") {
|
|
986
|
-
probe.settled ??= { verdict: survives(probe.left) ? "apart" : "gone" };
|
|
987
|
-
return null;
|
|
988
|
-
}
|
|
989
|
-
const placedAfter = /* @__PURE__ */ new Map();
|
|
990
|
-
const placed = /* @__PURE__ */ new Set();
|
|
991
|
-
const editingClaimOutlivesItsJoin = (mark, order) => {
|
|
992
|
-
const link = getDefined(followsOf(mark));
|
|
993
|
-
const change = changeOfLink(link);
|
|
994
|
-
if (!isEditingChange(mark.change) || resultOf(mark) !== "accept" || isEditingChange(change)) return false;
|
|
995
|
-
if (!isLive(link, links.holderOf(link, order)?.mark.kind)) return true;
|
|
996
|
-
return isKeyedLink(link) && !links.suggestionJoinsOf(link).some((holder) => holder.mark.kind === "join" && survives(holder.node)) && outcomeOf(change) === "keep";
|
|
997
|
-
};
|
|
998
|
-
for (const { follows, node, order } of followers) {
|
|
999
|
-
const claims = pending(node).filter((mark) => followsOf(mark));
|
|
1000
|
-
if (rejoinsSplit(node) || mergedInto.has(node) || standsIn.has(node) || !survives(node)) continue;
|
|
1001
|
-
const source = links.sourceOf(follows, order);
|
|
1002
|
-
if (stores && (!source || !survives(source.node) || decisionOf(source.mark) === "keep")) retainFollowers(node, claims.filter((mark) => editingClaimOutlivesItsJoin(mark, order)));
|
|
1003
|
-
if (!source || !survives(source.node)) continue;
|
|
1004
|
-
const anchor = mergedInto.has(source.node) ? standingOf(finalOf(source.node)) : standsIn.has(source.node) ? standingOf(source.node) : null;
|
|
1005
|
-
if (anchor && resultOf(source.mark) === "accept") {
|
|
1006
|
-
placed.add(node);
|
|
1007
|
-
placedAfter.set(anchor, [...placedAfter.get(anchor) ?? [], node]);
|
|
1008
|
-
continue;
|
|
1009
|
-
}
|
|
1010
|
-
if (emptiedTargets.has(node)) continue;
|
|
1011
|
-
const waiting = claims.filter((mark) => resultOf(mark) === "accept" && links.sourceOf([getDefined(followsOf(mark))], order) !== null);
|
|
1012
|
-
if (waiting.length === 0) continue;
|
|
1013
|
-
if (waiting.some((mark) => isEditingChange(mark.change))) {
|
|
1014
|
-
if (decisionOf(source.mark) === "keep") retainFollowers(node, waiting);
|
|
1015
|
-
} else wait([source.mark]);
|
|
1016
|
-
}
|
|
1017
|
-
const joinedCarriedTo = (node) => (mergedBlocks.get(node) ?? []).flatMap((block) => [...readAuthoredMarks(block).filter((mark) => mark.kind === "joined" && decisionOf(mark) === "keep"), ...joinedCarriedTo(block)]);
|
|
1018
|
-
const movedWith = (node) => {
|
|
1019
|
-
if (!emptiedTargets.has(node)) return [node, ...mergedBlocks.get(node) ?? []];
|
|
1020
|
-
const line = standsFor.get(node);
|
|
1021
|
-
return [node, ...line ? movedWith(line) : []];
|
|
1022
|
-
};
|
|
1023
|
-
blocks.forEach(({ ancestors, node }, index) => {
|
|
1024
|
-
const joins = pending(node).filter((mark) => mark.kind === "join" && decisionOf(mark) === "keep");
|
|
1025
|
-
if (joins.length === 0 || !survives(node)) return;
|
|
1026
|
-
const container = ancestors.at(-1);
|
|
1027
|
-
const keys = new Set(joins.map(linkOf));
|
|
1028
|
-
let before = index - 1;
|
|
1029
|
-
while (before >= 0 && precedesJoin(getDefined(blocks[before]), keys)) before -= 1;
|
|
1030
|
-
const candidate = blocks[before];
|
|
1031
|
-
const previous = candidate && (!container || candidate.ancestors.includes(container)) ? candidate.node : null;
|
|
1032
|
-
if (previous && (!survives(previous) || mergedInto.has(previous) || emptiedTargets.has(previous))) wait(joins);
|
|
1033
|
-
});
|
|
1034
|
-
const cutSides = /* @__PURE__ */ new Map();
|
|
1035
|
-
const holdsRejectedSplitCopies = (node) => {
|
|
1036
|
-
const own = new Set(cutsOf(node).map(({ change }) => change));
|
|
1037
|
-
return readAuthoredMarks(node).some((mark) => mark.kind === "format" && mark.split !== void 0 && !own.has(mark.split) && decisionOf(mark) === "reject");
|
|
1038
|
-
};
|
|
1039
|
-
let holdsRejectedCopies = false;
|
|
1040
|
-
const collectCuts = (nodes, index) => {
|
|
1041
|
-
for (const child of nodes) {
|
|
1042
|
-
holdsRejectedCopies ||= holdsRejectedSplitCopies(child);
|
|
1043
|
-
for (const cut of cutsOf(child)) {
|
|
1044
|
-
const sides = cutSides.get(cut.cut) ?? { tag: cut };
|
|
1045
|
-
sides[cut.side] = index;
|
|
1046
|
-
sides[cut.side === "end" ? "endNode" : "startNode"] = child;
|
|
1047
|
-
cutSides.set(cut.cut, sides);
|
|
1048
|
-
}
|
|
1049
|
-
if (child.children) collectCuts(child.children, index);
|
|
1050
|
-
}
|
|
1051
|
-
};
|
|
1052
|
-
blocks.forEach(({ node }, index) => collectCuts(node.children ?? [], index));
|
|
1053
|
-
const joinsCuts = [...cutSides.values()].some(({ tag }) => decisionOf(tag) === "reject") || holdsRejectedCopies;
|
|
1054
|
-
const lineChain = ({ ancestors, node }) => [
|
|
1055
|
-
node,
|
|
1056
|
-
...[...ancestors].reverse(),
|
|
1057
|
-
...site
|
|
1058
|
-
];
|
|
1059
|
-
const leftOf = (cut) => {
|
|
1060
|
-
const { end, endNode } = cutSides.get(cut) ?? {};
|
|
1061
|
-
return end !== void 0 && endNode ? {
|
|
1062
|
-
block: getDefined(blocks[end]),
|
|
1063
|
-
node: endNode,
|
|
1064
|
-
root
|
|
1065
|
-
} : cutIndex?.leftOf?.(cut);
|
|
1066
|
-
};
|
|
1067
|
-
const standsWhenCutDecides = ({ block, node }) => survives(node) || ownMarkRemoves(node) && survives(block.node);
|
|
1068
|
-
const predecessorsOf = ({ node }, seen = /* @__PURE__ */ new Set()) => {
|
|
1069
|
-
if (seen.has(node)) return [];
|
|
1070
|
-
seen.add(node);
|
|
1071
|
-
return cutsOf(node).flatMap((tag) => {
|
|
1072
|
-
if (tag.side !== "start" || resultOf(tag) === "accept") return [];
|
|
1073
|
-
const before = leftOf(tag.cut);
|
|
1074
|
-
return before ? [before, ...predecessorsOf(before, seen)] : [];
|
|
1075
|
-
});
|
|
1076
|
-
};
|
|
1077
|
-
const leftStands = (left) => standsWhenCutDecides(left) || predecessorsOf(left).some(standsWhenCutDecides);
|
|
1078
|
-
const finalBlockOf = (block) => standingOf(finalOf(block));
|
|
1079
|
-
const meets = ({ end, start }, left) => end !== void 0 && start !== void 0 && (end === start || finalBlockOf(getDefined(blocks[start]).node) === finalBlockOf(left.block.node));
|
|
1080
|
-
const copiesToStrip = (node) => {
|
|
1081
|
-
if (!cutIndex || !holdsRejectedSplitCopies(node)) return null;
|
|
1082
|
-
const own = new Set(cutsOf(node).map(({ cut }) => cut));
|
|
1083
|
-
const lineage = /* @__PURE__ */ new Set();
|
|
1084
|
-
const walk = (fragment) => {
|
|
1085
|
-
for (const { cut, side } of cutsOf(fragment)) {
|
|
1086
|
-
if (side !== "start" || lineage.has(cut)) continue;
|
|
1087
|
-
lineage.add(cut);
|
|
1088
|
-
const left = leftOf(cut);
|
|
1089
|
-
if (left) walk(left.node);
|
|
1090
|
-
}
|
|
1091
|
-
};
|
|
1092
|
-
walk(node);
|
|
1093
|
-
const keys = /* @__PURE__ */ new Set();
|
|
1094
|
-
for (const mark of dependencies.marks(node)) {
|
|
1095
|
-
if (mark.kind !== "format") continue;
|
|
1096
|
-
for (const copied of cutIndex.copiedFrom(copyKeyOf(mark))) {
|
|
1097
|
-
if (own.has(copied.cut.cut) || !lineage.has(copied.cut.cut) || resultOf(copied.cut) !== "reject") continue;
|
|
1098
|
-
const left = leftOf(copied.cut.cut);
|
|
1099
|
-
if (left && (left.root !== copied.right.root || finalBlockOf(left.block.node) !== finalBlockOf(copied.right.block)) && leftStands(left)) for (const key of copied.copied) keys.add(key);
|
|
1100
|
-
}
|
|
1101
|
-
}
|
|
1102
|
-
return keys.size > 0 ? keys : null;
|
|
1103
|
-
};
|
|
1104
|
-
for (const sides of cutSides.values()) {
|
|
1105
|
-
const { end, start, startNode, tag } = sides;
|
|
1106
|
-
if (decisionOf(tag) !== "reject") continue;
|
|
1107
|
-
const left = leftOf(tag.cut);
|
|
1108
|
-
if (!left || start === void 0 || !startNode || meets(sides, left)) continue;
|
|
1109
|
-
const leftChain = end === void 0 ? [left.block.node, ...[...left.block.ancestors].reverse()] : lineChain(left.block);
|
|
1110
|
-
const right = lineChain(getDefined(blocks[start]));
|
|
1111
|
-
const before = predecessorsOf(left);
|
|
1112
|
-
const place = {
|
|
1113
|
-
...placeUnder(leftChain),
|
|
1114
|
-
root: left.root
|
|
1115
|
-
};
|
|
1116
|
-
cutVerdict(tag.cut, left.node, {
|
|
1117
|
-
change: tag.change,
|
|
1118
|
-
forced: null,
|
|
1119
|
-
left: halfOf(left.node, pending(left.node), place),
|
|
1120
|
-
place,
|
|
1121
|
-
right: halfOf(startNode, pending(startNode), placeUnder(right))
|
|
1122
|
-
}, {
|
|
1123
|
-
between: [...end === void 0 ? [] : blocks.slice(end + 1, start).map(({ node }) => node), ...before.map(({ node }) => node)],
|
|
1124
|
-
place: [
|
|
1125
|
-
...leftChain,
|
|
1126
|
-
...right,
|
|
1127
|
-
...before.flatMap(({ block }) => [block.node, ...[...block.ancestors].reverse()])
|
|
1128
|
-
],
|
|
1129
|
-
unmet: leftStands(left) ? "apart" : "gone"
|
|
1130
|
-
});
|
|
1131
|
-
}
|
|
1132
|
-
for (const { endNode, tag } of cutSides.values()) {
|
|
1133
|
-
if (!endNode || decisionOf(tag) !== "keep") continue;
|
|
1134
|
-
const starts = cutsOf(endNode).filter(({ side }) => side === "start");
|
|
1135
|
-
if (starts.every((start) => decisionOf(start) === "keep")) {
|
|
1136
|
-
if (!survives(endNode)) wait(starts);
|
|
1137
|
-
} else if (survives(endNode)) wait(pending(endNode).filter(({ kind }) => kind === "delete"));
|
|
1138
|
-
}
|
|
1139
|
-
if (probe?.settled) return null;
|
|
1140
|
-
const movesContent = mergedBlocks.size > 0 || joinsCuts || placedAfter.size > 0 || standsFor.size > 0;
|
|
1141
|
-
let storedParents = null;
|
|
1142
|
-
const storedParentOf = (node) => {
|
|
1143
|
-
if (!storedParents) {
|
|
1144
|
-
const parents = /* @__PURE__ */ new WeakMap();
|
|
1145
|
-
const index = (nodes, parent) => {
|
|
1146
|
-
for (const child of nodes) {
|
|
1147
|
-
parents.set(child, parent);
|
|
1148
|
-
if (child.children) index(child.children, child);
|
|
1149
|
-
}
|
|
1150
|
-
};
|
|
1151
|
-
index(children, null);
|
|
1152
|
-
storedParents = parents;
|
|
1153
|
-
}
|
|
1154
|
-
return storedParents.get(node);
|
|
1155
|
-
};
|
|
1156
|
-
const movedFrom = (owner, original) => movesContent && storedParentOf(original) !== owner;
|
|
1157
|
-
const moves = [];
|
|
1158
|
-
const shown = /* @__PURE__ */ new WeakSet();
|
|
1159
|
-
const unwrapped = /* @__PURE__ */ new WeakSet();
|
|
1160
|
-
const hidden = /* @__PURE__ */ new Set();
|
|
1161
|
-
const takenWhole = /* @__PURE__ */ new Set();
|
|
1162
|
-
const pieceSubtrees = /* @__PURE__ */ new WeakMap();
|
|
1163
|
-
const inPiece = (piece, node) => {
|
|
1164
|
-
let nodes = pieceSubtrees.get(piece);
|
|
1165
|
-
if (!nodes) {
|
|
1166
|
-
nodes = subtreesOf([piece]);
|
|
1167
|
-
pieceSubtrees.set(piece, nodes);
|
|
1168
|
-
}
|
|
1169
|
-
return nodes.has(node);
|
|
1170
|
-
};
|
|
1171
|
-
const resolveList = (input, owner, parentType, ancestors, path, landing = false, landingBlock = null, placeChangedAbove = false, above = []) => {
|
|
1172
|
-
const out = [];
|
|
1173
|
-
const dirty = [];
|
|
1174
|
-
const place = {
|
|
1175
|
-
outerTypes: ancestors,
|
|
1176
|
-
parentType,
|
|
1177
|
-
root
|
|
1178
|
-
};
|
|
1179
|
-
const { joined, nodes } = joinsCuts ? joinRejectedCuts(input, {
|
|
1180
|
-
dependencies,
|
|
1181
|
-
join: ({ between, cut, left, original, right }) => {
|
|
1182
|
-
const halves = {
|
|
1183
|
-
change: cut.change,
|
|
1184
|
-
forced: null,
|
|
1185
|
-
left: halfOf(left, pending(left), place),
|
|
1186
|
-
place,
|
|
1187
|
-
right: halfOf(right, pending(right), place)
|
|
1188
|
-
};
|
|
1189
|
-
return cutVerdict(cut.cut, original, halves, {
|
|
1190
|
-
between,
|
|
1191
|
-
place: above
|
|
1192
|
-
}) === "together" ? leftSupplies(schema?.ownership ?? null, halves) : null;
|
|
1193
|
-
},
|
|
1194
|
-
apartFromRemoved: ({ cut, left, original, right }) => {
|
|
1195
|
-
const splitsOn = (node) => new Set(pending(node).flatMap((mark) => mark.kind === "format" && mark.split !== void 0 ? [mark.split] : []));
|
|
1196
|
-
const rightSplits = splitsOn(right);
|
|
1197
|
-
const seen = /* @__PURE__ */ new Set();
|
|
1198
|
-
const pendingRemovals = /* @__PURE__ */ new Set();
|
|
1199
|
-
let piecesStand = false;
|
|
1200
|
-
const walk = (fragment) => {
|
|
1201
|
-
const fragmentSplits = splitsOn(fragment);
|
|
1202
|
-
for (const split of cutsOf(fragment)) {
|
|
1203
|
-
if (split.side !== "start" || split.change === cut.change || seen.has(split.cut) || !fragmentSplits.has(split.change) || rightSplits.has(split.change)) continue;
|
|
1204
|
-
seen.add(split.cut);
|
|
1205
|
-
const piece = leftOf(split.cut);
|
|
1206
|
-
if (!piece) continue;
|
|
1207
|
-
if (!survives(piece.node)) {
|
|
1208
|
-
walk(piece.node);
|
|
1209
|
-
continue;
|
|
1210
|
-
}
|
|
1211
|
-
piecesStand = true;
|
|
1212
|
-
for (const mark of [...pending(piece.node), ...pending(piece.block.node)]) if (mark.kind === "delete" && decisionOf(mark) === "keep") pendingRemovals.add(mark.change);
|
|
1213
|
-
}
|
|
1214
|
-
};
|
|
1215
|
-
walk(leftOf(cut.cut)?.node ?? left);
|
|
1216
|
-
const settles = pendingRemovals.size > 0 ? { waits: [...pendingRemovals] } : { verdict: piecesStand ? "apart" : "gone" };
|
|
1217
|
-
if (probe?.key === cut.cut) probe.settled = probe.left === original ? settles : { verdict: "apart" };
|
|
1218
|
-
for (const change of pendingRemovals) waits.add(change);
|
|
1219
|
-
return piecesStand;
|
|
1220
|
-
},
|
|
1221
|
-
copiesToStrip,
|
|
1222
|
-
rejected: (cut) => resultOf(cut) === "reject",
|
|
1223
|
-
removedByItself: ownMarkRemoves,
|
|
1224
|
-
standsApart: (cut) => {
|
|
1225
|
-
const sides = cutSides.get(cut.cut);
|
|
1226
|
-
const left = leftOf(cut.cut);
|
|
1227
|
-
if (!left) return false;
|
|
1228
|
-
return sides && meets(sides, left) ? predecessorsOf(left).some(({ node }) => survives(node)) : leftStands(left);
|
|
1229
|
-
},
|
|
1230
|
-
survives
|
|
1231
|
-
}) : {
|
|
1232
|
-
joined: /* @__PURE__ */ new Map(),
|
|
1233
|
-
nodes: input
|
|
1234
|
-
};
|
|
1235
|
-
let restructured = joined.size > 0;
|
|
1236
|
-
let changed = false;
|
|
1237
|
-
const landHere = (pieces) => {
|
|
1238
|
-
const landed = resolveList(pieces, owner, parentType, ancestors, path, true, null, placeChangedAbove, above);
|
|
1239
|
-
for (const at of landed.dirty) dirty.push(out.length + at);
|
|
1240
|
-
out.push(...landed.list);
|
|
1241
|
-
};
|
|
1242
|
-
const land = (anchor) => {
|
|
1243
|
-
const pieces = placedAfter.get(anchor);
|
|
1244
|
-
if (!pieces) return;
|
|
1245
|
-
let after = getDefined(movedWith(anchor).at(-1));
|
|
1246
|
-
for (const node of pieces) {
|
|
1247
|
-
moves.push({
|
|
1248
|
-
after,
|
|
1249
|
-
node
|
|
1250
|
-
});
|
|
1251
|
-
after = node;
|
|
1252
|
-
}
|
|
1253
|
-
landHere(pieces);
|
|
1254
|
-
restructured = true;
|
|
1255
|
-
};
|
|
1256
|
-
for (const [index, node] of nodes.entries()) {
|
|
1257
|
-
if (probe?.settled) break;
|
|
1258
|
-
const shell = (mergedBlocks.get(node) ?? []).reduce((left, block) => {
|
|
1259
|
-
const judged = rejoined.get(block);
|
|
1260
|
-
if (!judged) return left;
|
|
1261
|
-
const supplier = judged.node === left ? judged : halfOf(left, pending(left), place);
|
|
1262
|
-
return joinedShell(left, block, null, dependencies, (key) => supplies(supplier, key));
|
|
1263
|
-
}, node);
|
|
1264
|
-
const marks = pending(shell);
|
|
1265
|
-
const stored = readMembers(shell);
|
|
1266
|
-
const original = joined.get(node) ?? node;
|
|
1267
|
-
const landedIn = landing ? node : landingBlock;
|
|
1268
|
-
if ((placed.has(node) || standsIn.has(node)) && !landing) {
|
|
1269
|
-
restructured = true;
|
|
1270
|
-
continue;
|
|
1271
|
-
}
|
|
1272
|
-
if (emptiedTargets.has(node)) {
|
|
1273
|
-
const line = standsFor.get(node);
|
|
1274
|
-
hidden.add(original);
|
|
1275
|
-
if (line) {
|
|
1276
|
-
handover.pass(node, line);
|
|
1277
|
-
moves.push({
|
|
1278
|
-
after: node,
|
|
1279
|
-
node: line
|
|
1280
|
-
});
|
|
1281
|
-
landHere([line]);
|
|
1282
|
-
}
|
|
1283
|
-
restructured = true;
|
|
1284
|
-
continue;
|
|
1285
|
-
}
|
|
1286
|
-
if (mergedInto.has(node)) {
|
|
1287
|
-
restructured = true;
|
|
1288
|
-
continue;
|
|
1289
|
-
}
|
|
1290
|
-
const unwrapsLine = isTextBlock(node) && marks.some((mark) => mark.kind === "unwrap" && isEditingChange(mark.change) && resultOf(mark) === "accept");
|
|
1291
|
-
const whole = takesWhole(node);
|
|
1292
|
-
const inner = !isText(node) && !whole && (ownMarkRemoves(node) || unwrapsLine) ? (node.children ?? []).flatMap(contentMarksIn) : [];
|
|
1293
|
-
wait(inner);
|
|
1294
|
-
if (ownMarkRemoves(node) && !survives(node)) {
|
|
1295
|
-
if (whole) takenWhole.add(original);
|
|
1296
|
-
else wait(cutsOf(node));
|
|
1297
|
-
if (isText(node)) changed = true;
|
|
1298
|
-
else {
|
|
1299
|
-
restructured = true;
|
|
1300
|
-
hidden.add(original);
|
|
1301
|
-
}
|
|
1302
|
-
continue;
|
|
1303
|
-
}
|
|
1304
|
-
const taken = handover.takenBy(node);
|
|
1305
|
-
const own = propsOf(shell);
|
|
1306
|
-
const props = taken ? handover.apply(own, taken) : own;
|
|
1307
|
-
const formats = decideFormats(props, taken ? marks.filter((mark) => mark.kind !== "format" || !handover.keys.has(mark.key)) : marks, reading, isText(node) ? (candidate, key) => schema?.canonicalizeTextProperties?.(candidate, parentType ? [parentType, ...ancestors] : [], root, key) ?? candidate : void 0);
|
|
1308
|
-
for (const change of formats?.waits ?? []) waits.add(change);
|
|
1309
|
-
const landFormats = () => {
|
|
1310
|
-
for (const tag of formats?.landed ?? []) if (!facts.landed(tag.id)) landings.set(tag.id, landedOf(tag));
|
|
1311
|
-
};
|
|
1312
|
-
const shownAs = !stores && outcome === "accept" && !isText(node) ? shownOf(shell) : null;
|
|
1313
|
-
const decidedProps = shownAs ? {
|
|
1314
|
-
...formats?.props ?? props,
|
|
1315
|
-
...shownAs
|
|
1316
|
-
} : formats?.props ?? props;
|
|
1317
|
-
const placeChanged = placeChangedAbove || movedFrom(owner, original) || typeOf(decidedProps) !== typeOf(props);
|
|
1318
|
-
const placedProps = schema && (placeChanged || formats?.changed || shownAs) ? heldProps(schema.ownership, decidedProps, {
|
|
1319
|
-
outerTypes: ancestors,
|
|
1320
|
-
parentType,
|
|
1321
|
-
root,
|
|
1322
|
-
text: isText(node)
|
|
1323
|
-
}) : decidedProps;
|
|
1324
|
-
if (!isText(node)) poolOf(original, shell);
|
|
1325
|
-
const kept = withBuiltSpares(keptMembers(shell, marks, (mark) => {
|
|
1326
|
-
const result = resultOf(mark);
|
|
1327
|
-
return mark.kind === "format" ? formats?.kept.has(mark) ?? false : result === "keep" || mark.kind === "join" && result === "accept" && retainedJoins.has(node) || (retainedFollowers.get(node)?.has(followerKeyOf(mark)) ?? false);
|
|
1328
|
-
}, stores && sparesIn(shell).length > 0 && stillBuilds(shell, [...node.children ?? [], ...(mergedBlocks.get(node) ?? []).flatMap((block) => block.children ?? [])])), landedSpares.get(original) ?? landedSpares.get(node));
|
|
1329
|
-
const dropsValue = placedProps !== decidedProps;
|
|
1330
|
-
if (dropsValue) waitOnPlaceChanges([node, ...above]);
|
|
1331
|
-
const outlived = [...new Map(inner.filter((mark) => mark.kind === "delete" && decisionOf(mark) === "keep" && !kept.includes(mark)).map((mark) => [incarnationOf(mark), mark])).values()];
|
|
1332
|
-
const carried = joinedCarriedTo(node);
|
|
1333
|
-
const formatted = {
|
|
1334
|
-
kept: outlived.length > 0 || carried.length > 0 ? [
|
|
1335
|
-
...kept,
|
|
1336
|
-
...outlived,
|
|
1337
|
-
...carried
|
|
1338
|
-
] : kept,
|
|
1339
|
-
props: placedProps
|
|
1340
|
-
};
|
|
1341
|
-
const members = formatted.kept.filter(notSpare);
|
|
1342
|
-
const storedMembers = stored.filter(notSpare);
|
|
1343
|
-
const selfChanged = props !== own || (formats?.changed ?? false) || dropsValue || members.length !== storedMembers.length || members.some((member, at) => member !== storedMembers[at]);
|
|
1344
|
-
if (selfChanged) changed = true;
|
|
1345
|
-
shown.add(node);
|
|
1346
|
-
shown.add(original);
|
|
1347
|
-
if (isText(node)) {
|
|
1348
|
-
landFormats();
|
|
1349
|
-
out.push(track(withMarks({
|
|
1350
|
-
...formatted.props,
|
|
1351
|
-
text: node.text
|
|
1352
|
-
}, formatted.kept), original));
|
|
1353
|
-
continue;
|
|
1354
|
-
}
|
|
1355
|
-
const type = typeOf(formatted.props);
|
|
1356
|
-
const merged = mergedBlocks.get(node) ?? [];
|
|
1357
|
-
if (landedIn || placedAfter.has(node)) {
|
|
1358
|
-
let after = node;
|
|
1359
|
-
for (const block of merged) {
|
|
1360
|
-
if (!landedIn || !inPiece(landedIn, block)) moves.push({
|
|
1361
|
-
after,
|
|
1362
|
-
node: block
|
|
1363
|
-
});
|
|
1364
|
-
after = block;
|
|
1365
|
-
}
|
|
1366
|
-
}
|
|
1367
|
-
const lifts = structureOf(node).unwrap && !(unwrapsLine && outlived.length > 0);
|
|
1368
|
-
const { changed: childrenChanged, dirty: childDirty, list: resolved } = resolveList([...node.children ?? [], ...merged.flatMap((block) => block.children ?? [])], original, lifts ? parentType : type, lifts || !parentType ? ancestors : [parentType, ...ancestors], [...path, index], false, landedIn, placeChanged || lifts, lifts ? above : [node, ...above]);
|
|
1369
|
-
const element = withMarks({
|
|
1370
|
-
...formatted.props,
|
|
1371
|
-
children: resolved
|
|
1372
|
-
}, formatted.kept);
|
|
1373
|
-
if (lifts) {
|
|
1374
|
-
restructured = true;
|
|
1375
|
-
unwrapped.add(node);
|
|
1376
|
-
if (resolved.some(isText) && contentOf(parentType)?.allowsText === false) unplaceable = true;
|
|
1377
|
-
wait(pending({ [AUTHORED_MARKS_KEY]: formatted.kept }));
|
|
1378
|
-
wait([resolved[0], nodes[index + 1]].flatMap((item) => pending(item).filter((mark) => mark.kind === "join" || mark.kind === "split")));
|
|
1379
|
-
landFormats();
|
|
1380
|
-
for (const at of childDirty) dirty.push(out.length + at);
|
|
1381
|
-
out.push(...resolved);
|
|
1382
|
-
land(node);
|
|
1383
|
-
continue;
|
|
1384
|
-
}
|
|
1385
|
-
const emptied = resolved.length === 0 && (node.children ?? []).length > 0;
|
|
1386
|
-
if (emptied && leftWithNoGridPart(gridHolder, node, node.children ?? [], (child) => takenWhole.has(child))) {
|
|
1387
|
-
shown.delete(node);
|
|
1388
|
-
shown.delete(original);
|
|
1389
|
-
takenWhole.add(original);
|
|
1390
|
-
hidden.add(original);
|
|
1391
|
-
restructured = true;
|
|
1392
|
-
continue;
|
|
1393
|
-
}
|
|
1394
|
-
landFormats();
|
|
1395
|
-
if (emptied) {
|
|
1396
|
-
wait(pending({ [AUTHORED_MARKS_KEY]: formatted.kept }).filter((mark) => !decidedWholeByGridPart(mark, above)));
|
|
1397
|
-
restructured = true;
|
|
1398
|
-
}
|
|
1399
|
-
out.push(track(element, original));
|
|
1400
|
-
if (childrenChanged || selfChanged || merged.length > 0 || original !== node) touched.add(element);
|
|
1401
|
-
if (touched.has(element) || childDirty.length > 0) {
|
|
1402
|
-
dirty.push(out.length - 1);
|
|
1403
|
-
dirtyChildren.set(element, childDirty);
|
|
1404
|
-
}
|
|
1405
|
-
land(node);
|
|
1406
|
-
}
|
|
1407
|
-
if (restructured) diagnostics.push({
|
|
1408
|
-
code: "authored-uncorrected",
|
|
1409
|
-
message: `A decision restructured the children of ${parentType ?? "an element"}, and corrections that depend on them did not run.`,
|
|
1410
|
-
path,
|
|
1411
|
-
severity: "warning",
|
|
1412
|
-
type: parentType
|
|
1413
|
-
});
|
|
1414
|
-
return {
|
|
1415
|
-
changed: changed || restructured,
|
|
1416
|
-
dirty,
|
|
1417
|
-
list: out
|
|
1418
|
-
};
|
|
1419
|
-
};
|
|
1420
|
-
const stillBuilds = (container, inside) => {
|
|
1421
|
-
const keeps = (mark) => decisionOf(mark) === "keep";
|
|
1422
|
-
const standing = (level) => level.flatMap((child) => ownMarkRemoves(child) && !survives(child) ? [] : structureOf(child).unwrap ? standing(child.children ?? []) : [child]);
|
|
1423
|
-
return buildClaimsOf(container, standing(inside), pending, keeps, (link, child) => {
|
|
1424
|
-
const join = links.sourceOf([link], getDefined(followerOrders.get(child)))?.mark;
|
|
1425
|
-
return join && keeps(join) ? join : null;
|
|
1426
|
-
}).length > 0;
|
|
1427
|
-
};
|
|
1428
|
-
const builtIn = /* @__PURE__ */ new WeakMap();
|
|
1429
|
-
const rootBuilt = /* @__PURE__ */ new Set();
|
|
1430
|
-
const waitOnBuild = (level, at) => {
|
|
1431
|
-
const [parent, ...ancestors] = at;
|
|
1432
|
-
wait(pending(parent).filter((mark) => isPlaceChange(mark) || mark.kind === "delete"));
|
|
1433
|
-
for (const child of level) wait(pending(child).filter(isStructureChange));
|
|
1434
|
-
for (const ancestor of ancestors) wait(pending(ancestor).filter(isStructureChange));
|
|
1435
|
-
};
|
|
1436
|
-
const waitOnPrefix = (level, completed, start, completeHere, slots) => {
|
|
1437
|
-
wait(slotDecidingInsertions(level, completed, completeHere, slots, (node) => start.includes(origins.get(node) ?? node), isInserted).flatMap((node) => pending(node).filter((mark) => mark.kind === "insert")));
|
|
1438
|
-
};
|
|
1439
|
-
const underInsertions = (completion, at) => {
|
|
1440
|
-
const marks = at.flatMap((node) => pending(node).filter((mark) => mark.kind === "insert" && decisionOf(mark) === "keep"));
|
|
1441
|
-
if (marks.length === 0 || completion.built.length === 0) return completion;
|
|
1442
|
-
const marked = new Map(completion.built.map(({ node }) => [node, dependencies.throughout(node, marks)]));
|
|
1443
|
-
return {
|
|
1444
|
-
built: completion.built.map((item) => ({
|
|
1445
|
-
...item,
|
|
1446
|
-
node: getDefined(marked.get(item.node))
|
|
1447
|
-
})),
|
|
1448
|
-
children: completion.children.map((node) => marked.get(node) ?? node)
|
|
1449
|
-
};
|
|
1450
|
-
};
|
|
1451
|
-
const addUnstored = (node) => {
|
|
1452
|
-
unstored.add(node);
|
|
1453
|
-
for (const child of node.children ?? []) if (child.children) addUnstored(child);
|
|
1454
|
-
};
|
|
1455
|
-
const carryUnstored = ({ children: copies, sources }) => {
|
|
1456
|
-
if (!sources || unstored.size === 0) return;
|
|
1457
|
-
const carry = (source, copy) => {
|
|
1458
|
-
if (source === copy) return;
|
|
1459
|
-
if (unstored.delete(source)) unstored.add(copy);
|
|
1460
|
-
const from = (source.children ?? []).filter((node) => node.children);
|
|
1461
|
-
const to = (copy.children ?? []).filter((node) => node.children);
|
|
1462
|
-
if (from.length !== to.length) return;
|
|
1463
|
-
from.forEach((node, index) => carry(node, getDefined(to[index])));
|
|
1464
|
-
};
|
|
1465
|
-
copies.forEach((copy, index) => {
|
|
1466
|
-
const source = sources[index];
|
|
1467
|
-
if (source) carry(source, copy);
|
|
1468
|
-
});
|
|
1469
|
-
};
|
|
1470
|
-
const dropFlattened = (before, after) => {
|
|
1471
|
-
if (unstored.size === 0) return;
|
|
1472
|
-
const kept = unstoredIn(unstored, after);
|
|
1473
|
-
for (const node of unstoredIn(unstored, before)) if (!kept.has(node)) unstored.delete(node);
|
|
1474
|
-
};
|
|
1475
|
-
const completeLevel = (level, at, startLevel, changed, dirty, listPart) => {
|
|
1476
|
-
let copy = null;
|
|
1477
|
-
const withBuilt = (node, completed) => {
|
|
1478
|
-
const keys = stores ? builtIn.get(node) : void 0;
|
|
1479
|
-
const rebuilt = {
|
|
1480
|
-
...node,
|
|
1481
|
-
children: completed
|
|
1482
|
-
};
|
|
1483
|
-
return keys ? withMembers(rebuilt, withBuiltSpares(readMembers(node), keys)) : rebuilt;
|
|
1484
|
-
};
|
|
1485
|
-
for (const index of dirty) {
|
|
1486
|
-
const node = getDefined(level[index]);
|
|
1487
|
-
const original = origins.get(node);
|
|
1488
|
-
const completed = completeLevel(node.children ?? [], [node, ...at], original?.children ?? [], touched.has(node), dirtyChildren.get(node) ?? []);
|
|
1489
|
-
if (completed === node.children) continue;
|
|
1490
|
-
copy ??= [...level];
|
|
1491
|
-
copy[index] = track(withBuilt(node, completed), original);
|
|
1492
|
-
}
|
|
1493
|
-
const nodes = copy ?? level;
|
|
1494
|
-
if (!changed) return nodes;
|
|
1495
|
-
const start = startOccupants(startLevel, isInserted);
|
|
1496
|
-
const pool = poolOf(at[0] ? origins.get(at[0]) ?? at[0] : void 0);
|
|
1497
|
-
const untaken = {
|
|
1498
|
-
spares: pool.spares,
|
|
1499
|
-
used: new Set(pool.used)
|
|
1500
|
-
};
|
|
1501
|
-
const slots = contentOf(at[0] ? typeOf(at[0]) : null)?.prefix ?? 0;
|
|
1502
|
-
const present = new Set(nodes.map((node) => origins.get(node) ?? node));
|
|
1503
|
-
const marksDecided = (node, kind, decision) => pending(node).filter((mark) => mark.kind === kind && decisionOf(mark) === decision);
|
|
1504
|
-
const contractedWith = (undone, removing = /* @__PURE__ */ new Map()) => contractedStart(start, slots, (node) => undone.has(node) || marksDecided(node, "split", "reject").length > 0 ? Number.NEGATIVE_INFINITY : mergedInto.has(node) ? Math.min(...marksDecided(node, "join", "accept").map((mark) => mark.at)) : null, (node) => {
|
|
1505
|
-
const marks = marksDecided(node, "delete", "accept");
|
|
1506
|
-
return removing.get(node) ?? (present.has(node) || marks.length === 0 ? null : Math.min(...marks.map((mark) => mark.at)));
|
|
1507
|
-
});
|
|
1508
|
-
let contracted;
|
|
1509
|
-
const completeHere = (items, commit = false, among = () => contracted ??= contractedWith(/* @__PURE__ */ new Set())) => complete(items, at, startLevel, (slot, candidate) => slotFate(start, slot, origins.get(candidate) ?? candidate, isInserted, (node) => among().has(node)), listPart, commit ? pool : untaken, commit);
|
|
1510
|
-
const completed = completeHere(nodes, true);
|
|
1511
|
-
carryUnstored(completed);
|
|
1512
|
-
dropFlattened(nodes, completed.sources ?? completed.children);
|
|
1513
|
-
if (completed.taken.length > 0) {
|
|
1514
|
-
const keys = new Set(completed.taken);
|
|
1515
|
-
if (at[0]) builtIn.set(at[0], keys);
|
|
1516
|
-
else for (const key of keys) rootBuilt.add(key);
|
|
1517
|
-
}
|
|
1518
|
-
const completion = underInsertions(completed, at);
|
|
1519
|
-
if (completion.built.length > 0) {
|
|
1520
|
-
for (const item of completion.built) addUnstored(item.node);
|
|
1521
|
-
waitOnBuild(nodes, at);
|
|
1522
|
-
}
|
|
1523
|
-
if (slots > 0) {
|
|
1524
|
-
waitOnPrefix(nodes, completion, start, completeHere, slots);
|
|
1525
|
-
const isSplit = (node) => pending(node).some((mark) => mark.kind === "split" && decisionOf(mark) === "keep");
|
|
1526
|
-
wait(slotDecidingInsertions(nodes, completion, (items) => completeHere(items, false, () => contractedWith(new Set(nodes.filter((node) => !items.includes(node)).map((node) => origins.get(node) ?? node)))), slots, (node) => start.includes(origins.get(node) ?? node), isSplit).flatMap((node) => pending(node).filter((mark) => mark.kind === "split")));
|
|
1527
|
-
const deletions = (node) => pending(node).filter((mark) => mark.kind === "delete" && decisionOf(mark) === "keep");
|
|
1528
|
-
const struck = nodes.slice(0, slots).filter((node) => deletions(node).length > 0);
|
|
1529
|
-
if (struck.length > 0) {
|
|
1530
|
-
const rest = nodes.filter((node) => !struck.includes(node));
|
|
1531
|
-
const removing = new Map(struck.map((node) => [origins.get(node) ?? node, Math.min(...deletions(node).map((mark) => mark.at))]));
|
|
1532
|
-
if (prefixHead(completeHere(rest), slots) !== prefixHead(completeHere(rest, false, () => contractedWith(/* @__PURE__ */ new Set(), removing)), slots)) wait(struck.flatMap(deletions));
|
|
1533
|
-
}
|
|
1534
|
-
}
|
|
1535
|
-
return mergeTextsWithEqualProps(completion.children);
|
|
1536
|
-
};
|
|
1537
|
-
const top = resolveList(children, null, site[0] ? typeOf(site[0]) : null, site.slice(1).flatMap((node) => typeOf(node) ?? []), [], false, null, false, site);
|
|
1538
|
-
if (probe) {
|
|
1539
|
-
probe.settled ??= { verdict: survives(probe.left) ? "apart" : "gone" };
|
|
1540
|
-
return null;
|
|
1541
|
-
}
|
|
1542
|
-
const placements = placementsOf(children, moves, (node) => shown.has(node) && !unwrapped.has(node) || mergedInto.has(node) && (node.children ?? []).some((child) => shown.has(child)));
|
|
1543
|
-
const resolvedChildren = completeLevel(top.list, site, children, top.changed || top.list.length < (part?.min ?? 0), top.dirty, part);
|
|
1544
|
-
let resolvedNodes = null;
|
|
1545
|
-
const indexResolved = (index, nodes) => {
|
|
1546
|
-
for (const node of nodes) {
|
|
1547
|
-
const original = origins.get(node);
|
|
1548
|
-
if (original && !index.has(original)) index.set(original, node);
|
|
1549
|
-
indexResolved(index, node.children ?? []);
|
|
1550
|
-
}
|
|
1551
|
-
return index;
|
|
1552
|
-
};
|
|
1553
|
-
const resolvedOf = (original) => {
|
|
1554
|
-
if (typeof original !== "object" || original === null) return null;
|
|
1555
|
-
resolvedNodes ??= indexResolved(/* @__PURE__ */ new Map(), resolvedChildren);
|
|
1556
|
-
return resolvedNodes.get(original) ?? null;
|
|
1557
|
-
};
|
|
1558
|
-
for (const node of removed ?? []) hidden.add(node);
|
|
1559
|
-
const spares = /* @__PURE__ */ new Map();
|
|
1560
|
-
if (stores && rootSpares.length > 0) putRootSpares(rootSpares, stillBuilds(null, given), rootBuilt, spares);
|
|
1561
|
-
return {
|
|
1562
|
-
blockers: [...waits],
|
|
1563
|
-
children: resolvedChildren,
|
|
1564
|
-
decided: [...decided],
|
|
1565
|
-
diagnostics,
|
|
1566
|
-
hidden: hidden.size > 0 ? hiddenBlocksOf(given, hidden, {
|
|
1567
|
-
lines: [...[...mergedBlocks].map(([into, merged]) => ({
|
|
1568
|
-
first: into,
|
|
1569
|
-
head: standingOf(into),
|
|
1570
|
-
last: merged
|
|
1571
|
-
})), ...[...standsFor].map(([target, line]) => ({
|
|
1572
|
-
first: target,
|
|
1573
|
-
head: standingOf(line),
|
|
1574
|
-
last: movedWith(target).slice(1)
|
|
1575
|
-
}))],
|
|
1576
|
-
resolved: resolvedChildren,
|
|
1577
|
-
resolvedOf,
|
|
1578
|
-
shows: (node) => shown.has(node) && !unwrapped.has(node)
|
|
1579
|
-
}) : [],
|
|
1580
|
-
landed: [...landings.values()],
|
|
1581
|
-
placements,
|
|
1582
|
-
resolvedOf: (original) => resolvedOf(original),
|
|
1583
|
-
spares,
|
|
1584
|
-
takenWhole,
|
|
1585
|
-
unplaceable,
|
|
1586
|
-
unstored: shownAll(unstored, resolvedChildren)
|
|
1587
|
-
};
|
|
1588
|
-
};
|
|
1589
|
-
/**
|
|
1590
|
-
* Which shown block each block a decision hides whole collapses into. A
|
|
1591
|
-
* block stored between the pieces of a joined line collapses into that line,
|
|
1592
|
-
* unless a shown element holds the block and not the line's first piece, as
|
|
1593
|
-
* an emptied quote the line's pieces pass over does. Any other block
|
|
1594
|
-
* collapses into its nearest shown ancestor.
|
|
1595
|
-
*/
|
|
1596
|
-
const hiddenBlocksOf = (given, hidden, { lines, resolved, resolvedOf, shows }) => {
|
|
1597
|
-
const places = /* @__PURE__ */ new Map();
|
|
1598
|
-
let count = 0;
|
|
1599
|
-
const walk = (nodes, parent, path) => {
|
|
1600
|
-
for (const [index, node] of nodes.entries()) {
|
|
1601
|
-
if (isText(node)) continue;
|
|
1602
|
-
const place = {
|
|
1603
|
-
at: count,
|
|
1604
|
-
end: 0,
|
|
1605
|
-
parent,
|
|
1606
|
-
path: [...path, index]
|
|
1607
|
-
};
|
|
1608
|
-
count += 1;
|
|
1609
|
-
places.set(node, place);
|
|
1610
|
-
walk(node.children ?? [], node, place.path);
|
|
1611
|
-
place.end = count - 1;
|
|
1612
|
-
}
|
|
1613
|
-
};
|
|
1614
|
-
walk(given, null, []);
|
|
1615
|
-
const spans = lines.flatMap(({ first, head, last }) => {
|
|
1616
|
-
const start = places.get(first);
|
|
1617
|
-
return start ? [{
|
|
1618
|
-
first,
|
|
1619
|
-
head,
|
|
1620
|
-
start: start.at,
|
|
1621
|
-
to: Math.max(...last.map((node) => places.get(node)?.at ?? -1))
|
|
1622
|
-
}] : [];
|
|
1623
|
-
});
|
|
1624
|
-
let outputPaths = null;
|
|
1625
|
-
const outputPathOf = (node) => {
|
|
1626
|
-
if (!outputPaths) {
|
|
1627
|
-
const paths = /* @__PURE__ */ new Map();
|
|
1628
|
-
const index = (nodes, path) => {
|
|
1629
|
-
for (const [at, child] of nodes.entries()) {
|
|
1630
|
-
if (isText(child)) continue;
|
|
1631
|
-
paths.set(child, [...path, at]);
|
|
1632
|
-
index(child.children ?? [], [...path, at]);
|
|
1633
|
-
}
|
|
1634
|
-
};
|
|
1635
|
-
index(resolved, []);
|
|
1636
|
-
outputPaths = paths;
|
|
1637
|
-
}
|
|
1638
|
-
const output = resolvedOf(node);
|
|
1639
|
-
return (output && outputPaths.get(output)) ?? null;
|
|
1640
|
-
};
|
|
1641
|
-
return [...hidden].flatMap((node) => {
|
|
1642
|
-
const place = places.get(node);
|
|
1643
|
-
if (!place) return [];
|
|
1644
|
-
let container = place.parent;
|
|
1645
|
-
while (container && !shows(container)) container = places.get(container)?.parent ?? null;
|
|
1646
|
-
const box = container ? places.get(container) : void 0;
|
|
1647
|
-
let owner = container;
|
|
1648
|
-
let from = -1;
|
|
1649
|
-
for (const line of spans) if ((line.first === node || line.start < place.at && place.at < line.to) && line.start > from && (!box || box.at < line.start && line.start <= box.end)) {
|
|
1650
|
-
owner = line.head;
|
|
1651
|
-
from = line.start;
|
|
1652
|
-
}
|
|
1653
|
-
return [{
|
|
1654
|
-
at: place.path,
|
|
1655
|
-
owner: owner && outputPathOf(owner)
|
|
1656
|
-
}];
|
|
1657
|
-
});
|
|
1658
|
-
};
|
|
1659
|
-
const CONTENT_AND_ENCLOSURE_KINDS = /* @__PURE__ */ new Set([
|
|
1660
|
-
"delete",
|
|
1661
|
-
"insert",
|
|
1662
|
-
"unwrap",
|
|
1663
|
-
"wrap"
|
|
1664
|
-
]);
|
|
1665
|
-
const shapesMergedLine = (mark) => mark.kind !== "format";
|
|
1666
|
-
/**
|
|
1667
|
-
* Each key's format tags decided by `decideKey`, or null for a node with no
|
|
1668
|
-
* format tag. A key that waits keeps its value and tags; its waits block the
|
|
1669
|
-
* whole decision.
|
|
1670
|
-
*/
|
|
1671
|
-
const decideFormats = (props, marks, reading, canonicalize) => {
|
|
1672
|
-
if (!marks.some((mark) => mark.kind === "format")) return null;
|
|
1673
|
-
const readsCopies = /* @__PURE__ */ new Set();
|
|
1674
|
-
const kept = /* @__PURE__ */ new Set();
|
|
1675
|
-
const landed = [];
|
|
1676
|
-
const waits = [];
|
|
1677
|
-
const keys = new Set(marks.flatMap((mark) => mark.kind === "format" ? [mark.key] : []));
|
|
1678
|
-
const next = { ...props };
|
|
1679
|
-
let changed = false;
|
|
1680
|
-
for (const key of keys) {
|
|
1681
|
-
const tags = marks.filter((mark) => mark.kind === "format" && mark.key === key);
|
|
1682
|
-
const decision = decideKey(tags, reading, props[key]);
|
|
1683
|
-
if (decision.readsCopies) readsCopies.add(key);
|
|
1684
|
-
waits.push(...decision.waits);
|
|
1685
|
-
landed.push(...decision.landed);
|
|
1686
|
-
for (const tag of decision.kept) kept.add(tag);
|
|
1687
|
-
if (decision.value.kind !== "set") {
|
|
1688
|
-
if (decision.waits.length > 0 || Object.hasOwn(props, key) || !canonicalize) continue;
|
|
1689
|
-
const value = tipsWrittenValue(tags);
|
|
1690
|
-
if (value === void 0) continue;
|
|
1691
|
-
const fitted = canonicalize({
|
|
1692
|
-
...props,
|
|
1693
|
-
[key]: value
|
|
1694
|
-
}, key);
|
|
1695
|
-
if (!Object.keys(props).some((sibling) => !Object.hasOwn(fitted, sibling))) continue;
|
|
1696
|
-
next[key] = value;
|
|
1697
|
-
changed = true;
|
|
1698
|
-
continue;
|
|
1699
|
-
}
|
|
1700
|
-
changed = true;
|
|
1701
|
-
if (decision.value.value === void 0) delete next[key];
|
|
1702
|
-
else next[key] = decision.value.value;
|
|
1703
|
-
}
|
|
1704
|
-
return {
|
|
1705
|
-
changed,
|
|
1706
|
-
kept,
|
|
1707
|
-
landed,
|
|
1708
|
-
props: next,
|
|
1709
|
-
readsCopies,
|
|
1710
|
-
waits
|
|
1711
|
-
};
|
|
1712
|
-
};
|
|
1713
|
-
const unstoredIn = (unstored, nodes) => {
|
|
1714
|
-
const shown = /* @__PURE__ */ new Set();
|
|
1715
|
-
const visit = (list) => {
|
|
1716
|
-
for (const node of list) {
|
|
1717
|
-
if (shown.size === unstored.size) return;
|
|
1718
|
-
if (unstored.has(node)) shown.add(node);
|
|
1719
|
-
if (node.children) visit(node.children);
|
|
1720
|
-
}
|
|
1721
|
-
};
|
|
1722
|
-
if (unstored.size > 0) visit(nodes);
|
|
1723
|
-
return shown;
|
|
1724
|
-
};
|
|
1725
|
-
/**
|
|
1726
|
-
* Throws only under the test environment, because production pairs a lost
|
|
1727
|
-
* unstored element with stored content by shape instead.
|
|
1728
|
-
*/
|
|
1729
|
-
const failInTests = (message) => {
|
|
1730
|
-
if ((globalThis.process?.env)?.NODE_ENV === "test") throw new Error(message);
|
|
1731
|
-
};
|
|
1732
|
-
const shownAll = (unstored, nodes) => {
|
|
1733
|
-
const shown = unstoredIn(unstored, nodes);
|
|
1734
|
-
if (shown.size !== unstored.size) failInTests(`The resolved children hold ${shown.size} of the ${unstored.size} elements completion built.`);
|
|
1735
|
-
return shown;
|
|
1736
|
-
};
|
|
1737
|
-
const mergeTextsWithEqualProps = (nodes) => {
|
|
1738
|
-
const out = [];
|
|
1739
|
-
for (const node of nodes) {
|
|
1740
|
-
const previous = out.at(-1);
|
|
1741
|
-
if (previous && isText(previous) && isText(node) && jsonEqual(propsOf(previous), propsOf(node))) {
|
|
1742
|
-
out[out.length - 1] = {
|
|
1743
|
-
...previous,
|
|
1744
|
-
text: `${previous.text}${node.text}`
|
|
1745
|
-
};
|
|
1746
|
-
continue;
|
|
1747
|
-
}
|
|
1748
|
-
out.push(node);
|
|
1749
|
-
}
|
|
1750
|
-
return out;
|
|
1751
|
-
};
|
|
1752
|
-
const spareOpsOf = (resolutions) => {
|
|
1753
|
-
const ops = new Map(resolutions.flatMap(({ spares }) => [...spares]));
|
|
1754
|
-
return ops.size === 0 ? NO_RECORD_OPS : /* @__PURE__ */ new Map([[RESERVES, ops]]);
|
|
1755
|
-
};
|
|
1756
|
-
/** Resolves every root, after a cover pass over the roots' own spare blocks. */
|
|
1757
|
-
const resolveAuthoredValue = (value, outcome, schema = null, options = {}) => readingCovered({
|
|
1758
|
-
cover: () => schema && coverStoredValues(schema.ownership, reserveNodesIn(getValueRecords(value))),
|
|
1759
|
-
read: () => resolveValueIn(value, outcome, schema, options)
|
|
1760
|
-
});
|
|
1761
|
-
const resolveValueIn = (value, outcome, schema, options) => {
|
|
1762
|
-
const facts = factsOf(value);
|
|
1763
|
-
const dependencies = createDependencies(facts);
|
|
1764
|
-
const resolveOptions = {
|
|
1765
|
-
...options,
|
|
1766
|
-
dependencies,
|
|
1767
|
-
facts,
|
|
1768
|
-
cutIndex: cutIndexIn(value, dependencies, schema)
|
|
1769
|
-
};
|
|
1770
|
-
const main = resolveAuthoredChildren(value.children, outcome, schema, "main", resolveOptions);
|
|
1771
|
-
const roots = Object.entries(value.roots ?? {}).map(([root, children]) => [root, resolveAuthoredChildren(children, outcome, schema, root, resolveOptions)]);
|
|
1772
|
-
const all = [main, ...roots.map(([, resolution]) => resolution)];
|
|
1773
|
-
const changedRoots = new Map(roots.flatMap(([root, resolution]) => resolution.children === value.roots?.[root] ? [] : [[root, void 0]]));
|
|
1774
|
-
if (main.children !== value.children) changedRoots.set("main", void 0);
|
|
1775
|
-
const dropped = new Set(schema && changedRoots.size > 0 ? orphanedValueRoots(schema.ownership, value, {
|
|
1776
|
-
children: main.children,
|
|
1777
|
-
roots: Object.fromEntries(roots.map(([root, resolution]) => [root, resolution.children]))
|
|
1778
|
-
}, changedRoots) : []);
|
|
1779
|
-
const kept = roots.filter(([root]) => !dropped.has(root));
|
|
1780
|
-
const live = [main, ...kept.map(([, resolution]) => resolution)];
|
|
1781
|
-
const byRoot = new Map([["main", main], ...kept]);
|
|
1782
|
-
const reserveOps = composeRecordOps(reserveDropsOf(getValueRecords(value), dropped), spareOpsOf(live));
|
|
1783
|
-
const childrenIn = (root) => getDefined(byRoot.get(root)).children;
|
|
1784
|
-
const base = dropped.size > 0 ? withoutValueRoots(value, dropped) : value;
|
|
1785
|
-
return {
|
|
1786
|
-
blockers: [...new Set(all.flatMap((resolution) => resolution.blockers))],
|
|
1787
|
-
decided: [...new Set(all.flatMap((resolution) => resolution.decided))],
|
|
1788
|
-
diagnostics: live.flatMap((resolution) => resolution.diagnostics),
|
|
1789
|
-
hiddenIn: (root) => byRoot.get(root)?.hidden ?? null,
|
|
1790
|
-
landed: live.flatMap((resolution) => resolution.landed),
|
|
1791
|
-
resolvedIn: (root) => byRoot.get(root)?.resolvedOf ?? null,
|
|
1792
|
-
resolvedOf: (original) => live.reduce((found, resolution) => found ?? resolution.resolvedOf(original), null),
|
|
1793
|
-
takenWhole: new Set(all.flatMap((resolution) => [...resolution.takenWhole])),
|
|
1794
|
-
unplaceable: live.some((resolution) => resolution.unplaceable),
|
|
1795
|
-
value: deriveValue(base, {
|
|
1796
|
-
children: childrenIn("main"),
|
|
1797
|
-
...base.roots ? { roots: Object.fromEntries(kept.map(([root]) => [root, childrenIn(root)])) } : {}
|
|
1798
|
-
}, composeRecordOps(composeRecordOps(putContexts(dependencies.minted()), putLanded(live.flatMap((resolution) => resolution.landed))), reserveOps))
|
|
1799
|
-
};
|
|
1800
|
-
};
|
|
1801
|
-
const resolveAuthoredWindows = (value, windows, outcome, schema, options) => readingCovered({
|
|
1802
|
-
cover: () => schema && coverStoredValues(schema.ownership, reserveNodesIn(getValueRecords(value))),
|
|
1803
|
-
read: () => {
|
|
1804
|
-
const facts = factsOf(value);
|
|
1805
|
-
const dependencies = createDependencies(facts);
|
|
1806
|
-
const cuts = cutIndexIn(value, dependencies, schema);
|
|
1807
|
-
let crossed = false;
|
|
1808
|
-
const cutIndex = {
|
|
1809
|
-
copiedFrom: (key) => {
|
|
1810
|
-
crossed = true;
|
|
1811
|
-
return cuts.copiedFrom(key);
|
|
1812
|
-
},
|
|
1813
|
-
...cuts.leftOf ? { leftOf: (cut) => {
|
|
1814
|
-
crossed = true;
|
|
1815
|
-
return cuts.leftOf?.(cut);
|
|
1816
|
-
} } : {}
|
|
1817
|
-
};
|
|
1818
|
-
const resolved = windows.map((window) => {
|
|
1819
|
-
const before = valueRootNodes(value, window.root).slice(window.from, window.to);
|
|
1820
|
-
return {
|
|
1821
|
-
...window,
|
|
1822
|
-
before,
|
|
1823
|
-
resolution: resolveAuthoredChildren(before, outcome, schema, window.root, {
|
|
1824
|
-
...options,
|
|
1825
|
-
cutIndex,
|
|
1826
|
-
dependencies,
|
|
1827
|
-
facts,
|
|
1828
|
-
part: {
|
|
1829
|
-
head: window.from === 0,
|
|
1830
|
-
min: 0
|
|
1831
|
-
}
|
|
1832
|
-
})
|
|
1833
|
-
};
|
|
1834
|
-
});
|
|
1835
|
-
if (crossed || resolved.some(({ before, resolution }) => resolution.children.length !== before.length)) return null;
|
|
1836
|
-
const all = resolved.map(({ resolution }) => resolution);
|
|
1837
|
-
const landed = all.flatMap((resolution) => resolution.landed);
|
|
1838
|
-
return {
|
|
1839
|
-
blockers: [...new Set(all.flatMap((resolution) => resolution.blockers))],
|
|
1840
|
-
decided: [...new Set(all.flatMap((resolution) => resolution.decided))],
|
|
1841
|
-
records: composeRecordOps(composeRecordOps(putContexts(dependencies.minted()), putLanded(landed)), spareOpsOf(all)),
|
|
1842
|
-
resolvedIn: (root) => resolved.find((window) => window.root === root)?.resolution.resolvedOf ?? null,
|
|
1843
|
-
resolvedOf: (original) => all.reduce((found, resolution) => found ?? resolution.resolvedOf(original), null),
|
|
1844
|
-
takenWhole: new Set(all.flatMap((resolution) => [...resolution.takenWhole])),
|
|
1845
|
-
unplaceable: all.some((resolution) => resolution.unplaceable),
|
|
1846
|
-
windows: resolved.map(({ before, resolution, ...window }) => ({
|
|
1847
|
-
...window,
|
|
1848
|
-
after: resolution.children,
|
|
1849
|
-
before
|
|
1850
|
-
}))
|
|
1851
|
-
};
|
|
1852
|
-
}
|
|
1853
|
-
});
|
|
1854
|
-
/**
|
|
1855
|
-
* `proposed` reads the document with every pending change accepted;
|
|
1856
|
-
* `accepted` reads it with every pending change rejected.
|
|
1857
|
-
*/
|
|
1858
|
-
const projectAuthoredValue = (value, projection, schema = null) => resolveAuthoredValue(value, projection === "proposed" ? "accept" : "reject", schema);
|
|
1859
|
-
//#endregion
|
|
1860
|
-
export { acceptedOwnShape, buildClaimsOf, buildsElement, changesBuild, claimsBreakBefore, completedJoinKeys, decidedJoinLeavesInPlace, failInTests, hasBoundaryMark, hasLiveJoinMark, isTextBlock, joinKeysOf, joinPassage, linksIn, mergesUp, pastFollowers, placementLinksIn, projectAuthoredValue, removes, resolveAuthoredChildren, resolveAuthoredValue, resolveAuthoredWindows, slotDecidingInsertions, slotFate, startOccupants };
|