@nudojs/harvester 0.2.18 → 0.3.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/dist/index.js +7 -5
- package/package.json +4 -4
package/dist/index.js
CHANGED
|
@@ -978,6 +978,7 @@ function emitAbs(a, expanding) {
|
|
|
978
978
|
import { readFileSync as readFileSync2, existsSync, statSync as statSync2, readdirSync } from "fs";
|
|
979
979
|
import { basename, dirname, join } from "path";
|
|
980
980
|
import ts2 from "typescript";
|
|
981
|
+
import { toJsBindingIdent } from "@nudojs/core/internal";
|
|
981
982
|
var BUILDERS = [
|
|
982
983
|
"fn",
|
|
983
984
|
"number",
|
|
@@ -1200,8 +1201,8 @@ function collectExports(sourceFile) {
|
|
|
1200
1201
|
}
|
|
1201
1202
|
return out;
|
|
1202
1203
|
}
|
|
1203
|
-
function draftExportName(name) {
|
|
1204
|
-
return name.includes(".") ? name.replace(/\./g, "_") : name;
|
|
1204
|
+
function draftExportName(name, used) {
|
|
1205
|
+
return toJsBindingIdent(name.includes(".") ? name.replace(/\./g, "_") : name, used);
|
|
1205
1206
|
}
|
|
1206
1207
|
function formatDtsContractDraft(label, files, exports) {
|
|
1207
1208
|
const draftable = exports.filter((e) => e.dsl !== void 0);
|
|
@@ -1213,6 +1214,7 @@ function formatDtsContractDraft(label, files, exports) {
|
|
|
1213
1214
|
}
|
|
1214
1215
|
if (draftable.some((e) => /\bany\s*\(/.test(e.dsl))) used.add("any");
|
|
1215
1216
|
const importList = BUILDERS.filter((b) => used.has(b)).join(", ");
|
|
1217
|
+
const exportUsed = /* @__PURE__ */ new Set();
|
|
1216
1218
|
const lines = [
|
|
1217
1219
|
"// @nudo:draft",
|
|
1218
1220
|
`// Generated by \`nudo contract --from-dts\` from ${label}`,
|
|
@@ -1239,7 +1241,7 @@ function formatDtsContractDraft(label, files, exports) {
|
|
|
1239
1241
|
}
|
|
1240
1242
|
if (e.note) lines.push(`// ${e.name} \u2014 ${e.note}`);
|
|
1241
1243
|
else lines.push(`// ${e.name} \u2014 from TypeScript`);
|
|
1242
|
-
lines.push(`export const ${draftExportName(e.name)} = ${e.dsl};`);
|
|
1244
|
+
lines.push(`export const ${draftExportName(e.name, exportUsed)} = ${e.dsl};`);
|
|
1243
1245
|
if (e.name.includes(".")) {
|
|
1244
1246
|
lines.push(`// sidecar key may also be written as \`${e.name}\``);
|
|
1245
1247
|
}
|
|
@@ -1456,8 +1458,8 @@ function formatHarvestSummary(h) {
|
|
|
1456
1458
|
return lines.join("\n");
|
|
1457
1459
|
}
|
|
1458
1460
|
function lookupHarvested(h, moduleName, exportName) {
|
|
1459
|
-
const mod = h.env.modules[moduleName];
|
|
1460
|
-
const a = mod
|
|
1461
|
+
const mod = Object.hasOwn(h.env.modules, moduleName) ? h.env.modules[moduleName] : void 0;
|
|
1462
|
+
const a = (mod !== void 0 && Object.hasOwn(mod, exportName) ? mod[exportName] : void 0) ?? (Object.hasOwn(h.env.globals, exportName) ? h.env.globals[exportName] : void 0);
|
|
1461
1463
|
if (!a) return void 0;
|
|
1462
1464
|
return formatShape2(a);
|
|
1463
1465
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nudojs/harvester",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.0",
|
|
4
4
|
"engines": {
|
|
5
5
|
"node": ">=20"
|
|
6
6
|
},
|
|
@@ -29,9 +29,9 @@
|
|
|
29
29
|
"registry": "https://registry.npmjs.org"
|
|
30
30
|
},
|
|
31
31
|
"dependencies": {
|
|
32
|
-
"@nudojs/core": "1.
|
|
33
|
-
"@nudojs/parser": "1.
|
|
34
|
-
"@nudojs/env": "0.4.
|
|
32
|
+
"@nudojs/core": "1.6.0",
|
|
33
|
+
"@nudojs/parser": "1.3.0",
|
|
34
|
+
"@nudojs/env": "0.4.14",
|
|
35
35
|
"@babel/types": "^8.0.6",
|
|
36
36
|
"typescript": "^6.0.3"
|
|
37
37
|
},
|