prunelle 0.8.0 → 0.10.0

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 (209) hide show
  1. package/llms.txt +68 -51
  2. package/package.json +7 -2
  3. package/src/a11y/declaration.ts +10 -17
  4. package/src/a11y/index.ts +69 -125
  5. package/src/animate.ts +127 -0
  6. package/src/build/asides.ts +51 -0
  7. package/src/build/bundle.ts +94 -136
  8. package/src/build/client-entries.ts +6 -6
  9. package/src/build/client-outputs.ts +75 -0
  10. package/src/build/client-plugin.ts +9 -4
  11. package/src/build/ecoindex.ts +4 -2
  12. package/src/build/files.ts +18 -0
  13. package/src/build/graph.ts +14 -6
  14. package/src/build/index.ts +23 -11
  15. package/src/build/island-promote.ts +42 -2
  16. package/src/build/islands.ts +63 -9
  17. package/src/build/key-types.ts +31 -0
  18. package/src/build/manifest.ts +117 -1
  19. package/src/build/plugin-host.ts +13 -1
  20. package/src/build/prerender.ts +8 -3
  21. package/src/build/reach.ts +18 -4
  22. package/src/build/report.ts +1 -1
  23. package/src/build/resolve.ts +5 -1
  24. package/src/build/route-types.ts +16 -0
  25. package/src/build/routes.ts +42 -15
  26. package/src/build/seed-ids.ts +65 -0
  27. package/src/build/seed-writes.ts +111 -0
  28. package/src/build/static-headers.ts +2 -2
  29. package/src/build/static.ts +1 -1
  30. package/src/cli/check-cache.ts +51 -0
  31. package/src/cli/check-consent.ts +95 -0
  32. package/src/cli/check-forms.ts +10 -2
  33. package/src/cli/check-links-patterns.ts +101 -0
  34. package/src/cli/check-links.ts +30 -105
  35. package/src/cli/check-regions.ts +185 -0
  36. package/src/cli/check-security.ts +50 -6
  37. package/src/cli/check.ts +49 -21
  38. package/src/cli/commands.ts +138 -16
  39. package/src/cli/docs.ts +21 -2
  40. package/src/cli/form-opaque-children.ts +40 -0
  41. package/src/cli/index.ts +1 -1
  42. package/src/cli/inspect.ts +2 -0
  43. package/src/cli/mcp-tools.ts +2 -2
  44. package/src/cli/new.ts +9 -5
  45. package/src/cli/upgrade-names.ts +14 -2
  46. package/src/cli/upgrade.ts +3 -0
  47. package/src/compiler/analyze.ts +22 -16
  48. package/src/compiler/cacheability-private.ts +13 -3
  49. package/src/compiler/cacheability.ts +24 -2
  50. package/src/compiler/compliance-contrast.ts +322 -0
  51. package/src/compiler/compliance-empty.ts +24 -0
  52. package/src/compiler/compliance-rgaa-content.ts +95 -0
  53. package/src/compiler/compliance-rgaa-criteria.ts +45 -0
  54. package/src/compiler/compliance-rgaa-pages.ts +140 -0
  55. package/src/compiler/compliance-rgaa.ts +19 -0
  56. package/src/compiler/compliance-rules.ts +72 -0
  57. package/src/compiler/compliance-third-party.ts +59 -0
  58. package/src/compiler/compliance-urls.ts +52 -0
  59. package/src/compiler/compliance.ts +61 -93
  60. package/src/compiler/cookie-inventory.ts +119 -0
  61. package/src/compiler/dom-attrs.ts +178 -22
  62. package/src/compiler/dom.ts +31 -44
  63. package/src/compiler/emit.ts +17 -6
  64. package/src/compiler/expr-context.ts +260 -207
  65. package/src/compiler/foreign-imports.ts +5 -3
  66. package/src/compiler/mistakes.ts +18 -9
  67. package/src/compiler/props-body.ts +263 -21
  68. package/src/compiler/props-pattern.ts +211 -0
  69. package/src/compiler/props.ts +324 -343
  70. package/src/compiler/signal-reads.ts +142 -29
  71. package/src/compiler/spread-handlers.ts +25 -13
  72. package/src/compiler/ssr-emit.ts +510 -0
  73. package/src/compiler/ssr-helpers.ts +165 -121
  74. package/src/compiler/ssr.ts +28 -441
  75. package/src/context.ts +14 -1
  76. package/src/dev/child.ts +1 -1
  77. package/src/dev/host-check.ts +2 -1
  78. package/src/dev/hot-islands.ts +71 -0
  79. package/src/dev/index.ts +31 -18
  80. package/src/dev/protocol.ts +1 -1
  81. package/src/dev/queue.ts +3 -2
  82. package/src/dev/reload.ts +5 -2
  83. package/src/dev/supervisor.ts +3 -1
  84. package/src/dev/watchers.ts +6 -2
  85. package/src/dom/action.ts +97 -14
  86. package/src/dom/attrs.ts +93 -25
  87. package/src/dom/extras.ts +91 -50
  88. package/src/dom/field-marks.ts +32 -0
  89. package/src/dom/hot.ts +9 -0
  90. package/src/dom/index.ts +44 -18
  91. package/src/dom/island-hot.ts +29 -0
  92. package/src/dom/island.ts +13 -2
  93. package/src/dom/loop.ts +259 -188
  94. package/src/dom/prefetch.ts +135 -0
  95. package/src/dom/regions.ts +515 -0
  96. package/src/dom/swap.ts +246 -0
  97. package/src/dom/trusted.ts +22 -0
  98. package/src/dom/upload.ts +44 -0
  99. package/src/eco/declaration.ts +44 -41
  100. package/src/eco/index.ts +8 -5
  101. package/src/href.ts +31 -0
  102. package/src/index.ts +12 -5
  103. package/src/plugins/config.ts +1 -1
  104. package/src/plugins/context.ts +7 -1
  105. package/src/plugins/daily.ts +27 -0
  106. package/src/plugins/index.ts +3 -3
  107. package/src/plugins/order.ts +1 -1
  108. package/src/plugins/public.ts +12 -5
  109. package/src/plugins/services.ts +88 -14
  110. package/src/plugins/types.ts +128 -10
  111. package/src/reactivity/graph.ts +244 -41
  112. package/src/reactivity/hmr.ts +101 -0
  113. package/src/reactivity/index.ts +243 -239
  114. package/src/reactivity/resource.ts +129 -0
  115. package/src/reactivity/seed.ts +141 -0
  116. package/src/reactivity/selector.ts +85 -47
  117. package/src/reactivity/server-seed.ts +202 -0
  118. package/src/reactivity/store.ts +331 -97
  119. package/src/rgpd/draft.ts +171 -0
  120. package/src/rgpd/forms.ts +85 -0
  121. package/src/rgpd/index.ts +57 -0
  122. package/src/server/action-flash.ts +1 -0
  123. package/src/server/action-protect.ts +3 -0
  124. package/src/server/action-registry.ts +11 -9
  125. package/src/server/action.ts +51 -19
  126. package/src/server/app-secret.ts +14 -8
  127. package/src/server/cache-invalidation.ts +97 -0
  128. package/src/server/compress.ts +55 -18
  129. package/src/server/consent.ts +21 -5
  130. package/src/server/cookie-inventory.ts +78 -0
  131. package/src/server/cookies.ts +77 -8
  132. package/src/server/cors.ts +98 -0
  133. package/src/server/csp-report.ts +90 -0
  134. package/src/server/discard.ts +13 -0
  135. package/src/server/document.ts +2 -2
  136. package/src/server/env.ts +1 -1
  137. package/src/server/errors.ts +9 -2
  138. package/src/server/field-errors.ts +91 -0
  139. package/src/server/form-schema.ts +16 -11
  140. package/src/server/health.ts +41 -11
  141. package/src/server/http.ts +28 -11
  142. package/src/server/index.ts +122 -307
  143. package/src/server/loader.ts +2 -0
  144. package/src/server/page.ts +3 -9
  145. package/src/server/plugin-host.ts +66 -16
  146. package/src/server/plugin-route-shadow.ts +24 -0
  147. package/src/server/public.ts +14 -3
  148. package/src/server/rate-limit.ts +49 -10
  149. package/src/server/region.ts +22 -2
  150. package/src/server/request-handler.ts +406 -0
  151. package/src/server/request-log.ts +94 -0
  152. package/src/server/route-cache.ts +55 -8
  153. package/src/server/route-input.ts +54 -0
  154. package/src/server/route-table.ts +53 -27
  155. package/src/server/router.ts +2 -1
  156. package/src/server/routing.ts +104 -45
  157. package/src/server/sanitize-html.ts +4 -2
  158. package/src/server/security.ts +38 -8
  159. package/src/server/serve-handlers.ts +16 -6
  160. package/src/server/served-file.ts +19 -14
  161. package/src/server/shared-store.ts +323 -0
  162. package/src/server/start.ts +12 -5
  163. package/src/server/static-dir.ts +34 -12
  164. package/src/server/stream.ts +2 -1
  165. package/src/server/surface.ts +39 -0
  166. package/src/server/webhook.ts +50 -0
  167. package/src/server/workers.ts +168 -0
  168. package/src/ssr/consent-banner.ts +20 -16
  169. package/src/ssr/consent-texts.ts +40 -0
  170. package/src/ssr/context.ts +174 -53
  171. package/src/ssr/cookie-table.ts +75 -0
  172. package/src/ssr/index.ts +63 -58
  173. package/src/ssr/navigation.ts +161 -14
  174. package/src/ssr/region.ts +9 -3
  175. package/src/style.ts +12 -5
  176. package/src/test/browser.ts +53 -23
  177. package/src/test/build-reuse.ts +85 -0
  178. package/src/test/index.ts +51 -8
  179. package/src/test/mount.ts +53 -0
  180. package/src/test/outside.ts +94 -0
  181. package/src/ts-plugin/diagnostics.ts +56 -18
  182. package/templates/_shared/AGENTS.md +1 -1
  183. package/templates/_shared/Dockerfile +22 -0
  184. package/templates/_shared/dockerignore +9 -0
  185. package/templates/_shared/gitignore +2 -0
  186. package/templates/app/.env.example +3 -1
  187. package/templates/app/compose.yaml +32 -0
  188. package/templates/app/db/migrations/001_notes.sql +7 -0
  189. package/templates/app/db/schema.ts +11 -0
  190. package/templates/app/package.json +1 -0
  191. package/templates/app/prunelle.config.ts +6 -0
  192. package/templates/app/src/actions/notes.ts +26 -0
  193. package/templates/app/src/auth.ts +4 -2
  194. package/templates/app/src/db.ts +5 -0
  195. package/templates/app/src/routes/dashboard/index.tsx +26 -1
  196. package/templates/app/src/routes/privacy.tsx +6 -2
  197. package/templates/app/tests/app.test.ts +14 -3
  198. package/templates/plugin/AGENTS.md +11 -0
  199. package/templates/plugin/CLAUDE.md +1 -0
  200. package/templates/plugin/README.md +27 -0
  201. package/templates/plugin/gitignore +2 -0
  202. package/templates/plugin/llms.txt +19 -0
  203. package/templates/plugin/package.json +33 -0
  204. package/templates/plugin/src/index.ts +40 -0
  205. package/templates/plugin/tests/fixture/prunelle.config.ts +4 -0
  206. package/templates/plugin/tests/fixture/src/routes/index.tsx +11 -0
  207. package/templates/plugin/tests/plugin.test.ts +42 -0
  208. package/templates/plugin/tsconfig.json +19 -0
  209. package/ts-plugin.cjs +4058 -2246
