prunelle 0.8.0 → 0.9.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (184) hide show
  1. package/llms.txt +61 -44
  2. package/package.json +7 -2
  3. package/src/a11y/declaration.ts +6 -10
  4. package/src/a11y/index.ts +69 -125
  5. package/src/animate.ts +127 -0
  6. package/src/build/asides.ts +51 -0
  7. package/src/build/bundle.ts +88 -134
  8. package/src/build/client-entries.ts +6 -6
  9. package/src/build/client-outputs.ts +75 -0
  10. package/src/build/client-plugin.ts +9 -4
  11. package/src/build/ecoindex.ts +4 -2
  12. package/src/build/files.ts +18 -0
  13. package/src/build/graph.ts +14 -6
  14. package/src/build/index.ts +20 -10
  15. package/src/build/islands.ts +4 -1
  16. package/src/build/key-types.ts +31 -0
  17. package/src/build/manifest.ts +19 -1
  18. package/src/build/plugin-host.ts +2 -0
  19. package/src/build/prerender.ts +2 -2
  20. package/src/build/reach.ts +14 -1
  21. package/src/build/report.ts +1 -1
  22. package/src/build/route-types.ts +16 -0
  23. package/src/build/routes.ts +24 -15
  24. package/src/build/seed-ids.ts +65 -0
  25. package/src/build/seed-writes.ts +111 -0
  26. package/src/build/static-headers.ts +2 -2
  27. package/src/build/static.ts +1 -1
  28. package/src/cli/check-cache.ts +51 -0
  29. package/src/cli/check-consent.ts +95 -0
  30. package/src/cli/check-forms.ts +2 -2
  31. package/src/cli/check-links-patterns.ts +101 -0
  32. package/src/cli/check-links.ts +16 -100
  33. package/src/cli/check-regions.ts +185 -0
  34. package/src/cli/check-security.ts +50 -6
  35. package/src/cli/check.ts +40 -18
  36. package/src/cli/commands.ts +134 -14
  37. package/src/cli/docs.ts +21 -2
  38. package/src/cli/index.ts +1 -1
  39. package/src/cli/inspect.ts +2 -0
  40. package/src/cli/mcp-tools.ts +2 -2
  41. package/src/cli/new.ts +9 -5
  42. package/src/cli/upgrade-names.ts +14 -2
  43. package/src/cli/upgrade.ts +3 -0
  44. package/src/compiler/analyze.ts +2 -2
  45. package/src/compiler/cacheability.ts +24 -2
  46. package/src/compiler/compliance-contrast.ts +284 -0
  47. package/src/compiler/compliance-empty.ts +24 -0
  48. package/src/compiler/compliance-rgaa-content.ts +95 -0
  49. package/src/compiler/compliance-rgaa-criteria.ts +45 -0
  50. package/src/compiler/compliance-rgaa-pages.ts +140 -0
  51. package/src/compiler/compliance-rgaa.ts +19 -0
  52. package/src/compiler/compliance-third-party.ts +59 -0
  53. package/src/compiler/compliance-urls.ts +52 -0
  54. package/src/compiler/compliance.ts +70 -42
  55. package/src/compiler/cookie-inventory.ts +119 -0
  56. package/src/compiler/foreign-imports.ts +5 -3
  57. package/src/compiler/mistakes.ts +18 -9
  58. package/src/compiler/props-pattern.ts +211 -0
  59. package/src/compiler/props.ts +177 -346
  60. package/src/compiler/ssr-emit.ts +510 -0
  61. package/src/compiler/ssr-helpers.ts +170 -121
  62. package/src/compiler/ssr.ts +25 -440
  63. package/src/context.ts +14 -1
  64. package/src/dev/child.ts +1 -1
  65. package/src/dev/hot-islands.ts +71 -0
  66. package/src/dev/index.ts +31 -18
  67. package/src/dev/protocol.ts +1 -1
  68. package/src/dev/queue.ts +3 -2
  69. package/src/dev/reload.ts +1 -1
  70. package/src/dev/supervisor.ts +3 -1
  71. package/src/dev/watchers.ts +6 -2
  72. package/src/dom/action.ts +97 -14
  73. package/src/dom/extras.ts +2 -1
  74. package/src/dom/field-marks.ts +24 -0
  75. package/src/dom/hot.ts +9 -0
  76. package/src/dom/index.ts +25 -5
  77. package/src/dom/island-hot.ts +29 -0
  78. package/src/dom/island.ts +13 -2
  79. package/src/dom/prefetch.ts +132 -0
  80. package/src/dom/regions.ts +498 -0
  81. package/src/dom/swap.ts +245 -0
  82. package/src/dom/trusted.ts +22 -0
  83. package/src/dom/upload.ts +44 -0
  84. package/src/eco/declaration.ts +39 -40
  85. package/src/eco/index.ts +5 -5
  86. package/src/href.ts +31 -0
  87. package/src/index.ts +9 -3
  88. package/src/plugins/config.ts +1 -1
  89. package/src/plugins/context.ts +7 -1
  90. package/src/plugins/daily.ts +27 -0
  91. package/src/plugins/index.ts +3 -3
  92. package/src/plugins/order.ts +1 -1
  93. package/src/plugins/public.ts +8 -5
  94. package/src/plugins/services.ts +88 -14
  95. package/src/plugins/types.ts +120 -9
  96. package/src/reactivity/hmr.ts +90 -0
  97. package/src/reactivity/index.ts +38 -18
  98. package/src/reactivity/resource.ts +115 -0
  99. package/src/reactivity/seed.ts +39 -0
  100. package/src/reactivity/server-seed.ts +194 -0
  101. package/src/reactivity/store.ts +55 -1
  102. package/src/rgpd/draft.ts +171 -0
  103. package/src/rgpd/forms.ts +85 -0
  104. package/src/rgpd/index.ts +57 -0
  105. package/src/server/action-flash.ts +1 -0
  106. package/src/server/action-registry.ts +6 -8
  107. package/src/server/action.ts +51 -19
  108. package/src/server/app-secret.ts +14 -8
  109. package/src/server/cache-invalidation.ts +96 -0
  110. package/src/server/compress.ts +3 -1
  111. package/src/server/consent.ts +16 -2
  112. package/src/server/cookie-inventory.ts +78 -0
  113. package/src/server/cookies.ts +50 -0
  114. package/src/server/csp-report.ts +86 -0
  115. package/src/server/discard.ts +13 -0
  116. package/src/server/document.ts +2 -2
  117. package/src/server/env.ts +1 -1
  118. package/src/server/errors.ts +9 -2
  119. package/src/server/field-errors.ts +91 -0
  120. package/src/server/form-schema.ts +16 -11
  121. package/src/server/health.ts +33 -12
  122. package/src/server/http.ts +25 -10
  123. package/src/server/index.ts +101 -298
  124. package/src/server/loader.ts +1 -0
  125. package/src/server/page.ts +3 -9
  126. package/src/server/plugin-host.ts +26 -8
  127. package/src/server/public.ts +14 -3
  128. package/src/server/rate-limit.ts +39 -10
  129. package/src/server/region.ts +3 -0
  130. package/src/server/request-handler.ts +370 -0
  131. package/src/server/request-log.ts +94 -0
  132. package/src/server/route-cache.ts +41 -6
  133. package/src/server/route-input.ts +54 -0
  134. package/src/server/route-table.ts +35 -19
  135. package/src/server/routing.ts +12 -11
  136. package/src/server/sanitize-html.ts +1 -1
  137. package/src/server/security.ts +38 -8
  138. package/src/server/serve-handlers.ts +9 -5
  139. package/src/server/shared-store.ts +314 -0
  140. package/src/server/start.ts +12 -5
  141. package/src/server/static-dir.ts +14 -10
  142. package/src/server/stream.ts +2 -1
  143. package/src/server/surface.ts +39 -0
  144. package/src/server/webhook.ts +48 -0
  145. package/src/server/workers.ts +168 -0
  146. package/src/ssr/consent-banner.ts +20 -16
  147. package/src/ssr/consent-texts.ts +40 -0
  148. package/src/ssr/context.ts +26 -3
  149. package/src/ssr/cookie-table.ts +75 -0
  150. package/src/ssr/index.ts +23 -13
  151. package/src/ssr/navigation.ts +161 -14
  152. package/src/test/browser.ts +50 -22
  153. package/src/test/build-reuse.ts +70 -0
  154. package/src/test/index.ts +45 -6
  155. package/src/test/mount.ts +53 -0
  156. package/src/test/outside.ts +94 -0
  157. package/templates/_shared/AGENTS.md +1 -1
  158. package/templates/_shared/Dockerfile +22 -0
  159. package/templates/_shared/dockerignore +9 -0
  160. package/templates/_shared/gitignore +2 -0
  161. package/templates/app/.env.example +3 -1
  162. package/templates/app/compose.yaml +32 -0
  163. package/templates/app/db/migrations/001_notes.sql +7 -0
  164. package/templates/app/db/schema.ts +11 -0
  165. package/templates/app/package.json +1 -0
  166. package/templates/app/prunelle.config.ts +6 -0
  167. package/templates/app/src/actions/notes.ts +26 -0
  168. package/templates/app/src/auth.ts +4 -2
  169. package/templates/app/src/db.ts +5 -0
  170. package/templates/app/src/routes/dashboard/index.tsx +26 -1
  171. package/templates/app/src/routes/privacy.tsx +6 -2
  172. package/templates/app/tests/app.test.ts +14 -3
  173. package/templates/plugin/AGENTS.md +11 -0
  174. package/templates/plugin/CLAUDE.md +1 -0
  175. package/templates/plugin/README.md +27 -0
  176. package/templates/plugin/gitignore +2 -0
  177. package/templates/plugin/llms.txt +19 -0
  178. package/templates/plugin/package.json +33 -0
  179. package/templates/plugin/src/index.ts +40 -0
  180. package/templates/plugin/tests/fixture/prunelle.config.ts +4 -0
  181. package/templates/plugin/tests/fixture/src/routes/index.tsx +11 -0
  182. package/templates/plugin/tests/plugin.test.ts +42 -0
  183. package/templates/plugin/tsconfig.json +19 -0
  184. package/ts-plugin.cjs +3674 -2196
