@quillmark/svelte 0.45.0 → 0.46.0

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/README.md CHANGED
@@ -1,8 +1,8 @@
1
1
  # @quillmark/svelte
2
2
 
3
- Editor + live-preview components for [quillmark](https://github.com/birdorbs/quillmark) WASM consumers. A WYSIWYG **VisualEditor**, and a canvas **Preview** that paints the compiled document and round-trips clicks to the editor, over one `@quillmark/wasm` session. Vanilla-TS cores with thin Svelte 5 wrappers.
3
+ Editor + live-preview components for [Quillmark](https://github.com/birdorbs/quillmark) WASM consumers. A WYSIWYG **VisualEditor**, and a canvas **Preview** that paints the compiled document and round-trips clicks to the editor, over one `@quillmark/wasm` session. Vanilla-TS cores with thin Svelte 5 wrappers.
4
4
 
5
- quillmark is pre-1.0. Its [stability statement](https://github.com/birdorbs/quillmark#status) says what any release can change and what every release keeps.
5
+ Quillmark is pre-1.0. Its [stability statement](https://github.com/birdorbs/quillmark#status) says what any release can change and what every release keeps.
6
6
 
7
7
  ## Install
8
8
 
@@ -41,7 +41,7 @@ const quill = Quill.fromTree(tree); // tree: Map<string, Uint8Array> of the quil
41
41
  const doc = quill.seedDocument();
42
42
 
43
43
  // An EXISTING document: parsed back from what you stored.
44
- const doc = Document.parse(markdown); // canonical quillmark markdown
44
+ const doc = Document.parse(markdown); // canonical Quillmark markdown
45
45
  const doc = Document.fromStored(json); // the versioned storage DTO (`doc.toStored()`)
46
46
 
47
47
  const session = await new Engine().open(quill, doc);
@@ -112,7 +112,7 @@ A host that opens several documents keys this shell on the document and guards i
112
112
 
113
113
  `ws.editor` and `ws.preview` are handler objects: spread them, or call one from a handler of the shell's own, as one that also saves each edit does with `onChange={(change) => { save(); ws.editor.onChange(change); }}`. The surfaces are read through getters because a preview mounts only once a session stands, so its ref arrives late. `onState` hands over a new `state` on every change: the `session` to mount the preview over, `diagnostics` for the editor, `formats` the backend emits, `review`, which is `none`, `shown` (the preview compiles the open review's projection) or `failed` (the projection did not compile, so the preview shows the document), and `status`, which is `opening`, `ready`, `refused` (the engine refused the last open or compile with `refused`; a session that stands still paints its last good compile, and the next edit after a refused open opens again), `paint-failed` (until the next edit) or `trapped`. `diagnostics` takes the shell's own as a getter, merged once each at every compile.
114
114
 
115
- `trapped` is terminal: the render build trapped (`runtime::backend_trapped`), so its state is undefined, the session is dropped for the preview to unmount and then freed, and nothing compiles or opens again until the page reloads; editing continues, on the core build. The render build is one per process, so a workspace created after a trap starts `trapped`.
115
+ `trapped` is terminal: the render build trapped (`runtime::backend_trapped`), so its state is undefined, the session is dropped for the preview to unmount and then freed, and nothing compiles or opens again until the page reloads; editing continues, on the core build. The engine latches the trap for its build, so a workspace standing beside the one that trapped, or created after it, meets the trap at its next call and ends `trapped` too, as does one whose host met the trap outside it.
116
116
 
117
117
  `ws.wrote(structural)` is the door for a write the shell made to the document itself: `true` compiles at once, as a card operation does, and otherwise the compile debounces as a keystroke's. `ws.flush()` runs a pending compile now and resolves once the page is current, for a shell that marks the page. `ws.render(format)` compiles a pending edit, waits on the open, and resolves `undefined` where the document does not compile, so a download is the document in hand, never a proposal the reader has not accepted, even while the preview shows one. `ws.doc` and `ws.quill` are the handles the editor mounts over. `ws.dispose(unmounted)` hands `onState` a state with no session, awaits `unmounted` so the surfaces go first, then frees the session.
118
118
 
@@ -340,7 +340,7 @@ const engine = new Engine({ fonts: [carlito] });
340
340
  <VisualEditor {doc} {quill} {fonts} />
341
341
  ```
342
342
 
343
- [`@quillmark/fonts`](../fonts) is the library every quillmark client builds its engine over, so a family a document names sets the same way in each; a host's own files go after it. `fontFaces` loads the render build, as `open` does, so mount the editor first and let the faces arrive behind it. A family the document already sets edits with no library at all, and the picker offers it so it can be cleared.
343
+ [`@quillmark/fonts`](../fonts) is the library every Quillmark client builds its engine over, so a family a document names sets the same way in each; a host's own files go after it. `fontFaces` loads the render build, as `open` does, so mount the editor first and let the faces arrive behind it. A family the document already sets edits with no library at all, and the picker offers it so it can be cleared.
344
344
 
345
345
  ### Recompiling
346
346
 
@@ -390,7 +390,7 @@ Both editor→preview hops or neither. A control reports its focus and no caret
390
390
 
391
391
  A pick carries a caret where the compile tracks the content under the point, and the field alone where it tracks only the placement — a scalar the plate prints without tracking. `setCaret` takes both: an absent `pos` reveals and focuses the field, which is the whole of what a click on plate-placed ink can mean. The address may name an array element (`main.keywords[0]`), which lands on that row.
392
392
 
393
- A consumer holding an `Addr` of its own maps it with the Document's `pathFor`. The playground's split-pane route takes both directions from the workspace, through a review projection and under a collaboration room; its landing page mounts the surfaces on their own verbs, with no workspace under them.
393
+ A consumer holding an `Addr` of its own maps it with the Document's `pathFor`. The playground's split-pane route takes both directions from the workspace, through a review projection and under a collaboration room; its `/surfaces` route mounts the surfaces on their own verbs, with no workspace under them.
394
394
 
395
395
  ## Errors
396
396
 
@@ -409,7 +409,7 @@ This is not the diagnostics channel. A `Diagnostic` is about the **document** an
409
409
 
410
410
  ## Canonical markdown
411
411
 
412
- `doc.toMarkdown()` returns the document's canonical quillmark markdown, which re-parses to an equal `Document`. A read-only mirror is that call in a `<pre>`, re-run after each edit lands, so it needs no surface from this package:
412
+ `doc.toMarkdown()` returns the document's canonical Quillmark markdown, which re-parses to an equal `Document`. A read-only mirror is that call in a `<pre>`, re-run after each edit lands, so it needs no surface from this package:
413
413
 
414
414
  ```ts
415
415
  el.textContent = doc.toMarkdown();
@@ -1,8 +1,4 @@
1
1
  export declare const TRAPPED = "runtime::backend_trapped";
2
- /** Whether the render build has trapped in this process: its state is undefined from then, so
3
- * nothing compiles, opens or paints on it again until the page reloads. */
4
- export declare function backendTrapped(): boolean;
5
- /** Whether `err` is the engine's trap. */
2
+ /** Whether `err` is the engine's trap. The engine latches it, so every later call into the trapped
3
+ * build rejects with it. */
6
4
  export declare function isBackendTrap(err: unknown): boolean;
7
- export declare function latch(): void;
8
- export declare function unlatch(): void;
@@ -1,20 +1,7 @@
1
- // The render build is one instance per process, so a trap in it is one latch for every
2
- // workspace in the process. `unlatch` is the tests' door.
3
1
  import { isQuillmarkError } from '@quillmark/wasm';
4
2
  export const TRAPPED = 'runtime::backend_trapped';
5
- let latched = false;
6
- /** Whether the render build has trapped in this process: its state is undefined from then, so
7
- * nothing compiles, opens or paints on it again until the page reloads. */
8
- export function backendTrapped() {
9
- return latched;
10
- }
11
- /** Whether `err` is the engine's trap. */
3
+ /** Whether `err` is the engine's trap. The engine latches it, so every later call into the trapped
4
+ * build rejects with it. */
12
5
  export function isBackendTrap(err) {
13
6
  return isQuillmarkError(err) && err.diagnostics.some((d) => d.code === TRAPPED);
14
7
  }
15
- export function latch() {
16
- latched = true;
17
- }
18
- export function unlatch() {
19
- latched = false;
20
- }
@@ -3,7 +3,7 @@
3
3
  // from the state it is handed.
4
4
  import { isQuillmarkError } from '@quillmark/wasm';
5
5
  import { errorMessage, reportError } from '../core/errors.js';
6
- import { backendTrapped, isBackendTrap, latch } from './trap.js';
6
+ import { isBackendTrap } from './trap.js';
7
7
  const SETTLE_MS = 120;
8
8
  /** What makes two diagnostics the same one: one message at two lines of a plate is two. */
9
9
  const keyOf = (d) => [
@@ -43,7 +43,7 @@ export function createWorkspace(opts) {
43
43
  let refused = [];
44
44
  let formats = [];
45
45
  let paintFailed = false;
46
- let trapped = backendTrapped();
46
+ let trapped = false;
47
47
  let disposed = false;
48
48
  let timer;
49
49
  let opening;
@@ -89,7 +89,6 @@ export function createWorkspace(opts) {
89
89
  function trap(err) {
90
90
  if (trapped)
91
91
  return;
92
- latch();
93
92
  trapped = true;
94
93
  stop();
95
94
  if (err !== undefined)
@@ -104,22 +103,16 @@ export function createWorkspace(opts) {
104
103
  emit();
105
104
  setTimeout(() => freeQuietly(lost), 0);
106
105
  }
107
- /** Whether this workspace is trapped, taking up a trap another one in the process latched. */
108
- function struck() {
109
- if (!trapped && backendTrapped())
110
- trap();
111
- return trapped;
112
- }
113
106
  function open() {
114
107
  behind = false;
115
108
  const run = (async () => {
116
109
  try {
117
110
  const engine = await opts.engine;
118
111
  formats = await engine.supportedFormats(quill);
119
- if (struck())
112
+ if (trapped)
120
113
  return;
121
114
  const opened = await engine.open(quill, doc);
122
- if (disposed || struck())
115
+ if (disposed || trapped)
123
116
  return freeQuietly(opened);
124
117
  session = opened;
125
118
  refused = [];
@@ -172,7 +165,7 @@ export function createWorkspace(opts) {
172
165
  }
173
166
  function compile() {
174
167
  stop();
175
- if (disposed || struck())
168
+ if (disposed || trapped)
176
169
  return Promise.resolve();
177
170
  if (!session) {
178
171
  if (!opening)
@@ -258,8 +251,7 @@ export function createWorkspace(opts) {
258
251
  void compile();
259
252
  }
260
253
  }
261
- if (!trapped)
262
- void open();
254
+ void open();
263
255
  return {
264
256
  get state() {
265
257
  return state;
@@ -322,7 +314,7 @@ export function createWorkspace(opts) {
322
314
  if (disposed)
323
315
  return undefined;
324
316
  await flush();
325
- if (disposed || struck() || !session)
317
+ if (disposed || trapped || !session)
326
318
  return undefined;
327
319
  if (review === 'shown')
328
320
  return renderDocument(session, format);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@quillmark/svelte",
3
- "version": "0.45.0",
3
+ "version": "0.46.0",
4
4
  "description": "Editor, live-preview and source surfaces over a Quillmark WASM session.",
5
5
  "repository": {
6
6
  "type": "git",
@@ -59,7 +59,7 @@
59
59
  "check": "svelte-check --tsconfig ./tsconfig.json --fail-on-warnings"
60
60
  },
61
61
  "peerDependencies": {
62
- "@quillmark/wasm": ">=0.142.0-0",
62
+ "@quillmark/wasm": ">=0.142.1-0",
63
63
  "svelte": "^5.33.0"
64
64
  },
65
65
  "dependencies": {