@hey-api/codegen-core 0.3.2 → 0.3.3

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 CHANGED
@@ -1,2 +1,2 @@
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.importKind&&(n.importKind===`default`?(o.defaultBinding=n.placeholder,n.kind===`type`&&(o.typeDefaultBinding=!0)):n.importKind===`namespace`&&(o.namespaceBinding=n.placeholder,n.kind===`type`&&(o.typeNamespaceBinding=!0))),n.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.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.identifierToFile(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++}identifierToFile(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.identifierToFile(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;indices=new Map;nodes=new Map;queryCache=new Map;queryCacheDependencies=new Map;registerOrder=new Set;stubCache=new Map;stubs=new Set;values=new Map;get(e){return typeof e==`number`?this.values.get(e):this.query(e)[0]}getValue(e){return this.nodes.get(e)}hasValue(e){return this.nodes.has(e)}get id(){return this._id++}isRegistered(e){let t=this.get(e);return t?this.registerOrder.has(t.id):!1}query(e){let t=this.buildCacheKey(e),n=this.queryCache.get(t);if(n)return n.map(e=>this.values.get(e));let r=[],i=this.buildIndexKeySpace(e),a=new Set,o=!1;for(let e of i){a.add(this.serializeIndexEntry(e));let t=this.indices.get(e[0]);if(!t){o=!0;break}let n=t.get(e[1]);if(!n){o=!0;break}r.push(n)}if(o||!r.length)return this.queryCacheDependencies.set(t,a),this.queryCache.set(t,[]),[];let s=new Set(r[0]);for(let e of r.slice(1))s=new Set([...s].filter(t=>e.has(t)));let c=[...s];return this.queryCacheDependencies.set(t,a),this.queryCache.set(t,c),c.map(e=>this.values.get(e))}reference(e){let[t]=this.query(e);if(t)return t;let n=this.buildCacheKey(e),r=this.stubCache.get(n);if(r!==void 0)return this.values.get(r);let i=this.id,a={exportFrom:[],id:i,meta:e,placeholder:p(String(i))};return this.values.set(a.id,a),this.stubs.add(a.id),this.stubCache.set(n,a.id),a}register(e){let t=e.id===void 0?this.id:e.id,n={...e,exportFrom:e.exportFrom??[],id:t,placeholder:e.placeholder??p(String(t))};if(this.values.set(n.id,n),this.registerOrder.add(n.id),n.meta){let e=this.buildIndexKeySpace(n.meta);this.indexSymbol(n.id,e),this.invalidateCache(e),this.replaceStubs(n,e)}return n}*registered(){for(let e of this.registerOrder.values())yield this.values.get(e)}setValue(e,t){return this.nodes.set(e,t)}buildCacheKey(e){return this.buildIndexKeySpace(e).map(e=>this.serializeIndexEntry(e)).sort().join(`|`)}buildIndexKeySpace(e,t=``){let n=[];for(let[r,i]of Object.entries(e)){let e=t?`${t}.${r}`:r;i&&typeof i==`object`&&!Array.isArray(i)?n.push(...this.buildIndexKeySpace(i,e)):n.push([e,i])}return n}indexSymbol(e,t){for(let[n,r]of t){this.indices.has(n)||this.indices.set(n,new Map);let t=this.indices.get(n),i=t.get(r)??new Set;i.add(e),t.set(r,i)}}invalidateCache(e){let t=e.map(e=>this.serializeIndexEntry(e));for(let[e,n]of this.queryCacheDependencies.entries())for(let r of t)if(n.has(r)){this.queryCacheDependencies.delete(e),this.queryCache.delete(e);break}}isSubset(e,t){let n=new Map(t);for(let[t,r]of e)if(!n.has(t)||n.get(t)!==r)return!1;return!0}replaceStubs(e,t){for(let n of this.stubs.values()){let r=this.values.get(n);if(r?.meta&&this.isSubset(this.buildIndexKeySpace(r.meta),t)){let t=this.buildCacheKey(r.meta);this.stubCache.delete(t),this.values.set(n,Object.assign(r,e)),this.stubs.delete(n)}}}serializeIndexEntry(e){return`${e[0]}:${JSON.stringify(e[1])}`}};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;
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.importKind&&(n.importKind===`default`?(o.defaultBinding=n.placeholder,n.kind===`type`&&(o.typeDefaultBinding=!0)):n.importKind===`namespace`&&(o.namespaceBinding=n.placeholder,n.kind===`type`&&(o.typeNamespaceBinding=!0))),n.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.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.identifierToFile(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++}identifierToFile(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.identifierToFile(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;indices=new Map;nodes=new Map;queryCache=new Map;queryCacheDependencies=new Map;registerOrder=new Set;stubCache=new Map;stubs=new Set;values=new Map;get(e){return typeof e==`number`?this.values.get(e):this.query(e)[0]}getValue(e){return this.nodes.get(e)}hasValue(e){return this.nodes.has(e)}get id(){return this._id++}isRegistered(e){let t=this.get(e);return t?this.registerOrder.has(t.id):!1}query(e){let t=this.buildCacheKey(e),n=this.queryCache.get(t);if(n)return n.map(e=>this.values.get(e));let r=[],i=this.buildIndexKeySpace(e),a=new Set,o=!1;for(let e of i){a.add(this.serializeIndexEntry(e));let t=this.indices.get(e[0]);if(!t){o=!0;break}let n=t.get(e[1]);if(!n){o=!0;break}r.push(n)}if(o||!r.length)return this.queryCacheDependencies.set(t,a),this.queryCache.set(t,[]),[];let s=new Set(r[0]);for(let e of r.slice(1))s=new Set([...s].filter(t=>e.has(t)));let c=[...s];return this.queryCacheDependencies.set(t,a),this.queryCache.set(t,c),c.map(e=>this.values.get(e))}reference(e){let[t]=this.query(e);if(t)return t;let n=this.buildCacheKey(e),r=this.stubCache.get(n);if(r!==void 0)return this.values.get(r);let i=this.id,a={id:i,meta:e,placeholder:p(String(i))};return this.values.set(a.id,a),this.stubs.add(a.id),this.stubCache.set(n,a.id),a}register(e){let t=e.id===void 0?this.id:e.id,n={...e,id:t,placeholder:e.placeholder??p(String(t))};if(this.values.set(n.id,n),this.registerOrder.add(n.id),n.meta){let e=this.buildIndexKeySpace(n.meta);this.indexSymbol(n.id,e),this.invalidateCache(e),this.replaceStubs(n,e)}return n}*registered(){for(let e of this.registerOrder.values())yield this.values.get(e)}setValue(e,t){return this.nodes.set(e,t)}buildCacheKey(e){return this.buildIndexKeySpace(e).map(e=>this.serializeIndexEntry(e)).sort().join(`|`)}buildIndexKeySpace(e,t=``){let n=[];for(let[r,i]of Object.entries(e)){let e=t?`${t}.${r}`:r;i&&typeof i==`object`&&!Array.isArray(i)?n.push(...this.buildIndexKeySpace(i,e)):n.push([e,i])}return n}indexSymbol(e,t){for(let[n,r]of t){this.indices.has(n)||this.indices.set(n,new Map);let t=this.indices.get(n),i=t.get(r)??new Set;i.add(e),t.set(r,i)}}invalidateCache(e){let t=e.map(e=>this.serializeIndexEntry(e));for(let[e,n]of this.queryCacheDependencies.entries())for(let r of t)if(n.has(r)){this.queryCacheDependencies.delete(e),this.queryCache.delete(e);break}}isSubset(e,t){let n=new Map(t);for(let[t,r]of e)if(!n.has(t)||n.get(t)!==r)return!1;return!0}replaceStubs(e,t){for(let n of this.stubs.values()){let r=this.values.get(n);if(r?.meta&&this.isSubset(this.buildIndexKeySpace(r.meta),t)){let t=this.buildCacheKey(r.meta);this.stubCache.delete(t),this.values.set(n,Object.assign(r,e)),this.stubs.delete(n)}}}serializeIndexEntry(e){return`${e[0]}:${JSON.stringify(e[1])}`}};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;if(r.add(n.id),this.symbolIdToFileIds.set(e.id,r),e.exportFrom)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
@@ -1 +1 @@
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","sets: Array<Set<SymbolId>>","stub: ISymbolOut","result: ISymbolOut","entries: Array<IndexEntry>","path","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.importKind) {\n if (symbol.importKind === 'default') {\n binding.defaultBinding = symbol.placeholder;\n if (symbol.kind === 'type') {\n binding.typeDefaultBinding = true;\n }\n } else if (symbol.importKind === 'namespace') {\n binding.namespaceBinding = symbol.placeholder;\n if (symbol.kind === 'type') {\n binding.typeNamespaceBinding = true;\n }\n }\n }\n // default to named binding\n if (\n symbol.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.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 {\n IFileIdentifier,\n IFileIn,\n IFileOut,\n IFileRegistry,\n} 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(identifier: IFileIdentifier): IFileOut | undefined {\n const file = this.identifierToFile(identifier);\n\n if (file.id !== undefined) {\n return this.values.get(file.id);\n }\n\n const selector =\n file.selector !== undefined ? JSON.stringify(file.selector) : 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 identifierToFile(\n identifier: IFileIdentifier,\n ): Pick<IFileIn, 'id' | 'selector'> {\n return typeof identifier === 'number'\n ? { id: identifier }\n : { selector: identifier };\n }\n\n isRegistered(identifier: IFileIdentifier): boolean {\n const file = this.get(identifier);\n return file ? this.registerOrder.has(file.id) : false;\n }\n\n reference(identifier: IFileIdentifier): IFileOut {\n const file = this.identifierToFile(identifier);\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 type { ISymbolMeta } from '../extensions/types';\nimport { wrapId } from '../renderer/utils';\nimport type {\n ISymbolIdentifier,\n ISymbolIn,\n ISymbolOut,\n ISymbolRegistry,\n} from './types';\n\ntype IndexEntry = [string, unknown];\ntype IndexKeySpace = ReadonlyArray<IndexEntry>;\ntype QueryCacheKey = string;\ntype SymbolId = number;\n\nexport class SymbolRegistry implements ISymbolRegistry {\n private _id: SymbolId = 0;\n private indices: Map<IndexEntry[0], Map<IndexEntry[1], Set<SymbolId>>> =\n new Map();\n private nodes: Map<SymbolId, unknown> = new Map();\n private queryCache: Map<QueryCacheKey, ReadonlyArray<SymbolId>> = new Map();\n private queryCacheDependencies: Map<QueryCacheKey, Set<QueryCacheKey>> =\n new Map();\n private registerOrder: Set<SymbolId> = new Set();\n private stubCache: Map<QueryCacheKey, SymbolId> = new Map();\n private stubs: Set<SymbolId> = new Set();\n private values: Map<SymbolId, ISymbolOut> = new Map();\n\n get(identifier: ISymbolIdentifier): ISymbolOut | undefined {\n return typeof identifier === 'number'\n ? this.values.get(identifier)\n : this.query(identifier)[0];\n }\n\n getValue(symbolId: SymbolId): unknown {\n return this.nodes.get(symbolId);\n }\n\n hasValue(symbolId: SymbolId): boolean {\n return this.nodes.has(symbolId);\n }\n\n get id(): SymbolId {\n return this._id++;\n }\n\n isRegistered(identifier: ISymbolIdentifier): boolean {\n const symbol = this.get(identifier);\n return symbol ? this.registerOrder.has(symbol.id) : false;\n }\n\n query(filter: ISymbolMeta): ReadonlyArray<ISymbolOut> {\n const cacheKey = this.buildCacheKey(filter);\n const cachedIds = this.queryCache.get(cacheKey);\n if (cachedIds) {\n return cachedIds.map((symbolId) => this.values.get(symbolId)!);\n }\n const sets: Array<Set<SymbolId>> = [];\n const indexKeySpace = this.buildIndexKeySpace(filter);\n const cacheDependencies = new Set<QueryCacheKey>();\n let missed = false;\n for (const indexEntry of indexKeySpace) {\n cacheDependencies.add(this.serializeIndexEntry(indexEntry));\n const values = this.indices.get(indexEntry[0]);\n if (!values) {\n missed = true;\n break;\n }\n const set = values.get(indexEntry[1]);\n if (!set) {\n missed = true;\n break;\n }\n sets.push(set);\n }\n if (missed || !sets.length) {\n this.queryCacheDependencies.set(cacheKey, cacheDependencies);\n this.queryCache.set(cacheKey, []);\n return [];\n }\n let result = new Set(sets[0]);\n for (const set of sets.slice(1)) {\n result = new Set([...result].filter((symbolId) => set.has(symbolId)));\n }\n const resultIds = [...result];\n this.queryCacheDependencies.set(cacheKey, cacheDependencies);\n this.queryCache.set(cacheKey, resultIds);\n return resultIds.map((symbolId) => this.values.get(symbolId)!);\n }\n\n reference(meta: ISymbolMeta): ISymbolOut {\n const [registered] = this.query(meta);\n if (registered) return registered;\n const cacheKey = this.buildCacheKey(meta);\n const cachedId = this.stubCache.get(cacheKey);\n if (cachedId !== undefined) return this.values.get(cachedId)!;\n const id = this.id;\n const stub: ISymbolOut = {\n exportFrom: [],\n id,\n meta,\n placeholder: wrapId(String(id)),\n };\n this.values.set(stub.id, stub);\n this.stubs.add(stub.id);\n this.stubCache.set(cacheKey, stub.id);\n return stub;\n }\n\n register(symbol: ISymbolIn): ISymbolOut {\n const id = symbol.id !== undefined ? symbol.id : this.id;\n const result: ISymbolOut = {\n ...symbol, // clone to avoid mutation\n exportFrom: symbol.exportFrom ?? [],\n id,\n placeholder: symbol.placeholder ?? wrapId(String(id)),\n };\n this.values.set(result.id, result);\n this.registerOrder.add(result.id);\n if (result.meta) {\n const indexKeySpace = this.buildIndexKeySpace(result.meta);\n this.indexSymbol(result.id, indexKeySpace);\n this.invalidateCache(indexKeySpace);\n this.replaceStubs(result, indexKeySpace);\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: SymbolId, value: unknown): Map<SymbolId, unknown> {\n return this.nodes.set(symbolId, value);\n }\n\n private buildCacheKey(filter: ISymbolMeta): QueryCacheKey {\n const indexKeySpace = this.buildIndexKeySpace(filter);\n return indexKeySpace\n .map((indexEntry) => this.serializeIndexEntry(indexEntry))\n .sort() // ensure order-insensitivity\n .join('|');\n }\n\n private buildIndexKeySpace(meta: ISymbolMeta, prefix = ''): IndexKeySpace {\n const entries: Array<IndexEntry> = [];\n for (const [key, value] of Object.entries(meta)) {\n const path = prefix ? `${prefix}.${key}` : key;\n if (value && typeof value === 'object' && !Array.isArray(value)) {\n entries.push(...this.buildIndexKeySpace(value as ISymbolMeta, path));\n } else {\n entries.push([path, value]);\n }\n }\n return entries;\n }\n\n private indexSymbol(symbolId: SymbolId, indexKeySpace: IndexKeySpace): void {\n for (const [key, value] of indexKeySpace) {\n if (!this.indices.has(key)) this.indices.set(key, new Map());\n const values = this.indices.get(key)!;\n const set = values.get(value) ?? new Set();\n set.add(symbolId);\n values.set(value, set);\n }\n }\n\n private invalidateCache(indexKeySpace: IndexKeySpace): void {\n const changed = indexKeySpace.map((indexEntry) =>\n this.serializeIndexEntry(indexEntry),\n );\n for (const [\n cacheKey,\n cacheDependencies,\n ] of this.queryCacheDependencies.entries()) {\n for (const key of changed) {\n if (cacheDependencies.has(key)) {\n this.queryCacheDependencies.delete(cacheKey);\n this.queryCache.delete(cacheKey);\n break;\n }\n }\n }\n }\n\n private isSubset(sub: IndexKeySpace, sup: IndexKeySpace): boolean {\n const supMap = new Map(sup);\n for (const [key, value] of sub) {\n if (!supMap.has(key) || supMap.get(key) !== value) {\n return false;\n }\n }\n return true;\n }\n\n private replaceStubs(symbol: ISymbolOut, indexKeySpace: IndexKeySpace): void {\n for (const stubId of this.stubs.values()) {\n const stub = this.values.get(stubId);\n if (\n stub?.meta &&\n this.isSubset(this.buildIndexKeySpace(stub.meta), indexKeySpace)\n ) {\n const cacheKey = this.buildCacheKey(stub.meta);\n this.stubCache.delete(cacheKey);\n this.values.set(stubId, Object.assign(stub, symbol));\n this.stubs.delete(stubId);\n }\n }\n }\n\n private serializeIndexEntry(indexEntry: IndexEntry): string {\n return `${indexEntry[0]}:${JSON.stringify(indexEntry[1])}`;\n }\n}\n","import path from 'node:path';\n\nimport type { IProjectRenderMeta } from '../extensions/types';\nimport { FileRegistry } from '../files/registry';\nimport type { IFileOut, IFileSelector } from '../files/types';\nimport type { IOutput } from '../output/types';\nimport type { IRenderer } from '../renderer/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): IFileSelector {\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,aACL,EAAO,aAAe,WAC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W,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,EAAmC,CAC9D,GAAI,EAAO,SACT,MAAO,CAAC,IAAsB,EAAO,SAAS,CAEhD,IAAM,EAAW,EAAO,cAAc,EAAO,CAI7C,OAHI,EACK,EAAS,MAAM,IAAI,CAErB,CAAC,KAAK,gBAAgB"}
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","sets: Array<Set<SymbolId>>","stub: ISymbolOut","result: ISymbolOut","entries: Array<IndexEntry>","path","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.importKind) {\n if (symbol.importKind === 'default') {\n binding.defaultBinding = symbol.placeholder;\n if (symbol.kind === 'type') {\n binding.typeDefaultBinding = true;\n }\n } else if (symbol.importKind === 'namespace') {\n binding.namespaceBinding = symbol.placeholder;\n if (symbol.kind === 'type') {\n binding.typeNamespaceBinding = true;\n }\n }\n }\n // default to named binding\n if (\n symbol.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.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 {\n IFileIdentifier,\n IFileIn,\n IFileOut,\n IFileRegistry,\n} 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(identifier: IFileIdentifier): IFileOut | undefined {\n const file = this.identifierToFile(identifier);\n\n if (file.id !== undefined) {\n return this.values.get(file.id);\n }\n\n const selector =\n file.selector !== undefined ? JSON.stringify(file.selector) : 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 identifierToFile(\n identifier: IFileIdentifier,\n ): Pick<IFileIn, 'id' | 'selector'> {\n return typeof identifier === 'number'\n ? { id: identifier }\n : { selector: identifier };\n }\n\n isRegistered(identifier: IFileIdentifier): boolean {\n const file = this.get(identifier);\n return file ? this.registerOrder.has(file.id) : false;\n }\n\n reference(identifier: IFileIdentifier): IFileOut {\n const file = this.identifierToFile(identifier);\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 type { ISymbolMeta } from '../extensions/types';\nimport { wrapId } from '../renderer/utils';\nimport type {\n ISymbolIdentifier,\n ISymbolIn,\n ISymbolOut,\n ISymbolRegistry,\n} from './types';\n\ntype IndexEntry = [string, unknown];\ntype IndexKeySpace = ReadonlyArray<IndexEntry>;\ntype QueryCacheKey = string;\ntype SymbolId = number;\n\nexport class SymbolRegistry implements ISymbolRegistry {\n private _id: SymbolId = 0;\n private indices: Map<IndexEntry[0], Map<IndexEntry[1], Set<SymbolId>>> =\n new Map();\n private nodes: Map<SymbolId, unknown> = new Map();\n private queryCache: Map<QueryCacheKey, ReadonlyArray<SymbolId>> = new Map();\n private queryCacheDependencies: Map<QueryCacheKey, Set<QueryCacheKey>> =\n new Map();\n private registerOrder: Set<SymbolId> = new Set();\n private stubCache: Map<QueryCacheKey, SymbolId> = new Map();\n private stubs: Set<SymbolId> = new Set();\n private values: Map<SymbolId, ISymbolOut> = new Map();\n\n get(identifier: ISymbolIdentifier): ISymbolOut | undefined {\n return typeof identifier === 'number'\n ? this.values.get(identifier)\n : this.query(identifier)[0];\n }\n\n getValue(symbolId: SymbolId): unknown {\n return this.nodes.get(symbolId);\n }\n\n hasValue(symbolId: SymbolId): boolean {\n return this.nodes.has(symbolId);\n }\n\n get id(): SymbolId {\n return this._id++;\n }\n\n isRegistered(identifier: ISymbolIdentifier): boolean {\n const symbol = this.get(identifier);\n return symbol ? this.registerOrder.has(symbol.id) : false;\n }\n\n query(filter: ISymbolMeta): ReadonlyArray<ISymbolOut> {\n const cacheKey = this.buildCacheKey(filter);\n const cachedIds = this.queryCache.get(cacheKey);\n if (cachedIds) {\n return cachedIds.map((symbolId) => this.values.get(symbolId)!);\n }\n const sets: Array<Set<SymbolId>> = [];\n const indexKeySpace = this.buildIndexKeySpace(filter);\n const cacheDependencies = new Set<QueryCacheKey>();\n let missed = false;\n for (const indexEntry of indexKeySpace) {\n cacheDependencies.add(this.serializeIndexEntry(indexEntry));\n const values = this.indices.get(indexEntry[0]);\n if (!values) {\n missed = true;\n break;\n }\n const set = values.get(indexEntry[1]);\n if (!set) {\n missed = true;\n break;\n }\n sets.push(set);\n }\n if (missed || !sets.length) {\n this.queryCacheDependencies.set(cacheKey, cacheDependencies);\n this.queryCache.set(cacheKey, []);\n return [];\n }\n let result = new Set(sets[0]);\n for (const set of sets.slice(1)) {\n result = new Set([...result].filter((symbolId) => set.has(symbolId)));\n }\n const resultIds = [...result];\n this.queryCacheDependencies.set(cacheKey, cacheDependencies);\n this.queryCache.set(cacheKey, resultIds);\n return resultIds.map((symbolId) => this.values.get(symbolId)!);\n }\n\n reference(meta: ISymbolMeta): ISymbolOut {\n const [registered] = this.query(meta);\n if (registered) return registered;\n const cacheKey = this.buildCacheKey(meta);\n const cachedId = this.stubCache.get(cacheKey);\n if (cachedId !== undefined) return this.values.get(cachedId)!;\n const id = this.id;\n const stub: ISymbolOut = {\n id,\n meta,\n placeholder: wrapId(String(id)),\n };\n this.values.set(stub.id, stub);\n this.stubs.add(stub.id);\n this.stubCache.set(cacheKey, stub.id);\n return stub;\n }\n\n register(symbol: ISymbolIn): ISymbolOut {\n const id = symbol.id !== undefined ? symbol.id : this.id;\n const result: ISymbolOut = {\n ...symbol, // clone to avoid mutation\n id,\n placeholder: symbol.placeholder ?? wrapId(String(id)),\n };\n this.values.set(result.id, result);\n this.registerOrder.add(result.id);\n if (result.meta) {\n const indexKeySpace = this.buildIndexKeySpace(result.meta);\n this.indexSymbol(result.id, indexKeySpace);\n this.invalidateCache(indexKeySpace);\n this.replaceStubs(result, indexKeySpace);\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: SymbolId, value: unknown): Map<SymbolId, unknown> {\n return this.nodes.set(symbolId, value);\n }\n\n private buildCacheKey(filter: ISymbolMeta): QueryCacheKey {\n const indexKeySpace = this.buildIndexKeySpace(filter);\n return indexKeySpace\n .map((indexEntry) => this.serializeIndexEntry(indexEntry))\n .sort() // ensure order-insensitivity\n .join('|');\n }\n\n private buildIndexKeySpace(meta: ISymbolMeta, prefix = ''): IndexKeySpace {\n const entries: Array<IndexEntry> = [];\n for (const [key, value] of Object.entries(meta)) {\n const path = prefix ? `${prefix}.${key}` : key;\n if (value && typeof value === 'object' && !Array.isArray(value)) {\n entries.push(...this.buildIndexKeySpace(value as ISymbolMeta, path));\n } else {\n entries.push([path, value]);\n }\n }\n return entries;\n }\n\n private indexSymbol(symbolId: SymbolId, indexKeySpace: IndexKeySpace): void {\n for (const [key, value] of indexKeySpace) {\n if (!this.indices.has(key)) this.indices.set(key, new Map());\n const values = this.indices.get(key)!;\n const set = values.get(value) ?? new Set();\n set.add(symbolId);\n values.set(value, set);\n }\n }\n\n private invalidateCache(indexKeySpace: IndexKeySpace): void {\n const changed = indexKeySpace.map((indexEntry) =>\n this.serializeIndexEntry(indexEntry),\n );\n for (const [\n cacheKey,\n cacheDependencies,\n ] of this.queryCacheDependencies.entries()) {\n for (const key of changed) {\n if (cacheDependencies.has(key)) {\n this.queryCacheDependencies.delete(cacheKey);\n this.queryCache.delete(cacheKey);\n break;\n }\n }\n }\n }\n\n private isSubset(sub: IndexKeySpace, sup: IndexKeySpace): boolean {\n const supMap = new Map(sup);\n for (const [key, value] of sub) {\n if (!supMap.has(key) || supMap.get(key) !== value) {\n return false;\n }\n }\n return true;\n }\n\n private replaceStubs(symbol: ISymbolOut, indexKeySpace: IndexKeySpace): void {\n for (const stubId of this.stubs.values()) {\n const stub = this.values.get(stubId);\n if (\n stub?.meta &&\n this.isSubset(this.buildIndexKeySpace(stub.meta), indexKeySpace)\n ) {\n const cacheKey = this.buildCacheKey(stub.meta);\n this.stubCache.delete(cacheKey);\n this.values.set(stubId, Object.assign(stub, symbol));\n this.stubs.delete(stubId);\n }\n }\n }\n\n private serializeIndexEntry(indexEntry: IndexEntry): string {\n return `${indexEntry[0]}:${JSON.stringify(indexEntry[1])}`;\n }\n}\n","import path from 'node:path';\n\nimport type { IProjectRenderMeta } from '../extensions/types';\nimport { FileRegistry } from '../files/registry';\nimport type { IFileOut, IFileSelector } from '../files/types';\nimport type { IOutput } from '../output/types';\nimport type { IRenderer } from '../renderer/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 if (symbol.exportFrom) {\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 }\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): IFileSelector {\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,aACL,EAAO,aAAe,WACxB,EAAQ,eAAiB,EAAO,YAC5B,EAAO,OAAS,SAClB,EAAQ,mBAAqB,KAEtB,EAAO,aAAe,cAC/B,EAAQ,iBAAmB,EAAO,YAC9B,EAAO,OAAS,SAClB,EAAQ,qBAAuB,MAMnC,EAAO,aAAe,SACrB,CAAC,EAAM,QAAU,CAAC,EAAQ,gBAAkB,CAAC,EAAQ,iBACtD,CACA,IAAI,EAAO,EAAO,YACZ,EAAmB,EAAK,cAAc,IAAI,EAAO,GAAG,CAC1D,GAAI,EAAkB,CACpB,IAAM,EAAyB,EAAW,cAAc,IAAI,EAAO,GAAG,CAClE,EACE,IAA2B,IAC7B,EAAO,EACP,EAAQ,QAAQ,GAAQ,GAEjB,EAAO,MAAQ,IAAqB,EAAO,OACpD,EAAO,EAAO,KACd,EAAQ,QAAQ,GAAQ,EAAO,aAGnC,EAAM,KAAK,EAAK,CACZ,EAAO,OAAS,QAClB,EAAU,KAAK,EAAK,CAKxB,IAAK,IAAM,KAAY,EAChB,EAAM,SAAS,EAAS,EAC3B,EAAM,KAAK,EAAS,CAKxB,MAFA,GAAQ,MAAQ,EAChB,EAAQ,UAAY,EACb,GAGI,GAAiB,EAAkB,IAA2B,CACzE,EAAO,QAAU,CAAE,GAAG,EAAO,QAAS,GAAG,EAAO,QAAS,CACrD,EAA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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,EAAmC,CAC9D,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
@@ -143,11 +143,11 @@ interface IBinding {
143
143
  */
144
144
  type IFileSelector = ReadonlyArray<string>;
145
145
  type IFileIdentifier = number | IFileSelector;
146
- interface IFileIn {
146
+ type IFileIn = {
147
147
  /**
148
148
  * File extension, if any.
149
149
  */
150
- readonly extension?: string;
150
+ extension?: string;
151
151
  /**
152
152
  * Indicates whether the file is external, meaning it is not generated
153
153
  * as part of the project but is referenced (e.g., a module from
@@ -155,7 +155,7 @@ interface IFileIn {
155
155
  *
156
156
  * @example true
157
157
  */
158
- readonly external?: boolean;
158
+ external?: boolean;
159
159
  /**
160
160
  * Unique file ID. If one is not provided, it will be auto-generated.
161
161
  */
@@ -166,21 +166,21 @@ interface IFileIn {
166
166
  *
167
167
  * @example "UserModel"
168
168
  */
169
- readonly name?: string;
169
+ name?: string;
170
170
  /**
171
171
  * Absolute logical output path for the file.
172
172
  *
173
173
  * @example "/src/models/user.ts"
174
174
  */
175
- readonly path?: string;
175
+ path?: string;
176
176
  /**
177
177
  * Selector array used to select this file.
178
178
  *
179
179
  * @example ["foo", "bar"]
180
180
  */
181
181
  readonly selector?: IFileSelector;
182
- }
183
- interface IFileOut extends IFileIn {
182
+ };
183
+ type IFileOut = IFileIn & {
184
184
  /**
185
185
  * Unique file ID.
186
186
  */
@@ -206,7 +206,7 @@ interface IFileOut extends IFileIn {
206
206
  */
207
207
  imports: Array<number>;
208
208
  };
209
- }
209
+ };
210
210
  interface IFileRegistry {
211
211
  /**
212
212
  * Get a file.
@@ -278,32 +278,32 @@ interface ISymbolMeta {
278
278
  //#endregion
279
279
  //#region src/symbols/types.d.ts
280
280
  type ISymbolIdentifier = number | ISymbolMeta;
281
- interface ISymbolIn {
281
+ type ISymbolIn = {
282
282
  /**
283
283
  * Array of file names (without extensions) from which this symbol is re-exported.
284
284
  *
285
285
  * @default undefined
286
286
  */
287
- readonly exportFrom?: ReadonlyArray<string>;
287
+ exportFrom?: ReadonlyArray<string>;
288
288
  /**
289
289
  * Whether this symbol is exported from its own file.
290
290
  *
291
291
  * @default false
292
292
  */
293
- readonly exported?: boolean;
293
+ exported?: boolean;
294
294
  /**
295
295
  * External module name if this symbol is imported from a module not managed
296
296
  * by the project (e.g. "zod", "lodash").
297
297
  *
298
298
  * @default undefined
299
299
  */
300
- readonly external?: string;
300
+ external?: string;
301
301
  /**
302
302
  * Optional output strategy to override default behavior.
303
303
  *
304
304
  * @returns The file path to output the symbol to, or undefined to fallback to default behavior.
305
305
  */
306
- readonly getFilePath?: (symbol: ISymbolOut) => string | undefined;
306
+ getFilePath?: (symbol: ISymbolOut) => string | undefined;
307
307
  /**
308
308
  * Unique symbol ID. If one is not provided, it will be auto-generated.
309
309
  */
@@ -311,47 +311,32 @@ interface ISymbolIn {
311
311
  /**
312
312
  * Kind of import if this symbol represents an import.
313
313
  */
314
- readonly importKind?: 'namespace' | 'default' | 'named';
314
+ importKind?: 'namespace' | 'default' | 'named';
315
315
  /**
316
316
  * Kind of symbol.
317
317
  */
318
- readonly kind?: 'type';
318
+ kind?: 'class' | 'function' | 'type';
319
319
  /**
320
320
  * Arbitrary metadata about the symbol.
321
321
  *
322
322
  * @default undefined
323
323
  */
324
- readonly meta?: ISymbolMeta;
324
+ meta?: ISymbolMeta;
325
325
  /**
326
326
  * The desired name for the symbol within its file. If there are multiple symbols
327
327
  * with the same desired name, this might not end up being the actual name.
328
328
  *
329
329
  * @example "UserModel"
330
330
  */
331
- readonly name?: string;
331
+ name?: string;
332
332
  /**
333
333
  * Placeholder name for the symbol to be replaced later with the final value.
334
334
  *
335
335
  * @example "_heyapi_31_"
336
336
  */
337
337
  readonly placeholder?: string;
338
- }
339
- interface ISymbolOut extends ISymbolIn {
340
- /**
341
- * Array of file names (without extensions) from which this symbol is re-exported.
342
- */
343
- readonly exportFrom: ReadonlyArray<string>;
344
- /**
345
- * Unique symbol ID.
346
- */
347
- readonly id: number;
348
- /**
349
- * Placeholder name for the symbol to be replaced later with the final value.
350
- *
351
- * @example "_heyapi_31_"
352
- */
353
- readonly placeholder: string;
354
- }
338
+ };
339
+ type ISymbolOut = Omit<ISymbolIn, 'id' | 'placeholder'> & Pick<Required<ISymbolIn>, 'id' | 'placeholder'>;
355
340
  interface ISymbolRegistry {
356
341
  /**
357
342
  * Get a symbol.
package/dist/index.d.ts CHANGED
@@ -143,11 +143,11 @@ interface IBinding {
143
143
  */
144
144
  type IFileSelector = ReadonlyArray<string>;
145
145
  type IFileIdentifier = number | IFileSelector;
146
- interface IFileIn {
146
+ type IFileIn = {
147
147
  /**
148
148
  * File extension, if any.
149
149
  */
150
- readonly extension?: string;
150
+ extension?: string;
151
151
  /**
152
152
  * Indicates whether the file is external, meaning it is not generated
153
153
  * as part of the project but is referenced (e.g., a module from
@@ -155,7 +155,7 @@ interface IFileIn {
155
155
  *
156
156
  * @example true
157
157
  */
158
- readonly external?: boolean;
158
+ external?: boolean;
159
159
  /**
160
160
  * Unique file ID. If one is not provided, it will be auto-generated.
161
161
  */
@@ -166,21 +166,21 @@ interface IFileIn {
166
166
  *
167
167
  * @example "UserModel"
168
168
  */
169
- readonly name?: string;
169
+ name?: string;
170
170
  /**
171
171
  * Absolute logical output path for the file.
172
172
  *
173
173
  * @example "/src/models/user.ts"
174
174
  */
175
- readonly path?: string;
175
+ path?: string;
176
176
  /**
177
177
  * Selector array used to select this file.
178
178
  *
179
179
  * @example ["foo", "bar"]
180
180
  */
181
181
  readonly selector?: IFileSelector;
182
- }
183
- interface IFileOut extends IFileIn {
182
+ };
183
+ type IFileOut = IFileIn & {
184
184
  /**
185
185
  * Unique file ID.
186
186
  */
@@ -206,7 +206,7 @@ interface IFileOut extends IFileIn {
206
206
  */
207
207
  imports: Array<number>;
208
208
  };
209
- }
209
+ };
210
210
  interface IFileRegistry {
211
211
  /**
212
212
  * Get a file.
@@ -278,32 +278,32 @@ interface ISymbolMeta {
278
278
  //#endregion
279
279
  //#region src/symbols/types.d.ts
280
280
  type ISymbolIdentifier = number | ISymbolMeta;
281
- interface ISymbolIn {
281
+ type ISymbolIn = {
282
282
  /**
283
283
  * Array of file names (without extensions) from which this symbol is re-exported.
284
284
  *
285
285
  * @default undefined
286
286
  */
287
- readonly exportFrom?: ReadonlyArray<string>;
287
+ exportFrom?: ReadonlyArray<string>;
288
288
  /**
289
289
  * Whether this symbol is exported from its own file.
290
290
  *
291
291
  * @default false
292
292
  */
293
- readonly exported?: boolean;
293
+ exported?: boolean;
294
294
  /**
295
295
  * External module name if this symbol is imported from a module not managed
296
296
  * by the project (e.g. "zod", "lodash").
297
297
  *
298
298
  * @default undefined
299
299
  */
300
- readonly external?: string;
300
+ external?: string;
301
301
  /**
302
302
  * Optional output strategy to override default behavior.
303
303
  *
304
304
  * @returns The file path to output the symbol to, or undefined to fallback to default behavior.
305
305
  */
306
- readonly getFilePath?: (symbol: ISymbolOut) => string | undefined;
306
+ getFilePath?: (symbol: ISymbolOut) => string | undefined;
307
307
  /**
308
308
  * Unique symbol ID. If one is not provided, it will be auto-generated.
309
309
  */
@@ -311,47 +311,32 @@ interface ISymbolIn {
311
311
  /**
312
312
  * Kind of import if this symbol represents an import.
313
313
  */
314
- readonly importKind?: 'namespace' | 'default' | 'named';
314
+ importKind?: 'namespace' | 'default' | 'named';
315
315
  /**
316
316
  * Kind of symbol.
317
317
  */
318
- readonly kind?: 'type';
318
+ kind?: 'class' | 'function' | 'type';
319
319
  /**
320
320
  * Arbitrary metadata about the symbol.
321
321
  *
322
322
  * @default undefined
323
323
  */
324
- readonly meta?: ISymbolMeta;
324
+ meta?: ISymbolMeta;
325
325
  /**
326
326
  * The desired name for the symbol within its file. If there are multiple symbols
327
327
  * with the same desired name, this might not end up being the actual name.
328
328
  *
329
329
  * @example "UserModel"
330
330
  */
331
- readonly name?: string;
331
+ name?: string;
332
332
  /**
333
333
  * Placeholder name for the symbol to be replaced later with the final value.
334
334
  *
335
335
  * @example "_heyapi_31_"
336
336
  */
337
337
  readonly placeholder?: string;
338
- }
339
- interface ISymbolOut extends ISymbolIn {
340
- /**
341
- * Array of file names (without extensions) from which this symbol is re-exported.
342
- */
343
- readonly exportFrom: ReadonlyArray<string>;
344
- /**
345
- * Unique symbol ID.
346
- */
347
- readonly id: number;
348
- /**
349
- * Placeholder name for the symbol to be replaced later with the final value.
350
- *
351
- * @example "_heyapi_31_"
352
- */
353
- readonly placeholder: string;
354
- }
338
+ };
339
+ type ISymbolOut = Omit<ISymbolIn, 'id' | 'placeholder'> & Pick<Required<ISymbolIn>, 'id' | 'placeholder'>;
355
340
  interface ISymbolRegistry {
356
341
  /**
357
342
  * Get a symbol.
package/dist/index.js CHANGED
@@ -1,2 +1,2 @@
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.importKind&&(n.importKind===`default`?(o.defaultBinding=n.placeholder,n.kind===`type`&&(o.typeDefaultBinding=!0)):n.importKind===`namespace`&&(o.namespaceBinding=n.placeholder,n.kind===`type`&&(o.typeNamespaceBinding=!0))),n.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.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.identifierToFile(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++}identifierToFile(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.identifierToFile(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;indices=new Map;nodes=new Map;queryCache=new Map;queryCacheDependencies=new Map;registerOrder=new Set;stubCache=new Map;stubs=new Set;values=new Map;get(e){return typeof e==`number`?this.values.get(e):this.query(e)[0]}getValue(e){return this.nodes.get(e)}hasValue(e){return this.nodes.has(e)}get id(){return this._id++}isRegistered(e){let t=this.get(e);return t?this.registerOrder.has(t.id):!1}query(e){let t=this.buildCacheKey(e),n=this.queryCache.get(t);if(n)return n.map(e=>this.values.get(e));let r=[],i=this.buildIndexKeySpace(e),a=new Set,o=!1;for(let e of i){a.add(this.serializeIndexEntry(e));let t=this.indices.get(e[0]);if(!t){o=!0;break}let n=t.get(e[1]);if(!n){o=!0;break}r.push(n)}if(o||!r.length)return this.queryCacheDependencies.set(t,a),this.queryCache.set(t,[]),[];let s=new Set(r[0]);for(let e of r.slice(1))s=new Set([...s].filter(t=>e.has(t)));let c=[...s];return this.queryCacheDependencies.set(t,a),this.queryCache.set(t,c),c.map(e=>this.values.get(e))}reference(e){let[t]=this.query(e);if(t)return t;let n=this.buildCacheKey(e),r=this.stubCache.get(n);if(r!==void 0)return this.values.get(r);let i=this.id,o={exportFrom:[],id:i,meta:e,placeholder:a(String(i))};return this.values.set(o.id,o),this.stubs.add(o.id),this.stubCache.set(n,o.id),o}register(e){let t=e.id===void 0?this.id:e.id,n={...e,exportFrom:e.exportFrom??[],id:t,placeholder:e.placeholder??a(String(t))};if(this.values.set(n.id,n),this.registerOrder.add(n.id),n.meta){let e=this.buildIndexKeySpace(n.meta);this.indexSymbol(n.id,e),this.invalidateCache(e),this.replaceStubs(n,e)}return n}*registered(){for(let e of this.registerOrder.values())yield this.values.get(e)}setValue(e,t){return this.nodes.set(e,t)}buildCacheKey(e){return this.buildIndexKeySpace(e).map(e=>this.serializeIndexEntry(e)).sort().join(`|`)}buildIndexKeySpace(e,t=``){let n=[];for(let[r,i]of Object.entries(e)){let e=t?`${t}.${r}`:r;i&&typeof i==`object`&&!Array.isArray(i)?n.push(...this.buildIndexKeySpace(i,e)):n.push([e,i])}return n}indexSymbol(e,t){for(let[n,r]of t){this.indices.has(n)||this.indices.set(n,new Map);let t=this.indices.get(n),i=t.get(r)??new Set;i.add(e),t.set(r,i)}}invalidateCache(e){let t=e.map(e=>this.serializeIndexEntry(e));for(let[e,n]of this.queryCacheDependencies.entries())for(let r of t)if(n.has(r)){this.queryCacheDependencies.delete(e),this.queryCache.delete(e);break}}isSubset(e,t){let n=new Map(t);for(let[t,r]of e)if(!n.has(t)||n.get(t)!==r)return!1;return!0}replaceStubs(e,t){for(let n of this.stubs.values()){let r=this.values.get(n);if(r?.meta&&this.isSubset(this.buildIndexKeySpace(r.meta),t)){let t=this.buildCacheKey(r.meta);this.stubCache.delete(t),this.values.set(n,Object.assign(r,e)),this.stubs.delete(n)}}}serializeIndexEntry(e){return`${e[0]}:${JSON.stringify(e[1])}`}},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};
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.importKind&&(n.importKind===`default`?(o.defaultBinding=n.placeholder,n.kind===`type`&&(o.typeDefaultBinding=!0)):n.importKind===`namespace`&&(o.namespaceBinding=n.placeholder,n.kind===`type`&&(o.typeNamespaceBinding=!0))),n.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.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.identifierToFile(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++}identifierToFile(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.identifierToFile(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;indices=new Map;nodes=new Map;queryCache=new Map;queryCacheDependencies=new Map;registerOrder=new Set;stubCache=new Map;stubs=new Set;values=new Map;get(e){return typeof e==`number`?this.values.get(e):this.query(e)[0]}getValue(e){return this.nodes.get(e)}hasValue(e){return this.nodes.has(e)}get id(){return this._id++}isRegistered(e){let t=this.get(e);return t?this.registerOrder.has(t.id):!1}query(e){let t=this.buildCacheKey(e),n=this.queryCache.get(t);if(n)return n.map(e=>this.values.get(e));let r=[],i=this.buildIndexKeySpace(e),a=new Set,o=!1;for(let e of i){a.add(this.serializeIndexEntry(e));let t=this.indices.get(e[0]);if(!t){o=!0;break}let n=t.get(e[1]);if(!n){o=!0;break}r.push(n)}if(o||!r.length)return this.queryCacheDependencies.set(t,a),this.queryCache.set(t,[]),[];let s=new Set(r[0]);for(let e of r.slice(1))s=new Set([...s].filter(t=>e.has(t)));let c=[...s];return this.queryCacheDependencies.set(t,a),this.queryCache.set(t,c),c.map(e=>this.values.get(e))}reference(e){let[t]=this.query(e);if(t)return t;let n=this.buildCacheKey(e),r=this.stubCache.get(n);if(r!==void 0)return this.values.get(r);let i=this.id,o={id:i,meta:e,placeholder:a(String(i))};return this.values.set(o.id,o),this.stubs.add(o.id),this.stubCache.set(n,o.id),o}register(e){let t=e.id===void 0?this.id:e.id,n={...e,id:t,placeholder:e.placeholder??a(String(t))};if(this.values.set(n.id,n),this.registerOrder.add(n.id),n.meta){let e=this.buildIndexKeySpace(n.meta);this.indexSymbol(n.id,e),this.invalidateCache(e),this.replaceStubs(n,e)}return n}*registered(){for(let e of this.registerOrder.values())yield this.values.get(e)}setValue(e,t){return this.nodes.set(e,t)}buildCacheKey(e){return this.buildIndexKeySpace(e).map(e=>this.serializeIndexEntry(e)).sort().join(`|`)}buildIndexKeySpace(e,t=``){let n=[];for(let[r,i]of Object.entries(e)){let e=t?`${t}.${r}`:r;i&&typeof i==`object`&&!Array.isArray(i)?n.push(...this.buildIndexKeySpace(i,e)):n.push([e,i])}return n}indexSymbol(e,t){for(let[n,r]of t){this.indices.has(n)||this.indices.set(n,new Map);let t=this.indices.get(n),i=t.get(r)??new Set;i.add(e),t.set(r,i)}}invalidateCache(e){let t=e.map(e=>this.serializeIndexEntry(e));for(let[e,n]of this.queryCacheDependencies.entries())for(let r of t)if(n.has(r)){this.queryCacheDependencies.delete(e),this.queryCache.delete(e);break}}isSubset(e,t){let n=new Map(t);for(let[t,r]of e)if(!n.has(t)||n.get(t)!==r)return!1;return!0}replaceStubs(e,t){for(let n of this.stubs.values()){let r=this.values.get(n);if(r?.meta&&this.isSubset(this.buildIndexKeySpace(r.meta),t)){let t=this.buildCacheKey(r.meta);this.stubCache.delete(t),this.values.set(n,Object.assign(r,e)),this.stubs.delete(n)}}}serializeIndexEntry(e){return`${e[0]}:${JSON.stringify(e[1])}`}},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;if(r.add(n.id),this.symbolIdToFileIds.set(e.id,r),e.exportFrom)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};
2
2
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
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","sets: Array<Set<SymbolId>>","stub: ISymbolOut","result: ISymbolOut","entries: Array<IndexEntry>","path","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.importKind) {\n if (symbol.importKind === 'default') {\n binding.defaultBinding = symbol.placeholder;\n if (symbol.kind === 'type') {\n binding.typeDefaultBinding = true;\n }\n } else if (symbol.importKind === 'namespace') {\n binding.namespaceBinding = symbol.placeholder;\n if (symbol.kind === 'type') {\n binding.typeNamespaceBinding = true;\n }\n }\n }\n // default to named binding\n if (\n symbol.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.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 {\n IFileIdentifier,\n IFileIn,\n IFileOut,\n IFileRegistry,\n} 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(identifier: IFileIdentifier): IFileOut | undefined {\n const file = this.identifierToFile(identifier);\n\n if (file.id !== undefined) {\n return this.values.get(file.id);\n }\n\n const selector =\n file.selector !== undefined ? JSON.stringify(file.selector) : 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 identifierToFile(\n identifier: IFileIdentifier,\n ): Pick<IFileIn, 'id' | 'selector'> {\n return typeof identifier === 'number'\n ? { id: identifier }\n : { selector: identifier };\n }\n\n isRegistered(identifier: IFileIdentifier): boolean {\n const file = this.get(identifier);\n return file ? this.registerOrder.has(file.id) : false;\n }\n\n reference(identifier: IFileIdentifier): IFileOut {\n const file = this.identifierToFile(identifier);\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 type { ISymbolMeta } from '../extensions/types';\nimport { wrapId } from '../renderer/utils';\nimport type {\n ISymbolIdentifier,\n ISymbolIn,\n ISymbolOut,\n ISymbolRegistry,\n} from './types';\n\ntype IndexEntry = [string, unknown];\ntype IndexKeySpace = ReadonlyArray<IndexEntry>;\ntype QueryCacheKey = string;\ntype SymbolId = number;\n\nexport class SymbolRegistry implements ISymbolRegistry {\n private _id: SymbolId = 0;\n private indices: Map<IndexEntry[0], Map<IndexEntry[1], Set<SymbolId>>> =\n new Map();\n private nodes: Map<SymbolId, unknown> = new Map();\n private queryCache: Map<QueryCacheKey, ReadonlyArray<SymbolId>> = new Map();\n private queryCacheDependencies: Map<QueryCacheKey, Set<QueryCacheKey>> =\n new Map();\n private registerOrder: Set<SymbolId> = new Set();\n private stubCache: Map<QueryCacheKey, SymbolId> = new Map();\n private stubs: Set<SymbolId> = new Set();\n private values: Map<SymbolId, ISymbolOut> = new Map();\n\n get(identifier: ISymbolIdentifier): ISymbolOut | undefined {\n return typeof identifier === 'number'\n ? this.values.get(identifier)\n : this.query(identifier)[0];\n }\n\n getValue(symbolId: SymbolId): unknown {\n return this.nodes.get(symbolId);\n }\n\n hasValue(symbolId: SymbolId): boolean {\n return this.nodes.has(symbolId);\n }\n\n get id(): SymbolId {\n return this._id++;\n }\n\n isRegistered(identifier: ISymbolIdentifier): boolean {\n const symbol = this.get(identifier);\n return symbol ? this.registerOrder.has(symbol.id) : false;\n }\n\n query(filter: ISymbolMeta): ReadonlyArray<ISymbolOut> {\n const cacheKey = this.buildCacheKey(filter);\n const cachedIds = this.queryCache.get(cacheKey);\n if (cachedIds) {\n return cachedIds.map((symbolId) => this.values.get(symbolId)!);\n }\n const sets: Array<Set<SymbolId>> = [];\n const indexKeySpace = this.buildIndexKeySpace(filter);\n const cacheDependencies = new Set<QueryCacheKey>();\n let missed = false;\n for (const indexEntry of indexKeySpace) {\n cacheDependencies.add(this.serializeIndexEntry(indexEntry));\n const values = this.indices.get(indexEntry[0]);\n if (!values) {\n missed = true;\n break;\n }\n const set = values.get(indexEntry[1]);\n if (!set) {\n missed = true;\n break;\n }\n sets.push(set);\n }\n if (missed || !sets.length) {\n this.queryCacheDependencies.set(cacheKey, cacheDependencies);\n this.queryCache.set(cacheKey, []);\n return [];\n }\n let result = new Set(sets[0]);\n for (const set of sets.slice(1)) {\n result = new Set([...result].filter((symbolId) => set.has(symbolId)));\n }\n const resultIds = [...result];\n this.queryCacheDependencies.set(cacheKey, cacheDependencies);\n this.queryCache.set(cacheKey, resultIds);\n return resultIds.map((symbolId) => this.values.get(symbolId)!);\n }\n\n reference(meta: ISymbolMeta): ISymbolOut {\n const [registered] = this.query(meta);\n if (registered) return registered;\n const cacheKey = this.buildCacheKey(meta);\n const cachedId = this.stubCache.get(cacheKey);\n if (cachedId !== undefined) return this.values.get(cachedId)!;\n const id = this.id;\n const stub: ISymbolOut = {\n exportFrom: [],\n id,\n meta,\n placeholder: wrapId(String(id)),\n };\n this.values.set(stub.id, stub);\n this.stubs.add(stub.id);\n this.stubCache.set(cacheKey, stub.id);\n return stub;\n }\n\n register(symbol: ISymbolIn): ISymbolOut {\n const id = symbol.id !== undefined ? symbol.id : this.id;\n const result: ISymbolOut = {\n ...symbol, // clone to avoid mutation\n exportFrom: symbol.exportFrom ?? [],\n id,\n placeholder: symbol.placeholder ?? wrapId(String(id)),\n };\n this.values.set(result.id, result);\n this.registerOrder.add(result.id);\n if (result.meta) {\n const indexKeySpace = this.buildIndexKeySpace(result.meta);\n this.indexSymbol(result.id, indexKeySpace);\n this.invalidateCache(indexKeySpace);\n this.replaceStubs(result, indexKeySpace);\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: SymbolId, value: unknown): Map<SymbolId, unknown> {\n return this.nodes.set(symbolId, value);\n }\n\n private buildCacheKey(filter: ISymbolMeta): QueryCacheKey {\n const indexKeySpace = this.buildIndexKeySpace(filter);\n return indexKeySpace\n .map((indexEntry) => this.serializeIndexEntry(indexEntry))\n .sort() // ensure order-insensitivity\n .join('|');\n }\n\n private buildIndexKeySpace(meta: ISymbolMeta, prefix = ''): IndexKeySpace {\n const entries: Array<IndexEntry> = [];\n for (const [key, value] of Object.entries(meta)) {\n const path = prefix ? `${prefix}.${key}` : key;\n if (value && typeof value === 'object' && !Array.isArray(value)) {\n entries.push(...this.buildIndexKeySpace(value as ISymbolMeta, path));\n } else {\n entries.push([path, value]);\n }\n }\n return entries;\n }\n\n private indexSymbol(symbolId: SymbolId, indexKeySpace: IndexKeySpace): void {\n for (const [key, value] of indexKeySpace) {\n if (!this.indices.has(key)) this.indices.set(key, new Map());\n const values = this.indices.get(key)!;\n const set = values.get(value) ?? new Set();\n set.add(symbolId);\n values.set(value, set);\n }\n }\n\n private invalidateCache(indexKeySpace: IndexKeySpace): void {\n const changed = indexKeySpace.map((indexEntry) =>\n this.serializeIndexEntry(indexEntry),\n );\n for (const [\n cacheKey,\n cacheDependencies,\n ] of this.queryCacheDependencies.entries()) {\n for (const key of changed) {\n if (cacheDependencies.has(key)) {\n this.queryCacheDependencies.delete(cacheKey);\n this.queryCache.delete(cacheKey);\n break;\n }\n }\n }\n }\n\n private isSubset(sub: IndexKeySpace, sup: IndexKeySpace): boolean {\n const supMap = new Map(sup);\n for (const [key, value] of sub) {\n if (!supMap.has(key) || supMap.get(key) !== value) {\n return false;\n }\n }\n return true;\n }\n\n private replaceStubs(symbol: ISymbolOut, indexKeySpace: IndexKeySpace): void {\n for (const stubId of this.stubs.values()) {\n const stub = this.values.get(stubId);\n if (\n stub?.meta &&\n this.isSubset(this.buildIndexKeySpace(stub.meta), indexKeySpace)\n ) {\n const cacheKey = this.buildCacheKey(stub.meta);\n this.stubCache.delete(cacheKey);\n this.values.set(stubId, Object.assign(stub, symbol));\n this.stubs.delete(stubId);\n }\n }\n }\n\n private serializeIndexEntry(indexEntry: IndexEntry): string {\n return `${indexEntry[0]}:${JSON.stringify(indexEntry[1])}`;\n }\n}\n","import path from 'node:path';\n\nimport type { IProjectRenderMeta } from '../extensions/types';\nimport { FileRegistry } from '../files/registry';\nimport type { IFileOut, IFileSelector } from '../files/types';\nimport type { IOutput } from '../output/types';\nimport type { IRenderer } from '../renderer/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): IFileSelector {\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":"yBAIA,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,aACL,EAAO,aAAe,WACxB,EAAQ,eAAiB,EAAO,YAC5B,EAAO,OAAS,SAClB,EAAQ,mBAAqB,KAEtB,EAAO,aAAe,cAC/B,EAAQ,iBAAmB,EAAO,YAC9B,EAAO,OAAS,SAClB,EAAQ,qBAAuB,MAMnC,EAAO,aAAe,SACrB,CAAC,EAAM,QAAU,CAAC,EAAQ,gBAAkB,CAAC,EAAQ,iBACtD,CACA,IAAI,EAAO,EAAO,YACZ,EAAmB,EAAK,cAAc,IAAI,EAAO,GAAG,CAC1D,GAAI,EAAkB,CACpB,IAAM,EAAyB,EAAW,cAAc,IAAI,EAAO,GAAG,CAClE,EACE,IAA2B,IAC7B,EAAO,EACP,EAAQ,QAAQ,GAAQ,GAEjB,EAAO,MAAQ,IAAqB,EAAO,OACpD,EAAO,EAAO,KACd,EAAQ,QAAQ,GAAQ,EAAO,aAGnC,EAAM,KAAK,EAAK,CACZ,EAAO,OAAS,QAClB,EAAU,KAAK,EAAK,CAKxB,IAAK,IAAM,KAAY,EAChB,EAAM,SAAS,EAAS,EAC3B,EAAM,KAAK,EAAS,CAKxB,MAFA,GAAQ,MAAQ,EAChB,EAAQ,UAAY,EACb,GAGI,GAAiB,EAAkB,IAA2B,CACzE,EAAO,QAAU,CAAE,GAAG,EAAO,QAAS,GAAG,EAAO,QAAS,CACrD,EAAO,iBAAmB,IAAA,KAC5B,EAAO,eAAiB,EAAO,gBAEjC,EAAO,MAA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,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,EAAmC,CAC9D,GAAI,EAAO,SACT,MAAO,CAAC,IAAsB,EAAO,SAAS,CAEhD,IAAM,EAAW,EAAO,cAAc,EAAO,CAI7C,OAHI,EACK,EAAS,MAAM,IAAI,CAErB,CAAC,KAAK,gBAAgB"}
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","sets: Array<Set<SymbolId>>","stub: ISymbolOut","result: ISymbolOut","entries: Array<IndexEntry>","path","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.importKind) {\n if (symbol.importKind === 'default') {\n binding.defaultBinding = symbol.placeholder;\n if (symbol.kind === 'type') {\n binding.typeDefaultBinding = true;\n }\n } else if (symbol.importKind === 'namespace') {\n binding.namespaceBinding = symbol.placeholder;\n if (symbol.kind === 'type') {\n binding.typeNamespaceBinding = true;\n }\n }\n }\n // default to named binding\n if (\n symbol.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.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 {\n IFileIdentifier,\n IFileIn,\n IFileOut,\n IFileRegistry,\n} 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(identifier: IFileIdentifier): IFileOut | undefined {\n const file = this.identifierToFile(identifier);\n\n if (file.id !== undefined) {\n return this.values.get(file.id);\n }\n\n const selector =\n file.selector !== undefined ? JSON.stringify(file.selector) : 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 identifierToFile(\n identifier: IFileIdentifier,\n ): Pick<IFileIn, 'id' | 'selector'> {\n return typeof identifier === 'number'\n ? { id: identifier }\n : { selector: identifier };\n }\n\n isRegistered(identifier: IFileIdentifier): boolean {\n const file = this.get(identifier);\n return file ? this.registerOrder.has(file.id) : false;\n }\n\n reference(identifier: IFileIdentifier): IFileOut {\n const file = this.identifierToFile(identifier);\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 type { ISymbolMeta } from '../extensions/types';\nimport { wrapId } from '../renderer/utils';\nimport type {\n ISymbolIdentifier,\n ISymbolIn,\n ISymbolOut,\n ISymbolRegistry,\n} from './types';\n\ntype IndexEntry = [string, unknown];\ntype IndexKeySpace = ReadonlyArray<IndexEntry>;\ntype QueryCacheKey = string;\ntype SymbolId = number;\n\nexport class SymbolRegistry implements ISymbolRegistry {\n private _id: SymbolId = 0;\n private indices: Map<IndexEntry[0], Map<IndexEntry[1], Set<SymbolId>>> =\n new Map();\n private nodes: Map<SymbolId, unknown> = new Map();\n private queryCache: Map<QueryCacheKey, ReadonlyArray<SymbolId>> = new Map();\n private queryCacheDependencies: Map<QueryCacheKey, Set<QueryCacheKey>> =\n new Map();\n private registerOrder: Set<SymbolId> = new Set();\n private stubCache: Map<QueryCacheKey, SymbolId> = new Map();\n private stubs: Set<SymbolId> = new Set();\n private values: Map<SymbolId, ISymbolOut> = new Map();\n\n get(identifier: ISymbolIdentifier): ISymbolOut | undefined {\n return typeof identifier === 'number'\n ? this.values.get(identifier)\n : this.query(identifier)[0];\n }\n\n getValue(symbolId: SymbolId): unknown {\n return this.nodes.get(symbolId);\n }\n\n hasValue(symbolId: SymbolId): boolean {\n return this.nodes.has(symbolId);\n }\n\n get id(): SymbolId {\n return this._id++;\n }\n\n isRegistered(identifier: ISymbolIdentifier): boolean {\n const symbol = this.get(identifier);\n return symbol ? this.registerOrder.has(symbol.id) : false;\n }\n\n query(filter: ISymbolMeta): ReadonlyArray<ISymbolOut> {\n const cacheKey = this.buildCacheKey(filter);\n const cachedIds = this.queryCache.get(cacheKey);\n if (cachedIds) {\n return cachedIds.map((symbolId) => this.values.get(symbolId)!);\n }\n const sets: Array<Set<SymbolId>> = [];\n const indexKeySpace = this.buildIndexKeySpace(filter);\n const cacheDependencies = new Set<QueryCacheKey>();\n let missed = false;\n for (const indexEntry of indexKeySpace) {\n cacheDependencies.add(this.serializeIndexEntry(indexEntry));\n const values = this.indices.get(indexEntry[0]);\n if (!values) {\n missed = true;\n break;\n }\n const set = values.get(indexEntry[1]);\n if (!set) {\n missed = true;\n break;\n }\n sets.push(set);\n }\n if (missed || !sets.length) {\n this.queryCacheDependencies.set(cacheKey, cacheDependencies);\n this.queryCache.set(cacheKey, []);\n return [];\n }\n let result = new Set(sets[0]);\n for (const set of sets.slice(1)) {\n result = new Set([...result].filter((symbolId) => set.has(symbolId)));\n }\n const resultIds = [...result];\n this.queryCacheDependencies.set(cacheKey, cacheDependencies);\n this.queryCache.set(cacheKey, resultIds);\n return resultIds.map((symbolId) => this.values.get(symbolId)!);\n }\n\n reference(meta: ISymbolMeta): ISymbolOut {\n const [registered] = this.query(meta);\n if (registered) return registered;\n const cacheKey = this.buildCacheKey(meta);\n const cachedId = this.stubCache.get(cacheKey);\n if (cachedId !== undefined) return this.values.get(cachedId)!;\n const id = this.id;\n const stub: ISymbolOut = {\n id,\n meta,\n placeholder: wrapId(String(id)),\n };\n this.values.set(stub.id, stub);\n this.stubs.add(stub.id);\n this.stubCache.set(cacheKey, stub.id);\n return stub;\n }\n\n register(symbol: ISymbolIn): ISymbolOut {\n const id = symbol.id !== undefined ? symbol.id : this.id;\n const result: ISymbolOut = {\n ...symbol, // clone to avoid mutation\n id,\n placeholder: symbol.placeholder ?? wrapId(String(id)),\n };\n this.values.set(result.id, result);\n this.registerOrder.add(result.id);\n if (result.meta) {\n const indexKeySpace = this.buildIndexKeySpace(result.meta);\n this.indexSymbol(result.id, indexKeySpace);\n this.invalidateCache(indexKeySpace);\n this.replaceStubs(result, indexKeySpace);\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: SymbolId, value: unknown): Map<SymbolId, unknown> {\n return this.nodes.set(symbolId, value);\n }\n\n private buildCacheKey(filter: ISymbolMeta): QueryCacheKey {\n const indexKeySpace = this.buildIndexKeySpace(filter);\n return indexKeySpace\n .map((indexEntry) => this.serializeIndexEntry(indexEntry))\n .sort() // ensure order-insensitivity\n .join('|');\n }\n\n private buildIndexKeySpace(meta: ISymbolMeta, prefix = ''): IndexKeySpace {\n const entries: Array<IndexEntry> = [];\n for (const [key, value] of Object.entries(meta)) {\n const path = prefix ? `${prefix}.${key}` : key;\n if (value && typeof value === 'object' && !Array.isArray(value)) {\n entries.push(...this.buildIndexKeySpace(value as ISymbolMeta, path));\n } else {\n entries.push([path, value]);\n }\n }\n return entries;\n }\n\n private indexSymbol(symbolId: SymbolId, indexKeySpace: IndexKeySpace): void {\n for (const [key, value] of indexKeySpace) {\n if (!this.indices.has(key)) this.indices.set(key, new Map());\n const values = this.indices.get(key)!;\n const set = values.get(value) ?? new Set();\n set.add(symbolId);\n values.set(value, set);\n }\n }\n\n private invalidateCache(indexKeySpace: IndexKeySpace): void {\n const changed = indexKeySpace.map((indexEntry) =>\n this.serializeIndexEntry(indexEntry),\n );\n for (const [\n cacheKey,\n cacheDependencies,\n ] of this.queryCacheDependencies.entries()) {\n for (const key of changed) {\n if (cacheDependencies.has(key)) {\n this.queryCacheDependencies.delete(cacheKey);\n this.queryCache.delete(cacheKey);\n break;\n }\n }\n }\n }\n\n private isSubset(sub: IndexKeySpace, sup: IndexKeySpace): boolean {\n const supMap = new Map(sup);\n for (const [key, value] of sub) {\n if (!supMap.has(key) || supMap.get(key) !== value) {\n return false;\n }\n }\n return true;\n }\n\n private replaceStubs(symbol: ISymbolOut, indexKeySpace: IndexKeySpace): void {\n for (const stubId of this.stubs.values()) {\n const stub = this.values.get(stubId);\n if (\n stub?.meta &&\n this.isSubset(this.buildIndexKeySpace(stub.meta), indexKeySpace)\n ) {\n const cacheKey = this.buildCacheKey(stub.meta);\n this.stubCache.delete(cacheKey);\n this.values.set(stubId, Object.assign(stub, symbol));\n this.stubs.delete(stubId);\n }\n }\n }\n\n private serializeIndexEntry(indexEntry: IndexEntry): string {\n return `${indexEntry[0]}:${JSON.stringify(indexEntry[1])}`;\n }\n}\n","import path from 'node:path';\n\nimport type { IProjectRenderMeta } from '../extensions/types';\nimport { FileRegistry } from '../files/registry';\nimport type { IFileOut, IFileSelector } from '../files/types';\nimport type { IOutput } from '../output/types';\nimport type { IRenderer } from '../renderer/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 if (symbol.exportFrom) {\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 }\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): IFileSelector {\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":"yBAIA,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,aACL,EAAO,aAAe,WACxB,EAAQ,eAAiB,EAAO,YAC5B,EAAO,OAAS,SAClB,EAAQ,mBAAqB,KAEtB,EAAO,aAAe,cAC/B,EAAQ,iBAAmB,EAAO,YAC9B,EAAO,OAAS,SAClB,EAAQ,qBAAuB,MAMnC,EAAO,aAAe,SACrB,CAAC,EAAM,QAAU,CAAC,EAAQ,gBAAkB,CAAC,EAAQ,iBACtD,CACA,IAAI,EAAO,EAAO,YACZ,EAAmB,EAAK,cAAc,IAAI,EAAO,GAAG,CAC1D,GAAI,EAAkB,CACpB,IAAM,EAAyB,EAAW,cAAc,IAAI,EAAO,GAAG,CAClE,EACE,IAA2B,IAC7B,EAAO,EACP,EAAQ,QAAQ,GAAQ,GAEjB,EAAO,MAAQ,IAAqB,EAAO,OACpD,EAAO,EAAO,KACd,EAAQ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api/codegen-core",
3
- "version": "0.3.2",
3
+ "version": "0.3.3",
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": {