@chaoset/adaptive-perf 0.2.0 → 0.2.2
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/client/client.cjs +44 -4
- package/lib/typert.host.js +50 -0
- package/package.json +3 -3
package/client/client.cjs
CHANGED
|
@@ -290,15 +290,55 @@ window.__ModuleLoader__.load({
|
|
|
290
290
|
}
|
|
291
291
|
|
|
292
292
|
// ── 插件 apply ───────────────────────────────────────────────────────
|
|
293
|
-
|
|
294
|
-
|
|
293
|
+
// DSH 客户端的 remote.<ns> 服务不会自动生成:必须由客户端代码用
|
|
294
|
+
// ctx.remote.$mount(contribution) 显式挂载(官方 dsh-api-remotes 即如此)。
|
|
295
|
+
// 若只把 remote.adaptivePerfConfig 写进 inject 而不挂载,命名空间永远
|
|
296
|
+
// 不存在,客户端插件会一直 pending,web boot 报 "did not activate"。
|
|
297
|
+
// 因此本插件先挂载自己的命名空间,再注册设置卡片。
|
|
298
|
+
const inject = ["slots", "locale", "remote"];
|
|
299
|
+
const passthroughSchema = { parse: (value) => value };
|
|
300
|
+
const REMOTE_CONTRIBUTION = {
|
|
301
|
+
package: "@chaoset/adaptive-perf",
|
|
302
|
+
descriptors: [
|
|
303
|
+
{
|
|
304
|
+
id: "@chaoset/adaptive-perf#adaptivePerfConfig/get",
|
|
305
|
+
service: "adaptivePerfConfig",
|
|
306
|
+
namespace: "adaptivePerfConfig",
|
|
307
|
+
method: "get",
|
|
308
|
+
invocation: { kind: "direct" },
|
|
309
|
+
parameters: [],
|
|
310
|
+
result: { mode: "strict", typeSymbol: "adaptivePerfConfig/get:result", schema: passthroughSchema }
|
|
311
|
+
},
|
|
312
|
+
{
|
|
313
|
+
id: "@chaoset/adaptive-perf#adaptivePerfConfig/set",
|
|
314
|
+
service: "adaptivePerfConfig",
|
|
315
|
+
namespace: "adaptivePerfConfig",
|
|
316
|
+
method: "set",
|
|
317
|
+
invocation: { kind: "direct" },
|
|
318
|
+
parameters: [{
|
|
319
|
+
name: "partial",
|
|
320
|
+
wire: "partial",
|
|
321
|
+
source: "json",
|
|
322
|
+
codec: { mode: "strict", typeSymbol: "adaptivePerfConfig/set:partial", schema: passthroughSchema }
|
|
323
|
+
}],
|
|
324
|
+
result: { mode: "strict", typeSymbol: "adaptivePerfConfig/set:result", schema: passthroughSchema }
|
|
325
|
+
}
|
|
326
|
+
]
|
|
327
|
+
};
|
|
328
|
+
async function apply(ctx) {
|
|
295
329
|
const t = ctx.locale.bind(NS);
|
|
296
330
|
ctx.effect(() => ctx.locale.register(NS, { zh, en }), "adaptive-perf: dictionaries");
|
|
297
|
-
|
|
331
|
+
// 先挂载命名空间,再用 ctx.get 取回服务:cordis 的属性访问(ctx.remote.X)
|
|
332
|
+
// 要求 X 出现在 inject 里,而本插件的命名空间由自己挂载,若写进 inject
|
|
333
|
+
// 会和自己等待的服务形成死锁,因此用 ctx.get(对未声明的服务合法)。
|
|
334
|
+
await ctx.remote.$mount(REMOTE_CONTRIBUTION);
|
|
335
|
+
const configService = ctx.get("remote.adaptivePerfConfig");
|
|
336
|
+
if (configService === void 0) throw new Error("adaptive-perf: remote.adaptivePerfConfig did not materialize after mount");
|
|
337
|
+
const getConfig = () => configService.get().then((result) => {
|
|
298
338
|
if (!result.ok) throw new Error("adaptivePerfConfig.get failed: " + result.error.code + ": " + result.error.message);
|
|
299
339
|
return result.value.config;
|
|
300
340
|
});
|
|
301
|
-
const setConfig = (partial) =>
|
|
341
|
+
const setConfig = (partial) => configService.set(partial).then((result) => {
|
|
302
342
|
if (!result.ok) throw new Error("adaptivePerfConfig.set failed: " + result.error.code + ": " + result.error.message);
|
|
303
343
|
return result.value;
|
|
304
344
|
});
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* typert.host.js — 手写的 Typert host 工件(typert-loader 机制)。
|
|
3
|
+
*
|
|
4
|
+
* 见 @chaoset/vision-router 的同名文件说明:通过 typert-loader 把端点注册
|
|
5
|
+
* 进 ctx.typert.local,避免依赖 Remote 装饰器 markers(typert-protocol
|
|
6
|
+
* 双实例时 markers 丢失导致 SRC 认领为空、web 设置页 404)。
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
const passthrough = (value) => value;
|
|
10
|
+
const codec = (typeSymbol) => ({
|
|
11
|
+
mode: 'strict',
|
|
12
|
+
typeSymbol,
|
|
13
|
+
schema: { _zod: true, parse: passthrough },
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
export const TYPERT = {
|
|
17
|
+
package: '@chaoset/adaptive-perf',
|
|
18
|
+
face: 'host',
|
|
19
|
+
schemas: [],
|
|
20
|
+
invocations: [
|
|
21
|
+
{
|
|
22
|
+
id: '@chaoset/adaptive-perf#adaptivePerfConfig/get',
|
|
23
|
+
service: 'adaptivePerfConfig',
|
|
24
|
+
namespace: 'adaptivePerfConfig',
|
|
25
|
+
method: 'get',
|
|
26
|
+
invocation: { kind: 'direct' },
|
|
27
|
+
parameters: [],
|
|
28
|
+
result: codec('@chaoset/adaptive-perf/types#AdaptivePerfConfig'),
|
|
29
|
+
sourceLocation: { file: 'packages/adaptive-perf/lib/remote.mjs', line: 1, column: 1 },
|
|
30
|
+
},
|
|
31
|
+
{
|
|
32
|
+
id: '@chaoset/adaptive-perf#adaptivePerfConfig/set',
|
|
33
|
+
service: 'adaptivePerfConfig',
|
|
34
|
+
namespace: 'adaptivePerfConfig',
|
|
35
|
+
method: 'set',
|
|
36
|
+
invocation: { kind: 'direct' },
|
|
37
|
+
parameters: [
|
|
38
|
+
{
|
|
39
|
+
name: 'partial',
|
|
40
|
+
wire: 'partial',
|
|
41
|
+
source: 'json',
|
|
42
|
+
codec: codec('@chaoset/adaptive-perf/types#PartialAdaptivePerfConfig'),
|
|
43
|
+
},
|
|
44
|
+
],
|
|
45
|
+
result: codec('@chaoset/adaptive-perf/types#SetResult'),
|
|
46
|
+
sourceLocation: { file: 'packages/adaptive-perf/lib/remote.mjs', line: 1, column: 1 },
|
|
47
|
+
},
|
|
48
|
+
],
|
|
49
|
+
model: { services: [], events: [], objects: [] },
|
|
50
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@chaoset/adaptive-perf",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.2",
|
|
4
4
|
"description": "DSH host plugin: bring standard / PTC presets to minimal-mode-level performance via runtime-context suppression and adaptive tool-catalog trimming with demand-driven escalation",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -13,6 +13,7 @@
|
|
|
13
13
|
"exports": {
|
|
14
14
|
".": "./lib/index.mjs",
|
|
15
15
|
"./client": "./client/client.cjs",
|
|
16
|
+
"./typert": "./lib/typert.host.js",
|
|
16
17
|
"./cordis.patch.yml": "./cordis.patch.yml",
|
|
17
18
|
"./package.json": "./package.json"
|
|
18
19
|
},
|
|
@@ -25,8 +26,7 @@
|
|
|
25
26
|
"inject": [
|
|
26
27
|
"slots",
|
|
27
28
|
"locale",
|
|
28
|
-
"remote"
|
|
29
|
-
"remote.adaptivePerfConfig"
|
|
29
|
+
"remote"
|
|
30
30
|
]
|
|
31
31
|
}
|
|
32
32
|
},
|