@hey-api/codegen-core 0.4.0 → 0.5.0
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/README.md +3 -123
- package/dist/index.cjs +2 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +205 -55
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.mts +205 -55
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +2 -1
- package/dist/index.mjs.map +1 -1
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
<div align="center">
|
|
2
|
-
<img alt="Three people building a brick structure" height="214" src="https://heyapi.dev/images/bricks-640w.png" width="320">
|
|
3
2
|
<h1 align="center"><b>Codegen Core</b></h1>
|
|
4
|
-
<p align="center">🧱 TypeScript framework for generating
|
|
3
|
+
<p align="center">🧱 TypeScript framework for generating files.</p>
|
|
5
4
|
</div>
|
|
6
5
|
|
|
7
6
|
<br/>
|
|
@@ -11,128 +10,9 @@
|
|
|
11
10
|
<a href="https://github.com/hey-api/openapi-ts/actions?query=branch%3Amain"><img src="https://github.com/hey-api/openapi-ts/actions/workflows/ci.yml/badge.svg?event=push&branch=main" alt="CI status" /></a>
|
|
12
11
|
</p>
|
|
13
12
|
|
|
14
|
-
|
|
15
|
-
<a href="https://github.com/hey-api/openapi-ts/issues">Issues</a>
|
|
16
|
-
<span> • </span>
|
|
17
|
-
<a href="https://heyapi.dev/openapi-ts/community/contributing">Contribute</a>
|
|
18
|
-
</p>
|
|
19
|
-
|
|
20
|
-
<br/>
|
|
21
|
-
|
|
22
|
-
## Dashboard
|
|
23
|
-
|
|
24
|
-
Access your projects and OpenAPI specifications in the [Hey API Platform](https://app.heyapi.dev/).
|
|
25
|
-
|
|
26
|
-
## Contributing
|
|
27
|
-
|
|
28
|
-
Want to see your code in products used by millions?
|
|
29
|
-
|
|
30
|
-
Start with our [Contributing](https://heyapi.dev/openapi-ts/community/contributing) guide and release your first feature.
|
|
31
|
-
|
|
32
|
-
## Sponsors
|
|
33
|
-
|
|
34
|
-
Help Hey API stay around for the long haul by becoming a [sponsor](https://github.com/sponsors/hey-api).
|
|
35
|
-
|
|
36
|
-
<h3 align="center">Gold</h3>
|
|
37
|
-
|
|
38
|
-
<table align="center" style="justify-content: center;align-items: center;display: flex;">
|
|
39
|
-
<tbody>
|
|
40
|
-
<tr>
|
|
41
|
-
<td align="center">
|
|
42
|
-
<p></p>
|
|
43
|
-
<p>
|
|
44
|
-
<a href="https://kutt.it/pkEZyc" target="_blank">
|
|
45
|
-
<picture height="50px">
|
|
46
|
-
<source media="(prefers-color-scheme: dark)" srcset="https://heyapi.dev/images/stainless-logo-wordmark-480w.jpeg">
|
|
47
|
-
<img alt="Stainless logo" height="50px" src="https://heyapi.dev/images/stainless-logo-wordmark-480w.jpeg">
|
|
48
|
-
</picture>
|
|
49
|
-
</a>
|
|
50
|
-
<br/>
|
|
51
|
-
Best-in-class developer interfaces for your API.
|
|
52
|
-
<br/>
|
|
53
|
-
<a href="https://kutt.it/pkEZyc" style="text-decoration:none;" target="_blank">
|
|
54
|
-
stainless.com
|
|
55
|
-
</a>
|
|
56
|
-
</p>
|
|
57
|
-
<p></p>
|
|
58
|
-
</td>
|
|
59
|
-
<td align="center">
|
|
60
|
-
<p></p>
|
|
61
|
-
<p>
|
|
62
|
-
<a href="https://kutt.it/QM9Q2N" target="_blank">
|
|
63
|
-
<picture height="50px">
|
|
64
|
-
<img alt="Opencode logo" height="50px" src="https://heyapi.dev/opencode-logo-wordmark.svg">
|
|
65
|
-
</picture>
|
|
66
|
-
</a>
|
|
67
|
-
<br/>
|
|
68
|
-
The open source coding agent.
|
|
69
|
-
<br/>
|
|
70
|
-
<a href="https://kutt.it/QM9Q2N" style="text-decoration:none;" target="_blank">
|
|
71
|
-
opencode.ai
|
|
72
|
-
</a>
|
|
73
|
-
</p>
|
|
74
|
-
<p></p>
|
|
75
|
-
</td>
|
|
76
|
-
</tr>
|
|
77
|
-
</tbody>
|
|
78
|
-
</table>
|
|
79
|
-
|
|
80
|
-
<h3 align="center">Silver</h3>
|
|
81
|
-
|
|
82
|
-
<table align="center" style="justify-content: center;align-items: center;display: flex;">
|
|
83
|
-
<tbody>
|
|
84
|
-
<tr>
|
|
85
|
-
<td align="center">
|
|
86
|
-
<a href="https://kutt.it/skQUVd" target="_blank">
|
|
87
|
-
<picture height="40px">
|
|
88
|
-
<source media="(prefers-color-scheme: dark)" srcset="https://heyapi.dev/images/scalar-logo-wordmark-480w.jpeg">
|
|
89
|
-
<img alt="Scalar logo" height="40px" src="https://heyapi.dev/scalar-logo-wordmark.svg">
|
|
90
|
-
</picture>
|
|
91
|
-
</a>
|
|
92
|
-
<br/>
|
|
93
|
-
<a href="https://kutt.it/skQUVd" style="text-decoration:none;" target="_blank">
|
|
94
|
-
scalar.com
|
|
95
|
-
</a>
|
|
96
|
-
</td>
|
|
97
|
-
<td align="center">
|
|
98
|
-
<a href="https://kutt.it/Dr9GuW" target="_blank">
|
|
99
|
-
<picture height="40px">
|
|
100
|
-
<img alt="FastAPI logo" height="40px" src="https://heyapi.dev/fastapi-logo-wordmark.svg">
|
|
101
|
-
</picture>
|
|
102
|
-
</a>
|
|
103
|
-
<br/>
|
|
104
|
-
<a href="https://kutt.it/Dr9GuW" style="text-decoration:none;" target="_blank">
|
|
105
|
-
fastapi.tiangolo.com
|
|
106
|
-
</a>
|
|
107
|
-
</td>
|
|
108
|
-
</tr>
|
|
109
|
-
</tbody>
|
|
110
|
-
</table>
|
|
111
|
-
|
|
112
|
-
<h3 align="center">Bronze</h3>
|
|
13
|
+
## Notice
|
|
113
14
|
|
|
114
|
-
|
|
115
|
-
<tbody>
|
|
116
|
-
<tr>
|
|
117
|
-
<td align="center">
|
|
118
|
-
<a href="https://kutt.it/YpaKsX" target="_blank">
|
|
119
|
-
<picture height="34px">
|
|
120
|
-
<source media="(prefers-color-scheme: dark)" srcset="https://heyapi.dev/images/kinde-logo-wordmark-dark-480w.webp">
|
|
121
|
-
<img alt="Kinde logo" height="34px" src="https://heyapi.dev/images/kinde-logo-wordmark-480w.jpeg">
|
|
122
|
-
</picture>
|
|
123
|
-
</a>
|
|
124
|
-
</td>
|
|
125
|
-
<td align="center">
|
|
126
|
-
<a href="https://kutt.it/KkqSaw" target="_blank">
|
|
127
|
-
<picture height="34px">
|
|
128
|
-
<source media="(prefers-color-scheme: dark)" srcset="https://heyapi.dev/images/cella-logo-wordmark-480w.webp">
|
|
129
|
-
<img alt="Cella logo" height="34px" src="https://heyapi.dev/cella-logo-wordmark.svg">
|
|
130
|
-
</picture>
|
|
131
|
-
</a>
|
|
132
|
-
</td>
|
|
133
|
-
</tr>
|
|
134
|
-
</tbody>
|
|
135
|
-
</table>
|
|
15
|
+
This is an internal framework. Visit [Hey API](https://heyapi.dev/) to discover our products.
|
|
136
16
|
|
|
137
17
|
## License
|
|
138
18
|
|
package/dist/index.cjs
CHANGED
|
@@ -1,2 +1,3 @@
|
|
|
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(`ansi-colors`);c=s(c);let l=require(`color-support`);l=s(l);let u=require(`node:path`);u=s(u);const d=`heyapi.file`,f=`heyapi.node`,p=`heyapi.symbol`;c.default.enabled=(0,l.default)().hasBasic;const m={analyzer:c.default.greenBright,dsl:c.default.cyanBright,file:c.default.yellowBright,registry:c.default.blueBright,symbol:c.default.magentaBright};function h(e,t){let n=process.env.DEBUG;if(!n)return;let r=n.split(`,`).map(e=>e.trim().toLowerCase());if(!(r.includes(`*`)||r.includes(`heyapi:*`)||r.includes(`heyapi:${t}`)||r.includes(t)))return;let i=(m[t]??c.default.whiteBright)(`heyapi:${t}`);console.debug(`${i} ${e}`)}var g=class{_exports=[];_extension;_finalPath;_imports=[];_language;_logicalFilePath;_name;_nodes=[];_renderer;"~brand"=`heyapi.file`;allNames=new Map;external;id;project;topLevelNames=new Map;constructor(e,t,n){this.external=e.external??!1,this.id=t,e.language!==void 0&&(this._language=e.language),this._logicalFilePath=e.logicalFilePath.split(u.default.sep).join(`/`),e.name!==void 0&&(this._name=e.name),this.project=n}get exports(){return[...this._exports]}get extension(){if(this._extension)return this._extension;let e=this.language,t=e?this.project.extensions[e]:void 0;if(t&&t[0])return t[0]}get finalPath(){return this._finalPath?this._finalPath:[...this._logicalFilePath?this._logicalFilePath.split(`/`).slice(0,-1):[],`${this.name}${this.extension??``}`].join(`/`)}get imports(){return[...this._imports]}get language(){if(this._language)return this._language;if(this._nodes[0])return this._nodes[0].language}get logicalFilePath(){return this._logicalFilePath}get name(){if(this._name)return this._name;let e=this._logicalFilePath.split(`/`).pop();if(e)return e;let t=`File ${this.toString()} has no name`;throw h(t,`file`),Error(t)}get nodes(){return[...this._nodes]}get renderer(){return this._renderer}addExport(e){this._exports.push(e)}addImport(e){this._imports.push(e)}addNode(e){this._nodes.push(e),e.file=this}setExtension(e){this._extension=e}setFinalPath(e){this._finalPath=e}setLanguage(e){this._language=e}setName(e){this._name=e}setRenderer(e){this._renderer=e}toString(){return`[File ${this._logicalFilePath}#${this.id}]`}};function _(e,t){return!e||typeof e!=`object`?!1:e[`~brand`]===t}function v(e){return!e||typeof e!=`object`?!1:_(e,f)}function y(e){return _(e[`~ref`],f)}function b(e){return _(e,p)}function x(e){return _(e[`~ref`],p)}const S={c:[`.c`],"c#":[`.cs`],"c++":[`.cpp`,`.hpp`],css:[`.css`],dart:[`.dart`],go:[`.go`],haskell:[`.hs`],html:[`.html`],java:[`.java`],javascript:[`.js`,`.jsx`],json:[`.json`],kotlin:[`.kt`],lua:[`.lua`],markdown:[`.md`],matlab:[`.m`],perl:[`.pl`],php:[`.php`],python:[`.py`],r:[`.r`],ruby:[`.rb`],rust:[`.rs`],scala:[`.scala`],shell:[`.sh`],sql:[`.sql`],swift:[`.swift`],typescript:[`.ts`,`.tsx`],yaml:[`.yaml`,`.yml`]},C=({attempt:e,baseName:t})=>e===0?t:`${t}${e+1}`,w=({attempt:e,baseName:t})=>e===0?t:`${t}_${e+1}`,T={php:w,python:w,ruby:w};var E=class{_id=0;_values=new Map;project;constructor(e){this.project=e}get(e){return this._values.get(this.createFileKey(e))}isRegistered(e){return this._values.has(this.createFileKey(e))}get nextId(){return this._id++}register(e){let t=this.createFileKey(e),n=this._values.get(t);return n?e.name&&n.setName(e.name):n=new g(e,this.nextId,this.project),this._values.set(t,n),n}*registered(){for(let e of this._values.values())yield e}createFileKey(e){let t=e.logicalFilePath.split(u.default.sep).join(`/`);return`${e.external?`ext:`:``}${t}${e.language?`:${e.language}`:``}`}};const D=e=>({"~ref":e}),O=e=>{let t={};for(let n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=D(e[n]));return t},k=e=>e?.[`~ref`],A=e=>{let t={};for(let n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=k(e[n]));return t},j=e=>typeof e==`object`&&!!e&&`~ref`in e;var M=class{list=[];add(e){return this.list.push(D(e))-1}*all(){for(let e of this.list){let t=k(e);t&&(yield t)}}remove(e){this.list[e]=D(null)}update(e,t){this.list[e]=D(t)}};function N(e,t){if(e===`interface`&&t===`interface`)return!0;if(e===`interface`&&t===`type`||e===`type`&&t===`interface`||e===`type`&&t===`type`)return!1;if(e===`interface`&&t===`class`||e===`class`&&t===`interface`||e===`enum`&&t===`namespace`||e===`namespace`&&t===`enum`||e===`class`&&t===`namespace`||e===`namespace`&&t===`class`||e===`namespace`&&t===`namespace`)return!0;if(e===`enum`&&t===`enum`)return!1;if(e===`function`&&t===`namespace`||e===`namespace`&&t===`function`)return!0;let n=new Set([`class`,`enum`,`function`,`var`]),r=n.has(e),i=n.has(t);if(r&&i)return!1;let a=new Set([`interface`,`type`]);return a.has(e),a.has(t),!0}const P=e=>({children:[],localNames:new Map,parent:e,symbols:[]});var F=class{scopes=P();symbol;scope=this.scopes;constructor(e){this.symbol=e}addDependency(e){this.symbol!==k(e)&&this.scope.symbols.push(e)}analyze(e){let t=j(e)?e:D(e);x(t)?this.addDependency(t):y(t)&&k(t).analyze(this)}localNames(e){let t=new Map;for(let[n,r]of e.localNames)t.set(n,new Set(r));if(e.parent){let n=this.localNames(e.parent);for(let[e,r]of n)if(!t.has(e))t.set(e,r);else{let n=t.get(e);for(let e of r)n.add(e)}}return t}popScope(){this.scope=this.scope.parent??this.scope}pushScope(){let e=P(this.scope);this.scope.children.push(e),this.scope=e}walkScopes(e,t=this.scopes){this.scope=t;for(let n of t.symbols)e(n,t);for(let n of t.children)t=n,this.walkScopes(e,t);this.scope=this.scopes}},I=class{nodeCache=new WeakMap;analyzeNode(e){let t=this.nodeCache.get(e);if(t)return t;let n=new F(e.symbol);return e.analyze(n),this.nodeCache.set(e,n),n}analyze(e,t){for(let n of e){let e=this.analyzeNode(n);t?.(e,n)}}};const L=e=>e===`type`||e===`interface`;var R=class{analyzer=new I;cacheResolvedNames=new Set;project;constructor(e){this.project=e}plan(e){this.cacheResolvedNames.clear(),this.allocateFiles(),this.assignLocalNames(),this.resolveFilePaths(e),this.planExports(),this.planImports()}allocateFiles(){this.analyzer.analyze(this.project.nodes.all(),(e,t)=>{let n=t.symbol;if(!n)return;let r=this.project.files.register(this.symbolToFileIn(n));r.addNode(t),n.setFile(r);for(let e of n.exportFrom)this.project.files.register({external:!1,language:r.language,logicalFilePath:e});e.walkScopes(e=>{let t=k(e);if(t.external&&t.isCanonical&&!t.file){let e=this.project.files.register(this.symbolToFileIn(t));t.setFile(e)}})})}assignLocalNames(){this.analyzer.analyze(this.project.nodes.all(),(e,t)=>{let n=t.symbol;n&&this.assignTopLevelName(n,e)}),this.analyzer.analyze(this.project.nodes.all(),(e,t)=>{let n=t.file;n&&e.walkScopes(t=>{let r=k(t);r.file||this.assignLocalName(r,e,{scopesToUpdate:[n.allNames]})})})}resolveFilePaths(e){for(let t of this.project.files.registered()){if(t.external)continue;let n=this.project.fileName?.(t.name)||t.name;t.setName(n);let r=t.finalPath;r&&t.setFinalPath(u.default.resolve(this.project.root,r));let i={file:t,meta:e,project:this.project},a=this.project.renderers.find(e=>e.supports(i));a&&t.setRenderer(a)}}planExports(){let e=new Map,t=new Map;this.analyzer.analyze(this.project.nodes.all(),(n,r)=>{if(!r.exported)return;let i=r.symbol;if(!i)return;let a=r.file;if(a)for(let o of i.exportFrom){let s=this.project.files.register({external:!1,language:r.language,logicalFilePath:o});if(s.id===a.id)continue;let c=e.get(s);c||(c=new Map,e.set(s,c));let l=this.project.symbols.register({exported:!0,external:i.external,importKind:i.importKind,kind:i.kind,name:i.finalName});l.setFile(s),t.set(l.id,a),this.assignTopLevelName(l,n);let u=c.get(l.finalName);u||(u={kinds:new Set,symbol:l},c.set(l.finalName,u)),u.kinds.add(l.kind)}});for(let[n,r]of e){let e=new Map;for(let[,n]of r){let r=t.get(n.symbol.id),i=e.get(r);i||={canExportAll:!0,exports:[],from:r,isTypeOnly:!0};let a=[...n.kinds].every(e=>L(e)),o=n.symbol.finalName;i.exports.push({exportedName:o,isTypeOnly:a,kind:n.symbol.importKind,sourceName:n.symbol.name}),n.symbol.name!==n.symbol.finalName&&(i.canExportAll=!1),a||(i.isTypeOnly=!1),e.set(r,i)}for(let[,t]of e)n.addExport(t)}}planImports(){let e=new Map;this.analyzer.analyze(this.project.nodes.all(),t=>{let n=t.symbol;if(!n)return;let r=n.file;if(!r)return;let i=e.get(r);i||(i=new Map,e.set(r,i)),t.walkScopes(e=>{let n=k(e);if(!n.file||n.file.id===r.id)return;n.external&&this.assignTopLevelName(n,t);let a=n.file.id,o=n.finalName,s=L(n.kind),c=`${a}|${o}|${n.importKind}|${s}`,l=i.get(c);if(!l){let e=this.project.symbols.register({exported:n.exported,external:n.external,importKind:n.importKind,kind:n.kind,name:n.finalName});e.setFile(r),this.assignTopLevelName(e,t,{scope:e.file.allNames}),l={dep:n,kinds:new Set,symbol:e},i.set(c,l),l.kinds.add(e.kind)}e[`~ref`]=l.symbol})});for(let[t,n]of e){let e=new Map;for(let[,t]of n){let n=t.dep.file,r=e.get(n);r||={from:n,imports:[],isTypeOnly:!0};let i=[...t.kinds].every(e=>L(e));t.symbol.importKind===`namespace`?(r.imports=[],r.namespaceImport=t.symbol.finalName):r.imports.push({isTypeOnly:i,kind:t.symbol.importKind,localName:t.symbol.finalName,sourceName:t.dep.finalName}),i||(r.isTypeOnly=!1),e.set(n,r)}for(let[,n]of e)t.addImport(n)}}assignTopLevelName(e,t,n){e.file&&this.assignSymbolName(e,{scope:n?.scope??e.file.topLevelNames,scopesToUpdate:[e.file.allNames,t.scopes.localNames,...n?.scopesToUpdate??[]]})}assignLocalName(e,t,n){this.assignSymbolName(e,{scope:n.scope??t.localNames(t.scope),scopesToUpdate:n.scopesToUpdate})}assignSymbolName(e,t){if(this.cacheResolvedNames.has(e.id))return;let n=e.name,r=e.nameSanitizer?.(n)??n,i=1;for(;![...t.scope.get(r)??[]].every(t=>N(e.kind,t));){let t=e.node?.language||e.file?.language,a=((t?this.project.nameConflictResolvers[t]:void 0)??this.project.defaultNameConflictResolver)({attempt:i,baseName:n});if(!a)throw Error(`Unresolvable name conflict: ${e.toString()}`);r=e.nameSanitizer?.(a)??a,i+=1}e.setFinalName(r),this.cacheResolvedNames.add(e.id);let a=[t.scope,...t.scopesToUpdate];for(let t of a)this.updateScope(e,t)}updateScope(e,t){let n=e.finalName,r=t.get(n)??new Set;r.add(e.kind),t.set(n,r)}symbolToFileIn(e){return{external:!!e.external,language:e.node?.language,logicalFilePath:e.external||e.getFilePath?.(e)||this.project.defaultFileName}}},z=class{_canonical;_exported;_exportFrom;_external;_file;_finalName;_getFilePath;_importKind;_kind;_meta;_name;_nameSanitizer;_node;"~brand"=p;id;constructor(e,t){this._exported=e.exported??!1,this._exportFrom=e.exportFrom??[],this._external=e.external,this._getFilePath=e.getFilePath,this.id=t,this._importKind=e.importKind??`named`,this._kind=e.kind??`var`,this._meta=e.meta,this._name=e.name}get canonical(){return this._canonical??this}get exported(){return this.canonical._exported}get exportFrom(){return this.canonical._exportFrom}get external(){return this.canonical._external}get file(){return this.canonical._file}get finalName(){if(!this.canonical._finalName){let e=`Symbol finalName has not been resolved yet for ${this.canonical.toString()}`;throw h(e,`symbol`),Error(e)}return this.canonical._finalName}get getFilePath(){return this.canonical._getFilePath}get importKind(){return this.canonical._importKind}get isCanonical(){return!this._canonical||this._canonical===this}get kind(){return this.canonical._kind}get meta(){return this.canonical._meta}get name(){return this.canonical._name}get nameSanitizer(){return this.canonical._nameSanitizer}get node(){return this.canonical._node}setCanonical(e){this._canonical=e}setExported(e){this.assertCanonical(),this._exported=e}setExportFrom(e){this.assertCanonical(),this._exportFrom=e}setFile(e){if(this.assertCanonical(),this._file&&this._file!==e){let e=`Symbol ${this.canonical.toString()} is already assigned to a different file.`;throw h(e,`symbol`),Error(e)}this._file=e}setFinalName(e){if(this.assertCanonical(),this._finalName&&this._finalName!==e){let e=`Symbol finalName has already been resolved for ${this.canonical.toString()}.`;throw h(e,`symbol`),Error(e)}this._finalName=e}setImportKind(e){this.assertCanonical(),this._importKind=e}setKind(e){this.assertCanonical(),this._kind=e}setName(e){this.assertCanonical(),this._name=e}setNameSanitizer(e){this.assertCanonical(),this._nameSanitizer=e}setNode(e){if(this.assertCanonical(),this._node&&this._node!==e){let e=`Symbol ${this.canonical.toString()} is already bound to a different node.`;throw h(e,`symbol`),Error(e)}this._node=e,e.symbol=this}toString(){return`[Symbol ${this.name}#${this.id}]`}assertCanonical(){if(this._canonical&&this._canonical!==this){let e=`Illegal mutation of stub symbol ${this.toString()} → canonical: ${this._canonical.toString()}`;throw h(e,`symbol`),Error(e)}}},B=class{_id=0;_indices=new Map;_queryCache=new Map;_queryCacheDependencies=new Map;_registered=new Set;_stubs=new Set;_stubCache=new Map;_values=new Map;get(e){return typeof e==`number`?this._values.get(e):this.query(e)[0]}isRegistered(e){let t=this.get(e);return t?this._registered.has(t.id):!1}get nextId(){return this._id++}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=new z({meta:e,name:``},this.nextId);return this._values.set(i.id,i),this._stubs.add(i.id),this._stubCache.set(n,i.id),i}register(e){let t=new z(e,this.nextId);if(this._values.set(t.id,t),this._registered.add(t.id),t.meta){let e=this.buildIndexKeySpace(t.meta);this.indexSymbol(t.id,e),this.invalidateCache(e),this.replaceStubs(t,e)}return t}*registered(){for(let e of this._registered.values())yield this._values.get(e)}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._stubs.delete(n),r.setCanonical(e)}}}serializeIndexEntry(e){return`${e[0]}:${JSON.stringify(e[1])}`}},V=class{files;nodes=new M;symbols=new B;defaultFileName;defaultNameConflictResolver;extensions;fileName;nameConflictResolvers;renderers;root;constructor(e){let t=e.fileName;this.defaultFileName=e.defaultFileName??`main`,this.defaultNameConflictResolver=e.defaultNameConflictResolver??C,this.extensions={...S,...e.extensions},this.fileName=typeof t==`string`?()=>t:t,this.files=new E(this),this.nameConflictResolvers={...T,...e.nameConflictResolvers},this.renderers=e.renderers??[],this.root=u.default.resolve(e.root).replace(/[/\\]+$/,``)}render(e){new R(this).plan(e);let t=[];for(let n of this.files.registered())if(n.finalPath&&n.renderer){let r=n.renderer.render({file:n,meta:e,project:this});t.push({content:r,path:n.finalPath})}return t}};exports.File=g,exports.Project=V,exports.Symbol=z,exports.debug=h,exports.defaultExtensions=S,exports.defaultNameConflictResolvers=T,exports.fromRef=k,exports.fromRefs=A,exports.isNode=v,exports.isNodeRef=y,exports.isRef=j,exports.isSymbol=b,exports.isSymbolRef=x,exports.nodeBrand=f,exports.ref=D,exports.refs=O,exports.simpleNameConflictResolver=C,exports.symbolBrand=p,exports.underscoreNameConflictResolver=w;
|
|
1
|
+
|
|
2
|
+
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);let l=require(`ansi-colors`);l=s(l);let u=require(`color-support`);u=s(u);const d=`heyapi.file`,f=`heyapi.node`,p=`heyapi.symbol`;l.default.enabled=(0,u.default)().hasBasic;const m=`heyapi`,h=/^(1|true|yes|on)$/i.test(process.env.HEYAPI_DISABLE_WARNINGS??``),g={analyzer:l.default.greenBright,dsl:l.default.cyanBright,file:l.default.yellowBright,registry:l.default.blueBright,symbol:l.default.magentaBright},_={deprecated:l.default.magentaBright};let v;function y(){if(v)return v;let e=process.env.DEBUG;return v=new Set(e?e.split(`,`).map(e=>e.trim().toLowerCase()):[]),v}const b=new Set;function x(e,t){let n=y();if(!(n.has(`*`)||n.has(`${m}:*`)||n.has(`${m}:${t}`)||n.has(t)))return;let r=(g[t]??l.default.whiteBright)(`${m}:${t}`);console.debug(`${r} ${e}`)}function S(e,t){if(h)return;let n=_[t]??l.default.yellowBright;console.warn(n(`${e}`))}function C({context:e,field:t,replacement:n}){let r=e?`${e}:${t}:${JSON.stringify(n)}`:`${t}:${JSON.stringify(n)}`;if(b.has(r))return;b.add(r);let i=`\`${t}\` is deprecated.`;if(n){let e=typeof n==`function`?n(t):n,r=(e instanceof Array?e:[e]).map(e=>`\`${e}\``).join(` or `);i+=` Use ${r} instead.`}S(`${e?`[${e}] `:``}${i}`,`deprecated`)}const w={debug:x,warn:S,warnDeprecated:C};var T=class{_exports=[];_extension;_finalPath;_imports=[];_language;_logicalFilePath;_name;_nodes=[];_renderer;"~brand"=`heyapi.file`;allNames=new Map;external;id;project;topLevelNames=new Map;constructor(e,t,n){this.external=e.external??!1,this.id=t,e.language!==void 0&&(this._language=e.language),this._logicalFilePath=e.logicalFilePath.split(c.default.sep).join(`/`),e.name!==void 0&&(this._name=e.name),this.project=n}get exports(){return[...this._exports]}get extension(){if(this.external)return;if(this._extension)return this._extension;let e=this.language,t=e?this.project.extensions[e]:void 0;if(t&&t[0])return t[0]}get finalPath(){return this._finalPath?this._finalPath:[...this._logicalFilePath?this._logicalFilePath.split(`/`).slice(0,-1):[],`${this.name}${this.extension??``}`].join(`/`)}get imports(){return[...this._imports]}get language(){if(this._language)return this._language;if(this._nodes[0])return this._nodes[0].language}get logicalFilePath(){return this._logicalFilePath}get name(){if(this._name)return this._name;let e=this._logicalFilePath.split(`/`).pop();if(e)return e;let t=`File ${this.toString()} has no name`;throw w.debug(t,`file`),Error(t)}get nodes(){return[...this._nodes]}get renderer(){return this._renderer}addExport(e){this._exports.push(e)}addImport(e){this._imports.push(e)}addNode(e){this._nodes.push(e),e.file=this}setExtension(e){this._extension=e}setFinalPath(e){this._finalPath=e}setLanguage(e){this._language=e}setName(e){this._name=e}setRenderer(e){this._renderer=e}toString(){return`[File ${this._logicalFilePath}#${this.id}]`}};function E(e,t){return!e||typeof e!=`object`?!1:e[`~brand`]===t}function D(e){return!e||typeof e!=`object`?!1:E(e,f)}function O(e){return E(e[`~ref`],f)}function k(e){return E(e,p)}function A(e){return E(e[`~ref`],p)}const j={c:[`.c`],"c#":[`.cs`],"c++":[`.cpp`,`.hpp`],css:[`.css`],dart:[`.dart`],go:[`.go`],haskell:[`.hs`],html:[`.html`],java:[`.java`],javascript:[`.js`,`.jsx`],json:[`.json`],kotlin:[`.kt`],lua:[`.lua`],markdown:[`.md`],matlab:[`.m`],perl:[`.pl`],php:[`.php`],python:[`.py`],r:[`.r`],ruby:[`.rb`],rust:[`.rs`],scala:[`.scala`],shell:[`.sh`],sql:[`.sql`],swift:[`.swift`],typescript:[`.ts`,`.tsx`],yaml:[`.yaml`,`.yml`]},M=({attempt:e,baseName:t})=>e===0?t:`${t}${e+1}`,N=({attempt:e,baseName:t})=>e===0?t:`${t}_${e+1}`,P={php:N,python:N,ruby:N};var F=class{_id=0;_values=new Map;project;constructor(e){this.project=e}get(e){return this._values.get(this.createFileKey(e))}isRegistered(e){return this._values.has(this.createFileKey(e))}get nextId(){return this._id++}register(e){let t=this.createFileKey(e),n=this._values.get(t);return n?e.name&&n.setName(e.name):n=new T(e,this.nextId,this.project),this._values.set(t,n),n}*registered(){for(let e of this._values.values())yield e}createFileKey(e){let t=e.logicalFilePath.split(c.default.sep).join(`/`);return`${e.external?`ext:`:``}${t}${e.language?`:${e.language}`:``}`}};const I=e=>B(e)?e:{"~ref":e},L=e=>{let t={};for(let n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=I(e[n]));return t},R=e=>e?.[`~ref`],z=e=>{let t={};for(let n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=R(e[n]));return t},B=e=>typeof e==`object`&&!!e&&`~ref`in e;var V=class{list=[];add(e){return this.list.push(I(e))-1}*all(){for(let e of this.list){let t=R(e);t&&(yield t)}}remove(e){this.list[e]=I(null)}update(e,t){this.list[e]=I(t)}};const H={class:3,enum:4,function:5,interface:1,namespace:0,type:2,var:6};function U(e,t){switch(H[e]>H[t]&&([e,t]=[t,e]),e){case`interface`:return t===`class`||t===`interface`;case`namespace`:return t===`class`||t===`enum`||t===`function`||t===`namespace`;case`type`:return t===`function`||t===`var`;default:return!1}}const W=(e={})=>({children:[],localNames:e.localNames||new Map,parent:e.parent,symbols:[]});var G=class{_parentStack=[];scope;scopes=W();symbol;constructor(e){this._parentStack.push(e),this.scope=this.scopes,this.symbol=e.symbol}get currentParent(){return this._parentStack[this._parentStack.length-1]}addChild(e,t=`container`){let n=this.currentParent;n&&(n.structuralChildren||=new Map,n.structuralChildren.set(e,t),e.structuralParents||=new Map,e.structuralParents.set(n,t))}addDependency(e){this.symbol!==R(e)&&this.scope.symbols.push(e)}analyze(e){let t=B(e)?e:I(e);if(A(t)){let e=R(t);e.node&&this.currentParent!==e.node&&this.addChild(e.node,`reference`),this.addDependency(t)}else if(O(t)){let e=R(t);this.addChild(e,`container`),this.pushParent(e),e.analyze(this),this.popParent()}}localNames(e){let t=new Map;for(let[n,r]of e.localNames)t.set(n,new Set(r));if(e.parent){let n=this.localNames(e.parent);for(let[e,r]of n)if(!t.has(e))t.set(e,r);else{let n=t.get(e);for(let e of r)n.add(e)}}return t}popParent(){this._parentStack.pop()}popScope(){this.scope=this.scope.parent??this.scope}pushParent(e){this._parentStack.push(e)}pushScope(){let e=W({parent:this.scope});this.scope.children.push(e),this.scope=e}walkScopes(e,t=this.scopes){this.scope=t;for(let n of t.symbols)e(n,t);for(let n of t.children)t=n,this.walkScopes(e,t);this.scope=this.scopes}},K=class{nodeCache=new WeakMap;analyzeNode(e){let t=this.nodeCache.get(e);if(t)return t;e.root=!0;let n=new G(e);return e.analyze(n),this.nodeCache.set(e,n),n}analyze(e,t){for(let n of e){let e=this.analyzeNode(n);t?.(e,n)}}};const q=e=>e===`type`||e===`interface`;var J=class{analyzer=new K;cacheResolvedNames=new Set;project;constructor(e){this.project=e}plan(e){this.cacheResolvedNames.clear(),this.allocateFiles(),this.assignLocalNames(),this.resolveFilePaths(e),this.planExports(),this.planImports()}allocateFiles(){this.analyzer.analyze(this.project.nodes.all(),(e,t)=>{let n=t.symbol;if(!n)return;let r=this.project.files.register({external:!1,language:t.language,logicalFilePath:n.getFilePath?.(n)||this.project.defaultFileName});r.addNode(t),n.setFile(r);for(let e of n.exportFrom)this.project.files.register({external:!1,language:r.language,logicalFilePath:e});e.walkScopes(e=>{let t=R(e);if(t.external&&t.isCanonical&&!t.file){let e=this.project.files.register({external:!0,language:t.node?.language,logicalFilePath:t.external});t.setFile(e)}})})}assignLocalNames(){this.analyzer.analyze(this.project.nodes.all(),(e,t)=>{let n=t.symbol;n&&this.assignTopLevelName({ctx:e,node:t,symbol:n})}),this.analyzer.analyze(this.project.nodes.all(),(e,t)=>{let n=t.file;n&&e.walkScopes(t=>{let r=R(t);r.file||this.assignLocalName({ctx:e,file:n,scopesToUpdate:[W({localNames:n.allNames})],symbol:r})})})}resolveFilePaths(e){for(let t of this.project.files.registered()){if(t.external){t.setFinalPath(t.logicalFilePath);continue}let n=this.project.fileName?.(t.name)||t.name;t.setName(n);let r=t.finalPath;r&&t.setFinalPath(c.default.resolve(this.project.root,r));let i={file:t,meta:e,project:this.project},a=this.project.renderers.find(e=>e.supports(i));a&&t.setRenderer(a)}}planExports(){let e=new Map,t=new Map;this.analyzer.analyze(this.project.nodes.all(),(n,r)=>{if(!r.exported)return;let i=r.symbol;if(!i)return;let a=r.file;if(a)for(let o of i.exportFrom){let s=this.project.files.register({external:!1,language:r.language,logicalFilePath:o});if(s.id===a.id)continue;let c=e.get(s);c||(c=new Map,e.set(s,c));let l=this.project.symbols.register({exported:!0,external:i.external,importKind:i.importKind,kind:i.kind,name:i.finalName});l.setFile(s),t.set(l.id,a),this.assignTopLevelName({ctx:n,symbol:l});let u=c.get(l.finalName);u||(u={kinds:new Set,symbol:l},c.set(l.finalName,u)),u.kinds.add(l.kind)}});for(let[n,r]of e){let e=new Map;for(let[,n]of r){let r=t.get(n.symbol.id),i=e.get(r);i||={canExportAll:!0,exports:[],from:r,isTypeOnly:!0};let a=[...n.kinds].every(e=>q(e)),o=n.symbol.finalName;i.exports.push({exportedName:o,isTypeOnly:a,kind:n.symbol.importKind,sourceName:n.symbol.name}),n.symbol.name!==n.symbol.finalName&&(i.canExportAll=!1),a||(i.isTypeOnly=!1),e.set(r,i)}for(let[,t]of e)n.addExport(t)}}planImports(){let e=new Map;this.analyzer.analyze(this.project.nodes.all(),t=>{let n=t.symbol;if(!n)return;let r=n.file;if(!r)return;let i=e.get(r);i||(i=new Map,e.set(r,i)),t.walkScopes(e=>{let n=R(e);if(!n.file||n.file.id===r.id)return;n.external&&this.assignTopLevelName({ctx:t,symbol:n});let a=n.file.id,o=n.finalName,s=q(n.kind),c=`${a}|${o}|${n.importKind}|${s}`,l=i.get(c);if(!l){let e=this.project.symbols.register({exported:n.exported,external:n.external,importKind:n.importKind,kind:n.kind,name:n.finalName});e.setFile(r),this.assignTopLevelName({ctx:t,scope:W({localNames:e.file.allNames}),symbol:e}),l={dep:n,kinds:new Set,symbol:e},i.set(c,l),l.kinds.add(e.kind)}e[`~ref`]=l.symbol})});for(let[t,n]of e){let e=new Map;for(let[,t]of n){let n=t.dep.file,r=e.get(n);r||={from:n,imports:[],isTypeOnly:!0,kind:`named`};let i=[...t.kinds].every(e=>q(e));t.symbol.importKind===`namespace`?(r.imports=[],r.kind=`namespace`,r.localName=t.symbol.finalName):t.symbol.importKind===`default`?(r.kind=`default`,r.localName=t.symbol.finalName):r.imports.push({isTypeOnly:i,localName:t.symbol.finalName,sourceName:t.dep.finalName}),i||(r.isTypeOnly=!1),e.set(n,r)}for(let[,n]of e)t.addImport(n)}}assignTopLevelName(e){e.symbol.file&&this.assignSymbolName({...e,file:e.symbol.file,scope:e?.scope??W({localNames:e.symbol.file.topLevelNames}),scopesToUpdate:[W({localNames:e.symbol.file.allNames}),e.ctx.scopes,...e?.scopesToUpdate??[]]})}assignLocalName(e){this.assignSymbolName({...e,scope:e.scope??e.ctx.scope})}assignSymbolName(e){let{ctx:t,file:n,node:r,scope:i,scopesToUpdate:a,symbol:o}=e;if(this.cacheResolvedNames.has(o.id))return;let s=o.name,c=r?.nameSanitizer?.(s)??o.node?.nameSanitizer?.(s)??s,l=1,u=t.localNames(i);for(;![...u.get(c)??[]].every(e=>U(o.kind,e));){let e=r?.language||o.node?.language||n.language,t=((e?this.project.nameConflictResolvers[e]:void 0)??this.project.defaultNameConflictResolver)({attempt:l,baseName:s});if(!t)throw Error(`Unresolvable name conflict: ${o.toString()}`);c=r?.nameSanitizer?.(t)??o.node?.nameSanitizer?.(t)??t,l+=1}o.setFinalName(c),this.cacheResolvedNames.add(o.id);let d=[i,...a];for(let e of d)this.updateScope(o,e)}updateScope(e,t){let n=e.finalName,r=t.localNames.get(n)??new Set;r.add(e.kind),t.localNames.set(n,r)}},Y=class{_canonical;_exported;_exportFrom;_external;_file;_finalName;_getFilePath;_importKind;_kind;_meta;_name;_node;"~brand"=p;id;constructor(e,t){this._exported=e.exported??!1,this._exportFrom=e.exportFrom??[],this._external=e.external,this._getFilePath=e.getFilePath,this.id=t,this._importKind=e.importKind??`named`,this._kind=e.kind??`var`,this._meta=e.meta,this._name=e.name}get canonical(){return this._canonical??this}get exported(){return this.canonical._exported}get exportFrom(){return this.canonical._exportFrom}get external(){return this.canonical._external}get file(){return this.canonical._file}get finalName(){if(!this.canonical._finalName){let e=`Symbol finalName has not been resolved yet for ${this.canonical.toString()}`;throw w.debug(e,`symbol`),Error(e)}return this.canonical._finalName}get getFilePath(){return this.canonical._getFilePath}get importKind(){return this.canonical._importKind}get isCanonical(){return!this._canonical||this._canonical===this}get kind(){return this.canonical._kind}get meta(){return this.canonical._meta}get name(){return this.canonical._name}get node(){return this.canonical._node}setCanonical(e){this._canonical=e}setExported(e){this.assertCanonical(),this._exported=e}setExportFrom(e){this.assertCanonical(),this._exportFrom=e}setFile(e){if(this.assertCanonical(),this._file&&this._file!==e){let e=`Symbol ${this.canonical.toString()} is already assigned to a different file.`;throw w.debug(e,`symbol`),Error(e)}this._file=e}setFinalName(e){if(this.assertCanonical(),this._finalName&&this._finalName!==e){let e=`Symbol finalName has already been resolved for ${this.canonical.toString()}.`;throw w.debug(e,`symbol`),Error(e)}this._finalName=e}setImportKind(e){this.assertCanonical(),this._importKind=e}setKind(e){this.assertCanonical(),this._kind=e}setName(e){this.assertCanonical(),this._name=e}setNode(e){if(this.assertCanonical(),this._node&&this._node!==e){let e=`Symbol ${this.canonical.toString()} is already bound to a different node.`;w.debug(e,`symbol`)}this._node=e,e.symbol=this}toString(){let e=this.canonical;return e._finalName&&e._finalName!==e._name?`[Symbol ${e._name} → ${e._finalName}#${e.id}]`:`[Symbol ${e._name}#${e.id}]`}assertCanonical(){if(this._canonical&&this._canonical!==this){let e=`Illegal mutation of stub symbol ${this.toString()} → canonical: ${this._canonical.toString()}`;throw w.debug(e,`symbol`),Error(e)}}},X=class{_id=0;_indices=new Map;_queryCache=new Map;_queryCacheDependencies=new Map;_registered=new Set;_stubs=new Set;_stubCache=new Map;_values=new Map;get(e){return typeof e==`number`?this._values.get(e):this.query(e)[0]}isRegistered(e){let t=this.get(e);return t?this._registered.has(t.id):!1}get nextId(){return this._id++}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=new Y({meta:e,name:``},this.nextId);return this._values.set(i.id,i),this._stubs.add(i.id),this._stubCache.set(n,i.id),i}register(e){let t=new Y(e,this.nextId);if(this._values.set(t.id,t),this._registered.add(t.id),t.meta){let e=this.buildIndexKeySpace(t.meta);this.indexSymbol(t.id,e),this.invalidateCache(e),this.replaceStubs(t,e)}return t}*registered(){for(let e of this._registered.values())yield this._values.get(e)}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._stubs.delete(n),r.setCanonical(e)}}}serializeIndexEntry(e){return`${e[0]}:${JSON.stringify(e[1])}`}},Z=class{files;nodes=new V;symbols=new X;defaultFileName;defaultNameConflictResolver;extensions;fileName;nameConflictResolvers;renderers;root;constructor(e){let t=e.fileName;this.defaultFileName=e.defaultFileName??`main`,this.defaultNameConflictResolver=e.defaultNameConflictResolver??M,this.extensions={...j,...e.extensions},this.fileName=typeof t==`string`?()=>t:t,this.files=new F(this),this.nameConflictResolvers={...P,...e.nameConflictResolvers},this.renderers=e.renderers??[],this.root=c.default.resolve(e.root).replace(/[/\\]+$/,``)}render(e){new J(this).plan(e);let t=[];for(let n of this.files.registered())if(!n.external&&n.finalPath&&n.renderer){let r=n.renderer.render({file:n,meta:e,project:this});t.push({content:r,path:n.finalPath})}return t}},Q=class e{children=new Map;items=[];name;parent;shell;shellSource;virtual;constructor(e,t,n){this.name=e,this.parent=t,this.virtual=n?.virtual??!1}get isRoot(){return!this.parent}child(t){return this.children.has(t)||this.children.set(t,new e(t,this)),this.children.get(t)}getPath(){let e=[],t=this;for(;t;)e.unshift(t.name),t=t.parent;return e}*itemsFrom(e){for(let t of this.items)t.source===e&&(yield t)}*walk(){for(let e of this.children.values())yield*e.walk();yield this}},$=class{_roots=new Map;_virtualRoot;get roots(){let e=Array.from(this._roots.values());return this._virtualRoot&&e.unshift(this._virtualRoot),e}insert(e){let{data:t,locations:n,source:r}=e;for(let e of n){let{path:n,shell:i}=e,a=n.filter(e=>!!e),o=a.slice(0,-1);if(!a[a.length-1])throw Error(`Cannot insert data without path.`);let s=null;for(let e of o)s=s?s.child(e):this.root(e),i&&!s.shell&&(s.shell=i,s.shellSource=r);s||=this.root(null),s.items.push({data:t,location:a,source:r})}}root(e){return e?(this._roots.has(e)||this._roots.set(e,new Q(e)),this._roots.get(e)):this._virtualRoot??=new Q(``,void 0,{virtual:!0})}*walk(){this._virtualRoot&&(yield*this._virtualRoot.walk());for(let e of this._roots.values())yield*e.walk()}};exports.File=T,exports.Project=Z,exports.StructureModel=$,exports.StructureNode=Q,exports.Symbol=Y,exports.defaultExtensions=j,exports.defaultNameConflictResolvers=P,exports.fromRef=R,exports.fromRefs=z,exports.isNode=D,exports.isNodeRef=O,exports.isRef=B,exports.isSymbol=k,exports.isSymbolRef=A,exports.log=w,exports.nodeBrand=f,exports.ref=I,exports.refs=L,exports.simpleNameConflictResolver=M,exports.symbolBrand=p,exports.underscoreNameConflictResolver=N;
|
|
2
3
|
//# sourceMappingURL=index.cjs.map
|
package/dist/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","names":["colors","path","defaultExtensions: Extensions","simpleNameConflictResolver: NameConflictResolver","underscoreNameConflictResolver: NameConflictResolver","defaultNameConflictResolvers: NameConflictResolvers","path","ref","names: NameScopes","file","path","ctx: RenderContext","exports","Symbol","sets: Array<Set<SymbolId>>","Symbol","entries: Array<IndexEntry>","path","path","files: Array<IOutput>"],"sources":["../src/brands.ts","../src/debug.ts","../src/files/file.ts","../src/guards.ts","../src/languages/extensions.ts","../src/planner/resolvers.ts","../src/languages/resolvers.ts","../src/files/registry.ts","../src/refs/refs.ts","../src/nodes/registry.ts","../src/project/namespace.ts","../src/planner/analyzer.ts","../src/planner/planner.ts","../src/symbols/symbol.ts","../src/symbols/registry.ts","../src/project/project.ts"],"sourcesContent":["export const fileBrand = 'heyapi.file';\nexport const nodeBrand = 'heyapi.node';\nexport const symbolBrand = 'heyapi.symbol';\n","import colors from 'ansi-colors';\n// @ts-expect-error\nimport colorSupport from 'color-support';\n\ncolors.enabled = colorSupport().hasBasic;\n\nconst DEBUG_GROUPS = {\n analyzer: colors.greenBright,\n dsl: colors.cyanBright,\n file: colors.yellowBright,\n registry: colors.blueBright,\n symbol: colors.magentaBright,\n} as const;\n\nexport function debug(message: string, group: keyof typeof DEBUG_GROUPS) {\n const value = process.env.DEBUG;\n if (!value) return;\n\n const groups = value.split(',').map((x) => x.trim().toLowerCase());\n\n if (\n !(\n groups.includes('*') ||\n groups.includes('heyapi:*') ||\n groups.includes(`heyapi:${group}`) ||\n groups.includes(group)\n )\n ) {\n return;\n }\n\n const color = DEBUG_GROUPS[group] ?? colors.whiteBright;\n const prefix = color(`heyapi:${group}`);\n\n console.debug(`${prefix} ${message}`);\n}\n","import path from 'node:path';\n\nimport type { ExportModule, ImportModule } from '../bindings';\nimport { fileBrand } from '../brands';\nimport { debug } from '../debug';\nimport type { Language } from '../languages/types';\nimport type { INode } from '../nodes/node';\nimport type { NameScopes } from '../planner/types';\nimport type { IProject } from '../project/types';\nimport type { Renderer } from '../renderer';\nimport type { IFileIn } from './types';\n\nexport class File {\n /**\n * Exports from this file.\n */\n private _exports: Array<ExportModule> = [];\n /**\n * File extension (e.g. `.ts`).\n */\n private _extension?: string;\n /**\n * Actual emitted file path, including extension and directories.\n */\n private _finalPath?: string;\n /**\n * Imports to this file.\n */\n private _imports: Array<ImportModule> = [];\n /**\n * Language of the file.\n */\n private _language?: Language;\n /**\n * Logical, extension-free path used for planning and routing.\n */\n private _logicalFilePath: string;\n /**\n * Base name of the file (without extension).\n */\n private _name?: string;\n /**\n * Syntax nodes contained in this file.\n */\n private _nodes: Array<INode> = [];\n /**\n * Renderer assigned to this file.\n */\n private _renderer?: Renderer;\n\n /** Brand used for identifying files. */\n readonly '~brand' = fileBrand;\n /** All names defined in this file, including local scopes. */\n allNames: NameScopes = new Map();\n /** Whether this file is external to the project. */\n external: boolean;\n /** Unique identifier for the file. */\n readonly id: number;\n /** The project this file belongs to. */\n readonly project: IProject;\n /** Names declared at the top level of the file. */\n topLevelNames: NameScopes = new Map();\n\n constructor(input: IFileIn, id: number, project: IProject) {\n this.external = input.external ?? false;\n this.id = id;\n if (input.language !== undefined) this._language = input.language;\n this._logicalFilePath = input.logicalFilePath.split(path.sep).join('/');\n if (input.name !== undefined) this._name = input.name;\n this.project = project;\n }\n\n /**\n * Exports from this file.\n */\n get exports(): ReadonlyArray<ExportModule> {\n return [...this._exports];\n }\n\n /**\n * Read-only accessor for the file extension.\n */\n get extension(): string | undefined {\n if (this._extension) return this._extension;\n const language = this.language;\n const extension = language ? this.project.extensions[language] : undefined;\n if (extension && extension[0]) return extension[0];\n return;\n }\n\n /**\n * Read-only accessor for the final emitted path.\n *\n * If undefined, the file has not yet been assigned a final path\n * or is external to the project and should not be emitted.\n */\n get finalPath(): string | undefined {\n if (this._finalPath) return this._finalPath;\n const dirs = this._logicalFilePath\n ? this._logicalFilePath.split('/').slice(0, -1)\n : [];\n return [...dirs, `${this.name}${this.extension ?? ''}`].join('/');\n }\n\n /**\n * Imports to this file.\n */\n get imports(): ReadonlyArray<ImportModule> {\n return [...this._imports];\n }\n\n /**\n * Language of the file; inferred from nodes or fallback if not set explicitly.\n */\n get language(): Language | undefined {\n if (this._language) return this._language;\n if (this._nodes[0]) return this._nodes[0].language;\n return;\n }\n\n /**\n * Logical, extension-free path used for planning and routing.\n */\n get logicalFilePath(): string {\n return this._logicalFilePath;\n }\n\n /**\n * Base name of the file (without extension).\n *\n * If no name was set explicitly, it is inferred from the logical file path.\n */\n get name(): string {\n if (this._name) return this._name;\n const name = this._logicalFilePath.split('/').pop();\n if (name) return name;\n const message = `File ${this.toString()} has no name`;\n debug(message, 'file');\n throw new Error(message);\n }\n\n /**\n * Syntax nodes contained in this file.\n */\n get nodes(): ReadonlyArray<INode> {\n return [...this._nodes];\n }\n\n /**\n * Renderer assigned to this file.\n */\n get renderer(): Renderer | undefined {\n return this._renderer;\n }\n\n /**\n * Add an export group to the file.\n */\n addExport(group: ExportModule): void {\n this._exports.push(group);\n }\n\n /**\n * Add an import group to the file.\n */\n addImport(group: ImportModule): void {\n this._imports.push(group);\n }\n\n /**\n * Add a syntax node to the file.\n */\n addNode(node: INode): void {\n this._nodes.push(node);\n node.file = this;\n }\n\n /**\n * Sets the file extension.\n */\n setExtension(extension: string): void {\n this._extension = extension;\n }\n\n /**\n * Sets the final emitted path of the file.\n */\n setFinalPath(path: string): void {\n this._finalPath = path;\n }\n\n /**\n * Sets the language of the file.\n */\n setLanguage(lang: Language): void {\n this._language = lang;\n }\n\n /**\n * Sets the name of the file.\n */\n setName(name: string): void {\n this._name = name;\n }\n\n /**\n * Sets the renderer assigned to this file.\n */\n setRenderer(renderer: Renderer): void {\n this._renderer = renderer;\n }\n\n /**\n * Returns a debug‑friendly string representation identifying the file.\n */\n toString(): string {\n return `[File ${this._logicalFilePath}#${this.id}]`;\n }\n}\n","import { nodeBrand, symbolBrand } from './brands';\nimport type { INode } from './nodes/node';\nimport type { Ref } from './refs/types';\nimport type { Symbol } from './symbols/symbol';\n\nexport function isBrand(value: unknown, brand: string): value is INode {\n if (!value || typeof value !== 'object') return false;\n return (value as any)['~brand'] === brand;\n}\n\nexport function isNode(value: unknown): value is INode {\n if (!value || typeof value !== 'object') return false;\n return isBrand(value, nodeBrand);\n}\n\nexport function isNodeRef(value: Ref<unknown>): value is Ref<INode> {\n return isBrand(value['~ref'], nodeBrand);\n}\n\nexport function isSymbol(value: unknown): value is Symbol {\n return isBrand(value, symbolBrand);\n}\n\nexport function isSymbolRef(value: Ref<unknown>): value is Ref<Symbol> {\n return isBrand(value['~ref'], symbolBrand);\n}\n","import type { Extensions } from './types';\n\nexport const defaultExtensions: Extensions = {\n c: ['.c'],\n 'c#': ['.cs'],\n 'c++': ['.cpp', '.hpp'],\n css: ['.css'],\n dart: ['.dart'],\n go: ['.go'],\n haskell: ['.hs'],\n html: ['.html'],\n java: ['.java'],\n javascript: ['.js', '.jsx'],\n json: ['.json'],\n kotlin: ['.kt'],\n lua: ['.lua'],\n markdown: ['.md'],\n matlab: ['.m'],\n perl: ['.pl'],\n php: ['.php'],\n python: ['.py'],\n r: ['.r'],\n ruby: ['.rb'],\n rust: ['.rs'],\n scala: ['.scala'],\n shell: ['.sh'],\n sql: ['.sql'],\n swift: ['.swift'],\n typescript: ['.ts', '.tsx'],\n yaml: ['.yaml', '.yml'],\n};\n","import type { NameConflictResolver } from './types';\n\nexport const simpleNameConflictResolver: NameConflictResolver = ({\n attempt,\n baseName,\n}) => (attempt === 0 ? baseName : `${baseName}${attempt + 1}`);\n\nexport const underscoreNameConflictResolver: NameConflictResolver = ({\n attempt,\n baseName,\n}) => (attempt === 0 ? baseName : `${baseName}_${attempt + 1}`);\n","import { underscoreNameConflictResolver } from '../planner/resolvers';\nimport type { NameConflictResolvers } from './types';\n\nexport const defaultNameConflictResolvers: NameConflictResolvers = {\n php: underscoreNameConflictResolver,\n python: underscoreNameConflictResolver,\n ruby: underscoreNameConflictResolver,\n};\n","import path from 'node:path';\n\nimport type { IProject } from '../project/types';\nimport { File } from './file';\nimport type { FileKeyArgs, IFileIn, IFileRegistry } from './types';\n\ntype FileId = number;\ntype FileKey = string;\n\nexport class FileRegistry implements IFileRegistry {\n private _id: FileId = 0;\n private _values: Map<FileKey, File> = new Map();\n private readonly project: IProject;\n\n constructor(project: IProject) {\n this.project = project;\n }\n\n get(args: FileKeyArgs): File | undefined {\n return this._values.get(this.createFileKey(args));\n }\n\n isRegistered(args: FileKeyArgs): boolean {\n return this._values.has(this.createFileKey(args));\n }\n\n get nextId(): FileId {\n return this._id++;\n }\n\n register(file: IFileIn): File {\n const key = this.createFileKey(file);\n\n let result = this._values.get(key);\n if (result) {\n if (file.name) {\n result.setName(file.name);\n }\n } else {\n result = new File(file, this.nextId, this.project);\n }\n\n this._values.set(key, result);\n\n return result;\n }\n\n *registered(): IterableIterator<File> {\n for (const file of this._values.values()) {\n yield file;\n }\n }\n\n private createFileKey(args: FileKeyArgs): string {\n const logicalPath = args.logicalFilePath.split(path.sep).join('/');\n return `${args.external ? 'ext:' : ''}${logicalPath}${args.language ? `:${args.language}` : ''}`;\n }\n}\n","import type { FromRefs, Ref, Refs } from './types';\n\n/**\n * Wraps a single value in a Ref object.\n *\n * @example\n * ```ts\n * const r = ref(123); // { '~ref': 123 }\n * console.log(r['~ref']); // 123\n * ```\n */\nexport const ref = <T>(value: T): Ref<T> => ({ '~ref': value });\n\n/**\n * Converts a plain object to an object of Refs (deep, per property).\n *\n * @example\n * ```ts\n * const obj = { a: 1, b: \"x\" };\n * const refs = refs(obj); // { a: { '~ref': 1 }, b: { '~ref': \"x\" } }\n * ```\n */\nexport const refs = <T extends Record<string, unknown>>(obj: T): Refs<T> => {\n const result = {} as Refs<T>;\n for (const key in obj) {\n if (Object.prototype.hasOwnProperty.call(obj, key)) {\n result[key] = ref(obj[key]);\n }\n }\n return result;\n};\n\n/**\n * Unwraps a single Ref object to its value.\n *\n * @example\n * ```ts\n * const r = { '~ref': 42 };\n * const n = fromRef(r); // 42\n * console.log(n); // 42\n * ```\n */\nexport const fromRef = <T extends Ref<unknown> | undefined>(\n ref: T,\n): T extends Ref<infer U> ? U : undefined =>\n ref?.['~ref'] as T extends Ref<infer U> ? U : undefined;\n\n/**\n * Converts an object of Refs back to a plain object (unwraps all refs).\n *\n * @example\n * ```ts\n * const refs = { a: { '~ref': 1 }, b: { '~ref': \"x\" } };\n * const plain = fromRefs(refs); // { a: 1, b: \"x\" }\n * ```\n */\nexport const fromRefs = <T extends Refs<Record<string, unknown>>>(\n obj: T,\n): FromRefs<T> => {\n const result = {} as FromRefs<T>;\n for (const key in obj) {\n if (Object.prototype.hasOwnProperty.call(obj, key)) {\n result[key] = fromRef(obj[key]!) as (typeof result)[typeof key];\n }\n }\n return result;\n};\n\n/**\n * Checks whether a value is a Ref object.\n *\n * @param value Value to check\n * @returns True if the value is a Ref object.\n */\nexport const isRef = <T>(value: unknown): value is Ref<T> =>\n typeof value === 'object' && value !== null && '~ref' in value;\n","import { fromRef, ref } from '../refs/refs';\nimport type { Ref } from '../refs/types';\nimport type { INode } from './node';\nimport type { INodeRegistry } from './types';\n\nexport class NodeRegistry implements INodeRegistry {\n private list: Array<Ref<INode | null>> = [];\n\n add(node: INode | null): number {\n const index = this.list.push(ref(node));\n return index - 1;\n }\n\n *all(): Iterable<INode> {\n for (const r of this.list) {\n const node = fromRef(r);\n if (node) yield node;\n }\n }\n\n remove(index: number): void {\n this.list[index] = ref(null);\n }\n\n update(index: number, node: INode | null): void {\n this.list[index] = ref(node);\n }\n}\n","import type { SymbolKind } from '../symbols/types';\n\n/**\n * Returns true if two declarations of given kinds\n * are allowed to share the same identifier in TypeScript.\n */\nexport function canShareName(a: SymbolKind, b: SymbolKind): boolean {\n // same-kind always valid for interfaces (merging)\n if (a === 'interface' && b === 'interface') return true;\n\n // type vs interface merges\n if (\n (a === 'interface' && b === 'type') ||\n (a === 'type' && b === 'interface')\n ) {\n return false; // TypeScript does NOT merge type-alias with interface.\n }\n\n // type vs type = conflict\n if (a === 'type' && b === 'type') return false;\n\n // interface vs class = allowed (declare-merge)\n if (\n (a === 'interface' && b === 'class') ||\n (a === 'class' && b === 'interface')\n ) {\n return true;\n }\n\n // enum vs namespace = allowed (merges into value+type)\n if (\n (a === 'enum' && b === 'namespace') ||\n (a === 'namespace' && b === 'enum')\n ) {\n return true;\n }\n\n // class vs namespace = allowed\n if (\n (a === 'class' && b === 'namespace') ||\n (a === 'namespace' && b === 'class')\n ) {\n return true;\n }\n\n // namespace vs namespace = allowed (merging)\n if (a === 'namespace' && b === 'namespace') return true;\n\n // enum vs enum = conflict IF values conflict (TypeScript flags duplicates)\n if (a === 'enum' && b === 'enum') return false;\n\n // function and namespace merge (namespace can augment function)\n if (\n (a === 'function' && b === 'namespace') ||\n (a === 'namespace' && b === 'function')\n ) {\n return true;\n }\n\n // these collide with each other in the value namespace\n const valueKinds = new Set<SymbolKind>(['class', 'enum', 'function', 'var']);\n\n const aInValue = valueKinds.has(a);\n const bInValue = valueKinds.has(b);\n\n if (aInValue && bInValue) return false;\n\n // type-only declarations do not collide with value-only declarations\n const typeKinds = new Set<SymbolKind>(['interface', 'type']);\n const aInType = typeKinds.has(a);\n const bInType = typeKinds.has(b);\n\n // if one is type-only and the other is value-only, they do NOT collide\n if (aInType !== bInType) return true;\n\n return true;\n}\n","import { isNodeRef, isSymbolRef } from '../guards';\nimport type { INode } from '../nodes/node';\nimport { fromRef, isRef, ref } from '../refs/refs';\nimport type { Ref } from '../refs/types';\nimport type { Symbol } from '../symbols/symbol';\nimport type { IAnalysisContext, Input, NameScopes, Scope } from './types';\n\nconst createScope = (parent?: Scope): Scope => ({\n children: [],\n localNames: new Map(),\n parent,\n symbols: [],\n});\n\nexport class AnalysisContext implements IAnalysisContext {\n scopes: Scope = createScope();\n symbol?: Symbol;\n scope: Scope = this.scopes;\n\n constructor(symbol?: Symbol) {\n this.symbol = symbol;\n }\n\n addDependency(symbol: Ref<Symbol>): void {\n if (this.symbol !== fromRef(symbol)) {\n this.scope.symbols.push(symbol);\n }\n }\n\n analyze(input: Input): void {\n const v = isRef(input) ? input : ref(input);\n if (isSymbolRef(v)) {\n this.addDependency(v);\n } else if (isNodeRef(v)) {\n fromRef(v).analyze(this);\n }\n }\n\n localNames(scope: Scope): NameScopes {\n const names: NameScopes = new Map();\n for (const [name, kinds] of scope.localNames) {\n names.set(name, new Set(kinds));\n }\n if (scope.parent) {\n const parentNames = this.localNames(scope.parent);\n for (const [name, kinds] of parentNames) {\n if (!names.has(name)) {\n names.set(name, kinds);\n } else {\n const existingKinds = names.get(name)!;\n for (const kind of kinds) {\n existingKinds.add(kind);\n }\n }\n }\n }\n return names;\n }\n\n popScope(): void {\n this.scope = this.scope.parent ?? this.scope;\n }\n\n pushScope(): void {\n const scope = createScope(this.scope);\n this.scope.children.push(scope);\n this.scope = scope;\n }\n\n walkScopes(\n callback: (symbol: Ref<Symbol>, scope: Scope) => void,\n scope: Scope = this.scopes,\n ): void {\n this.scope = scope;\n for (const symbol of scope.symbols) {\n callback(symbol, scope);\n }\n for (const child of scope.children) {\n scope = child;\n this.walkScopes(callback, scope);\n }\n this.scope = this.scopes;\n }\n}\n\nexport class Analyzer {\n private nodeCache = new WeakMap<INode, AnalysisContext>();\n\n analyzeNode(node: INode): AnalysisContext {\n const cached = this.nodeCache.get(node);\n if (cached) return cached;\n\n const ctx = new AnalysisContext(node.symbol);\n node.analyze(ctx);\n\n this.nodeCache.set(node, ctx);\n return ctx;\n }\n\n analyze(\n nodes: Iterable<INode>,\n callback?: (ctx: AnalysisContext, node: INode) => void,\n ): void {\n for (const node of nodes) {\n const ctx = this.analyzeNode(node);\n callback?.(ctx, node);\n }\n }\n}\n","import path from 'node:path';\n\nimport type { ExportModule, ImportModule } from '../bindings';\nimport type { IProjectRenderMeta } from '../extensions';\nimport type { File } from '../files/file';\nimport type { IFileIn } from '../files/types';\nimport { canShareName } from '../project/namespace';\nimport type { IProject } from '../project/types';\nimport { fromRef } from '../refs/refs';\nimport type { RenderContext } from '../renderer';\nimport type { Symbol } from '../symbols/symbol';\nimport type { SymbolKind } from '../symbols/types';\nimport type { AnalysisContext } from './analyzer';\nimport { Analyzer } from './analyzer';\nimport type { AssignOptions, NameScopes } from './types';\n\nconst isTypeOnlyKind = (kind: SymbolKind) =>\n kind === 'type' || kind === 'interface';\n\nexport class Planner {\n private readonly analyzer = new Analyzer();\n private readonly cacheResolvedNames = new Set<number>();\n private readonly project: IProject;\n\n constructor(project: IProject) {\n this.project = project;\n }\n\n /**\n * Executes the planning phase for the project.\n */\n plan(meta?: IProjectRenderMeta) {\n this.cacheResolvedNames.clear();\n this.allocateFiles();\n this.assignLocalNames();\n this.resolveFilePaths(meta);\n this.planExports();\n this.planImports();\n }\n\n /**\n * Creates and assigns a file to every node, re-export,\n * and external dependency.\n */\n private allocateFiles(): void {\n this.analyzer.analyze(this.project.nodes.all(), (ctx, node) => {\n const symbol = node.symbol;\n if (!symbol) return;\n\n const file = this.project.files.register(this.symbolToFileIn(symbol));\n file.addNode(node);\n symbol.setFile(file);\n for (const exportFrom of symbol.exportFrom) {\n this.project.files.register({\n external: false,\n language: file.language,\n logicalFilePath: exportFrom,\n });\n }\n ctx.walkScopes((dependency) => {\n const dep = fromRef(dependency);\n if (dep.external && dep.isCanonical && !dep.file) {\n const file = this.project.files.register(this.symbolToFileIn(dep));\n dep.setFile(file);\n }\n });\n });\n }\n\n /**\n * Assigns final names to all symbols.\n *\n * First assigns top-level (file-scoped) symbol names, then local symbols.\n */\n private assignLocalNames(): void {\n this.analyzer.analyze(this.project.nodes.all(), (ctx, node) => {\n const symbol = node.symbol;\n if (!symbol) return;\n this.assignTopLevelName(symbol, ctx);\n });\n\n this.analyzer.analyze(this.project.nodes.all(), (ctx, node) => {\n const file = node.file;\n if (!file) return;\n ctx.walkScopes((dependency) => {\n const dep = fromRef(dependency);\n // top-level or external symbol\n if (dep.file) return;\n this.assignLocalName(dep, ctx, {\n scopesToUpdate: [file.allNames],\n });\n });\n });\n }\n\n /**\n * Resolves and sets final file paths for all non-external files. Attaches renderers.\n *\n * Uses the project's fileName function if provided, otherwise uses the file's current name.\n *\n * Resolves final paths relative to the project's root directory.\n */\n private resolveFilePaths(meta?: IProjectRenderMeta): void {\n for (const file of this.project.files.registered()) {\n if (file.external) continue;\n const finalName = this.project.fileName?.(file.name) || file.name;\n file.setName(finalName);\n const finalPath = file.finalPath;\n if (finalPath) {\n file.setFinalPath(path.resolve(this.project.root, finalPath));\n }\n const ctx: RenderContext = { file, meta, project: this.project };\n const renderer = this.project.renderers.find((r) => r.supports(ctx));\n if (renderer) file.setRenderer(renderer);\n }\n }\n\n /**\n * Plans exports by analyzing all exported symbols.\n *\n * Registers re-export targets as files and creates new exported symbols for them.\n *\n * Assigns names to re-exported symbols and collects re-export metadata,\n * distinguishing type-only exports based on symbol kinds.\n */\n private planExports(): void {\n const seenByFile = new Map<\n File,\n Map<string, { kinds: Set<SymbolKind>; symbol: Symbol }>\n >();\n const sourceFile = new Map<number, File>();\n\n this.analyzer.analyze(this.project.nodes.all(), (ctx, node) => {\n if (!node.exported) return;\n\n const symbol = node.symbol;\n if (!symbol) return;\n\n const file = node.file;\n if (!file) return;\n\n for (const exportFrom of symbol.exportFrom) {\n const target = this.project.files.register({\n external: false,\n language: node.language,\n logicalFilePath: exportFrom,\n });\n if (target.id === file.id) continue;\n\n let fileMap = seenByFile.get(target);\n if (!fileMap) {\n fileMap = new Map();\n seenByFile.set(target, fileMap);\n }\n\n const exp = this.project.symbols.register({\n exported: true,\n external: symbol.external,\n importKind: symbol.importKind,\n kind: symbol.kind,\n name: symbol.finalName,\n });\n exp.setFile(target);\n sourceFile.set(exp.id, file);\n this.assignTopLevelName(exp, ctx);\n\n let entry = fileMap.get(exp.finalName);\n if (!entry) {\n entry = { kinds: new Set(), symbol: exp };\n fileMap.set(exp.finalName, entry);\n }\n entry.kinds.add(exp.kind);\n }\n });\n\n for (const [file, fileMap] of seenByFile) {\n const exports = new Map<File, ExportModule>();\n for (const [, entry] of fileMap) {\n const source = sourceFile.get(entry.symbol.id)!;\n let exp = exports.get(source);\n if (!exp) {\n exp = {\n canExportAll: true,\n exports: [],\n from: source,\n isTypeOnly: true,\n };\n }\n const isTypeOnly = [...entry.kinds].every((kind) =>\n isTypeOnlyKind(kind),\n );\n const exportedName = entry.symbol.finalName;\n exp.exports.push({\n exportedName,\n isTypeOnly,\n kind: entry.symbol.importKind,\n sourceName: entry.symbol.name,\n });\n if (entry.symbol.name !== entry.symbol.finalName) {\n exp.canExportAll = false;\n }\n if (!isTypeOnly) {\n exp.isTypeOnly = false;\n }\n exports.set(source, exp);\n }\n for (const [, exp] of exports) {\n file.addExport(exp);\n }\n }\n }\n\n /**\n * Plans imports by analyzing symbol dependencies across files.\n *\n * For external dependencies, assigns top-level names.\n *\n * Creates or reuses import symbols for dependencies from other files,\n * assigning names and updating import metadata including type-only flags.\n */\n private planImports(): void {\n const seenByFile = new Map<\n File,\n Map<\n string,\n {\n dep: Symbol;\n kinds: Set<SymbolKind>;\n symbol: Symbol;\n }\n >\n >();\n\n this.analyzer.analyze(this.project.nodes.all(), (ctx) => {\n const symbol = ctx.symbol;\n if (!symbol) return;\n\n const file = symbol.file;\n if (!file) return;\n\n let fileMap = seenByFile.get(file);\n if (!fileMap) {\n fileMap = new Map();\n seenByFile.set(file, fileMap);\n }\n\n ctx.walkScopes((dependency) => {\n const dep = fromRef(dependency);\n if (!dep.file || dep.file.id === file.id) return;\n\n if (dep.external) {\n this.assignTopLevelName(dep, ctx);\n }\n\n const fromFileId = dep.file.id;\n const importedName = dep.finalName;\n const isTypeOnly = isTypeOnlyKind(dep.kind);\n const kind = dep.importKind;\n const key = `${fromFileId}|${importedName}|${kind}|${isTypeOnly}`;\n\n let entry = fileMap.get(key);\n if (!entry) {\n const imp = this.project.symbols.register({\n exported: dep.exported,\n external: dep.external,\n importKind: dep.importKind,\n kind: dep.kind,\n name: dep.finalName,\n });\n imp.setFile(file);\n this.assignTopLevelName(imp, ctx, {\n scope: imp.file!.allNames,\n });\n entry = {\n dep,\n kinds: new Set(),\n symbol: imp,\n };\n fileMap.set(key, entry);\n entry.kinds.add(imp.kind);\n }\n\n dependency['~ref'] = entry.symbol;\n });\n });\n\n for (const [file, fileMap] of seenByFile) {\n const imports = new Map<File, ImportModule>();\n for (const [, entry] of fileMap) {\n const source = entry.dep.file!;\n let imp = imports.get(source);\n if (!imp) {\n imp = {\n from: source,\n imports: [],\n isTypeOnly: true,\n };\n }\n const isTypeOnly = [...entry.kinds].every((kind) =>\n isTypeOnlyKind(kind),\n );\n if (entry.symbol.importKind === 'namespace') {\n imp.imports = [];\n imp.namespaceImport = entry.symbol.finalName;\n } else {\n imp.imports.push({\n isTypeOnly,\n kind: entry.symbol.importKind,\n localName: entry.symbol.finalName,\n sourceName: entry.dep.finalName,\n });\n }\n if (!isTypeOnly) {\n imp.isTypeOnly = false;\n }\n imports.set(source, imp);\n }\n for (const [, imp] of imports) {\n file.addImport(imp);\n }\n }\n }\n\n /**\n * Assigns the final name to a top-level (file-scoped) symbol.\n *\n * Uses the symbol's file top-level names as the default scope,\n * and updates all relevant name scopes including the file's allNames and local scopes.\n *\n * Supports optional overrides for the naming scope and scopes to update.\n */\n private assignTopLevelName(\n symbol: Symbol,\n ctx: AnalysisContext,\n options?: Partial<AssignOptions>,\n ): void {\n if (!symbol.file) return;\n this.assignSymbolName(symbol, {\n scope: options?.scope ?? symbol.file.topLevelNames,\n scopesToUpdate: [\n symbol.file.allNames,\n ctx.scopes.localNames,\n ...(options?.scopesToUpdate ?? []),\n ],\n });\n }\n\n /**\n * Assigns the final name to a non-top-level (local) symbol.\n *\n * Uses the provided scope or derives it from the current analysis context's local names.\n *\n * Updates all provided name scopes accordingly.\n */\n private assignLocalName(\n symbol: Symbol,\n ctx: AnalysisContext,\n options: Pick<Partial<AssignOptions>, 'scope'> &\n Pick<AssignOptions, 'scopesToUpdate'>,\n ): void {\n this.assignSymbolName(symbol, {\n scope: options.scope ?? ctx.localNames(ctx.scope),\n scopesToUpdate: options.scopesToUpdate,\n });\n }\n\n /**\n * Assigns the final name to a symbol within the provided name scope.\n *\n * Resolves name conflicts until a unique name is found.\n *\n * Updates all specified name scopes with the assigned final name.\n */\n private assignSymbolName(symbol: Symbol, options: AssignOptions): void {\n if (this.cacheResolvedNames.has(symbol.id)) return;\n\n const baseName = symbol.name;\n let finalName = symbol.nameSanitizer?.(baseName) ?? baseName;\n let attempt = 1;\n\n while (true) {\n const kinds = [...(options.scope.get(finalName) ?? [])];\n\n const ok = kinds.every((kind) => canShareName(symbol.kind, kind));\n if (ok) break;\n\n const language = symbol.node?.language || symbol.file?.language;\n const resolver =\n (language ? this.project.nameConflictResolvers[language] : undefined) ??\n this.project.defaultNameConflictResolver;\n const resolvedName = resolver({ attempt, baseName });\n if (!resolvedName) {\n throw new Error(`Unresolvable name conflict: ${symbol.toString()}`);\n }\n\n finalName = symbol.nameSanitizer?.(resolvedName) ?? resolvedName;\n attempt = attempt + 1;\n }\n\n symbol.setFinalName(finalName);\n this.cacheResolvedNames.add(symbol.id);\n const updateScopes = [options.scope, ...options.scopesToUpdate];\n for (const scope of updateScopes) {\n this.updateScope(symbol, scope);\n }\n }\n\n /**\n * Updates the provided name scope with the symbol's final name and kind.\n *\n * Ensures the name scope tracks all kinds associated with a given name.\n */\n private updateScope(symbol: Symbol, scope: NameScopes): void {\n const name = symbol.finalName;\n const cache = scope.get(name) ?? new Set<SymbolKind>();\n cache.add(symbol.kind);\n scope.set(name, cache);\n }\n\n private symbolToFileIn(symbol: Symbol): IFileIn {\n return {\n external: Boolean(symbol.external),\n language: symbol.node?.language,\n logicalFilePath:\n symbol.external ||\n symbol.getFilePath?.(symbol) ||\n this.project.defaultFileName,\n } satisfies IFileIn;\n }\n}\n","import { symbolBrand } from '../brands';\nimport { debug } from '../debug';\nimport type { ISymbolMeta } from '../extensions';\nimport type { File } from '../files/file';\nimport type { INode } from '../nodes/node';\nimport type {\n BindingKind,\n ISymbolIn,\n SymbolKind,\n SymbolNameSanitizer,\n} from './types';\n\nexport class Symbol {\n /**\n * Canonical symbol this stub resolves to, if any.\n *\n * Stubs created during DSL construction may later be associated\n * with a fully registered symbol. Once set, all property lookups\n * should defer to the canonical symbol.\n */\n private _canonical?: Symbol;\n /**\n * True if this symbol is exported from its defining file.\n *\n * @default false\n */\n private _exported: boolean;\n /**\n * Names of files (without extension) from which this symbol is re-exported.\n *\n * @default []\n */\n private _exportFrom: ReadonlyArray<string>;\n /**\n * External module name if this symbol is imported from a module not managed\n * by the project (e.g. \"zod\", \"lodash\").\n *\n * @default undefined\n */\n private _external?: string;\n /**\n * The file this symbol is ultimately emitted into.\n *\n * Only top-level symbols have an assigned file.\n */\n private _file?: File;\n /**\n * The alias-resolved, conflict-free emitted name.\n */\n private _finalName?: string;\n /**\n * Custom strategy to determine file output path.\n *\n * @returns The file path to output the symbol to, or undefined to fallback to default behavior.\n */\n private _getFilePath?: (symbol: Symbol) => string | undefined;\n /**\n * How this symbol should be imported (namespace/default/named).\n *\n * @default 'named'\n */\n private _importKind: BindingKind;\n /**\n * Kind of symbol (class, type, alias, etc.).\n *\n * @default 'var'\n */\n private _kind: SymbolKind;\n /**\n * Arbitrary user metadata.\n *\n * @default undefined\n */\n private _meta?: ISymbolMeta;\n /**\n * Intended user-facing name before conflict resolution.\n *\n * @example \"UserModel\"\n */\n private _name: string;\n /**\n * Optional function to sanitize the symbol name.\n *\n * @default undefined\n */\n private _nameSanitizer?: SymbolNameSanitizer;\n /**\n * Node that defines this symbol.\n */\n private _node?: INode;\n\n /** Brand used for identifying symbols. */\n readonly '~brand' = symbolBrand;\n /** Globally unique, stable symbol ID. */\n readonly id: number;\n\n constructor(input: ISymbolIn, id: number) {\n this._exported = input.exported ?? false;\n this._exportFrom = input.exportFrom ?? [];\n this._external = input.external;\n this._getFilePath = input.getFilePath;\n this.id = id;\n this._importKind = input.importKind ?? 'named';\n this._kind = input.kind ?? 'var';\n this._meta = input.meta;\n this._name = input.name;\n }\n\n /**\n * Returns the canonical symbol for this instance.\n *\n * If this symbol was created as a stub, this getter returns\n * the fully registered canonical symbol. Otherwise, it returns\n * the symbol itself.\n */\n get canonical(): Symbol {\n return this._canonical ?? this;\n }\n\n /**\n * Indicates whether this symbol is exported from its defining file.\n */\n get exported(): boolean {\n return this.canonical._exported;\n }\n\n /**\n * Names of files (without extension) that re-export this symbol.\n */\n get exportFrom(): ReadonlyArray<string> {\n return this.canonical._exportFrom;\n }\n\n /**\n * External module from which this symbol originates, if any.\n */\n get external(): string | undefined {\n return this.canonical._external;\n }\n\n /**\n * Read‑only accessor for the assigned output file.\n *\n * Only top-level symbols have an assigned file.\n */\n get file(): File | undefined {\n return this.canonical._file;\n }\n\n /**\n * Read‑only accessor for the resolved final emitted name.\n */\n get finalName(): string {\n if (!this.canonical._finalName) {\n const message = `Symbol finalName has not been resolved yet for ${this.canonical.toString()}`;\n debug(message, 'symbol');\n throw new Error(message);\n }\n return this.canonical._finalName;\n }\n\n /**\n * Custom file path resolver, if provided.\n */\n get getFilePath(): ((symbol: Symbol) => string | undefined) | undefined {\n return this.canonical._getFilePath;\n }\n\n /**\n * How this symbol should be imported (named/default/namespace).\n */\n get importKind(): BindingKind {\n return this.canonical._importKind;\n }\n\n /**\n * Indicates whether this is a canonical symbol (not a stub).\n */\n get isCanonical(): boolean {\n return !this._canonical || this._canonical === this;\n }\n\n /**\n * The symbol's kind (class, type, alias, variable, etc.).\n */\n get kind(): SymbolKind {\n return this.canonical._kind;\n }\n\n /**\n * Arbitrary user‑provided metadata associated with this symbol.\n */\n get meta(): ISymbolMeta | undefined {\n return this.canonical._meta;\n }\n\n /**\n * User-intended name before aliasing or conflict resolution.\n */\n get name(): string {\n return this.canonical._name;\n }\n\n /**\n * Optional function to sanitize the symbol name.\n */\n get nameSanitizer(): SymbolNameSanitizer | undefined {\n return this.canonical._nameSanitizer;\n }\n\n /**\n * Read‑only accessor for the defining node.\n */\n get node(): INode | undefined {\n return this.canonical._node;\n }\n\n /**\n * Marks this symbol as a stub and assigns its canonical symbol.\n *\n * After calling this, all semantic queries (name, kind, file,\n * meta, etc.) should reflect the canonical symbol's values.\n *\n * @param symbol — The canonical symbol this stub should resolve to.\n */\n setCanonical(symbol: Symbol): void {\n this._canonical = symbol;\n }\n\n /**\n * Marks the symbol as exported from its file.\n *\n * @param exported — Whether the symbol is exported.\n */\n setExported(exported: boolean): void {\n this.assertCanonical();\n this._exported = exported;\n }\n\n /**\n * Records file names that re‑export this symbol.\n *\n * @param list — Source files re‑exporting this symbol.\n */\n setExportFrom(list: ReadonlyArray<string>): void {\n this.assertCanonical();\n this._exportFrom = list;\n }\n\n /**\n * Assigns the output file this symbol will be emitted into.\n *\n * This may only be set once.\n */\n setFile(file: File): void {\n this.assertCanonical();\n if (this._file && this._file !== file) {\n const message = `Symbol ${this.canonical.toString()} is already assigned to a different file.`;\n debug(message, 'symbol');\n throw new Error(message);\n }\n this._file = file;\n }\n\n /**\n * Assigns the conflict‑resolved final local name for this symbol.\n *\n * This may only be set once.\n */\n setFinalName(name: string): void {\n this.assertCanonical();\n if (this._finalName && this._finalName !== name) {\n const message = `Symbol finalName has already been resolved for ${this.canonical.toString()}.`;\n debug(message, 'symbol');\n throw new Error(message);\n }\n this._finalName = name;\n }\n\n /**\n * Sets how this symbol should be imported.\n *\n * @param kind — The import strategy (named/default/namespace).\n */\n setImportKind(kind: BindingKind): void {\n this.assertCanonical();\n this._importKind = kind;\n }\n\n /**\n * Sets the symbol's kind (class, type, alias, variable, etc.).\n *\n * @param kind — The new symbol kind.\n */\n setKind(kind: SymbolKind): void {\n this.assertCanonical();\n this._kind = kind;\n }\n\n /**\n * Updates the intended user‑facing name for this symbol.\n *\n * @param name — The new name.\n */\n setName(name: string): void {\n this.assertCanonical();\n this._name = name;\n }\n\n /**\n * Sets a custom function to sanitize the symbol's name.\n *\n * @param fn — The name sanitizer function to apply.\n */\n setNameSanitizer(fn: SymbolNameSanitizer): void {\n this.assertCanonical();\n this._nameSanitizer = fn;\n }\n\n /**\n * Binds the node that defines this symbol.\n *\n * This may only be set once.\n */\n setNode(node: INode): void {\n this.assertCanonical();\n if (this._node && this._node !== node) {\n const message = `Symbol ${this.canonical.toString()} is already bound to a different node.`;\n debug(message, 'symbol');\n throw new Error(message);\n }\n this._node = node;\n node.symbol = this;\n }\n\n /**\n * Returns a debug‑friendly string representation identifying the symbol.\n */\n toString(): string {\n return `[Symbol ${this.name}#${this.id}]`;\n }\n\n /**\n * Ensures this symbol is canonical before allowing mutation.\n *\n * A symbol that has been marked as a stub (i.e., its `_canonical` points\n * to a different symbol) may not be mutated. This guard throws an error\n * if any setter attempts to modify a stub, preventing accidental writes\n * to non‑canonical instances.\n *\n * @throws {Error} If the symbol is a stub and is being mutated.\n */\n private assertCanonical(): void {\n if (this._canonical && this._canonical !== this) {\n const message = `Illegal mutation of stub symbol ${this.toString()} → canonical: ${this._canonical.toString()}`;\n debug(message, 'symbol');\n throw new Error(message);\n }\n }\n}\n","import type { ISymbolMeta } from '../extensions';\nimport { Symbol } from './symbol';\nimport type { ISymbolIdentifier, ISymbolIn, ISymbolRegistry } 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 _queryCache: Map<QueryCacheKey, ReadonlyArray<SymbolId>> = new Map();\n private _queryCacheDependencies: Map<QueryCacheKey, Set<QueryCacheKey>> =\n new Map();\n private _registered: Set<SymbolId> = new Set();\n private _stubs: Set<SymbolId> = new Set();\n private _stubCache: Map<QueryCacheKey, SymbolId> = new Map();\n private _values: Map<SymbolId, Symbol> = new Map();\n\n get(identifier: ISymbolIdentifier): Symbol | undefined {\n return typeof identifier === 'number'\n ? this._values.get(identifier)\n : this.query(identifier)[0];\n }\n\n isRegistered(identifier: ISymbolIdentifier): boolean {\n const symbol = this.get(identifier);\n return symbol ? this._registered.has(symbol.id) : false;\n }\n\n get nextId(): SymbolId {\n return this._id++;\n }\n\n query(filter: ISymbolMeta): ReadonlyArray<Symbol> {\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): Symbol {\n const [registered] = this.query(meta);\n if (registered) return registered;\n\n const cacheKey = this.buildCacheKey(meta);\n const cachedId = this._stubCache.get(cacheKey);\n if (cachedId !== undefined) return this._values.get(cachedId)!;\n\n const stub = new Symbol({ meta, name: '' }, this.nextId);\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): Symbol {\n const result = new Symbol(symbol, this.nextId);\n\n this._values.set(result.id, result);\n this._registered.add(result.id);\n\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\n return result;\n }\n\n *registered(): IterableIterator<Symbol> {\n for (const id of this._registered.values()) {\n yield this._values.get(id)!;\n }\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: Symbol, 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._stubs.delete(stubId);\n stub.setCanonical(symbol);\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';\nimport { FileRegistry } from '../files/registry';\nimport { defaultExtensions } from '../languages/extensions';\nimport { defaultNameConflictResolvers } from '../languages/resolvers';\nimport type { Extensions, NameConflictResolvers } from '../languages/types';\nimport { NodeRegistry } from '../nodes/registry';\nimport type { IOutput } from '../output';\nimport { Planner } from '../planner/planner';\nimport { simpleNameConflictResolver } from '../planner/resolvers';\nimport type { NameConflictResolver } from '../planner/types';\nimport type { Renderer } from '../renderer';\nimport { SymbolRegistry } from '../symbols/registry';\nimport type { IProject } from './types';\n\nexport class Project implements IProject {\n readonly files: FileRegistry;\n readonly nodes = new NodeRegistry();\n readonly symbols = new SymbolRegistry();\n\n readonly defaultFileName: string;\n readonly defaultNameConflictResolver: NameConflictResolver;\n readonly extensions: Extensions;\n readonly fileName?: (name: string) => string;\n readonly nameConflictResolvers: NameConflictResolvers;\n readonly renderers: ReadonlyArray<Renderer>;\n readonly root: string;\n\n constructor(\n args: Pick<\n Partial<IProject>,\n | 'defaultFileName'\n | 'defaultNameConflictResolver'\n | 'extensions'\n | 'fileName'\n | 'nameConflictResolvers'\n | 'renderers'\n > &\n Pick<IProject, 'root'>,\n ) {\n const fileName = args.fileName;\n this.defaultFileName = args.defaultFileName ?? 'main';\n this.defaultNameConflictResolver =\n args.defaultNameConflictResolver ?? simpleNameConflictResolver;\n this.extensions = {\n ...defaultExtensions,\n ...args.extensions,\n };\n this.fileName = typeof fileName === 'string' ? () => fileName : fileName;\n this.files = new FileRegistry(this);\n this.nameConflictResolvers = {\n ...defaultNameConflictResolvers,\n ...args.nameConflictResolvers,\n };\n this.renderers = args.renderers ?? [];\n this.root = path.resolve(args.root).replace(/[/\\\\]+$/, '');\n }\n\n render(meta?: IProjectRenderMeta): ReadonlyArray<IOutput> {\n new Planner(this).plan(meta);\n const files: Array<IOutput> = [];\n for (const file of this.files.registered()) {\n if (file.finalPath && file.renderer) {\n const content = file.renderer.render({ file, meta, project: this });\n files.push({ content, path: file.finalPath });\n }\n }\n return files;\n }\n}\n"],"mappings":"0kBAAA,MAAa,EAAY,cACZ,EAAY,cACZ,EAAc,gBCE3B,EAAA,QAAO,SAAA,EAAA,EAAA,UAAwB,CAAC,SAEhC,MAAM,EAAe,CACnB,SAAUA,EAAAA,QAAO,YACjB,IAAKA,EAAAA,QAAO,WACZ,KAAMA,EAAAA,QAAO,aACb,SAAUA,EAAAA,QAAO,WACjB,OAAQA,EAAAA,QAAO,cAChB,CAED,SAAgB,EAAM,EAAiB,EAAkC,CACvE,IAAM,EAAQ,QAAQ,IAAI,MAC1B,GAAI,CAAC,EAAO,OAEZ,IAAM,EAAS,EAAM,MAAM,IAAI,CAAC,IAAK,GAAM,EAAE,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AAM,EAAO,KAAK,QAAQ,IAAI,EAAO,CACrC,GACE,GAAM,MACN,KAAK,SAAS,KAAK,mBAAmB,EAAK,KAAK,CAAE,EAAc,CAChE,CACA,IAAM,EAAW,KAAK,cAAc,EAAK,KAAK,CAC9C,KAAK,WAAW,OAAO,EAAS,CAChC,KAAK,OAAO,OAAO,EAAO,CAC1B,EAAK,aAAa,EAAO,GAK/B,oBAA4B,EAAgC,CAC1D,MAAO,GAAG,EAAW,GAAG,GAAG,KAAK,UAAU,EAAW,GAAG,KC5K/C,EAAb,KAAyC,CACvC,MACA,MAAiB,IAAI,EACrB,QAAmB,IAAI,EAEvB,gBACA,4BACA,WACA,SACA,sBACA,UACA,KAEA,YACE,EAUA,CACA,IAAM,EAAW,EAAK,SACtB,KAAK,gBAAkB,EAAK,iBAAmB,OAC/C,KAAK,4BACH,EAAK,6BAA+B,EACtC,KAAK,WAAa,CAChB,GAAG,EACH,GAAG,EAAK,WACT,CACD,KAAK,SAAW,OAAO,GAAa,aAAiB,EAAW,EAChE,KAAK,MAAQ,IAAI,EAAa,KAAK,CACnC,KAAK,sBAAwB,CAC3B,GAAG,EACH,GAAG,EAAK,sBACT,CACD,KAAK,UAAY,EAAK,WAAa,EAAE,CACrC,KAAK,KAAOC,EAAAA,QAAK,QAAQ,EAAK,KAAK,CAAC,QAAQ,UAAW,GAAG,CAG5D,OAAO,EAAmD,CACxD,IAAI,EAAQ,KAAK,CAAC,KAAK,EAAK,CAC5B,IAAMC,EAAwB,EAAE,CAChC,IAAK,IAAM,KAAQ,KAAK,MAAM,YAAY,CACxC,GAAI,EAAK,WAAa,EAAK,SAAU,CACnC,IAAM,EAAU,EAAK,SAAS,OAAO,CAAE,OAAM,OAAM,QAAS,KAAM,CAAC,CACnE,EAAM,KAAK,CAAE,UAAS,KAAM,EAAK,UAAW,CAAC,CAGjD,OAAO"}
|
|
1
|
+
{"version":3,"file":"index.cjs","names":["colors","cachedDebugGroups: Set<string> | undefined","path","defaultExtensions: Extensions","simpleNameConflictResolver: NameConflictResolver","underscoreNameConflictResolver: NameConflictResolver","defaultNameConflictResolvers: NameConflictResolvers","path","ref","kindRank: Record<SymbolKind, number>","names: NameScopes","file","path","ctx: RenderContext","exports","scope","Symbol","sets: Array<Set<SymbolId>>","Symbol","entries: Array<IndexEntry>","path","path","files: Array<IOutput>","path: Array<string>","cursor: StructureNode | undefined","path","path","cursor: StructureNode | null"],"sources":["../src/brands.ts","../src/log.ts","../src/files/file.ts","../src/guards.ts","../src/languages/extensions.ts","../src/planner/resolvers.ts","../src/languages/resolvers.ts","../src/files/registry.ts","../src/refs/refs.ts","../src/nodes/registry.ts","../src/project/namespace.ts","../src/planner/scope.ts","../src/planner/analyzer.ts","../src/planner/planner.ts","../src/symbols/symbol.ts","../src/symbols/registry.ts","../src/project/project.ts","../src/structure/node.ts","../src/structure/model.ts"],"sourcesContent":["export const fileBrand = 'heyapi.file';\nexport const nodeBrand = 'heyapi.node';\nexport const symbolBrand = 'heyapi.symbol';\n","import colors from 'ansi-colors';\n// @ts-expect-error\nimport colorSupport from 'color-support';\n\ncolors.enabled = colorSupport().hasBasic;\n\n/**\n * Accepts a value or a readonly array of values of type T.\n */\nexport type MaybeArray<T> = T | ReadonlyArray<T>;\n\n/**\n * Accepts a value or a function returning a value.\n */\nexport type MaybeFunc<T extends (...args: Array<any>) => any> =\n | T\n | ReturnType<T>;\n\nconst DEBUG_NAMESPACE = 'heyapi';\n\nconst NO_WARNINGS = /^(1|true|yes|on)$/i.test(\n process.env.HEYAPI_DISABLE_WARNINGS ?? '',\n);\n\nconst DebugGroups = {\n analyzer: colors.greenBright,\n dsl: colors.cyanBright,\n file: colors.yellowBright,\n registry: colors.blueBright,\n symbol: colors.magentaBright,\n} as const;\n\nconst WarnGroups = {\n deprecated: colors.magentaBright,\n} as const;\n\nlet cachedDebugGroups: Set<string> | undefined;\nfunction getDebugGroups(): Set<string> {\n if (cachedDebugGroups) return cachedDebugGroups;\n\n const value = process.env.DEBUG;\n cachedDebugGroups = new Set(\n value ? value.split(',').map((x) => x.trim().toLowerCase()) : [],\n );\n\n return cachedDebugGroups;\n}\n\n/**\n * Tracks which deprecations have been shown to avoid spam.\n */\nconst shownDeprecations = new Set<string>();\n\nfunction debug(message: string, group: keyof typeof DebugGroups) {\n const groups = getDebugGroups();\n if (\n !(\n groups.has('*') ||\n groups.has(`${DEBUG_NAMESPACE}:*`) ||\n groups.has(`${DEBUG_NAMESPACE}:${group}`) ||\n groups.has(group)\n )\n ) {\n return;\n }\n\n const color = DebugGroups[group] ?? colors.whiteBright;\n const prefix = color(`${DEBUG_NAMESPACE}:${group}`);\n\n console.debug(`${prefix} ${message}`);\n}\n\nfunction warn(message: string, group: keyof typeof WarnGroups) {\n if (NO_WARNINGS) return;\n\n const color = WarnGroups[group] ?? colors.yellowBright;\n\n console.warn(color(`${message}`));\n}\n\nfunction warnDeprecated({\n context,\n field,\n replacement,\n}: {\n context?: string;\n field: string;\n replacement?: MaybeFunc<(field: string) => MaybeArray<string>>;\n}) {\n const key = context\n ? `${context}:${field}:${JSON.stringify(replacement)}`\n : `${field}:${JSON.stringify(replacement)}`;\n\n if (shownDeprecations.has(key)) return;\n shownDeprecations.add(key);\n\n let message = `\\`${field}\\` is deprecated.`;\n\n if (replacement) {\n const reps =\n typeof replacement === 'function' ? replacement(field) : replacement;\n const repArray = reps instanceof Array ? reps : [reps];\n const repString = repArray.map((r) => `\\`${r}\\``).join(' or ');\n message += ` Use ${repString} instead.`;\n }\n\n const prefix = context ? `[${context}] ` : '';\n warn(`${prefix}${message}`, 'deprecated');\n}\n\nexport const log = {\n debug,\n warn,\n warnDeprecated,\n};\n","import path from 'node:path';\n\nimport type { ExportModule, ImportModule } from '../bindings';\nimport { fileBrand } from '../brands';\nimport type { Language } from '../languages/types';\nimport { log } from '../log';\nimport type { INode } from '../nodes/node';\nimport type { NameScopes } from '../planner/scope';\nimport type { IProject } from '../project/types';\nimport type { Renderer } from '../renderer';\nimport type { IFileIn } from './types';\n\nexport class File<Node extends INode = INode> {\n /**\n * Exports from this file.\n */\n private _exports: Array<ExportModule> = [];\n /**\n * File extension (e.g. `.ts`).\n */\n private _extension?: string;\n /**\n * Actual emitted file path, including extension and directories.\n */\n private _finalPath?: string;\n /**\n * Imports to this file.\n */\n private _imports: Array<ImportModule> = [];\n /**\n * Language of the file.\n */\n private _language?: Language;\n /**\n * Logical, extension-free path used for planning and routing.\n */\n private _logicalFilePath: string;\n /**\n * Base name of the file (without extension).\n */\n private _name?: string;\n /**\n * Syntax nodes contained in this file.\n */\n private _nodes: Array<Node> = [];\n /**\n * Renderer assigned to this file.\n */\n private _renderer?: Renderer;\n\n /** Brand used for identifying files. */\n readonly '~brand' = fileBrand;\n /** All names defined in this file, including local scopes. */\n allNames: NameScopes = new Map();\n /** Whether this file is external to the project. */\n external: boolean;\n /** Unique identifier for the file. */\n readonly id: number;\n /** The project this file belongs to. */\n readonly project: IProject;\n /** Names declared at the top level of the file. */\n topLevelNames: NameScopes = new Map();\n\n constructor(input: IFileIn, id: number, project: IProject) {\n this.external = input.external ?? false;\n this.id = id;\n if (input.language !== undefined) this._language = input.language;\n this._logicalFilePath = input.logicalFilePath.split(path.sep).join('/');\n if (input.name !== undefined) this._name = input.name;\n this.project = project;\n }\n\n /**\n * Exports from this file.\n */\n get exports(): ReadonlyArray<ExportModule> {\n return [...this._exports];\n }\n\n /**\n * Read-only accessor for the file extension.\n */\n get extension(): string | undefined {\n if (this.external) return;\n if (this._extension) return this._extension;\n const language = this.language;\n const extension = language ? this.project.extensions[language] : undefined;\n if (extension && extension[0]) return extension[0];\n return;\n }\n\n /**\n * Read-only accessor for the final emitted path.\n *\n * If undefined, the file has not yet been assigned a final path\n * or is external to the project and should not be emitted.\n */\n get finalPath(): string | undefined {\n if (this._finalPath) return this._finalPath;\n const dirs = this._logicalFilePath\n ? this._logicalFilePath.split('/').slice(0, -1)\n : [];\n return [...dirs, `${this.name}${this.extension ?? ''}`].join('/');\n }\n\n /**\n * Imports to this file.\n */\n get imports(): ReadonlyArray<ImportModule> {\n return [...this._imports];\n }\n\n /**\n * Language of the file; inferred from nodes or fallback if not set explicitly.\n */\n get language(): Language | undefined {\n if (this._language) return this._language;\n if (this._nodes[0]) return this._nodes[0].language;\n return;\n }\n\n /**\n * Logical, extension-free path used for planning and routing.\n */\n get logicalFilePath(): string {\n return this._logicalFilePath;\n }\n\n /**\n * Base name of the file (without extension).\n *\n * If no name was set explicitly, it is inferred from the logical file path.\n */\n get name(): string {\n if (this._name) return this._name;\n const name = this._logicalFilePath.split('/').pop();\n if (name) return name;\n const message = `File ${this.toString()} has no name`;\n log.debug(message, 'file');\n throw new Error(message);\n }\n\n /**\n * Syntax nodes contained in this file.\n */\n get nodes(): ReadonlyArray<Node> {\n return [...this._nodes];\n }\n\n /**\n * Renderer assigned to this file.\n */\n get renderer(): Renderer | undefined {\n return this._renderer;\n }\n\n /**\n * Add an export group to the file.\n */\n addExport(group: ExportModule): void {\n this._exports.push(group);\n }\n\n /**\n * Add an import group to the file.\n */\n addImport(group: ImportModule): void {\n this._imports.push(group);\n }\n\n /**\n * Add a syntax node to the file.\n */\n addNode(node: Node): void {\n this._nodes.push(node);\n node.file = this;\n }\n\n /**\n * Sets the file extension.\n */\n setExtension(extension: string): void {\n this._extension = extension;\n }\n\n /**\n * Sets the final emitted path of the file.\n */\n setFinalPath(path: string): void {\n this._finalPath = path;\n }\n\n /**\n * Sets the language of the file.\n */\n setLanguage(lang: Language): void {\n this._language = lang;\n }\n\n /**\n * Sets the name of the file.\n */\n setName(name: string): void {\n this._name = name;\n }\n\n /**\n * Sets the renderer assigned to this file.\n */\n setRenderer(renderer: Renderer): void {\n this._renderer = renderer;\n }\n\n /**\n * Returns a debug‑friendly string representation identifying the file.\n */\n toString(): string {\n return `[File ${this._logicalFilePath}#${this.id}]`;\n }\n}\n","import { nodeBrand, symbolBrand } from './brands';\nimport type { INode } from './nodes/node';\nimport type { Ref } from './refs/types';\nimport type { Symbol } from './symbols/symbol';\n\nexport function isBrand(value: unknown, brand: string): value is INode {\n if (!value || typeof value !== 'object') return false;\n return (value as any)['~brand'] === brand;\n}\n\nexport function isNode(value: unknown): value is INode {\n if (!value || typeof value !== 'object') return false;\n return isBrand(value, nodeBrand);\n}\n\nexport function isNodeRef(value: Ref<unknown>): value is Ref<INode> {\n return isBrand(value['~ref'], nodeBrand);\n}\n\nexport function isSymbol(value: unknown): value is Symbol {\n return isBrand(value, symbolBrand);\n}\n\nexport function isSymbolRef(value: Ref<unknown>): value is Ref<Symbol> {\n return isBrand(value['~ref'], symbolBrand);\n}\n","import type { Extensions } from './types';\n\nexport const defaultExtensions: Extensions = {\n c: ['.c'],\n 'c#': ['.cs'],\n 'c++': ['.cpp', '.hpp'],\n css: ['.css'],\n dart: ['.dart'],\n go: ['.go'],\n haskell: ['.hs'],\n html: ['.html'],\n java: ['.java'],\n javascript: ['.js', '.jsx'],\n json: ['.json'],\n kotlin: ['.kt'],\n lua: ['.lua'],\n markdown: ['.md'],\n matlab: ['.m'],\n perl: ['.pl'],\n php: ['.php'],\n python: ['.py'],\n r: ['.r'],\n ruby: ['.rb'],\n rust: ['.rs'],\n scala: ['.scala'],\n shell: ['.sh'],\n sql: ['.sql'],\n swift: ['.swift'],\n typescript: ['.ts', '.tsx'],\n yaml: ['.yaml', '.yml'],\n};\n","import type { NameConflictResolver } from './types';\n\nexport const simpleNameConflictResolver: NameConflictResolver = ({\n attempt,\n baseName,\n}) => (attempt === 0 ? baseName : `${baseName}${attempt + 1}`);\n\nexport const underscoreNameConflictResolver: NameConflictResolver = ({\n attempt,\n baseName,\n}) => (attempt === 0 ? baseName : `${baseName}_${attempt + 1}`);\n","import { underscoreNameConflictResolver } from '../planner/resolvers';\nimport type { NameConflictResolvers } from './types';\n\nexport const defaultNameConflictResolvers: NameConflictResolvers = {\n php: underscoreNameConflictResolver,\n python: underscoreNameConflictResolver,\n ruby: underscoreNameConflictResolver,\n};\n","import path from 'node:path';\n\nimport type { IProject } from '../project/types';\nimport { File } from './file';\nimport type { FileKeyArgs, IFileIn, IFileRegistry } from './types';\n\ntype FileId = number;\ntype FileKey = string;\n\nexport class FileRegistry implements IFileRegistry {\n private _id: FileId = 0;\n private _values: Map<FileKey, File> = new Map();\n private readonly project: IProject;\n\n constructor(project: IProject) {\n this.project = project;\n }\n\n get(args: FileKeyArgs): File | undefined {\n return this._values.get(this.createFileKey(args));\n }\n\n isRegistered(args: FileKeyArgs): boolean {\n return this._values.has(this.createFileKey(args));\n }\n\n get nextId(): FileId {\n return this._id++;\n }\n\n register(file: IFileIn): File {\n const key = this.createFileKey(file);\n\n let result = this._values.get(key);\n if (result) {\n if (file.name) {\n result.setName(file.name);\n }\n } else {\n result = new File(file, this.nextId, this.project);\n }\n\n this._values.set(key, result);\n\n return result;\n }\n\n *registered(): IterableIterator<File> {\n for (const file of this._values.values()) {\n yield file;\n }\n }\n\n private createFileKey(args: FileKeyArgs): string {\n const logicalPath = args.logicalFilePath.split(path.sep).join('/');\n return `${args.external ? 'ext:' : ''}${logicalPath}${args.language ? `:${args.language}` : ''}`;\n }\n}\n","import type { FromRef, FromRefs, Ref, Refs } from './types';\n\n/**\n * Wraps a single value in a Ref object.\n *\n * If the value is already a Ref, returns it as-is (idempotent).\n *\n * @example\n * ```ts\n * const r = ref(123); // { '~ref': 123 }\n * console.log(r['~ref']); // 123\n *\n * const r2 = ref(r); // { '~ref': 123 } (not double-wrapped)\n * ```\n */\nexport const ref = <T>(value: T): Ref<T> => {\n if (isRef(value)) {\n return value as Ref<T>;\n }\n return { '~ref': value } as Ref<T>;\n};\n\n/**\n * Converts a plain object to an object of Refs (deep, per property).\n *\n * @example\n * ```ts\n * const obj = { a: 1, b: \"x\" };\n * const refs = refs(obj); // { a: { '~ref': 1 }, b: { '~ref': \"x\" } }\n * ```\n */\nexport const refs = <T extends Record<string, unknown>>(obj: T): Refs<T> => {\n const result = {} as Refs<T>;\n for (const key in obj) {\n if (Object.prototype.hasOwnProperty.call(obj, key)) {\n result[key] = ref(obj[key]);\n }\n }\n return result;\n};\n\n/**\n * Unwraps a single Ref object to its value.\n *\n * @example\n * ```ts\n * const r = { '~ref': 42 };\n * const n = fromRef(r); // 42\n * console.log(n); // 42\n * ```\n */\nexport const fromRef = <T extends Ref<unknown> | undefined>(\n ref: T,\n): FromRef<T> => ref?.['~ref'] as FromRef<T>;\n\n/**\n * Converts an object of Refs back to a plain object (unwraps all refs).\n *\n * @example\n * ```ts\n * const refs = { a: { '~ref': 1 }, b: { '~ref': \"x\" } };\n * const plain = fromRefs(refs); // { a: 1, b: \"x\" }\n * ```\n */\nexport const fromRefs = <T extends Refs<Record<string, unknown>>>(\n obj: T,\n): FromRefs<T> => {\n const result = {} as FromRefs<T>;\n for (const key in obj) {\n if (Object.prototype.hasOwnProperty.call(obj, key)) {\n result[key] = fromRef(obj[key]!) as (typeof result)[typeof key];\n }\n }\n return result;\n};\n\n/**\n * Checks whether a value is a Ref object.\n *\n * @param value Value to check\n * @returns True if the value is a Ref object.\n */\nexport const isRef = <T>(value: unknown): value is Ref<T> =>\n typeof value === 'object' && value !== null && '~ref' in value;\n","import { fromRef, ref } from '../refs/refs';\nimport type { Ref } from '../refs/types';\nimport type { INode } from './node';\nimport type { INodeRegistry } from './types';\n\nexport class NodeRegistry implements INodeRegistry {\n private list: Array<Ref<INode | null>> = [];\n\n add(node: INode | null): number {\n const index = this.list.push(ref(node));\n return index - 1;\n }\n\n *all(): Iterable<INode> {\n for (const r of this.list) {\n const node = fromRef(r);\n if (node) yield node;\n }\n }\n\n remove(index: number): void {\n this.list[index] = ref(null);\n }\n\n update(index: number, node: INode | null): void {\n this.list[index] = ref(node);\n }\n}\n","import type { SymbolKind } from '../symbols/types';\n\nconst kindRank: Record<SymbolKind, number> = {\n class: 3,\n enum: 4,\n function: 5,\n interface: 1,\n namespace: 0,\n type: 2,\n var: 6,\n};\n\n/**\n * Returns true if two declarations of given kinds\n * are allowed to share the same identifier in TypeScript.\n */\nexport function canShareName(a: SymbolKind, b: SymbolKind): boolean {\n // sort based on TypeScript merge precedence so `a` is always the weaker merge candidate\n // ensures that asymmetric merges like `type + var` are correctly handled\n if (kindRank[a] > kindRank[b]) {\n [a, b] = [b, a];\n }\n\n switch (a) {\n case 'interface':\n return b === 'class' || b === 'interface';\n case 'namespace':\n return (\n b === 'class' || b === 'enum' || b === 'function' || b === 'namespace'\n );\n case 'type':\n // type can only merge with value-only declarations\n return b === 'function' || b === 'var';\n default:\n return false;\n }\n}\n","import type { Ref } from '../refs/types';\nimport type { Symbol } from '../symbols/symbol';\nimport type { SymbolKind } from '../symbols/types';\n\nexport type NameScopes = Map<string, Set<SymbolKind>>;\n\nexport type Scope = {\n /** Child scopes. */\n children: Array<Scope>;\n /** Resolved names in this scope. */\n localNames: NameScopes;\n /** Parent scope, if any. */\n parent?: Scope;\n /** Symbols registered in this scope. */\n symbols: Array<Ref<Symbol>>;\n};\n\nexport type AssignOptions = {\n /** The primary scope in which to assign a symbol's final name. */\n scope: Scope;\n /** Additional scopes to update as side effects when assigning a symbol's final name. */\n scopesToUpdate: ReadonlyArray<Scope>;\n};\n\nexport const createScope = (\n args: {\n localNames?: NameScopes;\n parent?: Scope;\n } = {},\n): Scope => ({\n children: [],\n localNames: args.localNames || new Map(),\n parent: args.parent,\n symbols: [],\n});\n","import { isNodeRef, isSymbolRef } from '../guards';\nimport type { INode, NodeRelationship } from '../nodes/node';\nimport { fromRef, isRef, ref } from '../refs/refs';\nimport type { Ref } from '../refs/types';\nimport type { Symbol } from '../symbols/symbol';\nimport type { NameScopes, Scope } from './scope';\nimport { createScope } from './scope';\nimport type { IAnalysisContext, Input } from './types';\n\nexport class AnalysisContext implements IAnalysisContext {\n /**\n * Stack of parent nodes during analysis.\n *\n * The top of the stack is the current semantic container.\n */\n private _parentStack: Array<INode> = [];\n\n scope: Scope;\n scopes: Scope = createScope();\n symbol?: Symbol;\n\n constructor(node: INode) {\n this._parentStack.push(node);\n this.scope = this.scopes;\n this.symbol = node.symbol;\n }\n\n /**\n * Get the current semantic parent (top of stack).\n */\n get currentParent(): INode | undefined {\n return this._parentStack[this._parentStack.length - 1];\n }\n\n /**\n * Register a child node under the current parent.\n */\n addChild(child: INode, relationship: NodeRelationship = 'container'): void {\n const parent = this.currentParent;\n if (!parent) return;\n\n if (!parent.structuralChildren) {\n parent.structuralChildren = new Map();\n }\n parent.structuralChildren.set(child, relationship);\n\n if (!child.structuralParents) {\n child.structuralParents = new Map();\n }\n child.structuralParents.set(parent, relationship);\n }\n\n addDependency(symbol: Ref<Symbol>): void {\n if (this.symbol !== fromRef(symbol)) {\n this.scope.symbols.push(symbol);\n }\n }\n\n analyze(input: Input): void {\n const value = isRef(input) ? input : ref(input);\n if (isSymbolRef(value)) {\n const symbol = fromRef(value);\n // avoid adding self as child\n if (symbol.node && this.currentParent !== symbol.node) {\n this.addChild(symbol.node, 'reference');\n }\n this.addDependency(value);\n } else if (isNodeRef(value)) {\n const node = fromRef(value);\n this.addChild(node, 'container');\n this.pushParent(node);\n node.analyze(this);\n this.popParent();\n }\n }\n\n localNames(scope: Scope): NameScopes {\n const names: NameScopes = new Map();\n for (const [name, kinds] of scope.localNames) {\n names.set(name, new Set(kinds));\n }\n if (scope.parent) {\n const parentNames = this.localNames(scope.parent);\n for (const [name, kinds] of parentNames) {\n if (!names.has(name)) {\n names.set(name, kinds);\n } else {\n const existingKinds = names.get(name)!;\n for (const kind of kinds) {\n existingKinds.add(kind);\n }\n }\n }\n }\n return names;\n }\n\n /**\n * Pop the current semantic parent.\n * Call this when exiting a container node.\n */\n popParent(): void {\n this._parentStack.pop();\n }\n\n popScope(): void {\n this.scope = this.scope.parent ?? this.scope;\n }\n\n /**\n * Push a node as the current semantic parent.\n */\n pushParent(node: INode): void {\n this._parentStack.push(node);\n }\n\n pushScope(): void {\n const scope = createScope({ parent: this.scope });\n this.scope.children.push(scope);\n this.scope = scope;\n }\n\n walkScopes(\n callback: (symbol: Ref<Symbol>, scope: Scope) => void,\n scope: Scope = this.scopes,\n ): void {\n this.scope = scope;\n for (const symbol of scope.symbols) {\n callback(symbol, scope);\n }\n for (const child of scope.children) {\n scope = child;\n this.walkScopes(callback, scope);\n }\n this.scope = this.scopes;\n }\n}\n\nexport class Analyzer {\n private nodeCache = new WeakMap<INode, AnalysisContext>();\n\n analyzeNode(node: INode): AnalysisContext {\n const cached = this.nodeCache.get(node);\n if (cached) return cached;\n\n node.root = true;\n const ctx = new AnalysisContext(node);\n node.analyze(ctx);\n\n this.nodeCache.set(node, ctx);\n return ctx;\n }\n\n analyze(\n nodes: Iterable<INode>,\n callback?: (ctx: AnalysisContext, node: INode) => void,\n ): void {\n for (const node of nodes) {\n const ctx = this.analyzeNode(node);\n callback?.(ctx, node);\n }\n }\n}\n","import path from 'node:path';\n\nimport type { ExportModule, ImportModule } from '../bindings';\nimport type { IProjectRenderMeta } from '../extensions';\nimport type { File } from '../files/file';\nimport type { INode } from '../nodes/node';\nimport { canShareName } from '../project/namespace';\nimport type { IProject } from '../project/types';\nimport { fromRef } from '../refs/refs';\nimport type { RenderContext } from '../renderer';\nimport type { Symbol } from '../symbols/symbol';\nimport type { SymbolKind } from '../symbols/types';\nimport type { AnalysisContext } from './analyzer';\nimport { Analyzer } from './analyzer';\nimport type { AssignOptions, Scope } from './scope';\nimport { createScope } from './scope';\n\nconst isTypeOnlyKind = (kind: SymbolKind) =>\n kind === 'type' || kind === 'interface';\n\nexport class Planner {\n private readonly analyzer = new Analyzer();\n private readonly cacheResolvedNames = new Set<number>();\n private readonly project: IProject;\n\n constructor(project: IProject) {\n this.project = project;\n }\n\n /**\n * Executes the planning phase for the project.\n */\n plan(meta?: IProjectRenderMeta) {\n this.cacheResolvedNames.clear();\n this.allocateFiles();\n this.assignLocalNames();\n this.resolveFilePaths(meta);\n this.planExports();\n this.planImports();\n }\n\n /**\n * Creates and assigns a file to every node, re-export,\n * and external dependency.\n */\n private allocateFiles(): void {\n this.analyzer.analyze(this.project.nodes.all(), (ctx, node) => {\n const symbol = node.symbol;\n if (!symbol) return;\n\n const file = this.project.files.register({\n external: false,\n language: node.language,\n logicalFilePath:\n symbol.getFilePath?.(symbol) || this.project.defaultFileName,\n });\n file.addNode(node);\n symbol.setFile(file);\n for (const exportFrom of symbol.exportFrom) {\n this.project.files.register({\n external: false,\n language: file.language,\n logicalFilePath: exportFrom,\n });\n }\n ctx.walkScopes((dependency) => {\n const dep = fromRef(dependency);\n if (dep.external && dep.isCanonical && !dep.file) {\n const file = this.project.files.register({\n external: true,\n language: dep.node?.language,\n logicalFilePath: dep.external,\n });\n dep.setFile(file);\n }\n });\n });\n }\n\n /**\n * Assigns final names to all symbols.\n *\n * First assigns top-level (file-scoped) symbol names, then local symbols.\n */\n private assignLocalNames(): void {\n this.analyzer.analyze(this.project.nodes.all(), (ctx, node) => {\n const symbol = node.symbol;\n if (!symbol) return;\n this.assignTopLevelName({ ctx, node, symbol });\n });\n\n this.analyzer.analyze(this.project.nodes.all(), (ctx, node) => {\n const file = node.file;\n if (!file) return;\n ctx.walkScopes((dependency) => {\n const dep = fromRef(dependency);\n // top-level or external symbol\n if (dep.file) return;\n // TODO: pass node\n this.assignLocalName({\n ctx,\n file,\n scopesToUpdate: [createScope({ localNames: file.allNames })],\n symbol: dep,\n });\n });\n });\n }\n\n /**\n * Resolves and sets final file paths for all non-external files. Attaches renderers.\n *\n * Uses the project's fileName function if provided, otherwise uses the file's current name.\n *\n * Resolves final paths relative to the project's root directory.\n */\n private resolveFilePaths(meta?: IProjectRenderMeta): void {\n for (const file of this.project.files.registered()) {\n if (file.external) {\n file.setFinalPath(file.logicalFilePath);\n continue;\n }\n const finalName = this.project.fileName?.(file.name) || file.name;\n file.setName(finalName);\n const finalPath = file.finalPath;\n if (finalPath) {\n file.setFinalPath(path.resolve(this.project.root, finalPath));\n }\n const ctx: RenderContext = { file, meta, project: this.project };\n const renderer = this.project.renderers.find((r) => r.supports(ctx));\n if (renderer) file.setRenderer(renderer);\n }\n }\n\n /**\n * Plans exports by analyzing all exported symbols.\n *\n * Registers re-export targets as files and creates new exported symbols for them.\n *\n * Assigns names to re-exported symbols and collects re-export metadata,\n * distinguishing type-only exports based on symbol kinds.\n */\n private planExports(): void {\n const seenByFile = new Map<\n File,\n Map<string, { kinds: Set<SymbolKind>; symbol: Symbol }>\n >();\n const sourceFile = new Map<number, File>();\n\n this.analyzer.analyze(this.project.nodes.all(), (ctx, node) => {\n if (!node.exported) return;\n\n const symbol = node.symbol;\n if (!symbol) return;\n\n const file = node.file;\n if (!file) return;\n\n for (const exportFrom of symbol.exportFrom) {\n const target = this.project.files.register({\n external: false,\n language: node.language,\n logicalFilePath: exportFrom,\n });\n if (target.id === file.id) continue;\n\n let fileMap = seenByFile.get(target);\n if (!fileMap) {\n fileMap = new Map();\n seenByFile.set(target, fileMap);\n }\n\n const exp = this.project.symbols.register({\n exported: true,\n external: symbol.external,\n importKind: symbol.importKind,\n kind: symbol.kind,\n name: symbol.finalName,\n });\n exp.setFile(target);\n sourceFile.set(exp.id, file);\n // TODO: pass node\n this.assignTopLevelName({ ctx, symbol: exp });\n\n let entry = fileMap.get(exp.finalName);\n if (!entry) {\n entry = { kinds: new Set(), symbol: exp };\n fileMap.set(exp.finalName, entry);\n }\n entry.kinds.add(exp.kind);\n }\n });\n\n for (const [file, fileMap] of seenByFile) {\n const exports = new Map<File, ExportModule>();\n for (const [, entry] of fileMap) {\n const source = sourceFile.get(entry.symbol.id)!;\n let exp = exports.get(source);\n if (!exp) {\n exp = {\n canExportAll: true,\n exports: [],\n from: source,\n isTypeOnly: true,\n };\n }\n const isTypeOnly = [...entry.kinds].every((kind) =>\n isTypeOnlyKind(kind),\n );\n const exportedName = entry.symbol.finalName;\n exp.exports.push({\n exportedName,\n isTypeOnly,\n kind: entry.symbol.importKind,\n sourceName: entry.symbol.name,\n });\n if (entry.symbol.name !== entry.symbol.finalName) {\n exp.canExportAll = false;\n }\n if (!isTypeOnly) {\n exp.isTypeOnly = false;\n }\n exports.set(source, exp);\n }\n for (const [, exp] of exports) {\n file.addExport(exp);\n }\n }\n }\n\n /**\n * Plans imports by analyzing symbol dependencies across files.\n *\n * For external dependencies, assigns top-level names.\n *\n * Creates or reuses import symbols for dependencies from other files,\n * assigning names and updating import metadata including type-only flags.\n */\n private planImports(): void {\n const seenByFile = new Map<\n File,\n Map<\n string,\n {\n dep: Symbol;\n kinds: Set<SymbolKind>;\n symbol: Symbol;\n }\n >\n >();\n\n this.analyzer.analyze(this.project.nodes.all(), (ctx) => {\n const symbol = ctx.symbol;\n if (!symbol) return;\n\n const file = symbol.file;\n if (!file) return;\n\n let fileMap = seenByFile.get(file);\n if (!fileMap) {\n fileMap = new Map();\n seenByFile.set(file, fileMap);\n }\n\n ctx.walkScopes((dependency) => {\n const dep = fromRef(dependency);\n if (!dep.file || dep.file.id === file.id) return;\n\n if (dep.external) {\n // TODO: pass node\n this.assignTopLevelName({ ctx, symbol: dep });\n }\n\n const fromFileId = dep.file.id;\n const importedName = dep.finalName;\n const isTypeOnly = isTypeOnlyKind(dep.kind);\n const kind = dep.importKind;\n const key = `${fromFileId}|${importedName}|${kind}|${isTypeOnly}`;\n\n let entry = fileMap.get(key);\n if (!entry) {\n const imp = this.project.symbols.register({\n exported: dep.exported,\n external: dep.external,\n importKind: dep.importKind,\n kind: dep.kind,\n name: dep.finalName,\n });\n imp.setFile(file);\n // TODO: pass node\n this.assignTopLevelName({\n ctx,\n scope: createScope({ localNames: imp.file!.allNames }),\n symbol: imp,\n });\n entry = {\n dep,\n kinds: new Set(),\n symbol: imp,\n };\n fileMap.set(key, entry);\n entry.kinds.add(imp.kind);\n }\n\n dependency['~ref'] = entry.symbol;\n });\n });\n\n for (const [file, fileMap] of seenByFile) {\n const imports = new Map<File, ImportModule>();\n for (const [, entry] of fileMap) {\n const source = entry.dep.file!;\n let imp = imports.get(source);\n if (!imp) {\n imp = {\n from: source,\n imports: [],\n isTypeOnly: true,\n kind: 'named',\n };\n }\n const isTypeOnly = [...entry.kinds].every((kind) =>\n isTypeOnlyKind(kind),\n );\n if (entry.symbol.importKind === 'namespace') {\n imp.imports = [];\n imp.kind = 'namespace';\n imp.localName = entry.symbol.finalName;\n } else if (entry.symbol.importKind === 'default') {\n imp.kind = 'default';\n imp.localName = entry.symbol.finalName;\n } else {\n imp.imports.push({\n isTypeOnly,\n localName: entry.symbol.finalName,\n sourceName: entry.dep.finalName,\n });\n }\n if (!isTypeOnly) {\n imp.isTypeOnly = false;\n }\n imports.set(source, imp);\n }\n for (const [, imp] of imports) {\n file.addImport(imp);\n }\n }\n }\n\n /**\n * Assigns the final name to a top-level (file-scoped) symbol.\n *\n * Uses the symbol's file top-level names as the default scope,\n * and updates all relevant name scopes including the file's allNames and local scopes.\n *\n * Supports optional overrides for the naming scope and scopes to update.\n */\n private assignTopLevelName(\n args: Partial<AssignOptions> & {\n ctx: AnalysisContext;\n debug?: boolean;\n node?: INode;\n symbol: Symbol;\n },\n ): void {\n if (!args.symbol.file) return;\n this.assignSymbolName({\n ...args,\n file: args.symbol.file,\n scope:\n args?.scope ??\n createScope({ localNames: args.symbol.file.topLevelNames }),\n scopesToUpdate: [\n createScope({ localNames: args.symbol.file.allNames }),\n args.ctx.scopes,\n ...(args?.scopesToUpdate ?? []),\n ],\n });\n }\n\n /**\n * Assigns the final name to a non-top-level (local) symbol.\n *\n * Uses the provided scope or derives it from the current analysis context's local names.\n *\n * Updates all provided name scopes accordingly.\n */\n private assignLocalName(\n args: Pick<Partial<AssignOptions>, 'scope'> &\n Pick<AssignOptions, 'scopesToUpdate'> & {\n ctx: AnalysisContext;\n debug?: boolean;\n /** The file the symbol belongs to. */\n file: File;\n node?: INode;\n symbol: Symbol;\n },\n ): void {\n this.assignSymbolName({\n ...args,\n scope: args.scope ?? args.ctx.scope,\n });\n }\n\n /**\n * Assigns the final name to a symbol within the provided name scope.\n *\n * Resolves name conflicts until a unique name is found.\n *\n * Updates all specified name scopes with the assigned final name.\n */\n private assignSymbolName(\n args: AssignOptions & {\n ctx: AnalysisContext;\n debug?: boolean;\n /** The file the symbol belongs to. */\n file: File;\n node?: INode;\n symbol: Symbol;\n },\n ): void {\n const { ctx, file, node, scope, scopesToUpdate, symbol } = args;\n if (this.cacheResolvedNames.has(symbol.id)) return;\n\n const baseName = symbol.name;\n let finalName =\n node?.nameSanitizer?.(baseName) ??\n symbol.node?.nameSanitizer?.(baseName) ??\n baseName;\n let attempt = 1;\n\n const localNames = ctx.localNames(scope);\n while (true) {\n const kinds = [...(localNames.get(finalName) ?? [])];\n\n const ok = kinds.every((kind) => canShareName(symbol.kind, kind));\n if (ok) break;\n\n const language = node?.language || symbol.node?.language || file.language;\n const resolver =\n (language ? this.project.nameConflictResolvers[language] : undefined) ??\n this.project.defaultNameConflictResolver;\n const resolvedName = resolver({ attempt, baseName });\n if (!resolvedName) {\n throw new Error(`Unresolvable name conflict: ${symbol.toString()}`);\n }\n\n finalName =\n node?.nameSanitizer?.(resolvedName) ??\n symbol.node?.nameSanitizer?.(resolvedName) ??\n resolvedName;\n attempt = attempt + 1;\n }\n\n symbol.setFinalName(finalName);\n this.cacheResolvedNames.add(symbol.id);\n const updateScopes = [scope, ...scopesToUpdate];\n for (const scope of updateScopes) {\n this.updateScope(symbol, scope);\n }\n }\n\n /**\n * Updates the provided name scope with the symbol's final name and kind.\n *\n * Ensures the name scope tracks all kinds associated with a given name.\n */\n private updateScope(symbol: Symbol, scope: Scope): void {\n const name = symbol.finalName;\n const cache = scope.localNames.get(name) ?? new Set();\n cache.add(symbol.kind);\n scope.localNames.set(name, cache);\n }\n}\n","import { symbolBrand } from '../brands';\nimport type { ISymbolMeta } from '../extensions';\nimport type { File } from '../files/file';\nimport { log } from '../log';\nimport type { INode } from '../nodes/node';\nimport type { BindingKind, ISymbolIn, SymbolKind } from './types';\n\nexport class Symbol<Node extends INode = INode> {\n /**\n * Canonical symbol this stub resolves to, if any.\n *\n * Stubs created during DSL construction may later be associated\n * with a fully registered symbol. Once set, all property lookups\n * should defer to the canonical symbol.\n */\n private _canonical?: Symbol;\n /**\n * True if this symbol is exported from its defining file.\n *\n * @default false\n */\n private _exported: boolean;\n /**\n * Names of files (without extension) from which this symbol is re-exported.\n *\n * @default []\n */\n private _exportFrom: ReadonlyArray<string>;\n /**\n * External module name if this symbol is imported from a module not managed\n * by the project (e.g. \"zod\", \"lodash\").\n *\n * @default undefined\n */\n private _external?: string;\n /**\n * The file this symbol is ultimately emitted into.\n *\n * Only top-level symbols have an assigned file.\n */\n private _file?: File;\n /**\n * The alias-resolved, conflict-free emitted name.\n */\n private _finalName?: string;\n /**\n * Custom strategy to determine file output path.\n *\n * @returns The file path to output the symbol to, or undefined to fallback to default behavior.\n */\n private _getFilePath?: (symbol: Symbol) => string | undefined;\n /**\n * How this symbol should be imported (namespace/default/named).\n *\n * @default 'named'\n */\n private _importKind: BindingKind;\n /**\n * Kind of symbol (class, type, alias, etc.).\n *\n * @default 'var'\n */\n private _kind: SymbolKind;\n /**\n * Arbitrary user metadata.\n *\n * @default undefined\n */\n private _meta?: ISymbolMeta;\n /**\n * Intended user-facing name before conflict resolution.\n *\n * @example \"UserModel\"\n */\n private _name: string;\n /**\n * Node that defines this symbol.\n */\n private _node?: Node;\n\n /** Brand used for identifying symbols. */\n readonly '~brand' = symbolBrand;\n /** Globally unique, stable symbol ID. */\n readonly id: number;\n\n constructor(input: ISymbolIn, id: number) {\n this._exported = input.exported ?? false;\n this._exportFrom = input.exportFrom ?? [];\n this._external = input.external;\n this._getFilePath = input.getFilePath;\n this.id = id;\n this._importKind = input.importKind ?? 'named';\n this._kind = input.kind ?? 'var';\n this._meta = input.meta;\n this._name = input.name;\n }\n\n /**\n * Returns the canonical symbol for this instance.\n *\n * If this symbol was created as a stub, this getter returns\n * the fully registered canonical symbol. Otherwise, it returns\n * the symbol itself.\n */\n get canonical(): Symbol {\n return this._canonical ?? this;\n }\n\n /**\n * Indicates whether this symbol is exported from its defining file.\n */\n get exported(): boolean {\n return this.canonical._exported;\n }\n\n /**\n * Names of files (without extension) that re-export this symbol.\n */\n get exportFrom(): ReadonlyArray<string> {\n return this.canonical._exportFrom;\n }\n\n /**\n * External module from which this symbol originates, if any.\n */\n get external(): string | undefined {\n return this.canonical._external;\n }\n\n /**\n * Read‑only accessor for the assigned output file.\n *\n * Only top-level symbols have an assigned file.\n */\n get file(): File | undefined {\n return this.canonical._file;\n }\n\n /**\n * Read‑only accessor for the resolved final emitted name.\n */\n get finalName(): string {\n if (!this.canonical._finalName) {\n const message = `Symbol finalName has not been resolved yet for ${this.canonical.toString()}`;\n log.debug(message, 'symbol');\n throw new Error(message);\n }\n return this.canonical._finalName;\n }\n\n /**\n * Custom file path resolver, if provided.\n */\n get getFilePath(): ((symbol: Symbol) => string | undefined) | undefined {\n return this.canonical._getFilePath;\n }\n\n /**\n * How this symbol should be imported (named/default/namespace).\n */\n get importKind(): BindingKind {\n return this.canonical._importKind;\n }\n\n /**\n * Indicates whether this is a canonical symbol (not a stub).\n */\n get isCanonical(): boolean {\n return !this._canonical || this._canonical === this;\n }\n\n /**\n * The symbol's kind (class, type, alias, variable, etc.).\n */\n get kind(): SymbolKind {\n return this.canonical._kind;\n }\n\n /**\n * Arbitrary user‑provided metadata associated with this symbol.\n */\n get meta(): ISymbolMeta | undefined {\n return this.canonical._meta;\n }\n\n /**\n * User-intended name before aliasing or conflict resolution.\n */\n get name(): string {\n return this.canonical._name;\n }\n\n /**\n * Read‑only accessor for the defining node.\n */\n get node(): Node | undefined {\n return this.canonical._node as Node | undefined;\n }\n\n /**\n * Marks this symbol as a stub and assigns its canonical symbol.\n *\n * After calling this, all semantic queries (name, kind, file,\n * meta, etc.) should reflect the canonical symbol's values.\n *\n * @param symbol — The canonical symbol this stub should resolve to.\n */\n setCanonical(symbol: Symbol): void {\n this._canonical = symbol;\n }\n\n /**\n * Marks the symbol as exported from its file.\n *\n * @param exported — Whether the symbol is exported.\n */\n setExported(exported: boolean): void {\n this.assertCanonical();\n this._exported = exported;\n }\n\n /**\n * Records file names that re‑export this symbol.\n *\n * @param list — Source files re‑exporting this symbol.\n */\n setExportFrom(list: ReadonlyArray<string>): void {\n this.assertCanonical();\n this._exportFrom = list;\n }\n\n /**\n * Assigns the output file this symbol will be emitted into.\n *\n * This may only be set once.\n */\n setFile(file: File): void {\n this.assertCanonical();\n if (this._file && this._file !== file) {\n const message = `Symbol ${this.canonical.toString()} is already assigned to a different file.`;\n log.debug(message, 'symbol');\n throw new Error(message);\n }\n this._file = file;\n }\n\n /**\n * Assigns the conflict‑resolved final local name for this symbol.\n *\n * This may only be set once.\n */\n setFinalName(name: string): void {\n this.assertCanonical();\n if (this._finalName && this._finalName !== name) {\n const message = `Symbol finalName has already been resolved for ${this.canonical.toString()}.`;\n log.debug(message, 'symbol');\n throw new Error(message);\n }\n this._finalName = name;\n }\n\n /**\n * Sets how this symbol should be imported.\n *\n * @param kind — The import strategy (named/default/namespace).\n */\n setImportKind(kind: BindingKind): void {\n this.assertCanonical();\n this._importKind = kind;\n }\n\n /**\n * Sets the symbol's kind (class, type, alias, variable, etc.).\n *\n * @param kind — The new symbol kind.\n */\n setKind(kind: SymbolKind): void {\n this.assertCanonical();\n this._kind = kind;\n }\n\n /**\n * Updates the intended user‑facing name for this symbol.\n *\n * @param name — The new name.\n */\n setName(name: string): void {\n this.assertCanonical();\n this._name = name;\n }\n\n /**\n * Binds the node that defines this symbol.\n *\n * This may only be set once.\n */\n setNode(node: Node): void {\n this.assertCanonical();\n if (this._node && this._node !== node) {\n const message = `Symbol ${this.canonical.toString()} is already bound to a different node.`;\n log.debug(message, 'symbol');\n // TODO: symbol <> node relationship needs to be refactor to 1:many\n // disabled in the meantime or it would throw\n // throw new Error(message);\n }\n this._node = node;\n node.symbol = this;\n }\n\n /**\n * Returns a debug‑friendly string representation identifying the symbol.\n */\n toString(): string {\n const canonical = this.canonical;\n if (canonical._finalName && canonical._finalName !== canonical._name) {\n return `[Symbol ${canonical._name} → ${canonical._finalName}#${canonical.id}]`;\n }\n return `[Symbol ${canonical._name}#${canonical.id}]`;\n }\n\n /**\n * Ensures this symbol is canonical before allowing mutation.\n *\n * A symbol that has been marked as a stub (i.e., its `_canonical` points\n * to a different symbol) may not be mutated. This guard throws an error\n * if any setter attempts to modify a stub, preventing accidental writes\n * to non‑canonical instances.\n *\n * @throws {Error} If the symbol is a stub and is being mutated.\n */\n private assertCanonical(): void {\n if (this._canonical && this._canonical !== this) {\n const message = `Illegal mutation of stub symbol ${this.toString()} → canonical: ${this._canonical.toString()}`;\n log.debug(message, 'symbol');\n throw new Error(message);\n }\n }\n}\n","import type { ISymbolMeta } from '../extensions';\nimport { Symbol } from './symbol';\nimport type { ISymbolIdentifier, ISymbolIn, ISymbolRegistry } 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 _queryCache: Map<QueryCacheKey, ReadonlyArray<SymbolId>> = new Map();\n private _queryCacheDependencies: Map<QueryCacheKey, Set<QueryCacheKey>> =\n new Map();\n private _registered: Set<SymbolId> = new Set();\n private _stubs: Set<SymbolId> = new Set();\n private _stubCache: Map<QueryCacheKey, SymbolId> = new Map();\n private _values: Map<SymbolId, Symbol> = new Map();\n\n get(identifier: ISymbolIdentifier): Symbol | undefined {\n return typeof identifier === 'number'\n ? this._values.get(identifier)\n : this.query(identifier)[0];\n }\n\n isRegistered(identifier: ISymbolIdentifier): boolean {\n const symbol = this.get(identifier);\n return symbol ? this._registered.has(symbol.id) : false;\n }\n\n get nextId(): SymbolId {\n return this._id++;\n }\n\n query(filter: ISymbolMeta): ReadonlyArray<Symbol> {\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): Symbol {\n const [registered] = this.query(meta);\n if (registered) return registered;\n\n const cacheKey = this.buildCacheKey(meta);\n const cachedId = this._stubCache.get(cacheKey);\n if (cachedId !== undefined) return this._values.get(cachedId)!;\n\n const stub = new Symbol({ meta, name: '' }, this.nextId);\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): Symbol {\n const result = new Symbol(symbol, this.nextId);\n\n this._values.set(result.id, result);\n this._registered.add(result.id);\n\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\n return result;\n }\n\n *registered(): IterableIterator<Symbol> {\n for (const id of this._registered.values()) {\n yield this._values.get(id)!;\n }\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: Symbol, 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._stubs.delete(stubId);\n stub.setCanonical(symbol);\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';\nimport { FileRegistry } from '../files/registry';\nimport { defaultExtensions } from '../languages/extensions';\nimport { defaultNameConflictResolvers } from '../languages/resolvers';\nimport type { Extensions, NameConflictResolvers } from '../languages/types';\nimport { NodeRegistry } from '../nodes/registry';\nimport type { IOutput } from '../output';\nimport { Planner } from '../planner/planner';\nimport { simpleNameConflictResolver } from '../planner/resolvers';\nimport type { NameConflictResolver } from '../planner/types';\nimport type { Renderer } from '../renderer';\nimport { SymbolRegistry } from '../symbols/registry';\nimport type { IProject } from './types';\n\nexport class Project implements IProject {\n readonly files: FileRegistry;\n readonly nodes = new NodeRegistry();\n readonly symbols = new SymbolRegistry();\n\n readonly defaultFileName: string;\n readonly defaultNameConflictResolver: NameConflictResolver;\n readonly extensions: Extensions;\n readonly fileName?: (name: string) => string;\n readonly nameConflictResolvers: NameConflictResolvers;\n readonly renderers: ReadonlyArray<Renderer>;\n readonly root: string;\n\n constructor(\n args: Pick<\n Partial<IProject>,\n | 'defaultFileName'\n | 'defaultNameConflictResolver'\n | 'extensions'\n | 'fileName'\n | 'nameConflictResolvers'\n | 'renderers'\n > &\n Pick<IProject, 'root'>,\n ) {\n const fileName = args.fileName;\n this.defaultFileName = args.defaultFileName ?? 'main';\n this.defaultNameConflictResolver =\n args.defaultNameConflictResolver ?? simpleNameConflictResolver;\n this.extensions = {\n ...defaultExtensions,\n ...args.extensions,\n };\n this.fileName = typeof fileName === 'string' ? () => fileName : fileName;\n this.files = new FileRegistry(this);\n this.nameConflictResolvers = {\n ...defaultNameConflictResolvers,\n ...args.nameConflictResolvers,\n };\n this.renderers = args.renderers ?? [];\n this.root = path.resolve(args.root).replace(/[/\\\\]+$/, '');\n }\n\n render(meta?: IProjectRenderMeta): ReadonlyArray<IOutput> {\n new Planner(this).plan(meta);\n const files: Array<IOutput> = [];\n for (const file of this.files.registered()) {\n if (!file.external && file.finalPath && file.renderer) {\n const content = file.renderer.render({ file, meta, project: this });\n files.push({ content, path: file.finalPath });\n }\n }\n return files;\n }\n}\n","import type { StructureItem, StructureShell } from './types';\n\nexport class StructureNode {\n /** Nested nodes within this node. */\n children: Map<string, StructureNode> = new Map();\n /** Items contained in this node. */\n items: Array<StructureItem> = [];\n /** The name of this node (e.g., \"Users\", \"Accounts\"). */\n name: string;\n /** Parent node in the hierarchy. Undefined if this is the root node. */\n parent?: StructureNode;\n /** Shell claimed for this node. */\n shell?: StructureShell;\n /** Source of the claimed shell. */\n shellSource?: symbol;\n /** True if this is a virtual root. */\n virtual: boolean;\n\n constructor(\n name: string,\n parent?: StructureNode,\n options?: {\n virtual?: boolean;\n },\n ) {\n this.name = name;\n this.parent = parent;\n this.virtual = options?.virtual ?? false;\n }\n\n get isRoot(): boolean {\n return !this.parent;\n }\n\n /**\n * Gets or creates a child node.\n *\n * If the child doesn't exist, it's created automatically.\n *\n * @param name - The name of the child node\n * @returns The child node instance\n */\n child(name: string): StructureNode {\n if (!this.children.has(name)) {\n this.children.set(name, new StructureNode(name, this));\n }\n return this.children.get(name)!;\n }\n\n /**\n * Gets the full path of this node in the hierarchy.\n *\n * @returns An array of node names from the root to this node\n */\n getPath(): ReadonlyArray<string> {\n const path: Array<string> = [];\n // eslint-disable-next-line @typescript-eslint/no-this-alias\n let cursor: StructureNode | undefined = this;\n while (cursor) {\n path.unshift(cursor.name);\n cursor = cursor.parent;\n }\n return path;\n }\n\n /**\n * Yields items from a specific source with typed data.\n *\n * @param source - The source symbol to filter by\n * @returns Generator of items from that source\n */\n *itemsFrom<T = unknown>(\n source: symbol,\n ): Generator<StructureItem & { data: T }> {\n for (const item of this.items) {\n if (item.source === source) {\n yield item as StructureItem & { data: T };\n }\n }\n }\n\n /**\n * Walk all nodes in the structure (depth-first, post-order).\n *\n * @returns Generator of all structure nodes\n */\n *walk(): Generator<StructureNode> {\n for (const node of this.children.values()) {\n yield* node.walk();\n }\n yield this;\n }\n}\n","import { StructureNode } from './node';\nimport type { StructureInsert } from './types';\n\nexport class StructureModel {\n /** Root nodes mapped by their names. */\n private _roots: Map<string, StructureNode> = new Map();\n /** Node for data without a specific root. */\n private _virtualRoot?: StructureNode;\n\n /**\n * Get all root nodes.\n */\n get roots(): ReadonlyArray<StructureNode> {\n const roots = Array.from(this._roots.values());\n if (this._virtualRoot) roots.unshift(this._virtualRoot);\n return roots;\n }\n\n /**\n * Insert data into the structure.\n */\n insert(args: StructureInsert): void {\n const { data, locations, source } = args;\n for (const location of locations) {\n const { path, shell } = location;\n const fullPath = path.filter((s): s is string => Boolean(s));\n const segments = fullPath.slice(0, -1);\n const name = fullPath[fullPath.length - 1];\n\n if (!name) {\n throw new Error('Cannot insert data without path.');\n }\n\n let cursor: StructureNode | null = null;\n\n for (const segment of segments) {\n if (!cursor) {\n cursor = this.root(segment);\n } else {\n cursor = cursor.child(segment);\n }\n\n if (shell && !cursor.shell) {\n cursor.shell = shell;\n cursor.shellSource = source;\n }\n }\n\n if (!cursor) {\n cursor = this.root(null);\n }\n\n cursor.items.push({ data, location: fullPath, source });\n }\n }\n\n /**\n * Gets or creates a root by name.\n *\n * If the root doesn't exist, it's created automatically.\n *\n * @param name - The name of the root\n * @returns The root instance\n */\n root(name: string | null): StructureNode {\n if (!name) {\n return (this._virtualRoot ??= new StructureNode('', undefined, {\n virtual: true,\n }));\n }\n if (!this._roots.has(name)) {\n this._roots.set(name, new StructureNode(name));\n }\n return this._roots.get(name)!;\n }\n\n /**\n * Walk all nodes in the structure (depth-first, post-order).\n *\n * @returns Generator of all structure nodes\n */\n *walk(): Generator<StructureNode> {\n if (this._virtualRoot) {\n yield* this._virtualRoot.walk();\n }\n for (const root of this._roots.values()) {\n yield* root.walk();\n }\n }\n}\n"],"mappings":";0kBAAA,MAAa,EAAY,cACZ,EAAY,cACZ,EAAc,gBCE3B,EAAA,QAAO,SAAA,EAAA,EAAA,UAAwB,CAAC,SAchC,MAAM,EAAkB,SAElB,EAAc,qBAAqB,KACvC,QAAQ,IAAI,yBAA2B,GACxC,CAEK,EAAc,CAClB,SAAUA,EAAAA,QAAO,YACjB,IAAKA,EAAAA,QAAO,WACZ,KAAMA,EAAAA,QAAO,aACb,SAAUA,EAAAA,QAAO,WACjB,OAAQA,EAAAA,QAA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