@serwist/vite 9.0.0-preview.12 → 9.0.0-preview.14

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 (68) hide show
  1. package/dist/chunks/schema.js +56 -0
  2. package/dist/index.d.ts +8 -7
  3. package/dist/index.d.ts.map +1 -1
  4. package/dist/index.js +65 -174
  5. package/dist/index.schema.d.ts +3 -0
  6. package/dist/index.schema.d.ts.map +1 -0
  7. package/dist/index.schema.js +3 -0
  8. package/dist/lib/api.d.ts.map +1 -0
  9. package/dist/lib/constants.d.ts.map +1 -0
  10. package/dist/{context.d.ts → lib/context.d.ts} +2 -2
  11. package/dist/lib/context.d.ts.map +1 -0
  12. package/dist/lib/log.d.ts.map +1 -0
  13. package/dist/{modules.d.ts → lib/modules.d.ts} +1 -1
  14. package/dist/lib/modules.d.ts.map +1 -0
  15. package/dist/lib/options.d.ts +4 -0
  16. package/dist/lib/options.d.ts.map +1 -0
  17. package/dist/lib/schema.d.ts +359 -0
  18. package/dist/lib/schema.d.ts.map +1 -0
  19. package/dist/lib/types.d.ts +127 -0
  20. package/dist/lib/types.d.ts.map +1 -0
  21. package/dist/lib/utils.d.ts.map +1 -0
  22. package/dist/lib/validator.d.ts +3 -0
  23. package/dist/lib/validator.d.ts.map +1 -0
  24. package/dist/plugins/build.d.ts +2 -2
  25. package/dist/plugins/build.d.ts.map +1 -1
  26. package/dist/plugins/dev.d.ts +2 -2
  27. package/dist/plugins/dev.d.ts.map +1 -1
  28. package/dist/plugins/main.d.ts +2 -2
  29. package/dist/plugins/main.d.ts.map +1 -1
  30. package/package.json +23 -53
  31. package/src/index.schema.ts +3 -0
  32. package/src/index.ts +8 -7
  33. package/src/{context.ts → lib/context.ts} +2 -2
  34. package/src/{log.ts → lib/log.ts} +1 -1
  35. package/src/{modules.ts → lib/modules.ts} +4 -5
  36. package/src/lib/options.ts +76 -0
  37. package/src/lib/schema.ts +35 -0
  38. package/src/lib/types.ts +163 -0
  39. package/src/lib/validator.ts +10 -0
  40. package/src/plugins/build.ts +2 -2
  41. package/src/plugins/dev.ts +3 -3
  42. package/src/plugins/main.ts +5 -5
  43. package/src/rollup.js +3 -2
  44. package/dist/api.d.ts.map +0 -1
  45. package/dist/assets.d.ts +0 -4
  46. package/dist/assets.d.ts.map +0 -1
  47. package/dist/constants.d.ts.map +0 -1
  48. package/dist/context.d.ts.map +0 -1
  49. package/dist/log.d.ts.map +0 -1
  50. package/dist/modules.d.ts.map +0 -1
  51. package/dist/options.d.ts +0 -4
  52. package/dist/options.d.ts.map +0 -1
  53. package/dist/types.d.ts +0 -191
  54. package/dist/types.d.ts.map +0 -1
  55. package/dist/utils-types.d.ts +0 -2
  56. package/dist/utils-types.d.ts.map +0 -1
  57. package/dist/utils.d.ts.map +0 -1
  58. package/src/assets.ts +0 -76
  59. package/src/options.ts +0 -90
  60. package/src/types.ts +0 -207
  61. package/src/utils-types.ts +0 -1
  62. /package/dist/{api.d.ts → lib/api.d.ts} +0 -0
  63. /package/dist/{constants.d.ts → lib/constants.d.ts} +0 -0
  64. /package/dist/{log.d.ts → lib/log.d.ts} +0 -0
  65. /package/dist/{utils.d.ts → lib/utils.d.ts} +0 -0
  66. /package/src/{api.ts → lib/api.ts} +0 -0
  67. /package/src/{constants.ts → lib/constants.ts} +0 -0
  68. /package/src/{utils.ts → lib/utils.ts} +0 -0
