@void/vue 0.7.5 → 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.
Files changed (2) hide show
  1. package/dist/plugin.mjs +4 -30
  2. package/package.json +3 -3
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
 
@@ -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 : ""}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@void/vue",
3
- "version": "0.7.5",
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.5"
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.5"
52
+ "void": "0.7.6"
53
53
  },
54
54
  "scripts": {
55
55
  "build": "vp pack",