@void/react 1.4.0 → 1.5.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.
@@ -1,7 +1,6 @@
1
1
  import { createActionClient } from "void/pages-client";
2
- //#region src/runtime/action.ts
3
- const client = createActionClient();
2
+ // src/runtime/action.ts
3
+ const client = createActionClient({ _resolveOnShell: true });
4
4
  const action = client.action;
5
5
  const setActionRouter = client.setActionRouter;
6
- //#endregion
7
6
  export { setActionRouter as n, action as t };
@@ -1,11 +1,10 @@
1
1
  import { createContext } from "react";
2
2
  import { idleNavigationState } from "void/pages-client";
3
- //#region src/runtime/context.ts
3
+ // src/runtime/context.ts
4
4
  const SharedContext = createContext(null);
5
5
  const ErrorsContext = createContext(null);
6
6
  const ParamsContext = createContext(null);
7
7
  const RouterContext = createContext(null);
8
8
  const NavigationContext = createContext(idleNavigationState());
9
9
  const FrontmatterContext = createContext({});
10
- //#endregion
11
10
  export { RouterContext as a, ParamsContext as i, FrontmatterContext as n, SharedContext as o, NavigationContext as r, ErrorsContext as t };
@@ -1,6 +1,5 @@
1
- //#region src/runtime/deferred-shell.ts
1
+ // src/runtime/deferred-shell.ts
2
2
  const DEFERRED_SHELL_END_ID = "__VOID_DEFERRED_SHELL_END__";
3
3
  const DEFERRED_SHELL_END_MARKER = `<template id="${DEFERRED_SHELL_END_ID}"></template>`;
4
4
  const DEFERRED_SHELL_CANCEL_REASON = "Void deferred shell complete";
5
- //#endregion
6
5
  export { DEFERRED_SHELL_END_ID as n, DEFERRED_SHELL_END_MARKER as r, DEFERRED_SHELL_CANCEL_REASON as t };
