@kubb/fabric-core 0.7.0 → 0.7.1

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kubb/fabric-core",
3
- "version": "0.7.0",
3
+ "version": "0.7.1",
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",
@@ -23,24 +23,24 @@
23
23
  "type": "module",
24
24
  "exports": {
25
25
  ".": {
26
- "import": "./dist/index.js",
27
- "require": "./dist/index.cjs"
26
+ "require": "./dist/index.cjs",
27
+ "import": "./dist/index.js"
28
28
  },
29
29
  "./parsers": {
30
- "import": "./dist/parsers.js",
31
- "require": "./dist/parsers.cjs"
30
+ "require": "./dist/parsers.cjs",
31
+ "import": "./dist/parsers.js"
32
32
  },
33
33
  "./parsers/typescript": {
34
- "import": "./dist/parsers/typescript.js",
35
- "require": "./dist/parsers/typescript.cjs"
34
+ "require": "./dist/parsers/typescript.cjs",
35
+ "import": "./dist/parsers/typescript.js"
36
36
  },
37
37
  "./plugins": {
38
- "import": "./dist/plugins.js",
39
- "require": "./dist/plugins.cjs"
38
+ "require": "./dist/plugins.cjs",
39
+ "import": "./dist/plugins.js"
40
40
  },
41
41
  "./types": {
42
- "import": "./dist/types.js",
43
- "require": "./dist/types.cjs"
42
+ "require": "./dist/types.cjs",
43
+ "import": "./dist/types.js"
44
44
  },
45
45
  "./package.json": "./package.json"
46
46
  },
