@nudojs/harvester 0.2.2 → 0.2.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +35 -0
- package/package.json +5 -2
package/dist/index.js
CHANGED
|
@@ -159,6 +159,11 @@ function collectStatement(ctx, stmt, scope) {
|
|
|
159
159
|
ctx.skipped++;
|
|
160
160
|
continue;
|
|
161
161
|
}
|
|
162
|
+
const iface = decl.type ? interfaceDeclOf(ctx, decl.type) : void 0;
|
|
163
|
+
if (iface) {
|
|
164
|
+
expandInterfaceAsModuleMembers(ctx, scope, iface);
|
|
165
|
+
continue;
|
|
166
|
+
}
|
|
162
167
|
ctx.pending.push({ t: "var", scope, name: decl.name.text, typeNode: decl.type });
|
|
163
168
|
ctx.symbols++;
|
|
164
169
|
}
|
|
@@ -259,6 +264,36 @@ function registerTypeDecl(ctx, scope, name, decl) {
|
|
|
259
264
|
ctx.qualifiedInterfaces.set(qualified, decl);
|
|
260
265
|
}
|
|
261
266
|
}
|
|
267
|
+
function interfaceDeclOf(ctx, typeNode) {
|
|
268
|
+
if (!ts.isTypeReferenceNode(typeNode)) return void 0;
|
|
269
|
+
const name = typeNameString(typeNode.typeName);
|
|
270
|
+
const d = ctx.interfaces.get(name) ?? ctx.qualifiedInterfaces.get(name);
|
|
271
|
+
return d && ts.isInterfaceDeclaration(d) ? d : void 0;
|
|
272
|
+
}
|
|
273
|
+
function expandInterfaceAsModuleMembers(ctx, scope, iface) {
|
|
274
|
+
for (const member of iface.members) {
|
|
275
|
+
if (ts.isMethodSignature(member)) {
|
|
276
|
+
const name = memberName(member);
|
|
277
|
+
if (name === void 0) continue;
|
|
278
|
+
const existing = ctx.pending.find(
|
|
279
|
+
(p) => p.t === "fn" && p.name === name && scopeKey(p.scope) === scopeKey(scope)
|
|
280
|
+
);
|
|
281
|
+
if (existing && existing.t === "fn") {
|
|
282
|
+
existing.decls.push(member);
|
|
283
|
+
continue;
|
|
284
|
+
}
|
|
285
|
+
ctx.pending.push({ t: "fn", scope, name, decls: [member] });
|
|
286
|
+
ctx.symbols++;
|
|
287
|
+
continue;
|
|
288
|
+
}
|
|
289
|
+
if (ts.isPropertySignature(member)) {
|
|
290
|
+
const name = memberName(member);
|
|
291
|
+
if (name === void 0) continue;
|
|
292
|
+
ctx.pending.push({ t: "var", scope, name, typeNode: member.type });
|
|
293
|
+
ctx.symbols++;
|
|
294
|
+
}
|
|
295
|
+
}
|
|
296
|
+
}
|
|
262
297
|
function registerAlias(ctx, scope, stmt) {
|
|
263
298
|
const name = stmt.name.text;
|
|
264
299
|
if (!ctx.aliases.has(name)) ctx.aliases.set(name, stmt);
|
package/package.json
CHANGED
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nudojs/harvester",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.3",
|
|
4
|
+
"engines": {
|
|
5
|
+
"node": ">=20"
|
|
6
|
+
},
|
|
4
7
|
"description": "Harvests TypeScript .d.ts declarations into Nudo env definitions",
|
|
5
8
|
"type": "module",
|
|
6
9
|
"license": "MIT",
|
|
@@ -27,7 +30,7 @@
|
|
|
27
30
|
},
|
|
28
31
|
"dependencies": {
|
|
29
32
|
"typescript": "^5.8.0",
|
|
30
|
-
"@nudojs/core": "0.
|
|
33
|
+
"@nudojs/core": "1.0.0"
|
|
31
34
|
},
|
|
32
35
|
"scripts": {
|
|
33
36
|
"build": "tsup src/index.ts --format esm --dts"
|