@hey-api/codegen-core 0.2.0 → 0.3.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/dist/index.cjs +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +101 -74
- package/dist/index.d.ts +101 -74
- package/dist/index.js +1 -2
- package/dist/index.js.map +1 -1
- package/package.json +5 -5
package/dist/index.cjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
|
|
1
|
+
var e=Object.create,t=Object.defineProperty,n=Object.getOwnPropertyDescriptor,r=Object.getOwnPropertyNames,i=Object.getPrototypeOf,a=Object.prototype.hasOwnProperty,o=(e,i,o,s)=>{if(i&&typeof i==`object`||typeof i==`function`)for(var c=r(i),l=0,u=c.length,d;l<u;l++)d=c[l],!a.call(e,d)&&d!==o&&t(e,d,{get:(e=>i[e]).bind(null,d),enumerable:!(s=n(i,d))||s.enumerable});return e},s=(n,r,a)=>(a=n==null?{}:e(i(n)),o(r||!n||!n.__esModule?t(a,`default`,{value:n,enumerable:!0}):a,n));let c=require(`node:path`);c=s(c);const l=({file:e,modulePath:t,symbol:n,symbolFile:r})=>{let i=[],a=[],o={aliases:{},from:t};if(n.meta?.importKind&&(n.meta.importKind===`default`?(o.defaultBinding=n.placeholder,n.meta.kind===`type`&&(o.typeDefaultBinding=!0)):n.meta.importKind===`namespace`&&(o.namespaceBinding=n.placeholder,n.meta.kind===`type`&&(o.typeNamespaceBinding=!0))),n.meta?.importKind===`named`||!i.length&&!o.defaultBinding&&!o.namespaceBinding){let t=n.placeholder,s=e.resolvedNames.get(n.id);if(s){let e=r.resolvedNames.get(n.id);e?e!==s&&(t=e,o.aliases[t]=s):n.name&&s!==n.name&&(t=n.name,o.aliases[t]=n.placeholder)}i.push(t),n.meta?.kind===`type`&&a.push(t)}for(let e of a)i.includes(e)||i.push(e);return o.names=i,o.typeNames=a,o},u=(e,t)=>{e.aliases={...e.aliases,...t.aliases},t.defaultBinding!==void 0&&(e.defaultBinding=t.defaultBinding),e.names=[...new Set([...e.names??[],...t.names??[]])],t.namespaceBinding!==void 0&&(e.namespaceBinding=t.namespaceBinding),t.typeDefaultBinding!==void 0&&(e.typeDefaultBinding=t.typeDefaultBinding),e.typeNames=[...new Set([...e.typeNames??[],...t.typeNames??[]])],t.typeNamespaceBinding!==void 0&&(e.typeNamespaceBinding=t.typeNamespaceBinding)};var d=class{map=new Map;reverse=new Map;delete(e){let t=this.map.get(e);return t!==void 0&&this.reverse.delete(t),this.map.delete(e)}deleteValue(e){let t=this.reverse.get(e);return t!==void 0&&this.map.delete(t),this.reverse.delete(e)}entries(){return this.map.entries()}get(e){return this.map.get(e)}getKey(e){return this.reverse.get(e)}hasKey(e){return this.map.has(e)}hasValue(e){return this.reverse.has(e)}keys(){return this.map.keys()}set(e,t){let n=this.map.get(e);n!==void 0&&n!==t&&this.reverse.delete(n);let r=this.reverse.get(t);return r!==void 0&&r!==e&&this.map.delete(r),this.map.set(e,t),this.reverse.set(t,e),this}get size(){return this.map.size}values(){return this.map.values()}[Symbol.iterator](){return this.map[Symbol.iterator]()}},f=class{_id=0;referenceOrder=new Set;registerOrder=new Set;selectorToId=new Map;values=new Map;get(e){let t=this.idOrSelector(e);if(t.id!==void 0)return this.values.get(t.id);let n=t.selector===void 0?void 0:JSON.stringify(t.selector);if(n){let e=this.selectorToId.get(n);if(e!==void 0)return this.values.get(e)}}get id(){return this._id++}idOrSelector(e){return typeof e==`number`?{id:e}:{selector:e}}isRegistered(e){let t=this.get(e);return t?this.registerOrder.has(t.id):!1}reference(e){let t=this.idOrSelector(e);return this.register(t)}*referenced(){for(let e of this.referenceOrder.values())yield this.values.get(e)}register(e){if(e.id!==void 0){let t=this.values.get(e.id);if(!t)throw Error(`File with ID ${e.id} not found. To register a new file, leave the ID undefined.`);return t}let t=Object.keys(e).some(e=>![`id`,`selector`].includes(e)),n,r=e.selector===void 0?void 0:JSON.stringify(e.selector);if(r){let e=this.selectorToId.get(r);if(e!==void 0){if(n=this.values.get(e),!n)throw Error(`File with ID ${e} not found. The selector ${r} matched an ID, but there was no result. This is likely an issue with the application logic.`);if(!t)return n}}let i=n?.id===void 0?this.id:n.id;return n={...n,...e,id:i,resolvedNames:n?.resolvedNames??new d,symbols:n?.symbols??{body:[],exports:[],imports:[]}},this.values.set(i,n),t?(this.registerOrder.add(i),this.referenceOrder.has(i)&&this.referenceOrder.delete(i)):this.referenceOrder.add(i),r&&this.selectorToId.set(r,i),n}*registered(){for(let e of this.registerOrder.values())yield this.values.get(e)}};const p=e=>`_heyapi_${e}_`,m=e=>e.slice(8,-1),h=()=>new RegExp(p(`\\d+`),`g`),g=(e,t)=>e.replace(h(),e=>t(Number.parseInt(m(e),10))||e);var _=class{_id=0;nodes=new Map;registerOrder=new Set;selectorToId=new Map;values=new Map;get(e){let t=this.idOrSelector(e);if(t.id!==void 0)return this.values.get(t.id);let n=t.selector===void 0?void 0:JSON.stringify(t.selector);if(n){let e=this.selectorToId.get(n);if(e!==void 0)return this.values.get(e)}}getValue(e){return this.nodes.get(e)}hasValue(e){return this.nodes.has(e)}get id(){return this._id++}idOrSelector(e){return typeof e==`number`?{id:e}:{selector:e}}isRegistered(e){let t=this.get(e);return t?this.registerOrder.has(t.id):!1}reference(e){let t=this.idOrSelector(e);return this.register(t)}register(e){if(e.id!==void 0){let t=this.values.get(e.id);if(!t)throw Error(`Symbol with ID ${e.id} not found. To register a new symbol, leave the ID undefined.`);return t}let t=Object.keys(e).some(e=>![`id`,`selector`].includes(e)),n,r=e.selector===void 0?void 0:JSON.stringify(e.selector);if(r){let e=this.selectorToId.get(r);if(e!==void 0){if(n=this.values.get(e),!n)throw Error(`Symbol with ID ${e} not found. The selector ${r} matched an ID, but there was no result. This is likely an issue with the application logic.`);if(!t)return n}}let i=n?.id===void 0?this.id:n.id,a=n?.exportFrom?[...n.exportFrom]:[];return e.exportFrom&&a.push(...e.exportFrom),n={...n,...e,exportFrom:a,id:i,placeholder:n?.placeholder??e.placeholder??p(String(i))},this.values.set(i,n),t&&this.registerOrder.add(i),r&&this.selectorToId.set(r,i),n}*registered(){for(let e of this.registerOrder.values())yield this.values.get(e)}setValue(e,t){return this.nodes.set(e,t)}};const v=`@`;var y=class{symbolIdToFileIds=new Map;defaultFileName;files=new f;fileName;renderers={};root;symbols=new _;constructor({defaultFileName:e,fileName:t,renderers:n,root:r}){this.defaultFileName=e??`main`,this.fileName=typeof t==`string`?()=>t:t,this.renderers=n,this.root=r}getRenderer(e){return e.extension?this.renderers[e.extension]:void 0}prepareFiles(){for(let e of this.symbols.registered()){let t=this.symbolToFileSelector(e),n=this.files.reference(t);n.symbols.body.push(e.id);let r=this.symbolIdToFileIds.get(e.id)??new Set;r.add(n.id),this.symbolIdToFileIds.set(e.id,r);for(let t of e.exportFrom){let r=[t],i=this.files.reference(r);i.id!==n.id&&i.symbols.exports.push(e.id)}}for(let e of this.files.referenced()){if(!e.selector)continue;if(e.selector[0]===`@`){let t=e.selector[1];if(!t){this.files.register({external:!0,selector:e.selector});continue}let n=c.default.extname(t);if(!n){this.files.register({external:!0,path:t,selector:e.selector});continue}this.files.register({extension:n,external:!0,path:t,selector:e.selector});continue}let t=e.selector.slice(0,-1),n=e.selector[e.selector.length-1];n=this.fileName?.(n)||n,this.files.register({extension:`.ts`,name:n,path:c.default.resolve(this.root,...t,`${n}.ts`),selector:e.selector})}}render(e){this.prepareFiles();let t=new Map;for(let n of this.files.registered()){if(n.external||!n.path)continue;let r=this.getRenderer(n);r&&t.set(n.id,{content:r.renderSymbols(n,this,e),path:n.path})}for(let[n,r]of t.entries()){let i=this.files.get(n),a=this.getRenderer(i).renderFile(r.content,i,this,e);a?t.set(i.id,{...r,content:a}):t.delete(i.id)}return Array.from(t.values())}symbolIdToFiles(e){let t=this.symbolIdToFileIds.get(e);return Array.from(t??[]).map(e=>this.files.get(e))}symbolToFileSelector(e){if(e.external)return[`@`,e.external];let t=e.getFilePath?.(e);return t?t.split(`/`):[this.defaultFileName]}};exports.Project=y,exports.createBinding=l,exports.mergeBindings=u,exports.renderIds=g;
|
|
2
2
|
//# sourceMappingURL=index.cjs.map
|
package/dist/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/bindings/utils.ts","../src/bimap/bimap.ts","../src/files/registry.ts","../src/renderer/utils.ts","../src/symbols/registry.ts","../src/project/project.ts"],"names":["createBinding","file","modulePath","symbol","symbolFile","names","typeNames","binding","name","fileResolvedName","symbolFileResolvedName","typeName","mergeBindings","target","source","BiMap","key","value","oldValue","oldKey","FileRegistry","fileIdOrSelector","selector","id","symbolIdOrSelector","result","hasOtherKeys","wrapId","symbolId","unwrapId","wrappedId","createPlaceholderRegExp","renderIds","replacerFn","match","SymbolRegistry","exportFrom","externalSourceSymbol","Project","defaultFileName","fileName","renderers","root","symbolIdToFileIds","exportSelector","exportFile","filePath","extension","path","dirs","meta","files","renderer","fileId","content","fileIds"],"mappings":"mJAIO,IAAMA,CAAAA,CAAgB,CAAC,CAC5B,IAAA,CAAAC,EACA,UAAA,CAAAC,CAAAA,CACA,OAAAC,CAAAA,CACA,UAAA,CAAAC,CACF,CAAA,GAKgB,CACd,IAAMC,CAAAA,CAAuB,GACvBC,CAAAA,CAA2B,GAC3BC,CAAAA,CAAmE,CACvE,QAAS,EAAC,CACV,KAAML,CACR,CAAA,CAeA,GAdIC,CAAAA,CAAO,IAAA,EAAM,aACXA,CAAAA,CAAO,IAAA,CAAK,aAAe,SAAA,EAC7BI,CAAAA,CAAQ,eAAiBJ,CAAAA,CAAO,WAAA,CAC5BA,EAAO,IAAA,CAAK,IAAA,GAAS,SACvBI,CAAAA,CAAQ,kBAAA,CAAqB,OAEtBJ,CAAAA,CAAO,IAAA,CAAK,aAAe,WAAA,GACpCI,CAAAA,CAAQ,iBAAmBJ,CAAAA,CAAO,WAAA,CAC9BA,EAAO,IAAA,CAAK,IAAA,GAAS,SACvBI,CAAAA,CAAQ,oBAAA,CAAuB,QAMnCJ,CAAAA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,OAAO,CAACkC,EAAsBlC,CAAAA,CAAO,QAAQ,EAE/C,IAAM2C,CAAAA,CAAW3C,EAAO,WAAA,GAAcA,CAAM,EAC5C,OAAI2C,CAAAA,CACKA,EAAS,KAAA,CAAM,GAAG,EAEpB,CAAC,IAAA,CAAK,eAAe,CAC9B,CACF","file":"index.cjs","sourcesContent":["import type { IFileOut } from '../files/types';\nimport type { ISymbolOut } from '../symbols/types';\nimport type { IBinding } from './types';\n\nexport const createBinding = ({\n file,\n modulePath,\n symbol,\n symbolFile,\n}: {\n file: IFileOut;\n modulePath: string;\n symbol: ISymbolOut;\n symbolFile: IFileOut;\n}): IBinding => {\n const names: Array<string> = [];\n const typeNames: Array<string> = [];\n const binding: IBinding & Pick<Required<IBinding>, 'aliases' | 'from'> = {\n aliases: {},\n from: modulePath,\n };\n if (symbol.meta?.importKind) {\n if (symbol.meta.importKind === 'default') {\n binding.defaultBinding = symbol.placeholder;\n if (symbol.meta.kind === 'type') {\n binding.typeDefaultBinding = true;\n }\n } else if (symbol.meta.importKind === 'namespace') {\n binding.namespaceBinding = symbol.placeholder;\n if (symbol.meta.kind === 'type') {\n binding.typeNamespaceBinding = true;\n }\n }\n }\n // default to named binding\n if (\n symbol.meta?.importKind === 'named' ||\n (!names.length && !binding.defaultBinding && !binding.namespaceBinding)\n ) {\n let name = symbol.placeholder;\n const fileResolvedName = file.resolvedNames.get(symbol.id);\n if (fileResolvedName) {\n const symbolFileResolvedName = symbolFile.resolvedNames.get(symbol.id);\n if (symbolFileResolvedName) {\n if (symbolFileResolvedName !== fileResolvedName) {\n name = symbolFileResolvedName;\n binding.aliases[name] = fileResolvedName;\n }\n } else if (symbol.name && fileResolvedName !== symbol.name) {\n name = symbol.name;\n binding.aliases[name] = symbol.placeholder;\n }\n }\n names.push(name);\n if (symbol.meta?.kind === 'type') {\n typeNames.push(name);\n }\n }\n // cast type names to names to allow for cleaner API,\n // otherwise users would have to define the same values twice\n for (const typeName of typeNames) {\n if (!names.includes(typeName)) {\n names.push(typeName);\n }\n }\n binding.names = names;\n binding.typeNames = typeNames;\n return binding;\n};\n\nexport const mergeBindings = (target: IBinding, source: IBinding): void => {\n target.aliases = { ...target.aliases, ...source.aliases };\n if (source.defaultBinding !== undefined) {\n target.defaultBinding = source.defaultBinding;\n }\n target.names = [\n ...new Set([...(target.names ?? []), ...(source.names ?? [])]),\n ];\n if (source.namespaceBinding !== undefined) {\n target.namespaceBinding = source.namespaceBinding;\n }\n if (source.typeDefaultBinding !== undefined) {\n target.typeDefaultBinding = source.typeDefaultBinding;\n }\n target.typeNames = [\n ...new Set([...(target.typeNames ?? []), ...(source.typeNames ?? [])]),\n ];\n if (source.typeNamespaceBinding !== undefined) {\n target.typeNamespaceBinding = source.typeNamespaceBinding;\n }\n};\n","import type { IBiMap } from './types';\n\nexport class BiMap<Key, Value> implements IBiMap<Key, Value> {\n private map = new Map<Key, Value>();\n private reverse = new Map<Value, Key>();\n\n delete(key: Key): boolean {\n const value = this.map.get(key);\n if (value !== undefined) {\n this.reverse.delete(value);\n }\n return this.map.delete(key);\n }\n\n deleteValue(value: Value): boolean {\n const key = this.reverse.get(value);\n if (key !== undefined) {\n this.map.delete(key);\n }\n return this.reverse.delete(value);\n }\n\n entries(): IterableIterator<[Key, Value]> {\n return this.map.entries();\n }\n\n get(key: Key): Value | undefined {\n return this.map.get(key);\n }\n\n getKey(value: Value): Key | undefined {\n return this.reverse.get(value);\n }\n\n hasKey(key: Key): boolean {\n return this.map.has(key);\n }\n\n hasValue(value: Value): boolean {\n return this.reverse.has(value);\n }\n\n keys(): IterableIterator<Key> {\n return this.map.keys();\n }\n\n set(key: Key, value: Value): this {\n const oldValue = this.map.get(key);\n if (oldValue !== undefined && oldValue !== value) {\n this.reverse.delete(oldValue);\n }\n const oldKey = this.reverse.get(value);\n if (oldKey !== undefined && oldKey !== key) {\n this.map.delete(oldKey);\n }\n this.map.set(key, value);\n this.reverse.set(value, key);\n return this;\n }\n\n get size(): number {\n return this.map.size;\n }\n\n values(): IterableIterator<Value> {\n return this.map.values();\n }\n\n [Symbol.iterator](): IterableIterator<[Key, Value]> {\n return this.map[Symbol.iterator]();\n }\n}\n","import { BiMap } from '../bimap/bimap';\nimport type { ISelector } from '../selectors/types';\nimport type { IFileIn, IFileOut, IFileRegistry } from './types';\n\nexport class FileRegistry implements IFileRegistry {\n private _id: number = 0;\n private referenceOrder: Set<number> = new Set();\n private registerOrder: Set<number> = new Set();\n private selectorToId: Map<string, number> = new Map();\n private values: Map<number, IFileOut> = new Map();\n\n get(fileIdOrSelector: number | ISelector): IFileOut | undefined {\n const symbol = this.idOrSelector(fileIdOrSelector);\n\n if (symbol.id !== undefined) {\n return this.values.get(symbol.id);\n }\n\n const selector =\n symbol.selector !== undefined\n ? JSON.stringify(symbol.selector)\n : undefined;\n\n if (selector) {\n const id = this.selectorToId.get(selector);\n if (id !== undefined) {\n return this.values.get(id);\n }\n }\n\n return;\n }\n\n get id(): number {\n return this._id++;\n }\n\n private idOrSelector(\n symbolIdOrSelector: number | ISelector,\n ): Pick<IFileIn, 'id' | 'selector'> {\n return typeof symbolIdOrSelector === 'number'\n ? { id: symbolIdOrSelector }\n : { selector: symbolIdOrSelector };\n }\n\n reference(fileIdOrSelector: number | ISelector): IFileOut {\n const file = this.idOrSelector(fileIdOrSelector);\n return this.register(file);\n }\n\n *referenced(): IterableIterator<IFileOut> {\n for (const id of this.referenceOrder.values()) {\n yield this.values.get(id)!;\n }\n }\n\n register(file: IFileIn): IFileOut {\n if (file.id !== undefined) {\n const result = this.values.get(file.id);\n if (!result) {\n throw new Error(\n `File with ID ${file.id} not found. To register a new file, leave the ID undefined.`,\n );\n }\n return result;\n }\n\n const hasOtherKeys = Object.keys(file).some(\n (key) => !['id', 'selector'].includes(key),\n );\n\n let result: IFileOut | undefined;\n\n const selector =\n file.selector !== undefined ? JSON.stringify(file.selector) : undefined;\n if (selector) {\n const id = this.selectorToId.get(selector);\n if (id !== undefined) {\n result = this.values.get(id);\n if (!result) {\n throw new Error(\n `File with ID ${id} not found. The selector ${selector} matched an ID, but there was no result. This is likely an issue with the application logic.`,\n );\n }\n if (!hasOtherKeys) {\n return result;\n }\n }\n }\n\n const id = result?.id !== undefined ? result.id : this.id;\n result = {\n ...result,\n ...file, // clone to avoid mutation\n id,\n resolvedNames: result?.resolvedNames ?? new BiMap(),\n symbols: result?.symbols ?? {\n body: [],\n exports: [],\n imports: [],\n },\n };\n this.values.set(id, result);\n\n if (hasOtherKeys) {\n this.registerOrder.add(id);\n } else {\n this.referenceOrder.add(id);\n }\n\n if (selector) {\n this.selectorToId.set(selector, id);\n }\n\n return result;\n }\n\n *registered(): IterableIterator<IFileOut> {\n for (const id of this.registerOrder.values()) {\n yield this.values.get(id)!;\n }\n }\n}\n","/**\n * Wraps an ID in namespace to avoid collisions when replacing it.\n *\n * @param symbolId Stringified symbol ID to use.\n * @returns The wrapped placeholder ID.\n */\nexport const wrapId = (symbolId: string): string => `_heyapi_${symbolId}_`;\n\n/**\n * Unwraps an ID from namespace.\n *\n * @param wrappedId The wrapped placeholder ID.\n * @returns Stringified ID to use.\n */\nconst unwrapId = (wrappedId: string): string =>\n wrappedId.slice('_heyapi_'.length, -1);\n\n/**\n * Returns a RegExp instance to match ID placeholders.\n *\n * @returns RegExp instance to match ID placeholders.\n */\nconst createPlaceholderRegExp = (): RegExp => new RegExp(wrapId('\\\\d+'), 'g');\n\n/**\n *\n * @param source The source string to replace.\n * @param replacerFn Accepts a symbol ID, returns resolved symbol name.\n * @returns The replaced source string.\n */\nexport const renderIds = (\n source: string,\n replacerFn: (symbolId: number) => string | undefined,\n): string =>\n source.replace(createPlaceholderRegExp(), (match) => {\n const symbolId = Number.parseInt(unwrapId(match), 10);\n return replacerFn(symbolId) || match;\n });\n","import { wrapId } from '../renderer/utils';\nimport type { ISelector } from '../selectors/types';\nimport type { ISymbolIn, ISymbolOut, ISymbolRegistry } from './types';\n\nexport class SymbolRegistry implements ISymbolRegistry {\n private _id: number = 0;\n private nodes: Map<number, unknown> = new Map();\n private registerOrder: Set<number> = new Set();\n private selectorToId: Map<string, number> = new Map();\n private values: Map<number, ISymbolOut> = new Map();\n\n get(symbolIdOrSelector: number | ISelector): ISymbolOut | undefined {\n const symbol = this.idOrSelector(symbolIdOrSelector);\n\n if (symbol.id !== undefined) {\n return this.values.get(symbol.id);\n }\n\n const selector =\n symbol.selector !== undefined\n ? JSON.stringify(symbol.selector)\n : undefined;\n\n if (selector) {\n const id = this.selectorToId.get(selector);\n if (id !== undefined) {\n return this.values.get(id);\n }\n }\n\n return;\n }\n\n getValue(symbolId: number): unknown {\n return this.nodes.get(symbolId);\n }\n\n hasValue(symbolId: number): boolean {\n return this.nodes.has(symbolId);\n }\n\n get id(): number {\n return this._id++;\n }\n\n private idOrSelector(\n symbolIdOrSelector: number | ISelector,\n ): Pick<ISymbolIn, 'id' | 'selector'> {\n return typeof symbolIdOrSelector === 'number'\n ? { id: symbolIdOrSelector }\n : { selector: symbolIdOrSelector };\n }\n\n reference(symbolIdOrSelector: number | ISelector): ISymbolOut {\n const symbol = this.idOrSelector(symbolIdOrSelector);\n return this.register(symbol);\n }\n\n register(symbol: ISymbolIn): ISymbolOut {\n if (symbol.id !== undefined) {\n const result = this.values.get(symbol.id);\n if (!result) {\n throw new Error(\n `Symbol with ID ${symbol.id} not found. To register a new symbol, leave the ID undefined.`,\n );\n }\n return result;\n }\n\n const hasOtherKeys = Object.keys(symbol).some(\n (key) => !['id', 'selector'].includes(key),\n );\n\n let result: ISymbolOut | undefined;\n\n const selector =\n symbol.selector !== undefined\n ? JSON.stringify(symbol.selector)\n : undefined;\n if (selector) {\n const id = this.selectorToId.get(selector);\n if (id !== undefined) {\n result = this.values.get(id);\n if (!result) {\n throw new Error(\n `Symbol with ID ${id} not found. The selector ${selector} matched an ID, but there was no result. This is likely an issue with the application logic.`,\n );\n }\n if (!hasOtherKeys) {\n return result;\n }\n }\n }\n\n const id = result?.id !== undefined ? result.id : this.id;\n const exportFrom: Array<string> = result?.exportFrom\n ? [...result.exportFrom]\n : [];\n if (symbol.exportFrom) {\n exportFrom.push(...symbol.exportFrom);\n }\n result = {\n ...result,\n ...symbol, // clone to avoid mutation\n exportFrom,\n id,\n placeholder:\n result?.placeholder ?? symbol.placeholder ?? wrapId(String(id)),\n };\n this.values.set(id, result);\n\n if (hasOtherKeys) {\n this.registerOrder.add(id);\n }\n\n if (selector) {\n this.selectorToId.set(selector, id);\n }\n\n return result;\n }\n\n *registered(): IterableIterator<ISymbolOut> {\n for (const id of this.registerOrder.values()) {\n yield this.values.get(id)!;\n }\n }\n\n setValue(symbolId: number, value: unknown): Map<number, unknown> {\n return this.nodes.set(symbolId, value);\n }\n}\n","import path from 'node:path';\n\nimport type { IProjectRenderMeta } from '../extensions/types';\nimport { FileRegistry } from '../files/registry';\nimport type { IFileOut } from '../files/types';\nimport type { IOutput } from '../output/types';\nimport type { IRenderer } from '../renderer/types';\nimport type { ISelector } from '../selectors/types';\nimport { SymbolRegistry } from '../symbols/registry';\nimport type { ISymbolOut } from '../symbols/types';\nimport type { IProject } from './types';\n\nconst externalSourceSymbol = '@';\n\nexport class Project implements IProject {\n private symbolIdToFileIds: Map<number, Set<number>> = new Map();\n\n readonly defaultFileName: string;\n readonly files = new FileRegistry();\n readonly fileName?: (name: string) => string;\n readonly renderers: Record<string, IRenderer> = {};\n readonly root: string;\n readonly symbols = new SymbolRegistry();\n\n constructor({\n defaultFileName,\n fileName,\n renderers,\n root,\n }: Pick<IProject, 'defaultFileName' | 'fileName' | 'renderers' | 'root'>) {\n this.defaultFileName = defaultFileName ?? 'main';\n this.fileName = typeof fileName === 'string' ? () => fileName : fileName;\n this.renderers = renderers;\n this.root = root;\n }\n\n private getRenderer(file: IFileOut): IRenderer | undefined {\n return file.extension ? this.renderers[file.extension] : undefined;\n }\n\n private prepareFiles(): void {\n // TODO: infer extension from symbols\n const extension = '.ts';\n for (const symbol of this.symbols.registered()) {\n const selector = this.symbolToFileSelector(symbol);\n const file = this.files.reference(selector);\n file.symbols.body.push(symbol.id);\n // update symbol->files map\n const symbolIdToFileIds =\n this.symbolIdToFileIds.get(symbol.id) ?? new Set();\n symbolIdToFileIds.add(file.id);\n this.symbolIdToFileIds.set(symbol.id, symbolIdToFileIds);\n // update re-exports\n for (const exportFrom of symbol.exportFrom) {\n const exportSelector = [exportFrom];\n const exportFile = this.files.reference(exportSelector);\n if (exportFile.id !== file.id) {\n exportFile.symbols.exports.push(symbol.id);\n }\n }\n }\n for (const file of this.files.referenced()) {\n if (!file.selector) continue;\n if (file.selector[0] === externalSourceSymbol) {\n const filePath = file.selector[1];\n if (!filePath) {\n this.files.register({\n external: true,\n selector: file.selector,\n });\n continue;\n }\n const extension = path.extname(filePath);\n if (!extension) {\n this.files.register({\n external: true,\n path: filePath,\n selector: file.selector,\n });\n continue;\n }\n this.files.register({\n extension,\n external: true,\n path: filePath,\n selector: file.selector,\n });\n continue;\n }\n const dirs = file.selector.slice(0, -1);\n let name = file.selector[file.selector.length - 1]!;\n name = this.fileName?.(name) || name;\n this.files.register({\n extension,\n name,\n path: path.resolve(this.root, ...dirs, `${name}${extension}`),\n selector: file.selector,\n });\n }\n\n // TODO: track symbol dependencies and inject imports into files\n // based on symbol references so the render step can just render\n }\n\n render(meta?: IProjectRenderMeta): ReadonlyArray<IOutput> {\n this.prepareFiles();\n const files: Map<number, IOutput> = new Map();\n for (const file of this.files.registered()) {\n if (file.external || !file.path) continue;\n const renderer = this.getRenderer(file);\n if (!renderer) continue;\n files.set(file.id, {\n content: renderer.renderSymbols(file, this, meta),\n path: file.path,\n });\n }\n for (const [fileId, value] of files.entries()) {\n const file = this.files.get(fileId)!;\n const renderer = this.getRenderer(file)!;\n const content = renderer.renderFile(value.content, file, this, meta);\n if (content) {\n files.set(file.id, { ...value, content });\n } else {\n files.delete(file.id);\n }\n }\n return Array.from(files.values());\n }\n\n symbolIdToFiles(symbolId: number): ReadonlyArray<IFileOut> {\n const fileIds = this.symbolIdToFileIds.get(symbolId);\n return Array.from(fileIds ?? []).map((fileId) => this.files.get(fileId)!);\n }\n\n private symbolToFileSelector(symbol: ISymbolOut): ISelector {\n if (symbol.external) {\n return [externalSourceSymbol, symbol.external];\n }\n const filePath = symbol.getFilePath?.(symbol);\n if (filePath) {\n return filePath.split('/');\n }\n return [this.defaultFileName];\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"index.cjs","names":["names: Array<string>","typeNames: Array<string>","binding: IBinding & Pick<Required<IBinding>, 'aliases' | 'from'>","result","result: IFileOut | undefined","id","result","result: ISymbolOut | undefined","id","exportFrom: Array<string>","extension","path","files: Map<number, IOutput>"],"sources":["../src/bindings/utils.ts","../src/bimap/bimap.ts","../src/files/registry.ts","../src/renderer/utils.ts","../src/symbols/registry.ts","../src/project/project.ts"],"sourcesContent":["import type { IFileOut } from '../files/types';\nimport type { ISymbolOut } from '../symbols/types';\nimport type { IBinding } from './types';\n\nexport const createBinding = ({\n file,\n modulePath,\n symbol,\n symbolFile,\n}: {\n file: IFileOut;\n modulePath: string;\n symbol: ISymbolOut;\n symbolFile: IFileOut;\n}): IBinding => {\n const names: Array<string> = [];\n const typeNames: Array<string> = [];\n const binding: IBinding & Pick<Required<IBinding>, 'aliases' | 'from'> = {\n aliases: {},\n from: modulePath,\n };\n if (symbol.meta?.importKind) {\n if (symbol.meta.importKind === 'default') {\n binding.defaultBinding = symbol.placeholder;\n if (symbol.meta.kind === 'type') {\n binding.typeDefaultBinding = true;\n }\n } else if (symbol.meta.importKind === 'namespace') {\n binding.namespaceBinding = symbol.placeholder;\n if (symbol.meta.kind === 'type') {\n binding.typeNamespaceBinding = true;\n }\n }\n }\n // default to named binding\n if (\n symbol.meta?.importKind === 'named' ||\n (!names.length && !binding.defaultBinding && !binding.namespaceBinding)\n ) {\n let name = symbol.placeholder;\n const fileResolvedName = file.resolvedNames.get(symbol.id);\n if (fileResolvedName) {\n const symbolFileResolvedName = symbolFile.resolvedNames.get(symbol.id);\n if (symbolFileResolvedName) {\n if (symbolFileResolvedName !== fileResolvedName) {\n name = symbolFileResolvedName;\n binding.aliases[name] = fileResolvedName;\n }\n } else if (symbol.name && fileResolvedName !== symbol.name) {\n name = symbol.name;\n binding.aliases[name] = symbol.placeholder;\n }\n }\n names.push(name);\n if (symbol.meta?.kind === 'type') {\n typeNames.push(name);\n }\n }\n // cast type names to names to allow for cleaner API,\n // otherwise users would have to define the same values twice\n for (const typeName of typeNames) {\n if (!names.includes(typeName)) {\n names.push(typeName);\n }\n }\n binding.names = names;\n binding.typeNames = typeNames;\n return binding;\n};\n\nexport const mergeBindings = (target: IBinding, source: IBinding): void => {\n target.aliases = { ...target.aliases, ...source.aliases };\n if (source.defaultBinding !== undefined) {\n target.defaultBinding = source.defaultBinding;\n }\n target.names = [\n ...new Set([...(target.names ?? []), ...(source.names ?? [])]),\n ];\n if (source.namespaceBinding !== undefined) {\n target.namespaceBinding = source.namespaceBinding;\n }\n if (source.typeDefaultBinding !== undefined) {\n target.typeDefaultBinding = source.typeDefaultBinding;\n }\n target.typeNames = [\n ...new Set([...(target.typeNames ?? []), ...(source.typeNames ?? [])]),\n ];\n if (source.typeNamespaceBinding !== undefined) {\n target.typeNamespaceBinding = source.typeNamespaceBinding;\n }\n};\n","import type { IBiMap } from './types';\n\nexport class BiMap<Key, Value> implements IBiMap<Key, Value> {\n private map = new Map<Key, Value>();\n private reverse = new Map<Value, Key>();\n\n delete(key: Key): boolean {\n const value = this.map.get(key);\n if (value !== undefined) {\n this.reverse.delete(value);\n }\n return this.map.delete(key);\n }\n\n deleteValue(value: Value): boolean {\n const key = this.reverse.get(value);\n if (key !== undefined) {\n this.map.delete(key);\n }\n return this.reverse.delete(value);\n }\n\n entries(): IterableIterator<[Key, Value]> {\n return this.map.entries();\n }\n\n get(key: Key): Value | undefined {\n return this.map.get(key);\n }\n\n getKey(value: Value): Key | undefined {\n return this.reverse.get(value);\n }\n\n hasKey(key: Key): boolean {\n return this.map.has(key);\n }\n\n hasValue(value: Value): boolean {\n return this.reverse.has(value);\n }\n\n keys(): IterableIterator<Key> {\n return this.map.keys();\n }\n\n set(key: Key, value: Value): this {\n const oldValue = this.map.get(key);\n if (oldValue !== undefined && oldValue !== value) {\n this.reverse.delete(oldValue);\n }\n const oldKey = this.reverse.get(value);\n if (oldKey !== undefined && oldKey !== key) {\n this.map.delete(oldKey);\n }\n this.map.set(key, value);\n this.reverse.set(value, key);\n return this;\n }\n\n get size(): number {\n return this.map.size;\n }\n\n values(): IterableIterator<Value> {\n return this.map.values();\n }\n\n [Symbol.iterator](): IterableIterator<[Key, Value]> {\n return this.map[Symbol.iterator]();\n }\n}\n","import { BiMap } from '../bimap/bimap';\nimport type { ISelector } from '../selectors/types';\nimport type { IFileIn, IFileOut, IFileRegistry } from './types';\n\nexport class FileRegistry implements IFileRegistry {\n private _id: number = 0;\n private referenceOrder: Set<number> = new Set();\n private registerOrder: Set<number> = new Set();\n private selectorToId: Map<string, number> = new Map();\n private values: Map<number, IFileOut> = new Map();\n\n get(fileIdOrSelector: number | ISelector): IFileOut | undefined {\n const symbol = this.idOrSelector(fileIdOrSelector);\n\n if (symbol.id !== undefined) {\n return this.values.get(symbol.id);\n }\n\n const selector =\n symbol.selector !== undefined\n ? JSON.stringify(symbol.selector)\n : undefined;\n\n if (selector) {\n const id = this.selectorToId.get(selector);\n if (id !== undefined) {\n return this.values.get(id);\n }\n }\n\n return;\n }\n\n get id(): number {\n return this._id++;\n }\n\n private idOrSelector(\n symbolIdOrSelector: number | ISelector,\n ): Pick<IFileIn, 'id' | 'selector'> {\n return typeof symbolIdOrSelector === 'number'\n ? { id: symbolIdOrSelector }\n : { selector: symbolIdOrSelector };\n }\n\n isRegistered(fileIdOrSelector: number | ISelector): boolean {\n const file = this.get(fileIdOrSelector);\n return file ? this.registerOrder.has(file.id) : false;\n }\n\n reference(fileIdOrSelector: number | ISelector): IFileOut {\n const file = this.idOrSelector(fileIdOrSelector);\n return this.register(file);\n }\n\n *referenced(): IterableIterator<IFileOut> {\n for (const id of this.referenceOrder.values()) {\n yield this.values.get(id)!;\n }\n }\n\n register(file: IFileIn): IFileOut {\n if (file.id !== undefined) {\n const result = this.values.get(file.id);\n if (!result) {\n throw new Error(\n `File with ID ${file.id} not found. To register a new file, leave the ID undefined.`,\n );\n }\n return result;\n }\n\n const hasOtherKeys = Object.keys(file).some(\n (key) => !['id', 'selector'].includes(key),\n );\n\n let result: IFileOut | undefined;\n\n const selector =\n file.selector !== undefined ? JSON.stringify(file.selector) : undefined;\n if (selector) {\n const id = this.selectorToId.get(selector);\n if (id !== undefined) {\n result = this.values.get(id);\n if (!result) {\n throw new Error(\n `File with ID ${id} not found. The selector ${selector} matched an ID, but there was no result. This is likely an issue with the application logic.`,\n );\n }\n if (!hasOtherKeys) {\n return result;\n }\n }\n }\n\n const id = result?.id !== undefined ? result.id : this.id;\n result = {\n ...result,\n ...file, // clone to avoid mutation\n id,\n resolvedNames: result?.resolvedNames ?? new BiMap(),\n symbols: result?.symbols ?? {\n body: [],\n exports: [],\n imports: [],\n },\n };\n this.values.set(id, result);\n\n if (hasOtherKeys) {\n this.registerOrder.add(id);\n if (this.referenceOrder.has(id)) {\n this.referenceOrder.delete(id);\n }\n } else {\n this.referenceOrder.add(id);\n }\n\n if (selector) {\n this.selectorToId.set(selector, id);\n }\n\n return result;\n }\n\n *registered(): IterableIterator<IFileOut> {\n for (const id of this.registerOrder.values()) {\n yield this.values.get(id)!;\n }\n }\n}\n","/**\n * Wraps an ID in namespace to avoid collisions when replacing it.\n *\n * @param symbolId Stringified symbol ID to use.\n * @returns The wrapped placeholder ID.\n */\nexport const wrapId = (symbolId: string): string => `_heyapi_${symbolId}_`;\n\n/**\n * Unwraps an ID from namespace.\n *\n * @param wrappedId The wrapped placeholder ID.\n * @returns Stringified ID to use.\n */\nconst unwrapId = (wrappedId: string): string =>\n wrappedId.slice('_heyapi_'.length, -1);\n\n/**\n * Returns a RegExp instance to match ID placeholders.\n *\n * @returns RegExp instance to match ID placeholders.\n */\nconst createPlaceholderRegExp = (): RegExp => new RegExp(wrapId('\\\\d+'), 'g');\n\n/**\n *\n * @param source The source string to replace.\n * @param replacerFn Accepts a symbol ID, returns resolved symbol name.\n * @returns The replaced source string.\n */\nexport const renderIds = (\n source: string,\n replacerFn: (symbolId: number) => string | undefined,\n): string =>\n source.replace(createPlaceholderRegExp(), (match) => {\n const symbolId = Number.parseInt(unwrapId(match), 10);\n return replacerFn(symbolId) || match;\n });\n","import { wrapId } from '../renderer/utils';\nimport type { ISelector } from '../selectors/types';\nimport type { ISymbolIn, ISymbolOut, ISymbolRegistry } from './types';\n\nexport class SymbolRegistry implements ISymbolRegistry {\n private _id: number = 0;\n private nodes: Map<number, unknown> = new Map();\n private registerOrder: Set<number> = new Set();\n private selectorToId: Map<string, number> = new Map();\n private values: Map<number, ISymbolOut> = new Map();\n\n get(symbolIdOrSelector: number | ISelector): ISymbolOut | undefined {\n const symbol = this.idOrSelector(symbolIdOrSelector);\n\n if (symbol.id !== undefined) {\n return this.values.get(symbol.id);\n }\n\n const selector =\n symbol.selector !== undefined\n ? JSON.stringify(symbol.selector)\n : undefined;\n\n if (selector) {\n const id = this.selectorToId.get(selector);\n if (id !== undefined) {\n return this.values.get(id);\n }\n }\n\n return;\n }\n\n getValue(symbolId: number): unknown {\n return this.nodes.get(symbolId);\n }\n\n hasValue(symbolId: number): boolean {\n return this.nodes.has(symbolId);\n }\n\n get id(): number {\n return this._id++;\n }\n\n private idOrSelector(\n symbolIdOrSelector: number | ISelector,\n ): Pick<ISymbolIn, 'id' | 'selector'> {\n return typeof symbolIdOrSelector === 'number'\n ? { id: symbolIdOrSelector }\n : { selector: symbolIdOrSelector };\n }\n\n isRegistered(symbolIdOrSelector: number | ISelector): boolean {\n const symbol = this.get(symbolIdOrSelector);\n return symbol ? this.registerOrder.has(symbol.id) : false;\n }\n\n reference(symbolIdOrSelector: number | ISelector): ISymbolOut {\n const symbol = this.idOrSelector(symbolIdOrSelector);\n return this.register(symbol);\n }\n\n register(symbol: ISymbolIn): ISymbolOut {\n if (symbol.id !== undefined) {\n const result = this.values.get(symbol.id);\n if (!result) {\n throw new Error(\n `Symbol with ID ${symbol.id} not found. To register a new symbol, leave the ID undefined.`,\n );\n }\n return result;\n }\n\n const hasOtherKeys = Object.keys(symbol).some(\n (key) => !['id', 'selector'].includes(key),\n );\n\n let result: ISymbolOut | undefined;\n\n const selector =\n symbol.selector !== undefined\n ? JSON.stringify(symbol.selector)\n : undefined;\n if (selector) {\n const id = this.selectorToId.get(selector);\n if (id !== undefined) {\n result = this.values.get(id);\n if (!result) {\n throw new Error(\n `Symbol with ID ${id} not found. The selector ${selector} matched an ID, but there was no result. This is likely an issue with the application logic.`,\n );\n }\n if (!hasOtherKeys) {\n return result;\n }\n }\n }\n\n const id = result?.id !== undefined ? result.id : this.id;\n const exportFrom: Array<string> = result?.exportFrom\n ? [...result.exportFrom]\n : [];\n if (symbol.exportFrom) {\n exportFrom.push(...symbol.exportFrom);\n }\n result = {\n ...result,\n ...symbol, // clone to avoid mutation\n exportFrom,\n id,\n placeholder:\n result?.placeholder ?? symbol.placeholder ?? wrapId(String(id)),\n };\n this.values.set(id, result);\n\n if (hasOtherKeys) {\n this.registerOrder.add(id);\n }\n\n if (selector) {\n this.selectorToId.set(selector, id);\n }\n\n return result;\n }\n\n *registered(): IterableIterator<ISymbolOut> {\n for (const id of this.registerOrder.values()) {\n yield this.values.get(id)!;\n }\n }\n\n setValue(symbolId: number, value: unknown): Map<number, unknown> {\n return this.nodes.set(symbolId, value);\n }\n}\n","import path from 'node:path';\n\nimport type { IProjectRenderMeta } from '../extensions/types';\nimport { FileRegistry } from '../files/registry';\nimport type { IFileOut } from '../files/types';\nimport type { IOutput } from '../output/types';\nimport type { IRenderer } from '../renderer/types';\nimport type { ISelector } from '../selectors/types';\nimport { SymbolRegistry } from '../symbols/registry';\nimport type { ISymbolOut } from '../symbols/types';\nimport type { IProject } from './types';\n\nconst externalSourceSymbol = '@';\n\nexport class Project implements IProject {\n private symbolIdToFileIds: Map<number, Set<number>> = new Map();\n\n readonly defaultFileName: string;\n readonly files = new FileRegistry();\n readonly fileName?: (name: string) => string;\n readonly renderers: Record<string, IRenderer> = {};\n readonly root: string;\n readonly symbols = new SymbolRegistry();\n\n constructor({\n defaultFileName,\n fileName,\n renderers,\n root,\n }: Pick<IProject, 'defaultFileName' | 'fileName' | 'renderers' | 'root'>) {\n this.defaultFileName = defaultFileName ?? 'main';\n this.fileName = typeof fileName === 'string' ? () => fileName : fileName;\n this.renderers = renderers;\n this.root = root;\n }\n\n private getRenderer(file: IFileOut): IRenderer | undefined {\n return file.extension ? this.renderers[file.extension] : undefined;\n }\n\n private prepareFiles(): void {\n // TODO: infer extension from symbols\n const extension = '.ts';\n for (const symbol of this.symbols.registered()) {\n const selector = this.symbolToFileSelector(symbol);\n const file = this.files.reference(selector);\n file.symbols.body.push(symbol.id);\n // update symbol->files map\n const symbolIdToFileIds =\n this.symbolIdToFileIds.get(symbol.id) ?? new Set();\n symbolIdToFileIds.add(file.id);\n this.symbolIdToFileIds.set(symbol.id, symbolIdToFileIds);\n // update re-exports\n for (const exportFrom of symbol.exportFrom) {\n const exportSelector = [exportFrom];\n const exportFile = this.files.reference(exportSelector);\n if (exportFile.id !== file.id) {\n exportFile.symbols.exports.push(symbol.id);\n }\n }\n }\n for (const file of this.files.referenced()) {\n if (!file.selector) continue;\n if (file.selector[0] === externalSourceSymbol) {\n const filePath = file.selector[1];\n if (!filePath) {\n this.files.register({\n external: true,\n selector: file.selector,\n });\n continue;\n }\n const extension = path.extname(filePath);\n if (!extension) {\n this.files.register({\n external: true,\n path: filePath,\n selector: file.selector,\n });\n continue;\n }\n this.files.register({\n extension,\n external: true,\n path: filePath,\n selector: file.selector,\n });\n continue;\n }\n const dirs = file.selector.slice(0, -1);\n let name = file.selector[file.selector.length - 1]!;\n name = this.fileName?.(name) || name;\n this.files.register({\n extension,\n name,\n path: path.resolve(this.root, ...dirs, `${name}${extension}`),\n selector: file.selector,\n });\n }\n\n // TODO: track symbol dependencies and inject imports into files\n // based on symbol references so the render step can just render\n }\n\n render(meta?: IProjectRenderMeta): ReadonlyArray<IOutput> {\n this.prepareFiles();\n const files: Map<number, IOutput> = new Map();\n for (const file of this.files.registered()) {\n if (file.external || !file.path) continue;\n const renderer = this.getRenderer(file);\n if (!renderer) continue;\n files.set(file.id, {\n content: renderer.renderSymbols(file, this, meta),\n path: file.path,\n });\n }\n for (const [fileId, value] of files.entries()) {\n const file = this.files.get(fileId)!;\n const renderer = this.getRenderer(file)!;\n const content = renderer.renderFile(value.content, file, this, meta);\n if (content) {\n files.set(file.id, { ...value, content });\n } else {\n files.delete(file.id);\n }\n }\n return Array.from(files.values());\n }\n\n symbolIdToFiles(symbolId: number): ReadonlyArray<IFileOut> {\n const fileIds = this.symbolIdToFileIds.get(symbolId);\n return Array.from(fileIds ?? []).map((fileId) => this.files.get(fileId)!);\n }\n\n private symbolToFileSelector(symbol: ISymbolOut): ISelector {\n if (symbol.external) {\n return [externalSourceSymbol, symbol.external];\n }\n const filePath = symbol.getFilePath?.(symbol);\n if (filePath) {\n return filePath.split('/');\n }\n return [this.defaultFileName];\n }\n}\n"],"mappings":"ggBAIA,MAAa,GAAiB,CAC5B,OACA,aACA,SACA,gBAMc,CACd,IAAMA,EAAuB,EAAE,CACzBC,EAA2B,EAAE,CAC7BC,EAAmE,CACvE,QAAS,EAAE,CACX,KAAM,EACP,CAeD,GAdI,EAAO,MAAM,aACX,EAAO,KAAK,aAAe,WAC7B,EAAQ,eAAiB,EAAO,YAC5B,EAAO,KAAK,OAAS,SACvB,EAAQ,mBAAqB,KAEtB,EAAO,KAAK,aAAe,cACpC,EAAQ,iBAAmB,EAAO,YAC9B,EAAO,KAAK,OAAS,SACvB,EAAQ,qBAAuB,MAMnC,EAAO,MAAM,aAAe,SAC3B,CAAC,EAAM,QAAU,CAAC,EAAQ,gBAAkB,CAAC,EAAQ,iBACtD,CACA,IAAI,EAAO,EAAO,YACZ,EAAmB,EAAK,cAAc,IAAI,EAAO,GAAG,CAC1D,GAAI,EAAkB,C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EAAK,GAAG,CAGzB,OAAO,MAAM,KAAK,EAAM,QAAQ,CAAC,CAGnC,gBAAgB,EAA2C,CACzD,IAAM,EAAU,KAAK,kBAAkB,IAAI,EAAS,CACpD,OAAO,MAAM,KAAK,GAAW,EAAE,CAAC,CAAC,IAAK,GAAW,KAAK,MAAM,IAAI,EAAO,CAAE,CAG3E,qBAA6B,EAA+B,CAC1D,GAAI,EAAO,SACT,MAAO,CAAC,IAAsB,EAAO,SAAS,CAEhD,IAAM,EAAW,EAAO,cAAc,EAAO,CAI7C,OAHI,EACK,EAAS,MAAM,IAAI,CAErB,CAAC,KAAK,gBAAgB"}
|
package/dist/index.d.cts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
//#region src/bimap/types.d.ts
|
|
1
2
|
/**
|
|
2
3
|
* Bi-directional map interface.
|
|
3
4
|
*
|
|
@@ -72,7 +73,8 @@ interface IBiMap<Key, Value> {
|
|
|
72
73
|
*/
|
|
73
74
|
[Symbol.iterator](): IterableIterator<[Key, Value]>;
|
|
74
75
|
}
|
|
75
|
-
|
|
76
|
+
//#endregion
|
|
77
|
+
//#region src/bindings/types.d.ts
|
|
76
78
|
interface IBinding {
|
|
77
79
|
/**
|
|
78
80
|
* Optional aliasing map for named symbols.
|
|
@@ -132,7 +134,8 @@ interface IBinding {
|
|
|
132
134
|
*/
|
|
133
135
|
typeNamespaceBinding?: boolean;
|
|
134
136
|
}
|
|
135
|
-
|
|
137
|
+
//#endregion
|
|
138
|
+
//#region src/selectors/types.d.ts
|
|
136
139
|
/**
|
|
137
140
|
* Selector array used to reference resources. We don't enforce
|
|
138
141
|
* uniqueness, but in practice it's desirable.
|
|
@@ -140,7 +143,8 @@ interface IBinding {
|
|
|
140
143
|
* @example ["zod", "#/components/schemas/Foo"]
|
|
141
144
|
*/
|
|
142
145
|
type ISelector = ReadonlyArray<string>;
|
|
143
|
-
|
|
146
|
+
//#endregion
|
|
147
|
+
//#region src/files/types.d.ts
|
|
144
148
|
interface IFileIn {
|
|
145
149
|
/**
|
|
146
150
|
* File extension, if any.
|
|
@@ -179,7 +183,6 @@ interface IFileIn {
|
|
|
179
183
|
*/
|
|
180
184
|
readonly selector?: ISelector;
|
|
181
185
|
}
|
|
182
|
-
|
|
183
186
|
interface IFileOut extends IFileIn {
|
|
184
187
|
/**
|
|
185
188
|
* Unique file ID.
|
|
@@ -207,7 +210,6 @@ interface IFileOut extends IFileIn {
|
|
|
207
210
|
imports: Array<number>;
|
|
208
211
|
};
|
|
209
212
|
}
|
|
210
|
-
|
|
211
213
|
interface IFileRegistry {
|
|
212
214
|
/**
|
|
213
215
|
* Get a file by its ID.
|
|
@@ -222,6 +224,13 @@ interface IFileRegistry {
|
|
|
222
224
|
* @returns File ID before being incremented
|
|
223
225
|
*/
|
|
224
226
|
readonly id: number;
|
|
227
|
+
/**
|
|
228
|
+
* Returns whether a file is registered in the registry.
|
|
229
|
+
*
|
|
230
|
+
* @param fileIdOrSelector File ID or selector to check.
|
|
231
|
+
* @returns True if the file is registered, false otherwise.
|
|
232
|
+
*/
|
|
233
|
+
isRegistered(fileIdOrSelector: number | ISelector): boolean;
|
|
225
234
|
/**
|
|
226
235
|
* Returns a file by ID or selector, registering it if it doesn't exist.
|
|
227
236
|
*
|
|
@@ -251,7 +260,8 @@ interface IFileRegistry {
|
|
|
251
260
|
*/
|
|
252
261
|
registered(): IterableIterator<IFileOut>;
|
|
253
262
|
}
|
|
254
|
-
|
|
263
|
+
//#endregion
|
|
264
|
+
//#region src/extensions/types.d.ts
|
|
255
265
|
/**
|
|
256
266
|
* Arbitrary metadata passed to the project's render function.
|
|
257
267
|
*
|
|
@@ -260,7 +270,6 @@ interface IFileRegistry {
|
|
|
260
270
|
interface IProjectRenderMeta {
|
|
261
271
|
[key: string]: unknown;
|
|
262
272
|
}
|
|
263
|
-
|
|
264
273
|
/**
|
|
265
274
|
* Additional metadata about the symbol.
|
|
266
275
|
*
|
|
@@ -269,7 +278,8 @@ interface IProjectRenderMeta {
|
|
|
269
278
|
interface ISymbolMeta {
|
|
270
279
|
[key: string]: unknown;
|
|
271
280
|
}
|
|
272
|
-
|
|
281
|
+
//#endregion
|
|
282
|
+
//#region src/symbols/types.d.ts
|
|
273
283
|
interface ISymbolIn {
|
|
274
284
|
/**
|
|
275
285
|
* Array of file names (without extensions) from which this symbol is re-exported.
|
|
@@ -336,7 +346,6 @@ interface ISymbolIn {
|
|
|
336
346
|
*/
|
|
337
347
|
readonly selector?: ISelector;
|
|
338
348
|
}
|
|
339
|
-
|
|
340
349
|
interface ISymbolOut extends ISymbolIn {
|
|
341
350
|
/**
|
|
342
351
|
* Array of file names (without extensions) from which this symbol is re-exported.
|
|
@@ -353,7 +362,6 @@ interface ISymbolOut extends ISymbolIn {
|
|
|
353
362
|
*/
|
|
354
363
|
readonly placeholder: string;
|
|
355
364
|
}
|
|
356
|
-
|
|
357
365
|
interface ISymbolRegistry {
|
|
358
366
|
/**
|
|
359
367
|
* Get a symbol by its ID.
|
|
@@ -382,6 +390,13 @@ interface ISymbolRegistry {
|
|
|
382
390
|
* @returns Symbol ID before being incremented.
|
|
383
391
|
*/
|
|
384
392
|
readonly id: number;
|
|
393
|
+
/**
|
|
394
|
+
* Returns whether a symbol is registered in the registry.
|
|
395
|
+
*
|
|
396
|
+
* @param symbolIdOrSelector Symbol ID or selector to check.
|
|
397
|
+
* @returns True if the symbol is registered, false otherwise.
|
|
398
|
+
*/
|
|
399
|
+
isRegistered(symbolIdOrSelector: number | ISelector): boolean;
|
|
385
400
|
/**
|
|
386
401
|
* Returns a symbol by ID or selector, registering it if it doesn't exist.
|
|
387
402
|
*
|
|
@@ -413,15 +428,22 @@ interface ISymbolRegistry {
|
|
|
413
428
|
*/
|
|
414
429
|
setValue(symbolId: number, value: unknown): Map<number, unknown>;
|
|
415
430
|
}
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
431
|
+
//#endregion
|
|
432
|
+
//#region src/bindings/utils.d.ts
|
|
433
|
+
declare const createBinding: ({
|
|
434
|
+
file,
|
|
435
|
+
modulePath,
|
|
436
|
+
symbol,
|
|
437
|
+
symbolFile
|
|
438
|
+
}: {
|
|
439
|
+
file: IFileOut;
|
|
440
|
+
modulePath: string;
|
|
441
|
+
symbol: ISymbolOut;
|
|
442
|
+
symbolFile: IFileOut;
|
|
422
443
|
}) => IBinding;
|
|
423
444
|
declare const mergeBindings: (target: IBinding, source: IBinding) => void;
|
|
424
|
-
|
|
445
|
+
//#endregion
|
|
446
|
+
//#region src/output/types.d.ts
|
|
425
447
|
interface IOutput {
|
|
426
448
|
/**
|
|
427
449
|
* The main content of the file to output.
|
|
@@ -438,22 +460,25 @@ interface IOutput {
|
|
|
438
460
|
*/
|
|
439
461
|
path: string;
|
|
440
462
|
}
|
|
441
|
-
|
|
463
|
+
//#endregion
|
|
464
|
+
//#region src/files/registry.d.ts
|
|
442
465
|
declare class FileRegistry implements IFileRegistry {
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
466
|
+
private _id;
|
|
467
|
+
private referenceOrder;
|
|
468
|
+
private registerOrder;
|
|
469
|
+
private selectorToId;
|
|
470
|
+
private values;
|
|
471
|
+
get(fileIdOrSelector: number | ISelector): IFileOut | undefined;
|
|
472
|
+
get id(): number;
|
|
473
|
+
private idOrSelector;
|
|
474
|
+
isRegistered(fileIdOrSelector: number | ISelector): boolean;
|
|
475
|
+
reference(fileIdOrSelector: number | ISelector): IFileOut;
|
|
476
|
+
referenced(): IterableIterator<IFileOut>;
|
|
477
|
+
register(file: IFileIn): IFileOut;
|
|
478
|
+
registered(): IterableIterator<IFileOut>;
|
|
455
479
|
}
|
|
456
|
-
|
|
480
|
+
//#endregion
|
|
481
|
+
//#region src/project/types.d.ts
|
|
457
482
|
/**
|
|
458
483
|
* Represents a code generation project consisting of multiple codegen files.
|
|
459
484
|
* Manages imports, symbols, and output generation across the project.
|
|
@@ -517,7 +542,8 @@ interface IProject {
|
|
|
517
542
|
*/
|
|
518
543
|
readonly symbols: ISymbolRegistry;
|
|
519
544
|
}
|
|
520
|
-
|
|
545
|
+
//#endregion
|
|
546
|
+
//#region src/renderer/types.d.ts
|
|
521
547
|
interface IRenderer {
|
|
522
548
|
/**
|
|
523
549
|
* Renders content with replaced symbols.
|
|
@@ -527,12 +553,7 @@ interface IRenderer {
|
|
|
527
553
|
* @param project The parent project the file belongs to.
|
|
528
554
|
* @returns Rendered content.
|
|
529
555
|
*/
|
|
530
|
-
renderFile(
|
|
531
|
-
content: string,
|
|
532
|
-
file: IFile,
|
|
533
|
-
project: IProject,
|
|
534
|
-
meta?: IProjectRenderMeta,
|
|
535
|
-
): string;
|
|
556
|
+
renderFile(content: string, file: IFile, project: IProject, meta?: IProjectRenderMeta): string;
|
|
536
557
|
/**
|
|
537
558
|
* Returns printable data containing symbols and exports.
|
|
538
559
|
*
|
|
@@ -541,46 +562,51 @@ interface IRenderer {
|
|
|
541
562
|
* @param meta Arbitrary metadata.
|
|
542
563
|
* @returns Printable string containing symbols and exports.
|
|
543
564
|
*/
|
|
544
|
-
renderSymbols(
|
|
545
|
-
file: IFileOut,
|
|
546
|
-
project: IProject,
|
|
547
|
-
meta?: IProjectRenderMeta,
|
|
548
|
-
): string;
|
|
565
|
+
renderSymbols(file: IFileOut, project: IProject, meta?: IProjectRenderMeta): string;
|
|
549
566
|
}
|
|
550
|
-
|
|
567
|
+
//#endregion
|
|
568
|
+
//#region src/symbols/registry.d.ts
|
|
551
569
|
declare class SymbolRegistry implements ISymbolRegistry {
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
570
|
+
private _id;
|
|
571
|
+
private nodes;
|
|
572
|
+
private registerOrder;
|
|
573
|
+
private selectorToId;
|
|
574
|
+
private values;
|
|
575
|
+
get(symbolIdOrSelector: number | ISelector): ISymbolOut | undefined;
|
|
576
|
+
getValue(symbolId: number): unknown;
|
|
577
|
+
hasValue(symbolId: number): boolean;
|
|
578
|
+
get id(): number;
|
|
579
|
+
private idOrSelector;
|
|
580
|
+
isRegistered(symbolIdOrSelector: number | ISelector): boolean;
|
|
581
|
+
reference(symbolIdOrSelector: number | ISelector): ISymbolOut;
|
|
582
|
+
register(symbol: ISymbolIn): ISymbolOut;
|
|
583
|
+
registered(): IterableIterator<ISymbolOut>;
|
|
584
|
+
setValue(symbolId: number, value: unknown): Map<number, unknown>;
|
|
566
585
|
}
|
|
567
|
-
|
|
586
|
+
//#endregion
|
|
587
|
+
//#region src/project/project.d.ts
|
|
568
588
|
declare class Project implements IProject {
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
589
|
+
private symbolIdToFileIds;
|
|
590
|
+
readonly defaultFileName: string;
|
|
591
|
+
readonly files: FileRegistry;
|
|
592
|
+
readonly fileName?: (name: string) => string;
|
|
593
|
+
readonly renderers: Record<string, IRenderer>;
|
|
594
|
+
readonly root: string;
|
|
595
|
+
readonly symbols: SymbolRegistry;
|
|
596
|
+
constructor({
|
|
597
|
+
defaultFileName,
|
|
598
|
+
fileName,
|
|
599
|
+
renderers,
|
|
600
|
+
root
|
|
601
|
+
}: Pick<IProject, 'defaultFileName' | 'fileName' | 'renderers' | 'root'>);
|
|
602
|
+
private getRenderer;
|
|
603
|
+
private prepareFiles;
|
|
604
|
+
render(meta?: IProjectRenderMeta): ReadonlyArray<IOutput>;
|
|
605
|
+
symbolIdToFiles(symbolId: number): ReadonlyArray<IFileOut>;
|
|
606
|
+
private symbolToFileSelector;
|
|
582
607
|
}
|
|
583
|
-
|
|
608
|
+
//#endregion
|
|
609
|
+
//#region src/renderer/utils.d.ts
|
|
584
610
|
/**
|
|
585
611
|
*
|
|
586
612
|
* @param source The source string to replace.
|
|
@@ -588,5 +614,6 @@ declare class Project implements IProject {
|
|
|
588
614
|
* @returns The replaced source string.
|
|
589
615
|
*/
|
|
590
616
|
declare const renderIds: (source: string, replacerFn: (symbolId: number) => string | undefined) => string;
|
|
591
|
-
|
|
617
|
+
//#endregion
|
|
592
618
|
export { type IBiMap as BiMap, type IBinding as Binding, type IFileOut as File, type IFileIn as FileIn, type IProject, type IOutput as Output, Project, type IProjectRenderMeta as ProjectRenderMeta, type IRenderer as Renderer, type ISelector as Selector, type ISymbolOut as Symbol, type ISymbolIn as SymbolIn, type ISymbolMeta as SymbolMeta, createBinding, mergeBindings, renderIds };
|
|
619
|
+
//# sourceMappingURL=index.d.cts.map
|
package/dist/index.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
//#region src/bimap/types.d.ts
|
|
1
2
|
/**
|
|
2
3
|
* Bi-directional map interface.
|
|
3
4
|
*
|
|
@@ -72,7 +73,8 @@ interface IBiMap<Key, Value> {
|
|
|
72
73
|
*/
|
|
73
74
|
[Symbol.iterator](): IterableIterator<[Key, Value]>;
|
|
74
75
|
}
|
|
75
|
-
|
|
76
|
+
//#endregion
|
|
77
|
+
//#region src/bindings/types.d.ts
|
|
76
78
|
interface IBinding {
|
|
77
79
|
/**
|
|
78
80
|
* Optional aliasing map for named symbols.
|
|
@@ -132,7 +134,8 @@ interface IBinding {
|
|
|
132
134
|
*/
|
|
133
135
|
typeNamespaceBinding?: boolean;
|
|
134
136
|
}
|
|
135
|
-
|
|
137
|
+
//#endregion
|
|
138
|
+
//#region src/selectors/types.d.ts
|
|
136
139
|
/**
|
|
137
140
|
* Selector array used to reference resources. We don't enforce
|
|
138
141
|
* uniqueness, but in practice it's desirable.
|
|
@@ -140,7 +143,8 @@ interface IBinding {
|
|
|
140
143
|
* @example ["zod", "#/components/schemas/Foo"]
|
|
141
144
|
*/
|
|
142
145
|
type ISelector = ReadonlyArray<string>;
|
|
143
|
-
|
|
146
|
+
//#endregion
|
|
147
|
+
//#region src/files/types.d.ts
|
|
144
148
|
interface IFileIn {
|
|
145
149
|
/**
|
|
146
150
|
* File extension, if any.
|
|
@@ -179,7 +183,6 @@ interface IFileIn {
|
|
|
179
183
|
*/
|
|
180
184
|
readonly selector?: ISelector;
|
|
181
185
|
}
|
|
182
|
-
|
|
183
186
|
interface IFileOut extends IFileIn {
|
|
184
187
|
/**
|
|
185
188
|
* Unique file ID.
|
|
@@ -207,7 +210,6 @@ interface IFileOut extends IFileIn {
|
|
|
207
210
|
imports: Array<number>;
|
|
208
211
|
};
|
|
209
212
|
}
|
|
210
|
-
|
|
211
213
|
interface IFileRegistry {
|
|
212
214
|
/**
|
|
213
215
|
* Get a file by its ID.
|
|
@@ -222,6 +224,13 @@ interface IFileRegistry {
|
|
|
222
224
|
* @returns File ID before being incremented
|
|
223
225
|
*/
|
|
224
226
|
readonly id: number;
|
|
227
|
+
/**
|
|
228
|
+
* Returns whether a file is registered in the registry.
|
|
229
|
+
*
|
|
230
|
+
* @param fileIdOrSelector File ID or selector to check.
|
|
231
|
+
* @returns True if the file is registered, false otherwise.
|
|
232
|
+
*/
|
|
233
|
+
isRegistered(fileIdOrSelector: number | ISelector): boolean;
|
|
225
234
|
/**
|
|
226
235
|
* Returns a file by ID or selector, registering it if it doesn't exist.
|
|
227
236
|
*
|
|
@@ -251,7 +260,8 @@ interface IFileRegistry {
|
|
|
251
260
|
*/
|
|
252
261
|
registered(): IterableIterator<IFileOut>;
|
|
253
262
|
}
|
|
254
|
-
|
|
263
|
+
//#endregion
|
|
264
|
+
//#region src/extensions/types.d.ts
|
|
255
265
|
/**
|
|
256
266
|
* Arbitrary metadata passed to the project's render function.
|
|
257
267
|
*
|
|
@@ -260,7 +270,6 @@ interface IFileRegistry {
|
|
|
260
270
|
interface IProjectRenderMeta {
|
|
261
271
|
[key: string]: unknown;
|
|
262
272
|
}
|
|
263
|
-
|
|
264
273
|
/**
|
|
265
274
|
* Additional metadata about the symbol.
|
|
266
275
|
*
|
|
@@ -269,7 +278,8 @@ interface IProjectRenderMeta {
|
|
|
269
278
|
interface ISymbolMeta {
|
|
270
279
|
[key: string]: unknown;
|
|
271
280
|
}
|
|
272
|
-
|
|
281
|
+
//#endregion
|
|
282
|
+
//#region src/symbols/types.d.ts
|
|
273
283
|
interface ISymbolIn {
|
|
274
284
|
/**
|
|
275
285
|
* Array of file names (without extensions) from which this symbol is re-exported.
|
|
@@ -336,7 +346,6 @@ interface ISymbolIn {
|
|
|
336
346
|
*/
|
|
337
347
|
readonly selector?: ISelector;
|
|
338
348
|
}
|
|
339
|
-
|
|
340
349
|
interface ISymbolOut extends ISymbolIn {
|
|
341
350
|
/**
|
|
342
351
|
* Array of file names (without extensions) from which this symbol is re-exported.
|
|
@@ -353,7 +362,6 @@ interface ISymbolOut extends ISymbolIn {
|
|
|
353
362
|
*/
|
|
354
363
|
readonly placeholder: string;
|
|
355
364
|
}
|
|
356
|
-
|
|
357
365
|
interface ISymbolRegistry {
|
|
358
366
|
/**
|
|
359
367
|
* Get a symbol by its ID.
|
|
@@ -382,6 +390,13 @@ interface ISymbolRegistry {
|
|
|
382
390
|
* @returns Symbol ID before being incremented.
|
|
383
391
|
*/
|
|
384
392
|
readonly id: number;
|
|
393
|
+
/**
|
|
394
|
+
* Returns whether a symbol is registered in the registry.
|
|
395
|
+
*
|
|
396
|
+
* @param symbolIdOrSelector Symbol ID or selector to check.
|
|
397
|
+
* @returns True if the symbol is registered, false otherwise.
|
|
398
|
+
*/
|
|
399
|
+
isRegistered(symbolIdOrSelector: number | ISelector): boolean;
|
|
385
400
|
/**
|
|
386
401
|
* Returns a symbol by ID or selector, registering it if it doesn't exist.
|
|
387
402
|
*
|
|
@@ -413,15 +428,22 @@ interface ISymbolRegistry {
|
|
|
413
428
|
*/
|
|
414
429
|
setValue(symbolId: number, value: unknown): Map<number, unknown>;
|
|
415
430
|
}
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
431
|
+
//#endregion
|
|
432
|
+
//#region src/bindings/utils.d.ts
|
|
433
|
+
declare const createBinding: ({
|
|
434
|
+
file,
|
|
435
|
+
modulePath,
|
|
436
|
+
symbol,
|
|
437
|
+
symbolFile
|
|
438
|
+
}: {
|
|
439
|
+
file: IFileOut;
|
|
440
|
+
modulePath: string;
|
|
441
|
+
symbol: ISymbolOut;
|
|
442
|
+
symbolFile: IFileOut;
|
|
422
443
|
}) => IBinding;
|
|
423
444
|
declare const mergeBindings: (target: IBinding, source: IBinding) => void;
|
|
424
|
-
|
|
445
|
+
//#endregion
|
|
446
|
+
//#region src/output/types.d.ts
|
|
425
447
|
interface IOutput {
|
|
426
448
|
/**
|
|
427
449
|
* The main content of the file to output.
|
|
@@ -438,22 +460,25 @@ interface IOutput {
|
|
|
438
460
|
*/
|
|
439
461
|
path: string;
|
|
440
462
|
}
|
|
441
|
-
|
|
463
|
+
//#endregion
|
|
464
|
+
//#region src/files/registry.d.ts
|
|
442
465
|
declare class FileRegistry implements IFileRegistry {
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
466
|
+
private _id;
|
|
467
|
+
private referenceOrder;
|
|
468
|
+
private registerOrder;
|
|
469
|
+
private selectorToId;
|
|
470
|
+
private values;
|
|
471
|
+
get(fileIdOrSelector: number | ISelector): IFileOut | undefined;
|
|
472
|
+
get id(): number;
|
|
473
|
+
private idOrSelector;
|
|
474
|
+
isRegistered(fileIdOrSelector: number | ISelector): boolean;
|
|
475
|
+
reference(fileIdOrSelector: number | ISelector): IFileOut;
|
|
476
|
+
referenced(): IterableIterator<IFileOut>;
|
|
477
|
+
register(file: IFileIn): IFileOut;
|
|
478
|
+
registered(): IterableIterator<IFileOut>;
|
|
455
479
|
}
|
|
456
|
-
|
|
480
|
+
//#endregion
|
|
481
|
+
//#region src/project/types.d.ts
|
|
457
482
|
/**
|
|
458
483
|
* Represents a code generation project consisting of multiple codegen files.
|
|
459
484
|
* Manages imports, symbols, and output generation across the project.
|
|
@@ -517,7 +542,8 @@ interface IProject {
|
|
|
517
542
|
*/
|
|
518
543
|
readonly symbols: ISymbolRegistry;
|
|
519
544
|
}
|
|
520
|
-
|
|
545
|
+
//#endregion
|
|
546
|
+
//#region src/renderer/types.d.ts
|
|
521
547
|
interface IRenderer {
|
|
522
548
|
/**
|
|
523
549
|
* Renders content with replaced symbols.
|
|
@@ -527,12 +553,7 @@ interface IRenderer {
|
|
|
527
553
|
* @param project The parent project the file belongs to.
|
|
528
554
|
* @returns Rendered content.
|
|
529
555
|
*/
|
|
530
|
-
renderFile(
|
|
531
|
-
content: string,
|
|
532
|
-
file: IFile,
|
|
533
|
-
project: IProject,
|
|
534
|
-
meta?: IProjectRenderMeta,
|
|
535
|
-
): string;
|
|
556
|
+
renderFile(content: string, file: IFile, project: IProject, meta?: IProjectRenderMeta): string;
|
|
536
557
|
/**
|
|
537
558
|
* Returns printable data containing symbols and exports.
|
|
538
559
|
*
|
|
@@ -541,46 +562,51 @@ interface IRenderer {
|
|
|
541
562
|
* @param meta Arbitrary metadata.
|
|
542
563
|
* @returns Printable string containing symbols and exports.
|
|
543
564
|
*/
|
|
544
|
-
renderSymbols(
|
|
545
|
-
file: IFileOut,
|
|
546
|
-
project: IProject,
|
|
547
|
-
meta?: IProjectRenderMeta,
|
|
548
|
-
): string;
|
|
565
|
+
renderSymbols(file: IFileOut, project: IProject, meta?: IProjectRenderMeta): string;
|
|
549
566
|
}
|
|
550
|
-
|
|
567
|
+
//#endregion
|
|
568
|
+
//#region src/symbols/registry.d.ts
|
|
551
569
|
declare class SymbolRegistry implements ISymbolRegistry {
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
570
|
+
private _id;
|
|
571
|
+
private nodes;
|
|
572
|
+
private registerOrder;
|
|
573
|
+
private selectorToId;
|
|
574
|
+
private values;
|
|
575
|
+
get(symbolIdOrSelector: number | ISelector): ISymbolOut | undefined;
|
|
576
|
+
getValue(symbolId: number): unknown;
|
|
577
|
+
hasValue(symbolId: number): boolean;
|
|
578
|
+
get id(): number;
|
|
579
|
+
private idOrSelector;
|
|
580
|
+
isRegistered(symbolIdOrSelector: number | ISelector): boolean;
|
|
581
|
+
reference(symbolIdOrSelector: number | ISelector): ISymbolOut;
|
|
582
|
+
register(symbol: ISymbolIn): ISymbolOut;
|
|
583
|
+
registered(): IterableIterator<ISymbolOut>;
|
|
584
|
+
setValue(symbolId: number, value: unknown): Map<number, unknown>;
|
|
566
585
|
}
|
|
567
|
-
|
|
586
|
+
//#endregion
|
|
587
|
+
//#region src/project/project.d.ts
|
|
568
588
|
declare class Project implements IProject {
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
589
|
+
private symbolIdToFileIds;
|
|
590
|
+
readonly defaultFileName: string;
|
|
591
|
+
readonly files: FileRegistry;
|
|
592
|
+
readonly fileName?: (name: string) => string;
|
|
593
|
+
readonly renderers: Record<string, IRenderer>;
|
|
594
|
+
readonly root: string;
|
|
595
|
+
readonly symbols: SymbolRegistry;
|
|
596
|
+
constructor({
|
|
597
|
+
defaultFileName,
|
|
598
|
+
fileName,
|
|
599
|
+
renderers,
|
|
600
|
+
root
|
|
601
|
+
}: Pick<IProject, 'defaultFileName' | 'fileName' | 'renderers' | 'root'>);
|
|
602
|
+
private getRenderer;
|
|
603
|
+
private prepareFiles;
|
|
604
|
+
render(meta?: IProjectRenderMeta): ReadonlyArray<IOutput>;
|
|
605
|
+
symbolIdToFiles(symbolId: number): ReadonlyArray<IFileOut>;
|
|
606
|
+
private symbolToFileSelector;
|
|
582
607
|
}
|
|
583
|
-
|
|
608
|
+
//#endregion
|
|
609
|
+
//#region src/renderer/utils.d.ts
|
|
584
610
|
/**
|
|
585
611
|
*
|
|
586
612
|
* @param source The source string to replace.
|
|
@@ -588,5 +614,6 @@ declare class Project implements IProject {
|
|
|
588
614
|
* @returns The replaced source string.
|
|
589
615
|
*/
|
|
590
616
|
declare const renderIds: (source: string, replacerFn: (symbolId: number) => string | undefined) => string;
|
|
591
|
-
|
|
617
|
+
//#endregion
|
|
592
618
|
export { type IBiMap as BiMap, type IBinding as Binding, type IFileOut as File, type IFileIn as FileIn, type IProject, type IOutput as Output, Project, type IProjectRenderMeta as ProjectRenderMeta, type IRenderer as Renderer, type ISelector as Selector, type ISymbolOut as Symbol, type ISymbolIn as SymbolIn, type ISymbolMeta as SymbolMeta, createBinding, mergeBindings, renderIds };
|
|
619
|
+
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.js
CHANGED
|
@@ -1,3 +1,2 @@
|
|
|
1
|
-
import {
|
|
2
|
-
var I=({file:l,modulePath:e,symbol:t,symbolFile:r})=>{let i=[],s=[],n={aliases:{},from:e};if(t.meta?.importKind&&(t.meta.importKind==="default"?(n.defaultBinding=t.placeholder,t.meta.kind==="type"&&(n.typeDefaultBinding=true)):t.meta.importKind==="namespace"&&(n.namespaceBinding=t.placeholder,t.meta.kind==="type"&&(n.typeNamespaceBinding=true))),t.meta?.importKind==="named"||!i.length&&!n.defaultBinding&&!n.namespaceBinding){let o=t.placeholder,d=l.resolvedNames.get(t.id);if(d){let m=r.resolvedNames.get(t.id);m?m!==d&&(o=m,n.aliases[o]=d):t.name&&d!==t.name&&(o=t.name,n.aliases[o]=t.placeholder);}i.push(o),t.meta?.kind==="type"&&s.push(o);}for(let o of s)i.includes(o)||i.push(o);return n.names=i,n.typeNames=s,n},g=(l,e)=>{l.aliases={...l.aliases,...e.aliases},e.defaultBinding!==void 0&&(l.defaultBinding=e.defaultBinding),l.names=[...new Set([...l.names??[],...e.names??[]])],e.namespaceBinding!==void 0&&(l.namespaceBinding=e.namespaceBinding),e.typeDefaultBinding!==void 0&&(l.typeDefaultBinding=e.typeDefaultBinding),l.typeNames=[...new Set([...l.typeNames??[],...e.typeNames??[]])],e.typeNamespaceBinding!==void 0&&(l.typeNamespaceBinding=e.typeNamespaceBinding);};var a=class{map=new Map;reverse=new Map;delete(e){let t=this.map.get(e);return t!==void 0&&this.reverse.delete(t),this.map.delete(e)}deleteValue(e){let t=this.reverse.get(e);return t!==void 0&&this.map.delete(t),this.reverse.delete(e)}entries(){return this.map.entries()}get(e){return this.map.get(e)}getKey(e){return this.reverse.get(e)}hasKey(e){return this.map.has(e)}hasValue(e){return this.reverse.has(e)}keys(){return this.map.keys()}set(e,t){let r=this.map.get(e);r!==void 0&&r!==t&&this.reverse.delete(r);let i=this.reverse.get(t);return i!==void 0&&i!==e&&this.map.delete(i),this.map.set(e,t),this.reverse.set(t,e),this}get size(){return this.map.size}values(){return this.map.values()}[Symbol.iterator](){return this.map[Symbol.iterator]()}};var p=class{_id=0;referenceOrder=new Set;registerOrder=new Set;selectorToId=new Map;values=new Map;get(e){let t=this.idOrSelector(e);if(t.id!==void 0)return this.values.get(t.id);let r=t.selector!==void 0?JSON.stringify(t.selector):void 0;if(r){let i=this.selectorToId.get(r);if(i!==void 0)return this.values.get(i)}}get id(){return this._id++}idOrSelector(e){return typeof e=="number"?{id:e}:{selector:e}}reference(e){let t=this.idOrSelector(e);return this.register(t)}*referenced(){for(let e of this.referenceOrder.values())yield this.values.get(e);}register(e){if(e.id!==void 0){let n=this.values.get(e.id);if(!n)throw new Error(`File with ID ${e.id} not found. To register a new file, leave the ID undefined.`);return n}let t=Object.keys(e).some(n=>!["id","selector"].includes(n)),r,i=e.selector!==void 0?JSON.stringify(e.selector):void 0;if(i){let n=this.selectorToId.get(i);if(n!==void 0){if(r=this.values.get(n),!r)throw new Error(`File with ID ${n} not found. The selector ${i} matched an ID, but there was no result. This is likely an issue with the application logic.`);if(!t)return r}}let s=r?.id!==void 0?r.id:this.id;return r={...r,...e,id:s,resolvedNames:r?.resolvedNames??new a,symbols:r?.symbols??{body:[],exports:[],imports:[]}},this.values.set(s,r),t?this.registerOrder.add(s):this.referenceOrder.add(s),i&&this.selectorToId.set(i,s),r}*registered(){for(let e of this.registerOrder.values())yield this.values.get(e);}};var f=l=>`_heyapi_${l}_`,b=l=>l.slice(8,-1),S=()=>new RegExp(f("\\d+"),"g"),v=(l,e)=>l.replace(S(),t=>{let r=Number.parseInt(b(t),10);return e(r)||t});var u=class{_id=0;nodes=new Map;registerOrder=new Set;selectorToId=new Map;values=new Map;get(e){let t=this.idOrSelector(e);if(t.id!==void 0)return this.values.get(t.id);let r=t.selector!==void 0?JSON.stringify(t.selector):void 0;if(r){let i=this.selectorToId.get(r);if(i!==void 0)return this.values.get(i)}}getValue(e){return this.nodes.get(e)}hasValue(e){return this.nodes.has(e)}get id(){return this._id++}idOrSelector(e){return typeof e=="number"?{id:e}:{selector:e}}reference(e){let t=this.idOrSelector(e);return this.register(t)}register(e){if(e.id!==void 0){let o=this.values.get(e.id);if(!o)throw new Error(`Symbol with ID ${e.id} not found. To register a new symbol, leave the ID undefined.`);return o}let t=Object.keys(e).some(o=>!["id","selector"].includes(o)),r,i=e.selector!==void 0?JSON.stringify(e.selector):void 0;if(i){let o=this.selectorToId.get(i);if(o!==void 0){if(r=this.values.get(o),!r)throw new Error(`Symbol with ID ${o} not found. The selector ${i} matched an ID, but there was no result. This is likely an issue with the application logic.`);if(!t)return r}}let s=r?.id!==void 0?r.id:this.id,n=r?.exportFrom?[...r.exportFrom]:[];return e.exportFrom&&n.push(...e.exportFrom),r={...r,...e,exportFrom:n,id:s,placeholder:r?.placeholder??e.placeholder??f(String(s))},this.values.set(s,r),t&&this.registerOrder.add(s),i&&this.selectorToId.set(i,s),r}*registered(){for(let e of this.registerOrder.values())yield this.values.get(e);}setValue(e,t){return this.nodes.set(e,t)}};var y="@",c=class{symbolIdToFileIds=new Map;defaultFileName;files=new p;fileName;renderers={};root;symbols=new u;constructor({defaultFileName:e,fileName:t,renderers:r,root:i}){this.defaultFileName=e??"main",this.fileName=typeof t=="string"?()=>t:t,this.renderers=r,this.root=i;}getRenderer(e){return e.extension?this.renderers[e.extension]:void 0}prepareFiles(){for(let t of this.symbols.registered()){let r=this.symbolToFileSelector(t),i=this.files.reference(r);i.symbols.body.push(t.id);let s=this.symbolIdToFileIds.get(t.id)??new Set;s.add(i.id),this.symbolIdToFileIds.set(t.id,s);for(let n of t.exportFrom){let o=[n],d=this.files.reference(o);d.id!==i.id&&d.symbols.exports.push(t.id);}}for(let t of this.files.referenced()){if(!t.selector)continue;if(t.selector[0]===y){let s=t.selector[1];if(!s){this.files.register({external:true,selector:t.selector});continue}let n=h.extname(s);if(!n){this.files.register({external:true,path:s,selector:t.selector});continue}this.files.register({extension:n,external:true,path:s,selector:t.selector});continue}let r=t.selector.slice(0,-1),i=t.selector[t.selector.length-1];i=this.fileName?.(i)||i,this.files.register({extension:".ts",name:i,path:h.resolve(this.root,...r,`${i}.ts`),selector:t.selector});}}render(e){this.prepareFiles();let t=new Map;for(let r of this.files.registered()){if(r.external||!r.path)continue;let i=this.getRenderer(r);i&&t.set(r.id,{content:i.renderSymbols(r,this,e),path:r.path});}for(let[r,i]of t.entries()){let s=this.files.get(r),o=this.getRenderer(s).renderFile(i.content,s,this,e);o?t.set(s.id,{...i,content:o}):t.delete(s.id);}return Array.from(t.values())}symbolIdToFiles(e){let t=this.symbolIdToFileIds.get(e);return Array.from(t??[]).map(r=>this.files.get(r))}symbolToFileSelector(e){if(e.external)return [y,e.external];let t=e.getFilePath?.(e);return t?t.split("/"):[this.defaultFileName]}};export{c as Project,I as createBinding,g as mergeBindings,v as renderIds};//# sourceMappingURL=index.js.map
|
|
1
|
+
import e from"node:path";const t=({file:e,modulePath:t,symbol:n,symbolFile:r})=>{let i=[],a=[],o={aliases:{},from:t};if(n.meta?.importKind&&(n.meta.importKind===`default`?(o.defaultBinding=n.placeholder,n.meta.kind===`type`&&(o.typeDefaultBinding=!0)):n.meta.importKind===`namespace`&&(o.namespaceBinding=n.placeholder,n.meta.kind===`type`&&(o.typeNamespaceBinding=!0))),n.meta?.importKind===`named`||!i.length&&!o.defaultBinding&&!o.namespaceBinding){let t=n.placeholder,s=e.resolvedNames.get(n.id);if(s){let e=r.resolvedNames.get(n.id);e?e!==s&&(t=e,o.aliases[t]=s):n.name&&s!==n.name&&(t=n.name,o.aliases[t]=n.placeholder)}i.push(t),n.meta?.kind===`type`&&a.push(t)}for(let e of a)i.includes(e)||i.push(e);return o.names=i,o.typeNames=a,o},n=(e,t)=>{e.aliases={...e.aliases,...t.aliases},t.defaultBinding!==void 0&&(e.defaultBinding=t.defaultBinding),e.names=[...new Set([...e.names??[],...t.names??[]])],t.namespaceBinding!==void 0&&(e.namespaceBinding=t.namespaceBinding),t.typeDefaultBinding!==void 0&&(e.typeDefaultBinding=t.typeDefaultBinding),e.typeNames=[...new Set([...e.typeNames??[],...t.typeNames??[]])],t.typeNamespaceBinding!==void 0&&(e.typeNamespaceBinding=t.typeNamespaceBinding)};var r=class{map=new Map;reverse=new Map;delete(e){let t=this.map.get(e);return t!==void 0&&this.reverse.delete(t),this.map.delete(e)}deleteValue(e){let t=this.reverse.get(e);return t!==void 0&&this.map.delete(t),this.reverse.delete(e)}entries(){return this.map.entries()}get(e){return this.map.get(e)}getKey(e){return this.reverse.get(e)}hasKey(e){return this.map.has(e)}hasValue(e){return this.reverse.has(e)}keys(){return this.map.keys()}set(e,t){let n=this.map.get(e);n!==void 0&&n!==t&&this.reverse.delete(n);let r=this.reverse.get(t);return r!==void 0&&r!==e&&this.map.delete(r),this.map.set(e,t),this.reverse.set(t,e),this}get size(){return this.map.size}values(){return this.map.values()}[Symbol.iterator](){return this.map[Symbol.iterator]()}},i=class{_id=0;referenceOrder=new Set;registerOrder=new Set;selectorToId=new Map;values=new Map;get(e){let t=this.idOrSelector(e);if(t.id!==void 0)return this.values.get(t.id);let n=t.selector===void 0?void 0:JSON.stringify(t.selector);if(n){let e=this.selectorToId.get(n);if(e!==void 0)return this.values.get(e)}}get id(){return this._id++}idOrSelector(e){return typeof e==`number`?{id:e}:{selector:e}}isRegistered(e){let t=this.get(e);return t?this.registerOrder.has(t.id):!1}reference(e){let t=this.idOrSelector(e);return this.register(t)}*referenced(){for(let e of this.referenceOrder.values())yield this.values.get(e)}register(e){if(e.id!==void 0){let t=this.values.get(e.id);if(!t)throw Error(`File with ID ${e.id} not found. To register a new file, leave the ID undefined.`);return t}let t=Object.keys(e).some(e=>![`id`,`selector`].includes(e)),n,i=e.selector===void 0?void 0:JSON.stringify(e.selector);if(i){let e=this.selectorToId.get(i);if(e!==void 0){if(n=this.values.get(e),!n)throw Error(`File with ID ${e} not found. The selector ${i} matched an ID, but there was no result. This is likely an issue with the application logic.`);if(!t)return n}}let a=n?.id===void 0?this.id:n.id;return n={...n,...e,id:a,resolvedNames:n?.resolvedNames??new r,symbols:n?.symbols??{body:[],exports:[],imports:[]}},this.values.set(a,n),t?(this.registerOrder.add(a),this.referenceOrder.has(a)&&this.referenceOrder.delete(a)):this.referenceOrder.add(a),i&&this.selectorToId.set(i,a),n}*registered(){for(let e of this.registerOrder.values())yield this.values.get(e)}};const a=e=>`_heyapi_${e}_`,o=e=>e.slice(8,-1),s=()=>new RegExp(a(`\\d+`),`g`),c=(e,t)=>e.replace(s(),e=>t(Number.parseInt(o(e),10))||e);var l=class{_id=0;nodes=new Map;registerOrder=new Set;selectorToId=new Map;values=new Map;get(e){let t=this.idOrSelector(e);if(t.id!==void 0)return this.values.get(t.id);let n=t.selector===void 0?void 0:JSON.stringify(t.selector);if(n){let e=this.selectorToId.get(n);if(e!==void 0)return this.values.get(e)}}getValue(e){return this.nodes.get(e)}hasValue(e){return this.nodes.has(e)}get id(){return this._id++}idOrSelector(e){return typeof e==`number`?{id:e}:{selector:e}}isRegistered(e){let t=this.get(e);return t?this.registerOrder.has(t.id):!1}reference(e){let t=this.idOrSelector(e);return this.register(t)}register(e){if(e.id!==void 0){let t=this.values.get(e.id);if(!t)throw Error(`Symbol with ID ${e.id} not found. To register a new symbol, leave the ID undefined.`);return t}let t=Object.keys(e).some(e=>![`id`,`selector`].includes(e)),n,r=e.selector===void 0?void 0:JSON.stringify(e.selector);if(r){let e=this.selectorToId.get(r);if(e!==void 0){if(n=this.values.get(e),!n)throw Error(`Symbol with ID ${e} not found. The selector ${r} matched an ID, but there was no result. This is likely an issue with the application logic.`);if(!t)return n}}let i=n?.id===void 0?this.id:n.id,o=n?.exportFrom?[...n.exportFrom]:[];return e.exportFrom&&o.push(...e.exportFrom),n={...n,...e,exportFrom:o,id:i,placeholder:n?.placeholder??e.placeholder??a(String(i))},this.values.set(i,n),t&&this.registerOrder.add(i),r&&this.selectorToId.set(r,i),n}*registered(){for(let e of this.registerOrder.values())yield this.values.get(e)}setValue(e,t){return this.nodes.set(e,t)}},u=class{symbolIdToFileIds=new Map;defaultFileName;files=new i;fileName;renderers={};root;symbols=new l;constructor({defaultFileName:e,fileName:t,renderers:n,root:r}){this.defaultFileName=e??`main`,this.fileName=typeof t==`string`?()=>t:t,this.renderers=n,this.root=r}getRenderer(e){return e.extension?this.renderers[e.extension]:void 0}prepareFiles(){for(let e of this.symbols.registered()){let t=this.symbolToFileSelector(e),n=this.files.reference(t);n.symbols.body.push(e.id);let r=this.symbolIdToFileIds.get(e.id)??new Set;r.add(n.id),this.symbolIdToFileIds.set(e.id,r);for(let t of e.exportFrom){let r=[t],i=this.files.reference(r);i.id!==n.id&&i.symbols.exports.push(e.id)}}for(let t of this.files.referenced()){if(!t.selector)continue;if(t.selector[0]===`@`){let n=t.selector[1];if(!n){this.files.register({external:!0,selector:t.selector});continue}let r=e.extname(n);if(!r){this.files.register({external:!0,path:n,selector:t.selector});continue}this.files.register({extension:r,external:!0,path:n,selector:t.selector});continue}let n=t.selector.slice(0,-1),r=t.selector[t.selector.length-1];r=this.fileName?.(r)||r,this.files.register({extension:`.ts`,name:r,path:e.resolve(this.root,...n,`${r}.ts`),selector:t.selector})}}render(e){this.prepareFiles();let t=new Map;for(let n of this.files.registered()){if(n.external||!n.path)continue;let r=this.getRenderer(n);r&&t.set(n.id,{content:r.renderSymbols(n,this,e),path:n.path})}for(let[n,r]of t.entries()){let i=this.files.get(n),a=this.getRenderer(i).renderFile(r.content,i,this,e);a?t.set(i.id,{...r,content:a}):t.delete(i.id)}return Array.from(t.values())}symbolIdToFiles(e){let t=this.symbolIdToFileIds.get(e);return Array.from(t??[]).map(e=>this.files.get(e))}symbolToFileSelector(e){if(e.external)return[`@`,e.external];let t=e.getFilePath?.(e);return t?t.split(`/`):[this.defaultFileName]}};export{u as Project,t as createBinding,n as mergeBindings,c as renderIds};
|
|
3
2
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/bindings/utils.ts","../src/bimap/bimap.ts","../src/files/registry.ts","../src/renderer/utils.ts","../src/symbols/registry.ts","../src/project/project.ts"],"names":["createBinding","file","modulePath","symbol","symbolFile","names","typeNames","binding","name","fileResolvedName","symbolFileResolvedName","typeName","mergeBindings","target","source","BiMap","key","value","oldValue","oldKey","FileRegistry","fileIdOrSelector","selector","id","symbolIdOrSelector","result","hasOtherKeys","wrapId","symbolId","unwrapId","wrappedId","createPlaceholderRegExp","renderIds","replacerFn","match","SymbolRegistry","exportFrom","externalSourceSymbol","Project","defaultFileName","fileName","renderers","root","symbolIdToFileIds","exportSelector","exportFile","filePath","extension","path","dirs","meta","files","renderer","fileId","content","fileIds"],"mappings":";AAIO,IAAMA,CAAAA,CAAgB,CAAC,CAC5B,IAAA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gB,EAAM,OAAA,CAAShB,CAAAA,CAAM,KAAMiD,CAAI,CAAA,CAC/DI,EACFH,CAAAA,CAAM,GAAA,CAAIlD,EAAK,EAAA,CAAI,CAAE,GAAGgB,CAAAA,CAAO,OAAA,CAAAqC,CAAQ,CAAC,CAAA,CAExCH,EAAM,MAAA,CAAOlD,CAAAA,CAAK,EAAE,EAExB,CACA,OAAO,KAAA,CAAM,IAAA,CAAKkD,EAAM,MAAA,EAAQ,CAClC,CAEA,eAAA,CAAgBvB,EAA2C,CACzD,IAAM2B,EAAU,IAAA,CAAK,iBAAA,CAAkB,IAAI3B,CAAQ,CAAA,CACnD,OAAO,KAAA,CAAM,IAAA,CAAK2B,GAAW,EAAE,EAAE,GAAA,CAAKF,CAAAA,EAAW,KAAK,KAAA,CAAM,GAAA,CAAIA,CAAM,CAAE,CAC1E,CAEQ,oBAAA,CAAqBlD,CAAAA,CAA+B,CAC1D,GAAIA,CAAAA,CAAO,SACT,OAAO,CAACkC,EAAsBlC,CAAAA,CAAO,QAAQ,EAE/C,IAAM2C,CAAAA,CAAW3C,EAAO,WAAA,GAAcA,CAAM,EAC5C,OAAI2C,CAAAA,CACKA,EAAS,KAAA,CAAM,GAAG,EAEpB,CAAC,IAAA,CAAK,eAAe,CAC9B,CACF","file":"index.js","sourcesContent":["import type { IFileOut } from '../files/types';\nimport type { ISymbolOut } from '../symbols/types';\nimport type { IBinding } from './types';\n\nexport const createBinding = ({\n file,\n modulePath,\n symbol,\n symbolFile,\n}: {\n file: IFileOut;\n modulePath: string;\n symbol: ISymbolOut;\n symbolFile: IFileOut;\n}): IBinding => {\n const names: Array<string> = [];\n const typeNames: Array<string> = [];\n const binding: IBinding & Pick<Required<IBinding>, 'aliases' | 'from'> = {\n aliases: {},\n from: modulePath,\n };\n if (symbol.meta?.importKind) {\n if (symbol.meta.importKind === 'default') {\n binding.defaultBinding = symbol.placeholder;\n if (symbol.meta.kind === 'type') {\n binding.typeDefaultBinding = true;\n }\n } else if (symbol.meta.importKind === 'namespace') {\n binding.namespaceBinding = symbol.placeholder;\n if (symbol.meta.kind === 'type') {\n binding.typeNamespaceBinding = true;\n }\n }\n }\n // default to named binding\n if (\n symbol.meta?.importKind === 'named' ||\n (!names.length && !binding.defaultBinding && !binding.namespaceBinding)\n ) {\n let name = symbol.placeholder;\n const fileResolvedName = file.resolvedNames.get(symbol.id);\n if (fileResolvedName) {\n const symbolFileResolvedName = symbolFile.resolvedNames.get(symbol.id);\n if (symbolFileResolvedName) {\n if (symbolFileResolvedName !== fileResolvedName) {\n name = symbolFileResolvedName;\n binding.aliases[name] = fileResolvedName;\n }\n } else if (symbol.name && fileResolvedName !== symbol.name) {\n name = symbol.name;\n binding.aliases[name] = symbol.placeholder;\n }\n }\n names.push(name);\n if (symbol.meta?.kind === 'type') {\n typeNames.push(name);\n }\n }\n // cast type names to names to allow for cleaner API,\n // otherwise users would have to define the same values twice\n for (const typeName of typeNames) {\n if (!names.includes(typeName)) {\n names.push(typeName);\n }\n }\n binding.names = names;\n binding.typeNames = typeNames;\n return binding;\n};\n\nexport const mergeBindings = (target: IBinding, source: IBinding): void => {\n target.aliases = { ...target.aliases, ...source.aliases };\n if (source.defaultBinding !== undefined) {\n target.defaultBinding = source.defaultBinding;\n }\n target.names = [\n ...new Set([...(target.names ?? []), ...(source.names ?? [])]),\n ];\n if (source.namespaceBinding !== undefined) {\n target.namespaceBinding = source.namespaceBinding;\n }\n if (source.typeDefaultBinding !== undefined) {\n target.typeDefaultBinding = source.typeDefaultBinding;\n }\n target.typeNames = [\n ...new Set([...(target.typeNames ?? []), ...(source.typeNames ?? [])]),\n ];\n if (source.typeNamespaceBinding !== undefined) {\n target.typeNamespaceBinding = source.typeNamespaceBinding;\n }\n};\n","import type { IBiMap } from './types';\n\nexport class BiMap<Key, Value> implements IBiMap<Key, Value> {\n private map = new Map<Key, Value>();\n private reverse = new Map<Value, Key>();\n\n delete(key: Key): boolean {\n const value = this.map.get(key);\n if (value !== undefined) {\n this.reverse.delete(value);\n }\n return this.map.delete(key);\n }\n\n deleteValue(value: Value): boolean {\n const key = this.reverse.get(value);\n if (key !== undefined) {\n this.map.delete(key);\n }\n return this.reverse.delete(value);\n }\n\n entries(): IterableIterator<[Key, Value]> {\n return this.map.entries();\n }\n\n get(key: Key): Value | undefined {\n return this.map.get(key);\n }\n\n getKey(value: Value): Key | undefined {\n return this.reverse.get(value);\n }\n\n hasKey(key: Key): boolean {\n return this.map.has(key);\n }\n\n hasValue(value: Value): boolean {\n return this.reverse.has(value);\n }\n\n keys(): IterableIterator<Key> {\n return this.map.keys();\n }\n\n set(key: Key, value: Value): this {\n const oldValue = this.map.get(key);\n if (oldValue !== undefined && oldValue !== value) {\n this.reverse.delete(oldValue);\n }\n const oldKey = this.reverse.get(value);\n if (oldKey !== undefined && oldKey !== key) {\n this.map.delete(oldKey);\n }\n this.map.set(key, value);\n this.reverse.set(value, key);\n return this;\n }\n\n get size(): number {\n return this.map.size;\n }\n\n values(): IterableIterator<Value> {\n return this.map.values();\n }\n\n [Symbol.iterator](): IterableIterator<[Key, Value]> {\n return this.map[Symbol.iterator]();\n }\n}\n","import { BiMap } from '../bimap/bimap';\nimport type { ISelector } from '../selectors/types';\nimport type { IFileIn, IFileOut, IFileRegistry } from './types';\n\nexport class FileRegistry implements IFileRegistry {\n private _id: number = 0;\n private referenceOrder: Set<number> = new Set();\n private registerOrder: Set<number> = new Set();\n private selectorToId: Map<string, number> = new Map();\n private values: Map<number, IFileOut> = new Map();\n\n get(fileIdOrSelector: number | ISelector): IFileOut | undefined {\n const symbol = this.idOrSelector(fileIdOrSelector);\n\n if (symbol.id !== undefined) {\n return this.values.get(symbol.id);\n }\n\n const selector =\n symbol.selector !== undefined\n ? JSON.stringify(symbol.selector)\n : undefined;\n\n if (selector) {\n const id = this.selectorToId.get(selector);\n if (id !== undefined) {\n return this.values.get(id);\n }\n }\n\n return;\n }\n\n get id(): number {\n return this._id++;\n }\n\n private idOrSelector(\n symbolIdOrSelector: number | ISelector,\n ): Pick<IFileIn, 'id' | 'selector'> {\n return typeof symbolIdOrSelector === 'number'\n ? { id: symbolIdOrSelector }\n : { selector: symbolIdOrSelector };\n }\n\n reference(fileIdOrSelector: number | ISelector): IFileOut {\n const file = this.idOrSelector(fileIdOrSelector);\n return this.register(file);\n }\n\n *referenced(): IterableIterator<IFileOut> {\n for (const id of this.referenceOrder.values()) {\n yield this.values.get(id)!;\n }\n }\n\n register(file: IFileIn): IFileOut {\n if (file.id !== undefined) {\n const result = this.values.get(file.id);\n if (!result) {\n throw new Error(\n `File with ID ${file.id} not found. To register a new file, leave the ID undefined.`,\n );\n }\n return result;\n }\n\n const hasOtherKeys = Object.keys(file).some(\n (key) => !['id', 'selector'].includes(key),\n );\n\n let result: IFileOut | undefined;\n\n const selector =\n file.selector !== undefined ? JSON.stringify(file.selector) : undefined;\n if (selector) {\n const id = this.selectorToId.get(selector);\n if (id !== undefined) {\n result = this.values.get(id);\n if (!result) {\n throw new Error(\n `File with ID ${id} not found. The selector ${selector} matched an ID, but there was no result. This is likely an issue with the application logic.`,\n );\n }\n if (!hasOtherKeys) {\n return result;\n }\n }\n }\n\n const id = result?.id !== undefined ? result.id : this.id;\n result = {\n ...result,\n ...file, // clone to avoid mutation\n id,\n resolvedNames: result?.resolvedNames ?? new BiMap(),\n symbols: result?.symbols ?? {\n body: [],\n exports: [],\n imports: [],\n },\n };\n this.values.set(id, result);\n\n if (hasOtherKeys) {\n this.registerOrder.add(id);\n } else {\n this.referenceOrder.add(id);\n }\n\n if (selector) {\n this.selectorToId.set(selector, id);\n }\n\n return result;\n }\n\n *registered(): IterableIterator<IFileOut> {\n for (const id of this.registerOrder.values()) {\n yield this.values.get(id)!;\n }\n }\n}\n","/**\n * Wraps an ID in namespace to avoid collisions when replacing it.\n *\n * @param symbolId Stringified symbol ID to use.\n * @returns The wrapped placeholder ID.\n */\nexport const wrapId = (symbolId: string): string => `_heyapi_${symbolId}_`;\n\n/**\n * Unwraps an ID from namespace.\n *\n * @param wrappedId The wrapped placeholder ID.\n * @returns Stringified ID to use.\n */\nconst unwrapId = (wrappedId: string): string =>\n wrappedId.slice('_heyapi_'.length, -1);\n\n/**\n * Returns a RegExp instance to match ID placeholders.\n *\n * @returns RegExp instance to match ID placeholders.\n */\nconst createPlaceholderRegExp = (): RegExp => new RegExp(wrapId('\\\\d+'), 'g');\n\n/**\n *\n * @param source The source string to replace.\n * @param replacerFn Accepts a symbol ID, returns resolved symbol name.\n * @returns The replaced source string.\n */\nexport const renderIds = (\n source: string,\n replacerFn: (symbolId: number) => string | undefined,\n): string =>\n source.replace(createPlaceholderRegExp(), (match) => {\n const symbolId = Number.parseInt(unwrapId(match), 10);\n return replacerFn(symbolId) || match;\n });\n","import { wrapId } from '../renderer/utils';\nimport type { ISelector } from '../selectors/types';\nimport type { ISymbolIn, ISymbolOut, ISymbolRegistry } from './types';\n\nexport class SymbolRegistry implements ISymbolRegistry {\n private _id: number = 0;\n private nodes: Map<number, unknown> = new Map();\n private registerOrder: Set<number> = new Set();\n private selectorToId: Map<string, number> = new Map();\n private values: Map<number, ISymbolOut> = new Map();\n\n get(symbolIdOrSelector: number | ISelector): ISymbolOut | undefined {\n const symbol = this.idOrSelector(symbolIdOrSelector);\n\n if (symbol.id !== undefined) {\n return this.values.get(symbol.id);\n }\n\n const selector =\n symbol.selector !== undefined\n ? JSON.stringify(symbol.selector)\n : undefined;\n\n if (selector) {\n const id = this.selectorToId.get(selector);\n if (id !== undefined) {\n return this.values.get(id);\n }\n }\n\n return;\n }\n\n getValue(symbolId: number): unknown {\n return this.nodes.get(symbolId);\n }\n\n hasValue(symbolId: number): boolean {\n return this.nodes.has(symbolId);\n }\n\n get id(): number {\n return this._id++;\n }\n\n private idOrSelector(\n symbolIdOrSelector: number | ISelector,\n ): Pick<ISymbolIn, 'id' | 'selector'> {\n return typeof symbolIdOrSelector === 'number'\n ? { id: symbolIdOrSelector }\n : { selector: symbolIdOrSelector };\n }\n\n reference(symbolIdOrSelector: number | ISelector): ISymbolOut {\n const symbol = this.idOrSelector(symbolIdOrSelector);\n return this.register(symbol);\n }\n\n register(symbol: ISymbolIn): ISymbolOut {\n if (symbol.id !== undefined) {\n const result = this.values.get(symbol.id);\n if (!result) {\n throw new Error(\n `Symbol with ID ${symbol.id} not found. To register a new symbol, leave the ID undefined.`,\n );\n }\n return result;\n }\n\n const hasOtherKeys = Object.keys(symbol).some(\n (key) => !['id', 'selector'].includes(key),\n );\n\n let result: ISymbolOut | undefined;\n\n const selector =\n symbol.selector !== undefined\n ? JSON.stringify(symbol.selector)\n : undefined;\n if (selector) {\n const id = this.selectorToId.get(selector);\n if (id !== undefined) {\n result = this.values.get(id);\n if (!result) {\n throw new Error(\n `Symbol with ID ${id} not found. The selector ${selector} matched an ID, but there was no result. This is likely an issue with the application logic.`,\n );\n }\n if (!hasOtherKeys) {\n return result;\n }\n }\n }\n\n const id = result?.id !== undefined ? result.id : this.id;\n const exportFrom: Array<string> = result?.exportFrom\n ? [...result.exportFrom]\n : [];\n if (symbol.exportFrom) {\n exportFrom.push(...symbol.exportFrom);\n }\n result = {\n ...result,\n ...symbol, // clone to avoid mutation\n exportFrom,\n id,\n placeholder:\n result?.placeholder ?? symbol.placeholder ?? wrapId(String(id)),\n };\n this.values.set(id, result);\n\n if (hasOtherKeys) {\n this.registerOrder.add(id);\n }\n\n if (selector) {\n this.selectorToId.set(selector, id);\n }\n\n return result;\n }\n\n *registered(): IterableIterator<ISymbolOut> {\n for (const id of this.registerOrder.values()) {\n yield this.values.get(id)!;\n }\n }\n\n setValue(symbolId: number, value: unknown): Map<number, unknown> {\n return this.nodes.set(symbolId, value);\n }\n}\n","import path from 'node:path';\n\nimport type { IProjectRenderMeta } from '../extensions/types';\nimport { FileRegistry } from '../files/registry';\nimport type { IFileOut } from '../files/types';\nimport type { IOutput } from '../output/types';\nimport type { IRenderer } from '../renderer/types';\nimport type { ISelector } from '../selectors/types';\nimport { SymbolRegistry } from '../symbols/registry';\nimport type { ISymbolOut } from '../symbols/types';\nimport type { IProject } from './types';\n\nconst externalSourceSymbol = '@';\n\nexport class Project implements IProject {\n private symbolIdToFileIds: Map<number, Set<number>> = new Map();\n\n readonly defaultFileName: string;\n readonly files = new FileRegistry();\n readonly fileName?: (name: string) => string;\n readonly renderers: Record<string, IRenderer> = {};\n readonly root: string;\n readonly symbols = new SymbolRegistry();\n\n constructor({\n defaultFileName,\n fileName,\n renderers,\n root,\n }: Pick<IProject, 'defaultFileName' | 'fileName' | 'renderers' | 'root'>) {\n this.defaultFileName = defaultFileName ?? 'main';\n this.fileName = typeof fileName === 'string' ? () => fileName : fileName;\n this.renderers = renderers;\n this.root = root;\n }\n\n private getRenderer(file: IFileOut): IRenderer | undefined {\n return file.extension ? this.renderers[file.extension] : undefined;\n }\n\n private prepareFiles(): void {\n // TODO: infer extension from symbols\n const extension = '.ts';\n for (const symbol of this.symbols.registered()) {\n const selector = this.symbolToFileSelector(symbol);\n const file = this.files.reference(selector);\n file.symbols.body.push(symbol.id);\n // update symbol->files map\n const symbolIdToFileIds =\n this.symbolIdToFileIds.get(symbol.id) ?? new Set();\n symbolIdToFileIds.add(file.id);\n this.symbolIdToFileIds.set(symbol.id, symbolIdToFileIds);\n // update re-exports\n for (const exportFrom of symbol.exportFrom) {\n const exportSelector = [exportFrom];\n const exportFile = this.files.reference(exportSelector);\n if (exportFile.id !== file.id) {\n exportFile.symbols.exports.push(symbol.id);\n }\n }\n }\n for (const file of this.files.referenced()) {\n if (!file.selector) continue;\n if (file.selector[0] === externalSourceSymbol) {\n const filePath = file.selector[1];\n if (!filePath) {\n this.files.register({\n external: true,\n selector: file.selector,\n });\n continue;\n }\n const extension = path.extname(filePath);\n if (!extension) {\n this.files.register({\n external: true,\n path: filePath,\n selector: file.selector,\n });\n continue;\n }\n this.files.register({\n extension,\n external: true,\n path: filePath,\n selector: file.selector,\n });\n continue;\n }\n const dirs = file.selector.slice(0, -1);\n let name = file.selector[file.selector.length - 1]!;\n name = this.fileName?.(name) || name;\n this.files.register({\n extension,\n name,\n path: path.resolve(this.root, ...dirs, `${name}${extension}`),\n selector: file.selector,\n });\n }\n\n // TODO: track symbol dependencies and inject imports into files\n // based on symbol references so the render step can just render\n }\n\n render(meta?: IProjectRenderMeta): ReadonlyArray<IOutput> {\n this.prepareFiles();\n const files: Map<number, IOutput> = new Map();\n for (const file of this.files.registered()) {\n if (file.external || !file.path) continue;\n const renderer = this.getRenderer(file);\n if (!renderer) continue;\n files.set(file.id, {\n content: renderer.renderSymbols(file, this, meta),\n path: file.path,\n });\n }\n for (const [fileId, value] of files.entries()) {\n const file = this.files.get(fileId)!;\n const renderer = this.getRenderer(file)!;\n const content = renderer.renderFile(value.content, file, this, meta);\n if (content) {\n files.set(file.id, { ...value, content });\n } else {\n files.delete(file.id);\n }\n }\n return Array.from(files.values());\n }\n\n symbolIdToFiles(symbolId: number): ReadonlyArray<IFileOut> {\n const fileIds = this.symbolIdToFileIds.get(symbolId);\n return Array.from(fileIds ?? []).map((fileId) => this.files.get(fileId)!);\n }\n\n private symbolToFileSelector(symbol: ISymbolOut): ISelector {\n if (symbol.external) {\n return [externalSourceSymbol, symbol.external];\n }\n const filePath = symbol.getFilePath?.(symbol);\n if (filePath) {\n return filePath.split('/');\n }\n return [this.defaultFileName];\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"index.js","names":["names: Array<string>","typeNames: Array<string>","binding: IBinding & Pick<Required<IBinding>, 'aliases' | 'from'>","result","result: IFileOut | undefined","id","result","result: ISymbolOut | undefined","id","exportFrom: Array<string>","extension","files: Map<number, IOutput>"],"sources":["../src/bindings/utils.ts","../src/bimap/bimap.ts","../src/files/registry.ts","../src/renderer/utils.ts","../src/symbols/registry.ts","../src/project/project.ts"],"sourcesContent":["import type { IFileOut } from '../files/types';\nimport type { ISymbolOut } from '../symbols/types';\nimport type { IBinding } from './types';\n\nexport const createBinding = ({\n file,\n modulePath,\n symbol,\n symbolFile,\n}: {\n file: IFileOut;\n modulePath: string;\n symbol: ISymbolOut;\n symbolFile: IFileOut;\n}): IBinding => {\n const names: Array<string> = [];\n const typeNames: Array<string> = [];\n const binding: IBinding & Pick<Required<IBinding>, 'aliases' | 'from'> = {\n aliases: {},\n from: modulePath,\n };\n if (symbol.meta?.importKind) {\n if (symbol.meta.importKind === 'default') {\n binding.defaultBinding = symbol.placeholder;\n if (symbol.meta.kind === 'type') {\n binding.typeDefaultBinding = true;\n }\n } else if (symbol.meta.importKind === 'namespace') {\n binding.namespaceBinding = symbol.placeholder;\n if (symbol.meta.kind === 'type') {\n binding.typeNamespaceBinding = true;\n }\n }\n }\n // default to named binding\n if (\n symbol.meta?.importKind === 'named' ||\n (!names.length && !binding.defaultBinding && !binding.namespaceBinding)\n ) {\n let name = symbol.placeholder;\n const fileResolvedName = file.resolvedNames.get(symbol.id);\n if (fileResolvedName) {\n const symbolFileResolvedName = symbolFile.resolvedNames.get(symbol.id);\n if (symbolFileResolvedName) {\n if (symbolFileResolvedName !== fileResolvedName) {\n name = symbolFileResolvedName;\n binding.aliases[name] = fileResolvedName;\n }\n } else if (symbol.name && fileResolvedName !== symbol.name) {\n name = symbol.name;\n binding.aliases[name] = symbol.placeholder;\n }\n }\n names.push(name);\n if (symbol.meta?.kind === 'type') {\n typeNames.push(name);\n }\n }\n // cast type names to names to allow for cleaner API,\n // otherwise users would have to define the same values twice\n for (const typeName of typeNames) {\n if (!names.includes(typeName)) {\n names.push(typeName);\n }\n }\n binding.names = names;\n binding.typeNames = typeNames;\n return binding;\n};\n\nexport const mergeBindings = (target: IBinding, source: IBinding): void => {\n target.aliases = { ...target.aliases, ...source.aliases };\n if (source.defaultBinding !== undefined) {\n target.defaultBinding = source.defaultBinding;\n }\n target.names = [\n ...new Set([...(target.names ?? []), ...(source.names ?? [])]),\n ];\n if (source.namespaceBinding !== undefined) {\n target.namespaceBinding = source.namespaceBinding;\n }\n if (source.typeDefaultBinding !== undefined) {\n target.typeDefaultBinding = source.typeDefaultBinding;\n }\n target.typeNames = [\n ...new Set([...(target.typeNames ?? []), ...(source.typeNames ?? [])]),\n ];\n if (source.typeNamespaceBinding !== undefined) {\n target.typeNamespaceBinding = source.typeNamespaceBinding;\n }\n};\n","import type { IBiMap } from './types';\n\nexport class BiMap<Key, Value> implements IBiMap<Key, Value> {\n private map = new Map<Key, Value>();\n private reverse = new Map<Value, Key>();\n\n delete(key: Key): boolean {\n const value = this.map.get(key);\n if (value !== undefined) {\n this.reverse.delete(value);\n }\n return this.map.delete(key);\n }\n\n deleteValue(value: Value): boolean {\n const key = this.reverse.get(value);\n if (key !== undefined) {\n this.map.delete(key);\n }\n return this.reverse.delete(value);\n }\n\n entries(): IterableIterator<[Key, Value]> {\n return this.map.entries();\n }\n\n get(key: Key): Value | undefined {\n return this.map.get(key);\n }\n\n getKey(value: Value): Key | undefined {\n return this.reverse.get(value);\n }\n\n hasKey(key: Key): boolean {\n return this.map.has(key);\n }\n\n hasValue(value: Value): boolean {\n return this.reverse.has(value);\n }\n\n keys(): IterableIterator<Key> {\n return this.map.keys();\n }\n\n set(key: Key, value: Value): this {\n const oldValue = this.map.get(key);\n if (oldValue !== undefined && oldValue !== value) {\n this.reverse.delete(oldValue);\n }\n const oldKey = this.reverse.get(value);\n if (oldKey !== undefined && oldKey !== key) {\n this.map.delete(oldKey);\n }\n this.map.set(key, value);\n this.reverse.set(value, key);\n return this;\n }\n\n get size(): number {\n return this.map.size;\n }\n\n values(): IterableIterator<Value> {\n return this.map.values();\n }\n\n [Symbol.iterator](): IterableIterator<[Key, Value]> {\n return this.map[Symbol.iterator]();\n }\n}\n","import { BiMap } from '../bimap/bimap';\nimport type { ISelector } from '../selectors/types';\nimport type { IFileIn, IFileOut, IFileRegistry } from './types';\n\nexport class FileRegistry implements IFileRegistry {\n private _id: number = 0;\n private referenceOrder: Set<number> = new Set();\n private registerOrder: Set<number> = new Set();\n private selectorToId: Map<string, number> = new Map();\n private values: Map<number, IFileOut> = new Map();\n\n get(fileIdOrSelector: number | ISelector): IFileOut | undefined {\n const symbol = this.idOrSelector(fileIdOrSelector);\n\n if (symbol.id !== undefined) {\n return this.values.get(symbol.id);\n }\n\n const selector =\n symbol.selector !== undefined\n ? JSON.stringify(symbol.selector)\n : undefined;\n\n if (selector) {\n const id = this.selectorToId.get(selector);\n if (id !== undefined) {\n return this.values.get(id);\n }\n }\n\n return;\n }\n\n get id(): number {\n return this._id++;\n }\n\n private idOrSelector(\n symbolIdOrSelector: number | ISelector,\n ): Pick<IFileIn, 'id' | 'selector'> {\n return typeof symbolIdOrSelector === 'number'\n ? { id: symbolIdOrSelector }\n : { selector: symbolIdOrSelector };\n }\n\n isRegistered(fileIdOrSelector: number | ISelector): boolean {\n const file = this.get(fileIdOrSelector);\n return file ? this.registerOrder.has(file.id) : false;\n }\n\n reference(fileIdOrSelector: number | ISelector): IFileOut {\n const file = this.idOrSelector(fileIdOrSelector);\n return this.register(file);\n }\n\n *referenced(): IterableIterator<IFileOut> {\n for (const id of this.referenceOrder.values()) {\n yield this.values.get(id)!;\n }\n }\n\n register(file: IFileIn): IFileOut {\n if (file.id !== undefined) {\n const result = this.values.get(file.id);\n if (!result) {\n throw new Error(\n `File with ID ${file.id} not found. To register a new file, leave the ID undefined.`,\n );\n }\n return result;\n }\n\n const hasOtherKeys = Object.keys(file).some(\n (key) => !['id', 'selector'].includes(key),\n );\n\n let result: IFileOut | undefined;\n\n const selector =\n file.selector !== undefined ? JSON.stringify(file.selector) : undefined;\n if (selector) {\n const id = this.selectorToId.get(selector);\n if (id !== undefined) {\n result = this.values.get(id);\n if (!result) {\n throw new Error(\n `File with ID ${id} not found. The selector ${selector} matched an ID, but there was no result. This is likely an issue with the application logic.`,\n );\n }\n if (!hasOtherKeys) {\n return result;\n }\n }\n }\n\n const id = result?.id !== undefined ? result.id : this.id;\n result = {\n ...result,\n ...file, // clone to avoid mutation\n id,\n resolvedNames: result?.resolvedNames ?? new BiMap(),\n symbols: result?.symbols ?? {\n body: [],\n exports: [],\n imports: [],\n },\n };\n this.values.set(id, result);\n\n if (hasOtherKeys) {\n this.registerOrder.add(id);\n if (this.referenceOrder.has(id)) {\n this.referenceOrder.delete(id);\n }\n } else {\n this.referenceOrder.add(id);\n }\n\n if (selector) {\n this.selectorToId.set(selector, id);\n }\n\n return result;\n }\n\n *registered(): IterableIterator<IFileOut> {\n for (const id of this.registerOrder.values()) {\n yield this.values.get(id)!;\n }\n }\n}\n","/**\n * Wraps an ID in namespace to avoid collisions when replacing it.\n *\n * @param symbolId Stringified symbol ID to use.\n * @returns The wrapped placeholder ID.\n */\nexport const wrapId = (symbolId: string): string => `_heyapi_${symbolId}_`;\n\n/**\n * Unwraps an ID from namespace.\n *\n * @param wrappedId The wrapped placeholder ID.\n * @returns Stringified ID to use.\n */\nconst unwrapId = (wrappedId: string): string =>\n wrappedId.slice('_heyapi_'.length, -1);\n\n/**\n * Returns a RegExp instance to match ID placeholders.\n *\n * @returns RegExp instance to match ID placeholders.\n */\nconst createPlaceholderRegExp = (): RegExp => new RegExp(wrapId('\\\\d+'), 'g');\n\n/**\n *\n * @param source The source string to replace.\n * @param replacerFn Accepts a symbol ID, returns resolved symbol name.\n * @returns The replaced source string.\n */\nexport const renderIds = (\n source: string,\n replacerFn: (symbolId: number) => string | undefined,\n): string =>\n source.replace(createPlaceholderRegExp(), (match) => {\n const symbolId = Number.parseInt(unwrapId(match), 10);\n return replacerFn(symbolId) || match;\n });\n","import { wrapId } from '../renderer/utils';\nimport type { ISelector } from '../selectors/types';\nimport type { ISymbolIn, ISymbolOut, ISymbolRegistry } from './types';\n\nexport class SymbolRegistry implements ISymbolRegistry {\n private _id: number = 0;\n private nodes: Map<number, unknown> = new Map();\n private registerOrder: Set<number> = new Set();\n private selectorToId: Map<string, number> = new Map();\n private values: Map<number, ISymbolOut> = new Map();\n\n get(symbolIdOrSelector: number | ISelector): ISymbolOut | undefined {\n const symbol = this.idOrSelector(symbolIdOrSelector);\n\n if (symbol.id !== undefined) {\n return this.values.get(symbol.id);\n }\n\n const selector =\n symbol.selector !== undefined\n ? JSON.stringify(symbol.selector)\n : undefined;\n\n if (selector) {\n const id = this.selectorToId.get(selector);\n if (id !== undefined) {\n return this.values.get(id);\n }\n }\n\n return;\n }\n\n getValue(symbolId: number): unknown {\n return this.nodes.get(symbolId);\n }\n\n hasValue(symbolId: number): boolean {\n return this.nodes.has(symbolId);\n }\n\n get id(): number {\n return this._id++;\n }\n\n private idOrSelector(\n symbolIdOrSelector: number | ISelector,\n ): Pick<ISymbolIn, 'id' | 'selector'> {\n return typeof symbolIdOrSelector === 'number'\n ? { id: symbolIdOrSelector }\n : { selector: symbolIdOrSelector };\n }\n\n isRegistered(symbolIdOrSelector: number | ISelector): boolean {\n const symbol = this.get(symbolIdOrSelector);\n return symbol ? this.registerOrder.has(symbol.id) : false;\n }\n\n reference(symbolIdOrSelector: number | ISelector): ISymbolOut {\n const symbol = this.idOrSelector(symbolIdOrSelector);\n return this.register(symbol);\n }\n\n register(symbol: ISymbolIn): ISymbolOut {\n if (symbol.id !== undefined) {\n const result = this.values.get(symbol.id);\n if (!result) {\n throw new Error(\n `Symbol with ID ${symbol.id} not found. To register a new symbol, leave the ID undefined.`,\n );\n }\n return result;\n }\n\n const hasOtherKeys = Object.keys(symbol).some(\n (key) => !['id', 'selector'].includes(key),\n );\n\n let result: ISymbolOut | undefined;\n\n const selector =\n symbol.selector !== undefined\n ? JSON.stringify(symbol.selector)\n : undefined;\n if (selector) {\n const id = this.selectorToId.get(selector);\n if (id !== undefined) {\n result = this.values.get(id);\n if (!result) {\n throw new Error(\n `Symbol with ID ${id} not found. The selector ${selector} matched an ID, but there was no result. This is likely an issue with the application logic.`,\n );\n }\n if (!hasOtherKeys) {\n return result;\n }\n }\n }\n\n const id = result?.id !== undefined ? result.id : this.id;\n const exportFrom: Array<string> = result?.exportFrom\n ? [...result.exportFrom]\n : [];\n if (symbol.exportFrom) {\n exportFrom.push(...symbol.exportFrom);\n }\n result = {\n ...result,\n ...symbol, // clone to avoid mutation\n exportFrom,\n id,\n placeholder:\n result?.placeholder ?? symbol.placeholder ?? wrapId(String(id)),\n };\n this.values.set(id, result);\n\n if (hasOtherKeys) {\n this.registerOrder.add(id);\n }\n\n if (selector) {\n this.selectorToId.set(selector, id);\n }\n\n return result;\n }\n\n *registered(): IterableIterator<ISymbolOut> {\n for (const id of this.registerOrder.values()) {\n yield this.values.get(id)!;\n }\n }\n\n setValue(symbolId: number, value: unknown): Map<number, unknown> {\n return this.nodes.set(symbolId, value);\n }\n}\n","import path from 'node:path';\n\nimport type { IProjectRenderMeta } from '../extensions/types';\nimport { FileRegistry } from '../files/registry';\nimport type { IFileOut } from '../files/types';\nimport type { IOutput } from '../output/types';\nimport type { IRenderer } from '../renderer/types';\nimport type { ISelector } from '../selectors/types';\nimport { SymbolRegistry } from '../symbols/registry';\nimport type { ISymbolOut } from '../symbols/types';\nimport type { IProject } from './types';\n\nconst externalSourceSymbol = '@';\n\nexport class Project implements IProject {\n private symbolIdToFileIds: Map<number, Set<number>> = new Map();\n\n readonly defaultFileName: string;\n readonly files = new FileRegistry();\n readonly fileName?: (name: string) => string;\n readonly renderers: Record<string, IRenderer> = {};\n readonly root: string;\n readonly symbols = new SymbolRegistry();\n\n constructor({\n defaultFileName,\n fileName,\n renderers,\n root,\n }: Pick<IProject, 'defaultFileName' | 'fileName' | 'renderers' | 'root'>) {\n this.defaultFileName = defaultFileName ?? 'main';\n this.fileName = typeof fileName === 'string' ? () => fileName : fileName;\n this.renderers = renderers;\n this.root = root;\n }\n\n private getRenderer(file: IFileOut): IRenderer | undefined {\n return file.extension ? this.renderers[file.extension] : undefined;\n }\n\n private prepareFiles(): void {\n // TODO: infer extension from symbols\n const extension = '.ts';\n for (const symbol of this.symbols.registered()) {\n const selector = this.symbolToFileSelector(symbol);\n const file = this.files.reference(selector);\n file.symbols.body.push(symbol.id);\n // update symbol->files map\n const symbolIdToFileIds =\n this.symbolIdToFileIds.get(symbol.id) ?? new Set();\n symbolIdToFileIds.add(file.id);\n this.symbolIdToFileIds.set(symbol.id, symbolIdToFileIds);\n // update re-exports\n for (const exportFrom of symbol.exportFrom) {\n const exportSelector = [exportFrom];\n const exportFile = this.files.reference(exportSelector);\n if (exportFile.id !== file.id) {\n exportFile.symbols.exports.push(symbol.id);\n }\n }\n }\n for (const file of this.files.referenced()) {\n if (!file.selector) continue;\n if (file.selector[0] === externalSourceSymbol) {\n const filePath = file.selector[1];\n if (!filePath) {\n this.files.register({\n external: true,\n selector: file.selector,\n });\n continue;\n }\n const extension = path.extname(filePath);\n if (!extension) {\n this.files.register({\n external: true,\n path: filePath,\n selector: file.selector,\n });\n continue;\n }\n this.files.register({\n extension,\n external: true,\n path: filePath,\n selector: file.selector,\n });\n continue;\n }\n const dirs = file.selector.slice(0, -1);\n let name = file.selector[file.selector.length - 1]!;\n name = this.fileName?.(name) || name;\n this.files.register({\n extension,\n name,\n path: path.resolve(this.root, ...dirs, `${name}${extension}`),\n selector: file.selector,\n });\n }\n\n // TODO: track symbol dependencies and inject imports into files\n // based on symbol references so the render step can just render\n }\n\n render(meta?: IProjectRenderMeta): ReadonlyArray<IOutput> {\n this.prepareFiles();\n const files: Map<number, IOutput> = new Map();\n for (const file of this.files.registered()) {\n if (file.external || !file.path) continue;\n const renderer = this.getRenderer(file);\n if (!renderer) continue;\n files.set(file.id, {\n content: renderer.renderSymbols(file, this, meta),\n path: file.path,\n });\n }\n for (const [fileId, value] of files.entries()) {\n const file = this.files.get(fileId)!;\n const renderer = this.getRenderer(file)!;\n const content = renderer.renderFile(value.content, file, this, meta);\n if (content) {\n files.set(file.id, { ...value, content });\n } else {\n files.delete(file.id);\n }\n }\n return Array.from(files.values());\n }\n\n symbolIdToFiles(symbolId: number): ReadonlyArray<IFileOut> {\n const fileIds = this.symbolIdToFileIds.get(symbolId);\n return Array.from(fileIds ?? []).map((fileId) => this.files.get(fileId)!);\n }\n\n private symbolToFileSelector(symbol: ISymbolOut): ISelector {\n if (symbol.external) {\n return [externalSourceSymbol, symbol.external];\n }\n const filePath = symbol.getFilePath?.(symbol);\n if (filePath) {\n return filePath.split('/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EAAmD,CACxD,KAAK,cAAc,CACnB,IAAMC,EAA8B,IAAI,IACxC,IAAK,IAAM,KAAQ,KAAK,MAAM,YAAY,CAAE,CAC1C,GAAI,EAAK,UAAY,CAAC,EAAK,KAAM,SACjC,IAAM,EAAW,KAAK,YAAY,EAAK,CAClC,GACL,EAAM,IAAI,EAAK,GAAI,CACjB,QAAS,EAAS,cAAc,EAAM,KAAM,EAAK,CACjD,KAAM,EAAK,KACZ,CAAC,CAEJ,IAAK,GAAM,CAAC,EAAQ,KAAU,EAAM,SAAS,CAAE,CAC7C,IAAM,EAAO,KAAK,MAAM,IAAI,EAAO,CAE7B,EADW,KAAK,YAAY,EAAK,CACd,WAAW,EAAM,QAAS,EAAM,KAAM,EAAK,CAChE,EACF,EAAM,IAAI,EAAK,GAAI,CAAE,GAAG,EAAO,UAAS,CAAC,CAEzC,EAAM,OAAO,EAAK,GAAG,CAGzB,OAAO,MAAM,KAAK,EAAM,QAAQ,CAAC,CAGnC,gBAAgB,EAA2C,CACzD,IAAM,EAAU,KAAK,kBAAkB,IAAI,EAAS,CACpD,OAAO,MAAM,KAAK,GAAW,EAAE,CAAC,CAAC,IAAK,GAAW,KAAK,MAAM,IAAI,EAAO,CAAE,CAG3E,qBAA6B,EAA+B,CAC1D,GAAI,EAAO,SACT,MAAO,CAAC,IAAsB,EAAO,SAAS,CAEhD,IAAM,EAAW,EAAO,cAAc,EAAO,CAI7C,OAHI,EACK,EAAS,MAAM,IAAI,CAErB,CAAC,KAAK,gBAAgB"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hey-api/codegen-core",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.1",
|
|
4
4
|
"description": "🧱 TypeScript framework for generating structured, multi-file source code from abstract syntax trees.",
|
|
5
5
|
"homepage": "https://heyapi.dev/",
|
|
6
6
|
"repository": {
|
|
@@ -47,7 +47,7 @@
|
|
|
47
47
|
"README.md"
|
|
48
48
|
],
|
|
49
49
|
"engines": {
|
|
50
|
-
"node": "
|
|
50
|
+
"node": ">=20.19.0"
|
|
51
51
|
},
|
|
52
52
|
"peerDependencies": {
|
|
53
53
|
"typescript": ">=5.5.3"
|
|
@@ -55,13 +55,13 @@
|
|
|
55
55
|
"devDependencies": {
|
|
56
56
|
"eslint": "9.17.0",
|
|
57
57
|
"prettier": "3.4.2",
|
|
58
|
-
"typescript": "5.
|
|
58
|
+
"typescript": "5.9.3",
|
|
59
59
|
"@config/vite-base": "0.0.1"
|
|
60
60
|
},
|
|
61
61
|
"scripts": {
|
|
62
|
-
"build": "
|
|
62
|
+
"build": "tsdown && pnpm check-exports",
|
|
63
63
|
"check-exports": "attw --pack . --profile node16",
|
|
64
|
-
"dev": "
|
|
64
|
+
"dev": "tsdown --watch",
|
|
65
65
|
"test:coverage": "vitest run --coverage",
|
|
66
66
|
"test:update": "vitest watch --update",
|
|
67
67
|
"test:watch": "vitest watch",
|