ripple 0.3.91 → 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 +32 -0
- package/package.json +1 -1
- package/src/constants.js +13 -0
- package/src/runtime/index-client.js +5 -1
- package/src/runtime/internal/client/hydration.js +4 -1
- package/src/runtime/internal/client/template.js +2 -1
- package/src/runtime/internal/client/try.js +199 -9
- package/src/runtime/internal/client/types.d.ts +25 -0
- package/src/runtime/internal/server/blocks.js +47 -9
- package/src/runtime/internal/server/css-registry.js +1 -1
- package/src/runtime/internal/server/index.js +546 -69
- package/src/runtime/internal/server/stream-runtime.js +173 -0
- package/src/server/index.js +2 -2
- package/src/utils/track-async-serialization.js +1 -1
- package/tests/hydration/compiled/client/streaming.js +448 -0
- package/tests/hydration/compiled/server/streaming.js +476 -0
- package/tests/hydration/components/streaming.tsrx +164 -0
- package/tests/hydration/streaming.test.js +342 -0
- package/tests/hydration/track-async-serialization.test.js +3 -3
- package/tests/hydration/try.test.js +4 -4
- package/tests/server/streaming-ssr.test.tsrx +714 -4
- package/tests/server/track-async-serialization.test.tsrx +9 -9
- package/types/server.d.ts +22 -1
|
@@ -17,7 +17,7 @@ describe('trackAsync serialization (server)', () => {
|
|
|
17
17
|
const { body } = await render(App);
|
|
18
18
|
expect(body).toContain('hello world');
|
|
19
19
|
// Should contain a serialization script tag
|
|
20
|
-
expect(body).toContain('
|
|
20
|
+
expect(body).toContain('__ripple_ta_');
|
|
21
21
|
expect(body).toContain('type="application/json"');
|
|
22
22
|
});
|
|
23
23
|
|
|
@@ -33,7 +33,7 @@ describe('trackAsync serialization (server)', () => {
|
|
|
33
33
|
|
|
34
34
|
const { body } = await render(App);
|
|
35
35
|
expect(body).toContain('42');
|
|
36
|
-
expect(body).toContain('
|
|
36
|
+
expect(body).toContain('__ripple_ta_');
|
|
37
37
|
});
|
|
38
38
|
|
|
39
39
|
it('serializes object trackAsync data correctly', async () => {
|
|
@@ -48,7 +48,7 @@ describe('trackAsync serialization (server)', () => {
|
|
|
48
48
|
|
|
49
49
|
const { body } = await render(App);
|
|
50
50
|
expect(body).toContain('Alice');
|
|
51
|
-
expect(body).toContain('
|
|
51
|
+
expect(body).toContain('__ripple_ta_');
|
|
52
52
|
});
|
|
53
53
|
|
|
54
54
|
it('serializes array trackAsync data correctly', async () => {
|
|
@@ -67,7 +67,7 @@ describe('trackAsync serialization (server)', () => {
|
|
|
67
67
|
|
|
68
68
|
const { body } = await render(App);
|
|
69
69
|
expect(body).toContain('<li>a</li>');
|
|
70
|
-
expect(body).toContain('
|
|
70
|
+
expect(body).toContain('__ripple_ta_');
|
|
71
71
|
});
|
|
72
72
|
|
|
73
73
|
it('serializes rejected trackAsync as error envelope', async () => {
|
|
@@ -85,7 +85,7 @@ describe('trackAsync serialization (server)', () => {
|
|
|
85
85
|
const { body } = await render(App);
|
|
86
86
|
const public_message = DEV ? 'fetch failed' : TRACK_ASYNC_PUBLIC_ERROR_MESSAGE;
|
|
87
87
|
expect(body).toContain(`<p class="error">${public_message}</p>`);
|
|
88
|
-
expect(body).toContain('
|
|
88
|
+
expect(body).toContain('__ripple_ta_');
|
|
89
89
|
expect(body).toContain('"ok":false');
|
|
90
90
|
expect(body).toContain(`"message":"${public_message}"`);
|
|
91
91
|
});
|
|
@@ -111,7 +111,7 @@ describe('trackAsync serialization (server)', () => {
|
|
|
111
111
|
const { body } = await render(Parent);
|
|
112
112
|
const public_message = DEV ? 'child error' : TRACK_ASYNC_PUBLIC_ERROR_MESSAGE;
|
|
113
113
|
expect(body).toContain(`<p class="parent-error">${public_message}</p>`);
|
|
114
|
-
expect(body).toContain('
|
|
114
|
+
expect(body).toContain('__ripple_ta_');
|
|
115
115
|
expect(body).toContain('"ok":false');
|
|
116
116
|
expect(body).toContain(`"message":"${public_message}"`);
|
|
117
117
|
});
|
|
@@ -133,7 +133,7 @@ describe('trackAsync serialization (server)', () => {
|
|
|
133
133
|
const { body } = await render(App);
|
|
134
134
|
const public_message = DEV ? 'sync failure' : TRACK_ASYNC_PUBLIC_ERROR_MESSAGE;
|
|
135
135
|
expect(body).toContain(`<p class="error">${public_message}</p>`);
|
|
136
|
-
expect(body).toContain('
|
|
136
|
+
expect(body).toContain('__ripple_ta_');
|
|
137
137
|
expect(body).toContain('"ok":false');
|
|
138
138
|
expect(body).toContain(`"message":"${public_message}"`);
|
|
139
139
|
expect(body).not.toContain('Error thrown during trackAsync execution');
|
|
@@ -154,7 +154,7 @@ describe('trackAsync serialization (server)', () => {
|
|
|
154
154
|
}
|
|
155
155
|
|
|
156
156
|
const { body } = await render(App);
|
|
157
|
-
expect(body).toContain('
|
|
157
|
+
expect(body).toContain('__ripple_ta_');
|
|
158
158
|
if (DEV) {
|
|
159
159
|
expect(body).toContain('\\u003c/script\\u003e');
|
|
160
160
|
expect(body).not.toContain(
|
|
@@ -179,7 +179,7 @@ describe('trackAsync serialization (server)', () => {
|
|
|
179
179
|
|
|
180
180
|
const { body } = await render(App);
|
|
181
181
|
// Find all script tag IDs
|
|
182
|
-
const matches = [...body.matchAll(/id="(
|
|
182
|
+
const matches = [...body.matchAll(/id="(__ripple_ta_[a-f0-9]+)"/g)];
|
|
183
183
|
expect(matches.length).toBe(2);
|
|
184
184
|
// Hashes should be different
|
|
185
185
|
expect(matches[0][1]).not.toBe(matches[1][1]);
|
package/types/server.d.ts
CHANGED
|
@@ -43,12 +43,27 @@ export interface Stream {
|
|
|
43
43
|
sink: StreamSink;
|
|
44
44
|
}
|
|
45
45
|
|
|
46
|
+
export interface StreamTemplate {
|
|
47
|
+
/** Document prefix, up to (and excluding) where SSR head content belongs. */
|
|
48
|
+
before: string;
|
|
49
|
+
/** From after the SSR head content to where the SSR body belongs. */
|
|
50
|
+
between: string;
|
|
51
|
+
/** Document suffix, pushed right before the stream closes. */
|
|
52
|
+
after: string;
|
|
53
|
+
}
|
|
54
|
+
|
|
46
55
|
export interface BaseRenderOptions {
|
|
47
56
|
stream?: StreamSink;
|
|
48
57
|
// defaults to true
|
|
49
58
|
// set to false to add more content
|
|
50
59
|
closeStream?: boolean;
|
|
51
60
|
rootBoundary?: RootBoundaryOptions;
|
|
61
|
+
/**
|
|
62
|
+
* Streaming only: document scaffold emitted around the shell — `before` +
|
|
63
|
+
* head content + `between` + body precede the streamed chunks, `after` is
|
|
64
|
+
* pushed when the stream closes.
|
|
65
|
+
*/
|
|
66
|
+
streamTemplate?: StreamTemplate;
|
|
52
67
|
}
|
|
53
68
|
|
|
54
69
|
export interface StreamingRenderOptions extends BaseRenderOptions {
|
|
@@ -59,7 +74,13 @@ export interface RenderOptions extends BaseRenderOptions {
|
|
|
59
74
|
stream?: undefined;
|
|
60
75
|
}
|
|
61
76
|
|
|
62
|
-
export declare function
|
|
77
|
+
export declare function createStream(): Stream;
|
|
78
|
+
|
|
79
|
+
/**
|
|
80
|
+
* Returns the CSS text for a set of scoped style hashes collected by
|
|
81
|
+
* `render()` — emit it in a `<style data-ripple-ssr>` tag.
|
|
82
|
+
*/
|
|
83
|
+
export declare function getCss(css: Set<string>): string;
|
|
63
84
|
|
|
64
85
|
export declare function render(
|
|
65
86
|
component: Component,
|