@@ -104,8 +104,8 @@
104
104
  "scripts": {
105
105
  "build": "tsdown && size-limit",
106
106
  "clean": "npx rimraf ./dist",
107
- "lint": "bun biome lint .",
108
- "lint:fix": "bun biome lint --fix --unsafe .",
107
+ "lint": "pnpm biome lint .",
108
+ "lint:fix": "pnpm biome lint --fix --unsafe .",
109
109
  "release": "pnpm publish --no-git-check",
110
110
  "release:canary": "bash ../../.github/canary.sh && node ../../scripts/build.js canary && pnpm publish --no-git-check",
111
111
  "start": "tsdown --watch ./src",
@@ -1 +0,0 @@
1
- {"version":3,"file":"defineProperty-BOlj8-IY.cjs","names":["n","r","e","t","e","r","n","i","t","r","n","i","e","e","t","n","r","i","uniqueBy","exports","prev: Array<KubbFile.Export>","prev: Array<KubbFile.Import>","path","trimExtName"],"sources":["../../../node_modules/.pnpm/remeda@2.32.0/node_modules/remeda/dist/utilityEvaluators-DORpnx39.js","../../../node_modules/.pnpm/remeda@2.32.0/node_modules/remeda/dist/pipe-jLehR9-P.js","../../../node_modules/.pnpm/remeda@2.32.0/node_modules/remeda/dist/purryFromLazy-3oywCNIb.js","../../../node_modules/.pnpm/remeda@2.32.0/node_modules/remeda/dist/uniqueBy-C_PxkF_D.js","../src/createFile.ts"],"sourcesContent":["const e={done:!0,hasNext:!1},t={done:!1,hasNext:!1},n=()=>e,r=e=>({hasNext:!0,next:e,done:!1});export{t as SKIP_ITEM,n as lazyEmptyEvaluator,r as lazyIdentityEvaluator};\n//# sourceMappingURL=utilityEvaluators-DORpnx39.js.map","import{SKIP_ITEM as e}from\"./utilityEvaluators-DORpnx39.js\";function t(e,...t){let a=e,o=t.map(e=>`lazy`in e?r(e):void 0),s=0;for(;s<t.length;){if(o[s]===void 0||!i(a)){let e=t[s];a=e(a),s+=1;continue}let e=[];for(let n=s;n<t.length;n++){let t=o[n];if(t===void 0||(e.push(t),t.isSingle))break}let r=[];for(let t of a)if(n(t,r,e))break;let{isSingle:c}=e.at(-1);a=c?r[0]:r,s+=e.length}return a}function n(t,r,i){if(i.length===0)return r.push(t),!1;let a=t,o=e,s=!1;for(let[e,t]of i.entries()){let{index:c,items:l}=t;if(l.push(a),o=t(a,c,l),t.index+=1,o.hasNext){if(o.hasMany??!1){for(let t of o.next)if(n(t,r,i.slice(e+1)))return!0;return s}a=o.next}if(!o.hasNext)break;o.done&&(s=!0)}return o.hasNext&&r.push(a),s}function r(e){let{lazy:t,lazyArgs:n}=e,r=t(...n);return Object.assign(r,{isSingle:t.single??!1,index:0,items:[]})}function i(e){return typeof e==`string`||typeof e==`object`&&!!e&&Symbol.iterator in e}export{t as pipe};\n//# sourceMappingURL=pipe-jLehR9-P.js.map","import{pipe as e}from\"./pipe-jLehR9-P.js\";function t(t,n){let r=n.length-t.length;if(r===1){let[r,...i]=n;return e(r,{lazy:t,lazyArgs:i})}if(r===0){let r={lazy:t,lazyArgs:n};return Object.assign(t=>e(t,r),r)}throw Error(`Wrong number of arguments`)}export{t as purryFromLazy};\n//# sourceMappingURL=purryFromLazy-3oywCNIb.js.map","import{SKIP_ITEM as e}from\"./utilityEvaluators-DORpnx39.js\";import{purryFromLazy as t}from\"./purryFromLazy-3oywCNIb.js\";function n(...e){return t(r,e)}function r(t){let n=t,r=new Set;return(t,i,a)=>{let o=n(t,i,a);return r.has(o)?e:(r.add(o),{done:!1,hasNext:!0,next:t})}}export{n as uniqueBy};\n//# sourceMappingURL=uniqueBy-C_PxkF_D.js.map","import { createHash } from 'node:crypto'\nimport path from 'node:path'\nimport { orderBy } from 'natural-orderby'\nimport { uniqueBy } from 'remeda'\nimport type * as KubbFile from './KubbFile.ts'\nimport { trimExtName } from './utils/trimExtName.ts'\n\nexport function combineSources(sources: Array<KubbFile.Source>): Array<KubbFile.Source> {\n return uniqueBy(sources, (obj) => {\n // For named sources, deduplicate by name, isExportable, and isTypeOnly\n // For unnamed sources, include the value to avoid deduplicating different code blocks\n // If both name and value are undefined, use an empty string as the unique identifier\n const uniqueId = obj.name ?? obj.value ?? ''\n const isExportable = obj.isExportable ?? false\n const isTypeOnly = obj.isTypeOnly ?? false\n return `${uniqueId}:${isExportable}:${isTypeOnly}`\n })\n}\n\nexport function combineExports(exports: Array<KubbFile.Export>): Array<KubbFile.Export> {\n const sorted = orderBy(exports, [\n (v) => !!Array.isArray(v.name),\n (v) => !v.isTypeOnly,\n (v) => v.path,\n (v) => !!v.name,\n (v) => (Array.isArray(v.name) ? orderBy(v.name) : v.name),\n ])\n\n const prev: Array<KubbFile.Export> = []\n // Map to track items by path for O(1) lookup\n const pathMap = new Map<string, KubbFile.Export>()\n // Map to track unique items by path+name+isTypeOnly+asAlias\n const uniqueMap = new Map<string, KubbFile.Export>()\n // Map to track items by path+name where isTypeOnly=true (for type-only check)\n const pathNameTypeTrueMap = new Map<string, KubbFile.Export>()\n\n for (const curr of sorted) {\n const name = curr.name\n const pathKey = curr.path\n const prevByPath = pathMap.get(pathKey)\n\n // Create unique key for path+name+isTypeOnly\n const nameKey = Array.isArray(name) ? JSON.stringify(name) : name || ''\n const pathNameTypeKey = `${pathKey}:${nameKey}:${curr.isTypeOnly}`\n // Check if there's already an item with the same path+name but with isTypeOnly=true\n const pathNameKey = `${pathKey}:${nameKey}`\n const prevByPathAndIsTypeOnly = pathNameTypeTrueMap.get(pathNameKey)\n\n if (prevByPathAndIsTypeOnly) {\n // we already have an export that has the same path and name but uses `isTypeOnly` (export type ...)\n continue\n }\n\n // Create unique key for path+name+isTypeOnly+asAlias\n const uniqueKey = `${pathNameTypeKey}:${curr.asAlias || ''}`\n const uniquePrev = uniqueMap.get(uniqueKey)\n\n // we already have an item that was unique enough or name field is empty or prev asAlias is set but current has no changes\n if (uniquePrev || (Array.isArray(name) && !name.length) || (prevByPath?.asAlias && !curr.asAlias)) {\n continue\n }\n\n if (!prevByPath) {\n const newItem = {\n ...curr,\n name: Array.isArray(name) ? [...new Set(name)] : name,\n }\n prev.push(newItem)\n pathMap.set(pathKey, newItem)\n uniqueMap.set(uniqueKey, newItem)\n // Track items with isTypeOnly=true for the type-only check\n if (newItem.isTypeOnly) {\n pathNameTypeTrueMap.set(pathNameKey, newItem)\n }\n continue\n }\n\n // merge all names when prev and current both have the same isTypeOnly set\n if (prevByPath && Array.isArray(prevByPath.name) && Array.isArray(curr.name) && prevByPath.isTypeOnly === curr.isTypeOnly) {\n prevByPath.name = [...new Set([...prevByPath.name, ...curr.name])]\n continue\n }\n\n prev.push(curr)\n uniqueMap.set(uniqueKey, curr)\n // Track items with isTypeOnly=true for the type-only check\n if (curr.isTypeOnly) {\n pathNameTypeTrueMap.set(pathNameKey, curr)\n }\n }\n\n return prev\n}\n\nexport function combineImports(imports: Array<KubbFile.Import>, exports: Array<KubbFile.Export>, source?: string): Array<KubbFile.Import> {\n const exportedNameLookup = new Set<string>()\n for (const item of exports) {\n const { name } = item\n if (!name) {\n continue\n }\n\n if (Array.isArray(name)) {\n for (const value of name) {\n if (value) {\n exportedNameLookup.add(value)\n }\n }\n continue\n }\n\n exportedNameLookup.add(name)\n }\n\n const usageCache = new Map<string, boolean>()\n const hasImportInSource = (importName: string): boolean => {\n if (!source) {\n return true\n }\n\n const cached = usageCache.get(importName)\n if (cached !== undefined) {\n return cached\n }\n\n const isUsed = source.includes(importName) || exportedNameLookup.has(importName)\n usageCache.set(importName, isUsed)\n\n return isUsed\n }\n\n const sorted = orderBy(imports, [\n (v) => !!Array.isArray(v.name),\n (v) => !v.isTypeOnly,\n (v) => v.path,\n (v) => !!v.name,\n (v) => (Array.isArray(v.name) ? orderBy(v.name) : v.name),\n ])\n\n const prev: Array<KubbFile.Import> = []\n // Map to track items by path+isTypeOnly for O(1) lookup\n const pathTypeMap = new Map<string, KubbFile.Import>()\n // Map to track unique items by path+name+isTypeOnly\n const uniqueMap = new Map<string, KubbFile.Import>()\n // Map to track items by path+name where isTypeOnly=true (for type-only check)\n const pathNameTypeTrueMap = new Map<string, KubbFile.Import>()\n\n for (const curr of sorted) {\n let name = Array.isArray(curr.name) ? [...new Set(curr.name)] : curr.name\n\n if (curr.path === curr.root) {\n // root and path are the same file, remove the \"./\" import\n continue\n }\n\n // merge all names and check if the importName is being used in the generated source and if not filter those imports out\n if (Array.isArray(name)) {\n name = name.filter((item) => (typeof item === 'string' ? hasImportInSource(item) : hasImportInSource(item.propertyName)))\n }\n\n const pathTypeKey = `${curr.path}:${curr.isTypeOnly}`\n const prevByPath = pathTypeMap.get(pathTypeKey)\n\n // Create key for name comparison\n const nameKey = Array.isArray(name) ? JSON.stringify(name) : name || ''\n const pathNameTypeKey = `${curr.path}:${nameKey}:${curr.isTypeOnly}`\n const uniquePrev = uniqueMap.get(pathNameTypeKey)\n // Check if there's already an item with the same path+name but with isTypeOnly=true\n const pathNameKey = `${curr.path}:${nameKey}`\n const prevByPathNameAndIsTypeOnly = pathNameTypeTrueMap.get(pathNameKey)\n\n if (prevByPathNameAndIsTypeOnly) {\n // we already have an import that has the same path and name but uses `isTypeOnly` (import type ...)\n continue\n }\n\n // already unique enough or name is empty\n if (uniquePrev || (Array.isArray(name) && !name.length)) {\n continue\n }\n\n // new item, append name\n if (!prevByPath) {\n const newItem = {\n ...curr,\n name,\n }\n prev.push(newItem)\n pathTypeMap.set(pathTypeKey, newItem)\n uniqueMap.set(pathNameTypeKey, newItem)\n // Track items with isTypeOnly=true for the type-only check\n if (newItem.isTypeOnly) {\n pathNameTypeTrueMap.set(pathNameKey, newItem)\n }\n continue\n }\n\n // merge all names when prev and current both have the same isTypeOnly set\n if (prevByPath && Array.isArray(prevByPath.name) && Array.isArray(name) && prevByPath.isTypeOnly === curr.isTypeOnly) {\n prevByPath.name = [...new Set([...prevByPath.name, ...name])]\n continue\n }\n\n // no import was found in the source, ignore import\n if (!Array.isArray(name) && name && !hasImportInSource(name)) {\n continue\n }\n\n prev.push(curr)\n uniqueMap.set(pathNameTypeKey, curr)\n // Track items with isTypeOnly=true for the type-only check\n if (curr.isTypeOnly) {\n pathNameTypeTrueMap.set(pathNameKey, curr)\n }\n }\n\n return prev\n}\n\n/**\n * Helper to create a file with name and id set\n */\nexport function createFile<TMeta extends object = object>(file: KubbFile.File<TMeta>): KubbFile.ResolvedFile<TMeta> {\n const extname = path.extname(file.baseName) as KubbFile.Extname\n if (!extname) {\n throw new Error(`No extname found for ${file.baseName}`)\n }\n\n const source = file.sources.map((item) => item.value).join('\\n\\n')\n const exports = file.exports?.length ? combineExports(file.exports) : []\n const imports = file.imports?.length && source ? combineImports(file.imports, exports, source) : []\n const sources = file.sources?.length ? combineSources(file.sources) : []\n\n return {\n ...file,\n id: createHash('sha256').update(file.path).digest('hex'),\n name: trimExtName(file.baseName),\n extname,\n imports: imports,\n exports: exports,\n sources: sources,\n meta: file.meta || ({} as TMeta),\n }\n}\n"],"x_google_ignoreList":[0,1,2,3],"mappings":";;;;;;;AAAA,MAAM,IAAE;CAAC,MAAK,CAAC;CAAE,SAAQ,CAAC;CAAE,EAAC,IAAE;CAAC,MAAK,CAAC;CAAE,SAAQ,CAAC;CAAE,EAACA,YAAM,GAAEC,OAAE,SAAI;CAAC,SAAQ,CAAC;CAAE,MAAKC;CAAE,MAAK,CAAC;CAAE;;;;ACAjC,SAASC,IAAE,KAAE,GAAGA,KAAE;CAAC,IAAI,IAAEC,KAAE,IAAED,IAAE,KAAI,QAAG,UAASC,MAAEC,IAAED,IAAE,GAAC,KAAK,EAAE,EAAC,IAAE;AAAE,QAAK,IAAED,IAAE,SAAQ;AAAC,MAAG,EAAE,OAAK,KAAK,KAAG,CAAC,EAAE,EAAE,EAAC;GAAC,IAAIC,MAAED,IAAE;AAAG,OAAEC,IAAE,EAAE,EAAC,KAAG;AAAE;;EAAS,IAAIA,MAAE,EAAE;AAAC,OAAI,IAAIE,MAAE,GAAEA,MAAEH,IAAE,QAAO,OAAI;GAAC,IAAIA,MAAE,EAAEG;AAAG,OAAGH,QAAI,KAAK,MAAIC,IAAE,KAAKD,IAAE,EAACA,IAAE,UAAU;;EAAM,IAAIE,MAAE,EAAE;AAAC,OAAI,IAAIF,OAAK,EAAE,KAAGG,IAAEH,KAAEE,KAAED,IAAE,CAAC;EAAM,IAAG,EAAC,UAAS,MAAGA,IAAE,GAAG,GAAG;AAAC,MAAE,IAAEC,IAAE,KAAGA,KAAE,KAAGD,IAAE;;AAAO,QAAO;;AAAE,SAASE,IAAE,KAAE,KAAE,KAAE;AAAC,KAAGC,IAAE,WAAS,EAAE,QAAOF,IAAE,KAAKF,IAAE,EAAC,CAAC;CAAE,IAAI,IAAEA,KAAE,IAAEC,GAAE,IAAE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","r","i","uniqueBy","prev: Array<KubbFile.Export>","prev: Array<KubbFile.Import>"],"sources":["../../../node_modules/.pnpm/remeda@2.32.0/node_modules/remeda/dist/utilityEvaluators-DORpnx39.js","../../../node_modules/.pnpm/remeda@2.32.0/node_modules/remeda/dist/pipe-jLehR9-P.js","../../../node_modules/.pnpm/remeda@2.32.0/node_modules/remeda/dist/purryFromLazy-3oywCNIb.js","../../../node_modules/.pnpm/remeda@2.32.0/node_modules/remeda/dist/uniqueBy-C_PxkF_D.js","../src/createFile.ts"],"sourcesContent":["const e={done:!0,hasNext:!1},t={done:!1,hasNext:!1},n=()=>e,r=e=>({hasNext:!0,next:e,done:!1});export{t as SKIP_ITEM,n as lazyEmptyEvaluator,r as lazyIdentityEvaluator};\n//# sourceMappingURL=utilityEvaluators-DORpnx39.js.map","import{SKIP_ITEM as e}from\"./utilityEvaluators-DORpnx39.js\";function t(e,...t){let a=e,o=t.map(e=>`lazy`in e?r(e):void 0),s=0;for(;s<t.length;){if(o[s]===void 0||!i(a)){let e=t[s];a=e(a),s+=1;continue}let e=[];for(let n=s;n<t.length;n++){let t=o[n];if(t===void 0||(e.push(t),t.isSingle))break}let r=[];for(let t of a)if(n(t,r,e))break;let{isSingle:c}=e.at(-1);a=c?r[0]:r,s+=e.length}return a}function n(t,r,i){if(i.length===0)return r.push(t),!1;let a=t,o=e,s=!1;for(let[e,t]of i.entries()){let{index:c,items:l}=t;if(l.push(a),o=t(a,c,l),t.index+=1,o.hasNext){if(o.hasMany??!1){for(let t of o.next)if(n(t,r,i.slice(e+1)))return!0;return s}a=o.next}if(!o.hasNext)break;o.done&&(s=!0)}return o.hasNext&&r.push(a),s}function r(e){let{lazy:t,lazyArgs:n}=e,r=t(...n);return Object.assign(r,{isSingle:t.single??!1,index:0,items:[]})}function i(e){return typeof e==`string`||typeof e==`object`&&!!e&&Symbol.iterator in e}export{t as pipe};\n//# sourceMappingURL=pipe-jLehR9-P.js.map","import{pipe as e}from\"./pipe-jLehR9-P.js\";function t(t,n){let r=n.length-t.length;if(r===1){let[r,...i]=n;return e(r,{lazy:t,lazyArgs:i})}if(r===0){let r={lazy:t,lazyArgs:n};return Object.assign(t=>e(t,r),r)}throw Error(`Wrong number of arguments`)}export{t as purryFromLazy};\n//# sourceMappingURL=purryFromLazy-3oywCNIb.js.map","import{SKIP_ITEM as e}from\"./utilityEvaluators-DORpnx39.js\";import{purryFromLazy as t}from\"./purryFromLazy-3oywCNIb.js\";function n(...e){return t(r,e)}function r(t){let n=t,r=new Set;return(t,i,a)=>{let o=n(t,i,a);return r.has(o)?e:(r.add(o),{done:!1,hasNext:!0,next:t})}}export{n as uniqueBy};\n//# sourceMappingURL=uniqueBy-C_PxkF_D.js.map","import { createHash } from 'node:crypto'\nimport path from 'node:path'\nimport { orderBy } from 'natural-orderby'\nimport { uniqueBy } from 'remeda'\nimport type * as KubbFile from './KubbFile.ts'\nimport { trimExtName } from './utils/trimExtName.ts'\n\nexport function combineSources(sources: Array<KubbFile.Source>): Array<KubbFile.Source> {\n return uniqueBy(sources, (obj) => {\n // For named sources, deduplicate by name, isExportable, and isTypeOnly\n // For unnamed sources, include the value to avoid deduplicating different code blocks\n // If both name and value are undefined, use an empty string as the unique identifier\n const uniqueId = obj.name ?? obj.value ?? ''\n const isExportable = obj.isExportable ?? false\n const isTypeOnly = obj.isTypeOnly ?? false\n return `${uniqueId}:${isExportable}:${isTypeOnly}`\n })\n}\n\nexport function combineExports(exports: Array<KubbFile.Export>): Array<KubbFile.Export> {\n const sorted = orderBy(exports, [\n (v) => !!Array.isArray(v.name),\n (v) => !v.isTypeOnly,\n (v) => v.path,\n (v) => !!v.name,\n (v) => (Array.isArray(v.name) ? orderBy(v.name) : v.name),\n ])\n\n const prev: Array<KubbFile.Export> = []\n // Map to track items by path for O(1) lookup\n const pathMap = new Map<string, KubbFile.Export>()\n // Map to track unique items by path+name+isTypeOnly+asAlias\n const uniqueMap = new Map<string, KubbFile.Export>()\n // Map to track items by path+name where isTypeOnly=true (for type-only check)\n const pathNameTypeTrueMap = new Map<string, KubbFile.Export>()\n\n for (const curr of sorted) {\n const name = curr.name\n const pathKey = curr.path\n const prevByPath = pathMap.get(pathKey)\n\n // Create unique key for path+name+isTypeOnly\n const nameKey = Array.isArray(name) ? JSON.stringify(name) : name || ''\n const pathNameTypeKey = `${pathKey}:${nameKey}:${curr.isTypeOnly}`\n // Check if there's already an item with the same path+name but with isTypeOnly=true\n const pathNameKey = `${pathKey}:${nameKey}`\n const prevByPathAndIsTypeOnly = pathNameTypeTrueMap.get(pathNameKey)\n\n if (prevByPathAndIsTypeOnly) {\n // we already have an export that has the same path and name but uses `isTypeOnly` (export type ...)\n continue\n }\n\n // Create unique key for path+name+isTypeOnly+asAlias\n const uniqueKey = `${pathNameTypeKey}:${curr.asAlias || ''}`\n const uniquePrev = uniqueMap.get(uniqueKey)\n\n // we already have an item that was unique enough or name field is empty or prev asAlias is set but current has no changes\n if (uniquePrev || (Array.isArray(name) && !name.length) || (prevByPath?.asAlias && !curr.asAlias)) {\n continue\n }\n\n if (!prevByPath) {\n const newItem = {\n ...curr,\n name: Array.isArray(name) ? [...new Set(name)] : name,\n }\n prev.push(newItem)\n pathMap.set(pathKey, newItem)\n uniqueMap.set(uniqueKey, newItem)\n // Track items with isTypeOnly=true for the type-only check\n if (newItem.isTypeOnly) {\n pathNameTypeTrueMap.set(pathNameKey, newItem)\n }\n continue\n }\n\n // merge all names when prev and current both have the same isTypeOnly set\n if (prevByPath && Array.isArray(prevByPath.name) && Array.isArray(curr.name) && prevByPath.isTypeOnly === curr.isTypeOnly) {\n prevByPath.name = [...new Set([...prevByPath.name, ...curr.name])]\n continue\n }\n\n prev.push(curr)\n uniqueMap.set(uniqueKey, curr)\n // Track items with isTypeOnly=true for the type-only check\n if (curr.isTypeOnly) {\n pathNameTypeTrueMap.set(pathNameKey, curr)\n }\n }\n\n return prev\n}\n\nexport function combineImports(imports: Array<KubbFile.Import>, exports: Array<KubbFile.Export>, source?: string): Array<KubbFile.Import> {\n const exportedNameLookup = new Set<string>()\n for (const item of exports) {\n const { name } = item\n if (!name) {\n continue\n }\n\n if (Array.isArray(name)) {\n for (const value of name) {\n if (value) {\n exportedNameLookup.add(value)\n }\n }\n continue\n }\n\n exportedNameLookup.add(name)\n }\n\n const usageCache = new Map<string, boolean>()\n const hasImportInSource = (importName: string): boolean => {\n if (!source) {\n return true\n }\n\n const cached = usageCache.get(importName)\n if (cached !== undefined) {\n return cached\n }\n\n const isUsed = source.includes(importName) || exportedNameLookup.has(importName)\n usageCache.set(importName, isUsed)\n\n return isUsed\n }\n\n const sorted = orderBy(imports, [\n (v) => !!Array.isArray(v.name),\n (v) => !v.isTypeOnly,\n (v) => v.path,\n (v) => !!v.name,\n (v) => (Array.isArray(v.name) ? orderBy(v.name) : v.name),\n ])\n\n const prev: Array<KubbFile.Import> = []\n // Map to track items by path+isTypeOnly for O(1) lookup\n const pathTypeMap = new Map<string, KubbFile.Import>()\n // Map to track unique items by path+name+isTypeOnly\n const uniqueMap = new Map<string, KubbFile.Import>()\n // Map to track items by path+name where isTypeOnly=true (for type-only check)\n const pathNameTypeTrueMap = new Map<string, KubbFile.Import>()\n\n for (const curr of sorted) {\n let name = Array.isArray(curr.name) ? [...new Set(curr.name)] : curr.name\n\n if (curr.path === curr.root) {\n // root and path are the same file, remove the \"./\" import\n continue\n }\n\n // merge all names and check if the importName is being used in the generated source and if not filter those imports out\n if (Array.isArray(name)) {\n name = name.filter((item) => (typeof item === 'string' ? hasImportInSource(item) : hasImportInSource(item.propertyName)))\n }\n\n const pathTypeKey = `${curr.path}:${curr.isTypeOnly}`\n const prevByPath = pathTypeMap.get(pathTypeKey)\n\n // Create key for name comparison\n const nameKey = Array.isArray(name) ? JSON.stringify(name) : name || ''\n const pathNameTypeKey = `${curr.path}:${nameKey}:${curr.isTypeOnly}`\n const uniquePrev = uniqueMap.get(pathNameTypeKey)\n // Check if there's already an item with the same path+name but with isTypeOnly=true\n const pathNameKey = `${curr.path}:${nameKey}`\n const prevByPathNameAndIsTypeOnly = pathNameTypeTrueMap.get(pathNameKey)\n\n if (prevByPathNameAndIsTypeOnly) {\n // we already have an import that has the same path and name but uses `isTypeOnly` (import type ...)\n continue\n }\n\n // already unique enough or name is empty\n if (uniquePrev || (Array.isArray(name) && !name.length)) {\n continue\n }\n\n // new item, append name\n if (!prevByPath) {\n const newItem = {\n ...curr,\n name,\n }\n prev.push(newItem)\n pathTypeMap.set(pathTypeKey, newItem)\n uniqueMap.set(pathNameTypeKey, newItem)\n // Track items with isTypeOnly=true for the type-only check\n if (newItem.isTypeOnly) {\n pathNameTypeTrueMap.set(pathNameKey, newItem)\n }\n continue\n }\n\n // merge all names when prev and current both have the same isTypeOnly set\n if (prevByPath && Array.isArray(prevByPath.name) && Array.isArray(name) && prevByPath.isTypeOnly === curr.isTypeOnly) {\n prevByPath.name = [...new Set([...prevByPath.name, ...name])]\n continue\n }\n\n // no import was found in the source, ignore import\n if (!Array.isArray(name) && name && !hasImportInSource(name)) {\n continue\n }\n\n prev.push(curr)\n uniqueMap.set(pathNameTypeKey, curr)\n // Track items with isTypeOnly=true for the type-only check\n if (curr.isTypeOnly) {\n pathNameTypeTrueMap.set(pathNameKey, curr)\n }\n }\n\n return prev\n}\n\n/**\n * Helper to create a file with name and id set\n */\nexport function createFile<TMeta extends object = object>(file: KubbFile.File<TMeta>): KubbFile.ResolvedFile<TMeta> {\n const extname = path.extname(file.baseName) as KubbFile.Extname\n if (!extname) {\n throw new Error(`No extname found for ${file.baseName}`)\n }\n\n const source = file.sources.map((item) => item.value).join('\\n\\n')\n const exports = file.exports?.length ? combineExports(file.exports) : []\n const imports = file.imports?.length && source ? combineImports(file.imports, exports, source) : []\n const sources = file.sources?.length ? combineSources(file.sources) : []\n\n return {\n ...file,\n id: createHash('sha256').update(file.path).digest('hex'),\n name: trimExtName(file.baseName),\n extname,\n imports: imports,\n exports: exports,\n sources: sources,\n meta: file.meta || ({} as TMeta),\n }\n}\n"],"x_google_ignoreList":[0,1,2,3],"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AAQ,WAAW,KAAK,IAAI,MAAM,QAAQ,KAAK,IAAI,WAAW,eAAe,KAAK,YAAY;AACpH,cAAW,OAAO,CAAC,GAAG,IAAI,IAAI,CAAC,GAAG,WAAW,MAAM,GAAG,KAAK,CAAC,CAAC;AAC7D;;AAIF,MAAI,CAAC,MAAM,QAAQ,KAAK,IAAI,QAAQ,CAAC,kBAAkB,KAAK,CAC1D;AAGF,OAAK,KAAK,KAAK;AACf,YAAU,IAAI,iBAAiB,KAAK;AAEpC,MAAI,KAAK,WACP,qBAAoB,IAAI,aAAa,KAAK;;AAI9C,QAAO;;;;;AAMT,SAAgB,WAA0C,MAA0D;;CAClH,MAAM,UAAU,KAAK,QAAQ,KAAK,SAAS;AAC3C,KAAI,CAAC,QACH,OAAM,IAAI,MAAM,wBAAwB,KAAK,WAAW;CAG1D,MAAM,SAAS,KAAK,QAAQ,KAAK,SAAS,KAAK,MAAM,CAAC,KAAK,OAAO;CAClE,MAAM,4BAAU,KAAK,uEAAS,UAAS,eAAe,KAAK,QAAQ,GAAG,EAAE;CACxE,MAAM,4BAAU,KAAK,uEAAS,WAAU,SAAS,eAAe,KAAK,SAAS,SAAS,OAAO,GAAG,EAAE;CACnG,MAAM,4BAAU,KAAK,uEAAS,UAAS,eAAe,KAAK,QAAQ,GAAG,EAAE;AAExE,QAAO;EACL,GAAG;EACH,IAAI,WAAW,SAAS,CAAC,OAAO,KAAK,KAAK,CAAC,OAAO,MAAM;EACxD,MAAM,YAAY,KAAK,SAAS;EAChC;EACS;EACA;EACA;EACT,MAAM,KAAK,QAAS,EAAE;EACvB"}
@@ -1,88 +0,0 @@
1
- import { t as trimExtName } from "./trimExtName-Dq2Z7SCT.js";
2
- import { t as defineParser } from "./defineParser-Bxv4mb-N.js";
3
- import { t as getRelativePath } from "./getRelativePath-DayVrg5k.js";
4
- import path from "node:path";
5
- import ts from "typescript";
6
-
7
- //#region src/parsers/typescriptParser.ts
8
- const { factory } = ts;
9
- /**
10
- * Convert AST TypeScript/TSX nodes to a string based on the TypeScript printer.
11
- */
12
- function print(...elements) {
13
- const sourceFile = ts.createSourceFile("print.tsx", "", ts.ScriptTarget.ES2022, true, ts.ScriptKind.TSX);
14
- const printer = ts.createPrinter({
15
- omitTrailingSemicolon: true,
16
- newLine: ts.NewLineKind.LineFeed,
17
- removeComments: false,
18
- noEmitHelpers: true
19
- });
20
- for (const node of elements) if (node.kind === ts.SyntaxKind.Unknown) console.error("⚠️ Unknown node found:", node);
21
- return printer.printList(ts.ListFormat.MultiLine, factory.createNodeArray(elements.filter(Boolean)), sourceFile).replace(/\r\n/g, "\n");
22
- }
23
- function createImport({ name, path: path$1, root, isTypeOnly = false, isNameSpace = false }) {
24
- const resolvePath = root ? getRelativePath(root, path$1) : path$1;
25
- if (!Array.isArray(name)) {
26
- if (isNameSpace) return factory.createImportDeclaration(void 0, factory.createImportClause(isTypeOnly, void 0, factory.createNamespaceImport(factory.createIdentifier(name))), factory.createStringLiteral(resolvePath), void 0);
27
- return factory.createImportDeclaration(void 0, factory.createImportClause(isTypeOnly, factory.createIdentifier(name), void 0), factory.createStringLiteral(resolvePath), void 0);
28
- }
29
- const specifiers = name.map((item) => {
30
- if (typeof item === "object") {
31
- const { propertyName, name: alias } = item;
32
- return factory.createImportSpecifier(false, alias ? factory.createIdentifier(propertyName) : void 0, factory.createIdentifier(alias !== null && alias !== void 0 ? alias : propertyName));
33
- }
34
- return factory.createImportSpecifier(false, void 0, factory.createIdentifier(item));
35
- });
36
- return factory.createImportDeclaration(void 0, factory.createImportClause(isTypeOnly, void 0, factory.createNamedImports(specifiers)), factory.createStringLiteral(resolvePath), void 0);
37
- }
38
- function createExport({ path: path$1, asAlias, isTypeOnly = false, name }) {
39
- if (name && !Array.isArray(name) && !asAlias) console.warn(`When using name as string, asAlias should be true ${name}`);
40
- if (!Array.isArray(name)) {
41
- const parsedName = (name === null || name === void 0 ? void 0 : name.match(/^\d/)) ? `_${name === null || name === void 0 ? void 0 : name.slice(1)}` : name;
42
- return factory.createExportDeclaration(void 0, isTypeOnly, asAlias && parsedName ? factory.createNamespaceExport(factory.createIdentifier(parsedName)) : void 0, factory.createStringLiteral(path$1), void 0);
43
- }
44
- return factory.createExportDeclaration(void 0, isTypeOnly, factory.createNamedExports(name.map((propertyName) => {
45
- return factory.createExportSpecifier(false, void 0, typeof propertyName === "string" ? factory.createIdentifier(propertyName) : propertyName);
46
- })), factory.createStringLiteral(path$1), void 0);
47
- }
48
- const typescriptParser = defineParser({
49
- name: "typescript",
50
- extNames: [".ts", ".js"],
51
- install() {},
52
- async parse(file, options = { extname: ".ts" }) {
53
- const sourceParts = [];
54
- for (const item of file.sources) if (item.value) sourceParts.push(item.value);
55
- const source = sourceParts.join("\n\n");
56
- const importNodes = [];
57
- for (const item of file.imports) {
58
- const importPath = item.root ? getRelativePath(item.root, item.path) : item.path;
59
- const hasExtname = !!path.extname(importPath);
60
- importNodes.push(createImport({
61
- name: item.name,
62
- path: options.extname && hasExtname ? `${trimExtName(importPath)}${options.extname}` : item.root ? trimExtName(importPath) : importPath,
63
- isTypeOnly: item.isTypeOnly
64
- }));
65
- }
66
- const exportNodes = [];
67
- for (const item of file.exports) {
68
- const exportPath = item.path;
69
- const hasExtname = !!path.extname(exportPath);
70
- exportNodes.push(createExport({
71
- name: item.name,
72
- path: options.extname && hasExtname ? `${trimExtName(item.path)}${options.extname}` : trimExtName(item.path),
73
- isTypeOnly: item.isTypeOnly,
74
- asAlias: item.asAlias
75
- }));
76
- }
77
- return [
78
- file.banner,
79
- print(...importNodes, ...exportNodes),
80
- source,
81
- file.footer
82
- ].filter((segment) => segment != null).join("\n");
83
- }
84
- });
85
-
86
- //#endregion
87
- export { typescriptParser as i, createImport as n, print as r, createExport as t };
88
- //# sourceMappingURL=typescriptParser-BLX7eX2k.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"typescriptParser-BLX7eX2k.js","names":["path","sourceParts: Array<string>","importNodes: Array<ts.ImportDeclaration>","exportNodes: Array<ts.ExportDeclaration>"],"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 * 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 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 }),\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;;;;AAKpB,SAAgB,MAAM,GAAG,UAAkC;CACzD,MAAM,aAAa,GAAG,iBAAiB,aAAa,IAAI,GAAG,aAAa,QAAQ,MAAM,GAAG,WAAW,IAAI;CAExG,MAAM,UAAU,GAAG,cAAc;EAC/B,uBAAuB;EACvB,SAAS,GAAG,YAAY;EACxB,gBAAgB;EAChB,eAAe;EAChB,CAAC;AAEF,MAAK,MAAM,QAAQ,SACjB,KAAI,KAAK,SAAS,GAAG,WAAW,QAC9B,SAAQ,MAAM,0BAA0B,KAAK;AAMjD,QAFe,QAAQ,UAAU,GAAG,WAAW,WAAW,QAAQ,gBAAgB,SAAS,OAAO,QAAQ,CAAC,EAAE,WAAW,CAE1G,QAAQ,SAAS,KAAK;;AAGtC,SAAgB,aAAa,EAC3B,MACA,cACA,MACA,aAAa,OACb,cAAc,SAOb;CACD,MAAM,cAAc,OAAO,gBAAgB,MAAMA,OAAK,GAAGA;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,U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K,MAAM,QAAQ,KAAK,SAAS;GAC/B,MAAM,aAAa,KAAK,OAAO,gBAAgB,KAAK,MAAM,KAAK,KAAK,GAAG,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;IAClB,CAAC,CACH;;EAGH,MAAMC,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"}
@@ -1,39 +0,0 @@
1
- import { u as Parser } from "./Fabric-CDFwTDyP.js";
2
- import ts from "typescript";
3
-
4
- //#region src/parsers/typescriptParser.d.ts
5
- /**
6
- * Convert AST TypeScript/TSX nodes to a string based on the TypeScript printer.
7
- */
8
- declare function print(...elements: Array<ts.Node>): string;
9
- declare function createImport({
10
- name,
11
- path,
12
- root,
13
- isTypeOnly,
14
- isNameSpace
15
- }: {
16
- name: string | Array<string | {
17
- propertyName: string;
18
- name?: string;
19
- }>;
20
- path: string;
21
- root?: string;
22
- isTypeOnly?: boolean;
23
- isNameSpace?: boolean;
24
- }): ts.ImportDeclaration;
25
- declare function createExport({
26
- path,
27
- asAlias,
28
- isTypeOnly,
29
- name
30
- }: {
31
- path: string;
32
- asAlias?: boolean;
33
- isTypeOnly?: boolean;
34
- name?: string | Array<ts.Identifier | string>;
35
- }): ts.ExportDeclaration;
36
- declare const typescriptParser: Parser<[], any>;
37
- //#endregion
38
- export { typescriptParser as i, createImport as n, print as r, createExport as t };
39
- //# sourceMappingURL=typescriptParser-CPUUUA9z.d.ts.map
@@ -1,39 +0,0 @@
1
- import { u as Parser } from "./Fabric-BXYWK9V4.cjs";
2
- import ts from "typescript";
3
-
4
- //#region src/parsers/typescriptParser.d.ts
5
- /**
6
- * Convert AST TypeScript/TSX nodes to a string based on the TypeScript printer.
7
- */
8
- declare function print(...elements: Array<ts.Node>): string;
9
- declare function createImport({
10
- name,
11
- path,
12
- root,
13
- isTypeOnly,
14
- isNameSpace
15
- }: {
16
- name: string | Array<string | {
17
- propertyName: string;
18
- name?: string;
19
- }>;
20
- path: string;
21
- root?: string;
22
- isTypeOnly?: boolean;
23
- isNameSpace?: boolean;
24
- }): ts.ImportDeclaration;
25
- declare function createExport({
26
- path,
27
- asAlias,
28
- isTypeOnly,
29
- name
30
- }: {
31
- path: string;
32
- asAlias?: boolean;
33
- isTypeOnly?: boolean;
34
- name?: string | Array<ts.Identifier | string>;
35
- }): ts.ExportDeclaration;
36
- declare const typescriptParser: Parser<[], any>;
37
- //#endregion
38
- export { typescriptParser as i, createImport as n, print as r, createExport as t };
39
- //# sourceMappingURL=typescriptParser-H0FvAP4t.d.cts.map
@@ -1,113 +0,0 @@
1
- const require_trimExtName = require('./trimExtName-DaBSwMN-.cjs');
2
- const require_defineParser = require('./defineParser-DODGK4rM.cjs');
3
- const require_getRelativePath = require('./getRelativePath-CLj7Ou6d.cjs');
4
- let node_path = require("node:path");
5
- node_path = require_trimExtName.__toESM(node_path);
6
- let typescript = require("typescript");
7
- typescript = require_trimExtName.__toESM(typescript);
8
-
9
- //#region src/parsers/typescriptParser.ts
10
- const { factory } = typescript.default;
11
- /**
12
- * Convert AST TypeScript/TSX nodes to a string based on the TypeScript printer.
13
- */
14
- function print(...elements) {
15
- const sourceFile = typescript.default.createSourceFile("print.tsx", "", typescript.default.ScriptTarget.ES2022, true, typescript.default.ScriptKind.TSX);
16
- const printer = typescript.default.createPrinter({
17
- omitTrailingSemicolon: true,
18
- newLine: typescript.default.NewLineKind.LineFeed,
19
- removeComments: false,
20
- noEmitHelpers: true
21
- });
22
- for (const node of elements) if (node.kind === typescript.default.SyntaxKind.Unknown) console.error("⚠️ Unknown node found:", node);
23
- return printer.printList(typescript.default.ListFormat.MultiLine, factory.createNodeArray(elements.filter(Boolean)), sourceFile).replace(/\r\n/g, "\n");
24
- }
25
- function createImport({ name, path: path$1, root, isTypeOnly = false, isNameSpace = false }) {
26
- const resolvePath = root ? require_getRelativePath.getRelativePath(root, path$1) : path$1;
27
- if (!Array.isArray(name)) {
28
- if (isNameSpace) return factory.createImportDeclaration(void 0, factory.createImportClause(isTypeOnly, void 0, factory.createNamespaceImport(factory.createIdentifier(name))), factory.createStringLiteral(resolvePath), void 0);
29
- return factory.createImportDeclaration(void 0, factory.createImportClause(isTypeOnly, factory.createIdentifier(name), void 0), factory.createStringLiteral(resolvePath), void 0);
30
- }
31
- const specifiers = name.map((item) => {
32
- if (typeof item === "object") {
33
- const { propertyName, name: alias } = item;
34
- return factory.createImportSpecifier(false, alias ? factory.createIdentifier(propertyName) : void 0, factory.createIdentifier(alias !== null && alias !== void 0 ? alias : propertyName));
35
- }
36
- return factory.createImportSpecifier(false, void 0, factory.createIdentifier(item));
37
- });
38
- return factory.createImportDeclaration(void 0, factory.createImportClause(isTypeOnly, void 0, factory.createNamedImports(specifiers)), factory.createStringLiteral(resolvePath), void 0);
39
- }
40
- function createExport({ path: path$1, asAlias, isTypeOnly = false, name }) {
41
- if (name && !Array.isArray(name) && !asAlias) console.warn(`When using name as string, asAlias should be true ${name}`);
42
- if (!Array.isArray(name)) {
43
- const parsedName = (name === null || name === void 0 ? void 0 : name.match(/^\d/)) ? `_${name === null || name === void 0 ? void 0 : name.slice(1)}` : name;
44
- return factory.createExportDeclaration(void 0, isTypeOnly, asAlias && parsedName ? factory.createNamespaceExport(factory.createIdentifier(parsedName)) : void 0, factory.createStringLiteral(path$1), void 0);
45
- }
46
- return factory.createExportDeclaration(void 0, isTypeOnly, factory.createNamedExports(name.map((propertyName) => {
47
- return factory.createExportSpecifier(false, void 0, typeof propertyName === "string" ? factory.createIdentifier(propertyName) : propertyName);
48
- })), factory.createStringLiteral(path$1), void 0);
49
- }
50
- const typescriptParser = require_defineParser.defineParser({
51
- name: "typescript",
52
- extNames: [".ts", ".js"],
53
- install() {},
54
- async parse(file, options = { extname: ".ts" }) {
55
- const sourceParts = [];
56
- for (const item of file.sources) if (item.value) sourceParts.push(item.value);
57
- const source = sourceParts.join("\n\n");
58
- const importNodes = [];
59
- for (const item of file.imports) {
60
- const importPath = item.root ? require_getRelativePath.getRelativePath(item.root, item.path) : item.path;
61
- const hasExtname = !!node_path.default.extname(importPath);
62
- importNodes.push(createImport({
63
- name: item.name,
64
- path: options.extname && hasExtname ? `${require_trimExtName.trimExtName(importPath)}${options.extname}` : item.root ? require_trimExtName.trimExtName(importPath) : importPath,
65
- isTypeOnly: item.isTypeOnly
66
- }));
67
- }
68
- const exportNodes = [];
69
- for (const item of file.exports) {
70
- const exportPath = item.path;
71
- const hasExtname = !!node_path.default.extname(exportPath);
72
- exportNodes.push(createExport({
73
- name: item.name,
74
- path: options.extname && hasExtname ? `${require_trimExtName.trimExtName(item.path)}${options.extname}` : require_trimExtName.trimExtName(item.path),
75
- isTypeOnly: item.isTypeOnly,
76
- asAlias: item.asAlias
77
- }));
78
- }
79
- return [
80
- file.banner,
81
- print(...importNodes, ...exportNodes),
82
- source,
83
- file.footer
84
- ].filter((segment) => segment != null).join("\n");
85
- }
86
- });
87
-
88
- //#endregion
89
- Object.defineProperty(exports, 'createExport', {
90
- enumerable: true,
91
- get: function () {
92
- return createExport;
93
- }
94
- });
95
- Object.defineProperty(exports, 'createImport', {
96
- enumerable: true,
97
- get: function () {
98
- return createImport;
99
- }
100
- });
101
- Object.defineProperty(exports, 'print', {
102
- enumerable: true,
103
- get: function () {
104
- return print;
105
- }
106
- });
107
- Object.defineProperty(exports, 'typescriptParser', {
108
- enumerable: true,
109
- get: function () {
110
- return typescriptParser;
111
- }
112
- });
113
- //# sourceMappingURL=typescriptParser-OjFZ_DeI.cjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"typescriptParser-OjFZ_DeI.cjs","names":["ts","getRelativePath","path","defineParser","sourceParts: Array<string>","importNodes: Array<ts.ImportDeclaration>","trimExtName","exportNodes: Array<ts.ExportDeclaration>"],"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 * 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 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 }),\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;;;;AAKpB,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,aAAa,EAC3B,MACA,cACA,MACA,aAAa,OACb,cAAc,SAOb;CACD,MAAM,cAAc,OAAOC,wCAAgB,MAAMC,OAAK,GAAGA;AAGzD,KAAI,CA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