@kubb/fabric-core 0.0.0-canary-20251022200241 → 0.0.0-canary-20251023132618

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-BaOaS0oU.d.ts} +19 -17
  2. package/dist/{App-DoQNlnGL.d.cts → App-kfFIExH4.d.cts} +19 -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/index-B4UcK65Y.d.ts +18 -0
  12. package/dist/index-C-k1b344.d.cts +18 -0
  13. package/dist/index.cjs +36 -66
  14. package/dist/index.cjs.map +1 -1
  15. package/dist/index.d.cts +3 -14
  16. package/dist/index.d.ts +3 -14
  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 +16 -8
  32. package/dist/plugins.d.ts +16 -8
  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-BBGeFKlP.js → typescriptParser-CrzOv_Aw.js} +3 -17
  38. package/dist/typescriptParser-CrzOv_Aw.js.map +1 -0
  39. package/dist/{typescriptParser-DOD1_QTe.d.cts → typescriptParser-DpZnax-m.d.cts} +2 -2
  40. package/dist/{typescriptParser-BBbbmG5W.cjs → typescriptParser-JawJ8wET.cjs} +5 -31
  41. package/dist/{typescriptParser-BBGeFKlP.js.map → typescriptParser-JawJ8wET.cjs.map} +1 -1
  42. package/dist/{typescriptParser-C9WJrwRd.d.ts → typescriptParser-ouLUNUEs.d.ts} +2 -2
  43. package/package.json +1 -1
  44. package/src/App.ts +15 -12
  45. package/src/FileProcessor.ts +13 -12
  46. package/src/createApp.ts +1 -13
  47. package/src/defineApp.ts +19 -32
  48. package/src/plugins/fsPlugin.ts +26 -12
  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
package/src/defineApp.ts CHANGED
@@ -1,22 +1,18 @@
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
- import type { App, AppContext, Component, AppEvents } from './App.ts'
6
+ import type { 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
- }
8
+ import type { App } from './index.ts'
13
9
 
14
- type RootRenderFunction<THostElement, TContext extends AppContext> = (this: TContext, container: THostElement, context: TContext) => AppRenderer
10
+ type RootRenderFunction<TApp extends App> = (app: TApp) => void | Promise<void>
15
11
 
16
- export type DefineApp<TContext extends AppContext> = (rootComponent?: Component, options?: TContext['options']) => App
12
+ export type DefineApp<TOptions> = (rootComponent?: Component, options?: TOptions) => App
17
13
 
18
- export function defineApp<THostElement, TContext extends AppContext>(instance: RootRenderFunction<THostElement, TContext>): DefineApp<TContext> {
19
- function createApp(rootComponent: Component, options?: TContext['options']): App {
14
+ export function defineApp<TOptions = unknown>(instance?: RootRenderFunction<App<TOptions>>): DefineApp<TOptions> {
15
+ function createApp(options?: TOptions): App {
20
16
  const events = new AsyncEventEmitter<AppEvents>()
21
17
  const installedPlugins = new Set<Plugin>()
22
18
  const installedParsers = new Set<Parser>()
@@ -27,31 +23,18 @@ export function defineApp<THostElement, TContext extends AppContext>(instance: R
27
23
  fileManager,
28
24
  installedPlugins,
29
25
  installedParsers,
30
- } as TContext
31
-
32
- const { render, renderToString, waitUntilExit } = instance.call(context, rootComponent, context)
26
+ } as AppContext<TOptions>
33
27
 
34
28
  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
- },
29
+ context,
46
30
  get files() {
47
31
  return fileManager.files
48
32
  },
49
- waitUntilExit,
50
33
  async addFile(...newFiles) {
51
34
  await fileManager.add(...newFiles)
52
35
  },
53
36
  use(pluginOrParser, ...options) {
54
- const args = Array.isArray(options) ? options : [options[0]]
37
+ const args = options
55
38
 
56
39
  if (pluginOrParser.type === 'plugin') {
57
40
  if (installedPlugins.has(pluginOrParser)) {
@@ -60,10 +43,10 @@ export function defineApp<THostElement, TContext extends AppContext>(instance: R
60
43
  installedPlugins.add(pluginOrParser)
61
44
  }
62
45
 
63
- if (pluginOrParser.override && isFunction(pluginOrParser.override)) {
64
- const overrider = pluginOrParser.override
46
+ if (pluginOrParser.inject && isFunction(pluginOrParser.inject)) {
47
+ const injecter = pluginOrParser.inject
65
48
 
66
- const extraApp = (overrider as any)(app, context, ...args)
49
+ const extraApp = (injecter as any)(app, ...args)
67
50
  Object.assign(app, extraApp)
68
51
  }
69
52
  }
@@ -78,14 +61,18 @@ export function defineApp<THostElement, TContext extends AppContext>(instance: R
78
61
  if (pluginOrParser && isFunction(pluginOrParser.install)) {
79
62
  const installer = pluginOrParser.install
80
63
 
81
- ;(installer as any)(app, context, ...args)
64
+ ;(installer as any)(app, ...args)
82
65
  }
83
66
 
84
67
  return app
85
68
  },
86
- } as App
69
+ } as App<TOptions>
87
70
 
71
+ // start
88
72
  events.emit('start', { app })
73
+ if (instance) {
74
+ instance(app)
75
+ }
89
76
 
90
77
  return app
91
78
  }
@@ -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,34 @@ 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
- declare module '../index.ts' {
83
+ // biome-ignore lint/suspicious/noTsIgnore: production ready
84
+ // @ts-ignore
85
+ declare module '@kubb/fabric-core' {
80
86
  interface App {
81
87
  write(options?: WriteOptions): Promise<void>
82
88
  }
83
89
  }
84
90
 
85
- export const fsPlugin = createPlugin<Options, { write(options?: WriteOptions): Promise<void> }>({
91
+ declare global {
92
+ namespace Kubb {
93
+ interface App {
94
+ write(options?: WriteOptions): Promise<void>
95
+ }
96
+ }
97
+ }
98
+
99
+ export const fsPlugin = createPlugin<Options, ExtendOptions>({
86
100
  name: 'fs',
87
101
  scope: 'write',
88
- async install(_app, context, options) {
89
- context.events.on('process:progress', async ({ file, source }) => {
102
+ async install(app, options) {
103
+ app.context.events.on('process:progress', async ({ file, source }) => {
90
104
  if (options?.onWrite) {
91
105
  await options.onWrite(file.path, source)
92
106
  }
93
107
  await write(file.path, source, { sanity: false })
94
108
  })
95
109
  },
96
- override(_app, context) {
110
+ inject(app) {
97
111
  return {
98
112
  async write(
99
113
  options = {
@@ -101,10 +115,10 @@ export const fsPlugin = createPlugin<Options, { write(options?: WriteOptions): P
101
115
  dryRun: false,
102
116
  },
103
117
  ) {
104
- await context.fileManager.write({
118
+ await app.context.fileManager.write({
105
119
  extension: options.extension,
106
120
  dryRun: options.dryRun,
107
- parsers: context.installedParsers,
121
+ parsers: app.context.installedParsers,
108
122
  })
109
123
  },
110
124
  }
@@ -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"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"typescriptParser-BBbbmG5W.cjs","names":["path","ts","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,\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