@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.
- package/lib/generated/fallbacks.generated.js +1 -2
- package/lib/generated/routes.generated.js +1 -5
- package/lib/index.js +59 -576
- package/lib/types/generated/contracts.generated.d.ts +0 -2
- package/lib/types/generated/fallbacks.generated.d.ts +1 -1
- package/lib/types/generated/fallbacks.generated.js +0 -3
- package/lib/types/generated/routes.generated.d.ts +1 -5
- package/lib/types/generated/routes.generated.js +0 -4
- package/lib/types/index.d.ts +3 -12
- package/lib/types/index.js +3 -9
- package/lib/types/locale.d.ts +17 -0
- package/lib/types/locale.js +53 -0
- package/lib/types/panel.d.ts +2 -3
- package/lib/types/panel.js +4 -47
- package/lib/types/presentation/action-menu.d.ts +0 -14
- package/lib/types/presentation/action-menu.js +0 -25
- package/lib/types/styles.d.ts +4 -0
- package/lib/types/styles.js +13 -0
- package/lib/types/workbench-view.js +4 -43
- package/package.json +1 -1
- package/lib/types/action.d.ts +0 -42
- package/lib/types/action.js +0 -46
- package/lib/types/async-resource.d.ts +0 -48
- package/lib/types/async-resource.js +0 -96
- package/lib/types/notice.d.ts +0 -18
- package/lib/types/notice.js +0 -17
- package/lib/types/presentation/chips.d.ts +0 -23
- package/lib/types/presentation/chips.js +0 -24
- package/lib/types/presentation/disclosure-group.d.ts +0 -13
- package/lib/types/presentation/disclosure-group.js +0 -11
- package/lib/types/presentation/time-text.d.ts +0 -15
- package/lib/types/presentation/time-text.js +0 -20
- package/lib/types/settings-gateway.d.ts +0 -68
- package/lib/types/settings-gateway.js +0 -52
- package/lib/types/settings-seat.d.ts +0 -21
- package/lib/types/settings-seat.js +0 -172
package/lib/types/notice.d.ts
DELETED
|
@@ -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
|
package/lib/types/notice.js
DELETED
|
@@ -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
|
|
@@ -1,68 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* One namespace's settings gateway: one scope for reads, one revision-fenced
|
|
3
|
-
* write, and a read-back in `finally`. The gateway owns no subscription — the
|
|
4
|
-
* platform settings scope already listens to document updates and resets.
|
|
5
|
-
* @module @lmzhen/dsh-evolution-client-kit
|
|
6
|
-
*/
|
|
7
|
-
import type { ConfigPathOpLike } from './seam.ts';
|
|
8
|
-
/** The read side of a platform settings scope. */
|
|
9
|
-
export interface SettingsScopeLike {
|
|
10
|
-
/** @returns the current namespace snapshot; only `revision` is read here. */
|
|
11
|
-
getSnapshot(): {
|
|
12
|
-
readonly revision?: number | undefined;
|
|
13
|
-
};
|
|
14
|
-
/** Queue a fresh describe and settle after it publishes or is superseded. */
|
|
15
|
-
load(): Promise<void>;
|
|
16
|
-
}
|
|
17
|
-
/** The write transport; one call carries the complete op list. */
|
|
18
|
-
export interface SettingsMutationApi {
|
|
19
|
-
mutate(input: {
|
|
20
|
-
readonly ns: string;
|
|
21
|
-
readonly ops: readonly ConfigPathOpLike[];
|
|
22
|
-
readonly expectedRevision?: number;
|
|
23
|
-
}): Promise<{
|
|
24
|
-
readonly result: {
|
|
25
|
-
readonly ok: boolean;
|
|
26
|
-
};
|
|
27
|
-
}>;
|
|
28
|
-
}
|
|
29
|
-
/** Write verdict and the independent read-back verdict. */
|
|
30
|
-
export interface SettingsSaveResult {
|
|
31
|
-
/** True only when the Host accepted the write. */
|
|
32
|
-
readonly written: boolean;
|
|
33
|
-
/** Read-back outcome; never derived from `written`. */
|
|
34
|
-
readonly readback: 'ok' | 'failed';
|
|
35
|
-
/** Transport/write failure, retained when the read-back was still attempted. */
|
|
36
|
-
readonly failure?: unknown;
|
|
37
|
-
}
|
|
38
|
-
/**
|
|
39
|
-
* Save one atomic op list and always read back.
|
|
40
|
-
* @param options - namespace, bound scope, mutation transport, and ops.
|
|
41
|
-
* @returns the write verdict plus the separate read-back verdict.
|
|
42
|
-
*/
|
|
43
|
-
export declare function saveSettings(options: {
|
|
44
|
-
readonly namespace: string;
|
|
45
|
-
readonly scope: SettingsScopeLike;
|
|
46
|
-
readonly api: SettingsMutationApi;
|
|
47
|
-
readonly ops: readonly ConfigPathOpLike[];
|
|
48
|
-
}): Promise<SettingsSaveResult>;
|
|
49
|
-
/** The platform binder face; one call per namespace is the whole contract. */
|
|
50
|
-
export interface SettingsBinderLike {
|
|
51
|
-
bind(spec: {
|
|
52
|
-
readonly namespace: string;
|
|
53
|
-
}): SettingsScopeLike;
|
|
54
|
-
}
|
|
55
|
-
/** One cached namespace gateway. */
|
|
56
|
-
export interface SettingsGateway {
|
|
57
|
-
readonly scope: SettingsScopeLike;
|
|
58
|
-
/** Save through this gateway's cached scope. */
|
|
59
|
-
save(ops: readonly ConfigPathOpLike[]): Promise<SettingsSaveResult>;
|
|
60
|
-
}
|
|
61
|
-
/**
|
|
62
|
-
* Bind each namespace once and reuse that scope for every later save.
|
|
63
|
-
* @param binder - the platform settings-scope service.
|
|
64
|
-
* @param api - the mutation transport.
|
|
65
|
-
* @returns a lookup that creates one gateway per namespace.
|
|
66
|
-
*/
|
|
67
|
-
export declare function createSettingsGatewayCache(binder: SettingsBinderLike, api: SettingsMutationApi): (namespace: string) => SettingsGateway;
|
|
68
|
-
//# sourceMappingURL=settings-gateway.d.ts.map
|
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Save one atomic op list and always read back.
|
|
3
|
-
* @param options - namespace, bound scope, mutation transport, and ops.
|
|
4
|
-
* @returns the write verdict plus the separate read-back verdict.
|
|
5
|
-
*/
|
|
6
|
-
export async function saveSettings(options) {
|
|
7
|
-
const revision = options.scope.getSnapshot().revision;
|
|
8
|
-
let written = false;
|
|
9
|
-
let failure;
|
|
10
|
-
try {
|
|
11
|
-
const response = await options.api.mutate({
|
|
12
|
-
ns: options.namespace,
|
|
13
|
-
ops: options.ops,
|
|
14
|
-
...(revision === undefined ? {} : { expectedRevision: revision }),
|
|
15
|
-
});
|
|
16
|
-
written = response.result.ok;
|
|
17
|
-
}
|
|
18
|
-
catch (error) {
|
|
19
|
-
failure = error;
|
|
20
|
-
}
|
|
21
|
-
let readback = 'ok';
|
|
22
|
-
try {
|
|
23
|
-
await options.scope.load();
|
|
24
|
-
}
|
|
25
|
-
catch (error) {
|
|
26
|
-
readback = 'failed';
|
|
27
|
-
failure ??= error;
|
|
28
|
-
}
|
|
29
|
-
return failure === undefined ? { written, readback } : { written, readback, failure };
|
|
30
|
-
}
|
|
31
|
-
/**
|
|
32
|
-
* Bind each namespace once and reuse that scope for every later save.
|
|
33
|
-
* @param binder - the platform settings-scope service.
|
|
34
|
-
* @param api - the mutation transport.
|
|
35
|
-
* @returns a lookup that creates one gateway per namespace.
|
|
36
|
-
*/
|
|
37
|
-
export function createSettingsGatewayCache(binder, api) {
|
|
38
|
-
const cache = new Map();
|
|
39
|
-
return (namespace) => {
|
|
40
|
-
const existing = cache.get(namespace);
|
|
41
|
-
if (existing !== undefined)
|
|
42
|
-
return existing;
|
|
43
|
-
const scope = binder.bind({ namespace });
|
|
44
|
-
const gateway = {
|
|
45
|
-
scope,
|
|
46
|
-
save: async (ops) => await saveSettings({ namespace, scope, api, ops }),
|
|
47
|
-
};
|
|
48
|
-
cache.set(namespace, gateway);
|
|
49
|
-
return gateway;
|
|
50
|
-
};
|
|
51
|
-
}
|
|
52
|
-
//# sourceMappingURL=settings-gateway.js.map
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Family settings data plane, adapted to the card's form shape.
|
|
3
|
-
*
|
|
4
|
-
* The platform RPC only serves its own namespace allowlist, so `connection.api.settings`
|
|
5
|
-
* cannot read family namespaces even though the host settings provider has them.
|
|
6
|
-
* These forms talk to the family's exact routes, which call the SAME platform
|
|
7
|
-
* settings provider (schema validation, revision fencing, redaction and storage
|
|
8
|
-
* stay platform-owned).
|
|
9
|
-
* @module @lmzhen/dsh-evolution-client-kit
|
|
10
|
-
*/
|
|
11
|
-
import type { ConfigFormsSeat } from './seam.ts';
|
|
12
|
-
interface ContextLike {
|
|
13
|
-
get?: (name: string) => unknown;
|
|
14
|
-
inject?: (deps: string[], callback: () => void) => void;
|
|
15
|
-
remote?: {
|
|
16
|
-
$on?: (event: string, listener: (namespace: string) => void) => () => void;
|
|
17
|
-
};
|
|
18
|
-
}
|
|
19
|
-
export declare function createSettingsSeat(ctx: ContextLike): ConfigFormsSeat;
|
|
20
|
-
export {};
|
|
21
|
-
//# sourceMappingURL=settings-seat.d.ts.map
|
|
@@ -1,172 +0,0 @@
|
|
|
1
|
-
import { ROUTES } from "./generated/routes.generated.js";
|
|
2
|
-
const SETTINGS_DESCRIBE = ROUTES.settings.describe;
|
|
3
|
-
const SETTINGS_MUTATE = ROUTES.settings.mutate;
|
|
4
|
-
const EMPTY = Object.freeze({
|
|
5
|
-
status: 'unavailable', value: undefined, user: undefined, writable: false, base: undefined, revision: undefined, reason: 'transport',
|
|
6
|
-
});
|
|
7
|
-
function snapshotFrom(value, ns) {
|
|
8
|
-
if (typeof value !== 'object' || value === null)
|
|
9
|
-
return EMPTY;
|
|
10
|
-
const list = value.namespaces;
|
|
11
|
-
if (!Array.isArray(list))
|
|
12
|
-
return EMPTY;
|
|
13
|
-
const item = list.find(candidate => typeof candidate === 'object' && candidate !== null && candidate.ns === ns);
|
|
14
|
-
return item === undefined ? { ...EMPTY, reason: 'not-served' } : item;
|
|
15
|
-
}
|
|
16
|
-
async function describe(namespace) {
|
|
17
|
-
try {
|
|
18
|
-
const response = await fetch(SETTINGS_DESCRIBE, { headers: { accept: 'application/json' } });
|
|
19
|
-
if (!response.ok)
|
|
20
|
-
return EMPTY;
|
|
21
|
-
const body = await response.json();
|
|
22
|
-
if (body.ok !== true)
|
|
23
|
-
return EMPTY;
|
|
24
|
-
return snapshotFrom(body.data, namespace);
|
|
25
|
-
}
|
|
26
|
-
catch {
|
|
27
|
-
return EMPTY;
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
/**
|
|
31
|
-
* Classify one refused write from the exact route's response: the route answers 409 for a revision
|
|
32
|
-
* CAS loss and 400 with an "invalid config" error for a schema refusal, so the card can name the
|
|
33
|
-
* right cause instead of calling every refusal a concurrent edit.
|
|
34
|
-
* @param response - the non-ok response.
|
|
35
|
-
* @returns the refusal class; anything the route did not name stays transport.
|
|
36
|
-
*/
|
|
37
|
-
async function refusalKind(response) {
|
|
38
|
-
if (response.status === 409)
|
|
39
|
-
return 'conflict';
|
|
40
|
-
try {
|
|
41
|
-
const body = await response.json();
|
|
42
|
-
return typeof body.error === 'string' && body.error.startsWith('invalid config') ? 'validation' : 'transport';
|
|
43
|
-
}
|
|
44
|
-
catch {
|
|
45
|
-
return 'transport';
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
async function write(namespace, ops, expectedRevision) {
|
|
49
|
-
try {
|
|
50
|
-
const response = await fetch(SETTINGS_MUTATE, {
|
|
51
|
-
method: 'POST',
|
|
52
|
-
headers: { 'content-type': 'application/json', accept: 'application/json' },
|
|
53
|
-
body: JSON.stringify({ ns: namespace, ops, ...(expectedRevision === undefined ? {} : { expectedRevision }) }),
|
|
54
|
-
});
|
|
55
|
-
if (!response.ok)
|
|
56
|
-
return { ok: false, kind: await refusalKind(response) };
|
|
57
|
-
const body = await response.json();
|
|
58
|
-
return { ok: body.ok === true, snapshot: snapshotFrom(body.data, namespace) };
|
|
59
|
-
}
|
|
60
|
-
catch {
|
|
61
|
-
return { ok: false, kind: 'transport' };
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
function createForm(namespace, ctx) {
|
|
65
|
-
let snapshot = { ...EMPTY, reason: 'seat-missing' };
|
|
66
|
-
let lastReady;
|
|
67
|
-
let generation = 0;
|
|
68
|
-
const listeners = new Set();
|
|
69
|
-
let remoteOff;
|
|
70
|
-
const notify = () => { for (const listener of listeners)
|
|
71
|
-
listener(); };
|
|
72
|
-
const absorb = (next) => {
|
|
73
|
-
if (next.status === 'ready') {
|
|
74
|
-
lastReady = next;
|
|
75
|
-
snapshot = next;
|
|
76
|
-
}
|
|
77
|
-
else if (lastReady !== undefined) {
|
|
78
|
-
// A failed re-read must not erase the last usable values. Keep ready + mark stale;
|
|
79
|
-
// the card shows the values with a warning instead of claiming the plugin is absent.
|
|
80
|
-
snapshot = { ...lastReady, stale: true, reason: next.reason ?? 'readback-failed' };
|
|
81
|
-
}
|
|
82
|
-
else {
|
|
83
|
-
snapshot = next;
|
|
84
|
-
}
|
|
85
|
-
notify();
|
|
86
|
-
};
|
|
87
|
-
const refresh = async () => {
|
|
88
|
-
startRemote();
|
|
89
|
-
const ticket = ++generation;
|
|
90
|
-
const next = await describe(namespace);
|
|
91
|
-
if (ticket !== generation)
|
|
92
|
-
return;
|
|
93
|
-
absorb(next);
|
|
94
|
-
};
|
|
95
|
-
const remote = () => ctx.get?.('remote');
|
|
96
|
-
const stopRemote = () => { remoteOff?.(); remoteOff = undefined; };
|
|
97
|
-
const startRemote = () => {
|
|
98
|
-
if (remoteOff !== undefined)
|
|
99
|
-
return;
|
|
100
|
-
remoteOff = remote()?.$on?.('settings/document-updated', (changed) => { if (changed === namespace)
|
|
101
|
-
void refresh(); });
|
|
102
|
-
};
|
|
103
|
-
const form = {
|
|
104
|
-
getSnapshot: () => snapshot,
|
|
105
|
-
subscribe: (listener) => {
|
|
106
|
-
listeners.add(listener);
|
|
107
|
-
startRemote();
|
|
108
|
-
void refresh();
|
|
109
|
-
return () => {
|
|
110
|
-
listeners.delete(listener);
|
|
111
|
-
if (listeners.size === 0)
|
|
112
|
-
stopRemote();
|
|
113
|
-
};
|
|
114
|
-
},
|
|
115
|
-
set: async (field, value) => (await form.mutate([{ op: 'set', path: [field], value }])),
|
|
116
|
-
unset: async (field) => (await form.mutate([{ op: 'unset', path: [field] }])),
|
|
117
|
-
save: async (ops, expectedRevision) => {
|
|
118
|
-
const revision = expectedRevision ?? snapshot.revision;
|
|
119
|
-
const outcome = await write(namespace, ops, revision);
|
|
120
|
-
if (outcome.snapshot !== undefined)
|
|
121
|
-
absorb(outcome.snapshot);
|
|
122
|
-
else
|
|
123
|
-
await refresh();
|
|
124
|
-
return outcome.ok ? { written: true } : { written: false, kind: outcome.kind ?? 'transport' };
|
|
125
|
-
},
|
|
126
|
-
mutate: async (ops, expectedRevision) => {
|
|
127
|
-
const revision = expectedRevision ?? snapshot.revision;
|
|
128
|
-
const outcome = await write(namespace, ops, revision);
|
|
129
|
-
if (outcome.snapshot !== undefined)
|
|
130
|
-
absorb(outcome.snapshot);
|
|
131
|
-
else
|
|
132
|
-
await refresh();
|
|
133
|
-
return outcome.ok;
|
|
134
|
-
},
|
|
135
|
-
refresh,
|
|
136
|
-
dispose: () => { stopRemote(); listeners.clear(); },
|
|
137
|
-
};
|
|
138
|
-
return form;
|
|
139
|
-
}
|
|
140
|
-
/**
|
|
141
|
-
* Build/return the ONE seat for one ClientContext. All panels share the same form,
|
|
142
|
-
* snapshot and revision; dispose removes the seat so a replacement context starts clean.
|
|
143
|
-
*/
|
|
144
|
-
const seats = new WeakMap();
|
|
145
|
-
export function createSettingsSeat(ctx) {
|
|
146
|
-
const key = ctx;
|
|
147
|
-
const existing = seats.get(key);
|
|
148
|
-
if (existing !== undefined)
|
|
149
|
-
return existing;
|
|
150
|
-
const forms = new Map();
|
|
151
|
-
const seat = {
|
|
152
|
-
get(namespace) {
|
|
153
|
-
let form = forms.get(namespace);
|
|
154
|
-
if (form === undefined) {
|
|
155
|
-
form = createForm(namespace, ctx);
|
|
156
|
-
forms.set(namespace, form);
|
|
157
|
-
}
|
|
158
|
-
return form;
|
|
159
|
-
},
|
|
160
|
-
dispose: () => {
|
|
161
|
-
for (const form of forms.values())
|
|
162
|
-
form.dispose?.();
|
|
163
|
-
forms.clear();
|
|
164
|
-
seats.delete(key);
|
|
165
|
-
},
|
|
166
|
-
};
|
|
167
|
-
seats.set(key, seat);
|
|
168
|
-
ctx.inject?.(['remote'], () => { for (const form of forms.values())
|
|
169
|
-
void form.refresh?.(); });
|
|
170
|
-
return seat;
|
|
171
|
-
}
|
|
172
|
-
//# sourceMappingURL=settings-seat.js.map
|