@void/vue 0.7.4 → 0.7.6

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/README.md CHANGED
@@ -33,6 +33,7 @@ Main runtime APIs live at `@void/vue`:
33
33
 
34
34
  - `Link`
35
35
  - `useRouter()`
36
+ - `useParams()`
36
37
  - `useNavigation()`
37
38
  - `useShared()`
38
39
  - `useForm()`
@@ -9,6 +9,9 @@ declare const Link: Component;
9
9
  //#region src/runtime/use-router.d.ts
10
10
  declare function useRouter(): VoidRouter;
11
11
  //#endregion
12
+ //#region src/runtime/use-params.d.ts
13
+ declare function useParams<T extends Record<string, string> = Record<string, string>>(): T;
14
+ //#endregion
12
15
  //#region src/runtime/use-shared.d.ts
13
16
  declare function useShared<T = CloudContextVariables["shared"]>(): T;
14
17
  //#endregion
@@ -76,4 +79,4 @@ declare function setActionRouter(router: VoidRouter): void;
76
79
  /** Programmatic one-shot page action call with Inertia page update */
77
80
  declare function action<U extends ActionUrl & string>(url: U, ...args: HasParams<U> extends true ? [options: ActionOptions<U>] : [options?: ActionOptions<U>]): Promise<ActionResult>;
78
81
  //#endregion
