@brickkit/core 0.13.1 → 0.13.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/dist/chunks/server.d.ts +4 -4
- package/dist/chunks/server.js +21 -11
- package/dist/chunks/server.js.map +1 -1
- package/package.json +1 -1
package/dist/chunks/server.d.ts
CHANGED
|
@@ -266,14 +266,14 @@ declare const compilerRuntime: Readonly<{
|
|
|
266
266
|
bindRoute: typeof bindRoute;
|
|
267
267
|
}>;
|
|
268
268
|
/**
|
|
269
|
-
* Build artifact bootstrap: import the app
|
|
270
|
-
*
|
|
269
|
+
* Build artifact bootstrap: import the bundled app. It is not re-analyzed
|
|
270
|
+
* against the IR: the bundle and its IR come from one build (#107).
|
|
271
271
|
*
|
|
272
|
-
* @
|
|
272
|
+
* @param _ir Ignored; kept so existing callers still type-check.
|
|
273
273
|
*/
|
|
274
274
|
declare function loadCompiledBrickApp(load: () => Promise<{
|
|
275
275
|
default: unknown;
|
|
276
|
-
}>,
|
|
276
|
+
}>, _ir?: BrickIR): Promise<BrickApp>;
|
|
277
277
|
interface CompiledRoute {
|
|
278
278
|
readonly ir: RouteIR;
|
|
279
279
|
readonly handler: CompiledHandler;
|
package/dist/chunks/server.js
CHANGED
|
@@ -1301,7 +1301,7 @@ function analyzeDeclaredApplication(services, prefix = DEFAULT_PREFIX) {
|
|
|
1301
1301
|
const previous = registered.get(key);
|
|
1302
1302
|
if (previous) {
|
|
1303
1303
|
if (route.plugin || previous.plugin) throw new DuplicateNameError(`Brick compiler: duplicate plugin route '${method} ${path}'`);
|
|
1304
|
-
diagnostics.push(`${key}: '${service.name}.${action.name}' shadowed by '${previous.name}' (
|
|
1304
|
+
diagnostics.push(`${key}: '${service.name}.${action.name}' shadowed by '${previous.name}' (earlier service, then lower action name, wins)`);
|
|
1305
1305
|
return;
|
|
1306
1306
|
}
|
|
1307
1307
|
if (typeof action.config.execute !== "function") throw new Error(`Brick compiler: '${service.name}.${action.name}' has no execute handler`);
|
|
@@ -1315,19 +1315,29 @@ function analyzeDeclaredApplication(services, prefix = DEFAULT_PREFIX) {
|
|
|
1315
1315
|
action
|
|
1316
1316
|
});
|
|
1317
1317
|
};
|
|
1318
|
-
|
|
1318
|
+
const candidates = [];
|
|
1319
|
+
for (const [index, service] of services.entries()) {
|
|
1319
1320
|
checkSegments(service);
|
|
1320
1321
|
for (const action of service.listActions()) {
|
|
1321
1322
|
const route = getActionRoute(action, prefix);
|
|
1322
1323
|
if (route === false) continue;
|
|
1323
|
-
|
|
1324
|
+
candidates.push([
|
|
1325
|
+
routeKey(route.method, route.path),
|
|
1326
|
+
index,
|
|
1327
|
+
service,
|
|
1328
|
+
action,
|
|
1329
|
+
route.method,
|
|
1330
|
+
route.path
|
|
1331
|
+
]);
|
|
1324
1332
|
}
|
|
1325
1333
|
}
|
|
1334
|
+
candidates.sort((a, b) => compare(a[0], b[0]) || a[1] - b[1] || compare(a[3].name, b[3].name));
|
|
1335
|
+
for (const [, , service, action, method, path] of candidates) add(service, action, method, path);
|
|
1326
1336
|
const preparations = services.flatMap((service) => portOf(service).listPreparations().map((contribution) => ({
|
|
1327
1337
|
service: service.name,
|
|
1328
1338
|
name: contribution.name,
|
|
1329
1339
|
metadata: schemaSnapshot(contribution.describe?.())
|
|
1330
|
-
})));
|
|
1340
|
+
})).sort((a, b) => compare(a.name, b.name)));
|
|
1331
1341
|
return {
|
|
1332
1342
|
ir: freezeIR({
|
|
1333
1343
|
version: 1,
|
|
@@ -1341,6 +1351,8 @@ function analyzeDeclaredApplication(services, prefix = DEFAULT_PREFIX) {
|
|
|
1341
1351
|
bindings
|
|
1342
1352
|
};
|
|
1343
1353
|
}
|
|
1354
|
+
/** Code-unit order, independent of locale. */
|
|
1355
|
+
const compare = (a, b) => a < b ? -1 : a > b ? 1 : 0;
|
|
1344
1356
|
/** What the compiler records about one action route. */
|
|
1345
1357
|
function describeRoute(service, action, method, path) {
|
|
1346
1358
|
const coercions = [];
|
|
@@ -1446,15 +1458,13 @@ function analyzeMatching(services, ir) {
|
|
|
1446
1458
|
return analyzed;
|
|
1447
1459
|
}
|
|
1448
1460
|
/**
|
|
1449
|
-
* Build artifact bootstrap: import the app
|
|
1450
|
-
*
|
|
1461
|
+
* Build artifact bootstrap: import the bundled app. It is not re-analyzed
|
|
1462
|
+
* against the IR: the bundle and its IR come from one build (#107).
|
|
1451
1463
|
*
|
|
1452
|
-
* @
|
|
1464
|
+
* @param _ir Ignored; kept so existing callers still type-check.
|
|
1453
1465
|
*/
|
|
1454
|
-
async function loadCompiledBrickApp(load,
|
|
1455
|
-
|
|
1456
|
-
analyzeMatching([...app.definition.services], ir);
|
|
1457
|
-
return app;
|
|
1466
|
+
async function loadCompiledBrickApp(load, _ir) {
|
|
1467
|
+
return requireBrickApp((await load()).default);
|
|
1458
1468
|
}
|
|
1459
1469
|
function bindAnalyzed(ir, bindings, bind = bindRoute) {
|
|
1460
1470
|
const routes = ir.routes.map((route, index) => {
|