@void/solid 0.7.6 → 0.7.7
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.
- package/dist/plugin.d.mts +5 -5
- package/dist/plugin.mjs +24 -17
- package/package.json +3 -3
- package/src/runtime/link.tsx +2 -2
- package/src/runtime/use-form.ts +6 -6
- package/src/runtime/use-island-form.ts +8 -8
package/dist/plugin.d.mts
CHANGED
|
@@ -2,15 +2,15 @@ import solid from "vite-plugin-solid";
|
|
|
2
2
|
import { Plugin } from "vite";
|
|
3
3
|
|
|
4
4
|
//#region src/plugin.d.ts
|
|
5
|
-
|
|
5
|
+
type PrefetchConfig = {
|
|
6
6
|
hoverDelay?: number;
|
|
7
7
|
cacheFor?: number | string | [string, string];
|
|
8
|
-
}
|
|
9
|
-
|
|
8
|
+
};
|
|
9
|
+
type VoidSolidOptions = Readonly<{
|
|
10
10
|
solid?: Parameters<typeof solid>[0];
|
|
11
11
|
viewTransitions?: boolean;
|
|
12
12
|
prefetch?: PrefetchConfig;
|
|
13
|
-
}
|
|
14
|
-
declare function voidSolid(options?: VoidSolidOptions):
|
|
13
|
+
}>;
|
|
14
|
+
declare function voidSolid(options?: VoidSolidOptions): ReadonlyArray<Plugin>;
|
|
15
15
|
//#endregion
|
|
16
16
|
export { VoidSolidOptions, voidSolid };
|
package/dist/plugin.mjs
CHANGED
|
@@ -180,17 +180,17 @@ function islandsPlugin(pagesDir) {
|
|
|
180
180
|
pageScan = await scanPages(root);
|
|
181
181
|
const importAttrRe = /import\s+\w+\s+from\s+("[^"]+"|'[^']+')\s+with\s*\{\s*island\s*:\s*("[^"]+"|'[^']+')\s*\}/g;
|
|
182
182
|
const filesToScan = [
|
|
183
|
-
...pageScan.pages.map((
|
|
184
|
-
filePath:
|
|
185
|
-
island:
|
|
183
|
+
...pageScan.pages.map((page) => ({
|
|
184
|
+
filePath: page.componentPath,
|
|
185
|
+
island: page.island
|
|
186
186
|
})),
|
|
187
|
-
...pageScan.layouts.map((
|
|
188
|
-
filePath:
|
|
189
|
-
island:
|
|
187
|
+
...pageScan.layouts.map((layout) => ({
|
|
188
|
+
filePath: layout.filePath,
|
|
189
|
+
island: layout.island
|
|
190
190
|
})),
|
|
191
|
-
...pageScan.namedLayouts.map((
|
|
192
|
-
filePath:
|
|
193
|
-
island:
|
|
191
|
+
...pageScan.namedLayouts.map((namedLayout) => ({
|
|
192
|
+
filePath: namedLayout.filePath,
|
|
193
|
+
island: namedLayout.island
|
|
194
194
|
}))
|
|
195
195
|
];
|
|
196
196
|
for (const entry of filesToScan) {
|
|
@@ -199,10 +199,10 @@ function islandsPlugin(pagesDir) {
|
|
|
199
199
|
const code = readFileSync(filePath, "utf-8");
|
|
200
200
|
const importerDir = dirname(filePath);
|
|
201
201
|
importAttrRe.lastIndex = 0;
|
|
202
|
-
let
|
|
203
|
-
while ((
|
|
204
|
-
const spec =
|
|
205
|
-
const strategy =
|
|
202
|
+
let importMatch;
|
|
203
|
+
while ((importMatch = importAttrRe.exec(code)) !== null) {
|
|
204
|
+
const spec = importMatch[1].slice(1, -1);
|
|
205
|
+
const strategy = importMatch[2].slice(1, -1);
|
|
206
206
|
const absPath = resolveSpecifier(spec, importerDir, COMPONENT_EXTENSIONS);
|
|
207
207
|
if (absPath) {
|
|
208
208
|
const islandId = normalizePath(relative(root, absPath)).replace(/\.[^.]+$/, "");
|
|
@@ -242,7 +242,7 @@ function islandsPlugin(pagesDir) {
|
|
|
242
242
|
handler(id) {
|
|
243
243
|
if (id === "\0" + ISLANDS_RENDERER_ID) {
|
|
244
244
|
if (!pageScan) return "export function renderIslandPage() { throw new Error('No pages found'); }";
|
|
245
|
-
const mdPlugin = resolvedConfig?.plugins?.find((
|
|
245
|
+
const mdPlugin = resolvedConfig?.plugins?.find((plugin) => plugin.name === "void-md");
|
|
246
246
|
const mdScriptIds = new Set(mdPlugin?.api?.getClientScripts?.()?.keys() ?? []);
|
|
247
247
|
const needsJS = computePagesNeedingClientJS$1();
|
|
248
248
|
return generateIslandRenderer(pageScan, pagesDir, mdScriptIds, needsJS);
|
|
@@ -677,17 +677,24 @@ start();
|
|
|
677
677
|
}
|
|
678
678
|
//#endregion
|
|
679
679
|
//#region src/plugin.ts
|
|
680
|
+
const SOLID_RUNTIME_PACKAGE = "@void/solid";
|
|
681
|
+
function excludeRuntimeFromOptimizeDeps() {
|
|
682
|
+
return { exclude: [SOLID_RUNTIME_PACKAGE] };
|
|
683
|
+
}
|
|
680
684
|
function configPlugin() {
|
|
681
685
|
return {
|
|
682
686
|
name: "void:solid:config",
|
|
683
687
|
config() {
|
|
684
688
|
return {
|
|
685
|
-
optimizeDeps:
|
|
689
|
+
optimizeDeps: excludeRuntimeFromOptimizeDeps(),
|
|
686
690
|
ssr: {
|
|
687
|
-
noExternal: [
|
|
688
|
-
optimizeDeps:
|
|
691
|
+
noExternal: [SOLID_RUNTIME_PACKAGE],
|
|
692
|
+
optimizeDeps: excludeRuntimeFromOptimizeDeps()
|
|
689
693
|
}
|
|
690
694
|
};
|
|
695
|
+
},
|
|
696
|
+
configEnvironment() {
|
|
697
|
+
return { optimizeDeps: excludeRuntimeFromOptimizeDeps() };
|
|
691
698
|
}
|
|
692
699
|
};
|
|
693
700
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@void/solid",
|
|
3
|
-
"version": "0.7.
|
|
3
|
+
"version": "0.7.7",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "git+https://github.com/voidzero-dev/void.git",
|
|
@@ -43,12 +43,12 @@
|
|
|
43
43
|
"solid-js": "^1.9.12",
|
|
44
44
|
"vite": "npm:@voidzero-dev/vite-plus-core@0.1.20",
|
|
45
45
|
"vite-plus": "^0.1.20",
|
|
46
|
-
"void": "0.7.
|
|
46
|
+
"void": "0.7.7"
|
|
47
47
|
},
|
|
48
48
|
"peerDependencies": {
|
|
49
49
|
"solid-js": "^1.9.0",
|
|
50
50
|
"vite": "npm:@voidzero-dev/vite-plus-core@0.1.20",
|
|
51
|
-
"void": "0.7.
|
|
51
|
+
"void": "0.7.7"
|
|
52
52
|
},
|
|
53
53
|
"scripts": {
|
|
54
54
|
"build": "vp pack",
|
package/src/runtime/link.tsx
CHANGED
|
@@ -16,7 +16,7 @@ type CommonProps = {
|
|
|
16
16
|
replace?: boolean;
|
|
17
17
|
reloadDocument?: boolean;
|
|
18
18
|
viewTransition?: boolean;
|
|
19
|
-
prefetch?: boolean | PrefetchStrategy |
|
|
19
|
+
prefetch?: boolean | PrefetchStrategy | ReadonlyArray<PrefetchStrategy>;
|
|
20
20
|
cacheFor?: number | string | [string, string];
|
|
21
21
|
onNavigate?: (event: NavigateEvent) => void;
|
|
22
22
|
children?: JSX.Element;
|
|
@@ -159,7 +159,7 @@ export function Link(props: LinkProps): JSX.Element {
|
|
|
159
159
|
const normalizedMethod = () => linkState().method;
|
|
160
160
|
const isGet = () => linkState().isGet;
|
|
161
161
|
const hrefWithData = () => linkState().href;
|
|
162
|
-
const strategies = createMemo<
|
|
162
|
+
const strategies = createMemo<ReadonlyArray<PrefetchStrategy>>(() => {
|
|
163
163
|
if (local.prefetch === false || local.prefetch === undefined || local.reloadDocument) {
|
|
164
164
|
return [];
|
|
165
165
|
}
|
package/src/runtime/use-form.ts
CHANGED
|
@@ -26,8 +26,8 @@ type UntypedForm = {
|
|
|
26
26
|
put(opts?: FormSubmitOptions): Promise<void>;
|
|
27
27
|
patch(opts?: FormSubmitOptions): Promise<void>;
|
|
28
28
|
delete(opts?: FormSubmitOptions): Promise<void>;
|
|
29
|
-
reset(...fields:
|
|
30
|
-
clearErrors(...fields:
|
|
29
|
+
reset(...fields: ReadonlyArray<string>): void;
|
|
30
|
+
clearErrors(...fields: ReadonlyArray<string>): void;
|
|
31
31
|
clearError(): void;
|
|
32
32
|
};
|
|
33
33
|
|
|
@@ -67,8 +67,8 @@ export function useForm<U extends ActionUrl & string>(
|
|
|
67
67
|
put(opts?: FormSubmitOptions): Promise<void>;
|
|
68
68
|
patch(opts?: FormSubmitOptions): Promise<void>;
|
|
69
69
|
delete(opts?: FormSubmitOptions): Promise<void>;
|
|
70
|
-
reset(...fields:
|
|
71
|
-
clearErrors(...fields:
|
|
70
|
+
reset(...fields: ReadonlyArray<keyof ResolveActionBody<U> & string>): void;
|
|
71
|
+
clearErrors(...fields: ReadonlyArray<keyof ResolveActionBody<U> & string>): void;
|
|
72
72
|
clearError(): void;
|
|
73
73
|
};
|
|
74
74
|
|
|
@@ -135,7 +135,7 @@ export function useForm(
|
|
|
135
135
|
setDataStore(field, value);
|
|
136
136
|
}
|
|
137
137
|
|
|
138
|
-
function reset(...fields:
|
|
138
|
+
function reset(...fields: ReadonlyArray<string>) {
|
|
139
139
|
if (fields.length === 0) {
|
|
140
140
|
setDataStore(reconcile({ ...defaults_ }));
|
|
141
141
|
} else {
|
|
@@ -145,7 +145,7 @@ export function useForm(
|
|
|
145
145
|
}
|
|
146
146
|
}
|
|
147
147
|
|
|
148
|
-
function clearErrors(...fields:
|
|
148
|
+
function clearErrors(...fields: ReadonlyArray<string>) {
|
|
149
149
|
if (fields.length === 0) {
|
|
150
150
|
setLocalErrors({});
|
|
151
151
|
} else {
|
|
@@ -29,7 +29,7 @@ async function readActionErrorBody(response: Response): Promise<unknown> {
|
|
|
29
29
|
}
|
|
30
30
|
}
|
|
31
31
|
|
|
32
|
-
export
|
|
32
|
+
export type IslandFormReturn<T extends Record<string, unknown>> = Readonly<{
|
|
33
33
|
data: T;
|
|
34
34
|
setData: <K extends keyof T & string>(field: K, value: T[K]) => void;
|
|
35
35
|
errors: Record<string, string>;
|
|
@@ -38,14 +38,14 @@ export interface IslandFormReturn<T extends Record<string, unknown>> {
|
|
|
38
38
|
hasChanges: boolean;
|
|
39
39
|
wasSuccessful: boolean;
|
|
40
40
|
recentlySuccessful: boolean;
|
|
41
|
-
reset: (...fields:
|
|
42
|
-
clearErrors: (...fields:
|
|
41
|
+
reset: (...fields: ReadonlyArray<keyof T & string>) => void;
|
|
42
|
+
clearErrors: (...fields: ReadonlyArray<string>) => void;
|
|
43
43
|
clearError: () => void;
|
|
44
44
|
post: (url: string) => Promise<void>;
|
|
45
45
|
put: (url: string) => Promise<void>;
|
|
46
46
|
patch: (url: string) => Promise<void>;
|
|
47
47
|
delete: (url: string) => Promise<void>;
|
|
48
|
-
}
|
|
48
|
+
}>;
|
|
49
49
|
|
|
50
50
|
/**
|
|
51
51
|
* Form composable for island pages. Uses fetch + page reload instead of the
|
|
@@ -70,7 +70,7 @@ export function useIslandForm<T extends Record<string, unknown>>(defaults: T): I
|
|
|
70
70
|
setDataStore(field, value);
|
|
71
71
|
}
|
|
72
72
|
|
|
73
|
-
function reset(...fields:
|
|
73
|
+
function reset(...fields: ReadonlyArray<string>) {
|
|
74
74
|
if (fields.length === 0) {
|
|
75
75
|
setDataStore(reconcile({ ...defaults_ }));
|
|
76
76
|
} else {
|
|
@@ -80,14 +80,14 @@ export function useIslandForm<T extends Record<string, unknown>>(defaults: T): I
|
|
|
80
80
|
}
|
|
81
81
|
}
|
|
82
82
|
|
|
83
|
-
function clearErrors(...fields:
|
|
83
|
+
function clearErrors(...fields: ReadonlyArray<string>) {
|
|
84
84
|
if (fields.length === 0) {
|
|
85
85
|
setErrors({});
|
|
86
86
|
} else {
|
|
87
87
|
setErrors((prev) => {
|
|
88
88
|
const next = { ...prev };
|
|
89
|
-
for (const
|
|
90
|
-
delete next[
|
|
89
|
+
for (const field of fields) {
|
|
90
|
+
delete next[field];
|
|
91
91
|
}
|
|
92
92
|
return next;
|
|
93
93
|
});
|