@webtypen/webframez-react 0.0.5 → 0.0.6

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/http.cjs CHANGED
@@ -478,6 +478,9 @@ function parseSearchParams(query) {
478
478
  }
479
479
 
480
480
  // src/http.ts
481
+ function createInitialHtmlErrorMarkup(message) {
482
+ return `<main style="font-family:system-ui,sans-serif;padding:24px"><h1 style="margin:0 0 12px">500</h1><p style="margin:0">${message}</p></main>`;
483
+ }
481
484
  var INITIAL_HTML_WORKER_SCRIPT = `
482
485
  const path = require("node:path");
483
486
  const Module = require("node:module");
@@ -559,6 +562,12 @@ function stripBasePath(pathname, basePath) {
559
562
  }
560
563
  return pathname;
561
564
  }
565
+ function sanitizeInitialHtmlWorkerNodeOptions(rawNodeOptions) {
566
+ if (!rawNodeOptions || rawNodeOptions.trim() === "") {
567
+ return "";
568
+ }
569
+ return rawNodeOptions.replace(/(^|\s)--conditions\s+react-server(?=\s|$)/g, " ").replace(/(^|\s)-r\s+(\S*webframez-react\/register)(?=\s|$)/g, " ").replace(/\s+/g, " ").trim();
570
+ }
562
571
  function createInitialHtmlWorker(pagesDir) {
563
572
  let child = null;
564
573
  let nextRequestId = 1;
@@ -590,6 +599,7 @@ function createInitialHtmlWorker(pagesDir) {
590
599
  cwd: process.cwd(),
591
600
  env: {
592
601
  ...process.env,
602
+ NODE_OPTIONS: sanitizeInitialHtmlWorkerNodeOptions(process.env.NODE_OPTIONS),
593
603
  WEBFRAMEZ_REACT_PAGES_DIR: pagesDir
594
604
  },
595
605
  stdio: ["ignore", "ignore", "pipe", "ipc"]
@@ -836,6 +846,32 @@ function createNodeRequestHandler(options) {
836
846
  });
837
847
  } catch (error) {
838
848
  console.error("[webframez-react] Failed to render initial HTML", error);
849
+ try {
850
+ initialHtmlWorker.dispose();
851
+ rootHtml = await initialHtmlWorker.render({
852
+ pathname: stripBasePath(url.pathname, basePath),
853
+ searchParams: parseSearchParams(url.searchParams),
854
+ cookies: requestCookies,
855
+ basename: basePath
856
+ });
857
+ } catch (retryError) {
858
+ console.error("[webframez-react] Retry for initial HTML failed", retryError);
859
+ res.statusCode = 500;
860
+ res.setHeader("Content-Type", "text/html");
861
+ res.end(
862
+ createHTMLShell({
863
+ title: "500 - Initial HTML render failed",
864
+ headTags: "",
865
+ clientScriptUrl,
866
+ rscEndpoint: rscPath,
867
+ rootHtml: createInitialHtmlErrorMarkup("Initial HTML render failed."),
868
+ basename: basePath,
869
+ liveReloadPath: liveReloadPath || void 0,
870
+ liveReloadServerId: liveReloadPath ? devServerId : void 0
871
+ })
872
+ );
873
+ return;
874
+ }
839
875
  }
840
876
  res.statusCode = resolved.statusCode;
841
877
  res.setHeader("Content-Type", "text/html");
package/dist/http.js CHANGED
@@ -453,6 +453,9 @@ function parseSearchParams(query) {
453
453
  }
454
454
 
455
455
  // src/http.ts
456
+ function createInitialHtmlErrorMarkup(message) {
457
+ return `<main style="font-family:system-ui,sans-serif;padding:24px"><h1 style="margin:0 0 12px">500</h1><p style="margin:0">${message}</p></main>`;
458
+ }
456
459
  var INITIAL_HTML_WORKER_SCRIPT = `
457
460
  const path = require("node:path");
458
461
  const Module = require("node:module");
@@ -534,6 +537,12 @@ function stripBasePath(pathname, basePath) {
534
537
  }
