@serwist/build 9.0.0-preview.11 → 9.0.0-preview.13
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/chunks/glob.js +2 -2
- package/dist/chunks/injectManifest.js +5 -5
- package/dist/index.d.ts +2 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -26
- package/dist/index.schema.d.ts +13 -0
- package/dist/index.schema.d.ts.map +1 -0
- package/dist/index.schema.js +9 -0
- package/dist/lib/validate-options.d.ts +1 -3
- package/dist/lib/validate-options.d.ts.map +1 -1
- package/dist/schema/assertType.d.ts +1 -0
- package/dist/schema/assertType.d.ts.map +1 -1
- package/dist/schema/injectManifest.d.ts +3 -3
- package/dist/schema/injectManifest.d.ts.map +1 -1
- package/dist/{lib/serwist-config-error.d.ts → schema/serwistConfigError.d.ts} +1 -1
- package/dist/schema/serwistConfigError.d.ts.map +1 -0
- package/dist/types.d.ts +0 -143
- package/dist/types.d.ts.map +1 -1
- package/package.json +13 -21
- package/src/index.schema.ts +29 -0
- package/src/index.ts +2 -3
- package/src/lib/validate-options.ts +2 -23
- package/src/schema/assertType.ts +2 -0
- package/src/schema/injectManifest.ts +4 -4
- package/src/types.ts +0 -175
- package/dist/chunks/vite.js +0 -7
- package/dist/chunks/webpack.js +0 -33
- package/dist/index.next.d.ts +0 -3
- package/dist/index.next.d.ts.map +0 -1
- package/dist/index.next.js +0 -38
- package/dist/lib/serwist-config-error.d.ts.map +0 -1
- package/dist/lib/validate-next-options.d.ts +0 -3
- package/dist/lib/validate-next-options.d.ts.map +0 -1
- package/dist/schema/next.d.ts +0 -240
- package/dist/schema/next.d.ts.map +0 -1
- package/dist/schema/vite.d.ts +0 -196
- package/dist/schema/vite.d.ts.map +0 -1
- package/dist/schema/webpack.d.ts +0 -225
- package/dist/schema/webpack.d.ts.map +0 -1
- package/src/index.next.ts +0 -3
- package/src/lib/validate-next-options.ts +0 -14
- package/src/schema/next.ts +0 -33
- package/src/schema/vite.ts +0 -18
- package/src/schema/webpack.ts +0 -46
- package/dist/chunks/{serwist-config-error.js → validationErrorMap.js} +7 -7
- /package/src/{lib/serwist-config-error.ts → schema/serwistConfigError.ts} +0 -0
package/dist/chunks/glob.js
CHANGED
|
@@ -48,11 +48,11 @@ const globPartial = z.object({
|
|
|
48
48
|
z.array(z.string())
|
|
49
49
|
])).optional()
|
|
50
50
|
}).strict("Do not pass invalid properties to GlobPartial!");
|
|
51
|
-
z.object({
|
|
51
|
+
const optionalGlobDirectoryPartial = z.object({
|
|
52
52
|
globDirectory: z.string().optional()
|
|
53
53
|
}).strict("Do not pass invalid properties to OptionalGlobDirectoryPartial!");
|
|
54
54
|
const requiredGlobDirectoryPartial = z.object({
|
|
55
55
|
globDirectory: z.string()
|
|
56
56
|
}).strict("Do not pass invalid properties to RequiredGlobDirectoryPartial!");
|
|
57
57
|
|
|
58
|
-
export { basePartial as b, globPartial as g, requiredGlobDirectoryPartial as r };
|
|
58
|
+
export { manifestTransform as a, basePartial as b, manifestTransformResult as c, globPartial as g, manifestEntry as m, optionalGlobDirectoryPartial as o, requiredGlobDirectoryPartial as r };
|
|
@@ -8,16 +8,16 @@ const requiredSwDestPartial = z.object({
|
|
|
8
8
|
swDest: z.string()
|
|
9
9
|
}).strict("Do not pass invalid properties to RequiredSwDest!");
|
|
10
10
|
|
|
11
|
-
const
|
|
11
|
+
const baseInjectPartial = z.object({
|
|
12
12
|
injectionPoint: z.string().default("self.__SW_MANIFEST"),
|
|
13
13
|
swSrc: z.string()
|
|
14
14
|
}).strict("Do not pass invalid properties to InjectPartial!");
|
|
15
|
-
const injectManifestOptions = basePartial.merge(globPartial).merge(
|
|
15
|
+
const injectManifestOptions = basePartial.merge(globPartial).merge(baseInjectPartial).merge(requiredSwDestPartial).merge(requiredGlobDirectoryPartial).strict("Do not pass invalid properties to InjectManifestOptions!");
|
|
16
16
|
|
|
17
17
|
var injectManifest = /*#__PURE__*/Object.freeze({
|
|
18
18
|
__proto__: null,
|
|
19
|
-
|
|
20
|
-
|
|
19
|
+
baseInjectPartial: baseInjectPartial,
|
|
20
|
+
injectManifestOptions: injectManifestOptions
|
|
21
21
|
});
|
|
22
22
|
|
|
23
|
-
export { injectManifest as a,
|
|
23
|
+
export { injectManifest as a, baseInjectPartial as b, injectManifestOptions as i, optionalSwDestPartial as o, requiredSwDestPartial as r };
|
package/dist/index.d.ts
CHANGED
|
@@ -9,7 +9,7 @@ import { rebasePath } from "./lib/rebase-path.js";
|
|
|
9
9
|
import { replaceAndUpdateSourceMap } from "./lib/replace-and-update-source-map.js";
|
|
10
10
|
import { transformManifest } from "./lib/transform-manifest.js";
|
|
11
11
|
import { translateURLToSourcemapPaths } from "./lib/translate-url-to-sourcemap-paths.js";
|
|
12
|
-
import {
|
|
13
|
-
export { errors, escapeRegExp, getFileManifestEntries, getManifest, getSourceMapURL, injectManifest, rebasePath, replaceAndUpdateSourceMap, stringify, transformManifest, translateURLToSourcemapPaths,
|
|
12
|
+
import { validateGetManifestOptions, validateInjectManifestOptions } from "./lib/validate-options.js";
|
|
13
|
+
export { errors, escapeRegExp, getFileManifestEntries, getManifest, getSourceMapURL, injectManifest, rebasePath, replaceAndUpdateSourceMap, stringify, transformManifest, translateURLToSourcemapPaths, validateGetManifestOptions, validateInjectManifestOptions, };
|
|
14
14
|
export type * from "./types.js";
|
|
15
15
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAOA,OAAO,SAAS,MAAM,4BAA4B,CAAC;AAEnD,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AACtD,OAAO,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAC;AACzC,OAAO,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AAC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B,YAAY,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -7,7 +7,7 @@ import { globSync } from 'glob';
|
|
|
7
7
|
import upath from 'upath';
|
|
8
8
|
import fse from 'fs-extra';
|
|
9
9
|
import prettyBytes from 'pretty-bytes';
|
|
10
|
-
import { v as validationErrorMap, S as SerwistConfigError } from './chunks/
|
|
10
|
+
import { v as validationErrorMap, S as SerwistConfigError } from './chunks/validationErrorMap.js';
|
|
11
11
|
import { SourceMapGenerator, SourceMapConsumer } from 'source-map';
|
|
12
12
|
import 'zod';
|
|
13
13
|
|
|
@@ -456,30 +456,6 @@ const validateInjectManifestOptions = async (input)=>{
|
|
|
456
456
|
}
|
|
457
457
|
return result.data;
|
|
458
458
|
};
|
|
459
|
-
const validateWebpackInjectManifestOptions = async (input)=>{
|
|
460
|
-
const result = await (await import('./chunks/webpack.js')).webpackInjectManifestOptions.spa(input, {
|
|
461
|
-
errorMap: validationErrorMap
|
|
462
|
-
});
|
|
463
|
-
if (!result.success) {
|
|
464
|
-
throw new SerwistConfigError({
|
|
465
|
-
moduleName: "@serwist/webpack-plugin",
|
|
466
|
-
message: JSON.stringify(result.error.format(), null, 2)
|
|
467
|
-
});
|
|
468
|
-
}
|
|
469
|
-
return result.data;
|
|
470
|
-
};
|
|
471
|
-
const validateViteInjectManifestOptions = async (input)=>{
|
|
472
|
-
const result = await (await import('./chunks/vite.js')).viteInjectManifestOptions.spa(input, {
|
|
473
|
-
errorMap: validationErrorMap
|
|
474
|
-
});
|
|
475
|
-
if (!result.success) {
|
|
476
|
-
throw new SerwistConfigError({
|
|
477
|
-
moduleName: "@serwist/vite",
|
|
478
|
-
message: JSON.stringify(result.error.format(), null, 2)
|
|
479
|
-
});
|
|
480
|
-
}
|
|
481
|
-
return result.data;
|
|
482
|
-
};
|
|
483
459
|
|
|
484
460
|
const getManifest = async (config)=>{
|
|
485
461
|
const options = await validateGetManifestOptions(config);
|
|
@@ -649,4 +625,4 @@ const injectManifest = async (config)=>{
|
|
|
649
625
|
};
|
|
650
626
|
};
|
|
651
627
|
|
|
652
|
-
export { errors, escapeRegExp, getFileManifestEntries, getManifest, getSourceMapURL, injectManifest, rebasePath, replaceAndUpdateSourceMap, transformManifest, translateURLToSourcemapPaths,
|
|
628
|
+
export { errors, escapeRegExp, getFileManifestEntries, getManifest, getSourceMapURL, injectManifest, rebasePath, replaceAndUpdateSourceMap, transformManifest, translateURLToSourcemapPaths, validateGetManifestOptions, validateInjectManifestOptions };
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { type Assignable, type Equals, assertType } from "./schema/assertType.js";
|
|
2
|
+
import { basePartial } from "./schema/base.js";
|
|
3
|
+
import { getManifestOptions } from "./schema/getManifest.js";
|
|
4
|
+
import { globPartial, optionalGlobDirectoryPartial, requiredGlobDirectoryPartial } from "./schema/glob.js";
|
|
5
|
+
import { baseInjectPartial, injectManifestOptions } from "./schema/injectManifest.js";
|
|
6
|
+
import { manifestEntry } from "./schema/manifestEntry.js";
|
|
7
|
+
import { manifestTransform, manifestTransformResult } from "./schema/manifestTransform.js";
|
|
8
|
+
import { SerwistConfigError } from "./schema/serwistConfigError.js";
|
|
9
|
+
import { optionalSwDestPartial, requiredSwDestPartial } from "./schema/swDest.js";
|
|
10
|
+
import { validationErrorMap } from "./schema/validationErrorMap.js";
|
|
11
|
+
export { assertType, basePartial, globPartial, baseInjectPartial as injectPartial, injectManifestOptions, getManifestOptions, manifestEntry, manifestTransform, manifestTransformResult, optionalGlobDirectoryPartial, requiredGlobDirectoryPartial, optionalSwDestPartial, requiredSwDestPartial, validationErrorMap, SerwistConfigError, };
|
|
12
|
+
export type { Assignable, Equals };
|
|
13
|
+
//# 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,KAAK,UAAU,EAAE,KAAK,MAAM,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AAClF,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAC/C,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAC7D,OAAO,EAAE,WAAW,EAAE,4BAA4B,EAAE,4BAA4B,EAAE,MAAM,kBAAkB,CAAC;AAC3G,OAAO,EAAE,iBAAiB,EAAE,qBAAqB,EAAE,MAAM,4BAA4B,CAAC;AACtF,OAAO,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAC;AAC1D,OAAO,EAAE,iBAAiB,EAAE,uBAAuB,EAAE,MAAM,+BAA+B,CAAC;AAC3F,OAAO,EAAE,kBAAkB,EAAE,MAAM,gCAAgC,CAAC;AACpE,OAAO,EAAE,qBAAqB,EAAE,qBAAqB,EAAE,MAAM,oBAAoB,CAAC;AAClF,OAAO,EAAE,kBAAkB,EAAE,MAAM,gCAAgC,CAAC;AAEpE,OAAO,EACL,UAAU,EACV,WAAW,EACX,WAAW,EACX,iBAAiB,IAAI,aAAa,EAClC,qBAAqB,EACrB,kBAAkB,EAClB,aAAa,EACb,iBAAiB,EACjB,uBAAuB,EACvB,4BAA4B,EAC5B,4BAA4B,EAC5B,qBAAqB,EACrB,qBAAqB,EACrB,kBAAkB,EAClB,kBAAkB,GACnB,CAAC;AACF,YAAY,EAAE,UAAU,EAAE,MAAM,EAAE,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export { b as basePartial, g as globPartial, m as manifestEntry, a as manifestTransform, c as manifestTransformResult, o as optionalGlobDirectoryPartial, r as requiredGlobDirectoryPartial } from './chunks/glob.js';
|
|
2
|
+
export { getManifestOptions } from './chunks/getManifest.js';
|
|
3
|
+
export { i as injectManifestOptions, b as injectPartial, o as optionalSwDestPartial, r as requiredSwDestPartial } from './chunks/injectManifest.js';
|
|
4
|
+
export { S as SerwistConfigError, v as validationErrorMap } from './chunks/validationErrorMap.js';
|
|
5
|
+
import 'zod';
|
|
6
|
+
|
|
7
|
+
function assertType() {}
|
|
8
|
+
|
|
9
|
+
export { assertType };
|
|
@@ -1,6 +1,4 @@
|
|
|
1
|
-
import type { GetManifestOptionsComplete, InjectManifestOptionsComplete
|
|
1
|
+
import type { GetManifestOptionsComplete, InjectManifestOptionsComplete } from "../types.js";
|
|
2
2
|
export declare const validateGetManifestOptions: (input: unknown) => Promise<GetManifestOptionsComplete>;
|
|
3
3
|
export declare const validateInjectManifestOptions: (input: unknown) => Promise<InjectManifestOptionsComplete>;
|
|
4
|
-
export declare const validateWebpackInjectManifestOptions: (input: unknown) => Promise<WebpackInjectManifestOptionsComplete>;
|
|
5
|
-
export declare const validateViteInjectManifestOptions: (input: unknown) => Promise<ViteInjectManifestOptionsComplete>;
|
|
6
4
|
//# sourceMappingURL=validate-options.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"validate-options.d.ts","sourceRoot":"","sources":["../../src/lib/validate-options.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"validate-options.d.ts","sourceRoot":"","sources":["../../src/lib/validate-options.ts"],"names":[],"mappings":"AASA,OAAO,KAAK,EAAE,0BAA0B,EAAE,6BAA6B,EAAE,MAAM,aAAa,CAAC;AAE7F,eAAO,MAAM,0BAA0B,UAAiB,OAAO,KAAG,QAAQ,0BAA0B,CAMnG,CAAC;AAEF,eAAO,MAAM,6BAA6B,UAAiB,OAAO,KAAG,QAAQ,6BAA6B,CAMzG,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"assertType.d.ts","sourceRoot":"","sources":["../../src/schema/assertType.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,MAAM,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,GAAG,IAAI,GAAG,KAAK,CAAC,GAAG,KAAK,CAAC;AAEtF,wBAAgB,UAAU,CAAC,EAAE,SAAS,IAAI,UAEzC"}
|
|
1
|
+
{"version":3,"file":"assertType.d.ts","sourceRoot":"","sources":["../../src/schema/assertType.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,MAAM,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,GAAG,IAAI,GAAG,KAAK,CAAC,GAAG,KAAK,CAAC;AAEtF,MAAM,MAAM,UAAU,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,GAAG,IAAI,GAAG,KAAK,CAAC;AAE9D,wBAAgB,UAAU,CAAC,EAAE,SAAS,IAAI,UAEzC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
|
-
export declare const
|
|
2
|
+
export declare const baseInjectPartial: z.ZodObject<{
|
|
3
3
|
injectionPoint: z.ZodDefault<z.ZodString>;
|
|
4
4
|
swSrc: z.ZodString;
|
|
5
5
|
}, "strict", z.ZodTypeAny, {
|
|
@@ -129,8 +129,8 @@ export declare const injectManifestOptions: z.ZodObject<{
|
|
|
129
129
|
globStrict: boolean;
|
|
130
130
|
injectionPoint: string;
|
|
131
131
|
swSrc: string;
|
|
132
|
-
swDest: string;
|
|
133
132
|
globDirectory: string;
|
|
133
|
+
swDest: string;
|
|
134
134
|
additionalPrecacheEntries?: (string | {
|
|
135
135
|
revision: string | null;
|
|
136
136
|
url: string;
|
|
@@ -163,8 +163,8 @@ export declare const injectManifestOptions: z.ZodObject<{
|
|
|
163
163
|
templatedURLs?: Record<string, string | string[]> | undefined;
|
|
164
164
|
}, {
|
|
165
165
|
swSrc: string;
|
|
166
|
-
swDest: string;
|
|
167
166
|
globDirectory: string;
|
|
167
|
+
swDest: string;
|
|
168
168
|
disablePrecacheManifest?: boolean | undefined;
|
|
169
169
|
maximumFileSizeToCacheInBytes?: number | undefined;
|
|
170
170
|
additionalPrecacheEntries?: (string | {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"injectManifest.d.ts","sourceRoot":"","sources":["../../src/schema/injectManifest.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAOxB,eAAO,MAAM,
|
|
1
|
+
{"version":3,"file":"injectManifest.d.ts","sourceRoot":"","sources":["../../src/schema/injectManifest.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAOxB,eAAO,MAAM,iBAAiB;;;;;;;;;EAK+B,CAAC;AAE9D,eAAO,MAAM,qBAAqB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAKmC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"serwistConfigError.d.ts","sourceRoot":"","sources":["../../src/schema/serwistConfigError.ts"],"names":[],"mappings":"AAAA,qBAAa,kBAAmB,SAAQ,KAAK;gBAC/B,EAAE,UAAU,EAAE,OAAO,EAAE,EAAE;QAAE,UAAU,CAAC,EAAE,MAAM,CAAC;QAAC,OAAO,CAAC,EAAE,MAAM,CAAA;KAAE;CAI/E"}
|
package/dist/types.d.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import type { Require } from "@serwist/utils";
|
|
2
|
-
import type { Pattern as GlobPattern } from "fast-glob";
|
|
3
2
|
import type { PackageJson } from "type-fest";
|
|
4
3
|
import type { z } from "zod";
|
|
5
4
|
import type { manifestEntry } from "./schema/manifestEntry.js";
|
|
@@ -145,37 +144,6 @@ export interface InjectPartial {
|
|
|
145
144
|
swSrc: string;
|
|
146
145
|
}
|
|
147
146
|
export type InjectResolved = Require<InjectPartial, "injectionPoint">;
|
|
148
|
-
export interface WebpackPartial {
|
|
149
|
-
/**
|
|
150
|
-
* One or more chunk names whose corresponding output files should be included
|
|
151
|
-
* in the precache manifest.
|
|
152
|
-
*/
|
|
153
|
-
chunks?: string[];
|
|
154
|
-
/**
|
|
155
|
-
* One or more specifiers used to exclude assets from the precache manifest.
|
|
156
|
-
* This is interpreted following
|
|
157
|
-
* [the same rules](https://webpack.js.org/configuration/module/#condition)
|
|
158
|
-
* as `webpack`'s standard `exclude` option.
|
|
159
|
-
* @default
|
|
160
|
-
* ```
|
|
161
|
-
* [/\.map$/, /^manifest.*\.js$]
|
|
162
|
-
* ```
|
|
163
|
-
*/
|
|
164
|
-
exclude?: (string | RegExp | ((arg0: any) => boolean))[];
|
|
165
|
-
/**
|
|
166
|
-
* One or more chunk names whose corresponding output files should be excluded
|
|
167
|
-
* from the precache manifest.
|
|
168
|
-
*/
|
|
169
|
-
excludeChunks?: string[];
|
|
170
|
-
/**
|
|
171
|
-
* One or more specifiers used to include assets in the precache manifest.
|
|
172
|
-
* This is interpreted following
|
|
173
|
-
* [the same rules](https://webpack.js.org/configuration/module/#condition)
|
|
174
|
-
* as `webpack`'s standard `include` option.
|
|
175
|
-
*/
|
|
176
|
-
include?: (string | RegExp | ((arg0: any) => boolean))[];
|
|
177
|
-
}
|
|
178
|
-
export type WebpackResolved = Require<WebpackPartial, "exclude">;
|
|
179
147
|
export interface RequiredSwDestPartial {
|
|
180
148
|
/**
|
|
181
149
|
* The path and filename of the service worker file that will be created by
|
|
@@ -193,121 +161,10 @@ export interface OptionalSwDestPartial {
|
|
|
193
161
|
swDest?: string;
|
|
194
162
|
}
|
|
195
163
|
export type OptionalSwDestResolved = OptionalSwDestPartial;
|
|
196
|
-
export interface WebpackInjectManifestPartial {
|
|
197
|
-
/**
|
|
198
|
-
* When `true` (the default), the `swSrc` file will be compiled by `webpack`.
|
|
199
|
-
* When `false`, compilation will not occur (and `webpackCompilationPlugins`
|
|
200
|
-
* can't be used.) Set to `false` if you want to inject the manifest into,
|
|
201
|
-
* e.g., a JSON file.
|
|
202
|
-
* @default true
|
|
203
|
-
*/
|
|
204
|
-
compileSrc?: boolean;
|
|
205
|
-
/**
|
|
206
|
-
* Optional `webpack` plugins that will be used when compiling the `swSrc`
|
|
207
|
-
* input file. Only valid if `compileSrc` is `true`.
|
|
208
|
-
*/
|
|
209
|
-
webpackCompilationPlugins?: any[];
|
|
210
|
-
}
|
|
211
|
-
export type WebpackInjectManifestResolved = Require<WebpackInjectManifestPartial, "compileSrc">;
|
|
212
|
-
export interface NextInjectManifestPartial {
|
|
213
|
-
/**
|
|
214
|
-
* Enables additional route caching when users navigate through pages with
|
|
215
|
-
* `next/link`. This improves the user experience in some cases but it
|
|
216
|
-
* also adds a bit of overhead due to additional network calls.
|
|
217
|
-
* @default false
|
|
218
|
-
*/
|
|
219
|
-
cacheOnNavigation?: boolean;
|
|
220
|
-
/**
|
|
221
|
-
* Whether Serwist should be disabled.
|
|
222
|
-
* @default false
|
|
223
|
-
*/
|
|
224
|
-
disable?: boolean;
|
|
225
|
-
/**
|
|
226
|
-
* Whether `@serwist/next` should automatically register the service worker for you. If
|
|
227
|
-
* you want to register the service worker yourself, set this to `false` and run
|
|
228
|
-
* `window.serwist.register()` in `componentDidMount` or `useEffect`.
|
|
229
|
-
* @example
|
|
230
|
-
* ```tsx
|
|
231
|
-
* // app/register-pwa.tsx
|
|
232
|
-
* "use client";
|
|
233
|
-
* import { useEffect } from "react";
|
|
234
|
-
* import type { Serwist } from "@serwist/window";
|
|
235
|
-
*
|
|
236
|
-
* declare global {
|
|
237
|
-
* interface Window {
|
|
238
|
-
* serwist: Serwist;
|
|
239
|
-
* }
|
|
240
|
-
* }
|
|
241
|
-
*
|
|
242
|
-
* export default function RegisterPWA() {
|
|
243
|
-
* useEffect(() => {
|
|
244
|
-
* if ("serviceWorker" in navigator && window.serwist !== undefined) {
|
|
245
|
-
* window.serwist.register();
|
|
246
|
-
* }
|
|
247
|
-
* }, []);
|
|
248
|
-
* return <></>;
|
|
249
|
-
* }
|
|
250
|
-
*
|
|
251
|
-
* // app/layout.tsx
|
|
252
|
-
* import RegisterPWA from "./register-pwa";
|
|
253
|
-
*
|
|
254
|
-
* export default function RootLayout({
|
|
255
|
-
* children,
|
|
256
|
-
* }: {
|
|
257
|
-
* children: React.ReactNode;
|
|
258
|
-
* }) {
|
|
259
|
-
* return (
|
|
260
|
-
* <html lang="en">
|
|
261
|
-
* <head />
|
|
262
|
-
* <body>
|
|
263
|
-
* <RegisterPWA />
|
|
264
|
-
* {children}
|
|
265
|
-
* </body>
|
|
266
|
-
* </html>
|
|
267
|
-
* );
|
|
268
|
-
* }
|
|
269
|
-
* ```
|
|
270
|
-
* @default true
|
|
271
|
-
*/
|
|
272
|
-
register?: boolean;
|
|
273
|
-
/**
|
|
274
|
-
* Whether Serwist should reload the app when it goes online.
|
|
275
|
-
* @default true
|
|
276
|
-
*/
|
|
277
|
-
reloadOnOnline?: boolean;
|
|
278
|
-
/**
|
|
279
|
-
* The service worker's URL scope. Set to `/foo/` so that paths under `/foo/` are under the service
|
|
280
|
-
* worker's control while others are not.
|
|
281
|
-
* @default nextConfig.basePath
|
|
282
|
-
*/
|
|
283
|
-
scope?: string;
|
|
284
|
-
/**
|
|
285
|
-
* The URL to the service worker.
|
|
286
|
-
* @default "/sw.js"
|
|
287
|
-
*/
|
|
288
|
-
swUrl?: string;
|
|
289
|
-
/**
|
|
290
|
-
* Files in the public directory matching any of these patterns
|
|
291
|
-
* will be included in the precache manifest. For more information,
|
|
292
|
-
* see [`node-glob`'s Glob Primer](https://github.com/isaacs/node-glob#glob-primer).
|
|
293
|
-
* @default
|
|
294
|
-
* ```
|
|
295
|
-
* ["**\/*"]
|
|
296
|
-
* ```
|
|
297
|
-
*/
|
|
298
|
-
globPublicPatterns?: GlobPattern | GlobPattern[];
|
|
299
|
-
}
|
|
300
|
-
export type NextInjectManifestResolved = Require<NextInjectManifestPartial, "cacheOnNavigation" | "disable" | "register" | "reloadOnOnline" | "swUrl" | "globPublicPatterns">;
|
|
301
164
|
export type GetManifestOptions = BasePartial & GlobPartial & RequiredGlobDirectoryPartial;
|
|
302
165
|
export type GetManifestOptionsComplete = BaseResolved & GlobResolved & RequiredGlobDirectoryResolved;
|
|
303
166
|
export type InjectManifestOptions = BasePartial & GlobPartial & InjectPartial & RequiredSwDestPartial & RequiredGlobDirectoryPartial;
|
|
304
167
|
export type InjectManifestOptionsComplete = BaseResolved & GlobResolved & InjectResolved & RequiredSwDestResolved & RequiredGlobDirectoryResolved;
|
|
305
|
-
export type WebpackInjectManifestOptions = BasePartial & WebpackPartial & InjectPartial & OptionalSwDestPartial & WebpackInjectManifestPartial;
|
|
306
|
-
export type WebpackInjectManifestOptionsComplete = BaseResolved & WebpackResolved & InjectResolved & OptionalSwDestResolved & WebpackInjectManifestResolved;
|
|
307
|
-
export type ViteInjectManifestOptions = BasePartial & GlobPartial & InjectPartial & RequiredSwDestPartial & RequiredGlobDirectoryPartial;
|
|
308
|
-
export type ViteInjectManifestOptionsComplete = BaseResolved & GlobResolved & InjectResolved & RequiredSwDestResolved & RequiredGlobDirectoryResolved;
|
|
309
|
-
export type NextInjectManifestOptions = Omit<WebpackInjectManifestOptions & RequiredSwDestPartial & NextInjectManifestPartial, "disablePrecacheManifest">;
|
|
310
|
-
export type NextInjectManifestOptionsComplete = Omit<WebpackInjectManifestOptionsComplete & RequiredSwDestResolved & NextInjectManifestResolved, "disablePrecacheManifest">;
|
|
311
168
|
export interface GetManifestResult {
|
|
312
169
|
count: number;
|
|
313
170
|
manifestEntries: ManifestEntry[] | undefined;
|
package/dist/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,gBAAgB,CA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AM,MAAM,0BAA0B,GAAG,YAAY,GAAG,YAAY,GAAG,6BAA6B,CAAC;AAErG,MAAM,MAAM,qBAAqB,GAAG,WAAW,GAAG,WAAW,GAAG,aAAa,GAAG,qBAAqB,GAAG,4BAA4B,CAAC;AAErI,MAAM,MAAM,6BAA6B,GAAG,YAAY,GAAG,YAAY,GAAG,cAAc,GAAG,sBAAsB,GAAG,6BAA6B,CAAC;AAElJ,MAAM,WAAW,iBAAiB;IAChC,KAAK,EAAE,MAAM,CAAC;IACd,eAAe,EAAE,aAAa,EAAE,GAAG,SAAS,CAAC;IAC7C,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,MAAM,EAAE,CAAC;CACpB;AAED,MAAM,MAAM,WAAW,GAAG,IAAI,CAAC,iBAAiB,EAAE,iBAAiB,CAAC,GAAG;IACrE,SAAS,EAAE,MAAM,EAAE,CAAC;CACrB,CAAC;AAEF;;GAEG;AACH,MAAM,WAAW,WAAW;IAC1B,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;CACd;AAED;;GAEG;AACH,MAAM,MAAM,SAAS,GAAG,KAAK,GAAG,MAAM,CAAC;AAEvC;;GAEG;AACH,MAAM,MAAM,kBAAkB,GAAG,WAAW,CAAC;AAE7C;;GAEG;AACH,MAAM,MAAM,WAAW,GAAG,aAAa,GAAG,gBAAgB,GAAG,uBAAuB,GAAG,oBAAoB,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@serwist/build",
|
|
3
|
-
"version": "9.0.0-preview.
|
|
3
|
+
"version": "9.0.0-preview.13",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "A module that integrates into your build process, helping you generate a manifest of local files that should be precached.",
|
|
6
6
|
"files": [
|
|
@@ -28,8 +28,8 @@
|
|
|
28
28
|
"types": "./dist/index.d.ts",
|
|
29
29
|
"typesVersions": {
|
|
30
30
|
"*": {
|
|
31
|
-
"
|
|
32
|
-
"./dist/index.
|
|
31
|
+
"schema": [
|
|
32
|
+
"./dist/index.schema.d.ts"
|
|
33
33
|
]
|
|
34
34
|
}
|
|
35
35
|
},
|
|
@@ -38,41 +38,33 @@
|
|
|
38
38
|
"types": "./dist/index.d.ts",
|
|
39
39
|
"default": "./dist/index.js"
|
|
40
40
|
},
|
|
41
|
-
"./
|
|
42
|
-
"types": "./dist/index.
|
|
43
|
-
"default": "./dist/index.
|
|
41
|
+
"./schema": {
|
|
42
|
+
"types": "./dist/index.schema.d.ts",
|
|
43
|
+
"default": "./dist/index.schema.js"
|
|
44
44
|
},
|
|
45
45
|
"./package.json": "./package.json"
|
|
46
46
|
},
|
|
47
47
|
"dependencies": {
|
|
48
48
|
"common-tags": "1.8.2",
|
|
49
|
-
"fast-glob": "3.3.2",
|
|
50
49
|
"fast-json-stable-stringify": "2.1.0",
|
|
51
50
|
"fs-extra": "11.2.0",
|
|
52
51
|
"glob": "10.3.10",
|
|
53
52
|
"pretty-bytes": "6.1.1",
|
|
54
|
-
"rollup": "4.
|
|
53
|
+
"rollup": "4.12.0",
|
|
55
54
|
"source-map": "0.8.0-beta.0",
|
|
56
55
|
"upath": "2.0.1",
|
|
57
56
|
"zod": "3.22.4",
|
|
58
|
-
"@serwist/
|
|
59
|
-
"@serwist/broadcast-update": "9.0.0-preview.11",
|
|
60
|
-
"@serwist/cacheable-response": "9.0.0-preview.11",
|
|
61
|
-
"@serwist/core": "9.0.0-preview.11",
|
|
62
|
-
"@serwist/expiration": "9.0.0-preview.11",
|
|
63
|
-
"@serwist/google-analytics": "9.0.0-preview.11",
|
|
64
|
-
"@serwist/precaching": "9.0.0-preview.11",
|
|
65
|
-
"@serwist/routing": "9.0.0-preview.11"
|
|
57
|
+
"@serwist/core": "9.0.0-preview.13"
|
|
66
58
|
},
|
|
67
59
|
"devDependencies": {
|
|
68
60
|
"@types/common-tags": "1.8.4",
|
|
69
61
|
"@types/fs-extra": "11.0.4",
|
|
70
|
-
"@types/node": "20.11.
|
|
62
|
+
"@types/node": "20.11.24",
|
|
71
63
|
"@types/stringify-object": "4.0.5",
|
|
72
|
-
"type-fest": "4.
|
|
73
|
-
"typescript": "5.
|
|
74
|
-
"@serwist/constants": "9.0.0-preview.
|
|
75
|
-
"@serwist/utils": "9.0.0-preview.
|
|
64
|
+
"type-fest": "4.11.0",
|
|
65
|
+
"typescript": "5.5.0-dev.20240304",
|
|
66
|
+
"@serwist/constants": "9.0.0-preview.13",
|
|
67
|
+
"@serwist/utils": "9.0.0-preview.13"
|
|
76
68
|
},
|
|
77
69
|
"peerDependencies": {
|
|
78
70
|
"typescript": ">=5.0.0"
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { type Assignable, type Equals, assertType } from "./schema/assertType.js";
|
|
2
|
+
import { basePartial } from "./schema/base.js";
|
|
3
|
+
import { getManifestOptions } from "./schema/getManifest.js";
|
|
4
|
+
import { globPartial, optionalGlobDirectoryPartial, requiredGlobDirectoryPartial } from "./schema/glob.js";
|
|
5
|
+
import { baseInjectPartial, injectManifestOptions } from "./schema/injectManifest.js";
|
|
6
|
+
import { manifestEntry } from "./schema/manifestEntry.js";
|
|
7
|
+
import { manifestTransform, manifestTransformResult } from "./schema/manifestTransform.js";
|
|
8
|
+
import { SerwistConfigError } from "./schema/serwistConfigError.js";
|
|
9
|
+
import { optionalSwDestPartial, requiredSwDestPartial } from "./schema/swDest.js";
|
|
10
|
+
import { validationErrorMap } from "./schema/validationErrorMap.js";
|
|
11
|
+
|
|
12
|
+
export {
|
|
13
|
+
assertType,
|
|
14
|
+
basePartial,
|
|
15
|
+
globPartial,
|
|
16
|
+
baseInjectPartial as injectPartial,
|
|
17
|
+
injectManifestOptions,
|
|
18
|
+
getManifestOptions,
|
|
19
|
+
manifestEntry,
|
|
20
|
+
manifestTransform,
|
|
21
|
+
manifestTransformResult,
|
|
22
|
+
optionalGlobDirectoryPartial,
|
|
23
|
+
requiredGlobDirectoryPartial,
|
|
24
|
+
optionalSwDestPartial,
|
|
25
|
+
requiredSwDestPartial,
|
|
26
|
+
validationErrorMap,
|
|
27
|
+
SerwistConfigError,
|
|
28
|
+
};
|
|
29
|
+
export type { Assignable, Equals };
|
package/src/index.ts
CHANGED
|
@@ -17,7 +17,7 @@ import { rebasePath } from "./lib/rebase-path.js";
|
|
|
17
17
|
import { replaceAndUpdateSourceMap } from "./lib/replace-and-update-source-map.js";
|
|
18
18
|
import { transformManifest } from "./lib/transform-manifest.js";
|
|
19
19
|
import { translateURLToSourcemapPaths } from "./lib/translate-url-to-sourcemap-paths.js";
|
|
20
|
-
import {
|
|
20
|
+
import { validateGetManifestOptions, validateInjectManifestOptions } from "./lib/validate-options.js";
|
|
21
21
|
|
|
22
22
|
export {
|
|
23
23
|
errors,
|
|
@@ -31,9 +31,8 @@ export {
|
|
|
31
31
|
stringify,
|
|
32
32
|
transformManifest,
|
|
33
33
|
translateURLToSourcemapPaths,
|
|
34
|
+
validateGetManifestOptions,
|
|
34
35
|
validateInjectManifestOptions,
|
|
35
|
-
validateViteInjectManifestOptions,
|
|
36
|
-
validateWebpackInjectManifestOptions,
|
|
37
36
|
};
|
|
38
37
|
|
|
39
38
|
export type * from "./types.js";
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { SerwistConfigError } from "../schema/serwistConfigError.js";
|
|
1
2
|
/*
|
|
2
3
|
Copyright 2021 Google LLC
|
|
3
4
|
|
|
@@ -6,13 +7,7 @@
|
|
|
6
7
|
https://opensource.org/licenses/MIT.
|
|
7
8
|
*/
|
|
8
9
|
import { validationErrorMap } from "../schema/validationErrorMap.js";
|
|
9
|
-
import type {
|
|
10
|
-
GetManifestOptionsComplete,
|
|
11
|
-
InjectManifestOptionsComplete,
|
|
12
|
-
ViteInjectManifestOptionsComplete,
|
|
13
|
-
WebpackInjectManifestOptionsComplete,
|
|
14
|
-
} from "../types.js";
|
|
15
|
-
import { SerwistConfigError } from "./serwist-config-error.js";
|
|
10
|
+
import type { GetManifestOptionsComplete, InjectManifestOptionsComplete } from "../types.js";
|
|
16
11
|
|
|
17
12
|
export const validateGetManifestOptions = async (input: unknown): Promise<GetManifestOptionsComplete> => {
|
|
18
13
|
const result = await (await import("../schema/getManifest.js")).getManifestOptions.spa(input, { errorMap: validationErrorMap });
|
|
@@ -29,19 +24,3 @@ export const validateInjectManifestOptions = async (input: unknown): Promise<Inj
|
|
|
29
24
|
}
|
|
30
25
|
return result.data;
|
|
31
26
|
};
|
|
32
|
-
|
|
33
|
-
export const validateWebpackInjectManifestOptions = async (input: unknown): Promise<WebpackInjectManifestOptionsComplete> => {
|
|
34
|
-
const result = await (await import("../schema/webpack.js")).webpackInjectManifestOptions.spa(input, { errorMap: validationErrorMap });
|
|
35
|
-
if (!result.success) {
|
|
36
|
-
throw new SerwistConfigError({ moduleName: "@serwist/webpack-plugin", message: JSON.stringify(result.error.format(), null, 2) });
|
|
37
|
-
}
|
|
38
|
-
return result.data;
|
|
39
|
-
};
|
|
40
|
-
|
|
41
|
-
export const validateViteInjectManifestOptions = async (input: unknown): Promise<ViteInjectManifestOptionsComplete> => {
|
|
42
|
-
const result = await (await import("../schema/vite.js")).viteInjectManifestOptions.spa(input, { errorMap: validationErrorMap });
|
|
43
|
-
if (!result.success) {
|
|
44
|
-
throw new SerwistConfigError({ moduleName: "@serwist/vite", message: JSON.stringify(result.error.format(), null, 2) });
|
|
45
|
-
}
|
|
46
|
-
return result.data;
|
|
47
|
-
};
|
package/src/schema/assertType.ts
CHANGED
|
@@ -5,7 +5,7 @@ import { basePartial } from "./base.js";
|
|
|
5
5
|
import { globPartial, requiredGlobDirectoryPartial } from "./glob.js";
|
|
6
6
|
import { requiredSwDestPartial } from "./swDest.js";
|
|
7
7
|
|
|
8
|
-
export const
|
|
8
|
+
export const baseInjectPartial = z
|
|
9
9
|
.object({
|
|
10
10
|
injectionPoint: z.string().default("self.__SW_MANIFEST"),
|
|
11
11
|
swSrc: z.string(),
|
|
@@ -14,12 +14,12 @@ export const injectPartial = z
|
|
|
14
14
|
|
|
15
15
|
export const injectManifestOptions = basePartial
|
|
16
16
|
.merge(globPartial)
|
|
17
|
-
.merge(
|
|
17
|
+
.merge(baseInjectPartial)
|
|
18
18
|
.merge(requiredSwDestPartial)
|
|
19
19
|
.merge(requiredGlobDirectoryPartial)
|
|
20
20
|
.strict("Do not pass invalid properties to InjectManifestOptions!");
|
|
21
21
|
|
|
22
|
-
assertType<Equals<InjectPartial, z.input<typeof
|
|
23
|
-
assertType<Equals<InjectResolved, z.output<typeof
|
|
22
|
+
assertType<Equals<InjectPartial, z.input<typeof baseInjectPartial>>>();
|
|
23
|
+
assertType<Equals<InjectResolved, z.output<typeof baseInjectPartial>>>();
|
|
24
24
|
assertType<Equals<InjectManifestOptions, z.input<typeof injectManifestOptions>>>();
|
|
25
25
|
assertType<Equals<InjectManifestOptionsComplete, z.output<typeof injectManifestOptions>>>();
|