bazis 0.97.5 → 0.97.7
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.
|
@@ -22,6 +22,8 @@ export function createProviderSelectionValidator(
|
|
|
22
22
|
|
|
23
23
|
const selected = new Map<Token<unknown>, Map<ServiceKey | undefined, ModuleGraphRecord>>();
|
|
24
24
|
const selectedFamilies = new Map<symbol, Map<ServiceKey | undefined, ModuleGraphRecord>>();
|
|
25
|
+
// Every module that registers a token (in registration order): the error names them all.
|
|
26
|
+
const registeredBy = new Map<Token<unknown>, Map<ServiceKey | undefined, ModuleGraphRecord[]>>();
|
|
25
27
|
for (const definition of definitions) {
|
|
26
28
|
const owner = recordOf.get(definition);
|
|
27
29
|
if (!owner) continue;
|
|
@@ -29,6 +31,11 @@ export function createProviderSelectionValidator(
|
|
|
29
31
|
const keys = selected.get(token) ?? new Map();
|
|
30
32
|
keys.set(definition.key, owner);
|
|
31
33
|
selected.set(token, keys);
|
|
34
|
+
const ownersByKey = registeredBy.get(token) ?? new Map<ServiceKey | undefined, ModuleGraphRecord[]>();
|
|
35
|
+
const owners = ownersByKey.get(definition.key) ?? [];
|
|
36
|
+
if (!owners.includes(owner)) owners.push(owner);
|
|
37
|
+
ownersByKey.set(definition.key, owners);
|
|
38
|
+
registeredBy.set(token, ownersByKey);
|
|
32
39
|
}
|
|
33
40
|
for (const registration of generics) {
|
|
34
41
|
const owner = genericRecordOf.get(registration);
|
|
@@ -82,9 +89,35 @@ export function createProviderSelectionValidator(
|
|
|
82
89
|
if (record.imports.some((imported) => exportsOwner(imported, owner, token))
|
|
83
90
|
|| globals.some((global) => exportsOwner(global, owner, token))) continue;
|
|
84
91
|
throw new ModuleEncapsulationError([
|
|
85
|
-
|
|
86
|
-
|
|
92
|
+
selectionMessage(record, tokenToDebugName(definition.provider.provide), tokenToDebugName(token), key, owner,
|
|
93
|
+
registeredBy.get(token)?.get(key) ?? [owner]),
|
|
87
94
|
]);
|
|
88
95
|
}
|
|
89
96
|
};
|
|
90
97
|
}
|
|
98
|
+
|
|
99
|
+
/**
|
|
100
|
+
* Explains a selection the consumer cannot see. The usual cause: the token is
|
|
101
|
+
* registered in several modules, and the whole application uses the last
|
|
102
|
+
* registration, which comes from a module the consumer does not import.
|
|
103
|
+
*/
|
|
104
|
+
function selectionMessage(
|
|
105
|
+
record: ModuleGraphRecord,
|
|
106
|
+
consumer: string,
|
|
107
|
+
token: string,
|
|
108
|
+
key: ServiceKey | undefined,
|
|
109
|
+
owner: ModuleGraphRecord,
|
|
110
|
+
owners: readonly ModuleGraphRecord[],
|
|
111
|
+
): string {
|
|
112
|
+
const subject = key === undefined ? `"${token}"` : `"${token}" with key ${JSON.stringify(String(key))}`;
|
|
113
|
+
const head = `Module "${record.name}": "${consumer}" depends on ${subject}`;
|
|
114
|
+
if (owners.length > 1) {
|
|
115
|
+
const modules = owners.map((item) => `"${item.name}"`).join(" and ");
|
|
116
|
+
// No colon after "token": the console redaction would read "token: the" as a secret.
|
|
117
|
+
return `${head}, but ${subject} is registered in ${modules}, and the application uses one implementation per token,`
|
|
118
|
+
+ ` the last registered one, from "${owner.name}", which "${record.name}" cannot see.`
|
|
119
|
+
+ ` Register ${subject} in one module, or give the implementations different keys (DI.keyedSingleton).`;
|
|
120
|
+
}
|
|
121
|
+
return `${head}, but the application uses the implementation from "${owner.name}", which "${record.name}" cannot see.`
|
|
122
|
+
+ ` Add "${owner.name}" to the imports of "${record.name}" and export ${subject} from it.`;
|
|
123
|
+
}
|
|
@@ -232,7 +232,7 @@ export class CodexAppServerClient implements CodexClient {
|
|
|
232
232
|
if (method === "account/updated") this.modelCache = undefined;
|
|
233
233
|
}, () => { this.clearLogin(); this.modelCache = undefined; });
|
|
234
234
|
const initialized = await client.request("initialize", {
|
|
235
|
-
clientInfo: { name: "bazis", title: "Bazis", version: "0.97.
|
|
235
|
+
clientInfo: { name: "bazis", title: "Bazis", version: "0.97.7" }, capabilities: { experimentalApi: true },
|
|
236
236
|
}, 15_000, signal);
|
|
237
237
|
if (resolve(text(initialized.codexHome, 4096)) !== this.paths.home) throw new CodexError("PROTOCOL_ERROR");
|
|
238
238
|
client.notify("initialized");
|
package/package.json
CHANGED