535
538
  return pathname;
536
539
  }
540
+ function sanitizeInitialHtmlWorkerNodeOptions(rawNodeOptions) {
541
+ if (!rawNodeOptions || rawNodeOptions.trim() === "") {
542
+ return "";
543
+ }
544
+ return rawNodeOptions.replace(/(^|\s)--conditions\s+react-server(?=\s|$)/g, " ").replace(/(^|\s)-r\s+(\S*webframez-react\/register)(?=\s|$)/g, " ").replace(/\s+/g, " ").trim();
545
+ }
537
546
  function createInitialHtmlWorker(pagesDir) {
538
547
  let child = null;
539
548
  let nextRequestId = 1;
@@ -565,6 +574,7 @@ function createInitialHtmlWorker(pagesDir) {
565
574
  cwd: process.cwd(),
566
575
  env: {
567
576
  ...process.env,
577
+ NODE_OPTIONS: sanitizeInitialHtmlWorkerNodeOptions(process.env.NODE_OPTIONS),
568
578
  WEBFRAMEZ_REACT_PAGES_DIR: pagesDir
569
579
  },
570
580
  stdio: ["ignore", "ignore", "pipe", "ipc"]
@@ -811,6 +821,32 @@ function createNodeRequestHandler(options) {
811
821
  });
812
822
  } catch (error) {
813
823
  console.error("[webframez-react] Failed to render initial HTML", error);
824
+ try {
825
+ initialHtmlWorker.dispose();
826
+ rootHtml = await initialHtmlWorker.render({
827
+ pathname: stripBasePath(url.pathname, basePath),
828
+ searchParams: parseSearchParams(url.searchParams),
829
+ cookies: requestCookies,
830
+ basename: basePath
831
+ });
832
+ } catch (retryError) {
833
+ console.error("[webframez-react] Retry for initial HTML failed", retryError);
834
+ res.statusCode = 500;
835
+ res.setHeader("Content-Type", "text/html");
836
+ res.end(
837
+ createHTMLShell({
838
+ title: "500 - Initial HTML render failed",
839
+ headTags: "",
840
+ clientScriptUrl,
841
+ rscEndpoint: rscPath,
842
+ rootHtml: createInitialHtmlErrorMarkup("Initial HTML render failed."),
843
+ basename: basePath,
844
+ liveReloadPath: liveReloadPath || void 0,
845
+ liveReloadServerId: liveReloadPath ? devServerId : void 0
846
+ })
847
+ );
848
+ return;
849
+ }
814
850
  }
815
851
  res.statusCode = resolved.statusCode;
816
852
  res.setHeader("Content-Type", "text/html");