@@ -0,0 +1,246 @@
1
+ // What a region swap and a whole-page `@prunellejs/spa` swap share: view transitions, scroll restoration, live announcements, and `Element.moveBefore`-based `[data-persist]` preservation.
2
+ // An element with `data-pru-keep-scroll="<key>"` keeps its offset by key; a `<Region>` that scrolls itself is remembered per entry as `region:<name>`.
3
+
4
+ import { getDocId } from './prefetch'
5
+
6
+ // Kept apart from `dom/trusted.ts` so island pages without `<Region>` never download a shared Trusted Types chunk, while sharing the created policy on `globalThis`.
7
+ interface HtmlPolicy { createHTML: (html: string) => string }
8
+ interface TrustedGlobal { __pruTT?: HtmlPolicy, trustedTypes?: { createPolicy: (name: string, rules: HtmlPolicy) => HtmlPolicy } }
9
+
10
+ export function trustedHtml(html: string): string {
11
+ const g = globalThis as TrustedGlobal
12
+ if (g.__pruTT === undefined) {
13
+ const pass: HtmlPolicy = { createHTML: s => s }
14
+ try {
15
+ g.__pruTT = g.trustedTypes?.createPolicy('prunelle', pass) ?? pass
16
+ }
17
+ catch {
18
+ g.__pruTT = pass
19
+ }
20
+ }
21
+ return g.__pruTT.createHTML(html)
22
+ }
23
+
24
+ export interface EntryScroll { y: number, k: Record<string, number> }
25
+
26
+ const SCROLLERS = '[data-pru-keep-scroll],[data-pru-region]'
27
+ const PERSIST = '[data-persist]'
28
+
29
+ const keyOf = (el: Element): string => el.getAttribute('data-pru-keep-scroll') ?? `region:${el.getAttribute('data-pru-region')}`
30
+
31
+ /** The offsets of the elements that keep theirs; `regions` adds the scrolled `<Region>`s, which a swap resets and a history entry restores. */
32
+ export function readScrolls(regions: boolean): Record<string, number> {
33
+ const out: Record<string, number> = {}
34
+ for (const el of document.querySelectorAll(SCROLLERS)) {
35
+ if (el.hasAttribute('data-pru-keep-scroll') || (regions && el.scrollTop > 0))
36
+ out[keyOf(el)] = el.scrollTop
37
+ }
38
+ return out
39
+ }
40
+
41
+ export function writeScrolls(offsets: Record<string, number>): void {
42
+ for (const el of document.querySelectorAll(SCROLLERS)) {
43
+ const top = offsets[keyOf(el)]
44
+ if (top !== undefined)
45
+ el.scrollTop = top
46
+ }
47
+ }
48
+
49
+ export function entryScroll(state: unknown): EntryScroll | undefined {
50
+ const saved = typeof state === 'object' && state !== null ? (state as { __pruScroll?: EntryScroll }).__pruScroll : undefined
51
+ return typeof saved?.y === 'number' ? saved : undefined
52
+ }
53
+
54
+ export function restoreScroll(saved: EntryScroll): void {
55
+ writeScrolls(saved.k)
56
+ window.scrollTo(0, saved.y)
57
+ }
58
+
59
+ /** Writes the page's scroll into the current history entry, so back and forward can return to it. */
60
+ export function saveScroll(): void {
61
+ try {
62
+ const prev = typeof history.state === 'object' && history.state !== null ? history.state as Record<string, unknown> : {}
63
+ history.replaceState({ ...prev, __pruDoc: getDocId(), __pruScroll: { y: window.scrollY, k: readScrolls(true) } satisfies EntryScroll }, '')
64
+ }
65
+ catch {
66
+ // Restricted history API environments (e.g. sandboxed iframes) refuse state updates: the entry keeps no scroll.
67
+ return
68
+ }
69
+ }
70
+
71
+ const trackedDocs = new WeakSet<Document>()
72
+
73
+ /** Keeps the current entry's scroll up to date once the page stops scrolling, as a swap by back or forward has no earlier moment to read it. */
74
+ export function trackScroll(): void {
75
+ if (typeof document === 'undefined' || trackedDocs.has(document))
76
+ return
77
+ trackedDocs.add(document)
78
+ let timer: ReturnType<typeof setTimeout> | undefined
79
+ document.addEventListener('scroll', () => {
80
+ clearTimeout(timer)
81
+ timer = setTimeout(saveScroll, 150)
82
+ }, { capture: true, passive: true })
83
+ }
84
+
85
+ export const ANNOUNCER_ID = '__pru-spa-announcer'
86
+
87
+ function applySrOnlyStyle(el: HTMLElement): void {
88
+ const s = el.style
89
+ s.position = 'absolute'
90
+ s.width = '1px'
91
+ s.height = '1px'
92
+ s.padding = '0'
93
+ s.margin = '-1px'
94
+ s.overflow = 'hidden'
95
+ s.clip = 'rect(0,0,0,0)'
96
+ s.whiteSpace = 'nowrap'
97
+ s.border = '0'
98
+ }
99
+
100
+ // A screen reader speaks a live region's change only once the region is in the page, and only when its text differs:
101
+ // the region is emptied now and filled on the next frame, so a new region, a moved one and a repeated title are all heard.
102
+ export function announce(text: string): void {
103
+ let region = document.getElementById(ANNOUNCER_ID)
104
+ if (region === null) {
105
+ region = document.createElement('div')
106
+ region.id = ANNOUNCER_ID
107
+ region.setAttribute('role', 'status')
108
+ region.setAttribute('aria-live', 'polite')
109
+ region.setAttribute('aria-atomic', 'true')
110
+ applySrOnlyStyle(region)
111
+ document.body.appendChild(region)
112
+ }
113
+ region.textContent = ''
114
+ requestAnimationFrame(() => {
115
+ region.textContent = text
116
+ })
117
+ }
118
+
119
+ /** The outermost `[data-persist]` elements under `root` by key (a nested one moves with its own), and a key found on two of them. */
120
+ export function persistedIn(root: ParentNode & Node): { byKey: Map<string, Element>, twice: string | undefined } {
121
+ const byKey = new Map<string, Element>()
122
+ let twice: string | undefined
123
+ for (const el of root.querySelectorAll(PERSIST)) {
124
+ const outer = el.parentElement?.closest(PERSIST)
125
+ const key = el.getAttribute('data-persist')
126
+ if (key === null || key === '' || (outer !== null && outer !== undefined && root.contains(outer)))
127
+ continue
128
+ if (byKey.has(key))
129
+ twice ??= key
130
+ byKey.set(key, el)
131
+ }
132
+ return { byKey, twice }
133
+ }
134
+
135
+ type Movable = ParentNode & { moveBefore?: (node: Node, child: Node | null) => void }
136
+
137
+ /**
138
+ * Replaces `container`'s children with `content`, preserving each live `[data-persist]` element in the place of
139
+ * the incoming element with the same key. Uses `Element.moveBefore` when available so focused fields keep focus/caret
140
+ * and iframes/media keep state; falls back to `insertBefore` with focus and selection restoration.
141
+ */
142
+ export function replaceKeeping(container: HTMLElement, content: DocumentFragment, keep?: ReadonlySet<Node>): void {
143
+ const incoming = persistedIn(content).byKey
144
+ const live = persistedIn(container).byKey
145
+ const old = [...container.childNodes]
146
+ container.append(content)
147
+ const focused = document.activeElement
148
+ const field = focused instanceof HTMLInputElement || focused instanceof HTMLTextAreaElement ? focused : undefined
149
+ const selection = field?.selectionStart == null ? undefined : [field.selectionStart, field.selectionEnd ?? field.selectionStart, field.selectionDirection ?? 'none'] as const
150
+ const preserved = new Set<Node>(keep)
151
+ let refocus = false
152
+ for (const [key, el] of live) {
153
+ const slot = incoming.get(key)
154
+ const parent = slot?.parentNode as Movable | null | undefined
155
+ if (slot === undefined || parent === null || parent === undefined)
156
+ continue
157
+ preserved.add(el)
158
+ if (typeof parent.moveBefore === 'function') {
159
+ parent.moveBefore(el, slot)
160
+ }
161
+ else {
162
+ refocus ||= focused !== null && el.contains(focused)
163
+ parent.insertBefore(el, slot)
164
+ }
165
+ slot.remove()
166
+ }
167
+ for (const node of old) {
168
+ if (!preserved.has(node))
169
+ node.remove()
170
+ }
171
+ if (refocus && focused instanceof HTMLElement && document.activeElement !== focused) {
172
+ focused.focus({ preventScroll: true })
173
+ if (field !== undefined && selection !== undefined)
174
+ field.setSelectionRange(...selection)
175
+ }
176
+ }
177
+
178
+ /** Copies attributes from `source` to `target`, removing attributes absent on `source`; the `keep` attribute is left as it is. */
179
+ export function syncElementAttrs(target: Element, source: Element, keep = ''): void {
180
+ for (const attr of [...target.attributes]) {
181
+ if (!source.hasAttribute(attr.name) && attr.name !== keep)
182
+ target.removeAttribute(attr.name)
183
+ }
184
+ for (const attr of source.attributes) {
185
+ if (attr.name !== keep && target.getAttribute(attr.name) !== attr.value)
186
+ target.setAttribute(attr.name, attr.value)
187
+ }
188
+ }
189
+
190
+ interface Transition { updateCallbackDone: Promise<void>, ready: Promise<void>, finished: Promise<void>, skipTransition: () => void }
191
+ type Transitions = Document & { startViewTransition?: (update: () => void) => Transition }
192
+
193
+ let running: Transition | undefined
194
+ const transitionDocs = new WeakSet<Document>()
195
+
196
+ // While a view transition runs, Chrome hit-tests every click to <html>: the click skips the transition and goes to what is under the pointer once it ends.
197
+ function retargetClick(event: MouseEvent): void {
198
+ const transition = running
199
+ if (transition === undefined || event.target !== document.documentElement || event.detail === 0 || event.button !== 0)
200
+ return
201
+ event.preventDefault()
202
+ event.stopImmediatePropagation()
203
+ const { clientX, clientY } = event
204
+ // A skipped transition rejects `ready` with AbortError.
205
+ void transition.ready.catch((err) => {
206
+ if (!(err instanceof DOMException && err.name === 'AbortError'))
207
+ console.error('[prunelle] view transition failed:', err)
208
+ })
209
+ transition.skipTransition()
210
+ const resend = (): void => {
211
+ const under = document.elementFromPoint(clientX, clientY)
212
+ if (under instanceof HTMLElement && under !== document.documentElement)
213
+ under.click()
214
+ }
215
+ void transition.finished.then(resend, resend)
216
+ }
217
+
218
+ // `navigation: { viewTransitions: false }` leaves the `@view-transition` rule out of every page: swaps follow what the page says.
219
+ function pageAnimates(): boolean {
220
+ for (const style of document.head.querySelectorAll('style')) {
221
+ if (style.textContent?.includes('@view-transition'))
222
+ return true
223
+ }
224
+ return false
225
+ }
226
+
227
+ /** Runs the DOM `update` inside a view transition where the browser has them, the app keeps them and the user allows motion; resolves once it ran. */
228
+ export async function swapInTransition(update: () => void, animate = true): Promise<void> {
229
+ const doc = document as Transitions
230
+ if (!animate || typeof doc.startViewTransition !== 'function' || matchMedia('(prefers-reduced-motion: reduce)').matches || !pageAnimates()) {
231
+ update()
232
+ return
233
+ }
234
+ if (!transitionDocs.has(document)) {
235
+ transitionDocs.add(document)
236
+ document.addEventListener('click', retargetClick, true)
237
+ }
238
+ const transition = doc.startViewTransition(update)
239
+ running = transition
240
+ const done = (): void => {
241
+ if (running === transition)
242
+ running = undefined
243
+ }
244
+ void transition.finished.then(done, done)
245
+ await transition.updateCallbackDone
246
+ }
@@ -0,0 +1,22 @@
1
+ // Every HTML string prunelle and its plugins write into the page goes through one Trusted Types policy, so the default CSP (`require-trusted-types-for 'script'`) can refuse the strings app code writes itself.
2
+ // The policy passes the string through: what it covers is HTML the app asked for in so many words (`innerHTML={html}`, a compiled template, a region swap).
3
+
4
+ interface HtmlPolicy { createHTML: (html: string) => string }
5
+ interface TrustedGlobal { __pruTT?: HtmlPolicy, trustedTypes?: { createPolicy: (name: string, rules: HtmlPolicy) => HtmlPolicy } }
6
+
7
+ function createPolicy(): HtmlPolicy {
8
+ const pass = { createHTML: (html: string) => html }
9
+ try {
10
+ return (globalThis as TrustedGlobal).trustedTypes?.createPolicy('prunelle', pass) ?? pass
11
+ }
12
+ catch {
13
+ // A CSP whose `trusted-types` leaves `prunelle` out refuses the policy; without `require-trusted-types-for` the plain string still works.
14
+ return pass
15
+ }
16
+ }
17
+
18
+ /** The HTML as a sink accepts it under Trusted Types: a `TrustedHTML` where the browser has them, the string itself elsewhere. */
19
+ export function trustedHtml(html: string): string {
20
+ const g = globalThis as TrustedGlobal
21
+ return (g.__pruTT ??= createPolicy()).createHTML(html)
22
+ }
@@ -0,0 +1,44 @@
1
+ // Loaded by an action stub only when a `useAction` form's `progress` is read, to send a FormData holding a `File` because `fetch` reports no upload progress: a page that never reads it ships none of it.
2
+
3
+ /** Posts a FormData holding a `File` with XMLHttpRequest, calling `onProgress` with the fraction sent (0 to 1), then 0 once it answers, and answers as `fetch` would; any other body goes through `fetch`. */
4
+ export function upload(url: string, init: RequestInit, onProgress: (fraction: number) => void): Promise<Response> {
5
+ const body = init.body
6
+ if (!(body instanceof FormData) || ![...body.values()].some(v => typeof v != 'string'))
7
+ return fetch(url, init)
8
+ const headers = init.headers as Record<string, string>
9
+ return new Promise<Response>((resolve, reject) => {
10
+ const signal = init.signal
11
+ if (signal?.aborted) {
12
+ reject(signal.reason ?? new DOMException('Aborted', 'AbortError'))
13
+ return
14
+ }
15
+ const onAbort = () => xhr.abort()
16
+ const end = <T>(settle: (value: T) => void, value: T) => {
17
+ signal?.removeEventListener('abort', onAbort)
18
+ onProgress(0)
19
+ settle(value)
20
+ }
21
+ const xhr = new XMLHttpRequest()
22
+ signal?.addEventListener('abort', onAbort, { once: true })
23
+ xhr.open('POST', url)
24
+ xhr.responseType = 'arraybuffer'
25
+ for (const name in headers)
26
+ xhr.setRequestHeader(name, headers[name]!)
27
+ xhr.upload.onprogress = e => e.lengthComputable && onProgress(e.loaded / e.total)
28
+ xhr.onerror = xhr.ontimeout = () => end(reject, new Error('Network error'))
29
+ xhr.onabort = () => end(reject, signal?.aborted ? (signal.reason ?? new DOMException('Aborted', 'AbortError')) : new Error('Network error'))
30
+ xhr.onload = () => {
31
+ // XHR follows redirects without telling: an answer from another URL is one, which `fetch` with `redirect: 'manual'` refuses.
32
+ if (xhr.responseURL && xhr.responseURL !== new URL(url, location.href).href)
33
+ return end(reject, new Error('Unexpected redirect'))
34
+ const res = new Response([204, 205, 304].includes(xhr.status) ? null : xhr.response as ArrayBuffer, { status: xhr.status, statusText: xhr.statusText })
35
+ for (const line of xhr.getAllResponseHeaders().trim().split(/\r?\n/)) {
36
+ const at = line.indexOf(':')
37
+ if (at > 0)
38
+ res.headers.append(line.slice(0, at), line.slice(at + 1).trim())
39
+ }
40
+ end(resolve, res)
41
+ }
42
+ xhr.send(body)
43
+ })
44
+ }
@@ -1,7 +1,7 @@
1
1
  // Drafts an editable French RGESN 2024 eco-design declaration page, shaped like the State's declaration tool, from what a build and `prunelle check` measure.
