@huanlin/dsh-plugin-interpreters 0.2.2 → 0.3.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/client.js CHANGED
@@ -38,69 +38,80 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
38
38
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
39
39
  var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
40
40
 
41
- // ../dsh/node_modules/.pnpm/use-sync-external-store@1.2.0_react@18.3.1/node_modules/use-sync-external-store/cjs/use-sync-external-store-with-selector.production.min.js
42
- var require_use_sync_external_store_with_selector_production_min = __commonJS({
43
- "../dsh/node_modules/.pnpm/use-sync-external-store@1.2.0_react@18.3.1/node_modules/use-sync-external-store/cjs/use-sync-external-store-with-selector.production.min.js"(exports) {
41
+ // node_modules/.pnpm/use-sync-external-store@1.6.0/node_modules/use-sync-external-store/cjs/use-sync-external-store-with-selector.production.js
42
+ var require_use_sync_external_store_with_selector_production = __commonJS({
43
+ "node_modules/.pnpm/use-sync-external-store@1.6.0/node_modules/use-sync-external-store/cjs/use-sync-external-store-with-selector.production.js"(exports) {
44
44
  "use strict";
45
- var g = require("react");
46
- function n(a, b) {
47
- return a === b && (0 !== a || 1 / a === 1 / b) || a !== a && b !== b;
45
+ var React = require("react");
46
+ function is(x, y) {
47
+ return x === y && (0 !== x || 1 / x === 1 / y) || x !== x && y !== y;
48
48
  }
49
- var p = "function" === typeof Object.is ? Object.is : n;
50
- var q = g.useSyncExternalStore;
51
- var r = g.useRef;
52
- var t = g.useEffect;
53
- var u = g.useMemo;
54
- var v = g.useDebugValue;
55
- exports.useSyncExternalStoreWithSelector = function(a, b, e, l, h) {
56
- var c = r(null);
57
- if (null === c.current) {
58
- var f = { hasValue: false, value: null };
59
- c.current = f;
60
- } else f = c.current;
61
- c = u(function() {
62
- function a2(a3) {
63
- if (!c2) {
64
- c2 = true;
65
- d2 = a3;
66
- a3 = l(a3);
67
- if (void 0 !== h && f.hasValue) {
68
- var b2 = f.value;
69
- if (h(b2, a3)) return k = b2;
49
+ var objectIs = "function" === typeof Object.is ? Object.is : is;
50
+ var useSyncExternalStore = React.useSyncExternalStore;
51
+ var useRef = React.useRef;
52
+ var useEffect = React.useEffect;
53
+ var useMemo = React.useMemo;
54
+ var useDebugValue = React.useDebugValue;
55
+ exports.useSyncExternalStoreWithSelector = function(subscribe, getSnapshot, getServerSnapshot, selector, isEqual) {
56
+ var instRef = useRef(null);
57
+ if (null === instRef.current) {
58
+ var inst = { hasValue: false, value: null };
59
+ instRef.current = inst;
60
+ } else inst = instRef.current;
61
+ instRef = useMemo(
62
+ function() {
63
+ function memoizedSelector(nextSnapshot) {
64
+ if (!hasMemo) {
65
+ hasMemo = true;
66
+ memoizedSnapshot = nextSnapshot;
67
+ nextSnapshot = selector(nextSnapshot);
68
+ if (void 0 !== isEqual && inst.hasValue) {
69
+ var currentSelection = inst.value;
70
+ if (isEqual(currentSelection, nextSnapshot))
71
+ return memoizedSelection = currentSelection;
72
+ }
73
+ return memoizedSelection = nextSnapshot;
70
74
  }
71
- return k = a3;
75
+ currentSelection = memoizedSelection;
76
+ if (objectIs(memoizedSnapshot, nextSnapshot)) return currentSelection;
77
+ var nextSelection = selector(nextSnapshot);
78
+ if (void 0 !== isEqual && isEqual(currentSelection, nextSelection))
79
+ return memoizedSnapshot = nextSnapshot, currentSelection;
80
+ memoizedSnapshot = nextSnapshot;
81
+ return memoizedSelection = nextSelection;
72
82
  }
73
- b2 = k;
74
- if (p(d2, a3)) return b2;
75
- var e2 = l(a3);
76
- if (void 0 !== h && h(b2, e2)) return b2;
77
- d2 = a3;
78
- return k = e2;
79
- }
80
- var c2 = false, d2, k, m = void 0 === e ? null : e;
81
- return [function() {
82
- return a2(b());
83
- }, null === m ? void 0 : function() {
84
- return a2(m());
85
- }];
86
- }, [b, e, l, h]);
87
- var d = q(a, c[0], c[1]);
88
- t(function() {
89
- f.hasValue = true;
90
- f.value = d;
91
- }, [d]);
92
- v(d);
93
- return d;
83
+ var hasMemo = false, memoizedSnapshot, memoizedSelection, maybeGetServerSnapshot = void 0 === getServerSnapshot ? null : getServerSnapshot;
84
+ return [
85
+ function() {
86
+ return memoizedSelector(getSnapshot());
87
+ },
88
+ null === maybeGetServerSnapshot ? void 0 : function() {
89
+ return memoizedSelector(maybeGetServerSnapshot());
90
+ }
91
+ ];
92
+ },
93
+ [getSnapshot, getServerSnapshot, selector, isEqual]
94
+ );
95
+ var value = useSyncExternalStore(subscribe, instRef[0], instRef[1]);
96
+ useEffect(
97
+ function() {
98
+ inst.hasValue = true;
99
+ inst.value = value;
100
+ },
101
+ [value]
102
+ );
103
+ useDebugValue(value);
104
+ return value;
94
105
  };
95
106
  }
96
107
  });
97
108
 
98
- // ../dsh/node_modules/.pnpm/use-sync-external-store@1.2.0_react@18.3.1/node_modules/use-sync-external-store/with-selector.js
109
+ // node_modules/.pnpm/use-sync-external-store@1.6.0/node_modules/use-sync-external-store/with-selector.js
99
110
  var require_with_selector = __commonJS({
100
- "../dsh/node_modules/.pnpm/use-sync-external-store@1.2.0_react@18.3.1/node_modules/use-sync-external-store/with-selector.js"(exports, module2) {
111
+ "node_modules/.pnpm/use-sync-external-store@1.6.0/node_modules/use-sync-external-store/with-selector.js"(exports, module2) {
101
112
  "use strict";
102
113
  if (true) {
103
- module2.exports = require_use_sync_external_store_with_selector_production_min();
114
+ module2.exports = require_use_sync_external_store_with_selector_production();
104
115
  } else {
105
116
  module2.exports = null;
106
117
  }
@@ -130,7 +141,7 @@ var import_react = require("react");
130
141
  var import_dsh_client_ui_primitives = require("@deepseek-ai/dsh-client-ui-primitives");
131
142
 
132
143
  // src/client/store.ts
133
- var import_client = require("@deepseek-ai/dsh-client-runtime/client");
144
+ var import_dsh_client_store = require("@deepseek-ai/dsh-client-store");
134
145
  function initialState() {
135
146
  return {
136
147
  status: "idle",
@@ -155,7 +166,7 @@ var InterpretersCardController = class {
155
166
  __publicField(this, "loaded", false);
156
167
  __publicField(this, "generation", 0);
157
168
  __publicField(this, "staged", /* @__PURE__ */ new Map());
158
- this.store = (0, import_client.createSnapshotStore)(initialState());
169
+ this.store = (0, import_dsh_client_store.createSnapshotStore)(initialState());
159
170
  void this.load();
160
171
  }
161
172
  /**
@@ -905,13 +916,23 @@ var dicts = {
905
916
  var inject = ["slots", "locale", "connection"];
906
917
  function apply(ctx) {
907
918
  ctx.effect(() => ctx.locale.register(NS, { zh, en }), "dsh-interpreters: dictionaries");
908
- const betterLocale = ctx.get("betterLocale");
909
- if (betterLocale) {
910
- ctx.effect(
911
- () => betterLocale.register(NS, dicts),
912
- "interpreters: better-locale override dicts"
913
- );
914
- }
919
+ ctx.effect(() => {
920
+ let dispose;
921
+ const sync = () => {
922
+ dispose?.();
923
+ dispose = void 0;
924
+ const store = ctx.get("betterLocale");
925
+ if (store !== void 0) {
926
+ dispose = store.register(NS, dicts);
927
+ }
928
+ };
929
+ sync();
930
+ const unsubscribe = ctx.locale.subscribe(sync);
931
+ return () => {
932
+ unsubscribe();
933
+ dispose?.();
934
+ };
935
+ }, "interpreters: better-locale override dicts");
915
936
  const controller = new InterpretersCardController();
916
937
  const useSnapshot = bindSnapshotSelector(controller.store);
917
938
  ctx.effect(() => {
@@ -940,12 +961,12 @@ function apply(ctx) {
940
961
  }
941
962
  /*! Bundled license information:
942
963
 
943
- use-sync-external-store/cjs/use-sync-external-store-with-selector.production.min.js:
964
+ use-sync-external-store/cjs/use-sync-external-store-with-selector.production.js:
944
965
  (**
945
966
  * @license React
946
- * use-sync-external-store-with-selector.production.min.js
967
+ * use-sync-external-store-with-selector.production.js
947
968
  *
948
- * Copyright (c) Facebook, Inc. and its affiliates.
969
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
949
970
  *
950
971
  * This source code is licensed under the MIT license found in the
951
972
  * LICENSE file in the root directory of this source tree.
package/lib/settings.js CHANGED
@@ -16,10 +16,9 @@
16
16
  *
17
17
  * @module dsh-interpreters/settings
18
18
  */
19
- import { settingsNamespace } from '@deepseek-ai/dsh-settings';
20
19
  import { Config } from './config.js';
21
20
  /** Settings namespace under which interpreter paths persist. */
22
- export const SETTINGS_NAMESPACE = settingsNamespace('interpreters');
21
+ export const SETTINGS_NAMESPACE = 'interpreters';
23
22
  /**
24
23
  * Mirror of the dsh-settings internal `isUnloading` guard. The cordis const
25
24
  * enum for fiber state is erased at compile time, so the literal states are
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * uSES bridge: turns any bare observable snapshot source into a typed
3
3
  * selector hook. Inlined from dsh-client-ui-renderer/src/client/bind.ts
4
- * (shell-only glue; business plugins depend on runtime + ui-slots only).
4
+ * (shell-only glue; business plugins depend on client-store + ui-slots only).
5
5
  *
6
6
  * @module dsh-interpreters/client/bindSnapshotSelector
7
7
  */
@@ -15,7 +15,7 @@
15
15
  *
16
16
  * @module @huanlin/dsh-plugin-interpreters/client
17
17
  */
18
- import type { ClientContext } from '@deepseek-ai/dsh-client-runtime/client';
18
+ import type { Context as ClientContext } from '@deepseek-ai/cordis';
19
19
  import { type InterpretersKey } from './locales.ts';
20
20
  export type { InterpretersCardInjected, InterpretersCardProps } from './InterpretersCard.tsx';
21
21
  export type { InterpretersKey } from './locales.ts';
@@ -32,21 +32,35 @@ export const inject = ['slots', 'locale', 'connection'];
32
32
  */
33
33
  export function apply(ctx) {
34
34
  ctx.effect(() => ctx.locale.register(NS, { zh, en }), 'dsh-interpreters: dictionaries');
35
- // Opt-in third-language overrides through @huanlin/dsh-plugin-better-locale:
36
- // when installed it publishes `ctx.betterLocale` (the override store) and
37
- // patches LocaleRuntime.lookup to consult it. `ctx.get` is a non-reactive
38
- // read of an optional service, so an absent plugin is a plain no-op.
39
- const betterLocale = ctx.get('betterLocale');
40
- if (betterLocale) {
41
- ctx.effect(() => betterLocale.register(NS, dicts), 'interpreters: better-locale override dicts');
42
- }
35
+ // Opt-in third-language overrides through @huanlin/dsh-plugin-better-locale.
36
+ // Activation-order-safe: ctx.get('betterLocale') is a non-reactive read, so
37
+ // if better-locale activates after us, the initial read returns undefined.
38
+ // We subscribe to ctx.locale better-locale bumps its revision on activation
39
+ // (persisted override) and on every override switch — and re-check on each bump.
40
+ ctx.effect(() => {
41
+ let dispose;
42
+ const sync = () => {
43
+ dispose?.();
44
+ dispose = undefined;
45
+ const store = ctx.get('betterLocale');
46
+ if (store !== undefined) {
47
+ dispose = store.register(NS, dicts);
48
+ }
49
+ };
50
+ sync();
51
+ const unsubscribe = ctx.locale.subscribe(sync);
52
+ return () => {
53
+ unsubscribe();
54
+ dispose?.();
55
+ };
56
+ }, 'interpreters: better-locale override dicts');
43
57
  // The store reads/writes the interpreters config over the plugin's
44
58
  // self-hosted HTTP route (`/interpreters/api/get` + `/interpreters/api/set`).
45
59
  const controller = new InterpretersCardController();
46
60
  const useSnapshot = bindSnapshotSelector(controller.store);
47
61
  // Pushed invalidations converge the open surface without polling. The dsh
48
- // snapshot removed the `settings/changed` host passthrough from the client
49
- // runtime Events vocabulary, so convergence rides `connection/reset` — a
62
+ // client Events vocabulary has no `settings/changed` host passthrough, so
63
+ // convergence rides `connection/reset` — a
50
64
  // connection reset invalidates the whole client state. A burst of resets
51
65
  // coalesces into a single refetch via the microtask debounce, and
52
66
  // `refreshIfLoaded` keeps an unopened card idle.
@@ -12,7 +12,7 @@
12
12
  *
13
13
  * @module dsh-interpreters/client/store
14
14
  */
15
- import { type SnapshotStore } from '@deepseek-ai/dsh-client-runtime/client';
15
+ import { type SnapshotStore } from '@deepseek-ai/dsh-client-store';
16
16
  /** The persisted shape of the `interpreters` namespace. */
17
17
  export interface InterpretersSettings {
18
18
  pythonPath?: string;
@@ -12,7 +12,7 @@
12
12
  *
13
13
  * @module dsh-interpreters/client/store
14
14
  */
15
- import { createSnapshotStore } from '@deepseek-ai/dsh-client-runtime/client';
15
+ import { createSnapshotStore } from '@deepseek-ai/dsh-client-store';
16
16
  /** Initial empty state. */
17
17
  function initialState() {
18
18
  return {
@@ -20,7 +20,7 @@
20
20
  * @module dsh-interpreters/gateway
21
21
  */
22
22
  import type { Context } from '@deepseek-ai/cordis';
23
- import type { Settings } from '@deepseek-ai/dsh-settings';
23
+ import type { SettingsProvider } from '@deepseek-ai/dsh-settings';
24
24
  import { type Config as ConfigType, type ResolvedConfig } from './config.js';
25
25
  import { type InterpretersSettingsBridge } from './settings.js';
26
26
  /** Wire view returned by both `get` and `set`: the fully-resolved config. */
@@ -49,7 +49,7 @@ export declare function registerHttpGateway(ctx: Context, bridge: InterpretersSe
49
49
  * @returns the new resolved config view.
50
50
  * @throws when the settings service is unavailable.
51
51
  */
52
- export declare function handleSet(body: unknown, settings: Settings | undefined, bridge: InterpretersSettingsBridge): Promise<InterpretersConfigView>;
52
+ export declare function handleSet(body: unknown, settings: SettingsProvider | undefined, bridge: InterpretersSettingsBridge): Promise<InterpretersConfigView>;
53
53
  /**
54
54
  * Extract and validate the patch from the request body.
55
55
  *
@@ -19,7 +19,7 @@
19
19
  import type { Context } from '@deepseek-ai/cordis';
20
20
  import { type Config as ConfigType } from './config.js';
21
21
  /** Settings namespace under which interpreter paths persist. */
22
- export declare const SETTINGS_NAMESPACE: import("@deepseek-ai/dsh-settings").SettingsNamespace;
22
+ export declare const SETTINGS_NAMESPACE: "interpreters";
23
23
  /** Read face the gateway and tool re-registration consume. */
24
24
  export interface InterpretersSettingsBridge {
25
25
  /** The current resolved config (composition seed while settings is absent). */
@@ -16,10 +16,9 @@
16
16
  *
17
17
  * @module dsh-interpreters/settings
18
18
  */
19
- import { settingsNamespace } from '@deepseek-ai/dsh-settings';
20
19
  import { Config } from './config.js';
21
20
  /** Settings namespace under which interpreter paths persist. */
22
- export const SETTINGS_NAMESPACE = settingsNamespace('interpreters');
21
+ export const SETTINGS_NAMESPACE = 'interpreters';
23
22
  /**
24
23
  * Mirror of the dsh-settings internal `isUnloading` guard. The cordis const
25
24
  * enum for fiber state is erased at compile time, so the literal states are
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@huanlin/dsh-plugin-interpreters",
3
- "version": "0.2.2",
3
+ "version": "0.3.0",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
@@ -33,26 +33,26 @@
33
33
  },
34
34
  "client": {
35
35
  "inject": [
36
- "@deepseek-ai/dsh-client-runtime",
37
36
  "@deepseek-ai/dsh-client-locale",
38
37
  "@deepseek-ai/dsh-client-connection",
39
- "@deepseek-ai/dsh-client-ui-settings-plugins",
40
- "@deepseek-ai/dsh-client-ui-slots"
38
+ "@deepseek-ai/dsh-client-ui-renderer",
39
+ "@deepseek-ai/dsh-client-ui-settings-plugins"
41
40
  ],
42
41
  "platform": "web"
43
42
  }
44
43
  },
45
44
  "peerDependencies": {
46
- "@deepseek-ai/cordis": "^4.0.1-rc.1",
47
- "@deepseek-ai/dsh-client-connection": "^0.1.0-rc.8",
48
- "@deepseek-ai/dsh-client-locale": "^0.1.0-rc.8",
49
- "@deepseek-ai/dsh-client-runtime": "^0.1.0-rc.8",
50
- "@deepseek-ai/dsh-client-ui-settings-plugins": "^0.1.0-rc.8",
51
- "@deepseek-ai/dsh-client-ui-primitives": "^0.1.0-rc.8",
52
- "@deepseek-ai/dsh-client-ui-slots": "^0.1.0-rc.8",
53
- "@deepseek-ai/dsh-host-webserver": "^0.1.0-rc.8",
54
- "@deepseek-ai/dsh-settings": "^0.1.0-rc.8",
55
- "@deepseek-ai/dsh-tools": "^0.1.0-rc.8",
45
+ "@deepseek-ai/cordis": "^4.0.1",
46
+ "@deepseek-ai/dsh-client-connection": "^0.1.2-rc.1",
47
+ "@deepseek-ai/dsh-client-locale": "^0.1.2-rc.1",
48
+ "@deepseek-ai/dsh-client-store": "^0.1.2-rc.1",
49
+ "@deepseek-ai/dsh-client-ui-primitives": "^0.1.2-rc.1",
50
+ "@deepseek-ai/dsh-client-ui-renderer": "^0.1.2-rc.1",
51
+ "@deepseek-ai/dsh-client-ui-settings-plugins": "^0.1.2-rc.1",
52
+ "@deepseek-ai/dsh-client-ui-slots": "^0.1.2-rc.1",
53
+ "@deepseek-ai/dsh-host-webserver": "^0.1.2-rc.1",
54
+ "@deepseek-ai/dsh-settings": "^0.1.2-rc.1",
55
+ "@deepseek-ai/dsh-tools": "^0.1.2-rc.1",
56
56
  "react": "^18.2.0",
57
57
  "schemastery": "^3.18.0"
58
58
  },
@@ -66,7 +66,10 @@
66
66
  "@deepseek-ai/dsh-client-locale": {
67
67
  "optional": true
68
68
  },
69
- "@deepseek-ai/dsh-client-runtime": {
69
+ "@deepseek-ai/dsh-client-store": {
70
+ "optional": true
71
+ },
72
+ "@deepseek-ai/dsh-client-ui-renderer": {
70
73
  "optional": true
71
74
  },
72
75
  "@deepseek-ai/dsh-client-ui-settings-plugins": {
@@ -95,20 +98,11 @@
95
98
  }
96
99
  },
97
100
  "devDependencies": {
98
- "@deepseek-ai/cordis": "^4.0.1-rc.1",
99
- "@deepseek-ai/dsh-client-connection": "^0.1.0-rc.8",
100
- "@deepseek-ai/dsh-client-locale": "^0.1.0-rc.8",
101
- "@deepseek-ai/dsh-client-runtime": "^0.1.0-rc.8",
102
- "@deepseek-ai/dsh-client-ui-settings-plugins": "^0.1.0-rc.8",
103
- "@deepseek-ai/dsh-client-ui-primitives": "^0.1.0-rc.8",
104
- "@deepseek-ai/dsh-client-ui-slots": "^0.1.0-rc.8",
105
- "@deepseek-ai/dsh-host-webserver": "^0.1.0-rc.8",
106
- "@deepseek-ai/dsh-settings": "^0.1.0-rc.8",
107
- "@deepseek-ai/dsh-tools": "^0.1.0-rc.8",
108
101
  "@types/node": "^22.20.0",
109
102
  "@types/react": "~18.3.1",
110
103
  "esbuild": "^0.28.2",
111
104
  "lightningcss": "^1.29.2",
105
+ "schemastery": "^3.18.0",
112
106
  "tsdown": "^0.22.2",
113
107
  "typescript": "^5.9.0",
114
108
  "use-sync-external-store": "^1.2.0",