@void/react 0.7.6 → 0.7.8

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.
@@ -15,7 +15,7 @@ type CommonProps = {
15
15
  replace?: boolean;
16
16
  reloadDocument?: boolean;
17
17
  viewTransition?: boolean;
18
- prefetch?: boolean | PrefetchStrategy | Array<PrefetchStrategy>;
18
+ prefetch?: boolean | PrefetchStrategy | ReadonlyArray<PrefetchStrategy>;
19
19
  cacheFor?: number | string | [string, string];
20
20
  onNavigate?: (event: {
21
21
  preventDefault(): void;
@@ -68,8 +68,8 @@ declare function useForm<U extends ActionUrl & string>(url: U, defaults: Resolve
68
68
  put(formData: FormData): void;
69
69
  patch(formData: FormData): void;
70
70
  delete(formData: FormData): void;
71
- reset(...fields: Array<keyof ResolveActionBody<U> & string>): void;
72
- clearErrors(...fields: Array<keyof ResolveActionBody<U> & string>): void;
71
+ reset(...fields: ReadonlyArray<keyof ResolveActionBody<U> & string>): void;
72
+ clearErrors(...fields: ReadonlyArray<keyof ResolveActionBody<U> & string>): void;
73
73
  clearError(): void;
74
74
  };
75
75
  //#endregion
@@ -77,7 +77,7 @@ declare function useForm<U extends ActionUrl & string>(url: U, defaults: Resolve
77
77
  declare function useNavigation(): NavigationState;
78
78
  //#endregion
79
79
  //#region src/runtime/use-island-form.d.ts
80
- interface IslandFormReturn<T extends Record<string, unknown>> {
80
+ type IslandFormReturn<T extends Record<string, unknown>> = Readonly<{
81
81
  data: T;
82
82
  setData: <K extends keyof T & string>(field: K, value: T[K]) => void;
83
83
  errors: Record<string, string>;
@@ -86,14 +86,14 @@ interface IslandFormReturn<T extends Record<string, unknown>> {
86
86
  hasChanges: boolean;
87
87
  wasSuccessful: boolean;
88
88
  recentlySuccessful: boolean;
89
- reset: (...fields: Array<keyof T & string>) => void;
90
- clearErrors: (...fields: Array<string>) => void;
89
+ reset: (...fields: ReadonlyArray<keyof T & string>) => void;
90
+ clearErrors: (...fields: ReadonlyArray<string>) => void;
91
91
  clearError: () => void;
92
92
  post: (url: string) => Promise<void>;
93
93
  put: (url: string) => Promise<void>;
94
94
  patch: (url: string) => Promise<void>;
95
95
  delete: (url: string) => Promise<void>;
96
- }
96
+ }>;
97
97
  /**
98
98
  * Form hook for island pages. Uses fetch + page reload instead of the
99
99
  * Void Router (which is not available in island mode).
package/dist/index.d.mts CHANGED
@@ -1,2 +1,2 @@
1
- import { a as ParamsContext, c as action, d as useNavigation, f as useForm, g as Link, h as useRouter, i as NavigationContext, l as setActionRouter, m as useParams, n as InferProps, o as RouterContext, p as useShared, r as ErrorsContext, s as SharedContext, t as Deferred, u as useIslandForm } from "./index-75EO-lLe.mjs";
1
+ import { a as ParamsContext, c as action, d as useNavigation, f as useForm, g as Link, h as useRouter, i as NavigationContext, l as setActionRouter, m as useParams, n as InferProps, o as RouterContext, p as useShared, r as ErrorsContext, s as SharedContext, t as Deferred, u as useIslandForm } from "./index-CykTJ4Xm.mjs";
2
2
  export { Deferred, ErrorsContext, InferProps, Link, NavigationContext, ParamsContext, RouterContext, SharedContext, action, setActionRouter, useForm, useIslandForm, useNavigation, useParams, useRouter, useShared };
package/dist/index.mjs CHANGED
@@ -1,4 +1,4 @@
1
1
  import { a as SharedContext, i as RouterContext, n as NavigationContext, r as ParamsContext, t as ErrorsContext } from "./context-CBGCQE3p.mjs";
2
- import { a as useParams, i as useShared, n as useNavigation, o as useRouter, r as useForm, s as Link, t as useIslandForm } from "./runtime-BpEAl7K2.mjs";
2
+ import { a as useParams, i as useShared, n as useNavigation, o as useRouter, r as useForm, s as Link, t as useIslandForm } from "./runtime-C0j3tKTP.mjs";
3
3
  import { n as setActionRouter, t as action } from "./action-BFWtavbf.mjs";
4
4
  export { ErrorsContext, Link, NavigationContext, ParamsContext, RouterContext, SharedContext, action, setActionRouter, useForm, useIslandForm, useNavigation, useParams, useRouter, useShared };
package/dist/plugin.d.mts CHANGED
@@ -2,15 +2,15 @@ import react from "@vitejs/plugin-react";
2
2
  import { Plugin } from "vite";
3
3
 
4
4
  //#region src/plugin.d.ts
5
- interface PrefetchConfig {
5
+ type PrefetchConfig = {
6
6
  hoverDelay?: number;
7
7
  cacheFor?: number | string | [string, string];
8
- }
9
- interface VoidReactOptions {
8
+ };
9
+ type VoidReactOptions = Readonly<{
10
10
  react?: Parameters<typeof react>[0];
11
11
  viewTransitions?: boolean;
12
12
  prefetch?: PrefetchConfig;
13
- }
14
- declare function voidReact(options?: VoidReactOptions): Array<Plugin>;
13
+ }>;
14
+ declare function voidReact(options?: VoidReactOptions): ReadonlyArray<Plugin>;
15
15
  //#endregion
16
16
  export { VoidReactOptions, voidReact };
package/dist/plugin.mjs CHANGED
@@ -170,17 +170,17 @@ function islandsPlugin(pagesDir) {
170
170
  pageScan = await scanPages(root);
171
171
  const importAttrRe = /import\s+\w+\s+from\s+("[^"]+"|'[^']+')\s+with\s*\{\s*island\s*:\s*("[^"]+"|'[^']+')\s*\}/g;
172
172
  const filesToScan = [
173
- ...pageScan.pages.map((p) => ({
174
- filePath: p.componentPath,
175
- island: p.island
173
+ ...pageScan.pages.map((page) => ({
174
+ filePath: page.componentPath,
175
+ island: page.island
176
176
  })),
177
- ...pageScan.layouts.map((l) => ({
178
- filePath: l.filePath,
179
- island: l.island
177
+ ...pageScan.layouts.map((layout) => ({
178
+ filePath: layout.filePath,
179
+ island: layout.island
180
180
  })),
181
- ...pageScan.namedLayouts.map((nl) => ({
182
- filePath: nl.filePath,
183
- island: nl.island
181
+ ...pageScan.namedLayouts.map((namedLayout) => ({
182
+ filePath: namedLayout.filePath,
183
+ island: namedLayout.island
184
184
  }))
185
185
  ];
186
186
  for (const entry of filesToScan) {
@@ -189,10 +189,10 @@ function islandsPlugin(pagesDir) {
189
189
  const code = readFileSync(filePath, "utf-8");
190
190
  const importerDir = dirname(filePath);
191
191
  importAttrRe.lastIndex = 0;
192
- let m;
193
- while ((m = importAttrRe.exec(code)) !== null) {
194
- const spec = m[1].slice(1, -1);
195
- const strategy = m[2].slice(1, -1);
192
+ let importMatch;
193
+ while ((importMatch = importAttrRe.exec(code)) !== null) {
194
+ const spec = importMatch[1].slice(1, -1);
195
+ const strategy = importMatch[2].slice(1, -1);
196
196
  const absPath = resolveSpecifier(spec, importerDir, COMPONENT_EXTENSIONS);
197
197
  if (absPath) {
198
198
  const islandId = normalizePath(relative(root, absPath)).replace(/\.[^.]+$/, "");
@@ -231,7 +231,7 @@ function islandsPlugin(pagesDir) {
231
231
  handler(id) {
232
232
  if (id === "\0" + ISLANDS_RENDERER_ID) {
233
233
  if (!pageScan) return "export function renderIslandPage() { throw new Error('No pages found'); }";
234
- const mdPlugin = resolvedConfig?.plugins?.find((p) => p.name === "void-md");
234
+ const mdPlugin = resolvedConfig?.plugins?.find((plugin) => plugin.name === "void-md");
235
235
  const mdScriptIds = new Set(mdPlugin?.api?.getClientScripts?.()?.keys() ?? []);
236
236
  const needsJS = computePagesNeedingClientJSLocal();
237
237
  return generateIslandRenderer(pageScan, pagesDir, isDev, mdScriptIds, needsJS);
@@ -1,2 +1,2 @@
1
- import { a as ParamsContext, c as action, d as useNavigation, f as useForm, g as Link, h as useRouter, i as NavigationContext, l as setActionRouter, m as useParams, n as InferProps, o as RouterContext, p as useShared, r as ErrorsContext, s as SharedContext, t as Deferred, u as useIslandForm } from "../index-75EO-lLe.mjs";
1
+ import { a as ParamsContext, c as action, d as useNavigation, f as useForm, g as Link, h as useRouter, i as NavigationContext, l as setActionRouter, m as useParams, n as InferProps, o as RouterContext, p as useShared, r as ErrorsContext, s as SharedContext, t as Deferred, u as useIslandForm } from "../index-CykTJ4Xm.mjs";
2
2
  export { Deferred, ErrorsContext, InferProps, Link, NavigationContext, ParamsContext, RouterContext, SharedContext, action, setActionRouter, useForm, useIslandForm, useNavigation, useParams, useRouter, useShared };
@@ -1,4 +1,4 @@
1
1
  import { a as SharedContext, i as RouterContext, n as NavigationContext, r as ParamsContext, t as ErrorsContext } from "../context-CBGCQE3p.mjs";
2
- import { a as useParams, i as useShared, n as useNavigation, o as useRouter, r as useForm, s as Link, t as useIslandForm } from "../runtime-BpEAl7K2.mjs";
2
+ import { a as useParams, i as useShared, n as useNavigation, o as useRouter, r as useForm, s as Link, t as useIslandForm } from "../runtime-C0j3tKTP.mjs";
3
3
  import { n as setActionRouter, t as action } from "../action-BFWtavbf.mjs";
4
4
  export { ErrorsContext, Link, NavigationContext, ParamsContext, RouterContext, SharedContext, action, setActionRouter, useForm, useIslandForm, useNavigation, useParams, useRouter, useShared };
@@ -6,7 +6,7 @@ import { CacheForResult } from "void/pages-prefetch";
6
6
  type ComponentModule = {
7
7
  default: ComponentType<any>;
8
8
  };
9
- interface ReactPagesConfig {
9
+ type ReactPagesConfig = Readonly<{
10
10
  components: Record<string, () => Promise<ComponentModule>>;
11
11
  layoutTree: Record<string, Array<string>>;
12
12
  routeMeta: Record<string, {
@@ -18,10 +18,10 @@ interface ReactPagesConfig {
18
18
  viewTransitions: boolean;
19
19
  prefetchHoverDelay: number;
20
20
  prefetchDefaultCacheFor: CacheForResult;
21
- }
22
- interface ReactPagesClient {
21
+ }>;
22
+ type ReactPagesClient = Readonly<{
23
23
  router: VoidRouter;
24
- }
24
+ }>;
25
25
  declare function startReactPages(config: ReactPagesConfig): Promise<ReactPagesClient>;
26
26
  //#endregion
27
27
  export { ReactPagesClient, ReactPagesConfig, startReactPages };
@@ -5,7 +5,7 @@ import { PageObject } from "void/pages-protocol";
5
5
  type ComponentModule = {
6
6
  default: ComponentType<any>;
7
7
  };
8
- interface ReactPagesServerConfig {
8
+ type ReactPagesServerConfig = Readonly<{
9
9
  pageObj: PageObject;
10
10
  assetTags: {
11
11
  css: string;
@@ -15,7 +15,7 @@ interface ReactPagesServerConfig {
15
15
  components: Record<string, () => Promise<ComponentModule>>;
16
16
  layoutTree: Record<string, Array<string>>;
17
17
  preambleScript?: string;
18
- }
18
+ }>;
19
19
  declare function renderReactPage({
20
20
  pageObj,
21
21
  assetTags,
@@ -425,7 +425,7 @@ function useIslandForm(defaults) {
425
425
  if (fields.length === 0) setErrors({});
426
426
  else setErrors((prev) => {
427
427
  const next = { ...prev };
428
- for (const f of fields) delete next[f];
428
+ for (const field of fields) delete next[field];
429
429
  return next;
430
430
  });
431
431
  }, []);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@void/react",
3
- "version": "0.7.6",
3
+ "version": "0.7.8",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git+https://github.com/voidzero-dev/void.git",
@@ -51,13 +51,13 @@
51
51
  "react-dom": "^19.2.6",
52
52
  "vite": "npm:@voidzero-dev/vite-plus-core@0.1.20",
53
53
  "vite-plus": "^0.1.20",
54
- "void": "0.7.6"
54
+ "void": "0.7.8"
55
55
  },
56
56
  "peerDependencies": {
57
57
  "react": "^19.0.0",
58
58
  "react-dom": "^19.0.0",
59
59
  "vite": "npm:@voidzero-dev/vite-plus-core@0.1.20",
60
- "void": "0.7.6"
60
+ "void": "0.7.8"
61
61
  },
62
62
  "scripts": {
63
63
  "build": "vp pack",