@inkandswitch/patchwork-pkg-base 0.0.41 → 0.0.42
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/package.json +1 -1
- package/packages/account/dist/{InlineContactAvatar-TVDLE2AV.js → InlineContactAvatar-6UAAJ73R.js} +2 -1
- package/packages/account/dist/InlineContactAvatar-6UAAJ73R.js.map +7 -0
- package/packages/account/dist/index.js +1 -1
- package/packages/chat/dist/{ChatRoot-DQkQQvPO.js → ChatRoot-WdCS4aLg.js} +3001 -2807
- package/packages/chat/dist/{context-tool-BuY29sJF.js → context-tool-KkwLFr2k.js} +2 -2
- package/packages/chat/dist/{index-NiYOPQzY.js → index-P8UuZ1jj.js} +3 -3
- package/packages/chat/dist/index.js +1 -1
- package/packages/chat/dist/{tool-He3mRTzT.js → tool-DWqQOW59.js} +2 -2
- package/packages/chat/package.json +1 -1
- package/packages/codemirror-base/dist/chunk-H5POLO74.js +2658 -0
- package/packages/codemirror-base/dist/chunk-H5POLO74.js.map +7 -0
- package/packages/codemirror-base/dist/lib/codemirror.js +1 -1
- package/packages/codemirror-base/dist/tool.js +9 -5
- package/packages/codemirror-base/dist/tool.js.map +2 -2
- package/packages/codemirror-base/package.json +1 -1
- package/packages/codemirror-markdown/dist/extensions/markdown.js +0 -94
- package/packages/codemirror-markdown/dist/extensions/markdown.js.map +3 -3
- package/packages/drafts/dist/assets/{DraftOverlayProvider-B0Mtq1UF.js → DraftOverlayProvider-VYKlzOy1.js} +85 -25
- package/packages/drafts/dist/assets/DraftOverlayProvider-VYKlzOy1.js.map +1 -0
- package/packages/drafts/dist/assets/{DraftListProvider-D41q9O5B.js → DraftStateProvider-DX8b_RgQ.js} +270 -39
- package/packages/drafts/dist/assets/DraftStateProvider-DX8b_RgQ.js.map +1 -0
- package/packages/drafts/dist/assets/{clone-policy-C4pVv5sr.js → clone-policy-CIdEhg7W.js} +5 -2
- package/packages/drafts/dist/assets/{clone-policy-C4pVv5sr.js.map → clone-policy-CIdEhg7W.js.map} +1 -1
- package/packages/drafts/dist/assets/draft-docs-Bi8K1y3a.js +554 -0
- package/packages/drafts/dist/assets/draft-docs-Bi8K1y3a.js.map +1 -0
- package/packages/drafts/dist/assets/main-BR_tW0sp.js +3105 -0
- package/packages/drafts/dist/assets/main-BR_tW0sp.js.map +1 -0
- package/packages/drafts/dist/index.js +14 -14
- package/packages/drafts/dist/index.js.map +1 -1
- package/packages/drafts/package.json +1 -1
- package/packages/threepane/dist/IsolatedDocumentArea-2JIBFDOX.js +2 -0
- package/packages/threepane/dist/{PatchworkFrame-4AEBOBRE.js → PatchworkFrame-P5P6JTJE.js} +2 -2
- package/packages/threepane/dist/chunk-CGHYPNSB.js +972 -0
- package/packages/threepane/dist/chunk-CGHYPNSB.js.map +7 -0
- package/packages/threepane/dist/index.js +1 -1
- package/packages/tldraw4/dist/tool.js +61 -10
- package/packages/tldraw4/dist/tool.js.map +2 -2
- package/packages/tldraw4/package.json +2 -2
- package/packages/account/dist/InlineContactAvatar-TVDLE2AV.js.map +0 -7
- package/packages/codemirror-base/dist/chunk-5IG5TKXV.js +0 -795
- package/packages/codemirror-base/dist/chunk-5IG5TKXV.js.map +0 -7
- package/packages/drafts/dist/assets/DraftListProvider-D41q9O5B.js.map +0 -1
- package/packages/drafts/dist/assets/DraftOverlayProvider-B0Mtq1UF.js.map +0 -1
- package/packages/drafts/dist/assets/main-Cp8VsNHh.js +0 -2331
- package/packages/drafts/dist/assets/main-Cp8VsNHh.js.map +0 -1
- package/packages/threepane/dist/IsolatedDocumentArea-MZBBRFMY.js +0 -2
- package/packages/threepane/dist/chunk-HNLVJAZZ.js +0 -972
- package/packages/threepane/dist/chunk-HNLVJAZZ.js.map +0 -7
- /package/packages/threepane/dist/{IsolatedDocumentArea-MZBBRFMY.js.map → IsolatedDocumentArea-2JIBFDOX.js.map} +0 -0
- /package/packages/threepane/dist/{PatchworkFrame-4AEBOBRE.js.map → PatchworkFrame-P5P6JTJE.js.map} +0 -0
|
@@ -7443,31 +7443,57 @@ function useAutomergeStore({
|
|
|
7443
7443
|
const [storeWithStatus, setStoreWithStatus] = (0, import_react3.useState)({
|
|
7444
7444
|
status: "loading"
|
|
7445
7445
|
});
|
|
7446
|
+
const readOnlyRef = (0, import_react3.useRef)(readOnly);
|
|
7447
|
+
readOnlyRef.current = readOnly;
|
|
7446
7448
|
(0, import_react3.useEffect)(() => {
|
|
7447
7449
|
const unsubs = [];
|
|
7448
7450
|
let preventPatchApplications = false;
|
|
7449
7451
|
function syncStoreChangesToAutomergeDoc({
|
|
7450
7452
|
changes
|
|
7451
7453
|
}) {
|
|
7454
|
+
if (readOnlyRef.current) return;
|
|
7452
7455
|
preventPatchApplications = true;
|
|
7453
7456
|
handle.change((doc2) => {
|
|
7454
7457
|
applyTLStoreChangesToAutomerge(doc2, changes);
|
|
7455
7458
|
});
|
|
7456
7459
|
preventPatchApplications = false;
|
|
7457
7460
|
}
|
|
7458
|
-
|
|
7459
|
-
|
|
7460
|
-
|
|
7461
|
-
|
|
7462
|
-
|
|
7463
|
-
|
|
7464
|
-
);
|
|
7465
|
-
}
|
|
7461
|
+
unsubs.push(
|
|
7462
|
+
store.listen(syncStoreChangesToAutomergeDoc, {
|
|
7463
|
+
source: "user",
|
|
7464
|
+
scope: "document"
|
|
7465
|
+
})
|
|
7466
|
+
);
|
|
7466
7467
|
const syncAutomergeDocChangesToStore = ({
|
|
7467
7468
|
patches,
|
|
7469
|
+
scopeReplaced,
|
|
7468
7470
|
doc: doc2
|
|
7469
7471
|
}) => {
|
|
7470
7472
|
if (preventPatchApplications) return;
|
|
7473
|
+
if (scopeReplaced) {
|
|
7474
|
+
const swapped = handle.doc();
|
|
7475
|
+
if (!swapped?.store) return;
|
|
7476
|
+
const migrated = store.schema.migrateStoreSnapshot({
|
|
7477
|
+
store: JSON.parse(JSON.stringify(swapped.store)),
|
|
7478
|
+
schema: JSON.parse(JSON.stringify(swapped.schema))
|
|
7479
|
+
});
|
|
7480
|
+
if (migrated.type === "error") {
|
|
7481
|
+
console.error(
|
|
7482
|
+
"[tldraw4] failed to migrate swapped-in snapshot:",
|
|
7483
|
+
migrated.reason
|
|
7484
|
+
);
|
|
7485
|
+
return;
|
|
7486
|
+
}
|
|
7487
|
+
const next = migrated.value;
|
|
7488
|
+
store.mergeRemoteChanges(() => {
|
|
7489
|
+
const toRemove = store.allRecords().filter(
|
|
7490
|
+
(record) => store.scopedTypes.document.has(record.typeName) && !(record.id in next)
|
|
7491
|
+
).map((record) => record.id);
|
|
7492
|
+
if (toRemove.length) store.remove(toRemove);
|
|
7493
|
+
store.put(Object.values(next));
|
|
7494
|
+
});
|
|
7495
|
+
return;
|
|
7496
|
+
}
|
|
7471
7497
|
applyAutomergePatchesToTLStore(patches, store, doc2 ?? handle.doc());
|
|
7472
7498
|
};
|
|
7473
7499
|
handle.on("change", syncAutomergeDocChangesToStore);
|
|
@@ -7490,9 +7516,32 @@ function useAutomergeStore({
|
|
|
7490
7516
|
unsubs.forEach((fn) => fn());
|
|
7491
7517
|
unsubs.length = 0;
|
|
7492
7518
|
};
|
|
7493
|
-
}, [handle, store
|
|
7519
|
+
}, [handle, store]);
|
|
7494
7520
|
return storeWithStatus;
|
|
7495
7521
|
}
|
|
7522
|
+
function useIsHandleReadOnly(handle) {
|
|
7523
|
+
const [readOnly, setReadOnly] = (0, import_react3.useState)(() => handle.isReadOnly());
|
|
7524
|
+
(0, import_react3.useEffect)(() => {
|
|
7525
|
+
setReadOnly(handle.isReadOnly());
|
|
7526
|
+
const onChange = (payload) => {
|
|
7527
|
+
if (payload.scopeReplaced) setReadOnly(handle.isReadOnly());
|
|
7528
|
+
};
|
|
7529
|
+
handle.on("change", onChange);
|
|
7530
|
+
return () => void handle.off("change", onChange);
|
|
7531
|
+
}, [handle]);
|
|
7532
|
+
return readOnly;
|
|
7533
|
+
}
|
|
7534
|
+
function useClearHistoryOnScopeSwap(handle) {
|
|
7535
|
+
const editor = useEditor();
|
|
7536
|
+
(0, import_react3.useEffect)(() => {
|
|
7537
|
+
if (!editor) return;
|
|
7538
|
+
const onChange = (payload) => {
|
|
7539
|
+
if (payload.scopeReplaced) editor.clearHistory();
|
|
7540
|
+
};
|
|
7541
|
+
handle.on("change", onChange);
|
|
7542
|
+
return () => void handle.off("change", onChange);
|
|
7543
|
+
}, [editor, handle]);
|
|
7544
|
+
}
|
|
7496
7545
|
function useAutomergePresence({
|
|
7497
7546
|
handle,
|
|
7498
7547
|
store,
|
|
@@ -8461,7 +8510,7 @@ function TldrawTool({
|
|
|
8461
8510
|
element
|
|
8462
8511
|
}) {
|
|
8463
8512
|
const handle = useDocHandle(docUrl, { suspense: true });
|
|
8464
|
-
const readOnly = handle
|
|
8513
|
+
const readOnly = useIsHandleReadOnly(handle);
|
|
8465
8514
|
const contactInfo = useContactInfo();
|
|
8466
8515
|
const store = useAutomergeStore({
|
|
8467
8516
|
handle,
|
|
@@ -8581,7 +8630,9 @@ function TldrawInner(props) {
|
|
|
8581
8630
|
const key = (0, import_react11.useMemo)(() => `${props.docUrl}-camera`, [props.docUrl]);
|
|
8582
8631
|
const editor = useEditor();
|
|
8583
8632
|
const repo = useRepo();
|
|
8633
|
+
const handle = useDocHandle(props.docUrl, { suspense: true });
|
|
8584
8634
|
usePatchworkDrop(props.element);
|
|
8635
|
+
useClearHistoryOnScopeSwap(handle);
|
|
8585
8636
|
const onChange = (0, import_react11.useCallback)(() => {
|
|
8586
8637
|
if (!editor) return;
|
|
8587
8638
|
const camstate = editor.getCameraState();
|