@void/vue 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.
@@ -31,8 +31,8 @@ declare function useForm<U extends ActionUrl & string>(url: U, defaults: Resolve
31
31
  put(opts?: FormSubmitOptions): Promise<void>;
32
32
  patch(opts?: FormSubmitOptions): Promise<void>;
33
33
  delete(opts?: FormSubmitOptions): Promise<void>;
34
- reset(...fields: Array<keyof ResolveActionBody<U> & string>): void;
35
- clearErrors(...fields: Array<keyof ResolveActionBody<U> & string>): void;
34
+ reset(...fields: ReadonlyArray<keyof ResolveActionBody<U> & string>): void;
35
+ clearErrors(...fields: ReadonlyArray<keyof ResolveActionBody<U> & string>): void;
36
36
  clearError(): void;
37
37
  };
38
38
  //#endregion
@@ -40,7 +40,7 @@ declare function useForm<U extends ActionUrl & string>(url: U, defaults: Resolve
40
40
  declare function useNavigation(): NavigationState;
41
41
  //#endregion
42
42
  //#region src/runtime/use-island-form.d.ts
43
- interface IslandFormReturn<T extends Record<string, unknown>> {
43
+ type IslandFormReturn<T extends Record<string, unknown>> = Readonly<{
44
44
  data: T;
45
45
  errors: Record<string, string>;
46
46
  error: VoidActionError | null;
@@ -53,10 +53,10 @@ interface IslandFormReturn<T extends Record<string, unknown>> {
53
53
  put(url: string): Promise<void>;
54
54
  patch(url: string): Promise<void>;
55
55
  delete(url: string): Promise<void>;
56
- reset(...fields: Array<keyof T & string>): void;
57
- clearErrors(...fields: Array<string>): void;
56
+ reset(...fields: ReadonlyArray<keyof T & string>): void;
57
+ clearErrors(...fields: ReadonlyArray<string>): void;
58
58
  clearError(): void;
59
- }
59
+ }>;
60
60
  /**
61
61
  * Form composable for island pages. Uses fetch + page reload instead of the
62
62
  * Void Router (which is not available in island mode).
package/dist/index.d.mts CHANGED
@@ -1,2 +1,2 @@
1
- import { a as useIslandForm, c as useShared, d as Link, i as setActionRouter, l as useParams, n as InferProps, o as useNavigation, r as action, s as useForm, t as Deferred, u as useRouter } from "./index-DjrFKwuZ.mjs";
1
+ import { a as useIslandForm, c as useShared, d as Link, i as setActionRouter, l as useParams, n as InferProps, o as useNavigation, r as action, s as useForm, t as Deferred, u as useRouter } from "./index-B-rddAws.mjs";
2
2
  export { Deferred, InferProps, Link, action, setActionRouter, useForm, useIslandForm, useNavigation, useParams, useRouter, useShared };
package/dist/plugin.d.mts CHANGED
@@ -2,10 +2,10 @@ import vue from "@vitejs/plugin-vue";
2
2
  import { Plugin } from "vite";
3
3
 
4
4
  //#region src/plugin.d.ts
5
- interface VoidVueOptions {
5
+ type VoidVueOptions = Readonly<{
6
6
  vue?: Parameters<typeof vue>[0];
7
7
  viewTransitions?: boolean;
8
- }
9
- declare function voidVue(options?: VoidVueOptions): Array<Plugin>;
8
+ }>;
9
+ declare function voidVue(options?: VoidVueOptions): ReadonlyArray<Plugin>;
10
10
  //#endregion
11
11
  export { VoidVueOptions, voidVue };
package/dist/plugin.mjs CHANGED
@@ -2,7 +2,7 @@ import vue from "@vitejs/plugin-vue";
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, configureIslandCssServer, needsIslandClientBundle, rebuildIslandCssMap, resolveSpecifier, rewriteCssImportForVirtualModule, watchPagesForRescan } from "void/pages-islands-plugin";
5
+ import { ISLANDS_CLIENT_ENTRY_ID, ISLANDS_RENDERER_ID, computePagesNeedingClientJS, 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 = "") {
@@ -142,16 +142,6 @@ const COMPONENT_EXTENSIONS = [
142
142
  ".ts",
143
143
  ".js"
144
144
  ];
145
- function fileHasCss(filePath) {
146
- try {
147
- const code = readFileSync(filePath, "utf-8");
148
- if (/import\b[^"']*["'][^"']+\.(?:css|scss|sass|less|styl|stylus|pcss|postcss)["']/.test(code)) return true;
149
- if (/<style\b(?![^>]*\bscoped\b)[^>]*>/.test(code)) return true;
150
- return false;
151
- } catch {
152
- return false;
153
- }
154
- }
155
145
  function extractCss(filePath) {
156
146
  const code = readFileSync(filePath, "utf-8");
157
147
  const parts = [];
@@ -174,13 +164,7 @@ function islandsPlugin(pagesDir) {
174
164
  const islandCssFiles = /* @__PURE__ */ new Set();
175
165
  let isDev = false;
176
166
  let viteRoot = "";
177
- const islandCssMap = /* @__PURE__ */ new Map();
178
167
  let resolvedConfig = null;
179
- /** Rebuild islandCssMap from current file contents (re-runs fileHasCss). */
180
- function rebuildIslandCssMap$1() {
181
- if (!pageScan) return;
182
- rebuildIslandCssMap(pageScan, pagesDir, islandCssMap, fileHasCss);
183
- }
184
168
  function computePagesNeedingClientJS$1() {
185
169
  if (!pageScan) return /* @__PURE__ */ new Set();
186
170
  return computePagesNeedingClientJS(pageScan, pagesDir, resolvedConfig);
@@ -194,10 +178,8 @@ function islandsPlugin(pagesDir) {
194
178
  isDev = config.command === "serve";
195
179
  },
196
180
  configureServer(server) {
197
- configureIslandCssServer(server, islandCssFiles, viteRoot, rebuildIslandCssMap$1);
198
181
  watchPagesForRescan(server, pagesDir, root, (scan) => {
199
182
  pageScan = scan;
200
- rebuildIslandCssMap$1();
201
183
  });
202
184
  },
203
185
  async buildStart() {
@@ -205,17 +187,17 @@ function islandsPlugin(pagesDir) {
205
187
  pageScan = await scanPages(root);
206
188
  const importAttrRe = /import\s+\w+\s+from\s+("[^"]+"|'[^']+')\s+with\s*\{\s*island\s*:\s*("[^"]+"|'[^']+')\s*\}/g;
207
189
  const filesToScan = [
208
- ...pageScan.pages.map((p) => ({
209
- filePath: p.componentPath,
210
- island: p.island
190
+ ...pageScan.pages.map((page) => ({
191
+ filePath: page.componentPath,
192
+ island: page.island
211
193
  })),
212
- ...pageScan.layouts.map((l) => ({
213
- filePath: l.filePath,
214
- island: l.island
194
+ ...pageScan.layouts.map((layout) => ({
195
+ filePath: layout.filePath,
196
+ island: layout.island
215
197
  })),
216
- ...pageScan.namedLayouts.map((nl) => ({
217
- filePath: nl.filePath,
218
- island: nl.island
198
+ ...pageScan.namedLayouts.map((namedLayout) => ({
199
+ filePath: namedLayout.filePath,
200
+ island: namedLayout.island
219
201
  }))
220
202
  ];
221
203
  for (const entry of filesToScan) {
@@ -224,10 +206,10 @@ function islandsPlugin(pagesDir) {
224
206
  const code = readFileSync(filePath, "utf-8");
225
207
  const importerDir = dirname(filePath);
226
208
  importAttrRe.lastIndex = 0;
227
- let m;
228
- while ((m = importAttrRe.exec(code)) !== null) {
229
- const spec = m[1].slice(1, -1);
230
- const strategy = m[2].slice(1, -1);
209
+ let importMatch;
210
+ while ((importMatch = importAttrRe.exec(code)) !== null) {
211
+ const spec = importMatch[1].slice(1, -1);
212
+ const strategy = importMatch[2].slice(1, -1);
231
213
  const absPath = resolveSpecifier(spec, importerDir, COMPONENT_EXTENSIONS);
232
214
  if (absPath) {
233
215
  const islandId = normalizePath(relative(root, absPath)).replace(/\.[^.]+$/, "");
@@ -245,7 +227,6 @@ function islandsPlugin(pagesDir) {
245
227
  const layoutChain = resolveEffectiveLayoutChain(page, pageScan.layouts, pageScan.namedLayouts);
246
228
  for (const layout of layoutChain) islandCssFiles.add(normalizePath(resolve(pagesDir, layout.filePath)));
247
229
  }
248
- rebuildIslandCssMap$1();
249
230
  }
250
231
  },
251
232
  resolveId: {
@@ -267,10 +248,10 @@ function islandsPlugin(pagesDir) {
267
248
  handler(id) {
268
249
  if (id === "\0" + ISLANDS_RENDERER_ID) {
269
250
  if (!pageScan) return "export function renderIslandPage() { throw new Error('No pages found'); }";
270
- const mdPlugin = resolvedConfig?.plugins?.find((p) => p.name === "void-md");
251
+ const mdPlugin = resolvedConfig?.plugins?.find((plugin) => plugin.name === "void-md");
271
252
  const mdScriptIds = new Set(mdPlugin?.api?.getClientScripts?.()?.keys() ?? []);
272
253
  const needsJS = computePagesNeedingClientJS$1();
273
- return generateIslandRenderer(pageScan, pagesDir, isDev, islandCssMap, viteRoot, mdScriptIds, needsJS);
254
+ return generateIslandRenderer(pageScan, pagesDir, mdScriptIds, needsJS);
274
255
  }
275
256
  if (id === "\0" + ISLANDS_CLIENT_ENTRY_ID) {
276
257
  if (!pageScan) return "";
@@ -337,13 +318,7 @@ function islandsPlugin(pagesDir) {
337
318
  }
338
319
  }];
339
320
  }
340
- function generateIslandRenderer(scan, pagesDir, isDev, islandCssMap, viteRoot, mdScriptIds, pagesNeedingClientJS) {
341
- let cssMapCode = "";
342
- if (isDev && islandCssMap.size > 0) {
343
- const cssMapObj = {};
344
- for (const [compId, paths] of islandCssMap) cssMapObj[compId] = paths.map((p) => "/" + normalizePath(relative(viteRoot, p)) + ".css");
345
- cssMapCode = `const __cssPaths = ${JSON.stringify(cssMapObj)};`;
346
- }
321
+ function generateIslandRenderer(scan, pagesDir, mdScriptIds, pagesNeedingClientJS) {
347
322
  const mdScriptIdsCode = `const __mdClientScriptIds = new Set(${JSON.stringify([...mdScriptIds])});`;
348
323
  const needsJSCode = `const __pagesNeedingClientJS = new Set(${JSON.stringify([...pagesNeedingClientJS])});`;
349
324
  return `
@@ -352,7 +327,6 @@ import { renderToString } from "vue/server-renderer";
352
327
  import { renderHeadToString, renderHtmlAttrs, renderBodyAttrs } from "void/pages-head";
353
328
 
354
329
  ${generateComponentManifest(scan, pagesDir)}
355
- ${cssMapCode}
356
330
  ${mdScriptIdsCode}
357
331
  ${needsJSCode}
358
332
 
@@ -395,7 +369,7 @@ export async function renderIslandPage(pageObj, assetTags) {
395
369
 
396
370
  return \`<!doctype html>
397
371
  <html\${htmlAttrs}>
398
- <head>\${headHtml}\${typeof __cssPaths !== "undefined" ? (__cssPaths[pageObj.component] || []).map(url => '<link rel="stylesheet" href="' + url + '">').join("\\n") : ""}\${assetTags.css}\${__pagesNeedingClientJS.has(pageObj.component) ? assetTags.preloads : ""}</head>
372
+ <head>\${headHtml}\${assetTags.css}\${__pagesNeedingClientJS.has(pageObj.component) ? assetTags.preloads : ""}</head>
399
373
  <body\${bodyAttrs}>
400
374
  <div id="app"\${__mdScriptAttr}>\${html}</div>
401
375
  \${__pagesNeedingClientJS.has(pageObj.component) ? assetTags.body : ""}
@@ -1,2 +1,2 @@
1
- import { a as useIslandForm, c as useShared, d as Link, i as setActionRouter, l as useParams, n as InferProps, o as useNavigation, r as action, s as useForm, t as Deferred, u as useRouter } from "../index-DjrFKwuZ.mjs";
1
+ import { a as useIslandForm, c as useShared, d as Link, i as setActionRouter, l as useParams, n as InferProps, o as useNavigation, r as action, s as useForm, t as Deferred, u as useRouter } from "../index-B-rddAws.mjs";
2
2
  export { Deferred, InferProps, Link, action, setActionRouter, useForm, useIslandForm, useNavigation, useParams, useRouter, useShared };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@void/vue",
3
- "version": "0.7.5",
3
+ "version": "0.7.7",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git+https://github.com/voidzero-dev/void.git",
@@ -44,12 +44,12 @@
44
44
  "vite": "npm:@voidzero-dev/vite-plus-core@0.1.20",
45
45
  "vite-plus": "^0.1.20",
46
46
  "vue": "^3.5.34",
47
- "void": "0.7.5"
47
+ "void": "0.7.7"
48
48
  },
49
49
  "peerDependencies": {
50
50
  "vite": "npm:@voidzero-dev/vite-plus-core@0.1.20",
51
51
  "vue": "^3.5.0",
52
- "void": "0.7.5"
52
+ "void": "0.7.7"
53
53
  },
54
54
  "scripts": {
55
55
  "build": "vp pack",