@quillmark/svelte 0.7.2 → 0.7.3

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.
@@ -15,5 +15,13 @@ import type { Document, CardAddr } from '@quillmark/wasm';
15
15
  * The drop is an explicit `delete`, not a stored `undefined`: whether a JS
16
16
  * `undefined` survives the wasm-bindgen crossing is not a property worth depending
17
17
  * on.
18
+ *
19
+ * **A namespace emptied of keys is removed, not stored empty.** That is
20
+ * `removeExtNamespace`'s one correct use: it takes the whole namespace, and there is
21
+ * nothing left in this one to lose. `$ext` goes with it when `editor` was the last
22
+ * namespace. A stored `{}` survives the model but not the emit, where an empty
23
+ * mapping omits its own key and leaves a bare `$ext:` that reads back as null and
24
+ * fails the next parse. A patch dropping keys the namespace does not have writes
25
+ * nothing, so dismissing tips on a document that carries none is not a mutation.
18
26
  */
19
27
  export declare function patchEditorExt(doc: Document, addr: CardAddr, patch: Record<string, unknown>): void;
@@ -14,16 +14,28 @@
14
14
  * The drop is an explicit `delete`, not a stored `undefined`: whether a JS
15
15
  * `undefined` survives the wasm-bindgen crossing is not a property worth depending
16
16
  * on.
17
+ *
18
+ * **A namespace emptied of keys is removed, not stored empty.** That is
19
+ * `removeExtNamespace`'s one correct use: it takes the whole namespace, and there is
20
+ * nothing left in this one to lose. `$ext` goes with it when `editor` was the last
21
+ * namespace. A stored `{}` survives the model but not the emit, where an empty
22
+ * mapping omits its own key and leaves a bare `$ext:` that reads back as null and
23
+ * fails the next parse. A patch dropping keys the namespace does not have writes
24
+ * nothing, so dismissing tips on a document that carries none is not a mutation.
17
25
  */
18
26
  export function patchEditorExt(doc, addr, patch) {
19
27
  // `getExtNamespace` reads just this namespace rather than serializing the whole
20
28
  // card to fish out one `$ext` slot.
21
- const next = { ...(doc.getExtNamespace(addr, 'editor') ?? {}) };
29
+ const current = doc.getExtNamespace(addr, 'editor');
30
+ const next = { ...(current ?? {}) };
22
31
  for (const [key, value] of Object.entries(patch)) {
23
32
  if (value === undefined)
24
33
  delete next[key];
25
34
  else
26
35
  next[key] = value;
27
36
  }
28
- doc.storeExtNamespace(addr, 'editor', next);
37
+ if (Object.keys(next).length > 0)
38
+ doc.storeExtNamespace(addr, 'editor', next);
39
+ else if (current)
40
+ doc.removeExtNamespace(addr, 'editor');
29
41
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@quillmark/svelte",
3
- "version": "0.7.2",
3
+ "version": "0.7.3",
4
4
  "description": "Editor, live-preview and source surfaces over a Quillmark WASM session.",
5
5
  "repository": {
6
6
  "type": "git",