@ai-ecoverse/slicc-jsh 0.3.3 → 0.3.5
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/host/main.mjs +9 -11
- package/dist/jsh.mjs +320 -126
- package/dist/meta-main.json +1 -1
- package/dist/node.mjs +320 -126
- package/package.json +2 -2
package/dist/host/main.mjs
CHANGED
|
@@ -10,7 +10,7 @@ import vm from "node:vm";
|
|
|
10
10
|
// package.json
|
|
11
11
|
var package_default = {
|
|
12
12
|
name: "@ai-ecoverse/slicc-jsh",
|
|
13
|
-
version: "0.3.
|
|
13
|
+
version: "0.3.5",
|
|
14
14
|
description: "Node.js-compatible runtime for slicc-kernel: the node and jsh commands (abi: js)",
|
|
15
15
|
type: "module",
|
|
16
16
|
license: "Apache-2.0",
|
|
@@ -80,7 +80,7 @@ var package_default = {
|
|
|
80
80
|
"trust:dry": "npx fledgling sync --dry-run -y --skip-publish"
|
|
81
81
|
},
|
|
82
82
|
devDependencies: {
|
|
83
|
-
"@ai-ecoverse/slicc-kernel": "1.
|
|
83
|
+
"@ai-ecoverse/slicc-kernel": "1.63.0",
|
|
84
84
|
"@ai-ecoverse/wasi-pnpm": "12.9.1-8",
|
|
85
85
|
"abort-controller": "3.0.0",
|
|
86
86
|
acorn: "8.19.0",
|
|
@@ -703,9 +703,11 @@ function prepareSource(source) {
|
|
|
703
703
|
return text;
|
|
704
704
|
}
|
|
705
705
|
function wrapSource(body) {
|
|
706
|
-
return `(async function (${JSH_PARAMS.join(", ")}) {
|
|
706
|
+
return `(async function (${JSH_PARAMS.join(", ")}) {
|
|
707
|
+
${body}
|
|
707
708
|
})`;
|
|
708
709
|
}
|
|
710
|
+
var WRAPPER_LINE_OFFSET = -1;
|
|
709
711
|
function dirnameOf2(path) {
|
|
710
712
|
const idx = path.lastIndexOf("/");
|
|
711
713
|
if (idx <= 0) return "/";
|
|
@@ -747,16 +749,12 @@ async function runJsh({ filename, engine: engine2, process: process2, console: c
|
|
|
747
749
|
const baseRequire = engine2.createRequire(filename);
|
|
748
750
|
const requireSliccy = createSliccyResolver({ engine: engine2, process: process2, require: baseRequire });
|
|
749
751
|
const require2 = wrapRequire(baseRequire, requireSliccy, module);
|
|
750
|
-
|
|
752
|
+
const body = (async () => {
|
|
751
753
|
const fn = engine2.compile(prepareSource(source), filename);
|
|
752
754
|
await fn(process2, console2, require2, module, module.exports, engine2.fetch, dirname, filename);
|
|
753
755
|
module.loaded = true;
|
|
754
|
-
}
|
|
755
|
-
|
|
756
|
-
engine2.writeStderr(`${err?.stack ?? err}
|
|
757
|
-
`);
|
|
758
|
-
return engine2.exit(1);
|
|
759
|
-
}
|
|
756
|
+
})();
|
|
757
|
+
engine2.started?.(body);
|
|
760
758
|
return void 0;
|
|
761
759
|
}
|
|
762
760
|
|
|
@@ -846,6 +844,7 @@ var engine = {
|
|
|
846
844
|
readSource: (filename) => readFileSync(filename, "utf8"),
|
|
847
845
|
compile: (body, filename) => vm.runInThisContext(wrapSource(body), {
|
|
848
846
|
filename,
|
|
847
|
+
lineOffset: WRAPPER_LINE_OFFSET,
|
|
849
848
|
importModuleDynamically: vm.constants.USE_MAIN_CONTEXT_DEFAULT_LOADER
|
|
850
849
|
}),
|
|
851
850
|
createRequire: (filename) => createRequire(filename),
|
|
@@ -858,7 +857,6 @@ var engine = {
|
|
|
858
857
|
spawn,
|
|
859
858
|
shell: [findOnPath("bash") ?? "sh", "-c"],
|
|
860
859
|
fetch: globalThis.fetch,
|
|
861
|
-
isExit: () => false,
|
|
862
860
|
exit: (code) => process.exit(code)
|
|
863
861
|
};
|
|
864
862
|
async function main() {
|