@kubb/fabric-core 0.1.3 → 0.1.4

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.
Files changed (56) hide show
  1. package/dist/{App-DUFbq4lD.d.ts → App-BxAl3dNP.d.ts} +14 -17
  2. package/dist/{App-DoQNlnGL.d.cts → App-D3DHa4Il.d.cts} +14 -17
  3. package/dist/createParser-B_RpW6sx.js +17 -0
  4. package/dist/createParser-B_RpW6sx.js.map +1 -0
  5. package/dist/createParser-DZB5qExa.cjs +29 -0
  6. package/dist/createParser-DZB5qExa.cjs.map +1 -0
  7. package/dist/defaultParser-Dl-OrbH1.cjs +20 -0
  8. package/dist/defaultParser-Dl-OrbH1.cjs.map +1 -0
  9. package/dist/defaultParser-vwyTb1XT.js +15 -0
  10. package/dist/defaultParser-vwyTb1XT.js.map +1 -0
  11. package/dist/defineApp-B9W1A5SV.d.ts +9 -0
  12. package/dist/defineApp-BP97CT5p.d.cts +9 -0
  13. package/dist/index.cjs +36 -66
  14. package/dist/index.cjs.map +1 -1
  15. package/dist/index.d.cts +3 -3
  16. package/dist/index.d.ts +3 -3
  17. package/dist/index.js +30 -60
  18. package/dist/index.js.map +1 -1
  19. package/dist/parsers/typescript.cjs +2 -1
  20. package/dist/parsers/typescript.d.cts +2 -2
  21. package/dist/parsers/typescript.d.ts +2 -2
  22. package/dist/parsers/typescript.js +2 -1
  23. package/dist/parsers.cjs +19 -6
  24. package/dist/parsers.cjs.map +1 -0
  25. package/dist/parsers.d.cts +2 -2
  26. package/dist/parsers.d.ts +2 -2
  27. package/dist/parsers.js +16 -3
  28. package/dist/parsers.js.map +1 -0
  29. package/dist/plugins.cjs +5 -5
  30. package/dist/plugins.cjs.map +1 -1
  31. package/dist/plugins.d.cts +8 -7
  32. package/dist/plugins.d.ts +8 -7
  33. package/dist/plugins.js +5 -5
  34. package/dist/plugins.js.map +1 -1
  35. package/dist/types.d.cts +2 -2
  36. package/dist/types.d.ts +2 -2
  37. package/dist/{typescriptParser-DOD1_QTe.d.cts → typescriptParser--N0n8KFn.d.cts} +2 -2
  38. package/dist/{typescriptParser-C9WJrwRd.d.ts → typescriptParser-CctRhsng.d.ts} +2 -2
  39. package/dist/{typescriptParser-BBGeFKlP.js → typescriptParser-CrzOv_Aw.js} +3 -17
  40. package/dist/typescriptParser-CrzOv_Aw.js.map +1 -0
  41. package/dist/{typescriptParser-BBbbmG5W.cjs → typescriptParser-JawJ8wET.cjs} +5 -31
  42. package/dist/{typescriptParser-BBGeFKlP.js.map → typescriptParser-JawJ8wET.cjs.map} +1 -1
  43. package/package.json +1 -1
  44. package/src/App.ts +9 -12
  45. package/src/FileProcessor.ts +13 -12
  46. package/src/createApp.ts +1 -13
  47. package/src/defineApp.ts +17 -32
  48. package/src/plugins/fsPlugin.ts +15 -11
  49. package/src/plugins/types.ts +2 -2
  50. package/dist/defineApp-C6WnoREI.d.ts +0 -14
  51. package/dist/defineApp-D1-njmtr.d.cts +0 -14
  52. package/dist/tsxParser-C741ZKCN.js +0 -26
  53. package/dist/tsxParser-C741ZKCN.js.map +0 -1
  54. package/dist/tsxParser-HDf_3TMc.cjs +0 -37
  55. package/dist/tsxParser-HDf_3TMc.cjs.map +0 -1
  56. package/dist/typescriptParser-BBbbmG5W.cjs.map +0 -1
@@ -1,4 +1,4 @@
1
- import { o as Parser } from "./App-DUFbq4lD.js";
1
+ import { o as Parser } from "./App-BxAl3dNP.js";
2
2
  import ts from "typescript";
3
3
 
4
4
  //#region src/parsers/typescriptParser.d.ts
