@absolutejs/absolute 0.19.0-beta.35 → 0.19.0-beta.36
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/.absolutejs/tsconfig.tsbuildinfo +1 -1
- package/dist/index.js +207 -294
- package/dist/index.js.map +4 -5
- package/dist/react/index.js +1 -88
- package/dist/react/index.js.map +4 -5
- package/native/packages/darwin-arm64/package.json +1 -1
- package/native/packages/darwin-x64/package.json +1 -1
- package/native/packages/linux-arm64/package.json +1 -1
- package/native/packages/linux-x64/package.json +1 -1
- package/package.json +5 -5
package/dist/react/index.js
CHANGED
|
@@ -98,97 +98,10 @@ body{min-height:100vh;background:linear-gradient(135deg,rgba(15,23,42,0.98) 0%,r
|
|
|
98
98
|
</html>`;
|
|
99
99
|
};
|
|
100
100
|
|
|
101
|
-
// src/dev/ssrRenderer.ts
|
|
102
|
-
var exports_ssrRenderer = {};
|
|
103
|
-
__export(exports_ssrRenderer, {
|
|
104
|
-
renderInWorker: () => renderInWorker
|
|
105
|
-
});
|
|
106
|
-
import { resolve } from "path";
|
|
107
|
-
var worker = null, requestId = 0, pending, getWorker = () => {
|
|
108
|
-
if (worker)
|
|
109
|
-
return worker;
|
|
110
|
-
const workerPath = resolve(import.meta.dir, "ssrWorker.ts");
|
|
111
|
-
worker = new Worker(workerPath);
|
|
112
|
-
worker.onmessage = (event) => {
|
|
113
|
-
const { id, ok, html, error } = event.data;
|
|
114
|
-
const req = pending.get(id);
|
|
115
|
-
if (!req)
|
|
116
|
-
return;
|
|
117
|
-
pending.delete(id);
|
|
118
|
-
if (ok) {
|
|
119
|
-
req.resolve(html);
|
|
120
|
-
} else {
|
|
121
|
-
req.reject(new Error(error ?? "SSR render failed"));
|
|
122
|
-
}
|
|
123
|
-
};
|
|
124
|
-
worker.onerror = (event) => {
|
|
125
|
-
console.error("[SSR Worker] Error:", event);
|
|
126
|
-
for (const [id, req] of pending) {
|
|
127
|
-
req.reject(new Error("SSR worker crashed"));
|
|
128
|
-
pending.delete(id);
|
|
129
|
-
}
|
|
130
|
-
worker = null;
|
|
131
|
-
};
|
|
132
|
-
return worker;
|
|
133
|
-
}, renderInWorker = (request) => new Promise((resolvePromise, rejectPromise) => {
|
|
134
|
-
const id = ++requestId;
|
|
135
|
-
pending.set(id, {
|
|
136
|
-
reject: rejectPromise,
|
|
137
|
-
resolve: resolvePromise
|
|
138
|
-
});
|
|
139
|
-
const w = getWorker();
|
|
140
|
-
w.postMessage({
|
|
141
|
-
componentPath: resolve(request.componentPath),
|
|
142
|
-
id,
|
|
143
|
-
indexPath: request.indexPath,
|
|
144
|
-
props: request.props
|
|
145
|
-
});
|
|
146
|
-
});
|
|
147
|
-
var init_ssrRenderer = __esm(() => {
|
|
148
|
-
pending = new Map;
|
|
149
|
-
});
|
|
150
|
-
|
|
151
101
|
// src/react/pageHandler.ts
|
|
152
|
-
var isDev = process.env["NODE_ENV"] === "development";
|
|
153
|
-
var resolveComponentPath = (component) => {
|
|
154
|
-
const name = component.displayName ?? component.name;
|
|
155
|
-
if (!name)
|
|
156
|
-
return null;
|
|
157
|
-
const config = globalThis.__hmrDevResult?.hmrState?.config;
|
|
158
|
-
const reactDir = config?.reactDirectory;
|
|
159
|
-
if (!reactDir)
|
|
160
|
-
return null;
|
|
161
|
-
const { resolve: resolve2, join } = __require("path");
|
|
162
|
-
const { existsSync } = __require("fs");
|
|
163
|
-
const pagesDir = resolve2(reactDir, "pages");
|
|
164
|
-
const candidates = [
|
|
165
|
-
join(pagesDir, `${name}.tsx`),
|
|
166
|
-
join(pagesDir, `${name}.jsx`),
|
|
167
|
-
join(pagesDir, `${name}.ts`)
|
|
168
|
-
];
|
|
169
|
-
for (const candidate of candidates) {
|
|
170
|
-
if (existsSync(candidate))
|
|
171
|
-
return candidate;
|
|
172
|
-
}
|
|
173
|
-
return null;
|
|
174
|
-
};
|
|
175
102
|
var handleReactPageRequest = async (PageComponent, index, ...props) => {
|
|
176
103
|
try {
|
|
177
104
|
const [maybeProps] = props;
|
|
178
|
-
if (isDev) {
|
|
179
|
-
const componentPath = resolveComponentPath(PageComponent);
|
|
180
|
-
if (componentPath) {
|
|
181
|
-
const { renderInWorker: renderInWorker2 } = await Promise.resolve().then(() => (init_ssrRenderer(), exports_ssrRenderer));
|
|
182
|
-
const html = await renderInWorker2({
|
|
183
|
-
componentPath,
|
|
184
|
-
indexPath: index,
|
|
185
|
-
props: maybeProps
|
|
186
|
-
});
|
|
187
|
-
return new Response(html, {
|
|
188
|
-
headers: { "Content-Type": "text/html" }
|
|
189
|
-
});
|
|
190
|
-
}
|
|
191
|
-
}
|
|
192
105
|
const { createElement } = await import("react");
|
|
193
106
|
const { renderToReadableStream } = await import("react-dom/server");
|
|
194
107
|
const element = maybeProps !== undefined ? createElement(PageComponent, maybeProps) : createElement(PageComponent);
|
|
@@ -215,5 +128,5 @@ export {
|
|
|
215
128
|
handleReactPageRequest
|
|
216
129
|
};
|
|
217
130
|
|
|
218
|
-
//# debugId=
|
|
131
|
+
//# debugId=EAAD0B18629FAAB864756E2164756E21
|
|
219
132
|
//# sourceMappingURL=index.js.map
|
package/dist/react/index.js.map
CHANGED
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
|
-
"sources": ["../src/utils/ssrErrorPage.ts", "../src/
|
|
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, '&').replace(/</g, '<').replace(/>/g, '>')}</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 {
|
|
7
|
-
"import type { ComponentType as ReactComponent } from 'react';\nimport { ssrErrorPage } from '../utils/ssrErrorPage';\n\nconst isDev = process.env['NODE_ENV'] === 'development';\n\n// In dev mode, resolve the component's source path from its name\n// so we can render in a worker (outside bun --hot's module graph)\nconst resolveComponentPath = (component: ReactComponent<Record<string, unknown>>) => {\n\tconst name = component.displayName ?? component.name;\n\tif (!name) return null;\n\n\tconst config = globalThis.__hmrDevResult?.hmrState?.config;\n\tconst reactDir = config?.reactDirectory;\n\tif (!reactDir) return null;\n\n\tconst { resolve, join } = require('node:path');\n\tconst { existsSync } = require('node:fs');\n\tconst pagesDir = resolve(reactDir, 'pages');\n\tconst candidates = [\n\t\tjoin(pagesDir, `${name}.tsx`),\n\t\tjoin(pagesDir, `${name}.jsx`),\n\t\tjoin(pagesDir, `${name}.ts`)\n\t];\n\n\tfor (const candidate of candidates) {\n\t\tif (existsSync(candidate)) return candidate;\n\t}\n\n\treturn null;\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\n\t\t// In dev mode, render in a worker to avoid polluting\n\t\t// bun --hot's module graph with frontend imports\n\t\tif (isDev) {\n\t\t\tconst componentPath = resolveComponentPath(\n\t\t\t\tPageComponent as ReactComponent<Record<string, unknown>>\n\t\t\t);\n\t\t\tif (componentPath) {\n\t\t\t\tconst { renderInWorker } = await import(\n\t\t\t\t\t'../dev/ssrRenderer'\n\t\t\t\t);\n\t\t\t\tconst html = await renderInWorker({\n\t\t\t\t\tcomponentPath,\n\t\t\t\t\tindexPath: index,\n\t\t\t\t\tprops: maybeProps as Record<string, unknown> | undefined\n\t\t\t\t});\n\n\t\t\t\treturn new Response(html, {\n\t\t\t\t\theaders: { 'Content-Type': 'text/html' }\n\t\t\t\t});\n\t\t\t}\n\t\t}\n\n\t\t// Production path (or fallback if component path not found)\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\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: 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\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\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: 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"
|
|
8
7
|
],
|
|
9
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IAAa,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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wB,eAAe;AAAA,MACvC,OAAO,CAAC,OAAgB;AAAA,QACvB,QAAQ,MAAM,gCAAgC,KAAK;AAAA;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": "EAAD0B18629FAAB864756E2164756E21",
|
|
11
10
|
"names": []
|
|
12
11
|
}
|
package/package.json
CHANGED
|
@@ -138,10 +138,10 @@
|
|
|
138
138
|
}
|
|
139
139
|
},
|
|
140
140
|
"optionalDependencies": {
|
|
141
|
-
"@absolutejs/native-darwin-arm64": "0.19.0-beta.
|
|
142
|
-
"@absolutejs/native-darwin-x64": "0.19.0-beta.
|
|
143
|
-
"@absolutejs/native-linux-arm64": "0.19.0-beta.
|
|
144
|
-
"@absolutejs/native-linux-x64": "0.19.0-beta.
|
|
141
|
+
"@absolutejs/native-darwin-arm64": "0.19.0-beta.36",
|
|
142
|
+
"@absolutejs/native-darwin-x64": "0.19.0-beta.36",
|
|
143
|
+
"@absolutejs/native-linux-arm64": "0.19.0-beta.36",
|
|
144
|
+
"@absolutejs/native-linux-x64": "0.19.0-beta.36"
|
|
145
145
|
},
|
|
146
146
|
"repository": {
|
|
147
147
|
"type": "git",
|
|
@@ -162,5 +162,5 @@
|
|
|
162
162
|
"typecheck": "bun run vue-tsc --noEmit"
|
|
163
163
|
},
|
|
164
164
|
"types": "./dist/src/index.d.ts",
|
|
165
|
-
"version": "0.19.0-beta.
|
|
165
|
+
"version": "0.19.0-beta.36"
|
|
166
166
|
}
|