@jskit-ai/kernel 0.1.147 → 0.1.149
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/moduleBootstrap.js +54 -54
- package/client/moduleBootstrap.test.js +12 -12
- package/client/{descriptorSections.js → packageMetadataSections.js} +15 -15
- package/client/vite/clientBootstrapPlugin.js +67 -100
- package/client/vite/clientBootstrapPlugin.test.js +177 -238
- package/internal/node/installedPackages.js +283 -0
- package/package.json +1 -1
- package/server/platform/providerRuntime/{descriptorCatalog.js → packageCatalog.js} +32 -47
- package/server/platform/providerRuntime/providerLoader.js +18 -18
- package/server/platform/providerRuntime.js +15 -22
- package/server/platform/providerRuntime.test.js +56 -171
- package/server/platform/surfaceRuntime.test.js +1 -1
- package/server/support/index.js +6 -0
- package/server/support/shellOutlets.js +15 -51
- package/server/support/shellOutlets.test.js +23 -26
- package/shared/support/generatedUiContract.js +1 -1
- package/shared/support/generatedUiContract.test.js +11 -1
- package/shared/validators/schemaDefinitions.test.js +39 -0
- package/internal/node/installedPackageDescriptor.js +0 -125
- package/server/platform/providerRuntime/lockfile.js +0 -27
- package/shared/support/packageDescriptor.test.js +0 -147
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { createApplication } from "../shared/runtime/application.js";
|
|
2
2
|
import { filterRoutesBySurface } from "../shared/surface/runtime.js";
|
|
3
3
|
import { isRecord } from "../shared/support/normalize.js";
|
|
4
|
-
import {
|
|
4
|
+
import { normalizePackageMetadataClientProviders, normalizePackageMetadataUiRoutes } from "./packageMetadataSections.js";
|
|
5
5
|
import { createStructuredLogger, summarizeRouterRoutes } from "./logging.js";
|
|
6
6
|
|
|
7
7
|
function normalizePackageId(value) {
|
|
@@ -110,7 +110,7 @@ function registerClientModuleRoutes({
|
|
|
110
110
|
seenRouteNames,
|
|
111
111
|
logger = null,
|
|
112
112
|
source = "module",
|
|
113
|
-
|
|
113
|
+
packageMetadataRouteDeclarations = null
|
|
114
114
|
} = {}) {
|
|
115
115
|
const normalizedPackageId = normalizePackageId(packageId);
|
|
116
116
|
if (!normalizedPackageId) {
|
|
@@ -124,11 +124,11 @@ function registerClientModuleRoutes({
|
|
|
124
124
|
}
|
|
125
125
|
|
|
126
126
|
const normalizedRoutes = normalizeRouteList(routes, { packageId: normalizedPackageId });
|
|
127
|
-
|
|
127
|
+
assertRoutesDeclaredInPackageMetadata({
|
|
128
128
|
packageId: normalizedPackageId,
|
|
129
129
|
source,
|
|
130
130
|
normalizedRoutes,
|
|
131
|
-
|
|
131
|
+
packageMetadataRouteDeclarations
|
|
132
132
|
});
|
|
133
133
|
const activeRoutes = filterRoutesBySurface(normalizedRoutes, {
|
|
134
134
|
surfaceRuntime,
|
|
@@ -224,11 +224,11 @@ function normalizeExplicitProviderClasses(value, packageId) {
|
|
|
224
224
|
return providers;
|
|
225
225
|
}
|
|
226
226
|
|
|
227
|
-
function
|
|
227
|
+
function resolvePackageMetadataProviderClasses(moduleNamespace, packageId, packageMetadataClientProviders = []) {
|
|
228
228
|
const providers = [];
|
|
229
229
|
const seenProviderIds = new Set();
|
|
230
230
|
|
|
231
|
-
for (const providerDeclaration of
|
|
231
|
+
for (const providerDeclaration of packageMetadataClientProviders) {
|
|
232
232
|
const exportName = String(providerDeclaration?.export || "").trim();
|
|
233
233
|
if (!exportName) {
|
|
234
234
|
continue;
|
|
@@ -237,13 +237,13 @@ function resolveDescriptorProviderClasses(moduleNamespace, packageId, descriptor
|
|
|
237
237
|
const providerClass = moduleNamespace?.[exportName];
|
|
238
238
|
if (!isProviderClass(providerClass)) {
|
|
239
239
|
throw new TypeError(
|
|
240
|
-
`Client module ${packageId}
|
|
240
|
+
`Client module ${packageId} packageMetadata provider export "${exportName}" is missing or invalid in "${packageId}/client".`
|
|
241
241
|
);
|
|
242
242
|
}
|
|
243
243
|
|
|
244
244
|
const providerId = String(providerClass.id || "").trim();
|
|
245
245
|
if (!providerId) {
|
|
246
|
-
throw new TypeError(`Client module ${packageId}
|
|
246
|
+
throw new TypeError(`Client module ${packageId} packageMetadata provider "${exportName}" requires static id.`);
|
|
247
247
|
}
|
|
248
248
|
|
|
249
249
|
if (seenProviderIds.has(providerId)) {
|
|
@@ -256,7 +256,7 @@ function resolveDescriptorProviderClasses(moduleNamespace, packageId, descriptor
|
|
|
256
256
|
return providers;
|
|
257
257
|
}
|
|
258
258
|
|
|
259
|
-
function resolveModuleProviderClasses(moduleNamespace, packageId,
|
|
259
|
+
function resolveModuleProviderClasses(moduleNamespace, packageId, packageMetadataClientProviders = []) {
|
|
260
260
|
if (!isRecord(moduleNamespace)) {
|
|
261
261
|
return [];
|
|
262
262
|
}
|
|
@@ -266,21 +266,21 @@ function resolveModuleProviderClasses(moduleNamespace, packageId, descriptorClie
|
|
|
266
266
|
return explicitProviders;
|
|
267
267
|
}
|
|
268
268
|
|
|
269
|
-
if (Array.isArray(
|
|
270
|
-
return
|
|
269
|
+
if (Array.isArray(packageMetadataClientProviders) && packageMetadataClientProviders.length > 0) {
|
|
270
|
+
return resolvePackageMetadataProviderClasses(moduleNamespace, packageId, packageMetadataClientProviders);
|
|
271
271
|
}
|
|
272
272
|
return [];
|
|
273
273
|
}
|
|
274
274
|
|
|
275
|
-
function
|
|
275
|
+
function buildPackageMetadataRouteDeclarationIndex({ packageId, packageMetadataUiRoutes = [] } = {}) {
|
|
276
276
|
const normalizedPackageId = normalizePackageId(packageId);
|
|
277
|
-
const
|
|
277
|
+
const packageMetadataRoutes = normalizePackageMetadataUiRoutes(packageMetadataUiRoutes);
|
|
278
278
|
const byId = new Map();
|
|
279
279
|
|
|
280
|
-
for (const
|
|
281
|
-
const routeId = String(
|
|
282
|
-
const routePath = String(
|
|
283
|
-
const routeScope = String(
|
|
280
|
+
for (const packageMetadataRoute of packageMetadataRoutes) {
|
|
281
|
+
const routeId = String(packageMetadataRoute.id || "").trim();
|
|
282
|
+
const routePath = String(packageMetadataRoute.path || "").trim();
|
|
283
|
+
const routeScope = String(packageMetadataRoute.scope || "surface")
|
|
284
284
|
.trim()
|
|
285
285
|
.toLowerCase();
|
|
286
286
|
if (!routeId || !routePath) {
|
|
@@ -291,7 +291,7 @@ function buildDescriptorRouteDeclarationIndex({ packageId, descriptorUiRoutes =
|
|
|
291
291
|
const existingRoute = byId.get(routeId);
|
|
292
292
|
if (existingRoute.path !== routePath || existingRoute.scope !== routeScope) {
|
|
293
293
|
throw new Error(
|
|
294
|
-
`
|
|
294
|
+
`PackageMetadata ui routes for ${normalizedPackageId} define duplicate id "${routeId}" with conflicting declarations.`
|
|
295
295
|
);
|
|
296
296
|
}
|
|
297
297
|
continue;
|
|
@@ -310,18 +310,18 @@ function buildDescriptorRouteDeclarationIndex({ packageId, descriptorUiRoutes =
|
|
|
310
310
|
return Object.freeze({ byId });
|
|
311
311
|
}
|
|
312
312
|
|
|
313
|
-
function
|
|
313
|
+
function assertRoutesDeclaredInPackageMetadata({
|
|
314
314
|
packageId,
|
|
315
315
|
source,
|
|
316
316
|
normalizedRoutes = [],
|
|
317
|
-
|
|
317
|
+
packageMetadataRouteDeclarations = null
|
|
318
318
|
} = {}) {
|
|
319
319
|
const normalizedSource = String(source || "").trim();
|
|
320
320
|
if (normalizedSource !== "clientRoutes") {
|
|
321
321
|
return;
|
|
322
322
|
}
|
|
323
323
|
|
|
324
|
-
const byId =
|
|
324
|
+
const byId = packageMetadataRouteDeclarations?.byId instanceof Map ? packageMetadataRouteDeclarations.byId : new Map();
|
|
325
325
|
const normalizedPackageId = normalizePackageId(packageId);
|
|
326
326
|
|
|
327
327
|
for (const route of normalizedRoutes) {
|
|
@@ -342,7 +342,7 @@ function assertRoutesDeclaredInDescriptor({
|
|
|
342
342
|
}
|
|
343
343
|
if (String(declaredRoute.path || "").trim() !== routePath) {
|
|
344
344
|
throw new Error(
|
|
345
|
-
`Global client route "${routeId}" from ${normalizedPackageId} (${source}) path "${routePath}" does not match
|
|
345
|
+
`Global client route "${routeId}" from ${normalizedPackageId} (${source}) path "${routePath}" does not match packageMetadata metadata.ui.routes path "${declaredRoute.path}".`
|
|
346
346
|
);
|
|
347
347
|
}
|
|
348
348
|
if (String(declaredRoute.scope || "").trim().toLowerCase() !== "global") {
|
|
@@ -353,30 +353,30 @@ function assertRoutesDeclaredInDescriptor({
|
|
|
353
353
|
}
|
|
354
354
|
}
|
|
355
355
|
|
|
356
|
-
function
|
|
356
|
+
function resolvePackageMetadataClientRoutes({
|
|
357
357
|
packageId,
|
|
358
|
-
|
|
358
|
+
packageMetadataUiRoutes = [],
|
|
359
359
|
routeComponents = {},
|
|
360
360
|
logger = null
|
|
361
361
|
} = {}) {
|
|
362
362
|
const normalizedPackageId = normalizePackageId(packageId);
|
|
363
|
-
const
|
|
364
|
-
if (
|
|
363
|
+
const packageMetadataRoutes = normalizePackageMetadataUiRoutes(packageMetadataUiRoutes);
|
|
364
|
+
if (packageMetadataRoutes.length < 1) {
|
|
365
365
|
return Object.freeze([]);
|
|
366
366
|
}
|
|
367
367
|
if (!isRecord(routeComponents)) {
|
|
368
368
|
throw new TypeError(
|
|
369
|
-
`Client module ${normalizedPackageId} declares
|
|
369
|
+
`Client module ${normalizedPackageId} declares packageMetadata ui routes but does not export a routeComponents map.`
|
|
370
370
|
);
|
|
371
371
|
}
|
|
372
372
|
|
|
373
373
|
const log = createStructuredLogger(logger);
|
|
374
374
|
const routes = [];
|
|
375
375
|
const skippedRoutes = [];
|
|
376
|
-
for (const
|
|
377
|
-
const routeId = String(
|
|
378
|
-
const routePath = String(
|
|
379
|
-
const autoRegister =
|
|
376
|
+
for (const packageMetadataRoute of packageMetadataRoutes) {
|
|
377
|
+
const routeId = String(packageMetadataRoute.id || "").trim();
|
|
378
|
+
const routePath = String(packageMetadataRoute.path || "").trim();
|
|
379
|
+
const autoRegister = packageMetadataRoute.autoRegister !== false;
|
|
380
380
|
if (!autoRegister) {
|
|
381
381
|
skippedRoutes.push(
|
|
382
382
|
Object.freeze({
|
|
@@ -390,32 +390,32 @@ function resolveDescriptorClientRoutes({
|
|
|
390
390
|
|
|
391
391
|
if (!routeId || !routePath) {
|
|
392
392
|
throw new Error(
|
|
393
|
-
`
|
|
393
|
+
`PackageMetadata ui route from ${normalizedPackageId} requires id and path when autoRegister is enabled.`
|
|
394
394
|
);
|
|
395
395
|
}
|
|
396
396
|
|
|
397
|
-
const componentKey = String(
|
|
397
|
+
const componentKey = String(packageMetadataRoute.componentKey || "").trim();
|
|
398
398
|
if (!componentKey) {
|
|
399
399
|
throw new Error(
|
|
400
|
-
`
|
|
400
|
+
`PackageMetadata ui route "${routeId}" from ${normalizedPackageId} requires componentKey when autoRegister is enabled.`
|
|
401
401
|
);
|
|
402
402
|
}
|
|
403
403
|
|
|
404
404
|
const routeComponent = routeComponents[componentKey];
|
|
405
405
|
if (!isRouteComponent(routeComponent)) {
|
|
406
406
|
throw new Error(
|
|
407
|
-
`
|
|
407
|
+
`PackageMetadata ui route "${routeId}" from ${normalizedPackageId} references unknown routeComponents key "${componentKey}".`
|
|
408
408
|
);
|
|
409
409
|
}
|
|
410
410
|
|
|
411
|
-
const scope = String(
|
|
411
|
+
const scope = String(packageMetadataRoute.scope || "surface")
|
|
412
412
|
.trim()
|
|
413
413
|
.toLowerCase();
|
|
414
|
-
const surface = String(
|
|
414
|
+
const surface = String(packageMetadataRoute.surface || "")
|
|
415
415
|
.trim()
|
|
416
416
|
.toLowerCase();
|
|
417
|
-
const guard = isRecord(
|
|
418
|
-
const baseMeta = isRecord(
|
|
417
|
+
const guard = isRecord(packageMetadataRoute.guard) ? { ...packageMetadataRoute.guard } : {};
|
|
418
|
+
const baseMeta = isRecord(packageMetadataRoute.meta) ? { ...packageMetadataRoute.meta } : {};
|
|
419
419
|
const baseMetaJskit = isRecord(baseMeta.jskit) ? { ...baseMeta.jskit } : {};
|
|
420
420
|
|
|
421
421
|
routes.push(
|
|
@@ -424,7 +424,7 @@ function resolveDescriptorClientRoutes({
|
|
|
424
424
|
path: routePath,
|
|
425
425
|
scope,
|
|
426
426
|
...(surface ? { surface } : {}),
|
|
427
|
-
...(String(
|
|
427
|
+
...(String(packageMetadataRoute.name || "").trim() ? { name: String(packageMetadataRoute.name || "").trim() } : {}),
|
|
428
428
|
component: routeComponent,
|
|
429
429
|
meta: {
|
|
430
430
|
...baseMeta,
|
|
@@ -435,7 +435,7 @@ function resolveDescriptorClientRoutes({
|
|
|
435
435
|
routeId,
|
|
436
436
|
scope,
|
|
437
437
|
componentKey,
|
|
438
|
-
source: "
|
|
438
|
+
source: "packageMetadata.ui.routes",
|
|
439
439
|
...(surface ? { surface } : {})
|
|
440
440
|
}
|
|
441
441
|
}
|
|
@@ -446,11 +446,11 @@ function resolveDescriptorClientRoutes({
|
|
|
446
446
|
log.debug(
|
|
447
447
|
{
|
|
448
448
|
packageId: normalizedPackageId,
|
|
449
|
-
|
|
449
|
+
packageMetadataRouteCount: packageMetadataRoutes.length,
|
|
450
450
|
autoRegisterRouteCount: routes.length,
|
|
451
451
|
skippedRoutes
|
|
452
452
|
},
|
|
453
|
-
"Processed
|
|
453
|
+
"Processed packageMetadata ui routes."
|
|
454
454
|
);
|
|
455
455
|
|
|
456
456
|
return Object.freeze(routes);
|
|
@@ -471,8 +471,8 @@ function normalizeClientModuleEntries(clientModules) {
|
|
|
471
471
|
return Object.freeze({
|
|
472
472
|
packageId,
|
|
473
473
|
module: moduleNamespace,
|
|
474
|
-
|
|
475
|
-
|
|
474
|
+
packageMetadataUiRoutes: normalizePackageMetadataUiRoutes(entry?.packageMetadataUiRoutes),
|
|
475
|
+
packageMetadataClientProviders: normalizePackageMetadataClientProviders(entry?.packageMetadataClientProviders)
|
|
476
476
|
});
|
|
477
477
|
})
|
|
478
478
|
.filter(Boolean)
|
|
@@ -552,7 +552,7 @@ async function bootClientModules({
|
|
|
552
552
|
"Starting JSKIT client module bootstrap."
|
|
553
553
|
);
|
|
554
554
|
for (const entry of moduleEntries) {
|
|
555
|
-
const providers = resolveModuleProviderClasses(entry.module, entry.packageId, entry.
|
|
555
|
+
const providers = resolveModuleProviderClasses(entry.module, entry.packageId, entry.packageMetadataClientProviders);
|
|
556
556
|
log.debug(
|
|
557
557
|
{
|
|
558
558
|
packageId: entry.packageId,
|
|
@@ -578,7 +578,7 @@ async function bootClientModules({
|
|
|
578
578
|
const seenRoutePaths = new Set();
|
|
579
579
|
const seenRouteNames = new Set();
|
|
580
580
|
const routeResults = [];
|
|
581
|
-
const registerRoutesForEntry = (routeList, packageId, source = "module",
|
|
581
|
+
const registerRoutesForEntry = (routeList, packageId, source = "module", packageMetadataRouteDeclarations = null) => {
|
|
582
582
|
if (!routeList || routeList.length === 0) {
|
|
583
583
|
return null;
|
|
584
584
|
}
|
|
@@ -592,7 +592,7 @@ async function bootClientModules({
|
|
|
592
592
|
seenRouteNames,
|
|
593
593
|
logger: log,
|
|
594
594
|
source,
|
|
595
|
-
|
|
595
|
+
packageMetadataRouteDeclarations
|
|
596
596
|
});
|
|
597
597
|
log.debug(
|
|
598
598
|
{
|
|
@@ -616,20 +616,20 @@ async function bootClientModules({
|
|
|
616
616
|
return result;
|
|
617
617
|
};
|
|
618
618
|
for (const entry of moduleEntries) {
|
|
619
|
-
const
|
|
619
|
+
const packageMetadataRouteDeclarations = buildPackageMetadataRouteDeclarationIndex({
|
|
620
620
|
packageId: entry.packageId,
|
|
621
|
-
|
|
621
|
+
packageMetadataUiRoutes: entry.packageMetadataUiRoutes
|
|
622
622
|
});
|
|
623
|
-
const
|
|
623
|
+
const packageMetadataRoutes = resolvePackageMetadataClientRoutes({
|
|
624
624
|
packageId: entry.packageId,
|
|
625
|
-
|
|
625
|
+
packageMetadataUiRoutes: entry.packageMetadataUiRoutes,
|
|
626
626
|
routeComponents: entry.module.routeComponents,
|
|
627
627
|
logger: log
|
|
628
628
|
});
|
|
629
|
-
registerRoutesForEntry(
|
|
629
|
+
registerRoutesForEntry(packageMetadataRoutes, entry.packageId, "packageMetadata.ui.routes", packageMetadataRouteDeclarations);
|
|
630
630
|
|
|
631
631
|
const moduleRoutes = Array.isArray(entry.module.clientRoutes) ? entry.module.clientRoutes : [];
|
|
632
|
-
registerRoutesForEntry(moduleRoutes, entry.packageId, "clientRoutes",
|
|
632
|
+
registerRoutesForEntry(moduleRoutes, entry.packageId, "clientRoutes", packageMetadataRouteDeclarations);
|
|
633
633
|
|
|
634
634
|
}
|
|
635
635
|
|
|
@@ -32,7 +32,7 @@ test("bootClientModules registers global routes regardless of surface mode", asy
|
|
|
32
32
|
clientModules: [
|
|
33
33
|
{
|
|
34
34
|
packageId: "@example/auth",
|
|
35
|
-
|
|
35
|
+
packageMetadataUiRoutes: [
|
|
36
36
|
{
|
|
37
37
|
id: "auth.login",
|
|
38
38
|
path: "/auth/login",
|
|
@@ -107,7 +107,7 @@ test("bootClientModules filters surface routes by mode", async () => {
|
|
|
107
107
|
assert.equal(router.routes[0].path, "/admin/dashboard");
|
|
108
108
|
});
|
|
109
109
|
|
|
110
|
-
test("bootClientModules registers
|
|
110
|
+
test("bootClientModules registers packageMetadata and clientRoutes with providers only", async () => {
|
|
111
111
|
const router = createRouterStub();
|
|
112
112
|
const surfaceRuntime = createSurfaceRuntimeFixture();
|
|
113
113
|
const events = [];
|
|
@@ -139,7 +139,7 @@ test("bootClientModules registers descriptor and clientRoutes with providers onl
|
|
|
139
139
|
},
|
|
140
140
|
{
|
|
141
141
|
packageId: "@example/zeta",
|
|
142
|
-
|
|
142
|
+
packageMetadataUiRoutes: [
|
|
143
143
|
{
|
|
144
144
|
id: "auth.default-login-2",
|
|
145
145
|
name: "auth-default-login-2",
|
|
@@ -287,7 +287,7 @@ test("bootClientModules rejects non-declared global clientRoutes", async () => {
|
|
|
287
287
|
clientModules: [
|
|
288
288
|
{
|
|
289
289
|
packageId: "@example/strict",
|
|
290
|
-
|
|
290
|
+
packageMetadataUiRoutes: [
|
|
291
291
|
{
|
|
292
292
|
id: "auth.default-login-2",
|
|
293
293
|
path: "/auth/default-login-2",
|
|
@@ -330,7 +330,7 @@ test("bootClientModules allows non-declared surface clientRoutes", async () => {
|
|
|
330
330
|
clientModules: [
|
|
331
331
|
{
|
|
332
332
|
packageId: "@example/surface-programmatic",
|
|
333
|
-
|
|
333
|
+
packageMetadataUiRoutes: [],
|
|
334
334
|
module: {
|
|
335
335
|
clientRoutes: [
|
|
336
336
|
{
|
|
@@ -355,7 +355,7 @@ test("bootClientModules allows non-declared surface clientRoutes", async () => {
|
|
|
355
355
|
assert.equal(router.routes[0].path, "/admin/projects");
|
|
356
356
|
});
|
|
357
357
|
|
|
358
|
-
test("bootClientModules loads client providers declared in
|
|
358
|
+
test("bootClientModules loads client providers declared in packageMetadataClientProviders", async () => {
|
|
359
359
|
const router = createRouterStub();
|
|
360
360
|
const surfaceRuntime = createSurfaceRuntimeFixture();
|
|
361
361
|
const events = [];
|
|
@@ -363,8 +363,8 @@ test("bootClientModules loads client providers declared in descriptorClientProvi
|
|
|
363
363
|
await bootClientModules({
|
|
364
364
|
clientModules: [
|
|
365
365
|
{
|
|
366
|
-
packageId: "@example/
|
|
367
|
-
|
|
366
|
+
packageId: "@example/packageMetadata-providers",
|
|
367
|
+
packageMetadataClientProviders: [
|
|
368
368
|
{
|
|
369
369
|
entrypoint: "src/client/providers/ExampleProvider.js",
|
|
370
370
|
export: "ExampleProvider"
|
|
@@ -372,7 +372,7 @@ test("bootClientModules loads client providers declared in descriptorClientProvi
|
|
|
372
372
|
],
|
|
373
373
|
module: {
|
|
374
374
|
ExampleProvider: class {
|
|
375
|
-
static id = "example.
|
|
375
|
+
static id = "example.packageMetadata.provider";
|
|
376
376
|
register() {
|
|
377
377
|
events.push("register");
|
|
378
378
|
}
|
|
@@ -392,7 +392,7 @@ test("bootClientModules loads client providers declared in descriptorClientProvi
|
|
|
392
392
|
assert.deepEqual(events, ["register", "boot"]);
|
|
393
393
|
});
|
|
394
394
|
|
|
395
|
-
test("bootClientModules throws when
|
|
395
|
+
test("bootClientModules throws when packageMetadataClientProviders export is missing", async () => {
|
|
396
396
|
const router = createRouterStub();
|
|
397
397
|
const surfaceRuntime = createSurfaceRuntimeFixture();
|
|
398
398
|
|
|
@@ -401,7 +401,7 @@ test("bootClientModules throws when descriptorClientProviders export is missing"
|
|
|
401
401
|
clientModules: [
|
|
402
402
|
{
|
|
403
403
|
packageId: "@example/missing-provider-export",
|
|
404
|
-
|
|
404
|
+
packageMetadataClientProviders: [
|
|
405
405
|
{
|
|
406
406
|
entrypoint: "src/client/providers/MissingProvider.js",
|
|
407
407
|
export: "MissingProvider"
|
|
@@ -415,6 +415,6 @@ test("bootClientModules throws when descriptorClientProviders export is missing"
|
|
|
415
415
|
surfaceMode: "all",
|
|
416
416
|
logger: { info() {}, warn() {}, error() {} }
|
|
417
417
|
}),
|
|
418
|
-
/
|
|
418
|
+
/packageMetadata provider export "MissingProvider" is missing or invalid/
|
|
419
419
|
);
|
|
420
420
|
});
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { isRecord } from "../shared/support/normalize.js";
|
|
2
2
|
import { sortStrings } from "../shared/support/sorting.js";
|
|
3
3
|
|
|
4
|
-
function
|
|
4
|
+
function normalizePackageMetadataUiRoutes(value) {
|
|
5
5
|
const routeEntries = Array.isArray(value) ? value : [];
|
|
6
6
|
const normalizedRoutes = [];
|
|
7
7
|
|
|
@@ -20,7 +20,7 @@ function normalizeDescriptorUiRoutes(value) {
|
|
|
20
20
|
return Object.freeze(normalizedRoutes);
|
|
21
21
|
}
|
|
22
22
|
|
|
23
|
-
function
|
|
23
|
+
function normalizePackageMetadataClientProviders(value) {
|
|
24
24
|
const entries = Array.isArray(value) ? value : [];
|
|
25
25
|
const providers = [];
|
|
26
26
|
|
|
@@ -45,30 +45,30 @@ function normalizeDescriptorClientProviders(value) {
|
|
|
45
45
|
return Object.freeze(providers);
|
|
46
46
|
}
|
|
47
47
|
|
|
48
|
-
function
|
|
48
|
+
function normalizePackageMetadataClientOptimizeSpecifiers(value) {
|
|
49
49
|
return Object.freeze(sortStrings(value));
|
|
50
50
|
}
|
|
51
51
|
|
|
52
|
-
function
|
|
53
|
-
const
|
|
54
|
-
const metadata = isRecord(
|
|
55
|
-
const runtime = isRecord(
|
|
52
|
+
function normalizeClientPackageMetadataSections(packageMetadataValue) {
|
|
53
|
+
const packageMetadata = isRecord(packageMetadataValue) ? packageMetadataValue : {};
|
|
54
|
+
const metadata = isRecord(packageMetadata.metadata) ? packageMetadata.metadata : {};
|
|
55
|
+
const runtime = isRecord(packageMetadata.runtime) ? packageMetadata.runtime : {};
|
|
56
56
|
const ui = isRecord(metadata.ui) ? metadata.ui : {};
|
|
57
57
|
const clientMetadata = isRecord(metadata.client) ? metadata.client : {};
|
|
58
58
|
const optimizeDeps = isRecord(clientMetadata.optimizeDeps) ? clientMetadata.optimizeDeps : {};
|
|
59
59
|
const runtimeClient = isRecord(runtime.client) ? runtime.client : {};
|
|
60
60
|
|
|
61
61
|
return Object.freeze({
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
62
|
+
packageMetadataUiRoutes: normalizePackageMetadataUiRoutes(ui.routes),
|
|
63
|
+
packageMetadataClientProviders: normalizePackageMetadataClientProviders(runtimeClient.providers),
|
|
64
|
+
packageMetadataClientOptimizeIncludeSpecifiers: normalizePackageMetadataClientOptimizeSpecifiers(optimizeDeps.include),
|
|
65
|
+
packageMetadataClientOptimizeExcludeSpecifiers: normalizePackageMetadataClientOptimizeSpecifiers(optimizeDeps.exclude)
|
|
66
66
|
});
|
|
67
67
|
}
|
|
68
68
|
|
|
69
69
|
export {
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
70
|
+
normalizePackageMetadataUiRoutes,
|
|
71
|
+
normalizePackageMetadataClientProviders,
|
|
72
|
+
normalizePackageMetadataClientOptimizeSpecifiers,
|
|
73
|
+
normalizeClientPackageMetadataSections
|
|
74
74
|
};
|