@void/svelte 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.
package/dist/plugin.d.mts CHANGED
@@ -2,15 +2,15 @@ import { svelte } from "@sveltejs/vite-plugin-svelte";
2
2
  import { Plugin } from "vite";
3
3
 
4
4
  //#region src/plugin.d.ts
5
- interface PrefetchConfig {
5
+ type PrefetchConfig = {
6
6
  hoverDelay?: number;
7
7
  cacheFor?: number | string | [string, string];
8
- }
9
- interface VoidSvelteOptions {
8
+ };
9
+ type VoidSvelteOptions = Readonly<{
10
10
  svelte?: Parameters<typeof svelte>[0];
11
11
  viewTransitions?: boolean;
12
12
  prefetch?: PrefetchConfig;
13
- }
14
- declare function voidSvelte(options?: VoidSvelteOptions): Array<Plugin>;
13
+ }>;
14
+ declare function voidSvelte(options?: VoidSvelteOptions): ReadonlyArray<Plugin>;
15
15
  //#endregion
16
16
  export { VoidSvelteOptions, voidSvelte };
package/dist/plugin.mjs CHANGED
@@ -2,7 +2,7 @@ import { svelte } from "@sveltejs/vite-plugin-svelte";
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 = "") {
@@ -153,13 +153,7 @@ function islandsPlugin(pagesDir) {
153
153
  const islandCssFiles = /* @__PURE__ */ new Set();
154
154
  let isDev = false;
155
155
  let viteRoot = "";
156
- const islandCssMap = /* @__PURE__ */ new Map();
157
156
  let resolvedConfig = null;
158
- /** Rebuild islandCssMap from current file contents (re-runs fileHasCssImports). */
159
- function rebuildIslandCssMap$1() {
160
- if (!pageScan) return;
161
- rebuildIslandCssMap(pageScan, pagesDir, islandCssMap, fileHasCssImports);
162
- }
163
157
  function computePagesNeedingClientJS$1() {
164
158
  if (!pageScan) return /* @__PURE__ */ new Set();
165
159
  return computePagesNeedingClientJS(pageScan, pagesDir, resolvedConfig);
@@ -173,10 +167,8 @@ function islandsPlugin(pagesDir) {
173
167
  isDev = config.command === "serve";
174
168
  },
175
169
  configureServer(server) {
176
- configureIslandCssServer(server, islandCssFiles, viteRoot, rebuildIslandCssMap$1);
177
170
  watchPagesForRescan(server, pagesDir, root, (scan) => {
178
171
  pageScan = scan;
179
- rebuildIslandCssMap$1();
180
172
  });
181
173
  },
182
174
  async buildStart() {
@@ -184,17 +176,17 @@ function islandsPlugin(pagesDir) {
184
176
  pageScan = await scanPages(root);
185
177
  const importAttrRe = /import\s+\w+\s+from\s+("[^"]+"|'[^']+')\s+with\s*\{\s*island\s*:\s*("[^"]+"|'[^']+')\s*\}/g;
186
178
  const filesToScan = [
187
- ...pageScan.pages.map((p) => ({
188
- filePath: p.componentPath,
189
- island: p.island
179
+ ...pageScan.pages.map((page) => ({
180
+ filePath: page.componentPath,
181
+ island: page.island
190
182
  })),
191
- ...pageScan.layouts.map((l) => ({
192
- filePath: l.filePath,
193
- island: l.island
183
+ ...pageScan.layouts.map((layout) => ({
184
+ filePath: layout.filePath,
185
+ island: layout.island
194
186
  })),
195
- ...pageScan.namedLayouts.map((nl) => ({
196
- filePath: nl.filePath,
197
- island: nl.island
187
+ ...pageScan.namedLayouts.map((namedLayout) => ({
188
+ filePath: namedLayout.filePath,
189
+ island: namedLayout.island
198
190
  }))
199
191
  ];
200
192
  for (const entry of filesToScan) {
@@ -203,10 +195,10 @@ function islandsPlugin(pagesDir) {
203
195
  const code = readFileSync(filePath, "utf-8");
204
196
  const importerDir = dirname(filePath);
205
197
  importAttrRe.lastIndex = 0;
206
- let m;
207
- while ((m = importAttrRe.exec(code)) !== null) {
208
- const spec = m[1].slice(1, -1);
209
- const strategy = m[2].slice(1, -1);
198
+ let importMatch;
199
+ while ((importMatch = importAttrRe.exec(code)) !== null) {
200
+ const spec = importMatch[1].slice(1, -1);
201
+ const strategy = importMatch[2].slice(1, -1);
210
202
  const absPath = resolveSpecifier(spec, importerDir, COMPONENT_EXTENSIONS);
211
203
  if (absPath) {
212
204
  const islandId = normalizePath(relative(root, absPath)).replace(/\.[^.]+$/, "");
@@ -224,7 +216,6 @@ function islandsPlugin(pagesDir) {
224
216
  const layoutChain = resolveEffectiveLayoutChain(page, pageScan.layouts, pageScan.namedLayouts);
225
217
  for (const layout of layoutChain) islandCssFiles.add(normalizePath(resolve(pagesDir, layout.filePath)));
226
218
  }
227
- rebuildIslandCssMap$1();
228
219
  }
229
220
  },
230
221
  resolveId: {
@@ -247,10 +238,10 @@ function islandsPlugin(pagesDir) {
247
238
  handler(id) {
248
239
  if (id === "\0" + ISLANDS_RENDERER_ID) {
249
240
  if (!pageScan) return "export function renderIslandPage() { throw new Error('No pages found'); }";
250
- const mdPlugin = resolvedConfig?.plugins?.find((p) => p.name === "void-md");
241
+ const mdPlugin = resolvedConfig?.plugins?.find((plugin) => plugin.name === "void-md");
251
242
  const mdScriptIds = new Set(mdPlugin?.api?.getClientScripts?.()?.keys() ?? []);
252
243
  const needsJS = computePagesNeedingClientJS$1();
253
- return generateIslandRenderer(pageScan, pagesDir, isDev, islandCssMap, viteRoot, mdScriptIds, needsJS);
244
+ return generateIslandRenderer(pageScan, pagesDir, mdScriptIds, needsJS);
254
245
  }
255
246
  if (id === "\0" + ISLANDS_CLIENT_ENTRY_ID) {
256
247
  if (!pageScan) return "";
@@ -350,13 +341,7 @@ function generateWrapperComponent(id) {
350
341
  </div>
351
342
  `;
352
343
  }
353
- function generateIslandRenderer(scan, pagesDir, isDev, islandCssMap, viteRoot, mdScriptIds, pagesNeedingClientJS) {
354
- let cssMapCode = "";
355
- if (isDev && islandCssMap.size > 0) {
356
- const cssMapObj = {};
357
- for (const [compId, paths] of islandCssMap) cssMapObj[compId] = paths.map((p) => "/" + normalizePath(relative(viteRoot, p)) + ".css");
358
- cssMapCode = `const __cssPaths = ${JSON.stringify(cssMapObj)};`;
359
- }
344
+ function generateIslandRenderer(scan, pagesDir, mdScriptIds, pagesNeedingClientJS) {
360
345
  const mdScriptIdsCode = `const __mdClientScriptIds = new Set(${JSON.stringify([...mdScriptIds])});`;
361
346
  const needsJSCode = `const __pagesNeedingClientJS = new Set(${JSON.stringify([...pagesNeedingClientJS])});`;
362
347
  return `
@@ -365,7 +350,6 @@ import App from "@void/svelte/App.svelte";
365
350
  import { renderHeadToString, renderHtmlAttrs, renderBodyAttrs } from "void/pages-head";
366
351
 
367
352
  ${generateComponentManifest(scan, pagesDir)}
368
- ${cssMapCode}
369
353
  ${mdScriptIdsCode}
370
354
  ${needsJSCode}
371
355
 
@@ -400,7 +384,7 @@ export async function renderIslandPage(pageObj, assetTags) {
400
384
 
401
385
  return \`<!doctype html>
402
386
  <html\${htmlAttrs}>
403
- <head>\${headHtml}\${typeof __cssPaths !== "undefined" ? (__cssPaths[pageObj.component] || []).map(url => '<link rel="stylesheet" href="' + url + '">').join("\\n") : ""}\${head}\${assetTags.css}\${__pagesNeedingClientJS.has(pageObj.component) ? assetTags.preloads : ""}</head>
387
+ <head>\${headHtml}\${head}\${assetTags.css}\${__pagesNeedingClientJS.has(pageObj.component) ? assetTags.preloads : ""}</head>
404
388
  <body\${bodyAttrs}>
405
389
  <div id="app"\${__mdScriptAttr}>\${html}</div>
406
390
  \${__pagesNeedingClientJS.has(pageObj.component) ? assetTags.body : ""}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@void/svelte",
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
  "svelte": "^5.55.5",
45
45
  "vite": "npm:@voidzero-dev/vite-plus-core@0.1.20",
46
46
  "vite-plus": "^0.1.20",
47
- "void": "0.7.5"
47
+ "void": "0.7.7"
48
48
  },
49
49
  "peerDependencies": {
50
50
  "svelte": "^5.0.0",
51
51
  "vite": "npm:@voidzero-dev/vite-plus-core@0.1.20",
52
- "void": "0.7.5"
52
+ "void": "0.7.7"
53
53
  },
54
54
  "scripts": {
55
55
  "build": "vp pack",
@@ -24,8 +24,8 @@ type UntypedForm = {
24
24
  put(opts?: FormSubmitOptions): Promise<void>;
25
25
  patch(opts?: FormSubmitOptions): Promise<void>;
26
26
  delete(opts?: FormSubmitOptions): Promise<void>;
27
- reset(...fields: Array<string>): void;
28
- clearErrors(...fields: Array<string>): void;
27
+ reset(...fields: ReadonlyArray<string>): void;
28
+ clearErrors(...fields: ReadonlyArray<string>): void;
29
29
  clearError(): void;
30
30
  };
31
31
 
@@ -61,8 +61,8 @@ export function useForm<U extends ActionUrl & string>(
61
61
  put(opts?: FormSubmitOptions): Promise<void>;
62
62
  patch(opts?: FormSubmitOptions): Promise<void>;
63
63
  delete(opts?: FormSubmitOptions): Promise<void>;
64
- reset(...fields: Array<keyof ResolveActionBody<U> & string>): void;
65
- clearErrors(...fields: Array<keyof ResolveActionBody<U> & string>): void;
64
+ reset(...fields: ReadonlyArray<keyof ResolveActionBody<U> & string>): void;
65
+ clearErrors(...fields: ReadonlyArray<keyof ResolveActionBody<U> & string>): void;
66
66
  clearError(): void;
67
67
  };
68
68
 
@@ -105,7 +105,7 @@ export function useForm(
105
105
  Object.keys(defaults_).some((key) => !isEqualFormValue(data[key], defaults_[key])),
106
106
  );
107
107
 
108
- function reset(...fields: Array<string>) {
108
+ function reset(...fields: ReadonlyArray<string>) {
109
109
  if (fields.length === 0) {
110
110
  data = { ...defaults_ };
111
111
  } else {
@@ -115,7 +115,7 @@ export function useForm(
115
115
  }
116
116
  }
117
117
 
118
- function clearErrors(...fields: Array<string>) {
118
+ function clearErrors(...fields: ReadonlyArray<string>) {
119
119
  if (fields.length === 0) {
120
120
  errors = {};
121
121
  } else {
@@ -13,8 +13,8 @@ type UntypedIslandForm = {
13
13
  put(url: string): Promise<void>;
14
14
  patch(url: string): Promise<void>;
15
15
  delete(url: string): Promise<void>;
16
- reset(...fields: Array<string>): void;
17
- clearErrors(...fields: Array<string>): void;
16
+ reset(...fields: ReadonlyArray<string>): void;
17
+ clearErrors(...fields: ReadonlyArray<string>): void;
18
18
  clearError(): void;
19
19
  };
20
20
 
@@ -64,7 +64,7 @@ export function useIslandForm(defaults: Record<string, unknown>): UntypedIslandF
64
64
  Object.keys(defaults_).some((key) => !isEqualFormValue(data[key], defaults_[key])),
65
65
  );
66
66
 
67
- function reset(...fields: Array<string>) {
67
+ function reset(...fields: ReadonlyArray<string>) {
68
68
  if (fields.length === 0) {
69
69
  data = { ...defaults_ };
70
70
  } else {
@@ -74,7 +74,7 @@ export function useIslandForm(defaults: Record<string, unknown>): UntypedIslandF
74
74
  }
75
75
  }
76
76
 
77
- function clearErrors(...fields: Array<string>) {
77
+ function clearErrors(...fields: ReadonlyArray<string>) {
78
78
  if (fields.length === 0) {
79
79
  errors = {};
80
80
  } else {