@@ -7,8 +7,8 @@ export { createAppContext, getAppContext, runWithAppContext } from './context'
7
7
  export type { AppRuntimeContext, CreateAppContextOptions } from './context'
8
8
  export { loadConfig } from './load'
9
9
  export { resolvePlugins } from './order'
10
- export { CMS_INLINE_ENABLED_SERVICE, CONTENT_COLLECTIONS_SERVICE, CONTENT_IMAGE_RESOLVER_SERVICE, I18N_CONFIG_SERVICE, JOBS_SERVICE, WEB_MANIFEST_SERVICE, serviceKey } from './services'
11
- export type { AccessedContentEntry, ActiveI18nConfig, ContentCollectionDescriptor, ContentCollectionEntrySummary, ContentCollectionsService, ContentImageResolver, ContentImageResult, JobsEnqueueOptions, JobsQueueOptions, JobsService, ServiceKey, WebManifestIcon, WebManifestInfo } from './services'
10
+ export { CONTENT_COLLECTIONS_SERVICE, CONTENT_IMAGE_RESOLVER_SERVICE, I18N_CONFIG_SERVICE, JOBS_SERVICE, registerUserDataService, USER_DATA_SERVICE, WEB_MANIFEST_SERVICE, serviceKey } from './services'
11
+ export type { ActiveI18nConfig, ContentCollectionDescriptor, ContentCollectionEntrySummary, ContentCollectionsService, ContentImageResolver, ContentImageResult, JobsEnqueueOptions, JobsQueueOptions, JobsService, ServiceKey, UserDataService, WebManifestIcon, WebManifestInfo } from './services'
12
12
  export type { ComplianceConfig, ComplianceRule } from '../compiler/compliance'
13
13
  export type { ConsentConfig } from '../server/consent'
14
- export type { BuildPluginContext, BuildPluginTarget, CheckPluginContext, DocumentHeadContext, FinalizeBuildContext, PrunelleConfig, PrunellePlugin, MiddlewareOptions, PluginRouteOptions, RequiresPluginContext, ServerErrorInfo, ServerPluginAPI, ServerRuntimeConfig } from './types'
14
+ export type { AppSurface, BuildPluginContext, BuildPluginTarget, CheckPluginContext, CookieDeclaration, DocumentHeadContext, FinalizeBuildContext, ProcessingDeclaration, PrunelleConfig, PrunellePlugin, MiddlewareOptions, PluginRouteOptions, RequestPhase, RequestRecord, RequiresPluginContext, ServerErrorInfo, ServerPluginAPI, ServerRuntimeConfig, SurfaceAction, SurfaceInput, SurfaceRoute, LogConfig } from './types'
@@ -16,7 +16,7 @@ function splitScope(name: string): { scope: string | undefined, pkg: string } {
16
16
  return { scope: undefined, pkg: name }
17
17
  }
