@quillmark/svelte 0.38.0 → 0.39.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.
@@ -110,6 +110,30 @@ export function createReview(source) {
110
110
  const key = listed[item.after];
111
111
  return key !== undefined && standing.has(key) ? key : 'end';
112
112
  }
113
+ /** What the appends of each append's run at higher indices add, in index order, by its id:
114
+ * read off the host's whole list, answered items with it, since an accepted one's member
115
+ * is what a later-taken one lands in front of. */
116
+ const later = $derived.by(() => {
117
+ const runs = new Map();
118
+ for (const item of source.items() ?? []) {
119
+ if (!onField(item) || source.exact(item.field))
120
+ continue;
121
+ const deep = source.nested(item.field);
122
+ const at = deep?.steps.at(-1);
123
+ if (!deep || typeof at !== 'number' || 'ahead' in item || !putsIn(item, deep.steps))
124
+ continue;
125
+ const run = `${deep.key} ${JSON.stringify(deep.steps.slice(0, -1))}`;
126
+ runs.set(run, [...(runs.get(run) ?? []), { at, id: item.id, after: item.after }]);
127
+ }
128
+ const out = new Map();
129
+ for (const run of runs.values())
130
+ for (const { at, id } of run)
131
+ out.set(id, run
132
+ .filter((other) => other.at > at)
133
+ .sort((a, b) => a.at - b.at)
134
+ .map((other) => other.after));
135
+ return out;
136
+ });
113
137
  const placed = $derived.by(() => {
114
138
  const out = new Map();
115
139
  const undrawn = [...cards.undrawn];
@@ -133,10 +157,10 @@ export function createReview(source) {
133
157
  const claimed = claims.get(deep.key) ?? new Set();
134
158
  claims.set(deep.key, claimed);
135
159
  const held = out.get(deep.key) ?? {};
136
- const { steps, found } = locate(deep.value, deep.steps, item, claimed);
137
- if ((held.nested ?? []).some((e) => sameValue(e.steps, steps) &&
138
- putsIn(e.item) === putsIn(item) &&
139
- !runsOfOne(e.item, item))) {
160
+ const adds = putsIn(item, deep.steps);
161
+ const { steps, found } = locate(deep.value, deep.steps, item, claimed, later.get(item.id));
162
+ if (!adds &&
163
+ (held.nested ?? []).some((e) => sameValue(e.steps, steps) && !putsIn(e.item, e.steps) && !runsOfOne(e.item, item))) {
140
164
  undrawn.push({ id: item.id, reason: 'taken' });
141
165
  continue;
142
166
  }
@@ -349,6 +373,7 @@ export function createReview(source) {
349
373
  return place && valueIn(place.value, place.steps);
350
374
  },
351
375
  at: (key) => fields.get(key) ?? {},
376
+ later: (id) => later.get(id) ?? [],
352
377
  marks: (key) => fields.has(key) || !!drawn.get(key)?.ids.length,
353
378
  keyOf(id) {
354
379
  const item = byId.get(id);
@@ -488,6 +513,7 @@ const NO_REVIEW = {
488
513
  cards: { adds: new Map(), removes: new Map() },
489
514
  wrote() { },
490
515
  at: () => ({}),
516
+ later: () => [],
491
517
  marks: () => false,
492
518
  keyOf: () => undefined,
493
519
  drew() { },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@quillmark/svelte",
3
- "version": "0.38.0",
3
+ "version": "0.39.0",
4
4
  "description": "Editor, live-preview and source surfaces over a Quillmark WASM session.",
5
5
  "repository": {
6
6
  "type": "git",