@@ -0,0 +1,56 @@
1
+ import { basePartial, globPartial, injectPartial, requiredSwDestPartial, requiredGlobDirectoryPartial } from '@serwist/build/schema';
2
+ import { z } from 'zod';
3
+
4
+ const hooks = z.object({
5
+ beforeBuildServiceWorker: z.function(z.tuple([
6
+ z.any()
7
+ ]), z.union([
8
+ z.promise(z.void()),
9
+ z.void()
10
+ ])).optional(),
11
+ closeBundleOrder: z.union([
12
+ z.literal("pre"),
13
+ z.literal("post"),
14
+ z.null()
15
+ ]).optional(),
16
+ configureOptions: z.function(z.tuple([
17
+ z.any(),
18
+ z.any()
19
+ ]), z.union([
20
+ z.promise(z.void()),
21
+ z.void()
22
+ ])).optional()
23
+ });
24
+ const devOptions = z.object({
25
+ bundle: z.boolean().default(true),
26
+ minify: z.union([
27
+ z.boolean(),
28
+ z.literal("terser"),
29
+ z.literal("esbuild")
30
+ ]).default(false)
31
+ });
32
+ const injectManifestPartial = z.object({
33
+ mode: z.union([
34
+ z.literal("development"),
35
+ z.literal("production")
36
+ ]),
37
+ type: z.union([
38
+ z.literal("classic"),
39
+ z.literal("module")
40
+ ]).default("classic"),
41
+ scope: z.string(),
42
+ base: z.string(),
43
+ disable: z.boolean().default(false),
44
+ integration: hooks.default({}),
45
+ swUrl: z.string().default("/sw.js"),
46
+ plugins: z.array(z.any()).default([]),
47
+ rollupFormat: z.union([
48
+ z.literal("es"),
49
+ z.literal("iife")
50
+ ]).default("es"),
51
+ rollupOptions: z.record(z.string(), z.any()).default({}),
52
+ devOptions: devOptions.default({})
53
+ });
54
+ const injectManifestOptions = basePartial.merge(globPartial).merge(injectPartial).merge(requiredSwDestPartial).merge(requiredGlobDirectoryPartial).merge(injectManifestPartial).strict("Do not pass invalid properties to InjectManifestOptions!");
55
+
56
+ export { devOptions, hooks, injectManifestOptions, injectManifestPartial };
package/dist/index.d.ts CHANGED
@@ -1,18 +1,19 @@
1
1
  import type { Plugin } from "vite";
2
- import { createApi } from "./api.js";
3
- import { createContext } from "./context.js";
2
+ import { createApi } from "./lib/api.js";
3
+ import { createContext } from "./lib/context.js";
4
+ import type { DevOptions, ExtendManifestEntriesHook, Hooks, PluginOptions, PluginOptionsComplete, SerwistViteApi } from "./lib/types.js";
5
+ import { resolveEntry, toFs } from "./lib/utils.js";
6
+ import { validateInjectManifestOptions } from "./lib/validator.js";
4
7
  import { buildPlugin } from "./plugins/build.js";
5
8
  import { devPlugin } from "./plugins/dev.js";
6
9
  import { mainPlugin } from "./plugins/main.js";
7
- import type { PluginOptions } from "./types.js";
8
- import { resolveEntry, toFs } from "./utils.js";
9
10
  /**
10
11
  * Integrates Serwist into your Vite app.
11
12
  * @param userOptions
12
13
  * @returns
13
14
  */
14
15
  export declare const serwist: (userOptions: PluginOptions) => Plugin[];