package/dist/index.cjs CHANGED
@@ -515,6 +515,9 @@ function parseSearchParams(query) {
515
515
  var import_node_fs2 = __toESM(require("node:fs"), 1);
516
516
  var import_node_path2 = __toESM(require("node:path"), 1);
517
517
  var import_node_child_process = require("node:child_process");
518
+ function createInitialHtmlErrorMarkup(message) {
519
+ return `<main style="font-family:system-ui,sans-serif;padding:24px"><h1 style="margin:0 0 12px">500</h1><p style="margin:0">${message}</p></main>`;
520
+ }
518
521
  var INITIAL_HTML_WORKER_SCRIPT = `
519
522
  const path = require("node:path");
520
523
  const Module = require("node:module");
@@ -596,6 +599,12 @@ function stripBasePath(pathname, basePath) {
596
599
  }
597
600
  return pathname;
598
601
  }
602
+ function sanitizeInitialHtmlWorkerNodeOptions(rawNodeOptions) {
603
+ if (!rawNodeOptions || rawNodeOptions.trim() === "") {
604
+ return "";
605
+ }
606
+ return rawNodeOptions.replace(/(^|\s)--conditions\s+react-server(?=\s|$)/g, " ").replace(/(^|\s)-r\s+(\S*webframez-react\/register)(?=\s|$)/g, " ").replace(/\s+/g, " ").trim();
607
+ }
599
608
  function createInitialHtmlWorker(pagesDir) {
600
609
  let child = null;
601
610
  let nextRequestId = 1;
@@ -627,6 +636,7 @@ function createInitialHtmlWorker(pagesDir) {
627
636
  cwd: process.cwd(),
628
637
  env: {
629
638
  ...process.env,
639
+ NODE_OPTIONS: sanitizeInitialHtmlWorkerNodeOptions(process.env.NODE_OPTIONS),
630
640
  WEBFRAMEZ_REACT_PAGES_DIR: pagesDir
631
641
  },
632
642
  stdio: ["ignore", "ignore", "pipe", "ipc"]
@@ -873,6 +883,32 @@ function createNodeRequestHandler(options) {
873
883
  });
874
884
  } catch (error) {
875
885
  console.error("[webframez-react] Failed to render initial HTML", error);
886
+ try {
887
+ initialHtmlWorker.dispose();
888
+ rootHtml = await initialHtmlWorker.render({
889
+ pathname: stripBasePath(url.pathname, basePath),
890
+ searchParams: parseSearchParams(url.searchParams),
891
+ cookies: requestCookies,
892
+ basename: basePath
893
+ });
894
+ } catch (retryError) {
895
+ console.error("[webframez-react] Retry for initial HTML failed", retryError);
896
+ res.statusCode = 500;
897
+ res.setHeader("Content-Type", "text/html");
898
+ res.end(
899
+ createHTMLShell({
900
+ title: "500 - Initial HTML render failed",
901
+ headTags: "",
902
+ clientScriptUrl,
903
+ rscEndpoint: rscPath,
904
+ rootHtml: createInitialHtmlErrorMarkup("Initial HTML render failed."),
905
+ basename: basePath,
906
+ liveReloadPath: liveReloadPath || void 0,
907
+ liveReloadServerId: liveReloadPath ? devServerId : void 0
908
+ })
909
+ );
910
+ return;
911
+ }
876
912
  }
877
913
  res.statusCode = resolved.statusCode;
878
914
  res.setHeader("Content-Type", "text/html");
package/dist/index.js CHANGED
@@ -479,6 +479,9 @@ function parseSearchParams(query) {
479
479
  import fs2 from "node:fs";
480
480
  import path2 from "node:path";
481
481
  import { spawn } from "node:child_process";
482
+ function createInitialHtmlErrorMarkup(message) {
483
+ return `<main style="font-family:system-ui,sans-serif;padding:24px"><h1 style="margin:0 0 12px">500</h1><p style="margin:0">${message}</p></main>`;
484
+ }
482
485
  var INITIAL_HTML_WORKER_SCRIPT = `
483
486
  const path = require("node:path");
484
487
  const Module = require("node:module");
@@ -560,6 +563,12 @@ function stripBasePath(pathname, basePath) {
560
563
  }
561
564
  return pathname;
562
565
  }
566
+ function sanitizeInitialHtmlWorkerNodeOptions(rawNodeOptions) {
567
+ if (!rawNodeOptions || rawNodeOptions.trim() === "") {
568
+ return "";
569
+ }
570
+ return rawNodeOptions.replace(/(^|\s)--conditions\s+react-server(?=\s|$)/g, " ").replace(/(^|\s)-r\s+(\S*webframez-react\/register)(?=\s|$)/g, " ").replace(/\s+/g, " ").trim();
571
+ }
563
572
  function createInitialHtmlWorker(pagesDir) {
564
573
  let child = null;
565
574
  let nextRequestId = 1;
@@ -591,6 +600,7 @@ function createInitialHtmlWorker(pagesDir) {
591
600
  cwd: process.cwd(),
592
601
  env: {
593
602
  ...process.env,
603
+ NODE_OPTIONS: sanitizeInitialHtmlWorkerNodeOptions(process.env.NODE_OPTIONS),
594
604
  WEBFRAMEZ_REACT_PAGES_DIR: pagesDir
595
605
  },
596
606
  stdio: ["ignore", "ignore", "pipe", "ipc"]
@@ -837,6 +847,32 @@ function createNodeRequestHandler(options) {
837
847
  });
838
848
  } catch (error) {
839
849
  console.error("[webframez-react] Failed to render initial HTML", error);
850
+ try {
851
+ initialHtmlWorker.dispose();
852
+ rootHtml = await initialHtmlWorker.render({
853
+ pathname: stripBasePath(url.pathname, basePath),
854
+ searchParams: parseSearchParams(url.searchParams),
855
+ cookies: requestCookies,
856
+ basename: basePath
857
+ });
858
+ } catch (retryError) {
859
+ console.error("[webframez-react] Retry for initial HTML failed", retryError);
860
+ res.statusCode = 500;
861
+ res.setHeader("Content-Type", "text/html");
862
+ res.end(
863
+ createHTMLShell({
864
+ title: "500 - Initial HTML render failed",
865
+ headTags: "",
866
+ clientScriptUrl,
867
+ rscEndpoint: rscPath,
868
+ rootHtml: createInitialHtmlErrorMarkup("Initial HTML render failed."),
869
+ basename: basePath,
870
+ liveReloadPath: liveReloadPath || void 0,
871
+ liveReloadServerId: liveReloadPath ? devServerId : void 0
872
+ })
873
+ );
874
+ return;
875
+ }
840
876
  }
