toiljs 0.0.61 → 0.0.63
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 +22 -0
- package/build/cli/.tsbuildinfo +1 -1
- package/build/client/.tsbuildinfo +1 -1
- package/build/client/index.d.ts +1 -1
- package/build/client/index.js +1 -1
- package/build/client/routing/hooks.d.ts +1 -0
- package/build/client/routing/hooks.js +7 -1
- package/build/client/routing/mount.js +0 -26
- package/build/client/ssr/markers.js +7 -3
- package/build/compiler/.tsbuildinfo +1 -1
- package/build/compiler/index.d.ts +4 -1
- package/build/compiler/index.js +46 -18
- package/build/compiler/template-build.d.ts +5 -4
- package/build/compiler/template-build.js +26 -9
- package/examples/basic/server/services/Stats.ts +2 -3
- package/examples/basic/server/services/remotes.ts +2 -2
- package/package.json +1 -1
- package/src/client/index.ts +1 -0
- package/src/client/routing/hooks.ts +16 -3
- package/src/client/routing/mount.tsx +8 -36
- package/src/client/ssr/markers.tsx +15 -5
- package/src/compiler/index.ts +104 -53
- package/src/compiler/template-build.ts +62 -14
- package/test/daemon-build.test.ts +31 -12
- package/test/ssr-hydration.test.tsx +122 -0
- package/test/ssr-render.test.ts +4 -2
- package/test/ssr-template.test.tsx +5 -1
- package/examples/basic/server/streams/Echo.ts +0 -49
|
@@ -356,8 +356,12 @@ describe('ssr build orchestration', () => {
|
|
|
356
356
|
|
|
357
357
|
const tmpl = art.tmpl.toString('utf8');
|
|
358
358
|
// Full document with the layout + page scaffold spliced into #root, holes removed.
|
|
359
|
+
// `<!--$-->` / `<!--/$-->` are the Suspense dehydration markers `assembleRouteElement`
|
|
360
|
+
// emits by wrapping each layout AND the route in `Suspense` (mirroring the client
|
|
361
|
+
// Router), so `hydrateRoot` can align its Suspense boundaries. The `<!-- -->` after `@`
|
|
362
|
+
// is React's text-boundary marker for the `username` hole; the hole text is stripped.
|
|
359
363
|
expect(tmpl).toContain(
|
|
360
|
-
'<div id="root"
|
|
364
|
+
'<div id="root"><!--$--><div class="app"><!--$--><main><h1>@<!-- --></h1><div></div><ul></ul></main><!--/$--></div><!--/$--></div>',
|
|
361
365
|
);
|
|
362
366
|
expect(tmpl).toContain('<template id="__toil_ssr"></template>');
|
|
363
367
|
expect(tmpl).toContain('/assets/app-abc123.js'); // bootstrap script preserved
|
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* A `@stream` protocol handler mounted at `/echo`, running as a RESIDENT wasm box
|
|
3
|
-
* per WebTransport connection on the Toil edge - distributed across the eligible
|
|
4
|
-
* L2/L3 nodes and pinned to ONE worker for the connection's lifetime via QUIC
|
|
5
|
-
* connection-id steering.
|
|
6
|
-
*
|
|
7
|
-
* The defining property of a `@stream` (vs a `@rest` handler): the box is
|
|
8
|
-
* RESIDENT, so instance state PERSISTS across events on the same connection. Here
|
|
9
|
-
* `count` survives every `@message` because the box is never reset between events
|
|
10
|
-
* - unlike a `@rest` handler, which is fresh per request. On the client:
|
|
11
|
-
*
|
|
12
|
-
* const stream = await Server.STREAM.echo.connect();
|
|
13
|
-
* stream.send(new TextEncoder().encode('hi'));
|
|
14
|
-
*
|
|
15
|
-
* Lifecycle hooks: `@connect` (open), `@message` (an inbound frame), `@close`
|
|
16
|
-
* (graceful close), `@disconnect` (abrupt transport loss).
|
|
17
|
-
*
|
|
18
|
-
* NOTE: reading the inbound frame and replying is the NEXT increment (the
|
|
19
|
-
* `StreamPacket` / `StreamOutbound` message bridge). The intended shape is:
|
|
20
|
-
*
|
|
21
|
-
* @message reply(packet: StreamPacket): StreamOutbound {
|
|
22
|
-
* return StreamOutbound.reply(packet.bytes()); // echo the bytes back
|
|
23
|
-
* }
|
|
24
|
-
*
|
|
25
|
-
* Until that lands, the hooks run on the connection lifecycle; this example counts
|
|
26
|
-
* frames to demonstrate that the resident box keeps state across them.
|
|
27
|
-
*/
|
|
28
|
-
@stream('echo')
|
|
29
|
-
class Echo {
|
|
30
|
-
// Resident per-connection state: survives across events (ResetMode::None).
|
|
31
|
-
private count: i32 = 0;
|
|
32
|
-
|
|
33
|
-
@connect
|
|
34
|
-
onConnect(): void {
|
|
35
|
-
// A fresh connection: its dedicated box starts the counter at 0.
|
|
36
|
-
this.count = 0;
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
@message
|
|
40
|
-
onMessage(): void {
|
|
41
|
-
// Persists across frames because the box is resident, not reset per event.
|
|
42
|
-
this.count = this.count + 1;
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
@close
|
|
46
|
-
onClose(): void {
|
|
47
|
-
// Graceful close: the per-connection box is torn down after this hook.
|
|
48
|
-
}
|
|
49
|
-
}
|