@void/react 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 -20
  2. package/package.json +3 -3
package/dist/plugin.mjs CHANGED
@@ -2,7 +2,7 @@ import react from "@vitejs/plugin-react";
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, extractCssImports, fileHasCssImports, needsIslandClientBundle, rebuildIslandCssMap, resolveSpecifier, rewriteCssImportForVirtualModule, watchPagesForRescan } from "void/pages-islands-plugin";
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 = "") {
@@ -148,13 +148,7 @@ function islandsPlugin(pagesDir) {
148
148
  const islandManifest = /* @__PURE__ */ new Map();
149
149
  const islandCssFiles = /* @__PURE__ */ new Set();
150
150
  let viteRoot = "";
151
- const islandCssMap = /* @__PURE__ */ new Map();
152
151
  let resolvedConfig = null;
153
- /** Rebuild islandCssMap from current file contents (re-runs fileHasCssImports). */
154
- function rebuildCssMapLocal() {
155
- if (!pageScan) return;
156
- rebuildIslandCssMap(pageScan, pagesDir, islandCssMap, fileHasCssImports);
157
- }
158
152
  function computePagesNeedingClientJSLocal() {
159
153
  if (!pageScan) return /* @__PURE__ */ new Set();
160
154
  return computePagesNeedingClientJS(pageScan, pagesDir, resolvedConfig);
@@ -167,10 +161,8 @@ function islandsPlugin(pagesDir) {
167
161
  isDev = config.command === "serve";
168
162
  },
169
163
  configureServer(server) {
170
- configureIslandCssServer(server, islandCssFiles, viteRoot, rebuildCssMapLocal);
171
164
  watchPagesForRescan(server, pagesDir, root, (scan) => {
172
165
  pageScan = scan;
173
- rebuildCssMapLocal();
174
166
  });
175
167
  },
176
168
  async buildStart() {
@@ -218,7 +210,6 @@ function islandsPlugin(pagesDir) {
218
210
  const layoutChain = resolveEffectiveLayoutChain(page, pageScan.layouts, pageScan.namedLayouts);
219
211
  for (const layout of layoutChain) islandCssFiles.add(normalizePath(resolve(pagesDir, layout.filePath)));
220
212
  }
221
- rebuildCssMapLocal();
222
213
  }
223
214
  },
224
215
  resolveId: {
@@ -243,7 +234,7 @@ function islandsPlugin(pagesDir) {
243
234
  const mdPlugin = resolvedConfig?.plugins?.find((p) => p.name === "void-md");
244
235
  const mdScriptIds = new Set(mdPlugin?.api?.getClientScripts?.()?.keys() ?? []);
245
236
  const needsJS = computePagesNeedingClientJSLocal();
246
- return generateIslandRenderer(pageScan, pagesDir, isDev, islandCssMap, viteRoot, mdScriptIds, needsJS);
237
+ return generateIslandRenderer(pageScan, pagesDir, isDev, mdScriptIds, needsJS);
247
238
  }
248
239
  if (id === "\0" + ISLANDS_CLIENT_ENTRY_ID) {
249
240
  if (!pageScan) return "";
@@ -304,7 +295,7 @@ function islandsPlugin(pagesDir) {
304
295
  }
305
296
  }];
306
297
  }
307
- function generateIslandRenderer(scan, pagesDir, isDev, islandCssMap, viteRoot, mdScriptIds, pagesNeedingClientJS) {
298
+ function generateIslandRenderer(scan, pagesDir, isDev, mdScriptIds, pagesNeedingClientJS) {
308
299
  const preambleScript = isDev ? `
309
300
  <script type="module">
310
301
  import RefreshRuntime from "/@react-refresh"
@@ -313,12 +304,6 @@ function generateIslandRenderer(scan, pagesDir, isDev, islandCssMap, viteRoot, m
313
304
  window.$RefreshSig$ = () => (type) => type
314
305
  window.__vite_plugin_react_preamble_installed__ = true
315
306
  <\/script>` : "";
316
- let cssMapCode = "";
317
- if (isDev && islandCssMap.size > 0) {
318
- const cssMapObj = {};
319
- for (const [compId, paths] of islandCssMap) cssMapObj[compId] = paths.map((p) => "/" + normalizePath(relative(viteRoot, p)) + ".css");
320
- cssMapCode = `const __cssPaths = ${JSON.stringify(cssMapObj)};`;
321
- }
322
307
  const mdScriptIdsCode = `const __mdClientScriptIds = new Set(${JSON.stringify([...mdScriptIds])});`;
323
308
  const needsJSCode = `const __pagesNeedingClientJS = new Set(${JSON.stringify([...pagesNeedingClientJS])});`;
324
309
  return `
@@ -328,7 +313,6 @@ import { SharedContext, ErrorsContext, ParamsContext } from "@void/react";
328
313
  import { renderHeadToString, renderHtmlAttrs, renderBodyAttrs } from "void/pages-head";
329
314
 
330
315
  ${generateComponentManifest(scan, pagesDir)}
331
- ${cssMapCode}
332
316
  ${mdScriptIdsCode}
333
317
  ${needsJSCode}
334
318
 
@@ -373,7 +357,7 @@ export async function renderIslandPage(pageObj, assetTags) {
373
357
 
374
358
  return \`<!doctype html>
375
359
  <html\${htmlAttrs}>
376
- <head>\${headHtml}\${typeof __cssPaths !== "undefined" ? (__cssPaths[pageObj.component] || []).map(url => '<link rel="stylesheet" href="' + url + '">').join("\\n") : ""}\${PREAMBLE_SCRIPT}\${assetTags.css}\${__pagesNeedingClientJS.has(pageObj.component) ? assetTags.preloads : ""}</head>
360
+ <head>\${headHtml}\${PREAMBLE_SCRIPT}\${assetTags.css}\${__pagesNeedingClientJS.has(pageObj.component) ? assetTags.preloads : ""}</head>
377
361
  <body\${bodyAttrs}>
378
362
  <div id="app"\${__mdScriptAttr}>\${html}</div>
379
363
  \${__pagesNeedingClientJS.has(pageObj.component) ? assetTags.body : ""}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@void/react",
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",
@@ -51,13 +51,13 @@
51
51
  "react-dom": "^19.2.6",
52
52
  "vite": "npm:@voidzero-dev/vite-plus-core@0.1.20",
53
53
  "vite-plus": "^0.1.20",
54
- "void": "0.7.5"
54
+ "void": "0.7.6"
55
55
  },
56
56
  "peerDependencies": {
57
57
  "react": "^19.0.0",
58
58
  "react-dom": "^19.0.0",
59
59
  "vite": "npm:@voidzero-dev/vite-plus-core@0.1.20",
60
- "void": "0.7.5"
60
+ "void": "0.7.6"
61
61
  },
62
62
  "scripts": {
63
63
  "build": "vp pack",