@theholocron/kyber 5.0.0-alpha.373 → 5.0.0-alpha.375
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/dist/plugins.d.mts +4 -1
- package/dist/plugins.mjs +11 -6
- package/package.json +6 -6
package/dist/plugins.d.mts
CHANGED
|
@@ -137,7 +137,10 @@ interface PluginLoader<Caps extends CapabilityShape, Extra extends object = Reco
|
|
|
137
137
|
loadedKeys(): CapabilityKeyOf<Caps>[];
|
|
138
138
|
/** The providers that failed to load. Empty on a clean load. */
|
|
139
139
|
loadFailures(): readonly PluginLoadFailure<CapabilityKeyOf<Caps>>[];
|
|
140
|
-
/**
|
|
140
|
+
/**
|
|
141
|
+
* The plugin object of each provider that was created, by provider name. A provider several capabilities name has the
|
|
142
|
+
* plugin built for the first of them, in the order of the config's `providers`.
|
|
143
|
+
*/
|
|
141
144
|
plugins(): ReadonlyMap<string, LoadedPlugin<Caps, Extra>>;
|
|
142
145
|
/**
|
|
143
146
|
* Imports one provider and builds its plugin with the given options, without any capability slot: nothing is added to
|
package/dist/plugins.mjs
CHANGED
|
@@ -166,15 +166,20 @@ function createPluginSystem(options) {
|
|
|
166
166
|
});
|
|
167
167
|
}
|
|
168
168
|
async loadProvider(tuple) {
|
|
169
|
-
return this.instantiate("provider", tuple);
|
|
169
|
+
return this.instantiate("provider", tuple, true);
|
|
170
170
|
}
|
|
171
171
|
async loadOne(key, tuple) {
|
|
172
|
-
const factory = (await this.instantiate(`capability \`${key}\``, tuple)).capabilities[key];
|
|
172
|
+
const factory = (await this.instantiate(`capability \`${key}\``, tuple, false)).capabilities[key];
|
|
173
173
|
if (typeof factory !== "function") throw new LoaderError(`\`${tuple.packageName}\` does not implement the \`${key}\` capability`);
|
|
174
174
|
return factory();
|
|
175
175
|
}
|
|
176
|
-
/**
|
|
177
|
-
|
|
176
|
+
/**
|
|
177
|
+
* Imports the package and builds the plugin (following a capability config package to its provider). The plugin
|
|
178
|
+
* is recorded under its provider's name: a provider named by several capabilities keeps the first one built, which
|
|
179
|
+
* is the one from the first entry in the config, and only `replace` (a provider loaded by name with options the
|
|
180
|
+
* caller gave) puts a new one in its place.
|
|
181
|
+
*/
|
|
182
|
+
async instantiate(subject, tuple, replace) {
|
|
178
183
|
const mod = await this.importer(tuple.packageName).catch((err) => {
|
|
179
184
|
throw new LoaderError(`failed to import \`${tuple.packageName}\` for ${subject}: ${messageOf(err)}`);
|
|
180
185
|
});
|
|
@@ -187,7 +192,7 @@ function createPluginSystem(options) {
|
|
|
187
192
|
...this.context,
|
|
188
193
|
...tuple.options
|
|
189
194
|
});
|
|
190
|
-
this.created.set(tuple.provider, plugin);
|
|
195
|
+
if (replace || !this.created.has(tuple.provider)) this.created.set(tuple.provider, plugin);
|
|
191
196
|
return plugin;
|
|
192
197
|
}
|
|
193
198
|
if (isCapabilityConfigModule(mod)) {
|
|
@@ -199,7 +204,7 @@ function createPluginSystem(options) {
|
|
|
199
204
|
...cap.options,
|
|
200
205
|
...tuple.options
|
|
201
206
|
}
|
|
202
|
-
});
|
|
207
|
+
}, replace);
|
|
203
208
|
}
|
|
204
209
|
throw new LoaderError(`\`${tuple.packageName}\` does not export \`createPlugin(options)\` or a capability config ({ provider, options? })`);
|
|
205
210
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@theholocron/kyber",
|
|
3
|
-
"version": "5.0.0-alpha.
|
|
3
|
+
"version": "5.0.0-alpha.375",
|
|
4
4
|
"description": "The reusable parts of a command-line tool: terminal output, prompts, the interactive menu, the update notifier, safe handling of tokens, a test harness and the global flags.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"cli",
|
|
@@ -105,12 +105,12 @@
|
|
|
105
105
|
"typescript": "^5.9.3",
|
|
106
106
|
"vitest": "^5.1.0",
|
|
107
107
|
"yargs": "^18.1.0",
|
|
108
|
-
"@theholocron/datapad": "5.0.0-alpha.373",
|
|
109
|
-
"@theholocron/observability": "0.7.0-alpha.2",
|
|
110
108
|
"@theholocron/eslint-config": "^8.9.0-alpha.12",
|
|
111
|
-
"@theholocron/
|
|
109
|
+
"@theholocron/datapad": "5.0.0-alpha.375",
|
|
110
|
+
"@theholocron/tsconfig": "^8.9.0-alpha.12",
|
|
112
111
|
"@theholocron/vitest-config": "^8.9.0-alpha.12",
|
|
113
|
-
"@theholocron/
|
|
112
|
+
"@theholocron/observability": "0.7.0-alpha.2",
|
|
113
|
+
"@theholocron/tsdown-config": "^8.9.0-alpha.12"
|
|
114
114
|
},
|
|
115
115
|
"peerDependencies": {
|
|
116
116
|
"@inquirer/prompts": "^8.0.0",
|
|
@@ -121,7 +121,7 @@
|
|
|
121
121
|
"dotenv": "^17.0.0",
|
|
122
122
|
"ora": "^9.0.0",
|
|
123
123
|
"yargs": "^18.0.0",
|
|
124
|
-
"@theholocron/datapad": "^5.0.0-alpha.
|
|
124
|
+
"@theholocron/datapad": "^5.0.0-alpha.375",
|
|
125
125
|
"@theholocron/observability": "^0.7.0-alpha.2"
|
|
126
126
|
},
|
|
127
127
|
"peerDependenciesMeta": {
|