@kubb/fabric-core 0.13.0 → 0.13.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{Fabric-CrRJykMN.d.ts → Fabric-BOjvMvNC.d.ts} +6 -9
- package/dist/{Fabric-DMmgrLto.d.cts → Fabric-w9Y9duM6.d.ts} +7 -7
- package/dist/{RootContext-Cf7WJM7r.d.cts → RootContext-BQHfIhhC.d.ts} +3 -3
- package/dist/{RootContext-CvaGJ-4g.d.ts → RootContext-Cbs-UQXM.d.ts} +3 -4
- package/dist/{chunk-BVHe6Par.js → chunk-BYypO7fO.js} +1 -5
- package/dist/{chunk-DVipidnM.cjs → chunk-uaV2rQ02.cjs} +0 -10
- package/dist/{defaultParser-BK-zOanQ.cjs → defaultParser-BAgmtMo_.cjs} +2 -3
- package/dist/{defaultParser-BK-zOanQ.cjs.map → defaultParser-BAgmtMo_.cjs.map} +1 -1
- package/dist/{defaultParser-BD_N68Bo.js → defaultParser-C1atU7yU.js} +2 -3
- package/dist/{defaultParser-BD_N68Bo.js.map → defaultParser-C1atU7yU.js.map} +1 -1
- package/dist/{getRelativePath-C4Au07ON.js → getRelativePath-BcieQL5M.js} +1 -2
- package/dist/{getRelativePath-C4Au07ON.js.map → getRelativePath-BcieQL5M.js.map} +1 -1
- package/dist/{getRelativePath-DpbA6qm5.cjs → getRelativePath-DVG8dIzW.cjs} +2 -2
- package/dist/{getRelativePath-DpbA6qm5.cjs.map → getRelativePath-DVG8dIzW.cjs.map} +1 -1
- package/dist/index.cjs +13 -10
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +6 -4
- package/dist/index.js +12 -10
- package/dist/index.js.map +1 -1
- package/dist/{onProcessExit-7fgW-UTF.js → onProcessExit-B0rJqX4s.js} +80 -182
- package/dist/onProcessExit-B0rJqX4s.js.map +1 -0
- package/dist/{onProcessExit-C7dVg0S0.cjs → onProcessExit-DENCUkMz.cjs} +80 -205
- package/dist/onProcessExit-DENCUkMz.cjs.map +1 -0
- package/dist/parsers/typescript.cjs +4 -4
- package/dist/parsers/typescript.cjs.map +1 -1
- package/dist/parsers/typescript.d.ts +1 -2
- package/dist/parsers/typescript.js +3 -4
- package/dist/parsers/typescript.js.map +1 -1
- package/dist/parsers.cjs +2 -3
- package/dist/parsers.cjs.map +1 -1
- package/dist/parsers.d.ts +1 -2
- package/dist/parsers.js +2 -3
- package/dist/parsers.js.map +1 -1
- package/dist/plugins.cjs +31 -41
- package/dist/plugins.cjs.map +1 -1
- package/dist/plugins.d.ts +2 -3
- package/dist/plugins.js +30 -41
- package/dist/plugins.js.map +1 -1
- package/dist/types.cjs +1 -1
- package/dist/types.d.ts +3 -4
- package/dist/types.js +1 -1
- package/dist/{useNodeTree-CgEKFUV-.d.cts → useNodeTree-6ZhDpI13.d.ts} +2 -2
- package/dist/{useNodeTree-CamNuFQP.d.ts → useNodeTree-Brj-fAVZ.d.ts} +2 -3
- package/package.json +3 -3
- package/src/Fabric.ts +5 -6
- package/src/createFabric.ts +5 -2
- package/src/utils/onProcessExit.ts +9 -0
- package/dist/index.d.cts +0 -602
- package/dist/onProcessExit-7fgW-UTF.js.map +0 -1
- package/dist/onProcessExit-C7dVg0S0.cjs.map +0 -1
- package/dist/parsers/typescript.d.cts +0 -45
- package/dist/parsers.d.cts +0 -37
- package/dist/plugins.d.cts +0 -119
- package/dist/types.d.cts +0 -11
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
-
const require_chunk = require('../chunk-
|
|
3
|
-
const require_getRelativePath = require('../getRelativePath-
|
|
2
|
+
const require_chunk = require('../chunk-uaV2rQ02.cjs');
|
|
3
|
+
const require_getRelativePath = require('../getRelativePath-DVG8dIzW.cjs');
|
|
4
4
|
let node_path = require("node:path");
|
|
5
5
|
node_path = require_chunk.__toESM(node_path);
|
|
6
6
|
let typescript = require("typescript");
|
|
@@ -45,7 +45,7 @@ function createImport({ name, path, root, isTypeOnly = false, isNameSpace = fals
|
|
|
45
45
|
const specifiers = name.map((item) => {
|
|
46
46
|
if (typeof item === "object") {
|
|
47
47
|
const { propertyName, name: alias } = item;
|
|
48
|
-
return factory.createImportSpecifier(false, alias ? factory.createIdentifier(propertyName) : void 0, factory.createIdentifier(alias
|
|
48
|
+
return factory.createImportSpecifier(false, alias ? factory.createIdentifier(propertyName) : void 0, factory.createIdentifier(alias ?? propertyName));
|
|
49
49
|
}
|
|
50
50
|
return factory.createImportSpecifier(false, void 0, factory.createIdentifier(item));
|
|
51
51
|
});
|
|
@@ -54,7 +54,7 @@ function createImport({ name, path, root, isTypeOnly = false, isNameSpace = fals
|
|
|
54
54
|
function createExport({ path, asAlias, isTypeOnly = false, name }) {
|
|
55
55
|
if (name && !Array.isArray(name) && !asAlias) console.warn(`When using name as string, asAlias should be true ${name}`);
|
|
56
56
|
if (!Array.isArray(name)) {
|
|
57
|
-
const parsedName =
|
|
57
|
+
const parsedName = name?.match(/^\d/) ? `_${name?.slice(1)}` : name;
|
|
58
58
|
return factory.createExportDeclaration(void 0, isTypeOnly, asAlias && parsedName ? factory.createNamespaceExport(factory.createIdentifier(parsedName)) : void 0, factory.createStringLiteral(path), void 0);
|
|
59
59
|
}
|
|
60
60
|
return factory.createExportDeclaration(void 0, isTypeOnly, factory.createNamedExports(name.map((propertyName) => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"typescript.cjs","names":["ts","getRelativePath","defineParser","path","trimExtName"],"sources":["../../src/parsers/typescriptParser.ts"],"sourcesContent":["import path from 'node:path'\nimport ts from 'typescript'\nimport { getRelativePath } from '../utils/getRelativePath.ts'\nimport { trimExtName } from '../utils/trimExtName.ts'\nimport { defineParser } from './defineParser.ts'\n\nconst { factory } = ts\n\n/**\n * Validates TypeScript AST nodes before printing to catch invalid nodes early.\n * Throws an error if any node has SyntaxKind.Unknown which would cause the TypeScript printer to crash.\n */\nexport function validateNodes(...nodes: ts.Node[]): void {\n for (const node of nodes) {\n if (!node) {\n throw new Error('Attempted to print undefined or null TypeScript node')\n }\n if (node.kind === ts.SyntaxKind.Unknown) {\n throw new Error(\n 'Invalid TypeScript AST node detected with SyntaxKind.Unknown. ' +\n `This typically indicates a schema pattern that couldn't be properly converted to TypeScript. ` +\n `Node: ${JSON.stringify(node, null, 2)}`,\n )\n }\n }\n}\n\n/**\n * Convert AST TypeScript/TSX nodes to a string based on the TypeScript printer.\n */\nexport function print(...elements: Array<ts.Node>): string {\n const sourceFile = ts.createSourceFile('print.tsx', '', ts.ScriptTarget.ES2022, true, ts.ScriptKind.TSX)\n\n const printer = ts.createPrinter({\n omitTrailingSemicolon: true,\n newLine: ts.NewLineKind.LineFeed,\n removeComments: false,\n noEmitHelpers: true,\n })\n\n for (const node of elements) {\n if (node.kind === ts.SyntaxKind.Unknown) {\n console.error('⚠️ Unknown node found:', node)\n }\n }\n\n const output = printer.printList(ts.ListFormat.MultiLine, factory.createNodeArray(elements.filter(Boolean)), sourceFile)\n\n return output.replace(/\\r\\n/g, '\\n')\n}\n\nexport function safePrint(...elements: Array<ts.Node>): string {\n validateNodes(...elements)\n\n return print(...elements)\n}\n\nexport function createImport({\n name,\n path,\n root,\n isTypeOnly = false,\n isNameSpace = false,\n}: {\n name: string | Array<string | { propertyName: string; name?: string }>\n path: string\n root?: string\n isTypeOnly?: boolean\n isNameSpace?: boolean\n}) {\n const resolvePath = root ? getRelativePath(root, path) : path\n\n // Namespace or default import\n if (!Array.isArray(name)) {\n if (isNameSpace) {\n return factory.createImportDeclaration(\n undefined,\n factory.createImportClause(isTypeOnly, undefined, factory.createNamespaceImport(factory.createIdentifier(name))),\n factory.createStringLiteral(resolvePath),\n undefined,\n )\n }\n\n return factory.createImportDeclaration(\n undefined,\n factory.createImportClause(isTypeOnly, factory.createIdentifier(name), undefined),\n factory.createStringLiteral(resolvePath),\n undefined,\n )\n }\n\n // Named imports\n const specifiers = name.map((item) => {\n if (typeof item === 'object') {\n const { propertyName, name: alias } = item\n return factory.createImportSpecifier(false, alias ? factory.createIdentifier(propertyName) : undefined, factory.createIdentifier(alias ?? propertyName))\n }\n\n return factory.createImportSpecifier(false, undefined, factory.createIdentifier(item))\n })\n\n return factory.createImportDeclaration(\n undefined,\n factory.createImportClause(isTypeOnly, undefined, factory.createNamedImports(specifiers)),\n factory.createStringLiteral(resolvePath),\n undefined,\n )\n}\n\nexport function createExport({\n path,\n asAlias,\n isTypeOnly = false,\n name,\n}: {\n path: string\n asAlias?: boolean\n isTypeOnly?: boolean\n name?: string | Array<ts.Identifier | string>\n}) {\n if (name && !Array.isArray(name) && !asAlias) {\n console.warn(`When using name as string, asAlias should be true ${name}`)\n }\n\n if (!Array.isArray(name)) {\n const parsedName = name?.match(/^\\d/) ? `_${name?.slice(1)}` : name\n\n return factory.createExportDeclaration(\n undefined,\n isTypeOnly,\n asAlias && parsedName ? factory.createNamespaceExport(factory.createIdentifier(parsedName)) : undefined,\n factory.createStringLiteral(path),\n undefined,\n )\n }\n\n return factory.createExportDeclaration(\n undefined,\n isTypeOnly,\n factory.createNamedExports(\n name.map((propertyName) => {\n return factory.createExportSpecifier(false, undefined, typeof propertyName === 'string' ? factory.createIdentifier(propertyName) : propertyName)\n }),\n ),\n factory.createStringLiteral(path),\n undefined,\n )\n}\n\nexport const typescriptParser = defineParser({\n name: 'typescript',\n extNames: ['.ts', '.js'],\n install() {},\n async parse(file, options = { extname: '.ts' }) {\n const sourceParts: Array<string> = []\n for (const item of file.sources) {\n if (item.value) {\n sourceParts.push(item.value)\n }\n }\n const source = sourceParts.join('\\n\\n')\n\n const importNodes: Array<ts.ImportDeclaration> = []\n for (const item of file.imports) {\n const importPath = item.root ? getRelativePath(item.root, item.path) : item.path\n const hasExtname = !!path.extname(importPath)\n\n importNodes.push(\n createImport({\n name: item.name,\n path: options.extname && hasExtname ? `${trimExtName(importPath)}${options.extname}` : item.root ? trimExtName(importPath) : importPath,\n isTypeOnly: item.isTypeOnly,\n isNameSpace: item.isNameSpace,\n }),\n )\n }\n\n const exportNodes: Array<ts.ExportDeclaration> = []\n for (const item of file.exports) {\n const exportPath = item.path\n const hasExtname = !!path.extname(exportPath)\n\n exportNodes.push(\n createExport({\n name: item.name,\n path: options.extname && hasExtname ? `${trimExtName(item.path)}${options.extname}` : trimExtName(item.path),\n isTypeOnly: item.isTypeOnly,\n asAlias: item.asAlias,\n }),\n )\n }\n\n const parts = [file.banner, print(...importNodes, ...exportNodes), source, file.footer].filter((segment): segment is string => segment != null)\n return parts.join('\\n')\n },\n})\n"],"mappings":";;;;;;;;;AAMA,MAAM,EAAE,YAAYA;;;;;AAMpB,SAAgB,cAAc,GAAG,OAAwB;AACvD,MAAK,MAAM,QAAQ,OAAO;AACxB,MAAI,CAAC,KACH,OAAM,IAAI,MAAM,uDAAuD;AAEzE,MAAI,KAAK,SAASA,mBAAG,WAAW,QAC9B,OAAM,IAAI,MACR,oKAEW,KAAK,UAAU,MAAM,MAAM,EAAE,GACzC;;;;;;AAQP,SAAgB,MAAM,GAAG,UAAkC;CACzD,MAAM,aAAaA,mBAAG,iBAAiB,aAAa,IAAIA,mBAAG,aAAa,QAAQ,MAAMA,mBAAG,WAAW,IAAI;CAExG,MAAM,UAAUA,mBAAG,cAAc;EAC/B,uBAAuB;EACvB,SAASA,mBAAG,YAAY;EACxB,gBAAgB;EAChB,eAAe;EAChB,CAAC;AAEF,MAAK,MAAM,QAAQ,SACjB,KAAI,KAAK,SAASA,mBAAG,WAAW,QAC9B,SAAQ,MAAM,0BAA0B,KAAK;AAMjD,QAFe,QAAQ,UAAUA,mBAAG,WAAW,WAAW,QAAQ,gBAAgB,SAAS,OAAO,QAAQ,CAAC,EAAE,WAAW,CAE1G,QAAQ,SAAS,KAAK;;AAGtC,SAAgB,UAAU,GAAG,UAAkC;AAC7D,eAAc,GAAG,SAAS;AAE1B,QAAO,MAAM,GAAG,SAAS;;AAG3B,SAAgB,aAAa,EAC3B,MACA,MACA,MACA,aAAa,OACb,cAAc,SAOb;CACD,MAAM,cAAc,OAAOC,wCAAgB,MAAM,KAAK,GAAG;AAGzD,KAAI,CAAC,MAAM,QAAQ,KAAK,EAAE;AACxB,MAAI,YACF,QAAO,QAAQ,wBACb,QACA,QAAQ,mBAAmB,YAAY,QAAW,QAAQ,sBAAsB,QAAQ,iBAAiB,KAAK,CAAC,CAAC,EAChH,QAAQ,oBAAoB,YAAY,EACxC,OACD;AAGH,SAAO,QAAQ,wBACb,QACA,QAAQ,mBAAmB,YAAY,QAAQ,iBAAiB,KAAK,EAAE,OAAU,EACjF,QAAQ,oBAAoB,YAAY,EACxC,OACD;;CAIH,MAAM,aAAa,KAAK,KAAK,SAAS;AACpC,MAAI,OAAO,SAAS,UAAU;GAC5B,MAAM,EAAE,cAAc,MAAM,UAAU;AACtC,UAAO,QAAQ,sBAAsB,OAAO,QAAQ,QAAQ,iBAAiB,aAAa,GAAG,QAAW,QAAQ,iBAAiB,
|
|
1
|
+
{"version":3,"file":"typescript.cjs","names":["ts","getRelativePath","defineParser","path","trimExtName"],"sources":["../../src/parsers/typescriptParser.ts"],"sourcesContent":["import path from 'node:path'\nimport ts from 'typescript'\nimport { getRelativePath } from '../utils/getRelativePath.ts'\nimport { trimExtName } from '../utils/trimExtName.ts'\nimport { defineParser } from './defineParser.ts'\n\nconst { factory } = ts\n\n/**\n * Validates TypeScript AST nodes before printing to catch invalid nodes early.\n * Throws an error if any node has SyntaxKind.Unknown which would cause the TypeScript printer to crash.\n */\nexport function validateNodes(...nodes: ts.Node[]): void {\n for (const node of nodes) {\n if (!node) {\n throw new Error('Attempted to print undefined or null TypeScript node')\n }\n if (node.kind === ts.SyntaxKind.Unknown) {\n throw new Error(\n 'Invalid TypeScript AST node detected with SyntaxKind.Unknown. ' +\n `This typically indicates a schema pattern that couldn't be properly converted to TypeScript. ` +\n `Node: ${JSON.stringify(node, null, 2)}`,\n )\n }\n }\n}\n\n/**\n * Convert AST TypeScript/TSX nodes to a string based on the TypeScript printer.\n */\nexport function print(...elements: Array<ts.Node>): string {\n const sourceFile = ts.createSourceFile('print.tsx', '', ts.ScriptTarget.ES2022, true, ts.ScriptKind.TSX)\n\n const printer = ts.createPrinter({\n omitTrailingSemicolon: true,\n newLine: ts.NewLineKind.LineFeed,\n removeComments: false,\n noEmitHelpers: true,\n })\n\n for (const node of elements) {\n if (node.kind === ts.SyntaxKind.Unknown) {\n console.error('⚠️ Unknown node found:', node)\n }\n }\n\n const output = printer.printList(ts.ListFormat.MultiLine, factory.createNodeArray(elements.filter(Boolean)), sourceFile)\n\n return output.replace(/\\r\\n/g, '\\n')\n}\n\nexport function safePrint(...elements: Array<ts.Node>): string {\n validateNodes(...elements)\n\n return print(...elements)\n}\n\nexport function createImport({\n name,\n path,\n root,\n isTypeOnly = false,\n isNameSpace = false,\n}: {\n name: string | Array<string | { propertyName: string; name?: string }>\n path: string\n root?: string\n isTypeOnly?: boolean\n isNameSpace?: boolean\n}) {\n const resolvePath = root ? getRelativePath(root, path) : path\n\n // Namespace or default import\n if (!Array.isArray(name)) {\n if (isNameSpace) {\n return factory.createImportDeclaration(\n undefined,\n factory.createImportClause(isTypeOnly, undefined, factory.createNamespaceImport(factory.createIdentifier(name))),\n factory.createStringLiteral(resolvePath),\n undefined,\n )\n }\n\n return factory.createImportDeclaration(\n undefined,\n factory.createImportClause(isTypeOnly, factory.createIdentifier(name), undefined),\n factory.createStringLiteral(resolvePath),\n undefined,\n )\n }\n\n // Named imports\n const specifiers = name.map((item) => {\n if (typeof item === 'object') {\n const { propertyName, name: alias } = item\n return factory.createImportSpecifier(false, alias ? factory.createIdentifier(propertyName) : undefined, factory.createIdentifier(alias ?? propertyName))\n }\n\n return factory.createImportSpecifier(false, undefined, factory.createIdentifier(item))\n })\n\n return factory.createImportDeclaration(\n undefined,\n factory.createImportClause(isTypeOnly, undefined, factory.createNamedImports(specifiers)),\n factory.createStringLiteral(resolvePath),\n undefined,\n )\n}\n\nexport function createExport({\n path,\n asAlias,\n isTypeOnly = false,\n name,\n}: {\n path: string\n asAlias?: boolean\n isTypeOnly?: boolean\n name?: string | Array<ts.Identifier | string>\n}) {\n if (name && !Array.isArray(name) && !asAlias) {\n console.warn(`When using name as string, asAlias should be true ${name}`)\n }\n\n if (!Array.isArray(name)) {\n const parsedName = name?.match(/^\\d/) ? `_${name?.slice(1)}` : name\n\n return factory.createExportDeclaration(\n undefined,\n isTypeOnly,\n asAlias && parsedName ? factory.createNamespaceExport(factory.createIdentifier(parsedName)) : undefined,\n factory.createStringLiteral(path),\n undefined,\n )\n }\n\n return factory.createExportDeclaration(\n undefined,\n isTypeOnly,\n factory.createNamedExports(\n name.map((propertyName) => {\n return factory.createExportSpecifier(false, undefined, typeof propertyName === 'string' ? factory.createIdentifier(propertyName) : propertyName)\n }),\n ),\n factory.createStringLiteral(path),\n undefined,\n )\n}\n\nexport const typescriptParser = defineParser({\n name: 'typescript',\n extNames: ['.ts', '.js'],\n install() {},\n async parse(file, options = { extname: '.ts' }) {\n const sourceParts: Array<string> = []\n for (const item of file.sources) {\n if (item.value) {\n sourceParts.push(item.value)\n }\n }\n const source = sourceParts.join('\\n\\n')\n\n const importNodes: Array<ts.ImportDeclaration> = []\n for (const item of file.imports) {\n const importPath = item.root ? getRelativePath(item.root, item.path) : item.path\n const hasExtname = !!path.extname(importPath)\n\n importNodes.push(\n createImport({\n name: item.name,\n path: options.extname && hasExtname ? `${trimExtName(importPath)}${options.extname}` : item.root ? trimExtName(importPath) : importPath,\n isTypeOnly: item.isTypeOnly,\n isNameSpace: item.isNameSpace,\n }),\n )\n }\n\n const exportNodes: Array<ts.ExportDeclaration> = []\n for (const item of file.exports) {\n const exportPath = item.path\n const hasExtname = !!path.extname(exportPath)\n\n exportNodes.push(\n createExport({\n name: item.name,\n path: options.extname && hasExtname ? `${trimExtName(item.path)}${options.extname}` : trimExtName(item.path),\n isTypeOnly: item.isTypeOnly,\n asAlias: item.asAlias,\n }),\n )\n }\n\n const parts = [file.banner, print(...importNodes, ...exportNodes), source, file.footer].filter((segment): segment is string => segment != null)\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AM,cAA6B,EAAE;AACrC,OAAK,MAAM,QAAQ,KAAK,QACtB,KAAI,KAAK,MACP,aAAY,KAAK,KAAK,MAAM;EAGhC,MAAM,SAAS,YAAY,KAAK,OAAO;EAEvC,MAAM,cAA2C,EAAE;AACnD,OAAK,MAAM,QAAQ,KAAK,SAAS;GAC/B,MAAM,aAAa,KAAK,OAAOD,wCAAgB,KAAK,MAAM,KAAK,KAAK,GAAG,KAAK;GAC5E,MAAM,aAAa,CAAC,CAACE,kBAAK,QAAQ,WAAW;AAE7C,eAAY,KACV,aAAa;IACX,MAAM,KAAK;IACX,MAAM,QAAQ,WAAW,aAAa,GAAGC,oCAAY,WAAW,GAAG,QAAQ,YAAY,KAAK,OAAOA,oCAAY,WAAW,GAAG;IAC7H,YAAY,KAAK;IACjB,aAAa,KAAK;IACnB,CAAC,CACH;;EAGH,MAAM,cAA2C,EAAE;AACnD,OAAK,MAAM,QAAQ,KAAK,SAAS;GAC/B,MAAM,aAAa,KAAK;GACxB,MAAM,aAAa,CAAC,CAACD,kBAAK,QAAQ,WAAW;AAE7C,eAAY,KACV,aAAa;IACX,MAAM,KAAK;IACX,MAAM,QAAQ,WAAW,aAAa,GAAGC,oCAAY,KAAK,KAAK,GAAG,QAAQ,YAAYA,oCAAY,KAAK,KAAK;IAC5G,YAAY,KAAK;IACjB,SAAS,KAAK;IACf,CAAC,CACH;;AAIH,SADc;GAAC,KAAK;GAAQ,MAAM,GAAG,aAAa,GAAG,YAAY;GAAE;GAAQ,KAAK;GAAO,CAAC,QAAQ,YAA+B,WAAW,KAAK,CAClI,KAAK,KAAK;;CAE1B,CAAC"}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import { n as
|
|
2
|
-
import { n as defineParser, r as trimExtName, t as getRelativePath } from "../getRelativePath-C4Au07ON.js";
|
|
1
|
+
import { n as defineParser, r as trimExtName, t as getRelativePath } from "../getRelativePath-BcieQL5M.js";
|
|
3
2
|
import path from "node:path";
|
|
4
3
|
import ts from "typescript";
|
|
5
4
|
|
|
@@ -42,7 +41,7 @@ function createImport({ name, path, root, isTypeOnly = false, isNameSpace = fals
|
|
|
42
41
|
const specifiers = name.map((item) => {
|
|
43
42
|
if (typeof item === "object") {
|
|
44
43
|
const { propertyName, name: alias } = item;
|
|
45
|
-
return factory.createImportSpecifier(false, alias ? factory.createIdentifier(propertyName) : void 0, factory.createIdentifier(alias
|
|
44
|
+
return factory.createImportSpecifier(false, alias ? factory.createIdentifier(propertyName) : void 0, factory.createIdentifier(alias ?? propertyName));
|
|
46
45
|
}
|
|
47
46
|
return factory.createImportSpecifier(false, void 0, factory.createIdentifier(item));
|
|
48
47
|
});
|
|
@@ -51,7 +50,7 @@ function createImport({ name, path, root, isTypeOnly = false, isNameSpace = fals
|
|
|
51
50
|
function createExport({ path, asAlias, isTypeOnly = false, name }) {
|
|
52
51
|
if (name && !Array.isArray(name) && !asAlias) console.warn(`When using name as string, asAlias should be true ${name}`);
|
|
53
52
|
if (!Array.isArray(name)) {
|
|
54
|
-
const parsedName =
|
|
53
|
+
const parsedName = name?.match(/^\d/) ? `_${name?.slice(1)}` : name;
|
|
55
54
|
return factory.createExportDeclaration(void 0, isTypeOnly, asAlias && parsedName ? factory.createNamespaceExport(factory.createIdentifier(parsedName)) : void 0, factory.createStringLiteral(path), void 0);
|
|
56
55
|
}
|
|
57
56
|
return factory.createExportDeclaration(void 0, isTypeOnly, factory.createNamedExports(name.map((propertyName) => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"typescript.js","names":[],"sources":["../../src/parsers/typescriptParser.ts"],"sourcesContent":["import path from 'node:path'\nimport ts from 'typescript'\nimport { getRelativePath } from '../utils/getRelativePath.ts'\nimport { trimExtName } from '../utils/trimExtName.ts'\nimport { defineParser } from './defineParser.ts'\n\nconst { factory } = ts\n\n/**\n * Validates TypeScript AST nodes before printing to catch invalid nodes early.\n * Throws an error if any node has SyntaxKind.Unknown which would cause the TypeScript printer to crash.\n */\nexport function validateNodes(...nodes: ts.Node[]): void {\n for (const node of nodes) {\n if (!node) {\n throw new Error('Attempted to print undefined or null TypeScript node')\n }\n if (node.kind === ts.SyntaxKind.Unknown) {\n throw new Error(\n 'Invalid TypeScript AST node detected with SyntaxKind.Unknown. ' +\n `This typically indicates a schema pattern that couldn't be properly converted to TypeScript. ` +\n `Node: ${JSON.stringify(node, null, 2)}`,\n )\n }\n }\n}\n\n/**\n * Convert AST TypeScript/TSX nodes to a string based on the TypeScript printer.\n */\nexport function print(...elements: Array<ts.Node>): string {\n const sourceFile = ts.createSourceFile('print.tsx', '', ts.ScriptTarget.ES2022, true, ts.ScriptKind.TSX)\n\n const printer = ts.createPrinter({\n omitTrailingSemicolon: true,\n newLine: ts.NewLineKind.LineFeed,\n removeComments: false,\n noEmitHelpers: true,\n })\n\n for (const node of elements) {\n if (node.kind === ts.SyntaxKind.Unknown) {\n console.error('⚠️ Unknown node found:', node)\n }\n }\n\n const output = printer.printList(ts.ListFormat.MultiLine, factory.createNodeArray(elements.filter(Boolean)), sourceFile)\n\n return output.replace(/\\r\\n/g, '\\n')\n}\n\nexport function safePrint(...elements: Array<ts.Node>): string {\n validateNodes(...elements)\n\n return print(...elements)\n}\n\nexport function createImport({\n name,\n path,\n root,\n isTypeOnly = false,\n isNameSpace = false,\n}: {\n name: string | Array<string | { propertyName: string; name?: string }>\n path: string\n root?: string\n isTypeOnly?: boolean\n isNameSpace?: boolean\n}) {\n const resolvePath = root ? getRelativePath(root, path) : path\n\n // Namespace or default import\n if (!Array.isArray(name)) {\n if (isNameSpace) {\n return factory.createImportDeclaration(\n undefined,\n factory.createImportClause(isTypeOnly, undefined, factory.createNamespaceImport(factory.createIdentifier(name))),\n factory.createStringLiteral(resolvePath),\n undefined,\n )\n }\n\n return factory.createImportDeclaration(\n undefined,\n factory.createImportClause(isTypeOnly, factory.createIdentifier(name), undefined),\n factory.createStringLiteral(resolvePath),\n undefined,\n )\n }\n\n // Named imports\n const specifiers = name.map((item) => {\n if (typeof item === 'object') {\n const { propertyName, name: alias } = item\n return factory.createImportSpecifier(false, alias ? factory.createIdentifier(propertyName) : undefined, factory.createIdentifier(alias ?? propertyName))\n }\n\n return factory.createImportSpecifier(false, undefined, factory.createIdentifier(item))\n })\n\n return factory.createImportDeclaration(\n undefined,\n factory.createImportClause(isTypeOnly, undefined, factory.createNamedImports(specifiers)),\n factory.createStringLiteral(resolvePath),\n undefined,\n )\n}\n\nexport function createExport({\n path,\n asAlias,\n isTypeOnly = false,\n name,\n}: {\n path: string\n asAlias?: boolean\n isTypeOnly?: boolean\n name?: string | Array<ts.Identifier | string>\n}) {\n if (name && !Array.isArray(name) && !asAlias) {\n console.warn(`When using name as string, asAlias should be true ${name}`)\n }\n\n if (!Array.isArray(name)) {\n const parsedName = name?.match(/^\\d/) ? `_${name?.slice(1)}` : name\n\n return factory.createExportDeclaration(\n undefined,\n isTypeOnly,\n asAlias && parsedName ? factory.createNamespaceExport(factory.createIdentifier(parsedName)) : undefined,\n factory.createStringLiteral(path),\n undefined,\n )\n }\n\n return factory.createExportDeclaration(\n undefined,\n isTypeOnly,\n factory.createNamedExports(\n name.map((propertyName) => {\n return factory.createExportSpecifier(false, undefined, typeof propertyName === 'string' ? factory.createIdentifier(propertyName) : propertyName)\n }),\n ),\n factory.createStringLiteral(path),\n undefined,\n )\n}\n\nexport const typescriptParser = defineParser({\n name: 'typescript',\n extNames: ['.ts', '.js'],\n install() {},\n async parse(file, options = { extname: '.ts' }) {\n const sourceParts: Array<string> = []\n for (const item of file.sources) {\n if (item.value) {\n sourceParts.push(item.value)\n }\n }\n const source = sourceParts.join('\\n\\n')\n\n const importNodes: Array<ts.ImportDeclaration> = []\n for (const item of file.imports) {\n const importPath = item.root ? getRelativePath(item.root, item.path) : item.path\n const hasExtname = !!path.extname(importPath)\n\n importNodes.push(\n createImport({\n name: item.name,\n path: options.extname && hasExtname ? `${trimExtName(importPath)}${options.extname}` : item.root ? trimExtName(importPath) : importPath,\n isTypeOnly: item.isTypeOnly,\n isNameSpace: item.isNameSpace,\n }),\n )\n }\n\n const exportNodes: Array<ts.ExportDeclaration> = []\n for (const item of file.exports) {\n const exportPath = item.path\n const hasExtname = !!path.extname(exportPath)\n\n exportNodes.push(\n createExport({\n name: item.name,\n path: options.extname && hasExtname ? `${trimExtName(item.path)}${options.extname}` : trimExtName(item.path),\n isTypeOnly: item.isTypeOnly,\n asAlias: item.asAlias,\n }),\n )\n }\n\n const parts = [file.banner, print(...importNodes, ...exportNodes), source, file.footer].filter((segment): segment is string => segment != null)\n return parts.join('\\n')\n },\n})\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"typescript.js","names":[],"sources":["../../src/parsers/typescriptParser.ts"],"sourcesContent":["import path from 'node:path'\nimport ts from 'typescript'\nimport { getRelativePath } from '../utils/getRelativePath.ts'\nimport { trimExtName } from '../utils/trimExtName.ts'\nimport { defineParser } from './defineParser.ts'\n\nconst { factory } = ts\n\n/**\n * Validates TypeScript AST nodes before printing to catch invalid nodes early.\n * Throws an error if any node has SyntaxKind.Unknown which would cause the TypeScript printer to crash.\n */\nexport function validateNodes(...nodes: ts.Node[]): void {\n for (const node of nodes) {\n if (!node) {\n throw new Error('Attempted to print undefined or null TypeScript node')\n }\n if (node.kind === ts.SyntaxKind.Unknown) {\n throw new Error(\n 'Invalid TypeScript AST node detected with SyntaxKind.Unknown. ' +\n `This typically indicates a schema pattern that couldn't be properly converted to TypeScript. ` +\n `Node: ${JSON.stringify(node, null, 2)}`,\n )\n }\n }\n}\n\n/**\n * Convert AST TypeScript/TSX nodes to a string based on the TypeScript printer.\n */\nexport function print(...elements: Array<ts.Node>): string {\n const sourceFile = ts.createSourceFile('print.tsx', '', ts.ScriptTarget.ES2022, true, ts.ScriptKind.TSX)\n\n const printer = ts.createPrinter({\n omitTrailingSemicolon: true,\n newLine: ts.NewLineKind.LineFeed,\n removeComments: false,\n noEmitHelpers: true,\n })\n\n for (const node of elements) {\n if (node.kind === ts.SyntaxKind.Unknown) {\n console.error('⚠️ Unknown node found:', node)\n }\n }\n\n const output = printer.printList(ts.ListFormat.MultiLine, factory.createNodeArray(elements.filter(Boolean)), sourceFile)\n\n return output.replace(/\\r\\n/g, '\\n')\n}\n\nexport function safePrint(...elements: Array<ts.Node>): string {\n validateNodes(...elements)\n\n return print(...elements)\n}\n\nexport function createImport({\n name,\n path,\n root,\n isTypeOnly = false,\n isNameSpace = false,\n}: {\n name: string | Array<string | { propertyName: string; name?: string }>\n path: string\n root?: string\n isTypeOnly?: boolean\n isNameSpace?: boolean\n}) {\n const resolvePath = root ? getRelativePath(root, path) : path\n\n // Namespace or default import\n if (!Array.isArray(name)) {\n if (isNameSpace) {\n return factory.createImportDeclaration(\n undefined,\n factory.createImportClause(isTypeOnly, undefined, factory.createNamespaceImport(factory.createIdentifier(name))),\n factory.createStringLiteral(resolvePath),\n undefined,\n )\n }\n\n return factory.createImportDeclaration(\n undefined,\n factory.createImportClause(isTypeOnly, factory.createIdentifier(name), undefined),\n factory.createStringLiteral(resolvePath),\n undefined,\n )\n }\n\n // Named imports\n const specifiers = name.map((item) => {\n if (typeof item === 'object') {\n const { propertyName, name: alias } = item\n return factory.createImportSpecifier(false, alias ? factory.createIdentifier(propertyName) : undefined, factory.createIdentifier(alias ?? propertyName))\n }\n\n return factory.createImportSpecifier(false, undefined, factory.createIdentifier(item))\n })\n\n return factory.createImportDeclaration(\n undefined,\n factory.createImportClause(isTypeOnly, undefined, factory.createNamedImports(specifiers)),\n factory.createStringLiteral(resolvePath),\n undefined,\n )\n}\n\nexport function createExport({\n path,\n asAlias,\n isTypeOnly = false,\n name,\n}: {\n path: string\n asAlias?: boolean\n isTypeOnly?: boolean\n name?: string | Array<ts.Identifier | string>\n}) {\n if (name && !Array.isArray(name) && !asAlias) {\n console.warn(`When using name as string, asAlias should be true ${name}`)\n }\n\n if (!Array.isArray(name)) {\n const parsedName = name?.match(/^\\d/) ? `_${name?.slice(1)}` : name\n\n return factory.createExportDeclaration(\n undefined,\n isTypeOnly,\n asAlias && parsedName ? factory.createNamespaceExport(factory.createIdentifier(parsedName)) : undefined,\n factory.createStringLiteral(path),\n undefined,\n )\n }\n\n return factory.createExportDeclaration(\n undefined,\n isTypeOnly,\n factory.createNamedExports(\n name.map((propertyName) => {\n return factory.createExportSpecifier(false, undefined, typeof propertyName === 'string' ? factory.createIdentifier(propertyName) : propertyName)\n }),\n ),\n factory.createStringLiteral(path),\n undefined,\n )\n}\n\nexport const typescriptParser = defineParser({\n name: 'typescript',\n extNames: ['.ts', '.js'],\n install() {},\n async parse(file, options = { extname: '.ts' }) {\n const sourceParts: Array<string> = []\n for (const item of file.sources) {\n if (item.value) {\n sourceParts.push(item.value)\n }\n }\n const source = sourceParts.join('\\n\\n')\n\n const importNodes: Array<ts.ImportDeclaration> = []\n for (const item of file.imports) {\n const importPath = item.root ? getRelativePath(item.root, item.path) : item.path\n const hasExtname = !!path.extname(importPath)\n\n importNodes.push(\n createImport({\n name: item.name,\n path: options.extname && hasExtname ? `${trimExtName(importPath)}${options.extname}` : item.root ? trimExtName(importPath) : importPath,\n isTypeOnly: item.isTypeOnly,\n isNameSpace: item.isNameSpace,\n }),\n )\n }\n\n const exportNodes: Array<ts.ExportDeclaration> = []\n for (const item of file.exports) {\n const exportPath = item.path\n const hasExtname = !!path.extname(exportPath)\n\n exportNodes.push(\n createExport({\n name: item.name,\n path: options.extname && hasExtname ? `${trimExtName(item.path)}${options.extname}` : trimExtName(item.path),\n isTypeOnly: item.isTypeOnly,\n asAlias: item.asAlias,\n }),\n )\n }\n\n const parts = [file.banner, print(...importNodes, ...exportNodes), source, file.footer].filter((segment): segment is string => segment != null)\n return parts.join('\\n')\n },\n})\n"],"mappings":";;;;;AAMA,MAAM,EAAE,YAAY;;;;;AAMpB,SAAgB,cAAc,GAAG,OAAwB;AACvD,MAAK,MAAM,QAAQ,OAAO;AACxB,MAAI,CAAC,KACH,OAAM,IAAI,MAAM,uDAAuD;AAEzE,MAAI,KAAK,SAAS,GAAG,WAAW,QAC9B,OAAM,IAAI,MACR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KAAK;GAC5E,MAAM,aAAa,CAAC,CAAC,KAAK,QAAQ,WAAW;AAE7C,eAAY,KACV,aAAa;IACX,MAAM,KAAK;IACX,MAAM,QAAQ,WAAW,aAAa,GAAG,YAAY,WAAW,GAAG,QAAQ,YAAY,KAAK,OAAO,YAAY,WAAW,GAAG;IAC7H,YAAY,KAAK;IACjB,aAAa,KAAK;IACnB,CAAC,CACH;;EAGH,MAAM,cAA2C,EAAE;AACnD,OAAK,MAAM,QAAQ,KAAK,SAAS;GAC/B,MAAM,aAAa,KAAK;GACxB,MAAM,aAAa,CAAC,CAAC,KAAK,QAAQ,WAAW;AAE7C,eAAY,KACV,aAAa;IACX,MAAM,KAAK;IACX,MAAM,QAAQ,WAAW,aAAa,GAAG,YAAY,KAAK,KAAK,GAAG,QAAQ,YAAY,YAAY,KAAK,KAAK;IAC5G,YAAY,KAAK;IACjB,SAAS,KAAK;IACf,CAAC,CACH;;AAIH,SADc;GAAC,KAAK;GAAQ,MAAM,GAAG,aAAa,GAAG,YAAY;GAAE;GAAQ,KAAK;GAAO,CAAC,QAAQ,YAA+B,WAAW,KAAK,CAClI,KAAK,KAAK;;CAE1B,CAAC"}
|
package/dist/parsers.cjs
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
-
const
|
|
3
|
-
const
|
|
4
|
-
const require_defaultParser = require('./defaultParser-BK-zOanQ.cjs');
|
|
2
|
+
const require_getRelativePath = require('./getRelativePath-DVG8dIzW.cjs');
|
|
3
|
+
const require_defaultParser = require('./defaultParser-BAgmtMo_.cjs');
|
|
5
4
|
const require_parsers_typescript = require('./parsers/typescript.cjs');
|
|
6
5
|
|
|
7
6
|
//#region src/parsers/tsxParser.ts
|
package/dist/parsers.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"parsers.cjs","names":["defineParser","typescriptParser"],"sources":["../src/parsers/tsxParser.ts"],"sourcesContent":["import { defineParser } from './defineParser.ts'\nimport { typescriptParser } from './typescriptParser.ts'\n\nexport const tsxParser = defineParser({\n name: 'tsx',\n extNames: ['.tsx', '.jsx'],\n install() {},\n async parse(file, options = { extname: '.tsx' }) {\n return typescriptParser.parse(file, options)\n },\n})\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"parsers.cjs","names":["defineParser","typescriptParser"],"sources":["../src/parsers/tsxParser.ts"],"sourcesContent":["import { defineParser } from './defineParser.ts'\nimport { typescriptParser } from './typescriptParser.ts'\n\nexport const tsxParser = defineParser({\n name: 'tsx',\n extNames: ['.tsx', '.jsx'],\n install() {},\n async parse(file, options = { extname: '.tsx' }) {\n return typescriptParser.parse(file, options)\n },\n})\n"],"mappings":";;;;;;AAGA,MAAa,YAAYA,qCAAa;CACpC,MAAM;CACN,UAAU,CAAC,QAAQ,OAAO;CAC1B,UAAU;CACV,MAAM,MAAM,MAAM,UAAU,EAAE,SAAS,QAAQ,EAAE;AAC/C,SAAOC,4CAAiB,MAAM,MAAM,QAAQ;;CAE/C,CAAC"}
|
package/dist/parsers.d.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { C as UserParser, S as Parser } from "./Fabric-CrRJykMN.js";
|
|
1
|
+
import { C as UserParser, S as Parser } from "./Fabric-BOjvMvNC.js";
|
|
3
2
|
import { typescriptParser } from "./parsers/typescript.js";
|
|
4
3
|
|
|
5
4
|
//#region src/parsers/defaultParser.d.ts
|
package/dist/parsers.js
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import { n as
|
|
2
|
-
import {
|
|
3
|
-
import { t as defaultParser } from "./defaultParser-BD_N68Bo.js";
|
|
1
|
+
import { n as defineParser } from "./getRelativePath-BcieQL5M.js";
|
|
2
|
+
import { t as defaultParser } from "./defaultParser-C1atU7yU.js";
|
|
4
3
|
import { typescriptParser } from "./parsers/typescript.js";
|
|
5
4
|
|
|
6
5
|
//#region src/parsers/tsxParser.ts
|
package/dist/parsers.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"parsers.js","names":[],"sources":["../src/parsers/tsxParser.ts"],"sourcesContent":["import { defineParser } from './defineParser.ts'\nimport { typescriptParser } from './typescriptParser.ts'\n\nexport const tsxParser = defineParser({\n name: 'tsx',\n extNames: ['.tsx', '.jsx'],\n install() {},\n async parse(file, options = { extname: '.tsx' }) {\n return typescriptParser.parse(file, options)\n },\n})\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"parsers.js","names":[],"sources":["../src/parsers/tsxParser.ts"],"sourcesContent":["import { defineParser } from './defineParser.ts'\nimport { typescriptParser } from './typescriptParser.ts'\n\nexport const tsxParser = defineParser({\n name: 'tsx',\n extNames: ['.tsx', '.jsx'],\n install() {},\n async parse(file, options = { extname: '.tsx' }) {\n return typescriptParser.parse(file, options)\n },\n})\n"],"mappings":";;;;;AAGA,MAAa,YAAY,aAAa;CACpC,MAAM;CACN,UAAU,CAAC,QAAQ,OAAO;CAC1B,UAAU;CACV,MAAM,MAAM,MAAM,UAAU,EAAE,SAAS,QAAQ,EAAE;AAC/C,SAAO,iBAAiB,MAAM,MAAM,QAAQ;;CAE/C,CAAC"}
|
package/dist/plugins.cjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
-
const require_chunk = require('./chunk-
|
|
3
|
-
const require_onProcessExit = require('./onProcessExit-
|
|
4
|
-
const require_getRelativePath = require('./getRelativePath-
|
|
2
|
+
const require_chunk = require('./chunk-uaV2rQ02.cjs');
|
|
3
|
+
const require_onProcessExit = require('./onProcessExit-DENCUkMz.cjs');
|
|
4
|
+
const require_getRelativePath = require('./getRelativePath-DVG8dIzW.cjs');
|
|
5
5
|
let node_path = require("node:path");
|
|
6
6
|
node_path = require_chunk.__toESM(node_path);
|
|
7
7
|
let node_fs = require("node:fs");
|
|
@@ -57,8 +57,7 @@ function getBarrelFiles({ files, root, mode }) {
|
|
|
57
57
|
const treeNode = require_onProcessExit.TreeNode.fromFiles(files, root);
|
|
58
58
|
if (!treeNode) return [];
|
|
59
59
|
treeNode.forEach((node) => {
|
|
60
|
-
|
|
61
|
-
if (!(node === null || node === void 0 ? void 0 : node.children) || !((_node$parent = node.parent) === null || _node$parent === void 0 ? void 0 : _node$parent.data.path)) return;
|
|
60
|
+
if (!node?.children || !node.parent?.data.path) return;
|
|
62
61
|
const parentPath = node.parent.data.path;
|
|
63
62
|
const barrelPath = node_path.default.join(parentPath, "index.ts");
|
|
64
63
|
let barrelFile = cachedFiles.get(barrelPath);
|
|
@@ -99,16 +98,13 @@ function getBarrelFiles({ files, root, mode }) {
|
|
|
99
98
|
}
|
|
100
99
|
});
|
|
101
100
|
const result = [...cachedFiles.values()];
|
|
102
|
-
if (mode === "all") return result.map((file) => {
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
...
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
}))
|
|
110
|
-
};
|
|
111
|
-
});
|
|
101
|
+
if (mode === "all") return result.map((file) => ({
|
|
102
|
+
...file,
|
|
103
|
+
exports: file.exports?.map((e) => ({
|
|
104
|
+
...e,
|
|
105
|
+
name: void 0
|
|
106
|
+
}))
|
|
107
|
+
}));
|
|
112
108
|
return result;
|
|
113
109
|
}
|
|
114
110
|
const barrelPlugin = definePlugin({
|
|
@@ -140,8 +136,7 @@ const barrelPlugin = definePlugin({
|
|
|
140
136
|
for (const file of barrelFiles) fileTypeCache.set(file, file.sources.every((source) => source.isTypeOnly));
|
|
141
137
|
const exports = [];
|
|
142
138
|
for (const file of barrelFiles) {
|
|
143
|
-
|
|
144
|
-
const containsOnlyTypes = (_fileTypeCache$get = fileTypeCache.get(file)) !== null && _fileTypeCache$get !== void 0 ? _fileTypeCache$get : false;
|
|
139
|
+
const containsOnlyTypes = fileTypeCache.get(file) ?? false;
|
|
145
140
|
for (const source of file.sources) {
|
|
146
141
|
if (!file.path || !source.isIndexable) continue;
|
|
147
142
|
exports.push({
|
|
@@ -172,25 +167,24 @@ const barrelPlugin = definePlugin({
|
|
|
172
167
|
//#region src/plugins/fsPlugin.ts
|
|
173
168
|
async function write(path, data, options = {}) {
|
|
174
169
|
if (typeof Bun !== "undefined") {
|
|
175
|
-
if (!data ||
|
|
170
|
+
if (!data || data?.trim() === "") return;
|
|
176
171
|
await Bun.write((0, node_path.resolve)(path), data.trim());
|
|
177
|
-
if (options
|
|
172
|
+
if (options?.sanity) {
|
|
178
173
|
const savedData = await Bun.file((0, node_path.resolve)(path)).text();
|
|
179
|
-
if (
|
|
174
|
+
if (savedData?.toString() !== data?.toString()) throw new Error(`Sanity check failed for ${path}\n\nData[${data.length}]:\n${data}\n\nSaved[${savedData.length}]:\n${savedData}\n`);
|
|
180
175
|
return savedData;
|
|
181
176
|
}
|
|
182
177
|
return data;
|
|
183
178
|
}
|
|
184
|
-
if (!data ||
|
|
179
|
+
if (!data || data?.trim() === "") return;
|
|
185
180
|
try {
|
|
186
|
-
|
|
187
|
-
if ((oldContent === null || oldContent === void 0 ? void 0 : oldContent.toString()) === (data === null || data === void 0 ? void 0 : data.toString())) return;
|
|
181
|
+
if ((await (0, node_fs_promises.readFile)((0, node_path.resolve)(path), { encoding: "utf-8" }))?.toString() === data?.toString()) return;
|
|
188
182
|
} catch (_err) {}
|
|
189
183
|
await (0, node_fs_promises.mkdir)((0, node_path.dirname)((0, node_path.resolve)(path)), { recursive: true });
|
|
190
184
|
await (0, node_fs_promises.writeFile)((0, node_path.resolve)(path), data.trim(), { encoding: "utf-8" });
|
|
191
|
-
if (options
|
|
185
|
+
if (options?.sanity) {
|
|
192
186
|
const savedData = await (0, node_fs_promises.readFile)((0, node_path.resolve)(path), { encoding: "utf-8" });
|
|
193
|
-
if (
|
|
187
|
+
if (savedData?.toString() !== data?.toString()) throw new Error(`Sanity check failed for ${path}\n\nData[${data.length}]:\n${data}\n\nSaved[${savedData.length}]:\n${savedData}\n`);
|
|
194
188
|
return savedData;
|
|
195
189
|
}
|
|
196
190
|
return data;
|
|
@@ -222,24 +216,22 @@ const fsPlugin = definePlugin({
|
|
|
222
216
|
|
|
223
217
|
//#endregion
|
|
224
218
|
//#region src/plugins/fsxPlugin/Runtime.ts
|
|
225
|
-
var _options = /* @__PURE__ */ new WeakMap();
|
|
226
|
-
var _renderPromise = /* @__PURE__ */ new WeakMap();
|
|
227
219
|
var Runtime = class {
|
|
220
|
+
#options;
|
|
221
|
+
exitPromise;
|
|
228
222
|
constructor(options) {
|
|
229
|
-
|
|
230
|
-
require_onProcessExit._defineProperty(this, "exitPromise", void 0);
|
|
231
|
-
require_onProcessExit._classPrivateFieldInitSpec(this, _renderPromise, Promise.resolve());
|
|
232
|
-
require_onProcessExit._defineProperty(this, "resolveExitPromise", () => {});
|
|
233
|
-
require_onProcessExit._defineProperty(this, "rejectExitPromise", () => {});
|
|
234
|
-
require_onProcessExit._defineProperty(this, "unsubscribeExit", () => {});
|
|
235
|
-
require_onProcessExit._classPrivateFieldSet2(_options, this, options);
|
|
223
|
+
this.#options = options;
|
|
236
224
|
this.unsubscribeExit = require_onProcessExit.onProcessExit((code) => {
|
|
237
225
|
this.unmount(code);
|
|
238
226
|
});
|
|
239
227
|
}
|
|
240
228
|
get fileManager() {
|
|
241
|
-
return
|
|
229
|
+
return this.#options.fileManager;
|
|
242
230
|
}
|
|
231
|
+
#renderPromise = Promise.resolve();
|
|
232
|
+
resolveExitPromise = () => {};
|
|
233
|
+
rejectExitPromise = () => {};
|
|
234
|
+
unsubscribeExit = () => {};
|
|
243
235
|
onError(error) {
|
|
244
236
|
throw error;
|
|
245
237
|
}
|
|
@@ -249,7 +241,7 @@ var Runtime = class {
|
|
|
249
241
|
}, 0);
|
|
250
242
|
}
|
|
251
243
|
async render(node) {
|
|
252
|
-
const treeNode =
|
|
244
|
+
const treeNode = this.#options.treeNode || new require_onProcessExit.TreeNode({
|
|
253
245
|
type: "Root",
|
|
254
246
|
props: {}
|
|
255
247
|
});
|
|
@@ -260,22 +252,20 @@ var Runtime = class {
|
|
|
260
252
|
onError: this.onError.bind(this)
|
|
261
253
|
};
|
|
262
254
|
try {
|
|
263
|
-
var _element;
|
|
264
255
|
treeNode.data.props = props;
|
|
265
256
|
const element = require_onProcessExit.Root({
|
|
266
257
|
...props,
|
|
267
258
|
children: node
|
|
268
259
|
});
|
|
269
|
-
await
|
|
270
|
-
return
|
|
260
|
+
await this.#renderPromise;
|
|
261
|
+
return element()?.toString() || "";
|
|
271
262
|
} catch (e) {
|
|
272
263
|
props.onError(e);
|
|
273
264
|
return "";
|
|
274
265
|
}
|
|
275
266
|
}
|
|
276
267
|
unmount(error) {
|
|
277
|
-
|
|
278
|
-
if ((_classPrivateFieldGet2$1 = require_onProcessExit._classPrivateFieldGet2(_options, this)) === null || _classPrivateFieldGet2$1 === void 0 ? void 0 : _classPrivateFieldGet2$1.debug) console.log("Unmount", error);
|
|
268
|
+
if (this.#options?.debug) console.log("Unmount", error);
|
|
279
269
|
this.unsubscribeExit();
|
|
280
270
|
if (error instanceof Error) {
|
|
281
271
|
this.rejectExitPromise(error);
|
package/dist/plugins.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plugins.cjs","names":["TreeNode","path","createFile","getRelativePath","onProcessExit","TreeNode","Root","clack"],"sources":["../src/plugins/definePlugin.ts","../src/plugins/barrelPlugin.ts","../src/plugins/fsPlugin.ts","../src/plugins/fsxPlugin/Runtime.ts","../src/plugins/fsxPlugin/fsxPlugin.ts","../src/plugins/loggerPlugin.ts"],"sourcesContent":["import type { Plugin, UserPlugin } from './types.ts'\n\n/**\n * Defines a Fabric plugin with type safety.\n *\n * Use this function to create plugins that hook into Fabric's lifecycle\n * events and extend its functionality.\n *\n * @param plugin - The plugin configuration object\n * @returns A typed plugin ready to use with Fabric\n *\n * @example\n * ```ts\n * import { definePlugin } from '@kubb/fabric-core'\n *\n * export const myPlugin = definePlugin({\n * name: 'my-plugin',\n * async setup(fabric) {\n * fabric.context.on('write:start', (files) => {\n * console.log(`Writing ${files.length} files`)\n * })\n * }\n * })\n * ```\n */\nexport function definePlugin<Options = unknown, TAppExtension extends Record<string, any> = {}>(\n plugin: UserPlugin<Options, TAppExtension>,\n): Plugin<Options, TAppExtension> {\n return {\n type: 'plugin',\n ...plugin,\n }\n}\n","/** biome-ignore-all lint/suspicious/useIterableCallbackReturn: not needed */\n\nimport path from 'node:path'\nimport { createFile } from '../createFile.ts'\nimport type * as KubbFile from '../KubbFile.ts'\nimport { getRelativePath } from '../utils/getRelativePath.ts'\nimport { TreeNode } from '../utils/TreeNode.ts'\nimport { definePlugin } from './definePlugin.ts'\n\ntype Mode = 'all' | 'named' | 'propagate' | false\n\ntype Options = {\n root: string\n mode: Mode\n dryRun?: boolean\n}\n\ntype WriteEntryOptions = {\n root: string\n mode: Mode\n}\n\ntype ExtendOptions = {\n /**\n * `fabric.writeEntry` should be called before `fabric.write`\n */\n writeEntry(options: WriteEntryOptions): Promise<void>\n}\n\ndeclare global {\n namespace Kubb {\n interface Fabric {\n /**\n * `fabric.writeEntry` should be called before `fabric.write`\n */\n writeEntry(options: WriteEntryOptions): Promise<void>\n }\n }\n}\n\ntype GetBarrelFilesOptions = {\n files: KubbFile.File[]\n root: string\n mode: Mode\n}\n\nexport function getBarrelFiles({ files, root, mode }: GetBarrelFilesOptions): Array<KubbFile.File> {\n // Do not generate when propagating or disabled\n if (mode === 'propagate' || mode === false) {\n return []\n }\n\n const indexableSourcesMap = new Map<KubbFile.File, Array<KubbFile.Source>>()\n\n for (const file of files) {\n const indexableSources: Array<KubbFile.Source> = []\n for (const source of file.sources || []) {\n if (source.isIndexable && source.name) {\n indexableSources.push(source)\n }\n }\n if (indexableSources.length > 0) {\n indexableSourcesMap.set(file, indexableSources)\n }\n }\n\n const cachedFiles = new Map<KubbFile.Path, KubbFile.File>()\n const dedupe = new Map<KubbFile.Path, Set<string>>()\n\n const treeNode = TreeNode.fromFiles(files, root)\n\n if (!treeNode) {\n return []\n }\n\n treeNode.forEach((node) => {\n // Only create a barrel for directory-like nodes that have a parent with a path\n if (!node?.children || !node.parent?.data.path) {\n return\n }\n\n const parentPath = node.parent.data.path as KubbFile.Path\n const barrelPath = path.join(parentPath, 'index.ts') as KubbFile.Path\n\n let barrelFile = cachedFiles.get(barrelPath)\n if (!barrelFile) {\n barrelFile = createFile({\n path: barrelPath,\n baseName: 'index.ts',\n imports: [],\n exports: [],\n sources: [],\n })\n cachedFiles.set(barrelPath, barrelFile)\n dedupe.set(barrelPath, new Set<string>())\n }\n\n const seen = dedupe.get(barrelPath)!\n\n for (const leaf of node.leaves) {\n const file = leaf.data.file\n if (!file || !file.path) {\n continue\n }\n\n const indexableSources = indexableSourcesMap.get(file)\n if (!indexableSources) {\n continue\n }\n\n for (const source of indexableSources) {\n const key = `${source.name}|${source.isTypeOnly ? '1' : '0'}`\n if (seen.has(key)) {\n continue\n }\n seen.add(key)\n\n // Always compute relative path from the parent directory to the file path\n barrelFile.exports!.push({\n name: [source.name!],\n path: getRelativePath(parentPath, file.path),\n isTypeOnly: source.isTypeOnly,\n })\n\n barrelFile!.sources.push({\n name: source.name!,\n isTypeOnly: source.isTypeOnly,\n value: '', // TODO use parser to generate import\n isExportable: mode === 'all' || mode === 'named',\n isIndexable: mode === 'all' || mode === 'named',\n })\n }\n }\n })\n\n const result = [...cachedFiles.values()]\n\n if (mode === 'all') {\n return result.map((file) => ({\n ...file,\n exports: file.exports?.map((e) => ({ ...e, name: undefined })),\n }))\n }\n\n return result\n}\n\nexport const barrelPlugin = definePlugin<Options, ExtendOptions>({\n name: 'barrel',\n install(ctx, options) {\n if (!options) {\n throw new Error('Barrel plugin requires options.root and options.mode')\n }\n\n if (!options.mode) {\n return undefined\n }\n\n ctx.on('files:writing:start', async (files) => {\n const root = options.root\n const barrelFiles = getBarrelFiles({ files, root, mode: options.mode })\n\n await ctx.fileManager.add(...barrelFiles)\n })\n },\n inject(ctx, options) {\n if (!options) {\n throw new Error('Barrel plugin requires options.root and options.mode')\n }\n\n return {\n async writeEntry({ root, mode }) {\n if (!mode || mode === 'propagate') {\n return undefined\n }\n\n const rootPath = path.resolve(root, 'index.ts')\n\n const barrelFiles: Array<KubbFile.ResolvedFile> = []\n for (const file of ctx.files) {\n for (const source of file.sources) {\n if (source.isIndexable) {\n barrelFiles.push(file)\n\n break\n }\n }\n }\n\n const fileTypeCache = new Map<KubbFile.ResolvedFile, boolean>()\n for (const file of barrelFiles) {\n fileTypeCache.set(\n file,\n file.sources.every((source) => source.isTypeOnly),\n )\n }\n\n const exports: Array<KubbFile.Export> = []\n for (const file of barrelFiles) {\n const containsOnlyTypes = fileTypeCache.get(file) ?? false\n\n for (const source of file.sources) {\n if (!file.path || !source.isIndexable) {\n continue\n }\n\n exports.push({\n name: mode === 'all' ? undefined : [source.name],\n path: getRelativePath(rootPath, file.path),\n isTypeOnly: mode === 'all' ? containsOnlyTypes : source.isTypeOnly,\n } as KubbFile.Export)\n }\n }\n\n const entryFile = createFile({\n path: rootPath,\n baseName: 'index.ts',\n imports: [],\n exports,\n sources: [],\n })\n\n await ctx.addFile(entryFile)\n\n await ctx.fileManager.write({\n mode: ctx.config.mode,\n dryRun: options.dryRun,\n parsers: ctx.installedParsers,\n })\n },\n }\n },\n})\n","import { rmSync } from 'node:fs'\nimport { mkdir, readFile, writeFile } from 'node:fs/promises'\nimport { dirname, resolve } from 'node:path'\nimport type * as KubbFile from '../KubbFile.ts'\nimport { definePlugin } from './definePlugin.ts'\n\ntype WriteOptions = {\n extension?: Record<KubbFile.Extname, KubbFile.Extname | ''>\n}\n\ntype Options = {\n dryRun?: boolean\n /**\n * Optional callback that is invoked whenever a file is written by the plugin.\n * Useful for tests to observe write operations without spying on internal functions.\n */\n onBeforeWrite?: (path: string, data: string | undefined) => void | Promise<void>\n clean?: {\n path: string\n }\n}\n\ntype ExtendOptions = {\n write(options?: WriteOptions): Promise<void>\n}\n\nexport async function write(path: string, data: string | undefined, options: { sanity?: boolean } = {}): Promise<string | undefined> {\n if (typeof Bun !== 'undefined') {\n if (!data || data?.trim() === '') {\n return undefined\n }\n\n await Bun.write(resolve(path), data.trim())\n\n if (options?.sanity) {\n const file = Bun.file(resolve(path))\n const savedData = await file.text()\n\n if (savedData?.toString() !== data?.toString()) {\n throw new Error(`Sanity check failed for ${path}\\n\\nData[${data.length}]:\\n${data}\\n\\nSaved[${savedData.length}]:\\n${savedData}\\n`)\n }\n\n return savedData\n }\n\n return data\n }\n\n if (!data || data?.trim() === '') {\n return undefined\n }\n\n try {\n const oldContent = await readFile(resolve(path), {\n encoding: 'utf-8',\n })\n if (oldContent?.toString() === data?.toString()) {\n return\n }\n } catch (_err) {\n /* empty */\n }\n\n await mkdir(dirname(resolve(path)), { recursive: true })\n await writeFile(resolve(path), data.trim(), { encoding: 'utf-8' })\n\n if (options?.sanity) {\n const savedData = await readFile(resolve(path), {\n encoding: 'utf-8',\n })\n\n if (savedData?.toString() !== data?.toString()) {\n throw new Error(`Sanity check failed for ${path}\\n\\nData[${data.length}]:\\n${data}\\n\\nSaved[${savedData.length}]:\\n${savedData}\\n`)\n }\n\n return savedData\n }\n\n return data\n}\n\ndeclare global {\n namespace Kubb {\n interface Fabric {\n write(options?: WriteOptions): Promise<void>\n }\n }\n}\n\nexport const fsPlugin = definePlugin<Options, ExtendOptions>({\n name: 'fs',\n install(ctx, options = {}) {\n if (options.clean) {\n rmSync(options.clean.path, { recursive: true, force: true })\n }\n\n ctx.on('file:processing:update', async ({ file, source }) => {\n if (options.onBeforeWrite) {\n await options.onBeforeWrite(file.path, source)\n }\n await write(file.path, source, { sanity: false })\n })\n },\n inject(ctx, { dryRun } = {}) {\n return {\n async write(\n options = {\n extension: { '.ts': '.ts' },\n },\n ) {\n await ctx.fileManager.write({\n mode: ctx.config.mode,\n extension: options.extension,\n dryRun,\n parsers: ctx.installedParsers,\n })\n\n await ctx.emit('lifecycle:end')\n },\n }\n },\n})\n","import { Root } from '../../components/Root.ts'\nimport type { ComponentNode } from '../../composables/useNodeTree.ts'\nimport type { FabricElement } from '../../Fabric.ts'\nimport type { FileManager } from '../../FileManager.ts'\nimport { onProcessExit } from '../../utils/onProcessExit.ts'\nimport { TreeNode } from '../../utils/TreeNode.ts'\n\ntype Options = {\n fileManager: FileManager\n treeNode?: TreeNode<ComponentNode>\n debug?: boolean\n}\n\nexport class Runtime {\n readonly #options: Options\n exitPromise?: Promise<void>\n\n constructor(options: Options) {\n this.#options = options\n\n // Unmount when process exits\n this.unsubscribeExit = onProcessExit((code) => {\n this.unmount(code)\n })\n }\n\n get fileManager() {\n return this.#options.fileManager\n }\n\n #renderPromise: Promise<void> = Promise.resolve()\n resolveExitPromise: () => void = () => {}\n rejectExitPromise: (reason?: Error) => void = () => {}\n unsubscribeExit: () => void = () => {}\n\n onError(error: Error): void {\n throw error\n }\n\n onExit(error?: Error): void {\n setTimeout(() => {\n this.unmount(error)\n }, 0)\n }\n\n async render(node: FabricElement): Promise<string> {\n const treeNode = this.#options.treeNode || new TreeNode<ComponentNode>({ type: 'Root', props: {} })\n\n const props = {\n fileManager: this.fileManager,\n treeNode,\n onExit: this.onExit.bind(this),\n onError: this.onError.bind(this),\n }\n\n try {\n treeNode.data.props = props\n\n const element = Root({ ...props, children: node })\n\n await this.#renderPromise\n\n return element()?.toString() || ''\n } catch (e) {\n props.onError(e as Error)\n return ''\n }\n }\n\n unmount(error?: Error | number | null): void {\n if (this.#options?.debug) {\n console.log('Unmount', error)\n }\n\n this.unsubscribeExit()\n\n if (error instanceof Error) {\n this.rejectExitPromise(error)\n return\n }\n\n this.resolveExitPromise()\n }\n\n async waitUntilExit(): Promise<void> {\n if (!this.exitPromise) {\n this.exitPromise = new Promise((resolve, reject) => {\n this.resolveExitPromise = resolve\n this.rejectExitPromise = reject\n })\n }\n\n return this.exitPromise\n }\n}\n","import type { ComponentNode } from '../../composables/useNodeTree.ts'\nimport type { FabricElement } from '../../Fabric.ts'\nimport { definePlugin } from '../../plugins/definePlugin.ts'\nimport type { TreeNode } from '../../utils/TreeNode.ts'\nimport { Runtime } from './Runtime.ts'\n\nexport type Options = {\n treeNode?: TreeNode<ComponentNode>\n /**\n * Set this to true to always see the result of the render in the console(line per render)\n */\n debug?: boolean\n}\n\ntype ExtendOptions = {\n render(App: FabricElement<any>): Promise<string>\n waitUntilExit(): Promise<void>\n}\n\ndeclare global {\n namespace Kubb {\n interface Fabric {\n render(App: FabricElement<any>): Promise<string>\n waitUntilExit(): Promise<void>\n }\n }\n}\n\nexport const fsxPlugin = definePlugin<Options, ExtendOptions>({\n name: 'fsx',\n install() {},\n inject(ctx, options = {}) {\n const runtime = new Runtime({ fileManager: ctx.fileManager, ...options })\n\n return {\n async render(App) {\n await ctx.emit('lifecycle:start')\n return runtime.render(App)\n },\n async waitUntilExit() {\n await runtime.waitUntilExit()\n },\n }\n },\n})\n","import { relative } from 'node:path'\nimport { styleText } from 'node:util'\nimport * as clack from '@clack/prompts'\nimport { definePlugin } from './definePlugin.ts'\n\ntype Options = {\n /**\n * Toggle progress bar output.\n * @default true\n */\n progress?: boolean\n}\n\nfunction pluralize(word: string, count: number) {\n return `${count} ${word}${count === 1 ? '' : 's'}`\n}\n\nconst DEFAULT_PROGRESS_BAR_SIZE = 30\n\nexport const loggerPlugin = definePlugin<Options>({\n name: 'logger',\n install(ctx, options = {}) {\n const { progress = true } = options\n\n const state = {\n spinner: clack.spinner(),\n isSpinning: false,\n progressBar: undefined as ReturnType<typeof clack.progress> | undefined,\n }\n\n function formatPath(path: string) {\n return relative(process.cwd(), path)\n }\n\n ctx.on('lifecycle:start', async () => {\n clack.intro(`${styleText('blue', 'Fabric')} ${styleText('dim', 'Starting run')}`)\n })\n\n ctx.on('lifecycle:render', async () => {\n clack.log.info(`${styleText('blue', 'ℹ')} Rendering application graph`)\n })\n\n ctx.on('files:added', async (files) => {\n if (!files.length) {\n return\n }\n\n clack.log.info(`${styleText('blue', 'ℹ')} Queued ${pluralize('file', files.length)}`)\n })\n\n ctx.on('file:resolve:path', async (file) => {\n clack.log.step(`Resolving path for ${styleText('dim', formatPath(file.path))}`)\n })\n\n ctx.on('file:resolve:name', async (file) => {\n clack.log.step(`Resolving name for ${styleText('dim', formatPath(file.path))}`)\n })\n\n ctx.on('files:processing:start', async (files) => {\n clack.log.step(`Processing ${styleText('green', pluralize('file', files.length))}`)\n\n if (progress) {\n state.progressBar = clack.progress({\n style: 'block',\n max: files.length,\n size: DEFAULT_PROGRESS_BAR_SIZE,\n })\n state.progressBar.start(`Processing ${files.length} files`)\n }\n })\n\n ctx.on('file:processing:start', async (file, index, total) => {\n if (!state.progressBar) {\n clack.log.step(`Processing ${styleText('dim', `[${index + 1}/${total}]`)} ${formatPath(file.path)}`)\n }\n })\n\n ctx.on('file:processing:update', async ({ processed, total, percentage, file }) => {\n if (state.progressBar) {\n // undefined = auto-increment by 1\n state.progressBar.advance(undefined, `Writing ${formatPath(file.path)}`)\n } else {\n const formattedPercentage = Number.isFinite(percentage) ? percentage.toFixed(1) : '0.0'\n clack.log.step(`Progress ${styleText('green', `${formattedPercentage}%`)} ${styleText('dim', `(${processed}/${total})`)} → ${formatPath(file.path)}`)\n }\n })\n\n ctx.on('file:processing:end', async (file, index, total) => {\n if (state.progressBar) {\n state.progressBar.message(`${styleText('green', '✓')} Finished ${styleText('dim', `[${index + 1}/${total}]`)} ${formatPath(file.path)}`)\n } else {\n clack.log.success(`${styleText('green', '✓')} Finished ${styleText('dim', `[${index + 1}/${total}]`)} ${formatPath(file.path)}`)\n }\n })\n\n ctx.on('files:processing:end', async (files) => {\n if (state.progressBar) {\n state.progressBar.stop(`${styleText('green', '✓')} Processed ${pluralize('file', files.length)}`)\n state.progressBar = undefined\n } else {\n clack.log.success(`${styleText('green', '✓')} Processed ${pluralize('file', files.length)}`)\n }\n })\n\n ctx.on('lifecycle:end', async () => {\n if (state.progressBar) {\n state.progressBar.stop()\n state.progressBar = undefined\n }\n\n clack.outro(`${styleText('blue', 'Fabric')} ${styleText('dim', 'completed')}`)\n })\n },\n})\n"],"mappings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GAAG;IAElI;AAEF,MAAI,GAAG,wBAAwB,OAAO,UAAU;AAC9C,OAAI,MAAM,aAAa;AACrB,UAAM,YAAY,KAAK,4BAAa,SAAS,IAAI,CAAC,aAAa,UAAU,QAAQ,MAAM,OAAO,GAAG;AACjG,UAAM,cAAc;SAEpB,gBAAM,IAAI,QAAQ,4BAAa,SAAS,IAAI,CAAC,aAAa,UAAU,QAAQ,MAAM,OAAO,GAAG;IAE9F;AAEF,MAAI,GAAG,iBAAiB,YAAY;AAClC,OAAI,MAAM,aAAa;AACrB,UAAM,YAAY,MAAM;AACxB,UAAM,cAAc;;AAGtB,kBAAM,MAAM,4BAAa,QAAQ,SAAS,CAAC,4BAAa,OAAO,YAAY,GAAG;IAC9E;;CAEL,CAAC"}
|
|
1
|
+
{"version":3,"file":"plugins.cjs","names":["TreeNode","path","createFile","getRelativePath","#options","onProcessExit","TreeNode","Root","#renderPromise","clack"],"sources":["../src/plugins/definePlugin.ts","../src/plugins/barrelPlugin.ts","../src/plugins/fsPlugin.ts","../src/plugins/fsxPlugin/Runtime.ts","../src/plugins/fsxPlugin/fsxPlugin.ts","../src/plugins/loggerPlugin.ts"],"sourcesContent":["import type { Plugin, UserPlugin } from './types.ts'\n\n/**\n * Defines a Fabric plugin with type safety.\n *\n * Use this function to create plugins that hook into Fabric's lifecycle\n * events and extend its functionality.\n *\n * @param plugin - The plugin configuration object\n * @returns A typed plugin ready to use with Fabric\n *\n * @example\n * ```ts\n * import { definePlugin } from '@kubb/fabric-core'\n *\n * export const myPlugin = definePlugin({\n * name: 'my-plugin',\n * async setup(fabric) {\n * fabric.context.on('write:start', (files) => {\n * console.log(`Writing ${files.length} files`)\n * })\n * }\n * })\n * ```\n */\nexport function definePlugin<Options = unknown, TAppExtension extends Record<string, any> = {}>(\n plugin: UserPlugin<Options, TAppExtension>,\n): Plugin<Options, TAppExtension> {\n return {\n type: 'plugin',\n ...plugin,\n }\n}\n","/** biome-ignore-all lint/suspicious/useIterableCallbackReturn: not needed */\n\nimport path from 'node:path'\nimport { createFile } from '../createFile.ts'\nimport type * as KubbFile from '../KubbFile.ts'\nimport { getRelativePath } from '../utils/getRelativePath.ts'\nimport { TreeNode } from '../utils/TreeNode.ts'\nimport { definePlugin } from './definePlugin.ts'\n\ntype Mode = 'all' | 'named' | 'propagate' | false\n\ntype Options = {\n root: string\n mode: Mode\n dryRun?: boolean\n}\n\ntype WriteEntryOptions = {\n root: string\n mode: Mode\n}\n\ntype ExtendOptions = {\n /**\n * `fabric.writeEntry` should be called before `fabric.write`\n */\n writeEntry(options: WriteEntryOptions): Promise<void>\n}\n\ndeclare global {\n namespace Kubb {\n interface Fabric {\n /**\n * `fabric.writeEntry` should be called before `fabric.write`\n */\n writeEntry(options: WriteEntryOptions): Promise<void>\n }\n }\n}\n\ntype GetBarrelFilesOptions = {\n files: KubbFile.File[]\n root: string\n mode: Mode\n}\n\nexport function getBarrelFiles({ files, root, mode }: GetBarrelFilesOptions): Array<KubbFile.File> {\n // Do not generate when propagating or disabled\n if (mode === 'propagate' || mode === false) {\n return []\n }\n\n const indexableSourcesMap = new Map<KubbFile.File, Array<KubbFile.Source>>()\n\n for (const file of files) {\n const indexableSources: Array<KubbFile.Source> = []\n for (const source of file.sources || []) {\n if (source.isIndexable && source.name) {\n indexableSources.push(source)\n }\n }\n if (indexableSources.length > 0) {\n indexableSourcesMap.set(file, indexableSources)\n }\n }\n\n const cachedFiles = new Map<KubbFile.Path, KubbFile.File>()\n const dedupe = new Map<KubbFile.Path, Set<string>>()\n\n const treeNode = TreeNode.fromFiles(files, root)\n\n if (!treeNode) {\n return []\n }\n\n treeNode.forEach((node) => {\n // Only create a barrel for directory-like nodes that have a parent with a path\n if (!node?.children || !node.parent?.data.path) {\n return\n }\n\n const parentPath = node.parent.data.path as KubbFile.Path\n const barrelPath = path.join(parentPath, 'index.ts') as KubbFile.Path\n\n let barrelFile = cachedFiles.get(barrelPath)\n if (!barrelFile) {\n barrelFile = createFile({\n path: barrelPath,\n baseName: 'index.ts',\n imports: [],\n exports: [],\n sources: [],\n })\n cachedFiles.set(barrelPath, barrelFile)\n dedupe.set(barrelPath, new Set<string>())\n }\n\n const seen = dedupe.get(barrelPath)!\n\n for (const leaf of node.leaves) {\n const file = leaf.data.file\n if (!file || !file.path) {\n continue\n }\n\n const indexableSources = indexableSourcesMap.get(file)\n if (!indexableSources) {\n continue\n }\n\n for (const source of indexableSources) {\n const key = `${source.name}|${source.isTypeOnly ? '1' : '0'}`\n if (seen.has(key)) {\n continue\n }\n seen.add(key)\n\n // Always compute relative path from the parent directory to the file path\n barrelFile.exports!.push({\n name: [source.name!],\n path: getRelativePath(parentPath, file.path),\n isTypeOnly: source.isTypeOnly,\n })\n\n barrelFile!.sources.push({\n name: source.name!,\n isTypeOnly: source.isTypeOnly,\n value: '', // TODO use parser to generate import\n isExportable: mode === 'all' || mode === 'named',\n isIndexable: mode === 'all' || mode === 'named',\n })\n }\n }\n })\n\n const result = [...cachedFiles.values()]\n\n if (mode === 'all') {\n return result.map((file) => ({\n ...file,\n exports: file.exports?.map((e) => ({ ...e, name: undefined })),\n }))\n }\n\n return result\n}\n\nexport const barrelPlugin = definePlugin<Options, ExtendOptions>({\n name: 'barrel',\n install(ctx, options) {\n if (!options) {\n throw new Error('Barrel plugin requires options.root and options.mode')\n }\n\n if (!options.mode) {\n return undefined\n }\n\n ctx.on('files:writing:start', async (files) => {\n const root = options.root\n const barrelFiles = getBarrelFiles({ files, root, mode: options.mode })\n\n await ctx.fileManager.add(...barrelFiles)\n })\n },\n inject(ctx, options) {\n if (!options) {\n throw new Error('Barrel plugin requires options.root and options.mode')\n }\n\n return {\n async writeEntry({ root, mode }) {\n if (!mode || mode === 'propagate') {\n return undefined\n }\n\n const rootPath = path.resolve(root, 'index.ts')\n\n const barrelFiles: Array<KubbFile.ResolvedFile> = []\n for (const file of ctx.files) {\n for (const source of file.sources) {\n if (source.isIndexable) {\n barrelFiles.push(file)\n\n break\n }\n }\n }\n\n const fileTypeCache = new Map<KubbFile.ResolvedFile, boolean>()\n for (const file of barrelFiles) {\n fileTypeCache.set(\n file,\n file.sources.every((source) => source.isTypeOnly),\n )\n }\n\n const exports: Array<KubbFile.Export> = []\n for (const file of barrelFiles) {\n const containsOnlyTypes = fileTypeCache.get(file) ?? false\n\n for (const source of file.sources) {\n if (!file.path || !source.isIndexable) {\n continue\n }\n\n exports.push({\n name: mode === 'all' ? undefined : [source.name],\n path: getRelativePath(rootPath, file.path),\n isTypeOnly: mode === 'all' ? containsOnlyTypes : source.isTypeOnly,\n } as KubbFile.Export)\n }\n }\n\n const entryFile = createFile({\n path: rootPath,\n baseName: 'index.ts',\n imports: [],\n exports,\n sources: [],\n })\n\n await ctx.addFile(entryFile)\n\n await ctx.fileManager.write({\n mode: ctx.config.mode,\n dryRun: options.dryRun,\n parsers: ctx.installedParsers,\n })\n },\n }\n },\n})\n","import { rmSync } from 'node:fs'\nimport { mkdir, readFile, writeFile } from 'node:fs/promises'\nimport { dirname, resolve } from 'node:path'\nimport type * as KubbFile from '../KubbFile.ts'\nimport { definePlugin } from './definePlugin.ts'\n\ntype WriteOptions = {\n extension?: Record<KubbFile.Extname, KubbFile.Extname | ''>\n}\n\ntype Options = {\n dryRun?: boolean\n /**\n * Optional callback that is invoked whenever a file is written by the plugin.\n * Useful for tests to observe write operations without spying on internal functions.\n */\n onBeforeWrite?: (path: string, data: string | undefined) => void | Promise<void>\n clean?: {\n path: string\n }\n}\n\ntype ExtendOptions = {\n write(options?: WriteOptions): Promise<void>\n}\n\nexport async function write(path: string, data: string | undefined, options: { sanity?: boolean } = {}): Promise<string | undefined> {\n if (typeof Bun !== 'undefined') {\n if (!data || data?.trim() === '') {\n return undefined\n }\n\n await Bun.write(resolve(path), data.trim())\n\n if (options?.sanity) {\n const file = Bun.file(resolve(path))\n const savedData = await file.text()\n\n if (savedData?.toString() !== data?.toString()) {\n throw new Error(`Sanity check failed for ${path}\\n\\nData[${data.length}]:\\n${data}\\n\\nSaved[${savedData.length}]:\\n${savedData}\\n`)\n }\n\n return savedData\n }\n\n return data\n }\n\n if (!data || data?.trim() === '') {\n return undefined\n }\n\n try {\n const oldContent = await readFile(resolve(path), {\n encoding: 'utf-8',\n })\n if (oldContent?.toString() === data?.toString()) {\n return\n }\n } catch (_err) {\n /* empty */\n }\n\n await mkdir(dirname(resolve(path)), { recursive: true })\n await writeFile(resolve(path), data.trim(), { encoding: 'utf-8' })\n\n if (options?.sanity) {\n const savedData = await readFile(resolve(path), {\n encoding: 'utf-8',\n })\n\n if (savedData?.toString() !== data?.toString()) {\n throw new Error(`Sanity check failed for ${path}\\n\\nData[${data.length}]:\\n${data}\\n\\nSaved[${savedData.length}]:\\n${savedData}\\n`)\n }\n\n return savedData\n }\n\n return data\n}\n\ndeclare global {\n namespace Kubb {\n interface Fabric {\n write(options?: WriteOptions): Promise<void>\n }\n }\n}\n\nexport const fsPlugin = definePlugin<Options, ExtendOptions>({\n name: 'fs',\n install(ctx, options = {}) {\n if (options.clean) {\n rmSync(options.clean.path, { recursive: true, force: true })\n }\n\n ctx.on('file:processing:update', async ({ file, source }) => {\n if (options.onBeforeWrite) {\n await options.onBeforeWrite(file.path, source)\n }\n await write(file.path, source, { sanity: false })\n })\n },\n inject(ctx, { dryRun } = {}) {\n return {\n async write(\n options = {\n extension: { '.ts': '.ts' },\n },\n ) {\n await ctx.fileManager.write({\n mode: ctx.config.mode,\n extension: options.extension,\n dryRun,\n parsers: ctx.installedParsers,\n })\n\n await ctx.emit('lifecycle:end')\n },\n }\n },\n})\n","import { Root } from '../../components/Root.ts'\nimport type { ComponentNode } from '../../composables/useNodeTree.ts'\nimport type { FabricElement } from '../../Fabric.ts'\nimport type { FileManager } from '../../FileManager.ts'\nimport { onProcessExit } from '../../utils/onProcessExit.ts'\nimport { TreeNode } from '../../utils/TreeNode.ts'\n\ntype Options = {\n fileManager: FileManager\n treeNode?: TreeNode<ComponentNode>\n debug?: boolean\n}\n\nexport class Runtime {\n readonly #options: Options\n exitPromise?: Promise<void>\n\n constructor(options: Options) {\n this.#options = options\n\n // Unmount when process exits\n this.unsubscribeExit = onProcessExit((code) => {\n this.unmount(code)\n })\n }\n\n get fileManager() {\n return this.#options.fileManager\n }\n\n #renderPromise: Promise<void> = Promise.resolve()\n resolveExitPromise: () => void = () => {}\n rejectExitPromise: (reason?: Error) => void = () => {}\n unsubscribeExit: () => void = () => {}\n\n onError(error: Error): void {\n throw error\n }\n\n onExit(error?: Error): void {\n setTimeout(() => {\n this.unmount(error)\n }, 0)\n }\n\n async render(node: FabricElement): Promise<string> {\n const treeNode = this.#options.treeNode || new TreeNode<ComponentNode>({ type: 'Root', props: {} })\n\n const props = {\n fileManager: this.fileManager,\n treeNode,\n onExit: this.onExit.bind(this),\n onError: this.onError.bind(this),\n }\n\n try {\n treeNode.data.props = props\n\n const element = Root({ ...props, children: node })\n\n await this.#renderPromise\n\n return element()?.toString() || ''\n } catch (e) {\n props.onError(e as Error)\n return ''\n }\n }\n\n unmount(error?: Error | number | null): void {\n if (this.#options?.debug) {\n console.log('Unmount', error)\n }\n\n this.unsubscribeExit()\n\n if (error instanceof Error) {\n this.rejectExitPromise(error)\n return\n }\n\n this.resolveExitPromise()\n }\n\n async waitUntilExit(): Promise<void> {\n if (!this.exitPromise) {\n this.exitPromise = new Promise((resolve, reject) => {\n this.resolveExitPromise = resolve\n this.rejectExitPromise = reject\n })\n }\n\n return this.exitPromise\n }\n}\n","import type { ComponentNode } from '../../composables/useNodeTree.ts'\nimport type { FabricElement } from '../../Fabric.ts'\nimport { definePlugin } from '../../plugins/definePlugin.ts'\nimport type { TreeNode } from '../../utils/TreeNode.ts'\nimport { Runtime } from './Runtime.ts'\n\nexport type Options = {\n treeNode?: TreeNode<ComponentNode>\n /**\n * Set this to true to always see the result of the render in the console(line per render)\n */\n debug?: boolean\n}\n\ntype ExtendOptions = {\n render(App: FabricElement<any>): Promise<string>\n waitUntilExit(): Promise<void>\n}\n\ndeclare global {\n namespace Kubb {\n interface Fabric {\n render(App: FabricElement<any>): Promise<string>\n waitUntilExit(): Promise<void>\n }\n }\n}\n\nexport const fsxPlugin = definePlugin<Options, ExtendOptions>({\n name: 'fsx',\n install() {},\n inject(ctx, options = {}) {\n const runtime = new Runtime({ fileManager: ctx.fileManager, ...options })\n\n return {\n async render(App) {\n await ctx.emit('lifecycle:start')\n return runtime.render(App)\n },\n async waitUntilExit() {\n await runtime.waitUntilExit()\n },\n }\n },\n})\n","import { relative } from 'node:path'\nimport { styleText } from 'node:util'\nimport * as clack from '@clack/prompts'\nimport { definePlugin } from './definePlugin.ts'\n\ntype Options = {\n /**\n * Toggle progress bar output.\n * @default true\n */\n progress?: boolean\n}\n\nfunction pluralize(word: string, count: number) {\n return `${count} ${word}${count === 1 ? '' : 's'}`\n}\n\nconst DEFAULT_PROGRESS_BAR_SIZE = 30\n\nexport const loggerPlugin = definePlugin<Options>({\n name: 'logger',\n install(ctx, options = {}) {\n const { progress = true } = options\n\n const state = {\n spinner: clack.spinner(),\n isSpinning: false,\n progressBar: undefined as ReturnType<typeof clack.progress> | undefined,\n }\n\n function formatPath(path: string) {\n return relative(process.cwd(), path)\n }\n\n ctx.on('lifecycle:start', async () => {\n clack.intro(`${styleText('blue', 'Fabric')} ${styleText('dim', 'Starting run')}`)\n })\n\n ctx.on('lifecycle:render', async () => {\n clack.log.info(`${styleText('blue', 'ℹ')} Rendering application graph`)\n })\n\n ctx.on('files:added', async (files) => {\n if (!files.length) {\n return\n }\n\n clack.log.info(`${styleText('blue', 'ℹ')} Queued ${pluralize('file', files.length)}`)\n })\n\n ctx.on('file:resolve:path', async (file) => {\n clack.log.step(`Resolving path for ${styleText('dim', formatPath(file.path))}`)\n })\n\n ctx.on('file:resolve:name', async (file) => {\n clack.log.step(`Resolving name for ${styleText('dim', formatPath(file.path))}`)\n })\n\n ctx.on('files:processing:start', async (files) => {\n clack.log.step(`Processing ${styleText('green', pluralize('file', files.length))}`)\n\n if (progress) {\n state.progressBar = clack.progress({\n style: 'block',\n max: files.length,\n size: DEFAULT_PROGRESS_BAR_SIZE,\n })\n state.progressBar.start(`Processing ${files.length} files`)\n }\n })\n\n ctx.on('file:processing:start', async (file, index, total) => {\n if (!state.progressBar) {\n clack.log.step(`Processing ${styleText('dim', `[${index + 1}/${total}]`)} ${formatPath(file.path)}`)\n }\n })\n\n ctx.on('file:processing:update', async ({ processed, total, percentage, file }) => {\n if (state.progressBar) {\n // undefined = auto-increment by 1\n state.progressBar.advance(undefined, `Writing ${formatPath(file.path)}`)\n } else {\n const formattedPercentage = Number.isFinite(percentage) ? percentage.toFixed(1) : '0.0'\n clack.log.step(`Progress ${styleText('green', `${formattedPercentage}%`)} ${styleText('dim', `(${processed}/${total})`)} → ${formatPath(file.path)}`)\n }\n })\n\n ctx.on('file:processing:end', async (file, index, total) => {\n if (state.progressBar) {\n state.progressBar.message(`${styleText('green', '✓')} Finished ${styleText('dim', `[${index + 1}/${total}]`)} ${formatPath(file.path)}`)\n } else {\n clack.log.success(`${styleText('green', '✓')} Finished ${styleText('dim', `[${index + 1}/${total}]`)} ${formatPath(file.path)}`)\n }\n })\n\n ctx.on('files:processing:end', async (files) => {\n if (state.progressBar) {\n state.progressBar.stop(`${styleText('green', '✓')} Processed ${pluralize('file', files.length)}`)\n state.progressBar = undefined\n } else {\n clack.log.success(`${styleText('green', '✓')} Processed ${pluralize('file', files.length)}`)\n }\n })\n\n ctx.on('lifecycle:end', async () => {\n if (state.progressBar) {\n state.progressBar.stop()\n state.progressBar = undefined\n }\n\n clack.outro(`${styleText('blue', 'Fabric')} ${styleText('dim', 'completed')}`)\n })\n },\n})\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAyBA,SAAgB,aACd,QACgC;AAChC,QAAO;EACL,MAAM;EACN,GAAG;EACJ;;;;;;ACeH,SAAgB,eAAe,EAAE,OAAO,MAAM,QAAqD;AAEjG,KAAI,SAAS,eAAe,SAAS,MACnC,QAAO,EAAE;CAGX,MAAM,sCAAsB,IAAI,KAA4C;AAE5E,MAAK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BAAiB,YAAY;AAClC,OAAI,MAAM,aAAa;AACrB,UAAM,YAAY,MAAM;AACxB,UAAM,cAAc;;AAGtB,kBAAM,MAAM,4BAAa,QAAQ,SAAS,CAAC,4BAAa,OAAO,YAAY,GAAG;IAC9E;;CAEL,CAAC"}
|
package/dist/plugins.d.ts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import { r as TreeNode, t as ComponentNode } from "./useNodeTree-CamNuFQP.js";
|
|
1
|
+
import { E as Extname, a as FabricElement, l as Plugin, u as UserPlugin } from "./Fabric-BOjvMvNC.js";
|
|
2
|
+
import { r as TreeNode, t as ComponentNode } from "./useNodeTree-6ZhDpI13.js";
|
|
4
3
|
|
|
5
4
|
//#region src/plugins/barrelPlugin.d.ts
|
|
6
5
|
type Mode = 'all' | 'named' | 'propagate' | false;
|