@lmzhen/dsh-evolution-client-kit 0.47.0 → 0.48.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/lib/index.js CHANGED
@@ -4,20 +4,58 @@ import "./generated/contracts.generated.js";
4
4
  import { Block, FailureBlock, failureText, loadStateOf } from "./generated/states.generated.js";
5
5
  import { TOKENS, TOKEN_CSS, tokenVars } from "./tokens.js";
6
6
  import { createRequire } from "node:module";
7
- import { createElement, useState } from "react";
7
+ import { createElement } from "react";
8
8
  //#region \0rolldown/runtime.js
9
9
  var __require = /* @__PURE__ */ createRequire(import.meta.url);
10
- /** Fail loud when a client bundle is mounted without the shell seats it consumes. */
11
- function requireClientSeats(ctx, owner) {
12
- const candidate = ctx;
13
- if (candidate.slots === void 0 || candidate.locale === void 0) throw new Error(owner + ": the client slots/locale seats are not mounted");
14
- return candidate;
15
- }
16
10
  function interpolate(text, values) {
17
11
  if (values === void 0) return text;
18
12
  return text.replace(/\{(\w+)\}/g, (_match, key) => String(values[key] ?? ""));
19
13
  }
20
- function injectStyles$1(doc, css, tagId) {
14
+ /**
15
+ * Fill `{slot}` placeholders, keeping an unmatched placeholder visible.
16
+ * This is the panel-copy contract (a missing value is a bug to see, not an empty string).
17
+ */
18
+ function fillTemplate(text, values) {
19
+ if (values === void 0) return text;
20
+ return text.replace(/\{(\w+)\}/g, (match, key) => {
21
+ const value = values[key];
22
+ return value === void 0 ? match : String(value);
23
+ });
24
+ }
25
+ /** Register one namespace's dictionaries and bind a fallback-first lookup. */
26
+ function bindLocale(ctx, namespace, dictionaries, fallback = "en", register = true) {
27
+ const seam = ctx;
28
+ let registered = !register;
29
+ if (register) ctx.effect(() => {
30
+ try {
31
+ const dispose = seam.locale.register(namespace, dictionaries);
32
+ registered = true;
33
+ return dispose;
34
+ } catch (error) {
35
+ ctx.logger.warn(namespace + ": the locale seat refused the dictionary (" + String(error) + "); falls back to the bundle copy");
36
+ return () => {};
37
+ }
38
+ }, namespace + ": locale");
39
+ const own = dictionaries[fallback] ?? dictionaries.en;
40
+ const lookup = (key) => {
41
+ const fallbackText = own[key] ?? key;
42
+ if (!registered) return fallbackText;
43
+ try {
44
+ return seam.locale.bind(namespace)(key);
45
+ } catch {
46
+ return fallbackText;
47
+ }
48
+ };
49
+ return {
50
+ t: (key, values) => interpolate(lookup(key), values),
51
+ label: () => lookup("entry.label")
52
+ };
53
+ }
54
+ //#endregion
55
+ //#region lib/types/styles.js
56
+ /** The one owner of plugin `<style>` tags; a new owner replaces the old tag so the
57
+ * old disposer only removes a detached node. */
58
+ function injectPluginStyles(doc, css, tagId) {
21
59
  if (doc === void 0) return () => {};
22
60
  doc.querySelector("style[data-plugin-css=\"" + tagId + "\"]")?.remove();
23
61
  const tag = doc.createElement("style");
@@ -28,6 +66,14 @@ function injectStyles$1(doc, css, tagId) {
28
66
  tag.remove();
29
67
  };
30
68
  }
69
+ //#endregion
70
+ //#region lib/types/panel.js
71
+ /** Fail loud when a client bundle is mounted without the shell seats it consumes. */
72
+ function requireClientSeats(ctx, owner) {
73
+ const candidate = ctx;
74
+ if (candidate.slots === void 0 || candidate.locale === void 0) throw new Error(owner + ": the client slots/locale seats are not mounted");
75
+ return candidate;
76
+ }
31
77
  /**
32
78
  * Register one sidebar row and its main body under one lifecycle.
33
79
  * @param ctx - the client context carrying the slots and locale seats.
@@ -35,30 +81,8 @@ function injectStyles$1(doc, css, tagId) {
35
81
  */
36
82
  function registerSidebarPanel(ctx, spec) {
37
83
  const seam = ctx;
38
- let registered = false;
39
- ctx.effect(() => {
40
- try {
41
- const dispose = seam.locale.register(spec.namespace, spec.dictionaries);
42
- registered = true;
43
- return dispose;
44
- } catch (error) {
45
- ctx.logger.warn(spec.namespace + ": the locale seat refused the dictionary (" + String(error) + "); the panel falls back to the bundle copy");
46
- return () => {};
47
- }
48
- }, spec.namespace + ": locale");
49
- ctx.effect(() => injectStyles$1(typeof document === "undefined" ? void 0 : document, spec.styles.css, spec.styles.tagId), spec.namespace + ": styles");
50
- const fallback = spec.dictionaries[spec.fallback ?? "en"] ?? spec.dictionaries.en;
51
- const lookup = (key) => {
52
- const own = fallback[key] ?? key;
53
- if (!registered) return own;
54
- try {
55
- return seam.locale.bind(spec.namespace)(key);
56
- } catch {
57
- return own;
58
- }
59
- };
60
- const t = (key, values) => interpolate(lookup(key), values);
61
- const label = () => lookup("entry.label");
84
+ ctx.effect(() => injectPluginStyles(typeof document === "undefined" ? void 0 : document, spec.styles.css, spec.styles.tagId), spec.namespace + ": styles");
85
+ const { t, label } = bindLocale(ctx, spec.namespace, spec.dictionaries, spec.fallback ?? "en");
62
86
  seam.slots.inject("sidebar.panellist", function* () {
63
87
  yield seam.slots.register({
64
88
  name: "sidebar.panellist",
@@ -77,17 +101,6 @@ function registerSidebarPanel(ctx, spec) {
77
101
  }
78
102
  //#endregion
79
103
  //#region lib/types/workbench-view.js
80
- function injectStyles(doc, css, tagId) {
81
- if (doc === void 0) return () => {};
82
- doc.querySelector("style[data-plugin-css=\"" + tagId + "\"]")?.remove();
83
- const tag = doc.createElement("style");
84
- tag.setAttribute("data-plugin-css", tagId);
85
- tag.textContent = css;
86
- doc.head.appendChild(tag);
87
- return () => {
88
- tag.remove();
89
- };
90
- }
91
104
  /**
92
105
  * Register one view into `evolution.workbench.view`.
93
106
  * @param ctx - client cordis context.
@@ -95,33 +108,8 @@ function injectStyles(doc, css, tagId) {
95
108
  */
96
109
  function registerWorkbenchView(ctx, spec) {
97
110
  const seam = ctx;
98
- let registered = false;
99
- ctx.effect(() => {
100
- try {
101
- const dispose = seam.locale.register(spec.namespace, spec.dictionaries);
102
- registered = true;
103
- return dispose;
104
- } catch (error) {
105
- ctx.logger.warn(spec.namespace + ": locale refused (" + String(error) + "); the view falls back to the bundle copy");
106
- return () => {};
107
- }
108
- }, spec.namespace + ": locale");
109
- ctx.effect(() => injectStyles(typeof document === "undefined" ? void 0 : document, spec.styles.css, spec.styles.tagId), spec.namespace + ": styles");
110
- const fallback = spec.dictionaries["en"];
111
- const lookup = (key) => {
112
- const own = fallback[key] ?? key;
113
- if (!registered) return own;
114
- try {
115
- return seam.locale.bind(spec.namespace)(key);
116
- } catch {
117
- return own;
118
- }
119
- };
120
- const t = (key, values) => {
121
- const template = lookup(key);
122
- if (values === void 0) return template;
123
- return template.replace(/\{(\w+)\}/g, (match, slot) => values[slot] === void 0 ? match : String(values[slot]));
124
- };
111
+ ctx.effect(() => injectPluginStyles(typeof document === "undefined" ? void 0 : document, spec.styles.css, spec.styles.tagId), spec.namespace + ": styles");
112
+ const { t } = bindLocale(ctx, spec.namespace, spec.dictionaries);
125
113
  seam.slots.inject("evolution.workbench.view", function* () {
126
114
  yield seam.slots.register({
127
115
  name: "evolution.workbench.view",
@@ -149,112 +137,6 @@ function panelWorkspaceId(ctx) {
149
137
  } catch {}
150
138
  }
151
139
  //#endregion
152
- //#region lib/types/async-resource.js
153
- /**
154
- * One read operation's lifecycle: initial load, background refresh, stale-answer
155
- * suppression, and an explicit failure slot. Consumers derive `empty` from a
156
- * successful `data` value; this type never conflates "not loaded yet" with
157
- * "loaded and empty".
158
- * @module @lmzhen/dsh-evolution-client-kit
159
- */
160
- /**
161
- * Serialize one resource's reads without remounting the consumer.
162
- */
163
- var AsyncResource = class {
164
- #state = Object.freeze({
165
- status: "loading",
166
- refreshing: false,
167
- data: void 0,
168
- failure: void 0,
169
- generation: 0
170
- });
171
- #listeners = /* @__PURE__ */ new Set();
172
- #generation = 0;
173
- #controller;
174
- #disposed = false;
175
- /** @returns the stable snapshot for uSES. */
176
- getSnapshot() {
177
- return this.#state;
178
- }
179
- /**
180
- * Observe snapshot replacements.
181
- * @param listener - called after each publish.
182
- * @returns the disposer.
183
- */
184
- subscribe(listener) {
185
- this.#listeners.add(listener);
186
- return () => {
187
- this.#listeners.delete(listener);
188
- };
189
- }
190
- /**
191
- * Run one read. A prior read is aborted; only this generation may publish.
192
- * @param load - loader receiving the cancellation signal.
193
- * @returns settlement after this generation commits or is superseded.
194
- */
195
- async load(load) {
196
- if (this.#disposed) return;
197
- const generation = this.#generation + 1;
198
- this.#generation = generation;
199
- this.#controller?.abort();
200
- const controller = new AbortController();
201
- this.#controller = controller;
202
- const previous = this.#state;
203
- this.#publish({
204
- status: previous.data === void 0 ? "loading" : "ready",
205
- refreshing: previous.data !== void 0,
206
- data: previous.data,
207
- failure: previous.failure,
208
- generation
209
- });
210
- try {
211
- const data = await load(controller.signal);
212
- if (this.#disposed || generation !== this.#generation) return;
213
- this.#publish({
214
- status: "ready",
215
- refreshing: false,
216
- data,
217
- failure: void 0,
218
- generation
219
- });
220
- } catch (failure) {
221
- if (this.#disposed || generation !== this.#generation || controller.signal.aborted) return;
222
- this.#publish({
223
- status: previous.data === void 0 ? "error" : "ready",
224
- refreshing: false,
225
- data: previous.data,
226
- failure,
227
- generation
228
- });
229
- }
230
- }
231
- /** Drop the current value and return to the initial loading state. */
232
- reset() {
233
- this.#generation += 1;
234
- this.#controller?.abort();
235
- this.#controller = void 0;
236
- this.#publish({
237
- status: "loading",
238
- refreshing: false,
239
- data: void 0,
240
- failure: void 0,
241
- generation: this.#generation
242
- });
243
- }
244
- /** Abort the in-flight read and stop notifying. */
245
- dispose() {
246
- this.#disposed = true;
247
- this.#generation += 1;
248
- this.#controller?.abort();
249
- this.#controller = void 0;
250
- this.#listeners.clear();
251
- }
252
- #publish(state) {
253
- this.#state = Object.freeze(state);
254
- for (const listener of this.#listeners) listener();
255
- }
256
- };
257
- //#endregion
258
140
  //#region lib/types/format.js
259
141
  /** Parse an ISO string, epoch ms, or null into a valid Date; null when absent/invalid. */
260
142
  function toLocalDate(value) {
@@ -304,23 +186,6 @@ function isSameLocalDay(value, now = /* @__PURE__ */ new Date()) {
304
186
  return date.getFullYear() === now.getFullYear() && date.getMonth() === now.getMonth() && date.getDate() === now.getDate();
305
187
  }
306
188
  //#endregion
307
- //#region lib/types/notice.js
308
- /** One inline state notice: semantic tone plus text, no surface-specific styling. */
309
- /**
310
- * Render one informative/warning/error line. The caller owns the surface class and CSS;
311
- * this leaf owns only the accessible role and the fact/count split.
312
- * @param props - tone, text, optional count/class.
313
- * @returns a semantic state notice.
314
- */
315
- function StateNotice({ tone, text, count, className }) {
316
- return createElement("div", {
317
- "data-role": "state-notice",
318
- "data-tone": tone,
319
- role: tone === "error" ? "alert" : "status",
320
- ...className === void 0 ? {} : { className }
321
- }, createElement("span", { "data-role": "state-notice-text" }, text), count === void 0 ? null : createElement("span", { "data-role": "state-notice-count" }, String(count)));
322
- }
323
- //#endregion
324
189
  //#region lib/types/presentation/decision-frame.js
325
190
  /** One decision card: title, facts, at most one primary, secondary actions and details. */
326
191
  function actionButton$1(action, role) {
@@ -370,31 +235,6 @@ function TaskBanner({ count, text, className }) {
370
235
  }, createElement("strong", { "data-role": "task-banner-count" }, String(count)), createElement("span", { "data-role": "task-banner-text" }, text));
371
236
  }
372
237
  //#endregion
373
- //#region lib/types/presentation/chips.js
374
- /** Read-only status chips and toggleable filter chips. */
375
- /** Render one semantic status word. */
376
- function StatusChip({ label, tone = "neutral", className }) {
377
- return createElement("span", {
378
- "data-role": "status-chip",
379
- "data-tone": tone,
380
- ...className === void 0 ? {} : { className }
381
- }, label);
382
- }
383
- /** Render a toggleable filter with the pressed state exposed to assistive tech. */
384
- function FilterChip({ label, active, onClick, count, disabled = false, className }) {
385
- return createElement("button", {
386
- type: "button",
387
- "data-role": "filter-chip",
388
- "data-active": active ? "true" : "false",
389
- "aria-pressed": active ? "true" : "false",
390
- disabled,
391
- ...className === void 0 ? {} : { className },
392
- onClick: () => {
393
- if (!disabled) onClick();
394
- }
395
- }, createElement("span", { "data-role": "filter-chip-label" }, label), count === void 0 ? null : createElement("span", { "data-role": "filter-chip-count" }, String(count)));
396
- }
397
- //#endregion
398
238
  //#region lib/types/presentation/empty-state.js
399
239
  /** A compact completed/empty state with at most one primary next step. */
400
240
  function actionButton(action, role) {
@@ -445,36 +285,6 @@ const RESPONSIVE_TABLE_CSS = [
445
285
  "}"
446
286
  ].join(String.fromCharCode(10));
447
287
  //#endregion
448
- //#region lib/types/presentation/disclosure-group.js
449
- /** A native details group for normal/secondary facts. */
450
- /** Render a closed-by-default disclosure without introducing another accordion model. */
451
- function DisclosureGroup({ summary, count, children, defaultOpen = false, className }) {
452
- return createElement("details", {
453
- "data-role": "disclosure-group",
454
- ...defaultOpen ? { open: true } : {},
455
- ...className === void 0 ? {} : { className }
456
- }, createElement("summary", { "data-role": "disclosure-summary" }, createElement("span", { "data-role": "disclosure-title" }, summary), count === void 0 ? null : createElement("span", { "data-role": "disclosure-count" }, String(count))), createElement("div", { "data-role": "disclosure-content" }, children));
457
- }
458
- //#endregion
459
- //#region lib/types/presentation/time-text.js
460
- /** The one local-time presentation used by reading surfaces. */
461
- /**
462
- * Render a local wall time, or a neutral dash when the fact is unknown.
463
- * @param props - ISO/epoch value and seconds preference.
464
- * @returns a time element with the raw value in dateTime when valid.
465
- */
466
- function TimeText({ value, seconds = true, className }) {
467
- const text = formatLocalDateTime(value, { seconds });
468
- const ms = typeof value === "number" ? value : typeof value === "string" ? Date.parse(value) : NaN;
469
- const raw = Number.isFinite(ms) ? new Date(ms).toISOString() : void 0;
470
- return createElement("time", {
471
- "data-role": "time-text",
472
- ...raw === void 0 ? {} : { dateTime: raw },
473
- ...text === null ? {} : { title: text },
474
- ...className === void 0 ? {} : { className }
475
- }, text ?? "—");
476
- }
477
- //#endregion
478
288
  //#region lib/types/presentation/action-menu.js
479
289
  /**
480
290
  * The one seam onto the platform's menu material, plus a small fallback for deployments
@@ -482,31 +292,6 @@ function TimeText({ value, seconds = true, className }) {
482
292
  */
483
293
  const PLATFORM_UI_MODULE = "@deepseek-ai/dsh-client-ui-primitives";
484
294
  /**
485
- * Render the coordinate/action menu through the platform primitives, or a plain fallback.
486
- * @param props - rows, accessible label, position/style and optional primitive override.
487
- * @returns the menu element.
488
- */
489
- function ActionMenu({ actions, label, style, className, primitives = PLATFORM_MENU }) {
490
- if (primitives !== void 0) return renderPlatformMenu(primitives, actions, label, style ?? {}, className);
491
- return createElement("div", {
492
- "data-role": "action-menu-fallback",
493
- role: "menu",
494
- "aria-label": label,
495
- ...style === void 0 ? {} : { style },
496
- ...className === void 0 ? {} : { className }
497
- }, actions.map((action) => createElement("button", {
498
- key: action.id,
499
- type: "button",
500
- role: "menuitem",
501
- disabled: action.disabled === true,
502
- "data-danger": action.danger === true ? "true" : "false",
503
- ...action.separatorBefore === true ? { "data-separator-before": "true" } : {},
504
- onClick: () => {
505
- if (action.disabled !== true) action.onSelect();
506
- }
507
- }, action.label)));
508
- }
509
- /**
510
295
  * Render the platform menu directly. Kept exported for callers that already own the primitive row.
511
296
  * @param primitives - platform MenuSurface/MenuItemButton pair.
512
297
  * @param actions - rows in display order.
@@ -555,51 +340,6 @@ const PLATFORM_MENU = (() => {
555
340
  }
556
341
  })();
557
342
  //#endregion
558
- //#region lib/types/action.js
559
- /**
560
- * Command-only actions. Approval decisions are a separate host API and must never
561
- * be represented as a copyable command here.
562
- * @module @lmzhen/dsh-evolution-client-kit
563
- */
564
- /**
565
- * Copy one command and report the host verdict.
566
- * @param action - the command action.
567
- * @param writeClipboard - platform clipboard writer.
568
- * @param confirm - optional in-UI confirmation.
569
- * @returns the settled copy status.
570
- */
571
- async function copyAction(action, writeClipboard, confirm) {
572
- if (action.enabled === false) return "idle";
573
- if (confirm !== void 0 && !confirm(action)) return "idle";
574
- if (action.confirm !== void 0 && !action.confirm(action)) return "idle";
575
- try {
576
- return await writeClipboard(action.command) ? "copied" : "failed";
577
- } catch {
578
- return "failed";
579
- }
580
- }
581
- /**
582
- * Render one command-copy action with real success/failure feedback.
583
- * @param props - action, clipboard writer, and localized labels.
584
- * @returns the button and its status line.
585
- */
586
- function CommandCopyButton({ action, writeClipboard, labels, className }) {
587
- const [status, setStatus] = useState("idle");
588
- const text = status === "copying" ? labels.copying : status === "copied" ? labels.copied : status === "failed" ? labels.failed : labels.copy;
589
- return createElement("span", { className }, createElement("button", {
590
- type: "button",
591
- disabled: action.enabled === false || status === "copying",
592
- "aria-label": action.label,
593
- onClick: () => {
594
- setStatus("copying");
595
- copyAction(action, writeClipboard).then(setStatus);
596
- }
597
- }, action.label), createElement("span", {
598
- role: "status",
599
- "aria-live": "polite"
600
- }, text === labels.copy ? "" : text));
601
- }
602
- //#endregion
603
343
  //#region lib/types/surface.js
604
344
  /**
605
345
  * Shared opaque page surface. Skin images may sit behind the shell; every
@@ -611,4 +351,4 @@ const PAGE_SURFACE_CLASS = "evolution-page-surface";
611
351
  /** Stylesheet for {@link PAGE_SURFACE_CLASS}; consumers append it to their own CSS. */
612
352
  const PAGE_SURFACE_CSS = ".evolution-page-surface{min-height:100%;background:var(--dsw-alias-bg-base);color:var(--dsw-alias-label-primary)}";
613
353
  //#endregion
614
- export { ActionMenu, AsyncResource, Block, CommandCopyButton, DecisionFrame, DisclosureGroup, EmptyState, FALLBACKS, FailureBlock, FilterChip, PAGE_SURFACE_CLASS, PAGE_SURFACE_CSS, PLATFORM_MENU, RESPONSIVE_TABLE_CSS, ROUTES, StateNotice, StatusChip, TOKENS, TOKEN_CSS, TaskBanner, TimeText, copyAction, failureText, formatLocalClock, formatLocalDateTime, isSameLocalDay, loadStateOf, menuPrimitivesFrom, panelWorkspaceId, registerSidebarPanel, registerWorkbenchView, renderPlatformMenu, requireClientSeats, tokenVars };
354
+ export { Block, DecisionFrame, EmptyState, FALLBACKS, FailureBlock, PAGE_SURFACE_CLASS, PAGE_SURFACE_CSS, PLATFORM_MENU, RESPONSIVE_TABLE_CSS, ROUTES, TOKENS, TOKEN_CSS, TaskBanner, bindLocale, failureText, fillTemplate, formatLocalClock, formatLocalDateTime, injectPluginStyles, isSameLocalDay, loadStateOf, menuPrimitivesFrom, panelWorkspaceId, registerSidebarPanel, registerWorkbenchView, renderPlatformMenu, requireClientSeats, tokenVars };
@@ -27,8 +27,6 @@ export interface DiagnosticsView {
27
27
  readonly facts: readonly DocFactRow[];
28
28
  readonly runtime: readonly DiagnosticRow[];
29
29
  }
30
- /** The installation form the doctor reports (W8 install-form-detected row). */
31
- export type InstallFormId = 'M1' | 'M2' | 'M3' | 'M4';
32
30
  /** One surface's command-face path(s) — the client `fallbacks.generated.ts` table's row type. */
33
31
  export interface FallbackHint {
34
32
  readonly command: string;
@@ -4,25 +4,19 @@ export { registerSidebarPanel, requireClientSeats, type SidebarPanelSpec, type T
4
4
  export { registerWorkbenchView } from './workbench-view.ts';
5
5
  export type { WorkbenchViewSpec } from './workbench-view.ts';
6
6
  export { panelWorkspaceId } from './workspace.ts';
7
- export { AsyncResource } from './async-resource.ts';
8
7
  export { formatLocalClock, formatLocalDateTime, isSameLocalDay, type LocalDateTimeOptions } from './format.ts';
9
- export { StateNotice, type StateNoticeProps, type StateNoticeTone } from './notice.ts';
10
8
  export { DecisionFrame, type DecisionFrameProps } from './presentation/decision-frame.ts';
11
9
  export { TaskBanner, type TaskBannerProps } from './presentation/task-banner.ts';
12
- export { StatusChip, FilterChip, type StatusChipProps, type FilterChipProps } from './presentation/chips.ts';
13
10
  export { EmptyState, type EmptyStateProps } from './presentation/empty-state.ts';
14
11
  export { RESPONSIVE_TABLE_CSS } from './presentation/table.ts';
15
- export { DisclosureGroup, type DisclosureGroupProps } from './presentation/disclosure-group.ts';
16
- export { TimeText, type TimeTextProps } from './presentation/time-text.ts';
17
- export { ActionMenu, PLATFORM_MENU, renderPlatformMenu, menuPrimitivesFrom, type ActionMenuProps, type RowMenuAction, type MenuPrimitives, type MenuSurfaceComponent, type MenuItemButtonComponent } from './presentation/action-menu.ts';
12
+ export { PLATFORM_MENU, renderPlatformMenu, menuPrimitivesFrom, type RowMenuAction, type MenuPrimitives, type MenuSurfaceComponent, type MenuItemButtonComponent } from './presentation/action-menu.ts';
18
13
  export type { PresentationTone, PresentationAction, DecisionFact, DecisionModel } from './presentation/types.ts';
19
- export { CommandCopyButton, copyAction } from './action.ts';
20
- export type { ActionRef, CommandCopyButtonProps, CommandCopyLabels, CopyStatus } from './action.ts';
21
- export type { AsyncLoader, AsyncState, AsyncStatus } from './async-resource.ts';
22
14
  export { ROUTES } from './generated/routes.generated.ts';
23
15
  export { FALLBACKS } from './generated/fallbacks.generated.ts';
24
16
  export * from './generated/contracts.generated.ts';
25
17
  export * from './generated/states.generated.ts';
26
18
  export { TOKEN_CSS, TOKENS, tokenVars } from './tokens.ts';
27
19
  export { PAGE_SURFACE_CLASS, PAGE_SURFACE_CSS } from './surface.ts';
20
+ export { injectPluginStyles } from './styles.ts';
21
+ export { fillTemplate, bindLocale } from './locale.ts';
28
22
  //# sourceMappingURL=index.d.ts.map
@@ -1,22 +1,18 @@
1
1
  export { registerSidebarPanel, requireClientSeats } from "./panel.js";
2
2
  export { registerWorkbenchView } from "./workbench-view.js";
3
3
  export { panelWorkspaceId } from "./workspace.js";
4
- export { AsyncResource } from "./async-resource.js";
5
4
  export { formatLocalClock, formatLocalDateTime, isSameLocalDay } from "./format.js";
6
- export { StateNotice } from "./notice.js";
7
5
  export { DecisionFrame } from "./presentation/decision-frame.js";
8
6
  export { TaskBanner } from "./presentation/task-banner.js";
9
- export { StatusChip, FilterChip } from "./presentation/chips.js";
10
7
  export { EmptyState } from "./presentation/empty-state.js";
11
8
  export { RESPONSIVE_TABLE_CSS } from "./presentation/table.js";
12
- export { DisclosureGroup } from "./presentation/disclosure-group.js";
13
- export { TimeText } from "./presentation/time-text.js";
14
- export { ActionMenu, PLATFORM_MENU, renderPlatformMenu, menuPrimitivesFrom } from "./presentation/action-menu.js";
15
- export { CommandCopyButton, copyAction } from "./action.js";
9
+ export { PLATFORM_MENU, renderPlatformMenu, menuPrimitivesFrom } from "./presentation/action-menu.js";
16
10
  export { ROUTES } from "./generated/routes.generated.js";
17
11
  export { FALLBACKS } from "./generated/fallbacks.generated.js";
18
12
  export * from "./generated/contracts.generated.js";
19
13
  export * from "./generated/states.generated.js";
20
14
  export { TOKEN_CSS, TOKENS, tokenVars } from "./tokens.js";
21
15
  export { PAGE_SURFACE_CLASS, PAGE_SURFACE_CSS } from "./surface.js";
16
+ export { injectPluginStyles } from "./styles.js";
17
+ export { fillTemplate, bindLocale } from "./locale.js";
22
18
  //# sourceMappingURL=index.js.map
@@ -0,0 +1,17 @@
1
+ import type { Context as ClientContext } from '@deepseek-ai/cordis';
2
+ import type { LocaleDictionaries } from './seam.ts';
3
+ import type { SupportedLocale } from './generated/i18n.generated.ts';
4
+ export declare const FALLBACK_LOCALE: "en";
5
+ /** Dictionary lookup used by the panel body and row label. */
6
+ export type Translate = (key: string, values?: Readonly<Record<string, string | number>>) => string;
7
+ /**
8
+ * Fill `{slot}` placeholders, keeping an unmatched placeholder visible.
9
+ * This is the panel-copy contract (a missing value is a bug to see, not an empty string).
10
+ */
11
+ export declare function fillTemplate(text: string, values?: Readonly<Record<string, string | number>>): string;
12
+ /** Register one namespace's dictionaries and bind a fallback-first lookup. */
13
+ export declare function bindLocale(ctx: ClientContext, namespace: string, dictionaries: LocaleDictionaries, fallback?: SupportedLocale, register?: boolean): {
14
+ readonly t: Translate;
15
+ readonly label: () => string;
16
+ };
17
+ //# sourceMappingURL=locale.d.ts.map
@@ -0,0 +1,53 @@
1
+ export const FALLBACK_LOCALE = 'en';
2
+ function interpolate(text, values) {
3
+ if (values === undefined)
4
+ return text;
5
+ return text.replace(/\{(\w+)\}/g, (_match, key) => String(values[key] ?? ''));
6
+ }
7
+ /**
8
+ * Fill `{slot}` placeholders, keeping an unmatched placeholder visible.
9
+ * This is the panel-copy contract (a missing value is a bug to see, not an empty string).
10
+ */
11
+ export function fillTemplate(text, values) {
12
+ if (values === undefined)
13
+ return text;
14
+ return text.replace(/\{(\w+)\}/g, (match, key) => {
15
+ const value = values[key];
16
+ return value === undefined ? match : String(value);
17
+ });
18
+ }
19
+ /** Register one namespace's dictionaries and bind a fallback-first lookup. */
20
+ export function bindLocale(ctx, namespace, dictionaries, fallback = FALLBACK_LOCALE, register = true) {
21
+ const seam = ctx;
22
+ let registered = !register;
23
+ if (register) {
24
+ ctx.effect(() => {
25
+ try {
26
+ const dispose = seam.locale.register(namespace, dictionaries);
27
+ registered = true;
28
+ return dispose;
29
+ }
30
+ catch (error) {
31
+ ctx.logger.warn(namespace + ': the locale seat refused the dictionary (' + String(error) + '); falls back to the bundle copy');
32
+ return () => { };
33
+ }
34
+ }, namespace + ': locale');
35
+ }
36
+ const own = dictionaries[fallback] ?? dictionaries.en;
37
+ const lookup = (key) => {
38
+ const fallbackText = own[key] ?? key;
39
+ if (!registered)
40
+ return fallbackText;
41
+ try {
42
+ return seam.locale.bind(namespace)(key);
43
+ }
44
+ catch {
45
+ return fallbackText;
46
+ }
47
+ };
48
+ return {
49
+ t: (key, values) => interpolate(lookup(key), values),
50
+ label: () => lookup('entry.label'),
51
+ };
52
+ }
53
+ //# sourceMappingURL=locale.js.map
@@ -6,10 +6,9 @@ import type { Context as ClientContext } from '@deepseek-ai/cordis';
6
6
  import type { ReactNode } from 'react';
7
7
  import type { ClientSeam, LocaleDictionaries } from './seam.ts';
8
8
  import type { SupportedLocale } from './generated/i18n.generated.ts';
9
- /** Dictionary lookup used by the panel body and row label. */
10
- export type Translate = (key: string, values?: Readonly<Record<string, string | number>>) => string;
9
+ import { type Translate } from './locale.ts';
10
+ export type { Translate } from './locale.ts';
11
11
  /** The feature-specific part of one sidebar panel. */
12
- export declare const FALLBACK_LOCALE: "en";
13
12
  export interface SidebarPanelSpec<Face> {
14
13
  /** The row id; the keyed main body uses the same value. */
15
14
  id: string;
@@ -1,5 +1,5 @@
1
- /** The feature-specific part of one sidebar panel. */
2
- export const FALLBACK_LOCALE = 'en';
1
+ import { bindLocale, FALLBACK_LOCALE } from "./locale.js";
2
+ import { injectPluginStyles } from "./styles.js";
3
3
  /** Fail loud when a client bundle is mounted without the shell seats it consumes. */
4
4
  export function requireClientSeats(ctx, owner) {
5
5
  const candidate = ctx;
@@ -8,24 +8,6 @@ export function requireClientSeats(ctx, owner) {
8
8
  }
9
9
  return candidate;
10
10
  }
11
- function interpolate(text, values) {
12
- if (values === undefined)
13
- return text;
14
- return text.replace(/\{(\w+)\}/g, (_match, key) => String(values[key] ?? ''));
15
- }
16
- function injectStyles(doc, css, tagId) {
17
- if (doc === undefined)
18
- return () => { };
19
- const previous = doc.querySelector('style[data-plugin-css="' + tagId + '"]');
20
- // P2-29: a new owner must OUTLIVE the old owner's disposer. Replace the tag
21
- // instead of reusing it: the old disposer then removes a detached node.
22
- previous?.remove();
23
- const tag = doc.createElement('style');
24
- tag.setAttribute('data-plugin-css', tagId);
25
- tag.textContent = css;
26
- doc.head.append(tag);
27
- return () => { tag.remove(); };
28
- }
29
11
  /**
30
12
  * Register one sidebar row and its main body under one lifecycle.
31
13
  * @param ctx - the client context carrying the slots and locale seats.
@@ -33,33 +15,8 @@ function injectStyles(doc, css, tagId) {
33
15
  */
34
16
  export function registerSidebarPanel(ctx, spec) {
35
17
  const seam = ctx;
36
- let registered = false;
37
- ctx.effect(() => {
38
- try {
39
- const dispose = seam.locale.register(spec.namespace, spec.dictionaries);
40
- registered = true;
41
- return dispose;
42
- }
43
- catch (error) {
44
- ctx.logger.warn(spec.namespace + ': the locale seat refused the dictionary (' + String(error) + '); the panel falls back to the bundle copy');
45
- return () => { };
46
- }
47
- }, spec.namespace + ': locale');
48
- ctx.effect(() => injectStyles(typeof document === 'undefined' ? undefined : document, spec.styles.css, spec.styles.tagId), spec.namespace + ': styles');
49
- const fallback = spec.dictionaries[spec.fallback ?? FALLBACK_LOCALE] ?? spec.dictionaries.en;
50
- const lookup = (key) => {
51
- const own = fallback[key] ?? key;
52
- if (!registered)
53
- return own;
54
- try {
55
- return seam.locale.bind(spec.namespace)(key);
56
- }
57
- catch {
58
- return own;
59
- }
60
- };
61
- const t = (key, values) => interpolate(lookup(key), values);
62
- const label = () => lookup('entry.label');
18
+ ctx.effect(() => injectPluginStyles(typeof document === 'undefined' ? undefined : document, spec.styles.css, spec.styles.tagId), spec.namespace + ': styles');
19
+ const { t, label } = bindLocale(ctx, spec.namespace, spec.dictionaries, spec.fallback ?? FALLBACK_LOCALE);
63
20
  seam.slots.inject('sidebar.panellist', function* () {
64
21
  yield seam.slots.register({ name: 'sidebar.panellist', id: spec.id, order: spec.order, label }, spec.icon);
65
22
  yield seam.slots.register({
@@ -30,20 +30,6 @@ export interface RowMenuAction {
30
30
  readonly disabled?: boolean | undefined;
31
31
  readonly danger?: boolean | undefined;
32
32
  }
33
- /** Props for the shared action menu. */
34
- export interface ActionMenuProps {
35
- readonly actions: readonly RowMenuAction[];
36
- readonly label: string;
37
- readonly style?: Record<string, string | number> | undefined;
38
- readonly className?: string | undefined;
39
- readonly primitives?: MenuPrimitives | undefined;
40
- }
41
- /**
42
- * Render the coordinate/action menu through the platform primitives, or a plain fallback.
43
- * @param props - rows, accessible label, position/style and optional primitive override.
44
- * @returns the menu element.
45
- */
46
- export declare function ActionMenu({ actions, label, style, className, primitives }: ActionMenuProps): ReactNode;
47
33
  /**
48
34
  * Render the platform menu directly. Kept exported for callers that already own the primitive row.
49
35
  * @param primitives - platform MenuSurface/MenuItemButton pair.
@@ -4,31 +4,6 @@
4
4
  */
5
5
  import { createElement } from 'react';
6
6
  const PLATFORM_UI_MODULE = '@deepseek-ai/dsh-client-ui-primitives';
7
- /**
8
- * Render the coordinate/action menu through the platform primitives, or a plain fallback.
9
- * @param props - rows, accessible label, position/style and optional primitive override.
10
- * @returns the menu element.
11
- */
12
- export function ActionMenu({ actions, label, style, className, primitives = PLATFORM_MENU }) {
13
- if (primitives !== undefined)
14
- return renderPlatformMenu(primitives, actions, label, style ?? {}, className);
15
- return createElement('div', {
16
- 'data-role': 'action-menu-fallback',
17
- role: 'menu',
18
- 'aria-label': label,
19
- ...(style === undefined ? {} : { style }),
20
- ...(className === undefined ? {} : { className }),
21
- }, actions.map(action => createElement('button', {
22
- key: action.id,
23
- type: 'button',
24
- role: 'menuitem',
25
- disabled: action.disabled === true,
26
- 'data-danger': action.danger === true ? 'true' : 'false',
27
- ...(action.separatorBefore === true ? { 'data-separator-before': 'true' } : {}),
28
- onClick: () => { if (action.disabled !== true)
29
- action.onSelect(); },
30
- }, action.label)));
31
- }
32
7
  /**
33
8
  * Render the platform menu directly. Kept exported for callers that already own the primitive row.
34
9
  * @param primitives - platform MenuSurface/MenuItemButton pair.
@@ -0,0 +1,4 @@
1
+ /** The one owner of plugin `<style>` tags; a new owner replaces the old tag so the
2
+ * old disposer only removes a detached node. */
3
+ export declare function injectPluginStyles(doc: Document | undefined, css: string, tagId: string): () => void;
4
+ //# sourceMappingURL=styles.d.ts.map
@@ -0,0 +1,13 @@
1
+ /** The one owner of plugin `<style>` tags; a new owner replaces the old tag so the
2
+ * old disposer only removes a detached node. */
3
+ export function injectPluginStyles(doc, css, tagId) {
4
+ if (doc === undefined)
5
+ return () => { };
6
+ doc.querySelector('style[data-plugin-css="' + tagId + '"]')?.remove();
7
+ const tag = doc.createElement('style');
8
+ tag.setAttribute('data-plugin-css', tagId);
9
+ tag.textContent = css;
10
+ doc.head.append(tag);
11
+ return () => { tag.remove(); };
12
+ }
13
+ //# sourceMappingURL=styles.js.map
@@ -1,15 +1,5 @@
1
- import { FALLBACK_LOCALE } from "./panel.js";
2
- function injectStyles(doc, css, tagId) {
3
- if (doc === undefined)
4
- return () => { };
5
- const previous = doc.querySelector('style[data-plugin-css="' + tagId + '"]');
6
- previous?.remove();
7
- const tag = doc.createElement('style');
8
- tag.setAttribute('data-plugin-css', tagId);
9
- tag.textContent = css;
10
- doc.head.appendChild(tag);
11
- return () => { tag.remove(); };
12
- }
1
+ import { bindLocale } from "./locale.js";
2
+ import { injectPluginStyles } from "./styles.js";
13
3
  /**
14
4
  * Register one view into `evolution.workbench.view`.
15
5
  * @param ctx - client cordis context.
@@ -17,37 +7,8 @@ function injectStyles(doc, css, tagId) {
17
7
  */
18
8
  export function registerWorkbenchView(ctx, spec) {
19
9
  const seam = ctx;
20
- let registered = false;
21
- ctx.effect(() => {
22
- try {
23
- const dispose = seam.locale.register(spec.namespace, spec.dictionaries);
24
- registered = true;
25
- return dispose;
26
- }
27
- catch (error) {
28
- ctx.logger.warn(spec.namespace + ': locale refused (' + String(error) + '); the view falls back to the bundle copy');
29
- return () => { };
30
- }
31
- }, spec.namespace + ': locale');
32
- ctx.effect(() => injectStyles(typeof document === 'undefined' ? undefined : document, spec.styles.css, spec.styles.tagId), spec.namespace + ': styles');
33
- const fallback = spec.dictionaries[FALLBACK_LOCALE];
34
- const lookup = (key) => {
35
- const own = fallback[key] ?? key;
36
- if (!registered)
37
- return own;
38
- try {
39
- return seam.locale.bind(spec.namespace)(key);
40
- }
41
- catch {
42
- return own;
43
- }
44
- };
45
- const t = (key, values) => {
46
- const template = lookup(key);
47
- if (values === undefined)
48
- return template;
49
- return template.replace(/\{(\w+)\}/g, (match, slot) => values[slot] === undefined ? match : String(values[slot]));
50
- };
10
+ ctx.effect(() => injectPluginStyles(typeof document === 'undefined' ? undefined : document, spec.styles.css, spec.styles.tagId), spec.namespace + ': styles');
11
+ const { t } = bindLocale(ctx, spec.namespace, spec.dictionaries);
51
12
  seam.slots.inject('evolution.workbench.view', function* () {
52
13
  yield seam.slots.register({
53
14
  name: 'evolution.workbench.view',
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@lmzhen/dsh-evolution-client-kit",
3
3
  "description": "Shared browser seams and lifecycle for the evolution family sidebar panels (community build)",
4
- "version": "0.47.0",
4
+ "version": "0.48.0",
5
5
  "private": false,
6
6
  "publishConfig": {
7
7
  "access": "public"
@@ -1,42 +0,0 @@
1
- import type { ReactNode } from 'react';
2
- /** One user-facing action whose effect is copying an exact command. */
3
- export interface ActionRef {
4
- readonly id: string;
5
- readonly label: string;
6
- readonly command: string;
7
- /** False renders the action disabled with no clipboard attempt. */
8
- readonly enabled?: boolean;
9
- /** Optional in-UI confirmation before the write; the callback owns the dialog. */
10
- readonly confirm?: (action: ActionRef) => boolean;
11
- }
12
- /** User-facing copy states; `copied` is set only after the clipboard accepted the text. */
13
- export type CopyStatus = 'idle' | 'copying' | 'copied' | 'failed';
14
- /** Labels the host surface supplies in its own language. */
15
- export interface CommandCopyLabels {
16
- readonly copy: string;
17
- readonly copying: string;
18
- readonly copied: string;
19
- readonly failed: string;
20
- }
21
- /** Props for the shared copy control. */
22
- export interface CommandCopyButtonProps {
23
- readonly action: ActionRef;
24
- readonly writeClipboard: (text: string) => Promise<boolean>;
25
- readonly labels: CommandCopyLabels;
26
- readonly className?: string | undefined;
27
- }
28
- /**
29
- * Copy one command and report the host verdict.
30
- * @param action - the command action.
31
- * @param writeClipboard - platform clipboard writer.
32
- * @param confirm - optional in-UI confirmation.
33
- * @returns the settled copy status.
34
- */
35
- export declare function copyAction(action: ActionRef, writeClipboard: (text: string) => Promise<boolean>, confirm?: (action: ActionRef) => boolean): Promise<CopyStatus>;
36
- /**
37
- * Render one command-copy action with real success/failure feedback.
38
- * @param props - action, clipboard writer, and localized labels.
39
- * @returns the button and its status line.
40
- */
41
- export declare function CommandCopyButton({ action, writeClipboard, labels, className }: CommandCopyButtonProps): ReactNode;
42
- //# sourceMappingURL=action.d.ts.map
@@ -1,46 +0,0 @@
1
- /**
2
- * Command-only actions. Approval decisions are a separate host API and must never
3
- * be represented as a copyable command here.
4
- * @module @lmzhen/dsh-evolution-client-kit
5
- */
6
- import { createElement, useState } from 'react';
7
- /**
8
- * Copy one command and report the host verdict.
9
- * @param action - the command action.
10
- * @param writeClipboard - platform clipboard writer.
11
- * @param confirm - optional in-UI confirmation.
12
- * @returns the settled copy status.
13
- */
14
- export async function copyAction(action, writeClipboard, confirm) {
15
- if (action.enabled === false)
16
- return 'idle';
17
- if (confirm !== undefined && !confirm(action))
18
- return 'idle';
19
- if (action.confirm !== undefined && !action.confirm(action))
20
- return 'idle';
21
- try {
22
- return await writeClipboard(action.command) ? 'copied' : 'failed';
23
- }
24
- catch {
25
- return 'failed';
26
- }
27
- }
28
- /**
29
- * Render one command-copy action with real success/failure feedback.
30
- * @param props - action, clipboard writer, and localized labels.
31
- * @returns the button and its status line.
32
- */
33
- export function CommandCopyButton({ action, writeClipboard, labels, className }) {
34
- const [status, setStatus] = useState('idle');
35
- const text = status === 'copying' ? labels.copying : status === 'copied' ? labels.copied : status === 'failed' ? labels.failed : labels.copy;
36
- return createElement('span', { className }, createElement('button', {
37
- type: 'button',
38
- disabled: action.enabled === false || status === 'copying',
39
- 'aria-label': action.label,
40
- onClick: () => {
41
- setStatus('copying');
42
- void copyAction(action, writeClipboard).then(setStatus);
43
- },
44
- }, action.label), createElement('span', { role: 'status', 'aria-live': 'polite' }, text === labels.copy ? '' : text));
45
- }
46
- //# sourceMappingURL=action.js.map
@@ -1,48 +0,0 @@
1
- /**
2
- * One read operation's lifecycle: initial load, background refresh, stale-answer
3
- * suppression, and an explicit failure slot. Consumers derive `empty` from a
4
- * successful `data` value; this type never conflates "not loaded yet" with
5
- * "loaded and empty".
6
- * @module @lmzhen/dsh-evolution-client-kit
7
- */
8
- /** The three settled states; `refreshing` is orthogonal so old data can stay visible. */
9
- export type AsyncStatus = 'loading' | 'ready' | 'error';
10
- /** Immutable snapshot published to render hooks. */
11
- export interface AsyncState<T> {
12
- readonly status: AsyncStatus;
13
- /** A newer read is in flight while `data` remains the previous successful value. */
14
- readonly refreshing: boolean;
15
- /** Last successful value; undefined before the first success or after reset. */
16
- readonly data: T | undefined;
17
- /** Latest failure, cleared by the next successful read. */
18
- readonly failure: unknown;
19
- /** Monotonic request id; only the latest generation may publish. */
20
- readonly generation: number;
21
- }
22
- /** A loader may use the signal to cancel work when a newer read supersedes it. */
23
- export type AsyncLoader<T> = (signal: AbortSignal) => Promise<T>;
24
- /**
25
- * Serialize one resource's reads without remounting the consumer.
26
- */
27
- export declare class AsyncResource<T> {
28
- #private;
29
- /** @returns the stable snapshot for uSES. */
30
- getSnapshot(): AsyncState<T>;
31
- /**
32
- * Observe snapshot replacements.
33
- * @param listener - called after each publish.
34
- * @returns the disposer.
35
- */
36
- subscribe(listener: () => void): () => void;
37
- /**
38
- * Run one read. A prior read is aborted; only this generation may publish.
39
- * @param load - loader receiving the cancellation signal.
40
- * @returns settlement after this generation commits or is superseded.
41
- */
42
- load(load: AsyncLoader<T>): Promise<void>;
43
- /** Drop the current value and return to the initial loading state. */
44
- reset(): void;
45
- /** Abort the in-flight read and stop notifying. */
46
- dispose(): void;
47
- }
48
- //# sourceMappingURL=async-resource.d.ts.map
@@ -1,96 +0,0 @@
1
- /**
2
- * One read operation's lifecycle: initial load, background refresh, stale-answer
3
- * suppression, and an explicit failure slot. Consumers derive `empty` from a
4
- * successful `data` value; this type never conflates "not loaded yet" with
5
- * "loaded and empty".
6
- * @module @lmzhen/dsh-evolution-client-kit
7
- */
8
- /**
9
- * Serialize one resource's reads without remounting the consumer.
10
- */
11
- export class AsyncResource {
12
- #state = Object.freeze({
13
- status: 'loading',
14
- refreshing: false,
15
- data: undefined,
16
- failure: undefined,
17
- generation: 0,
18
- });
19
- #listeners = new Set();
20
- #generation = 0;
21
- #controller;
22
- #disposed = false;
23
- /** @returns the stable snapshot for uSES. */
24
- getSnapshot() {
25
- return this.#state;
26
- }
27
- /**
28
- * Observe snapshot replacements.
29
- * @param listener - called after each publish.
30
- * @returns the disposer.
31
- */
32
- subscribe(listener) {
33
- this.#listeners.add(listener);
34
- return () => { this.#listeners.delete(listener); };
35
- }
36
- /**
37
- * Run one read. A prior read is aborted; only this generation may publish.
38
- * @param load - loader receiving the cancellation signal.
39
- * @returns settlement after this generation commits or is superseded.
40
- */
41
- async load(load) {
42
- if (this.#disposed)
43
- return;
44
- const generation = this.#generation + 1;
45
- this.#generation = generation;
46
- this.#controller?.abort();
47
- const controller = new AbortController();
48
- this.#controller = controller;
49
- const previous = this.#state;
50
- this.#publish({
51
- status: previous.data === undefined ? 'loading' : 'ready',
52
- refreshing: previous.data !== undefined,
53
- data: previous.data,
54
- failure: previous.failure,
55
- generation,
56
- });
57
- try {
58
- const data = await load(controller.signal);
59
- if (this.#disposed || generation !== this.#generation)
60
- return;
61
- this.#publish({ status: 'ready', refreshing: false, data, failure: undefined, generation });
62
- }
63
- catch (failure) {
64
- if (this.#disposed || generation !== this.#generation || controller.signal.aborted)
65
- return;
66
- this.#publish({
67
- status: previous.data === undefined ? 'error' : 'ready',
68
- refreshing: false,
69
- data: previous.data,
70
- failure,
71
- generation,
72
- });
73
- }
74
- }
75
- /** Drop the current value and return to the initial loading state. */
76
- reset() {
77
- this.#generation += 1;
78
- this.#controller?.abort();
79
- this.#controller = undefined;
80
- this.#publish({ status: 'loading', refreshing: false, data: undefined, failure: undefined, generation: this.#generation });
81
- }
82
- /** Abort the in-flight read and stop notifying. */
83
- dispose() {
84
- this.#disposed = true;
85
- this.#generation += 1;
86
- this.#controller?.abort();
87
- this.#controller = undefined;
88
- this.#listeners.clear();
89
- }
90
- #publish(state) {
91
- this.#state = Object.freeze(state);
92
- for (const listener of this.#listeners)
93
- listener();
94
- }
95
- }
96
- //# sourceMappingURL=async-resource.js.map
@@ -1,18 +0,0 @@
1
- /** One inline state notice: semantic tone plus text, no surface-specific styling. */
2
- import { type ReactNode } from 'react';
3
- export type StateNoticeTone = 'info' | 'warning' | 'error';
4
- export interface StateNoticeProps {
5
- readonly tone: StateNoticeTone;
6
- readonly text: string;
7
- /** Optional count shown after the sentence (e.g. "2 expired"). */
8
- readonly count?: number | undefined;
9
- readonly className?: string | undefined;
10
- }
11
- /**
12
- * Render one informative/warning/error line. The caller owns the surface class and CSS;
13
- * this leaf owns only the accessible role and the fact/count split.
14
- * @param props - tone, text, optional count/class.
15
- * @returns a semantic state notice.
16
- */
17
- export declare function StateNotice({ tone, text, count, className }: StateNoticeProps): ReactNode;
18
- //# sourceMappingURL=notice.d.ts.map
@@ -1,17 +0,0 @@
1
- /** One inline state notice: semantic tone plus text, no surface-specific styling. */
2
- import { createElement } from 'react';
3
- /**
4
- * Render one informative/warning/error line. The caller owns the surface class and CSS;
5
- * this leaf owns only the accessible role and the fact/count split.
6
- * @param props - tone, text, optional count/class.
7
- * @returns a semantic state notice.
8
- */
9
- export function StateNotice({ tone, text, count, className }) {
10
- return createElement('div', {
11
- 'data-role': 'state-notice',
12
- 'data-tone': tone,
13
- role: tone === 'error' ? 'alert' : 'status',
14
- ...(className === undefined ? {} : { className }),
15
- }, createElement('span', { 'data-role': 'state-notice-text' }, text), count === undefined ? null : createElement('span', { 'data-role': 'state-notice-count' }, String(count)));
16
- }
17
- //# sourceMappingURL=notice.js.map
@@ -1,23 +0,0 @@
1
- /** Read-only status chips and toggleable filter chips. */
2
- import { type ReactNode } from 'react';
3
- import type { PresentationTone } from './types.ts';
4
- /** Props for one non-interactive status chip. */
5
- export interface StatusChipProps {
6
- readonly label: string;
7
- readonly tone?: PresentationTone | undefined;
8
- readonly className?: string | undefined;
9
- }
10
- /** Render one semantic status word. */
11
- export declare function StatusChip({ label, tone, className }: StatusChipProps): ReactNode;
12
- /** Props for a filter chip that only changes the visible list. */
13
- export interface FilterChipProps {
14
- readonly label: string;
15
- readonly active: boolean;
16
- readonly onClick: () => void;
17
- readonly count?: number | undefined;
18
- readonly disabled?: boolean | undefined;
19
- readonly className?: string | undefined;
20
- }
21
- /** Render a toggleable filter with the pressed state exposed to assistive tech. */
22
- export declare function FilterChip({ label, active, onClick, count, disabled, className }: FilterChipProps): ReactNode;
23
- //# sourceMappingURL=chips.d.ts.map
@@ -1,24 +0,0 @@
1
- /** Read-only status chips and toggleable filter chips. */
2
- import { createElement } from 'react';
3
- /** Render one semantic status word. */
4
- export function StatusChip({ label, tone = 'neutral', className }) {
5
- return createElement('span', {
6
- 'data-role': 'status-chip',
7
- 'data-tone': tone,
8
- ...(className === undefined ? {} : { className }),
9
- }, label);
10
- }
11
- /** Render a toggleable filter with the pressed state exposed to assistive tech. */
12
- export function FilterChip({ label, active, onClick, count, disabled = false, className }) {
13
- return createElement('button', {
14
- type: 'button',
15
- 'data-role': 'filter-chip',
16
- 'data-active': active ? 'true' : 'false',
17
- 'aria-pressed': active ? 'true' : 'false',
18
- disabled,
19
- ...(className === undefined ? {} : { className }),
20
- onClick: () => { if (!disabled)
21
- onClick(); },
22
- }, createElement('span', { 'data-role': 'filter-chip-label' }, label), count === undefined ? null : createElement('span', { 'data-role': 'filter-chip-count' }, String(count)));
23
- }
24
- //# sourceMappingURL=chips.js.map
@@ -1,13 +0,0 @@
1
- /** A native details group for normal/secondary facts. */
2
- import { type ReactNode } from 'react';
3
- /** Props for the shared disclosure group. */
4
- export interface DisclosureGroupProps {
5
- readonly summary: string;
6
- readonly count?: number | undefined;
7
- readonly children: ReactNode;
8
- readonly defaultOpen?: boolean | undefined;
9
- readonly className?: string | undefined;
10
- }
11
- /** Render a closed-by-default disclosure without introducing another accordion model. */
12
- export declare function DisclosureGroup({ summary, count, children, defaultOpen, className }: DisclosureGroupProps): ReactNode;
13
- //# sourceMappingURL=disclosure-group.d.ts.map
@@ -1,11 +0,0 @@
1
- /** A native details group for normal/secondary facts. */
2
- import { createElement } from 'react';
3
- /** Render a closed-by-default disclosure without introducing another accordion model. */
4
- export function DisclosureGroup({ summary, count, children, defaultOpen = false, className }) {
5
- return createElement('details', {
6
- 'data-role': 'disclosure-group',
7
- ...(defaultOpen ? { open: true } : {}),
8
- ...(className === undefined ? {} : { className }),
9
- }, createElement('summary', { 'data-role': 'disclosure-summary' }, createElement('span', { 'data-role': 'disclosure-title' }, summary), count === undefined ? null : createElement('span', { 'data-role': 'disclosure-count' }, String(count))), createElement('div', { 'data-role': 'disclosure-content' }, children));
10
- }
11
- //# sourceMappingURL=disclosure-group.js.map
@@ -1,15 +0,0 @@
1
- /** The one local-time presentation used by reading surfaces. */
2
- import { type ReactNode } from 'react';
3
- /** Props for the shared time text. */
4
- export interface TimeTextProps {
5
- readonly value: string | number | null | undefined;
6
- readonly seconds?: boolean | undefined;
7
- readonly className?: string | undefined;
8
- }
9
- /**
10
- * Render a local wall time, or a neutral dash when the fact is unknown.
11
- * @param props - ISO/epoch value and seconds preference.
12
- * @returns a time element with the raw value in dateTime when valid.
13
- */
14
- export declare function TimeText({ value, seconds, className }: TimeTextProps): ReactNode;
15
- //# sourceMappingURL=time-text.d.ts.map
@@ -1,20 +0,0 @@
1
- /** The one local-time presentation used by reading surfaces. */
2
- import { createElement } from 'react';
3
- import { formatLocalDateTime } from "../format.js";
4
- /**
5
- * Render a local wall time, or a neutral dash when the fact is unknown.
6
- * @param props - ISO/epoch value and seconds preference.
7
- * @returns a time element with the raw value in dateTime when valid.
8
- */
9
- export function TimeText({ value, seconds = true, className }) {
10
- const text = formatLocalDateTime(value, { seconds });
11
- const ms = typeof value === 'number' ? value : typeof value === 'string' ? Date.parse(value) : Number.NaN;
12
- const raw = Number.isFinite(ms) ? new Date(ms).toISOString() : undefined;
13
- return createElement('time', {
14
- 'data-role': 'time-text',
15
- ...(raw === undefined ? {} : { dateTime: raw }),
16
- ...(text === null ? {} : { title: text }),
17
- ...(className === undefined ? {} : { className }),
18
- }, text ?? '—');
19
- }
20
- //# sourceMappingURL=time-text.js.map