@ripple-ts/vite-plugin 0.3.92 → 0.3.93
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/CHANGELOG.md +13 -0
- package/package.json +3 -3
- package/src/server/render-route.js +3 -4
- package/src/server/stream-response.js +1 -1
- package/src/server/virtual-entry.js +4 -4
- package/tests/render-route-props.test.js +3 -3
- package/tests/stream-response.test.js +8 -1
- package/types/production.d.ts +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,18 @@
|
|
|
1
1
|
# @ripple-ts/vite-plugin
|
|
2
2
|
|
|
3
|
+
## 0.3.93
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [`9db5a49`](https://github.com/Ripple-TS/ripple/commit/9db5a49e45c2eb3bb4f6b46c65c0aaf9016633ad)
|
|
8
|
+
Thanks [@leonidaz](https://github.com/leonidaz)! - Rename the `ripple/server`
|
|
9
|
+
helper exports to camelCase: `create_ssr_stream` is now `createStream` and
|
|
10
|
+
`get_css_for_hashes` is now `getCss` (returning the CSS text for the scoped
|
|
11
|
+
style hashes collected by `render()`). The old snake_case exports are removed;
|
|
12
|
+
update imports accordingly. The vite plugin consumes the new names internally.
|
|
13
|
+
- Updated dependencies []:
|
|
14
|
+
- @ripple-ts/adapter@0.3.93
|
|
15
|
+
|
|
3
16
|
## 0.3.92
|
|
4
17
|
|
|
5
18
|
### Patch Changes
|
package/package.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"description": "Vite plugin for Ripple",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"author": "Dominic Gannaway",
|
|
6
|
-
"version": "0.3.
|
|
6
|
+
"version": "0.3.93",
|
|
7
7
|
"type": "module",
|
|
8
8
|
"module": "src/index.js",
|
|
9
9
|
"main": "src/index.js",
|
|
@@ -32,14 +32,14 @@
|
|
|
32
32
|
"url": "https://github.com/Ripple-TS/ripple/issues"
|
|
33
33
|
},
|
|
34
34
|
"dependencies": {
|
|
35
|
-
"@ripple-ts/adapter": "0.3.
|
|
35
|
+
"@ripple-ts/adapter": "0.3.93",
|
|
36
36
|
"@tsrx/ripple": "0.1.38"
|
|
37
37
|
},
|
|
38
38
|
"devDependencies": {
|
|
39
39
|
"@types/node": "^24.3.0",
|
|
40
40
|
"type-fest": "^5.6.0",
|
|
41
41
|
"vite": "^8.0.12",
|
|
42
|
-
"ripple": "0.3.
|
|
42
|
+
"ripple": "0.3.93"
|
|
43
43
|
},
|
|
44
44
|
"publishConfig": {
|
|
45
45
|
"access": "public"
|
|
@@ -41,8 +41,7 @@ export async function handleRenderRoute(route, context, vite, rippleConfig) {
|
|
|
41
41
|
}
|
|
42
42
|
|
|
43
43
|
// Load ripple server utilities
|
|
44
|
-
const { render,
|
|
45
|
-
await vite.ssrLoadModule('ripple/server');
|
|
44
|
+
const { render, getCss, createStream } = await vite.ssrLoadModule('ripple/server');
|
|
46
45
|
|
|
47
46
|
// Load the page component
|
|
48
47
|
const entryPath = get_route_entry_path(route.entry);
|
|
@@ -102,7 +101,7 @@ export async function handleRenderRoute(route, context, vite, rippleConfig) {
|
|
|
102
101
|
if (streamTemplate) {
|
|
103
102
|
return createStreamingResponse({
|
|
104
103
|
render,
|
|
105
|
-
createSsrStream:
|
|
104
|
+
createSsrStream: createStream,
|
|
106
105
|
component: RootComponent,
|
|
107
106
|
rootBoundary: rippleConfig?.rootBoundary,
|
|
108
107
|
streamTemplate,
|
|
@@ -122,7 +121,7 @@ export async function handleRenderRoute(route, context, vite, rippleConfig) {
|
|
|
122
121
|
// Generate CSS tags
|
|
123
122
|
let cssContent = '';
|
|
124
123
|
if (css.size > 0) {
|
|
125
|
-
const cssString =
|
|
124
|
+
const cssString = getCss(css);
|
|
126
125
|
if (cssString) {
|
|
127
126
|
cssContent = `<style data-ripple-ssr>${cssString}</style>`;
|
|
128
127
|
}
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* (render-route.js) and the production runtime (production.js).
|
|
4
4
|
*
|
|
5
5
|
* Platform-agnostic: relies only on the Web `Response`/`ReadableStream`
|
|
6
|
-
* globals and the `render`/`
|
|
6
|
+
* globals and the `render`/`createStream` functions injected by the
|
|
7
7
|
* caller.
|
|
8
8
|
*/
|
|
9
9
|
|
|
@@ -35,7 +35,7 @@ import {
|
|
|
35
35
|
* Generate the virtual server entry module source code.
|
|
36
36
|
*
|
|
37
37
|
* The generated module:
|
|
38
|
-
* 1. Imports ripple SSR utilities (render,
|
|
38
|
+
* 1. Imports ripple SSR utilities (render, getCss, executeServerFunction)
|
|
39
39
|
* 2. Imports createHandler from @ripple-ts/vite-plugin/production
|
|
40
40
|
* 3. Imports ripple.config.ts to get adapter, middlewares, and routes
|
|
41
41
|
* 4. Imports each RenderRoute's entry (and layout) as SSR components
|
|
@@ -144,7 +144,7 @@ export function generateServerEntry(options) {
|
|
|
144
144
|
// Auto-generated server entry for production build
|
|
145
145
|
// Do not edit — regenerated on each build
|
|
146
146
|
|
|
147
|
-
import { render,
|
|
147
|
+
import { render, getCss, createStream, executeServerFunction } from 'ripple/server';
|
|
148
148
|
import { createHandler, resolveRippleConfig } from '@ripple-ts/vite-plugin/production';
|
|
149
149
|
import { readFileSync, existsSync } from 'node:fs';
|
|
150
150
|
import { fileURLToPath } from 'node:url';
|
|
@@ -206,10 +206,10 @@ const handler = createHandler(
|
|
|
206
206
|
},
|
|
207
207
|
{
|
|
208
208
|
render,
|
|
209
|
-
getCss
|
|
209
|
+
getCss,
|
|
210
210
|
htmlTemplate,
|
|
211
211
|
executeServerFunction,
|
|
212
|
-
createSsrStream:
|
|
212
|
+
createSsrStream: createStream,
|
|
213
213
|
},
|
|
214
214
|
);
|
|
215
215
|
|
|
@@ -217,7 +217,7 @@ describe('render route SSR props', () => {
|
|
|
217
217
|
const { render } = createHandlerOptions();
|
|
218
218
|
return {
|
|
219
219
|
render,
|
|
220
|
-
|
|
220
|
+
getCss: () => '',
|
|
221
221
|
};
|
|
222
222
|
}
|
|
223
223
|
if (id === '/src/ToolPage.tsrx') {
|
|
@@ -277,7 +277,7 @@ describe('render route SSR props', () => {
|
|
|
277
277
|
const { render } = createHandlerOptions();
|
|
278
278
|
return {
|
|
279
279
|
render,
|
|
280
|
-
|
|
280
|
+
getCss: () => '',
|
|
281
281
|
};
|
|
282
282
|
}
|
|
283
283
|
if (id === '/src/ToolPage.tsrx') {
|
|
@@ -349,7 +349,7 @@ describe('render route SSR props', () => {
|
|
|
349
349
|
Component({ fromRender: true });
|
|
350
350
|
return { head: '', body: '<div>ok</div>', css: new Set() };
|
|
351
351
|
},
|
|
352
|
-
|
|
352
|
+
getCss: () => '',
|
|
353
353
|
};
|
|
354
354
|
}
|
|
355
355
|
if (id === '/src/ToolPage.tsrx') {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { describe, it, expect } from 'vitest';
|
|
1
|
+
import { describe, it, expect, vi } from 'vitest';
|
|
2
2
|
import { buildStreamTemplate, createStreamingResponse } from '../src/server/stream-response.js';
|
|
3
3
|
|
|
4
4
|
describe('buildStreamTemplate', () => {
|
|
@@ -70,6 +70,8 @@ describe('createStreamingResponse', () => {
|
|
|
70
70
|
});
|
|
71
71
|
|
|
72
72
|
it('propagates render failures to the sink', async () => {
|
|
73
|
+
// createStreamingResponse logs the failure — keep it out of test output
|
|
74
|
+
const error_log = vi.spyOn(console, 'error').mockImplementation(() => {});
|
|
73
75
|
/** @type {unknown} */
|
|
74
76
|
let errored = null;
|
|
75
77
|
const response = createStreamingResponse({
|
|
@@ -92,5 +94,10 @@ describe('createStreamingResponse', () => {
|
|
|
92
94
|
expect(response).toBeInstanceOf(Response);
|
|
93
95
|
await new Promise((resolve) => setTimeout(resolve, 0));
|
|
94
96
|
expect(errored).toBeInstanceOf(Error);
|
|
97
|
+
expect(error_log).toHaveBeenCalledWith(
|
|
98
|
+
'[ripple] SSR streaming error:',
|
|
99
|
+
expect.objectContaining({ message: 'render exploded' }),
|
|
100
|
+
);
|
|
101
|
+
error_log.mockRestore();
|
|
95
102
|
});
|
|
96
103
|
});
|
package/types/production.d.ts
CHANGED
|
@@ -90,7 +90,7 @@ export interface HandlerOptions {
|
|
|
90
90
|
getCss: (css: Set<string>) => string;
|
|
91
91
|
htmlTemplate: string;
|
|
92
92
|
executeServerFunction: (fn: Function, body: string) => Promise<string>;
|
|
93
|
-
/** `
|
|
93
|
+
/** `createStream` from 'ripple/server' — required when streaming is enabled */
|
|
94
94
|
createSsrStream?: () => {
|
|
95
95
|
stream: ReadableStream<Uint8Array>;
|
|
96
96
|
sink: StreamSink;
|