package/dist/index.d.mts CHANGED
@@ -2,15 +2,12 @@ import { AnchorHTMLAttributes, ButtonHTMLAttributes, Context, FormHTMLAttributes
2
2
  import { ActionClient, FormMethod, FormModel, FormResetOptions, NavigationState, VoidActionError, VoidRouter } from "void/pages-client";
3
3
  import { CloudContextVariables, InferProps } from "void";
4
4
  import { ActionFormOptions, ActionUrl, ResolveActionBody } from "void/routes";
5
- //#region src/runtime/form.d.ts
6
5
  type FormProps = Omit<FormHTMLAttributes<HTMLFormElement>, "action" | "onSubmit" | "method" | "onError"> & {
7
6
  form: FormModel<[FormData]>;
8
7
  method?: FormMethod;
9
8
  renderError?: (error: VoidActionError) => ReactNode;
10
9
  };
11
10
  export declare function Form({ form, method, renderError, children, ...props }: FormProps): ReactElement;
12
- //#endregion
13
- //#region src/runtime/link.d.ts
14
11
  type PrefetchStrategy = "hover" | "click" | "mount" | "visible";
15
12
  type LinkMethod = "GET" | "POST" | "PUT" | "PATCH" | "DELETE";
16
13
  type CommonProps = {
@@ -30,17 +27,9 @@ type CommonProps = {
30
27
  };
31
28
  type LinkProps = CommonProps & Omit<AnchorHTMLAttributes<HTMLAnchorElement>, keyof CommonProps> & Omit<ButtonHTMLAttributes<HTMLButtonElement>, keyof CommonProps>;
32
29
  export declare function Link({ href, method, data, preserveScroll, preserveState, replace, reloadDocument, viewTransition, prefetch: prefetchProp, cacheFor, onNavigate, children, style, onClick: onClickProp, onMouseEnter: onMouseEnterProp, onMouseLeave: onMouseLeaveProp, onFocus: onFocusProp, onMouseDown: onMouseDownProp, onTouchStart: onTouchStartProp, ...rest }: LinkProps): JSX.Element;
33
- //#endregion
34
- //#region src/runtime/use-router.d.ts
35
30
  export declare function useRouter(): VoidRouter;
36
- //#endregion
37
- //#region src/runtime/use-params.d.ts
38
31
  export declare function useParams<T extends Record<string, string> = Record<string, string>>(): T;
39
- //#endregion
40
- //#region src/runtime/use-shared.d.ts
41
32
  export declare function useShared<T = CloudContextVariables["shared"]>(): T;
42
- //#endregion
43
- //#region src/runtime/use-form.d.ts
44
33
  type FormOptions = {
45
34
  params?: Record<string, string>;
46
35
  resetOnSuccess?: boolean;
@@ -66,11 +55,7 @@ export declare function useForm<U extends ActionUrl & string>(url: U, defaults:
66
55
  clearErrors(...fields: ReadonlyArray<keyof ResolveActionBody<U> & string>): void;
67
56
  clearError(): void;
68
57
  };
69
- //#endregion
70
- //#region src/runtime/use-navigation.d.ts
71
58
  export declare function useNavigation(): NavigationState;
72
- //#endregion
73
- //#region src/runtime/use-island-form.d.ts
74
59
  type IslandFormReturn<T extends Record<string, unknown>> = Readonly<{
75
60
  data: T;
76
61
  setData: <K extends keyof T & string>(field: K, value: T[K]) => void;
@@ -93,20 +78,13 @@ type IslandFormReturn<T extends Record<string, unknown>> = Readonly<{
93
78
  * Void Router (which is not available in island mode).
94
79
  */
95
80
  export declare function useIslandForm<T extends Record<string, unknown>>(defaults: T): IslandFormReturn<T>;
96
- //#endregion
97
- //#region src/runtime/action.d.ts
98
81
  export declare const action: ActionClient["action"];
99
82
  export declare const setActionRouter: ActionClient["setActionRouter"];
100
- //#endregion
101
- //#region src/runtime/context.d.ts
102
83
  export declare const SharedContext: Context<Record<string, unknown> | null>;
103
84
  export declare const ErrorsContext: Context<Record<string, string> | null>;
104
85
  export declare const ParamsContext: Context<Record<string, string> | null>;
105
86
  export declare const RouterContext: Context<VoidRouter | null>;
106
87
  export declare const NavigationContext: Context<NavigationState>;
107
88
  export declare const FrontmatterContext: Context<Record<string, unknown>>;
108
- //#endregion
109
- //#region src/runtime/index.d.ts
110
89
  export type Deferred<T> = Promise<T>;
111
- //#endregion
112
90
  export type { InferProps };
package/dist/index.mjs CHANGED
@@ -1,9 +1,9 @@
1
- import { a as RouterContext, i as ParamsContext, n as FrontmatterContext, o as SharedContext, r as NavigationContext, t as ErrorsContext } from "./context-D2ctU4yT.mjs";
2
- import { n as setActionRouter, t as action } from "./action-4EvQppia.mjs";
1
+ import { a as RouterContext, i as ParamsContext, n as FrontmatterContext, o as SharedContext, r as NavigationContext, t as ErrorsContext } from "./context-BQpawTZc.mjs";
2
+ import { n as setActionRouter, t as action } from "./action-CyCVdW12.mjs";
3
3
  import { useActionState, useCallback, useContext, useEffect, useMemo, useRef, useState } from "react";
4
4
  import { cloneFormValue, formErrorMessage, formRetryMessage, formSubmissionBlocked, getValidationErrors, interpolateRouteParams, isAbortError, isEqualFormValue, isModifiedEvent, mergeDataIntoHref, parseFormResetArgs, scheduleFormRetry, ssrProxy, submitAction, submitIslandAction } from "void/pages-client";
5
5
  import { jsx, jsxs } from "react/jsx-runtime";
6
- //#region src/runtime/form.tsx
6
+ // src/runtime/form.tsx
7
7
  function Form({ form, method = "post", renderError, children, ...props }) {
8
8
  const [now, setNow] = useState(Date.now);
9
9
  useEffect(() => scheduleFormRetry(form.error, () => setNow(Date.now())), [form.error]);
@@ -24,8 +24,7 @@ function Form({ form, method = "post", renderError, children, ...props }) {
24
24
  }), children]
25
25
  });
26
26
  }
27
- //#endregion
28
- //#region src/runtime/link.tsx
27
+ // src/runtime/link.tsx
29
28
  function Link({ href, method = "GET", data, preserveScroll = false, preserveState = false, replace = false, reloadDocument = false, viewTransition, prefetch: prefetchProp = false, cacheFor, onNavigate, children, style, onClick: onClickProp, onMouseEnter: onMouseEnterProp, onMouseLeave: onMouseLeaveProp, onFocus: onFocusProp, onMouseDown: onMouseDownProp, onTouchStart: onTouchStartProp, ...rest }) {
30
29
  const router = useContext(RouterContext);
31
30
  const elementRef = useRef(null);
@@ -208,27 +207,23 @@ function Link({ href, method = "GET", data, preserveScroll = false, preserveStat
208
207
  children
209
208
  });
210
209
  }
211
- //#endregion
212
- //#region src/runtime/use-router.ts
210
+ // src/runtime/use-router.ts
213
211
  function useRouter() {
214
212
  return useContext(RouterContext) ?? ssrProxy;
215
213
  }
216
- //#endregion
217
- //#region src/runtime/use-params.ts
214
+ // src/runtime/use-params.ts
218
215
  function useParams() {
219
216
  const params = useContext(ParamsContext);
220
217
  if (params === null) throw new Error("useParams(): must be used inside a Void page.");
221
218
  return params;
222
219
  }
223
- //#endregion
224
- //#region src/runtime/use-shared.ts
220
+ // src/runtime/use-shared.ts
225
221
  function useShared() {
226
222
  const shared = useContext(SharedContext);
227
223
  if (!shared) throw new Error("useShared(): must be used inside a Void page.");
228
224
  return shared;
229
225
  }
230
- //#endregion
231
- //#region src/runtime/use-form.ts
226
+ // src/runtime/use-form.ts
232
227
  function useForm(url, defaults, options) {
233
228
  const router = useContext(RouterContext);
234
229
  const [data, setDataState] = useState(() => cloneFormValue(defaults));
@@ -364,13 +359,11 @@ function useForm(url, defaults, options) {
364
359
  clearError
365
360
  };
366
361
  }
367
- //#endregion
368
- //#region src/runtime/use-navigation.ts
362
+ // src/runtime/use-navigation.ts
369
363
  function useNavigation() {
370
364
  return useContext(NavigationContext);
371
365
  }
372
- //#endregion
373
- //#region src/runtime/use-island-form.ts
366
+ // src/runtime/use-island-form.ts
374
367
  /**
375
368
  * Form hook for island pages. Uses fetch + page reload instead of the
376
369
  * Void Router (which is not available in island mode).
@@ -458,5 +451,4 @@ function useIslandForm(defaults) {
458
451
  delete: (url) => submit(url, "DELETE")
459
452
  };
460
453
  }
461
- //#endregion
462
454
  export { ErrorsContext, Form, FrontmatterContext, Link, NavigationContext, ParamsContext, RouterContext, SharedContext, action, setActionRouter, useForm, useIslandForm, useNavigation, useParams, useRouter, useShared };
package/dist/plugin.d.mts CHANGED
@@ -1,17 +1,13 @@
1
1
  import react from "@vitejs/plugin-react";
2
2
  import { Plugin } from "vite";
3
- //#region src/plugin-pages.d.ts
4
3
  type PrefetchConfig = {
5
4
  hoverDelay?: number;
6
5
  cacheFor?: number | string | [string, string];
7
6
  };
8
- //#endregion
9
- //#region src/plugin.d.ts
10
7
  export type VoidReactOptions = Readonly<{
11
8
  react?: Parameters<typeof react>[0];
12
9
  viewTransitions?: boolean;
13
10
  prefetch?: PrefetchConfig;
14
11
  }>;
15
12
  export declare function voidReact(options?: VoidReactOptions): Array<Plugin>;
16
- //#endregion
17
13
  export {};
package/dist/plugin.mjs CHANGED
@@ -4,7 +4,7 @@ import { existsSync, readFileSync } from "node:fs";
4
4
  import nodePath from "node:path";
5
5
  import { normalizePath } from "vite";
6
6
  import { ISLANDS_CLIENT_ENTRY_ID, ISLANDS_RENDERER_ID, computePagesNeedingClientJS, editIslandSource, findIslandImports, findStaticCssImports, hasIslandPages, islandStylesPlugin, recordIslandStyles, recordedIslandStyles, resolveSpecifier, rewriteCssImportForVirtualModule, watchPagesForRescan } from "void/pages-islands-plugin";
7
- //#region ../../node_modules/.pnpm/pathslash@0.1.0/node_modules/pathslash/dist/index.mjs
7
+ // ../../node_modules/.pnpm/pathslash@0.1.0/node_modules/pathslash/dist/index.mjs
8
8
  const BACKSLASH_RE = /\\/g;
9
9
  const isWindows = process.platform === "win32";
10
10
  /**
@@ -42,8 +42,7 @@ const posix = { ...nodePath.posix };
42
42
  posix.posix = win32.posix = posix;
43
43
  posix.win32 = win32.win32 = win32;
44
44
  const { basename, delimiter, dirname, extname, format, isAbsolute, join, matchesGlob, normalize, parse, relative, resolve, sep, toNamespacedPath } = isWindows ? win32 : posix;
45
- //#endregion
46
- //#region src/plugin-pages.ts
45
+ // src/plugin-pages.ts
47
46
  const CLIENT_ENTRY_ID = "virtual:void-pages-client";
48
47
  const WORKER_ENVIRONMENT_NAME = "void_worker";
49
48
  const REACT_DEDUPE = ["react", "react-dom"];
@@ -179,8 +178,7 @@ function generateClientEntry(scan, pagesDir, viewTransitions, prefetch, staticPa
179
178
  export { router };
180
179
  `;
181
180
  }
182
- //#endregion
183
- //#region src/plugin-islands.ts
181
+ // src/plugin-islands.ts
184
182
  const COMPONENT_EXTENSIONS = [
185
183
  ".tsx",
186
184
  ".jsx",
@@ -431,8 +429,7 @@ initIslands(islands, hydrateIsland);
431
429
  `);
432
430
  return lines.join("\n");
433
431
  }
434
- //#endregion
435
- //#region src/plugin.ts
432
+ // src/plugin.ts
436
433
  function voidReact(options) {
437
434
  const root = process.cwd();
438
435
  const pagesDir = resolvePagesDir(root);
@@ -446,5 +443,4 @@ function voidReact(options) {
446
443
  ...islandsPlugin(pagesDir, { root })
447
444
  ];
448
445
  }
449
- //#endregion
450
446
  export { voidReact };
@@ -2,7 +2,6 @@ import { ComponentType } from "react";
2
2
  import { VoidRouter } from "void/pages-client";
3
3
  import { CacheForResult } from "void/pages-prefetch";
4
4
  import { PageObject } from "void/pages-protocol";
5
- //#region src/runtime/pages-client.d.ts
6
5
  type ComponentModule = {
7
6
  default: ComponentType<any>;
8
7
  };
@@ -29,5 +28,4 @@ export type ReactPagesClient = Readonly<{
29
28
  router: VoidRouter;
30
29
  }>;
31
30
  export declare function startReactPages(config: ReactPagesConfig): Promise<ReactPagesClient>;
32
- //#endregion
33
31
  export {};
@@ -1,10 +1,10 @@
1
- import { a as RouterContext, i as ParamsContext, o as SharedContext, r as NavigationContext, t as ErrorsContext } from "../context-D2ctU4yT.mjs";
2
- import { n as setActionRouter } from "../action-4EvQppia.mjs";
3
- import { n as DEFERRED_SHELL_END_ID } from "../deferred-shell-DOuP2YAo.mjs";
1
+ import { a as RouterContext, i as ParamsContext, o as SharedContext, r as NavigationContext, t as ErrorsContext } from "../context-BQpawTZc.mjs";
2
+ import { n as setActionRouter } from "../action-CyCVdW12.mjs";
3
+ import { n as DEFERRED_SHELL_END_ID } from "../deferred-shell-D5T32zXz.mjs";
4
4
  import React, { Suspense, startTransition, use, useCallback, useEffect, useInsertionEffect, useLayoutEffect, useMemo, useReducer, useState, useTransition } from "react";
5
- import { createPageNavigationEngine, createRouterFacade, idleNavigationState, isAbortError, isCallSiteActionError, refreshPage } from "void/pages-client";
5
+ import { createPageNavigationEngine, createRouterFacade, idleNavigationState, isAbortError, isCallSiteActionError, refreshPage, toUrlString } from "void/pages-client";
6
6
  import { createRoot, hydrateRoot } from "react-dom/client";
7
- //#region src/runtime/pages-client.ts
7
+ // src/runtime/pages-client.ts
8
8
  const deferredState = /* @__PURE__ */ new WeakMap();
9
9
  const viewTransitionWaiters = /* @__PURE__ */ new Map();
10
10
  const pendingVisitSettlers = /* @__PURE__ */ new Map();
@@ -51,8 +51,9 @@ function currentUrl() {
51
51
  return window.location.pathname + window.location.search + window.location.hash;
52
52
  }
53
53
  function normalizeUrl(value) {
54
- if (typeof value === "string" && value.startsWith("#")) return value;
55
- const url = value instanceof URL ? value : new URL(value, window.location.origin);
54
+ const urlString = toUrlString(value);
55
+ if (urlString.startsWith("#")) return urlString;
56
+ const url = new URL(urlString, window.location.origin);
56
57
  return url.origin === window.location.origin ? url.pathname + url.search + url.hash : url.href;
57
58
  }
58
59
  /** Page data holds a decoded path. Compare it with browser URLs in their encoded form. */
@@ -513,5 +514,4 @@ async function startReactPages(config) {
513
514
  engine.start();
514
515
  return { router };
515
516
  }
516
- //#endregion
517
517
  export { startReactPages };
@@ -1,6 +1,5 @@
1
1
  import { ComponentType } from "react";
2
2
  import { PageObject } from "void/pages-protocol";
3
- //#region src/runtime/pages-server.d.ts
4
3
  type ComponentModule = {
5
4
  default: ComponentType<any>;
6
5
  };
@@ -16,5 +15,4 @@ export type ReactPagesServerConfig = Readonly<{
16
15
  preambleScript?: string;
17
16
  }>;
18
17
  export declare function renderReactPage({ pageObj, assetTags, components, layoutTree, preambleScript }: ReactPagesServerConfig): Promise<ReadableStream<Uint8Array>>;
19
- //#endregion
20
18
  export {};
@@ -1,11 +1,11 @@
1
- import { a as RouterContext, i as ParamsContext, o as SharedContext, r as NavigationContext, t as ErrorsContext } from "../context-D2ctU4yT.mjs";
2
- import { n as DEFERRED_SHELL_END_ID, r as DEFERRED_SHELL_END_MARKER, t as DEFERRED_SHELL_CANCEL_REASON } from "../deferred-shell-DOuP2YAo.mjs";
1
+ import { a as RouterContext, i as ParamsContext, o as SharedContext, r as NavigationContext, t as ErrorsContext } from "../context-BQpawTZc.mjs";
2
+ import { n as DEFERRED_SHELL_END_ID, r as DEFERRED_SHELL_END_MARKER, t as DEFERRED_SHELL_CANCEL_REASON } from "../deferred-shell-D5T32zXz.mjs";
3
3
  import React from "react";
4
4
  import { createSsrRouter, idleNavigationState } from "void/pages-client";
5
5
  import { renderToReadableStream } from "react-dom/server";
6
6
  import { renderBodyAttrs, renderHeadToString, renderHtmlAttrs } from "void/pages-head";
7
7
  import { serializePageData } from "void/pages-server";
8
- //#region src/runtime/page-streams.ts
8
+ // src/runtime/page-streams.ts
9
9
  function concatStreams(streams) {
10
10
  let index = 0;
11
11
  let reader;
@@ -94,8 +94,7 @@ function readDeferredShell(stream) {
94
94
  }
95
95
  }, { highWaterMark: 0 });
