@aiwayds/dsh-llm-proxy 0.2.0 → 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/README.md +2 -1
- package/lib/deep-equal.d.ts +23 -0
- package/lib/deep-equal.js +40 -0
- package/lib/deep-equal.js.map +1 -0
- package/lib/index.d.ts +3 -2
- package/lib/index.js +25 -9
- package/lib/index.js.map +1 -1
- package/package.json +9 -9
- package/src/deep-equal.ts +36 -0
- package/src/index.ts +33 -9
package/README.md
CHANGED
|
@@ -65,7 +65,8 @@ cordis 闭包,导致双实例崩溃(详见 dsh 生态 link-dsh-closure 机
|
|
|
65
65
|
## 配置入口(settings.yaml 命名空间段)
|
|
66
66
|
|
|
67
67
|
dsh 插件的用户配置唯一入口是 **settings.yaml 里按插件 id 命名的命名空间段**。本插件通过
|
|
68
|
-
`@deepseek-ai/dsh-settings
|
|
68
|
+
`@deepseek-ai/dsh-settings`(要求 `>=0.1.2-alpha.3`)settings provider 的
|
|
69
|
+
`installSection` 注册了 `dsh-llm-proxy` 命名空间
|
|
69
70
|
(与 harness 内置插件 `llm-deepseek` 的 `llm-deepseek:` 段同机制),所以请在
|
|
70
71
|
`~/.dsh/settings.yaml` 写:
|
|
71
72
|
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Deep equality over JSON-compatible data (objects, arrays, primitives).
|
|
3
|
+
*
|
|
4
|
+
* Localized copy of `deepEqualJson` from `@deepseek-ai/dsh-settings@0.1.1-rc.2`
|
|
5
|
+
* (`lib/index.js`): dsh-settings 0.1.2-alpha.3 removed the module-level export,
|
|
6
|
+
* relocating the identical implementation into `@deepseek-ai/dsh-util-values`,
|
|
7
|
+
* which is not a declared dependency of this plugin. The relation is unchanged
|
|
8
|
+
* between the two host versions — structural equality over JSON data, arrays
|
|
9
|
+
* compared element-wise, objects compared as key sets with recursively equal
|
|
10
|
+
* values, everything else by `Object.is`-style identity — so this copy is a
|
|
11
|
+
* drop-in replacement, not a behavioral fork.
|
|
12
|
+
*
|
|
13
|
+
* Used to skip a router rebuild when a settings update resolves to the same
|
|
14
|
+
* policy as the live one.
|
|
15
|
+
*
|
|
16
|
+
* @module @aiwayds/dsh-llm-proxy/deep-equal
|
|
17
|
+
*/
|
|
18
|
+
/**
|
|
19
|
+
* @param a - one JSON-compatible value.
|
|
20
|
+
* @param b - the other JSON-compatible value.
|
|
21
|
+
* @returns whether the two values are structurally equal.
|
|
22
|
+
*/
|
|
23
|
+
export declare function deepEqualJson(a: unknown, b: unknown): boolean;
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Deep equality over JSON-compatible data (objects, arrays, primitives).
|
|
3
|
+
*
|
|
4
|
+
* Localized copy of `deepEqualJson` from `@deepseek-ai/dsh-settings@0.1.1-rc.2`
|
|
5
|
+
* (`lib/index.js`): dsh-settings 0.1.2-alpha.3 removed the module-level export,
|
|
6
|
+
* relocating the identical implementation into `@deepseek-ai/dsh-util-values`,
|
|
7
|
+
* which is not a declared dependency of this plugin. The relation is unchanged
|
|
8
|
+
* between the two host versions — structural equality over JSON data, arrays
|
|
9
|
+
* compared element-wise, objects compared as key sets with recursively equal
|
|
10
|
+
* values, everything else by `Object.is`-style identity — so this copy is a
|
|
11
|
+
* drop-in replacement, not a behavioral fork.
|
|
12
|
+
*
|
|
13
|
+
* Used to skip a router rebuild when a settings update resolves to the same
|
|
14
|
+
* policy as the live one.
|
|
15
|
+
*
|
|
16
|
+
* @module @aiwayds/dsh-llm-proxy/deep-equal
|
|
17
|
+
*/
|
|
18
|
+
/**
|
|
19
|
+
* @param a - one JSON-compatible value.
|
|
20
|
+
* @param b - the other JSON-compatible value.
|
|
21
|
+
* @returns whether the two values are structurally equal.
|
|
22
|
+
*/
|
|
23
|
+
export function deepEqualJson(a, b) {
|
|
24
|
+
if (a === b)
|
|
25
|
+
return true;
|
|
26
|
+
if (typeof a !== 'object' || typeof b !== 'object' || a === null || b === null)
|
|
27
|
+
return false;
|
|
28
|
+
if (Array.isArray(a) || Array.isArray(b)) {
|
|
29
|
+
if (!Array.isArray(a) || !Array.isArray(b) || a.length !== b.length)
|
|
30
|
+
return false;
|
|
31
|
+
return a.every((entry, index) => deepEqualJson(entry, b[index]));
|
|
32
|
+
}
|
|
33
|
+
const left = a;
|
|
34
|
+
const right = b;
|
|
35
|
+
const keys = Object.keys(left);
|
|
36
|
+
if (keys.length !== Object.keys(right).length)
|
|
37
|
+
return false;
|
|
38
|
+
return keys.every((key) => key in right && deepEqualJson(left[key], right[key]));
|
|
39
|
+
}
|
|
40
|
+
//# sourceMappingURL=deep-equal.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"deep-equal.js","sourceRoot":"","sources":["../src/deep-equal.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH;;;;GAIG;AACH,MAAM,UAAU,aAAa,CAAC,CAAU,EAAE,CAAU;IAClD,IAAI,CAAC,KAAK,CAAC;QAAE,OAAO,IAAI,CAAA;IACxB,IAAI,OAAO,CAAC,KAAK,QAAQ,IAAI,OAAO,CAAC,KAAK,QAAQ,IAAI,CAAC,KAAK,IAAI,IAAI,CAAC,KAAK,IAAI;QAAE,OAAO,KAAK,CAAA;IAC5F,IAAI,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,IAAI,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,CAAC;QACzC,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,MAAM,KAAK,CAAC,CAAC,MAAM;YAAE,OAAO,KAAK,CAAA;QACjF,OAAO,CAAC,CAAC,KAAK,CAAC,CAAC,KAAK,EAAE,KAAK,EAAE,EAAE,CAAC,aAAa,CAAC,KAAK,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAA;IAClE,CAAC;IACD,MAAM,IAAI,GAAG,CAA4B,CAAA;IACzC,MAAM,KAAK,GAAG,CAA4B,CAAA;IAC1C,MAAM,IAAI,GAAG,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;IAC9B,IAAI,IAAI,CAAC,MAAM,KAAK,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,MAAM;QAAE,OAAO,KAAK,CAAA;IAC3D,OAAO,IAAI,CAAC,KAAK,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,IAAI,KAAK,IAAI,aAAa,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAA;AAClF,CAAC"}
|
package/lib/index.d.ts
CHANGED
|
@@ -15,8 +15,9 @@
|
|
|
15
15
|
* carries the plugin's configuration and troubleshooting guide.
|
|
16
16
|
*
|
|
17
17
|
* User configuration arrives exclusively through the `dsh-llm-proxy`
|
|
18
|
-
* settings.yaml namespace (registered via
|
|
19
|
-
* seam harness core plugins use); the bundle entry
|
|
18
|
+
* settings.yaml namespace (registered via the settings provider's
|
|
19
|
+
* installSection, the same seam harness core plugins use); the bundle entry
|
|
20
|
+
* config is the base layer.
|
|
20
21
|
* Edits to the settings section hot-publish: the router is rebuilt in place,
|
|
21
22
|
* unless the resolved values are unchanged, in which case the rebuild is
|
|
22
23
|
* skipped (the settings attach itself fires one redundant onChange).
|
package/lib/index.js
CHANGED
|
@@ -15,8 +15,9 @@
|
|
|
15
15
|
* carries the plugin's configuration and troubleshooting guide.
|
|
16
16
|
*
|
|
17
17
|
* User configuration arrives exclusively through the `dsh-llm-proxy`
|
|
18
|
-
* settings.yaml namespace (registered via
|
|
19
|
-
* seam harness core plugins use); the bundle entry
|
|
18
|
+
* settings.yaml namespace (registered via the settings provider's
|
|
19
|
+
* installSection, the same seam harness core plugins use); the bundle entry
|
|
20
|
+
* config is the base layer.
|
|
20
21
|
* Edits to the settings section hot-publish: the router is rebuilt in place,
|
|
21
22
|
* unless the resolved values are unchanged, in which case the rebuild is
|
|
22
23
|
* skipped (the settings attach itself fires one redundant onChange).
|
|
@@ -29,10 +30,10 @@
|
|
|
29
30
|
*/
|
|
30
31
|
import { readFile } from 'node:fs/promises';
|
|
31
32
|
import { fileURLToPath } from 'node:url';
|
|
32
|
-
import { deepEqualJson, installSettingsSection, settingsNamespace } from '@deepseek-ai/dsh-settings';
|
|
33
33
|
import { BUNDLED_SKILL_RANK, } from '@deepseek-ai/dsh-skill';
|
|
34
34
|
import z from '@deepseek-ai/schemastery';
|
|
35
35
|
import * as undici from 'undici';
|
|
36
|
+
import { deepEqualJson } from "./deep-equal.js";
|
|
36
37
|
import { createProxyRouterDispatcher, withUndiciErrorListener } from "./router.js";
|
|
37
38
|
export { matchOrigin } from "./match.js";
|
|
38
39
|
export { createProxyRouterDispatcher, resolveRoute } from "./router.js";
|
|
@@ -43,8 +44,14 @@ export const inject = ['skills'];
|
|
|
43
44
|
* The settings.yaml namespace this plugin owns. dsh feeds user configuration
|
|
44
45
|
* to plugins only through registered settings namespaces; the document
|
|
45
46
|
* section key that reaches this plugin is exactly this string.
|
|
47
|
+
*
|
|
48
|
+
* A plain literal is the supported spelling since dsh-settings
|
|
49
|
+
* 0.1.2-alpha.3: `register`/`installSection` brand-check the namespace at the
|
|
50
|
+
* type level (`SettingsNamespaceInput`) and validate the same pattern at
|
|
51
|
+
* runtime (`parseSettingsNamespace`), replacing the removed
|
|
52
|
+
* `settingsNamespace()` helper.
|
|
46
53
|
*/
|
|
47
|
-
const SETTINGS_NAMESPACE =
|
|
54
|
+
const SETTINGS_NAMESPACE = 'dsh-llm-proxy';
|
|
48
55
|
/** Runtime schema for {@link Config}. */
|
|
49
56
|
export const Config = z.object({
|
|
50
57
|
enabled: z.boolean().default(true),
|
|
@@ -325,11 +332,20 @@ export function apply(ctx, config = {}, internals = {}) {
|
|
|
325
332
|
// that never mount a settings service; when the service appears, the
|
|
326
333
|
// layered section takes over and subsequent edits hot-publish here.
|
|
327
334
|
rejudge(true);
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
335
|
+
// Optional-settings consumer wiring. The rc.2 module-level
|
|
336
|
+
// installSettingsSection() helper was removed in dsh-settings
|
|
337
|
+
// 0.1.2-alpha.3; the attach / detach-fallback / watch body moved behind the
|
|
338
|
+
// provider as SettingsProvider.installSection (identical semantics — the
|
|
339
|
+
// entry config stays the fallback source when the provider detaches).
|
|
340
|
+
// ctx.inject keeps the whole wiring dormant on hosts that never mount a
|
|
341
|
+
// settings service.
|
|
342
|
+
ctx.inject(['settings'], (sctx) => {
|
|
343
|
+
sctx.settings.installSection(ctx, SETTINGS_NAMESPACE, Config, config, {
|
|
344
|
+
setSource: (current) => {
|
|
345
|
+
getSource = current;
|
|
346
|
+
},
|
|
347
|
+
onChange: () => rejudge(false),
|
|
348
|
+
});
|
|
333
349
|
});
|
|
334
350
|
}
|
|
335
351
|
//# sourceMappingURL=index.js.map
|
package/lib/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AAEH,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAA;AAC3C,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAA;AAUxC,OAAO,EACL,kBAAkB,GAInB,MAAM,wBAAwB,CAAA;AAC/B,OAAO,CAAC,MAAM,0BAA0B,CAAA;AACxC,OAAO,KAAK,MAAM,MAAM,QAAQ,CAAA;AAChC,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAA;AAC/C,OAAO,EAAE,2BAA2B,EAAE,uBAAuB,EAAsB,MAAM,aAAa,CAAA;AAEtG,OAAO,EAAE,WAAW,EAAE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B,CAAC;YACD,QAAQ,EAAE,GAAG,EAAE,CAAC,OAAO,CAAC,KAAK,CAAC;SAC/B,CAAC,CAAA;IACJ,CAAC,CAAC,CAAA;AACJ,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aiwayds/dsh-llm-proxy",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.0",
|
|
4
4
|
"description": "dsh plugin: SYSTEM proxy (env) + LLM traffic-splitting proxy via a process-global undici routing dispatcher",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "lib/index.js",
|
|
@@ -40,10 +40,10 @@
|
|
|
40
40
|
"undici": "8.9.0"
|
|
41
41
|
},
|
|
42
42
|
"peerDependencies": {
|
|
43
|
-
"@deepseek-ai/cordis": "4.0.
|
|
44
|
-
"@deepseek-ai/schemastery": "3.18.
|
|
45
|
-
"@deepseek-ai/dsh-settings": "0.1.
|
|
46
|
-
"@deepseek-ai/dsh-skill": "0.1.
|
|
43
|
+
"@deepseek-ai/cordis": "4.0.2",
|
|
44
|
+
"@deepseek-ai/schemastery": "3.18.2",
|
|
45
|
+
"@deepseek-ai/dsh-settings": ">=0.1.2-alpha.3",
|
|
46
|
+
"@deepseek-ai/dsh-skill": ">=0.1.2-alpha.3"
|
|
47
47
|
},
|
|
48
48
|
"peerDependenciesMeta": {
|
|
49
49
|
"@deepseek-ai/cordis": {
|
|
@@ -57,10 +57,10 @@
|
|
|
57
57
|
}
|
|
58
58
|
},
|
|
59
59
|
"devDependencies": {
|
|
60
|
-
"@deepseek-ai/cordis": "4.0.
|
|
61
|
-
"@deepseek-ai/schemastery": "3.18.
|
|
62
|
-
"@deepseek-ai/dsh-settings": "0.1.
|
|
63
|
-
"@deepseek-ai/dsh-skill": "0.1.
|
|
60
|
+
"@deepseek-ai/cordis": "4.0.2",
|
|
61
|
+
"@deepseek-ai/schemastery": "3.18.2",
|
|
62
|
+
"@deepseek-ai/dsh-settings": "0.1.2-alpha.3",
|
|
63
|
+
"@deepseek-ai/dsh-skill": "0.1.2-alpha.3",
|
|
64
64
|
"@types/node": "^24.0.0",
|
|
65
65
|
"typescript": "^5.9.0"
|
|
66
66
|
},
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Deep equality over JSON-compatible data (objects, arrays, primitives).
|
|
3
|
+
*
|
|
4
|
+
* Localized copy of `deepEqualJson` from `@deepseek-ai/dsh-settings@0.1.1-rc.2`
|
|
5
|
+
* (`lib/index.js`): dsh-settings 0.1.2-alpha.3 removed the module-level export,
|
|
6
|
+
* relocating the identical implementation into `@deepseek-ai/dsh-util-values`,
|
|
7
|
+
* which is not a declared dependency of this plugin. The relation is unchanged
|
|
8
|
+
* between the two host versions — structural equality over JSON data, arrays
|
|
9
|
+
* compared element-wise, objects compared as key sets with recursively equal
|
|
10
|
+
* values, everything else by `Object.is`-style identity — so this copy is a
|
|
11
|
+
* drop-in replacement, not a behavioral fork.
|
|
12
|
+
*
|
|
13
|
+
* Used to skip a router rebuild when a settings update resolves to the same
|
|
14
|
+
* policy as the live one.
|
|
15
|
+
*
|
|
16
|
+
* @module @aiwayds/dsh-llm-proxy/deep-equal
|
|
17
|
+
*/
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* @param a - one JSON-compatible value.
|
|
21
|
+
* @param b - the other JSON-compatible value.
|
|
22
|
+
* @returns whether the two values are structurally equal.
|
|
23
|
+
*/
|
|
24
|
+
export function deepEqualJson(a: unknown, b: unknown): boolean {
|
|
25
|
+
if (a === b) return true
|
|
26
|
+
if (typeof a !== 'object' || typeof b !== 'object' || a === null || b === null) return false
|
|
27
|
+
if (Array.isArray(a) || Array.isArray(b)) {
|
|
28
|
+
if (!Array.isArray(a) || !Array.isArray(b) || a.length !== b.length) return false
|
|
29
|
+
return a.every((entry, index) => deepEqualJson(entry, b[index]))
|
|
30
|
+
}
|
|
31
|
+
const left = a as Record<string, unknown>
|
|
32
|
+
const right = b as Record<string, unknown>
|
|
33
|
+
const keys = Object.keys(left)
|
|
34
|
+
if (keys.length !== Object.keys(right).length) return false
|
|
35
|
+
return keys.every((key) => key in right && deepEqualJson(left[key], right[key]))
|
|
36
|
+
}
|
package/src/index.ts
CHANGED
|
@@ -15,8 +15,9 @@
|
|
|
15
15
|
* carries the plugin's configuration and troubleshooting guide.
|
|
16
16
|
*
|
|
17
17
|
* User configuration arrives exclusively through the `dsh-llm-proxy`
|
|
18
|
-
* settings.yaml namespace (registered via
|
|
19
|
-
* seam harness core plugins use); the bundle entry
|
|
18
|
+
* settings.yaml namespace (registered via the settings provider's
|
|
19
|
+
* installSection, the same seam harness core plugins use); the bundle entry
|
|
20
|
+
* config is the base layer.
|
|
20
21
|
* Edits to the settings section hot-publish: the router is rebuilt in place,
|
|
21
22
|
* unless the resolved values are unchanged, in which case the rebuild is
|
|
22
23
|
* skipped (the settings attach itself fires one redundant onChange).
|
|
@@ -31,7 +32,14 @@
|
|
|
31
32
|
import { readFile } from 'node:fs/promises'
|
|
32
33
|
import { fileURLToPath } from 'node:url'
|
|
33
34
|
import type { Context } from '@deepseek-ai/cordis'
|
|
34
|
-
|
|
35
|
+
// Type-only side-effect import: loads dsh-settings' `declare module
|
|
36
|
+
// '@deepseek-ai/cordis'` augmentation, which is what puts `ctx.settings` on
|
|
37
|
+
// the Context type. There is no runtime import — the host provides the
|
|
38
|
+
// settings service; alpha.3 removed the module-level settingsNamespace(),
|
|
39
|
+
// installSettingsSection(), and deepEqualJson() helpers this plugin used to
|
|
40
|
+
// import (see SETTINGS_NAMESPACE below, the installSection call in apply(),
|
|
41
|
+
// and ./deep-equal.ts for their replacements).
|
|
42
|
+
import type {} from '@deepseek-ai/dsh-settings'
|
|
35
43
|
import {
|
|
36
44
|
BUNDLED_SKILL_RANK,
|
|
37
45
|
type SkillCandidate,
|
|
@@ -40,6 +48,7 @@ import {
|
|
|
40
48
|
} from '@deepseek-ai/dsh-skill'
|
|
41
49
|
import z from '@deepseek-ai/schemastery'
|
|
42
50
|
import * as undici from 'undici'
|
|
51
|
+
import { deepEqualJson } from './deep-equal.ts'
|
|
43
52
|
import { createProxyRouterDispatcher, withUndiciErrorListener, type LlmProxyEntry } from './router.ts'
|
|
44
53
|
|
|
45
54
|
export { matchOrigin } from './match.ts'
|
|
@@ -54,8 +63,14 @@ export const inject = ['skills']
|
|
|
54
63
|
* The settings.yaml namespace this plugin owns. dsh feeds user configuration
|
|
55
64
|
* to plugins only through registered settings namespaces; the document
|
|
56
65
|
* section key that reaches this plugin is exactly this string.
|
|
66
|
+
*
|
|
67
|
+
* A plain literal is the supported spelling since dsh-settings
|
|
68
|
+
* 0.1.2-alpha.3: `register`/`installSection` brand-check the namespace at the
|
|
69
|
+
* type level (`SettingsNamespaceInput`) and validate the same pattern at
|
|
70
|
+
* runtime (`parseSettingsNamespace`), replacing the removed
|
|
71
|
+
* `settingsNamespace()` helper.
|
|
57
72
|
*/
|
|
58
|
-
const SETTINGS_NAMESPACE =
|
|
73
|
+
const SETTINGS_NAMESPACE = 'dsh-llm-proxy'
|
|
59
74
|
|
|
60
75
|
/** Plugin configuration. */
|
|
61
76
|
export interface Config {
|
|
@@ -420,10 +435,19 @@ export function apply(ctx: Context, config: Config = {}, internals: ApplyInterna
|
|
|
420
435
|
// that never mount a settings service; when the service appears, the
|
|
421
436
|
// layered section takes over and subsequent edits hot-publish here.
|
|
422
437
|
rejudge(true)
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
438
|
+
// Optional-settings consumer wiring. The rc.2 module-level
|
|
439
|
+
// installSettingsSection() helper was removed in dsh-settings
|
|
440
|
+
// 0.1.2-alpha.3; the attach / detach-fallback / watch body moved behind the
|
|
441
|
+
// provider as SettingsProvider.installSection (identical semantics — the
|
|
442
|
+
// entry config stays the fallback source when the provider detaches).
|
|
443
|
+
// ctx.inject keeps the whole wiring dormant on hosts that never mount a
|
|
444
|
+
// settings service.
|
|
445
|
+
ctx.inject(['settings'], (sctx) => {
|
|
446
|
+
sctx.settings.installSection(ctx, SETTINGS_NAMESPACE, Config, config, {
|
|
447
|
+
setSource: (current) => {
|
|
448
|
+
getSource = current
|
|
449
|
+
},
|
|
450
|
+
onChange: () => rejudge(false),
|
|
451
|
+
})
|
|
428
452
|
})
|
|
429
453
|
}
|