2
2
 
3
3
  import type { BundleReport } from '../build/report'
4
- import { mkdirSync, writeFileSync } from 'node:fs'
4
+ import { existsSync, mkdirSync, writeFileSync } from 'node:fs'
5
5
  import { dirname, join, resolve } from 'node:path'
6
6
  import { escapeAttr, escapeJsxText, formatFrenchDate, layoutRendersMain, STATEMENT_PLACEHOLDER } from '../a11y/declaration'
7
7
  import { relPosix } from '../build/files'
@@ -29,15 +29,12 @@ export interface EcoFacts {
29
29
  routesDir?: string | undefined
30
30
  }
31
31
 
32
- export type EcoVerdict = 'Validé' | 'Non validé'
33
-
34
32
  export interface EcoCriterion {
35
33
  id: string
36
34
  /** The criterion's wording in the RGESN 2024. */
37
35
  label: string
38
36
  priority: 'Prioritaire' | 'Recommandé' | 'Modéré'
39
- /** Absent when prunelle measures part of the criterion and a person has to judge the rest. */
40
- verdict?: EcoVerdict | undefined
37
+ /** What prunelle saw: the verdict is a person's to write, a lint with partial coverage cannot back one. */
41
38
  evidence: string
42
39
  }
43
40
 
@@ -54,6 +51,8 @@ export interface EcoDeclarationOptions {
54
51
  date?: Date | undefined
55
52
  /** Write the page to disk (default: `true`). */
56
53
  write?: boolean | undefined
54
+ /** Overwrite a declaration already at the destination (default: refuse). */
55
+ force?: boolean | undefined
57
56
  }
