toiljs 0.0.115 → 0.0.117

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.
Files changed (326) hide show
  1. package/CHANGELOG.md +10 -0
  2. package/README.md +16 -7
  3. package/TYPESCRIPT_LAW.md +1946 -2073
  4. package/build/backend/.tsbuildinfo +1 -1
  5. package/build/cli/.tsbuildinfo +1 -1
  6. package/build/cli/index.js +2375 -258
  7. package/build/client/.tsbuildinfo +1 -1
  8. package/build/client/dev/devtools.js +1 -1
  9. package/build/client/dev/error-overlay.js +1 -1
  10. package/build/client/routing/mount.js +1 -1
  11. package/build/compiler/.tsbuildinfo +1 -1
  12. package/build/compiler/auth-emails.js +7 -3
  13. package/build/compiler/emails.js +1 -1
  14. package/build/compiler/index.d.ts +1 -0
  15. package/build/compiler/index.js +25 -4
  16. package/build/compiler/pages.js +2 -3
  17. package/build/compiler/prerender.d.ts +3 -8
  18. package/build/compiler/prerender.js +88 -127
  19. package/build/compiler/ssg.js +3 -4
  20. package/build/compiler/template-build.js +3 -4
  21. package/build/compiler/toil-docs.generated.js +6 -5
  22. package/build/compiler/vite.js +3 -6
  23. package/build/devserver/.tsbuildinfo +1 -1
  24. package/build/devserver/db/database.js +7 -3
  25. package/build/devserver/db/types.js +1 -1
  26. package/build/devserver/production.js +4 -3
  27. package/build/devserver/runtime/crypto.d.ts +1 -1
  28. package/build/io/.tsbuildinfo +1 -1
  29. package/build/logger/.tsbuildinfo +1 -1
  30. package/build/shared/.tsbuildinfo +1 -1
  31. package/examples/basic/client/routes/analytics.tsx +7 -5
  32. package/examples/basic/server/tsconfig.json +1 -3
  33. package/package.json +45 -44
  34. package/presets/no-uint8array-tostring.js +120 -153
  35. package/presets/oxlint.d.ts +5 -0
  36. package/presets/oxlint.js +224 -0
  37. package/server/runtime/tsconfig.json +1 -3
  38. package/tsconfig.json +2 -11
  39. package/.github/ISSUE_TEMPLATE/bug_report.md +0 -38
  40. package/.github/ISSUE_TEMPLATE/bug_report.yml +0 -90
  41. package/.github/ISSUE_TEMPLATE/config.yml +0 -8
  42. package/.github/ISSUE_TEMPLATE/feature_request.md +0 -20
  43. package/.github/PULL_REQUEST_TEMPLATE.md +0 -43
  44. package/.github/changelog-config.json +0 -45
  45. package/.github/dependabot.yml +0 -27
  46. package/.github/workflows/ci.yml +0 -222
  47. package/.vscode/settings.json +0 -10
  48. package/docs/README.md +0 -107
  49. package/docs/auth/README.md +0 -104
  50. package/docs/auth/configuration.md +0 -105
  51. package/docs/auth/emails.md +0 -92
  52. package/docs/auth/extending.md +0 -202
  53. package/docs/auth/how-it-works.md +0 -138
  54. package/docs/auth/usage.md +0 -188
  55. package/docs/backend/README.md +0 -143
  56. package/docs/backend/data.md +0 -351
  57. package/docs/backend/rest.md +0 -402
  58. package/docs/backend/rpc.md +0 -226
  59. package/docs/background/README.md +0 -114
  60. package/docs/background/daemons.md +0 -276
  61. package/docs/background/derive.md +0 -179
  62. package/docs/cli/README.md +0 -379
  63. package/docs/concepts/ai-guide.md +0 -132
  64. package/docs/concepts/config.md +0 -416
  65. package/docs/concepts/decorators.md +0 -127
  66. package/docs/concepts/security.md +0 -108
  67. package/docs/concepts/tiers.md +0 -166
  68. package/docs/concepts/types.md +0 -216
  69. package/docs/database/README.md +0 -143
  70. package/docs/database/capacity.md +0 -350
  71. package/docs/database/counters.md +0 -174
  72. package/docs/database/documents.md +0 -277
  73. package/docs/database/events.md +0 -307
  74. package/docs/database/membership.md +0 -246
  75. package/docs/database/setup.md +0 -155
  76. package/docs/database/unique.md +0 -216
  77. package/docs/database/views.md +0 -246
  78. package/docs/frontend/README.md +0 -104
  79. package/docs/frontend/components.md +0 -286
  80. package/docs/frontend/data-fetching.md +0 -260
  81. package/docs/frontend/images.md +0 -148
  82. package/docs/frontend/metadata.md +0 -344
  83. package/docs/frontend/navigation.md +0 -296
  84. package/docs/frontend/rendering.md +0 -236
  85. package/docs/frontend/routing.md +0 -346
  86. package/docs/frontend/scripts.md +0 -118
  87. package/docs/frontend/search.md +0 -191
  88. package/docs/frontend/styling.md +0 -147
  89. package/docs/frontend/toil-global.md +0 -216
  90. package/docs/getting-started/README.md +0 -81
  91. package/docs/getting-started/create-project.md +0 -131
  92. package/docs/getting-started/deploy.md +0 -101
  93. package/docs/getting-started/first-app.md +0 -215
  94. package/docs/getting-started/installation.md +0 -124
  95. package/docs/getting-started/migrating.md +0 -125
  96. package/docs/getting-started/project-structure.md +0 -163
  97. package/docs/introduction/README.md +0 -66
  98. package/docs/introduction/design-principles.md +0 -81
  99. package/docs/introduction/distributed.md +0 -91
  100. package/docs/introduction/how-it-works.md +0 -121
  101. package/docs/introduction/hyperscale.md +0 -70
  102. package/docs/introduction/modern-stack.md +0 -85
  103. package/docs/introduction/vs-other-frameworks.md +0 -64
  104. package/docs/introduction/why-toil.md +0 -99
  105. package/docs/llms.txt +0 -95
  106. package/docs/realtime/README.md +0 -102
  107. package/docs/realtime/channels.md +0 -211
  108. package/docs/realtime/streams.md +0 -369
  109. package/docs/services/README.md +0 -60
  110. package/docs/services/analytics.md +0 -279
  111. package/docs/services/caching.md +0 -175
  112. package/docs/services/cookies.md +0 -235
  113. package/docs/services/crypto.md +0 -209
  114. package/docs/services/email.md +0 -289
  115. package/docs/services/environment.md +0 -141
  116. package/docs/services/ratelimit.md +0 -174
  117. package/docs/services/time.md +0 -85
  118. package/eslint.config.js +0 -57
  119. package/examples/basic/client/routes/docs/[...slug].tsx +0 -12
  120. package/presets/eslint.js +0 -88
  121. package/src/backend/index.ts +0 -204
  122. package/src/cli/configure.ts +0 -363
  123. package/src/cli/create.ts +0 -924
  124. package/src/cli/db.ts +0 -158
  125. package/src/cli/diagnostics.ts +0 -665
  126. package/src/cli/doctor.ts +0 -982
  127. package/src/cli/features.ts +0 -170
  128. package/src/cli/index.ts +0 -326
  129. package/src/cli/notify.ts +0 -120
  130. package/src/cli/proc.ts +0 -56
  131. package/src/cli/ui.ts +0 -169
  132. package/src/cli/update.ts +0 -248
  133. package/src/cli/updates.ts +0 -92
  134. package/src/cli/validate.ts +0 -31
  135. package/src/cli/version-check.ts +0 -125
  136. package/src/client/auth.ts +0 -869
  137. package/src/client/channel/channel.ts +0 -146
  138. package/src/client/components/Form.tsx +0 -65
  139. package/src/client/components/Image.tsx +0 -160
  140. package/src/client/components/Script.tsx +0 -113
  141. package/src/client/components/Slot.tsx +0 -21
  142. package/src/client/dev/devtools.tsx +0 -1089
  143. package/src/client/dev/error-overlay.tsx +0 -225
  144. package/src/client/errors.ts +0 -11
  145. package/src/client/head/head.ts +0 -182
  146. package/src/client/head/metadata.ts +0 -110
  147. package/src/client/index.ts +0 -130
  148. package/src/client/navigation/Link.tsx +0 -108
  149. package/src/client/navigation/NavLink.tsx +0 -86
  150. package/src/client/navigation/navigation.ts +0 -235
  151. package/src/client/navigation/prefetch.ts +0 -169
  152. package/src/client/navigation/scroll.ts +0 -53
  153. package/src/client/routing/Router.tsx +0 -216
  154. package/src/client/routing/action.ts +0 -122
  155. package/src/client/routing/error-boundary.tsx +0 -43
  156. package/src/client/routing/hooks.ts +0 -140
  157. package/src/client/routing/lazy.ts +0 -77
  158. package/src/client/routing/loader.ts +0 -381
  159. package/src/client/routing/match.ts +0 -47
  160. package/src/client/routing/mount.tsx +0 -90
  161. package/src/client/routing/params-context.ts +0 -10
  162. package/src/client/routing/slot-context.ts +0 -7
  163. package/src/client/rpc.ts +0 -97
  164. package/src/client/search/search.ts +0 -189
  165. package/src/client/search/use-page-search.ts +0 -73
  166. package/src/client/ssr/markers.tsx +0 -172
  167. package/src/client/stream/client.ts +0 -237
  168. package/src/client/types.ts +0 -73
  169. package/src/compiler/auth-emails.ts +0 -312
  170. package/src/compiler/config.ts +0 -369
  171. package/src/compiler/docs.ts +0 -127
  172. package/src/compiler/email-preview.ts +0 -314
  173. package/src/compiler/emails.ts +0 -404
  174. package/src/compiler/fonts.ts +0 -89
  175. package/src/compiler/generate.ts +0 -471
  176. package/src/compiler/image-blur.ts +0 -42
  177. package/src/compiler/image-report.ts +0 -88
  178. package/src/compiler/index.ts +0 -1362
  179. package/src/compiler/pages.ts +0 -49
  180. package/src/compiler/plugin.ts +0 -391
  181. package/src/compiler/prerender.ts +0 -263
  182. package/src/compiler/routes.ts +0 -170
  183. package/src/compiler/seo.ts +0 -415
  184. package/src/compiler/sri.ts +0 -144
  185. package/src/compiler/ssg.ts +0 -177
  186. package/src/compiler/ssr-codegen.ts +0 -85
  187. package/src/compiler/template-build.ts +0 -676
  188. package/src/compiler/template.ts +0 -262
  189. package/src/compiler/toil-docs.generated.ts +0 -77
  190. package/src/compiler/vite.ts +0 -245
  191. package/src/devserver/analytics/index.ts +0 -317
  192. package/src/devserver/config/dotenv.ts +0 -102
  193. package/src/devserver/config/env.ts +0 -30
  194. package/src/devserver/config/ratelimit.ts +0 -123
  195. package/src/devserver/daemon/catalog.ts +0 -120
  196. package/src/devserver/daemon/cron.ts +0 -87
  197. package/src/devserver/daemon/host.ts +0 -134
  198. package/src/devserver/daemon/index.ts +0 -369
  199. package/src/devserver/daemon/runtime.ts +0 -48
  200. package/src/devserver/db/catalog.ts +0 -109
  201. package/src/devserver/db/database.ts +0 -1834
  202. package/src/devserver/db/derives.ts +0 -121
  203. package/src/devserver/db/index.ts +0 -20
  204. package/src/devserver/db/routeKinds.ts +0 -191
  205. package/src/devserver/db/types.ts +0 -168
  206. package/src/devserver/email/caps.ts +0 -0
  207. package/src/devserver/email/config.ts +0 -141
  208. package/src/devserver/email/console.ts +0 -348
  209. package/src/devserver/email/index.ts +0 -155
  210. package/src/devserver/email/providers.ts +0 -131
  211. package/src/devserver/email/status.ts +0 -23
  212. package/src/devserver/email/validate.ts +0 -37
  213. package/src/devserver/email/wire.ts +0 -55
  214. package/src/devserver/http/cache.ts +0 -0
  215. package/src/devserver/http/envelope.ts +0 -157
  216. package/src/devserver/http/proxy.ts +0 -172
  217. package/src/devserver/http/runtime.ts +0 -387
  218. package/src/devserver/index.ts +0 -43
  219. package/src/devserver/production-ipc.ts +0 -63
  220. package/src/devserver/production-worker.ts +0 -83
  221. package/src/devserver/production.ts +0 -718
  222. package/src/devserver/runtime/crypto.ts +0 -587
  223. package/src/devserver/runtime/host.ts +0 -427
  224. package/src/devserver/runtime/module.ts +0 -442
  225. package/src/devserver/server.ts +0 -251
  226. package/src/devserver/ssr.ts +0 -208
  227. package/src/devserver/stream/catalog.ts +0 -106
  228. package/src/devserver/stream/host.ts +0 -42
  229. package/src/devserver/stream/index.ts +0 -301
  230. package/src/devserver/stream/manager.ts +0 -167
  231. package/src/devserver/stream/router.ts +0 -101
  232. package/src/devserver/stream/wire.ts +0 -58
  233. package/src/devserver/stream/ws.ts +0 -78
  234. package/src/devserver/wasm/sections.ts +0 -59
  235. package/src/devserver/wasm/surface.ts +0 -115
  236. package/src/io/FastMap.ts +0 -151
  237. package/src/io/FastSet.ts +0 -113
  238. package/src/io/codec.ts +0 -362
  239. package/src/io/index.ts +0 -10
  240. package/src/io/lengths.ts +0 -14
  241. package/src/io/types.ts +0 -19
  242. package/src/logger/index.ts +0 -22
  243. package/src/shared/index.ts +0 -46
  244. package/test/analytics-dev.test.ts +0 -113
  245. package/test/assembly/aspect-shim.ts +0 -33
  246. package/test/assembly/cookie.spec.ts +0 -303
  247. package/test/assembly/example.spec.ts +0 -22
  248. package/test/assembly/ssr.spec.ts +0 -95
  249. package/test/assembly.test.ts +0 -59
  250. package/test/auth-emails.test.ts +0 -118
  251. package/test/built-ssr.test.ts +0 -148
  252. package/test/channel.test.ts +0 -21
  253. package/test/config-host-port.test.ts +0 -59
  254. package/test/configure.test.ts +0 -94
  255. package/test/daemon-build.test.ts +0 -278
  256. package/test/daemon-catalog.test.ts +0 -349
  257. package/test/daemon-emulation.test.ts +0 -256
  258. package/test/db.test.ts +0 -0
  259. package/test/devserver-database.test.ts +0 -1102
  260. package/test/devserver-email.test.ts +0 -306
  261. package/test/devserver-pqauth.test.ts +0 -93
  262. package/test/devserver-secrets.test.ts +0 -63
  263. package/test/devserver.test.ts +0 -259
  264. package/test/doctor.test.ts +0 -298
  265. package/test/dom/Image.test.tsx +0 -144
  266. package/test/dom/Link.test.tsx +0 -67
  267. package/test/dom/NavLink.test.tsx +0 -37
  268. package/test/dom/Script.test.tsx +0 -48
  269. package/test/dom/action.test.tsx +0 -146
  270. package/test/dom/error-overlay.test.tsx +0 -44
  271. package/test/dom/loader.test.tsx +0 -121
  272. package/test/dom/navigation.test.ts +0 -59
  273. package/test/dom/revalidate.test.tsx +0 -38
  274. package/test/dom/route-head.test.tsx +0 -56
  275. package/test/dom/router-loading.test.tsx +0 -44
  276. package/test/dom/scroll.test.ts +0 -56
  277. package/test/dom/slot.test.tsx +0 -131
  278. package/test/dom/use-metadata.test.tsx +0 -58
  279. package/test/dom/view-transitions.test.tsx +0 -53
  280. package/test/dynamic-routing.test.ts +0 -132
  281. package/test/email-console.test.ts +0 -86
  282. package/test/email-preview.test.ts +0 -73
  283. package/test/emails.test.ts +0 -58
  284. package/test/errors.test.ts +0 -21
  285. package/test/example-guestbook.test.ts +0 -123
  286. package/test/features.test.ts +0 -149
  287. package/test/fixtures/bignum-wire/spec.ts +0 -25
  288. package/test/fixtures/daemon-app.ts +0 -65
  289. package/test/fixtures/stream-echo.ts +0 -26
  290. package/test/fixtures/stream-gate.ts +0 -28
  291. package/test/fixtures/stream-trap.ts +0 -18
  292. package/test/fixtures/stream-typed.ts +0 -41
  293. package/test/fonts.test.ts +0 -28
  294. package/test/global-setup.ts +0 -17
  295. package/test/head.test.ts +0 -42
  296. package/test/image-blur.test.ts +0 -50
  297. package/test/io.test.ts +0 -117
  298. package/test/metadata.test.ts +0 -40
  299. package/test/navlink.test.ts +0 -28
  300. package/test/pages.test.ts +0 -105
  301. package/test/placeholder.test.ts +0 -9
  302. package/test/pqauth-e2e.test.ts +0 -216
  303. package/test/pqauth-email.test.ts +0 -801
  304. package/test/prerender.test.ts +0 -116
  305. package/test/prettier-plugin.test.ts +0 -46
  306. package/test/routes.test.ts +0 -76
  307. package/test/rpc-bignum-wire.test.ts +0 -164
  308. package/test/rpc-dispatch.test.ts +0 -132
  309. package/test/rpc-kinds.test.ts +0 -18
  310. package/test/rpc.test.ts +0 -66
  311. package/test/search.test.ts +0 -114
  312. package/test/seo.test.ts +0 -175
  313. package/test/slot-layouts.test.ts +0 -69
  314. package/test/sri.test.ts +0 -129
  315. package/test/ssg.test.ts +0 -36
  316. package/test/ssr-hydration.test.tsx +0 -122
  317. package/test/ssr-render.test.ts +0 -197
  318. package/test/ssr-template.test.tsx +0 -482
  319. package/test/stream-emulation.test.ts +0 -479
  320. package/test/ui.test.ts +0 -40
  321. package/test/update.test.ts +0 -58
  322. package/test/validate.test.ts +0 -42
  323. package/test/version-check.test.ts +0 -130
  324. package/tests/data-parity/generated-parity.ts +0 -99
  325. package/tests/data-parity/parity.ts +0 -80
  326. package/tests/data-parity/spec.ts +0 -46