15
- export { buildPlugin as build, createApi, createContext, devPlugin as dev, mainPlugin as main, resolveEntry, toFs };
16
- export type { SerwistViteContext } from "./context.js";
17
- export * from "./types.js";
16
+ export { buildPlugin as build, createApi, createContext, devPlugin as dev, mainPlugin as main, resolveEntry, toFs, validateInjectManifestOptions };
17
+ export type { SerwistViteContext } from "./lib/context.js";
18
+ export type { PluginOptions, PluginOptionsComplete, Hooks, ExtendManifestEntriesHook, DevOptions, SerwistViteApi };
18
19
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,MAAM,CAAC;AAEnC,OAAO,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AACrC,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAC7C,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AACjD,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAC7C,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAC/C,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAChD,OAAO,EAAE,YAAY,EAAE,IAAI,EAAE,MAAM,YAAY,CAAC;AAEhD;;;;GAIG;AACH,eAAO,MAAM,OAAO,gBAAiB,aAAa,KAAG,MAAM,EAI1D,CAAC;AAGF,OAAO,EAAE,WAAW,IAAI,KAAK,EAAE,SAAS,EAAE,aAAa,EAAE,SAAS,IAAI,GAAG,EAAE,UAAU,IAAI,IAAI,EAAE,YAAY,EAAE,IAAI,EAAE,CAAC;AACpH,YAAY,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAC;AACvD,cAAc,YAAY,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,MAAM,CAAC;AAEnC,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AACzC,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AACjD,OAAO,KAAK,EAAE,UAAU,EAAE,yBAAyB,EAAE,KAAK,EAAE,aAAa,EAAE,qBAAqB,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AACzI,OAAO,EAAE,YAAY,EAAE,IAAI,EAAE,MAAM,gBAAgB,CAAC;AACpD,OAAO,EAAE,6BAA6B,EAAE,MAAM,oBAAoB,CAAC;AACnE,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AACjD,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAC7C,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAE/C;;;;GAIG;AACH,eAAO,MAAM,OAAO,gBAAiB,aAAa,KAAG,MAAM,EAI1D,CAAC;AAGF,OAAO,EAAE,WAAW,IAAI,KAAK,EAAE,SAAS,EAAE,aAAa,EAAE,SAAS,IAAI,GAAG,EAAE,UAAU,IAAI,IAAI,EAAE,YAAY,EAAE,IAAI,EAAE,6BAA6B,EAAE,CAAC;AACnJ,YAAY,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AAC3D,YAAY,EAAE,aAAa,EAAE,qBAAqB,EAAE,KAAK,EAAE,yBAAyB,EAAE,UAAU,EAAE,cAAc,EAAE,CAAC"}
package/dist/index.js CHANGED
@@ -1,68 +1,13 @@
1
+ import { cyan, green, dim, yellow } from 'kolorist';
1
2
  import assert from 'node:assert';
2
3
  import fs from 'node:fs/promises';
3
- import path, { resolve } from 'node:path';
4
- import { normalizePath } from 'vite';
4
+ import path from 'node:path';
5
5
  import fs$1 from 'node:fs';
