@absolutejs/absolute 0.19.0-beta.33 → 0.19.0-beta.35
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/.claude/settings.local.json +2 -1
- package/dist/dev/ssrWorker.ts +55 -0
- package/dist/index.js +294 -207
- package/dist/index.js.map +5 -4
- package/dist/react/index.js +88 -1
- package/dist/react/index.js.map +5 -4
- package/dist/src/dev/ssrRenderer.d.ts +7 -0
- package/dist/src/dev/ssrWorker.d.ts +0 -0
- 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 +6 -6
|
@@ -147,7 +147,8 @@
|
|
|
147
147
|
"Bash(/dev/null cd:*)",
|
|
148
148
|
"Bash(CMAKE_BUILD_TYPE=Release bun bd -- -Doptimize=ReleaseFast)",
|
|
149
149
|
"Bash(/dev/null rm:*)",
|
|
150
|
-
"Bash(grep '\"\"version\"\"' package.json)"
|
|
150
|
+
"Bash(grep '\"\"version\"\"' package.json)",
|
|
151
|
+
"Bash(cd:*)"
|
|
151
152
|
]
|
|
152
153
|
}
|
|
153
154
|
}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
// SSR Worker — renders React components in a separate context so
|
|
2
|
+
// frontend imports don't pollute bun --hot's module graph.
|
|
3
|
+
// Each render dynamically imports the component fresh.
|
|
4
|
+
|
|
5
|
+
/* eslint-disable no-restricted-globals */
|
|
6
|
+
|
|
7
|
+
self.onmessage = async (event) => {
|
|
8
|
+
const { id, componentPath, indexPath, props } = event.data;
|
|
9
|
+
|
|
10
|
+
try {
|
|
11
|
+
// Dynamic import with cache bust — always gets fresh module
|
|
12
|
+
const timestamp = Date.now();
|
|
13
|
+
const mod = await import(`${componentPath}?t=${timestamp}`);
|
|
14
|
+
const Component = mod.default ?? Object.values(mod)[0];
|
|
15
|
+
|
|
16
|
+
const { createElement } = await import('react');
|
|
17
|
+
const { renderToReadableStream } = await import('react-dom/server');
|
|
18
|
+
|
|
19
|
+
const propsScript = props
|
|
20
|
+
? `window.__INITIAL_PROPS__=${JSON.stringify(props)}`
|
|
21
|
+
: '';
|
|
22
|
+
|
|
23
|
+
const element = props
|
|
24
|
+
? createElement(Component, props)
|
|
25
|
+
: createElement(Component);
|
|
26
|
+
|
|
27
|
+
const stream = await renderToReadableStream(element, {
|
|
28
|
+
bootstrapModules: indexPath ? [indexPath] : [],
|
|
29
|
+
bootstrapScriptContent: propsScript || undefined,
|
|
30
|
+
onError(error: unknown) {
|
|
31
|
+
console.error('[SSR Worker] React streaming error:', error);
|
|
32
|
+
}
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
// Collect the stream into a string
|
|
36
|
+
const reader = stream.getReader();
|
|
37
|
+
const chunks: string[] = [];
|
|
38
|
+
const decoder = new TextDecoder();
|
|
39
|
+
|
|
40
|
+
let done = false;
|
|
41
|
+
while (!done) {
|
|
42
|
+
const result = await reader.read();
|
|
43
|
+
done = result.done;
|
|
44
|
+
if (result.value) {
|
|
45
|
+
chunks.push(decoder.decode(result.value, { stream: !done }));
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
self.postMessage({ html: chunks.join(''), id, ok: true });
|
|
50
|
+
} catch (error) {
|
|
51
|
+
const message =
|
|
52
|
+
error instanceof Error ? error.message : String(error);
|
|
53
|
+
self.postMessage({ error: message, id, ok: false });
|
|
54
|
+
}
|
|
55
|
+
};
|