@void/solid 0.7.5 → 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 +28 -37
- 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
|
@@ -2,7 +2,7 @@ import solid from "vite-plugin-solid";
|
|
|
2
2
|
import { existsSync, readFileSync, readdirSync } from "node:fs";
|
|
3
3
|
import { normalizePath } from "vite";
|
|
4
4
|
import { generateComponentManifest, resolveEffectiveLayoutChain, resolveStaticPageDataBuildOptions, scanPages } from "void/pages";
|
|
5
|
-
import { ISLANDS_CLIENT_ENTRY_ID, ISLANDS_RENDERER_ID, computePagesNeedingClientJS,
|
|
5
|
+
import { ISLANDS_CLIENT_ENTRY_ID, ISLANDS_RENDERER_ID, computePagesNeedingClientJS, extractCssImports, needsIslandClientBundle, resolveSpecifier, rewriteCssImportForVirtualModule, watchPagesForRescan } from "void/pages-islands-plugin";
|
|
6
6
|
//#region ../../node_modules/.pnpm/pathe@2.0.3/node_modules/pathe/dist/shared/pathe.M-eThtNZ.mjs
|
|
7
7
|
const _DRIVE_LETTER_START_RE = /^[A-Za-z]:\//;
|
|
8
8
|
function normalizeWindowsPath(input = "") {
|
|
@@ -157,13 +157,7 @@ function islandsPlugin(pagesDir) {
|
|
|
157
157
|
const wrapperMeta = /* @__PURE__ */ new Map();
|
|
158
158
|
let wrapperId = 0;
|
|
159
159
|
let viteRoot = "";
|
|
160
|
-
const islandCssMap = /* @__PURE__ */ new Map();
|
|
161
160
|
let resolvedConfig = null;
|
|
162
|
-
/** Rebuild islandCssMap from current file contents (re-runs fileHasCssImports). */
|
|
163
|
-
function rebuildIslandCssMap$1() {
|
|
164
|
-
if (!pageScan) return;
|
|
165
|
-
rebuildIslandCssMap(pageScan, pagesDir, islandCssMap, fileHasCssImports);
|
|
166
|
-
}
|
|
167
161
|
function computePagesNeedingClientJS$1() {
|
|
168
162
|
if (!pageScan) return /* @__PURE__ */ new Set();
|
|
169
163
|
return computePagesNeedingClientJS(pageScan, pagesDir, resolvedConfig);
|
|
@@ -177,10 +171,8 @@ function islandsPlugin(pagesDir) {
|
|
|
177
171
|
isDev = config.command === "serve";
|
|
178
172
|
},
|
|
179
173
|
configureServer(server) {
|
|
180
|
-
configureIslandCssServer(server, islandCssFiles, viteRoot, rebuildIslandCssMap$1);
|
|
181
174
|
watchPagesForRescan(server, pagesDir, root, (scan) => {
|
|
182
175
|
pageScan = scan;
|
|
183
|
-
rebuildIslandCssMap$1();
|
|
184
176
|
});
|
|
185
177
|
},
|
|
186
178
|
async buildStart() {
|
|
@@ -188,17 +180,17 @@ function islandsPlugin(pagesDir) {
|
|
|
188
180
|
pageScan = await scanPages(root);
|
|
189
181
|
const importAttrRe = /import\s+\w+\s+from\s+("[^"]+"|'[^']+')\s+with\s*\{\s*island\s*:\s*("[^"]+"|'[^']+')\s*\}/g;
|
|
190
182
|
const filesToScan = [
|
|
191
|
-
...pageScan.pages.map((
|
|
192
|
-
filePath:
|
|
193
|
-
island:
|
|
183
|
+
...pageScan.pages.map((page) => ({
|
|
184
|
+
filePath: page.componentPath,
|
|
185
|
+
island: page.island
|
|
194
186
|
})),
|
|
195
|
-
...pageScan.layouts.map((
|
|
196
|
-
filePath:
|
|
197
|
-
island:
|
|
187
|
+
...pageScan.layouts.map((layout) => ({
|
|
188
|
+
filePath: layout.filePath,
|
|
189
|
+
island: layout.island
|
|
198
190
|
})),
|
|
199
|
-
...pageScan.namedLayouts.map((
|
|
200
|
-
filePath:
|
|
201
|
-
island:
|
|
191
|
+
...pageScan.namedLayouts.map((namedLayout) => ({
|
|
192
|
+
filePath: namedLayout.filePath,
|
|
193
|
+
island: namedLayout.island
|
|
202
194
|
}))
|
|
203
195
|
];
|
|
204
196
|
for (const entry of filesToScan) {
|
|
@@ -207,10 +199,10 @@ function islandsPlugin(pagesDir) {
|
|
|
207
199
|
const code = readFileSync(filePath, "utf-8");
|
|
208
200
|
const importerDir = dirname(filePath);
|
|
209
201
|
importAttrRe.lastIndex = 0;
|
|
210
|
-
let
|
|
211
|
-
while ((
|
|
212
|
-
const spec =
|
|
213
|
-
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);
|
|
214
206
|
const absPath = resolveSpecifier(spec, importerDir, COMPONENT_EXTENSIONS);
|
|
215
207
|
if (absPath) {
|
|
216
208
|
const islandId = normalizePath(relative(root, absPath)).replace(/\.[^.]+$/, "");
|
|
@@ -228,7 +220,6 @@ function islandsPlugin(pagesDir) {
|
|
|
228
220
|
const layoutChain = resolveEffectiveLayoutChain(page, pageScan.layouts, pageScan.namedLayouts);
|
|
229
221
|
for (const layout of layoutChain) islandCssFiles.add(normalizePath(resolve(pagesDir, layout.filePath)));
|
|
230
222
|
}
|
|
231
|
-
rebuildIslandCssMap$1();
|
|
232
223
|
}
|
|
233
224
|
},
|
|
234
225
|
resolveId: {
|
|
@@ -251,10 +242,10 @@ function islandsPlugin(pagesDir) {
|
|
|
251
242
|
handler(id) {
|
|
252
243
|
if (id === "\0" + ISLANDS_RENDERER_ID) {
|
|
253
244
|
if (!pageScan) return "export function renderIslandPage() { throw new Error('No pages found'); }";
|
|
254
|
-
const mdPlugin = resolvedConfig?.plugins?.find((
|
|
245
|
+
const mdPlugin = resolvedConfig?.plugins?.find((plugin) => plugin.name === "void-md");
|
|
255
246
|
const mdScriptIds = new Set(mdPlugin?.api?.getClientScripts?.()?.keys() ?? []);
|
|
256
247
|
const needsJS = computePagesNeedingClientJS$1();
|
|
257
|
-
return generateIslandRenderer(pageScan, pagesDir,
|
|
248
|
+
return generateIslandRenderer(pageScan, pagesDir, mdScriptIds, needsJS);
|
|
258
249
|
}
|
|
259
250
|
if (id === "\0" + ISLANDS_CLIENT_ENTRY_ID) {
|
|
260
251
|
if (!pageScan) return "";
|
|
@@ -329,13 +320,7 @@ export default function _IslandWrap(props) {
|
|
|
329
320
|
}
|
|
330
321
|
`;
|
|
331
322
|
}
|
|
332
|
-
function generateIslandRenderer(scan, pagesDir,
|
|
333
|
-
let cssMapCode = "";
|
|
334
|
-
if (isDev && islandCssMap.size > 0) {
|
|
335
|
-
const cssMapObj = {};
|
|
336
|
-
for (const [compId, paths] of islandCssMap) cssMapObj[compId] = paths.map((p) => "/" + normalizePath(relative(viteRoot, p)) + ".css");
|
|
337
|
-
cssMapCode = `const __cssPaths = ${JSON.stringify(cssMapObj)};`;
|
|
338
|
-
}
|
|
323
|
+
function generateIslandRenderer(scan, pagesDir, mdScriptIds, pagesNeedingClientJS) {
|
|
339
324
|
const mdScriptIdsCode = `const __mdClientScriptIds = new Set(${JSON.stringify([...mdScriptIds])});`;
|
|
340
325
|
const needsJSCode = `const __pagesNeedingClientJS = new Set(${JSON.stringify([...pagesNeedingClientJS])});`;
|
|
341
326
|
return `
|
|
@@ -345,7 +330,6 @@ import { SharedContext, ErrorsContext, ParamsContext } from "@void/solid";
|
|
|
345
330
|
import { renderHeadToString, renderHtmlAttrs, renderBodyAttrs } from "void/pages-head";
|
|
346
331
|
|
|
347
332
|
${generateComponentManifest(scan, pagesDir)}
|
|
348
|
-
${cssMapCode}
|
|
349
333
|
${mdScriptIdsCode}
|
|
350
334
|
${needsJSCode}
|
|
351
335
|
|
|
@@ -396,7 +380,7 @@ export async function renderIslandPage(pageObj, assetTags) {
|
|
|
396
380
|
|
|
397
381
|
return \`<!doctype html>
|
|
398
382
|
<html\${htmlAttrs}>
|
|
399
|
-
<head>\${headHtml}\${
|
|
383
|
+
<head>\${headHtml}\${assetTags.css}\${__pagesNeedingClientJS.has(pageObj.component) ? assetTags.preloads : ""}\${__pagesNeedingClientJS.has(pageObj.component) ? generateHydrationScript() : ""}</head>
|
|
400
384
|
<body\${bodyAttrs}>
|
|
401
385
|
<div id="app"\${__mdScriptAttr}>\${html}</div>
|
|
402
386
|
\${__pagesNeedingClientJS.has(pageObj.component) ? assetTags.body : ""}
|
|
@@ -693,17 +677,24 @@ start();
|
|
|
693
677
|
}
|
|
694
678
|
//#endregion
|
|
695
679
|
//#region src/plugin.ts
|
|
680
|
+
const SOLID_RUNTIME_PACKAGE = "@void/solid";
|
|
681
|
+
function excludeRuntimeFromOptimizeDeps() {
|
|
682
|
+
return { exclude: [SOLID_RUNTIME_PACKAGE] };
|
|
683
|
+
}
|
|
696
684
|
function configPlugin() {
|
|
697
685
|
return {
|
|
698
686
|
name: "void:solid:config",
|
|
699
687
|
config() {
|
|
700
688
|
return {
|
|
701
|
-
optimizeDeps:
|
|
689
|
+
optimizeDeps: excludeRuntimeFromOptimizeDeps(),
|
|
702
690
|
ssr: {
|
|
703
|
-
noExternal: [
|
|
704
|
-
optimizeDeps:
|
|
691
|
+
noExternal: [SOLID_RUNTIME_PACKAGE],
|
|
692
|
+
optimizeDeps: excludeRuntimeFromOptimizeDeps()
|
|
705
693
|
}
|
|
706
694
|
};
|
|
695
|
+
},
|
|
696
|
+
configEnvironment() {
|
|
697
|
+
return { optimizeDeps: excludeRuntimeFromOptimizeDeps() };
|
|
707
698
|
}
|
|
708
699
|
};
|
|
709
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
|
});
|