@akanjs/language 3.2.0-rc.17 → 3.2.0-rc.18
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/guardResolver.d.ts +0 -6
- package/index.cjs +89 -48
- package/index.js +89 -48
- package/package.json +1 -1
- package/server.js +89 -48
package/guardResolver.d.ts
CHANGED
|
@@ -56,15 +56,9 @@ export declare class GuardResolver {
|
|
|
56
56
|
find(local: string, site: GuardSite): GuardLookup;
|
|
57
57
|
madeInPlace(fileName: string, name: string): DeclaredGuard | undefined;
|
|
58
58
|
declare(facts: FileFacts[]): DeclaredGuard[];
|
|
59
|
-
reexportOf(owner: string, name: string, near: string | null): {
|
|
60
|
-
local: string;
|
|
61
|
-
site: GuardSite;
|
|
62
|
-
} | null;
|
|
63
59
|
declarationOf(owner: string, name: string, near: string | null, depth?: number): Declaration | null;
|
|
64
60
|
starExportsOf(owner: string, near: string): StarExports;
|
|
65
61
|
exportsAt(path: string, name: string): ModuleExports;
|
|
66
|
-
hasModule(path: string): boolean;
|
|
67
|
-
packagesUnder(owner: string, folder: string): string[];
|
|
68
62
|
declares(owner: string, name: string): boolean;
|
|
69
63
|
declaresAt(path: string, name: string): boolean;
|
|
70
64
|
inOwner(fileName: string, owner: string | null): string;
|
package/index.cjs
CHANGED
|
@@ -161,6 +161,38 @@ ${at.file}` : null;
|
|
|
161
161
|
return node.fields ? { ...node, fields: node.fields.map(({ digest: _field, ...field }) => field) } : node;
|
|
162
162
|
}
|
|
163
163
|
}
|
|
164
|
+
// pkgs/akanjs/common/facetBarrel.ts
|
|
165
|
+
var barrelFacetDirs = ["ui", "webkit", "srvkit", "common", "plugin"];
|
|
166
|
+
var sourceFilePattern = /\.(ts|tsx)$/;
|
|
167
|
+
var excludedFilePattern = /(^index\.tsx?$|\.d\.ts$|\.(test|spec)\.(ts|tsx)$|\.css$|\.scss$|\.sass$)/;
|
|
168
|
+
var pascalCasePattern = /^[A-Z][A-Za-z0-9]*$/;
|
|
169
|
+
var camelCasePattern = /^[a-z][A-Za-z0-9]*$/;
|
|
170
|
+
var letterRankOf = (char) => char.toLowerCase().charCodeAt(0) * 2 + (char === char.toLowerCase() ? 1 : 0);
|
|
171
|
+
var digitRunAt = (name, idx) => /^\d+/.exec(name.slice(idx))?.[0] ?? "";
|
|
172
|
+
var compareExportNames = (a, b) => {
|
|
173
|
+
for (let idx = 0;idx < a.length && idx < b.length; ) {
|
|
174
|
+
const [runA, runB] = [digitRunAt(a, idx), digitRunAt(b, idx)];
|
|
175
|
+
if (runA && runB && runA !== runB)
|
|
176
|
+
return runA.length - runB.length || (runA < runB ? -1 : 1);
|
|
177
|
+
if (runA && runB)
|
|
178
|
+
idx += runA.length;
|
|
179
|
+
else if (runA || runB)
|
|
180
|
+
return runA ? -1 : 1;
|
|
181
|
+
else if (a.charAt(idx) !== b.charAt(idx))
|
|
182
|
+
return letterRankOf(a.charAt(idx)) - letterRankOf(b.charAt(idx));
|
|
183
|
+
else
|
|
184
|
+
idx++;
|
|
185
|
+
}
|
|
186
|
+
return a.length - b.length;
|
|
187
|
+
};
|
|
188
|
+
var facetBarrelNamesOf = (facet, files, dirs) => {
|
|
189
|
+
const nameCasePattern = facet === "ui" ? pascalCasePattern : camelCasePattern;
|
|
190
|
+
return [
|
|
191
|
+
...files.filter((file) => sourceFilePattern.test(file) && !excludedFilePattern.test(file)).map((file) => file.replace(sourceFilePattern, "")),
|
|
192
|
+
...dirs.filter((dir) => !dir.startsWith("."))
|
|
193
|
+
].filter((name) => nameCasePattern.test(name)).sort(compareExportNames);
|
|
194
|
+
};
|
|
195
|
+
|
|
164
196
|
// pkgs/@akanjs/language/escapeRegExp.ts
|
|
165
197
|
var regExpSpecials = /[\\^$.*+?()[\]{}|]/g;
|
|
166
198
|
var escapeRegExp = (text) => text.replace(regExpSpecials, (special) => `\\${special}`);
|
|
@@ -831,6 +863,7 @@ var aliasPattern = /^@(apps|libs)\/([^/]+)/;
|
|
|
831
863
|
var maxMapDepth = 4;
|
|
832
864
|
var identifierPattern = /^[\p{ID_Start}$_][\p{ID_Continue}$\u200c\u200d]*$/u;
|
|
833
865
|
var starExportPattern = /export\s*\*\s*from\s*["']([^"']+)["']/g;
|
|
866
|
+
var facetEntryPattern = new RegExp(`^((?:apps|libs)/[^/]+/(${barrelFacetDirs.map(escapeRegExp).join("|")}))/([^/]+)(/)?`);
|
|
834
867
|
var exportingPatternOf = (name) => new RegExp(`export\\s*\\{(?:[^}]*?[\\s,])?${escapeRegExp(name)}(?![\\w$])`);
|
|
835
868
|
var declaringPatternOf = (name, isAnyBinding) => {
|
|
836
869
|
const escaped = escapeRegExp(name);
|
|
@@ -856,6 +889,7 @@ class GuardResolver {
|
|
|
856
889
|
#moduleExports = new Map;
|
|
857
890
|
#ownerFiles = null;
|
|
858
891
|
#modules = null;
|
|
892
|
+
#barrels = null;
|
|
859
893
|
constructor(source, routes) {
|
|
860
894
|
this.#source = source;
|
|
861
895
|
this.#routes = routes;
|
|
@@ -983,7 +1017,7 @@ ${name}`, guard);
|
|
|
983
1017
|
const own = this.#nearest(candidates.filter((other) => other.owner === from), ({ site }) => site.fileName, near);
|
|
984
1018
|
if (own)
|
|
985
1019
|
return own;
|
|
986
|
-
const reexport = from && depth < maxMapDepth ? this
|
|
1020
|
+
const reexport = from && depth < maxMapDepth ? this.#reexportOf(from, name, near) : null;
|
|
987
1021
|
if (reexport)
|
|
988
1022
|
return this.#factoryAt(factories, reexport.local, reexport.site, depth + 1);
|
|
989
1023
|
return from && near ? this.#throughStar(candidates, from, name, near) : undefined;
|
|
@@ -1021,13 +1055,13 @@ ${name}`, guard);
|
|
|
1021
1055
|
const visible = isBase ? undefined : declared.find((other) => this.visible(other.owner, site.owner));
|
|
1022
1056
|
return visible ? { guard: visible } : { name, from };
|
|
1023
1057
|
}
|
|
1024
|
-
const reexport = from && depth < maxMapDepth ? this
|
|
1058
|
+
const reexport = from && depth < maxMapDepth ? this.#reexportOf(from, name, near) : null;
|
|
1025
1059
|
if (reexport)
|
|
1026
1060
|
return this.#findGuard(reexport.local, reexport.site, depth + 1, isBase);
|
|
1027
1061
|
const reached = from && near ? this.#throughStar(declared, from, name, near) : undefined;
|
|
1028
1062
|
return reached ? { guard: reached } : { name, from };
|
|
1029
1063
|
}
|
|
1030
|
-
reexportOf(owner, name, near) {
|
|
1064
|
+
#reexportOf(owner, name, near) {
|
|
1031
1065
|
const key = `${owner}
|
|
1032
1066
|
${name}
|
|
1033
1067
|
${near ?? ""}`;
|
|
@@ -1184,20 +1218,24 @@ ${near}`;
|
|
|
1184
1218
|
return cached;
|
|
1185
1219
|
const found = { owners: [], packages: [], paths: [near], isOpaque: false };
|
|
1186
1220
|
this.#starExports.set(key, found);
|
|
1187
|
-
|
|
1188
|
-
|
|
1189
|
-
|
|
1190
|
-
|
|
1191
|
-
|
|
1192
|
-
|
|
1193
|
-
|
|
1194
|
-
|
|
1195
|
-
|
|
1196
|
-
|
|
1197
|
-
|
|
1198
|
-
|
|
1199
|
-
|
|
1200
|
-
|
|
1221
|
+
const reach = (specifier, path, target) => {
|
|
1222
|
+
if (path === null && !found.packages.includes(specifier))
|
|
1223
|
+
found.packages.push(specifier);
|
|
1224
|
+
if (target === undefined || target === frameworkOwner || path === null)
|
|
1225
|
+
found.isOpaque = true;
|
|
1226
|
+
else if (!found.paths.includes(path))
|
|
1227
|
+
found.paths.push(path);
|
|
1228
|
+
if (target && target !== frameworkOwner && target !== owner && !found.owners.includes(target))
|
|
1229
|
+
found.owners.push(target);
|
|
1230
|
+
};
|
|
1231
|
+
for (let idx = 0;idx < found.paths.length; idx++) {
|
|
1232
|
+
const path = found.paths[idx] ?? "";
|
|
1233
|
+
for (const module2 of this.#barrelAt(path) ?? [])
|
|
1234
|
+
reach(module2, module2, ownerOf(module2) ?? undefined);
|
|
1235
|
+
for (const fileName of this.#modulesAt(path))
|
|
1236
|
+
for (const [, specifier = ""] of this.#source.readText(fileName)?.matchAll(starExportPattern) ?? [])
|
|
1237
|
+
reach(specifier, this.pathOfSpecifier(fileName, specifier), this.ownerOfSpecifier(fileName, specifier));
|
|
1238
|
+
}
|
|
1201
1239
|
return found;
|
|
1202
1240
|
}
|
|
1203
1241
|
exportsAt(path, name) {
|
|
@@ -1206,7 +1244,7 @@ ${name}`;
|
|
|
1206
1244
|
const cached = this.#moduleExports.get(key);
|
|
1207
1245
|
if (cached)
|
|
1208
1246
|
return cached;
|
|
1209
|
-
const found = { named: null, stars: [] };
|
|
1247
|
+
const found = { named: null, stars: this.#barrelAt(path) ?? [] };
|
|
1210
1248
|
const exporting = exportingPatternOf(name);
|
|
1211
1249
|
for (const fileName of this.#modulesAt(path)) {
|
|
1212
1250
|
const text = this.#source.readText(fileName);
|
|
@@ -1238,21 +1276,23 @@ ${name}`;
|
|
|
1238
1276
|
}
|
|
1239
1277
|
return this.#modules.get(path) ?? [];
|
|
1240
1278
|
}
|
|
1241
|
-
|
|
1242
|
-
|
|
1243
|
-
|
|
1244
|
-
|
|
1245
|
-
|
|
1246
|
-
|
|
1247
|
-
|
|
1248
|
-
|
|
1249
|
-
|
|
1250
|
-
|
|
1251
|
-
|
|
1252
|
-
|
|
1253
|
-
|
|
1279
|
+
#barrelAt(path) {
|
|
1280
|
+
if (!this.#barrels) {
|
|
1281
|
+
const entries = new Map;
|
|
1282
|
+
for (const [fileName] of this.#source.files) {
|
|
1283
|
+
const [, folder, facet, entry, nested] = this.#source.relative(fileName).match(facetEntryPattern) ?? [];
|
|
1284
|
+
if (!folder || !facet || !entry)
|
|
1285
|
+
continue;
|
|
1286
|
+
const found = entries.get(folder) ?? { facet, files: new Set, dirs: new Set };
|
|
1287
|
+
(nested ? found.dirs : found.files).add(entry);
|
|
1288
|
+
entries.set(folder, found);
|
|
1289
|
+
}
|
|
1290
|
+
this.#barrels = new Map([...entries].map(([folder, { facet, files, dirs }]) => [
|
|
1291
|
+
folder,
|
|
1292
|
+
facetBarrelNamesOf(facet, [...files], [...dirs]).map((name) => `${folder}/${name}`)
|
|
1293
|
+
]));
|
|
1254
1294
|
}
|
|
1255
|
-
return
|
|
1295
|
+
return this.#modulesAt(path).length ? undefined : this.#barrels.get(path);
|
|
1256
1296
|
}
|
|
1257
1297
|
declares(owner, name) {
|
|
1258
1298
|
const declaring = declaringPatternOf(name, true);
|
|
@@ -1313,7 +1353,9 @@ export
|
|
|
1313
1353
|
}
|
|
1314
1354
|
|
|
1315
1355
|
// pkgs/@akanjs/language/adaptorResolver.ts
|
|
1316
|
-
var
|
|
1356
|
+
var packageOf = (specifier) => specifier.split("/").slice(0, specifier.startsWith("@") ? 2 : 1).join("/");
|
|
1357
|
+
var packageKeyOf = ({ name, from }) => `${packageOf(from)}
|
|
1358
|
+
${name}`;
|
|
1317
1359
|
|
|
1318
1360
|
class AdaptorResolver {
|
|
1319
1361
|
#source;
|
|
@@ -1404,8 +1446,6 @@ ${field}`))
|
|
|
1404
1446
|
return own.find((adaptor) => adaptor.fileName === fileName) ?? first;
|
|
1405
1447
|
if (own.length === 1)
|
|
1406
1448
|
return first;
|
|
1407
|
-
if (!this.#resolver.hasModule(path))
|
|
1408
|
-
return own.find((adaptor) => this.#source.relative(adaptor.fileName).startsWith(`${path}/`)) ?? first;
|
|
1409
1449
|
const exported = this.#exportedAt(name, path, new Set).filter((item) => first || ("fact" in item));
|
|
1410
1450
|
const [only] = exported;
|
|
1411
1451
|
if (only)
|
|
@@ -1415,7 +1455,7 @@ ${field}`))
|
|
|
1415
1455
|
#exportedAt(name, path, seen) {
|
|
1416
1456
|
const key = `${path}
|
|
1417
1457
|
${name}`;
|
|
1418
|
-
if (seen.has(key)
|
|
1458
|
+
if (seen.has(key))
|
|
1419
1459
|
return [];
|
|
1420
1460
|
seen.add(key);
|
|
1421
1461
|
const here = (this.#adaptors.get(name) ?? []).filter((adaptor) => {
|
|
@@ -1431,25 +1471,26 @@ ${name}`;
|
|
|
1431
1471
|
const target = named.from === null ? path : this.#resolver.pathOfSpecifier(named.fileName, named.from);
|
|
1432
1472
|
return target === null ? [] : this.#exportedAt(named.name, target, seen);
|
|
1433
1473
|
}
|
|
1434
|
-
|
|
1474
|
+
const reached = stars.flatMap((star) => this.#exportedAt(name, star, seen));
|
|
1475
|
+
return [...new Map(reached.map((item) => ["fact" in item ? item.id : packageKeyOf(item), item])).values()];
|
|
1435
1476
|
}
|
|
1436
1477
|
#packageAdaptorOf(name, specifier) {
|
|
1437
1478
|
if (frameworkPattern.test(specifier))
|
|
1438
1479
|
return this.#sink.addNode(this.#sink.key("adaptor", null, name), "adaptor", null, name, null, [frameworkOwner]).id;
|
|
1439
|
-
const pkg =
|
|
1480
|
+
const pkg = packageOf(specifier);
|
|
1440
1481
|
return this.#sink.addNode(this.#sink.key("adaptor", pkg, name), "adaptor", null, name, null, [pkg]).id;
|
|
1441
1482
|
}
|
|
1442
1483
|
#packageShimOf(owner, name, near) {
|
|
1443
|
-
|
|
1444
|
-
const [shim] = reexport?.site.imports ?? [];
|
|
1445
|
-
if (reexport && shim && this.#resolver.pathOfSpecifier(reexport.site.fileName, shim.from) === null)
|
|
1446
|
-
return { name: reexport.local === "default" ? name : reexport.local, from: shim.from };
|
|
1447
|
-
if (reexport || !near)
|
|
1484
|
+
if (!near)
|
|
1448
1485
|
return null;
|
|
1449
|
-
const
|
|
1486
|
+
const shims = this.#exportedAt(name, near, new Set).filter((item) => !("fact" in item));
|
|
1487
|
+
const [shim] = shims;
|
|
1488
|
+
if (shim)
|
|
1489
|
+
return shims.length === 1 ? shim : null;
|
|
1490
|
+
const { packages, paths } = this.#resolver.starExportsOf(owner, near);
|
|
1450
1491
|
const [only] = packages;
|
|
1451
|
-
const isDeclared =
|
|
1452
|
-
return packages.
|
|
1492
|
+
const isDeclared = paths.some((path) => this.#resolver.declaresAt(path, name));
|
|
1493
|
+
return only && new Set(packages.map(packageOf)).size === 1 && !isDeclared ? { name, from: only } : null;
|
|
1453
1494
|
}
|
|
1454
1495
|
#nodeOf({ fact, owner, fileName, id }) {
|
|
1455
1496
|
const detail = fact.refName ? [fact.refName] : [];
|
|
@@ -1484,6 +1525,7 @@ var PAGE_ROUTE_EXPORTS = new Set([
|
|
|
1484
1525
|
"guard"
|
|
1485
1526
|
]);
|
|
1486
1527
|
var LAYOUT_ROUTE_EXPORTS = new Set([...PAGE_ROUTE_EXPORTS, "NotFound", "Error"]);
|
|
1528
|
+
var GENERATED_ROOT_LAYOUT_EXPORTS = new Set(["McpAppRoot", "LevelBoundary"]);
|
|
1487
1529
|
var ROOT_LAYOUT_ROUTE_EXPORTS = new Set([
|
|
1488
1530
|
...LAYOUT_ROUTE_EXPORTS,
|
|
1489
1531
|
"fonts",
|
|
@@ -1493,8 +1535,7 @@ var ROOT_LAYOUT_ROUTE_EXPORTS = new Set([
|
|
|
1493
1535
|
"wsConnect",
|
|
1494
1536
|
"layoutStyle",
|
|
1495
1537
|
"viewport",
|
|
1496
|
-
|
|
1497
|
-
"LevelBoundary"
|
|
1538
|
+
...GENERATED_ROOT_LAYOUT_EXPORTS
|
|
1498
1539
|
]);
|
|
1499
1540
|
var RESERVED_ROUTE_CONFIG_EXPORTS = new Set([...ROOT_LAYOUT_ROUTE_EXPORTS].filter((name) => name !== "default" && !/^[A-Z]/.test(name)));
|
|
1500
1541
|
function parseRouteModuleKey(key) {
|
package/index.js
CHANGED
|
@@ -109,6 +109,38 @@ ${at.file}` : null;
|
|
|
109
109
|
return node.fields ? { ...node, fields: node.fields.map(({ digest: _field, ...field }) => field) } : node;
|
|
110
110
|
}
|
|
111
111
|
}
|
|
112
|
+
// pkgs/akanjs/common/facetBarrel.ts
|
|
113
|
+
var barrelFacetDirs = ["ui", "webkit", "srvkit", "common", "plugin"];
|
|
114
|
+
var sourceFilePattern = /\.(ts|tsx)$/;
|
|
115
|
+
var excludedFilePattern = /(^index\.tsx?$|\.d\.ts$|\.(test|spec)\.(ts|tsx)$|\.css$|\.scss$|\.sass$)/;
|
|
116
|
+
var pascalCasePattern = /^[A-Z][A-Za-z0-9]*$/;
|
|
117
|
+
var camelCasePattern = /^[a-z][A-Za-z0-9]*$/;
|
|
118
|
+
var letterRankOf = (char) => char.toLowerCase().charCodeAt(0) * 2 + (char === char.toLowerCase() ? 1 : 0);
|
|
119
|
+
var digitRunAt = (name, idx) => /^\d+/.exec(name.slice(idx))?.[0] ?? "";
|
|
120
|
+
var compareExportNames = (a, b) => {
|
|
121
|
+
for (let idx = 0;idx < a.length && idx < b.length; ) {
|
|
122
|
+
const [runA, runB] = [digitRunAt(a, idx), digitRunAt(b, idx)];
|
|
123
|
+
if (runA && runB && runA !== runB)
|
|
124
|
+
return runA.length - runB.length || (runA < runB ? -1 : 1);
|
|
125
|
+
if (runA && runB)
|
|
126
|
+
idx += runA.length;
|
|
127
|
+
else if (runA || runB)
|
|
128
|
+
return runA ? -1 : 1;
|
|
129
|
+
else if (a.charAt(idx) !== b.charAt(idx))
|
|
130
|
+
return letterRankOf(a.charAt(idx)) - letterRankOf(b.charAt(idx));
|
|
131
|
+
else
|
|
132
|
+
idx++;
|
|
133
|
+
}
|
|
134
|
+
return a.length - b.length;
|
|
135
|
+
};
|
|
136
|
+
var facetBarrelNamesOf = (facet, files, dirs) => {
|
|
137
|
+
const nameCasePattern = facet === "ui" ? pascalCasePattern : camelCasePattern;
|
|
138
|
+
return [
|
|
139
|
+
...files.filter((file) => sourceFilePattern.test(file) && !excludedFilePattern.test(file)).map((file) => file.replace(sourceFilePattern, "")),
|
|
140
|
+
...dirs.filter((dir) => !dir.startsWith("."))
|
|
141
|
+
].filter((name) => nameCasePattern.test(name)).sort(compareExportNames);
|
|
142
|
+
};
|
|
143
|
+
|
|
112
144
|
// pkgs/@akanjs/language/escapeRegExp.ts
|
|
113
145
|
var regExpSpecials = /[\\^$.*+?()[\]{}|]/g;
|
|
114
146
|
var escapeRegExp = (text) => text.replace(regExpSpecials, (special) => `\\${special}`);
|
|
@@ -779,6 +811,7 @@ var aliasPattern = /^@(apps|libs)\/([^/]+)/;
|
|
|
779
811
|
var maxMapDepth = 4;
|
|
780
812
|
var identifierPattern = /^[\p{ID_Start}$_][\p{ID_Continue}$\u200c\u200d]*$/u;
|
|
781
813
|
var starExportPattern = /export\s*\*\s*from\s*["']([^"']+)["']/g;
|
|
814
|
+
var facetEntryPattern = new RegExp(`^((?:apps|libs)/[^/]+/(${barrelFacetDirs.map(escapeRegExp).join("|")}))/([^/]+)(/)?`);
|
|
782
815
|
var exportingPatternOf = (name) => new RegExp(`export\\s*\\{(?:[^}]*?[\\s,])?${escapeRegExp(name)}(?![\\w$])`);
|
|
783
816
|
var declaringPatternOf = (name, isAnyBinding) => {
|
|
784
817
|
const escaped = escapeRegExp(name);
|
|
@@ -804,6 +837,7 @@ class GuardResolver {
|
|
|
804
837
|
#moduleExports = new Map;
|
|
805
838
|
#ownerFiles = null;
|
|
806
839
|
#modules = null;
|
|
840
|
+
#barrels = null;
|
|
807
841
|
constructor(source, routes) {
|
|
808
842
|
this.#source = source;
|
|
809
843
|
this.#routes = routes;
|
|
@@ -931,7 +965,7 @@ ${name}`, guard);
|
|
|
931
965
|
const own = this.#nearest(candidates.filter((other) => other.owner === from), ({ site }) => site.fileName, near);
|
|
932
966
|
if (own)
|
|
933
967
|
return own;
|
|
934
|
-
const reexport = from && depth < maxMapDepth ? this
|
|
968
|
+
const reexport = from && depth < maxMapDepth ? this.#reexportOf(from, name, near) : null;
|
|
935
969
|
if (reexport)
|
|
936
970
|
return this.#factoryAt(factories, reexport.local, reexport.site, depth + 1);
|
|
937
971
|
return from && near ? this.#throughStar(candidates, from, name, near) : undefined;
|
|
@@ -969,13 +1003,13 @@ ${name}`, guard);
|
|
|
969
1003
|
const visible = isBase ? undefined : declared.find((other) => this.visible(other.owner, site.owner));
|
|
970
1004
|
return visible ? { guard: visible } : { name, from };
|
|
971
1005
|
}
|
|
972
|
-
const reexport = from && depth < maxMapDepth ? this
|
|
1006
|
+
const reexport = from && depth < maxMapDepth ? this.#reexportOf(from, name, near) : null;
|
|
973
1007
|
if (reexport)
|
|
974
1008
|
return this.#findGuard(reexport.local, reexport.site, depth + 1, isBase);
|
|
975
1009
|
const reached = from && near ? this.#throughStar(declared, from, name, near) : undefined;
|
|
976
1010
|
return reached ? { guard: reached } : { name, from };
|
|
977
1011
|
}
|
|
978
|
-
reexportOf(owner, name, near) {
|
|
1012
|
+
#reexportOf(owner, name, near) {
|
|
979
1013
|
const key = `${owner}
|
|
980
1014
|
${name}
|
|
981
1015
|
${near ?? ""}`;
|
|
@@ -1132,20 +1166,24 @@ ${near}`;
|
|
|
1132
1166
|
return cached;
|
|
1133
1167
|
const found = { owners: [], packages: [], paths: [near], isOpaque: false };
|
|
1134
1168
|
this.#starExports.set(key, found);
|
|
1135
|
-
|
|
1136
|
-
|
|
1137
|
-
|
|
1138
|
-
|
|
1139
|
-
|
|
1140
|
-
|
|
1141
|
-
|
|
1142
|
-
|
|
1143
|
-
|
|
1144
|
-
|
|
1145
|
-
|
|
1146
|
-
|
|
1147
|
-
|
|
1148
|
-
|
|
1169
|
+
const reach = (specifier, path, target) => {
|
|
1170
|
+
if (path === null && !found.packages.includes(specifier))
|
|
1171
|
+
found.packages.push(specifier);
|
|
1172
|
+
if (target === undefined || target === frameworkOwner || path === null)
|
|
1173
|
+
found.isOpaque = true;
|
|
1174
|
+
else if (!found.paths.includes(path))
|
|
1175
|
+
found.paths.push(path);
|
|
1176
|
+
if (target && target !== frameworkOwner && target !== owner && !found.owners.includes(target))
|
|
1177
|
+
found.owners.push(target);
|
|
1178
|
+
};
|
|
1179
|
+
for (let idx = 0;idx < found.paths.length; idx++) {
|
|
1180
|
+
const path = found.paths[idx] ?? "";
|
|
1181
|
+
for (const module of this.#barrelAt(path) ?? [])
|
|
1182
|
+
reach(module, module, ownerOf(module) ?? undefined);
|
|
1183
|
+
for (const fileName of this.#modulesAt(path))
|
|
1184
|
+
for (const [, specifier = ""] of this.#source.readText(fileName)?.matchAll(starExportPattern) ?? [])
|
|
1185
|
+
reach(specifier, this.pathOfSpecifier(fileName, specifier), this.ownerOfSpecifier(fileName, specifier));
|
|
1186
|
+
}
|
|
1149
1187
|
return found;
|
|
1150
1188
|
}
|
|
1151
1189
|
exportsAt(path, name) {
|
|
@@ -1154,7 +1192,7 @@ ${name}`;
|
|
|
1154
1192
|
const cached = this.#moduleExports.get(key);
|
|
1155
1193
|
if (cached)
|
|
1156
1194
|
return cached;
|
|
1157
|
-
const found = { named: null, stars: [] };
|
|
1195
|
+
const found = { named: null, stars: this.#barrelAt(path) ?? [] };
|
|
1158
1196
|
const exporting = exportingPatternOf(name);
|
|
1159
1197
|
for (const fileName of this.#modulesAt(path)) {
|
|
1160
1198
|
const text = this.#source.readText(fileName);
|
|
@@ -1186,21 +1224,23 @@ ${name}`;
|
|
|
1186
1224
|
}
|
|
1187
1225
|
return this.#modules.get(path) ?? [];
|
|
1188
1226
|
}
|
|
1189
|
-
|
|
1190
|
-
|
|
1191
|
-
|
|
1192
|
-
|
|
1193
|
-
|
|
1194
|
-
|
|
1195
|
-
|
|
1196
|
-
|
|
1197
|
-
|
|
1198
|
-
|
|
1199
|
-
|
|
1200
|
-
|
|
1201
|
-
|
|
1227
|
+
#barrelAt(path) {
|
|
1228
|
+
if (!this.#barrels) {
|
|
1229
|
+
const entries = new Map;
|
|
1230
|
+
for (const [fileName] of this.#source.files) {
|
|
1231
|
+
const [, folder, facet, entry, nested] = this.#source.relative(fileName).match(facetEntryPattern) ?? [];
|
|
1232
|
+
if (!folder || !facet || !entry)
|
|
1233
|
+
continue;
|
|
1234
|
+
const found = entries.get(folder) ?? { facet, files: new Set, dirs: new Set };
|
|
1235
|
+
(nested ? found.dirs : found.files).add(entry);
|
|
1236
|
+
entries.set(folder, found);
|
|
1237
|
+
}
|
|
1238
|
+
this.#barrels = new Map([...entries].map(([folder, { facet, files, dirs }]) => [
|
|
1239
|
+
folder,
|
|
1240
|
+
facetBarrelNamesOf(facet, [...files], [...dirs]).map((name) => `${folder}/${name}`)
|
|
1241
|
+
]));
|
|
1202
1242
|
}
|
|
1203
|
-
return
|
|
1243
|
+
return this.#modulesAt(path).length ? undefined : this.#barrels.get(path);
|
|
1204
1244
|
}
|
|
1205
1245
|
declares(owner, name) {
|
|
1206
1246
|
const declaring = declaringPatternOf(name, true);
|
|
@@ -1261,7 +1301,9 @@ export
|
|
|
1261
1301
|
}
|
|
1262
1302
|
|
|
1263
1303
|
// pkgs/@akanjs/language/adaptorResolver.ts
|
|
1264
|
-
var
|
|
1304
|
+
var packageOf = (specifier) => specifier.split("/").slice(0, specifier.startsWith("@") ? 2 : 1).join("/");
|
|
1305
|
+
var packageKeyOf = ({ name, from }) => `${packageOf(from)}
|
|
1306
|
+
${name}`;
|
|
1265
1307
|
|
|
1266
1308
|
class AdaptorResolver {
|
|
1267
1309
|
#source;
|
|
@@ -1352,8 +1394,6 @@ ${field}`))
|
|
|
1352
1394
|
return own.find((adaptor) => adaptor.fileName === fileName) ?? first;
|
|
1353
1395
|
if (own.length === 1)
|
|
1354
1396
|
return first;
|
|
1355
|
-
if (!this.#resolver.hasModule(path))
|
|
1356
|
-
return own.find((adaptor) => this.#source.relative(adaptor.fileName).startsWith(`${path}/`)) ?? first;
|
|
1357
1397
|
const exported = this.#exportedAt(name, path, new Set).filter((item) => first || ("fact" in item));
|
|
1358
1398
|
const [only] = exported;
|
|
1359
1399
|
if (only)
|
|
@@ -1363,7 +1403,7 @@ ${field}`))
|
|
|
1363
1403
|
#exportedAt(name, path, seen) {
|
|
1364
1404
|
const key = `${path}
|
|
1365
1405
|
${name}`;
|
|
1366
|
-
if (seen.has(key)
|
|
1406
|
+
if (seen.has(key))
|
|
1367
1407
|
return [];
|
|
1368
1408
|
seen.add(key);
|
|
1369
1409
|
const here = (this.#adaptors.get(name) ?? []).filter((adaptor) => {
|
|
@@ -1379,25 +1419,26 @@ ${name}`;
|
|
|
1379
1419
|
const target = named.from === null ? path : this.#resolver.pathOfSpecifier(named.fileName, named.from);
|
|
1380
1420
|
return target === null ? [] : this.#exportedAt(named.name, target, seen);
|
|
1381
1421
|
}
|
|
1382
|
-
|
|
1422
|
+
const reached = stars.flatMap((star) => this.#exportedAt(name, star, seen));
|
|
1423
|
+
return [...new Map(reached.map((item) => ["fact" in item ? item.id : packageKeyOf(item), item])).values()];
|
|
1383
1424
|
}
|
|
1384
1425
|
#packageAdaptorOf(name, specifier) {
|
|
1385
1426
|
if (frameworkPattern.test(specifier))
|
|
1386
1427
|
return this.#sink.addNode(this.#sink.key("adaptor", null, name), "adaptor", null, name, null, [frameworkOwner]).id;
|
|
1387
|
-
const pkg =
|
|
1428
|
+
const pkg = packageOf(specifier);
|
|
1388
1429
|
return this.#sink.addNode(this.#sink.key("adaptor", pkg, name), "adaptor", null, name, null, [pkg]).id;
|
|
1389
1430
|
}
|
|
1390
1431
|
#packageShimOf(owner, name, near) {
|
|
1391
|
-
|
|
1392
|
-
const [shim] = reexport?.site.imports ?? [];
|
|
1393
|
-
if (reexport && shim && this.#resolver.pathOfSpecifier(reexport.site.fileName, shim.from) === null)
|
|
1394
|
-
return { name: reexport.local === "default" ? name : reexport.local, from: shim.from };
|
|
1395
|
-
if (reexport || !near)
|
|
1432
|
+
if (!near)
|
|
1396
1433
|
return null;
|
|
1397
|
-
const
|
|
1434
|
+
const shims = this.#exportedAt(name, near, new Set).filter((item) => !("fact" in item));
|
|
1435
|
+
const [shim] = shims;
|
|
1436
|
+
if (shim)
|
|
1437
|
+
return shims.length === 1 ? shim : null;
|
|
1438
|
+
const { packages, paths } = this.#resolver.starExportsOf(owner, near);
|
|
1398
1439
|
const [only] = packages;
|
|
1399
|
-
const isDeclared =
|
|
1400
|
-
return packages.
|
|
1440
|
+
const isDeclared = paths.some((path) => this.#resolver.declaresAt(path, name));
|
|
1441
|
+
return only && new Set(packages.map(packageOf)).size === 1 && !isDeclared ? { name, from: only } : null;
|
|
1401
1442
|
}
|
|
1402
1443
|
#nodeOf({ fact, owner, fileName, id }) {
|
|
1403
1444
|
const detail = fact.refName ? [fact.refName] : [];
|
|
@@ -1432,6 +1473,7 @@ var PAGE_ROUTE_EXPORTS = new Set([
|
|
|
1432
1473
|
"guard"
|
|
1433
1474
|
]);
|
|
1434
1475
|
var LAYOUT_ROUTE_EXPORTS = new Set([...PAGE_ROUTE_EXPORTS, "NotFound", "Error"]);
|
|
1476
|
+
var GENERATED_ROOT_LAYOUT_EXPORTS = new Set(["McpAppRoot", "LevelBoundary"]);
|
|
1435
1477
|
var ROOT_LAYOUT_ROUTE_EXPORTS = new Set([
|
|
1436
1478
|
...LAYOUT_ROUTE_EXPORTS,
|
|
1437
1479
|
"fonts",
|
|
@@ -1441,8 +1483,7 @@ var ROOT_LAYOUT_ROUTE_EXPORTS = new Set([
|
|
|
1441
1483
|
"wsConnect",
|
|
1442
1484
|
"layoutStyle",
|
|
1443
1485
|
"viewport",
|
|
1444
|
-
|
|
1445
|
-
"LevelBoundary"
|
|
1486
|
+
...GENERATED_ROOT_LAYOUT_EXPORTS
|
|
1446
1487
|
]);
|
|
1447
1488
|
var RESERVED_ROUTE_CONFIG_EXPORTS = new Set([...ROOT_LAYOUT_ROUTE_EXPORTS].filter((name) => name !== "default" && !/^[A-Z]/.test(name)));
|
|
1448
1489
|
function parseRouteModuleKey(key) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@akanjs/language",
|
|
3
|
-
"version": "3.2.0-rc.
|
|
3
|
+
"version": "3.2.0-rc.18",
|
|
4
4
|
"description": "Editor-independent Akan.js language core: resolves derived names (slices, queries, CRUD, form setters) back to the source key that produced them.",
|
|
5
5
|
"sourceType": "module",
|
|
6
6
|
"type": "module",
|
package/server.js
CHANGED
|
@@ -5,6 +5,38 @@ import { existsSync, readdirSync, readFileSync, realpathSync, statSync } from "n
|
|
|
5
5
|
import path from "node:path";
|
|
6
6
|
import { fileURLToPath, pathToFileURL } from "node:url";
|
|
7
7
|
|
|
8
|
+
// pkgs/akanjs/common/facetBarrel.ts
|
|
9
|
+
var barrelFacetDirs = ["ui", "webkit", "srvkit", "common", "plugin"];
|
|
10
|
+
var sourceFilePattern = /\.(ts|tsx)$/;
|
|
11
|
+
var excludedFilePattern = /(^index\.tsx?$|\.d\.ts$|\.(test|spec)\.(ts|tsx)$|\.css$|\.scss$|\.sass$)/;
|
|
12
|
+
var pascalCasePattern = /^[A-Z][A-Za-z0-9]*$/;
|
|
13
|
+
var camelCasePattern = /^[a-z][A-Za-z0-9]*$/;
|
|
14
|
+
var letterRankOf = (char) => char.toLowerCase().charCodeAt(0) * 2 + (char === char.toLowerCase() ? 1 : 0);
|
|
15
|
+
var digitRunAt = (name, idx) => /^\d+/.exec(name.slice(idx))?.[0] ?? "";
|
|
16
|
+
var compareExportNames = (a, b) => {
|
|
17
|
+
for (let idx = 0;idx < a.length && idx < b.length; ) {
|
|
18
|
+
const [runA, runB] = [digitRunAt(a, idx), digitRunAt(b, idx)];
|
|
19
|
+
if (runA && runB && runA !== runB)
|
|
20
|
+
return runA.length - runB.length || (runA < runB ? -1 : 1);
|
|
21
|
+
if (runA && runB)
|
|
22
|
+
idx += runA.length;
|
|
23
|
+
else if (runA || runB)
|
|
24
|
+
return runA ? -1 : 1;
|
|
25
|
+
else if (a.charAt(idx) !== b.charAt(idx))
|
|
26
|
+
return letterRankOf(a.charAt(idx)) - letterRankOf(b.charAt(idx));
|
|
27
|
+
else
|
|
28
|
+
idx++;
|
|
29
|
+
}
|
|
30
|
+
return a.length - b.length;
|
|
31
|
+
};
|
|
32
|
+
var facetBarrelNamesOf = (facet, files, dirs) => {
|
|
33
|
+
const nameCasePattern = facet === "ui" ? pascalCasePattern : camelCasePattern;
|
|
34
|
+
return [
|
|
35
|
+
...files.filter((file) => sourceFilePattern.test(file) && !excludedFilePattern.test(file)).map((file) => file.replace(sourceFilePattern, "")),
|
|
36
|
+
...dirs.filter((dir) => !dir.startsWith("."))
|
|
37
|
+
].filter((name) => nameCasePattern.test(name)).sort(compareExportNames);
|
|
38
|
+
};
|
|
39
|
+
|
|
8
40
|
// pkgs/@akanjs/language/escapeRegExp.ts
|
|
9
41
|
var regExpSpecials = /[\\^$.*+?()[\]{}|]/g;
|
|
10
42
|
var escapeRegExp = (text) => text.replace(regExpSpecials, (special) => `\\${special}`);
|
|
@@ -675,6 +707,7 @@ var aliasPattern = /^@(apps|libs)\/([^/]+)/;
|
|
|
675
707
|
var maxMapDepth = 4;
|
|
676
708
|
var identifierPattern = /^[\p{ID_Start}$_][\p{ID_Continue}$\u200c\u200d]*$/u;
|
|
677
709
|
var starExportPattern = /export\s*\*\s*from\s*["']([^"']+)["']/g;
|
|
710
|
+
var facetEntryPattern = new RegExp(`^((?:apps|libs)/[^/]+/(${barrelFacetDirs.map(escapeRegExp).join("|")}))/([^/]+)(/)?`);
|
|
678
711
|
var exportingPatternOf = (name) => new RegExp(`export\\s*\\{(?:[^}]*?[\\s,])?${escapeRegExp(name)}(?![\\w$])`);
|
|
679
712
|
var declaringPatternOf = (name, isAnyBinding) => {
|
|
680
713
|
const escaped = escapeRegExp(name);
|
|
@@ -700,6 +733,7 @@ class GuardResolver {
|
|
|
700
733
|
#moduleExports = new Map;
|
|
701
734
|
#ownerFiles = null;
|
|
702
735
|
#modules = null;
|
|
736
|
+
#barrels = null;
|
|
703
737
|
constructor(source, routes) {
|
|
704
738
|
this.#source = source;
|
|
705
739
|
this.#routes = routes;
|
|
@@ -827,7 +861,7 @@ ${name}`, guard);
|
|
|
827
861
|
const own = this.#nearest(candidates.filter((other) => other.owner === from), ({ site }) => site.fileName, near);
|
|
828
862
|
if (own)
|
|
829
863
|
return own;
|
|
830
|
-
const reexport = from && depth < maxMapDepth ? this
|
|
864
|
+
const reexport = from && depth < maxMapDepth ? this.#reexportOf(from, name, near) : null;
|
|
831
865
|
if (reexport)
|
|
832
866
|
return this.#factoryAt(factories, reexport.local, reexport.site, depth + 1);
|
|
833
867
|
return from && near ? this.#throughStar(candidates, from, name, near) : undefined;
|
|
@@ -865,13 +899,13 @@ ${name}`, guard);
|
|
|
865
899
|
const visible = isBase ? undefined : declared.find((other) => this.visible(other.owner, site.owner));
|
|
866
900
|
return visible ? { guard: visible } : { name, from };
|
|
867
901
|
}
|
|
868
|
-
const reexport = from && depth < maxMapDepth ? this
|
|
902
|
+
const reexport = from && depth < maxMapDepth ? this.#reexportOf(from, name, near) : null;
|
|
869
903
|
if (reexport)
|
|
870
904
|
return this.#findGuard(reexport.local, reexport.site, depth + 1, isBase);
|
|
871
905
|
const reached = from && near ? this.#throughStar(declared, from, name, near) : undefined;
|
|
872
906
|
return reached ? { guard: reached } : { name, from };
|
|
873
907
|
}
|
|
874
|
-
reexportOf(owner, name, near) {
|
|
908
|
+
#reexportOf(owner, name, near) {
|
|
875
909
|
const key = `${owner}
|
|
876
910
|
${name}
|
|
877
911
|
${near ?? ""}`;
|
|
@@ -1028,20 +1062,24 @@ ${near}`;
|
|
|
1028
1062
|
return cached;
|
|
1029
1063
|
const found = { owners: [], packages: [], paths: [near], isOpaque: false };
|
|
1030
1064
|
this.#starExports.set(key, found);
|
|
1031
|
-
|
|
1032
|
-
|
|
1033
|
-
|
|
1034
|
-
|
|
1035
|
-
|
|
1036
|
-
|
|
1037
|
-
|
|
1038
|
-
|
|
1039
|
-
|
|
1040
|
-
|
|
1041
|
-
|
|
1042
|
-
|
|
1043
|
-
|
|
1044
|
-
|
|
1065
|
+
const reach = (specifier, path, target) => {
|
|
1066
|
+
if (path === null && !found.packages.includes(specifier))
|
|
1067
|
+
found.packages.push(specifier);
|
|
1068
|
+
if (target === undefined || target === frameworkOwner || path === null)
|
|
1069
|
+
found.isOpaque = true;
|
|
1070
|
+
else if (!found.paths.includes(path))
|
|
1071
|
+
found.paths.push(path);
|
|
1072
|
+
if (target && target !== frameworkOwner && target !== owner && !found.owners.includes(target))
|
|
1073
|
+
found.owners.push(target);
|
|
1074
|
+
};
|
|
1075
|
+
for (let idx = 0;idx < found.paths.length; idx++) {
|
|
1076
|
+
const path = found.paths[idx] ?? "";
|
|
1077
|
+
for (const module of this.#barrelAt(path) ?? [])
|
|
1078
|
+
reach(module, module, ownerOf(module) ?? undefined);
|
|
1079
|
+
for (const fileName of this.#modulesAt(path))
|
|
1080
|
+
for (const [, specifier = ""] of this.#source.readText(fileName)?.matchAll(starExportPattern) ?? [])
|
|
1081
|
+
reach(specifier, this.pathOfSpecifier(fileName, specifier), this.ownerOfSpecifier(fileName, specifier));
|
|
1082
|
+
}
|
|
1045
1083
|
return found;
|
|
1046
1084
|
}
|
|
1047
1085
|
exportsAt(path, name) {
|
|
@@ -1050,7 +1088,7 @@ ${name}`;
|
|
|
1050
1088
|
const cached = this.#moduleExports.get(key);
|
|
1051
1089
|
if (cached)
|
|
1052
1090
|
return cached;
|
|
1053
|
-
const found = { named: null, stars: [] };
|
|
1091
|
+
const found = { named: null, stars: this.#barrelAt(path) ?? [] };
|
|
1054
1092
|
const exporting = exportingPatternOf(name);
|
|
1055
1093
|
for (const fileName of this.#modulesAt(path)) {
|
|
1056
1094
|
const text = this.#source.readText(fileName);
|
|
@@ -1082,21 +1120,23 @@ ${name}`;
|
|
|
1082
1120
|
}
|
|
1083
1121
|
return this.#modules.get(path) ?? [];
|
|
1084
1122
|
}
|
|
1085
|
-
|
|
1086
|
-
|
|
1087
|
-
|
|
1088
|
-
|
|
1089
|
-
|
|
1090
|
-
|
|
1091
|
-
|
|
1092
|
-
|
|
1093
|
-
|
|
1094
|
-
|
|
1095
|
-
|
|
1096
|
-
|
|
1097
|
-
|
|
1123
|
+
#barrelAt(path) {
|
|
1124
|
+
if (!this.#barrels) {
|
|
1125
|
+
const entries = new Map;
|
|
1126
|
+
for (const [fileName] of this.#source.files) {
|
|
1127
|
+
const [, folder, facet, entry, nested] = this.#source.relative(fileName).match(facetEntryPattern) ?? [];
|
|
1128
|
+
if (!folder || !facet || !entry)
|
|
1129
|
+
continue;
|
|
1130
|
+
const found = entries.get(folder) ?? { facet, files: new Set, dirs: new Set };
|
|
1131
|
+
(nested ? found.dirs : found.files).add(entry);
|
|
1132
|
+
entries.set(folder, found);
|
|
1133
|
+
}
|
|
1134
|
+
this.#barrels = new Map([...entries].map(([folder, { facet, files, dirs }]) => [
|
|
1135
|
+
folder,
|
|
1136
|
+
facetBarrelNamesOf(facet, [...files], [...dirs]).map((name) => `${folder}/${name}`)
|
|
1137
|
+
]));
|
|
1098
1138
|
}
|
|
1099
|
-
return
|
|
1139
|
+
return this.#modulesAt(path).length ? undefined : this.#barrels.get(path);
|
|
1100
1140
|
}
|
|
1101
1141
|
declares(owner, name) {
|
|
1102
1142
|
const declaring = declaringPatternOf(name, true);
|
|
@@ -1157,7 +1197,9 @@ export
|
|
|
1157
1197
|
}
|
|
1158
1198
|
|
|
1159
1199
|
// pkgs/@akanjs/language/adaptorResolver.ts
|
|
1160
|
-
var
|
|
1200
|
+
var packageOf = (specifier) => specifier.split("/").slice(0, specifier.startsWith("@") ? 2 : 1).join("/");
|
|
1201
|
+
var packageKeyOf = ({ name, from }) => `${packageOf(from)}
|
|
1202
|
+
${name}`;
|
|
1161
1203
|
|
|
1162
1204
|
class AdaptorResolver {
|
|
1163
1205
|
#source;
|
|
@@ -1248,8 +1290,6 @@ ${field}`))
|
|
|
1248
1290
|
return own.find((adaptor) => adaptor.fileName === fileName) ?? first;
|
|
1249
1291
|
if (own.length === 1)
|
|
1250
1292
|
return first;
|
|
1251
|
-
if (!this.#resolver.hasModule(path))
|
|
1252
|
-
return own.find((adaptor) => this.#source.relative(adaptor.fileName).startsWith(`${path}/`)) ?? first;
|
|
1253
1293
|
const exported = this.#exportedAt(name, path, new Set).filter((item) => first || ("fact" in item));
|
|
1254
1294
|
const [only] = exported;
|
|
1255
1295
|
if (only)
|
|
@@ -1259,7 +1299,7 @@ ${field}`))
|
|
|
1259
1299
|
#exportedAt(name, path, seen) {
|
|
1260
1300
|
const key = `${path}
|
|
1261
1301
|
${name}`;
|
|
1262
|
-
if (seen.has(key)
|
|
1302
|
+
if (seen.has(key))
|
|
1263
1303
|
return [];
|
|
1264
1304
|
seen.add(key);
|
|
1265
1305
|
const here = (this.#adaptors.get(name) ?? []).filter((adaptor) => {
|
|
@@ -1275,25 +1315,26 @@ ${name}`;
|
|
|
1275
1315
|
const target = named.from === null ? path : this.#resolver.pathOfSpecifier(named.fileName, named.from);
|
|
1276
1316
|
return target === null ? [] : this.#exportedAt(named.name, target, seen);
|
|
1277
1317
|
}
|
|
1278
|
-
|
|
1318
|
+
const reached = stars.flatMap((star) => this.#exportedAt(name, star, seen));
|
|
1319
|
+
return [...new Map(reached.map((item) => ["fact" in item ? item.id : packageKeyOf(item), item])).values()];
|
|
1279
1320
|
}
|
|
1280
1321
|
#packageAdaptorOf(name, specifier) {
|
|
1281
1322
|
if (frameworkPattern.test(specifier))
|
|
1282
1323
|
return this.#sink.addNode(this.#sink.key("adaptor", null, name), "adaptor", null, name, null, [frameworkOwner]).id;
|
|
1283
|
-
const pkg =
|
|
1324
|
+
const pkg = packageOf(specifier);
|
|
1284
1325
|
return this.#sink.addNode(this.#sink.key("adaptor", pkg, name), "adaptor", null, name, null, [pkg]).id;
|
|
1285
1326
|
}
|
|
1286
1327
|
#packageShimOf(owner, name, near) {
|
|
1287
|
-
|
|
1288
|
-
const [shim] = reexport?.site.imports ?? [];
|
|
1289
|
-
if (reexport && shim && this.#resolver.pathOfSpecifier(reexport.site.fileName, shim.from) === null)
|
|
1290
|
-
return { name: reexport.local === "default" ? name : reexport.local, from: shim.from };
|
|
1291
|
-
if (reexport || !near)
|
|
1328
|
+
if (!near)
|
|
1292
1329
|
return null;
|
|
1293
|
-
const
|
|
1330
|
+
const shims = this.#exportedAt(name, near, new Set).filter((item) => !("fact" in item));
|
|
1331
|
+
const [shim] = shims;
|
|
1332
|
+
if (shim)
|
|
1333
|
+
return shims.length === 1 ? shim : null;
|
|
1334
|
+
const { packages, paths } = this.#resolver.starExportsOf(owner, near);
|
|
1294
1335
|
const [only] = packages;
|
|
1295
|
-
const isDeclared =
|
|
1296
|
-
return packages.
|
|
1336
|
+
const isDeclared = paths.some((path) => this.#resolver.declaresAt(path, name));
|
|
1337
|
+
return only && new Set(packages.map(packageOf)).size === 1 && !isDeclared ? { name, from: only } : null;
|
|
1297
1338
|
}
|
|
1298
1339
|
#nodeOf({ fact, owner, fileName, id }) {
|
|
1299
1340
|
const detail = fact.refName ? [fact.refName] : [];
|
|
@@ -1328,6 +1369,7 @@ var PAGE_ROUTE_EXPORTS = new Set([
|
|
|
1328
1369
|
"guard"
|
|
1329
1370
|
]);
|
|
1330
1371
|
var LAYOUT_ROUTE_EXPORTS = new Set([...PAGE_ROUTE_EXPORTS, "NotFound", "Error"]);
|
|
1372
|
+
var GENERATED_ROOT_LAYOUT_EXPORTS = new Set(["McpAppRoot", "LevelBoundary"]);
|
|
1331
1373
|
var ROOT_LAYOUT_ROUTE_EXPORTS = new Set([
|
|
1332
1374
|
...LAYOUT_ROUTE_EXPORTS,
|
|
1333
1375
|
"fonts",
|
|
@@ -1337,8 +1379,7 @@ var ROOT_LAYOUT_ROUTE_EXPORTS = new Set([
|
|
|
1337
1379
|
"wsConnect",
|
|
1338
1380
|
"layoutStyle",
|
|
1339
1381
|
"viewport",
|
|
1340
|
-
|
|
1341
|
-
"LevelBoundary"
|
|
1382
|
+
...GENERATED_ROOT_LAYOUT_EXPORTS
|
|
1342
1383
|
]);
|
|
1343
1384
|
var RESERVED_ROUTE_CONFIG_EXPORTS = new Set([...ROOT_LAYOUT_ROUTE_EXPORTS].filter((name) => name !== "default" && !/^[A-Z]/.test(name)));
|
|
1344
1385
|
function parseRouteModuleKey(key) {
|