96
96
  }
97
- //#endregion
98
- //#region src/runtime/pages-server.ts
97
+ // src/runtime/pages-server.ts
99
98
  function createPendingDeferred() {
100
99
  return new Promise(() => {});
101
100
  }
@@ -155,5 +154,4 @@ async function renderReactPage({ pageObj, assetTags, components, layoutTree, pre
155
154
  </html>`)
156
155
  ]);
157
156
  }
158
- //#endregion
159
157
  export { renderReactPage };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@void/react",
3
- "version": "1.4.0",
3
+ "version": "1.5.0",
4
4
  "description": "React pages, server rendering, forms, and navigation for Void.",
5
5
  "homepage": "https://void.cloud",
6
6
  "bugs": {
@@ -41,22 +41,22 @@
41
41
  "@vitejs/plugin-react": "^6.1.2"
42
42
  },
43
43
  "devDependencies": {
44
- "@types/node": "^26.6.5",
44
+ "@types/node": "^26.6.6",
45
45
  "@types/react": "^19.3.0",
46
46
  "@types/react-dom": "^19.3.0",
47
47
  "happy-dom": "^21.0.4",
48
48
  "pathslash": "^0.1.0",
49
49
  "react": "^19.3.1",
50
50
  "react-dom": "^19.3.1",
51
- "vite": "npm:@voidzero-dev/vite-plus-core@1.3.0",
52
- "vite-plus": "1.3.0",
53
- "void": "1.4.0"
51
+ "vite": "npm:@voidzero-dev/vite-plus-core@1.4.0",
52
+ "vite-plus": "1.4.0",
53
+ "void": "1.5.0"
54
54
  },
55
55
  "peerDependencies": {
56
56
  "react": "^19.0.0",
57
57
  "react-dom": "^19.0.0",
58
58
  "vite": "^8.0.0",
59
- "void": "1.4.0"
59
+ "void": "1.5.0"
60
60
  },
61
61
  "scripts": {
62
62
  "build": "vp pack",