18
18
 
19
- // Compares scoped plugin names without their shared `@scope/` prefix so short official plugins (`@prunellejs/cms` vs `@prunellejs/mcp`, `@prunellejs/seo` vs `@prunellejs/spa`) never false-positive as typos.
19
+ // Compares scoped plugin names without their shared `@scope/` prefix so short official plugins (`@prunellejs/pwa` vs `@prunellejs/spa`, `@prunellejs/seo` vs `@prunellejs/spa`) never false-positive as typos.
20
20
  function closestPluginName(depName: string, names: readonly string[]): string | undefined {
21
21
  const dep = splitScope(depName)
22
22
  if (dep.scope === undefined)
@@ -1,15 +1,18 @@
1
1
  // `prunelle/config`: what `prunelle.config.ts` and plugin packages use.
2
2
 
3
- export { a11y, auditAccessibility, draftAccessibilityStatement, formatA11yReport, rgaaCriteriaForAxeRule } from '../a11y/index'
4
- export type { A11yAuditOptions, A11yAuditReport, A11yImpact, A11yPluginOptions, A11yRouteReport, A11yViolation, A11yViolationNode, AccessibilityDeclarationOptions, AccessibilityDeclarationResult, ComplianceStatus, RgaaCriterion } from '../a11y/index'
3
+ export { auditAccessibility, draftAccessibilityStatement, formatA11yReport, rgaaCriteriaForAxeRule } from '../a11y/index'
4
+ export type { A11yAuditOptions, A11yAuditReport, A11yImpact, A11yRouteReport, A11yViolation, A11yViolationNode, AccessibilityDeclarationOptions, AccessibilityDeclarationResult, ComplianceStatus, RgaaCriterion } from '../a11y/index'
5
5
  export { isInside } from '../build/is-inside'
6
6
  export { distLocator, firstLoadUrls, measureFirstLoad } from '../build/first-load'
7
7
  export type { FirstLoad, Locate } from '../build/first-load'
8
8
  export { brotliSize } from '../build/precompress'
9
+ export { writeKeyTypes } from '../build/key-types'
10
+ export type { KeyTypes } from '../build/key-types'
9
11
  export { minifyCss } from '../build/style-bundles'
10
12
  export { defineConfig, definePlugin } from './config'
11
- export { CMS_INLINE_ENABLED_SERVICE, CONTENT_COLLECTIONS_SERVICE, CONTENT_IMAGE_RESOLVER_SERVICE, I18N_CONFIG_SERVICE, JOBS_SERVICE, serviceKey, UI_KUI_LAYER_SERVICE, WEB_MANIFEST_SERVICE } from './services'
12
- export type { AccessedContentEntry, ActiveI18nConfig, ContentCollectionDescriptor, ContentCollectionEntrySummary, ContentCollectionsService, ContentImageResolver, ContentImageResult, JobsEnqueueOptions, JobsQueueOptions, JobsService, ServiceKey, WebManifestIcon, WebManifestInfo } from './services'
13
+ export { scheduleDaily } from './daily'
14
+ export { CONTENT_COLLECTIONS_SERVICE, CONTENT_IMAGE_RESOLVER_SERVICE, I18N_CONFIG_SERVICE, JOBS_SERVICE, PUBLIC_FILES_SERVICE, registerUserDataService, serviceKey, UI_LAYER_SERVICE, USER_DATA_SERVICE, WEB_MANIFEST_SERVICE } from './services'
15
+ export type { ActiveI18nConfig, ContentCollectionDescriptor, ContentCollectionEntrySummary, ContentCollectionsService, ContentImageResolver, ContentImageResult, JobsEnqueueOptions, JobsQueueOptions, JobsService, PublicFile, PublicFilesService, ServiceKey, UserDataService, WebManifestIcon, WebManifestInfo } from './services'
13
16
  export type { ComplianceConfig, ComplianceRule } from '../compiler/compliance'
14
17
  export type { ConsentConfig } from '../server/consent'
15
- export type { BudgetConfig, BuildPluginContext, BuildPluginTarget, CheckPluginContext, DocumentHeadContext, FinalizeBuildContext, PrunelleConfig, PrunellePlugin, MiddlewareOptions, PluginRouteOptions, RequiresPluginContext, ServerErrorInfo, ServerPluginAPI, ServerRuntimeConfig } from './types'
18
+ export type { AppSurface, BudgetConfig, BuildPluginContext, BuildPluginTarget, CheckPluginContext, CookieDeclaration, DocumentHeadContext, FinalizeBuildContext, ProcessingDeclaration, PrunelleConfig, PrunellePlugin, MiddlewareOptions, PluginRouteOptions, RequestPhase, RequestRecord, RequiresPluginContext, ServerErrorInfo, ServerPluginAPI, ServerRuntimeConfig, SurfaceAction, SurfaceInput, SurfaceRoute, LogConfig } from './types'
@@ -1,6 +1,5 @@
1
1
  // Service keys: `serviceKey` for any plugin, and the keys shared between two plugins, kept in core as contracts so neither depends on the other.
2
2
 
3
- import type { RequestContext } from '../server/http'
4
3
  import type { StandardSchemaV1 } from '../server/standard-schema'
5
4
 
6
5
  declare const SERVICE_TYPE: unique symbol
@@ -23,8 +22,8 @@ export interface ActiveI18nConfig {
23
22
 
24
23
  export const I18N_CONFIG_SERVICE = serviceKey<ActiveI18nConfig>('prunelle.i18n.config')
25
24
 
26
- /** Set by `@prunellejs/ui` when it emits its grammar layer, so `@prunellejs/tailwind` places the `kui` layer between its base and utilities layers. */
27
- export const UI_KUI_LAYER_SERVICE = serviceKey<boolean>('prunelle.ui.kuiLayer')
25
+ /** Set by `@prunellejs/ui` when it emits its grammar layer, so `@prunellejs/tailwind` places the `pru-ui` layer between its base and utilities layers. */
26
+ export const UI_LAYER_SERVICE = serviceKey<boolean>('prunelle.ui.layer')
28
27
 
29
28
  export interface ContentImageResult {
30
29
  src: string
@@ -64,24 +63,13 @@ export interface ContentCollectionDescriptor {
64
63
  clearCache(): void
65
64
  }
66
65
 
67
- export interface AccessedContentEntry {
68
- readonly collection: string
69
- readonly slug: string
70
- readonly locale?: string | undefined
71
- }
72
-
73
66
  export interface ContentCollectionsService {
74
67
  list(root?: string): readonly ContentCollectionDescriptor[] | Promise<readonly ContentCollectionDescriptor[]>
75
68
  discover?(root: string): Promise<readonly ContentCollectionDescriptor[]>
76
- /** Returns file-backed content entries accessed during the given dev request (primary `get()` entries first). */
77
- accessedEntries?(ctx: RequestContext): readonly AccessedContentEntry[]
78
69
  }
79
70
 
80
71
  export const CONTENT_COLLECTIONS_SERVICE = serviceKey<ContentCollectionsService>('prunelle.content.collections')
81
72
 
82
- /** Provided by `@prunellejs/cms` in dev mode when in-page editing is enabled so `@prunellejs/content` emits body anchor comments. */
83
- export const CMS_INLINE_ENABLED_SERVICE = serviceKey<boolean>('prunelle.cms.inline')
84
-
85
73
  export interface JobsQueueOptions {
86
74
  attempts?: number | undefined
87
75
  backoff?: 'exponential' | 'fixed' | number | undefined
@@ -97,10 +85,80 @@ export interface JobsService {
97
85
  queue<T = unknown>(name: string, handler: (data: T) => void | Promise<void>, options?: JobsQueueOptions): void
98
86
  enqueue<T = unknown>(name: string, data: T, options?: JobsEnqueueOptions): Promise<void> | void
99
87
  drain?(options?: { now?: number | undefined, includeDelayed?: boolean | undefined }): Promise<number>
88
+ /** Runs `handler` on a 5-field cron, in one process of the app per tick. */
89
+ schedule?(name: string, cron: string, handler: () => void | Promise<void>, options?: { timeZone?: string | undefined }): void
100
90
  }
101
91
 
102
92
  export const JOBS_SERVICE = serviceKey<JobsService>('prunelle.jobs.service')
103
93
 
94
+ /** The rows a plugin keeps about one user, which `@prunellejs/auth` adds to an account's export and erases with it. */
95
+ export interface UserDataService {
96
+ /** Keyed by where the rows come from, such as a table name. */
97
+ exportUser(userId: string): Promise<Record<string, unknown>>
98
+ /** A throw keeps the account. */
99
+ deleteUser(userId: string): Promise<void>
100
+ }
101
+
102
+ /** Provided by plugins keeping personal data (such as `@prunellejs/db` and `@prunellejs/files`), read by `@prunellejs/auth` when it exports or deletes an account. */
103
+ export const USER_DATA_SERVICE = serviceKey<UserDataService>('prunelle.userData')
104
+
105
+ const USER_DATA_PROVIDERS = Symbol.for('prunelle.userData.providers')
106
+
107
+ interface CompositeUserDataService extends UserDataService {
108
+ readonly [USER_DATA_PROVIDERS]: UserDataService[]
109
+ }
110
+
111
+ function providersOf(service: UserDataService): readonly UserDataService[] {
112
+ return USER_DATA_PROVIDERS in service ? (service as CompositeUserDataService)[USER_DATA_PROVIDERS] : [service]
113
+ }
114
+
115
+ /** Merges two `UserDataService` providers into one that runs every registered provider's `exportUser` and `deleteUser`. */
116
+ export function mergeUserDataServices(existing: UserDataService | undefined, added: UserDataService): UserDataService {
117
+ if (existing === undefined)
118
+ return added
119
+ const incoming = providersOf(added)
120
+ if (USER_DATA_PROVIDERS in existing) {
121
+ const list = (existing as CompositeUserDataService)[USER_DATA_PROVIDERS]
122
+ for (const provider of incoming) {
123
+ if (!list.includes(provider))
124
+ list.push(provider)
125
+ }
126
+ return existing
127
+ }
128
+ const providers: UserDataService[] = [existing]
129
+ for (const provider of incoming) {
130
+ if (!providers.includes(provider))
131
+ providers.push(provider)
132
+ }
133
+ if (providers.length === 1)
134
+ return existing
135
+ const composite: CompositeUserDataService = {
136
+ [USER_DATA_PROVIDERS]: providers,
137
+ async exportUser(userId) {
138
+ const out: Record<string, unknown> = {}
139
+ for (const provider of providers)
140
+ Object.assign(out, await provider.exportUser(userId))
141
+ return out
142
+ },
143
+ async deleteUser(userId) {
144
+ for (const provider of providers)
145
+ await provider.deleteUser(userId)
146
+ },
147
+ }
148
+ return composite
149
+ }
150
+
151
+ /** Registers an RGPD user-data provider so `api.inject(USER_DATA_SERVICE)` merges exports and runs deletions across every registered plugin. */
152
+ export function registerUserDataService(
153
+ api: { provide<T>(key: ServiceKey<T>, value: T): void, inject<T>(key: ServiceKey<T>): T | undefined },
154
+ service: UserDataService,
155
+ ): void {
156
+ const existing = api.inject(USER_DATA_SERVICE)
157
+ const merged = mergeUserDataServices(existing, service)
158
+ if (merged !== existing)
159
+ api.provide(USER_DATA_SERVICE, merged)
160
+ }
161
+
104
162
  export interface WebManifestIcon {
105
163
  readonly src: string
106
164
  readonly sizes?: string | undefined
@@ -118,3 +176,19 @@ export interface WebManifestInfo {
118
176
  }
119
177
 
120
178
  export const WEB_MANIFEST_SERVICE = serviceKey<WebManifestInfo>('prunelle.webManifest')
179
+
180
+ /** A public uploaded file, found by the path it is served at. */
181
+ export interface PublicFile {
182
+ readonly contentType: string
183
+ /** Changes whenever the bytes do. */
184
+ readonly etag: string
185
+ bytes(): Promise<Uint8Array<ArrayBuffer>>
186
+ }
187
+
188
+ export interface PublicFilesService {
189
+ /** The public file served at `path` (`/files/avatars/a.jpg`); undefined for a path it does not serve, a missing file and a private one. */
190
+ find(path: string): Promise<PublicFile | undefined>
191
+ }
192
+
193
+ /** Provided by `@prunellejs/files`, read by `@prunellejs/images` to resize an upload. */
194
+ export const PUBLIC_FILES_SERVICE = serviceKey<PublicFilesService>('prunelle.files.public')
@@ -4,7 +4,7 @@ import type { BunPlugin } from 'bun'
4
4
  import type { RouteManifestEntry } from '../build/index'
5
5
  import type { ComplianceConfig } from '../compiler/compliance'
6
6
  import type { ConsentConfig } from '../server/consent'
7
- import type { HealthCheckConfig, HealthCheckFn, HealthCheckResult } from '../server/health'
7
+ import type { HealthCheckConfig, HealthCheckFn, HealthCheckResult, RequestPhaseName } from '../server/health'
8
8
  import type { Middleware, RequestContext } from '../server/index'
9
9
  import type { RateLimit, RateLimiter } from '../server/rate-limit'
10
10
  import type { RouteCacheOptions } from '../server/route-cache'
@@ -18,6 +18,8 @@ export type BuildPluginTarget = 'client' | 'server' | 'compile'
18
18
 
19
19
  export interface BuildPluginContext {
20
20
  readonly root: string
21
+ /** The app's routes folder, absolute (`src/routes` unless the config moves it). */
22
+ readonly routesDir?: string | undefined
21
23
  readonly outDir: string
22
24
  readonly assetPrefix: string
23
25
  readonly site?: string | undefined
@@ -86,6 +88,8 @@ export interface CheckPluginContext {
86
88
  readonly routesDir: string
87
89
  /** The app's own static folder (`publicDir`, `public/` by default), as `prunelle check` resolved it. */
88
90
  readonly publicDir?: string | undefined
91
+ /** The app's `site` from `prunelle.config.ts`, left out when it sets none. */
92
+ readonly site?: string | undefined
89
93
  /** Report a validation error from `prunelle check`. */
90
94
  error(message: string): void
91
95
  /** Report what may be intended but usually is not; `prunelle check --strict` fails on it. */
@@ -102,6 +106,8 @@ export interface RequiresPluginContext {
102
106
  readonly site: string | undefined
103
107
  /** The categories `consent.categories` declares, `essential` left out; empty when the app declares none. */
104
108
  readonly consentCategories: readonly string[]
109
+ /** `PrunelleConfig.store`, when the app sets it: a plugin that keeps data can use the same database. */
110
+ readonly store?: string | undefined
105
111
  }
106
112
 
107
113
  export interface PluginRouteOptions {
@@ -130,6 +136,35 @@ export interface MiddlewareOptions {
130
136
  scope?: 'all' | 'rendered' | 'dynamic' | string | undefined
131
137
  }
132
138
 
139
+ /** What an action or an API route takes: no schema, a schema with its JSON Schema, or a schema whose library gives none (`vendor` names it). */
140
+ export type SurfaceInput =
141
+ | { readonly kind: 'none' }
142
+ | { readonly kind: 'json', readonly schema: Readonly<Record<string, unknown>> }
143
+ | { readonly kind: 'unsupported', readonly vendor: string, /** What the library threw converting the schema, when it has a converter that failed. */ readonly reason?: string | undefined }
144
+
145
+ /** A server action as an outside client calls it: `POST url`. */
146
+ export interface SurfaceAction {
147
+ /** The export's name. */
148
+ readonly name: string
149
+ readonly url: string
150
+ readonly input: SurfaceInput
151
+ /** The calls one client may make, when the action limits them. */
152
+ readonly rateLimited: boolean
153
+ }
154
+
155
+ /** An API route (a route with method exports and no page): `input` is its `export const schema`, the body of a method that takes one and the query of `GET`. */
156
+ export interface SurfaceRoute {
157
+ /** Such as `/api/users/:id`. */
158
+ readonly path: string
159
+ readonly methods: readonly string[]
160
+ readonly input: SurfaceInput
161
+ }
162
+
163
+ export interface AppSurface {
164
+ readonly actions: readonly SurfaceAction[]
165
+ readonly routes: readonly SurfaceRoute[]
166
+ }
167
+
133
168
  export interface ServerPluginAPI {
134
169
  readonly root: string
135
170
  readonly outDir: string
@@ -147,8 +182,8 @@ export interface ServerPluginAPI {
147
182
  use(middleware: Middleware, options?: MiddlewareOptions): void
148
183
  /** Register a custom HTTP route (e.g. GET /sitemap.xml, POST /auth/callback). */
149
184
  route(method: string, path: string, handler: (ctx: RequestContext) => Response | Promise<Response>, options?: PluginRouteOptions): void
150
- /** A limiter counting in this server's store, for limits a route option cannot express (per account, per email): `hit(key)` returns 0, or the seconds to wait, and `peek(key)` answers the same without counting. */
151
- rateLimiter(limit: Pick<RateLimit, 'max' | 'windowMs'>): RateLimiter
185
+ /** A limiter counting in this server's store, for limits a route option cannot express (per account, per email): `await hit(key)` returns 0, or the seconds to wait, and `peek(key)` answers the same without counting. With a shared `store`, every process counts one window per `name` (default: the plugin's name and the call's order). */
186
+ rateLimiter(limit: Pick<RateLimit, 'max' | 'windowMs'>, name?: string): RateLimiter
152
187
  /** Rewrite an incoming pathname before route matching (e.g. strip /fr locale prefix). */
153
188
  rewrite(fn: (pathname: string, ctx: RequestContext) => string | undefined): void
154
189
  /** Register a server-scoped service for other plugins or render-time helpers (isolated per server instance). */
@@ -161,12 +196,45 @@ export interface ServerPluginAPI {
161
196
  healthCheck(name: string, fn: HealthCheckFn): void
162
197
  /** Register a shutdown cleanup callback run when `app.dispose()` is called (dev reloads, tests, graceful exit). */
163
198
  onShutdown(fn: () => void | Promise<void>): void
199
+ /** The app's server actions and API routes with the JSON Schema of their input, for a plugin that describes them to outside clients. Read it when a request needs it: a dev server reloads the modules. */
200
+ surface(): AppSurface
201
+ /** Hear each request once its response is ready, with its status, duration and phases (traces, metrics). A server with no such hook and no access log measures nothing. */
202
+ onRequestEnd(fn: (record: RequestRecord) => void): void
203
+ }
204
+
205
+ /** One phase of a request: `middleware` is the time spent in middlewares before and after the page, drawn from where the chain began. */
206
+ export interface RequestPhase {
207
+ name: RequestPhaseName
208
+ /** Milliseconds since the epoch. */
209
+ start: number
210
+ duration: number
211
+ }
212
+
213
+ /** A request the server answered, as the access log and `onRequestEnd` hooks hear it. */
214
+ export interface RequestRecord {
215
+ request: Request
216
+ requestId: string | undefined
217
+ status: number
218
+ /** When the request arrived, in milliseconds since the epoch. */
219
+ start: number
220
+ /** Milliseconds until the response was ready to send; a streamed body goes on after. */
221
+ duration: number
222
+ /** The phases the request went through, in the order they began: none for a file or a prerendered page. */
223
+ phases: readonly RequestPhase[]
224
+ }
225
+
226
+ export interface LogConfig {
227
+ /** `'json'` prints each unhandled error as one JSON line with its request id, source, method and path (default `'text'`). */
228
+ format?: 'text' | 'json' | undefined
229
+ /** Prints one line per request to stdout: method, path (never the query), status, duration and request id. */
230
+ access?: boolean | undefined
164
231
  }
165
232
 
166
233
  export interface ServerErrorInfo {
167
234
  error: unknown
168
235
  request: Request
169
- source: 'route' | 'action' | 'plugin'
236
+ /** `'csp'` is a violation report the browser sent under `security.cspReports`: `error.cause` holds its `directive`, `blockedUrl`, `page`, and `sourceFile` and `line` when the browser gave them. */
237
+ source: 'route' | 'action' | 'plugin' | 'csp'
170
238
  requestId?: string | undefined
171
239
  }
172
240
 
@@ -183,6 +251,39 @@ export interface DocumentHeadContext {
183
251
  add(html: string): void
184
252
  }
185
253
 
254
+ /** A cookie a plugin sets, listed by `<CookieTable>`. */
255
+ export interface CookieDeclaration {
256
+ name: string
257
+ /** What the cookie is for: one text, or one per language such as `{ en: 'Keeps you signed in.', fr: 'Vous garde connecté.' }`. */
258
+ purpose: string | Readonly<Record<string, string>>
259
+ /** `'essential'`, or the consent category the cookie waits for. */
260
+ category: string
261
+ /** Lifetime in seconds; left out for a cookie that ends with the browser session. */
262
+ maxAge?: number | undefined
263
+ }
264
+
265
+ /** Personal data a plugin processes, which `prunelle rgpd --draft` writes into the privacy notice and the record of processing; in French, as both are. */
266
+ export interface ProcessingDeclaration {
267
+ /** Such as `'Comptes et connexion'`. */
268
+ name: string
269
+ /** What the data is used for (finalité). */
270
+ purpose: string
271
+ /** Whose data it is, such as `'les personnes inscrites'`; left out, the publisher writes it. */
272
+ people?: string | undefined
273
+ /** One item per kind of data, such as `['adresse e-mail', 'empreinte du mot de passe']`. */
274
+ data: readonly string[]
275
+ /** The RGPD art. 6 basis, when the plugin can tell; left out, the publisher writes it. */
276
+ legalBasis?: string | undefined
277
+ /** How long the data is kept. */
278
+ retention?: string | undefined
279
+ /** Who else receives it, such as the mail provider. */
280
+ recipients?: readonly string[] | undefined
281
+ /** What protects it, for the record of processing. */
282
+ security?: readonly string[] | undefined
283
+ /** Paths whose forms feed this processing, such as `'/auth/'`: a form posting under one is not listed again as the app's own. */
284
+ formActions?: readonly string[] | undefined
285
+ }
286
+
186
287
  export interface PrunellePlugin {
187
288
  name: string
188
289
  /** Execution phase: `'pre'` runs before normal plugins, `'post'` runs after them. */
@@ -204,9 +305,11 @@ export interface PrunellePlugin {
204
305
  /** Code transform run during client & server compilation (`.ts` and `.tsx`). */
205
306
  transform?: (code: string, id: string, target: 'server' | 'client') => string | undefined | void
206
307
  /** Native Bun.build plugins (e.g. bun-plugin-tailwind, images, icons). Factory is invoked per build target. */
207
- bunPlugins?: BunPlugin[] | ((info: { root: string, assetPrefix: string, minify: boolean, target: BuildPluginTarget, lang?: string | undefined }) => BunPlugin[]) | undefined
308
+ bunPlugins?: BunPlugin[] | ((info: { root: string, assetPrefix: string, minify: boolean, target: BuildPluginTarget, lang?: string | undefined, multiLocale?: boolean | undefined }) => BunPlugin[]) | undefined
208
309
  /** Global CSS files to bundle and inject as <link rel="stylesheet"> in <head>. */
209
310
  css?: string[] | undefined
311
+ /** Set `true` when this plugin scans app source files (e.g. Tailwind utility classes) to produce client CSS, so `prunelle dev` rebuilds client CSS on static `.tsx`/`.ts` edits. */
312
+ affectsClientCss?: boolean | undefined
210
313
  /** Mutate `<html lang>`, `htmlAttrs`, `<title>`, or append tags to `<head>` before core renders the document once. */
211
314
  head?: (head: DocumentHeadContext, ctx: RequestContext) => void | Promise<void>
212
315
  /** Post-process rendered HTML before sending (applies to pages, `<Suspense>` shells, `_error.tsx`, and `_404.tsx`). */
@@ -217,8 +320,12 @@ export interface PrunellePlugin {
217
320
  clientEntry?: string | undefined
218
321
  /** Inline scripts the plugin writes into pages (from `head`, `transformHtml` or `addHead`), each as it stands between its tags: the CSP of every page allows them by hash. */
219
322
  inlineScripts?: readonly string[] | undefined
220
- /** Client module bundled on its own and loaded only on routes whose tree renders a `<Region>`; every other page stays free of it. */
221
- regionClientEntry?: string | undefined
323
+ /** The cookies the plugin sets, for `<CookieTable>`; a function gets the app's `site`, for a name that depends on https. */
324
+ cookies?: readonly CookieDeclaration[] | ((app: { site: string | undefined }) => readonly CookieDeclaration[]) | undefined
325
+ /** The personal data the plugin processes, for the privacy notice and the record of processing `prunelle rgpd --draft` writes. */
326
+ processing?: readonly ProcessingDeclaration[] | ((app: { site: string | undefined }) => readonly ProcessingDeclaration[]) | undefined
327
+ /** What goes wrong when several processes serve the app with no `store`, as a clause (`"publish() reaches the streams of its own process only"`): `prunelle start --workers` warns with it. */
328
+ perProcess?: string | undefined
222
329
  /**
223
330
  * What the plugin needs to run in production, read from its options, the app's config and the environment: one message per unmet setting, naming it and its fix.
224
331
  * A production start refuses while any is unmet, listing them all; `prunelle dev`, tests and `prunelle check` warn.
@@ -228,8 +335,8 @@ export interface PrunellePlugin {
228
335
  check?: (ctx: CheckPluginContext) => void | Promise<void>
229
336
  /** Extra directories or files (relative to app root or absolute) for `prunelle dev` to watch. */
230
337
  watchPaths?: string[] | ((root: string) => string[]) | undefined
231
- /** Register custom CLI subcommands (e.g. `prunelle i18n check`). */
232
- commands?: Record<string, (args: string[], root: string) => void | Promise<void>> | undefined
338
+ /** Register custom CLI subcommands (e.g. `prunelle i18n check`); `app.store` is `PrunelleConfig.store`, for a command that opens the app's database. */
339
+ commands?: Record<string, (args: string[], root: string, app: { store: string | undefined }) => void | Promise<void>> | undefined
233
340
  }
234
341
 
235
342
  /** Shared runtime server options inherited from `prunelle.config.ts` and overridable by `createServer`, `testApp`, `devServer`, and `--compile`. */
@@ -251,9 +358,13 @@ export interface ServerRuntimeConfig {
251
358
  compress?: boolean | undefined
252
359
  /** Bounded in-memory cache for routes exporting `export const cache = ...` (default: 500 entries / 32 MiB; set `false` to disable). */
253
360
  routeCache?: RouteCacheOptions | false | undefined
361
+ /** The store every process of the app shares, for rate limits, live messages and cache invalidation: a SQLite file (`'data/app.db'`, resolved against the app root) or a `postgres://` URL. Unset, each process keeps them in its own memory. */
362
+ store?: string | undefined
254
363
  /** Health check function or named check map evaluated on `GET ${assetPrefix}/health`. */
255
364
  healthCheck?: HealthCheckConfig | undefined
256
365
  onError?: ((info: ServerErrorInfo) => void) | undefined
366
+ /** How the server logs: unhandled errors as JSON lines, and an access log. */
367
+ log?: LogConfig | undefined
257
368
  plugins?: PrunellePlugin[] | undefined
258
369
  }
259
370
 
@@ -0,0 +1,90 @@
1
+ // Dev only: what `prunelle dev` needs to swap an island's code in an open page and keep its state. The island chunks `prunelle dev` builds import this module, which puts its hooks on the page; no other module imports it, so a production build holds none of it.
2
+
3
+ import type { Signal } from './graph'
4
+
5
+ /** A signal an island made while it rendered, and what its declaration was. */
6
+ export interface HmrSignal { k: string, s: Signal<unknown> }
7
+
8
+ /** What the reactivity and DOM runtimes call, once an island chunk has put it on the page. */
9
+ export interface HmrHooks {
10
+ /** Lists a signal made now, and gives it the value the previous render's signal in the same place ended with, when both were declared alike. */
11
+ note: (s: Signal<unknown>) => void
12
+ /** `render`, listing the signals made while it runs (the ones made later, from an effect or a handler, are not listed). */
13
+ wrap: <T>(render: () => T) => () => T
14
+ /** Ties the signals the render that just ran made to the function that disposes it, so the next render can start from them. */
15
+ keep: (dispose: () => void) => () => void
16
+ /** Runs `mount`, a render of the island whose disposer was `previous`, with that island's signals handed on. */
17
+ restore: <T>(previous: () => void, mount: () => T) => T
18
+ }
19
+
20
+ export interface HmrHost { __pruHmr?: HmrHooks }
21
+
22
+ interface Recording { prev: readonly HmrSignal[] | undefined, made: HmrSignal[] }
23
+
24
+ let recording: Recording | undefined
25
+ // What the next render starts from: set by `restore`, taken by the render that follows.
26
+ let restoreFrom: readonly HmrSignal[] | undefined
27
+ let lastMade: HmrSignal[] = []
28
+
29
+ let unique = 0
30
+ const kept = new WeakMap<() => void, HmrSignal[]>()
31
+
32
+ // A declaration reads the same when its initial value serializes the same; a value that cannot be serialized never reads the same.
33
+ function declarationOf(initial: unknown): string {
34
+ try {
35
+ return `${typeof initial}:${JSON.stringify(initial)}`
36
+ }
37
+ catch {
38
+ return `?${unique++}`
39
+ }
40
+ }
41
+
42
+ const host = globalThis as HmrHost
43
+
44
+ // A swapped island's chunk carries its own copy of this module and replaces the hooks with its own, so what a render kept stays in a map shared through the page.
45
+ export const hooks: HmrHooks = {
46
+ note(s) {
47
+ if (recording === undefined)
48
+ return
49
+ const k = declarationOf(s.peek())
50
+ const before = recording.prev?.[recording.made.length]
51
+ if (before !== undefined && before.k === k)
52
+ (s as unknown as { _v: unknown })._v = before.s.peek()
53
+ recording.made.push({ k, s })
54
+ },
55
+ wrap(render) {
56
+ return () => {
57
+ const outer = recording
58
+ const made: HmrSignal[] = []
59
+ recording = { prev: restoreFrom, made }
60
+ restoreFrom = undefined
61
+ try {
62
+ return render()
63
+ }
64
+ finally {
65
+ recording = outer
66
+ lastMade = made
67
+ }
68
+ }
69
+ },
70
+ keep(dispose) {
71
+ keptOnPage().set(dispose, lastMade)
72
+ return dispose
73
+ },
74
+ restore(previous, mount) {
75
+ restoreFrom = keptOnPage().get(previous)
76
+ try {
77
+ return mount()
78
+ }
79
+ finally {
80
+ restoreFrom = undefined
81
+ }
82
+ },
83
+ }
84
+
85
+ function keptOnPage(): WeakMap<() => void, HmrSignal[]> {
86
+ const page = globalThis as { __pruHmrKept?: WeakMap<() => void, HmrSignal[]> }
87
+ return page.__pruHmrKept ??= kept
88
+ }
89
+
90
+ host.__pruHmr = hooks
@@ -3,8 +3,14 @@
3
3
 
4
4
  import type { DepNode, Link, Owned, Owner, ReadonlySignal, Signal, SubNode } from './graph'
5
5
  import { adopt, linkSub, throwErrors, unadopt, unlinkAll, unlinkRemaining, unlinkSubs, unobserve } from './graph'
6
+ import type { HmrHost } from './hmr'
7
+ import { inServerRender, isSharedWrite, recordSharedWrite, shareOutsideRender } from './server-seed'
6
8
 
7
9
  export type { IdScope, Owner, ReadonlySignal, Signal } from './graph'
10
+ export type { RequestSeeds } from './server-seed'
11
+ export { isSharedWrite, nameSeed, recordSharedWrite, renderOnServer, shareOutsideRender, sharedPath } from './server-seed'
12
+
13
+ declare const PRUNELLE_BROWSER: boolean | undefined
8
14
 
9
15
  const enum F {
10
16
  CLEAN = 0,
@@ -30,6 +36,8 @@ let qNext: SubNode[] = []
30
36
  let flushing = false
31
37
  // Signal writes so far: an unobserved computed that checked at the same count can skip its version walk.
32
38
  let writes = 0
39
+ // Set while recordWrites() runs: each signal write hands it the signal, the value it replaced, and the new value; a store write hands the undo itself.
40
+ let rec: ((target: Signal<unknown> | (() => void), prev?: unknown, next?: unknown) => void) | undefined
33
41
  // Bumped after a flush that threw so observed computeds still left DIRTY/CHECK re-propagate downstream on recovery.
34
42
  let propWave = 0
35
43
 
@@ -175,6 +183,11 @@ class SignalNode<T> implements DepNode, Signal<T> {
175
183
  set value(next: T) {
176
184
  if (Object.is(this._v, next))
177
185
  return
186
+ if ((typeof PRUNELLE_BROWSER === 'undefined' || !PRUNELLE_BROWSER) && isSharedWrite(this)) {
187
+ const prev = this._v
188
+ recordSharedWrite(this, [], () => this.value = next, () => this.value = prev, next)
189
+ }
190
+ rec?.(this, this._v, next)
178
191
  this._v = next
179
192
  this.v++
180
193
  writes++
@@ -437,6 +450,23 @@ export function writeCount(): number {
437
450
  return writes
438
451
  }
439
452
 
453
+ /** Internal: the undo sink of the running recordWrites(), for the store's own writes. */
454
+ export function writeRecorder(): ((undo: () => void) => void) | undefined {
455
+ return rec
456
+ }
457
+
458
+ /** Internal: runs `fn` in a batch and pushes onto `undos` what restores each signal and store write it made, in order. */
459
+ export function recordWrites<T>(fn: () => T, undos: (() => void)[]): T {
460
+ const outer = rec
461
+ rec = (target, prev, next) => undos.push(typeof target === 'function' ? target : () => { if (Object.is(target.peek(), next)) target.value = prev })
462
+ try {
463
+ return batch(fn)
464
+ }
465
+ finally {
466
+ rec = outer
467
+ }
468
+ }
469
+
440
470
  /** Internal: signal that runs `onUnsub` and bumps its version when its last subscriber detaches. */
441
471
  export function watchedSignal<T>(initial: T, onUnsub: () => void): Signal<T> {
442
472
  const s = new SignalNode(initial)
@@ -454,33 +484,23 @@ export function root<T>(fn: (dispose: () => void) => T): T {
454
484
  }
455
485
 
456
486
  export function signal<T>(initial: T): Signal<T> {
457
- return new SignalNode(initial)
487
+ const s = new SignalNode(initial)
488
+ if (process.env.NODE_ENV !== 'production')
489
+ (globalThis as HmrHost).__pruHmr?.note(s as Signal<unknown>)
490
+ if (typeof PRUNELLE_BROWSER === 'undefined' || !PRUNELLE_BROWSER)
491
+ shareOutsideRender(s)
492
+ return s
458
493
  }
459
494
 
460
495
  export function computed<T>(fn: () => T): ReadonlySignal<T> {
461
496
  return new ComputedNode(fn, currentOwner)
462
497
  }
463
498
 
464
- declare const PRUNELLE_BROWSER: boolean | undefined
465
-
466
- let serverRenders = 0
467
-
468
- /** Internal: runs an island's server render, during which `effect` and `onMount` do nothing. */
469
- export function renderOnServer<T>(fn: () => T): T {
470
- serverRenders++
471
- try {
472
- return fn()
473
- }
474
- finally {
475
- serverRenders--
476
- }
477
- }
478
-
479
499
  function noop(): void {}
480
500
 
481
501
  // An effect skips the server render, as onMount does: a timer or request it starts would outlive the response. The client build defines PRUNELLE_BROWSER, which drops the check.
482
502
  export function effect(fn: () => void | (() => void)): () => void {
483
- if ((typeof PRUNELLE_BROWSER === 'undefined' || !PRUNELLE_BROWSER) && serverRenders > 0)
503
+ if ((typeof PRUNELLE_BROWSER === 'undefined' || !PRUNELLE_BROWSER) && inServerRender())
484
504
  return noop
485
505
  if (process.env.NODE_ENV !== 'production' && !currentOwner && currentSub && (currentSub.f & F.COMPUTED))
486
506
  console.warn('prunelle: effect() created while a computed runs has no owner and is never disposed. Create it in a component or an effect.')
@@ -538,7 +558,7 @@ export function onCleanup(fn: () => void): void {
538
558
 
539
559
  // A render creates its nodes and inserts them in the same task, so a microtask later they are in the document.
540
560
  export function onMount(fn: () => void | (() => void)): void {
541
- if (((typeof PRUNELLE_BROWSER === 'undefined' || !PRUNELLE_BROWSER) && serverRenders > 0) || typeof document === 'undefined')
561
+ if (((typeof PRUNELLE_BROWSER === 'undefined' || !PRUNELLE_BROWSER) && inServerRender()) || typeof document === 'undefined')
542
562
  return
543
563
  const owner = currentOwner
544
564
  queueMicrotask(() => {