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.
- package/llms.txt +68 -51
- package/package.json +7 -2
- package/src/a11y/declaration.ts +10 -17
- package/src/a11y/index.ts +69 -125
- package/src/animate.ts +127 -0
- package/src/build/asides.ts +51 -0
- package/src/build/bundle.ts +94 -136
- package/src/build/client-entries.ts +6 -6
- package/src/build/client-outputs.ts +75 -0
- package/src/build/client-plugin.ts +9 -4
- package/src/build/ecoindex.ts +4 -2
- package/src/build/files.ts +18 -0
- package/src/build/graph.ts +14 -6
- package/src/build/index.ts +23 -11
- package/src/build/island-promote.ts +42 -2
- package/src/build/islands.ts +63 -9
- package/src/build/key-types.ts +31 -0
- package/src/build/manifest.ts +117 -1
- package/src/build/plugin-host.ts +13 -1
- package/src/build/prerender.ts +8 -3
- package/src/build/reach.ts +18 -4
- package/src/build/report.ts +1 -1
- package/src/build/resolve.ts +5 -1
- package/src/build/route-types.ts +16 -0
- package/src/build/routes.ts +42 -15
- package/src/build/seed-ids.ts +65 -0
- package/src/build/seed-writes.ts +111 -0
- package/src/build/static-headers.ts +2 -2
- package/src/build/static.ts +1 -1
- package/src/cli/check-cache.ts +51 -0
- package/src/cli/check-consent.ts +95 -0
- package/src/cli/check-forms.ts +10 -2
- package/src/cli/check-links-patterns.ts +101 -0
- package/src/cli/check-links.ts +30 -105
- package/src/cli/check-regions.ts +185 -0
- package/src/cli/check-security.ts +50 -6
- package/src/cli/check.ts +49 -21
- package/src/cli/commands.ts +138 -16
- package/src/cli/docs.ts +21 -2
- package/src/cli/form-opaque-children.ts +40 -0
- package/src/cli/index.ts +1 -1
- package/src/cli/inspect.ts +2 -0
- package/src/cli/mcp-tools.ts +2 -2
- package/src/cli/new.ts +9 -5
- package/src/cli/upgrade-names.ts +14 -2
- package/src/cli/upgrade.ts +3 -0
- package/src/compiler/analyze.ts +22 -16
- package/src/compiler/cacheability-private.ts +13 -3
- package/src/compiler/cacheability.ts +24 -2
- package/src/compiler/compliance-contrast.ts +322 -0
- package/src/compiler/compliance-empty.ts +24 -0
- package/src/compiler/compliance-rgaa-content.ts +95 -0
- package/src/compiler/compliance-rgaa-criteria.ts +45 -0
- package/src/compiler/compliance-rgaa-pages.ts +140 -0
- package/src/compiler/compliance-rgaa.ts +19 -0
- package/src/compiler/compliance-rules.ts +72 -0
- package/src/compiler/compliance-third-party.ts +59 -0
- package/src/compiler/compliance-urls.ts +52 -0
- package/src/compiler/compliance.ts +61 -93
- package/src/compiler/cookie-inventory.ts +119 -0
- package/src/compiler/dom-attrs.ts +178 -22
- package/src/compiler/dom.ts +31 -44
- package/src/compiler/emit.ts +17 -6
- package/src/compiler/expr-context.ts +260 -207
- package/src/compiler/foreign-imports.ts +5 -3
- package/src/compiler/mistakes.ts +18 -9
- package/src/compiler/props-body.ts +263 -21
- package/src/compiler/props-pattern.ts +211 -0
- package/src/compiler/props.ts +324 -343
- package/src/compiler/signal-reads.ts +142 -29
- package/src/compiler/spread-handlers.ts +25 -13
- package/src/compiler/ssr-emit.ts +510 -0
- package/src/compiler/ssr-helpers.ts +165 -121
- package/src/compiler/ssr.ts +28 -441
- package/src/context.ts +14 -1
- package/src/dev/child.ts +1 -1
- package/src/dev/host-check.ts +2 -1
- package/src/dev/hot-islands.ts +71 -0
- package/src/dev/index.ts +31 -18
- package/src/dev/protocol.ts +1 -1
- package/src/dev/queue.ts +3 -2
- package/src/dev/reload.ts +5 -2
- package/src/dev/supervisor.ts +3 -1
- package/src/dev/watchers.ts +6 -2
- package/src/dom/action.ts +97 -14
- package/src/dom/attrs.ts +93 -25
- package/src/dom/extras.ts +91 -50
- package/src/dom/field-marks.ts +32 -0
- package/src/dom/hot.ts +9 -0
- package/src/dom/index.ts +44 -18
- package/src/dom/island-hot.ts +29 -0
- package/src/dom/island.ts +13 -2
- package/src/dom/loop.ts +259 -188
- package/src/dom/prefetch.ts +135 -0
- package/src/dom/regions.ts +515 -0
- package/src/dom/swap.ts +246 -0
- package/src/dom/trusted.ts +22 -0
- package/src/dom/upload.ts +44 -0
- package/src/eco/declaration.ts +44 -41
- package/src/eco/index.ts +8 -5
- package/src/href.ts +31 -0
- package/src/index.ts +12 -5
- package/src/plugins/config.ts +1 -1
- package/src/plugins/context.ts +7 -1
- package/src/plugins/daily.ts +27 -0
- package/src/plugins/index.ts +3 -3
- package/src/plugins/order.ts +1 -1
- package/src/plugins/public.ts +12 -5
- package/src/plugins/services.ts +88 -14
- package/src/plugins/types.ts +128 -10
- package/src/reactivity/graph.ts +244 -41
- package/src/reactivity/hmr.ts +101 -0
- package/src/reactivity/index.ts +243 -239
- package/src/reactivity/resource.ts +129 -0
- package/src/reactivity/seed.ts +141 -0
- package/src/reactivity/selector.ts +85 -47
- package/src/reactivity/server-seed.ts +202 -0
- package/src/reactivity/store.ts +331 -97
- package/src/rgpd/draft.ts +171 -0
- package/src/rgpd/forms.ts +85 -0
- package/src/rgpd/index.ts +57 -0
- package/src/server/action-flash.ts +1 -0
- package/src/server/action-protect.ts +3 -0
- package/src/server/action-registry.ts +11 -9
- package/src/server/action.ts +51 -19
- package/src/server/app-secret.ts +14 -8
- package/src/server/cache-invalidation.ts +97 -0
- package/src/server/compress.ts +55 -18
- package/src/server/consent.ts +21 -5
- package/src/server/cookie-inventory.ts +78 -0
- package/src/server/cookies.ts +77 -8
- package/src/server/cors.ts +98 -0
- package/src/server/csp-report.ts +90 -0
- package/src/server/discard.ts +13 -0
- package/src/server/document.ts +2 -2
- package/src/server/env.ts +1 -1
- package/src/server/errors.ts +9 -2
- package/src/server/field-errors.ts +91 -0
- package/src/server/form-schema.ts +16 -11
- package/src/server/health.ts +41 -11
- package/src/server/http.ts +28 -11
- package/src/server/index.ts +122 -307
- package/src/server/loader.ts +2 -0
- package/src/server/page.ts +3 -9
- package/src/server/plugin-host.ts +66 -16
- package/src/server/plugin-route-shadow.ts +24 -0
- package/src/server/public.ts +14 -3
- package/src/server/rate-limit.ts +49 -10
- package/src/server/region.ts +22 -2
- package/src/server/request-handler.ts +406 -0
- package/src/server/request-log.ts +94 -0
- package/src/server/route-cache.ts +55 -8
- package/src/server/route-input.ts +54 -0
- package/src/server/route-table.ts +53 -27
- package/src/server/router.ts +2 -1
- package/src/server/routing.ts +104 -45
- package/src/server/sanitize-html.ts +4 -2
- package/src/server/security.ts +38 -8
- package/src/server/serve-handlers.ts +16 -6
- package/src/server/served-file.ts +19 -14
- package/src/server/shared-store.ts +323 -0
- package/src/server/start.ts +12 -5
- package/src/server/static-dir.ts +34 -12
- package/src/server/stream.ts +2 -1
- package/src/server/surface.ts +39 -0
- package/src/server/webhook.ts +50 -0
- package/src/server/workers.ts +168 -0
- package/src/ssr/consent-banner.ts +20 -16
- package/src/ssr/consent-texts.ts +40 -0
- package/src/ssr/context.ts +174 -53
- package/src/ssr/cookie-table.ts +75 -0
- package/src/ssr/index.ts +63 -58
- package/src/ssr/navigation.ts +161 -14
- package/src/ssr/region.ts +9 -3
- package/src/style.ts +12 -5
- package/src/test/browser.ts +53 -23
- package/src/test/build-reuse.ts +85 -0
- package/src/test/index.ts +51 -8
- package/src/test/mount.ts +53 -0
- package/src/test/outside.ts +94 -0
- package/src/ts-plugin/diagnostics.ts +56 -18
- package/templates/_shared/AGENTS.md +1 -1
- package/templates/_shared/Dockerfile +22 -0
- package/templates/_shared/dockerignore +9 -0
- package/templates/_shared/gitignore +2 -0
- package/templates/app/.env.example +3 -1
- package/templates/app/compose.yaml +32 -0
- package/templates/app/db/migrations/001_notes.sql +7 -0
- package/templates/app/db/schema.ts +11 -0
- package/templates/app/package.json +1 -0
- package/templates/app/prunelle.config.ts +6 -0
- package/templates/app/src/actions/notes.ts +26 -0
- package/templates/app/src/auth.ts +4 -2
- package/templates/app/src/db.ts +5 -0
- package/templates/app/src/routes/dashboard/index.tsx +26 -1
- package/templates/app/src/routes/privacy.tsx +6 -2
- package/templates/app/tests/app.test.ts +14 -3
- package/templates/plugin/AGENTS.md +11 -0
- package/templates/plugin/CLAUDE.md +1 -0
- package/templates/plugin/README.md +27 -0
- package/templates/plugin/gitignore +2 -0
- package/templates/plugin/llms.txt +19 -0
- package/templates/plugin/package.json +33 -0
- package/templates/plugin/src/index.ts +40 -0
- package/templates/plugin/tests/fixture/prunelle.config.ts +4 -0
- package/templates/plugin/tests/fixture/src/routes/index.tsx +11 -0
- package/templates/plugin/tests/plugin.test.ts +42 -0
- package/templates/plugin/tsconfig.json +19 -0
- package/ts-plugin.cjs +4058 -2246
package/llms.txt
CHANGED
|
@@ -5,24 +5,26 @@
|
|
|
5
5
|
## Core Rules
|
|
6
6
|
|
|
7
7
|
- **Imports**:
|
|
8
|
-
- `prunelle`: signals, `Head`, `Suspense`, `Catch`, `Region`, `ConsentGate`, `ConsentBanner`, `ConsentPreferences`, `createContext`, `provideContext`, `useContext`, `useId`, `useAction`.
|
|
8
|
+
- `prunelle`: signals, `Head`, `Suspense`, `Catch`, `Region`, `ConsentGate`, `ConsentBanner`, `ConsentPreferences`, `CookieTable`, `createContext`, `provideContext`, `useContext`, `useId`, `useAction`.
|
|
9
9
|
- `prunelle/server`: `action`, `getActionError`, `notFound`, route types, `DEFAULT_CSP`, `extendCsp`, and the Server helpers below.
|
|
10
|
-
- `prunelle/config`: `defineConfig`, `definePlugin`, `serviceKey`, `I18N_CONFIG_SERVICE`, `CONTENT_IMAGE_RESOLVER_SERVICE`, `CONTENT_COLLECTIONS_SERVICE`, `JOBS_SERVICE`, `WEB_MANIFEST_SERVICE`, `isInside(dir, target, { orSame })`, `firstLoadUrls`, `distLocator`, `measureFirstLoad`, `brotliSize`, `minifyCss`, `
|
|
10
|
+
- `prunelle/config`: `defineConfig`, `definePlugin`, `serviceKey`, `I18N_CONFIG_SERVICE`, `UI_LAYER_SERVICE`, `CONTENT_IMAGE_RESOLVER_SERVICE`, `CONTENT_COLLECTIONS_SERVICE`, `JOBS_SERVICE` (`schedule?(name, cron, handler)` runs a plugin's task on the app's jobs schedule), `scheduleDaily(api, name, cron, chore, failure)` (on jobs when the app has it, else in each process a minute after start, never in `prunelle check`, then daily), `USER_DATA_SERVICE` (`{ exportUser(userId), deleteUser(userId) }`: auth adds the export under `data` and calls the deletion before deleting the account) and `registerUserDataService(api, service)` (registers a provider without overwriting other plugins' providers), `WEB_MANIFEST_SERVICE`, `PUBLIC_FILES_SERVICE` (`{ find(path) }`: a public upload by the path it is served at, from `@prunellejs/files` for `@prunellejs/images`), `isInside(dir, target, { orSame })`, `firstLoadUrls`, `distLocator`, `measureFirstLoad`, `brotliSize`, `minifyCss`, `writeKeyTypes`, `auditAccessibility`, `draftAccessibilityStatement`, `formatA11yReport`, `rgaaCriteriaForAxeRule`, plugin types.
|
|
11
11
|
- `prunelle/build` (programmatic `build`, `createBuildCache`, `analyzeBundleWeights`, `computeEcoIndex`), `prunelle/test` (`testApp`, `testBrowser`), `prunelle/ts-plugin` (TS language-service plugin).
|
|
12
12
|
- An `@kayjs/*` import, prunelle's name when it was kay v2, fails the compile (`prunelle upgrade` rewrites them); `prunelle/internal/*` is compiler output, outside semver.
|
|
13
13
|
- **Standard TSX & compiler guardrails**: `.tsx` files with `jsxImportSource: "prunelle"`. The compiler and runtime refuse React/Solid/Astro habits.
|
|
14
14
|
- Works natively: `class` or `className` (never both), `.map()` with `key={...}`, `&&`, ternaries, `{...spread}`, SVG elements, style strings or objects (`style={{ color: 'red' }}`; an object drops a value that would end its declaration, and `NaN`), CSS and `*.module.css` imports.
|
|
15
15
|
- `innerHTML={html}` takes a string or `raw(html)`: never `{ __html }`, never `dangerouslySetInnerHTML`, never on void elements or with children.
|
|
16
16
|
- Events are camelCase DOM names (`onClick`, `onDblClick`, `onKeyDown`), never lowercase `onclick`, `on:click`, `onDoubleClick`, `*Capture`, string handlers or render-time assignments. `onChange` on a text `<input>`/`<textarea>` fires on blur and warns to use `onInput` for every keystroke; `onFocus`/`onBlur` do not bubble, use `onFocusIn`/`onFocusOut`.
|
|
17
|
+
- `ref={animate('slide')}` (`animate` from `prunelle`; effects `'fade'` (default), `'slide'`, `'scale'`, `'collapse'`, keyframes or `(el) => keyframes`; `{ duration?: 200, easing? }`) animates an element in when an island adds it after hydration (not the first render of a client-only island) and holds it, `inert`, until its animation ends (the duration plus 100 ms at most; none in a hidden tab) when a conditional or a keyed list row removes it (the element carrying the ref is the one removed). `prefers-reduced-motion: reduce` makes it appear and go at once. It costs 0 B on pages that do not import it; a page that does ships about 1.03 KB gzip more (bench-probes `/animate`: 8552 B against 7497 B for `/list`, the same list without the ref).
|
|
17
18
|
- `ref` is always a callback `ref={el => ...}`, never `{ current }`. SVG attributes are kebab-case (`stroke-width`, `fill-opacity`). Entities in string attrs and props decode like text (`title="a & b"` is `a & b`; an `innerHTML` string stays as written). Use `value`/`checked` (not `defaultValue`/`defaultChecked`) and boolean `{false}` (not `"false"`).
|
|
18
|
-
- Refused: `client:*`/`use:*`/`class:list`/`set:html` directives, a hook or signal imported from `react`, `preact`, `solid-js`, `vue` or `svelte` (the fix names the prunelle form), an import that resolves to nothing (`prunelle check`), `<slot>` (take `children`), a leading `---` frontmatter block, `'use client'`/`'use server'`,
|
|
19
|
-
- Literal `javascript:`/`vbscript:`/non-image `data:` URLs warn and are stripped;
|
|
19
|
+
- Refused: `client:*`/`use:*`/`class:list`/`set:html` directives, a hook or signal imported from `react`, `preact`, `solid-js`, `vue` or `svelte` (the fix names the prunelle form), an import that resolves to nothing (`prunelle check`), `<slot>` (take `children`), a leading `---` frontmatter block, `'use client'`/`'use server'`, Promises, functions, signals or plain objects in JSX text/attrs, and route exports other frameworks read (`getStaticProps`, `getStaticPaths`, `generateStaticParams`, `metadata`, `revalidate`, a lowercase `get`), each naming the prunelle export. The error for an Astro or Next habit ends with its guide, `docs/getting-started/coming-from-astro` or `coming-from-next`, which maps that framework's concepts to prunelle's.
|
|
20
|
+
- Literal `javascript:`/`vbscript:`/non-image `data:` URLs warn and are stripped; a spread rendered on the server drops every `on*` attribute, and a spread in an island binds an `on*` prop only when it is a function (a string `on*` is dropped); both drop `innerHTML`, `srcdoc` and `javascript:`/`vbscript:` URLs, and `dangerouslySetInnerHTML` in a spread throws.
|
|
20
21
|
- **Signals, Context & IDs (`prunelle`)**:
|
|
21
|
-
- `const count = signal(0)` (`.value` read/write, `.peek()` untracked), `computed(() =>
|
|
22
|
-
-
|
|
23
|
-
-
|
|
22
|
+
- `const count = signal(0, { equals? })` (`.value` read/write, `.peek()` untracked), `computed(() => ..., { equals? })`, `effect(() => ...)` (return cleanup, never `async`; skipped while an island renders on the server, so derive values with `computed`), `batch(() => ...)`, `untrack(() => ...)`, `root(dispose => ...)`, `onMount(() => ...)` (runs after DOM attach; return cleanup), `onCleanup(() => ...)`, `getOwner()` (`Owner | undefined`) + `runWithOwner(owner, fn)`, `selector(() => id.value, fn?)` (O(1) selection, or custom matcher `fn(key, value)`), `store(obj)` + `snapshot(s)` + `reconcile(target, next)` (structurally diffs plain objects/arrays into a store inside `batch()`).
|
|
23
|
+
- `const posts = resource(() => page.value, (page, { signal }) => fetch(`/api/posts?page=${page}`, { signal }).then(r => r.json()), { initial? })` loads async data in an island: `posts.value` (the last value, kept while the next run loads or fails), `posts.loading.value`, `posts.error.value` (an `Error`, cleared when a new fetch starts or the source is `undefined`), `posts.refetch()`, `posts.mutate(next)` (writes directly to `posts.value` and participates in `useAction({ optimistic })` rollback/rebase). It re-runs when the source changes, aborting the run it replaces and discarding its late answer; a source of `undefined` waits. An action as the fetcher (`resource(() => ({ page: page.value }), listPosts)`) gives its typed `data` to `value` and its failure to `error`. `resource(({ signal }) => ...)` alone runs once, tracking nothing it reads. It never fetches on the server: the island renders `loading`, or `initial` (from `load()`), which the browser keeps until the source changes. 0 B on pages that do not use it.
|
|
24
|
+
- A local signal, computed, `resource`, or signal-valued hook field (`resource.loading`/`error`, `useAction` `pending`/`error`/`fieldErrors`/`data`/`progress`, `useLive` `status`/`last`/`error`) read without `.value` in JSX, an `if`/ternary/loop test or `!`, and `const { value } = count`, fail compile. Destructuring a `store()`, snapshotting `const x = sig.value` at a component's top level and rendering `{x}` in JSX, and mutating a destructured prop warn in browser-reachable components. To let a child mutate parent state, pass the signal itself (`<Modal open={isOpen} />`).
|
|
25
|
+
- Context: `const Ctx = createContext(defaultValue)`, `<Ctx.Provider value={v}>` or `provideContext(Ctx, v, fn)`, `useContext(Ctx)`. `useId(prefix = 'k')` gives deterministic hydration-safe IDs, scoped per island or SSR request (a region answer adds its own prefix, so ids stay unique after a swap or an append).
|
|
24
26
|
- **Reactive props**: Destructuring props (`function Badge({ count = 0, ...rest }: Props)`) stays reactive in client components (in the parameter list only: `const { a } = props` in the body reads once, and a browser component doing it is warned), and a default beyond a literal or a name (`items = []`, `id = useId()`) runs once per call; server-rendered children inside islands are preserved via `<pru-slot>`.
|
|
25
|
-
- **Automatic islands**: a component using reactive primitives (`signal`, `computed`, `effect`, `onMount`, `store`, `selector`), DOM `on*` handlers/`ref`, or imported reactive module state becomes an island, decided per component.
|
|
27
|
+
- **Automatic islands**: a component using reactive primitives (`signal`, `computed`, `effect`, `onMount`, `onCleanup`, `store`, `selector`, `useAction`, `resource`), DOM `on*` handlers/`ref`, or imported reactive module state becomes an island, decided per component. Islands importing the same module share its signals, stores and resources, whatever their `$hydrate` modes; the module gives the first value. To start it from the request (a cart count from `load()`), pass it as a prop and write it while the island renders (`items.value = count`): on the server the write lands in a per-request copy that the islands after it read, the page carries the paths it wrote in an `s` attribute on that island, and the browser sets them on the module's `const x = signal(…)` or `store(…)` when that module first runs, before any island hydrates, and re-applies them when `@prunellejs/spa` or `<Region>` swaps new islands into the page (JSON values only, a BigInt, cycle, Date or `__proto__` key throws naming the signal; the page carries nothing when no island writes, and the build ships the helper only in an app where a module writes imported state outside an event handler, `onMount` or `effect`). An island writing a signal made elsewhere (in `load()` or a function) while it renders on the server throws.
|
|
26
28
|
- A static export beside an island stays static. A component that needs the browser is an island of its own wherever server code renders it as a tag, same file included: the page around it stays static, and its chunk keeps only the code of the file it reaches, so an async page importing server code can render a local widget.
|
|
27
29
|
- A same-file helper that needs the browser makes each component calling it an island; a primitive called at a file's top level makes every component of the file one.
|
|
28
30
|
- `<Head>`/`<Suspense>` in an island fail compile (`<Catch>` works in both). An island reading a context provided outside it throws in SSR: pass the value as a prop. Server children handed to an island render before it, in the page's scope.
|
|
@@ -37,106 +39,121 @@
|
|
|
37
39
|
- **Routes (`src/routes/`)**:
|
|
38
40
|
- `export default async function Page({ params, locals, url })`: strictly server-only (`0 KB` JS; cannot use signals/handlers directly).
|
|
39
41
|
- Sync `export default function Page({ data, params, locals, url }: PageProps<typeof load>)`: static or auto-island; optional `export async function load(ctx)` runs server-only and returns data, `notFound()` (from `prunelle/server`; return or throw it to render `_404.tsx` with HTTP `404`), or a `Response` (e.g. redirect).
|
|
42
|
+
- Route patterns are types: `prunelle dev`, `build` and `check` write `src/prunelle-routes.d.ts` (an app with a `tsconfig.json`; gitignored in the templates, `check` writes it before typechecking), so `RouteContext<'/posts/[slug]'>`, `PageProps<'/posts/[slug]'>` and `href(pattern, params)` (from `prunelle`: `href('/posts/[slug]', { slug })` encodes each param, drops an absent `[[optional]]` segment) refuse a pattern no route file serves. `ctx.redirect()` and `href` attributes still take any string; `prunelle check` reports a literal no route serves as `[link/broken]`.
|
|
40
43
|
- Special files: `_layout.tsx` (nested outer→inner, receives `{ children, params, locals, url }`, server-only), `_middleware.ts` (`(ctx, next) => Response`, outer→inner), `_error.tsx` (receives `{ error }`, server-only), `_404.tsx` (server-only; also emitted as `404.html`, and as `<folder>/404.html` for static non-group folders in `--static`), and status pages `_401.tsx`, `_403.tsx`, `_429.tsx`, `_503.tsx` (receive `{ status, message, url, params, locals }`). Each needs a default export; an unsupported `_NNN.tsx` (e.g. `_418.tsx`) fails `prunelle check` and `prunelle build`.
|
|
41
44
|
- `_404.tsx`, `_error.tsx` and status pages may live in any subfolder (including `(group)/`) and win over the root one for routes under it, wrapped in that folder's layouts. `ctx.deny(status, message, fieldErrors?)` renders the nearest status page (else the nearest `_error.tsx`, else clean HTML) when the request accepts HTML (`Accept: text/html`), and JSON otherwise (actions keep JSON for JS and flash + 303 for zero-JS forms).
|
|
42
45
|
- Any other file under `src/routes/` must export a page, a method handler or an action (guarded by its folder's `_middleware.ts`), else `prunelle build`/`prunelle check` fail: prefix helpers or their folder with `_`.
|
|
43
|
-
- Params, groups & optionals: `(name)/` groups routes under its `_layout.tsx` and `_middleware.ts` without adding a URL segment; `[[lang]]/about.tsx` matches `/about` and `/fr/about` (`params.lang` typed `string | undefined`); `[slug].tsx` → `params.slug`; `[...path].tsx` → `params.path` (segments joined by `/`).
|
|
46
|
+
- Params, groups & optionals: `(name)/` groups routes under its `_layout.tsx` and `_middleware.ts` without adding a URL segment; `[[lang]]/about.tsx` matches `/about` and `/fr/about` (`params.lang` typed `string | undefined`); `[slug].tsx` → `params.slug`; `[...path].tsx` → `params.path` (segments joined by `/`). A whole file or folder name is one of these forms: `pre-[id].tsx` (text beside a parameter) and `[[...rest]].tsx` (optional catch-all) fail `prunelle build` and `prunelle check`; use `[id].tsx`, or `[...rest].tsx` plus an `index.tsx`.
|
|
44
47
|
- Matchers: `[id=integer].tsx` and `[...path=slug].tsx` match only accepted values and fall through on mismatch (built-ins: `integer` → `` `${number}` ``, `uuid` → `` `${string}-${string}-${string}-${string}-${string}` ``, `slug` → `string`; custom matchers live in `src/params/<name>.ts` exporting `match` or `default`). Unknown matchers or conflicting route patterns fail build and check naming both files; precedence is `static > matched param > param > optional > catch-all`.
|
|
45
48
|
- Params arrive percent-decoded; a segment holding an encoded `/`, `\` or NUL, or a `.`/`..` segment, matches no dynamic route (404) unless a plugin catch-all route sets `encodedSlashes`, so a param is safe to join into a path. Static pages, `public/` files and `prunelle start` serving a `--static` export decode by the same rule (`/a%2fb.txt` never serves `a/b.txt`).
|
|
46
|
-
- API routes: `.ts` files exporting standard `HTTP_METHOD_EXPORTS` (`GET`, `HEAD`, `POST`, `PUT`, `PATCH`, `DELETE`, `OPTIONS`) receiving `RequestContext` (`request`, `url`, `params`, `cookies`, `locals`, `ip`, `requestId`, `region`, `json()`, `text()`, `redirect(location, status?, { external? })`, `deny()`). `redirect()` stays on this site: a target on another origin throws unless `{ external: true }`, so never pass one read from the request. CSRF checks run on every method outside the safe allowlist (`GET`, `HEAD`, `OPTIONS`), trusting only the forwarded origin when `trustProxy` resolves one (or `trustedOrigins`). `export const csrf = false` opts out of origin checks (webhooks, bearer APIs)
|
|
49
|
+
- API routes: `.ts` files exporting standard `HTTP_METHOD_EXPORTS` (`GET`, `HEAD`, `POST`, `PUT`, `PATCH`, `DELETE`, `OPTIONS`) receiving `RequestContext` (`request`, `url`, `params`, `cookies`, `locals`, `ip`, `requestId`, `region`, `json()`, `text()`, `redirect(location, status?, { external? })`, `deny()`). `redirect()` stays on this site: a target on another origin throws unless `{ external: true }`, so never pass one read from the request. CSRF checks run on every method outside the safe allowlist (`GET`, `HEAD`, `OPTIONS`), trusting only the forwarded origin when `trustProxy` resolves one (or `trustedOrigins`). `export const schema = <Standard Schema>` makes the route validate its JSON body (`POST`/`PUT`/`PATCH`/`DELETE`) or query (`GET`/`HEAD`) before the handler: a failure answers 400 `{ ok: false, status: 400, error, fieldErrors, issues }` like an action, and the handler reads the parsed value as `ctx.input` (typed `unknown`: cast it to the schema's output type). `export const csrf = false` opts out of origin checks (webhooks, bearer APIs), and `prunelle check` warns `security/csrf-off` unless the route calls `verifyWebhook()`; `prunelle check` warns on it (`security/csrf-off`) until `// prunelle-ignore security/csrf-off` above the export says the route verifies its own signature or token.
|
|
47
50
|
- Prerendering: `export const prerender = true` (+ `export function paths() { return ['/posts/a'] }`, required for dynamic routes and for every dynamic page under `--static`, or `prunelle build` fails; unlisted params return `404`, and so does a listed URL that answered other than `200` at build, which the build warns about). Skipped in `prunelle dev`. Static pages that read nothing from the request or clock are reported `cacheable` by `prunelle inspect` and prerender automatically with `autoPrerender: true` or `prunelle build --auto-prerender`.
|
|
48
51
|
- Page language: `export const lang = 'fr'` gives that route `<html lang="fr">` when it is written in another language than `lang` in `prunelle.config.ts` (a French accessibility statement on an English site). It wins over plugin head hooks such as `@prunellejs/i18n`'s; `@prunellejs/ui` labels keep the config's language. A value that is not a language tag literal (`'french'`, `''`, a variable) fails `prunelle check` and `prunelle build`.
|
|
49
52
|
- Slow responses: the server closes a request silent for 30 s (streamed pages and SSE lift it themselves); `export const idleTimeout = '5m'` (seconds or a duration string, `0` for no limit) sets it for that route's requests alone, from when its handler or page starts. A value that is not such a literal fails `prunelle check` and `prunelle build`.
|
|
50
|
-
- Route caching: `export const cache = '1h'` (or `{ maxAge: '1h', staleWhileRevalidate?: '1d' }`) serves a bounded in-memory LRU render (`routeCache: { maxEntries?, maxBytes? } | false`), re-renders in the background once stale, and sends `cache-control: public, s-maxage=..., stale-while-revalidate=...` (`private, no-cache` under an app `_middleware.ts
|
|
53
|
+
- Route caching: `export const cache = '1h'` (or `{ maxAge: '1h', staleWhileRevalidate?: '1d', tags?: ['posts'] }`) serves a bounded in-memory LRU render (`routeCache: { maxEntries?, maxBytes? } | false`), re-renders in the background once stale, and sends `cache-control: public, s-maxage=..., stale-while-revalidate=...` (`private, no-cache` under an app `_middleware.ts` or a plugin middleware scoped to a path (`api.use(mw, { scope: '/admin' })`), which may gate it; one scoped to a request kind, like sessions, locales or analytics, keeps the public header; the server cache still serves it behind the gate and, once stale, refreshes it on the request that passes the gate rather than in the background), with a weak `ETag` that a matching `If-None-Match` turns into a `304`. Its key leaves out `utm_*`, `gclid`, `gbraid`, `wbraid`, `dclid`, `fbclid`, `msclkid`, `mc_cid` and `mc_eid`, so a campaign link reuses the entry (a page showing them reads them uncached). A cached route (or its layout `load()` or imported local modules) reading `ctx.cookies`, `ctx.locals`, `ctx.consent`, `ctx.ip`, `Cookie`/`Authorization` or dynamic/bulk headers, `getActionError()`, `<ConsentGate>`, or passing `ctx`/`props`/`request` to a helper that does (or cannot be followed) fails `prunelle check` and `prunelle build` naming the read; at runtime the route cache also refuses to store any render that reads private request data, a plugin `head` or `transformHtml` hook's read included.
|
|
54
|
+
- `await invalidateCache('/posts/hello', '/blog/*', { tag: 'posts' })` (`prunelle/server`) drops the cached renders of a path (every host and query string, with or without its trailing slash; read as written, so a slug `100%`, `what?` or `a#b` names its page, and a path with a query such as `'/posts?page=2'` throws), of a path and every page under it (`'/*'`: all), or of every route whose `cache.tags` holds the tag, so their next request renders fresh; a render already running answers its request but is not stored. Call it from server code (an action, a route, `load()`, a job, a plugin's server hook): elsewhere it throws. It drops in this process at once and, with `store`, in every other once the promise settles; it never rejects, logging a store it cannot reach. A CDN keeps its copy until its `s-maxage` runs out. `prunelle check` warns `cache/unknown-tag` on a tag no route declares.
|
|
51
55
|
- **Streaming & Head**: `<Head><title>...</title></Head>` (innermost `<title>` wins). A page with no `<link rel="icon">` and no `public/favicon.ico` gets `<link rel="icon" href="data:,">`, so no `/favicon.ico` 404.
|
|
52
56
|
- `<Suspense fallback={<p>Loading</p>} error={<p>Failed</p>}><AsyncComp /></Suspense>` streams resolved HTML inline with 0 KB external JS. It takes exactly one child; an async component anywhere but as the only child of `<Suspense>` fails build and check, even inside an async page. Boundaries nest, time out after `streamTimeout` (default `30000` ms), and their errors also fire `onError`.
|
|
53
57
|
- `<Catch fallback={<p>Failed</p> | (error, retry) => ...}>` renders its fallback in place of children that throw or an awaited child that rejects, on the server (firing `onError`; nothing streams) and in an island, where it also catches a child effect's later throw and `retry()` renders the children again (there it is written as a tag: calling `Catch()` as a function throws); errors thrown by event handlers are not caught.
|
|
54
|
-
- **Regions** (`<Region>`
|
|
58
|
+
- **Regions** (`<Region>` & `refreshRegion` from `prunelle`): `<Region name="pane" as="section" ...attrs>children</Region>` is server-only like `Head` and renders `<section data-pru-region="pane">` (a `<div>` without `as`). Its client runtime loads automatically **only on routes rendering a `<Region>`** (0 B on pages without one, no plugin needed). `<a href data-pru-target="pane">` and `<form data-pru-target="pane">` swap that region in place with the server's answer (`x-pru-region`, `x-pru-title`, `x-pru-icon`, `x-pru-attrs`, `x-pru-build`, `vary: x-pru-region`): the tab takes the new title and `<link rel="icon">`, and the region element follows the new page's own attributes (`class`, `data-*`, `aria-*`); without JS the link or form loads the whole page. Supports `data-pru-append` (Load more), `data-pru-live` (debounced live GET form), `data-pru-sync="q tag"`, `[data-pru-prefetch]`, nested regions (`outer/inner`), `<form method="post" data-pru-target="...">` (follows redirects and swaps 4xx validation HTML in place), `data-persist="<key>"` via `Element.moveBefore`, lazy island runtime loading when a swap delivers `<pru-island>` onto an initially island-less page, `pru:region` event, and `await refreshRegion(name)` from `prunelle`. `prunelle check` validates `data-pru-target` names against parsed `<Region>` JSX across `src/`.
|
|
55
59
|
- **Actions (`prunelle/server` & `useAction` from `prunelle`)**: `export const fn = action(standardSchema, async (input, ctx) => ..., options?)` or `action(async (ctx) => ...)`, a top-level named export so Prunelle can assign it a URL. `ctx` provides `redirect()` and `deny(status, message, fieldErrors?)`.
|
|
56
|
-
- Zero-JS form: `<form action={fn} method="post">`. Array fields are coerced from checkboxes/multi-selects (`name="tags"` or `name="tags[]"` always parses as an array `tags`, and dotted names like `name="address.city"` parse into nested objects `{ address: { city } }`; a name that both holds a value and nests others, `a` beside `a.b`, answers `400` with that field in `fieldErrors`). SSR adds `required`, `minlength`/`maxlength`, `min`/`max`/`step`, `pattern` and `type="email"|"url"|"number"` to `<input>`/`<select>`/`<textarea>` from the action's Standard Schema JSON Schema unless the app wrote that attribute (0 B client JS, no implicit `<option>` tags). A validation failure sets an `HttpOnly` flash cookie, read with `getActionError(ctx.locals)` (the flash is signed with `PRUNELLE_FORM_SECRET` or `AUTH_SECRET`; its `values` are the fields the action schema declares, minus secrets such as password, token, card or `format: "password"`, or exactly `flashFields`; a schema with no JSON Schema output declares none, so list `flashFields`), and redirects `303` to the trusted Referer.
|
|
57
|
-
- `protect: { rateLimit?: { max, windowMs, key? }, honeypot?: boolean | string, minTime?: number }` (or top-level `rateLimit`) enforces `rateLimit` (`429` + `Retry-After` / flash+303) before body parsing, then honeypot/`minTime`, then schema validation. It renders a hidden honeypot and an action-URL-bound HMAC-signed `_pru_ts` timestamp into `<form action={fn}>` automatically and refuses bots, fast submits and timestamps older than two hours with `400` and the one message `Submission rejected` before the handler runs. Set `PRUNELLE_FORM_SECRET` or `AUTH_SECRET` in production when using `minTime`, else Prunelle logs a warning when the action is defined (the key is derived from it with HKDF). A `minTime` form an island renders only in the browser has no timestamp and is refused (`prunelle dev` says so): render it on the first render, hidden until needed. The timestamp is signed per request, so a `minTime` form on a page exporting `prerender = true` or `cache` fails `prunelle check` and `prunelle build` (`action/min-time-frozen`), a `--static` export of one fails the build, and `autoPrerender` leaves such a page to render at request time.
|
|
60
|
+
- Zero-JS form: `<form action={fn} method="post">`. Array fields are coerced from checkboxes/multi-selects (`name="tags"` or `name="tags[]"` always parses as an array `tags`, and dotted names like `name="address.city"` parse into nested objects `{ address: { city } }`; a name that both holds a value and nests others, `a` beside `a.b`, answers `400` with that field in `fieldErrors`). SSR adds `required`, `minlength`/`maxlength`, `min`/`max`/`step`, `pattern` and `type="email"|"url"|"number"` to `<input>`/`<select>`/`<textarea>` from the action's Standard Schema JSON Schema unless the app wrote that attribute (0 B client JS, no implicit `<option>` tags). A validation failure sets an `HttpOnly` flash cookie, read with `getActionError(ctx.locals)` (the flash is signed with `PRUNELLE_FORM_SECRET` or `AUTH_SECRET`; its `values` are the fields the action schema declares, minus secrets such as password, token, card or `format: "password"`, or exactly `flashFields`; a schema with no JSON Schema output declares none, so list `flashFields`), and redirects `303` to the trusted Referer. After a failed submit (the flash render, or `useAction`'s `onSubmit` in an island), each control `fieldErrors` names gets `aria-invalid="true"` and `aria-describedby` pointing at the element of its form whose whole text is the message (the first after it, else the last before; given an id `pru-err-<name>` if it has none), unless the app or `Field` set `aria-invalid`; the next submit removes them. So render the message as text inside the form, e.g. `<p role="alert">{err.fieldErrors.title}</p>`.
|
|
61
|
+
- `protect: { rateLimit?: { max, windowMs, key? }, honeypot?: boolean | string, minTime?: number }` (or top-level `rateLimit`) enforces `rateLimit` (`429` + `Retry-After` / flash+303) before body parsing, then honeypot/`minTime`, then schema validation. A honeypot name holding `.` or `[` throws when the action is defined (the form parser nests such names). It renders a hidden honeypot and an action-URL-bound HMAC-signed `_pru_ts` timestamp into `<form action={fn}>` automatically and refuses bots, fast submits and timestamps older than two hours with `400` and the one message `Submission rejected` before the handler runs. Set `PRUNELLE_FORM_SECRET` or `AUTH_SECRET` in production when using `minTime`, else Prunelle logs a warning when the action is defined (the key is derived from it with HKDF). A `minTime` form an island renders only in the browser has no timestamp and is refused (`prunelle dev` says so): render it on the first render, hidden until needed. The timestamp is signed per request, so a `minTime` form on a page exporting `prerender = true` or `cache` fails `prunelle check` and `prunelle build` (`action/min-time-frozen`), a `--static` export of one fails the build, and `autoPrerender` leaves such a page to render at request time.
|
|
58
62
|
- `prunelle check` and `prunelle build` report unknown form fields with the closest name (a schema taking extra keys through `additionalProperties` or `patternProperties` accepts those), missing required fields, invalid `<select>` enum options (a control counts for the form its `form="id"` names, as in the browser), unsupported schema libraries (once per vendor) and unguarded public form actions without `protect`.
|
|
59
63
|
- Island RPC: `const res = await fn(data)` always resolves to `{ ok: true, data }` or `{ ok: false, status, error, fieldErrors?, issues? }`; it accepts `FormData` for files, and redirects navigate the page (to another site only for `ctx.redirect(url, status, { external: true })`; any other cross-site target fails with `Redirect to another site refused`).
|
|
60
|
-
- In islands, `const form = useAction(fn, { reset?, onSuccess?, onError? })` returns `{ pending, error, fieldErrors, data, action, onSubmit, submit, reset }` (`pending`/`error`/`fieldErrors`/`data` are `ReadonlySignal`s). Wire `<form action={form.action} method="post" onSubmit={form.onSubmit}>` for progressive enhancement; it keeps the SSR protection fields and HTML5 constraints.
|
|
64
|
+
- In islands, `const form = useAction(fn, { reset?, onSuccess?, onError?, optimistic? })` returns `{ pending, error, fieldErrors, data, progress, action, onSubmit, submit, reset }` (`pending`/`error`/`fieldErrors`/`data`/`progress` are `ReadonlySignal`s; `progress` is the fraction uploaded, 0 to 1, of a submit whose `FormData` holds a `File`, sent through a module fetched only by a form whose `progress` is read, and 0 otherwise). Wire `<form action={form.action} method="post" onSubmit={form.onSubmit}>` for progressive enhancement; it keeps the SSR protection fields and HTML5 constraints.
|
|
65
|
+
- `optimistic: (input) => { notes.value = [...notes.value, String((input as FormData).get('body'))] }` changes the page as the request leaves (`input` is the `FormData` from `onSubmit`, or what `submit()` got). Its signal and store writes are recorded and undone, before `onError`, when the result is `{ ok: false }` or the request fails; a failed change among several forms' in flight is undone alone, the later ones made again. It must be synchronous: returning a promise throws.
|
|
61
66
|
- A route, `load()`, middleware or another action may also call it: it runs in that request, schema and folder `_middleware.ts` included, and resolves to the same result; called outside a request it throws.
|
|
62
67
|
- Server code is stripped from client bundles. CSRF `Origin`/`Sec-Fetch-Site` is checked on every unsafe method before middleware and body parsing, unmatched paths and 405s included, and a request carrying a cookie with neither header must have a same-site `Referer`; the folder's `_middleware.ts` runs before the handler.
|
|
63
|
-
- **Config (`prunelle.config.ts`)**: `defineConfig({ site, lang, port, routesDir, outDir, publicDir, assetPrefix, security, trustedOrigins, trustProxy, maxRequestBodySize, navigation, routeCache, autoPrerender, streamTimeout, consent, compliance, budget, compress, healthCheck, onError, plugins })`. `trustProxy: true | number` trusts that many right-most proxy hops for `X-Forwarded-*`; with `site` set, an `X-Forwarded-Host` naming neither the site's host nor a `trustedOrigins` one is ignored for the origin check and `ctx.redirect`, `Host` standing in, and `prunelle check` warns `[security/proxy-no-site]` on `trustProxy` without `site` (an https `site` makes cookies `Secure` and sends HSTS without it, also under `start --static`, but not in `prunelle dev`; production warns once on `X-Forwarded-Proto` while it is off, and once on the first POST refused as `untrusted origin`, naming the Origin, the origin the server computed, `trustProxy` and `trustedOrigins`); `prunelle start` in production notices when it binds loopback (the default; `HOST` or `--host 0.0.0.0` opens it for a container); `maxRequestBodySize` defaults to `1 MiB`. `lang` sets `<html lang>` and the language of `@prunellejs/ui`'s built-in labels (`'fr'` or `'fr-*'` gives French ones); with no `lang` and no `@prunellejs/i18n`, `prunelle check` warns `rgaa/document-lang`.
|
|
64
|
-
-
|
|
68
|
+
- **Config (`prunelle.config.ts`)**: `defineConfig({ site, lang, port, routesDir, outDir, publicDir, assetPrefix, security, trustedOrigins, cors, trustProxy, maxRequestBodySize, navigation, routeCache, store, autoPrerender, streamTimeout, consent, compliance, budget, compress, healthCheck, onError, log, plugins })`. `cors: { origins: ['https://front.example'], credentials?, exposeHeaders? }` answers those origins with `Access-Control-Allow-Origin` on every response (every response then sends `Vary: Origin`) and their preflight with a 204 before any middleware, also under `start --static`, and lets them through the CSRF check (plugins see them in `api.trustedOrigins`); `origins: '*'` lets any origin read (its preflight allows `GET` and `HEAD`) but keeps the CSRF check, and throws with `credentials: true`; unset, no other origin may call the app. `trustProxy: true | number` trusts that many right-most proxy hops for `X-Forwarded-*`; with `site` set, an `X-Forwarded-Host` naming neither the site's host nor a `trustedOrigins` one is ignored for the origin check and `ctx.redirect`, `Host` standing in, and `prunelle check` warns `[security/proxy-no-site]` on `trustProxy` without `site` (an https `site` makes cookies `Secure` and sends HSTS without it, also under `start --static`, but not in `prunelle dev`; production warns once on `X-Forwarded-Proto` while it is off, and once on the first POST refused as `untrusted origin`, naming the Origin, the origin the server computed, `trustProxy` and `trustedOrigins`); `prunelle start` in production notices when it binds loopback (the default; `HOST` or `--host 0.0.0.0` opens it for a container); `maxRequestBodySize` defaults to `1 MiB`. `lang` sets `<html lang>` and the language of `@prunellejs/ui`'s built-in labels (`'fr'` or `'fr-*'` gives French ones); with no `lang` and no `@prunellejs/i18n`, `prunelle check` warns `rgaa/document-lang`.
|
|
69
|
+
- `store: 'data/app.db'` (a SQLite file, relative to the root) or `store: process.env.DATABASE_URL` (`postgres://`, read at start) is the database every process of the app shares: rate limits count there across processes, `invalidateCache()` drops the page in every process, and `@prunellejs/live` `publish()` reaches every process (Postgres `LISTEN`/`NOTIFY`, SQLite polled every 200 ms while a stream is open). prunelle creates `prunelle_rate_hits` (client keys, IP addresses by default, kept for each limiter's window: list it in the processing register) and `prunelle_messages` on first use. Each app needs its own database or file: channels, tables and rate-limit scopes carry no app name, so two apps on one database see each other's messages and counts. `@prunellejs/db` given no `url` queries the `store` itself, SQLite or Postgres. `@prunellejs/auth` and `@prunellejs/jobs` given no store of their own use a SQLite `store` file; with a Postgres one a production start refuses until they get their own. Unset, each process keeps them in memory and opens no database. Plugins reach it with `api.inject(SHARED_STORE)` (`prunelle/server`): `publish(channel, payload)` reaches the `subscribe(channel, fn)` of every other process; in `requires(ctx)`, `parseStoreSpec(ctx.store, ctx.root)` tells a SQLite `{ kind, file }` from a `{ kind: 'postgres', url }`.
|
|
70
|
+
- **Security headers & CSP**: on by default (`security: false` disables them, or override `csp`, `hsts`, `frameOptions`, `referrerPolicy`, `contentTypeOptions`, `permissionsPolicy`, `crossOriginOpenerPolicy`, `crossOriginResourcePolicy`; the last two default to `same-origin`, and every header also goes on the build-swap `503`). `prunelle check` warns on `security: false`, `csp: false`, `'unsafe-inline'` in a script or style directive, `trustedTypes: false` and `export const csrf = false` (`security/headers-off`, `csp-off`, `unsafe-inline`, `trusted-types-off`, `csrf-off`). The strict `DEFAULT_CSP` (style attributes allowed) gets automatic SHA-256 hashes for island/Suspense styles, the app's own `<style>` blocks and stream scripts; `HSTS` is sent on HTTPS requests.
|
|
71
|
+
- `DEFAULT_CSP` ends with `require-trusted-types-for 'script'; trusted-types prunelle 'allow-duplicates'`: the browser refuses `el.innerHTML = html`, `insertAdjacentHTML`, `DOMParser` and `document.write` from app code, while prunelle and its plugins write through their `prunelle` policy (`innerHTML={html}` on an element, region swaps, SPA navigations). Write HTML with `innerHTML={html}`, text with `textContent`, or through an app policy added with `csp: { 'trusted-types': ['my-policy'] }`; `security: { trustedTypes: false }` drops both directives. `prunelle check` warns `[security/html-sink]` at each such write in `src/`.
|
|
72
|
+
- `security: { cspReports: true }` adds `report-uri /_pru/csp-report` (and, under `prunelle start` with an https `site`, `report-to` plus `Reporting-Endpoints`): each violation reaches `onError` as `source: 'csp'`, `error.message` `CSP violation: <directive> blocked <url> on <page>`, `error.cause` `{ directive, blockedUrl, page, sourceFile?, line? }` (stderr without a hook). 30 reports a minute per client, 16 KB each; extension-caused reports are dropped; a `--static` export leaves the directives out.
|
|
65
73
|
- `security: { csp: { 'style-src': [...], 'font-src': [...] } }` (or `extendCsp()` / `DEFAULT_CSP` from `prunelle/server`) adds sources to single directives without copying the whole policy; a new `*-src` directive inherits `default-src`, and automatic hashes still land in the extended directives.
|
|
66
|
-
- A `--static` export embeds each page's and `404.html`'s hashed CSP in `<meta http-equiv="Content-Security-Policy">` with `frame-ancestors`, `report-uri` and `sandbox` stripped (browsers ignore them in `<meta>`): the build writes the headers that cannot live there from `security` into `dist/_headers` (Netlify, Cloudflare Pages), `dist/prunelle.caddy` (`import` it in a site block) and `dist/prunelle.nginx.conf` (`include` it in a server block), with the exact-path rules of `dist/_redirects` (written by `@prunellejs/seo` `redirects`, or shipped in `public/`) as `redir` and `location =` lines; a file the app ships under those names is kept, and `security: false` skips `_headers` while keeping comment-only `prunelle.caddy` / `prunelle.nginx.conf` (plus any `_redirects` rules) so existing includes do not fail.
|
|
67
|
-
- **Observability**: the Bun server (not a `--static` export served by `prunelle start`) answers `/_pru/health` (at `${assetPrefix}/health`): `200 { ok: true }`, or `503` when the app's `healthCheck` or a plugin's `api.healthCheck(name, fn)` fails or takes over 5 s (cached for 5 s; a failure reads `check failed`, the error goes to stderr, `prunelle dev` shows it); `./app --health` probes it for a container `HEALTHCHECK`. Every request gets `ctx.requestId` (honoring a safe incoming `x-request-id` when `trustProxy` is truthy), returned in `x-request-id` and passed to `onError` as `info.requestId`. `prunelle dev` sends `Server-Timing` (`middleware`, `load`, `render`, `stream`; zero overhead in production).
|
|
74
|
+
- A `--static` export embeds each page's and `404.html`'s hashed CSP in `<meta http-equiv="Content-Security-Policy">` with `frame-ancestors`, `report-uri`, `report-to` and `sandbox` stripped (browsers ignore them in `<meta>`): the build writes the headers that cannot live there from `security` into `dist/_headers` (Netlify, Cloudflare Pages), `dist/prunelle.caddy` (`import` it in a site block) and `dist/prunelle.nginx.conf` (`include` it in a server block), with the exact-path rules of `dist/_redirects` (written by `@prunellejs/seo` `redirects`, or shipped in `public/`) as `redir` and `location =` lines; a file the app ships under those names is kept, and `security: false` skips `_headers` while keeping comment-only `prunelle.caddy` / `prunelle.nginx.conf` (plus any `_redirects` rules) so existing includes do not fail.
|
|
75
|
+
- **Observability**: the Bun server (not a `--static` export served by `prunelle start`) answers `/_pru/health` (at `${assetPrefix}/health`): `200 { ok: true }`, or `503` when the app's `healthCheck` or a plugin's `api.healthCheck(name, fn)` fails or takes over 5 s (cached for 5 s; a failure reads `check failed`, the error goes to stderr, `prunelle dev` shows it); `./app --health` probes it for a container `HEALTHCHECK`. Every request gets `ctx.requestId` (honoring a safe incoming `x-request-id` when `trustProxy` is truthy), returned in `x-request-id` and passed to `onError` as `info.requestId`. `prunelle dev` sends `Server-Timing` (`middleware`, `load`, `render`, `stream`; zero overhead in production). `log: { format: 'json', access: true }` in `prunelle.config.ts` prints unhandled errors as one JSON line each (`time`, `level`, `msg`, `source`, `method`, `path`, `requestId`, `error`, `stack`) and one access line per request to stdout (`GET /posts 200 3.4ms [id]`, or JSON with `method`, `path`, `status`, `duration`, `requestId`; never the query or the IP; the health probe is skipped). A plugin hears each request with `api.onRequestEnd(record)`: `{ request, requestId, status, start, duration, phases: { name, start, duration }[], route? }`, times in epoch milliseconds, `route` the template that answered (`/blog/:slug`, a page's or a plugin route's; none for a file, a prerendered page or no match), phases in the order they began; it runs before the response is sent, so queue the work.
|
|
68
76
|
- **Server helpers (`prunelle/server`)**:
|
|
69
77
|
- `defineEnv(standardSchema)` validates env vars at startup. `nodeEnv()` is safe in `--compile`: server code reads it, never `process.env.NODE_ENV`, which `prunelle build` leaves unset for a prerendered page (build and `prunelle check` warn on such a read outside island code).
|
|
70
78
|
- HTML escaping: `raw`, `esc`, `escAttr`, `escJson` (JSON text for a `<script>`), `escXml` (text for a feed or sitemap: also drops the control characters XML forbids).
|
|
71
|
-
- HTTP: `getClientIp`, `isHttpsRequest`, `isTrustedOrigin`, `verifyOrigin`, `wantsJson`, `safeEqual` (constant-time secret compare), `deriveKey(purpose, secret?)` (a 32-byte HKDF key for one purpose from the app secret, or from a plugin's own `secret`, so a token made for one use never verifies for another), `signPayload(purpose, payload, secret?)` / `verifyPayload(purpose, signed, secret?)` (`<hmac>.<payload>` under that key; verify returns the payload or `undefined`; not encrypted), `readStringFields` (a body's string fields, on a null-prototype record), and `safeRedirect(target, fallback = '/')`, which returns the trimmed target only when it is a path on this site, refusing absolute and protocol-relative URLs, backslashes and control characters (`@prunellejs/auth` and the consent endpoint use it).
|
|
72
|
-
- `createRateLimitStore({ maxKeys?, maxHits? })`: a standalone sliding-window store whose `.limiter({ max, windowMs }).hit(key)` returns 0 or the seconds to wait, and `.peek(key)` the same without counting; plugins use `api.rateLimiter()`. A `rateLimit` with no `key` counts the client's network: an IPv4 address without its port or `::ffff:` mapping, or an IPv6 address's /64; `rateLimitAddress(ip)` gives that key to a custom limiter.
|
|
79
|
+
- HTTP: `getClientIp`, `isHttpsRequest`, `isTrustedOrigin`, `verifyOrigin`, `wantsJson`, `safeEqual` (constant-time secret compare), `startSecret()` (a random secret made once per start, the same in every `--workers` process: key a plugin's ephemeral state with it, never persist it), `deriveKey(purpose, secret?)` (a 32-byte HKDF key for one purpose from the app secret, or from a plugin's own `secret`, so a token made for one use never verifies for another), `signPayload(purpose, payload, secret?)` / `verifyPayload(purpose, signed, secret?)` (`<hmac>.<payload>` under that key; verify returns the payload or `undefined`; not encrypted), `verifyWebhook(request, 'standard' | 'stripe' | 'github', secret, { toleranceSeconds? })` (the body when its Standard Webhooks, Stripe or GitHub signature holds, compared in constant time, its signed time within 5 minutes; `undefined` otherwise; throws on a missing secret), `readStringFields` (a body's string fields, on a null-prototype record), and `safeRedirect(target, fallback = '/')`, which returns the trimmed target only when it is a path on this site, refusing absolute and protocol-relative URLs, backslashes and control characters (`@prunellejs/auth` and the consent endpoint use it).
|
|
80
|
+
- `createRateLimitStore({ maxKeys?, maxHits? })`: a standalone sliding-window store, `maxKeys` (10 000) and `maxHits` (1 000 000) capping each of its limiters rather than the store, whose `.limiter({ max, windowMs }).hit(key)` returns 0 or the seconds to wait, and `.peek(key)` the same without counting; plugins use `api.rateLimiter()`. A `rateLimit` with no `key` counts the client's network: an IPv4 address without its port or `::ffff:` mapping, or an IPv6 address's /64; `rateLimitAddress(ip)` gives that key to a custom limiter.
|
|
73
81
|
- Standard Schema: `StandardSchemaV1` (including optional `'~standard'.jsonSchema: { input, output? }` Standard JSON Schema extension), `validateSchema`, `validateSchemaSync`, `formatSchemaIssues`, `formatIssuePath`.
|
|
74
82
|
- `declare module 'prunelle/server' { interface PrunelleLocals { ... } }` types `ctx.locals`; `createServer({ root })` runs a built app inside another program.
|
|
75
83
|
- **French web law & Consent (RGPD, CNIL, RGAA, RGESN, LCEN - 0 B client JS)**: `prunelle check` and production `prunelle build` emit actionable warnings (never hard errors):
|
|
76
84
|
- RGAA: `rgaa/img-alt` (`<img>` without `alt`, or `alt={undefined}`/`alt={false}`, unless `role="presentation"` or `aria-hidden`), `rgaa/form-label` (unlabelled `<input>`/`<select>`/`<textarea>`, or a ui `<Select>` with no `Field`, `<label for>` or `ariaLabel`; a `<Label>` component wraps like `<label>`, and `for={ids.name}` matches `id={ids.name}`), `rgaa/accessible-name` (empty or icon-only `<button>`/`<a>`, `<svg role="img">` without `aria-label` or `<title>`), `rgaa/duplicate-id` (duplicate literal `id` in one component, or a static `id` inside `.map()`), `rgaa/positive-tabindex` (`tabindex > 0`).
|
|
77
|
-
- RGAA structure: `rgaa/nested-control` (interactive element inside `<a>`/`<button>`/`<summary>`), `rgaa/link-as-button` (`<a>` without `href` with `onClick`, or `href="#"` / `javascript:`), `rgaa/unknown-role`, `rgaa/unknown-aria`, `rgaa/invalid-aria-value`, `rgaa/skipped-heading` (downward heading jump > 1 in one component), `rgaa/table-without-header` (`<table>` without `<th>`), `rgaa/fieldset-without-legend`, `rgaa/click-without-key` (`onClick` on a non-interactive element without a key handler), `rgaa/role-without-focus` (`role="button"` and other operable roles without `tabIndex`), `rgaa/mouse-only` (`onMouseEnter`/`onMouseOver` without `onFocus`/`onFocusIn`, `onMouseLeave`/`onMouseOut` without `onBlur`/`onFocusOut`), `rgaa/frame-title` (`<iframe>` without `title`), `rgaa/empty-heading`, `rgaa/autocomplete` (email, phone, name or address field without `autocomplete`), `rgaa/autofocus`, `rgaa/meta-refresh`, `rgaa/document-lang` (no `lang` in `prunelle.config.ts` and no `@prunellejs/i18n`, so pages say `<html lang="en">`), and `rgaa/accessibility-statement` (missing `/accessibilite` when `compliance: { publicBody: true }`; on any site, a statement still holding `[à compléter : ...]`).
|
|
78
|
-
- `rgpd/third-party-url`: a third-party `<script src>`, `<link rel="stylesheet|preload|preconnect|dns-prefetch|modulepreload|prefetch|prerender|icon|apple-touch-icon|manifest">`, `<iframe src>`, `<img src/srcset>`, `<video src/poster>`, `<audio>`, `<source>`, `<track>`, `<object data>`, `<embed>`, SVG `<image>`/`<use>`/`<feImage>` `href`, a `style` attribute's `url(...)`, or CSS `@import`/`url(...)` in `src/` or the CSS of `publicDir`, outside `<ConsentGate>` or `site`. A string, template literal (its leading text; in `style`, every text segment), `a ? b : c` or `a ?? b` value is read; `<ConsentGate category="essential">` always renders, so it gates nothing.
|
|
85
|
+
- RGAA structure: `rgaa/nested-control` (interactive element inside `<a>`/`<button>`/`<summary>`), `rgaa/link-as-button` (`<a>` without `href` with `onClick`, or `href="#"` / `javascript:`), `rgaa/unknown-role`, `rgaa/unknown-aria`, `rgaa/invalid-aria-value`, `rgaa/skipped-heading` (downward heading jump > 1 in one component), `rgaa/table-without-header` (`<table>` without `<th>`), `rgaa/fieldset-without-legend`, `rgaa/click-without-key` (`onClick` on a non-interactive element without a key handler), `rgaa/role-without-focus` (`role="button"` and other operable roles without `tabIndex`), `rgaa/mouse-only` (`onMouseEnter`/`onMouseOver` without `onFocus`/`onFocusIn`, `onMouseLeave`/`onMouseOut` without `onBlur`/`onFocusOut`), `rgaa/frame-title` (`<iframe>` without `title`), `rgaa/empty-heading`, `rgaa/autocomplete` (email, phone, name or address field without `autocomplete`), `rgaa/generic-link-text` (a link whose whole text is `en savoir plus`, `lire la suite`, `click here` and the like, with no `aria-label`), `rgaa/video-captions` (`<video>` with no `<track kind="captions">` unless muted with no `controls`), `rgaa/table-caption` (data `<table>` with no `<caption>` or `aria-label`), `rgaa/skip-link` (a `_layout.tsx` rendering a `<header>` or `<nav>` with no `<a href="#main">` in it or a layout above), `rgaa/page-title` (a page with no `<Head><title>` in it or its layouts; skipped when `@prunellejs/seo` checks titles), `rgaa/contrast` (a CSS rule setting both `color` and its background under 4.5:1, or 3:1 for large text, in the light or the dark scheme, with `:root` tokens of the same stylesheet resolved), `rgaa/autofocus`, `rgaa/meta-refresh`, `rgaa/document-lang` (no `lang` in `prunelle.config.ts` and no `@prunellejs/i18n`, so pages say `<html lang="en">`), and `rgaa/accessibility-statement` (missing `/accessibilite` when `compliance: { publicBody: true }`; on any site, a statement still holding `[à compléter : ...]`).
|
|
86
|
+
- `rgpd/third-party-url`: a third-party `<script src>`, `<link rel="stylesheet|preload|preconnect|dns-prefetch|modulepreload|prefetch|prerender|icon|apple-touch-icon|manifest">`, `<iframe src>`, `<img src/srcset>`, `<video src/poster>`, `<audio>`, `<source>`, `<track>`, `<object data>`, `<embed>`, SVG `<image>`/`<use>`/`<feImage>` `href`, a `style` attribute's `url(...)`, or CSS `@import`/`url(...)` in `src/` or the CSS of `publicDir`, outside `<ConsentGate>` or `site`. A string, template literal (its leading text; in `style`, every text segment), `a ? b : c` or `a ?? b` value is read; a value it cannot read (a variable, `post.cover`, a call, a template starting with `${...}`) is reported as `<img src={...}>` (gate it, self-host it, or `// prunelle-ignore rgpd/third-party-url`); a component's literal third-party `src`/`href`/`url` prop is reported too (not `href` on `Link`, `NavLink`, `A`, `Anchor`); `<ConsentGate category="essential">` always renders, so it gates nothing.
|
|
87
|
+
- `rgpd/consent-preferences`: `consent` is set, `<ConsentBanner>` is used and no file renders `<ConsentPreferences>`, so nobody can change or withdraw their choice. `rgpd/cookie-category`: `consent` is set and `ctx.cookies.set(name, value)` has no `{ category }` (options held in a variable or spread are not read). `rgpd/cookie-purpose`: a `cookies.set` whose name, `purpose`, `category` or lifetime (`maxAge` as a number or a product of numbers; neither `maxAge` nor `expires` is a session cookie) is not a literal, so `<CookieTable>` shows `[to fill in: ...]` (`[à compléter : ...]` in French); calls for the same name are merged.
|
|
79
88
|
- RGESN: `rgesn/autoplay` (`<video>`/`<audio>` with `autoplay`), `rgesn/img-size` (`<img>` without both `width` and `height`, unless spread), `rgesn/img-sizes` (a `srcset` of `w` descriptors without `sizes`, unless spread), `rgesn/large-public-file` (a file in `publicDir` over 1 MB), `rgesn/declaration` (`/ecoconception` still holding a `[à compléter` placeholder), `rgesn/island-by-value` (an imported island read as a value, `const D = Counter`, `{ C: Counter }` or `c={Counter}`, which hydrates what holds it whole: render `<Counter />` itself; a production `prunelle build` reports it too, and an ignore covers one read only).
|
|
80
|
-
- `lcen/legal-notice`: a page app missing `/mentions-legales`, `/legal`, or a localized variant (`/fr/mentions-legales`, `/[lang]/mentions-legales`),
|
|
81
|
-
- `rgpd/privacy-notice`: a `.tsx` file in `src/` with an `<input>` collecting an email or a phone number (`type="email|tel"` or `name="email|phone|tel"`, read from the parsed JSX, so a commented-out one does not count) while the app has no `/privacy`, `/confidentialite`, `/politique-de-confidentialite` or localized variant, or a privacy notice still holding a `[to fill in` placeholder outside a comment (`prunelle-ignore` works on both, and on the placeholders of the legal notice, accessibility statement and eco declaration). The `app` template ships `/privacy` and links it under its sign-up form.
|
|
82
|
-
- Silence per rule with `compliance: { ignore: [...], legalNotice?: string | false, privacyNotice?: string | false, publicBody?: boolean }`, or `// prunelle-ignore <rule>` / `/* prunelle-ignore <rule> */` / `// prunelle-ignore-file <rule>`. The form check's warnings (`action/unguarded-public-form`, `form/invalid-option`, `form/schema-unsupported`, `form/unchecked` for an action module that fails to import, an ignore silencing that form only) are silenced the same way, the comment going on the line above the `<form>` or `<option>`; its errors cannot be. So is `security/csrf-off`, the comment going above `export const csrf = false`, and `security/proxy-no-site` through `compliance.ignore`.
|
|
83
|
-
- One-declaration consent: `consent: { categories: ['analytics', 'media'] | { analytics: 'Audience measurement' }, cookieName?: 'pru_consent', maxAge?: 15552000, endpoint?: '/_pru/consent', version?: '2026-11' }` wires a CSRF-protected `POST /_pru/consent` endpoint (a zero-JS `<form method="post" action="/_pru/consent">` with `action="accept-all"|"reject-all"` or category checkboxes, `name="categories" value="analytics"` or `name="analytics"`, gets a `303`, JSON a `200`), exposes `ctx.consent` (`decided`, `decidedAt`, `categories`, `labels`, `endpoint`, `has(cat)`, `all()`), refuses `ctx.cookies.set(name, val, { category })` before consent is granted, and exports server-only `<ConsentGate category="media" fallback={...}>` (0 KB browser JS, refused inside islands). The cookie stores the time of the choice and `version`: changing `version` asks every visitor again. `prunelle check` warns (`rgpd/consent-retention`) when `maxAge` is past 180 days, and `prunelle dev` warns once per cookie set with no `category`, which counts as essential.
|
|
84
|
-
- `<ConsentBanner policyHref?="/cookies" policyLabel? title? accept? refuse? choose? save? legend?>{text?}</ConsentBanner>` renders, until the visitor decides, a form with Refuse all and Accept all side by side and the categories (by label) behind a `<details
|
|
89
|
+
- `lcen/legal-notice`: a page app missing `/mentions-legales`, `/legal`, or a localized variant (`/fr/mentions-legales`, `/[lang]/mentions-legales`), a legal notice page that renders no text, or one still holding a `[to fill in` placeholder.
|
|
90
|
+
- `rgpd/privacy-notice`: a `.tsx` file in `src/` with an `<input>` collecting an email or a phone number (`type="email|tel"` or `name="email|phone|tel"`, read from the parsed JSX, so a commented-out one does not count) while the app has no `/privacy`, `/confidentialite`, `/politique-de-confidentialite` or localized variant, or a privacy notice still holding a `[to fill in` or `[à compléter` placeholder outside a comment (`prunelle-ignore` works on both, and on the placeholders of the legal notice, accessibility statement and eco declaration). The `app` template ships `/privacy` and links it under its sign-up form.
|
|
91
|
+
- Silence per rule with `compliance: { ignore: [...], legalNotice?: string | false, privacyNotice?: string | false, publicBody?: boolean }`, or `// prunelle-ignore <rule>` / `/* prunelle-ignore <rule> */` / `// prunelle-ignore-file <rule>`. The form check's warnings (`action/unguarded-public-form`, `form/invalid-option`, `form/schema-unsupported`, `form/unchecked` for an action module that fails to import, an ignore silencing that form only) are silenced the same way, the comment going on the line above the `<form>` or `<option>`; its errors cannot be. So is `security/csrf-off`, the comment going above `export const csrf = false`, and `security/proxy-no-site` through `compliance.ignore`. A plugin `check(ctx)` warning is silenced by its tag in `compliance.ignore` (`'pwa/manifest-missing'`, `'seo/missing-image'`), typed from the plugins the config imports; a plugin declares its tags with `declare module 'prunelle/config' { interface PrunellePluginRules { 'ns/rule': true } }`.
|
|
92
|
+
- One-declaration consent: `consent: { categories: ['analytics', 'media'] | { analytics: 'Audience measurement' }, cookieName?: 'pru_consent', maxAge?: 15552000, endpoint?: '/_pru/consent', version?: '2026-11' }` wires a CSRF-protected `POST /_pru/consent` endpoint (a zero-JS `<form method="post" action="/_pru/consent">` with `action="accept-all"|"reject-all"` or category checkboxes, `name="categories" value="analytics"` or `name="analytics"`, gets a `303`, JSON a `200`), exposes `ctx.consent` (`decided`, `decidedAt`, `categories`, `labels`, `endpoint`, `lang`, `has(cat)`, `all()`), refuses `ctx.cookies.set(name, val, { category })` before consent is granted, expires on `POST /_pru/consent` the cookies of each refused category that this server process set and the request carries, and exports server-only `<ConsentGate category="media" fallback={...}>` (0 KB browser JS, refused inside islands). The cookie stores the time of the choice and `version`: changing `version` asks every visitor again, and so does a choice older than `maxAge` (whatever the browser kept). `prunelle check` warns (`rgpd/consent-retention`) when `maxAge` is past 180 days, and `prunelle dev` warns once per cookie set with no `category`, which counts as essential.
|
|
93
|
+
- `<ConsentBanner policyHref?="/cookies" policyLabel? title? accept? refuse? choose? save? legend?>{text?}</ConsentBanner>` renders, until the visitor decides, a form with Refuse all and Accept all side by side and the categories (by label) behind a `<details>`, its texts in French when `lang` is `fr` (English otherwise, each prop overrides); `<ConsentPreferences />` renders the choice in force, to change or withdraw it (put it on the cookie policy page). Both are server-only, private on a cached route, and throw `prunelle: <ConsentBanner> has no consent category to ask about` without `consent.categories`. Markup: `data-ui="consent"` with `data-part` `title`, `body`, `form`, `actions`, `details`, `choices`, `choice`, `preferences`; buttons carry `data-ui="button"`.
|
|
94
|
+
- `<CookieTable caption? />` (server-only, 0 B of JS) renders a `<table data-ui="table">` of every cookie the site sets, with its name, purpose, category (`consent.categories` label, or Essential) and lifetime, in French when `lang` is `fr`: `pru_consent` when `consent` is set, `__pru_action_err` (60 s) when the app has an action, each plugin's `cookies` (auth: the session cookie, `__Host-` named when `site` is https, its `_2fa`, `_webauthn` and, with a provider, `_oauth` cookies; analytics: `pru_no_count`), then the app's, read by `prunelle build` from `ctx.cookies.set(name, value, { category, purpose: 'Keeps the chosen theme.', maxAge })` (`purpose` is only read, never sent).
|
|
85
95
|
- **Page changes (plain multi-page navigation, 0 B of JS)**: every page carries inline, CSP-hashed `@view-transition { navigation: auto }` (inside `@media (prefers-reduced-motion: no-preference)`) and a `<script type="speculationrules">` prefetching same-origin links on press (`eagerness: conservative`); it never links to another origin, `/_pru/*` (actions included), `[download]`, `[rel~=nofollow]`, nor a link or ancestor with `data-pru-no-prefetch`. Name an element that stays still with CSS `view-transition-name`.
|
|
86
|
-
- `defineConfig({ navigation: { viewTransitions?: boolean (true; `false` also keeps `@prunellejs/spa`
|
|
96
|
+
- `defineConfig({ navigation: { viewTransitions?: boolean (true; `false` also keeps `<Region>` and `@prunellejs/spa` swaps out of view transitions), prefetch?: 'conservative' | 'moderate' | 'eager' | false ('conservative'), prerender?: 'conservative' | 'moderate' | 'eager' | boolean (false; true is 'moderate'; it runs `load()` of pages nobody opens) } })`; a bad value throws `prunelle: navigation.<key> is ...`.
|
|
87
97
|
- `data-pru-keep-scroll="<key>"` on a scrolling element keeps its `scrollTop` across page loads (restored before first paint when the next page has the same key; per history entry on back/forward/reload; a no-op when `sessionStorage` is blocked), through one inline hashed script at the end of `<body>` on pages using the attribute. The key is a literal string without `"<>&` (compile error otherwise, also for a nested panel of the same key); the same key on two elements of one rendered page throws `prunelle: data-pru-keep-scroll="..." is on two elements of one page`. `@prunellejs/spa` keeps the same attribute across its swaps.
|
|
88
98
|
- **Static files & CSS**: Files in `public/` are served at `/` (dotfiles and dot folders stay out of the build except `.well-known/`; `prunelle check` warns `security/public-dotfile`; a plugin `emitAsset`/`emitPublic` path that leaves the output folder throws, naming the plugin) with ETag/`304` (`Cache-Control: no-cache` in `prunelle dev`; embedded in `--static` and `--compile`); prerendered pages (sent with `Cache-Control: no-cache`, so a revisit revalidates) and hashed assets answer an ETag, a `304` and a `HEAD` length too. Import `.css` or `*.module.css` directly from any component or layout.
|
|
89
99
|
- `prunelle build` consolidates local stylesheets into at most one site-wide hashed immutable sheet plus one per-route sheet when needed, preserving `@layer` and plugin-before-app cascade order.
|
|
90
100
|
- It compresses hashed assets, `public/` files and prerendered pages of 256 B or more into `.br` and `.gz` files beside them, kept when smaller, which the server sends as they are; it compresses on the fly (zstd, gzip) only what has none, such as pages rendered per request, and flushes a page streamed past `<Suspense>` with each part. A `public/x.css.br` the app ships is kept and sent as `x.css` in brotli.
|
|
91
101
|
- `prunelle start` on a `--static` export lists its files at startup (`x` serves `x.html` or `x/index.html`, a miss `404.html`), re-lists them when one changes in place, and loads a new export with no restart.
|
|
92
102
|
- **CLI (scaffold, check, build, start & upgrade)**: `--help` and `--completions fish|bash|zsh` come from `@kaynooo/cli-kit`. Exit codes: `0` done, `1` finding/failure, `2` usage error.
|
|
93
|
-
- `prunelle new <dir> [--template minimal|fullstack|blog|app] [--force]`: a folder holding only `.git` counts as empty, `--force` prints `prunelle new: overwrote <file>` for each file it replaces; its `AGENTS.md` points agents at `node_modules/prunelle/llms.txt`; it writes `.mcp.json` registering `prunelle mcp`, `tsconfig.json` with `prunelle/ts-plugin`, and a `.gitignore` listing `node_modules/`, `dist/`, `.prunelle-cache/`, `.prunelle-dev/`, `.env` files (`.env.example` kept)
|
|
94
|
-
- `prunelle check [dir] [--no-typecheck] [--json] [--strict]`: every compiler mistake at `file:line:col: error:`, warnings at `file:line:col: warning:` (RGAA/RGPD/LCEN compliance, broken internal links `[link/broken]` across JSX, `ctx.redirect()` and Markdown content bodies (`// prunelle-ignore` silences one), cached-route private reads, form-vs-schema field/option/protection checks, and plugin `check(ctx)` hooks such as `@prunellejs/seo`). `--json` prints `{ ok, checkedFiles, typecheck, errors, warnings }`; `--strict` exits 1 on a warning; `prunelle build` refuses the same mistakes and form-schema errors without the typecheck.
|
|
103
|
+
- `prunelle new <dir> [--template minimal|fullstack|blog|app|plugin] [--force]`: a folder holding only `.git` counts as empty, `--force` prints `prunelle new: overwrote <file>` for each file it replaces; its `AGENTS.md` points agents at `node_modules/prunelle/llms.txt`; it writes `.mcp.json` registering `prunelle mcp`, `tsconfig.json` with `prunelle/ts-plugin`, and a `.gitignore` listing `node_modules/`, `dist/`, `.prunelle-cache/`, `.prunelle-dev/`, `.env` files (`.env.example` kept), `data/`, where the `app` template's SQLite store lives, and `data-prod/`, the container's; a `Dockerfile` building the `--compile` binary onto a distroless image run as uid 1000 (`HOST=0.0.0.0`, `HEALTHCHECK ./server --health`), its `.dockerignore`, and in the `app` template a `compose.yaml` publishing on `127.0.0.1` with the store in `data-prod/`. Every template's layout renders `<main id="main">` (with a skip link before any header) and a footer linking the legal notice and `src/routes/accessibilite.tsx`, the statement `prunelle new` drafts with its `[à compléter : ...]` for `prunelle check` to flag. `--template plugin` writes a plugin package instead: `src/index.ts`, a test mounting it with `testApp({ root, plugins })` on the app in `tests/fixture`, its `llms.txt`, and `prunelle` as a peer dependency.
|
|
104
|
+
- `prunelle check [dir] [--no-typecheck] [--json] [--strict]`: every compiler mistake at `file:line:col: error:`, warnings at `file:line:col: warning:` (RGAA/RGPD/LCEN compliance, broken internal links `[link/broken]` across JSX, `ctx.redirect()` and Markdown content bodies (`// prunelle-ignore` silences one), cached-route private reads, form-vs-schema field/option/protection checks, and plugin `check(ctx)` hooks such as `@prunellejs/seo`). `--json` prints `{ ok, checkedFiles, typecheck, errors, warnings }`; `--strict` exits 1 on a warning; the text output ends with how many of the 106 RGAA 4.1 criteria its rules partly cover (23); `prunelle build` refuses the same mistakes and form-schema errors without the typecheck.
|
|
95
105
|
- `prunelle inspect [dir] [--json]`: fast static report, without bundling, of routes (groups, optional params, matchers, `cache`, accurate `autoPrerender` `cacheable`), `statusPages`, `paramMatchers`, islands with their interactivity `reason` and `hydrate` mode, actions with URLs and guarding `_middleware.ts`, and active plugins in resolved order; `--json` prints `{ routes, statusPages, paramMatchers, islands, actions, plugins }`.
|
|
96
|
-
- `prunelle build [dir] [--static] [--compile [out]] [--auto-prerender] [--analyze] [--json] [--max-js <size>]`: `--analyze` lists each route's eager JS, CSS, fonts, first load (brotli), EcoIndex grade/score/inputs for prerendered routes (as `cnumr/ecoindex_python`
|
|
97
|
-
- `prunelle
|
|
98
|
-
- `prunelle
|
|
99
|
-
-
|
|
106
|
+
- `prunelle build [dir] [--static] [--compile [out]] [--auto-prerender] [--analyze] [--json] [--max-js <size>]`: `--analyze` lists each route's eager JS, CSS, fonts, first load (brotli), EcoIndex grade/score/inputs for prerendered routes (a static estimate from the build's files, not a browser visit, computed as `cnumr/ecoindex_python` does, the grade from the unrounded score, every image and third-party request of the page counted), and its islands with why each is one (`--analyze --json` outputs `BundleReport` JSON); `firstLoadUrls`, `distLocator` and `measureFirstLoad` from `prunelle/config` give plugins the same figure, and `await brotliSize(html)` reads the brotli cache. `--max-js 40kb` fails on a route whose gzipped eager JS is over it; `budget: { js?: '40kb', firstLoad?: '500kb' }` in `prunelle.config.ts` (bytes or KB) does the same on every build, `firstLoad` capping the brotli first load, and `--max-js` overrides `budget.js` for one run.
|
|
107
|
+
- `prunelle a11y [--draft [dest]] [--force] [--audit-date YYYY-MM-DD --rate <percent>] [--json] [--routes /a,/b] [--all-static] [--org <name>] [--contact <email>] [--no-fail]`: an axe-core scan whose results are mapped to RGAA criteria, covering what axe can detect, not an RGAA audit; axe-core tags `RGAAv4` + WCAG 2.1 A/AA, each result mapped to its RGAA criterion, axe's `incomplete` results reported as `toCheck`, to check by hand, counted with the page JS errors and `skipped` routes (not opened) in the report; `--draft` refuses to overwrite an existing statement unless `--force` is given; the draft's level comes from the manual audit only, "non conforme" without one, "totalement conforme" refused when the same run found axe violations, derogations and out-of-scope contents left as `[à compléter : ...]`, and `prunelle check` warns about `[à compléter : ...]` left in any published statement.
|
|
108
|
+
- `prunelle eco [dir] [--declaration [path]] [--force] [--service <name>] [--org <name>] [--contact <email>]`: builds the app and reports what it saw of the RGESN 2024 criteria it can read (4.1 autoplay, 4.4 third parties, 6.1 weight cap from `budget.firstLoad`, 6.3 compression, 6.5 unused resources, 6.7 one domain), saying what each check cannot see and giving no verdict: a person writes every one; `--declaration` writes an editable French declaration page (default `src/routes/ecoconception.tsx`) with each prerendered page's EcoIndex (a static estimate, not a browser visit), that evidence and a `[à compléter` placeholder for every verdict and the rest; a page already there is refused (exit 1) unless `--force`.
|
|
109
|
+
- `prunelle rgpd [dir] [--draft [path]] [--force] [--org <name>] [--contact <email>]`: lists the personal data each plugin's `processing` declares (auth: accounts and sessions, following `storeIp`, `storeUserAgent` and its lifetimes; analytics: what it sends the provider, with consent as the legal basis when counting waits for it; files) and the forms of each `.tsx` file holding an email or phone `<input>`, every named field of such a form listed (a form whose `action` is under a plugin's `formActions`, such as `/auth/`, is that plugin's). `--draft` writes a French privacy notice (default `src/routes/confidentialite.tsx`, prerendered, with `<CookieTable />`, the rights and the CNIL complaint) and `registre-des-traitements.md` (the RGPD art. 30 record, kept out of the site), each detail nobody declared left as a `[à compléter : ...]` that `rgpd/privacy-notice` reports; without `--force` it writes neither when one exists.
|
|
110
|
+
- `prunelle start [dir] [--port 3000] [--host [addr]] [--workers <n|auto>]`; `--workers` (Linux) runs n processes on one port with `SO_REUSEPORT`, the primary serving nothing and starting the others once the first listens, restarting a worker that dies after it listened and stopping all when one exits before it listens (it reports listening over Bun's IPC channel, and stops when the primary dies); with neither `PRUNELLE_FORM_SECRET` nor `AUTH_SECRET` the workers share one random secret (`startSecret()` in `prunelle/server`), and with no `store` worker 1 warns what each process keeps alone (rate limits, `invalidateCache()`, and each plugin's `perProcess` clause). `prunelle upgrade [dir] [--no-install]` moves a kay v2 app or workspace onto prunelle (kay v1 left untouched, a folder on neither refused, symbolic links never followed; `sqliteAuthStore()` preserves accounts).
|
|
111
|
+
- Plugin commands: `prunelle ui-eject <grammar> [dest]`, `prunelle mcp-footprint`, `prunelle i18n-check`, `prunelle icons-find <words> [--set <prefix>] [--limit <n>]`, `prunelle pwa-vapid [--json]`, `prunelle db migrate|status`. A command gets `(args, root, { store })`. They load from `prunelle.config.ts` only when the first word is no built-in, and take `--root <dir>` and `--help`.
|
|
100
112
|
- **CLI (dev, editor & agent tooling)**:
|
|
101
|
-
- `prunelle dev [dir] [--port 3000] [--host [addr]]`: binds loopback `127.0.0.1` by default; answers `421` to a `Host` other than `localhost`, `*.localhost`, an IP address, its `--host` and the hosts of `site` and `trustedOrigins` (against DNS rebinding: add a tunnel's origin to `trustedOrigins`); marks rendered elements with `data-pru-src="file:line:col"` in dev only (production output is byte-identical), and Alt-click opens `$PRUNELLE_EDITOR` or `$VISUAL` in VS Code, Cursor, Zed, JetBrains, Sublime, Helix or a `{file}:{line}:{col}` template (`/_pru/open-editor` answers `403` off loopback and honours `trustedOrigins`); records dev build, crash and runtime errors in `.prunelle-dev/last-errors.jsonl`; runs the app in a child process recycled on `prunelle.config.ts` edits or past 2 GB; edits in `public/` reload without rebuilding.
|
|
113
|
+
- `prunelle dev [dir] [--port 3000] [--host [addr]]`: binds loopback `127.0.0.1` by default; answers `421` to a `Host` other than `localhost`, `*.localhost`, an IP address, its `--host` and the hosts of `site` and `trustedOrigins` (against DNS rebinding: add a tunnel's origin to `trustedOrigins`); marks rendered elements with `data-pru-src="file:line:col"` in dev only (production output is byte-identical), and Alt-click opens `$PRUNELLE_EDITOR` or `$VISUAL` in VS Code, Cursor, Zed, JetBrains, Sublime, Helix or a `{file}:{line}:{col}` template (`/_pru/open-editor` answers `403` off loopback and honours `trustedOrigins`); records dev build, crash and runtime errors in `.prunelle-dev/last-errors.jsonl`; runs the app in a child process recycled on `prunelle.config.ts` edits or past 2 GB; edits in `public/` reload without rebuilding; saving an island's file swaps that island in the open page without a reload and keeps the values of the signals and stores it made while rendering (same declaration, same place), while a file that is no island, a `load()` or a stylesheet change still reloads.
|
|
102
114
|
- `prunelle render <url> [--method|-X <m>] [--body|-d <data>] [--header|-H "K: V"] [--cookie|-b "k=v"] [-i|--include] [--fresh]`: built on `testApp()`, it builds or reuses `.prunelle-cache/render-build` with no port bound and without touching `dist/`, and prints the body (status, headers and body with `-i`); exit `0` for `2xx`/`3xx`, `1` otherwise.
|
|
103
|
-
- `prunelle docs <words...> [--json] [--limit <n>]`: searches `llms.txt` of `prunelle
|
|
115
|
+
- `prunelle docs <words...> [--json] [--limit <n>]`: searches `llms.txt` of `prunelle`, every installed `@prunellejs/*` package and every dependency in the app's `package.json` that ships one, at the installed versions; `--json` prints `{ query, words, packages, matches }`.
|
|
104
116
|
- `prunelle mcp [dir] [--allow-write]`: stdio MCP server for coding agents exposing `check`, `inspect`, `build_analyze`, `build` (requires `--allow-write`), `render` (a method other than GET, HEAD or OPTIONS requires `--allow-write`), `docs` and `dev_errors` tools, plus `prunelle://llms/<pkg>` resources; it reloads `prunelle.config.ts` fresh on every tool call, and paths stay inside the project.
|
|
105
117
|
- `prunelle/ts-plugin`, added to `tsconfig.json` `compilerOptions.plugins` as `{ "name": "prunelle/ts-plugin", "site"?: "...", "compliance"?: {...} }`, surfaces compiler mistakes, compliance warnings and 18 mechanical quick fixes in `tsserver` editors (select the workspace TypeScript version in VS Code; `tsserver`-only until `tsgo` supports plugins).
|
|
106
118
|
- **Testing (`prunelle/test`)**:
|
|
107
|
-
- `const app = await testApp({ root, prebuilt?, outDir? })` builds into its own `.prunelle-cache/test-*` folder, removed at exit, never into `dist
|
|
119
|
+
- `const app = await testApp({ root, prebuilt?, outDir?, plugins? })` (`plugins` replaces those of the app's config, as a plugin's own tests mount it on a fixture app) builds into its own `.prunelle-cache/test-*` folder, removed at exit, never into `dist/`, and reuses the build of an earlier call on the same root in the process while the app's files, the files outside its root the build read, build options and `process.env` are unchanged (not with `outDir`, `plugins` or `analyze`; the app still loads afresh) (`prebuilt: true` reuses the latest testApp build of that root in the process, else `dist/`). In-process, with a persistent cookie jar and no port: `app.get()`, `app.post()`, `app.import(path)` (the app's bundled copy of a route, action file or `prunelle.config.ts`), `app.submit(action | url, fields)` (sends an empty honeypot and an aged signed timestamp for `protect`ed `ServerAction`s unless overridden), `app.fetch()`, `app.cookies`, `app.clearCookies()`, `app.clock.set(time)` / `app.clock.advance(ms)` (the `Date.now()` the app and the test read, until dispose), `app.stub(url | RegExp, Response | (request) => Response)` (answers an outgoing request by origin and path; one leaving the machine with no stub is refused with its URL and makes `dispose()` throw, loopback goes through, and a `fetch` mock the test set first answers everything instead), `app.dispose()` (`await using app = await testApp(...)`).
|
|
108
120
|
- Unhandled errors in routes, actions, plugin routes and streamed `<Suspense>` boundaries log their source, method, path and stack to stderr (`console.error`) under `prunelle start` and `prunelle dev` when no `onError` hook is configured (an `onError` handles them without doubling). `testApp()` captures them silently in `app.errors` (`route GET /p: message`); `testApp({ dev: true })` shows them in the 500 like `prunelle dev` does.
|
|
109
121
|
- With `dev` (`prunelle dev`, `testApp({ dev: true })`), the 500 carries message and stack, each frame at its `src/` file and line (under `prunelle start` too, through the source maps `prunelle build` writes; a `--compile` binary names its own code), as JSON `{ ok: false, status: 500, error, stack }` when the request wants JSON, else text; `_error.tsx` still renders. Production stays `Internal Server Error`, and `_error.tsx` receives that message too, never the thrown one. `prunelle dev` build errors also answer JSON/text per `Accept`.
|
|
110
|
-
- Islands: `const b = await testBrowser({ root, timeout?, browserPath? })` (needs `playwright-core` as a dev dependency and Chrome/Chromium; serves the production build on `b.origin`, a free 127.0.0.1 port), then `const page = await b.open(path)`, which resolves once the page has loaded and its `load`/`client` islands have hydrated (`visible`, `idle`, `interaction` and `media(...)` ones are the test's to trigger); `b.open(path, { reducedMotion: true })` asks for less motion.
|
|
122
|
+
- Islands: `const b = await testBrowser({ root, timeout?, browserPath? })` (needs `playwright-core` as a dev dependency and Chrome/Chromium; serves the production build on `b.origin`, a free 127.0.0.1 port), then `const page = await b.open(path)`, which resolves once the page has loaded and its `load`/`client` islands have hydrated (`visible`, `idle`, `interaction` and `media(...)` ones are the test's to trigger); `b.open(path, { reducedMotion: true })` asks for less motion; `b.mount('src/islands/Counter.tsx', { start: 2 }, { export?: 'Counter' })` opens that one component alone on an empty page, hydrated the same way, with no route to write (props are JSON, each component is built once per testBrowser).
|
|
111
123
|
- `page` has a live `page.url`, `page.click(sel)`, `page.hover(sel)`, `page.fill(sel, value)`, `page.press(key)`, `page.text(sel)`, `page.waitFor(sel | fn)`, `page.evaluate(fn)`, `page.errors` (page errors, console errors, 4xx/5xx responses) and `page.close()`; end with `await b.close()`.
|
|
112
124
|
- **Plugins (`prunelle.config.ts`)**: `export default defineConfig({ plugins: [...] })` / `definePlugin(...)`. Order with `enforce: 'pre' | 'post'` and `after: ['@prunellejs/i18n']` (a name no plugin has is an optional dependency, unless it is one typo from one that is, which fails). Two plugins sharing a `name` fail, and so does an unknown config key, naming the closest one.
|
|
113
125
|
- A stateful plugin's `createX()` returns the plugin and the app's handle in one object: `plugins: [auth, mail, rooms]`, with `auth.guard()`, `mail.send()`, `rooms.publish()` in routes. Stateless plugins are `x()`.
|
|
114
126
|
- `server(api)`: `use(mw, { scope? })` (`'all'` default, prerendered pages included; `'rendered'` skips prerendered pages, for middleware that only feeds rendering such as a session; `'dynamic'` also skips pages with no `load`; or a path prefix), `rewrite` (also run once per prerendered page at start, on an anonymous GET: no side effects), `healthCheck(name, fn)` (feeds `/_pru/health`; returning `false` or throwing turns it `503`), `provide(key, value)`/`inject(key)` typed by `serviceKey<T>(name)` from `prunelle/config`, `getBuildData`. `api.dev` is true under `prunelle dev`, and `api.devExposed` when `prunelle dev --host` binds an address other machines reach: a dev-only route that writes or reveals data refuses to start unguarded then.
|
|
115
|
-
- `api.route(method, path, handler, { csrf?, trustedOrigins?, trustProxy?, rateLimit?, encodedSlashes? })`: `rateLimit: { max, windowMs, key? }` answers `429` with `Retry-After` before the handler past `max` per window, per `ctx.ip` or `key(ctx)`; `encodedSlashes: true` lets a `*name` catch-all take a segment holding `%2F`, `%5C` or `%00`, left encoded in the param, for text such as a URL, never a file path (on a path with no catch-all it throws). Responses get the security headers; an HTML one without its own CSP gets the app's, its `<style>` blocks hashed.
|
|
116
|
-
- `api.rateLimiter({ max, windowMs })` returns a limiter in the server's store (
|
|
117
|
-
- Build hooks: `build(ctx)` (`emitAsset`, `emitPublic`, `addStyle`, `addRouteStyle`, `addHead`, `addRouteHead`, `provide`, `inject`, `setData`, `routes`), `afterPrerender(ctx)` (`routes`, `publicFiles`, `assets`, `emitAsset`, `emitPublic`, `setData`), `transform`, `bunPlugins` (array or `({ root, assetPrefix, minify, target, lang }) => [...]`), `css`, `prerenderPaths`, `clientEntry`, `
|
|
127
|
+
- `api.route(method, path, handler, { csrf?, trustedOrigins?, trustProxy?, rateLimit?, encodedSlashes? })`: `rateLimit: { max, windowMs, key? }` answers `429` with `Retry-After` before the handler past `max` per window, per `ctx.ip` or `key(ctx)`; `encodedSlashes: true` lets a `*name` catch-all take a segment holding `%2F`, `%5C` or `%00`, left encoded in the param, for text such as a URL, never a file path (on a path with no catch-all it throws). A GET route at the path of an app page (plugin routes are matched first) stops the server at start and fails `prunelle check`, naming the plugin and the page. Responses get the security headers; an HTML one without its own CSP gets the app's, its `<style>` blocks hashed.
|
|
128
|
+
- `api.rateLimiter({ max, windowMs }, name?)` returns a limiter in the server's store (each limiter keeps at most 10 000 keys and 1 000 000 hits, not the store as a whole; swept every minute, dropped with the server) for a limit a route option cannot key, such as per email: `await hit(key)` returns 0, or the whole seconds to wait; `await peek(key)` answers the same without counting, to check a limit that only some outcomes count. With `store` set it counts there under the plugin's name and `name` (default: its order among the plugin's limiters), so name a limiter created while serving requests.
|
|
129
|
+
- Build hooks: `build(ctx)` (`routesDir`, `emitAsset`, `emitPublic`, `addStyle`, `addRouteStyle`, `addHead`, `addRouteHead`, `provide`, `inject`, `setData`, `routes`), `afterPrerender(ctx)` (`routes`, `publicFiles`, `assets`, `emitAsset`, `emitPublic`, `setData`), `transform`, `bunPlugins` (array or `({ root, assetPrefix, minify, target, lang, multiLocale }) => [...]`), `css`, `prerenderPaths`, `clientEntry`, `watchPaths`, `commands`.
|
|
130
|
+
- `cookies`: the cookies the plugin sets, `{ name, purpose: string | { en, fr }, category, maxAge? }[]` (no `maxAge`: a session cookie) or `({ site }) => [...]`, listed by `<CookieTable>`; `CookieDeclaration` from `prunelle/config`.
|
|
131
|
+
- `processing`: the personal data the plugin processes, `{ name, purpose, people, data: string[], legalBasis?, retention?, recipients?, security?, formActions? }[]` in French (a field left out becomes a `[à compléter : ...]`) or `({ site }) => [...]`, written by `prunelle rgpd --draft` into the privacy notice and the record of processing; `ProcessingDeclaration` from `prunelle/config`.
|
|
118
132
|
- Page hooks: `head(head, ctx)`, `transformHtml`, `inlineScripts` (the inline scripts the plugin writes into pages, each as it stands between its tags: every page's CSP allows them by hash, since prunelle never hashes a script it finds in a page), `onError(info)` (`{ error, request, source, requestId }`), `check(ctx)`.
|
|
119
|
-
- `
|
|
120
|
-
-
|
|
121
|
-
-
|
|
122
|
-
|
|
123
|
-
- `@prunellejs/
|
|
133
|
+
- `perProcess: '<clause>'` names what goes wrong when several processes serve the app with no `store` (`@prunellejs/live`: `publish() reaches the streams of its own process only`); `prunelle start --workers` prints it.
|
|
134
|
+
- `requires({ root, site, consentCategories })` returns one message per setting the plugin needs in production, naming it and its fix: a production start (`NODE_ENV=production`, not `prunelle dev`) refuses while any is unmet, listing them all; `prunelle dev`, tests and `prunelle check` warn once each; a throwing `requires` counts as unmet. First-party: auth refuses an in-memory store, a missing or short `secret`, a missing `mailer` when `requireEmailVerification` or `inactivity` is on, or a missing `site` with `inactivity`, jobs and db an in-memory database, files `memoryFiles()` or a missing signing secret, mail a missing transport or `from`, mcp a missing `token`, seo and a content feed a missing `site`, analytics a consent category `consent.categories` does not declare.
|
|
135
|
+
- Runtime state (timers, connections, caches) is created in `server(api)` and released in `api.onShutdown()`, never in the plugin factory: `prunelle dev` starts the next server on the same instance before shutting the last one down, and a new process on a `prunelle.config.ts` edit. A throwing `onShutdown`, `onError` or `onRequestEnd` hook is logged with its plugin's name; the others still run.
|
|
136
|
+
- First-party packages (21 total with `prunelle`), each with its full reference:
|
|
137
|
+
- `@prunellejs/ui` (`node_modules/@prunellejs/ui/llms.txt`): zero-JS layout, form and overlay primitives, island widgets (`Tabs`, `Menu`, `Select`, `CommandPalette`, `DataTable`, `toast()`), `@layer pru-ui` Style Grammars, `prunelle ui-eject`.
|
|
138
|
+
- `@prunellejs/auth` (`node_modules/@prunellejs/auth/llms.txt`): Argon2id passwords, hashed sessions, email verification, magic links, OAuth 2.0 + PKCE, TOTP 2FA with recovery codes, passkeys (`@prunellejs/auth/passkey`), organizations & `auth.guard({ org, role })`, RGPD export and deletion, deletion of accounts inactive for 2 years after a warning mail, `sqliteAuthStore()`.
|
|
139
|
+
- `@prunellejs/db` (`node_modules/@prunellejs/db/llms.txt`): `db.sql` tagged templates on Bun.SQL (SQLite or Postgres, the app's `store` by default), `.sql` migrations applied once each at start or by `prunelle db migrate`, and `defineSchema()` personal columns exported and erased with auth's account, purged past their retention, listed by `prunelle rgpd --draft`.
|
|
124
140
|
- `@prunellejs/jobs` (`node_modules/@prunellejs/jobs/llms.txt`): durable `bun:sqlite` job queues (`createJobs()`), Standard Schema input validation, dedup keys, retries/backoff, single-process cron `schedule()`, graceful `onShutdown()` drain, and `drainJobs()` test helper.
|
|
125
141
|
- `@prunellejs/files` (`node_modules/@prunellejs/files/llms.txt`): file upload storage (`diskFiles`, `s3Files` on Bun's S3Client, `memoryFiles`), magic-byte MIME sniffing, public & expiring HMAC signed URLs, RGPD `deleteWhere(prefix)`, traversal hardening.
|
|
126
142
|
- `@prunellejs/pwa` (`node_modules/@prunellejs/pwa/llms.txt`): offline service worker caching hashed `/_pru/` assets and pages with zero first-visit JS bundle overhead, RFC 8291/8292 Web Push (`pwa.push()`, `@prunellejs/pwa/client`), `prunelle pwa-vapid`, and manifest installability checks.
|
|
127
143
|
- `@prunellejs/content` (`node_modules/@prunellejs/content/llms.txt`): Markdown/YAML file and headless-CMS collections with Standard Schema validation, `entry.render()`, TOC and RSS feeds.
|
|
128
|
-
- `@prunellejs/cms` (`node_modules/@prunellejs/cms/llms.txt`): dev-only schema-driven CMS at `/_pru/cms` with in-page editing of content collections; 0 B in production.
|
|
129
144
|
- `@prunellejs/search` (`node_modules/@prunellejs/search/llms.txt`): build-time per-locale site search, a zero-JS `GET /search` page and a lazy client for `CommandPalette`.
|
|
145
|
+
- `@prunellejs/openapi` (`node_modules/@prunellejs/openapi/llms.txt`): an OpenAPI 3.1 document at `/openapi.json` of the actions and the API routes that `export const schema`, from their JSON Schema; dev-only unless `production: true`, limited with `prefix` or `exclude`. A plugin reads the same list with `api.surface()`.
|
|
146
|
+
- `@prunellejs/otel` (`node_modules/@prunellejs/otel/llms.txt`): OpenTelemetry traces over OTLP/HTTP with no dependency, each request a server span and its `middleware`, `load`, `render` and `stream` phases child spans, `traceparent` continued; `OTEL_EXPORTER_OTLP_ENDPOINT` names the collector.
|
|
130
147
|
- `@prunellejs/analytics` (`node_modules/@prunellejs/analytics/llms.txt`): CNIL-compliant cookie-free server-side audience measurement (Plausible, Umami, Matomo or custom), `trackEvent()`.
|
|
131
148
|
- `@prunellejs/live` (`node_modules/@prunellejs/live/llms.txt`): typed SSE rooms (`createRooms()`, `publish()`) and the browser `useLive()` hook.
|
|
132
|
-
- `@prunellejs/mcp` (`node_modules/@prunellejs/mcp/llms.txt`): MCP Streamable HTTP
|
|
149
|
+
- `@prunellejs/mcp` (`node_modules/@prunellejs/mcp/llms.txt`): MCP server over the JSON-only subset of Streamable HTTP (no SSE stream) exposing actions and handlers as tools, `prunelle mcp-footprint`.
|
|
133
150
|
- `@prunellejs/images` (`node_modules/@prunellejs/images/llms.txt`): build-time AVIF/WebP pipeline, `<Picture>`, `shareCard()` OG images.
|
|
134
151
|
- `@prunellejs/seo` (`node_modules/@prunellejs/seo/llms.txt`): title template, canonical URLs, OG/Twitter/`jsonLd()`, `sitemap.xml`, redirects, manifest, favicons, self-hosted fonts and SEO checks.
|
|
135
|
-
- `@prunellejs/i18n` (`node_modules/@prunellejs/i18n/llms.txt`): locale URLs (`ctx.locals.locale`/`t`/`localize`), `hreflang`, `Intl` formatters, `prunelle i18n-check`.
|
|
152
|
+
- `@prunellejs/i18n` (`node_modules/@prunellejs/i18n/llms.txt`): locale URLs (`ctx.locals.locale`/`t`/`localize`/`switchLocale`), plurals, typed keys, `Accept-Language` on `/`, `dir="rtl"`, `hreflang`, `Intl` formatters, `prunelle i18n-check`.
|
|
136
153
|
- `@prunellejs/icons` (`node_modules/@prunellejs/icons/llms.txt`): `~icons/<set>/<name>` inline SVG imports, accessible `<Icon>`, `prunelle icons-find`.
|
|
137
154
|
- `@prunellejs/mail` (`node_modules/@prunellejs/mail/llms.txt`): `createMailer()`, TSX email components, `MAIL_URL` (SMTP, Resend, Postmark), dev outbox at `/_pru/mail`.
|
|
138
155
|
- `@prunellejs/tailwind` (`node_modules/@prunellejs/tailwind/llms.txt`): Tailwind v4 via `tailwind()`.
|
|
139
|
-
- `@prunellejs/spa` (`node_modules/@prunellejs/spa/llms.txt`):
|
|
156
|
+
- `@prunellejs/spa` (`node_modules/@prunellejs/spa/llms.txt`): opt-in `spa()` full-page navigation with `[data-persist]` islands (`<Region>` partial swaps are built into core `prunelle`).
|
|
140
157
|
- **Server builds & `--compile`**:
|
|
141
158
|
- `prunelle build` writes a stage folder beside `outDir` and renames it in only once every step (bundles, plugin hooks, prerender, `--compile`) passed, so a failed build leaves the previous `outDir` byte-identical and a running `prunelle start` keeps serving it. Each build is marked with `.prunelle-output`; a folder holding files prunelle did not build is refused by name (an empty one or an unmarked older prunelle build is replaced; a folder holding only a subfolder named like a custom `assetPrefix` is not one). An `outDir` inside `publicDir` is refused.
|
|
142
159
|
- Once a build lands, `prunelle start` loads it in-process with no restart: requests arriving meanwhile wait for it, plugin `server()` runs again and the old build's `api.onShutdown()` hooks run, a build that fails to load is logged while the old one keeps answering, and a new port/host/`maxRequestBodySize` needs a restart. A file it can no longer read answers `404` `no-store`.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "prunelle",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.10.0",
|
|
4
4
|
"description": "Bun-native TSX web framework with zero-directive automatic islands, fine-grained signals, and single-binary deploys",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"homepage": "https://prunelle.kaynooo.fr",
|
|
@@ -33,7 +33,12 @@
|
|
|
33
33
|
"./internal/dom-extras": "./src/dom/extras.ts",
|
|
34
34
|
"./internal/dom-loop": "./src/dom/loop.ts",
|
|
35
35
|
"./internal/action": "./src/dom/action.ts",
|
|
36
|
+
"./internal/prefetch": "./src/dom/prefetch.ts",
|
|
37
|
+
"./internal/swap": "./src/dom/swap.ts",
|
|
38
|
+
"./internal/regions": "./src/dom/regions.ts",
|
|
39
|
+
"./internal/seed": "./src/reactivity/seed.ts",
|
|
36
40
|
"./internal/island": "./src/dom/island.ts",
|
|
41
|
+
"./internal/hot": "./src/dom/hot.ts",
|
|
37
42
|
"./internal/ssr": "./src/ssr/index.ts",
|
|
38
43
|
"./internal/server": "./src/server/index.ts"
|
|
39
44
|
},
|
|
@@ -46,7 +51,7 @@
|
|
|
46
51
|
"directory": "packages/prunelle"
|
|
47
52
|
},
|
|
48
53
|
"dependencies": {
|
|
49
|
-
"@kaynooo/cli-kit": "^0.
|
|
54
|
+
"@kaynooo/cli-kit": "^0.55.0",
|
|
50
55
|
"oxc-parser": "^0.155.0"
|
|
51
56
|
},
|
|
52
57
|
"peerDependencies": {
|
package/src/a11y/declaration.ts
CHANGED
|
@@ -88,14 +88,11 @@ export function escapeAttr(value: string): string {
|
|
|
88
88
|
.replaceAll('>', '>')
|
|
89
89
|
}
|
|
90
90
|
|
|
91
|
+
// The day in Paris: a draft written between midnight and 2 a.m. there is still dated by the UTC day before otherwise.
|
|
91
92
|
export function formatFrenchDate(date: Date): { iso: string, human: string } {
|
|
92
|
-
const
|
|
93
|
-
const
|
|
94
|
-
|
|
95
|
-
month: 'long',
|
|
96
|
-
year: 'numeric',
|
|
97
|
-
timeZone: 'UTC',
|
|
98
|
-
}).format(date)
|
|
93
|
+
const timeZone = 'Europe/Paris'
|
|
94
|
+
const iso = new Intl.DateTimeFormat('en-CA', { day: '2-digit', month: '2-digit', year: 'numeric', timeZone }).format(date)
|
|
95
|
+
const human = new Intl.DateTimeFormat('fr-FR', { day: 'numeric', month: 'long', year: 'numeric', timeZone }).format(date)
|
|
99
96
|
return { iso, human }
|
|
100
97
|
}
|
|
101
98
|
|
|
@@ -161,8 +158,8 @@ function automatedResultParagraph(report: A11yAuditReport | undefined, axeLabel:
|
|
|
161
158
|
const violationCount = report.totalViolations
|
|
162
159
|
return [
|
|
163
160
|
' <p>',
|
|
164
|
-
` L'audit automatisé réalisé via <code>prunelle a11y</code> (${escapeJsxText(axeLabel)}, règles
|
|
165
|
-
`
|
|
161
|
+
` L'audit automatisé réalisé via <code>prunelle a11y</code> (${escapeJsxText(axeLabel)}, règles de balises ${escapeJsxText(report.tags.join(', '))})`,
|
|
162
|
+
` a porté sur <strong>${routeCount}</strong> page${routeCount === 1 ? '' : 's'} et a relevé{' '}`,
|
|
166
163
|
` <strong>${violationCount}</strong> violation${violationCount === 1 ? '' : 's'} automatisée${violationCount === 1 ? '' : 's'}.`,
|
|
167
164
|
' </p>',
|
|
168
165
|
].join('\n')
|
|
@@ -227,6 +224,8 @@ export function draftAccessibilityStatement(options: AccessibilityDeclarationOpt
|
|
|
227
224
|
const dest = resolve(root, options.outPath ?? DEFAULT_DECLARATION_PATH)
|
|
228
225
|
const relativePath = relPosix(root, dest)
|
|
229
226
|
const status = inferComplianceStatus(options.audit)
|
|
227
|
+
if (status === 'full' && options.report !== undefined && options.report.totalViolations > 0)
|
|
228
|
+
throw new Error(`prunelle: the manual audit says "totalement conforme" (rate 100) but the axe-core run in this same command found ${options.report.totalViolations} violation${options.report.totalViolations === 1 ? '' : 's'}: fix them, or lower --rate to the share of criteria the manual audit really found met.`)
|
|
230
229
|
const org = options.organization?.trim() || `${STATEMENT_PLACEHOLDER} : nom de l'organisme]`
|
|
231
230
|
const siteUrl = options.siteUrl?.trim() || `${STATEMENT_PLACEHOLDER} : adresse du site]`
|
|
232
231
|
const { iso, human } = formatFrenchDate(options.date ?? new Date())
|
|
@@ -276,16 +275,10 @@ ${manualAuditParagraph(options.audit, options.report !== undefined)}
|
|
|
276
275
|
${renderNonConformities(options.report)}
|
|
277
276
|
|
|
278
277
|
<h3>Dérogations pour charge disproportionnée</h3>
|
|
279
|
-
<p>
|
|
280
|
-
{/* TODO: lister ici les éventuelles dérogations justifiées */}
|
|
281
|
-
Aucune.
|
|
282
|
-
</p>
|
|
278
|
+
<p>${STATEMENT_PLACEHOLDER} : dérogations justifiées pour charge disproportionnée, ou « Aucune » si le site n'en invoque pas]</p>
|
|
283
279
|
|
|
284
280
|
<h3>Contenus non soumis à l'obligation d'accessibilité</h3>
|
|
285
|
-
<p>
|
|
286
|
-
{/* TODO: lister ici les contenus tiers ou archives hors périmètre */}
|
|
287
|
-
Aucun.
|
|
288
|
-
</p>
|
|
281
|
+
<p>${STATEMENT_PLACEHOLDER} : contenus tiers ou archives hors périmètre, ou « Aucun » s'il n'y en a pas]</p>
|
|
289
282
|
</section>
|
|
290
283
|
|
|
291
284
|
<section>
|