@lmzhen/dsh-evolution-client-kit 0.46.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.
Files changed (36) hide show
  1. package/lib/generated/fallbacks.generated.js +1 -2
  2. package/lib/generated/routes.generated.js +1 -5
  3. package/lib/index.js +59 -576
  4. package/lib/types/generated/contracts.generated.d.ts +0 -2
  5. package/lib/types/generated/fallbacks.generated.d.ts +1 -1
  6. package/lib/types/generated/fallbacks.generated.js +0 -3
  7. package/lib/types/generated/routes.generated.d.ts +1 -5
  8. package/lib/types/generated/routes.generated.js +0 -4
  9. package/lib/types/index.d.ts +3 -12
  10. package/lib/types/index.js +3 -9
  11. package/lib/types/locale.d.ts +17 -0
  12. package/lib/types/locale.js +53 -0
  13. package/lib/types/panel.d.ts +2 -3
  14. package/lib/types/panel.js +4 -47
  15. package/lib/types/presentation/action-menu.d.ts +0 -14
  16. package/lib/types/presentation/action-menu.js +0 -25
  17. package/lib/types/styles.d.ts +4 -0
  18. package/lib/types/styles.js +13 -0
  19. package/lib/types/workbench-view.js +4 -43
  20. package/package.json +1 -1
  21. package/lib/types/action.d.ts +0 -42
  22. package/lib/types/action.js +0 -46
  23. package/lib/types/async-resource.d.ts +0 -48
  24. package/lib/types/async-resource.js +0 -96
  25. package/lib/types/notice.d.ts +0 -18
  26. package/lib/types/notice.js +0 -17
  27. package/lib/types/presentation/chips.d.ts +0 -23
  28. package/lib/types/presentation/chips.js +0 -24
  29. package/lib/types/presentation/disclosure-group.d.ts +0 -13
  30. package/lib/types/presentation/disclosure-group.js +0 -11
  31. package/lib/types/presentation/time-text.d.ts +0 -15
  32. package/lib/types/presentation/time-text.js +0 -20
  33. package/lib/types/settings-gateway.d.ts +0 -68
  34. package/lib/types/settings-gateway.js +0 -52
  35. package/lib/types/settings-seat.d.ts +0 -21
  36. package/lib/types/settings-seat.js +0 -172
@@ -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,5 +4,5 @@ import type { FallbackHint } from './contracts.generated.ts';
4
4
  * COMMAND_FALLBACKS (the ONE home). When the platform's connection carrier is absent (E-325) the
5
5
  * panels render this hint instead of a bare HTTP failure — same use case, command face.
6
6
  */
7
- export declare const FALLBACKS: Readonly<Record<'approval' | 'skill-history' | 'skill-health' | 'merge' | 'diagnostics' | 'settings', FallbackHint>>;
7
+ export declare const FALLBACKS: Readonly<Record<'approval' | 'skill-history' | 'skill-health' | 'merge' | 'diagnostics', FallbackHint>>;
8
8
  //# sourceMappingURL=fallbacks.generated.d.ts.map
@@ -21,8 +21,5 @@ export const FALLBACKS = {
21
21
  command: '/evolution doctor',
22
22
  platformCli: 'dsh --json /evolution doctor',
23
23
  },
24
- settings: {
25
- command: '/evolution params --group deployment(写入由平台插件管理的 row 配置页承载)',
26
- },
27
24
  };
28
25
  //# sourceMappingURL=fallbacks.generated.js.map
@@ -1,5 +1,5 @@
1
1
  /** One host data-plane surface the browser half can call. */
