@nifrajs/web 2.2.0 → 2.4.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 (179) 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-diagnostics.d.ts +20 -0
  23. package/dist/dev-diagnostics.d.ts.map +1 -0
  24. package/dist/dev-diagnostics.js +34 -0
  25. package/dist/dev-diagnostics.js.map +1 -0
  26. package/dist/dev-error.d.ts +10 -13
  27. package/dist/dev-error.d.ts.map +1 -1
  28. package/dist/dev-error.js +51 -37
  29. package/dist/dev-error.js.map +1 -1
  30. package/dist/dev-port.d.ts +3 -3
  31. package/dist/dev-port.d.ts.map +1 -1
  32. package/dist/dev-port.js +10 -4
  33. package/dist/dev-port.js.map +1 -1
  34. package/dist/dev.d.ts +4 -4
  35. package/dist/dev.d.ts.map +1 -1
  36. package/dist/dev.js +28 -12
  37. package/dist/dev.js.map +1 -1
  38. package/dist/diagnostic.d.ts +93 -0
  39. package/dist/diagnostic.d.ts.map +1 -0
  40. package/dist/diagnostic.js +205 -0
  41. package/dist/diagnostic.js.map +1 -0
  42. package/dist/draft.d.ts +12 -12
  43. package/dist/draft.js +11 -11
  44. package/dist/fn-state.d.ts +56 -0
  45. package/dist/fn-state.d.ts.map +1 -0
  46. package/dist/fn-state.js +77 -0
  47. package/dist/fn-state.js.map +1 -0
  48. package/dist/fn.d.ts +111 -0
  49. package/dist/fn.d.ts.map +1 -0
  50. package/dist/fn.js +125 -0
  51. package/dist/fn.js.map +1 -0
  52. package/dist/fonts-google.d.ts +9 -9
  53. package/dist/fonts-google.js +10 -10
  54. package/dist/fonts.d.ts +7 -7
  55. package/dist/fonts.js +1 -1
  56. package/dist/forms.d.ts +8 -8
  57. package/dist/fs.d.ts +1 -1
  58. package/dist/fs.js +1 -1
  59. package/dist/index.d.ts +151 -70
  60. package/dist/index.d.ts.map +1 -1
  61. package/dist/index.js +317 -139
  62. package/dist/index.js.map +1 -1
  63. package/dist/internal/head-attributes.d.ts +15 -0
  64. package/dist/internal/head-attributes.d.ts.map +1 -0
  65. package/dist/internal/head-attributes.js +99 -0
  66. package/dist/internal/head-attributes.js.map +1 -0
  67. package/dist/internal/script-types.d.ts +14 -0
  68. package/dist/internal/script-types.d.ts.map +1 -0
  69. package/dist/internal/script-types.js +17 -0
  70. package/dist/internal/script-types.js.map +1 -0
  71. package/dist/internal/server-boundary.d.ts +60 -0
  72. package/dist/internal/server-boundary.d.ts.map +1 -0
  73. package/dist/internal/server-boundary.js +174 -0
  74. package/dist/internal/server-boundary.js.map +1 -0
  75. package/dist/internal/timing-safe-equal.d.ts +1 -1
  76. package/dist/internal/timing-safe-equal.js +1 -1
  77. package/dist/internal/vite-import.d.ts +63 -0
  78. package/dist/internal/vite-import.d.ts.map +1 -0
  79. package/dist/internal/vite-import.js +94 -0
  80. package/dist/internal/vite-import.js.map +1 -0
  81. package/dist/islands.d.ts +5 -5
  82. package/dist/islands.js +5 -5
  83. package/dist/isr.d.ts +15 -15
  84. package/dist/isr.js +7 -7
  85. package/dist/manifest.d.ts +73 -35
  86. package/dist/manifest.d.ts.map +1 -1
  87. package/dist/manifest.js +10 -16
  88. package/dist/manifest.js.map +1 -1
  89. package/dist/module-graph.d.ts +5 -5
  90. package/dist/module-graph.js +4 -4
  91. package/dist/navigation.d.ts +120 -5
  92. package/dist/navigation.d.ts.map +1 -1
  93. package/dist/navigation.js +37 -5
  94. package/dist/navigation.js.map +1 -1
  95. package/dist/plugins/css-modules.d.ts +3 -3
  96. package/dist/plugins/css-modules.js +0 -0
  97. package/dist/plugins/kit.d.ts +8 -8
  98. package/dist/plugins/kit.js +9 -9
  99. package/dist/plugins/scss.js +3 -3
  100. package/dist/plugins/vite-leak-guard.d.ts +1 -1
  101. package/dist/plugins/vite-leak-guard.js +1 -1
  102. package/dist/plugins/vite-server-fn.d.ts +23 -0
  103. package/dist/plugins/vite-server-fn.d.ts.map +1 -0
  104. package/dist/plugins/vite-server-fn.js +51 -0
  105. package/dist/plugins/vite-server-fn.js.map +1 -0
  106. package/dist/plugins/vite-server-only.d.ts +49 -0
  107. package/dist/plugins/vite-server-only.d.ts.map +1 -0
  108. package/dist/plugins/vite-server-only.js +57 -0
  109. package/dist/plugins/vite-server-only.js.map +1 -0
  110. package/dist/prerender.d.ts +5 -5
  111. package/dist/prerender.js +7 -7
  112. package/dist/query.d.ts +10 -10
  113. package/dist/query.js +15 -15
  114. package/dist/route-manifest.d.ts +1 -1
  115. package/dist/route-manifest.js +2 -2
  116. package/dist/router.d.ts +30 -21
  117. package/dist/router.d.ts.map +1 -1
  118. package/dist/router.js +62 -32
  119. package/dist/router.js.map +1 -1
  120. package/dist/search.d.ts +94 -0
  121. package/dist/search.d.ts.map +1 -0
  122. package/dist/search.js +232 -0
  123. package/dist/search.js.map +1 -0
  124. package/dist/server-only.d.ts +6 -6
  125. package/dist/server-only.js +7 -7
  126. package/dist/service-worker.d.ts +56 -0
  127. package/dist/service-worker.d.ts.map +1 -0
  128. package/dist/service-worker.js +127 -0
  129. package/dist/service-worker.js.map +1 -0
  130. package/dist/vite.d.ts +16 -14
  131. package/dist/vite.d.ts.map +1 -1
  132. package/dist/vite.js +51 -24
  133. package/dist/vite.js.map +1 -1
  134. package/package.json +38 -4
  135. package/server-manifest.d.ts +31 -0
  136. package/src/build-vite.ts +24 -77
  137. package/src/build.ts +137 -105
  138. package/src/bun-dev-entry.ts +1 -1
  139. package/src/chunk-names.ts +1 -1
  140. package/src/client.ts +215 -32
  141. package/src/conformance.ts +3 -3
  142. package/src/deferred.ts +17 -17
  143. package/src/dev-diagnostics.ts +47 -0
  144. package/src/dev-error.ts +64 -33
  145. package/src/dev-port.ts +17 -5
  146. package/src/dev.ts +36 -20
  147. package/src/diagnostic.ts +284 -0
  148. package/src/draft.ts +15 -15
  149. package/src/fn-state.ts +107 -0
  150. package/src/fn.ts +199 -0
  151. package/src/fonts-google.ts +13 -13
  152. package/src/fonts.ts +7 -7
  153. package/src/forms.ts +8 -8
  154. package/src/fs.ts +2 -2
  155. package/src/index.ts +460 -181
  156. package/src/internal/head-attributes.ts +109 -0
  157. package/src/internal/script-types.ts +18 -0
  158. package/src/internal/server-boundary.ts +187 -0
  159. package/src/internal/timing-safe-equal.ts +1 -1
  160. package/src/internal/vite-import.ts +92 -0
  161. package/src/islands.ts +7 -7
  162. package/src/isr.ts +17 -17
  163. package/src/manifest.ts +83 -42
  164. package/src/module-graph.ts +6 -6
  165. package/src/navigation.ts +151 -5
  166. package/src/plugins/css-modules.ts +0 -0
  167. package/src/plugins/kit.ts +11 -11
  168. package/src/plugins/scss.ts +3 -3
  169. package/src/plugins/vite-leak-guard.ts +2 -2
  170. package/src/plugins/vite-server-fn.ts +67 -0
  171. package/src/plugins/vite-server-only.ts +75 -0
  172. package/src/prerender.ts +10 -10
  173. package/src/query.ts +22 -22
  174. package/src/route-manifest.ts +3 -3
  175. package/src/router.ts +98 -45
  176. package/src/search.ts +297 -0
  177. package/src/server-only.ts +7 -7
  178. package/src/service-worker.ts +165 -0
  179. package/src/vite.ts +61 -32