841
877
  res.statusCode = resolved.statusCode;
842
878
  res.setHeader("Content-Type", "text/html");
@@ -481,6 +481,9 @@ function parseSearchParams(query) {
481
481
  }
482
482
 
483
483
  // src/http.ts
484
+ function createInitialHtmlErrorMarkup(message) {
485
+ return `<main style="font-family:system-ui,sans-serif;padding:24px"><h1 style="margin:0 0 12px">500</h1><p style="margin:0">${message}</p></main>`;
486
+ }
484
487
  var INITIAL_HTML_WORKER_SCRIPT = `
485
488
  const path = require("node:path");
486
489
  const Module = require("node:module");
@@ -562,6 +565,12 @@ function stripBasePath(pathname, basePath) {
562
565
  }
563
566
  return pathname;
564
567
  }
568
+ function sanitizeInitialHtmlWorkerNodeOptions(rawNodeOptions) {
569
+ if (!rawNodeOptions || rawNodeOptions.trim() === "") {
570
+ return "";
571
+ }
572
+ return rawNodeOptions.replace(/(^|\s)--conditions\s+react-server(?=\s|$)/g, " ").replace(/(^|\s)-r\s+(\S*webframez-react\/register)(?=\s|$)/g, " ").replace(/\s+/g, " ").trim();
573
+ }
565
574
  function createInitialHtmlWorker(pagesDir) {
566
575
  let child = null;
567
576
  let nextRequestId = 1;
@@ -593,6 +602,7 @@ function createInitialHtmlWorker(pagesDir) {
593
602
  cwd: process.cwd(),
594
603
  env: {
595
604
  ...process.env,
605
+ NODE_OPTIONS: sanitizeInitialHtmlWorkerNodeOptions(process.env.NODE_OPTIONS),
596
606
  WEBFRAMEZ_REACT_PAGES_DIR: pagesDir
597
607
  },
598
608
  stdio: ["ignore", "ignore", "pipe", "ipc"]
@@ -839,6 +849,32 @@ function createNodeRequestHandler(options) {
839
849
  });
840
850
  } catch (error) {
841
851
  console.error("[webframez-react] Failed to render initial HTML", error);
852
+ try {
853
+ initialHtmlWorker.dispose();
854
+ rootHtml = await initialHtmlWorker.render({
855
+ pathname: stripBasePath(url.pathname, basePath),
856
+ searchParams: parseSearchParams(url.searchParams),
857
+ cookies: requestCookies,
858
+ basename: basePath
859
+ });
860
+ } catch (retryError) {
861
+ console.error("[webframez-react] Retry for initial HTML failed", retryError);
862
+ res.statusCode = 500;
863
+ res.setHeader("Content-Type", "text/html");
864
+ res.end(
865
+ createHTMLShell({
866
+ title: "500 - Initial HTML render failed",
867
+ headTags: "",
868
+ clientScriptUrl,
869
+ rscEndpoint: rscPath,
870
+ rootHtml: createInitialHtmlErrorMarkup("Initial HTML render failed."),
871
+ basename: basePath,
872
+ liveReloadPath: liveReloadPath || void 0,
873
+ liveReloadServerId: liveReloadPath ? devServerId : void 0
874
+ })
875
+ );
876
+ return;
877
+ }
842
878
  }
843
879
  res.statusCode = resolved.statusCode;
844
880
  res.setHeader("Content-Type", "text/html");
@@ -453,6 +453,9 @@ function parseSearchParams(query) {
453
453
  }
454
454
 
455
455
  // src/http.ts
456
+ function createInitialHtmlErrorMarkup(message) {
457
+ return `<main style="font-family:system-ui,sans-serif;padding:24px"><h1 style="margin:0 0 12px">500</h1><p style="margin:0">${message}</p></main>`;
458
+ }
456
459
  var INITIAL_HTML_WORKER_SCRIPT = `