@@ -1,197 +0,0 @@
1
- /**
2
- * End-to-end guest render: drive the real ToilScript-compiled `render` export
3
- * of the basic example's server wasm, decode its values envelope, and confirm
4
- * the guest produces exactly the bytes the Rust host's `decode_values`/`assemble`
5
- * expects (the same wire format proven on the host side in
6
- * `toil-backend/src/host/template/assemble.rs`). Closing the loop with the
7
- * golden byte-identity test (`ssr-template.test.tsx`), this proves the full
8
- * chain: guest values -> splice -> React-identical HTML.
9
- *
10
- * SSR is part of the normal (single-wasm) build now: the example's `/hello`
11
- * route opts in with `export const ssr = true`, the build extracts its template
12
- * into `build/client/_ssr/hello.{tmpl,slots,slots.ts}`, and the server
13
- * `render` (`examples/basic/server/SsrHelloRender.ts`) fills the holes. We drive
14
- * the same `build/server/release.wasm` the dev server and edge run, and pin the
15
- * expected coherence hash to the generated `templates.json` so the guest and the
16
- * deployed template are proven to agree.
17
- */
18
- import fs from 'node:fs';
19
- import path from 'node:path';
20
- import { fileURLToPath } from 'node:url';
21
-
22
- import { describe, expect, it } from 'vitest';
23
-
24
- import { WasmServerModule } from '../src/devserver/index.js';
25
- import { spliceTemplate } from '../src/compiler/template.js';
26
-
27
- const EXAMPLE = path.resolve(
28
- path.dirname(fileURLToPath(import.meta.url)),
29
- '../examples/basic',
30
- );
31
- /** Single-wasm SSR: the server `render` lives in the normal server wasm. */
32
- const SERVER_WASM = path.join(EXAMPLE, 'build/server/release.wasm');
33
- const SSR_DIR = path.join(EXAMPLE, 'build/client/_ssr');
34
- const TEMPLATES = path.join(SSR_DIR, 'templates.json');
35
-
36
- interface DecodedSlot {
37
- slotId: number;
38
- kind: number;
39
- value: Buffer;
40
- }
41
- interface DecodedValues {
42
- status: number;
43
- hash: Buffer;
44
- headers: [string, string][];
45
- slots: DecodedSlot[];
46
- }
47
-
48
- /** Mirror of the host `decode_values`: parse the guest values envelope. */
49
- function decodeValues(buf: Uint8Array): DecodedValues {
50
- const b = Buffer.from(buf);
51
- let o = 0;
52
- const status = b.readUInt16LE(o);
53
- o += 2;
54
- const hash = b.subarray(o, o + 32);
55
- o += 32;
56
- const nHeaders = b.readUInt16LE(o);
57
- o += 2;
58
- const headers: [string, string][] = [];
59
- for (let i = 0; i < nHeaders; i++) {
60
- const nameLen = b.readUInt16LE(o);
61
- o += 2;
62
- const valLen = b.readUInt16LE(o);
63
- o += 2;
64
- const name = b.toString('utf8', o, o + nameLen);
65
- o += nameLen;
66
- const val = b.toString('utf8', o, o + valLen);
67
- o += valLen;
68
- headers.push([name, val]);
69
- }
70
- const nSlots = b.readUInt16LE(o);
71
- o += 2;
72
- const slots: DecodedSlot[] = [];
73
- for (let i = 0; i < nSlots; i++) {
74
- const slotId = b.readUInt16LE(o);
75
- o += 2;
76
- const kind = b.readUInt8(o);
77
- o += 1;
78
- const valueLen = b.readUInt32LE(o);
79
- o += 4;
80
- slots.push({ slotId, kind, value: b.subarray(o, o + valueLen) });
81
- o += valueLen;
82
- }
83
- expect(o).toBe(b.length); // no trailing garbage
84
- return { status, hash, headers, slots };
85
- }
86
-
87
- /** The hash the build pinned for the `/hello` template (deploy-skew guard). */
88
- function helloTemplateHash(): Buffer {
89
- const index = JSON.parse(fs.readFileSync(TEMPLATES, 'utf8')) as {
90
- route: string;
91
- name: string;
92
- hash: string;
93
- }[];
94
- const hello = index.find((t) => t.route === '/hello');
95
- if (!hello) throw new Error('no /hello template in templates.json');
96
- return Buffer.from(hello.hash, 'hex');
97
- }
98
-
99
- // Skip cleanly when the example has not been built (no toolchain in CI): the
100
- // build is what produces both the wasm and the template artifacts.
101
- const built = fs.existsSync(SERVER_WASM) && fs.existsSync(TEMPLATES);
102
-
103
- describe.skipIf(!built)('edge SSR guest render (real single-wasm build)', () => {
104
- const load = (): WasmServerModule => {
105
- const m = new WasmServerModule(SERVER_WASM);
106
- m.refresh();
107
- return m;
108
- };
109
- const render = (m: WasmServerModule, p: string): Uint8Array =>
110
- m.dispatchRender({
111
- method: 'GET',
112
- path: p,
113
- headers: [['host', 'localhost']],
114
- body: new Uint8Array(0),
115
- });
116
-
117
- it('produces a values envelope with the deployed template hash and escaped holes', () => {
118
- const d = decodeValues(render(load(), '/hello'));
119
- expect(d.status).toBe(200);
120
- // The guest's compiled-in HASH must equal the deployed template's hash,
121
- // or the host rejects the response as a deploy skew.
122
- expect(d.hash.equals(helloTemplateHash())).toBe(true);
123
-
124
- // Top-level slots in document order: name (text), blurb (raw), services (repeat).
125
- expect(d.slots.map((s) => `${s.slotId}:${s.kind}`)).toEqual([
126
- '0:0', // name, text
127
- '1:1', // blurb, raw
128
- '2:3', // services, repeat
129
- ]);
130
- // Text hole: the default greeting target.
131
- expect(d.slots[0].value.toString('utf8')).toBe('world');
132
- // Raw hole: inserted verbatim (NOT escaped).
133
- expect(d.slots[1].value.toString('utf8')).toBe(
134
- 'Rendered at the <strong>edge</strong> from a tiny values envelope.',
135
- );
136
- // Repeat hole: three stamped rows, each nested hole React-escaped.
137
- expect(d.slots[2].value.toString('utf8')).toBe(
138
- '<li><strong>record</strong><span class="hello-region">us-east</span></li>' +
139
- '<li><strong>unique</strong><span class="hello-region">eu-west</span></li>' +
140
- '<li><strong>counter</strong><span class="hello-region">ap-south</span></li>',
141
- );
142
- });
143
-
144
- it('escapes a text hole derived from the request (?name=)', () => {
145
- const d = decodeValues(render(load(), '/hello?name=A<b>%26"x'));
146
- expect(d.status).toBe(200);
147
- // setText React-escapes: & -> &amp;, <> -> entities, " -> &quot;.
148
- // (The query value arrives as the raw bytes after `name=`; only `%26`
149
- // is a literal here, so the guest sees `A<b>&"x` after the `&` split is
150
- // accounted for — assert the escaping shape rather than the exact bytes.)
151
- const v = d.slots[0].value.toString('utf8');
152
- expect(v).not.toContain('<b>');
153
- expect(v).toContain('&lt;');
154
- });
155
-
156
- it('splices into the real built template exactly (guest -> host -> HTML)', () => {
157
- const d = decodeValues(render(load(), '/hello'));
158
- const tmpl = fs.readFileSync(path.join(SSR_DIR, 'hello.tmpl'));
159
- const slotsBin = fs.readFileSync(path.join(SSR_DIR, 'hello.slots'));
160
-
161
- // Read the top-level slot offsets straight from the .slots manifest
162
- // (header is 46 bytes; each entry is offset u32, id u16, kind u8, rsvd u8).
163
- const nSlots = slotsBin.readUInt16LE(44);
164
- const byId = new Map(d.slots.map((s) => [s.slotId, s.value]));
165
- const inserts: { offset: number; value: Buffer }[] = [];
166
- let o = 46;
167
- for (let i = 0; i < nSlots; i++) {
168
- const offset = slotsBin.readUInt32LE(o);
169
- const id = slotsBin.readUInt16LE(o + 4);
170
- inserts.push({ offset, value: Buffer.from(byId.get(id)!) });
171
- o += 8;
172
- }
173
- const out = spliceTemplate(tmpl, inserts).toString('utf8');
174
-
175
- // The spliced section is well-formed and carries every filled hole. The
176
- // `<!-- -->` around `world` are React's text-boundary markers (renderToString
177
- // emits them so hydrateRoot can align the `name` hole between "Hello, " and "!").
178
- expect(out).toContain(
179
- '<section class="hello"><h1>Hello, <!-- -->world<!-- -->!</h1>' +
180
- '<p class="hello-blurb"><span>Rendered at the <strong>edge</strong> ' +
181
- 'from a tiny values envelope.</span></p>' +
182
- '<h2>Service snapshot</h2>' +
183
- '<ul class="hello-services">' +
184
- '<li><strong>record</strong><span class="hello-region">us-east</span></li>' +
185
- '<li><strong>unique</strong><span class="hello-region">eu-west</span></li>' +
186
- '<li><strong>counter</strong><span class="hello-region">ap-south</span></li>' +
187
- '</ul></section>',
188
- );
189
- });
190
-
191
- it('fails safe (status 500, zero hash, no slots) for an unmatched path', () => {
192
- const d = decodeValues(render(load(), '/not-an-ssr-route'));
193
- expect(d.status).toBe(500);
194
- expect([...d.hash]).toEqual(Array(32).fill(0));
195
- expect(d.slots).toHaveLength(0);
196
- });
197
- });
@@ -1,482 +0,0 @@
1
- /**
2
- * The load-bearing test for edge SSR: prove that the build's
3
- * template-with-holes + a guest-style stamp reproduces, BYTE FOR BYTE, what
4
- * React renders for the same data. If this holds, the browser's `hydrateRoot`
5
- * sees identical markup and hydration is clean.
6
- *
7
- * Strategy:
8
- * 1. Render the component with markers in SENTINEL mode (build) -> strip ->
9
- * `.tmpl` + slot records.
10
- * 2. Render the SAME component with REAL data normally -> `expected`.
11
- * 3. Simulate the guest: stamp each hole's value (React-escaped text, raw
12
- * verbatim, repeat = stamp the captured row template per real item) and
13
- * splice into the `.tmpl`.
14
- * 4. assert stamped === expected.
15
- */
16
- import fs from 'node:fs';
17
- import os from 'node:os';
18
- import path from 'node:path';
19
-
20
- import { renderToStaticMarkup } from 'react-dom/server';
21
- import { describe, expect, it } from 'vitest';
22
-
23
- import { Hole, Island, RawHtml, Repeat, attr, __setSsrBuild } from '../src/client/ssr/markers';
24
- import { LoaderDataContext, useLoaderData } from '../src/client/routing/loader';
25
- import {
26
- extractRouteTemplate,
27
- injectIntoShell,
28
- routeTemplateName,
29
- writeTemplateArtifacts,
30
- } from '../src/compiler/template-build';
31
- import {
32
- assignSlotIds,
33
- coherenceHash,
34
- encodeSlots,
35
- extractFromHtml,
36
- kindByte,
37
- reactEscapeHtml,
38
- spliceTemplate,
39
- type SlotRecord,
40
- } from '../src/compiler/template';
41
- import { generateSlotsModule } from '../src/compiler/ssr-codegen';
42
-
43
- interface Post {
44
- title: string;
45
- }
46
- interface ProfileData {
47
- username: string;
48
- bioHtml: string;
49
- posts: Post[];
50
- }
51
-
52
- function Profile({ d }: { d: ProfileData }): React.ReactElement {
53
- return (
54
- <main>
55
- <h1>
56
- @<Hole id="username">{d.username}</Hole>
57
- </h1>
58
- <RawHtml id="bio" html={d.bioHtml} />
59
- <ul>
60
- <Repeat id="posts" each={d.posts}>
61
- {(p: Post) => (
62
- <li>
63
- <Hole id="title">{p.title}</Hole>
64
- </li>
65
- )}
66
- </Repeat>
67
- </ul>
68
- </main>
69
- );
70
- }
71
-
72
- /** Render under the build sentinel pass (always restores the flag). */
73
- function renderBuild(el: React.ReactElement): string {
74
- __setSsrBuild(true);
75
- try {
76
- return renderToStaticMarkup(el);
77
- } finally {
78
- __setSsrBuild(false);
79
- }
80
- }
81
-
82
- /** Simulate the guest: produce the bytes for one top-level slot from real data. */
83
- function stampSlot(slot: SlotRecord, d: ProfileData): Buffer {
84
- if (slot.kind === 'text' && slot.id === 'username') {
85
- return Buffer.from(reactEscapeHtml(d.username), 'utf8');
86
- }
87
- if (slot.kind === 'raw' && slot.id === 'bio') {
88
- return Buffer.from(d.bioHtml, 'utf8');
89
- }
90
- if (slot.kind === 'repeat' && slot.id === 'posts') {
91
- const rowTmpl = slot.rowTemplate!;
92
- const rows: Buffer[] = d.posts.map((p) =>
93
- spliceTemplate(
94
- rowTmpl,
95
- slot.rowSlots!.map((rs) => ({
96
- offset: rs.offset,
97
- value: Buffer.from(reactEscapeHtml(p.title), 'utf8'),
98
- })),
99
- ),
100
- );
101
- return Buffer.concat(rows);
102
- }
103
- throw new Error(`unexpected slot ${slot.id}/${slot.kind}`);
104
- }
105
-
106
- function assemble(tmpl: Buffer, slots: SlotRecord[], d: ProfileData): Buffer {
107
- return spliceTemplate(
108
- tmpl,
109
- slots.map((s) => ({ offset: s.offset, value: stampSlot(s, d) })),
110
- );
111
- }
112
-
113
- describe('ssr template extraction', () => {
114
- it('strips sentinels and records hole offsets', () => {
115
- const sample: ProfileData = {
116
- username: 'ada',
117
- bioHtml: '<em>hi</em>',
118
- posts: [{ title: 'first' }],
119
- };
120
- const { tmpl, slots } = extractFromHtml(renderBuild(<Profile d={sample} />));
121
-
122
- // Static scaffold = React's own output, holes removed. The <div> from
123
- // RawHtml's wrapper is present and empty; the <ul> is empty.
124
- expect(tmpl.toString('utf8')).toBe('<main><h1>@</h1><div></div><ul></ul></main>');
125
-
126
- expect(slots.map((s) => `${s.id}:${s.kind}`)).toEqual([
127
- 'username:text',
128
- 'bio:raw',
129
- 'posts:repeat',
130
- ]);
131
- // Offsets are ascending and land at the right spots.
132
- const t = tmpl.toString('utf8');
133
- expect(t.slice(0, slots[0].offset)).toBe('<main><h1>@');
134
- expect(slots[1].offset).toBe(t.indexOf('<div>') + '<div>'.length);
135
- expect(slots[2].offset).toBe(t.indexOf('<ul>') + '<ul>'.length);
136
-
137
- // Repeat captured the single-row sub-template + its nested hole.
138
- const posts = slots[2];
139
- expect(posts.rowTemplate!.toString('utf8')).toBe('<li></li>');
140
- expect(posts.rowSlots!.map((r) => `${r.id}:${r.kind}`)).toEqual(['title:text']);
141
- expect(posts.rowSlots![0].offset).toBe('<li>'.length);
142
- });
143
-
144
- it('collapses Island to nothing server-side', () => {
145
- const html = renderBuild(
146
- <div>
147
- <Island>
148
- <span>client only</span>
149
- </Island>
150
- </div>,
151
- );
152
- expect(extractFromHtml(html).tmpl.toString('utf8')).toBe('<div></div>');
153
- });
154
- });
155
-
156
- describe('ssr GOLDEN byte-identity (template+stamp === React render)', () => {
157
- const sample: ProfileData = {
158
- username: 'ada',
159
- bioHtml: '<em>sample</em>',
160
- posts: [{ title: 'sample' }],
161
- };
162
-
163
- function check(real: ProfileData): void {
164
- const { tmpl, slots } = extractFromHtml(renderBuild(<Profile d={sample} />));
165
- const stamped = assemble(tmpl, slots, real);
166
- const expected = renderToStaticMarkup(<Profile d={real} />);
167
- expect(stamped.toString('utf8')).toBe(expected);
168
- }
169
-
170
- it('matches for plain data', () => {
171
- check({
172
- username: 'grace',
173
- bioHtml: '<strong>Rear Admiral</strong>',
174
- posts: [{ title: 'COBOL' }, { title: 'the bug' }, { title: 'compilers' }],
175
- });
176
- });
177
-
178
- it('matches when values need React escaping (the &#x27; / &quot; cases)', () => {
179
- check({
180
- username: `A<b>&"'x`,
181
- bioHtml: '<em>raw & <kept></em>', // raw: NOT escaped, verbatim
182
- posts: [{ title: 'a & b' }, { title: '<script>' }, { title: `it's "ok"` }],
183
- });
184
- });
185
-
186
- it('matches for an empty list (zero rows)', () => {
187
- check({ username: 'zero', bioHtml: '<i/>', posts: [] });
188
- });
189
-
190
- it('matches for a single row', () => {
191
- check({ username: 'one', bioHtml: 'x', posts: [{ title: 'only' }] });
192
- });
193
- });
194
-
195
- describe('ssr .slots binary manifest', () => {
196
- it('encodes the documented layout and round-trips offsets/kinds', () => {
197
- const sample: ProfileData = {
198
- username: 'ada',
199
- bioHtml: '<em>x</em>',
200
- posts: [{ title: 't' }],
201
- };
202
- const { tmpl, slots } = extractFromHtml(renderBuild(<Profile d={sample} />));
203
- const ids = assignSlotIds(slots);
204
- const hash = coherenceHash(tmpl, slots);
205
- const buf = encodeSlots(tmpl.length, hash, slots, ids);
206
-
207
- // Header: magic "TSLT", version 1, flags 0, tmpl_len, hash, n_slots.
208
- expect(buf.subarray(0, 4).toString('ascii')).toBe('TSLT');
209
- expect(buf.readUInt16LE(4)).toBe(1);
210
- expect(buf.readUInt16LE(6)).toBe(0);
211
- expect(buf.readUInt32LE(8)).toBe(tmpl.length);
212
- expect(buf.subarray(12, 44).equals(hash)).toBe(true);
213
- expect(buf.readUInt16LE(44)).toBe(slots.length);
214
-
215
- // Slot entries: offset u32, slot_id u16, kind u8, reserved u8.
216
- let o = 46;
217
- slots.forEach((s, i) => {
218
- expect(buf.readUInt32LE(o)).toBe(s.offset);
219
- expect(buf.readUInt16LE(o + 4)).toBe(ids.get(s.id));
220
- expect(buf.readUInt8(o + 6)).toBe(kindByte(s.kind));
221
- expect(buf.readUInt8(o + 7)).toBe(0);
222
- expect(ids.get(s.id)).toBe(i); // document-order numbering
223
- o += 8;
224
- });
225
- expect(o).toBe(buf.length);
226
- });
227
-
228
- it('coherence hash changes when the template changes', () => {
229
- const a = extractFromHtml(
230
- renderBuild(<Profile d={{ username: 'a', bioHtml: 'x', posts: [{ title: 't' }] }} />),
231
- );
232
- const h1 = coherenceHash(a.tmpl, a.slots);
233
- const h2 = coherenceHash(Buffer.concat([a.tmpl, Buffer.from('!')]), a.slots);
234
- expect(h1.equals(h2)).toBe(false);
235
- });
236
- });
237
-
238
- describe('ssr guest codegen (Slot enum + HASH)', () => {
239
- const sample: ProfileData = {
240
- username: 'ada',
241
- bioHtml: '<em>x</em>',
242
- posts: [{ title: 't' }],
243
- };
244
-
245
- it('emits a Slot enum matching the .slots numbering and the 32-byte HASH', () => {
246
- const { tmpl, slots } = extractFromHtml(renderBuild(<Profile d={sample} />));
247
- const ids = assignSlotIds(slots);
248
- const hash = coherenceHash(tmpl, slots);
249
- const mod = generateSlotsModule('u_name', slots, hash);
250
-
251
- // Enum members use the SAME ids the host .slots carries.
252
- expect(mod).toContain('export enum Slot {');
253
- expect(mod).toContain(`username = ${ids.get('username')},`);
254
- expect(mod).toContain(`bio = ${ids.get('bio')},`);
255
- expect(mod).toContain(`posts = ${ids.get('posts')},`);
256
- // HASH literal has exactly 32 bytes.
257
- const arr = mod.match(/HASH: StaticArray<u8> = \[([^\]]*)\]/)![1];
258
- expect(arr.split(',').filter((s) => s.trim().length > 0)).toHaveLength(32);
259
- expect(mod).toContain(`0x${hash[0].toString(16).padStart(2, '0')}`);
260
- });
261
-
262
- it('rejects a hole id that is not a valid identifier', () => {
263
- const bad: SlotRecord[] = [{ id: 'has-dash', kind: 'text', offset: 0 }];
264
- expect(() => generateSlotsModule('r', bad, Buffer.alloc(32))).toThrow(/not a valid identifier/);
265
- });
266
- });
267
-
268
- describe('ssr attribute holes (attr())', () => {
269
- it('is transparent in the browser and a sentinel under the build extractor', () => {
270
- // Browser (default): passes the value through unchanged.
271
- expect(attr('link', '/u/ada')).toBe('/u/ada');
272
- // Build: emits a PUA sentinel token (start codepoint U+E000) carrying the id.
273
- __setSsrBuild(true);
274
- try {
275
- const tok = attr('link', '/u/ada');
276
- expect(tok).not.toBe('/u/ada');
277
- expect(tok.charCodeAt(0)).toBe(0xe000);
278
- expect(tok).toContain('link');
279
- } finally {
280
- __setSsrBuild(false);
281
- }
282
- });
283
-
284
- it('extracts an attr slot whose guest stamp reproduces React attribute output byte-for-byte', () => {
285
- // Render with the attr() hole in an attribute position, in build mode.
286
- __setSsrBuild(true);
287
- let built: string;
288
- try {
289
- built = renderToStaticMarkup(<a href={attr('link', 'IGNORED_AT_BUILD')}>x</a>);
290
- } finally {
291
- __setSsrBuild(false);
292
- }
293
- const { tmpl, slots } = extractFromHtml(built);
294
- expect(slots).toHaveLength(1);
295
- expect(slots[0]).toMatchObject({ id: 'link', kind: 'attr' });
296
- expect(kindByte(slots[0].kind)).toBe(2);
297
- // The .tmpl carries the attribute with the hole stripped to an empty value.
298
- expect(tmpl.toString('utf8')).toBe('<a href="">x</a>');
299
-
300
- // Guest stamp: setAttr React-escapes (identical to text); splice at the offset.
301
- const value = '/u/ada?q="a"&b<c>';
302
- const stamped = spliceTemplate(tmpl, [
303
- { offset: slots[0].offset, value: Buffer.from(reactEscapeHtml(value), 'utf8') },
304
- ]).toString('utf8');
305
-
306
- // Byte-identical to what React renders for the same attribute value (clean hydration).
307
- expect(stamped).toBe(renderToStaticMarkup(<a href={value}>x</a>));
308
- });
309
- });
310
-
311
- describe('ssr build orchestration', () => {
312
- const SHELL =
313
- '<!doctype html><html><head><title>t</title></head><body><div id="root"></div>' +
314
- '<script type="module" src="/assets/app-abc123.js"></script></body></html>';
315
-
316
- // A page that reads its data from the loader context (exercises the provider
317
- // path), wrapped in a simple SSR-safe layout.
318
- function ProfilePage(): React.ReactElement {
319
- const d = useLoaderData<ProfileData>();
320
- return <Profile d={d} />;
321
- }
322
- function Layout({ children }: { children?: React.ReactNode }): React.ReactElement {
323
- return <div className="app">{children}</div>;
324
- }
325
-
326
- const sample: ProfileData = {
327
- username: 'ada',
328
- bioHtml: '<em>x</em>',
329
- posts: [{ title: 't' }],
330
- };
331
-
332
- it('sanitizes route patterns into file-safe names', () => {
333
- expect(routeTemplateName('/u/:name')).toBe('u_name');
334
- expect(routeTemplateName('/')).toBe('index');
335
- expect(routeTemplateName('/blog/[id]')).toBe('blog_id');
336
- });
337
-
338
- it('injects rendered route HTML into the shell #root with the SSR marker', () => {
339
- const out = injectIntoShell(SHELL, '<main>hi</main>');
340
- expect(out).toContain('<div id="root"><main>hi</main></div>');
341
- expect(out).toContain('<template id="__toil_ssr"></template>');
342
- // the hashed script tag is preserved (so hydration boots)
343
- expect(out).toContain('/assets/app-abc123.js');
344
- });
345
-
346
- it('renders a route (page + layout + loader data) to template artifacts and writes them', () => {
347
- const art = extractRouteTemplate({
348
- name: 'profile',
349
- Page: ProfilePage,
350
- layouts: [Layout],
351
- loaderData: sample,
352
- loaderContext: LoaderDataContext,
353
- setSsrBuild: __setSsrBuild,
354
- shell: SHELL,
355
- });
356
-
357
- const tmpl = art.tmpl.toString('utf8');
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.
363
- expect(tmpl).toContain(
364
- '<div id="root"><!--$--><div class="app"><!--$--><main><h1>@<!-- --></h1><div></div><ul></ul></main><!--/$--></div><!--/$--></div>',
365
- );
366
- expect(tmpl).toContain('<template id="__toil_ssr"></template>');
367
- expect(tmpl).toContain('/assets/app-abc123.js'); // bootstrap script preserved
368
- expect(art.slotCount).toBe(3); // username, bio, posts
369
- expect(art.hash).toHaveLength(32);
370
-
371
- // The generated AS Slot module names every hole.
372
- expect(art.slotsModule).toContain('export enum Slot {');
373
- for (const id of ['username', 'bio', 'posts']) expect(art.slotsModule).toContain(`${id} =`);
374
-
375
- // Write to disk and read back; the .slots header is well-formed and the
376
- // tmpl_len in it matches the .tmpl byte length (the host's first check).
377
- const dir = fs.mkdtempSync(path.join(os.tmpdir(), 'toil-ssr-'));
378
- try {
379
- writeTemplateArtifacts(dir, art);
380
- const tmplFile = fs.readFileSync(path.join(dir, 'profile.tmpl'));
381
- const slotsFile = fs.readFileSync(path.join(dir, 'profile.slots'));
382
- const modFile = fs.readFileSync(path.join(dir, 'profile.slots.ts'), 'utf8');
383
-
384
- expect(tmplFile.equals(art.tmpl)).toBe(true);
385
- expect(slotsFile.subarray(0, 4).toString('ascii')).toBe('TSLT');
386
- expect(slotsFile.readUInt16LE(4)).toBe(1); // version
387
- expect(slotsFile.readUInt32LE(8)).toBe(tmplFile.length); // tmpl_len matches .tmpl
388
- expect(slotsFile.subarray(12, 44).equals(art.hash)).toBe(true);
389
- expect(slotsFile.readUInt16LE(44)).toBe(3); // n_slots
390
- expect(modFile).toContain('export const HASH: StaticArray<u8>');
391
- } finally {
392
- fs.rmSync(dir, { recursive: true, force: true });
393
- }
394
- });
395
-
396
- it('bakes the route SEO (title/description/og incl og:image) into the template <head>', () => {
397
- const art = extractRouteTemplate({
398
- name: 'profile',
399
- Page: ProfilePage,
400
- layouts: [Layout],
401
- loaderData: sample,
402
- loaderContext: LoaderDataContext,
403
- setSsrBuild: __setSsrBuild,
404
- shell: SHELL,
405
- seo: {
406
- url: 'https://ex.com',
407
- title: 'Site',
408
- openGraph: { siteName: 'Site', image: 'https://ex.com/og.png' },
409
- },
410
- metadata: {
411
- title: 'Profile',
412
- description: 'A user profile',
413
- openGraph: { title: 'Profile OG' },
414
- },
415
- pattern: '/u/ada',
416
- });
417
- const tmpl = art.tmpl.toString('utf8');
418
- // The route's own title replaces the shell's, and its metadata + the site SEO are in <head>,
419
- // so an SSR route serves the same per-page tags a crawler would get from <route>/index.html.
420
- expect(tmpl).toContain('<title>Profile</title>');
421
- expect(tmpl).not.toContain('<title>t</title>');
422
- expect(tmpl).toContain('<meta name="description" content="A user profile" />');
423
- expect(tmpl).toContain('<meta property="og:title" content="Profile OG" />');
424
- expect(tmpl).toContain('<meta property="og:image" content="https://ex.com/og.png" />');
425
- // Per-route canonical / og:url point at THIS route, not the site root.
426
- expect(tmpl).toContain('<link rel="canonical" href="https://ex.com/u/ada" />');
427
- expect(tmpl).toContain('<meta property="og:url" content="https://ex.com/u/ada" />');
428
- // The baked head is inside art.tmpl, so it is covered by the coherence hash.
429
- expect(art.hash).toHaveLength(32);
430
- // Holes are unaffected (still body-only).
431
- expect(art.slotCount).toBe(3);
432
- });
433
-
434
- it('skips SEO injection when no seo config is passed (head unchanged)', () => {
435
- const art = extractRouteTemplate({
436
- name: 'p',
437
- Page: ProfilePage,
438
- layouts: [Layout],
439
- loaderData: sample,
440
- loaderContext: LoaderDataContext,
441
- setSsrBuild: __setSsrBuild,
442
- shell: SHELL,
443
- });
444
- const tmpl = art.tmpl.toString('utf8');
445
- expect(tmpl).toContain('<title>t</title>'); // shell title untouched
446
- expect(tmpl).not.toContain('og:image');
447
- expect(tmpl).not.toContain('rel="canonical"');
448
- });
449
-
450
- it('bakes the component-level head (useHead/<Head>) the static metadata did not set', () => {
451
- const componentHead = {
452
- title: 'Layout Title',
453
- meta: [
454
- { name: 'author', content: 'me' },
455
- { name: 'description', content: 'layout desc' },
456
- ],
457
- link: [{ rel: 'me', href: 'https://x.test' }],
458
- };
459
- const art = extractRouteTemplate({
460
- name: 'p',
461
- Page: ProfilePage,
462
- layouts: [Layout],
463
- loaderData: sample,
464
- loaderContext: LoaderDataContext,
465
- setSsrBuild: __setSsrBuild,
466
- shell: SHELL,
467
- seo: { title: 'Site', description: 'site desc' },
468
- metadata: { description: 'route desc' }, // route sets a description but NO title
469
- pattern: '/p',
470
- drainSsrHead: () => componentHead,
471
- });
472
- const tmpl = art.tmpl.toString('utf8');
473
- // Component title wins because the route's static metadata set no title of its own.
474
- expect(tmpl).toContain('<title>Layout Title</title>');
475
- // A component meta the route SEO didn't carry is added, owned by the client (data-toil-head).
476
- expect(tmpl).toContain('<meta data-toil-head name="author" content="me" />');
477
- // The component description is deduped (the route SEO already baked one).
478
- expect(tmpl.match(/name="description"/g)?.length).toBe(1);
479
- // A component link is added too.
480
- expect(tmpl).toContain('<link data-toil-head rel="me" href="https://x.test" />');
481
- });
482
- });