package/dist/fonts.d.ts CHANGED
@@ -1,17 +1,17 @@
1
1
  /**
2
- * Font optimization primitives — generate a **CLS-safe `@font-face`** rule and the matching
2
+ * Font optimization primitives - generate a **CLS-safe `@font-face`** rule and the matching
3
3
  * **preload `<link>`** for a self-hosted font. The two fixes that matter most (the ones `next/font`
4
4
  * automates) are right here: `font-display: swap` (text paints immediately, no invisible-text FOIT)
5
5
  * plus a preload so the file downloads with the document, and optional metric overrides
6
6
  * (`size-adjust`/`ascent-override`/…) so swapping from the fallback to the web font doesn't shift layout.
7
7
  *
8
- * Self-host the file (drop a `.woff2` in your assets — never hotlink Google's CDN), then:
8
+ * Self-host the file (drop a `.woff2` in your assets - never hotlink Google's CDN), then:
9
9
  *
10
- * // fonts.css (imported by your app — the CSS pipeline bundles + links it)
10
+ * // fonts.css (imported by your app - the CSS pipeline bundles + links it)
11
11
  * import { fontFace } from "@nifrajs/web"
12
12
  * export default fontFace({ family: "Inter", src: [{ url: "/fonts/inter.woff2" }], weight: "100 900" })
13
13
  *
14
- * // a root layout's meta — becomes a <link rel="preload" as="font"> in <head>
14
+ * // a root layout's meta - becomes a <link rel="preload" as="font"> in <head>
15
15
  * export const meta = { link: [fontPreload({ href: "/fonts/inter.woff2" })] }
16
16
  */
