@mxpicture/build-api 0.2.106 → 0.3.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/code/code.fix.d.ts.map +1 -1
- package/dist/code/code.fix.js.map +1 -1
- package/dist/exp/ExportsFinder.d.ts +6 -14
- package/dist/exp/ExportsFinder.d.ts.map +1 -1
- package/dist/exp/ExportsFinder.js +27 -87
- package/dist/exp/ExportsFinder.js.map +1 -1
- package/dist/exp/ExportsFinderBag.d.ts +0 -5
- package/dist/exp/ExportsFinderBag.d.ts.map +1 -1
- package/dist/exp/ExportsFinderBag.js +0 -13
- package/dist/exp/ExportsFinderBag.js.map +1 -1
- package/dist/exp/exports.finder.d.ts +13 -0
- package/dist/exp/exports.finder.d.ts.map +1 -0
- package/dist/exp/exports.finder.js +20 -0
- package/dist/exp/exports.finder.js.map +1 -0
- package/dist/exp/exports.key.d.ts.map +1 -1
- package/dist/exp/exports.key.js +0 -1
- package/dist/exp/exports.key.js.map +1 -1
- package/dist/exp/exports.node.d.ts +2 -0
- package/dist/exp/exports.node.d.ts.map +1 -1
- package/dist/exp/exports.node.js +20 -1
- package/dist/exp/exports.node.js.map +1 -1
- package/dist/exp/exports.package.d.ts +3 -1
- package/dist/exp/exports.package.d.ts.map +1 -1
- package/dist/exp/exports.package.js +15 -0
- package/dist/exp/exports.package.js.map +1 -1
- package/dist/exp/exports.requested.d.ts +6 -0
- package/dist/exp/exports.requested.d.ts.map +1 -0
- package/dist/exp/exports.requested.js +11 -0
- package/dist/exp/exports.requested.js.map +1 -0
- package/dist/exp/index.d.ts +2 -0
- package/dist/exp/index.d.ts.map +1 -1
- package/dist/exp/index.js +2 -0
- package/dist/exp/index.js.map +1 -1
- package/dist/types/types.exports.d.ts +4 -1
- package/dist/types/types.exports.d.ts.map +1 -1
- package/dist/types/types.exports.js.map +1 -1
- package/package.json +4 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"code.fix.d.ts","sourceRoot":"","sources":["../../src/code/code.fix.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,YAAY,GAAU,MAAM,MAAM,
|
|
1
|
+
{"version":3,"file":"code.fix.d.ts","sourceRoot":"","sources":["../../src/code/code.fix.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,YAAY,GAAU,MAAM,MAAM,oBAiB9C,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"code.fix.js","sourceRoot":"","sources":["../../src/code/code.fix.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAEhC,MAAM,CAAC,MAAM,YAAY,GAAG,KAAK,EAAE,IAAY,EAAE,EAAE;IACjD,MAAM,MAAM,GAAG,IAAI,MAAM,CAAC;QACxB,GAAG,EAAE,IAAI;QACT,cAAc,EAAE;YACd,eAAe,EAAE;gBACf,MAAM,EAAE,CAAC,MAAM,MAAM,CAAC,2BAA2B,CAAC,CAAC,CAAC,OAAO;gBAC3D,aAAa,EAAE;oBACb,WAAW,EAAE,QAAQ;oBACrB,UAAU,EAAE,QAAQ;iBACrB;aACF;SACF;KACF,CAAC,CAAC;IAEH,MAAM,CAAC,MAAM,CAAC,GAAG,MAAM,MAAM,CAAC,QAAQ,CAAC,IAAI,EAAE,EAAE,WAAW,EAAE,IAAI,EAAE,CAAC,CAAC;
|
|
1
|
+
{"version":3,"file":"code.fix.js","sourceRoot":"","sources":["../../src/code/code.fix.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAEhC,MAAM,CAAC,MAAM,YAAY,GAAG,KAAK,EAAE,IAAY,EAAE,EAAE;IACjD,MAAM,MAAM,GAAG,IAAI,MAAM,CAAC;QACxB,GAAG,EAAE,IAAI;QACT,cAAc,EAAE;YACd,eAAe,EAAE;gBACf,MAAM,EAAE,CAAC,MAAM,MAAM,CAAC,2BAA2B,CAAC,CAAC,CAAC,OAAO;gBAC3D,aAAa,EAAE;oBACb,WAAW,EAAE,QAAQ;oBACrB,UAAU,EAAE,QAAQ;iBACrB;aACF;SACF;KACF,CAAC,CAAC;IAEH,MAAM,CAAC,MAAM,CAAC,GAAG,MAAM,MAAM,CAAC,QAAQ,CAAC,IAAI,EAAE,EAAE,WAAW,EAAE,IAAI,EAAE,CAAC,CAAC;IAEpE,OAAO,MAAM,CAAC,MAAM,IAAI,IAAI,CAAC;AAC/B,CAAC,CAAC","sourcesContent":["import { ESLint } from \"eslint\";\n\nexport const fixCodeTypes = async (code: string) => {\n const eslint = new ESLint({\n fix: true,\n overrideConfig: {\n languageOptions: {\n parser: (await import(\"@typescript-eslint/parser\")).default,\n parserOptions: {\n ecmaVersion: \"latest\",\n sourceType: \"module\",\n },\n },\n },\n });\n\n const [result] = await eslint.lintText(code, { warnIgnored: true });\n\n return result.output ?? code;\n};\n"]}
|
|
@@ -1,15 +1,5 @@
|
|
|
1
|
-
import type { ExportNodeTyped, ExportsCommonExcludes, PackageAPI } from "../types/types.exports.js";
|
|
1
|
+
import type { ExportNodeTyped, ExportsCommonExcludes, ExportsRequested, PackageAPI } from "../types/types.exports.js";
|
|
2
2
|
import { ExportsFinderBag } from "./ExportsFinderBag.js";
|
|
3
|
-
/**
|
|
4
|
-
* Retrieve (or lazily create) an {@link ExportsFinder} for the given JSON file.
|
|
5
|
-
*
|
|
6
|
-
* @remarks
|
|
7
|
-
* Results are cached by file path; subsequent calls return the same instance.
|
|
8
|
-
*
|
|
9
|
-
* @param jsonFilePath - Path to a JSON exports file.
|
|
10
|
-
* @returns A promise resolving to the cached {@link ExportsFinder}.
|
|
11
|
-
*/
|
|
12
|
-
export declare const exportsFinder: (jsonFilePath: string, excludes?: ExportsCommonExcludes) => Promise<ExportsFinder>;
|
|
13
3
|
/**
|
|
14
4
|
* Lookup index for typed export nodes across multiple packages.
|
|
15
5
|
*
|
|
@@ -20,7 +10,7 @@ export declare const exportsFinder: (jsonFilePath: string, excludes?: ExportsCom
|
|
|
20
10
|
export declare class ExportsFinder {
|
|
21
11
|
readonly bag: ExportsFinderBag;
|
|
22
12
|
protected _predictedBag: ExportsFinderBag | null;
|
|
23
|
-
protected
|
|
13
|
+
protected _requesteds: ExportsRequested[];
|
|
24
14
|
/**
|
|
25
15
|
* Build a finder from an array of {@link PackageAPI} objects.
|
|
26
16
|
*
|
|
@@ -38,12 +28,14 @@ export declare class ExportsFinder {
|
|
|
38
28
|
* Mark an export as requested.
|
|
39
29
|
*
|
|
40
30
|
* @param name - Export name to flag.
|
|
41
|
-
* @throws Error if the export is not found.
|
|
42
31
|
*/
|
|
43
32
|
request(name: string): void;
|
|
33
|
+
protected validateRequested(req: ExportsRequested): ExportsRequested;
|
|
44
34
|
activatePrediction(bag?: ExportsFinderBag): void;
|
|
45
35
|
addPrediction(node: ExportNodeTyped): void;
|
|
46
|
-
|
|
36
|
+
validate(): void;
|
|
37
|
+
get requesteds(): ExportsRequested[];
|
|
38
|
+
requested(name: string, isValid?: boolean): ExportsRequested | null;
|
|
47
39
|
/**
|
|
48
40
|
* Create a deep copy of this finder.
|
|
49
41
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ExportsFinder.d.ts","sourceRoot":"","sources":["../../src/exp/ExportsFinder.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"ExportsFinder.d.ts","sourceRoot":"","sources":["../../src/exp/ExportsFinder.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,eAAe,EACf,qBAAqB,EACrB,gBAAgB,EAChB,UAAU,EACX,MAAM,2BAA2B,CAAC;AAGnC,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAEzD;;;;;;GAMG;AACH,qBAAa,aAAa;IACxB,SAAgB,GAAG,EAAE,gBAAgB,CAAC;IACtC,SAAS,CAAC,aAAa,EAAE,gBAAgB,GAAG,IAAI,CAAQ;IACxD,SAAS,CAAC,WAAW,EAAE,gBAAgB,EAAE,CAAM;IAE/C;;;;OAIG;WACW,YAAY,CACxB,IAAI,EAAE,UAAU,EAAE,EAClB,QAAQ,CAAC,EAAE,qBAAqB,GAC/B,aAAa;IAMhB;;;;OAIG;WACW,aAAa,CACzB,KAAK,EAAE,GAAG,CAAC,MAAM,EAAE,eAAe,CAAC,GAAG,gBAAgB,EACtD,SAAS,CAAC,EAAE,GAAG,CAAC,MAAM,EAAE,eAAe,CAAC,GAAG,gBAAgB,GAAG,IAAI,GACjE,aAAa;IAgBhB,SAAS,aAAa,GAAG,EAAE,gBAAgB;IAI3C;;;;OAIG;IACI,OAAO,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI;IAIlC,SAAS,CAAC,iBAAiB,CAAC,GAAG,EAAE,gBAAgB,GAAG,gBAAgB;IAI7D,kBAAkB,CAAC,GAAG,CAAC,EAAE,gBAAgB;IAIzC,aAAa,CAAC,IAAI,EAAE,eAAe,GAAG,IAAI;IAK1C,QAAQ,IAAI,IAAI;IAmBvB,IAAW,UAAU,IAAI,gBAAgB,EAAE,CAE1C;IAEM,SAAS,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,OAAO,GAAG,gBAAgB,GAAG,IAAI;IAQ1E;;;;OAIG;IACI,KAAK,IAAI,aAAa;CAG9B"}
|
|
@@ -1,56 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import { readExportsFile } from "./ExportsFile.js";
|
|
1
|
+
import { mapPackagesToTyped } from "./exports.package.js";
|
|
2
|
+
import { validateRequested } from "./exports.requested.js";
|
|
4
3
|
import { ExportsFinderBag } from "./ExportsFinderBag.js";
|
|
5
|
-
const __finders = {};
|
|
6
|
-
/**
|
|
7
|
-
* Retrieve (or lazily create) an {@link ExportsFinder} for the given JSON file.
|
|
8
|
-
*
|
|
9
|
-
* @remarks
|
|
10
|
-
* Results are cached by file path; subsequent calls return the same instance.
|
|
11
|
-
*
|
|
12
|
-
* @param jsonFilePath - Path to a JSON exports file.
|
|
13
|
-
* @returns A promise resolving to the cached {@link ExportsFinder}.
|
|
14
|
-
*/
|
|
15
|
-
export const exportsFinder = async (jsonFilePath, excludes) => {
|
|
16
|
-
if (!__finders[jsonFilePath]) {
|
|
17
|
-
const pkgs = await readExportsFile(jsonFilePath);
|
|
18
|
-
__finders[jsonFilePath] = ExportsFinder.createByPkgs(pkgs, excludes);
|
|
19
|
-
}
|
|
20
|
-
return __finders[jsonFilePath];
|
|
21
|
-
};
|
|
22
|
-
const mapNodesToTyped = (packageName, type, target, nodeItems, excludePackageJson) => {
|
|
23
|
-
for (const node of nodeItems) {
|
|
24
|
-
if (excludePackageJson && matchesNode(node, packageJsonPattern))
|
|
25
|
-
continue;
|
|
26
|
-
const current = {
|
|
27
|
-
...node,
|
|
28
|
-
type,
|
|
29
|
-
packageName,
|
|
30
|
-
};
|
|
31
|
-
const found = target.get(node.name);
|
|
32
|
-
if (found) {
|
|
33
|
-
if (!exportNodeEquals(current, found))
|
|
34
|
-
throw new Error(`Duplicate export name ${node.name}`);
|
|
35
|
-
continue;
|
|
36
|
-
}
|
|
37
|
-
target.set(node.name, current);
|
|
38
|
-
}
|
|
39
|
-
return target;
|
|
40
|
-
};
|
|
41
|
-
const mapPackageToTyped = (target, pkg, excludes) => {
|
|
42
|
-
const runtimeExports = structuredClone(pkg.runtimeExports);
|
|
43
|
-
const typeExports = structuredClone(pkg.typeExports);
|
|
44
|
-
removeKnownDuplicateNodes(runtimeExports, typeExports);
|
|
45
|
-
mapNodesToTyped(pkg.packageName, ExportNodeType.type, target, typeExports, excludes?.excludePackageJson);
|
|
46
|
-
mapNodesToTyped(pkg.packageName, ExportNodeType.runtime, target, runtimeExports, excludes?.excludePackageJson);
|
|
47
|
-
return target;
|
|
48
|
-
};
|
|
49
|
-
const mapPackagesToTyped = (target, pkgs, excludes) => {
|
|
50
|
-
for (const pkg of pkgs)
|
|
51
|
-
mapPackageToTyped(target, pkg, excludes);
|
|
52
|
-
return target;
|
|
53
|
-
};
|
|
54
4
|
/**
|
|
55
5
|
* Lookup index for typed export nodes across multiple packages.
|
|
56
6
|
*
|
|
@@ -61,7 +11,7 @@ const mapPackagesToTyped = (target, pkgs, excludes) => {
|
|
|
61
11
|
export class ExportsFinder {
|
|
62
12
|
bag;
|
|
63
13
|
_predictedBag = null;
|
|
64
|
-
|
|
14
|
+
_requesteds = [];
|
|
65
15
|
/**
|
|
66
16
|
* Build a finder from an array of {@link PackageAPI} objects.
|
|
67
17
|
*
|
|
@@ -92,25 +42,12 @@ export class ExportsFinder {
|
|
|
92
42
|
* Mark an export as requested.
|
|
93
43
|
*
|
|
94
44
|
* @param name - Export name to flag.
|
|
95
|
-
* @throws Error if the export is not found.
|
|
96
45
|
*/
|
|
97
46
|
request(name) {
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
}
|
|
103
|
-
catch (error) {
|
|
104
|
-
if (!this._predictedBag)
|
|
105
|
-
throw error;
|
|
106
|
-
}
|
|
107
|
-
// check/add prediction (predict bag)
|
|
108
|
-
try {
|
|
109
|
-
this._predictedBag.update({ name, requested: true });
|
|
110
|
-
}
|
|
111
|
-
catch {
|
|
112
|
-
this._requestedPredictedNames.push(name);
|
|
113
|
-
}
|
|
47
|
+
this._requesteds.push(this.validateRequested({ name }));
|
|
48
|
+
}
|
|
49
|
+
validateRequested(req) {
|
|
50
|
+
return validateRequested(req, this.bag, this._predictedBag);
|
|
114
51
|
}
|
|
115
52
|
activatePrediction(bag) {
|
|
116
53
|
this._predictedBag ??= bag ?? new ExportsFinderBag();
|
|
@@ -121,25 +58,28 @@ export class ExportsFinder {
|
|
|
121
58
|
if (!this._predictedBag.has(node.name))
|
|
122
59
|
this._predictedBag.add(node);
|
|
123
60
|
}
|
|
124
|
-
|
|
125
|
-
|
|
61
|
+
validate() {
|
|
62
|
+
for (const req of this._requesteds)
|
|
63
|
+
this.validateRequested(req);
|
|
64
|
+
const invalids = this._requesteds.filter((req) => !req.valid);
|
|
65
|
+
if (invalids.length === 0)
|
|
126
66
|
return;
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
for (const name of this._requestedPredictedNames) {
|
|
136
|
-
if (firsts.length < 3)
|
|
137
|
-
firsts.push(name);
|
|
138
|
-
else
|
|
139
|
-
others.push(name);
|
|
140
|
-
}
|
|
141
|
-
throw new Error(`Predicted names missing: ${firsts.join(", ")}${others.length > 0 ? ", ..." : ""}`);
|
|
67
|
+
// throw error, not all predicted names were provided
|
|
68
|
+
const firsts = [];
|
|
69
|
+
const others = [];
|
|
70
|
+
for (const { name } of invalids) {
|
|
71
|
+
if (firsts.length < 3)
|
|
72
|
+
firsts.push(name);
|
|
73
|
+
else
|
|
74
|
+
others.push(name);
|
|
142
75
|
}
|
|
76
|
+
throw new Error(`Predicted names missing: ${firsts.join(", ")}${others.length > 0 ? ", ..." : ""}`);
|
|
77
|
+
}
|
|
78
|
+
get requesteds() {
|
|
79
|
+
return this._requesteds;
|
|
80
|
+
}
|
|
81
|
+
requested(name, isValid) {
|
|
82
|
+
return (this._requesteds.find((req) => req.name === name && (!isValid || req.valid === true)) ?? null);
|
|
143
83
|
}
|
|
144
84
|
/**
|
|
145
85
|
* Create a deep copy of this finder.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ExportsFinder.js","sourceRoot":"","sources":["../../src/exp/ExportsFinder.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAC;AAOzD,OAAO,EACL,WAAW,EACX,kBAAkB,EAClB,gBAAgB,EAChB,yBAAyB,GAC1B,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AACnD,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAEzD,MAAM,SAAS,GAAkC,EAAE,CAAC;AAEpD;;;;;;;;GAQG;AACH,MAAM,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;QACjD,IAAI,CAAC,wBAAwB,CAAC,MAAM,GAAG,CAAC,CAAC;QAEzC,KAAK,MAAM,IAAI,IAAI,KAAK;YAAE,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;QAE7C,IAAI,IAAI,CAAC,wBAAwB,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YAC7C,qDAAqD;YACrD,MAAM,MAAM,GAAa,EAAE,CAAC;YAC5B,MAAM,MAAM,GAAa,EAAE,CAAC;YAE5B,KAAK,MAAM,IAAI,IAAI,IAAI,CAAC,wBAAwB,EAAE,CAAC;gBACjD,IAAI,MAAM,CAAC,MAAM,GAAG,CAAC;oBAAE,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;;oBACpC,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;YACzB,CAAC;YAED,MAAM,IAAI,KAAK,CACb,4BAA4B,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,MAAM,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,EAAE,CACnF,CAAC;QACJ,CAAC;IACH,CAAC;IAED;;;;OAIG;IACI,KAAK;QACV,OAAO,aAAa,CAAC,aAAa,CAAC,IAAI,CAAC,GAAG,CAAC,KAAK,EAAE,IAAI,CAAC,aAAa,CAAC,CAAC;IACzE,CAAC;CACF","sourcesContent":["import { ExportNodeType } from \"../enum/enum.exports.js\";\nimport type {\n ExportNode,\n ExportNodeTyped,\n ExportsCommonExcludes,\n PackageAPI,\n} from \"../types/types.exports.js\";\nimport {\n matchesNode,\n packageJsonPattern,\n exportNodeEquals,\n removeKnownDuplicateNodes,\n} from \"./exports.node.js\";\nimport { readExportsFile } from \"./ExportsFile.js\";\nimport { ExportsFinderBag } from \"./ExportsFinderBag.js\";\n\nconst __finders: Record<string, ExportsFinder> = {};\n\n/**\n * Retrieve (or lazily create) an {@link ExportsFinder} for the given JSON file.\n *\n * @remarks\n * Results are cached by file path; subsequent calls return the same instance.\n *\n * @param jsonFilePath - Path to a JSON exports file.\n * @returns A promise resolving to the cached {@link ExportsFinder}.\n */\nexport const exportsFinder = async (\n jsonFilePath: string,\n excludes?: ExportsCommonExcludes,\n) => {\n if (!__finders[jsonFilePath]) {\n const pkgs = await readExportsFile(jsonFilePath);\n __finders[jsonFilePath] = ExportsFinder.createByPkgs(pkgs, excludes);\n }\n return __finders[jsonFilePath];\n};\n\nconst mapNodesToTyped = (\n packageName: string,\n type: ExportNodeType,\n target: Map<string, ExportNodeTyped>,\n nodeItems: ExportNode[],\n excludePackageJson?: boolean,\n): Map<string, ExportNodeTyped> => {\n for (const node of nodeItems) {\n if (excludePackageJson && matchesNode(node, packageJsonPattern)) continue;\n\n const current: ExportNodeTyped = {\n ...node,\n type,\n packageName,\n };\n\n const found = target.get(node.name);\n if (found) {\n if (!exportNodeEquals(current, found))\n throw new Error(`Duplicate export name ${node.name}`);\n continue;\n }\n\n target.set(node.name, current);\n }\n return target;\n};\n\nconst mapPackageToTyped = (\n target: Map<string, ExportNodeTyped>,\n pkg: PackageAPI,\n excludes?: ExportsCommonExcludes,\n): Map<string, ExportNodeTyped> => {\n const runtimeExports = structuredClone(pkg.runtimeExports);\n const typeExports = structuredClone(pkg.typeExports);\n removeKnownDuplicateNodes(runtimeExports, typeExports);\n\n mapNodesToTyped(\n pkg.packageName,\n ExportNodeType.type,\n target,\n typeExports,\n excludes?.excludePackageJson,\n );\n\n mapNodesToTyped(\n pkg.packageName,\n ExportNodeType.runtime,\n target,\n runtimeExports,\n excludes?.excludePackageJson,\n );\n return target;\n};\n\nconst mapPackagesToTyped = (\n target: Map<string, ExportNodeTyped>,\n pkgs: PackageAPI[],\n excludes?: ExportsCommonExcludes,\n): Map<string, ExportNodeTyped> => {\n for (const pkg of pkgs) mapPackageToTyped(target, pkg, excludes);\n return target;\n};\n\n/**\n * Lookup index for typed export nodes across multiple packages.\n *\n * @remarks\n * Provides O(1) access to export metadata by name and supports marking\n * specific exports as \"requested\" for downstream code-generation steps.\n */\nexport class ExportsFinder {\n public readonly bag: ExportsFinderBag;\n protected _predictedBag: ExportsFinderBag | null = null;\n protected _requestedPredictedNames: string[] = [];\n\n /**\n * Build a finder from an array of {@link PackageAPI} objects.\n *\n * @param pkgs - Packages whose exports are indexed.\n */\n public static createByPkgs(\n pkgs: PackageAPI[],\n excludes?: ExportsCommonExcludes,\n ): ExportsFinder {\n return new ExportsFinder(\n new ExportsFinderBag(mapPackagesToTyped(new Map(), pkgs, excludes)),\n );\n }\n\n /**\n * Build a finder from a pre-built node map (deep-cloned).\n *\n * @param nodes - Map of export names to typed nodes.\n */\n public static createByNodes(\n nodes: Map<string, ExportNodeTyped> | ExportsFinderBag,\n predicted?: Map<string, ExportNodeTyped> | ExportsFinderBag | null,\n ): ExportsFinder {\n const finder = new ExportsFinder(\n nodes instanceof ExportsFinderBag\n ? nodes\n : new ExportsFinderBag(structuredClone(nodes)),\n );\n\n if (predicted)\n finder.activatePrediction(\n predicted instanceof ExportsFinderBag\n ? predicted\n : new ExportsFinderBag(structuredClone(predicted)),\n );\n return finder;\n }\n\n protected constructor(bag: ExportsFinderBag) {\n this.bag = bag;\n }\n\n /**\n * Mark an export as requested.\n *\n * @param name - Export name to flag.\n * @throws Error if the export is not found.\n */\n public request(name: string): void {\n // check bag (main)\n try {\n this.bag.update({ name, requested: true });\n return;\n } catch (error) {\n if (!this._predictedBag) throw error;\n }\n\n // check/add prediction (predict bag)\n try {\n this._predictedBag.update({ name, requested: true });\n } catch {\n this._requestedPredictedNames.push(name);\n }\n }\n\n public activatePrediction(bag?: ExportsFinderBag) {\n this._predictedBag ??= bag ?? new ExportsFinderBag();\n }\n\n public addPrediction(node: ExportNodeTyped): void {\n if (!this._predictedBag) this._predictedBag = new ExportsFinderBag();\n if (!this._predictedBag.has(node.name)) this._predictedBag.add(node);\n }\n\n public validatePrediction(): void {\n if (!this._predictedBag) return;\n const names = [...this._requestedPredictedNames];\n this._requestedPredictedNames.length = 0;\n\n for (const name of names) this.request(name);\n\n if (this._requestedPredictedNames.length > 0) {\n // throw error, not all predicted names were provided\n const firsts: string[] = [];\n const others: string[] = [];\n\n for (const name of this._requestedPredictedNames) {\n if (firsts.length < 3) firsts.push(name);\n else others.push(name);\n }\n\n throw new Error(\n `Predicted names missing: ${firsts.join(\", \")}${others.length > 0 ? \", ...\" : \"\"}`,\n );\n }\n }\n\n /**\n * Create a deep copy of this finder.\n *\n * prediction bag is not cloned --> needed for collecting\n */\n public clone(): ExportsFinder {\n return ExportsFinder.createByNodes(this.bag.nodes, this._predictedBag);\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"ExportsFinder.js","sourceRoot":"","sources":["../../src/exp/ExportsFinder.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAC1D,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAC3D,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAEzD;;;;;;GAMG;AACH,MAAM,OAAO,aAAa;IACR,GAAG,CAAmB;IAC5B,aAAa,GAA4B,IAAI,CAAC;IAC9C,WAAW,GAAuB,EAAE,CAAC;IAE/C;;;;OAIG;IACI,MAAM,CAAC,YAAY,CACxB,IAAkB,EAClB,QAAgC;QAEhC,OAAO,IAAI,aAAa,CACtB,IAAI,gBAAgB,CAAC,kBAAkB,CAAC,IAAI,GAAG,EAAE,EAAE,IAAI,EAAE,QAAQ,CAAC,CAAC,CACpE,CAAC;IACJ,CAAC;IAED;;;;OAIG;IACI,MAAM,CAAC,aAAa,CACzB,KAAsD,EACtD,SAAkE;QAElE,MAAM,MAAM,GAAG,IAAI,aAAa,CAC9B,KAAK,YAAY,gBAAgB;YAC/B,CAAC,CAAC,KAAK;YACP,CAAC,CAAC,IAAI,gBAAgB,CAAC,eAAe,CAAC,KAAK,CAAC,CAAC,CACjD,CAAC;QAEF,IAAI,SAAS;YACX,MAAM,CAAC,k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AAM,MAAM,GAAa,EAAE,CAAC;QAC5B,MAAM,MAAM,GAAa,EAAE,CAAC;QAE5B,KAAK,MAAM,EAAE,IAAI,EAAE,IAAI,QAAQ,EAAE,CAAC;YAChC,IAAI,MAAM,CAAC,MAAM,GAAG,CAAC;gBAAE,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;;gBACpC,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QACzB,CAAC;QAED,MAAM,IAAI,KAAK,CACb,4BAA4B,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,MAAM,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,EAAE,CACnF,CAAC;IACJ,CAAC;IAED,IAAW,UAAU;QACnB,OAAO,IAAI,CAAC,WAAW,CAAC;IAC1B,CAAC;IAEM,SAAS,CAAC,IAAY,EAAE,OAAiB;QAC9C,OAAO,CACL,IAAI,CAAC,WAAW,CAAC,IAAI,CACnB,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,CAAC,IAAI,KAAK,IAAI,IAAI,CAAC,CAAC,OAAO,IAAI,GAAG,CAAC,KAAK,KAAK,IAAI,CAAC,CAC/D,IAAI,IAAI,CACV,CAAC;IACJ,CAAC;IAED;;;;OAIG;IACI,KAAK;QACV,OAAO,aAAa,CAAC,aAAa,CAAC,IAAI,CAAC,GAAG,CAAC,KAAK,EAAE,IAAI,CAAC,aAAa,CAAC,CAAC;IACzE,CAAC;CACF","sourcesContent":["import type {\n ExportNodeTyped,\n ExportsCommonExcludes,\n ExportsRequested,\n PackageAPI,\n} from \"../types/types.exports.js\";\nimport { mapPackagesToTyped } from \"./exports.package.js\";\nimport { validateRequested } from \"./exports.requested.js\";\nimport { ExportsFinderBag } from \"./ExportsFinderBag.js\";\n\n/**\n * Lookup index for typed export nodes across multiple packages.\n *\n * @remarks\n * Provides O(1) access to export metadata by name and supports marking\n * specific exports as \"requested\" for downstream code-generation steps.\n */\nexport class ExportsFinder {\n public readonly bag: ExportsFinderBag;\n protected _predictedBag: ExportsFinderBag | null = null;\n protected _requesteds: ExportsRequested[] = [];\n\n /**\n * Build a finder from an array of {@link PackageAPI} objects.\n *\n * @param pkgs - Packages whose exports are indexed.\n */\n public static createByPkgs(\n pkgs: PackageAPI[],\n excludes?: ExportsCommonExcludes,\n ): ExportsFinder {\n return new ExportsFinder(\n new ExportsFinderBag(mapPackagesToTyped(new Map(), pkgs, excludes)),\n );\n }\n\n /**\n * Build a finder from a pre-built node map (deep-cloned).\n *\n * @param nodes - Map of export names to typed nodes.\n */\n public static createByNodes(\n nodes: Map<string, ExportNodeTyped> | ExportsFinderBag,\n predicted?: Map<string, ExportNodeTyped> | ExportsFinderBag | null,\n ): ExportsFinder {\n const finder = new ExportsFinder(\n nodes instanceof ExportsFinderBag\n ? nodes\n : new ExportsFinderBag(structuredClone(nodes)),\n );\n\n if (predicted)\n finder.activatePrediction(\n predicted instanceof ExportsFinderBag\n ? predicted\n : new ExportsFinderBag(structuredClone(predicted)),\n );\n return finder;\n }\n\n protected constructor(bag: ExportsFinderBag) {\n this.bag = bag;\n }\n\n /**\n * Mark an export as requested.\n *\n * @param name - Export name to flag.\n */\n public request(name: string): void {\n this._requesteds.push(this.validateRequested({ name }));\n }\n\n protected validateRequested(req: ExportsRequested): ExportsRequested {\n return validateRequested(req, this.bag, this._predictedBag);\n }\n\n public activatePrediction(bag?: ExportsFinderBag) {\n this._predictedBag ??= bag ?? new ExportsFinderBag();\n }\n\n public addPrediction(node: ExportNodeTyped): void {\n if (!this._predictedBag) this._predictedBag = new ExportsFinderBag();\n if (!this._predictedBag.has(node.name)) this._predictedBag.add(node);\n }\n\n public validate(): void {\n for (const req of this._requesteds) this.validateRequested(req);\n const invalids = this._requesteds.filter((req) => !req.valid);\n if (invalids.length === 0) return;\n\n // throw error, not all predicted names were provided\n const firsts: string[] = [];\n const others: string[] = [];\n\n for (const { name } of invalids) {\n if (firsts.length < 3) firsts.push(name);\n else others.push(name);\n }\n\n throw new Error(\n `Predicted names missing: ${firsts.join(\", \")}${others.length > 0 ? \", ...\" : \"\"}`,\n );\n }\n\n public get requesteds(): ExportsRequested[] {\n return this._requesteds;\n }\n\n public requested(name: string, isValid?: boolean): ExportsRequested | null {\n return (\n this._requesteds.find(\n (req) => req.name === name && (!isValid || req.valid === true),\n ) ?? null\n );\n }\n\n /**\n * Create a deep copy of this finder.\n *\n * prediction bag is not cloned --> needed for collecting\n */\n public clone(): ExportsFinder {\n return ExportsFinder.createByNodes(this.bag.nodes, this._predictedBag);\n }\n}\n"]}
|
|
@@ -10,9 +10,6 @@ export declare class ExportsFinderBag {
|
|
|
10
10
|
readonly nodes: Map<string, ExportNodeTyped>;
|
|
11
11
|
constructor(nodes?: Map<string, ExportNodeTyped> | null);
|
|
12
12
|
add(node: ExportNodeTyped): void;
|
|
13
|
-
update(node: Partial<ExportNodeTyped> & {
|
|
14
|
-
name: string;
|
|
15
|
-
}): ExportNodeTyped;
|
|
16
13
|
/**
|
|
17
14
|
* Look up a typed export node by name.
|
|
18
15
|
*
|
|
@@ -22,8 +19,6 @@ export declare class ExportsFinderBag {
|
|
|
22
19
|
*/
|
|
23
20
|
get(name: string): ExportNodeTyped;
|
|
24
21
|
has(name: string): boolean;
|
|
25
|
-
/** All nodes that have been marked as requested. */
|
|
26
|
-
get requested(): ExportNodeTyped[];
|
|
27
22
|
get all(): ExportNodeTyped[];
|
|
28
23
|
}
|
|
29
24
|
//# sourceMappingURL=ExportsFinderBag.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ExportsFinderBag.d.ts","sourceRoot":"","sources":["../../src/exp/ExportsFinderBag.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAC;
|
|
1
|
+
{"version":3,"file":"ExportsFinderBag.d.ts","sourceRoot":"","sources":["../../src/exp/ExportsFinderBag.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAC;AAEjE;;;;;;GAMG;AACH,qBAAa,gBAAgB;IAC3B,SAAgB,KAAK,EAAE,GAAG,CAAC,MAAM,EAAE,eAAe,CAAC,CAAC;gBAEjC,KAAK,CAAC,EAAE,GAAG,CAAC,MAAM,EAAE,eAAe,CAAC,GAAG,IAAI;IAIvD,GAAG,CAAC,IAAI,EAAE,eAAe;IAMhC;;;;;;OAMG;IACI,GAAG,CAAC,IAAI,EAAE,MAAM,GAAG,eAAe;IAMlC,GAAG,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO;IAIjC,IAAW,GAAG,IAAI,eAAe,EAAE,CAElC;CACF"}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { enrichStruct } from "./exports.common.js";
|
|
2
1
|
/**
|
|
3
2
|
* Lookup index for typed export nodes across multiple packages.
|
|
4
3
|
*
|
|
@@ -16,11 +15,6 @@ export class ExportsFinderBag {
|
|
|
16
15
|
throw new Error(`Export ${node.name} already exists`);
|
|
17
16
|
this.nodes.set(node.name, node);
|
|
18
17
|
}
|
|
19
|
-
update(node) {
|
|
20
|
-
const found = this.get(node.name);
|
|
21
|
-
enrichStruct(node, found, Object.keys(node));
|
|
22
|
-
return found;
|
|
23
|
-
}
|
|
24
18
|
/**
|
|
25
19
|
* Look up a typed export node by name.
|
|
26
20
|
*
|
|
@@ -37,13 +31,6 @@ export class ExportsFinderBag {
|
|
|
37
31
|
has(name) {
|
|
38
32
|
return this.nodes.has(name);
|
|
39
33
|
}
|
|
40
|
-
/** All nodes that have been marked as requested. */
|
|
41
|
-
get requested() {
|
|
42
|
-
return this.nodes
|
|
43
|
-
.values()
|
|
44
|
-
.filter((node) => node.requested)
|
|
45
|
-
.toArray();
|
|
46
|
-
}
|
|
47
34
|
get all() {
|
|
48
35
|
return this.nodes.values().toArray();
|
|
49
36
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ExportsFinderBag.js","sourceRoot":"","sources":["../../src/exp/ExportsFinderBag.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"ExportsFinderBag.js","sourceRoot":"","sources":["../../src/exp/ExportsFinderBag.ts"],"names":[],"mappings":"AAEA;;;;;;GAMG;AACH,MAAM,OAAO,gBAAgB;IACX,KAAK,CAA+B;IAEpD,YAAmB,KAA2C;QAC5D,IAAI,CAAC,KAAK,GAAG,KAAK,IAAI,IAAI,GAAG,EAAE,CAAC;IAClC,CAAC;IAEM,GAAG,CAAC,IAAqB;QAC9B,IAAI,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC;YACrB,MAAM,IAAI,KAAK,CAAC,UAAU,IAAI,CAAC,IAAI,iBAAiB,CAAC,CAAC;QACxD,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;IAClC,CAAC;IAED;;;;;;OAMG;IACI,GAAG,CAAC,IAAY;QACrB,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;QACnC,IAAI,CAAC,KAAK;YAAE,MAAM,IAAI,KAAK,CAAC,uBAAuB,IAAI,EAAE,CAAC,CAAC;QAC3D,OAAO,KAAK,CAAC;IACf,CAAC;IAEM,GAAG,CAAC,IAAY;QACrB,OAAO,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;IAC9B,CAAC;IAED,IAAW,GAAG;QACZ,OAAO,IAAI,CAAC,KAAK,CAAC,MAAM,EAAE,CAAC,OAAO,EAAE,CAAC;IACvC,CAAC;CACF","sourcesContent":["import type { ExportNodeTyped } from \"../types/types.exports.js\";\n\n/**\n * Lookup index for typed export nodes across multiple packages.\n *\n * @remarks\n * Provides O(1) access to export metadata by name and supports marking\n * specific exports as \"requested\" for downstream code-generation steps.\n */\nexport class ExportsFinderBag {\n public readonly nodes: Map<string, ExportNodeTyped>;\n\n public constructor(nodes?: Map<string, ExportNodeTyped> | null) {\n this.nodes = nodes ?? new Map();\n }\n\n public add(node: ExportNodeTyped) {\n if (this.has(node.name))\n throw new Error(`Export ${node.name} already exists`);\n this.nodes.set(node.name, node);\n }\n\n /**\n * Look up a typed export node by name.\n *\n * @param name - Export name.\n * @returns The matching {@link ExportNodeTyped}.\n * @throws Error if no export matches `name`.\n */\n public get(name: string): ExportNodeTyped {\n const found = this.nodes.get(name);\n if (!found) throw new Error(`No export found for ${name}`);\n return found;\n }\n\n public has(name: string): boolean {\n return this.nodes.has(name);\n }\n\n public get all(): ExportNodeTyped[] {\n return this.nodes.values().toArray();\n }\n}\n"]}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { ExportsCommonExcludes } from "../types/types.exports.js";
|
|
2
|
+
import { ExportsFinder } from "./ExportsFinder.js";
|
|
3
|
+
/**
|
|
4
|
+
* Retrieve (or lazily create) an {@link ExportsFinder} for the given JSON file.
|
|
5
|
+
*
|
|
6
|
+
* @remarks
|
|
7
|
+
* Results are cached by file path; subsequent calls return the same instance.
|
|
8
|
+
*
|
|
9
|
+
* @param jsonFilePath - Path to a JSON exports file.
|
|
10
|
+
* @returns A promise resolving to the cached {@link ExportsFinder}.
|
|
11
|
+
*/
|
|
12
|
+
export declare const exportsFinder: (jsonFilePath: string, excludes?: ExportsCommonExcludes) => Promise<ExportsFinder>;
|
|
13
|
+
//# sourceMappingURL=exports.finder.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"exports.finder.d.ts","sourceRoot":"","sources":["../../src/exp/exports.finder.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,2BAA2B,CAAC;AAEvE,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAInD;;;;;;;;GAQG;AACH,eAAO,MAAM,aAAa,GACxB,cAAc,MAAM,EACpB,WAAW,qBAAqB,2BAOjC,CAAC"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { readExportsFile } from "./ExportsFile.js";
|
|
2
|
+
import { ExportsFinder } from "./ExportsFinder.js";
|
|
3
|
+
const __finders = {};
|
|
4
|
+
/**
|
|
5
|
+
* Retrieve (or lazily create) an {@link ExportsFinder} for the given JSON file.
|
|
6
|
+
*
|
|
7
|
+
* @remarks
|
|
8
|
+
* Results are cached by file path; subsequent calls return the same instance.
|
|
9
|
+
*
|
|
10
|
+
* @param jsonFilePath - Path to a JSON exports file.
|
|
11
|
+
* @returns A promise resolving to the cached {@link ExportsFinder}.
|
|
12
|
+
*/
|
|
13
|
+
export const exportsFinder = async (jsonFilePath, excludes) => {
|
|
14
|
+
if (!__finders[jsonFilePath]) {
|
|
15
|
+
const pkgs = await readExportsFile(jsonFilePath);
|
|
16
|
+
__finders[jsonFilePath] = ExportsFinder.createByPkgs(pkgs, excludes);
|
|
17
|
+
}
|
|
18
|
+
return __finders[jsonFilePath];
|
|
19
|
+
};
|
|
20
|
+
//# sourceMappingURL=exports.finder.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"exports.finder.js","sourceRoot":"","sources":["../../src/exp/exports.finder.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AACnD,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAEnD,MAAM,SAAS,GAAkC,EAAE,CAAC;AAEpD;;;;;;;;GAQG;AACH,MAAM,CAAC,MAAM,aAAa,GAAG,KAAK,EAChC,YAAoB,EACpB,QAAgC,EAChC,EAAE;IACF,IAAI,CAAC,SAAS,CAAC,YAAY,CAAC,EAAE,CAAC;QAC7B,MAAM,IAAI,GAAG,MAAM,eAAe,CAAC,YAAY,CAAC,CAAC;QACjD,SAAS,CAAC,YAAY,CAAC,GAAG,aAAa,CAAC,YAAY,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAC;IACvE,CAAC;IACD,OAAO,SAAS,CAAC,YAAY,CAAC,CAAC;AACjC,CAAC,CAAC","sourcesContent":["import type { ExportsCommonExcludes } from \"../types/types.exports.js\";\nimport { readExportsFile } from \"./ExportsFile.js\";\nimport { ExportsFinder } from \"./ExportsFinder.js\";\n\nconst __finders: Record<string, ExportsFinder> = {};\n\n/**\n * Retrieve (or lazily create) an {@link ExportsFinder} for the given JSON file.\n *\n * @remarks\n * Results are cached by file path; subsequent calls return the same instance.\n *\n * @param jsonFilePath - Path to a JSON exports file.\n * @returns A promise resolving to the cached {@link ExportsFinder}.\n */\nexport const exportsFinder = async (\n jsonFilePath: string,\n excludes?: ExportsCommonExcludes,\n) => {\n if (!__finders[jsonFilePath]) {\n const pkgs = await readExportsFile(jsonFilePath);\n __finders[jsonFilePath] = ExportsFinder.createByPkgs(pkgs, excludes);\n }\n return __finders[jsonFilePath];\n};\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"exports.key.d.ts","sourceRoot":"","sources":["../../src/exp/exports.key.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,UAAU,EACV,UAAU,EACV,eAAe,EACf,UAAU,EACX,MAAM,2BAA2B,CAAC;AASnC,oEAAoE;AACpE,eAAO,MAAM,cAAc,EAAgC,CAAC,MAAM,UAAU,CAAC,EAAE,CAAC;
|
|
1
|
+
{"version":3,"file":"exports.key.d.ts","sourceRoot":"","sources":["../../src/exp/exports.key.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,UAAU,EACV,UAAU,EACV,eAAe,EACf,UAAU,EACX,MAAM,2BAA2B,CAAC;AASnC,oEAAoE;AACpE,eAAO,MAAM,cAAc,EAAgC,CAAC,MAAM,UAAU,CAAC,EAAE,CAAC;AAWhF,yEAAyE;AACzE,eAAO,MAAM,mBAAmB,EAE3B,CAAC,MAAM,eAAe,CAAC,EAAE,CAAC;AAQ/B,oEAAoE;AACpE,eAAO,MAAM,cAAc,EAAgC,CAAC,MAAM,UAAU,CAAC,EAAE,CAAC;AAUhF,oEAAoE;AACpE,eAAO,MAAM,cAAc,EAAgC,CAAC,MAAM,UAAU,CAAC,EAAE,CAAC"}
|
package/dist/exp/exports.key.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"exports.key.js","sourceRoot":"","sources":["../../src/exp/exports.key.ts"],"names":[],"mappings":"AAOA,MAAM,YAAY,GAAyB;IACzC,IAAI,EAAE,SAAU;IAChB,IAAI,EAAE,SAAU;IAChB,MAAM,EAAE,SAAU;CACnB,CAAC;AACF,KAAK,YAAY,CAAC;AAElB,oEAAoE;AACpE,MAAM,CAAC,MAAM,cAAc,GAAG,MAAM,CAAC,IAAI,CAAC,YAAY,CAAyB,CAAC;AAEhF,MAAM,iBAAiB,GAA8B;IACnD,IAAI,EAAE,SAAU;IAChB,IAAI,EAAE,SAAU;IAChB,MAAM,EAAE,SAAU;IAClB,WAAW,EAAE,SAAU;IACvB,IAAI,EAAE,SAAU;
|
|
1
|
+
{"version":3,"file":"exports.key.js","sourceRoot":"","sources":["../../src/exp/exports.key.ts"],"names":[],"mappings":"AAOA,MAAM,YAAY,GAAyB;IACzC,IAAI,EAAE,SAAU;IAChB,IAAI,EAAE,SAAU;IAChB,MAAM,EAAE,SAAU;CACnB,CAAC;AACF,KAAK,YAAY,CAAC;AAElB,oEAAoE;AACpE,MAAM,CAAC,MAAM,cAAc,GAAG,MAAM,CAAC,IAAI,CAAC,YAAY,CAAyB,CAAC;AAEhF,MAAM,iBAAiB,GAA8B;IACnD,IAAI,EAAE,SAAU;IAChB,IAAI,EAAE,SAAU;IAChB,MAAM,EAAE,SAAU;IAClB,WAAW,EAAE,SAAU;IACvB,IAAI,EAAE,SAAU;CACjB,CAAC;AACF,KAAK,iBAAiB,CAAC;AAEvB,yEAAyE;AACzE,MAAM,CAAC,MAAM,mBAAmB,GAAG,MAAM,CAAC,IAAI,CAC5C,iBAAiB,CACW,CAAC;AAE/B,MAAM,YAAY,GAAyB;IACzC,EAAE,EAAE,SAAU;IACd,IAAI,EAAE,SAAU;CACjB,CAAC;AACF,KAAK,YAAY,CAAC;AAElB,oEAAoE;AACpE,MAAM,CAAC,MAAM,cAAc,GAAG,MAAM,CAAC,IAAI,CAAC,YAAY,CAAyB,CAAC;AAEhF,MAAM,YAAY,GAAyB;IACzC,WAAW,EAAE,SAAU;IACvB,WAAW,EAAE,SAAU;IACvB,cAAc,EAAE,SAAU;IAC1B,WAAW,EAAE,SAAU;CACxB,CAAC;AACF,KAAK,YAAY,CAAC;AAElB,oEAAoE;AACpE,MAAM,CAAC,MAAM,cAAc,GAAG,MAAM,CAAC,IAAI,CAAC,YAAY,CAAyB,CAAC","sourcesContent":["import type {\n EntryPoint,\n ExportNode,\n ExportNodeTyped,\n PackageAPI,\n} from \"../types/types.exports.js\";\n\nconst __exportNode: Required<ExportNode> = {\n name: undefined!,\n kind: undefined!,\n source: undefined!,\n};\nvoid __exportNode;\n\n/** Keys of the {@link ExportNode} interface, derived at runtime. */\nexport const exportNodeKeys = Object.keys(__exportNode) as (keyof ExportNode)[];\n\nconst __exportNodeTyped: Required<ExportNodeTyped> = {\n name: undefined!,\n kind: undefined!,\n source: undefined!,\n packageName: undefined!,\n type: undefined!,\n};\nvoid __exportNodeTyped;\n\n/** Keys of the {@link ExportNodeTyped} interface, derived at runtime. */\nexport const exportNodeTypedKeys = Object.keys(\n __exportNodeTyped,\n) as (keyof ExportNodeTyped)[];\n\nconst __entryPoint: Required<EntryPoint> = {\n id: undefined!,\n file: undefined!,\n};\nvoid __entryPoint;\n\n/** Keys of the {@link EntryPoint} interface, derived at runtime. */\nexport const entryPointKeys = Object.keys(__entryPoint) as (keyof EntryPoint)[];\n\nconst __packageAPI: Required<PackageAPI> = {\n packageName: undefined!,\n entrypoints: undefined!,\n runtimeExports: undefined!,\n typeExports: undefined!,\n};\nvoid __packageAPI;\n\n/** Keys of the {@link PackageAPI} interface, derived at runtime. */\nexport const packageAPIKeys = Object.keys(__packageAPI) as (keyof PackageAPI)[];\n"]}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { ExportNodeType } from "../enum/enum.exports.js";
|
|
1
2
|
import type { ExportNode, ExportNodeTyped, ExportsPattern } from "../types/types.exports.js";
|
|
2
3
|
/**
|
|
3
4
|
* Compare two {@link ExportNodeTyped} objects for equality.
|
|
@@ -18,4 +19,5 @@ export declare const removeKnownDuplicateNodes: (...nodes: ExportNode[][]) => vo
|
|
|
18
19
|
export declare const removeKnownDuplNodesMap: (nodes: Map<string, ExportNodeTyped>[]) => void;
|
|
19
20
|
export declare const removeNodes: (pattern: ExportsPattern, ...nodes: ExportNode[][]) => void;
|
|
20
21
|
export declare const removeNodesMap: (pattern: ExportsPattern, ...nodes: Map<string, ExportNodeTyped>[]) => void;
|
|
22
|
+
export declare const mapNodesToTyped: (packageName: string, type: ExportNodeType, target: Map<string, ExportNodeTyped>, nodeItems: ExportNode[], excludePackageJson?: boolean) => Map<string, ExportNodeTyped>;
|
|
21
23
|
//# sourceMappingURL=exports.node.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"exports.node.d.ts","sourceRoot":"","sources":["../../src/exp/exports.node.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,UAAU,EACV,eAAe,EACf,cAAc,EACf,MAAM,2BAA2B,CAAC;AAInC;;;;;;;;;GASG;AACH,eAAO,MAAM,gBAAgB,GAAI,GAAG,eAAe,EAAE,GAAG,eAAe,
|
|
1
|
+
{"version":3,"file":"exports.node.d.ts","sourceRoot":"","sources":["../../src/exp/exports.node.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAC;AAC9D,OAAO,KAAK,EACV,UAAU,EACV,eAAe,EACf,cAAc,EACf,MAAM,2BAA2B,CAAC;AAInC;;;;;;;;;GASG;AACH,eAAO,MAAM,gBAAgB,GAAI,GAAG,eAAe,EAAE,GAAG,eAAe,YAChB,CAAC;AAExD,eAAO,MAAM,kBAAkB,EAAE,cAEhC,CAAC;AAEF,eAAO,MAAM,WAAW,GACtB,MAAM,UAAU,EAChB,UAAU,cAAc,KACvB,OAGqE,CAAC;AAGzE,eAAO,MAAM,mBAAmB,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAItD,CAAC;AAEF,eAAO,MAAM,wBAAwB,GAAI,MAAM,MAAM,KAAG,MAAM,GAAG,IAGjD,CAAC;AAEjB,eAAO,MAAM,yBAAyB,GAAI,GAAG,OAAO,UAAU,EAAE,EAAE,KAAG,IAQpE,CAAC;AAEF,eAAO,MAAM,uBAAuB,GAClC,OAAO,GAAG,CAAC,MAAM,EAAE,eAAe,CAAC,EAAE,KACpC,IAQF,CAAC;AAEF,eAAO,MAAM,WAAW,GACtB,SAAS,cAAc,EACvB,GAAG,OAAO,UAAU,EAAE,EAAE,KACvB,IAIF,CAAC;AAEF,eAAO,MAAM,cAAc,GACzB,SAAS,cAAc,EACvB,GAAG,OAAO,GAAG,CAAC,MAAM,EAAE,eAAe,CAAC,EAAE,KACvC,IAIF,CAAC;AAEF,eAAO,MAAM,eAAe,GAC1B,aAAa,MAAM,EACnB,MAAM,cAAc,EACpB,QAAQ,GAAG,CAAC,MAAM,EAAE,eAAe,CAAC,EACpC,WAAW,UAAU,EAAE,EACvB,qBAAqB,OAAO,KAC3B,GAAG,CAAC,MAAM,EAAE,eAAe,CAoB7B,CAAC"}
|
package/dist/exp/exports.node.js
CHANGED
|
@@ -10,7 +10,7 @@ import micromatch from "micromatch";
|
|
|
10
10
|
* @param b - Second node.
|
|
11
11
|
* @returns `true` when all non-`requested` keys are equal.
|
|
12
12
|
*/
|
|
13
|
-
export const exportNodeEquals = (a, b) => !exportNodeTypedKeys.find((key) =>
|
|
13
|
+
export const exportNodeEquals = (a, b) => !exportNodeTypedKeys.find((key) => a[key] !== b[key]);
|
|
14
14
|
export const packageJsonPattern = {
|
|
15
15
|
source: "**/package.json",
|
|
16
16
|
};
|
|
@@ -56,4 +56,23 @@ export const removeNodesMap = (pattern, ...nodes) => {
|
|
|
56
56
|
if (matchesNode(node, pattern))
|
|
57
57
|
nodeItems.delete(name);
|
|
58
58
|
};
|
|
59
|
+
export const mapNodesToTyped = (packageName, type, target, nodeItems, excludePackageJson) => {
|
|
60
|
+
for (const node of nodeItems) {
|
|
61
|
+
if (excludePackageJson && matchesNode(node, packageJsonPattern))
|
|
62
|
+
continue;
|
|
63
|
+
const current = {
|
|
64
|
+
...node,
|
|
65
|
+
type,
|
|
66
|
+
packageName,
|
|
67
|
+
};
|
|
68
|
+
const found = target.get(node.name);
|
|
69
|
+
if (found) {
|
|
70
|
+
if (!exportNodeEquals(current, found))
|
|
71
|
+
throw new Error(`Duplicate export name ${node.name}`);
|
|
72
|
+
continue;
|
|
73
|
+
}
|
|
74
|
+
target.set(node.name, current);
|
|
75
|
+
}
|
|
76
|
+
return target;
|
|
77
|
+
};
|
|
59
78
|
//# sourceMappingURL=exports.node.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"exports.node.js","sourceRoot":"","sources":["../../src/exp/exports.node.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"exports.node.js","sourceRoot":"","sources":["../../src/exp/exports.node.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AACvD,OAAO,UAAU,MAAM,YAAY,CAAC;AAEpC;;;;;;;;;GASG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAC,CAAkB,EAAE,CAAkB,EAAE,EAAE,CACzE,CAAC,mBAAmB,CAAC,IAAI,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC;AAExD,MAAM,CAAC,MAAM,kBAAkB,GAAmB;IAChD,MAAM,EAAE,iBAAiB;CAC1B,CAAC;AAEF,MAAM,CAAC,MAAM,WAAW,GAAG,CACzB,IAAgB,EAChB,QAAwB,EACf,EAAE,CACX,CAAC,CAAC,QAAQ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AC,IAAI,EAAE,kBAAkB,CAAC;YAAE,SAAS;QAE1E,MAAM,OAAO,GAAoB;YAC/B,GAAG,IAAI;YACP,IAAI;YACJ,WAAW;SACZ,CAAC;QAEF,MAAM,KAAK,GAAG,MAAM,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QACpC,IAAI,KAAK,EAAE,CAAC;YACV,IAAI,CAAC,gBAAgB,CAAC,OAAO,EAAE,KAAK,CAAC;gBACnC,MAAM,IAAI,KAAK,CAAC,yBAAyB,IAAI,CAAC,IAAI,EAAE,CAAC,CAAC;YACxD,SAAS;QACX,CAAC;QAED,MAAM,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;IACjC,CAAC;IACD,OAAO,MAAM,CAAC;AAChB,CAAC,CAAC","sourcesContent":["import type { ExportNodeType } from \"../enum/enum.exports.js\";\nimport type {\n ExportNode,\n ExportNodeTyped,\n ExportsPattern,\n} from \"../types/types.exports.js\";\nimport { exportNodeTypedKeys } from \"./exports.key.js\";\nimport micromatch from \"micromatch\";\n\n/**\n * Compare two {@link ExportNodeTyped} objects for equality.\n *\n * @remarks\n * The `requested` flag is intentionally excluded from the comparison.\n *\n * @param a - First node.\n * @param b - Second node.\n * @returns `true` when all non-`requested` keys are equal.\n */\nexport const exportNodeEquals = (a: ExportNodeTyped, b: ExportNodeTyped) =>\n !exportNodeTypedKeys.find((key) => a[key] !== b[key]);\n\nexport const packageJsonPattern: ExportsPattern = {\n source: \"**/package.json\",\n};\n\nexport const matchesNode = (\n node: ExportNode,\n patterns: ExportsPattern,\n): boolean =>\n (!patterns.name || micromatch.isMatch(node.name, patterns.name)) &&\n (!patterns.kind || micromatch.isMatch(node.kind, patterns.kind)) &&\n (!patterns.source || micromatch.isMatch(node.source, patterns.source));\n\n// if both (type and runtime) found, remove second (runtime)\nexport const knownDuplicateKinds: Record<string, string> = {\n ClassDeclaration: \"function\",\n TypeAliasDeclaration: \"object\",\n enum: \"object\",\n};\n\nexport const findKnowDuplicateRuntime = (type: string): string | null =>\n Object.entries(knownDuplicateKinds).find(\n ([duplType]) => duplType === type,\n )?.[1] ?? null;\n\nexport const removeKnownDuplicateNodes = (...nodes: ExportNode[][]): void => {\n for (const nodeItems of nodes) {\n for (const node of nodeItems) {\n const runtimeKind = findKnowDuplicateRuntime(node.kind);\n if (!runtimeKind) continue;\n removeNodes({ name: node.name, kind: runtimeKind }, ...nodes);\n }\n }\n};\n\nexport const removeKnownDuplNodesMap = (\n nodes: Map<string, ExportNodeTyped>[],\n): void => {\n for (const nodeItems of nodes) {\n for (const [, node] of nodeItems) {\n const runtimeKind = findKnowDuplicateRuntime(node.kind);\n if (!runtimeKind) continue;\n removeNodesMap({ name: node.name, kind: runtimeKind }, ...nodes);\n }\n }\n};\n\nexport const removeNodes = (\n pattern: ExportsPattern,\n ...nodes: ExportNode[][]\n): void => {\n for (const nodeItems of nodes)\n for (let i = 0; i < nodeItems.length; i++)\n if (matchesNode(nodeItems[i], pattern)) nodeItems.splice(i--, 1);\n};\n\nexport const removeNodesMap = (\n pattern: ExportsPattern,\n ...nodes: Map<string, ExportNodeTyped>[]\n): void => {\n for (const nodeItems of nodes)\n for (const [name, node] of nodeItems)\n if (matchesNode(node, pattern)) nodeItems.delete(name);\n};\n\nexport const mapNodesToTyped = (\n packageName: string,\n type: ExportNodeType,\n target: Map<string, ExportNodeTyped>,\n nodeItems: ExportNode[],\n excludePackageJson?: boolean,\n): Map<string, ExportNodeTyped> => {\n for (const node of nodeItems) {\n if (excludePackageJson && matchesNode(node, packageJsonPattern)) continue;\n\n const current: ExportNodeTyped = {\n ...node,\n type,\n packageName,\n };\n\n const found = target.get(node.name);\n if (found) {\n if (!exportNodeEquals(current, found))\n throw new Error(`Duplicate export name ${node.name}`);\n continue;\n }\n\n target.set(node.name, current);\n }\n return target;\n};\n"]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { PackageAPI } from "../types/types.exports.js";
|
|
1
|
+
import type { ExportNodeTyped, ExportsCommonExcludes, PackageAPI } from "../types/types.exports.js";
|
|
2
2
|
/** Reset the resolved-package cache. */
|
|
3
3
|
export declare const clearResolvedPackage: () => void;
|
|
4
4
|
/**
|
|
@@ -31,4 +31,6 @@ export declare const enrichPackageAPI: (src: PackageAPI, tar: PackageAPI) => voi
|
|
|
31
31
|
* @returns The mutated `tars` array.
|
|
32
32
|
*/
|
|
33
33
|
export declare const enrichPackageAPIs: (_srcs: PackageAPI[], tars: PackageAPI[]) => PackageAPI[];
|
|
34
|
+
export declare const mapPackageToTyped: (target: Map<string, ExportNodeTyped>, pkg: PackageAPI, excludes?: ExportsCommonExcludes) => Map<string, ExportNodeTyped>;
|
|
35
|
+
export declare const mapPackagesToTyped: (target: Map<string, ExportNodeTyped>, pkgs: PackageAPI[], excludes?: ExportsCommonExcludes) => Map<string, ExportNodeTyped>;
|
|
34
36
|
//# sourceMappingURL=exports.package.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"exports.package.d.ts","sourceRoot":"","sources":["../../src/exp/exports.package.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"exports.package.d.ts","sourceRoot":"","sources":["../../src/exp/exports.package.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,eAAe,EACf,qBAAqB,EACrB,UAAU,EACX,MAAM,2BAA2B,CAAC;AAWnC,wCAAwC;AACxC,eAAO,MAAM,oBAAoB,YAEhC,CAAC;AAEF;;;;;;;;;GASG;AACH,eAAO,MAAM,kBAAkB,GAAI,KAAK,MAAM,KAAG,MAMhD,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,gBAAgB,GAAI,KAAK,UAAU,EAAE,KAAK,UAAU,SACzB,CAAC;AAEzC;;;;;;;;;;GAUG;AACH,eAAO,MAAM,iBAAiB,GAC5B,OAAO,UAAU,EAAE,EACnB,MAAM,UAAU,EAAE,KACjB,UAAU,EAoBZ,CAAC;AAEF,eAAO,MAAM,iBAAiB,GAC5B,QAAQ,GAAG,CAAC,MAAM,EAAE,eAAe,CAAC,EACpC,KAAK,UAAU,EACf,WAAW,qBAAqB,KAC/B,GAAG,CAAC,MAAM,EAAE,eAAe,CAqB7B,CAAC;AAEF,eAAO,MAAM,kBAAkB,GAC7B,QAAQ,GAAG,CAAC,MAAM,EAAE,eAAe,CAAC,EACpC,MAAM,UAAU,EAAE,EAClB,WAAW,qBAAqB,KAC/B,GAAG,CAAC,MAAM,EAAE,eAAe,CAG7B,CAAC"}
|
|
@@ -2,6 +2,8 @@ import { createRequire } from "node:module";
|
|
|
2
2
|
import { packageAPIKeys } from "./exports.key.js";
|
|
3
3
|
import { dirname } from "node:path";
|
|
4
4
|
import { enrichStruct } from "./exports.common.js";
|
|
5
|
+
import { ExportNodeType } from "../enum/enum.exports.js";
|
|
6
|
+
import { removeKnownDuplicateNodes, mapNodesToTyped } from "./exports.node.js";
|
|
5
7
|
const require = createRequire(import.meta.url);
|
|
6
8
|
let __resolvedPackage = {};
|
|
7
9
|
/** Reset the resolved-package cache. */
|
|
@@ -59,4 +61,17 @@ export const enrichPackageAPIs = (_srcs, tars) => {
|
|
|
59
61
|
tars.push(...srcs);
|
|
60
62
|
return tars;
|
|
61
63
|
};
|
|
64
|
+
export const mapPackageToTyped = (target, pkg, excludes) => {
|
|
65
|
+
const runtimeExports = structuredClone(pkg.runtimeExports);
|
|
66
|
+
const typeExports = structuredClone(pkg.typeExports);
|
|
67
|
+
removeKnownDuplicateNodes(runtimeExports, typeExports);
|
|
68
|
+
mapNodesToTyped(pkg.packageName, ExportNodeType.type, target, typeExports, excludes?.excludePackageJson);
|
|
69
|
+
mapNodesToTyped(pkg.packageName, ExportNodeType.runtime, target, runtimeExports, excludes?.excludePackageJson);
|
|
70
|
+
return target;
|
|
71
|
+
};
|
|
72
|
+
export const mapPackagesToTyped = (target, pkgs, excludes) => {
|
|
73
|
+
for (const pkg of pkgs)
|
|
74
|
+
mapPackageToTyped(target, pkg, excludes);
|
|
75
|
+
return target;
|
|
76
|
+
};
|
|
62
77
|
//# sourceMappingURL=exports.package.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"exports.package.js","sourceRoot":"","sources":["../../src/exp/exports.package.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"exports.package.js","sourceRoot":"","sources":["../../src/exp/exports.package.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAM5C,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AACnD,OAAO,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAC;AACzD,OAAO,EAAE,yBAAyB,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAE/E,MAAM,OAAO,GAAG,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AAE/C,IAAI,iBAAiB,GAA2B,EAAE,CAAC;AAEnD,wCAAwC;AACxC,MAAM,CAAC,MAAM,oBAAoB,GAAG,GAAG,EAAE;IACvC,iBAAiB,GAAG,EAAE,CAAC;AACzB,CAAC,CAAC;AAEF;;;;;;;;;GASG;AACH,MAAM,CAAC,MAAM,kBAAkB,GAAG,CAAC,GAAW,EAAU,EAAE;IACxD,IAAI,CAAC,iBAAiB,CAAC,GAAG,CAAC,EAAE,CAAC;QAC5B,MAAM,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC,GAAG,GAAG,eAAe,CAAC,CAAC;QACvD,iBAAiB,CAAC,GAAG,CAAC,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;IAC5C,CAAC;IACD,OAAO,iBAAiB,CAAC,GAAG,CAAC,CAAC;AAChC,CAAC,CAAC;AAEF;;;;;GA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,CAAC;IAEvD,eAAe,CACb,GAAG,CAAC,WAAW,EACf,cAAc,CAAC,IAAI,EACnB,MAAM,EACN,WAAW,EACX,QAAQ,EAAE,kBAAkB,CAC7B,CAAC;IAEF,eAAe,CACb,GAAG,CAAC,WAAW,EACf,cAAc,CAAC,OAAO,EACtB,MAAM,EACN,cAAc,EACd,QAAQ,EAAE,kBAAkB,CAC7B,CAAC;IACF,OAAO,MAAM,CAAC;AAChB,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,kBAAkB,GAAG,CAChC,MAAoC,EACpC,IAAkB,EAClB,QAAgC,EACF,EAAE;IAChC,KAAK,MAAM,GAAG,IAAI,IAAI;QAAE,iBAAiB,CAAC,MAAM,EAAE,GAAG,EAAE,QAAQ,CAAC,CAAC;IACjE,OAAO,MAAM,CAAC;AAChB,CAAC,CAAC","sourcesContent":["import { createRequire } from \"node:module\";\nimport type {\n ExportNodeTyped,\n ExportsCommonExcludes,\n PackageAPI,\n} from \"../types/types.exports.js\";\nimport { packageAPIKeys } from \"./exports.key.js\";\nimport { dirname } from \"node:path\";\nimport { enrichStruct } from \"./exports.common.js\";\nimport { ExportNodeType } from \"../enum/enum.exports.js\";\nimport { removeKnownDuplicateNodes, mapNodesToTyped } from \"./exports.node.js\";\n\nconst require = createRequire(import.meta.url);\n\nlet __resolvedPackage: Record<string, string> = {};\n\n/** Reset the resolved-package cache. */\nexport const clearResolvedPackage = () => {\n __resolvedPackage = {};\n};\n\n/**\n * Resolve the on-disk root directory of an installed NPM package.\n *\n * @remarks\n * Uses `require.resolve` to locate the package's `package.json`,\n * then returns its parent directory. Results are cached.\n *\n * @param pkg - Package name (e.g. `\"typescript\"`).\n * @returns Absolute path to the package root.\n */\nexport const resolvePackageRoot = (pkg: string): string => {\n if (!__resolvedPackage[pkg]) {\n const pkgJson = require.resolve(`${pkg}/package.json`);\n __resolvedPackage[pkg] = dirname(pkgJson);\n }\n return __resolvedPackage[pkg];\n};\n\n/**\n * Copy non-undefined fields from `src` into `tar` for a single {@link PackageAPI}.\n *\n * @param src - Source package data.\n * @param tar - Target package data (mutated in place).\n */\nexport const enrichPackageAPI = (src: PackageAPI, tar: PackageAPI) =>\n enrichStruct(src, tar, packageAPIKeys);\n\n/**\n * Merge an array of source packages into a target array.\n *\n * @remarks\n * Target entries not present in `_srcs` are removed, new source entries\n * are appended. Matching entries are enriched in place.\n *\n * @param _srcs - Source package data (deep-cloned before mutation).\n * @param tars - Target package array (mutated in place).\n * @returns The mutated `tars` array.\n */\nexport const enrichPackageAPIs = (\n _srcs: PackageAPI[],\n tars: PackageAPI[],\n): PackageAPI[] => {\n const srcs = structuredClone(_srcs);\n\n for (let tarIndex = 0; tarIndex < tars.length; tarIndex++) {\n const srcIndex = srcs.findIndex(\n (src) => src.packageName === tars[tarIndex].packageName,\n );\n // delete if not existing in src\n if (srcIndex < 0) {\n tars.splice(tarIndex, 1);\n continue;\n }\n\n enrichPackageAPI(srcs[srcIndex], tars[tarIndex]);\n srcs.splice(srcIndex, 1);\n }\n\n // reverse / add new elements\n tars.push(...srcs);\n return tars;\n};\n\nexport const mapPackageToTyped = (\n target: Map<string, ExportNodeTyped>,\n pkg: PackageAPI,\n excludes?: ExportsCommonExcludes,\n): Map<string, ExportNodeTyped> => {\n const runtimeExports = structuredClone(pkg.runtimeExports);\n const typeExports = structuredClone(pkg.typeExports);\n removeKnownDuplicateNodes(runtimeExports, typeExports);\n\n mapNodesToTyped(\n pkg.packageName,\n ExportNodeType.type,\n target,\n typeExports,\n excludes?.excludePackageJson,\n );\n\n mapNodesToTyped(\n pkg.packageName,\n ExportNodeType.runtime,\n target,\n runtimeExports,\n excludes?.excludePackageJson,\n );\n return target;\n};\n\nexport const mapPackagesToTyped = (\n target: Map<string, ExportNodeTyped>,\n pkgs: PackageAPI[],\n excludes?: ExportsCommonExcludes,\n): Map<string, ExportNodeTyped> => {\n for (const pkg of pkgs) mapPackageToTyped(target, pkg, excludes);\n return target;\n};\n"]}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { ExportsRequested } from "../types/types.exports.js";
|
|
2
|
+
import type { ExportsFinderBag } from "./ExportsFinderBag.js";
|
|
3
|
+
export declare const isRequestedValid: (name: string, ...bags: (ExportsFinderBag | null | undefined)[]) => boolean;
|
|
4
|
+
export declare const validateRequested: (req: ExportsRequested, ...bags: (ExportsFinderBag | null | undefined)[]) => ExportsRequested;
|
|
5
|
+
export declare const validateRequesteds: (reqs: ExportsRequested[], ...bags: (ExportsFinderBag | null | undefined)[]) => ExportsRequested[];
|
|
6
|
+
//# sourceMappingURL=exports.requested.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"exports.requested.d.ts","sourceRoot":"","sources":["../../src/exp/exports.requested.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,2BAA2B,CAAC;AAClE,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAE9D,eAAO,MAAM,gBAAgB,GAC3B,MAAM,MAAM,EACZ,GAAG,MAAM,CAAC,gBAAgB,GAAG,IAAI,GAAG,SAAS,CAAC,EAAE,KAC/C,OAA+C,CAAC;AAEnD,eAAO,MAAM,iBAAiB,GAC5B,KAAK,gBAAgB,EACrB,GAAG,MAAM,CAAC,gBAAgB,GAAG,IAAI,GAAG,SAAS,CAAC,EAAE,KAC/C,gBAGF,CAAC;AAEF,eAAO,MAAM,kBAAkB,GAC7B,MAAM,gBAAgB,EAAE,EACxB,GAAG,MAAM,CAAC,gBAAgB,GAAG,IAAI,GAAG,SAAS,CAAC,EAAE,KAC/C,gBAAgB,EAGlB,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export const isRequestedValid = (name, ...bags) => !!bags.find((bag) => bag?.has(name));
|
|
2
|
+
export const validateRequested = (req, ...bags) => {
|
|
3
|
+
req.valid = !!bags.find((bag) => bag?.has(req.name));
|
|
4
|
+
return req;
|
|
5
|
+
};
|
|
6
|
+
export const validateRequesteds = (reqs, ...bags) => {
|
|
7
|
+
for (const req of reqs)
|
|
8
|
+
validateRequested(req, ...bags);
|
|
9
|
+
return reqs;
|
|
10
|
+
};
|
|
11
|
+
//# sourceMappingURL=exports.requested.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"exports.requested.js","sourceRoot":"","sources":["../../src/exp/exports.requested.ts"],"names":[],"mappings":"AAGA,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAC9B,IAAY,EACZ,GAAG,IAA6C,EACvC,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,EAAE,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC;AAEnD,MAAM,CAAC,MAAM,iBAAiB,GAAG,CAC/B,GAAqB,EACrB,GAAG,IAA6C,EAC9B,EAAE;IACpB,GAAG,CAAC,KAAK,GAAG,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,EAAE,GAAG,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC;IACrD,OAAO,GAAG,CAAC;AACb,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,kBAAkB,GAAG,CAChC,IAAwB,EACxB,GAAG,IAA6C,EAC5B,EAAE;IACtB,KAAK,MAAM,GAAG,IAAI,IAAI;QAAE,iBAAiB,CAAC,GAAG,EAAE,GAAG,IAAI,CAAC,CAAC;IACxD,OAAO,IAAI,CAAC;AACd,CAAC,CAAC","sourcesContent":["import type { ExportsRequested } from \"../types/types.exports.js\";\nimport type { ExportsFinderBag } from \"./ExportsFinderBag.js\";\n\nexport const isRequestedValid = (\n name: string,\n ...bags: (ExportsFinderBag | null | undefined)[]\n): boolean => !!bags.find((bag) => bag?.has(name));\n\nexport const validateRequested = (\n req: ExportsRequested,\n ...bags: (ExportsFinderBag | null | undefined)[]\n): ExportsRequested => {\n req.valid = !!bags.find((bag) => bag?.has(req.name));\n return req;\n};\n\nexport const validateRequesteds = (\n reqs: ExportsRequested[],\n ...bags: (ExportsFinderBag | null | undefined)[]\n): ExportsRequested[] => {\n for (const req of reqs) validateRequested(req, ...bags);\n return reqs;\n};\n"]}
|
package/dist/exp/index.d.ts
CHANGED
|
@@ -8,9 +8,11 @@ export * from "./ExportsParser.js";
|
|
|
8
8
|
export * from "./ExportsParserJson.js";
|
|
9
9
|
export * from "./exports.common.js";
|
|
10
10
|
export * from "./exports.file.js";
|
|
11
|
+
export * from "./exports.finder.js";
|
|
11
12
|
export * from "./exports.key.js";
|
|
12
13
|
export * from "./exports.module.js";
|
|
13
14
|
export * from "./exports.node.js";
|
|
14
15
|
export * from "./exports.package.js";
|
|
15
16
|
export * from "./exports.parse.js";
|
|
17
|
+
export * from "./exports.requested.js";
|
|
16
18
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/exp/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/exp/index.ts"],"names":[],"mappings":"AACA,cAAc,qBAAqB,CAAC;AACpC,cAAc,uBAAuB,CAAC;AACtC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,kBAAkB,CAAC;AACjC,cAAc,oBAAoB,CAAC;AACnC,cAAc,uBAAuB,CAAC;AACtC,cAAc,oBAAoB,CAAC;AACnC,cAAc,wBAAwB,CAAC;AACvC,cAAc,qBAAqB,CAAC;AACpC,cAAc,mBAAmB,CAAC;AAClC,cAAc,kBAAkB,CAAC;AACjC,cAAc,qBAAqB,CAAC;AACpC,cAAc,mBAAmB,CAAC;AAClC,cAAc,sBAAsB,CAAC;AACrC,cAAc,oBAAoB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/exp/index.ts"],"names":[],"mappings":"AACA,cAAc,qBAAqB,CAAC;AACpC,cAAc,uBAAuB,CAAC;AACtC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,kBAAkB,CAAC;AACjC,cAAc,oBAAoB,CAAC;AACnC,cAAc,uBAAuB,CAAC;AACtC,cAAc,oBAAoB,CAAC;AACnC,cAAc,wBAAwB,CAAC;AACvC,cAAc,qBAAqB,CAAC;AACpC,cAAc,mBAAmB,CAAC;AAClC,cAAc,qBAAqB,CAAC;AACpC,cAAc,kBAAkB,CAAC;AACjC,cAAc,qBAAqB,CAAC;AACpC,cAAc,mBAAmB,CAAC;AAClC,cAAc,sBAAsB,CAAC;AACrC,cAAc,oBAAoB,CAAC;AACnC,cAAc,wBAAwB,CAAC"}
|
package/dist/exp/index.js
CHANGED
|
@@ -9,9 +9,11 @@ export * from "./ExportsParser.js";
|
|
|
9
9
|
export * from "./ExportsParserJson.js";
|
|
10
10
|
export * from "./exports.common.js";
|
|
11
11
|
export * from "./exports.file.js";
|
|
12
|
+
export * from "./exports.finder.js";
|
|
12
13
|
export * from "./exports.key.js";
|
|
13
14
|
export * from "./exports.module.js";
|
|
14
15
|
export * from "./exports.node.js";
|
|
15
16
|
export * from "./exports.package.js";
|
|
16
17
|
export * from "./exports.parse.js";
|
|
18
|
+
export * from "./exports.requested.js";
|
|
17
19
|
//# sourceMappingURL=index.js.map
|
package/dist/exp/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/exp/index.ts"],"names":[],"mappings":"AAAA,mEAAmE;AACnE,cAAc,qBAAqB,CAAC;AACpC,cAAc,uBAAuB,CAAC;AACtC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,kBAAkB,CAAC;AACjC,cAAc,oBAAoB,CAAC;AACnC,cAAc,uBAAuB,CAAC;AACtC,cAAc,oBAAoB,CAAC;AACnC,cAAc,wBAAwB,CAAC;AACvC,cAAc,qBAAqB,CAAC;AACpC,cAAc,mBAAmB,CAAC;AAClC,cAAc,kBAAkB,CAAC;AACjC,cAAc,qBAAqB,CAAC;AACpC,cAAc,mBAAmB,CAAC;AAClC,cAAc,sBAAsB,CAAC;AACrC,cAAc,oBAAoB,CAAC","sourcesContent":["// This file is auto-generated for build-cli. Do not edit manually.\nexport * from \"./ExportsContent.js\";\nexport * from \"./ExportsExtractor.js\";\nexport * from \"./ExportsExtractorItem.js\";\nexport * from \"./ExportsFile.js\";\nexport * from \"./ExportsFinder.js\";\nexport * from \"./ExportsFinderBag.js\";\nexport * from \"./ExportsParser.js\";\nexport * from \"./ExportsParserJson.js\";\nexport * from \"./exports.common.js\";\nexport * from \"./exports.file.js\";\nexport * from \"./exports.key.js\";\nexport * from \"./exports.module.js\";\nexport * from \"./exports.node.js\";\nexport * from \"./exports.package.js\";\nexport * from \"./exports.parse.js\";\n"]}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/exp/index.ts"],"names":[],"mappings":"AAAA,mEAAmE;AACnE,cAAc,qBAAqB,CAAC;AACpC,cAAc,uBAAuB,CAAC;AACtC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,kBAAkB,CAAC;AACjC,cAAc,oBAAoB,CAAC;AACnC,cAAc,uBAAuB,CAAC;AACtC,cAAc,oBAAoB,CAAC;AACnC,cAAc,wBAAwB,CAAC;AACvC,cAAc,qBAAqB,CAAC;AACpC,cAAc,mBAAmB,CAAC;AAClC,cAAc,qBAAqB,CAAC;AACpC,cAAc,kBAAkB,CAAC;AACjC,cAAc,qBAAqB,CAAC;AACpC,cAAc,mBAAmB,CAAC;AAClC,cAAc,sBAAsB,CAAC;AACrC,cAAc,oBAAoB,CAAC;AACnC,cAAc,wBAAwB,CAAC","sourcesContent":["// This file is auto-generated for build-cli. Do not edit manually.\nexport * from \"./ExportsContent.js\";\nexport * from \"./ExportsExtractor.js\";\nexport * from \"./ExportsExtractorItem.js\";\nexport * from \"./ExportsFile.js\";\nexport * from \"./ExportsFinder.js\";\nexport * from \"./ExportsFinderBag.js\";\nexport * from \"./ExportsParser.js\";\nexport * from \"./ExportsParserJson.js\";\nexport * from \"./exports.common.js\";\nexport * from \"./exports.file.js\";\nexport * from \"./exports.finder.js\";\nexport * from \"./exports.key.js\";\nexport * from \"./exports.module.js\";\nexport * from \"./exports.node.js\";\nexport * from \"./exports.package.js\";\nexport * from \"./exports.parse.js\";\nexport * from \"./exports.requested.js\";\n"]}
|
|
@@ -15,7 +15,6 @@ export interface ExportNode {
|
|
|
15
15
|
export interface ExportNodeTyped extends ExportNode {
|
|
16
16
|
packageName: string;
|
|
17
17
|
type: ExportNodeType;
|
|
18
|
-
requested?: boolean;
|
|
19
18
|
}
|
|
20
19
|
/**
|
|
21
20
|
* Represents a resolved package entrypoint.
|
|
@@ -60,4 +59,8 @@ export interface ExportsCommonExcludes {
|
|
|
60
59
|
excludePackageJson?: boolean;
|
|
61
60
|
excludeKnownDuplicates?: boolean;
|
|
62
61
|
}
|
|
62
|
+
export interface ExportsRequested {
|
|
63
|
+
name: string;
|
|
64
|
+
valid?: boolean;
|
|
65
|
+
}
|
|
63
66
|
//# sourceMappingURL=types.exports.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.exports.d.ts","sourceRoot":"","sources":["../../src/types/types.exports.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAC;AAC9D,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AAExD;;GAEG;AACH,MAAM,WAAW,UAAU;IACzB,kBAAkB;IAClB,IAAI,EAAE,MAAM,CAAC;IACb,qDAAqD;IACrD,IAAI,EAAE,MAAM,CAAC;IACb,wBAAwB;IACxB,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,qEAAqE;AACrE,MAAM,WAAW,eAAgB,SAAQ,UAAU;IACjD,WAAW,EAAE,MAAM,CAAC;IACpB,IAAI,EAAE,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"types.exports.d.ts","sourceRoot":"","sources":["../../src/types/types.exports.ts"],"names":[],"mappings":"AAAA,OAAO,KA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pC,kBAAkB,CAAC,EAAE,OAAO,CAAC;IAC7B,sBAAsB,CAAC,EAAE,OAAO,CAAC;CAClC;AAED,MAAM,WAAW,gBAAgB;IAC/B,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,CAAC,EAAE,OAAO,CAAC;CACjB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.exports.js","sourceRoot":"","sources":["../../src/types/types.exports.ts"],"names":[],"mappings":"","sourcesContent":["import type { ExportNodeType } from \"../enum/enum.exports.js\";\nimport type { RunRepoRootParams } from \"./types.run.js\";\n\n/**\n * Represents a discovered export in a package.\n */\nexport interface ExportNode {\n /** Export name */\n name: string;\n /** Type of export (function, object, class, etc.) */\n kind: string;\n /** Source entrypoint */\n source: string;\n}\n\n/** An {@link ExportNode} enriched with package and type metadata. */\nexport interface ExportNodeTyped extends ExportNode {\n packageName: string;\n type: ExportNodeType;\n
|
|
1
|
+
{"version":3,"file":"types.exports.js","sourceRoot":"","sources":["../../src/types/types.exports.ts"],"names":[],"mappings":"","sourcesContent":["import type { ExportNodeType } from \"../enum/enum.exports.js\";\nimport type { RunRepoRootParams } from \"./types.run.js\";\n\n/**\n * Represents a discovered export in a package.\n */\nexport interface ExportNode {\n /** Export name */\n name: string;\n /** Type of export (function, object, class, etc.) */\n kind: string;\n /** Source entrypoint */\n source: string;\n}\n\n/** An {@link ExportNode} enriched with package and type metadata. */\nexport interface ExportNodeTyped extends ExportNode {\n packageName: string;\n type: ExportNodeType;\n}\n\n/**\n * Represents a resolved package entrypoint.\n */\nexport interface EntryPoint {\n /** Import specifier used to load the entrypoint */\n id: string;\n /** Absolute path to resolved file */\n file?: string;\n}\n\n/**\n * Final API analysis result.\n */\nexport interface PackageAPI {\n /** Name of root package */\n packageName: string;\n /** All discovered entrypoints */\n entrypoints: EntryPoint[];\n /** Runtime exports discovered via module loading */\n runtimeExports: ExportNode[];\n /** Type exports discovered via `.d.ts` parsing */\n typeExports: ExportNode[];\n}\n\n/**\n * Parameters for bulk-updating packages that match a pattern.\n */\nexport interface ExportsExtractorParams\n extends RunRepoRootParams, ExportsCommonExcludes {\n filePaths?: string[];\n filterPackages?: string[];\n}\n\n/** Parameters for loading workspace packages into an exports file. */\nexport interface ExportsPackagesParams extends RunRepoRootParams {\n filePath?: string;\n filterPackages?: string[];\n}\n\nexport interface ExportsPattern {\n name?: string; // e.g. *some\n kind?: string; // e.g. some*kind\n source?: string; // e.g. */package.json\n}\n\nexport interface ExportsCommonExcludes {\n excludePackageJson?: boolean;\n excludeKnownDuplicates?: boolean;\n}\n\nexport interface ExportsRequested {\n name: string;\n valid?: boolean;\n}\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mxpicture/build-api",
|
|
3
|
-
"version": "0.2
|
|
3
|
+
"version": "0.3.2",
|
|
4
4
|
"description": "Build utilities API",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"author": "MXPicture",
|
|
@@ -58,5 +58,8 @@
|
|
|
58
58
|
"typescript": "^5.9.3",
|
|
59
59
|
"yaml": "^2.8.2",
|
|
60
60
|
"zod": "^4.3.6"
|
|
61
|
+
},
|
|
62
|
+
"devDependencies": {
|
|
63
|
+
"@types/node": "^25.3.2"
|
|
61
64
|
}
|
|
62
65
|
}
|