58
57
 
59
58
  export interface EcoDeclarationResult {
@@ -97,44 +96,48 @@ function foreignAssetPrefix(assetPrefix: string, site: string | undefined): stri
97
96
  return assetPrefix
98
97
  }
99
98
 
100
- function checkRuleVerdict(
99
+ // What `prunelle check` reads is the JSX of the source files: the rest of an app escapes it.
100
+ const LINT_LIMITS = 'Cette vérification lit le JSX : elle ne voit ni les valeurs dynamiques, ni le contenu des composants, ni les lignes ignorées (prunelle-ignore).'
101
+
102
+ function lintEvidence(
101
103
  files: readonly string[],
102
104
  ignored: boolean,
103
105
  rule: string,
104
- validText: string,
105
- invalidPrefix: string,
106
+ cleanText: string,
107
+ foundPrefix: string,
106
108
  manualPrompt: string,
107
- ): Pick<EcoCriterion, 'verdict' | 'evidence'> {
109
+ ): string {
108
110
  if (files.length > 0)
109
- return { verdict: 'Non validé', evidence: `${invalidPrefix}${files.join(', ')}.` }
111
+ return `${foundPrefix}${files.join(', ')}. ${LINT_LIMITS}`
110
112
  if (ignored)
111
- return { verdict: undefined, evidence: `La règle ${rule} est ignorée dans prunelle.config.ts (compliance.ignore) ; ${fill(manualPrompt)}.` }
112
- return { verdict: 'Validé', evidence: validText }
113
+ return `La règle ${rule} est ignorée dans prunelle.config.ts (compliance.ignore) ; ${fill(manualPrompt)}.`
114
+ return `${cleanText} ${LINT_LIMITS}`
113
115
  }
114
116
 
115
- function sameDomainVerdict(assetOrigin: string | undefined, externalPages: readonly string[]): Pick<EcoCriterion, 'verdict' | 'evidence'> {
117
+ function sameDomainEvidence(assetOrigin: string | undefined, externalPages: readonly string[], measured: number): string {
118
+ const notMeasured = measured === 0 ? 'Aucune page n\'est prérendue : prunelle n\'a mesuré aucune requête des pages. ' : ''
116
119
  if (assetOrigin === undefined && externalPages.length === 0) {
117
- return {
118
- verdict: 'Validé',
119
- evidence: 'Les scripts, feuilles de style, polices et images sont servis par le domaine des pages.',
120
- }
121
- }
122
- if (assetOrigin !== undefined && externalPages.length === 0) {
123
- return {
124
- verdict: 'Non validé',
125
- evidence: `Les scripts et feuilles de style sont servis depuis ${assetOrigin}, un autre domaine que celui des pages.`,
126
- }
120
+ return measured === 0
121
+ ? `${notMeasured}Les scripts et feuilles de style du build ne viennent pas d'un domaine distinct (assetPrefix).`
122
+ : 'Les scripts et feuilles de style du build ne viennent pas d\'un domaine distinct (assetPrefix), et les pages prérendues ne chargent aucune ressource tierce que prunelle ait vue.'
127
123
  }
124
+ if (assetOrigin !== undefined && externalPages.length === 0)
125
+ return `${notMeasured}Les scripts et feuilles de style sont servis depuis ${assetOrigin}, un autre domaine que celui des pages.`
128
126
  const externalNote = `des ressources statiques sont chargées depuis un autre domaine sur : ${externalPages.join(', ')}`
129
- return {
130
- verdict: 'Non validé',
131
- evidence: assetOrigin === undefined
132
- ? `${externalNote[0]!.toUpperCase()}${externalNote.slice(1)}.`
133
- : `Les scripts et feuilles de style sont servis depuis ${assetOrigin}, un autre domaine que celui des pages ; ${externalNote}.`,
134
- }
127
+ return assetOrigin === undefined
128
+ ? `${externalNote[0]!.toUpperCase()}${externalNote.slice(1)}.`
129
+ : `Les scripts et feuilles de style sont servis depuis ${assetOrigin}, un autre domaine que celui des pages ; ${externalNote}.`
130
+ }
131
+
132
+ function noJsEvidence(total: number, noJs: number): string {
133
+ if (total === 0)
134
+ return 'Aucune page n\'est prérendue : prunelle n\'a rien mesuré du JavaScript envoyé.'
135
+ if (noJs === total)
136
+ return 'Aucune page n\'envoie de JavaScript.'
137
+ return `${noJs} page${noJs <= 1 ? '' : 's'} sur ${total} n'${noJs <= 1 ? 'envoie' : 'envoient'} aucun JavaScript ; les autres ne chargent que le code de leurs composants interactifs.`
135
138
  }
136
139
 
137
- /** The RGESN 2024 criteria prunelle can judge, or measure in part, from the build, `prunelle check` and the config. */
140
+ /** What prunelle saw of the RGESN 2024 criteria it can read from the build, `prunelle check` and the config: a person writes each verdict. */
138
141
  export function evaluateEcoCriteria(facts: EcoFacts): EcoCriterion[] {
139
142
  const autoplay = filesWarnedFor(facts.warnings, 'rgesn/autoplay')
140
143
  const thirdParty = filesWarnedFor(facts.warnings, 'rgpd/third-party-url')
@@ -155,11 +158,11 @@ export function evaluateEcoCriteria(facts: EcoFacts): EcoCriterion[] {
155
158
  id: '4.1',
156
159
  label: 'Le service numérique comporte-t-il uniquement des animations, vidéos et sons dont la lecture automatique est désactivée ?',
157
160
  priority: 'Prioritaire',
158
- ...checkRuleVerdict(
161
+ evidence: lintEvidence(
159
162
  autoplay,
160
163
  ignored.has('rgesn/autoplay'),
161
164
  'rgesn/autoplay',
162
- 'Aucune vidéo ni aucun son du code source ne se lance seul (prunelle check, règle rgesn/autoplay).',
165
+ 'prunelle check ne signale aucune lecture automatique de vidéo ni de son (règle rgesn/autoplay).',
163
166
  'Une lecture automatique reste dans : ',
164
167
  'vérification manuelle de la lecture automatique',
165
168
  ),
@@ -168,11 +171,11 @@ export function evaluateEcoCriteria(facts: EcoFacts): EcoCriterion[] {
168
171
  id: '4.4',
169
172
  label: 'Le service numérique permet-il à l\'utilisateur de décider de l\'activation d\'un service tiers ?',
170
173
  priority: 'Recommandé',
171
- ...checkRuleVerdict(
174
+ evidence: lintEvidence(
172
175
  thirdParty,
173
176
  ignored.has('rgpd/third-party-url'),
174
177
  'rgpd/third-party-url',
175
- 'Aucune ressource tierce n\'est chargée avant le consentement du visiteur : chacune attend son accord (prunelle check, règle rgpd/third-party-url).',
178
+ 'prunelle check ne signale aucune ressource tierce chargée sans le consentement du visiteur (règle rgpd/third-party-url).',
176
179
  'Des ressources tierces se chargent sans consentement dans : ',
177
180
  'vérification manuelle des services tiers',
178
181
  ),
@@ -181,7 +184,6 @@ export function evaluateEcoCriteria(facts: EcoFacts): EcoCriterion[] {
181
184
  id: '6.1',
182
185
  label: 'Le service numérique s\'astreint-il à un poids maximum et une limite de requête par écran ?',
183
186
  priority: 'Recommandé',
184
- verdict: facts.firstLoadBudget === undefined ? 'Non validé' : undefined,
185
187
  evidence: facts.firstLoadBudget === undefined
186
188
  ? 'Aucun poids maximum par écran n\'est fixé.'
187
189
  : `Le premier chargement de chaque page est plafonné à ${frNumber.format(facts.firstLoadBudget / 1024)} Kio, vérifié à chaque build.${mostRequests} ${fill('limite de requêtes par écran')}.`,
@@ -190,7 +192,6 @@ export function evaluateEcoCriteria(facts: EcoFacts): EcoCriterion[] {
190
192
  id: '6.3',
191
193
  label: 'Le service numérique a-t-il mis en place des techniques de compression pour les ressources transférées dont il a le contrôle ?',
192
194
  priority: 'Modéré',
193
- verdict: facts.compress ? 'Validé' : 'Non validé',
194
195
  evidence: facts.compress
195
196
  ? 'Le JavaScript et les feuilles de style sont minifiés ; les fichiers sont précompressés en brotli et gzip au build, et les réponses dynamiques compressées à l\'envoi.'
196
197
  : `La compression du serveur est désactivée (compress: false) ; ${fill('compression assurée en amont, le cas échéant')}.`,
@@ -199,13 +200,13 @@ export function evaluateEcoCriteria(facts: EcoFacts): EcoCriterion[] {
199
200
  id: '6.5',
200
201
  label: 'Le service numérique évite-t-il de déclencher le chargement de ressources et de contenus inutilisés pour chaque fonctionnalité ?',
201
202
  priority: 'Recommandé',
202
- evidence: `${noJs === total ? 'Aucune page n\'envoie de JavaScript.' : `${noJs} page${noJs <= 1 ? '' : 's'} sur ${total} n'${noJs <= 1 ? 'envoie' : 'envoient'} aucun JavaScript ; les autres ne chargent que le code de leurs composants interactifs.`} ${fill('images, polices et données chargées sans être affichées')}.`,
203
+ evidence: `${noJsEvidence(total, noJs)} ${fill('images, polices et données chargées sans être affichées')}.`,
203
204
  },
204
205
  {
205
206
  id: '6.7',
206
207
  label: 'Le service numérique héberge-t-il toutes les ressources statiques transférées dont il est l\'émetteur sur un même domaine ?',
207
208
  priority: 'Modéré',
208
- ...sameDomainVerdict(assetOrigin, externalPages),
209
+ evidence: sameDomainEvidence(assetOrigin, externalPages, measured.length),
209
210
  },
210
211
  ]
211
212
  }
@@ -222,7 +223,7 @@ function measuresSection(report: BundleReport): string {
222
223
  return ` <p>${fill('mesures des pages représentatives : aucune page n\'est prérendue, prunelle n\'a rien mesuré')}</p>`
223
224
  return [
224
225
  ' <table>',
225
- ' <caption>EcoIndex de chaque page prérendue, mesuré par prunelle build, avec les gaz à effet de serre (gCO2e) et l\'eau (cl) d\'une visite</caption>',
226
+ ' <caption>Estimation statique de l\'EcoIndex de chaque page prérendue, calculée par prunelle build sur le HTML et les fichiers du build (et non sur une visite dans un navigateur), avec les gaz à effet de serre (gCO2e) et l\'eau (cl) d\'une visite</caption>',
226
227
  ' <thead>',
227
228
  ' <tr><th scope="col">Page</th><th scope="col">EcoIndex</th><th scope="col">Poids</th><th scope="col">Requêtes</th><th scope="col">GES</th><th scope="col">Eau</th></tr>',
228
229
  ' </thead>',
@@ -238,7 +239,7 @@ function criteriaSections(criteria: readonly EcoCriterion[]): string {
238
239
  ` <h3>${c.id}. ${escapeJsxText(c.label)}</h3>`,
239
240
  ' <dl>',
240
241
  ` <dt>Priorité</dt><dd>${c.priority}</dd>`,
241
- ` <dt>Évaluation</dt><dd>${escapeJsxText(c.verdict ?? fill('Validé, Non validé ou Non applicable'))}</dd>`,
242
+ ` <dt>Évaluation</dt><dd>${escapeJsxText(fill('Validé, Non validé ou Non applicable'))}</dd>`,
242
243
  ` <dt>Justification</dt><dd>${escapeJsxText(c.evidence)}</dd>`,
243
244
  ' </dl>',
244
245
  ].join('\n')).join('\n')
@@ -262,7 +263,7 @@ export function draftEcoDeclaration(options: EcoDeclarationOptions): EcoDeclarat
262
263
  const wrapper = layoutRendersMain(root, dest) ? 'article' : 'main'
263
264
 
264
265
  const content = `// Brouillon de déclaration d'écoconception RGESN 2024 généré par \`prunelle eco --declaration\`.
265
- // prunelle évalue les critères qu'il mesure ; les autres, et chaque mention entre crochets, sont à compléter avant publication : \`prunelle check\` signale celles qui restent.
266
+ // prunelle indique ce qu'il a constaté pour chaque critère ; l'évaluation de chacun, et chaque mention entre crochets, sont à compléter avant publication : \`prunelle check\` signale celles qui restent.
266
267
 
267
268
  import { Head } from 'prunelle'
268
269
 
@@ -321,6 +322,8 @@ ${criteriaSections(criteria)}
321
322
  `
322
323
 
323
324
  if (options.write !== false) {
325
+ if (existsSync(dest) && options.force !== true)
326
+ throw new Error(`prunelle: ${relativePath} already exists: pass --force to overwrite it.`)
324
327
  mkdirSync(dirname(dest), { recursive: true })
325
328
  writeFileSync(dest, content)
326
329
  }
package/src/eco/index.ts CHANGED
@@ -7,12 +7,14 @@ import { loadConfig } from '../plugins/load'
7
7
  import { draftEcoDeclaration, evaluateEcoCriteria } from './declaration'
8
8
 
9
9
  export { DEFAULT_ECO_DECLARATION_PATH, draftEcoDeclaration, evaluateEcoCriteria } from './declaration'
10
- export type { EcoCriterion, EcoDeclarationOptions, EcoDeclarationResult, EcoFacts, EcoVerdict } from './declaration'
10
+ export type { EcoCriterion, EcoDeclarationOptions, EcoDeclarationResult, EcoFacts } from './declaration'
11
11
 
12
12
  export interface EcoRunOptions {
13
13
  root: string
14
14
  /** Write the declaration page, at this path (`''` for `<routesDir>/ecoconception.tsx`). */
15
15
  declaration?: string | undefined
16
+ /** Overwrite a declaration already there. */
17
+ force?: boolean | undefined
16
18
  service?: string | undefined
17
19
  organization?: string | undefined
18
20
  contactEmail?: string | undefined
@@ -51,6 +53,7 @@ export async function runEco(options: EcoRunOptions): Promise<EcoRunResult> {
51
53
  outPath: options.declaration === '' ? undefined : options.declaration,
52
54
  routesDir: facts.routesDir,
53
55
  facts,
56
+ force: options.force,
54
57
  service: options.service,
55
58
  organization: options.organization,
56
59
  contactEmail: options.contactEmail,
@@ -59,11 +62,11 @@ export async function runEco(options: EcoRunOptions): Promise<EcoRunResult> {
59
62
  }
60
63
 
61
64
  export function formatEcoResult(result: EcoRunResult): string {
62
- const lines = ['prunelle eco: the RGESN 2024 criteria prunelle can judge from the build, prunelle check and the config']
65
+ const lines = ['prunelle eco: what prunelle saw of the RGESN 2024 criteria it can read from the build, prunelle check and the config']
63
66
  for (const c of result.criteria)
64
- lines.push(` ${c.id.padEnd(4)} ${(c.verdict ?? 'to judge').padEnd(10)} ${c.evidence}`)
67
+ lines.push(` ${c.id.padEnd(4)} ${c.evidence}`)
65
68
  lines.push(result.declaration === undefined
66
- ? 'The other criteria are for a person to judge: prunelle eco --declaration drafts the page that holds them all.'
67
- : `prunelle eco: drafted the RGESN 2024 eco-design declaration at ${result.declaration.relativePath}: fill in each [à compléter ...] before publishing it.`)
69
+ ? 'The verdicts are for a person to write: prunelle eco --declaration drafts the page that holds them all.'
70
+ : `prunelle eco: drafted the RGESN 2024 eco-design declaration at ${result.declaration.relativePath}: write each verdict and fill in each [à compléter ...] before publishing it.`)
68
71
  return lines.join('\n')
69
72
  }
package/src/href.ts ADDED
@@ -0,0 +1,31 @@
1
+ // `href('/posts/[slug]', { slug })`: the path of a route, built from its pattern; a pattern no route file serves fails to typecheck once prunelle has written `prunelle-routes.d.ts`.
2
+
3
+ import type { ExtractRouteParams, RoutePattern } from './server/http'
4
+
5
+ type HrefParams<P extends string> = { [K in keyof ExtractRouteParams<P>]: ExtractRouteParams<P>[K] | number }
6
+
7
+ const OPTIONAL_SEG_RE = /^\[\[([^\]=]+)(?:=[^\]]+)?\]\]$/
8
+ const REST_SEG_RE = /^\[\.\.\.([^\]=]+)(?:=[^\]]+)?\]$/
9
+ const PARAM_RE = /\[([^\]=]+)(?:=[^\]]+)?\]/g
10
+
11
+ export function href<P extends RoutePattern>(pattern: P, ...[params]: {} extends ExtractRouteParams<P> ? [params?: HrefParams<P>] : [params: HrefParams<P>]): string {
12
+ const values = (params ?? {}) as Record<string, string | number | undefined>
13
+ const value = (name: string): string => {
14
+ const given = values[name]
15
+ if (given === undefined || given === '')
16
+ throw new Error(`prunelle: href("${pattern}") needs \`${name}\` in its params: pass it, or link to a route without it.`)
17
+ return String(given)
18
+ }
19
+ const parts: string[] = []
20
+ for (const segment of pattern.split('/')) {
21
+ const optional = OPTIONAL_SEG_RE.exec(segment)
22
+ const rest = REST_SEG_RE.exec(segment)
23
+ if (optional !== null)
24
+ parts.push(values[optional[1]!] === undefined ? '' : encodeURIComponent(String(values[optional[1]!])))
25
+ else if (rest !== null)
26
+ parts.push(value(rest[1]!).split('/').map(encodeURIComponent).join('/'))
27
+ else
28
+ parts.push(segment.replace(PARAM_RE, (_, name: string) => encodeURIComponent(value(name))))
29
+ }
30
+ return `/${parts.filter(part => part !== '').join('/')}`
31
+ }
package/src/index.ts CHANGED
@@ -1,5 +1,5 @@
1
- export { Catch, ConsentBanner, ConsentGate, ConsentPreferences, createContext, Head, provideContext, Region, Suspense, useContext, useId } from './context'
2
- export type { CatchProps, ConsentBannerProps, ConsentGateProps, ConsentTexts, Context, RegionProps } from './context'
1
+ export { Catch, ConsentBanner, ConsentGate, ConsentPreferences, CookieTable, createContext, Head, provideContext, Region, Suspense, useContext, useId } from './context'
2
+ export type { CatchProps, ConsentBannerProps, ConsentGateProps, ConsentTexts, Context, CookieTableProps, RegionProps } from './context'
3
3
  export {
4
4
  batch,
5
5
  computed,
@@ -8,15 +8,22 @@ export {
8
8
  onCleanup,
9
9
  onMount,
10
10
  root,
11
+ runWithOwner,
11
12
  signal,
12
13
  untrack,
13
14
  } from './reactivity/index'
14
- export type { Owner, ReadonlySignal, Signal } from './reactivity/index'
15
+ export type { Owner, ReadonlySignal, Signal, SignalOptions } from './reactivity/index'
16
+ export { resource } from './reactivity/resource'
17
+ export type { Resource, ResourceOptions, ResourceRun } from './reactivity/resource'
15
18
  export { selector } from './reactivity/selector'
16
19
  export type { Selector } from './reactivity/selector'
17
- export { snapshot, store } from './reactivity/store'
20
+ export { reconcile, snapshot, store } from './reactivity/store'
21
+ export { animate } from './animate'
22
+ export type { AnimateEffect, AnimateOptions } from './animate'
18
23
  export { useAction } from './dom/action'
19
24
  export type { ActionForm, ClientAction, UseActionOptions } from './dom/action'
25
+ export { refreshRegion } from './dom/regions'
20
26
  export type { Component, Html, HydrateStrategy, PrunelleChild } from './jsx-runtime'
21
- export type { ExtractRouteParams, PrunelleLocals, LayoutProps, LoaderData, LoaderFn, NotFoundResult, PageProps, RequestConsent, RouteContext } from './server/index'
27
+ export { href } from './href'
28
+ export type { ExtractRouteParams, PrunelleLocals, LayoutProps, LoaderData, LoaderFn, NotFoundResult, PageProps, RequestConsent, RouteContext, RoutePattern } from './server/index'
22
29
 
@@ -7,7 +7,7 @@ export function defineConfig(config: PrunelleConfig): PrunelleConfig {
7
7
  }
8
8
 
9
9
  // Typed as records so that a key added to the config types without being listed here fails the typecheck.
10
- const RUNTIME_KEYS: Record<keyof ServerRuntimeConfig, true> = { site: true, lang: true, assetPrefix: true, security: true, trustedOrigins: true, trustProxy: true, maxRequestBodySize: true, navigation: true, streamTimeout: true, consent: true, compress: true, routeCache: true, healthCheck: true, onError: true, plugins: true }
10
+ const RUNTIME_KEYS: Record<keyof ServerRuntimeConfig, true> = { site: true, lang: true, assetPrefix: true, security: true, trustedOrigins: true, cors: true, trustProxy: true, maxRequestBodySize: true, navigation: true, streamTimeout: true, consent: true, compress: true, routeCache: true, store: true, healthCheck: true, onError: true, log: true, plugins: true }
11
11
  const BUILD_KEYS: Record<Exclude<keyof PrunelleConfig, keyof ServerRuntimeConfig>, true> = { port: true, routesDir: true, outDir: true, publicDir: true, compliance: true, autoPrerender: true, budget: true }
12
12
  const BUILD_KEY_SET = new Set<string>(Object.keys(BUILD_KEYS))
13
13
  const RUNTIME_CONFIG_KEYS = Object.keys(RUNTIME_KEYS) as (keyof ServerRuntimeConfig)[]