6
- import process$1 from 'node:process';
7
- import crypto from 'node:crypto';
8
- import fg from 'fast-glob';
9
-
10
- let enabled = true;
11
- const globalVar = typeof self !== 'undefined' ? self : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : {};
12
- let supportLevel = 0;
13
- if (globalVar.process && globalVar.process.env && globalVar.process.stdout) {
14
- const { FORCE_COLOR, NODE_DISABLE_COLORS, NO_COLOR, TERM, COLORTERM } = globalVar.process.env;
15
- if (NODE_DISABLE_COLORS || NO_COLOR || FORCE_COLOR === '0') {
16
- enabled = false;
17
- } else if (FORCE_COLOR === '1' || FORCE_COLOR === '2' || FORCE_COLOR === '3') {
18
- enabled = true;
19
- } else if (TERM === 'dumb') {
20
- enabled = false;
21
- } else if ('CI' in globalVar.process.env && [
22
- 'TRAVIS',
23
- 'CIRCLECI',
24
- 'APPVEYOR',
25
- 'GITLAB_CI',
26
- 'GITHUB_ACTIONS',
27
- 'BUILDKITE',
28
- 'DRONE'
29
- ].some((vendor)=>vendor in globalVar.process.env)) {
30
- enabled = true;
31
- } else {
32
- enabled = process.stdout.isTTY;
33
- }
34
- if (enabled) {
35
- if (process.platform === 'win32') {
36
- supportLevel = 3;
37
- } else {
38
- if (COLORTERM && (COLORTERM === 'truecolor' || COLORTERM === '24bit')) {
39
- supportLevel = 3;
40
- } else if (TERM && (TERM.endsWith('-256color') || TERM.endsWith('256'))) {
41
- supportLevel = 2;
42
- } else {
43
- supportLevel = 1;
44
- }
45
- }
46
- }
47
- }
48
- let options = {
49
- enabled,
50
- supportLevel
51
- };
52
- function kolorist(start, end, level = 1) {
53
- const open = `\x1b[${start}m`;
54
- const close = `\x1b[${end}m`;
55
- const regex = new RegExp(`\\x1b\\[${end}m`, 'g');
56
- return (str)=>{
57
- return options.enabled && options.supportLevel >= level ? open + ('' + str).replace(regex, open) + close : '' + str;
58
- };
59
- }
60
- const dim = kolorist(2, 22);
61
- const green = kolorist(32, 39);
62
- const yellow = kolorist(33, 39);
63
- const cyan = kolorist(36, 39);
6
+ import { validationErrorMap, SerwistConfigError } from '@serwist/build/schema';
7
+ import { normalizePath } from 'vite';
8
+ import process from 'node:process';
64
9
 
65
- var version = "9.0.0-preview.12";
10
+ var version = "9.0.0-preview.14";
66
11
 
67
12
  const logSerwistResult = (buildResult, viteOptions)=>{
68
13
  const { logLevel = "info" } = viteOptions;
@@ -89,9 +34,8 @@ const loadSerwistBuild = async ()=>{
89
34
  return require("@serwist/build");
90
35
  }
91
36
  };
