@mxpicture/build-api 0.2.58 → 0.2.60
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/{pkg/ExportExtractor.d.ts → exp/ExportsExtractor.d.ts} +8 -8
- package/dist/exp/ExportsExtractor.d.ts.map +1 -0
- package/dist/{pkg/ExportExtractor.js → exp/ExportsExtractor.js} +30 -31
- package/dist/exp/ExportsExtractor.js.map +1 -0
- package/dist/exp/ExportsJsonFile.d.ts +13 -0
- package/dist/exp/ExportsJsonFile.d.ts.map +1 -0
- package/dist/exp/ExportsJsonFile.js +59 -0
- package/dist/exp/ExportsJsonFile.js.map +1 -0
- package/dist/exp/ExportsTsFile.d.ts +9 -0
- package/dist/exp/ExportsTsFile.d.ts.map +1 -0
- package/dist/exp/ExportsTsFile.js +29 -0
- package/dist/exp/ExportsTsFile.js.map +1 -0
- package/dist/exp/exports.d.ts +3 -0
- package/dist/exp/exports.d.ts.map +1 -0
- package/dist/exp/exports.js +945 -0
- package/dist/exp/exports.js.map +1 -0
- package/dist/exp/index.d.ts +5 -0
- package/dist/exp/index.d.ts.map +1 -0
- package/dist/exp/index.js +6 -0
- package/dist/exp/index.js.map +1 -0
- package/dist/pkg/UpdatePackages.d.ts.map +1 -1
- package/dist/pkg/UpdatePackages.js +14 -13
- package/dist/pkg/UpdatePackages.js.map +1 -1
- package/dist/pkg/index.d.ts +0 -1
- package/dist/pkg/index.d.ts.map +1 -1
- package/dist/pkg/index.js +0 -1
- package/dist/pkg/index.js.map +1 -1
- package/dist/scripts/generateOwnExports.d.ts +2 -0
- package/dist/scripts/generateOwnExports.d.ts.map +1 -0
- package/dist/scripts/generateOwnExports.js +24 -0
- package/dist/scripts/generateOwnExports.js.map +1 -0
- package/dist/types/types.exports.d.ts +3 -3
- package/dist/types/types.exports.d.ts.map +1 -1
- package/dist/types/types.exports.js.map +1 -1
- package/package.json +6 -3
- package/dist/pkg/ExportExtractor.d.ts.map +0 -1
- package/dist/pkg/ExportExtractor.js.map +0 -1
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
import { EntryPoint,
|
|
1
|
+
import { EntryPoint, ExportsExtractorParams, ExportNode, PackageAPI } from "../types/types.exports.js";
|
|
2
2
|
import { PackageJson } from "../types/types.package.js";
|
|
3
|
-
|
|
4
|
-
export declare
|
|
5
|
-
|
|
3
|
+
import { ExportsJsonFile } from "./ExportsJsonFile.js";
|
|
4
|
+
export declare const runExportsExtractor: (params: ExportsExtractorParams) => Promise<void>;
|
|
5
|
+
export declare class ExportsExtractor {
|
|
6
|
+
protected file: ExportsJsonFile;
|
|
6
7
|
/**
|
|
7
8
|
* Analyze an installed package and produce
|
|
8
9
|
* a structured API representation.
|
|
9
10
|
*
|
|
10
11
|
* @param pkg package name
|
|
11
12
|
*/
|
|
12
|
-
constructor(
|
|
13
|
+
constructor(file: ExportsJsonFile);
|
|
13
14
|
/**
|
|
14
15
|
* Analyze an installed package and build its API model.
|
|
15
16
|
*/
|
|
16
17
|
run(): Promise<PackageAPI>;
|
|
17
|
-
writeJson(
|
|
18
|
-
toJson(content: PackageAPI): Promise<string>;
|
|
18
|
+
writeJson(): Promise<void>;
|
|
19
19
|
/**
|
|
20
20
|
* Resolve the root directory of an installed package.
|
|
21
21
|
*/
|
|
@@ -41,4 +41,4 @@ export declare class ExportExtractor {
|
|
|
41
41
|
*/
|
|
42
42
|
protected parseTypeExports(root: string): Promise<ExportNode[]>;
|
|
43
43
|
}
|
|
44
|
-
//# sourceMappingURL=
|
|
44
|
+
//# sourceMappingURL=ExportsExtractor.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ExportsExtractor.d.ts","sourceRoot":"","sources":["../../src/exp/ExportsExtractor.ts"],"names":[],"mappings":"AAMA,OAAO,EACL,UAAU,EACV,sBAAsB,EACtB,UAAU,EACV,UAAU,EACX,MAAM,2BAA2B,CAAC;AAEnC,OAAO,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAC;AAExD,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAIvD,eAAO,MAAM,mBAAmB,GAAU,QAAQ,sBAAsB,kBAgBvE,CAAC;AAEF,qBAAa,gBAAgB;IAOR,SAAS,CAAC,IAAI,EAAE,eAAe;IANlD;;;;;OAKG;gBAC0B,IAAI,EAAE,eAAe;IAElD;;OAEG;IACU,GAAG,IAAI,OAAO,CAAC,UAAU,CAAC;IAmB1B,SAAS,IAAI,OAAO,CAAC,IAAI,CAAC;IAIvC;;OAEG;IACH,SAAS,CAAC,kBAAkB,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM;IAKjD;;OAEG;IACH,SAAS,CAAC,kBAAkB,CAC1B,GAAG,EAAE,MAAM,EACX,OAAO,EAAE,WAAW,GACnB,UAAU,EAAE;IAmCf;;OAEG;cACa,yBAAyB,CACvC,IAAI,EAAE,MAAM,EACZ,WAAW,EAAE,UAAU,EAAE,GACxB,OAAO,CAAC,UAAU,EAAE,CAAC;IAuBxB;;OAEG;cACa,UAAU,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAQxE;;OAEG;cACa,qBAAqB,CACnC,WAAW,EAAE,UAAU,EAAE,GACxB,OAAO,CAAC,UAAU,EAAE,CAAC;IAiBxB;;OAEG;cACa,gBAAgB,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,UAAU,EAAE,CAAC;CA0CtE"}
|
|
@@ -1,59 +1,58 @@
|
|
|
1
|
-
import { dirname, relative } from "node:path";
|
|
1
|
+
import { dirname, join, relative } from "node:path";
|
|
2
2
|
import ts from "typescript";
|
|
3
3
|
import { glob } from "glob";
|
|
4
4
|
import { createRequire } from "node:module";
|
|
5
5
|
import { resolve as resolveExports } from "resolve.exports";
|
|
6
|
-
import { readPackageJson } from "
|
|
6
|
+
import { readPackageJson } from "../pkg/pkg.fs.js";
|
|
7
7
|
import { initWorkspace } from "../workspace/Workspace.js";
|
|
8
8
|
import { createSourceFileMap } from "../code/code.common.js";
|
|
9
|
-
import {
|
|
10
|
-
import { jsonStringify, JsonStringifyFormat } from "../common/common.json.js";
|
|
9
|
+
import { ExportsJsonFile } from "./ExportsJsonFile.js";
|
|
11
10
|
const require = createRequire(import.meta.url);
|
|
12
|
-
export const
|
|
11
|
+
export const runExportsExtractor = async (params) => {
|
|
13
12
|
initWorkspace(params.repoRoot);
|
|
14
|
-
|
|
13
|
+
if (!params.json)
|
|
14
|
+
params.json = join(params.repoRoot, "exports.json");
|
|
15
|
+
const file = new ExportsJsonFile(params.package, params.json);
|
|
16
|
+
const exp = new ExportsExtractor(file);
|
|
15
17
|
const result = await exp.run();
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
}
|
|
18
|
+
await exp.writeJson();
|
|
19
|
+
console.log("{");
|
|
20
|
+
console.log(` packageName: ${result.packageName}`);
|
|
21
|
+
console.log(` entrypoints: ${result.entrypoints.length}`);
|
|
22
|
+
console.log(` runtimeExports: ${result.runtimeExports.length}`);
|
|
23
|
+
console.log(` typeExports: ${result.typeExports.length}`);
|
|
24
|
+
console.log("}");
|
|
23
25
|
};
|
|
24
|
-
export class
|
|
25
|
-
|
|
26
|
+
export class ExportsExtractor {
|
|
27
|
+
file;
|
|
26
28
|
/**
|
|
27
29
|
* Analyze an installed package and produce
|
|
28
30
|
* a structured API representation.
|
|
29
31
|
*
|
|
30
32
|
* @param pkg package name
|
|
31
33
|
*/
|
|
32
|
-
constructor(
|
|
33
|
-
this.
|
|
34
|
+
constructor(file) {
|
|
35
|
+
this.file = file;
|
|
34
36
|
}
|
|
35
37
|
/**
|
|
36
38
|
* Analyze an installed package and build its API model.
|
|
37
39
|
*/
|
|
38
40
|
async run() {
|
|
39
|
-
const
|
|
41
|
+
const pkgFile = this.file.content;
|
|
42
|
+
const root = this.resolvePackageRoot(pkgFile.packageName);
|
|
40
43
|
const pkgJson = await readPackageJson(root);
|
|
41
|
-
let entrypoints = this.resolveEntrypoints(
|
|
44
|
+
let entrypoints = this.resolveEntrypoints(pkgFile.packageName, pkgJson);
|
|
42
45
|
entrypoints = await this.expandWildcardEntrypoints(root, entrypoints);
|
|
43
46
|
const runtimeExports = await this.inspectRuntimeExports(entrypoints);
|
|
44
47
|
const typeExports = await this.parseTypeExports(root);
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
};
|
|
51
|
-
}
|
|
52
|
-
async writeJson(filePath, content) {
|
|
53
|
-
return writeFile(filePath, await this.toJson(content));
|
|
48
|
+
pkgFile.packageName = pkgJson.name;
|
|
49
|
+
pkgFile.entrypoints = entrypoints;
|
|
50
|
+
pkgFile.runtimeExports = runtimeExports;
|
|
51
|
+
pkgFile.typeExports = typeExports;
|
|
52
|
+
return pkgFile;
|
|
54
53
|
}
|
|
55
|
-
async
|
|
56
|
-
return
|
|
54
|
+
async writeJson() {
|
|
55
|
+
return this.file.write();
|
|
57
56
|
}
|
|
58
57
|
/**
|
|
59
58
|
* Resolve the root directory of an installed package.
|
|
@@ -177,4 +176,4 @@ export class ExportExtractor {
|
|
|
177
176
|
return nodes;
|
|
178
177
|
}
|
|
179
178
|
}
|
|
180
|
-
//# sourceMappingURL=
|
|
179
|
+
//# sourceMappingURL=ExportsExtractor.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ExportsExtractor.js","sourceRoot":"","sources":["../../src/exp/ExportsExtractor.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AACpD,OAAO,EAAE,MAAM,YAAY,CAAC;AAC5B,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AAC5B,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,EAAE,OAAO,IAAI,cAAc,EAAE,M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,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC;wBAC9B,MAAM,EAAE,QAAQ;qBACjB,CAAC,CAAC;gBACL,CAAC;gBAED,IAAI,EAAE,CAAC,iBAAiB,CAAC,IAAI,CAAC,EAAE,CAAC;oBAC/B,KAAK,CAAC,IAAI,CAAC;wBACT,IAAI,EAAE,IAAI,CAAC,IAAI,CAAC,IAAI;wBACpB,IAAI,EAAE,MAAM;wBACZ,MAAM,EAAE,QAAQ;qBACjB,CAAC,CAAC;gBACL,CAAC;YACH,CAAC,CAAC,CAAC;QACL,CAAC;QAED,OAAO,KAAK,CAAC;IACf,CAAC;CACF","sourcesContent":["import { dirname, join, relative } from \"node:path\";\nimport ts from \"typescript\";\nimport { glob } from \"glob\";\nimport { createRequire } from \"node:module\";\nimport { resolve as resolveExports } from \"resolve.exports\";\nimport { readPackageJson } from \"../pkg/pkg.fs.js\";\nimport {\n EntryPoint,\n ExportsExtractorParams,\n ExportNode,\n PackageAPI,\n} from \"../types/types.exports.js\";\nimport { initWorkspace } from \"../workspace/Workspace.js\";\nimport { PackageJson } from \"../types/types.package.js\";\nimport { createSourceFileMap } from \"../code/code.common.js\";\nimport { ExportsJsonFile } from \"./ExportsJsonFile.js\";\n\nconst require = createRequire(import.meta.url);\n\nexport const runExportsExtractor = async (params: ExportsExtractorParams) => {\n initWorkspace(params.repoRoot);\n\n if (!params.json) params.json = join(params.repoRoot, \"exports.json\");\n\n const file = new ExportsJsonFile(params.package, params.json);\n const exp = new ExportsExtractor(file);\n const result = await exp.run();\n await exp.writeJson();\n\n console.log(\"{\");\n console.log(` packageName: ${result.packageName}`);\n console.log(` entrypoints: ${result.entrypoints.length}`);\n console.log(` runtimeExports: ${result.runtimeExports.length}`);\n console.log(` typeExports: ${result.typeExports.length}`);\n console.log(\"}\");\n};\n\nexport class ExportsExtractor {\n /**\n * Analyze an installed package and produce\n * a structured API representation.\n *\n * @param pkg package name\n */\n public constructor(protected file: ExportsJsonFile) {}\n\n /**\n * Analyze an installed package and build its API model.\n */\n public async run(): Promise<PackageAPI> {\n const pkgFile = this.file.content;\n\n const root = this.resolvePackageRoot(pkgFile.packageName);\n const pkgJson = await readPackageJson(root);\n\n let entrypoints = this.resolveEntrypoints(pkgFile.packageName, pkgJson);\n entrypoints = await this.expandWildcardEntrypoints(root, entrypoints);\n\n const runtimeExports = await this.inspectRuntimeExports(entrypoints);\n const typeExports = await this.parseTypeExports(root);\n\n pkgFile.packageName = pkgJson.name;\n pkgFile.entrypoints = entrypoints;\n pkgFile.runtimeExports = runtimeExports;\n pkgFile.typeExports = typeExports;\n return pkgFile;\n }\n\n public async writeJson(): Promise<void> {\n return this.file.write();\n }\n\n /**\n * Resolve the root directory of an installed package.\n */\n protected resolvePackageRoot(pkg: string): string {\n const pkgJson = require.resolve(`${pkg}/package.json`);\n return dirname(pkgJson);\n }\n\n /**\n * Resolve entrypoints using the Node exports algorithm.\n */\n protected resolveEntrypoints(\n pkg: string,\n pkgJson: PackageJson,\n ): EntryPoint[] {\n const entrypoints: EntryPoint[] = [];\n\n if (!pkgJson.exports) {\n entrypoints.push({ id: pkg });\n return entrypoints;\n }\n\n const keys = Object.keys(pkgJson.exports);\n\n for (const key of keys) {\n try {\n const resolved = resolveExports(pkgJson, key, {\n conditions: [\"node\", \"import\", \"require\", \"default\"],\n });\n\n if (!resolved) continue;\n\n const files = Array.isArray(resolved) ? resolved : [resolved];\n\n for (const file of files) {\n const specifier =\n key === \".\" ? pkg : `${pkg}/${key.replace(\"./\", \"\")}`;\n\n entrypoints.push({\n id: specifier,\n file,\n });\n }\n } catch {}\n }\n\n return entrypoints;\n }\n\n /**\n * Expand wildcard export patterns.\n */\n protected async expandWildcardEntrypoints(\n root: string,\n entrypoints: EntryPoint[],\n ): Promise<EntryPoint[]> {\n return (\n await Promise.allSettled(\n entrypoints.map(async (entry) => {\n if (!entry.file?.includes(\"*\")) return [entry];\n\n const pattern = entry.file;\n const files = await glob.glob(pattern, {\n cwd: root,\n absolute: true,\n });\n\n return files.map((file) => ({\n id: relative(root, file).replace(/\\.(js|mjs|cjs)$/, \"\"),\n file,\n }));\n }),\n )\n )\n .filter((r) => r.status === \"fulfilled\")\n .flatMap((r) => r.value);\n }\n\n /**\n * Dynamically import a module supporting ESM and CommonJS.\n */\n protected async loadModule(id: string): Promise<Record<string, unknown>> {\n try {\n return await import(id);\n } catch {\n return require(id);\n }\n }\n\n /**\n * Extract runtime exports from entrypoints.\n */\n protected async inspectRuntimeExports(\n entrypoints: EntryPoint[],\n ): Promise<ExportNode[]> {\n return (\n await Promise.allSettled(\n entrypoints.map(async (entry) => {\n const mod = await this.loadModule(entry.id);\n return Object.keys(mod).map((name) => ({\n name,\n kind: typeof mod[name],\n source: entry.id,\n }));\n }),\n )\n )\n .filter((r) => r.status === \"fulfilled\")\n .flatMap((r) => r.value);\n }\n\n /**\n * Parse TypeScript declaration files to extract exported types.\n */\n protected async parseTypeExports(root: string): Promise<ExportNode[]> {\n const nodes: ExportNode[] = [];\n\n const filePaths = await glob.glob(\"**/*.d.ts\", {\n cwd: root,\n absolute: true,\n });\n\n const srcMap = createSourceFileMap(filePaths);\n\n for (const filePath of filePaths) {\n const file = srcMap.get(filePath);\n if (!file) continue;\n\n ts.forEachChild(file.sourceFile, (node) => {\n if (\n ts.isInterfaceDeclaration(node) ||\n ts.isTypeAliasDeclaration(node) ||\n ts.isClassDeclaration(node) ||\n ts.isFunctionDeclaration(node)\n ) {\n if (!node.name) return;\n\n nodes.push({\n name: node.name.text,\n kind: ts.SyntaxKind[node.kind],\n source: filePath,\n });\n }\n\n if (ts.isEnumDeclaration(node)) {\n nodes.push({\n name: node.name.text,\n kind: \"enum\",\n source: filePath,\n });\n }\n });\n }\n\n return nodes;\n }\n}\n"]}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { PackageAPI } from "../types/types.exports.js";
|
|
2
|
+
export declare const loadExportsJsonFile: (filePath: string) => Promise<ExportsJsonFile>;
|
|
3
|
+
export declare class ExportsJsonFile {
|
|
4
|
+
readonly filePath: string;
|
|
5
|
+
protected _content: PackageAPI;
|
|
6
|
+
constructor(packageName: string, filePath: string);
|
|
7
|
+
get packageName(): string;
|
|
8
|
+
get content(): PackageAPI;
|
|
9
|
+
read(): Promise<PackageAPI>;
|
|
10
|
+
write(): Promise<void>;
|
|
11
|
+
json(): Promise<string>;
|
|
12
|
+
}
|
|
13
|
+
//# sourceMappingURL=ExportsJsonFile.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ExportsJsonFile.d.ts","sourceRoot":"","sources":["../../src/exp/ExportsJsonFile.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAC;AA6BvD,eAAO,MAAM,mBAAmB,GAC9B,UAAU,MAAM,KACf,OAAO,CAAC,eAAe,CAIzB,CAAC;AAEF,qBAAa,eAAe;aAKR,QAAQ,EAAE,MAAM;IAJlC,SAAS,CAAC,QAAQ,EAAE,UAAU,CAAC;gBAG7B,WAAW,EAAE,MAAM,EACH,QAAQ,EAAE,MAAM;IAUlC,IAAW,WAAW,IAAI,MAAM,CAE/B;IAED,IAAW,OAAO,IAAI,UAAU,CAE/B;IAEY,IAAI,IAAI,OAAO,CAAC,UAAU,CAAC;IAM3B,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;IAKtB,IAAI,IAAI,OAAO,CAAC,MAAM,CAAC;CAGrC"}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { dirname } from "node:path";
|
|
2
|
+
import { mkdir, readFile, writeFile } from "node:fs/promises";
|
|
3
|
+
import { jsonStringify, JsonStringifyFormat } from "../common/common.json.js";
|
|
4
|
+
import { array, object, string } from "zod";
|
|
5
|
+
const entryPointShape = {
|
|
6
|
+
id: string(),
|
|
7
|
+
file: string().optional(),
|
|
8
|
+
};
|
|
9
|
+
const entryPointSchema = object(entryPointShape);
|
|
10
|
+
const exportNodeShape = {
|
|
11
|
+
name: string(),
|
|
12
|
+
kind: string(),
|
|
13
|
+
source: string(),
|
|
14
|
+
};
|
|
15
|
+
const exportNodeSchema = object(exportNodeShape);
|
|
16
|
+
const fileShape = {
|
|
17
|
+
packageName: string(),
|
|
18
|
+
entrypoints: array(entryPointSchema),
|
|
19
|
+
runtimeExports: array(exportNodeSchema),
|
|
20
|
+
typeExports: array(exportNodeSchema),
|
|
21
|
+
};
|
|
22
|
+
const fileSchema = object(fileShape);
|
|
23
|
+
export const loadExportsJsonFile = async (filePath) => {
|
|
24
|
+
const exp = new ExportsJsonFile("", filePath);
|
|
25
|
+
await exp.read();
|
|
26
|
+
return exp;
|
|
27
|
+
};
|
|
28
|
+
export class ExportsJsonFile {
|
|
29
|
+
filePath;
|
|
30
|
+
_content;
|
|
31
|
+
constructor(packageName, filePath) {
|
|
32
|
+
this.filePath = filePath;
|
|
33
|
+
this._content = {
|
|
34
|
+
packageName,
|
|
35
|
+
entrypoints: [],
|
|
36
|
+
runtimeExports: [],
|
|
37
|
+
typeExports: [],
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
get packageName() {
|
|
41
|
+
return this._content.packageName;
|
|
42
|
+
}
|
|
43
|
+
get content() {
|
|
44
|
+
return this._content;
|
|
45
|
+
}
|
|
46
|
+
async read() {
|
|
47
|
+
const cont = await readFile(this.filePath, { encoding: "utf8" });
|
|
48
|
+
this._content = await fileSchema.parseAsync(cont);
|
|
49
|
+
return this._content;
|
|
50
|
+
}
|
|
51
|
+
async write() {
|
|
52
|
+
await mkdir(dirname(this.filePath), { recursive: true });
|
|
53
|
+
return writeFile(this.filePath, await this.json(), { encoding: "utf8" });
|
|
54
|
+
}
|
|
55
|
+
async json() {
|
|
56
|
+
return jsonStringify(this._content, JsonStringifyFormat.jsonStringify);
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
//# sourceMappingURL=ExportsJsonFile.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ExportsJsonFile.js","sourceRoot":"","sources":["../../src/exp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AR,QAAQ,CAAQ;QAEhC,IAAI,CAAC,QAAQ,GAAG;YACd,WAAW;YACX,WAAW,EAAE,EAAE;YACf,cAAc,EAAE,EAAE;YAClB,WAAW,EAAE,EAAE;SAChB,CAAC;IACJ,CAAC;IAED,IAAW,WAAW;QACpB,OAAO,IAAI,CAAC,QAAQ,CAAC,WAAW,CAAC;IACnC,CAAC;IAED,IAAW,OAAO;QAChB,OAAO,IAAI,CAAC,QAAQ,CAAC;IACvB,CAAC;IAEM,KAAK,CAAC,IAAI;QACf,MAAM,IAAI,GAAG,MAAM,QAAQ,CAAC,IAAI,CAAC,QAAQ,EAAE,EAAE,QAAQ,EAAE,MAAM,EAAE,CAAC,CAAC;QACjE,IAAI,CAAC,QAAQ,GAAG,MAAM,UAAU,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC;QAClD,OAAO,IAAI,CAAC,QAAQ,CAAC;IACvB,CAAC;IAEM,KAAK,CAAC,KAAK;QAChB,MAAM,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,QAAQ,CAAC,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;QACzD,OAAO,SAAS,CAAC,IAAI,CAAC,QAAQ,EAAE,MAAM,IAAI,CAAC,IAAI,EAAE,EAAE,EAAE,QAAQ,EAAE,MAAM,EAAE,CAAC,CAAC;IAC3E,CAAC;IAEM,KAAK,CAAC,IAAI;QACf,OAAO,aAAa,CAAC,IAAI,CAAC,QAAQ,EAAE,mBAAmB,CAAC,aAAa,CAAC,CAAC;IACzE,CAAC;CACF","sourcesContent":["import { dirname } from \"node:path\";\nimport { PackageAPI } from \"../types/types.exports.js\";\nimport { mkdir, readFile, writeFile } from \"node:fs/promises\";\nimport { jsonStringify, JsonStringifyFormat } from \"../common/common.json.js\";\nimport { array, object, string } from \"zod\";\n\nconst entryPointShape = {\n id: string(),\n file: string().optional(),\n};\n\nconst entryPointSchema = object(entryPointShape);\n\nconst exportNodeShape = {\n name: string(),\n kind: string(),\n source: string(),\n};\n\nconst exportNodeSchema = object(exportNodeShape);\n\nconst fileShape = {\n packageName: string(),\n entrypoints: array(entryPointSchema),\n runtimeExports: array(exportNodeSchema),\n typeExports: array(exportNodeSchema),\n};\n\nconst fileSchema = object(fileShape);\n\nexport const loadExportsJsonFile = async (\n filePath: string,\n): Promise<ExportsJsonFile> => {\n const exp = new ExportsJsonFile(\"\", filePath);\n await exp.read();\n return exp;\n};\n\nexport class ExportsJsonFile {\n protected _content: PackageAPI;\n\n public constructor(\n packageName: string,\n public readonly filePath: string,\n ) {\n this._content = {\n packageName,\n entrypoints: [],\n runtimeExports: [],\n typeExports: [],\n };\n }\n\n public get packageName(): string {\n return this._content.packageName;\n }\n\n public get content(): PackageAPI {\n return this._content;\n }\n\n public async read(): Promise<PackageAPI> {\n const cont = await readFile(this.filePath, { encoding: \"utf8\" });\n this._content = await fileSchema.parseAsync(cont);\n return this._content;\n }\n\n public async write(): Promise<void> {\n await mkdir(dirname(this.filePath), { recursive: true });\n return writeFile(this.filePath, await this.json(), { encoding: \"utf8\" });\n }\n\n public async json(): Promise<string> {\n return jsonStringify(this._content, JsonStringifyFormat.jsonStringify);\n }\n}\n"]}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { PackageAPI } from "../types/types.exports.js";
|
|
2
|
+
import { ExportsJsonFile } from "./ExportsJsonFile.js";
|
|
3
|
+
export declare class ExportsTsFile extends ExportsJsonFile {
|
|
4
|
+
static linkByJson(json: ExportsJsonFile): ExportsTsFile;
|
|
5
|
+
read(): Promise<PackageAPI>;
|
|
6
|
+
write(): Promise<void>;
|
|
7
|
+
ts(): Promise<string>;
|
|
8
|
+
}
|
|
9
|
+
//# sourceMappingURL=ExportsTsFile.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ExportsTsFile.d.ts","sourceRoot":"","sources":["../../src/exp/ExportsTsFile.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAC;AAGvD,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAGvD,qBAAa,aAAc,SAAQ,eAAe;WAClC,UAAU,CAAC,IAAI,EAAE,eAAe,GAAG,aAAa;IAOxC,IAAI,IAAI,OAAO,CAAC,UAAU,CAAC;IAI3B,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;IAK/B,EAAE,IAAI,OAAO,CAAC,MAAM,CAAC;CAQnC"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { dirname } from "node:path";
|
|
2
|
+
import { mkdir, writeFile } from "node:fs/promises";
|
|
3
|
+
import { jsonStringify, JsonStringifyFormat } from "../common/common.json.js";
|
|
4
|
+
import { ExportsJsonFile } from "./ExportsJsonFile.js";
|
|
5
|
+
import { formatCode } from "../code/code.format.js";
|
|
6
|
+
export class ExportsTsFile extends ExportsJsonFile {
|
|
7
|
+
static linkByJson(json) {
|
|
8
|
+
const filePath = json.filePath.replace(/\.json$/, ".ts");
|
|
9
|
+
const ts = new ExportsTsFile(json.packageName, filePath);
|
|
10
|
+
ts._content = json.content;
|
|
11
|
+
return ts;
|
|
12
|
+
}
|
|
13
|
+
async read() {
|
|
14
|
+
throw new Error("Read not implemented for ExportsTsFile");
|
|
15
|
+
}
|
|
16
|
+
async write() {
|
|
17
|
+
await mkdir(dirname(this.filePath), { recursive: true });
|
|
18
|
+
return writeFile(this.filePath, await this.ts(), { encoding: "utf8" });
|
|
19
|
+
}
|
|
20
|
+
async ts() {
|
|
21
|
+
const code = [
|
|
22
|
+
'import { PackageAPI } from "../types/types.exports.js";',
|
|
23
|
+
"",
|
|
24
|
+
`export const pkgExport: PackageAPI = ${await jsonStringify(this._content, JsonStringifyFormat.jsonStringify)}`,
|
|
25
|
+
];
|
|
26
|
+
return await formatCode(code.join("\n"));
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
//# sourceMappingURL=ExportsTsFile.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,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C;QACF,OAAO,MAAM,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;IAC3C,CAAC;CACF","sourcesContent":["import { dirname } from \"node:path\";\nimport { PackageAPI } from \"../types/types.exports.js\";\nimport { mkdir, writeFile } from \"node:fs/promises\";\nimport { jsonStringify, JsonStringifyFormat } from \"../common/common.json.js\";\nimport { ExportsJsonFile } from \"./ExportsJsonFile.js\";\nimport { formatCode } from \"../code/code.format.js\";\n\nexport class ExportsTsFile extends ExportsJsonFile {\n public static linkByJson(json: ExportsJsonFile): ExportsTsFile {\n const filePath = json.filePath.replace(/\\.json$/, \".ts\");\n const ts = new ExportsTsFile(json.packageName, filePath);\n ts._content = json.content;\n return ts;\n }\n\n public override async read(): Promise<PackageAPI> {\n throw new Error(\"Read not implemented for ExportsTsFile\");\n }\n\n public override async write(): Promise<void> {\n await mkdir(dirname(this.filePath), { recursive: true });\n return writeFile(this.filePath, await this.ts(), { encoding: \"utf8\" });\n }\n\n public async ts(): Promise<string> {\n const code: string[] = [\n 'import { PackageAPI } from \"../types/types.exports.js\";',\n \"\",\n `export const pkgExport: PackageAPI = ${await jsonStringify(this._content, JsonStringifyFormat.jsonStringify)}`,\n ];\n return await formatCode(code.join(\"\\n\"));\n }\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"exports.d.ts","sourceRoot":"","sources":["../../src/exp/exports.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAC;AAEvD,eAAO,MAAM,SAAS,EAAE,UAg/BvB,CAAC"}
|