@@ -47,4 +47,4 @@ declare function createExport({
47
47
  declare const typescriptParser: Parser<[], any>;
48
48
  //#endregion
49
49
  export { typescriptParser as i, createImport as n, print as r, createExport as t };
50
- //# sourceMappingURL=typescriptParser-C9WJrwRd.d.ts.map
50
+ //# sourceMappingURL=typescriptParser-CctRhsng.d.ts.map
@@ -1,21 +1,7 @@
1
+ import { n as trimExtName, t as createParser } from "./createParser-B_RpW6sx.js";
1
2
  import path, { normalize, relative } from "node:path";
2
3
  import ts from "typescript";
3
4
 
4
- //#region src/utils/trimExtName.ts
5
- function trimExtName(text) {
6
- return text.replace(/\.[^/.]+$/, "");
7
- }
8
-
9
- //#endregion
10
- //#region src/parsers/createParser.ts
11
- function createParser(parser) {
12
- return {
13
- type: "parser",
14
- ...parser
15
- };
16
- }
17
-
18
- //#endregion
19
5
  //#region src/utils/getRelativePath.ts
20
6
  function slash(path$1, platform = "linux") {
21
7
  const isWindowsPath = /^\\\\\?\\/.test(path$1);
@@ -129,5 +115,5 @@ const typescriptParser = createParser({
129
115
  });
130
116
 
131
117
  //#endregion
132
- export { createParser as a, typescriptParser as i, createImport as n, trimExtName as o, print as r, createExport as t };
133
- //# sourceMappingURL=typescriptParser-BBGeFKlP.js.map
118
+ export { typescriptParser as i, createImport as n, print as r, createExport as t };
119
+ //# sourceMappingURL=typescriptParser-CrzOv_Aw.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"typescriptParser-CrzOv_Aw.js","names":["path","output: string","path","importPropertyName: ts.Identifier | undefined","importName: ts.NamedImportBindings | undefined"],"sources":["../src/utils/getRelativePath.ts","../src/parsers/typescriptParser.ts"],"sourcesContent":["import { normalize, relative } from 'node:path'\n\nfunction slash(path: string, platform: 'windows' | 'mac' | 'linux' = 'linux') {\n const isWindowsPath = /^\\\\\\\\\\?\\\\/.test(path)\n const normalizedPath = normalize(path)\n\n if (['linux', 'mac'].includes(platform) && !isWindowsPath) {\n // linux and mac\n return normalizedPath.replaceAll(/\\\\/g, '/').replace('../', '')\n }\n\n // windows\n return normalizedPath.replaceAll(/\\\\/g, '/').replace('../', '')\n}\n\nexport function getRelativePath(rootDir?: string | null, filePath?: string | null, platform: 'windows' | 'mac' | 'linux' = 'linux'): string {\n if (!rootDir || !filePath) {\n throw new Error(`Root and file should be filled in when retrieving the relativePath, ${rootDir || ''} ${filePath || ''}`)\n }\n\n const relativePath = relative(rootDir, filePath)\n\n // On Windows, paths are separated with a \"\\\"\n // However, web browsers use \"/\" no matter the platform\n const slashedPath = slash(relativePath, platform)\n\n if (slashedPath.startsWith('../')) {\n return slashedPath\n }\n\n return `./${slashedPath}`\n}\n","import ts from 'typescript'\nimport { getRelativePath } from '../utils/getRelativePath.ts'\nimport { trimExtName } from '../utils/trimExtName.ts'\nimport path from 'node:path'\nimport { createParser } from './createParser.ts'\n\nconst { factory } = ts\n\ntype PrintOptions = {\n source?: string\n baseName?: string\n scriptKind?: ts.ScriptKind\n}\n\n/**\n * Escaped new lines in code with block comments so they can be restored by {@link restoreNewLines}\n */\nconst escapeNewLines = (code: string) => code.replace(/\\n\\n/g, '\\n/* :newline: */')\n\n/**\n * Reverses {@link escapeNewLines} and restores new lines\n */\nconst restoreNewLines = (code: string) => code.replace(/\\/\\* :newline: \\*\\//g, '\\n')\n\n/**\n * Convert AST TypeScript/TSX nodes to a string based on the TypeScript printer.\n * Ensures consistent output across environments.\n * Also works as a formatter when `source` is provided without `elements`.\n */\nexport function print(elements: Array<ts.Node> = [], { source = '', baseName = 'print.tsx', scriptKind = ts.ScriptKind.TSX }: PrintOptions = {}): string {\n const sourceFile = ts.createSourceFile(baseName, escapeNewLines(source), ts.ScriptTarget.ES2022, true, scriptKind)\n\n const printer = ts.createPrinter({\n omitTrailingSemicolon: true,\n newLine: ts.NewLineKind.LineFeed,\n removeComments: false,\n noEmitHelpers: true,\n })\n\n let output: string\n\n if (elements.length > 0) {\n // Print only provided nodes\n const nodes = elements.filter(Boolean).sort((a, b) => (a.pos ?? 0) - (b.pos ?? 0))\n output = printer.printList(ts.ListFormat.MultiLine, factory.createNodeArray(nodes), sourceFile)\n } else {\n // Format the whole file\n output = printer.printFile(sourceFile)\n }\n\n return restoreNewLines(output).replace(/\\r\\n/g, '\\n')\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 if (!Array.isArray(name)) {\n let importPropertyName: ts.Identifier | undefined = factory.createIdentifier(name)\n let importName: ts.NamedImportBindings | undefined\n\n if (isNameSpace) {\n importPropertyName = undefined\n importName = factory.createNamespaceImport(factory.createIdentifier(name))\n }\n\n return factory.createImportDeclaration(\n undefined,\n factory.createImportClause(isTypeOnly, importPropertyName, importName),\n factory.createStringLiteral(resolvePath),\n undefined,\n )\n }\n\n return factory.createImportDeclaration(\n undefined,\n factory.createImportClause(\n isTypeOnly,\n undefined,\n factory.createNamedImports(\n name.map((item) => {\n if (typeof item === 'object') {\n const obj = item as { propertyName: string; name?: string }\n if (obj.name) {\n return factory.createImportSpecifier(false, factory.createIdentifier(obj.propertyName), factory.createIdentifier(obj.name))\n }\n\n return factory.createImportSpecifier(false, undefined, factory.createIdentifier(obj.propertyName))\n }\n\n return factory.createImportSpecifier(false, undefined, factory.createIdentifier(item))\n }),\n ),\n ),\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 = createParser({\n name: 'typescript',\n extNames: ['.ts', '.js'],\n install() {},\n async parse(file, options = { extname: '.ts' }) {\n const source = file.sources.map((item) => item.value).join('\\n\\n')\n\n const importNodes = file.imports\n .map((item) => {\n const importPath = item.root ? getRelativePath(item.root, item.path) : item.path\n const hasExtname = !!path.extname(importPath)\n\n return createImport({\n name: item.name,\n path: options.extname && hasExtname ? `${trimExtName(importPath)}${options.extname}` : item.root ? trimExtName(importPath) : importPath,\n isTypeOnly: item.isTypeOnly,\n })\n })\n .filter(Boolean)\n\n const exportNodes = file.exports\n .map((item) => {\n const exportPath = item.path\n\n const hasExtname = !!path.extname(exportPath)\n\n return 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 .filter(Boolean)\n\n return [file.banner, print([...importNodes, ...exportNodes]), source, file.footer].join('\\n')\n },\n})\n"],"mappings":";;;;;AAEA,SAAS,MAAM,QAAc,WAAwC,SAAS;CAC5E,MAAM,gBAAgB,YAAY,KAAKA,OAAK;CAC5C,MAAM,iBAAiB,UAAUA,OAAK;AAEtC,KAAI,CAAC,SAAS,MAAM,CAAC,SAAS,SAAS,IAAI,CAAC,cAE1C,QAAO,eAAe,WAAW,OAAO,IAAI,CAAC,QAAQ,OAAO,GAAG;AAIjE,QAAO,eAAe,WAAW,OAAO,IAAI,CAAC,QAAQ,OAAO,GAAG;;AAGjE,SAAgB,gBAAgB,SAAyB,UAA0B,WAAwC,SAAiB;AAC1I,KAAI,CAAC,WAAW,CAAC,SACf,OAAM,IAAI,MAAM,uEAAuE,WAAW,GAAG,GAAG,YAAY,KAAK;CAO3H,MAAM,cAAc,MAJC,SAAS,SAAS,SAAS,EAIR,SAAS;AAEjD,KAAI,YAAY,WAAW,MAAM,CAC/B,QAAO;AAGT,QAAO,KAAK;;;;;ACxBd,MAAM,EAAE,YAAY;;;;AAWpB,MAAM,kBAAkB,SAAiB,KAAK,QAAQ,SAAS,oBAAoB;;;;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M,KAAK,KAAK,GAAG,KAAK;GAC5E,MAAM,aAAa,CAAC,CAAC,KAAK,QAAQ,WAAW;AAE7C,UAAO,aAAa;IAClB,MAAM,KAAK;IACX,MAAM,QAAQ,WAAW,aAAa,GAAG,YAAY,WAAW,GAAG,QAAQ,YAAY,KAAK,OAAO,YAAY,WAAW,GAAG;IAC7H,YAAY,KAAK;IAClB,CAAC;IACF,CACD,OAAO,QAAQ;EAElB,MAAM,cAAc,KAAK,QACtB,KAAK,SAAS;GACb,MAAM,aAAa,KAAK;GAExB,MAAM,aAAa,CAAC,CAAC,KAAK,QAAQ,WAAW;AAE7C,UAAO,aAAa;IAClB,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;IACF,CACD,OAAO,QAAQ;AAElB,SAAO;GAAC,KAAK;GAAQ,MAAM,CAAC,GAAG,aAAa,GAAG,YAAY,CAAC;GAAE;GAAQ,KAAK;GAAO,CAAC,KAAK,KAAK;;CAEhG,CAAC"}
@@ -1,24 +1,10 @@
1
1
  const require_chunk = require('./chunk-CUT6urMc.cjs');
2
+ const require_createParser = require('./createParser-DZB5qExa.cjs');
2
3
  let node_path = require("node:path");
3
4
  node_path = require_chunk.__toESM(node_path);
4
5
  let typescript = require("typescript");
5
6
  typescript = require_chunk.__toESM(typescript);
6
7
 
7
- //#region src/utils/trimExtName.ts
8
- function trimExtName(text) {
9
- return text.replace(/\.[^/.]+$/, "");
10
- }
11
-
12
- //#endregion
13
- //#region src/parsers/createParser.ts
14
- function createParser(parser) {
15
- return {
16
- type: "parser",
17
- ...parser
18
- };
19
- }
20
-
21
- //#endregion
22
8
  //#region src/utils/getRelativePath.ts
23
9
  function slash(path$1, platform = "linux") {
24
10
  const isWindowsPath = /^\\\\\?\\/.test(path$1);
@@ -97,7 +83,7 @@ function createExport({ path: path$1, asAlias, isTypeOnly = false, name }) {
97
83
  return factory.createExportSpecifier(false, void 0, typeof propertyName === "string" ? factory.createIdentifier(propertyName) : propertyName);
98
84
  })), factory.createStringLiteral(path$1), void 0);
99
85
  }