457
460
  const path = require("node:path");
458
461
  const Module = require("node:module");
@@ -534,6 +537,12 @@ function stripBasePath(pathname, basePath) {
534
537
  }
535
538
  return pathname;
536
539
  }
540
+ function sanitizeInitialHtmlWorkerNodeOptions(rawNodeOptions) {
541
+ if (!rawNodeOptions || rawNodeOptions.trim() === "") {
542
+ return "";
543
+ }
544
+ return rawNodeOptions.replace(/(^|\s)--conditions\s+react-server(?=\s|$)/g, " ").replace(/(^|\s)-r\s+(\S*webframez-react\/register)(?=\s|$)/g, " ").replace(/\s+/g, " ").trim();
545
+ }
537
546
  function createInitialHtmlWorker(pagesDir) {
538
547
  let child = null;
539
548
  let nextRequestId = 1;
@@ -565,6 +574,7 @@ function createInitialHtmlWorker(pagesDir) {
565
574
  cwd: process.cwd(),
566
575
  env: {
567
576
  ...process.env,
577
+ NODE_OPTIONS: sanitizeInitialHtmlWorkerNodeOptions(process.env.NODE_OPTIONS),
568
578
  WEBFRAMEZ_REACT_PAGES_DIR: pagesDir
569
579
  },
570
580
  stdio: ["ignore", "ignore", "pipe", "ipc"]
@@ -811,6 +821,32 @@ function createNodeRequestHandler(options) {
811
821
  });
812
822
  } catch (error) {
813
823
  console.error("[webframez-react] Failed to render initial HTML", error);
824
+ try {
825
+ initialHtmlWorker.dispose();
826
+ rootHtml = await initialHtmlWorker.render({
827
+ pathname: stripBasePath(url.pathname, basePath),
828
+ searchParams: parseSearchParams(url.searchParams),
829
+ cookies: requestCookies,
830
+ basename: basePath
831
+ });
832
+ } catch (retryError) {
833
+ console.error("[webframez-react] Retry for initial HTML failed", retryError);
834
+ res.statusCode = 500;
835
+ res.setHeader("Content-Type", "text/html");
836
+ res.end(
837
+ createHTMLShell({
838
+ title: "500 - Initial HTML render failed",
839
+ headTags: "",
840
+ clientScriptUrl,
841
+ rscEndpoint: rscPath,
842
+ rootHtml: createInitialHtmlErrorMarkup("Initial HTML render failed."),
843
+ basename: basePath,
844
+ liveReloadPath: liveReloadPath || void 0,
845
+ liveReloadServerId: liveReloadPath ? devServerId : void 0
846
+ })
847
+ );
848
+ return;
849
+ }
814
850
  }
815
851
  res.statusCode = resolved.statusCode;
816
852
  res.setHeader("Content-Type", "text/html");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@webtypen/webframez-react",
3
- "version": "0.0.5",
3
+ "version": "0.0.6",
4
4
  "description": "TypeScript React RSC addition for @webtypen/webframez-core",
5
5
  "homepage": "https://webtypen.de/",
6
6
  "author": {