@nifrajs/web 2.2.0 → 2.3.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 (163) hide show
  1. package/README.md +3 -3
  2. package/dist/build-vite.d.ts +4 -4
  3. package/dist/build-vite.d.ts.map +1 -1
  4. package/dist/build-vite.js +20 -74
  5. package/dist/build-vite.js.map +1 -1
  6. package/dist/build.d.ts +64 -42
  7. package/dist/build.d.ts.map +1 -1
  8. package/dist/build.js +100 -78
  9. package/dist/build.js.map +1 -1
  10. package/dist/bun-dev-entry.d.ts +1 -1
  11. package/dist/bun-dev-entry.js +1 -1
  12. package/dist/chunk-names.js +1 -1
  13. package/dist/client.d.ts +3 -9
  14. package/dist/client.d.ts.map +1 -1
  15. package/dist/client.js +201 -29
  16. package/dist/client.js.map +1 -1
  17. package/dist/conformance.d.ts +2 -2
  18. package/dist/conformance.js +3 -3
  19. package/dist/deferred.d.ts +11 -11
  20. package/dist/deferred.d.ts.map +1 -1
  21. package/dist/deferred.js +16 -16
  22. package/dist/dev-error.d.ts +2 -2
  23. package/dist/dev-error.js +3 -3
  24. package/dist/dev-port.d.ts +2 -2
  25. package/dist/dev-port.js +1 -1
  26. package/dist/dev.d.ts +3 -3
  27. package/dist/dev.js +9 -9
  28. package/dist/draft.d.ts +12 -12
  29. package/dist/draft.js +11 -11
  30. package/dist/fn-state.d.ts +56 -0
  31. package/dist/fn-state.d.ts.map +1 -0
  32. package/dist/fn-state.js +77 -0
  33. package/dist/fn-state.js.map +1 -0
  34. package/dist/fn.d.ts +111 -0
  35. package/dist/fn.d.ts.map +1 -0
  36. package/dist/fn.js +125 -0
  37. package/dist/fn.js.map +1 -0
  38. package/dist/fonts-google.d.ts +9 -9
  39. package/dist/fonts-google.js +10 -10
  40. package/dist/fonts.d.ts +7 -7
  41. package/dist/fonts.js +1 -1
  42. package/dist/forms.d.ts +8 -8
  43. package/dist/fs.d.ts +1 -1
  44. package/dist/fs.js +1 -1
  45. package/dist/index.d.ts +151 -70
  46. package/dist/index.d.ts.map +1 -1
  47. package/dist/index.js +317 -139
  48. package/dist/index.js.map +1 -1
  49. package/dist/internal/head-attributes.d.ts +15 -0
  50. package/dist/internal/head-attributes.d.ts.map +1 -0
  51. package/dist/internal/head-attributes.js +99 -0
  52. package/dist/internal/head-attributes.js.map +1 -0
  53. package/dist/internal/script-types.d.ts +14 -0
  54. package/dist/internal/script-types.d.ts.map +1 -0
  55. package/dist/internal/script-types.js +17 -0
  56. package/dist/internal/script-types.js.map +1 -0
  57. package/dist/internal/server-boundary.d.ts +60 -0
  58. package/dist/internal/server-boundary.d.ts.map +1 -0
  59. package/dist/internal/server-boundary.js +174 -0
  60. package/dist/internal/server-boundary.js.map +1 -0
  61. package/dist/internal/timing-safe-equal.d.ts +1 -1
  62. package/dist/internal/timing-safe-equal.js +1 -1
  63. package/dist/internal/vite-import.d.ts +63 -0
  64. package/dist/internal/vite-import.d.ts.map +1 -0
  65. package/dist/internal/vite-import.js +94 -0
  66. package/dist/internal/vite-import.js.map +1 -0
  67. package/dist/islands.d.ts +5 -5
  68. package/dist/islands.js +5 -5
  69. package/dist/isr.d.ts +15 -15
  70. package/dist/isr.js +7 -7
  71. package/dist/manifest.d.ts +73 -35
  72. package/dist/manifest.d.ts.map +1 -1
  73. package/dist/manifest.js +10 -16
  74. package/dist/manifest.js.map +1 -1
  75. package/dist/module-graph.d.ts +5 -5
  76. package/dist/module-graph.js +4 -4
  77. package/dist/navigation.d.ts +120 -5
  78. package/dist/navigation.d.ts.map +1 -1
  79. package/dist/navigation.js +37 -5
  80. package/dist/navigation.js.map +1 -1
  81. package/dist/plugins/css-modules.d.ts +3 -3
  82. package/dist/plugins/css-modules.js +0 -0
  83. package/dist/plugins/kit.d.ts +8 -8
  84. package/dist/plugins/kit.js +9 -9
  85. package/dist/plugins/scss.js +3 -3
  86. package/dist/plugins/vite-leak-guard.d.ts +1 -1
  87. package/dist/plugins/vite-leak-guard.js +1 -1
  88. package/dist/plugins/vite-server-fn.d.ts +23 -0
  89. package/dist/plugins/vite-server-fn.d.ts.map +1 -0
  90. package/dist/plugins/vite-server-fn.js +51 -0
  91. package/dist/plugins/vite-server-fn.js.map +1 -0
  92. package/dist/plugins/vite-server-only.d.ts +49 -0
  93. package/dist/plugins/vite-server-only.d.ts.map +1 -0
  94. package/dist/plugins/vite-server-only.js +57 -0
  95. package/dist/plugins/vite-server-only.js.map +1 -0
  96. package/dist/prerender.d.ts +5 -5
  97. package/dist/prerender.js +7 -7
  98. package/dist/query.d.ts +10 -10
  99. package/dist/query.js +15 -15
  100. package/dist/route-manifest.d.ts +1 -1
  101. package/dist/route-manifest.js +2 -2
  102. package/dist/router.d.ts +30 -21
  103. package/dist/router.d.ts.map +1 -1
  104. package/dist/router.js +57 -28
  105. package/dist/router.js.map +1 -1
  106. package/dist/search.d.ts +94 -0
  107. package/dist/search.d.ts.map +1 -0
  108. package/dist/search.js +232 -0
  109. package/dist/search.js.map +1 -0
  110. package/dist/server-only.d.ts +6 -6
  111. package/dist/server-only.js +7 -7
  112. package/dist/service-worker.d.ts +56 -0
  113. package/dist/service-worker.d.ts.map +1 -0
  114. package/dist/service-worker.js +127 -0
  115. package/dist/service-worker.js.map +1 -0
  116. package/dist/vite.d.ts +15 -13
  117. package/dist/vite.d.ts.map +1 -1
  118. package/dist/vite.js +31 -21
  119. package/dist/vite.js.map +1 -1
  120. package/package.json +33 -4
  121. package/server-manifest.d.ts +31 -0
  122. package/src/build-vite.ts +24 -77
  123. package/src/build.ts +137 -105
  124. package/src/bun-dev-entry.ts +1 -1
  125. package/src/chunk-names.ts +1 -1
  126. package/src/client.ts +215 -32
  127. package/src/conformance.ts +3 -3
  128. package/src/deferred.ts +17 -17
  129. package/src/dev-error.ts +3 -3
  130. package/src/dev-port.ts +2 -2
  131. package/src/dev.ts +12 -12
  132. package/src/draft.ts +15 -15
  133. package/src/fn-state.ts +107 -0
  134. package/src/fn.ts +199 -0
  135. package/src/fonts-google.ts +13 -13
  136. package/src/fonts.ts +7 -7
  137. package/src/forms.ts +8 -8
  138. package/src/fs.ts +2 -2
  139. package/src/index.ts +460 -181
  140. package/src/internal/head-attributes.ts +109 -0
  141. package/src/internal/script-types.ts +18 -0
  142. package/src/internal/server-boundary.ts +187 -0
  143. package/src/internal/timing-safe-equal.ts +1 -1
  144. package/src/internal/vite-import.ts +92 -0
  145. package/src/islands.ts +7 -7
  146. package/src/isr.ts +17 -17
  147. package/src/manifest.ts +83 -42
  148. package/src/module-graph.ts +6 -6
  149. package/src/navigation.ts +151 -5
  150. package/src/plugins/css-modules.ts +0 -0
  151. package/src/plugins/kit.ts +11 -11
  152. package/src/plugins/scss.ts +3 -3
  153. package/src/plugins/vite-leak-guard.ts +2 -2
  154. package/src/plugins/vite-server-fn.ts +67 -0
  155. package/src/plugins/vite-server-only.ts +75 -0
  156. package/src/prerender.ts +10 -10
  157. package/src/query.ts +22 -22
  158. package/src/route-manifest.ts +3 -3
  159. package/src/router.ts +91 -41
  160. package/src/search.ts +297 -0
  161. package/src/server-only.ts +7 -7
  162. package/src/service-worker.ts +165 -0
  163. package/src/vite.ts +41 -29