17
17
  import type { LinkDescriptor } from "./manifest.js";
@@ -32,7 +32,7 @@ export interface FontFace {
32
32
  readonly style?: "normal" | "italic" | "oblique";
33
33
  /** Defaults to `"swap"` (no flash of invisible text). */
34
34
  readonly display?: FontDisplay;
35
- /** Restrict the glyphs this face covers, e.g. `"U+0000-00FF"` — lets the browser skip the download
35
+ /** Restrict the glyphs this face covers, e.g. `"U+0000-00FF"` - lets the browser skip the download
36
36
  * for pages without those characters. */
37
37
  readonly unicodeRange?: string;
38
38
  /** Metric overrides that eliminate layout shift when the fallback swaps to the web font (the
@@ -53,13 +53,13 @@ export interface FontPreloadInput {
53
53
  readonly href: string;
54
54
  /** MIME type (`font/woff2`, …). Inferred from the extension when omitted. */
55
55
  readonly type?: string;
56
- /** `crossorigin` mode — defaults to `"anonymous"`. Fonts are always fetched in CORS mode, and a
56
+ /** `crossorigin` mode - defaults to `"anonymous"`. Fonts are always fetched in CORS mode, and a
57
57
  * preload whose `crossorigin` doesn't match the actual fetch is **wasted** (downloaded twice), so
58
58
  * this is on by default. */
59
59
  readonly crossOrigin?: "anonymous" | "use-credentials";
60
60
  }
61
61
  /**
62
- * Build a font preload as a `<link>` attribute set for a route/layout's `meta.link` — nifra injects it
62
+ * Build a font preload as a `<link>` attribute set for a route/layout's `meta.link` - nifra injects it
63
63
  * into `<head>` (`<link rel="preload" as="font" type="font/woff2" crossorigin="anonymous">`). Values are
64
64
  * escaped at injection by the head renderer. Preloading the font file removes a render-blocking round
65
65
  * trip (the browser would otherwise discover the font only after parsing the CSS).
package/dist/fonts.js CHANGED
@@ -69,7 +69,7 @@ export function fontFace(face) {
69
69
  return `@font-face {\n ${declarations.join(";\n ")};\n}`;
70
70
  }
71
71
  /**
72
- * Build a font preload as a `<link>` attribute set for a route/layout's `meta.link` — nifra injects it
72
+ * Build a font preload as a `<link>` attribute set for a route/layout's `meta.link` - nifra injects it
73
73
  * into `<head>` (`<link rel="preload" as="font" type="font/woff2" crossorigin="anonymous">`). Values are
74
74
  * escaped at injection by the head renderer. Preloading the font file removes a render-blocking round
75
75
  * trip (the browser would otherwise discover the font only after parsing the CSS).
package/dist/forms.d.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";
@@ -23,23 +23,23 @@ type FormEntry = ReturnType<FormData["get"]>;
23
23
  type FormEntries = ReturnType<FormData["getAll"]>;
24
24
  /** The route registry baked into a server's type (`typeof app`). */