100
- const typescriptParser = createParser({
86
+ const typescriptParser = require_createParser.createParser({
101
87
  name: "typescript",
102
88
  extNames: [".ts", ".js"],
103
89
  install() {},
@@ -108,7 +94,7 @@ const typescriptParser = createParser({
108
94
  const hasExtname = !!node_path.default.extname(importPath);
109
95
  return createImport({
110
96
  name: item.name,
111
- path: options.extname && hasExtname ? `${trimExtName(importPath)}${options.extname}` : item.root ? trimExtName(importPath) : importPath,
97
+ path: options.extname && hasExtname ? `${require_createParser.trimExtName(importPath)}${options.extname}` : item.root ? require_createParser.trimExtName(importPath) : importPath,
112
98
  isTypeOnly: item.isTypeOnly
113
99
  });
114
100
  }).filter(Boolean);
@@ -117,7 +103,7 @@ const typescriptParser = createParser({
117
103
  const hasExtname = !!node_path.default.extname(exportPath);
118
104
  return createExport({
119
105
  name: item.name,
120
- path: options.extname && hasExtname ? `${trimExtName(item.path)}${options.extname}` : trimExtName(item.path),
106
+ path: options.extname && hasExtname ? `${require_createParser.trimExtName(item.path)}${options.extname}` : require_createParser.trimExtName(item.path),
121
107
  isTypeOnly: item.isTypeOnly,
122
108
  asAlias: item.asAlias
123
109
  });
@@ -144,28 +130,16 @@ Object.defineProperty(exports, 'createImport', {
144
130
  return createImport;
145
131
  }
146
132
  });
147
- Object.defineProperty(exports, 'createParser', {
148
- enumerable: true,
149
- get: function () {
150
- return createParser;
151
- }
152
- });
153
133
  Object.defineProperty(exports, 'print', {
154
134
  enumerable: true,
155
135
  get: function () {
156
136
  return print;
157
137
  }
158
138
  });
159
- Object.defineProperty(exports, 'trimExtName', {
160
- enumerable: true,
161
- get: function () {
162
- return trimExtName;
163
- }
164
- });
165
139
  Object.defineProperty(exports, 'typescriptParser', {
166
140
  enumerable: true,
167
141
  get: function () {
168
142
  return typescriptParser;
169
143
  }
170
144
  });
171
- //# sourceMappingURL=typescriptParser-BBbbmG5W.cjs.map
145
+ //# sourceMappingURL=typescriptParser-JawJ8wET.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"typescriptParser-BBGeFKlP.js","names":["path","output: string","path","importPropertyName: ts.Identifier | undefined","importName: ts.NamedImportBindings | undefined"],"sources":["../src/utils/trimExtName.ts","../src/parsers/createParser.ts","../src/utils/getRelativePath.ts","../src/parsers/typescriptParser.ts"],"sourcesContent":["export function trimExtName(text: string): string {\n return text.replace(/\\.[^/.]+$/, '')\n}\n","import type { Parser, UserParser } from './types.ts'\n\nexport function createParser<TOptions = any[], TMeta extends object = any>(parser: UserParser<TOptions, TMeta>): Parser<TOptions, TMeta> {\n return {\n type: 'parser',\n ...parser,\n }\n}\n","import { normalize, relative } from 'node:path'\n\nfunction slash(path: string, platform: 'windows' | 'mac' | 'linux' = 'linux') {\n const isWindowsPath = /^\\\\\\\\\\?\\\\/.test(path)\n const normalizedPath = normalize(path)\n\n if (['linux', 'mac'].includes(platform) && !isWindowsPath) {\n // linux and mac\n return normalizedPath.replaceAll(/\\\\/g, '/').replace('../', '')\n }\n\n // windows\n return normalizedPath.replaceAll(/\\\\/g, '/').replace('../', '')\n}\n\nexport function getRelativePath(rootDir?: string | null, filePath?: string | null, platform: 'windows' | 'mac' | 'linux' = 'linux'): string {\n if (!rootDir || !filePath) {\n throw new Error(`Root and file should be filled in when retrieving the relativePath, ${rootDir || ''} ${filePath || ''}`)\n }\n\n const relativePath = relative(rootDir, filePath)\n\n // On Windows, paths are separated with a \"\\\"\n // However, web browsers use \"/\" no matter the platform\n const slashedPath = slash(relativePath, platform)\n\n if (slashedPath.startsWith('../')) {\n return slashedPath\n }\n\n return `./${slashedPath}`\n}\n","import ts from 'typescript'\nimport { getRelativePath } from '../utils/getRelativePath.ts'\nimport { trimExtName } from '../utils/trimExtName.ts'\nimport path from 'node:path'\nimport { createParser } from './createParser.ts'\n\nconst { factory } = ts\n\ntype PrintOptions = {\n source?: string\n baseName?: string\n scriptKind?: ts.ScriptKind\n}\n\n/**\n * Escaped new lines in code with block comments so they can be restored by {@link restoreNewLines}\n */\nconst escapeNewLines = (code: string) => code.replace(/\\n\\n/g, '\\n/* :newline: */')\n\n/**\n * Reverses {@link escapeNewLines} and restores new lines\n */\nconst restoreNewLines = (code: string) => code.replace(/\\/\\* :newline: \\*\\//g, '\\n')\n\n/**\n * Convert AST TypeScript/TSX nodes to a string based on the TypeScript printer.\n * Ensures consistent output across environments.\n * Also works as a formatter when `source` is provided without `elements`.\n */\nexport function print(elements: Array<ts.Node> = [], { source = '', baseName = 'print.tsx', scriptKind = ts.ScriptKind.TSX }: PrintOptions = {}): string {\n const sourceFile = ts.createSourceFile(baseName, escapeNewLines(source), ts.ScriptTarget.ES2022, true, scriptKind)\n\n const printer = ts.createPrinter({\n omitTrailingSemicolon: true,\n newLine: ts.NewLineKind.LineFeed,\n removeComments: false,\n noEmitHelpers: true,\n })\n\n let output: string\n\n if (elements.length > 0) {\n // Print only provided nodes\n const nodes = elements.filter(Boolean).sort((a, b) => (a.pos ?? 0) - (b.pos ?? 0))\n output = printer.printList(ts.ListFormat.MultiLine, factory.createNodeArray(nodes), sourceFile)\n } else {\n // Format the whole file\n output = printer.printFile(sourceFile)\n }\n\n return restoreNewLines(output).replace(/\\r\\n/g, '\\n')\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 if (!Array.isArray(name)) {\n let importPropertyName: ts.Identifier | undefined = factory.createIdentifier(name)\n let importName: ts.NamedImportBindings | undefined\n\n if (isNameSpace) {\n importPropertyName = undefined\n importName = factory.createNamespaceImport(factory.createIdentifier(name))\n }\n\n return factory.createImportDeclaration(\n undefined,\n factory.createImportClause(isTypeOnly, importPropertyName, importName),\n factory.createStringLiteral(resolvePath),\n undefined,\n )\n }\n\n return factory.createImportDeclaration(\n undefined,\n factory.createImportClause(\n isTypeOnly,\n undefined,\n factory.createNamedImports(\n name.map((item) => {\n if (typeof item === 'object') {\n const obj = item as { propertyName: string; name?: string }\n if (obj.name) {\n return factory.createImportSpecifier(false, factory.createIdentifier(obj.propertyName), factory.createIdentifier(obj.name))\n }\n\n return factory.createImportSpecifier(false, undefined, factory.createIdentifier(obj.propertyName))\n }\n\n return factory.createImportSpecifier(false, undefined, factory.createIdentifier(item))\n }),\n ),\n ),\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 = createParser({\n name: 'typescript',\n extNames: ['.ts', '.js'],\n install() {},\n async parse(file, options = { extname: '.ts' }) {\n const source = file.sources.map((item) => item.value).join('\\n\\n')\n\n const importNodes = file.imports\n .map((item) => {\n const importPath = item.root ? getRelativePath(item.root, item.path) : item.path\n const hasExtname = !!path.extname(importPath)\n\n return createImport({\n name: item.name,\n path: options.extname && hasExtname ? `${trimExtName(importPath)}${options.extname}` : item.root ? trimExtName(importPath) : importPath,\n isTypeOnly: item.isTypeOnly,\n })\n })\n .filter(Boolean)\n\n const exportNodes = file.exports\n .map((item) => {\n const exportPath = item.path\n\n const hasExtname = !!path.extname(exportPath)\n\n return 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 .filter(Boolean)\n\n return [file.banner, print([...importNodes, ...exportNodes]), source, file.footer].join('\\n')\n },\n})\n"],"mappings":";;;;AAAA,SAAgB,YAAY,MAAsB;AAChD,QAAO,KAAK,QAAQ,aAAa,GAAG;;;;;ACCtC,SAAgB,aAA2D,QAA8D;AACvI,QAAO;EACL,MAAM;EACN,GAAG;EACJ;;;;;ACJH,SAAS,MAAM,QAAc,WAAwC,SAAS;CAC5E,MAAM,gBAAgB,YAAY,KAAKA,OAAK;CAC5C,MAAM,iBAAiB,UAAUA,OAAK;AAEtC,KAAI,CAAC,SAAS,MAAM,CAAC,SAAS,SAAS,IAAI,CAAC,cAE1C,QAAO,eAAe,WAAW,OAAO,IAAI,CAAC,QAAQ,OAAO,GAAG;AAIjE,QAAO,eAAe,WAAW,OAAO,IAAI,CAAC,QAAQ,OAAO,GAAG;;AAGjE,SAAgB,gBAAgB,SAAyB,UAA0B,WAAwC,SAAiB;AAC1I,KAAI,CAAC,WAAW,CAAC,SACf,OAAM,IAAI,MAAM,uEAAuE,WAAW,GAAG,GAAG,YAAY,KAAK;CAO3H,MAAM,cAAc,MAJC,SAAS,SAAS,SAAS,EAIR,SAAS;AAEjD,KAAI,YAAY,WAAW,MAAM,CAC/B,QAAO;AAGT,QAAO,KAAK;;;;;ACxBd,MAAM,EAAE,YAAY;;;;AAWpB,MAAM,kBAAkB,SAAiB,KAAK,QAAQ,SAAS,oBAAoB;;;;AAKnF,MAAM,mBAAmB,SAAiB,KAAK,QAAQ,wBAAwB,KAAK;;;;;;AAOpF,SAAgB,MAAM,WAA2B,EAAE,EAAE,E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AAM,KAAK;IACX,MAAM,QAAQ,WAAW,aAAa,GAAG,YAAY,WAAW,GAAG,QAAQ,YAAY,KAAK,OAAO,YAAY,WAAW,GAAG;IAC7H,YAAY,KAAK;IAClB,CAAC;IACF,CACD,OAAO,QAAQ;EAElB,MAAM,cAAc,KAAK,QACtB,KAAK,SAAS;GACb,MAAM,aAAa,KAAK;GAExB,MAAM,aAAa,CAAC,CAAC,KAAK,QAAQ,WAAW;AAE7C,UAAO,aAAa;IAClB,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;IACF,CACD,OAAO,QAAQ;AAElB,SAAO;GAAC,KAAK;GAAQ,MAAM,CAAC,GAAG,aAAa,GAAG,YAAY,CAAC;GAAE;GAAQ,KAAK;GAAO,CAAC,KAAK,KAAK;;CAEhG,CAAC"}
1
+ {"version":3,"file":"typescriptParser-JawJ8wET.cjs","names":["path","ts","output: string","path","importPropertyName: ts.Identifier | undefined","importName: ts.NamedImportBindings | undefined","createParser","trimExtName"],"sources":["../src/utils/getRelativePath.ts","../src/parsers/typescriptParser.ts"],"sourcesContent":["import { normalize, relative } from 'node:path'\n\nfunction slash(path: string, platform: 'windows' | 'mac' | 'linux' = 'linux') {\n const isWindowsPath = /^\\\\\\\\\\?\\\\/.test(path)\n const normalizedPath = normalize(path)\n\n if (['linux', 'mac'].includes(platform) && !isWindowsPath) {\n // linux and mac\n return normalizedPath.replaceAll(/\\\\/g, '/').replace('../', '')\n }\n\n // windows\n return normalizedPath.replaceAll(/\\\\/g, '/').replace('../', '')\n}\n\nexport function getRelativePath(rootDir?: string | null, filePath?: string | null, platform: 'windows' | 'mac' | 'linux' = 'linux'): string {\n if (!rootDir || !filePath) {\n throw new Error(`Root and file should be filled in when retrieving the relativePath, ${rootDir || ''} ${filePath || ''}`)\n }\n\n const relativePath = relative(rootDir, filePath)\n\n // On Windows, paths are separated with a \"\\\"\n // However, web browsers use \"/\" no matter the platform\n const slashedPath = slash(relativePath, platform)\n\n if (slashedPath.startsWith('../')) {\n return slashedPath\n }\n\n return `./${slashedPath}`\n}\n","import ts from 'typescript'\nimport { getRelativePath } from '../utils/getRelativePath.ts'\nimport { trimExtName } from '../utils/trimExtName.ts'\nimport path from 'node:path'\nimport { createParser } from './createParser.ts'\n\nconst { factory } = ts\n\ntype PrintOptions = {\n source?: string\n baseName?: string\n scriptKind?: ts.ScriptKind\n}\n\n/**\n * Escaped new lines in code with block comments so they can be restored by {@link restoreNewLines}\n */\nconst escapeNewLines = (code: string) => code.replace(/\\n\\n/g, '\\n/* :newline: */')\n\n/**\n * Reverses {@link escapeNewLines} and restores new lines\n */\nconst restoreNewLines = (code: string) => code.replace(/\\/\\* :newline: \\*\\//g, '\\n')\n\n/**\n * Convert AST TypeScript/TSX nodes to a string based on the TypeScript printer.\n * Ensures consistent output across environments.\n * Also works as a formatter when `source` is provided without `elements`.\n */\nexport function print(elements: Array<ts.Node> = [], { source = '', baseName = 'print.tsx', scriptKind = ts.ScriptKind.TSX }: PrintOptions = {}): string {\n const sourceFile = ts.createSourceFile(baseName, escapeNewLines(source), ts.ScriptTarget.ES2022, true, scriptKind)\n\n const printer = ts.createPrinter({\n omitTrailingSemicolon: true,\n newLine: ts.NewLineKind.LineFeed,\n removeComments: false,\n noEmitHelpers: true,\n })\n\n let output: string\n\n if (elements.length > 0) {\n // Print only provided nodes\n const nodes = elements.filter(Boolean).sort((a, b) => (a.pos ?? 0) - (b.pos ?? 0))\n output = printer.printList(ts.ListFormat.MultiLine, factory.createNodeArray(nodes), sourceFile)\n } else {\n // Format the whole file\n output = printer.printFile(sourceFile)\n }\n\n return restoreNewLines(output).replace(/\\r\\n/g, '\\n')\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 if (!Array.isArray(name)) {\n let importPropertyName: ts.Identifier | undefined = factory.createIdentifier(name)\n let importName: ts.NamedImportBindings | undefined\n\n if (isNameSpace) {\n importPropertyName = undefined\n importName = factory.createNamespaceImport(factory.createIdentifier(name))\n }\n\n return factory.createImportDeclaration(\n undefined,\n factory.createImportClause(isTypeOnly, importPropertyName, importName),\n factory.createStringLiteral(resolvePath),\n undefined,\n )\n }\n\n return factory.createImportDeclaration(\n undefined,\n factory.createImportClause(\n isTypeOnly,\n undefined,\n factory.createNamedImports(\n name.map((item) => {\n if (typeof item === 'object') {\n const obj = item as { propertyName: string; name?: string }\n if (obj.name) {\n return factory.createImportSpecifier(false, factory.createIdentifier(obj.propertyName), factory.createIdentifier(obj.name))\n }\n\n return factory.createImportSpecifier(false, undefined, factory.createIdentifier(obj.propertyName))\n }\n\n return factory.createImportSpecifier(false, undefined, factory.createIdentifier(item))\n }),\n ),\n ),\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 = createParser({\n name: 'typescript',\n extNames: ['.ts', '.js'],\n install() {},\n async parse(file, options = { extname: '.ts' }) {\n const source = file.sources.map((item) => item.value).join('\\n\\n')\n\n const importNodes = file.imports\n .map((item) => {\n const importPath = item.root ? getRelativePath(item.root, item.path) : item.path\n const hasExtname = !!path.extname(importPath)\n\n return createImport({\n name: item.name,\n path: options.extname && hasExtname ? `${trimExtName(importPath)}${options.extname}` : item.root ? trimExtName(importPath) : importPath,\n isTypeOnly: item.isTypeOnly,\n })\n })\n .filter(Boolean)\n\n const exportNodes = file.exports\n .map((item) => {\n const exportPath = item.path\n\n const hasExtname = !!path.extname(exportPath)\n\n return 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 .filter(Boolean)\n\n return [file.banner, print([...importNodes, ...exportNodes]), source, file.footer].join('\\n')\n },\n})\n"],"mappings":";;;;;;;;AAEA,SAAS,MAAM,QAAc,WAAwC,SAAS;CAC5E,MAAM,gBAAgB,YAAY,KAAKA,OAAK;CAC5C,MAAM,0CAA2BA,OAAK;AAEtC,KAAI,CAAC,SAAS,MAAM,CAAC,SAAS,SAAS,IAAI,CAAC,cAE1C,QAAO,eAAe,WAAW,OAAO,IAAI,CAAC,QAAQ,OAAO,GAAG;AAIjE,QAAO,eAAe,WAAW,OAAO,IAAI,CAAC,QAAQ,OAAO,GAAG;;AAGjE,SAAgB,gBAAgB,SAAyB,UAA0B,WAAwC,SAAiB;AAC1I,KAAI,CAAC,WAAW,CAAC,SACf,OAAM,IAAI,MAAM,uEAAuE,WAAW,GAAG,GAAG,YAAY,KAAK;CAO3H,MAAM,cAAc,8BAJU,SAAS,SAAS,EAIR,SAAS;AAEjD,KAAI,YAAY,WAAW,MAAM,CAC/B,QAAO;AAGT,QAAO,KAAK;;;;;ACxBd,MAAM,EAAE,YAAYC;;;;AAWpB,MAAM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tB,KAAK,SAAS;GACb,MAAM,aAAa,KAAK,OAAO,gBAAgB,KAAK,MAAM,KAAK,KAAK,GAAG,KAAK;GAC5E,MAAM,aAAa,CAAC,CAACH,kBAAK,QAAQ,WAAW;AAE7C,UAAO,aAAa;IAClB,MAAM,KAAK;IACX,MAAM,QAAQ,WAAW,aAAa,GAAGI,iCAAY,WAAW,GAAG,QAAQ,YAAY,KAAK,OAAOA,iCAAY,WAAW,GAAG;IAC7H,YAAY,KAAK;IAClB,CAAC;IACF,CACD,OAAO,QAAQ;EAElB,MAAM,cAAc,KAAK,QACtB,KAAK,SAAS;GACb,MAAM,aAAa,KAAK;GAExB,MAAM,aAAa,CAAC,CAACJ,kBAAK,QAAQ,WAAW;AAE7C,UAAO,aAAa;IAClB,MAAM,KAAK;IACX,MAAM,QAAQ,WAAW,aAAa,GAAGI,iCAAY,KAAK,KAAK,GAAG,QAAQ,YAAYA,iCAAY,KAAK,KAAK;IAC5G,YAAY,KAAK;IACjB,SAAS,KAAK;IACf,CAAC;IACF,CACD,OAAO,QAAQ;AAElB,SAAO;GAAC,KAAK;GAAQ,MAAM,CAAC,GAAG,aAAa,GAAG,YAAY,CAAC;GAAE;GAAQ,KAAK;GAAO,CAAC,KAAK,KAAK;;CAEhG,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kubb/fabric-core",
3
- "version": "0.1.3",
3
+ "version": "0.1.4",
4
4
  "description": "Core functionality for Kubb's plugin-based code generation system, providing the foundation for transforming OpenAPI specifications.",
5
5
  "keywords": [
6
6
  "typescript",
package/src/App.ts CHANGED
@@ -63,21 +63,19 @@ export type AppContext<TOptions = unknown> = {
63
63
  }
64
64
 
65
65
  export type Install<TOptions = any[] | object | undefined> = TOptions extends any[]
66
- ? (app: App, context: AppContext, ...options: TOptions) => void
66
+ ? (app: App, ...options: TOptions) => void
67
67
  : TOptions extends object
68
- ? (app: App, context: AppContext, options?: TOptions) => void
69
- : (app: App, context: AppContext) => void
68
+ ? (app: App, options?: TOptions) => void
69
+ : (app: App) => void
70
70
 
71
- export type Override<TOptions = any[] | object | undefined, TAppExtension extends Record<string, any> = {}> = TOptions extends any[]
72
- ? (app: App, context: AppContext, ...options: TOptions) => Partial<TAppExtension>
71
+ export type Inject<TOptions = any[] | object | undefined, TAppExtension extends Record<string, any> = {}> = TOptions extends any[]
72
+ ? (app: App, ...options: TOptions) => Partial<TAppExtension>
73
73
  : TOptions extends object
74
- ? (app: App, context: AppContext, options?: TOptions) => Partial<TAppExtension>
75
- : (app: App, context: AppContext) => Partial<TAppExtension>
74
+ ? (app: App, options?: TOptions) => Partial<TAppExtension>
75
+ : (app: App) => Partial<TAppExtension>
76
76
 
77
- export interface App {
78
- _component: Component
79
- render(): Promise<void>
80
- renderToString(): Promise<string>
77
+ export interface App<TOptions = unknown> {
78
+ context: AppContext<TOptions>
81
79
  files: Array<KubbFile.ResolvedFile>
82
80
  use<TOptions extends any[] | object = any, TMeta extends object = object, TAppExtension extends Record<string, any> = {}>(
83
81
  pluginOrParser: Plugin<TOptions, TAppExtension> | Parser<TOptions, TMeta>,
@@ -87,5 +85,4 @@ export interface App {
87
85
  pluginOrParser: Plugin<TOptions, TAppExtension> | Parser<TOptions, TMeta>,
88
86
  ): this & TAppExtension
89
87
  addFile(...files: Array<KubbFile.File>): Promise<void>
90
- waitUntilExit(): Promise<void>
91
88
  }
@@ -1,13 +1,10 @@
1
1
  import type * as KubbFile from './KubbFile.ts'
2
2
  import pLimit from 'p-limit'
3
- import path from 'node:path'
4
3
 
5
4
  import type { Parser } from './parsers/types.ts'
6
5
  import { defaultParser } from './parsers/defaultParser.ts'
7
6
  import { AsyncEventEmitter } from './utils/AsyncEventEmitter.ts'
8
7
  import type { AppEvents } from './App.ts'
9
- import { typescriptParser } from './parsers/typescriptParser.ts'
10
- import { tsxParser } from './parsers/tsxParser.ts'
11
8
 
12
9
  export type ProcessFilesProps = {
13
10
  parsers?: Set<Parser>
@@ -34,19 +31,20 @@ export class FileProcessor {
34
31
  return this
35
32
  }
36
33
 
37
- get #defaultParser(): Set<Parser> {
38
- return new Set<Parser>([typescriptParser, tsxParser, defaultParser])
39
- }
40
-
41
- async parse(file: KubbFile.ResolvedFile, { parsers = this.#defaultParser, extension }: GetParseOptions = {}): Promise<string> {
42
- const extname = path.extname(file.path) as KubbFile.Extname
34
+ async parse(file: KubbFile.ResolvedFile, { parsers = new Set(), extension }: GetParseOptions = {}): Promise<string> {
43
35
  const parseExtName = extension?.[file.extname] || undefined
44
36
 
45
- if (!extname) {
37
+ if (!file.extname) {
46
38
  return defaultParser.parse(file, { extname: parseExtName })
47
39
  }
48
40
 
49
- const parser = [...parsers].find((item) => item.extNames?.includes(extname))
41
+ let parser: Parser | undefined
42
+ for (const item of parsers) {
43
+ if (item.extNames?.includes(file.extname)) {
44
+ parser = item
45
+ break
46
+ }
47
+ }
50
48
 
51
49
  if (!parser) {
52
50
  return defaultParser.parse(file, { extname: parseExtName })
@@ -67,7 +65,10 @@ export class FileProcessor {
67
65
 
68
66
  if (!dryRun) {
69
67
  const source = await this.parse(resolvedFile, { extension, parsers })
70
- await this.events.emit('process:progress', { file: resolvedFile, source, processed, percentage: (processed / total) * 100, total })
68
+ const nextProcessed = processed + 1
69
+ const percentage = (nextProcessed / total) * 100
70
+ processed = nextProcessed
71
+ await this.events.emit('process:progress', { file: resolvedFile, source, processed, percentage, total })
71
72
  }
72
73
 
73
74
  await this.events.emit('file:end', { file: resolvedFile, index, total })
package/src/createApp.ts CHANGED
@@ -1,15 +1,3 @@
1
1
  import { defineApp } from './defineApp.ts'
2
2
 
3
- export const createApp = defineApp(() => {
4
- return {
5
- async render() {
6
- throw new Error('Method not implemented')
7
- },
8
- async renderToString() {
9
- throw new Error('Method not implemented')
10
- },
11
- async waitUntilExit() {
12
- throw new Error('Method not implemented')
13
- },
14
- }
15
- })
3
+ export const createApp = defineApp()
package/src/defineApp.ts CHANGED
@@ -1,22 +1,16 @@
1
1
  import { FileManager } from './FileManager.ts'
2
- import { isFunction, isPromise } from 'remeda'
2
+ import { isFunction } from 'remeda'
3
3
  import type { Plugin } from './plugins/types.ts'
4
4
  import type { Parser } from './parsers/types.ts'
5
5
  import { AsyncEventEmitter } from './utils/AsyncEventEmitter.ts'
6
6
  import type { App, AppContext, Component, AppEvents } from './App.ts'
7
7
 
8
- type AppRenderer = {
9
- render(): Promise<void> | void
10
- renderToString(): Promise<string> | string
11
- waitUntilExit(): Promise<void>
12
- }
13
-
14
- type RootRenderFunction<THostElement, TContext extends AppContext> = (this: TContext, container: THostElement, context: TContext) => AppRenderer
8
+ type RootRenderFunction<TApp extends App> = (app: TApp) => void | Promise<void>
15
9
 
16
- export type DefineApp<TContext extends AppContext> = (rootComponent?: Component, options?: TContext['options']) => App
10
+ export type DefineApp<TOptions> = (rootComponent?: Component, options?: TOptions) => App
17
11
 
18
- export function defineApp<THostElement, TContext extends AppContext>(instance: RootRenderFunction<THostElement, TContext>): DefineApp<TContext> {
19
- function createApp(rootComponent: Component, options?: TContext['options']): App {
12
+ export function defineApp<TOptions = unknown>(instance?: RootRenderFunction<App<TOptions>>): DefineApp<TOptions> {
13
+ function createApp(options?: TOptions): App {
20
14
  const events = new AsyncEventEmitter<AppEvents>()
21
15
  const installedPlugins = new Set<Plugin>()
22
16
  const installedParsers = new Set<Parser>()
@@ -27,31 +21,18 @@ export function defineApp<THostElement, TContext extends AppContext>(instance: R
27
21
  fileManager,
28
22
  installedPlugins,
29
23
  installedParsers,
30
- } as TContext
31
-
32
- const { render, renderToString, waitUntilExit } = instance.call(context, rootComponent, context)
24
+ } as AppContext<TOptions>
33
25
 
34
26
  const app = {
35
- _component: rootComponent,
36
- async render() {
37
- if (isPromise(render)) {
38
- await render()
39
- } else {
40
- render()
41
- }
42
- },
43
- async renderToString() {
44
- return renderToString()
45
- },
27
+ context,
46
28
  get files() {
47
29
  return fileManager.files
48
30
  },
49
- waitUntilExit,
50
31
  async addFile(...newFiles) {
51
32
  await fileManager.add(...newFiles)
52
33
  },
53
34
  use(pluginOrParser, ...options) {
54
- const args = Array.isArray(options) ? options : [options[0]]
35
+ const args = options
55
36
 
56
37
  if (pluginOrParser.type === 'plugin') {
57
38
  if (installedPlugins.has(pluginOrParser)) {
@@ -60,10 +41,10 @@ export function defineApp<THostElement, TContext extends AppContext>(instance: R
60
41
  installedPlugins.add(pluginOrParser)
61
42
  }
62
43
 
63
- if (pluginOrParser.override && isFunction(pluginOrParser.override)) {
64
- const overrider = pluginOrParser.override
44
+ if (pluginOrParser.inject && isFunction(pluginOrParser.inject)) {
45
+ const injecter = pluginOrParser.inject
65
46
 
66
- const extraApp = (overrider as any)(app, context, ...args)
47
+ const extraApp = (injecter as any)(app, ...args)
67
48
  Object.assign(app, extraApp)
68
49
  }
69
50
  }
@@ -78,14 +59,18 @@ export function defineApp<THostElement, TContext extends AppContext>(instance: R
78
59
  if (pluginOrParser && isFunction(pluginOrParser.install)) {
79
60
  const installer = pluginOrParser.install
80
61
 
81
- ;(installer as any)(app, context, ...args)
62
+ ;(installer as any)(app, ...args)
82
63
  }
83
64
 
84
65
  return app
85
66
  },
86
- } as App
67
+ } as App<TOptions>
87
68
 
69
+ // start
88
70
  events.emit('start', { app })
71
+ if (instance) {
72
+ instance(app)
73
+ }
89
74
 
90
75
  return app
91
76
  }
@@ -4,6 +4,11 @@ import fs from 'fs-extra'
4
4
  import { resolve } from 'node:path'
5
5
  import type * as KubbFile from '../KubbFile.ts'
6
6
 
7
+ type WriteOptions = {
8
+ extension?: Record<KubbFile.Extname, KubbFile.Extname | ''>
9
+ dryRun?: boolean
10
+ }
11
+
7
12
  type Options = {
8
13
  /**
9
14
  * Optional callback that is invoked whenever a file is written by the plugin.
@@ -12,6 +17,10 @@ type Options = {
12
17
  onWrite?: (path: string, data: string) => void | Promise<void>
13
18
  }
14
19
 
20
+ type ExtendOptions = {
21
+ write(options?: WriteOptions): Promise<void>
22
+ }
23
+
15
24
  export async function write(path: string, data: string, options: { sanity?: boolean } = {}): Promise<string | undefined> {
16
25
  if (data.trim() === '') {
17
26
  return undefined
@@ -71,29 +80,24 @@ export async function write(path: string, data: string, options: { sanity?: bool
71
80
  )(path, data.trim(), options)
72
81
  }
73
82
 
74
- type WriteOptions = {
75
- extension?: Record<KubbFile.Extname, KubbFile.Extname | ''>
76
- dryRun?: boolean
77
- }
78
-
79
83
  declare module '../index.ts' {
80
84
  interface App {
81
85
  write(options?: WriteOptions): Promise<void>
82
86
  }
83
87
  }
84
88
 
85
- export const fsPlugin = createPlugin<Options, { write(options?: WriteOptions): Promise<void> }>({
89
+ export const fsPlugin = createPlugin<Options, ExtendOptions>({
86
90
  name: 'fs',
87
91
  scope: 'write',
88
- async install(_app, context, options) {
89
- context.events.on('process:progress', async ({ file, source }) => {
92
+ async install(app, options) {
93
+ app.context.events.on('process:progress', async ({ file, source }) => {
90
94
  if (options?.onWrite) {
91
95
  await options.onWrite(file.path, source)
92
96
  }
93
97
  await write(file.path, source, { sanity: false })
94
98
  })
95
99
  },
96
- override(_app, context) {
100
+ inject(app) {
97
101
  return {
98
102
  async write(
99
103
  options = {
@@ -101,10 +105,10 @@ export const fsPlugin = createPlugin<Options, { write(options?: WriteOptions): P
101
105
  dryRun: false,
102
106
  },
103
107
  ) {
104
- await context.fileManager.write({
108
+ await app.context.fileManager.write({
105
109
  extension: options.extension,
106
110
  dryRun: options.dryRun,
107
- parsers: context.installedParsers,
111
+ parsers: app.context.installedParsers,
108
112
  })
109
113
  },
110
114
  }
@@ -1,4 +1,4 @@
1
- import type { Install, Override } from '../App.ts'
1
+ import type { Install, Inject } from '../App.ts'
2
2
 
3
3
  export type Plugin<TOptions = any[], TAppExtension extends Record<string, any> = {}> = {
4
4
  name: string
@@ -9,7 +9,7 @@ export type Plugin<TOptions = any[], TAppExtension extends Record<string, any> =
9
9
  * Runtime app overrides or extensions.
10
10
  * Merged into the app instance after install.
11
11
  */
12
- override?: Override<TOptions, TAppExtension>
12
+ inject?: Inject<TOptions, TAppExtension>
13
13
  }
14
14
 
15
15
  export type UserPlugin<TOptions = any[], TAppExtension extends Record<string, any> = {}> = Omit<Plugin<TOptions, TAppExtension>, 'type'>
@@ -1,14 +0,0 @@
1
- import { n as AppContext, r as Component, t as App } from "./App-DUFbq4lD.js";
2
-
3
- //#region src/defineApp.d.ts
4
- type AppRenderer = {
5
- render(): Promise<void> | void;
6
- renderToString(): Promise<string> | string;
7
- waitUntilExit(): Promise<void>;
8
- };
9
- type RootRenderFunction<THostElement, TContext extends AppContext> = (this: TContext, container: THostElement, context: TContext) => AppRenderer;
10
- type DefineApp<TContext extends AppContext> = (rootComponent?: Component, options?: TContext['options']) => App;
11
- declare function defineApp<THostElement, TContext extends AppContext>(instance: RootRenderFunction<THostElement, TContext>): DefineApp<TContext>;
12
- //#endregion
13
- export { defineApp as n, DefineApp as t };
14
- //# sourceMappingURL=defineApp-C6WnoREI.d.ts.map
@@ -1,14 +0,0 @@
1
- import { n as AppContext, r as Component, t as App } from "./App-DoQNlnGL.cjs";
2
-
3
- //#region src/defineApp.d.ts
4
- type AppRenderer = {
5
- render(): Promise<void> | void;
6
- renderToString(): Promise<string> | string;
7
- waitUntilExit(): Promise<void>;
8
- };
9
- type RootRenderFunction<THostElement, TContext extends AppContext> = (this: TContext, container: THostElement, context: TContext) => AppRenderer;
10
- type DefineApp<TContext extends AppContext> = (rootComponent?: Component, options?: TContext['options']) => App;
11
- declare function defineApp<THostElement, TContext extends AppContext>(instance: RootRenderFunction<THostElement, TContext>): DefineApp<TContext>;
12
- //#endregion
13
- export { defineApp as n, DefineApp as t };
14
- //# sourceMappingURL=defineApp-D1-njmtr.d.cts.map
@@ -1,26 +0,0 @@
1
- import { a as createParser, i as typescriptParser } from "./typescriptParser-BBGeFKlP.js";
2
-
3
- //#region src/parsers/defaultParser.ts
4
- const defaultParser = createParser({
5
- name: "default",
6
- extNames: [".json"],
7
- install() {},
8
- async parse(file) {
9
- return file.sources.map((item) => item.value).join("\n\n");
10
- }
11
- });
12
-
13
- //#endregion
14
- //#region src/parsers/tsxParser.ts
15
- const tsxParser = createParser({
16
- name: "tsx",
17
- extNames: [".tsx", ".jsx"],
18
- install() {},
19
- async parse(file, options = { extname: ".tsx" }) {
20
- return typescriptParser.parse(file, options);
21
- }
22
- });
23
-
24
- //#endregion
25
- export { defaultParser as n, tsxParser as t };
26
- //# sourceMappingURL=tsxParser-C741ZKCN.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"tsxParser-C741ZKCN.js","names":[],"sources":["../src/parsers/defaultParser.ts","../src/parsers/tsxParser.ts"],"sourcesContent":["import { createParser } from './createParser.ts'\n\nexport const defaultParser = createParser({\n name: 'default',\n extNames: ['.json'],\n install() {},\n async parse(file) {\n return file.sources.map((item) => item.value).join('\\n\\n')\n },\n})\n","import { typescriptParser } from './typescriptParser.ts'\nimport { createParser } from './createParser.ts'\n\nexport const tsxParser = createParser({\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":";;;AAEA,MAAa,gBAAgB,aAAa;CACxC,MAAM;CACN,UAAU,CAAC,QAAQ;CACnB,UAAU;CACV,MAAM,MAAM,MAAM;AAChB,SAAO,KAAK,QAAQ,KAAK,SAAS,KAAK,MAAM,CAAC,KAAK,OAAO;;CAE7D,CAAC;;;;ACNF,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"}
@@ -1,37 +0,0 @@
1
- const require_typescriptParser = require('./typescriptParser-BBbbmG5W.cjs');
2
-
3
- //#region src/parsers/defaultParser.ts
4
- const defaultParser = require_typescriptParser.createParser({
5
- name: "default",
6
- extNames: [".json"],
7
- install() {},
8
- async parse(file) {
9
- return file.sources.map((item) => item.value).join("\n\n");
10
- }
11
- });
12
-
13
- //#endregion
14
- //#region src/parsers/tsxParser.ts
15
- const tsxParser = require_typescriptParser.createParser({
16
- name: "tsx",
17
- extNames: [".tsx", ".jsx"],
18
- install() {},
19
- async parse(file, options = { extname: ".tsx" }) {
20
- return require_typescriptParser.typescriptParser.parse(file, options);
21
- }
22
- });
23
-
24
- //#endregion
25
- Object.defineProperty(exports, 'defaultParser', {
26
- enumerable: true,
27
- get: function () {
28
- return defaultParser;
29
- }
30
- });
31
- Object.defineProperty(exports, 'tsxParser', {
32
- enumerable: true,
33
- get: function () {
34
- return tsxParser;
35
- }
36
- });
37
- //# sourceMappingURL=tsxParser-HDf_3TMc.cjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"tsxParser-HDf_3TMc.cjs","names":["createParser","createParser","typescriptParser"],"sources":["../src/parsers/defaultParser.ts","../src/parsers/tsxParser.ts"],"sourcesContent":["import { createParser } from './createParser.ts'\n\nexport const defaultParser = createParser({\n name: 'default',\n extNames: ['.json'],\n install() {},\n async parse(file) {\n return file.sources.map((item) => item.value).join('\\n\\n')\n },\n})\n","import { typescriptParser } from './typescriptParser.ts'\nimport { createParser } from './createParser.ts'\n\nexport const tsxParser = createParser({\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":";;;AAEA,MAAa,gBAAgBA,sCAAa;CACxC,MAAM;CACN,UAAU,CAAC,QAAQ;CACnB,UAAU;CACV,MAAM,MAAM,MAAM;AAChB,SAAO,KAAK,QAAQ,KAAK,SAAS,KAAK,MAAM,CAAC,KAAK,OAAO;;CAE7D,CAAC;;;;ACNF,MAAa,YAAYC,sCAAa;CACpC,MAAM;CACN,UAAU,CAAC,QAAQ,OAAO;CAC1B,UAAU;CACV,MAAM,MAAM,MAAM,UAAU,EAAE,SAAS,QAAQ,EAAE;AAC/C,SAAOC,0CAAiB,MAAM,MAAM,QAAQ;;CAE/C,CAAC"}