package/src/forms.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  /**
2
- * `@nifrajs/web/forms` — a typed form ↔ backend-schema binding. The three artifacts that must agree —
3
- * a form's `<input name>`, the action's `formData.get`, and the typed-client payload — all key off the
2
+ * `@nifrajs/web/forms` - a typed form ↔ backend-schema binding. The three artifacts that must agree -
3
+ * a form's `<input name>`, the action's `formData.get`, and the typed-client payload - all key off the
4
4
  * ONE route body schema, derived purely from `typeof backend`. A typo'd field name, or a field the
5
5
  * schema doesn't have, becomes a COMPILE error instead of a silent runtime empty.
6
6
  *
@@ -8,14 +8,14 @@
8
8
  * import { formFor } from "@nifrajs/web/forms"
9
9
  *
10
10
  * const f = formFor<typeof backend, "/todos">() // method defaults to "post"
11
- * // In the component (any framework — spread the props onto an input):
11
+ * // In the component (any framework - spread the props onto an input):
12
12
  * <input {...f.field("text")} /> // "text" ∈ the body's keys, else a compile error
13
13
  * // In the action:
14
14
  * const text = f.read(await request.formData(), "text") // an orphan key won't compile
15
15
  * await api.todos.post({ text }) // payload already typed by nifra
16
16
  *
17
17
  * Framework-agnostic + dependency-free: no codegen, no schema is bundled into the client, and the
18
- * runtime is a trivial pass-through — all the work is in the types. It checks the field KEY, never the
18
+ * runtime is a trivial pass-through - all the work is in the types. It checks the field KEY, never the
19
19
  * MEANING (a `field("email")` collecting a phone is still valid here); that stays an app/AI concern.
20
20
  */
