@rsc-kit/core 0.18.1 → 0.20.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 (77) hide show
  1. package/dist/action.d.ts +16 -2
  2. package/dist/action.js +21 -12
  3. package/dist/action.js.map +1 -1
  4. package/dist/apiPrerender.js +25 -7
  5. package/dist/apiPrerender.js.map +1 -1
  6. package/dist/clientPackages.d.ts +30 -0
  7. package/dist/clientPackages.js +234 -0
  8. package/dist/clientPackages.js.map +1 -0
  9. package/dist/compress.d.ts +12 -0
  10. package/dist/compress.js +134 -0
  11. package/dist/compress.js.map +1 -0
  12. package/dist/compressRuntime.d.ts +8 -0
  13. package/dist/compressRuntime.js +62 -0
  14. package/dist/compressRuntime.js.map +1 -0
  15. package/dist/files.d.ts +20 -0
  16. package/dist/files.js +38 -0
  17. package/dist/files.js.map +1 -1
  18. package/dist/formSubmit.d.ts +1 -0
  19. package/dist/formSubmit.js +14 -0
  20. package/dist/formSubmit.js.map +1 -0
  21. package/dist/host.d.ts +23 -0
  22. package/dist/host.js +175 -31
  23. package/dist/host.js.map +1 -1
  24. package/dist/hostCalls.d.ts +15 -0
  25. package/dist/hostCalls.js +75 -8
  26. package/dist/hostCalls.js.map +1 -1
  27. package/dist/js/Form.d.ts +21 -4
  28. package/dist/js/Form.js +110 -83
  29. package/dist/js/Form.js.map +1 -1
  30. package/dist/js/Link.d.ts +5 -5
  31. package/dist/js/Link.js.map +1 -1
  32. package/dist/js/RedirectBoundary.js.map +1 -1
  33. package/dist/js/RouteErrorBoundary.d.ts +6 -2
  34. package/dist/js/RouteErrorBoundary.js +10 -0
  35. package/dist/js/RouteErrorBoundary.js.map +1 -1
  36. package/dist/js/SlotBoundary.d.ts +7 -1
  37. package/dist/js/SlotBoundary.js +9 -1
  38. package/dist/js/SlotBoundary.js.map +1 -1
  39. package/dist/js/createViteRscApp.d.ts +1 -0
  40. package/dist/js/createViteRscApp.js +54 -5
  41. package/dist/js/createViteRscApp.js.map +1 -1
  42. package/dist/js/errors.d.ts +3 -1
  43. package/dist/js/errors.js +26 -3
  44. package/dist/js/errors.js.map +1 -1
  45. package/dist/js/formEncoding.d.ts +72 -3
  46. package/dist/js/formEncoding.js +284 -20
  47. package/dist/js/formEncoding.js.map +1 -1
  48. package/dist/js/navigate.d.ts +6 -3
  49. package/dist/js/navigate.js +57 -7
  50. package/dist/js/navigate.js.map +1 -1
  51. package/dist/js/nuqs.js.map +1 -1
  52. package/dist/js/router.d.ts +3 -3
  53. package/dist/js/router.js.map +1 -1
  54. package/dist/js/updateStore.js +8 -2
  55. package/dist/js/updateStore.js.map +1 -1
  56. package/dist/manifest.d.ts +6 -0
  57. package/dist/manifest.js.map +1 -1
  58. package/dist/openapi.d.ts +74 -0
  59. package/dist/openapi.js +172 -0
  60. package/dist/openapi.js.map +1 -0
  61. package/dist/redirect.d.ts +4 -4
  62. package/dist/redirect.js.map +1 -1
  63. package/dist/request.d.ts +56 -2
  64. package/dist/request.js +68 -4
  65. package/dist/request.js.map +1 -1
  66. package/dist/routes.d.ts +17 -6
  67. package/dist/routes.js.map +1 -1
  68. package/dist/testing.d.ts +14 -0
  69. package/dist/testing.js +56 -2
  70. package/dist/testing.js.map +1 -1
  71. package/dist/useSsr.d.ts +11 -0
  72. package/dist/useSsr.js +15 -0
  73. package/dist/useSsr.js.map +1 -1
  74. package/dist/vite.d.ts +69 -1
  75. package/dist/vite.js +481 -51
  76. package/dist/vite.js.map +1 -1
  77. package/package.json +5 -1
package/dist/vite.d.ts CHANGED
@@ -1,5 +1,6 @@
1
+ import type { PrerenderResult } from "./prerender.js";
1
2
  import type { WebManifestOptions } from "./webManifest.js";
