castle-web-cli 0.4.248 → 0.4.250

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.
@@ -143,6 +143,7 @@ export interface ServerHubPlaceConfig {
143
143
  result?: unknown;
144
144
  maxDurationSec?: unknown;
145
145
  houseResume?: unknown;
146
+ resumeWindowSec?: unknown;
146
147
  }
147
148
  export interface ServerHubConfig extends ServerHubPlaceConfig {
148
149
  analytics?: boolean;
@@ -331,6 +331,7 @@ function hubPlaceConfig(place) {
331
331
  ...(place.result === undefined ? {} : { result: place.result }),
332
332
  ...(place.maxDurationSec === undefined ? {} : { maxDurationSec: place.maxDurationSec }),
333
333
  ...(place.houseResume === undefined ? {} : { houseResume: place.houseResume }),
334
+ ...(place.resumeWindowSec === undefined ? {} : { resumeWindowSec: place.resumeWindowSec }),
334
335
  };
335
336
  }
336
337
  function pushConfig(value) {
@@ -82,7 +82,7 @@
82
82
  "title": "base",
83
83
  "deckId": "yRcmH4_aYllE",
84
84
  "cardId": "zkFdingmIm3m",
85
- "publishedVersion": "2026-11-19T03:57:01.819Z",
85
+ "publishedVersion": "2026-11-19T05:45:37.255Z",
86
86
  "provides": [
87
87
  "castle-web-sdk"
88
88
  ]
@@ -202,6 +202,16 @@ the [atomic save API](#atomic-saves). A board has
202
202
  game state. Its `resetGeneration` is present only after an administrator has
203
203
  reset that player's progress for this deck. It is a monotonic reset marker,
204
204
  separate from the handle's `generation`, which fences playthrough operations.
205
+ Its `set(values, { check: { target, writer } })` and `remove(keys, { check })`
206
+ take the same optional writer check as `session.storage.user(id).set`: the
207
+ platform applies each request only while `writer` (from `claim`) still holds
208
+ `target`, and otherwise fails it with `CAULDRON_STORAGE_WRITER_LOST`. The check
209
+ is per request: a `set` or `remove` too big for one request is split, and when
210
+ the claim is lost partway the earlier requests stay written and the rest are not
211
+ sent. Without the option the request is unchanged. castle-web serve refuses a checked write instead of emulating it.
212
+ Writer checks are not yet supported in persistent-world sessions: there a checked
213
+ write (`set`, `remove` or `increment` on a scope, playthrough `set` or `remove`) is refused with
214
+ `CAULDRON_STORAGE_UNAVAILABLE` and nothing is written, until a server update ships.
205
215
  Deck-scope storage writes are not fenced by either generation; a server using
206
216
  `session.storage.deck` must discard its own stale queued writes and cached
207
217
  per-player values when it observes a newer reset marker.
@@ -21,7 +21,9 @@ export interface ServerStorageListPage<T extends Json = Json> {
21
21
  * `writer` (from `claim`) still holds `target` for this session, checked atomically
22
22
  * with the write; otherwise it rejects with `CAULDRON_STORAGE_WRITER_LOST`
23
23
  * (`committed: false`) and nothing is written. A `set` large enough to need several
24
- * requests checks each one, so a claim lost partway stops the rest.
24
+ * requests checks each one, so a claim lost partway stops the rest. Not yet supported
25
+ * in persistent-world sessions: there a checked write is refused with
26
+ * `CAULDRON_STORAGE_UNAVAILABLE` (nothing written) until a server update ships.
25
27
  */
26
28
  export interface ServerStorageWriteOptions {
27
29
  check?: {
@@ -69,8 +71,14 @@ export interface ServerPlaythrough {
69
71
  /** Explicit narrative changes for this same player and generation. */
70
72
  readonly characters: ServerPlaythroughCharacters;
71
73
  get<T extends Json = Json>(keys: string[]): Promise<Record<string, T>>;
72
- set(values: Record<string, Json>): Promise<void>;
73
- remove(keys: string[]): Promise<void>;
74
+ /**
75
+ * With `{ check: { target, writer } }`, as on `session.storage.user(id).set`, the
76
+ * platform applies each request only while `writer` still holds `target`'s claim
77
+ * (CAULDRON_STORAGE_WRITER_LOST otherwise). A split write is checked per request:
78
+ * requests sent before the claim was lost stay written.
79
+ */
80
+ set(values: Record<string, Json>, options?: ServerStorageWriteOptions): Promise<void>;
81
+ remove(keys: string[], options?: ServerStorageWriteOptions): Promise<void>;
74
82
  reset(operationId: string): Promise<ServerPlaythrough>;
75
83
  }
76
84
  export interface RecordCharacterEventInput {
@@ -234,15 +234,17 @@ function createPlaythrough(call, subject, generation, resetGeneration) {
234
234
  const entries = await call("playthroughGet", { subject, generation, keys: assertKeys(keys, "session.storage.playthrough.get") });
235
235
  return decodeEntries(entries, "session.storage.playthrough.get");
236
236
  },
237
- async set(values) {
237
+ async set(values, options) {
238
+ const fence = writerCheck(options, "session.storage.playthrough.set");
238
239
  const entries = encodeEntries(values, "session.storage.playthrough.set");
239
240
  for (const chunk of batched(entries, "session.storage.playthrough.set")) {
240
- await call("playthroughSet", { subject, generation, entries: chunk });
241
+ await call("playthroughSet", { subject, generation, entries: chunk, ...fence });
241
242
  }
242
243
  },
243
- async remove(keys) {
244
+ async remove(keys, options) {
245
+ const fence = writerCheck(options, "session.storage.playthrough.remove");
244
246
  for (const chunk of chunked(assertKeys(keys, "session.storage.playthrough.remove"), MAX_KEYS_PER_CALL)) {
245
- await call("playthroughDelete", { subject, generation, keys: chunk });
247
+ await call("playthroughDelete", { subject, generation, keys: chunk, ...fence });
246
248
  }
247
249
  },
248
250
  async reset(operationId) {
@@ -1547,6 +1547,15 @@ export function makeChrome({ onBack, onAvatar, onColor = () => {}, avatarCount,
1547
1547
  placeMenu.sheet.remove();
1548
1548
  placeMenu.css.remove();
1549
1549
  placeMenu.restoreHud?.();
1550
+ // Only the sheet lying over them masked the HUD and its prompt: they come
1551
+ // back with it, even while a host's own cover keeps the controls masked.
1552
+ if (placeMenu.over) {
1553
+ for (const node of [hud, hudText]) {
1554
+ if (node?.dataset) {delete node.dataset.hubMenuCovered;}
1555
+ menuCovered.delete(node);
1556
+ }
1557
+ placeMenu.over = false;
1558
+ }
1550
1559
  uncoverControls();
1551
1560
  placeMenu.sheet = placeMenu.css = placeMenu.listeners = null;
1552
1561
  placeMenu.onOpen?.(false);
@@ -1573,6 +1582,7 @@ export function makeChrome({ onBack, onAvatar, onColor = () => {}, avatarCount,
1573
1582
  actionChips, actRail, padContext?.node, companionLock,
1574
1583
  ...[...root.children].filter((node) => node.dataset?.hub === 'action-rail'),
1575
1584
  ...[...extraSurfaces.values()].filter((item) => item.kind === 'control').map((item) => item.node),
1585
+ ...(placeMenu?.sheet && placeMenu.over ? [hud, hudText] : []),
1576
1586
  ].filter((node) => node?.dataset);
1577
1587
  }
1578
1588
  // A host drawing its own covering sheet (the native UI tree menu) asks for
@@ -1589,6 +1599,24 @@ export function makeChrome({ onBack, onAvatar, onColor = () => {}, avatarCount,
1589
1599
  menuCovered.add(node);
1590
1600
  }
1591
1601
  }
1602
+ // The safe pass had no place for the open sheet at its floor height
1603
+ // (`placeMenu.floor`, short of its own height) clear of the HUD and the
1604
+ // controls: on a short web frame (497x213) the lane beside a two-line HUD
1605
+ // left a 67 px sheet whose list had no height at all. From then until it
1606
+ // closes the sheet lies over them, placed against the host corners and the
1607
+ // cards still drawn (`safeLayout.js`), and they take the covered mask as
1608
+ // under a row sheet, the HUD and its prompt too (`menuCoveredNodes`): the
1609
+ // mask is asked again every frame and never reads or writes their inline
1610
+ // visibility, which decorating rewrites.
1611
+ function menuOver() {
1612
+ if (!placeMenu?.sheet || placeMenu.over) {return;}
1613
+ placeMenu.over = true;
1614
+ if (!placeMenu.covers) {
1615
+ placeMenu.covers = true;
1616
+ placeMenu.css.textContent += ` ${MENU_COVERED_RULE}\n`;
1617
+ }
1618
+ coverControls();
1619
+ }
1592
1620
  function uncoverControls() {
1593
1621
  if (hostCover || !menuCovered.size) {return;}
1594
1622
  for (const node of menuCovered) {delete node.dataset.hubMenuCovered;}
@@ -1632,6 +1660,7 @@ export function makeChrome({ onBack, onAvatar, onColor = () => {}, avatarCount,
1632
1660
  const height = Object.hasOwn(spec, 'face') ? 40 : 55;
1633
1661
  // A short view keeps a row of choices: never under SHORT_PX (menuTree.js), short of the view.
1634
1662
  const floor = Object.hasOwn(spec, 'face') ? SHORT_FACE_PX : SHORT_PX;
1663
+ placeMenu.floor = floor;
1635
1664
  const cap = (unit) => (rows && !Object.hasOwn(spec, 'face') ? `calc(100${unit} - 24px)` : `min(max(${height}${unit}, ${floor}px), calc(100${unit} - 24px))`);
1636
1665
  const listeners = new AbortController(), signal = listeners.signal, timers = new Set();
1637
1666
  // The same column, padding, corners and shadow as the Doors/chat panels.
@@ -3420,7 +3449,8 @@ export function makeChrome({ onBack, onAvatar, onColor = () => {}, avatarCount,
3420
3449
  ] },
3421
3450
  surface('sound', sound?.button, 'control', false, { right: 12, top: 64 }), { ...surface('sound-card', sound?.card, 'card'), beside: sound?.button, offControls: true },
3422
3451
  surface('actions', actionChips), surface('ask-card', askCard, 'card'),
3423
- surface('menu', placeMenu?.sheet, 'card'), surface('text-ask', textAsk?.card, 'card'),
3452
+ { ...surface('menu', placeMenu?.sheet, 'card'), ...(placeMenu?.sheet ? { minHeight: placeMenu.floor, over: () => placeMenu?.over === true, onOver: menuOver } : {}) },
3453
+ surface('text-ask', textAsk?.card, 'card'),
3424
3454
  surface('toast', toast, 'toast', true, { top: 12 }), surface('ribbon', ribbon, 'ribbon', true),
3425
3455
  surface('cabinet', cabinet, 'card', true), surface('feed', feed, 'text', true, { left: 10 }),
3426
3456
  surface('stats', stats, 'text', true, { right: 8, top: 8 }), surface('stuck', stuckChip, 'pointer', true),
@@ -382,6 +382,8 @@ export function makeSafeLayout({ root, entries, view = globalThis.window, hud =
382
382
  // how to put it back there.
383
383
  let promptMoved = null, promptBack = null;
384
384
  promptHeld = null;
385
+ // The final box of a card lying over the chrome (`over`), if any.
386
+ let overBox = null;
385
387
  // Act prompts on a new lane; one a later surface lands on is hidden.
386
388
  let actMoved = [];
387
389
  actHeld = new Map();
@@ -446,7 +448,10 @@ export function makeSafeLayout({ root, entries, view = globalThis.window, hud =
446
448
  if (kind === 'text') {bands.push(...actMoved.map((item) => item.box));}
447
449
  }
448
450
  if (kind === 'card' || standing(entry)) {
449
- bands.push(...controls);
451
+ // A card placed after a sheet lying over the chrome (`over`) does
452
+ // not yield to it: such a card (the invite dialog) is drawn above the
453
+ // chrome and keeps its own place and size over the sheet.
454
+ bands.push(...(kind === 'card' ? controls.filter((band) => band !== overBox) : controls));
450
455
  const hudBox = visibleRect(hud());
451
456
  if (hudBox) {bands.push(hudBox);}
452
457
  }
@@ -495,7 +500,13 @@ export function makeSafeLayout({ root, entries, view = globalThis.window, hud =
495
500
  ?? clearPlacement(value, viewport, margin, hit, value.width, true)
496
501
  ?? safePlacement(value, viewport, margin);
497
502
  };
498
- const place = (value) => kind === 'card' ? panelPlacement(value, viewport, margin, bands)
503
+ // A card lying over the HUD and the controls (`over`, the place menu
504
+ // on a short frame), which its owner masks, is placed against the host
505
+ // corners and the other cards still drawn (an invite dialog over the
506
+ // chrome takes the taps where it lies).
507
+ const overBands = () => [...corners, ...current.filter((other) => other !== entry && other.kind === 'card' && !other.projected)
508
+ .map((other) => visibleRect(other.node)).filter(Boolean)];
509
+ const place = (value) => kind === 'card' ? panelPlacement(value, viewport, margin, entry.over?.() ? overBands() : bands)
499
510
  : (kind === 'text' && entry.transient) || pill ? clearText(value)
500
511
  : standing(entry) ? beside(value)
501
512
  : kind === 'pointer' && entry.transient && entry.id?.startsWith('pointer:') ? chip(value)
@@ -563,6 +574,22 @@ export function makeSafeLayout({ root, entries, view = globalThis.window, hud =
563
574
  const natural = box;
564
575
  let final = lay(place, box);
565
576
  if (!final) {continue;}
577
+ // A card with a floor (`minHeight`: the place menu keeps a row of
578
+ // choices) that its place would squeeze under it, or under its own
579
+ // height where that is less, asks to lie over the HUD and the controls
580
+ // (`onOver`) and is placed again against the corners and the cards.
581
+ if (kind === 'card' && entry.minHeight && entry.onOver && !entry.over?.()) {
582
+ const room = viewport.h - Math.max(margin?.top ?? 6, viewport.insets.top) - Math.max(margin?.bottom ?? 6, viewport.insets.bottom);
583
+ if (final.height < Math.min(entry.minHeight, natural.height, room) - 0.5) {
584
+ entry.onOver();
585
+ if (entry.over?.()) {
586
+ corrections.clearNode(node);
587
+ box = visibleRect(node);
588
+ final = box && lay(place, box);
589
+ if (!final) {continue;}
590
+ }
591
+ }
592
+ }
566
593
  // The Sound card (`offControls`) also goes beside its button when its
567
594
  // panel place lands on another control, as at 179x250.
568
595
  const own = kind === 'card' && visibleRect(entry.beside);
@@ -627,6 +654,7 @@ export function makeSafeLayout({ root, entries, view = globalThis.window, hud =
627
654
  continue;
628
655
  }
629
656
  if (kind === 'card' || entry.transient) {keepOff(final); actOff(final);}
657
+ if (final && kind === 'card' && entry.over?.()) {overBox = final;}
630
658
  if (final && !entry.transient && kind !== 'hud' && kind !== 'label' && kind !== 'pointer') {controls.push(final);}
631
659
  if (final && entry.transient) {(kind === 'label' || kind === 'pointer' ? floating : transient).push(final);}
632
660
  if (final && clear && entry.transient) {captions.push({ node, pill });}
@@ -303,6 +303,14 @@ export function create(session, optedIn) {
303
303
  }
304
304
  return Boolean(entry && active(entry) && !entry.closed && !entry.lost && (entry.unleased || entry.writer !== undefined));
305
305
  },
306
+ // v1.228: another store of the account's (a playthrough) bound to the
307
+ // claim `like` (a view from deck/user) is bound to: its `set`/`remove`
308
+ // carry that claim's writer check and run in account order, its reads
309
+ // wait for that claim. The raw store where `like` is no lease view.
310
+ bind(raw, like) {
311
+ const binding = bindings.get(like);
312
+ return enabled && raw && binding ? view(raw, binding.userId, binding.bound) : raw;
313
+ },
306
314
  ready(userId) { return enabled ? accounts.get(userId)?.ready ?? Promise.resolve() : Promise.resolve(); },
307
315
  fence(userId) { return enabled ? fenceEntry(accounts.get(userId)) : Promise.resolve(); },
308
316
  lost(userId) { return enabled && accounts.get(userId)?.lost === true; },
@@ -4171,7 +4171,12 @@ saves; a visit back inside that window claims anew the same way. A host with no
4171
4171
 
4172
4172
  `hub.saves` exposes `enabled`, `deck(userId)`, `fence(userId)`, `ready(userId)`,
4173
4173
  `lost(userId)`, `onLost(fn)` (called with the user ID; returns unsubscribe),
4174
- `onDrain(fn)` (v1.227, above; returns unsubscribe) and `holds(view)`.
4174
+ `onDrain(fn)` (v1.227, above; returns unsubscribe), `holds(view)`, and
4175
+ `bind(store, view)` (v1.228): another store of the account (a
4176
+ `session.storage.playthrough` handle) bound to the claim `view` is bound to,
4177
+ so its `set`/`remove` carry that claim's writer check and run in account
4178
+ order, and its reads wait for that claim; the store itself where `view` is
4179
+ no lease view or the lease is off.
4175
4180
  `deck` returns the raw deck store by identity when disabled or when the host
4176
4181
  lacks root `claim`/`transaction`. Otherwise its `get`/`list`/`snapshot` wait for the claim
4177
4182
  to commit or give up; `set`/`remove`/`increment`/`transaction`/`conditionalWrite`
@@ -4197,9 +4202,9 @@ check, the lease runs a separate fence first, which leaves one round trip of
4197
4202
  window: ordinary writes in `castle-web serve` and persistent-world sessions (a
4198
4203
  checked write answers `CAULDRON_STORAGE_UNAVAILABLE`, nothing sent),
4199
4204
  `conditionalWrite` on a view (its checks need a revision), and root atomic
4200
- calls (`fence(userId)`, `hub.wallet`). Playthrough writes
4201
- (`session.storage.playthrough`) carry no writer check on the platform at all;
4202
- a place can only fence before them.
4205
+ calls (`fence(userId)`, `hub.wallet`). Playthrough writes carry the writer
4206
+ check through `bind` (v1.228) where the SDK sends it; with an older SDK the
4207
+ check is dropped and only a fence before them protects them.
4203
4208
 
4204
4209
  A refused write rejects with `CAULDRON_STORAGE_WRITER_LOST` and loses the claim
4205
4210
  for good: nothing retries it, later writes fail locally, `onLost` is invoked and
@@ -5472,6 +5477,7 @@ a deck written before them remains valid.
5472
5477
  | 2026-11-18 (v1.223) | Writer leases (server-only, no wire or manifest change): a lone visit back that arrives while an earlier visit's revalidation is still out checks the claim again once that round settles (on whichever claim it settled), so a check from before another instance's takeover never lets the return proceed only to lose its first save. `resumePose` takes its snapshot through the lease view too, so it reads only once the claim settles and keeps a pose the previous writer saved just before; its 5 s read budget starts once the claim has settled. An older pending round that resumes on a replacement claim a newer arrival is already checking waits for that round and keeps the claim it found; it never inherits a claim that round reopens. A take holds its queue place at once, so an end asked while it waits for the claim runs after it. Without `writerLease` nothing changes. No deck opts in yet. |
5473
5478
  | 2026-11-18 (v1.224) | Writer leases (server-only): `await hub.saves.holds(view)` tells whether the claim a save view writes through is still active and has not been lost, after pending claim checks settle. Unrecognized views and lease-off stores answer true. No manifest or wire change. |
5474
5479
  | 2026-11-18 (v1.226) | Writer leases (server-only, no manifest or wire change): every `set`/`remove`/`increment` through a `hub.saves` view carries the platform writer check of the claim it is bound to, so a stale write is refused atomically instead of after a separate fence (the write-after-fence window is closed for ordinary writes where the platform checks). A refusal loses the claim and is never retried. Where a checked write answers `CAULDRON_STORAGE_UNAVAILABLE` (`castle-web serve`, persistent-world sessions; the details may sit under `extensions`) the session fences and writes unchecked as before; view `transaction`/`conditionalWrite` and root atomic calls keep their fence. Every lone arrival now claims anew and the place reloads (no revalidation of a held claim): queued writes of the previous visit go first for up to 5 s; claims are sent or retried only while a connected visit is here, and a resume picks a waiting claim up again. `holds(view)` also waits for the account's current claim. Without `writerLease` nothing changes. No deck opts in yet. |
5480
+ | 2026-11-18 (v1.228) | Writer leases (server-only, no manifest or wire change): `hub.saves.bind(store, view)` returns another store of the account (a `session.storage.playthrough` handle) bound to the claim `view` is bound to: `set`/`remove` carry that claim's writer check and run in account order, reads wait for that claim. The raw store when `view` is not a lease view or the lease is off. The Town conversation saves through it. No deck opts in yet. |
5475
5481
  | 2026-11-18 (v1.227) | Writer leases (server-only, no manifest or wire change): a `hub.saves` view `transaction` goes as one root transaction carrying the claim's writer check, so a superseded claim's bucket transaction is refused atomically (no fence; the receipt is unchanged). `hub.saves.onDrain(fn)` runs `fn(userId)` before a lone return waits for the previous visit's writes, so a place hands its own held writes for the account to their views first (within the same 5 s); a view's reads wait only for its own claim. Claims are compare-and-set on the lease revision read just before (`expectedRevision`, inert until the SDK carries it): a late claim after another instance's is refused, and looked again only for a connected visit. `resumePose` (lease on or off) sends a take's clear again under the same operation after a lost answer (for up to 30 s), and keeps the revision for the end save even when it arrives after the read budget. Without `writerLease` nothing changes, except that resumePose retry. No deck opts in yet. |
5476
5482
  | 2026-11-18 (v1.225) | Writer leases (server-only): a lone visit back whose claim check is refused, or still failing after 20 s, claims anew like a taken claim instead of keeping a claim its first save may find lost; writes already queued under the old claim go first under their own fences, a check that settles after the account's connected visits here have all gone (held visits count as gone) never claims anew (taken or not), and a claim still retrying stops once no visit of the account remains. `friendBests` `report(playerId, best, saves?)` under a lease writes the `fb:<key>` index through the given `hub.saves` view (else the account's view at the call), so a best whose claim was replaced never reaches the index. The write-after-fence window stays open: the platform has no writer check on ordinary writes. Without `writerLease` nothing changes. No manifest or wire change. |
5477
5483
  | 2026-10-25 (v1.193) | Town purse paid ledger: the Town deck's scope gains `paid:<userId>:<paymentId>`, an integer tokens count for one once-only payment, set once (a repeatable `set`) and never lowered or removed. Payment ids are the fixed list `bell:1`..`bell:7`, `bell:encore:1`..`bell:encore:7` and `errand:cat` (hub-town `tokens.js` `PAID`, T9). A balance is `tokens:<userId>` plus every ledger row, less hat prices and `spent:<userId>`; the Town's wardrobe read and the House's `chirpPurchases` funds read the rows by key. Each payment marks its old claim (`<earn key>:ledger`), raises it, then sets its row, so a layer on older code reads it as claimed. Ghost adds `paid` to `HUB_TOWN_PLAYER_NAMESPACES` (door-deck reads) and to the hub user reset. Compatibility: absent rows, the balance is exactly the old one; an older Town or House reader, or a Ghost without the namespace, shows a lower balance, never a higher one; this House against a Ghost without the namespace has its funds read refused, so Ghost lands first. Gifts, the day's bonuses and game results keep the old claim-then-credit path. No manifest key, wire field or SDK change. |
@@ -65,19 +65,31 @@ try {
65
65
  return { id, top: r.top, bottom: r.bottom, h: r.height, hits: hit === b || b.contains(hit), inSheet: r.top >= s.top - 0.5 && r.bottom <= s.bottom + 0.5 };
66
66
  });
67
67
  const hudNode = document.querySelector('[data-hub-copy]').parentElement;
68
- return { hudShown: getComputedStyle(hudNode).visibility === 'visible', capped: sheet.hasAttribute('data-hub-safe-max-height'), moved: sheet.hasAttribute('data-hub-safe-translate'), boxes: chrome.layout().boxes, safe: sheet.getAttribute('style').match(/--hub-safe[^;]*/g), sheet: { top: s.top, bottom: s.bottom, h: s.height }, buttons };
68
+ const seen = { hudShown: getComputedStyle(hudNode).visibility === 'visible', hudCovered: hudNode.hasAttribute('data-hub-menu-covered'), capped: sheet.hasAttribute('data-hub-safe-max-height'), moved: sheet.hasAttribute('data-hub-safe-translate'), boxes: chrome.layout().boxes, safe: sheet.getAttribute('style').match(/--hub-safe[^;]*/g), sheet: { top: s.top, bottom: s.bottom, h: s.height }, buttons };
69
+ // The safe pass's cap outranks the sheet's own height rules: written
70
+ // as that pass writes it (`safeStyle.js`), it is the height drawn.
71
+ sheet.style.setProperty('--hub-safe-max-height', '100px');
72
+ sheet.setAttribute('data-hub-safe-max-height', '');
73
+ seen.safeCapWins = sheet.getBoundingClientRect().height;
74
+ return seen;
69
75
  } finally {
70
76
  chrome.dispose();
71
77
  }
72
78
  }, { spec, showHud });
73
79
  const at = `${width}x${height} ${name}: ${JSON.stringify(seen)}`;
74
- // The live case: the shown HUD leaves the sheet a short place, so the
75
- // safe pass both caps and moves it. Without both, the cascade this
76
- // test guards was not exercised.
77
- if (showHud) assert(seen.hudShown, `the HUD is shown, ${at}`);
80
+ // The live case: the shown HUD left the sheet a short place under the
81
+ // host corners. It is moved, and lies over the HUD at its full height
82
+ // rather than under its floor (SHORT_PX), as the place menu does on a
83
+ // short frame (the look grid below).
84
+ // A sheet that lies over the HUD masks it, however its inline
85
+ // visibility is written.
86
+ if (showHud) assert(seen.hudShown !== seen.hudCovered, `the HUD is shown unless the sheet lies over it, ${at}`);
78
87
  if (showHud && width === 497 && height === 213 && name === 'confirm under the HUD') {
79
- assert(seen.capped && seen.moved, `the safe pass caps and moves the sheet, ${at}`);
88
+ assert(seen.moved && !seen.capped && seen.sheet.h >= 188.5 && seen.hudCovered, `the sheet is moved over the HUD at its full height, ${at}`);
80
89
  }
90
+ // The sheet's own rule once out-ranked the safe pass's cap while the
91
+ // move still applied, so the footer left the frame.
92
+ assert(Math.abs(seen.safeCapWins - 100) < 0.5, `the safe pass's cap outranks the sheet's own height, ${at}`);
81
93
  assert(seen.sheet.top >= -0.5 && seen.sheet.bottom <= height + 0.5, `sheet inside the frame, ${at}`);
82
94
  for (const b of seen.buttons) {
83
95
  assert(b.top >= -0.5 && b.bottom <= height + 0.5, `${b.id} inside the frame, ${at}`);
@@ -88,7 +100,158 @@ try {
88
100
  checks++;
89
101
  }
90
102
  }
91
- console.log(`menu footer: ${checks} real DOM size checks passed`);
103
+ // The place menu's tile grid (the Town's Market looks: one section, six
104
+ // tiles) on the frames a web landscape and portrait view give an embedded
105
+ // deck. On the 497x213 one (844x390 outer) the lane the safe pass found
106
+ // beside the HUD and the controls was 42-67 px tall, so the list under the
107
+ // title had no height at all and no tile could be reached. The list keeps
108
+ // at least a tile row, and every tile scrolls to a place a tap reaches.
109
+ const LOOKS = { title: 'Market looks', sections: [{ title: 'Browse', items: ['Bea · 4 hats', 'Hob · 4 hats', 'Fern · 4 hats', 'Skip · 4 hats', 'Market Cart', 'My goal'].map((label, i) => ({ id: `look-${i}`, label })) }] };
110
+ const GRID_SIZES = [[497, 213], [707, 303], [844, 390], [390, 844], [574, 246], [640, 200], [800, 360]];
111
+ let grid = 0;
112
+ for (const [width, height] of GRID_SIZES) {
113
+ await page.setViewportSize({ width, height });
114
+ await page.goto('http://layout.test/');
115
+ // Live (R246, Nov 19): the HUD's two lines and controls either side of
116
+ // the bottom of the frame, which left the sheet a lane 192 px wide.
117
+ for (const [name, controls] of [['look grid under the HUD', false], ['look grid under the HUD between controls', true]]) {
118
+ const seen = await page.evaluate(async ({ spec, controls }) => {
119
+ const { makeChrome } = await import('/kits/hub-game/code/client/chrome.js');
120
+ const chrome = makeChrome({ avatarCount: 1, onBack() {}, onAvatar() {}, safeInsets: true });
121
+ const extra = [];
122
+ try {
123
+ chrome.setHud({ title: 'The town remembers you', text: 'Come and see Mabel.' }, null);
124
+ if (controls) {
125
+ for (const [id, side] of [['test-left', 'left'], ['test-right', 'right']]) {
126
+ const node = document.createElement('button');
127
+ Object.assign(node.style, { position: 'fixed', [side]: '6px', bottom: '6px', width: `${Math.round(innerWidth * 0.26)}px`, height: '150px', pointerEvents: 'auto', zIndex: '2147483000' });
128
+ document.body.appendChild(node);
129
+ extra.push(node);
130
+ chrome.safeSurface(id, node, 'control');
131
+ }
132
+ }
133
+ chrome.setMenu({ n: 1, spec }, () => {});
134
+ const settle = async () => {
135
+ for (let i = 0; i < 3; i++) {
136
+ // A frame as the hub's loop draws it (`hub.js`).
137
+ chrome.beginLayoutFrame();
138
+ chrome.endLayoutFrame();
139
+ chrome.flushSafeInsets();
140
+ await new Promise(resolve => requestAnimationFrame(() => requestAnimationFrame(resolve)));
141
+ chrome.frameSafeInsets();
142
+ }
143
+ };
144
+ await settle();
145
+ const sheet = document.querySelector('[data-hub="menu"]');
146
+ const body = [...sheet.querySelectorAll('div')].find((node) => getComputedStyle(node).overflowY === 'auto');
147
+ const box = (node) => { const r = node.getBoundingClientRect(); return { top: r.top, bottom: r.bottom, left: r.left, right: r.right }; };
148
+ const hits = (node) => { const r = node.getBoundingClientRect(); const hit = document.elementFromPoint((r.left + r.right) / 2, (r.top + r.bottom) / 2); return hit === node || node.contains(hit); };
149
+ const close = sheet.querySelector('[aria-label="Close"]');
150
+ const seen = { sheet: box(sheet), body: { ...box(body), client: body.clientHeight, scroll: body.scrollHeight }, close: { ...box(close), hits: hits(close) }, hudShown: getComputedStyle(document.querySelector('[data-hub-copy]').parentElement).visibility === 'visible', latched: document.querySelector('[data-hub-copy]').parentElement.hasAttribute('data-hub-menu-covered'), tiles: [] };
151
+ const tileHeight = sheet.querySelector('.hub-menu-tile').getBoundingClientRect().height;
152
+ seen.tileHeight = tileHeight;
153
+ for (const tile of sheet.querySelectorAll('.hub-menu-tile')) {
154
+ // The player scrolls the list until the tile shows.
155
+ tile.scrollIntoView({ block: 'nearest', inline: 'nearest' });
156
+ await new Promise(resolve => requestAnimationFrame(resolve));
157
+ const r = box(tile), b = box(body);
158
+ seen.tiles.push({ id: tile.dataset.id, ...r, inBody: r.top >= b.top - 0.5 && r.bottom <= b.bottom + 0.5, hits: hits(tile) });
159
+ }
160
+ // The lifecycle of a sheet lying over the HUD: the HUD stays masked
161
+ // while decorating rewrites its inline visibility, a control made
162
+ // while it is open is masked too, and closing it gives everything
163
+ // back; the next sheet starts unlatched.
164
+ const hudNode = document.querySelector('[data-hub-copy]').parentElement;
165
+ const shown = (node) => getComputedStyle(node).visibility === 'visible';
166
+ const late = document.createElement('button');
167
+ Object.assign(late.style, { position: 'fixed', left: '50%', top: '40%', width: '40px', height: '40px', pointerEvents: 'auto' });
168
+ document.body.appendChild(late);
169
+ extra.push(late);
170
+ chrome.safeSurface('test-late', late, 'control');
171
+ hudNode.style.visibility = '';
172
+ await settle();
173
+ seen.over = { hud: shown(hudNode), late: shown(late), controls: extra.slice(0, -1).map(shown) };
174
+ chrome.cancelMenu();
175
+ await settle();
176
+ seen.closed = { hud: shown(hudNode), late: shown(late), controls: extra.slice(0, -1).map(shown), sheet: Boolean(document.querySelector('[data-hub="menu"]')) };
177
+ chrome.setMenu({ n: 2, spec: { ...spec, title: 'Again' } }, () => {});
178
+ const again = document.querySelector('[data-hub="menu"]');
179
+ seen.again = { hud: shown(hudNode), covered: again.querySelector('style').textContent.includes('data-hub-menu-covered') };
180
+ // A host's own cover (the native menu) masks only the controls:
181
+ // a latched sheet closed under it gives the HUD back.
182
+ await settle();
183
+ chrome.coverControls(true);
184
+ chrome.cancelMenu();
185
+ await settle();
186
+ seen.hostCover = { hud: shown(hudNode), late: shown(late) };
187
+ chrome.coverControls(false);
188
+ return seen;
189
+ } finally {
190
+ chrome.dispose();
191
+ for (const node of extra) {node.remove();}
192
+ }
193
+ }, { spec: LOOKS, controls });
194
+ const at = `${width}x${height} ${name}: ${JSON.stringify(seen)}`;
195
+ assert(seen.sheet.top >= -0.5 && seen.sheet.bottom <= height + 0.5, `sheet inside the frame, ${at}`);
196
+ assert(seen.close.top >= -0.5 && seen.close.bottom <= height + 0.5 && seen.close.hits, `Close inside the frame and reached, ${at}`);
197
+ assert(seen.body.client >= seen.tileHeight - 0.5, `the list keeps at least a row of tiles, ${at}`);
198
+ assert.equal(seen.tiles.length, 6, `six tiles, ${at}`);
199
+ for (const tile of seen.tiles) {
200
+ assert(tile.top >= -0.5 && tile.bottom <= height + 0.5 && tile.inBody, `${tile.id} scrolls inside the frame, ${at}`);
201
+ assert(tile.hits, `a tap on ${tile.id} reaches it, ${at}`);
202
+ }
203
+ const latched = seen.latched;
204
+ if (width === 497 && height === 213) {assert(latched, `the sheet lies over the HUD here, ${at}`);}
205
+ if (latched) {
206
+ assert(!seen.over.hud && !seen.over.late && seen.over.controls.every((on) => !on), `the HUD and every control, a late one too, are masked under the sheet, ${at}`);
207
+ assert(!seen.closed.sheet && seen.closed.hud && seen.closed.late && seen.closed.controls.every(Boolean), `closing the sheet gives them back, ${at}`);
208
+ assert(seen.again.hud && !seen.again.covered, `the next sheet starts unlatched, ${at}`);
209
+ assert(seen.hostCover.hud && !seen.hostCover.late, `a host's cover keeps the controls, not the HUD, once the sheet closes, ${at}`);
210
+ }
211
+ grid++;
212
+ }
213
+ }
214
+ // A card drawn over the chrome (the invite dialog, outside the mask) keeps
215
+ // its taps: a sheet that lies over the HUD is placed off it where it can
216
+ // be, and where it cannot (an invite at its full 473x189) the invite keeps
217
+ // its whole size over the sheet instead of yielding to it.
218
+ for (const [w, h] of [[120, 99], [473, 189]]) {
219
+ await page.setViewportSize({ width: 497, height: 213 });
220
+ await page.goto('http://layout.test/');
221
+ const seen = await page.evaluate(async ({ spec, w, h }) => {
222
+ const { makeChrome } = await import('/kits/hub-game/code/client/chrome.js');
223
+ const chrome = makeChrome({ avatarCount: 1, onBack() {}, onAvatar() {}, safeInsets: true });
224
+ const invite = document.createElement('section');
225
+ Object.assign(invite.style, { position: 'fixed', zIndex: '2147480001', left: '6px', bottom: '12px', width: `${w}px`, height: `${h}px`, pointerEvents: 'auto', background: '#241a2e' });
226
+ document.body.appendChild(invite);
227
+ try {
228
+ chrome.setHud({ title: 'The town remembers you', text: 'Come and see Mabel.' }, null);
229
+ chrome.safeSurface('invite-dialog', invite, 'card');
230
+ chrome.setMenu({ n: 1, spec }, () => {});
231
+ for (let i = 0; i < 3; i++) {
232
+ chrome.flushSafeInsets();
233
+ await new Promise(resolve => requestAnimationFrame(() => requestAnimationFrame(resolve)));
234
+ chrome.frameSafeInsets();
235
+ }
236
+ const box = (node) => { const r = node.getBoundingClientRect(); return { left: r.left, top: r.top, right: r.right, bottom: r.bottom }; };
237
+ const i = box(invite);
238
+ const hit = document.elementFromPoint((i.left + i.right) / 2, (i.top + i.bottom) / 2);
239
+ return { sheet: box(document.querySelector('[data-hub="menu"]')), invite: { ...i, hits: hit === invite || invite.contains(hit) }, hudCovered: document.querySelector('[data-hub-copy]').parentElement.hasAttribute('data-hub-menu-covered') };
240
+ } finally {
241
+ chrome.dispose();
242
+ invite.remove();
243
+ }
244
+ }, { spec: LOOKS, w, h });
245
+ const at = `497x213 look grid beside a ${w}x${h} invite card: ${JSON.stringify(seen)}`;
246
+ const { sheet, invite } = seen;
247
+ assert(seen.hudCovered, `the sheet lies over the HUD, ${at}`);
248
+ assert(invite.hits && invite.bottom - invite.top >= h - 0.5 && invite.top >= -0.5 && invite.bottom <= 213.5, `the invite keeps its size and its taps, ${at}`);
249
+ if (w === 120) {
250
+ assert(sheet.right <= invite.left + 0.5 || sheet.left >= invite.right - 0.5 || sheet.bottom <= invite.top + 0.5 || sheet.top >= invite.bottom - 0.5, `the sheet keeps off the card, ${at}`);
251
+ }
252
+ grid++;
253
+ }
254
+ console.log(`menu footer: ${checks} real DOM size checks passed; look grid: ${grid} short-frame checks passed`);
92
255
  } finally {
93
256
  await browser.close();
94
257
  }
@@ -671,3 +671,23 @@ test('a visit that leaves while its claim reads the lease sends no claim (round
671
671
  assert.equal(writerOf('101'), current, 'B keeps the account');
672
672
  await b.api.deck('101').set({ mine: 1 });
673
673
  });
674
+
675
+ test('bind gives another store of the account the claim of a view (v1.228)', async t => {
676
+ const { instance } = setup(t), a = instance('a'), b = instance('b');
677
+ a.lease.join('p1', '101'); await a.api.ready('101');
678
+ const view = a.api.deck('101');
679
+ const sent = [];
680
+ const play = { async get() { return {}; }, async set(values, options) { sent.push(options); a.checkAs?.(options?.check); }, generation: 1 };
681
+ const bound = a.api.bind(play, view);
682
+ assert.equal(bound.generation, 1);
683
+ await bound.set({ 'said:x': 1 });
684
+ assert.deepEqual(sent[0].check.target, { scope: 'user', subject: '101', prefix: 'hub:writer:' });
685
+ assert.equal(a.api.bind(play, {}), play, 'no lease view: the raw store');
686
+ b.lease.join('p2', '101'); await b.api.ready('101');
687
+ // A new claim here makes a store bound to the old view refuse locally.
688
+ a.lease.leave('p1'); a.lease.join('p3', '101'); await a.api.ready('101');
689
+ await assert.rejects(bound.set({ 'said:x': 2 }), lost);
690
+ assert.equal(sent.length, 1);
691
+ const off = create({ storage: a.storage }, false);
692
+ assert.equal(off.api.bind(play, view), play, 'lease off: the raw store');
693
+ });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "castle-web-cli",
3
- "version": "0.4.248",
3
+ "version": "0.4.250",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git+https://github.com/castle-xyz/castle-experimental-web.git"