@jskit-ai/shell-web 0.2.21 → 0.2.23

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/CHANGELOG.md CHANGED
@@ -2,6 +2,7 @@
2
2
 
3
3
  ## Unreleased
4
4
 
5
+ - `shell.bootstrap.refresh()` runs one bootstrap request at a time and keeps at most one more waiting: everyone who asks while one waits shares it, and it reads the route and the handlers' request only when it starts. Each call used to queue its own request, so a burst of N realtime events or auth state reads fetched and applied the whole bootstrap N times in a row; it now does so at most twice.
5
6
  - The navigation bar's destinations (`ShellTabLinkItem`) are plain `v-btn`s with an icon and a label, drawn by `@jskit-ai/material-web`'s `material.css` as every `v-bottom-navigation` is: their icon is 24dp in the 64x32 indicator (it was 19dp), and `.tab-link-item__indicator` is gone (the indicator is the icon's own box, `.tab-link-item .v-icon`).
6
7
  - On compact windows the top app bar moves only the top-right items it has no room for into its overflow menu: the items stay while they fit beside the whole page title, and those that don't follow the page actions into the menu, farthest from the corner first. The item nearest the corner (the account avatar) still stays unless the page's primary action takes its place, and medium and wider windows are unchanged. The bar used to decide by the window's size class alone, so a short title and three small icons went into the menu. It measures the title and its items as drawn, and again when the bar's content changes (a new title, an item's count, a page action), when the window is resized and when fonts load. Each top-right item now renders once and moves between the bar and the menu as the same component, and the menu keeps it mounted while it is closed: an item that does more than draw a button (a live count, a panel, a floating button it teleports above the navigation bar) existed only while the menu was open on a phone, and was created anew each time it moved. `ShellPageActionsTarget` keeps its `#menu` slot mounted while the menu is closed and takes `menu-items` (default true), false while the slot holds nothing to show. `ShellLayout` sizes the title's `h1` to its text, up to the room it has.
7
8
  - `ShellLayout`'s drawer fits its labels and identity by default (what `drawerWidth="content"` did), instead of Material 3's fixed 360dp, so an app no longer wraps `ShellLayout` to get a narrow drawer. It stays within 120-360dp and, as a modal drawer, leaves 56dp of the page beside it. `drawerWidth="material"` gives Material 3's full 360dp (narrowed on a small window, as before), a number still fixes the width and `"content"` still fits it. `runAdaptiveShellSmokeCase` reads the drawer's width again while it settles, and accepts a fitted drawer at its 120dp minimum or one its identity widens past the labels.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jskit-ai/shell-web",
3
- "version": "0.2.21",
3
+ "version": "0.2.23",
4
4
  "type": "module",
5
5
  "scripts": {
6
6
  "test": "jskit test"
@@ -46,14 +46,14 @@
46
46
  "./locales/en.json": "./locales/en.json"
47
47
  },
48
48
  "dependencies": {
49
- "@jskit-ai/architecture-inspector": "0.1.15"
49
+ "@jskit-ai/architecture-inspector": "0.1.16"
50
50
  },
51
51
  "devDependencies": {
52
52
  "@jskit-ai/material-web": "0.1.5",
53
53
  "@vue/compiler-sfc": "3.5.44"
54
54
  },
55
55
  "peerDependencies": {
56
- "@jskit-ai/kernel": "0.2.17",
56
+ "@jskit-ai/kernel": "0.2.18",
57
57
  "pinia": "^4.0.3",
58
58
  "vue": "^3.5.44",
59
59
  "vue-router": "^5.3.1",
@@ -48,7 +48,8 @@ function createShellBootstrapRuntime({
48
48
  bootstrapPath = BOOTSTRAP_PATH
49
49
  }) {
50
50
  let initialized = false;
51
- let refreshQueue = Promise.resolve();
51
+ let runningRefresh = null;
52
+ let pendingRefresh = null;
52
53
 
53
54
  async function resolveBootstrapRequest(reason = "manual") {
54
55
  const payloadHandlers = handlers.list();
@@ -165,9 +166,27 @@ function createShellBootstrapRuntime({
165
166
  }
166
167
  }
167
168
 
169
+ function startRefresh(reason) {
170
+ runningRefresh = performRefresh(reason).finally(() => {
171
+ runningRefresh = null;
172
+ });
173
+ return runningRefresh;
174
+ }
175
+
176
+ // One refresh runs and at most one waits: everyone asking while one waits
177
+ // shares it, since it resolves its request only when it starts.
168
178
  function refresh(reason = "manual") {
169
- refreshQueue = refreshQueue.catch(() => null).then(() => performRefresh(reason));
170
- return refreshQueue;
179
+ if (pendingRefresh) {
180
+ return pendingRefresh;
181
+ }
182
+ if (!runningRefresh) {
183
+ return startRefresh(reason);
184
+ }
185
+ pendingRefresh = runningRefresh.catch(() => null).then(() => {
186
+ pendingRefresh = null;
187
+ return startRefresh(reason);
188
+ });
189
+ return pendingRefresh;
171
190
  }
172
191
 
173
192
  async function initialize() {
@@ -234,3 +234,58 @@ test("shell bootstrap runtime queue recovers after a refresh rejects", async ()
234
234
  await assert.rejects(runtime.refresh("manual"), /error handler failed/);
235
235
  assert.deepEqual(await runtime.refresh("manual"), { recovered: true });
236
236
  });
237
+
238
+ test("shell bootstrap runtime runs one refresh and lets every later caller share one waiting refresh", async () => {
239
+ const handlers = createBootstrapPayloadHandlerRegistry();
240
+ const placementRuntime = createPlacementRuntime({ step: "first" });
241
+ const appliedReasons = [];
242
+ handlers.register(Object.freeze({
243
+ handlerId: "test.bootstrap.coalesce",
244
+ order: 0,
245
+ resolveBootstrapRequest({ placementRuntime: runtimePlacement }) {
246
+ return { query: { step: runtimePlacement.getContext().step } };
247
+ },
248
+ applyBootstrapPayload({ reason }) {
249
+ appliedReasons.push(reason);
250
+ },
251
+ handleBootstrapError() {}
252
+ }));
253
+ const fetched = [];
254
+ let releaseFirst = () => {};
255
+ const firstHeld = new Promise((resolve) => {
256
+ releaseFirst = resolve;
257
+ });
258
+ const runtime = createShellBootstrapRuntime({
259
+ handlers,
260
+ placementRuntime,
261
+ logger: silentLogger,
262
+ fetchImplementation: async (url) => {
263
+ fetched.push(url);
264
+ if (fetched.length === 1) {
265
+ await firstHeld;
266
+ }
267
+ return {
268
+ ok: true,
269
+ async json() {
270
+ return { url };
271
+ }
272
+ };
273
+ }
274
+ });
275
+
276
+ const first = runtime.refresh("init");
277
+ const waiting = [runtime.refresh("auth.state"), runtime.refresh("realtime"), runtime.refresh("route")];
278
+ await new Promise((resolve) => setTimeout(resolve, 0));
279
+ placementRuntime.setContext({ step: "second" });
280
+ releaseFirst();
281
+
282
+ assert.deepEqual(await first, { url: "/api/bootstrap?step=first" });
283
+ for (const result of await Promise.all(waiting)) {
284
+ assert.deepEqual(result, { url: "/api/bootstrap?step=second" });
285
+ }
286
+ assert.deepEqual(fetched, ["/api/bootstrap?step=first", "/api/bootstrap?step=second"]);
287
+ assert.deepEqual(appliedReasons, ["init", "auth.state"]);
288
+
289
+ assert.deepEqual(await runtime.refresh("manual"), { url: "/api/bootstrap?step=second" });
290
+ assert.equal(fetched.length, 3);
291
+ });