92
- const injectManifest = async (config)=>{
93
- const { validateViteInjectManifestOptions, getFileManifestEntries, stringify } = await loadSerwistBuild();
94
- const options = await validateViteInjectManifestOptions(config);
37
+ const injectManifest = async (options)=>{
38
+ const { getFileManifestEntries, stringify } = await loadSerwistBuild();
95
39
  const { count, size, manifestEntries, warnings } = await getFileManifestEntries(options);
96
40
  const manifestString = manifestEntries === undefined ? "undefined" : stringify(manifestEntries);
97
41
  return {
@@ -103,7 +47,7 @@ const injectManifest = async (config)=>{
103
47
  };
104
48
  };
105
49
  const generateServiceWorker = async (ctx)=>{
106
- const { format, plugins, rollupOptions } = ctx.options.injectManifestRollupOptions;
50
+ const { plugins, rollupOptions, rollupFormat } = ctx.options;
107
51
  const parsedSwDest = path.parse(ctx.options.injectManifest.swDest);
108
52
  let injectManifestResult = undefined;
109
53
  if (ctx.options.injectManifest.injectionPoint) {
@@ -189,7 +133,7 @@ const generateServiceWorker = async (ctx)=>{
189
133
  entry: ctx.options.injectManifest.swSrc,
190
134
  name: "app",
191
135
  formats: [
192
- format
136
+ rollupFormat
193
137
  ]
194
138
  },
195
139
  rollupOptions: {
@@ -254,26 +198,6 @@ const createContext = (userOptions, framework)=>{
254
198
  };
255
199
  };
256
200
 
257
- const buildPlugin = (ctx, api)=>{
258
- return {
259
- name: "@serwist/vite:build",
260
- enforce: "post",
261
- apply: "build",
262
- closeBundle: {
263
- sequential: true,
264
- order: ctx.userOptions?.integration?.closeBundleOrder,
265
- async handler () {
266
- if (!ctx.viteConfig.build.ssr && !ctx.options.disable) {
267
- await api.generateSW();
268
- }
269
- }
270
- },
271
- async buildEnd (error) {
272
- if (error) throw error;
273
- }
274
- };
275
- };
276
-
277
201
  const slash = (str)=>{
278
202
  return str.replace(/\\/g, "/");
279
203
  };
@@ -306,6 +230,39 @@ const toFs = (str)=>{
306
230
  return `/@fs${str.startsWith("/") ? "" : "/"}${str}`;
307
231
  };
308
232
 
233
+ const validateInjectManifestOptions = async (input)=>{
234
+ const result = await (await import('./chunks/schema.js')).injectManifestOptions.spa(input, {
235
+ errorMap: validationErrorMap
236
+ });
237
+ if (!result.success) {
238
+ throw new SerwistConfigError({
239
+ moduleName: "@serwist/vite",
240
+ message: JSON.stringify(result.error.format(), null, 2)
241
+ });
242
+ }
243
+ return result.data;
244
+ };
245
+
246
+ const buildPlugin = (ctx, api)=>{
247
+ return {
248
+ name: "@serwist/vite:build",
249
+ enforce: "post",
250
+ apply: "build",
251
+ closeBundle: {
252
+ sequential: true,
253
+ order: ctx.userOptions?.integration?.closeBundleOrder,
254
+ async handler () {
255
+ if (!ctx.viteConfig.build.ssr && !ctx.options.disable) {
256
+ await api.generateSW();
257
+ }
258
+ }
259
+ },
260
+ async buildEnd (error) {
261
+ if (error) throw error;
262
+ }
263
+ };
264
+ };
265
+
309
266
  const devPlugin = (ctx, api)=>{
310
267
  return {
311
268
  name: "@serwist/vite:dev",
@@ -349,107 +306,41 @@ const devPlugin = (ctx, api)=>{
349
306
  const INTERNAL_SERWIST_VIRTUAL = "virtual:internal-serwist";
350
307
  const RESOLVED_INTERNAL_SERWIST_VIRTUAL = `\0${INTERNAL_SERWIST_VIRTUAL}`;
351
308
 
352
- const buildManifestEntry = (publicDir, url)=>{
353
- return new Promise((resolve$1, reject)=>{
354
- const cHash = crypto.createHash("MD5");
355
- const stream = fs$1.createReadStream(resolve(publicDir, url));
356
- stream.on("error", (err)=>{
357
- reject(err);
358
- });
359
- stream.on("data", (chunk)=>{
360
- cHash.update(chunk);
361
- });
362
- stream.on("end", ()=>{
363
- return resolve$1({
364
- url,
365
- revision: `${cHash.digest("hex")}`
366
- });
367
- });
368
- });
369
- };
370
- const lookupAdditionalPrecacheEntries = (serwistOptions)=>{
371
- return serwistOptions.additionalPrecacheEntries || [];
372
- };
373
- const normalizeIconPath = (path)=>{
374
- return path.startsWith("/") ? path.substring(1) : path;
375
- };
376
- const configureStaticAssets = async (resolvedPluginOptions, viteConfig)=>{
377
- const { injectManifest, includeAssets } = resolvedPluginOptions;
378
- const { publicDir } = viteConfig;
379
- const globs = [];
380
- const manifestEntries = lookupAdditionalPrecacheEntries(injectManifest);
381
- if (includeAssets) {
382
- if (Array.isArray(includeAssets)) globs.push(...includeAssets.map(normalizeIconPath));
383
- else globs.push(normalizeIconPath(includeAssets));
384
- }
385
- if (globs.length > 0) {
386
- let assets = await fg(globs, {
387
- cwd: publicDir,
388
- onlyFiles: true,
389
- unique: true
390
- });
391
- if (manifestEntries.length > 0) {
392
- const included = manifestEntries.map((me)=>{
393
- if (typeof me === "string") return me;
394
- return me.url;
395
- });
396
- assets = assets.filter((a)=>!included.includes(a));
397
- }
398
- const assetsEntries = await Promise.all(assets.map((a)=>{
399
- return buildManifestEntry(publicDir, a);
400
- }));
401
- manifestEntries.push(...assetsEntries);
402
- }
403
- if (manifestEntries.length > 0) {
404
- injectManifest.additionalPrecacheEntries = manifestEntries;
405
- }
309
+ const prepareConfigForValidation = (viteConfig, { mode = process.env.NODE_ENV === "production" || process.env.NODE_ENV === "development" ? process.env.NODE_ENV : "production", base = viteConfig.base, scope: _scope, devOptions, ...injectManifest })=>{
310
+ const basePath = resolveBasePath(base);
311
+ return {
312
+ mode,
313
+ base: basePath,
314
+ scope: _scope || basePath,
315
+ devOptions,
316
+ ...injectManifest
317
+ };
406
318
  };
407
-
408
319
  const resolveOptions = async (options, viteConfig)=>{
409
- const { type = "classic", mode = process$1.env.NODE_ENV === "production" || process$1.env.NODE_ENV === "development" ? process$1.env.NODE_ENV : "production", injectRegister = "auto", registerType = "prompt", minify = true, base = viteConfig.base, scope: _scope, swUrl = "/sw.js", includeAssets = undefined, useCredentials = false, disable = false, integration = {}, buildBase, devOptions, plugins = [], rollupOptions = {}, rollupFormat = "es", ...injectManifest } = options;
410
- const basePath = resolveBasePath(base);
411
- const scope = _scope || basePath;
320
+ const { mode, type, scope, base, disable, integration, swUrl, swSrc, swDest, plugins, rollupFormat, rollupOptions, devOptions, ...userInjectManifest } = await validateInjectManifestOptions(prepareConfigForValidation(viteConfig, options));
412
321
  let assetsDir = slash(viteConfig.build.assetsDir ?? "assets");
413
322
  if (assetsDir[assetsDir.length - 1] !== "/") assetsDir += "/";
414
- const resolvedDevOptions = {
415
- bundle: true,
416
- minify: false,
417
- ...devOptions
418
- };
419
323
  const dontCacheBustURLsMatching = new RegExp(`^${assetsDir.replace(/^\.*?\//, "")}`);
420
- const { validateViteInjectManifestOptions } = await loadSerwistBuild();
421
- const validatedInjectManifest = await validateViteInjectManifestOptions(injectManifest);
422
- const { swSrc, swDest, ...userInjectManifest } = validatedInjectManifest || {};
423
324
  const resolvedPluginOptions = {
424
- base: basePath,
425
- type,
426
325
  mode,
427
- injectRegister,
428
- registerType,
429
- useCredentials,
326
+ type,
327
+ scope,
328
+ base,
329
+ disable,
330
+ integration,
430
331
  swUrl,
332
+ plugins,
333
+ rollupFormat,
334
+ rollupOptions,
335
+ devOptions,
431
336
  injectManifest: {
432
337
  dontCacheBustURLsMatching,
433
338
  ...userInjectManifest,
434
339
  swSrc: path.resolve(viteConfig.root, swSrc),
435
340
  swDest: path.resolve(viteConfig.root, viteConfig.build.outDir, swDest),
436
341
  disablePrecacheManifest: !viteConfig.isProduction
437
- },
438
- scope,
439
- minify,
440
- includeAssets,
441
- disable,
442
- integration,
443
- buildBase: buildBase ?? basePath,
444
- injectManifestRollupOptions: {
445
- plugins,
446
- rollupOptions,
447
- format: rollupFormat
448
- },
449
- devOptions: resolvedDevOptions
342
+ }
450
343
  };
451
- const calculateHash = !resolvedPluginOptions.disable && resolvedPluginOptions.includeAssets && viteConfig.command === "build";
452
- if (calculateHash) await configureStaticAssets(resolvedPluginOptions, viteConfig);
453
344
  return resolvedPluginOptions;
454
345
  };
455
346
 
@@ -477,7 +368,7 @@ const mainPlugin = (ctx, api)=>{
477
368
  },
478
369
  load (id) {
479
370
  if (id === RESOLVED_INTERNAL_SERWIST_VIRTUAL) {
480
- return `export const swUrl = "${path.posix.join(ctx.options.buildBase, ctx.options.swUrl)}";
371
+ return `export const swUrl = "${path.posix.join(ctx.options.base, ctx.options.swUrl)}";
481
372
  export const swScope = "${ctx.options.scope}";
482
373
  export const swType = "${ctx.devEnvironment ? "module" : ctx.options.type}";`;
483
374
  }
@@ -497,4 +388,4 @@ const serwist = (userOptions)=>{
497
388
  ];
498
389
  };
499
390
 
500
- export { buildPlugin as build, createApi, createContext, devPlugin as dev, mainPlugin as main, resolveEntry, serwist, toFs };
391
+ export { buildPlugin as build, createApi, createContext, devPlugin as dev, mainPlugin as main, resolveEntry, serwist, toFs, validateInjectManifestOptions };
@@ -0,0 +1,3 @@
1
+ import { devOptions, hooks, injectManifestOptions, injectManifestPartial } from "./lib/schema.js";
2
+ export { hooks, devOptions, injectManifestPartial, injectManifestOptions };
3
+ //# sourceMappingURL=index.schema.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.schema.d.ts","sourceRoot":"","sources":["../src/index.schema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,KAAK,EAAE,qBAAqB,EAAE,qBAAqB,EAAE,MAAM,iBAAiB,CAAC;AAElG,OAAO,EAAE,KAAK,EAAE,UAAU,EAAE,qBAAqB,EAAE,qBAAqB,EAAE,CAAC"}
@@ -0,0 +1,3 @@
1
+ export { devOptions, hooks, injectManifestOptions, injectManifestPartial } from './chunks/schema.js';
2
+ import '@serwist/build/schema';
3
+ import 'zod';
@@ -0,0 +1 @@
1
+ {"version":3,"file":"api.d.ts","sourceRoot":"","sources":["../../src/lib/api.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAC;AAGvD,OAAO,KAAK,EAA6B,cAAc,EAAE,MAAM,YAAY,CAAC;AAE5E,eAAO,MAAM,SAAS,QAAS,kBAAkB,KAAG,cA8BnD,CAAC"}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../src/lib/constants.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,wBAAwB,6BAA6B,CAAC;AACnE,eAAO,MAAM,iCAAiC,+BAAkC,CAAC"}
@@ -1,5 +1,5 @@
1
1
  import type { ResolvedConfig } from "vite";
2
- import type { PluginOptions, ResolvedPluginOptions } from "./types.js";
2
+ import type { PluginOptions, PluginOptionsComplete } from "./types.js";
3
3
  export type SerwistViteFrameworks = "nuxt";
4
4
  export interface SerwistViteContext {
5
5
  /**
@@ -18,7 +18,7 @@ export interface SerwistViteContext {
18
18
  * Note: this is different from `userOptions` in that it has been parsed, whereas
19
19
  * `userOptions` is the raw configuration that the user provides us.
20
20
  */
21
- options: ResolvedPluginOptions;
21
+ options: PluginOptionsComplete;
22
22
  useImportRegister: boolean;
23
23
  /**
24
24
  * Is the plugin running on dev?
@@ -0,0 +1 @@
1
+ {"version":3,"file":"context.d.ts","sourceRoot":"","sources":["../../src/lib/context.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,MAAM,CAAC;AAE3C,OAAO,KAAK,EAAE,aAAa,EAAE,qBAAqB,EAAE,MAAM,YAAY,CAAC;AAEvE,MAAM,MAAM,qBAAqB,GAAG,MAAM,CAAC;AAE3C,MAAM,WAAW,kBAAkB;IACjC;;;;OAIG;IACH,UAAU,EAAE,cAAc,CAAC;IAC3B;;OAEG;IACH,WAAW,EAAE,aAAa,CAAC;IAC3B;;;;;OAKG;IACH,OAAO,EAAE,qBAAqB,CAAC;IAC/B,iBAAiB,EAAE,OAAO,CAAC;IAC3B;;;;OAIG;IACH,cAAc,EAAE,OAAO,CAAC;IACxB,8CAA8C;IAC9C,SAAS,EAAE,qBAAqB,GAAG,SAAS,CAAC;CAC9C;AAED,eAAO,MAAM,aAAa,gBAAiB,aAAa,aAAa,qBAAqB,GAAG,SAAS,KAAG,kBASxG,CAAC"}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"log.d.ts","sourceRoot":"","sources":["../../src/lib/log.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAElD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,MAAM,CAAC;AAI3C,eAAO,MAAM,gBAAgB,gBAAiB,KAAK,WAAW,EAAE,OAAO,GAAG,MAAM,GAAG,UAAU,CAAC,eAAe,cAAc,SAkB1H,CAAC"}
@@ -4,7 +4,7 @@ export declare const loadSerwistBuild: () => Promise<typeof SerwistBuild>;
4
4
  interface BuildResult extends SerwistBuild.GetManifestResult {
5
5
  manifestString: string;
6
6
  }
7
- export declare const injectManifest: (config: SerwistBuild.ViteInjectManifestOptions) => Promise<BuildResult>;
7
+ export declare const injectManifest: (options: SerwistBuild.GetManifestOptions) => Promise<BuildResult>;
8
8
  export declare const generateServiceWorker: (ctx: SerwistViteContext) => Promise<BuildResult | undefined>;
9
9
  export {};
10
10
  //# sourceMappingURL=modules.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"modules.d.ts","sourceRoot":"","sources":["../../src/lib/modules.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,KAAK,YAAY,MAAM,gBAAgB,CAAC;AAEpD,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAC;AAEvD,eAAO,MAAM,gBAAgB,QAAa,QAAQ,mBAAmB,CASpE,CAAC;AAEF,UAAU,WAAY,SAAQ,YAAY,CAAC,iBAAiB;IAC1D,cAAc,EAAE,MAAM,CAAC;CACxB;AAED,eAAO,MAAM,cAAc,YAAmB,aAAa,kBAAkB,KAAG,QAAQ,WAAW,CAWlG,CAAC;AAEF,eAAO,MAAM,qBAAqB,QAAe,kBAAkB,qCAwIlE,CAAC"}
@@ -0,0 +1,4 @@
1
+ import type { ResolvedConfig } from "vite";
2
+ import type { PluginOptions, PluginOptionsComplete } from "./types.js";
3
+ export declare const resolveOptions: (options: PluginOptions, viteConfig: ResolvedConfig) => Promise<PluginOptionsComplete>;
4
+ //# sourceMappingURL=options.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"options.d.ts","sourceRoot":"","sources":["../../src/lib/options.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,MAAM,CAAC;AAE3C,OAAO,KAAK,EAAE,aAAa,EAAE,qBAAqB,EAAE,MAAM,YAAY,CAAC;AAwBvE,eAAO,MAAM,cAAc,YAAmB,aAAa,cAAc,cAAc,KAAG,QAAQ,qBAAqB,CA8CtH,CAAC"}