2
- export type SurfaceId = 'approval' | 'skill-history' | 'skill-health' | 'merge' | 'diagnostics' | 'settings';
2
+ export type SurfaceId = 'approval' | 'skill-history' | 'skill-health' | 'merge' | 'diagnostics';
3
3
  /**
4
4
  * Every family host path, generated from evolution-core's HOST_ROUTES (the ONE declaration).
5
5
  * A browser half cannot import the host package at runtime (client bundles keep @deepseek-ai/*
@@ -36,9 +36,5 @@ export declare const ROUTES: {
36
36
  readonly diagnostics: {
37
37
  readonly view: "/api/dsh-evolution/diagnostics";
38
38
  };
39
- readonly settings: {
40
- readonly describe: "/api/dsh-evolution/settings/describe";
41
- readonly mutate: "/api/dsh-evolution/settings/mutate";
42
- };
43
39
  };
44
40
  //# sourceMappingURL=routes.generated.d.ts.map
@@ -35,9 +35,5 @@ export const ROUTES = {
35
35
  diagnostics: {
36
36
  view: '/api/dsh-evolution/diagnostics',
37
37
  },
38
- settings: {
39
- describe: '/api/dsh-evolution/settings/describe',
40
- mutate: '/api/dsh-evolution/settings/mutate',
41
- },
42
38
  };
43
39
  //# sourceMappingURL=routes.generated.js.map
@@ -2,30 +2,21 @@
2
2
  export type { ClientSeam, ConfigFormLike, ConfigFormSnapshotLike, ConfigFormsSeat, ConfigPathOpLike, ConfigWriteKind, ConfigWriteOutcome, LocaleSeat, PanelBodyOptions, PanelRowOptions, SettingsFace, SlotsSeat } from './seam.ts';
3
3
  export { registerSidebarPanel, requireClientSeats, type SidebarPanelSpec, type Translate } from './panel.ts';
4
4
  export { registerWorkbenchView } from './workbench-view.ts';
5
- export { createSettingsSeat } from './settings-seat.ts';
6
5
  export type { WorkbenchViewSpec } from './workbench-view.ts';
7
6
  export { panelWorkspaceId } from './workspace.ts';
8
- export { AsyncResource } from './async-resource.ts';
9
7
  export { formatLocalClock, formatLocalDateTime, isSameLocalDay, type LocalDateTimeOptions } from './format.ts';
10
- export { StateNotice, type StateNoticeProps, type StateNoticeTone } from './notice.ts';
11
8
  export { DecisionFrame, type DecisionFrameProps } from './presentation/decision-frame.ts';
12
9
  export { TaskBanner, type TaskBannerProps } from './presentation/task-banner.ts';
13
- export { StatusChip, FilterChip, type StatusChipProps, type FilterChipProps } from './presentation/chips.ts';
14
10
  export { EmptyState, type EmptyStateProps } from './presentation/empty-state.ts';
15
11
  export { RESPONSIVE_TABLE_CSS } from './presentation/table.ts';
16
- export { DisclosureGroup, type DisclosureGroupProps } from './presentation/disclosure-group.ts';
17
- export { TimeText, type TimeTextProps } from './presentation/time-text.ts';
18
- 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';
19
13
  export type { PresentationTone, PresentationAction, DecisionFact, DecisionModel } from './presentation/types.ts';
20
- export { CommandCopyButton, copyAction } from './action.ts';
21
- export type { ActionRef, CommandCopyButtonProps, CommandCopyLabels, CopyStatus } from './action.ts';
22
- export type { AsyncLoader, AsyncState, AsyncStatus } from './async-resource.ts';
23
14
  export { ROUTES } from './generated/routes.generated.ts';
24
15
  export { FALLBACKS } from './generated/fallbacks.generated.ts';
25
16
  export * from './generated/contracts.generated.ts';
26
17
  export * from './generated/states.generated.ts';
27
18
  export { TOKEN_CSS, TOKENS, tokenVars } from './tokens.ts';
28
19
  export { PAGE_SURFACE_CLASS, PAGE_SURFACE_CSS } from './surface.ts';
29
- export { createSettingsGatewayCache, saveSettings } from './settings-gateway.ts';
30
- export type { SettingsBinderLike, SettingsGateway, SettingsMutationApi, SettingsSaveResult, SettingsScopeLike } from './settings-gateway.ts';
20
+ export { injectPluginStyles } from './styles.ts';
21
+ export { fillTemplate, bindLocale } from './locale.ts';
31
22
  //# sourceMappingURL=index.d.ts.map
@@ -1,24 +1,18 @@
1
1
  export { registerSidebarPanel, requireClientSeats } from "./panel.js";
2
2
  export { registerWorkbenchView } from "./workbench-view.js";
3
- export { createSettingsSeat } from "./settings-seat.js";
4
3
  export { panelWorkspaceId } from "./workspace.js";
5
- export { AsyncResource } from "./async-resource.js";
6
4
  export { formatLocalClock, formatLocalDateTime, isSameLocalDay } from "./format.js";
7
- export { StateNotice } from "./notice.js";
8
5
  export { DecisionFrame } from "./presentation/decision-frame.js";
9
6
  export { TaskBanner } from "./presentation/task-banner.js";
10
- export { StatusChip, FilterChip } from "./presentation/chips.js";
11
7
  export { EmptyState } from "./presentation/empty-state.js";
12
8
  export { RESPONSIVE_TABLE_CSS } from "./presentation/table.js";
13
- export { DisclosureGroup } from "./presentation/disclosure-group.js";
14
- export { TimeText } from "./presentation/time-text.js";
15
- export { ActionMenu, PLATFORM_MENU, renderPlatformMenu, menuPrimitivesFrom } from "./presentation/action-menu.js";
16
- export { CommandCopyButton, copyAction } from "./action.js";
9
+ export { PLATFORM_MENU, renderPlatformMenu, menuPrimitivesFrom } from "./presentation/action-menu.js";
17
10
  export { ROUTES } from "./generated/routes.generated.js";
18
11
  export { FALLBACKS } from "./generated/fallbacks.generated.js";
19
12
  export * from "./generated/contracts.generated.js";
20
13
  export * from "./generated/states.generated.js";
21
14
  export { TOKEN_CSS, TOKENS, tokenVars } from "./tokens.js";
22
15
  export { PAGE_SURFACE_CLASS, PAGE_SURFACE_CSS } from "./surface.js";
23
- export { createSettingsGatewayCache, saveSettings } from "./settings-gateway.js";
16
+ export { injectPluginStyles } from "./styles.js";
17
+ export { fillTemplate, bindLocale } from "./locale.js";
24
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.46.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