hyperbook 0.98.1 → 0.98.2

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.
@@ -537,8 +537,12 @@ const runOpenScadInvocation = async ({
537
537
 
538
538
  const outputs = [];
539
539
  for (const outputPath of outputPaths) {
540
- const content = instance.FS.readFile(outputPath, { encoding: "binary" });
541
- outputs.push([outputPath, content]);
540
+ try {
541
+ const content = instance.FS.readFile(outputPath, { encoding: "binary" });
542
+ outputs.push([outputPath, content]);
543
+ } catch (_) {
544
+ // Output file missing — render produced no output (handled by caller)
545
+ }
542
546
  }
543
547
 
544
548
  return {
@@ -548,7 +552,7 @@ const runOpenScadInvocation = async ({
548
552
  elapsedMillis: performance.now() - start,
549
553
  };
550
554
  } catch (e) {
551
- const error = `${e}`;
555
+ const error = e?.message || (typeof e === "string" ? e : String(e)) || "Unknown error";
552
556
  mergedOutputs.push({ error });
553
557
  return {
554
558
  exitCode: undefined,
@@ -560,6 +564,24 @@ const runOpenScadInvocation = async ({
560
564
  }
561
565
  };
562
566
 
567
+ // Adjust "line N" references in stderr messages by a given offset (e.g. -1 when a
568
+ // header line is prepended to the user's code so reported line numbers stay accurate).
569
+ // Parser syntax errors are reported at the position OpenSCAD expected the next token
570
+ // (one past the actual expression), so they get an extra -1 applied.
571
+ const adjustStderrLineNumbers = (mergedOutputs, offset) =>
572
+ mergedOutputs.map((entry) => {
573
+ if (typeof entry?.stderr !== "string") return entry;
574
+ const isParserError = /Parser error/i.test(entry.stderr);
575
+ const effectiveOffset = isParserError ? offset - 1 : offset;
576
+ return {
577
+ ...entry,
578
+ stderr: entry.stderr.replace(/\bline (\d+)/g, (match, n) => {
579
+ const adjusted = parseInt(n, 10) + effectiveOffset;
580
+ return `line ${adjusted > 0 ? adjusted : parseInt(n, 10)}`;
581
+ }),
582
+ };
583
+ });
584
+
563
585
  self.addEventListener("message", async (event) => {
564
586
  const { requestId, type, payload } = event.data || {};
565
587
  if (!requestId || typeof type !== "string") return;
@@ -582,6 +604,7 @@ self.addEventListener("message", async (event) => {
582
604
  "--export-format=param",
583
605
  ],
584
606
  });
607
+ result = { ...result, mergedOutputs: adjustStderrLineNumbers(result.mergedOutputs, -1) };
585
608
  const serialized = serializeInvocationResults(result);
586
609
  self.postMessage({ requestId, ok: true, result: serialized.result }, serialized.transfer);
587
610
  return;
@@ -602,6 +625,7 @@ self.addEventListener("message", async (event) => {
602
625
  "--export-format=param",
603
626
  ],
604
627
  });
628
+ result = { ...result, mergedOutputs: adjustStderrLineNumbers(result.mergedOutputs, -1) };
605
629
 
606
630
  const codeParams = getExtractedParameters(result);
607
631
  const ui = buildParamFormUi(
@@ -642,6 +666,9 @@ self.addEventListener("message", async (event) => {
642
666
  ...OPENSCAD_FEATURE_ARGS,
643
667
  ],
644
668
  });
669
+ if (payload?.isPreview) {
670
+ result = { ...result, mergedOutputs: adjustStderrLineNumbers(result.mergedOutputs, -1) };
671
+ }
645
672
  // For preview OFF renders, parse geometry here in the worker so the main thread
646
673
  // never has to do heavy text parsing or Float32Array building.
647
674
  if (format === "off" && payload?.isPreview && result.exitCode === 0 && !result.error) {
package/dist/index.js CHANGED
@@ -202235,7 +202235,7 @@ module.exports = /*#__PURE__*/JSON.parse('{"application/1d-interleaved-parityfec
202235
202235
  /***/ ((module) => {
202236
202236
 
202237
202237
  "use strict";
202238
- module.exports = /*#__PURE__*/JSON.parse('{"name":"hyperbook","version":"0.98.1","author":"Mike Barkmin","homepage":"https://github.com/openpatch/hyperbook#readme","license":"MIT","bin":{"hyperbook":"./dist/index.js"},"files":["dist"],"publishConfig":{"access":"public"},"repository":{"type":"git","url":"git+https://github.com/openpatch/hyperbook.git","directory":"packages/hyperbook"},"bugs":{"url":"https://github.com/openpatch/hyperbook/issues"},"engines":{"node":">=18"},"scripts":{"version":"pnpm build","lint":"tsc --noEmit","dev":"ncc build ./index.ts -w -o dist/","build":"rimraf dist && ncc build ./index.ts -o ./dist/ --no-cache --no-source-map-register --external favicons --external sharp && node postbuild.mjs"},"dependencies":{"favicons":"^7.2.0"},"devDependencies":{"create-hyperbook":"workspace:*","@hyperbook/fs":"workspace:*","@hyperbook/markdown":"workspace:*","@hyperbook/types":"workspace:*","@pnpm/exportable-manifest":"1000.0.6","@types/archiver":"6.0.3","@types/async-retry":"1.4.9","@types/cross-spawn":"6.0.6","@types/lunr":"^2.3.7","@types/prompts":"2.4.9","@types/tar":"6.1.13","@types/ws":"^8.5.14","@vercel/ncc":"0.38.3","archiver":"7.0.1","async-retry":"1.3.3","chalk":"5.4.1","chokidar":"4.0.3","commander":"12.1.0","cpy":"11.1.0","cross-spawn":"7.0.6","domutils":"^3.2.2","extract-zip":"^2.0.1","got":"12.6.0","htmlparser2":"^10.0.0","lunr":"^2.3.9","lunr-languages":"^1.14.0","mime":"^4.0.6","prompts":"2.4.2","rimraf":"6.0.1","tar":"7.4.3","update-check":"1.5.4","ws":"^8.18.0"}}');
202238
+ module.exports = /*#__PURE__*/JSON.parse('{"name":"hyperbook","version":"0.98.2","author":"Mike Barkmin","homepage":"https://github.com/openpatch/hyperbook#readme","license":"MIT","bin":{"hyperbook":"./dist/index.js"},"files":["dist"],"publishConfig":{"access":"public"},"repository":{"type":"git","url":"git+https://github.com/openpatch/hyperbook.git","directory":"packages/hyperbook"},"bugs":{"url":"https://github.com/openpatch/hyperbook/issues"},"engines":{"node":">=18"},"scripts":{"version":"pnpm build","lint":"tsc --noEmit","dev":"ncc build ./index.ts -w -o dist/","build":"rimraf dist && ncc build ./index.ts -o ./dist/ --no-cache --no-source-map-register --external favicons --external sharp && node postbuild.mjs"},"dependencies":{"favicons":"^7.2.0"},"devDependencies":{"create-hyperbook":"workspace:*","@hyperbook/fs":"workspace:*","@hyperbook/markdown":"workspace:*","@hyperbook/types":"workspace:*","@pnpm/exportable-manifest":"1000.0.6","@types/archiver":"6.0.3","@types/async-retry":"1.4.9","@types/cross-spawn":"6.0.6","@types/lunr":"^2.3.7","@types/prompts":"2.4.9","@types/tar":"6.1.13","@types/ws":"^8.5.14","@vercel/ncc":"0.38.3","archiver":"7.0.1","async-retry":"1.3.3","chalk":"5.4.1","chokidar":"4.0.3","commander":"12.1.0","cpy":"11.1.0","cross-spawn":"7.0.6","domutils":"^3.2.2","extract-zip":"^2.0.1","got":"12.6.0","htmlparser2":"^10.0.0","lunr":"^2.3.9","lunr-languages":"^1.14.0","mime":"^4.0.6","prompts":"2.4.2","rimraf":"6.0.1","tar":"7.4.3","update-check":"1.5.4","ws":"^8.18.0"}}');
202239
202239
 
202240
202240
  /***/ })
202241
202241
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "hyperbook",
3
- "version": "0.98.1",
3
+ "version": "0.98.2",
4
4
  "author": "Mike Barkmin",
5
5
  "homepage": "https://github.com/openpatch/hyperbook#readme",
6
6
  "license": "MIT",
@@ -57,9 +57,9 @@
57
57
  "update-check": "1.5.4",
58
58
  "ws": "^8.18.0",
59
59
  "create-hyperbook": "0.3.6",
60
- "@hyperbook/markdown": "0.69.1",
61
- "@hyperbook/fs": "0.25.0",
62
- "@hyperbook/types": "0.23.0"
60
+ "@hyperbook/types": "0.23.0",
61
+ "@hyperbook/markdown": "0.69.2",
62
+ "@hyperbook/fs": "0.25.0"
63
63
  },
64
64
  "scripts": {
65
65
  "version": "pnpm build",