@void/vue 0.7.13 → 0.8.0
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.mjs +50 -44
- package/package.json +3 -3
package/dist/plugin.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import vue from "@vitejs/plugin-vue";
|
|
2
|
+
import { generateComponentManifest, resolveEffectiveLayoutChain, resolvePagesDir, resolveStaticPageDataBuildOptions, scanPages } from "void/pages";
|
|
2
3
|
import { existsSync, readFileSync, readdirSync } from "node:fs";
|
|
3
4
|
import { normalizePath } from "vite";
|
|
4
|
-
import { generateComponentManifest, resolveEffectiveLayoutChain, resolveStaticPageDataBuildOptions, scanPages } from "void/pages";
|
|
5
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]:\//;
|
|
@@ -9,42 +9,9 @@ function normalizeWindowsPath(input = "") {
|
|
|
9
9
|
if (!input) return input;
|
|
10
10
|
return input.replace(/\\/g, "/").replace(_DRIVE_LETTER_START_RE, (r) => r.toUpperCase());
|
|
11
11
|
}
|
|
12
|
-
const _UNC_REGEX = /^[/\\]{2}/;
|
|
13
12
|
const _IS_ABSOLUTE_RE = /^[/\\](?![/\\])|^[/\\]{2}(?!\.)|^[A-Za-z]:[/\\]/;
|
|
14
13
|
const _DRIVE_LETTER_RE = /^[A-Za-z]:$/;
|
|
15
14
|
const _ROOT_FOLDER_RE = /^\/([A-Za-z]:)?$/;
|
|
16
|
-
const normalize = function(path) {
|
|
17
|
-
if (path.length === 0) return ".";
|
|
18
|
-
path = normalizeWindowsPath(path);
|
|
19
|
-
const isUNCPath = path.match(_UNC_REGEX);
|
|
20
|
-
const isPathAbsolute = isAbsolute(path);
|
|
21
|
-
const trailingSeparator = path[path.length - 1] === "/";
|
|
22
|
-
path = normalizeString(path, !isPathAbsolute);
|
|
23
|
-
if (path.length === 0) {
|
|
24
|
-
if (isPathAbsolute) return "/";
|
|
25
|
-
return trailingSeparator ? "./" : ".";
|
|
26
|
-
}
|
|
27
|
-
if (trailingSeparator) path += "/";
|
|
28
|
-
if (_DRIVE_LETTER_RE.test(path)) path += "/";
|
|
29
|
-
if (isUNCPath) {
|
|
30
|
-
if (!isPathAbsolute) return `//./${path}`;
|
|
31
|
-
return `//${path}`;
|
|
32
|
-
}
|
|
33
|
-
return isPathAbsolute && !isAbsolute(path) ? `/${path}` : path;
|
|
34
|
-
};
|
|
35
|
-
const join = function(...segments) {
|
|
36
|
-
let path = "";
|
|
37
|
-
for (const seg of segments) {
|
|
38
|
-
if (!seg) continue;
|
|
39
|
-
if (path.length > 0) {
|
|
40
|
-
const pathTrailing = path[path.length - 1] === "/";
|
|
41
|
-
const segLeading = seg[0] === "/";
|
|
42
|
-
if (pathTrailing && segLeading) path += seg.slice(1);
|
|
43
|
-
else path += pathTrailing || segLeading ? seg : `/${seg}`;
|
|
44
|
-
} else path += seg;
|
|
45
|
-
}
|
|
46
|
-
return normalize(path);
|
|
47
|
-
};
|
|
48
15
|
function cwd() {
|
|
49
16
|
if (typeof process !== "undefined" && typeof process.cwd === "function") return process.cwd().replace(/\\/g, "/");
|
|
50
17
|
return "/";
|
|
@@ -174,9 +141,9 @@ function extractCss(filePath) {
|
|
|
174
141
|
}
|
|
175
142
|
return parts.join("\n");
|
|
176
143
|
}
|
|
177
|
-
function islandsPlugin(pagesDir) {
|
|
144
|
+
function islandsPlugin(pagesDir, options) {
|
|
178
145
|
let pageScan = null;
|
|
179
|
-
const root = dirname(pagesDir);
|
|
146
|
+
const root = options?.root ?? dirname(pagesDir);
|
|
180
147
|
const islandManifest = /* @__PURE__ */ new Map();
|
|
181
148
|
const islandCssFiles = /* @__PURE__ */ new Set();
|
|
182
149
|
let isDev = false;
|
|
@@ -201,7 +168,7 @@ function islandsPlugin(pagesDir) {
|
|
|
201
168
|
},
|
|
202
169
|
async buildStart() {
|
|
203
170
|
if (existsSync(pagesDir)) {
|
|
204
|
-
pageScan = await scanPages(root);
|
|
171
|
+
pageScan = await scanPages(root, { pagesDir });
|
|
205
172
|
const filesToScan = [
|
|
206
173
|
...pageScan.pages.map((page) => ({
|
|
207
174
|
filePath: page.componentPath,
|
|
@@ -483,8 +450,26 @@ function hasNonIslandPages(dir) {
|
|
|
483
450
|
}
|
|
484
451
|
function pagesPlugin(pagesDir, options) {
|
|
485
452
|
let pageScan = null;
|
|
453
|
+
let isDev = false;
|
|
486
454
|
let viteConfig;
|
|
487
|
-
const root = dirname(pagesDir);
|
|
455
|
+
const root = options?.root ?? dirname(pagesDir);
|
|
456
|
+
const normalizedPagesDir = normalizePath(pagesDir);
|
|
457
|
+
let pendingRescan = null;
|
|
458
|
+
const rescanPages = async () => {
|
|
459
|
+
pageScan = existsSync(pagesDir) ? await scanPages(root, { pagesDir }) : null;
|
|
460
|
+
};
|
|
461
|
+
const runRescan = () => {
|
|
462
|
+
pendingRescan ??= rescanPages().finally(() => {
|
|
463
|
+
pendingRescan = null;
|
|
464
|
+
});
|
|
465
|
+
return pendingRescan;
|
|
466
|
+
};
|
|
467
|
+
const invalidatePageModules = (server) => {
|
|
468
|
+
for (const env of Object.values(server.environments)) for (const id of ["\0" + RENDERER_ID, "\0" + CLIENT_ENTRY_ID]) {
|
|
469
|
+
const mod = env.moduleGraph.getModuleById(id);
|
|
470
|
+
if (mod) env.moduleGraph.invalidateModule(mod);
|
|
471
|
+
}
|
|
472
|
+
};
|
|
488
473
|
return [{
|
|
489
474
|
name: "void-vue:pages-transform",
|
|
490
475
|
enforce: "pre",
|
|
@@ -514,7 +499,7 @@ function pagesPlugin(pagesDir, options) {
|
|
|
514
499
|
}, {
|
|
515
500
|
name: "void-vue:pages",
|
|
516
501
|
async buildStart() {
|
|
517
|
-
|
|
502
|
+
await runRescan();
|
|
518
503
|
},
|
|
519
504
|
resolveId: {
|
|
520
505
|
filter: { id: /^virtual:void-pages-(renderer|client)$/ },
|
|
@@ -524,7 +509,9 @@ function pagesPlugin(pagesDir, options) {
|
|
|
524
509
|
},
|
|
525
510
|
load: {
|
|
526
511
|
filter: { id: /^\0virtual:void-pages-(renderer|client)$/ },
|
|
527
|
-
handler(id) {
|
|
512
|
+
async handler(id) {
|
|
513
|
+
if (isDev && pendingRescan) await pendingRescan;
|
|
514
|
+
if (!pageScan && existsSync(pagesDir)) await runRescan();
|
|
528
515
|
if (id === "\0" + RENDERER_ID) {
|
|
529
516
|
if (!pageScan) return "export function renderPage() { throw new Error('No pages found'); }";
|
|
530
517
|
return generateRendererModule(pageScan, pagesDir);
|
|
@@ -535,12 +522,27 @@ function pagesPlugin(pagesDir, options) {
|
|
|
535
522
|
}
|
|
536
523
|
}
|
|
537
524
|
},
|
|
525
|
+
configureServer(server) {
|
|
526
|
+
const handlePagesChange = async (path, event) => {
|
|
527
|
+
const normalizedPath = normalizePath(path);
|
|
528
|
+
if (normalizedPath !== normalizedPagesDir && !normalizedPath.startsWith(normalizedPagesDir + "/")) return;
|
|
529
|
+
if (event === "change" && !normalizedPath.endsWith(".md")) return;
|
|
530
|
+
await runRescan();
|
|
531
|
+
invalidatePageModules(server);
|
|
532
|
+
};
|
|
533
|
+
server.watcher.on("add", (path) => handlePagesChange(path, "add"));
|
|
534
|
+
server.watcher.on("change", (path) => handlePagesChange(path, "change"));
|
|
535
|
+
server.watcher.on("unlink", (path) => handlePagesChange(path, "unlink"));
|
|
536
|
+
},
|
|
538
537
|
configResolved(config) {
|
|
539
538
|
viteConfig = config;
|
|
540
539
|
},
|
|
541
540
|
config(_, env) {
|
|
542
541
|
if (!existsSync(pagesDir)) return;
|
|
543
|
-
if (env.command === "serve")
|
|
542
|
+
if (env.command === "serve") {
|
|
543
|
+
isDev = true;
|
|
544
|
+
return { optimizeDeps: { include: ["vue"] } };
|
|
545
|
+
}
|
|
544
546
|
if (!hasNonIslandPages(pagesDir)) return;
|
|
545
547
|
return { environments: { client: { build: {
|
|
546
548
|
manifest: true,
|
|
@@ -713,11 +715,15 @@ start();
|
|
|
713
715
|
//#endregion
|
|
714
716
|
//#region src/plugin.ts
|
|
715
717
|
function voidVue(options) {
|
|
716
|
-
const
|
|
718
|
+
const root = process.cwd();
|
|
719
|
+
const pagesDir = resolvePagesDir(root);
|
|
717
720
|
return [
|
|
718
721
|
vue(options?.vue),
|
|
719
|
-
...pagesPlugin(pagesDir, {
|
|
720
|
-
|
|
722
|
+
...pagesPlugin(pagesDir, {
|
|
723
|
+
root,
|
|
724
|
+
viewTransitions: options?.viewTransitions
|
|
725
|
+
}),
|
|
726
|
+
...islandsPlugin(pagesDir, { root })
|
|
721
727
|
];
|
|
722
728
|
}
|
|
723
729
|
//#endregion
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@void/vue",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.8.0",
|
|
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.
|
|
47
|
+
"void": "0.8.0"
|
|
48
48
|
},
|
|
49
49
|
"peerDependencies": {
|
|
50
50
|
"vite": "^8.0.0",
|
|
51
51
|
"vue": "^3.5.0",
|
|
52
|
-
"void": "0.
|
|
52
|
+
"void": "0.8.0"
|
|
53
53
|
},
|
|
54
54
|
"scripts": {
|
|
55
55
|
"build": "vp pack",
|