@serwist/next 8.4.3 → 9.0.0-preview.0
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/index.d.ts +5 -4
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +51 -43
- package/dist/index.worker.d.ts +5 -0
- package/dist/index.worker.d.ts.map +1 -0
- package/dist/{index.browser.cjs → index.worker.js} +57 -22
- package/dist/internal-types.d.ts +6 -0
- package/dist/internal-types.d.ts.map +1 -0
- package/dist/sw-entry-worker.d.ts +1 -0
- package/dist/sw-entry-worker.d.ts.map +1 -0
- package/dist/sw-entry.d.ts +1 -0
- package/dist/sw-entry.d.ts.map +1 -0
- package/dist/utils/find-first-truthy.d.ts +1 -0
- package/dist/utils/find-first-truthy.d.ts.map +1 -0
- package/dist/utils/get-content-hash.d.ts +1 -0
- package/dist/utils/get-content-hash.d.ts.map +1 -0
- package/dist/utils/get-file-hash.d.ts +1 -0
- package/dist/utils/get-file-hash.d.ts.map +1 -0
- package/dist/utils/get-package-version.d.ts +1 -0
- package/dist/utils/get-package-version.d.ts.map +1 -0
- package/dist/utils/index.d.ts +1 -0
- package/dist/utils/index.d.ts.map +1 -0
- package/dist/utils/load-tsconfig.d.ts +1 -0
- package/dist/utils/load-tsconfig.d.ts.map +1 -0
- package/dist/utils/logger.d.ts +1 -0
- package/dist/utils/logger.d.ts.map +1 -0
- package/dist/utils.d.ts +1 -0
- package/dist/utils.d.ts.map +1 -0
- package/dist/worker/defaultCache.d.ts +3 -0
- package/dist/worker/defaultCache.d.ts.map +1 -0
- package/dist/worker/definePageRuntimeCaching.d.ts +16 -0
- package/dist/worker/definePageRuntimeCaching.d.ts.map +1 -0
- package/package.json +47 -49
- package/src/index.ts +241 -0
- package/src/index.worker.ts +5 -0
- package/src/internal-types.ts +17 -0
- package/src/sw-entry-worker.ts +46 -0
- package/src/sw-entry.ts +64 -0
- package/src/utils/find-first-truthy.ts +15 -0
- package/src/utils/get-content-hash.ts +10 -0
- package/src/utils/get-file-hash.ts +4 -0
- package/src/utils/get-package-version.ts +16 -0
- package/src/utils/load-tsconfig.ts +27 -0
- package/src/utils/logger.ts +57 -0
- package/src/utils.ts +11 -0
- package/src/worker/defaultCache.ts +223 -0
- package/src/worker/definePageRuntimeCaching.ts +36 -0
- package/dist/index.browser.d.cts +0 -2
- package/dist/index.browser.d.ts +0 -2
- package/dist/index.browser.js +0 -208
- package/dist/index.cjs +0 -933
- package/dist/index.d.cts +0 -5
- package/dist/internal-types.d.cts +0 -9
- package/dist/sw-entry-worker.cjs +0 -35
- package/dist/sw-entry-worker.d.cts +0 -7
- package/dist/sw-entry.cjs +0 -43
- package/dist/sw-entry.d.cts +0 -6
- package/dist/types.d.cts +0 -81
- package/dist/types.d.ts +0 -81
- package/dist/utils/find-first-truthy.d.cts +0 -7
- package/dist/utils/get-content-hash.d.cts +0 -3
- package/dist/utils/get-file-hash.d.cts +0 -3
- package/dist/utils/get-package-version.d.cts +0 -6
- package/dist/utils/load-tsconfig.d.cts +0 -2
- package/dist/utils/logger.d.cts +0 -5
- package/dist/utils.d.cts +0 -0
- /package/{dist/utils/index.d.cts → src/utils/index.ts} +0 -0
package/dist/index.cjs
DELETED
|
@@ -1,933 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
-
|
|
5
|
-
var path = require('node:path');
|
|
6
|
-
var node_url = require('node:url');
|
|
7
|
-
var webpackPlugin = require('@serwist/webpack-plugin');
|
|
8
|
-
var internal = require('@serwist/webpack-plugin/internal');
|
|
9
|
-
var cleanWebpackPlugin = require('clean-webpack-plugin');
|
|
10
|
-
var fg = require('fast-glob');
|
|
11
|
-
var crypto = require('node:crypto');
|
|
12
|
-
var fs = require('node:fs');
|
|
13
|
-
var node_module = require('node:module');
|
|
14
|
-
var process = require('node:process');
|
|
15
|
-
var os = require('node:os');
|
|
16
|
-
var tty = require('node:tty');
|
|
17
|
-
|
|
18
|
-
var _documentCurrentScript = typeof document !== 'undefined' ? document.currentScript : null;
|
|
19
|
-
/**
|
|
20
|
-
* Find the first truthy value in an array.
|
|
21
|
-
* @param arr
|
|
22
|
-
* @param fn
|
|
23
|
-
* @returns
|
|
24
|
-
*/ const findFirstTruthy = (arr, fn)=>{
|
|
25
|
-
for (const i of arr){
|
|
26
|
-
const resolved = fn(i);
|
|
27
|
-
if (resolved) {
|
|
28
|
-
return resolved;
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
return undefined;
|
|
32
|
-
};
|
|
33
|
-
|
|
34
|
-
const getFileHash = (file)=>crypto.createHash("md5").update(fs.readFileSync(file)).digest("hex");
|
|
35
|
-
|
|
36
|
-
const getContentHash = (file, isDev)=>{
|
|
37
|
-
if (isDev) {
|
|
38
|
-
return "development";
|
|
39
|
-
}
|
|
40
|
-
return getFileHash(file).slice(0, 16);
|
|
41
|
-
};
|
|
42
|
-
|
|
43
|
-
node_module.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.src || new URL('index.cjs', document.baseURI).href)));
|
|
44
|
-
|
|
45
|
-
const loadTSConfig = (baseDir, relativeTSConfigPath)=>{
|
|
46
|
-
try {
|
|
47
|
-
// Find tsconfig.json file
|
|
48
|
-
const tsConfigPath = findFirstTruthy([
|
|
49
|
-
relativeTSConfigPath ?? "tsconfig.json",
|
|
50
|
-
"jsconfig.json"
|
|
51
|
-
], (filePath)=>{
|
|
52
|
-
const resolvedPath = path.join(baseDir, filePath);
|
|
53
|
-
return fs.existsSync(resolvedPath) ? resolvedPath : undefined;
|
|
54
|
-
});
|
|
55
|
-
if (!tsConfigPath) {
|
|
56
|
-
return undefined;
|
|
57
|
-
}
|
|
58
|
-
// Read tsconfig.json file
|
|
59
|
-
const tsConfigFile = JSON.parse(fs.readFileSync(tsConfigPath, "utf-8"));
|
|
60
|
-
return tsConfigFile;
|
|
61
|
-
} catch {
|
|
62
|
-
return undefined;
|
|
63
|
-
}
|
|
64
|
-
};
|
|
65
|
-
|
|
66
|
-
const ANSI_BACKGROUND_OFFSET = 10;
|
|
67
|
-
const wrapAnsi16 = (offset = 0)=>(code)=>`\u001B[${code + offset}m`;
|
|
68
|
-
const wrapAnsi256 = (offset = 0)=>(code)=>`\u001B[${38 + offset};5;${code}m`;
|
|
69
|
-
const wrapAnsi16m = (offset = 0)=>(red, green, blue)=>`\u001B[${38 + offset};2;${red};${green};${blue}m`;
|
|
70
|
-
const styles$1 = {
|
|
71
|
-
modifier: {
|
|
72
|
-
reset: [
|
|
73
|
-
0,
|
|
74
|
-
0
|
|
75
|
-
],
|
|
76
|
-
// 21 isn't widely supported and 22 does the same thing
|
|
77
|
-
bold: [
|
|
78
|
-
1,
|
|
79
|
-
22
|
|
80
|
-
],
|
|
81
|
-
dim: [
|
|
82
|
-
2,
|
|
83
|
-
22
|
|
84
|
-
],
|
|
85
|
-
italic: [
|
|
86
|
-
3,
|
|
87
|
-
23
|
|
88
|
-
],
|
|
89
|
-
underline: [
|
|
90
|
-
4,
|
|
91
|
-
24
|
|
92
|
-
],
|
|
93
|
-
overline: [
|
|
94
|
-
53,
|
|
95
|
-
55
|
|
96
|
-
],
|
|
97
|
-
inverse: [
|
|
98
|
-
7,
|
|
99
|
-
27
|
|
100
|
-
],
|
|
101
|
-
hidden: [
|
|
102
|
-
8,
|
|
103
|
-
28
|
|
104
|
-
],
|
|
105
|
-
strikethrough: [
|
|
106
|
-
9,
|
|
107
|
-
29
|
|
108
|
-
]
|
|
109
|
-
},
|
|
110
|
-
color: {
|
|
111
|
-
black: [
|
|
112
|
-
30,
|
|
113
|
-
39
|
|
114
|
-
],
|
|
115
|
-
red: [
|
|
116
|
-
31,
|
|
117
|
-
39
|
|
118
|
-
],
|
|
119
|
-
green: [
|
|
120
|
-
32,
|
|
121
|
-
39
|
|
122
|
-
],
|
|
123
|
-
yellow: [
|
|
124
|
-
33,
|
|
125
|
-
39
|
|
126
|
-
],
|
|
127
|
-
blue: [
|
|
128
|
-
34,
|
|
129
|
-
39
|
|
130
|
-
],
|
|
131
|
-
magenta: [
|
|
132
|
-
35,
|
|
133
|
-
39
|
|
134
|
-
],
|
|
135
|
-
cyan: [
|
|
136
|
-
36,
|
|
137
|
-
39
|
|
138
|
-
],
|
|
139
|
-
white: [
|
|
140
|
-
37,
|
|
141
|
-
39
|
|
142
|
-
],
|
|
143
|
-
// Bright color
|
|
144
|
-
blackBright: [
|
|
145
|
-
90,
|
|
146
|
-
39
|
|
147
|
-
],
|
|
148
|
-
gray: [
|
|
149
|
-
90,
|
|
150
|
-
39
|
|
151
|
-
],
|
|
152
|
-
grey: [
|
|
153
|
-
90,
|
|
154
|
-
39
|
|
155
|
-
],
|
|
156
|
-
redBright: [
|
|
157
|
-
91,
|
|
158
|
-
39
|
|
159
|
-
],
|
|
160
|
-
greenBright: [
|
|
161
|
-
92,
|
|
162
|
-
39
|
|
163
|
-
],
|
|
164
|
-
yellowBright: [
|
|
165
|
-
93,
|
|
166
|
-
39
|
|
167
|
-
],
|
|
168
|
-
blueBright: [
|
|
169
|
-
94,
|
|
170
|
-
39
|
|
171
|
-
],
|
|
172
|
-
magentaBright: [
|
|
173
|
-
95,
|
|
174
|
-
39
|
|
175
|
-
],
|
|
176
|
-
cyanBright: [
|
|
177
|
-
96,
|
|
178
|
-
39
|
|
179
|
-
],
|
|
180
|
-
whiteBright: [
|
|
181
|
-
97,
|
|
182
|
-
39
|
|
183
|
-
]
|
|
184
|
-
},
|
|
185
|
-
bgColor: {
|
|
186
|
-
bgBlack: [
|
|
187
|
-
40,
|
|
188
|
-
49
|
|
189
|
-
],
|
|
190
|
-
bgRed: [
|
|
191
|
-
41,
|
|
192
|
-
49
|
|
193
|
-
],
|
|
194
|
-
bgGreen: [
|
|
195
|
-
42,
|
|
196
|
-
49
|
|
197
|
-
],
|
|
198
|
-
bgYellow: [
|
|
199
|
-
43,
|
|
200
|
-
49
|
|
201
|
-
],
|
|
202
|
-
bgBlue: [
|
|
203
|
-
44,
|
|
204
|
-
49
|
|
205
|
-
],
|
|
206
|
-
bgMagenta: [
|
|
207
|
-
45,
|
|
208
|
-
49
|
|
209
|
-
],
|
|
210
|
-
bgCyan: [
|
|
211
|
-
46,
|
|
212
|
-
49
|
|
213
|
-
],
|
|
214
|
-
bgWhite: [
|
|
215
|
-
47,
|
|
216
|
-
49
|
|
217
|
-
],
|
|
218
|
-
// Bright color
|
|
219
|
-
bgBlackBright: [
|
|
220
|
-
100,
|
|
221
|
-
49
|
|
222
|
-
],
|
|
223
|
-
bgGray: [
|
|
224
|
-
100,
|
|
225
|
-
49
|
|
226
|
-
],
|
|
227
|
-
bgGrey: [
|
|
228
|
-
100,
|
|
229
|
-
49
|
|
230
|
-
],
|
|
231
|
-
bgRedBright: [
|
|
232
|
-
101,
|
|
233
|
-
49
|
|
234
|
-
],
|
|
235
|
-
bgGreenBright: [
|
|
236
|
-
102,
|
|
237
|
-
49
|
|
238
|
-
],
|
|
239
|
-
bgYellowBright: [
|
|
240
|
-
103,
|
|
241
|
-
49
|
|
242
|
-
],
|
|
243
|
-
bgBlueBright: [
|
|
244
|
-
104,
|
|
245
|
-
49
|
|
246
|
-
],
|
|
247
|
-
bgMagentaBright: [
|
|
248
|
-
105,
|
|
249
|
-
49
|
|
250
|
-
],
|
|
251
|
-
bgCyanBright: [
|
|
252
|
-
106,
|
|
253
|
-
49
|
|
254
|
-
],
|
|
255
|
-
bgWhiteBright: [
|
|
256
|
-
107,
|
|
257
|
-
49
|
|
258
|
-
]
|
|
259
|
-
}
|
|
260
|
-
};
|
|
261
|
-
Object.keys(styles$1.modifier);
|
|
262
|
-
const foregroundColorNames = Object.keys(styles$1.color);
|
|
263
|
-
const backgroundColorNames = Object.keys(styles$1.bgColor);
|
|
264
|
-
[
|
|
265
|
-
...foregroundColorNames,
|
|
266
|
-
...backgroundColorNames
|
|
267
|
-
];
|
|
268
|
-
function assembleStyles() {
|
|
269
|
-
const codes = new Map();
|
|
270
|
-
for (const [groupName, group] of Object.entries(styles$1)){
|
|
271
|
-
for (const [styleName, style] of Object.entries(group)){
|
|
272
|
-
styles$1[styleName] = {
|
|
273
|
-
open: `\u001B[${style[0]}m`,
|
|
274
|
-
close: `\u001B[${style[1]}m`
|
|
275
|
-
};
|
|
276
|
-
group[styleName] = styles$1[styleName];
|
|
277
|
-
codes.set(style[0], style[1]);
|
|
278
|
-
}
|
|
279
|
-
Object.defineProperty(styles$1, groupName, {
|
|
280
|
-
value: group,
|
|
281
|
-
enumerable: false
|
|
282
|
-
});
|
|
283
|
-
}
|
|
284
|
-
Object.defineProperty(styles$1, 'codes', {
|
|
285
|
-
value: codes,
|
|
286
|
-
enumerable: false
|
|
287
|
-
});
|
|
288
|
-
styles$1.color.close = '\u001B[39m';
|
|
289
|
-
styles$1.bgColor.close = '\u001B[49m';
|
|
290
|
-
styles$1.color.ansi = wrapAnsi16();
|
|
291
|
-
styles$1.color.ansi256 = wrapAnsi256();
|
|
292
|
-
styles$1.color.ansi16m = wrapAnsi16m();
|
|
293
|
-
styles$1.bgColor.ansi = wrapAnsi16(ANSI_BACKGROUND_OFFSET);
|
|
294
|
-
styles$1.bgColor.ansi256 = wrapAnsi256(ANSI_BACKGROUND_OFFSET);
|
|
295
|
-
styles$1.bgColor.ansi16m = wrapAnsi16m(ANSI_BACKGROUND_OFFSET);
|
|
296
|
-
// From https://github.com/Qix-/color-convert/blob/3f0e0d4e92e235796ccb17f6e85c72094a651f49/conversions.js
|
|
297
|
-
Object.defineProperties(styles$1, {
|
|
298
|
-
rgbToAnsi256: {
|
|
299
|
-
value (red, green, blue) {
|
|
300
|
-
// We use the extended greyscale palette here, with the exception of
|
|
301
|
-
// black and white. normal palette only has 4 greyscale shades.
|
|
302
|
-
if (red === green && green === blue) {
|
|
303
|
-
if (red < 8) {
|
|
304
|
-
return 16;
|
|
305
|
-
}
|
|
306
|
-
if (red > 248) {
|
|
307
|
-
return 231;
|
|
308
|
-
}
|
|
309
|
-
return Math.round((red - 8) / 247 * 24) + 232;
|
|
310
|
-
}
|
|
311
|
-
return 16 + 36 * Math.round(red / 255 * 5) + 6 * Math.round(green / 255 * 5) + Math.round(blue / 255 * 5);
|
|
312
|
-
},
|
|
313
|
-
enumerable: false
|
|
314
|
-
},
|
|
315
|
-
hexToRgb: {
|
|
316
|
-
value (hex) {
|
|
317
|
-
const matches = /[a-f\d]{6}|[a-f\d]{3}/i.exec(hex.toString(16));
|
|
318
|
-
if (!matches) {
|
|
319
|
-
return [
|
|
320
|
-
0,
|
|
321
|
-
0,
|
|
322
|
-
0
|
|
323
|
-
];
|
|
324
|
-
}
|
|
325
|
-
let [colorString] = matches;
|
|
326
|
-
if (colorString.length === 3) {
|
|
327
|
-
colorString = [
|
|
328
|
-
...colorString
|
|
329
|
-
].map((character)=>character + character).join('');
|
|
330
|
-
}
|
|
331
|
-
const integer = Number.parseInt(colorString, 16);
|
|
332
|
-
return [
|
|
333
|
-
/* eslint-disable no-bitwise */ integer >> 16 & 0xFF,
|
|
334
|
-
integer >> 8 & 0xFF,
|
|
335
|
-
integer & 0xFF
|
|
336
|
-
];
|
|
337
|
-
},
|
|
338
|
-
enumerable: false
|
|
339
|
-
},
|
|
340
|
-
hexToAnsi256: {
|
|
341
|
-
value: (hex)=>styles$1.rgbToAnsi256(...styles$1.hexToRgb(hex)),
|
|
342
|
-
enumerable: false
|
|
343
|
-
},
|
|
344
|
-
ansi256ToAnsi: {
|
|
345
|
-
value (code) {
|
|
346
|
-
if (code < 8) {
|
|
347
|
-
return 30 + code;
|
|
348
|
-
}
|
|
349
|
-
if (code < 16) {
|
|
350
|
-
return 90 + (code - 8);
|
|
351
|
-
}
|
|
352
|
-
let red;
|
|
353
|
-
let green;
|
|
354
|
-
let blue;
|
|
355
|
-
if (code >= 232) {
|
|
356
|
-
red = ((code - 232) * 10 + 8) / 255;
|
|
357
|
-
green = red;
|
|
358
|
-
blue = red;
|
|
359
|
-
} else {
|
|
360
|
-
code -= 16;
|
|
361
|
-
const remainder = code % 36;
|
|
362
|
-
red = Math.floor(code / 36) / 5;
|
|
363
|
-
green = Math.floor(remainder / 6) / 5;
|
|
364
|
-
blue = remainder % 6 / 5;
|
|
365
|
-
}
|
|
366
|
-
const value = Math.max(red, green, blue) * 2;
|
|
367
|
-
if (value === 0) {
|
|
368
|
-
return 30;
|
|
369
|
-
}
|
|
370
|
-
// eslint-disable-next-line no-bitwise
|
|
371
|
-
let result = 30 + (Math.round(blue) << 2 | Math.round(green) << 1 | Math.round(red));
|
|
372
|
-
if (value === 2) {
|
|
373
|
-
result += 60;
|
|
374
|
-
}
|
|
375
|
-
return result;
|
|
376
|
-
},
|
|
377
|
-
enumerable: false
|
|
378
|
-
},
|
|
379
|
-
rgbToAnsi: {
|
|
380
|
-
value: (red, green, blue)=>styles$1.ansi256ToAnsi(styles$1.rgbToAnsi256(red, green, blue)),
|
|
381
|
-
enumerable: false
|
|
382
|
-
},
|
|
383
|
-
hexToAnsi: {
|
|
384
|
-
value: (hex)=>styles$1.ansi256ToAnsi(styles$1.hexToAnsi256(hex)),
|
|
385
|
-
enumerable: false
|
|
386
|
-
}
|
|
387
|
-
});
|
|
388
|
-
return styles$1;
|
|
389
|
-
}
|
|
390
|
-
const ansiStyles = assembleStyles();
|
|
391
|
-
|
|
392
|
-
// From: https://github.com/sindresorhus/has-flag/blob/main/index.js
|
|
393
|
-
/// function hasFlag(flag, argv = globalThis.Deno?.args ?? process.argv) {
|
|
394
|
-
function hasFlag(flag, argv = globalThis.Deno ? globalThis.Deno.args : process.argv) {
|
|
395
|
-
const prefix = flag.startsWith('-') ? '' : flag.length === 1 ? '-' : '--';
|
|
396
|
-
const position = argv.indexOf(prefix + flag);
|
|
397
|
-
const terminatorPosition = argv.indexOf('--');
|
|
398
|
-
return position !== -1 && (terminatorPosition === -1 || position < terminatorPosition);
|
|
399
|
-
}
|
|
400
|
-
const { env } = process;
|
|
401
|
-
let flagForceColor;
|
|
402
|
-
if (hasFlag('no-color') || hasFlag('no-colors') || hasFlag('color=false') || hasFlag('color=never')) {
|
|
403
|
-
flagForceColor = 0;
|
|
404
|
-
} else if (hasFlag('color') || hasFlag('colors') || hasFlag('color=true') || hasFlag('color=always')) {
|
|
405
|
-
flagForceColor = 1;
|
|
406
|
-
}
|
|
407
|
-
function envForceColor() {
|
|
408
|
-
if ('FORCE_COLOR' in env) {
|
|
409
|
-
if (env.FORCE_COLOR === 'true') {
|
|
410
|
-
return 1;
|
|
411
|
-
}
|
|
412
|
-
if (env.FORCE_COLOR === 'false') {
|
|
413
|
-
return 0;
|
|
414
|
-
}
|
|
415
|
-
return env.FORCE_COLOR.length === 0 ? 1 : Math.min(Number.parseInt(env.FORCE_COLOR, 10), 3);
|
|
416
|
-
}
|
|
417
|
-
}
|
|
418
|
-
function translateLevel(level) {
|
|
419
|
-
if (level === 0) {
|
|
420
|
-
return false;
|
|
421
|
-
}
|
|
422
|
-
return {
|
|
423
|
-
level,
|
|
424
|
-
hasBasic: true,
|
|
425
|
-
has256: level >= 2,
|
|
426
|
-
has16m: level >= 3
|
|
427
|
-
};
|
|
428
|
-
}
|
|
429
|
-
function _supportsColor(haveStream, { streamIsTTY, sniffFlags = true } = {}) {
|
|
430
|
-
const noFlagForceColor = envForceColor();
|
|
431
|
-
if (noFlagForceColor !== undefined) {
|
|
432
|
-
flagForceColor = noFlagForceColor;
|
|
433
|
-
}
|
|
434
|
-
const forceColor = sniffFlags ? flagForceColor : noFlagForceColor;
|
|
435
|
-
if (forceColor === 0) {
|
|
436
|
-
return 0;
|
|
437
|
-
}
|
|
438
|
-
if (sniffFlags) {
|
|
439
|
-
if (hasFlag('color=16m') || hasFlag('color=full') || hasFlag('color=truecolor')) {
|
|
440
|
-
return 3;
|
|
441
|
-
}
|
|
442
|
-
if (hasFlag('color=256')) {
|
|
443
|
-
return 2;
|
|
444
|
-
}
|
|
445
|
-
}
|
|
446
|
-
// Check for Azure DevOps pipelines.
|
|
447
|
-
// Has to be above the `!streamIsTTY` check.
|
|
448
|
-
if ('TF_BUILD' in env && 'AGENT_NAME' in env) {
|
|
449
|
-
return 1;
|
|
450
|
-
}
|
|
451
|
-
if (haveStream && !streamIsTTY && forceColor === undefined) {
|
|
452
|
-
return 0;
|
|
453
|
-
}
|
|
454
|
-
const min = forceColor || 0;
|
|
455
|
-
if (env.TERM === 'dumb') {
|
|
456
|
-
return min;
|
|
457
|
-
}
|
|
458
|
-
if (process.platform === 'win32') {
|
|
459
|
-
// Windows 10 build 10586 is the first Windows release that supports 256 colors.
|
|
460
|
-
// Windows 10 build 14931 is the first release that supports 16m/TrueColor.
|
|
461
|
-
const osRelease = os.release().split('.');
|
|
462
|
-
if (Number(osRelease[0]) >= 10 && Number(osRelease[2]) >= 10_586) {
|
|
463
|
-
return Number(osRelease[2]) >= 14_931 ? 3 : 2;
|
|
464
|
-
}
|
|
465
|
-
return 1;
|
|
466
|
-
}
|
|
467
|
-
if ('CI' in env) {
|
|
468
|
-
if ('GITHUB_ACTIONS' in env || 'GITEA_ACTIONS' in env) {
|
|
469
|
-
return 3;
|
|
470
|
-
}
|
|
471
|
-
if ([
|
|
472
|
-
'TRAVIS',
|
|
473
|
-
'CIRCLECI',
|
|
474
|
-
'APPVEYOR',
|
|
475
|
-
'GITLAB_CI',
|
|
476
|
-
'BUILDKITE',
|
|
477
|
-
'DRONE'
|
|
478
|
-
].some((sign)=>sign in env) || env.CI_NAME === 'codeship') {
|
|
479
|
-
return 1;
|
|
480
|
-
}
|
|
481
|
-
return min;
|
|
482
|
-
}
|
|
483
|
-
if ('TEAMCITY_VERSION' in env) {
|
|
484
|
-
return /^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(env.TEAMCITY_VERSION) ? 1 : 0;
|
|
485
|
-
}
|
|
486
|
-
if (env.COLORTERM === 'truecolor') {
|
|
487
|
-
return 3;
|
|
488
|
-
}
|
|
489
|
-
if (env.TERM === 'xterm-kitty') {
|
|
490
|
-
return 3;
|
|
491
|
-
}
|
|
492
|
-
if ('TERM_PROGRAM' in env) {
|
|
493
|
-
const version = Number.parseInt((env.TERM_PROGRAM_VERSION || '').split('.')[0], 10);
|
|
494
|
-
switch(env.TERM_PROGRAM){
|
|
495
|
-
case 'iTerm.app':
|
|
496
|
-
{
|
|
497
|
-
return version >= 3 ? 3 : 2;
|
|
498
|
-
}
|
|
499
|
-
case 'Apple_Terminal':
|
|
500
|
-
{
|
|
501
|
-
return 2;
|
|
502
|
-
}
|
|
503
|
-
}
|
|
504
|
-
}
|
|
505
|
-
if (/-256(color)?$/i.test(env.TERM)) {
|
|
506
|
-
return 2;
|
|
507
|
-
}
|
|
508
|
-
if (/^screen|^xterm|^vt100|^vt220|^rxvt|color|ansi|cygwin|linux/i.test(env.TERM)) {
|
|
509
|
-
return 1;
|
|
510
|
-
}
|
|
511
|
-
if ('COLORTERM' in env) {
|
|
512
|
-
return 1;
|
|
513
|
-
}
|
|
514
|
-
return min;
|
|
515
|
-
}
|
|
516
|
-
function createSupportsColor(stream, options = {}) {
|
|
517
|
-
const level = _supportsColor(stream, {
|
|
518
|
-
streamIsTTY: stream && stream.isTTY,
|
|
519
|
-
...options
|
|
520
|
-
});
|
|
521
|
-
return translateLevel(level);
|
|
522
|
-
}
|
|
523
|
-
const supportsColor = {
|
|
524
|
-
stdout: createSupportsColor({
|
|
525
|
-
isTTY: tty.isatty(1)
|
|
526
|
-
}),
|
|
527
|
-
stderr: createSupportsColor({
|
|
528
|
-
isTTY: tty.isatty(2)
|
|
529
|
-
})
|
|
530
|
-
};
|
|
531
|
-
|
|
532
|
-
// TODO: When targeting Node.js 16, use `String.prototype.replaceAll`.
|
|
533
|
-
function stringReplaceAll(string, substring, replacer) {
|
|
534
|
-
let index = string.indexOf(substring);
|
|
535
|
-
if (index === -1) {
|
|
536
|
-
return string;
|
|
537
|
-
}
|
|
538
|
-
const substringLength = substring.length;
|
|
539
|
-
let endIndex = 0;
|
|
540
|
-
let returnValue = '';
|
|
541
|
-
do {
|
|
542
|
-
returnValue += string.slice(endIndex, index) + substring + replacer;
|
|
543
|
-
endIndex = index + substringLength;
|
|
544
|
-
index = string.indexOf(substring, endIndex);
|
|
545
|
-
}while (index !== -1)
|
|
546
|
-
returnValue += string.slice(endIndex);
|
|
547
|
-
return returnValue;
|
|
548
|
-
}
|
|
549
|
-
function stringEncaseCRLFWithFirstIndex(string, prefix, postfix, index) {
|
|
550
|
-
let endIndex = 0;
|
|
551
|
-
let returnValue = '';
|
|
552
|
-
do {
|
|
553
|
-
const gotCR = string[index - 1] === '\r';
|
|
554
|
-
returnValue += string.slice(endIndex, gotCR ? index - 1 : index) + prefix + (gotCR ? '\r\n' : '\n') + postfix;
|
|
555
|
-
endIndex = index + 1;
|
|
556
|
-
index = string.indexOf('\n', endIndex);
|
|
557
|
-
}while (index !== -1)
|
|
558
|
-
returnValue += string.slice(endIndex);
|
|
559
|
-
return returnValue;
|
|
560
|
-
}
|
|
561
|
-
|
|
562
|
-
const { stdout: stdoutColor, stderr: stderrColor } = supportsColor;
|
|
563
|
-
const GENERATOR = Symbol('GENERATOR');
|
|
564
|
-
const STYLER = Symbol('STYLER');
|
|
565
|
-
const IS_EMPTY = Symbol('IS_EMPTY');
|
|
566
|
-
// `supportsColor.level` → `ansiStyles.color[name]` mapping
|
|
567
|
-
const levelMapping = [
|
|
568
|
-
'ansi',
|
|
569
|
-
'ansi',
|
|
570
|
-
'ansi256',
|
|
571
|
-
'ansi16m'
|
|
572
|
-
];
|
|
573
|
-
const styles = Object.create(null);
|
|
574
|
-
const applyOptions = (object, options = {})=>{
|
|
575
|
-
if (options.level && !(Number.isInteger(options.level) && options.level >= 0 && options.level <= 3)) {
|
|
576
|
-
throw new Error('The `level` option should be an integer from 0 to 3');
|
|
577
|
-
}
|
|
578
|
-
// Detect level if not set manually
|
|
579
|
-
const colorLevel = stdoutColor ? stdoutColor.level : 0;
|
|
580
|
-
object.level = options.level === undefined ? colorLevel : options.level;
|
|
581
|
-
};
|
|
582
|
-
const chalkFactory = (options)=>{
|
|
583
|
-
const chalk = (...strings)=>strings.join(' ');
|
|
584
|
-
applyOptions(chalk, options);
|
|
585
|
-
Object.setPrototypeOf(chalk, createChalk.prototype);
|
|
586
|
-
return chalk;
|
|
587
|
-
};
|
|
588
|
-
function createChalk(options) {
|
|
589
|
-
return chalkFactory(options);
|
|
590
|
-
}
|
|
591
|
-
Object.setPrototypeOf(createChalk.prototype, Function.prototype);
|
|
592
|
-
for (const [styleName, style] of Object.entries(ansiStyles)){
|
|
593
|
-
styles[styleName] = {
|
|
594
|
-
get () {
|
|
595
|
-
const builder = createBuilder(this, createStyler(style.open, style.close, this[STYLER]), this[IS_EMPTY]);
|
|
596
|
-
Object.defineProperty(this, styleName, {
|
|
597
|
-
value: builder
|
|
598
|
-
});
|
|
599
|
-
return builder;
|
|
600
|
-
}
|
|
601
|
-
};
|
|
602
|
-
}
|
|
603
|
-
styles.visible = {
|
|
604
|
-
get () {
|
|
605
|
-
const builder = createBuilder(this, this[STYLER], true);
|
|
606
|
-
Object.defineProperty(this, 'visible', {
|
|
607
|
-
value: builder
|
|
608
|
-
});
|
|
609
|
-
return builder;
|
|
610
|
-
}
|
|
611
|
-
};
|
|
612
|
-
const getModelAnsi = (model, level, type, ...arguments_)=>{
|
|
613
|
-
if (model === 'rgb') {
|
|
614
|
-
if (level === 'ansi16m') {
|
|
615
|
-
return ansiStyles[type].ansi16m(...arguments_);
|
|
616
|
-
}
|
|
617
|
-
if (level === 'ansi256') {
|
|
618
|
-
return ansiStyles[type].ansi256(ansiStyles.rgbToAnsi256(...arguments_));
|
|
619
|
-
}
|
|
620
|
-
return ansiStyles[type].ansi(ansiStyles.rgbToAnsi(...arguments_));
|
|
621
|
-
}
|
|
622
|
-
if (model === 'hex') {
|
|
623
|
-
return getModelAnsi('rgb', level, type, ...ansiStyles.hexToRgb(...arguments_));
|
|
624
|
-
}
|
|
625
|
-
return ansiStyles[type][model](...arguments_);
|
|
626
|
-
};
|
|
627
|
-
const usedModels = [
|
|
628
|
-
'rgb',
|
|
629
|
-
'hex',
|
|
630
|
-
'ansi256'
|
|
631
|
-
];
|
|
632
|
-
for (const model of usedModels){
|
|
633
|
-
styles[model] = {
|
|
634
|
-
get () {
|
|
635
|
-
const { level } = this;
|
|
636
|
-
return function(...arguments_) {
|
|
637
|
-
const styler = createStyler(getModelAnsi(model, levelMapping[level], 'color', ...arguments_), ansiStyles.color.close, this[STYLER]);
|
|
638
|
-
return createBuilder(this, styler, this[IS_EMPTY]);
|
|
639
|
-
};
|
|
640
|
-
}
|
|
641
|
-
};
|
|
642
|
-
const bgModel = 'bg' + model[0].toUpperCase() + model.slice(1);
|
|
643
|
-
styles[bgModel] = {
|
|
644
|
-
get () {
|
|
645
|
-
const { level } = this;
|
|
646
|
-
return function(...arguments_) {
|
|
647
|
-
const styler = createStyler(getModelAnsi(model, levelMapping[level], 'bgColor', ...arguments_), ansiStyles.bgColor.close, this[STYLER]);
|
|
648
|
-
return createBuilder(this, styler, this[IS_EMPTY]);
|
|
649
|
-
};
|
|
650
|
-
}
|
|
651
|
-
};
|
|
652
|
-
}
|
|
653
|
-
const proto = Object.defineProperties(()=>{}, {
|
|
654
|
-
...styles,
|
|
655
|
-
level: {
|
|
656
|
-
enumerable: true,
|
|
657
|
-
get () {
|
|
658
|
-
return this[GENERATOR].level;
|
|
659
|
-
},
|
|
660
|
-
set (level) {
|
|
661
|
-
this[GENERATOR].level = level;
|
|
662
|
-
}
|
|
663
|
-
}
|
|
664
|
-
});
|
|
665
|
-
const createStyler = (open, close, parent)=>{
|
|
666
|
-
let openAll;
|
|
667
|
-
let closeAll;
|
|
668
|
-
if (parent === undefined) {
|
|
669
|
-
openAll = open;
|
|
670
|
-
closeAll = close;
|
|
671
|
-
} else {
|
|
672
|
-
openAll = parent.openAll + open;
|
|
673
|
-
closeAll = close + parent.closeAll;
|
|
674
|
-
}
|
|
675
|
-
return {
|
|
676
|
-
open,
|
|
677
|
-
close,
|
|
678
|
-
openAll,
|
|
679
|
-
closeAll,
|
|
680
|
-
parent
|
|
681
|
-
};
|
|
682
|
-
};
|
|
683
|
-
const createBuilder = (self, _styler, _isEmpty)=>{
|
|
684
|
-
// Single argument is hot path, implicit coercion is faster than anything
|
|
685
|
-
// eslint-disable-next-line no-implicit-coercion
|
|
686
|
-
const builder = (...arguments_)=>applyStyle(builder, arguments_.length === 1 ? '' + arguments_[0] : arguments_.join(' '));
|
|
687
|
-
// We alter the prototype because we must return a function, but there is
|
|
688
|
-
// no way to create a function with a different prototype
|
|
689
|
-
Object.setPrototypeOf(builder, proto);
|
|
690
|
-
builder[GENERATOR] = self;
|
|
691
|
-
builder[STYLER] = _styler;
|
|
692
|
-
builder[IS_EMPTY] = _isEmpty;
|
|
693
|
-
return builder;
|
|
694
|
-
};
|
|
695
|
-
const applyStyle = (self, string)=>{
|
|
696
|
-
if (self.level <= 0 || !string) {
|
|
697
|
-
return self[IS_EMPTY] ? '' : string;
|
|
698
|
-
}
|
|
699
|
-
let styler = self[STYLER];
|
|
700
|
-
if (styler === undefined) {
|
|
701
|
-
return string;
|
|
702
|
-
}
|
|
703
|
-
const { openAll, closeAll } = styler;
|
|
704
|
-
if (string.includes('\u001B')) {
|
|
705
|
-
while(styler !== undefined){
|
|
706
|
-
// Replace any instances already present with a re-opening code
|
|
707
|
-
// otherwise only the part of the string until said closing code
|
|
708
|
-
// will be colored, and the rest will simply be 'plain'.
|
|
709
|
-
string = stringReplaceAll(string, styler.close, styler.open);
|
|
710
|
-
styler = styler.parent;
|
|
711
|
-
}
|
|
712
|
-
}
|
|
713
|
-
// We can move both next actions out of loop, because remaining actions in loop won't have
|
|
714
|
-
// any/visible effect on parts we add here. Close the styling before a linebreak and reopen
|
|
715
|
-
// after next line to fix a bleed issue on macOS: https://github.com/chalk/chalk/pull/92
|
|
716
|
-
const lfIndex = string.indexOf('\n');
|
|
717
|
-
if (lfIndex !== -1) {
|
|
718
|
-
string = stringEncaseCRLFWithFirstIndex(string, closeAll, openAll, lfIndex);
|
|
719
|
-
}
|
|
720
|
-
return openAll + string + closeAll;
|
|
721
|
-
};
|
|
722
|
-
Object.defineProperties(createChalk.prototype, styles);
|
|
723
|
-
const chalk = createChalk();
|
|
724
|
-
createChalk({
|
|
725
|
-
level: stderrColor ? stderrColor.level : 0
|
|
726
|
-
});
|
|
727
|
-
var chalk$1 = chalk;
|
|
728
|
-
|
|
729
|
-
const mapLoggingMethodToConsole = {
|
|
730
|
-
wait: "log",
|
|
731
|
-
error: "error",
|
|
732
|
-
warn: "warn",
|
|
733
|
-
info: "log",
|
|
734
|
-
event: "log"
|
|
735
|
-
};
|
|
736
|
-
const prefixes = {
|
|
737
|
-
wait: `${chalk$1.white(chalk$1.bold("○"))} (serwist)`,
|
|
738
|
-
error: `${chalk$1.red(chalk$1.bold("X"))} (serwist)`,
|
|
739
|
-
warn: `${chalk$1.yellow(chalk$1.bold("⚠"))} (serwist)`,
|
|
740
|
-
info: `${chalk$1.white(chalk$1.bold("○"))} (serwist)`,
|
|
741
|
-
event: `${chalk$1.green(chalk$1.bold("✓"))} (serwist)`
|
|
742
|
-
};
|
|
743
|
-
const prefixedLog = (prefixType, ...message)=>{
|
|
744
|
-
const consoleMethod = mapLoggingMethodToConsole[prefixType];
|
|
745
|
-
const prefix = prefixes[prefixType];
|
|
746
|
-
if ((message[0] === "" || message[0] === undefined) && message.length === 1) {
|
|
747
|
-
message.shift();
|
|
748
|
-
}
|
|
749
|
-
// If there's no message, don't print the prefix but a new line
|
|
750
|
-
if (message.length === 0) {
|
|
751
|
-
console[consoleMethod]("");
|
|
752
|
-
} else {
|
|
753
|
-
console[consoleMethod](` ${prefix}`, ...message);
|
|
754
|
-
}
|
|
755
|
-
};
|
|
756
|
-
const info = (...message)=>{
|
|
757
|
-
prefixedLog("info", ...message);
|
|
758
|
-
};
|
|
759
|
-
const event = (...message)=>{
|
|
760
|
-
prefixedLog("event", ...message);
|
|
761
|
-
};
|
|
762
|
-
|
|
763
|
-
const __dirname$1 = node_url.fileURLToPath(new URL(".", (typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.src || new URL('index.cjs', document.baseURI).href))));
|
|
764
|
-
const withPWAInit = (pluginOptions)=>{
|
|
765
|
-
return (nextConfig = {})=>({
|
|
766
|
-
...nextConfig,
|
|
767
|
-
webpack (config, options) {
|
|
768
|
-
const webpack = options.webpack;
|
|
769
|
-
const { buildId, dev } = options;
|
|
770
|
-
const basePath = options.config.basePath || "/";
|
|
771
|
-
const tsConfigJson = loadTSConfig(options.dir, nextConfig?.typescript?.tsconfigPath);
|
|
772
|
-
const { cacheOnFrontEndNav = false, disable = false, scope = basePath, swUrl = "sw.js", register = true, reloadOnOnline = true, ...buildOptions } = pluginOptions;
|
|
773
|
-
if (typeof nextConfig.webpack === "function") {
|
|
774
|
-
config = nextConfig.webpack(config, options);
|
|
775
|
-
}
|
|
776
|
-
if (disable) {
|
|
777
|
-
options.isServer && info("Serwist is disabled.");
|
|
778
|
-
return config;
|
|
779
|
-
}
|
|
780
|
-
if (!config.plugins) {
|
|
781
|
-
config.plugins = [];
|
|
782
|
-
}
|
|
783
|
-
event(`Compiling for ${options.isServer ? "server" : "client (static)"}...`);
|
|
784
|
-
const _sw = path.posix.join(basePath, swUrl);
|
|
785
|
-
const _scope = path.posix.join(scope, "/");
|
|
786
|
-
config.plugins.push(new webpack.DefinePlugin({
|
|
787
|
-
"self.__SERWIST_SW_ENTRY.sw": `'${_sw}'`,
|
|
788
|
-
"self.__SERWIST_SW_ENTRY.scope": `'${_scope}'`,
|
|
789
|
-
"self.__SERWIST_SW_ENTRY.cacheOnFrontEndNav": `${Boolean(cacheOnFrontEndNav)}`,
|
|
790
|
-
"self.__SERWIST_SW_ENTRY.register": `${Boolean(register)}`,
|
|
791
|
-
"self.__SERWIST_SW_ENTRY.reloadOnOnline": `${Boolean(reloadOnOnline)}`
|
|
792
|
-
}));
|
|
793
|
-
const swEntryJs = path.join(__dirname$1, "sw-entry.js");
|
|
794
|
-
const entry = config.entry;
|
|
795
|
-
config.entry = async ()=>{
|
|
796
|
-
const entries = await entry();
|
|
797
|
-
if (entries["main.js"] && !entries["main.js"].includes(swEntryJs)) {
|
|
798
|
-
if (Array.isArray(entries["main.js"])) {
|
|
799
|
-
entries["main.js"].unshift(swEntryJs);
|
|
800
|
-
} else if (typeof entries["main.js"] === "string") {
|
|
801
|
-
entries["main.js"] = [
|
|
802
|
-
swEntryJs,
|
|
803
|
-
entries["main.js"]
|
|
804
|
-
];
|
|
805
|
-
}
|
|
806
|
-
}
|
|
807
|
-
if (entries["main-app"] && !entries["main-app"].includes(swEntryJs)) {
|
|
808
|
-
if (Array.isArray(entries["main-app"])) {
|
|
809
|
-
entries["main-app"].unshift(swEntryJs);
|
|
810
|
-
} else if (typeof entries["main-app"] === "string") {
|
|
811
|
-
entries["main-app"] = [
|
|
812
|
-
swEntryJs,
|
|
813
|
-
entries["main-app"]
|
|
814
|
-
];
|
|
815
|
-
}
|
|
816
|
-
}
|
|
817
|
-
return entries;
|
|
818
|
-
};
|
|
819
|
-
if (!options.isServer) {
|
|
820
|
-
if (!register) {
|
|
821
|
-
info("Service worker won't be automatically registered as per the config, please call the following code in componentDidMount or useEffect:");
|
|
822
|
-
info(" window.serwist.register()");
|
|
823
|
-
if (!tsConfigJson?.compilerOptions?.types?.includes("@serwist/next/typings")) {
|
|
824
|
-
info("You may also want to add @serwist/next/typings to compilerOptions.types in your tsconfig.json/jsconfig.json.");
|
|
825
|
-
}
|
|
826
|
-
}
|
|
827
|
-
const { swSrc: providedSwSrc, swDest: providedSwDest, additionalPrecacheEntries, exclude = [], modifyURLPrefix = {}, manifestTransforms = [], ...otherBuildOptions } = buildOptions;
|
|
828
|
-
let swSrc = providedSwSrc;
|
|
829
|
-
let swDest = providedSwDest;
|
|
830
|
-
if (!path.isAbsolute(swSrc)) {
|
|
831
|
-
swSrc = path.join(options.dir, swSrc);
|
|
832
|
-
}
|
|
833
|
-
if (!path.isAbsolute(swDest)) {
|
|
834
|
-
swDest = path.join(options.dir, swDest);
|
|
835
|
-
}
|
|
836
|
-
const destDir = path.dirname(swDest);
|
|
837
|
-
const shouldBuildSWEntryWorker = cacheOnFrontEndNav;
|
|
838
|
-
let swEntryPublicPath = undefined;
|
|
839
|
-
if (shouldBuildSWEntryWorker) {
|
|
840
|
-
const swEntryWorkerSrc = path.join(__dirname$1, "sw-entry-worker.js");
|
|
841
|
-
const swEntryName = `swe-worker-${getContentHash(swEntryWorkerSrc, dev)}.js`;
|
|
842
|
-
swEntryPublicPath = path.posix.join(basePath, swEntryName);
|
|
843
|
-
const swEntryWorkerDest = path.join(destDir, swEntryName);
|
|
844
|
-
config.plugins.push(new internal.ChildCompilationPlugin({
|
|
845
|
-
src: swEntryWorkerSrc,
|
|
846
|
-
dest: swEntryWorkerDest
|
|
847
|
-
}));
|
|
848
|
-
}
|
|
849
|
-
config.plugins.push(new webpack.DefinePlugin({
|
|
850
|
-
"self.__SERWIST_SW_ENTRY.swEntryWorker": swEntryPublicPath && `'${swEntryPublicPath}'`
|
|
851
|
-
}));
|
|
852
|
-
info(`Service worker: ${swDest}`);
|
|
853
|
-
info(` URL: ${_sw}`);
|
|
854
|
-
info(` Scope: ${_scope}`);
|
|
855
|
-
config.plugins.push(new cleanWebpackPlugin.CleanWebpackPlugin({
|
|
856
|
-
cleanOnceBeforeBuildPatterns: [
|
|
857
|
-
path.join(destDir, "swe-worker-*.js"),
|
|
858
|
-
path.join(destDir, "swe-worker-*.js.map"),
|
|
859
|
-
swDest
|
|
860
|
-
]
|
|
861
|
-
}));
|
|
862
|
-
// Precache files in public folder
|
|
863
|
-
let resolvedManifestEntries = additionalPrecacheEntries;
|
|
864
|
-
if (!resolvedManifestEntries) {
|
|
865
|
-
const swDestFileName = path.basename(swDest);
|
|
866
|
-
resolvedManifestEntries = fg.sync([
|
|
867
|
-
"**/*",
|
|
868
|
-
// Include these in case the user outputs these files to `public`.
|
|
869
|
-
"!swe-worker-*.js",
|
|
870
|
-
"!swe-worker-*.js.map",
|
|
871
|
-
`!${swDestFileName.replace(/^\/+/, "")}`,
|
|
872
|
-
`!${swDestFileName.replace(/^\/+/, "")}.map`
|
|
873
|
-
], {
|
|
874
|
-
cwd: "public"
|
|
875
|
-
}).map((f)=>({
|
|
876
|
-
url: path.posix.join(basePath, f),
|
|
877
|
-
revision: getFileHash(`public/${f}`)
|
|
878
|
-
}));
|
|
879
|
-
}
|
|
880
|
-
const publicPath = config.output?.publicPath;
|
|
881
|
-
config.plugins.push(new webpackPlugin.InjectManifest({
|
|
882
|
-
swSrc,
|
|
883
|
-
swDest,
|
|
884
|
-
disablePrecacheManifest: dev,
|
|
885
|
-
additionalPrecacheEntries: dev ? [] : resolvedManifestEntries,
|
|
886
|
-
exclude: [
|
|
887
|
-
...exclude,
|
|
888
|
-
({ asset })=>{
|
|
889
|
-
if (asset.name.startsWith("server/") || asset.name.match(/^((app-|^)build-manifest\.json|react-loadable-manifest\.json)$/)) {
|
|
890
|
-
return true;
|
|
891
|
-
}
|
|
892
|
-
if (dev && !asset.name.startsWith("static/runtime/")) {
|
|
893
|
-
return true;
|
|
894
|
-
}
|
|
895
|
-
return false;
|
|
896
|
-
}
|
|
897
|
-
],
|
|
898
|
-
modifyURLPrefix: {
|
|
899
|
-
...modifyURLPrefix,
|
|
900
|
-
"/_next/../public/": "/"
|
|
901
|
-
},
|
|
902
|
-
manifestTransforms: [
|
|
903
|
-
...manifestTransforms,
|
|
904
|
-
async (manifestEntries, compilation)=>{
|
|
905
|
-
const manifest = manifestEntries.map((m)=>{
|
|
906
|
-
m.url = m.url.replace("/_next//static/image", "/_next/static/image");
|
|
907
|
-
m.url = m.url.replace("/_next//static/media", "/_next/static/media");
|
|
908
|
-
if (m.revision === null) {
|
|
909
|
-
let key = m.url;
|
|
910
|
-
if (typeof publicPath === "string" && key.startsWith(publicPath)) {
|
|
911
|
-
key = m.url.substring(publicPath.length);
|
|
912
|
-
}
|
|
913
|
-
const asset = compilation.assetsInfo.get(key);
|
|
914
|
-
m.revision = asset ? asset.contenthash || buildId : buildId;
|
|
915
|
-
}
|
|
916
|
-
m.url = m.url.replace(/\[/g, "%5B").replace(/\]/g, "%5D");
|
|
917
|
-
return m;
|
|
918
|
-
});
|
|
919
|
-
return {
|
|
920
|
-
manifest,
|
|
921
|
-
warnings: []
|
|
922
|
-
};
|
|
923
|
-
}
|
|
924
|
-
],
|
|
925
|
-
...otherBuildOptions
|
|
926
|
-
}));
|
|
927
|
-
}
|
|
928
|
-
return config;
|
|
929
|
-
}
|
|
930
|
-
});
|
|
931
|
-
};
|
|
932
|
-
|
|
933
|
-
exports.default = withPWAInit;
|