79
- export { useIslandForm as a, useShared as c, setActionRouter as i, useRouter as l, InferProps as n, useNavigation as o, action as r, useForm as s, Deferred as t, Link as u };
82
+ export { useIslandForm as a, useShared as c, Link as d, setActionRouter as i, useParams as l, InferProps as n, useNavigation as o, action as r, useForm as s, Deferred as t, useRouter as u };
package/dist/index.d.mts CHANGED
@@ -1,2 +1,2 @@
1
- import { a as useIslandForm, c as useShared, i as setActionRouter, l as useRouter, n as InferProps, o as useNavigation, r as action, s as useForm, t as Deferred, u as Link } from "./index-C0fE29Kv.mjs";
2
- export { Deferred, InferProps, Link, action, setActionRouter, useForm, useIslandForm, useNavigation, useRouter, useShared };
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";
2
+ export { Deferred, InferProps, Link, action, setActionRouter, useForm, useIslandForm, useNavigation, useParams, useRouter, useShared };
package/dist/index.mjs CHANGED
@@ -1,2 +1,2 @@
1
- import { a as useForm, c as Link, i as useNavigation, n as setActionRouter, o as useShared, r as useIslandForm, s as useRouter, t as action } from "./runtime-DL_B0L_H.mjs";
2
- export { Link, action, setActionRouter, useForm, useIslandForm, useNavigation, useRouter, useShared };
1
+ import { a as useForm, c as useRouter, i as useNavigation, l as Link, n as setActionRouter, o as useShared, r as useIslandForm, s as useParams, t as action } from "./runtime-DtQg9eTF.mjs";
2
+ export { Link, action, setActionRouter, useForm, useIslandForm, useNavigation, useParams, useRouter, useShared };
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() {
@@ -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: {
@@ -270,7 +251,7 @@ function islandsPlugin(pagesDir) {
270
251
  const mdPlugin = resolvedConfig?.plugins?.find((p) => p.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
 
@@ -373,6 +347,7 @@ export async function renderIslandPage(pageObj, assetTags) {
373
347
  setup() {
374
348
  provide("__void_shared", reactive(pageObj.shared || {}));
375
349
  provide("__void_errors", reactive(pageObj.errors || {}));
350
+ provide("__void_params", reactive(pageObj.params || {}));
376
351
  if (__frontmatter) provide("__void_frontmatter", __frontmatter);
377
352
  // No router provided — islands have no Void Router
378
353
  return () => {
@@ -394,7 +369,7 @@ export async function renderIslandPage(pageObj, assetTags) {
394
369
 
395
370
  return \`<!doctype html>
396
371
  <html\${htmlAttrs}>
397
- <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>
398
373
  <body\${bodyAttrs}>
399
374
  <div id="app"\${__mdScriptAttr}>\${html}</div>
400
375
  \${__pagesNeedingClientJS.has(pageObj.component) ? assetTags.body : ""}
@@ -590,7 +565,8 @@ export async function renderPage(pageObj, assetTags) {
590
565
  setup() {
591
566
  provide("__void_shared", reactive(pageObj.shared || {}));
592
567
  provide("__void_errors", reactive(pageObj.errors || {}));
593
- provide("__void_router", createSsrRouter(pageObj.url || "/"));
568
+ provide("__void_params", reactive(pageObj.params || {}));
569
+ provide("__void_router", createSsrRouter(pageObj.url || "/", pageObj.params || {}));
594
570
  provide("__void_navigation", idleNavigationState());
595
571
  return () => {
596
572
  patchProps(PageComponent, pageObj.props);
@@ -634,6 +610,7 @@ ${generateComponentManifest(scan, pagesDir)}
634
610
 
635
611
  const shared = reactive({});
636
612
  const errors = reactive({});
613
+ const params = reactive({});
637
614
  const currentComponent = shallowRef(null);
638
615
  const currentLayouts = shallowRef([]);
639
616
  const currentProps = shallowRef({});
@@ -646,6 +623,11 @@ function patchProps(comp, props) {
646
623
  comp.__voidPatched = true;
647
624
  }
648
625
 
626
+ function replaceRecord(target, source) {
627
+ for (const key of Object.keys(target)) delete target[key];
628
+ Object.assign(target, source || {});
629
+ }
630
+
649
631
  const { router, initialPageData, initialComponent, initialLayouts, start } =
650
632
  await createVoidRouter({
651
633
  adapter: {
@@ -655,8 +637,8 @@ const { router, initialPageData, initialComponent, initialLayouts, start } =
655
637
  isLoading: (ref) => ref.loading,
656
638
  applyUpdate(pageData, comp, layouts) {
657
639
  Object.assign(shared, pageData.shared || {});
658
- for (const key of Object.keys(errors)) delete errors[key];
659
- Object.assign(errors, pageData.errors || {});
640
+ replaceRecord(errors, pageData.errors || {});
641
+ replaceRecord(params, pageData.params || {});
660
642
  currentProps.value = pageData.props;
661
643
  currentLayouts.value = layouts;
662
644
  currentComponent.value = comp;
@@ -679,12 +661,13 @@ const { router, initialPageData, initialComponent, initialLayouts, start } =
679
661
  },
680
662
  });
681
663
 
682
- const reactiveRouter = createRouterFacade(router, () => routeUrl.value);
664
+ const reactiveRouter = createRouterFacade(router, () => routeUrl.value, () => params);
683
665
 
684
666
  setActionRouter(reactiveRouter);
685
667
 
686
668
  Object.assign(shared, initialPageData.shared || {});
687
- Object.assign(errors, initialPageData.errors || {});
669
+ replaceRecord(errors, initialPageData.errors || {});
670
+ replaceRecord(params, initialPageData.params || {});
688
671
  currentProps.value = initialPageData.props;
689
672
  currentComponent.value = initialComponent;
690
673
  currentLayouts.value = initialLayouts;
@@ -693,6 +676,7 @@ const app = createSSRApp({
693
676
  setup() {
694
677
  provide("__void_shared", shared);
695
678
  provide("__void_errors", errors);
679
+ provide("__void_params", params);
696
680
  provide("__void_router", reactiveRouter);
697
681
  provide("__void_navigation", navigation);
698
682
 
@@ -1,2 +1,2 @@
1
- import { a as useIslandForm, c as useShared, i as setActionRouter, l as useRouter, n as InferProps, o as useNavigation, r as action, s as useForm, t as Deferred, u as Link } from "../index-C0fE29Kv.mjs";
2
- export { Deferred, InferProps, Link, action, setActionRouter, useForm, useIslandForm, useNavigation, useRouter, useShared };
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";
2
+ export { Deferred, InferProps, Link, action, setActionRouter, useForm, useIslandForm, useNavigation, useParams, useRouter, useShared };
@@ -1,2 +1,2 @@
1
- import { a as useForm, c as Link, i as useNavigation, n as setActionRouter, o as useShared, r as useIslandForm, s as useRouter, t as action } from "../runtime-DL_B0L_H.mjs";
2
- export { Link, action, setActionRouter, useForm, useIslandForm, useNavigation, useRouter, useShared };
1
+ import { a as useForm, c as useRouter, i as useNavigation, l as Link, n as setActionRouter, o as useShared, r as useIslandForm, s as useParams, t as action } from "../runtime-DtQg9eTF.mjs";
2
+ export { Link, action, setActionRouter, useForm, useIslandForm, useNavigation, useParams, useRouter, useShared };
@@ -222,6 +222,13 @@ function useRouter() {
222
222
  return inject("__void_router", null) ?? ssrProxy;
223
223
  }
224
224
  //#endregion
225
+ //#region src/runtime/use-params.ts
226
+ function useParams() {
227
+ const params = inject("__void_params");
228
+ if (!params) throw new Error("useParams(): must be used inside a Void page.");
229
+ return params;
230
+ }
231
+ //#endregion
225
232
  //#region src/runtime/use-shared.ts
226
233
  function useShared() {
227
234
  const shared = inject("__void_shared");
@@ -459,4 +466,4 @@ async function action(url, ...args) {
459
466
  });
460
467
  }
461
468
  //#endregion
462
- export { useForm as a, Link as c, useNavigation as i, setActionRouter as n, useShared as o, useIslandForm as r, useRouter as s, action as t };
469
+ export { useForm as a, useRouter as c, useNavigation as i, Link as l, setActionRouter as n, useShared as o, useIslandForm as r, useParams as s, action as t };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@void/vue",
3
- "version": "0.7.4",
3
+ "version": "0.7.6",
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.4"
47
+ "void": "0.7.6"
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.4"
52
+ "void": "0.7.6"
53
53
  },
54
54
  "scripts": {
55
55
  "build": "vp pack",