@lmzhen/dsh-evolution-client-kit 0.39.1 → 0.40.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 +16 -8
- package/lib/types/panel.d.ts +1 -0
- package/lib/types/panel.js +3 -1
- package/lib/types/settings-seat.d.ts +1 -5
- package/lib/types/settings-seat.js +14 -4
- package/lib/types/workbench-view.js +2 -1
- package/package.json +1 -1
package/lib/index.js
CHANGED
|
@@ -7,8 +7,6 @@ import { createRequire } from "node:module";
|
|
|
7
7
|
import { createElement, useState } from "react";
|
|
8
8
|
//#region \0rolldown/runtime.js
|
|
9
9
|
var __require = /* @__PURE__ */ createRequire(import.meta.url);
|
|
10
|
-
//#endregion
|
|
11
|
-
//#region lib/types/panel.js
|
|
12
10
|
/** Fail loud when a client bundle is mounted without the shell seats it consumes. */
|
|
13
11
|
function requireClientSeats(ctx, owner) {
|
|
14
12
|
const candidate = ctx;
|
|
@@ -49,7 +47,7 @@ function registerSidebarPanel(ctx, spec) {
|
|
|
49
47
|
}
|
|
50
48
|
}, spec.namespace + ": locale");
|
|
51
49
|
ctx.effect(() => injectStyles$1(typeof document === "undefined" ? void 0 : document, spec.styles.css, spec.styles.tagId), spec.namespace + ": styles");
|
|
52
|
-
const fallback = spec.dictionaries[spec.fallback ?? "
|
|
50
|
+
const fallback = spec.dictionaries[spec.fallback ?? "en"];
|
|
53
51
|
const lookup = (key) => {
|
|
54
52
|
const own = fallback[key] ?? key;
|
|
55
53
|
if (!registered) return own;
|
|
@@ -109,7 +107,7 @@ function registerWorkbenchView(ctx, spec) {
|
|
|
109
107
|
}
|
|
110
108
|
}, spec.namespace + ": locale");
|
|
111
109
|
ctx.effect(() => injectStyles(typeof document === "undefined" ? void 0 : document, spec.styles.css, spec.styles.tagId), spec.namespace + ": styles");
|
|
112
|
-
const fallback = spec.dictionaries
|
|
110
|
+
const fallback = spec.dictionaries["en"];
|
|
113
111
|
const lookup = (key) => {
|
|
114
112
|
const own = fallback[key] ?? key;
|
|
115
113
|
if (!registered) return own;
|
|
@@ -239,6 +237,7 @@ function createForm(namespace, ctx) {
|
|
|
239
237
|
notify();
|
|
240
238
|
};
|
|
241
239
|
const refresh = async () => {
|
|
240
|
+
startRemote();
|
|
242
241
|
const ticket = ++generation;
|
|
243
242
|
const next = await describe(namespace);
|
|
244
243
|
if (ticket !== generation) return;
|
|
@@ -299,13 +298,16 @@ function createForm(namespace, ctx) {
|
|
|
299
298
|
return form;
|
|
300
299
|
}
|
|
301
300
|
/**
|
|
302
|
-
* Build
|
|
303
|
-
*
|
|
304
|
-
* a dead seat with the previous one.
|
|
301
|
+
* Build/return the ONE seat for one ClientContext. All panels share the same form,
|
|
302
|
+
* snapshot and revision; dispose removes the seat so a replacement context starts clean.
|
|
305
303
|
*/
|
|
304
|
+
const seats = /* @__PURE__ */ new WeakMap();
|
|
306
305
|
function createSettingsSeat(ctx) {
|
|
306
|
+
const key = ctx;
|
|
307
|
+
const existing = seats.get(key);
|
|
308
|
+
if (existing !== void 0) return existing;
|
|
307
309
|
const forms = /* @__PURE__ */ new Map();
|
|
308
|
-
|
|
310
|
+
const seat = {
|
|
309
311
|
get(namespace) {
|
|
310
312
|
let form = forms.get(namespace);
|
|
311
313
|
if (form === void 0) {
|
|
@@ -317,8 +319,14 @@ function createSettingsSeat(ctx) {
|
|
|
317
319
|
dispose: () => {
|
|
318
320
|
for (const form of forms.values()) form.dispose?.();
|
|
319
321
|
forms.clear();
|
|
322
|
+
seats.delete(key);
|
|
320
323
|
}
|
|
321
324
|
};
|
|
325
|
+
seats.set(key, seat);
|
|
326
|
+
ctx.inject?.(["remote"], () => {
|
|
327
|
+
for (const form of forms.values()) form.refresh?.();
|
|
328
|
+
});
|
|
329
|
+
return seat;
|
|
322
330
|
}
|
|
323
331
|
//#endregion
|
|
324
332
|
//#region lib/types/workspace.js
|
package/lib/types/panel.d.ts
CHANGED
|
@@ -8,6 +8,7 @@ import type { ClientSeam } from './seam.ts';
|
|
|
8
8
|
/** Dictionary lookup used by the panel body and row label. */
|
|
9
9
|
export type Translate = (key: string, values?: Readonly<Record<string, string | number>>) => string;
|
|
10
10
|
/** The feature-specific part of one sidebar panel. */
|
|
11
|
+
export declare const FALLBACK_LOCALE: "en";
|
|
11
12
|
export interface SidebarPanelSpec<Face> {
|
|
12
13
|
/** The row id; the keyed main body uses the same value. */
|
|
13
14
|
id: string;
|
package/lib/types/panel.js
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
/** The feature-specific part of one sidebar panel. */
|
|
2
|
+
export const FALLBACK_LOCALE = 'en';
|
|
1
3
|
/** Fail loud when a client bundle is mounted without the shell seats it consumes. */
|
|
2
4
|
export function requireClientSeats(ctx, owner) {
|
|
3
5
|
const candidate = ctx;
|
|
@@ -44,7 +46,7 @@ export function registerSidebarPanel(ctx, spec) {
|
|
|
44
46
|
}
|
|
45
47
|
}, spec.namespace + ': locale');
|
|
46
48
|
ctx.effect(() => injectStyles(typeof document === 'undefined' ? undefined : document, spec.styles.css, spec.styles.tagId), spec.namespace + ': styles');
|
|
47
|
-
const fallback = spec.dictionaries[spec.fallback ??
|
|
49
|
+
const fallback = spec.dictionaries[spec.fallback ?? FALLBACK_LOCALE];
|
|
48
50
|
const lookup = (key) => {
|
|
49
51
|
const own = fallback[key] ?? key;
|
|
50
52
|
if (!registered)
|
|
@@ -11,15 +11,11 @@
|
|
|
11
11
|
import type { ConfigFormsSeat } from './seam.ts';
|
|
12
12
|
interface ContextLike {
|
|
13
13
|
get?: (name: string) => unknown;
|
|
14
|
+
inject?: (deps: string[], callback: () => void) => void;
|
|
14
15
|
remote?: {
|
|
15
16
|
$on?: (event: string, listener: (namespace: string) => void) => () => void;
|
|
16
17
|
};
|
|
17
18
|
}
|
|
18
|
-
/**
|
|
19
|
-
* Build one seat per client registration; every form's remote listener is released by
|
|
20
|
-
* the caller's effect. No module-level WeakMap: a replaced registration must not share
|
|
21
|
-
* a dead seat with the previous one.
|
|
22
|
-
*/
|
|
23
19
|
export declare function createSettingsSeat(ctx: ContextLike): ConfigFormsSeat;
|
|
24
20
|
export {};
|
|
25
21
|
//# sourceMappingURL=settings-seat.d.ts.map
|
|
@@ -85,6 +85,7 @@ function createForm(namespace, ctx) {
|
|
|
85
85
|
notify();
|
|
86
86
|
};
|
|
87
87
|
const refresh = async () => {
|
|
88
|
+
startRemote();
|
|
88
89
|
const ticket = ++generation;
|
|
89
90
|
const next = await describe(namespace);
|
|
90
91
|
if (ticket !== generation)
|
|
@@ -137,13 +138,17 @@ function createForm(namespace, ctx) {
|
|
|
137
138
|
return form;
|
|
138
139
|
}
|
|
139
140
|
/**
|
|
140
|
-
* Build
|
|
141
|
-
*
|
|
142
|
-
* a dead seat with the previous one.
|
|
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
143
|
*/
|
|
144
|
+
const seats = new WeakMap();
|
|
144
145
|
export function createSettingsSeat(ctx) {
|
|
146
|
+
const key = ctx;
|
|
147
|
+
const existing = seats.get(key);
|
|
148
|
+
if (existing !== undefined)
|
|
149
|
+
return existing;
|
|
145
150
|
const forms = new Map();
|
|
146
|
-
|
|
151
|
+
const seat = {
|
|
147
152
|
get(namespace) {
|
|
148
153
|
let form = forms.get(namespace);
|
|
149
154
|
if (form === undefined) {
|
|
@@ -156,7 +161,12 @@ export function createSettingsSeat(ctx) {
|
|
|
156
161
|
for (const form of forms.values())
|
|
157
162
|
form.dispose?.();
|
|
158
163
|
forms.clear();
|
|
164
|
+
seats.delete(key);
|
|
159
165
|
},
|
|
160
166
|
};
|
|
167
|
+
seats.set(key, seat);
|
|
168
|
+
ctx.inject?.(['remote'], () => { for (const form of forms.values())
|
|
169
|
+
void form.refresh?.(); });
|
|
170
|
+
return seat;
|
|
161
171
|
}
|
|
162
172
|
//# sourceMappingURL=settings-seat.js.map
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { FALLBACK_LOCALE } from "./panel.js";
|
|
1
2
|
function injectStyles(doc, css, tagId) {
|
|
2
3
|
if (doc === undefined)
|
|
3
4
|
return () => { };
|
|
@@ -29,7 +30,7 @@ export function registerWorkbenchView(ctx, spec) {
|
|
|
29
30
|
}
|
|
30
31
|
}, spec.namespace + ': locale');
|
|
31
32
|
ctx.effect(() => injectStyles(typeof document === 'undefined' ? undefined : document, spec.styles.css, spec.styles.tagId), spec.namespace + ': styles');
|
|
32
|
-
const fallback = spec.dictionaries
|
|
33
|
+
const fallback = spec.dictionaries[FALLBACK_LOCALE];
|
|
33
34
|
const lookup = (key) => {
|
|
34
35
|
const own = fallback[key] ?? key;
|
|
35
36
|
if (!registered)
|
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.
|
|
4
|
+
"version": "0.40.0",
|
|
5
5
|
"private": false,
|
|
6
6
|
"publishConfig": {
|
|
7
7
|
"access": "public"
|