@lmzhen/dsh-evolution-io 0.3.61 → 0.3.62
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 +22 -3
- package/lib/types/index.d.ts +14 -1
- package/package.json +2 -2
package/lib/index.js
CHANGED
|
@@ -6,23 +6,42 @@ import { Service } from "@deepseek-ai/cordis";
|
|
|
6
6
|
*/
|
|
7
7
|
var EvolutionIoRegistry = class extends Service {
|
|
8
8
|
providers = /* @__PURE__ */ new Map();
|
|
9
|
+
/** Name of the provider that declared itself the default (P2-7, v14). */
|
|
10
|
+
defaultName;
|
|
9
11
|
constructor(ctx) {
|
|
10
12
|
super(ctx, "evolutionIo");
|
|
11
13
|
}
|
|
12
|
-
|
|
14
|
+
/**
|
|
15
|
+
* @param options.default - mark this provider as the one a nameless
|
|
16
|
+
* `provider()` resolves. The first explicit default wins; without any
|
|
17
|
+
* default the registry keeps its historical registration-order fallback.
|
|
18
|
+
*/
|
|
19
|
+
registerProvider(provider, options = {}) {
|
|
13
20
|
if (this.providers.has(provider.name)) throw new Error(`evolution IO provider "${provider.name}" already registered`);
|
|
14
21
|
this.providers.set(provider.name, provider);
|
|
22
|
+
if (options.default === true) this.defaultName ??= provider.name;
|
|
15
23
|
return () => {
|
|
16
|
-
if (this.providers.get(provider.name) === provider)
|
|
24
|
+
if (this.providers.get(provider.name) === provider) {
|
|
25
|
+
this.providers.delete(provider.name);
|
|
26
|
+
if (this.defaultName === provider.name) this.defaultName = void 0;
|
|
27
|
+
}
|
|
17
28
|
};
|
|
18
29
|
}
|
|
30
|
+
/** Whether a provider with this exact name is mounted. */
|
|
31
|
+
hasProvider(name) {
|
|
32
|
+
return this.providers.has(name);
|
|
33
|
+
}
|
|
34
|
+
/** Whether ANY provider is mounted (used by lazy/boot-time probes). */
|
|
35
|
+
hasProviders() {
|
|
36
|
+
return this.providers.size > 0;
|
|
37
|
+
}
|
|
19
38
|
provider(name) {
|
|
20
39
|
if (name) {
|
|
21
40
|
const provider = this.providers.get(name);
|
|
22
41
|
if (provider) return provider;
|
|
23
42
|
throw new Error(`evolution IO provider "${name}" is not registered`);
|
|
24
43
|
}
|
|
25
|
-
const first = this.providers.values().next().value;
|
|
44
|
+
const first = (this.defaultName === void 0 ? void 0 : this.providers.get(this.defaultName)) ?? this.providers.values().next().value;
|
|
26
45
|
if (!first) throw new Error("no evolution IO provider registered");
|
|
27
46
|
return first;
|
|
28
47
|
}
|
package/lib/types/index.d.ts
CHANGED
|
@@ -28,8 +28,21 @@ declare module '@deepseek-ai/cordis' {
|
|
|
28
28
|
}
|
|
29
29
|
export declare class EvolutionIoRegistry extends Service {
|
|
30
30
|
private readonly providers;
|
|
31
|
+
/** Name of the provider that declared itself the default (P2-7, v14). */
|
|
32
|
+
private defaultName;
|
|
31
33
|
constructor(ctx: Context);
|
|
32
|
-
|
|
34
|
+
/**
|
|
35
|
+
* @param options.default - mark this provider as the one a nameless
|
|
36
|
+
* `provider()` resolves. The first explicit default wins; without any
|
|
37
|
+
* default the registry keeps its historical registration-order fallback.
|
|
38
|
+
*/
|
|
39
|
+
registerProvider(provider: EvolutionIo, options?: {
|
|
40
|
+
default?: boolean;
|
|
41
|
+
}): () => void;
|
|
42
|
+
/** Whether a provider with this exact name is mounted. */
|
|
43
|
+
hasProvider(name: string): boolean;
|
|
44
|
+
/** Whether ANY provider is mounted (used by lazy/boot-time probes). */
|
|
45
|
+
hasProviders(): boolean;
|
|
33
46
|
provider(name?: string): EvolutionIo;
|
|
34
47
|
}
|
|
35
48
|
export default EvolutionIoRegistry;
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lmzhen/dsh-evolution-io",
|
|
3
3
|
"description": "IO seam for evolution providers (community build)",
|
|
4
|
-
"version": "0.3.
|
|
4
|
+
"version": "0.3.62",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
7
7
|
},
|
|
@@ -30,7 +30,7 @@
|
|
|
30
30
|
],
|
|
31
31
|
"license": "MIT",
|
|
32
32
|
"dependencies": {
|
|
33
|
-
"@lmzhen/dsh-evolution-core": "^0.3.
|
|
33
|
+
"@lmzhen/dsh-evolution-core": "^0.3.62"
|
|
34
34
|
},
|
|
35
35
|
"peerDependencies": {
|
|
36
36
|
"@deepseek-ai/dsh-invariants": "^0.1.1-rc.2",
|