21
21
  import type { RouteInfo, Server } from "@nifrajs/core/server"
@@ -28,7 +28,7 @@ type FormEntries = ReturnType<FormData["getAll"]>
28
28
  /** The route registry baked into a server's type (`typeof app`). */
29
29
  type RegistryOf<App> = App extends Server<infer R, infer _Ctx> ? R : never
30
30
 
31
- /** Every route path the app declares — constrains `Path`, so a wrong path is itself a type error. */
31
+ /** Every route path the app declares - constrains `Path`, so a wrong path is itself a type error. */
32
32
  export type RoutePaths<App> = keyof RegistryOf<App> & string
33
33
 
34
34
  /** The body object type of `App`'s `Method Path` route (`never` when the route declares no body). */
@@ -42,7 +42,7 @@ export type RouteBody<
42
42
  : never
43
43
  : never
44
44
 
45
- /** The valid field names for that route's body — the schema's keys as a string union. */
45
+ /** The valid field names for that route's body - the schema's keys as a string union. */
46
46
  export type FieldKey<App, Path extends string, Method extends string> = [
47
47
  RouteBody<App, Path, Method>,
48
48
  ] extends [never]
@@ -53,13 +53,13 @@ export type FieldKey<App, Path extends string, Method extends string> = [
53
53
  export type FieldProps = Record<string, unknown>
54
54
 
55
55
  export interface FormHandle<App, Path extends string, Method extends string> {
56
- /** Input props for a schema field. `name` is constrained to the body's keys — a typo, or a field the
56
+ /** Input props for a schema field. `name` is constrained to the body's keys - a typo, or a field the
57
57
  * schema doesn't have, is a COMPILE error. Spread onto an element: `<input {...f.field("text")} />`. */
58
58
  field<K extends FieldKey<App, Path, Method>>(
59
59
  name: K,
60
60
  props?: FieldProps,
61
61
  ): FieldProps & { name: K }
62
- /** `formData.get`, key-constrained to the body's fields — reading an orphan key won't compile. */
62
+ /** `formData.get`, key-constrained to the body's fields - reading an orphan key won't compile. */
63
63
  read<K extends FieldKey<App, Path, Method>>(form: FormData, name: K): FormEntry
64
64
  /** `formData.getAll`, key-checked the same way. */
65
65
  readAll<K extends FieldKey<App, Path, Method>>(form: FormData, name: K): FormEntries
package/src/fs.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @nifrajs/web/fs — filesystem route discovery. Separated from the main entry so `app.fetch`
2
+ * @nifrajs/web/fs - filesystem route discovery. Separated from the main entry so `app.fetch`
3
3
  * (and the rest of @nifrajs/web) stays fs-free + edge-portable: this runs at build/startup
4
4
  * only. It scans a routes dir and feeds the pure `buildManifest`.
5
5
  */
@@ -8,7 +8,7 @@ import { buildManifest, type Manifest, type RouteModule } from "./manifest.ts"
8
8
 
9
9
  /** Options for {@link discoverRoutes}. */
10
10
  export interface DiscoverRoutesOptions {
11
- /** Appended (as `?<importQuery>`) to each route's dynamic import — the dev server sets a
11
+ /** Appended (as `?<importQuery>`) to each route's dynamic import - the dev server sets a
12
12
  * changing value to bust Bun's module cache so SSR picks up edited route files. Ignored when
13
13
  * {@link load} is supplied, which does its own cache handling. */
14
14
  readonly importQuery?: string