@absolutejs/absolute 0.18.3-beta.7 → 0.18.3-beta.9

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.
@@ -99,10 +99,34 @@ body{min-height:100vh;background:linear-gradient(135deg,rgba(15,23,42,0.98) 0%,r
99
99
  };
100
100
 
101
101
  // src/react/pageHandler.ts
102
+ var ensureReactConsistency = (react) => {
103
+ const pinned = globalThis.__reactModuleRef;
104
+ if (!pinned || pinned === react)
105
+ return;
106
+ const KEY = "__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED";
107
+ const pinnedInternals = pinned[KEY];
108
+ const currentInternals = react[KEY];
109
+ if (!pinnedInternals || !currentInternals || pinnedInternals === currentInternals)
110
+ return;
111
+ for (const prop of Object.keys(pinnedInternals)) {
112
+ Object.defineProperty(currentInternals, prop, {
113
+ get() {
114
+ return pinnedInternals[prop];
115
+ },
116
+ set(v) {
117
+ pinnedInternals[prop] = v;
118
+ },
119
+ configurable: true,
120
+ enumerable: true
121
+ });
122
+ }
123
+ };
102
124
  var handleReactPageRequest = async (PageComponent, index, ...props) => {
103
125
  try {
104
126
  const [maybeProps] = props;
105
- const { createElement } = await import("react");
127
+ const react = await import("react");
128
+ ensureReactConsistency(react);
129
+ const { createElement } = react;
106
130
  const { renderToReadableStream } = await import("react-dom/server");
107
131
  const element = maybeProps !== undefined ? createElement(PageComponent, maybeProps) : createElement(PageComponent);
108
132
  const refreshStubs = "window.$RefreshReg$=function(){};window.$RefreshSig$=function(){return function(t){return t}};";
@@ -129,5 +153,5 @@ export {
129
153
  handleReactPageRequest
130
154
  };
131
155
 
132
- //# debugId=B73602A258AC0EF264756E2164756E21
156
+ //# debugId=F8A662356402AA3364756E2164756E21
133
157
  //# sourceMappingURL=index.js.map
@@ -3,9 +3,9 @@
3
3
  "sources": ["../src/utils/ssrErrorPage.ts", "../src/react/pageHandler.ts"],
4
4
  "sourcesContent": [
5
5
  "export const ssrErrorPage = (framework: string, error: unknown) => {\n\tconst frameworkColors: Record<string, string> = {\n\t\tangular: '#dd0031',\n\t\thtml: '#e34c26',\n\t\thtmx: '#1a365d',\n\t\treact: '#61dafb',\n\t\tsvelte: '#ff3e00',\n\t\tvue: '#42b883'\n\t};\n\n\tconst accent = frameworkColors[framework] ?? '#94a3b8';\n\tconst label = framework.charAt(0).toUpperCase() + framework.slice(1);\n\tconst message = error instanceof Error ? error.message : String(error);\n\n\treturn `<!DOCTYPE html>\n<html>\n<head>\n<meta charset=\"utf-8\">\n<meta name=\"viewport\" content=\"width=device-width, initial-scale=1\">\n<title>SSR Error - AbsoluteJS</title>\n<style>\n*{margin:0;padding:0;box-sizing:border-box}\nbody{min-height:100vh;background:linear-gradient(135deg,rgba(15,23,42,0.98) 0%,rgba(30,41,59,0.98) 100%);color:#e2e8f0;font-family:\"JetBrains Mono\",\"Fira Code\",ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;font-size:14px;line-height:1.6;display:flex;align-items:flex-start;justify-content:center;padding:32px}\n.card{max-width:720px;width:100%;background:rgba(30,41,59,0.6);border:1px solid rgba(71,85,105,0.5);border-radius:16px;box-shadow:0 25px 50px -12px rgba(0,0,0,0.5),0 0 0 1px rgba(255,255,255,0.05);overflow:hidden}\n.header{display:flex;align-items:center;justify-content:space-between;gap:16px;padding:20px 24px;background:rgba(15,23,42,0.5);border-bottom:1px solid rgba(71,85,105,0.4)}\n.brand{font-weight:700;font-size:20px;color:#fff;letter-spacing:-0.02em}\n.badge{padding:5px 10px;border-radius:8px;font-size:12px;font-weight:600;background:${accent};color:#fff;opacity:0.95;box-shadow:0 2px 4px rgba(0,0,0,0.2)}\n.kind{color:#94a3b8;font-size:13px;font-weight:500}\n.content{padding:24px}\n.label{font-size:11px;font-weight:600;text-transform:uppercase;letter-spacing:0.08em;color:#94a3b8;margin-bottom:8px}\n.message{margin:0;padding:16px 20px;background:rgba(239,68,68,0.12);border:1px solid rgba(239,68,68,0.25);border-radius:10px;overflow-x:auto;white-space:pre-wrap;word-break:break-word;color:#fca5a5;font-size:13px;line-height:1.5}\n.hint{margin-top:20px;padding:12px 20px;background:rgba(71,85,105,0.3);border-radius:10px;border:1px solid rgba(71,85,105,0.4);color:#cbd5e1;font-size:13px}\n</style>\n</head>\n<body>\n<div class=\"card\">\n<div class=\"header\">\n<div style=\"display:flex;align-items:center;gap:12px\">\n<span class=\"brand\">AbsoluteJS</span>\n<span class=\"badge\">${label}</span>\n</div>\n<span class=\"kind\">Server Render Error</span>\n</div>\n<div class=\"content\">\n<div class=\"label\">What went wrong</div>\n<pre class=\"message\">${message.replace(/&/g, '&amp;').replace(/</g, '&lt;').replace(/>/g, '&gt;')}</pre>\n<div class=\"hint\">A component threw during server-side rendering. Check the terminal for the full stack trace.</div>\n</div>\n</div>\n</body>\n</html>`;\n};\n",
6
- "import type { ComponentType as ReactComponent } from 'react';\nimport { ssrErrorPage } from '../utils/ssrErrorPage';\n\nexport const handleReactPageRequest = async <\n\tProps extends Record<string, unknown> = Record<never, never>\n>(\n\tPageComponent: ReactComponent<Props>,\n\tindex: string,\n\t...props: keyof Props extends never ? [] : [props: NoInfer<Props>]\n) => {\n\ttry {\n\t\tconst [maybeProps] = props;\n\t\tconst { createElement } = await import('react');\n\t\tconst { renderToReadableStream } = await import('react-dom/server');\n\n\t\tconst element =\n\t\t\tmaybeProps !== undefined\n\t\t\t\t? createElement(PageComponent, maybeProps)\n\t\t\t\t: createElement(PageComponent);\n\n\t\t// In dev mode, Bun's reactFastRefresh injects $RefreshReg$/$RefreshSig$\n\t\t// calls into component code. With code splitting, shared component chunks\n\t\t// may load before the chunk containing reactRefreshSetup.ts — causing a\n\t\t// ReferenceError. These no-op stubs ensure the globals exist before any\n\t\t// module code runs. reactRefreshSetup.ts overwrites them with the real\n\t\t// implementations once its chunk executes.\n\t\tconst refreshStubs =\n\t\t\tprocess.env.NODE_ENV === 'development'\n\t\t\t\t? 'window.$RefreshReg$=function(){};window.$RefreshSig$=function(){return function(t){return t}};'\n\t\t\t\t: '';\n\t\tconst propsScript = maybeProps\n\t\t\t? `window.__INITIAL_PROPS__=${JSON.stringify(maybeProps)}`\n\t\t\t: '';\n\n\t\tconst stream = await renderToReadableStream(element, {\n\t\t\tbootstrapModules: [index],\n\t\t\tbootstrapScriptContent: refreshStubs + propsScript || undefined,\n\t\t\tonError(error: unknown) {\n\t\t\t\tconsole.error('[SSR] React streaming error:', error);\n\t\t\t}\n\t\t});\n\n\t\treturn new Response(stream, {\n\t\t\theaders: { 'Content-Type': 'text/html' }\n\t\t});\n\t} catch (error) {\n\t\tconsole.error('[SSR] React render error:', error);\n\n\t\treturn new Response(ssrErrorPage('react', error), {\n\t\t\theaders: { 'Content-Type': 'text/html' },\n\t\t\tstatus: 500\n\t\t});\n\t}\n};\n"
6
+ "import type { ComponentType as ReactComponent } from 'react';\nimport { ssrErrorPage } from '../utils/ssrErrorPage';\n\n/**\n * After `bun install` adds new packages, Bun's module cache can resolve\n * `react` to a new instance while `react-dom` still holds the original.\n * The two copies have separate `__SECRET_INTERNALS__` objects, so the\n * hook dispatcher set by react-dom is invisible to hooks in user\n * components — causing \"Invalid hook call\".\n *\n * Fix: redirect the new React's internals to the pinned (original)\n * instance via property descriptors so both share one dispatcher.\n */\nconst ensureReactConsistency = (\n\treact: typeof import('react')\n): void => {\n\tconst pinned = globalThis.__reactModuleRef;\n\tif (!pinned || pinned === react) return;\n\n\tconst KEY =\n\t\t'__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED' as const;\n\ttype Internals = Record<string, unknown>;\n\n\tconst pinnedInternals = (pinned as Record<string, unknown>)[\n\t\tKEY\n\t] as Internals | undefined;\n\tconst currentInternals = (react as Record<string, unknown>)[\n\t\tKEY\n\t] as Internals | undefined;\n\n\tif (\n\t\t!pinnedInternals ||\n\t\t!currentInternals ||\n\t\tpinnedInternals === currentInternals\n\t)\n\t\treturn;\n\n\t// Delegate each internals key (H, A, T, S …) so reads/writes on the\n\t// new React go through to the pinned instance that react-dom uses.\n\tfor (const prop of Object.keys(pinnedInternals)) {\n\t\tObject.defineProperty(currentInternals, prop, {\n\t\t\tget() {\n\t\t\t\treturn pinnedInternals[prop];\n\t\t\t},\n\t\t\tset(v: unknown) {\n\t\t\t\tpinnedInternals[prop] = v;\n\t\t\t},\n\t\t\tconfigurable: true,\n\t\t\tenumerable: true\n\t\t});\n\t}\n};\n\nexport const handleReactPageRequest = async <\n\tProps extends Record<string, unknown> = Record<never, never>\n>(\n\tPageComponent: ReactComponent<Props>,\n\tindex: string,\n\t...props: keyof Props extends never ? [] : [props: NoInfer<Props>]\n) => {\n\ttry {\n\t\tconst [maybeProps] = props;\n\t\tconst react = await import('react');\n\t\tensureReactConsistency(react);\n\t\tconst { createElement } = react;\n\t\tconst { renderToReadableStream } = await import('react-dom/server');\n\n\t\tconst element =\n\t\t\tmaybeProps !== undefined\n\t\t\t\t? createElement(PageComponent, maybeProps)\n\t\t\t\t: createElement(PageComponent);\n\n\t\t// In dev mode, Bun's reactFastRefresh injects $RefreshReg$/$RefreshSig$\n\t\t// calls into component code. With code splitting, shared component chunks\n\t\t// may load before the chunk containing reactRefreshSetup.ts — causing a\n\t\t// ReferenceError. These no-op stubs ensure the globals exist before any\n\t\t// module code runs. reactRefreshSetup.ts overwrites them with the real\n\t\t// implementations once its chunk executes.\n\t\tconst refreshStubs =\n\t\t\tprocess.env.NODE_ENV === 'development'\n\t\t\t\t? 'window.$RefreshReg$=function(){};window.$RefreshSig$=function(){return function(t){return t}};'\n\t\t\t\t: '';\n\t\tconst propsScript = maybeProps\n\t\t\t? `window.__INITIAL_PROPS__=${JSON.stringify(maybeProps)}`\n\t\t\t: '';\n\n\t\tconst stream = await renderToReadableStream(element, {\n\t\t\tbootstrapModules: [index],\n\t\t\tbootstrapScriptContent: refreshStubs + propsScript || undefined,\n\t\t\tonError(error: unknown) {\n\t\t\t\tconsole.error('[SSR] React streaming error:', error);\n\t\t\t}\n\t\t});\n\n\t\treturn new Response(stream, {\n\t\t\theaders: { 'Content-Type': 'text/html' }\n\t\t});\n\t} catch (error) {\n\t\tconsole.error('[SSR] React render error:', error);\n\n\t\treturn new Response(ssrErrorPage('react', error), {\n\t\t\theaders: { 'Content-Type': 'text/html' },\n\t\t\tstatus: 500\n\t\t});\n\t}\n};\n"
7
7
  ],
8
- "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAO,IAAM,eAAe,CAAC,WAAmB,UAAmB;AAAA,EAClE,MAAM,kBAA0C;AAAA,IAC/C,SAAS;AAAA,IACT,MAAM;AAAA,IACN,MAAM;AAAA,IACN,OAAO;AAAA,IACP,QAAQ;AAAA,IACR,KAAK;AAAA,EACN;AAAA,EAEA,MAAM,SAAS,gBAAgB,cAAc;AAAA,EAC7C,MAAM,QAAQ,UAAU,OAAO,CAAC,EAAE,YAAY,IAAI,UAAU,MAAM,CAAC;AAAA,EACnE,MAAM,UAAU,iBAAiB,QAAQ,MAAM,UAAU,OAAO,KAAK;AAAA,EAErE,OAAO;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,sFAY8E;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,sBAahE;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,uBAMC,QAAQ,QAAQ,MAAM,OAAO,EAAE,QAAQ,MAAM,MAAM,EAAE,QAAQ,MAAM,MAAM;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;AC1CzF,IAAM,yBAAyB,OAGrC,eACA,UACG,UACC;AAAA,EACJ,IAAI;AAAA,IACH,OAAO,cAAc;AAAA,IACrB,QAAQ,kBAAkB,MAAa;AAAA,IACvC,QAAQ,2BAA2B,MAAa;AAAA,IAEhD,MAAM,UACL,eAAe,YACZ,cAAc,eAAe,UAAU,IACvC,cAAc,aAAa;AAAA,IAQ/B,MAAM,eAEF;AAAA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A;AAAA,IAErD,CAAC;AAAA,IAED,OAAO,IAAI,SAAS,QAAQ;AAAA,MAC3B,SAAS,EAAE,gBAAgB,YAAY;AAAA,IACxC,CAAC;AAAA,IACA,OAAO,OAAO;AAAA,IACf,QAAQ,MAAM,6BAA6B,KAAK;AAAA,IAEhD,OAAO,IAAI,SAAS,aAAa,SAAS,KAAK,GAAG;AAAA,MACjD,SAAS,EAAE,gBAAgB,YAAY;AAAA,MACvC,QAAQ;AAAA,IACT,CAAC;AAAA;AAAA;",
9
+ "debugId": "F8A662356402AA3364756E2164756E21",
10
10
  "names": []
11
11
  }
package/package.json CHANGED
@@ -4,7 +4,6 @@
4
4
  "absolute": "./dist/cli/index.js"
5
5
  },
6
6
  "dependencies": {
7
- "@absolutejs/absolute": "0.18.2-beta.1",
8
7
  "@angular/compiler": "^21.0.0",
9
8
  "react-refresh": "^0.18.0"
10
9
  },
@@ -152,5 +151,5 @@
152
151
  "typecheck": "bun run vue-tsc --noEmit"
153
152
  },
154
153
  "types": "./dist/src/index.d.ts",
155
- "version": "0.18.3-beta.7"
154
+ "version": "0.18.3-beta.9"
156
155
  }
@@ -5,6 +5,10 @@ declare global {
5
5
  var __absoluteVersion: string | undefined;
6
6
  var __hmrServerMtime: number | undefined;
7
7
  var __hmrSkipServerRestart: boolean | undefined;
8
+ /** Pinned React module from initial devBuild — used to detect and bridge
9
+ * duplicate React instances after bun install invalidates the module cache. */
10
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
11
+ var __reactModuleRef: any;
8
12
  var __hmrDevResult:
9
13
  | {
10
14
  hmrState: import('../src/dev/clientManager').HMRState;