2
- import type { PluginOption } from "vite";
3
+ import type { Plugin, PluginOption } from "vite";
3
4
  export interface RscKitOptions {
4
5
  /** Project root. Defaults to RSC_PROJECT_ROOT, then cwd. */
5
6
  projectRoot?: string;
@@ -17,6 +18,38 @@ export interface RscKitOptions {
17
18
  * sent: it names no product, and a CDN rule or a check can key on it.
18
19
  */
19
20
  identify?: boolean;
21
+ /**
22
+ * An OpenAPI document from the route tree, at `/openapi.json`.
23
+ *
24
+ * One path per route.ts, one operation per method export, parameters and
25
+ * request bodies from the route's `params`, `searchParams` and `body`
26
+ * schemas - a Standard Schema that describes itself as JSON Schema (Zod 4,
27
+ * ArkType). A route under a middleware.ts gets a security requirement. A
28
+ * route says the rest about itself with `export const openapi = { summary,
29
+ * tags, responses }`; the document says its own with `info`, `servers`,
30
+ * `security`. An api route the build stores, without middleware.
31
+ *
32
+ * The page that reads it is Scalar's: `export const GET = ApiReference({
33
+ * url: '/openapi.json' })` from @scalar/nextjs-api-reference in a route.ts.
34
+ */
35
+ openapi?: boolean | {
36
+ path?: string;
37
+ info?: {
38
+ title?: string;
39
+ version?: string;
40
+ description?: string;
41
+ };
42
+ servers?: {
43
+ url: string;
44
+ description?: string;
45
+ }[];
46
+ security?: Record<string, string[]>[];
47
+ components?: Record<string, unknown>;
48
+ tags?: {
49
+ name: string;
50
+ description?: string;
51
+ }[];
52
+ };
20
53
  /**
21
54
  * Unroll named imports from a barrel package on the server, in development.
22
55
  *
@@ -290,6 +323,28 @@ export declare const SERVICE_WORKER: (version: string, precache: string[], froze
290
323
  * it. The file is a literal object by contract, which is all that has to parse.
291
324
  */
292
325
  export declare function declaredManifest(appDir: string): WebManifestOptions | null;
326
+ /**
327
+ * The url a navigation falls back to when nothing else can answer it.
328
+ *
329
+ * An ordinary route at /offline, and it has to be one the build STORED — a
330
+ * page that renders per request cannot be served when there is no request to
331
+ * be made. So a dynamic /offline is refused as a fallback rather than
332
+ * precached and found wanting at the one moment it matters, and the build says
333
+ * which read did it.
334
+ */
335
+ export declare function offlineFallback(frozen: string[], results: PrerenderResult[]): string | null;
336
+ /**
337
+ * Whether a public file is worth fetching before it is asked for.
338
+ *
339
+ * The precache is what lets the app boot with no network: the scripts, the
340
+ * stylesheets, the fonts, the manifest and its icons. Everything else in
341
+ * public/ - an image, a wasm module, the share card - is cached the first
342
+ * time it is used, which is what the fetch handler does for any hashed
343
+ * asset. Precaching all of it made an install cost a megabyte before the
344
+ * visitor had seen a page: 765 kB of it a webp encoder, the rest a png no
345
+ * browser ever renders.
346
+ */
347
+ export declare function bootsTheApp(file: string): boolean;
293
348
  export declare function smallStylesheetReader(assetsDir: string, setting: "auto" | true | number): (href: string) => string | null;
294
349
  /** A server action the bundle registered: where it is and what it is called. */
295
350
  export interface KnownAction {
@@ -297,12 +352,25 @@ export interface KnownAction {
297
352
  name: string;
298
353
  file: string;
299
354
  }
355
+ /**
356
+ * The identifier a route file is imported as in the generated entries.
357
+ *
358
+ * One-to-one with the path, which the obvious "replace everything odd with an
359
+ * underscore" is not: app/agent-account/page and app/agent/account/page
360
+ * both came out as _c_app_agent_account_page, and the entry declared the
361
+ * same import twice. A slash is an underscore, because that is what every
362
+ * alias reads like; anything else that is not a letter or digit - a hyphen,
363
+ * a dot, the brackets of a param, the parens of a group, an underscore of
364
+ * its own - is its character code, so no two paths share an alias.
365
+ */
366
+ export declare function toAlias(name: string): string;
300
367
  /**
301
368
  * The worker the dev server serves at /sw.js: it removes the one a production
302
369
  * run left on this origin, and the caches with it, then reloads each page it
303
370
  * was controlling so they load uncontrolled. Nothing else runs in development.
304
371
  */
305
372
  export declare const DEV_WORKER = "self.addEventListener('install', () => self.skipWaiting())\nself.addEventListener('activate', (event) => {\n event.waitUntil((async () => {\n const keys = await caches.keys()\n await Promise.all(keys.filter((k) => k.startsWith('rsc-kit-')).map((k) => caches.delete(k)))\n await self.clients.claim()\n const pages = await self.clients.matchAll({ type: 'window' })\n await self.registration.unregister()\n for (const page of pages) page.navigate(page.url).catch(() => {})\n })())\n})\n";
373
+ export declare function serverRendererInRsc(): Plugin;
306
374
  /**
307
375
  * The project's typecheck, as part of the build.
308
376
  *