25
25
  type RegistryOf<App> = App extends Server<infer R, infer _Ctx> ? R : never;
26
- /** Every route path the app declares — constrains `Path`, so a wrong path is itself a type error. */
26
+ /** Every route path the app declares - constrains `Path`, so a wrong path is itself a type error. */
27
27
  export type RoutePaths<App> = keyof RegistryOf<App> & string;
28
28
  /** The body object type of `App`'s `Method Path` route (`never` when the route declares no body). */
29
29
  export type RouteBody<App, Path extends string, Method extends string> = Path extends keyof RegistryOf<App> ? Uppercase<Method> extends keyof RegistryOf<App>[Path] ? (RegistryOf<App>[Path][Uppercase<Method>] & RouteInfo)["body"] : never : never;
30
- /** The valid field names for that route's body — the schema's keys as a string union. */
30
+ /** The valid field names for that route's body - the schema's keys as a string union. */
31
31
  export type FieldKey<App, Path extends string, Method extends string> = [
32
32
  RouteBody<App, Path, Method>
33
33
  ] extends [never] ? never : keyof RouteBody<App, Path, Method> & string;
34
34
  /** Extra attributes merged into the returned input props (id, type, defaultValue, placeholder, …). */
35
35
  export type FieldProps = Record<string, unknown>;
36
36
  export interface FormHandle<App, Path extends string, Method extends string> {
37
- /** Input props for a schema field. `name` is constrained to the body's keys — a typo, or a field the
37
+ /** Input props for a schema field. `name` is constrained to the body's keys - a typo, or a field the
38
38
  * schema doesn't have, is a COMPILE error. Spread onto an element: `<input {...f.field("text")} />`. */
39
39
  field<K extends FieldKey<App, Path, Method>>(name: K, props?: FieldProps): FieldProps & {
40
40
  name: K;
41
41
  };
42
- /** `formData.get`, key-constrained to the body's fields — reading an orphan key won't compile. */
42
+ /** `formData.get`, key-constrained to the body's fields - reading an orphan key won't compile. */
43
43
  read<K extends FieldKey<App, Path, Method>>(form: FormData, name: K): FormEntry;
44
44
  /** `formData.getAll`, key-checked the same way. */
45
45
  readAll<K extends FieldKey<App, Path, Method>>(form: FormData, name: K): FormEntries;
package/dist/fs.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  import { type Manifest } from "./manifest.js";
2
2
  /** Options for {@link discoverRoutes}. */
3
3
  export interface DiscoverRoutesOptions {
4
- /** Appended (as `?<importQuery>`) to each route's dynamic import — the dev server sets a
4
+ /** Appended (as `?<importQuery>`) to each route's dynamic import - the dev server sets a
5
5
  * changing value to bust Bun's module cache so SSR picks up edited route files. Ignored when
6
6
  * {@link load} is supplied, which does its own cache handling. */
7
7
  readonly importQuery?: string;
package/dist/fs.js CHANGED
@@ -7,7 +7,7 @@ var __rewriteRelativeImportExtension = (this && this.__rewriteRelativeImportExte
7
7
  return path;
8
8
  };
9
9
  /**
10
- * @nifrajs/web/fs — filesystem route discovery. Separated from the main entry so `app.fetch`
10
+ * @nifrajs/web/fs - filesystem route discovery. Separated from the main entry so `app.fetch`
11
11
  * (and the rest of @nifrajs/web) stays fs-free + edge-portable: this runs at build/startup
12
12
  * only. It scans a routes dir and feeds the pure `buildManifest`.
13
13
  */