@netlify/plugin-nextjs 5.9.0 → 5.9.2
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/build/content/prerendered.js +2 -2
- package/dist/build/content/static.js +2 -2
- package/dist/build/functions/edge.js +1 -1
- package/dist/esm-chunks/{chunk-BFYMHE3E.js → chunk-HGXG447M.js} +13 -0
- package/dist/esm-chunks/chunk-LVXJQ2G2.js +147 -0
- package/dist/esm-chunks/{chunk-KBX7SJLC.js → chunk-NEZW7TGG.js} +1 -1
- package/dist/esm-chunks/{next-4L47PQSM.js → next-H2VMRX5P.js} +2 -4
- package/dist/esm-chunks/{package-LCNINN36.js → package-36IBNZ37.js} +2 -2
- package/dist/index.js +4 -4
- package/dist/run/handlers/cache.cjs +251 -139
- package/dist/run/handlers/request-context.cjs +88 -63
- package/dist/run/handlers/server.js +4 -4
- package/dist/run/handlers/tracer.cjs +88 -57
- package/dist/run/handlers/tracing.js +2 -2
- package/dist/run/handlers/wait-until.cjs +88 -57
- package/dist/run/next.cjs +88 -59
- package/edge-runtime/lib/middleware.ts +1 -1
- package/edge-runtime/lib/response.ts +5 -2
- package/edge-runtime/vendor/deno.land/x/htmlrewriter@v1.0.0/pkg/htmlrewriter.js +1218 -0
- package/edge-runtime/vendor/deno.land/x/htmlrewriter@v1.0.0/pkg/htmlrewriter_bg.wasm +0 -0
- package/edge-runtime/vendor/deno.land/x/htmlrewriter@v1.0.0/src/index.ts +80 -0
- package/edge-runtime/vendor/deno.land/x/{html_rewriter@v0.1.0-pre.17/vendor/html_rewriter.d.ts → htmlrewriter@v1.0.0/src/types.d.ts} +8 -25
- package/edge-runtime/vendor/import_map.json +0 -2
- package/edge-runtime/vendor.ts +1 -1
- package/package.json +1 -1
- package/dist/esm-chunks/chunk-NDSDIXRD.js +0 -122
- package/edge-runtime/vendor/deno.land/std@0.134.0/fmt/colors.ts +0 -536
- package/edge-runtime/vendor/deno.land/std@0.134.0/testing/_diff.ts +0 -360
- package/edge-runtime/vendor/deno.land/std@0.134.0/testing/asserts.ts +0 -866
- package/edge-runtime/vendor/deno.land/x/html_rewriter@v0.1.0-pre.17/index.ts +0 -133
- package/edge-runtime/vendor/deno.land/x/html_rewriter@v0.1.0-pre.17/vendor/asyncify.js +0 -112
- package/edge-runtime/vendor/deno.land/x/html_rewriter@v0.1.0-pre.17/vendor/html_rewriter.js +0 -974
- package/edge-runtime/vendor/raw.githubusercontent.com/worker-tools/resolvable-promise/master/index.ts +0 -50
- package/dist/esm-chunks/{chunk-BVYZSEV6.js → chunk-J4D25YDX.js} +3 -3
- package/dist/esm-chunks/{chunk-HWMLYAVP.js → chunk-NTLBFRPA.js} +3 -3
|
@@ -1,360 +0,0 @@
|
|
|
1
|
-
// Copyright 2018-2022 the Deno authors. All rights reserved. MIT license.
|
|
2
|
-
// This module is browser compatible.
|
|
3
|
-
|
|
4
|
-
interface FarthestPoint {
|
|
5
|
-
y: number;
|
|
6
|
-
id: number;
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
export enum DiffType {
|
|
10
|
-
removed = "removed",
|
|
11
|
-
common = "common",
|
|
12
|
-
added = "added",
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
export interface DiffResult<T> {
|
|
16
|
-
type: DiffType;
|
|
17
|
-
value: T;
|
|
18
|
-
details?: Array<DiffResult<T>>;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
const REMOVED = 1;
|
|
22
|
-
const COMMON = 2;
|
|
23
|
-
const ADDED = 3;
|
|
24
|
-
|
|
25
|
-
function createCommon<T>(A: T[], B: T[], reverse?: boolean): T[] {
|
|
26
|
-
const common = [];
|
|
27
|
-
if (A.length === 0 || B.length === 0) return [];
|
|
28
|
-
for (let i = 0; i < Math.min(A.length, B.length); i += 1) {
|
|
29
|
-
if (
|
|
30
|
-
A[reverse ? A.length - i - 1 : i] === B[reverse ? B.length - i - 1 : i]
|
|
31
|
-
) {
|
|
32
|
-
common.push(A[reverse ? A.length - i - 1 : i]);
|
|
33
|
-
} else {
|
|
34
|
-
return common;
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
return common;
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
/**
|
|
41
|
-
* Renders the differences between the actual and expected values
|
|
42
|
-
* @param A Actual value
|
|
43
|
-
* @param B Expected value
|
|
44
|
-
*/
|
|
45
|
-
export function diff<T>(A: T[], B: T[]): Array<DiffResult<T>> {
|
|
46
|
-
const prefixCommon = createCommon(A, B);
|
|
47
|
-
const suffixCommon = createCommon(
|
|
48
|
-
A.slice(prefixCommon.length),
|
|
49
|
-
B.slice(prefixCommon.length),
|
|
50
|
-
true,
|
|
51
|
-
).reverse();
|
|
52
|
-
A = suffixCommon.length
|
|
53
|
-
? A.slice(prefixCommon.length, -suffixCommon.length)
|
|
54
|
-
: A.slice(prefixCommon.length);
|
|
55
|
-
B = suffixCommon.length
|
|
56
|
-
? B.slice(prefixCommon.length, -suffixCommon.length)
|
|
57
|
-
: B.slice(prefixCommon.length);
|
|
58
|
-
const swapped = B.length > A.length;
|
|
59
|
-
[A, B] = swapped ? [B, A] : [A, B];
|
|
60
|
-
const M = A.length;
|
|
61
|
-
const N = B.length;
|
|
62
|
-
if (!M && !N && !suffixCommon.length && !prefixCommon.length) return [];
|
|
63
|
-
if (!N) {
|
|
64
|
-
return [
|
|
65
|
-
...prefixCommon.map(
|
|
66
|
-
(c): DiffResult<typeof c> => ({ type: DiffType.common, value: c }),
|
|
67
|
-
),
|
|
68
|
-
...A.map(
|
|
69
|
-
(a): DiffResult<typeof a> => ({
|
|
70
|
-
type: swapped ? DiffType.added : DiffType.removed,
|
|
71
|
-
value: a,
|
|
72
|
-
}),
|
|
73
|
-
),
|
|
74
|
-
...suffixCommon.map(
|
|
75
|
-
(c): DiffResult<typeof c> => ({ type: DiffType.common, value: c }),
|
|
76
|
-
),
|
|
77
|
-
];
|
|
78
|
-
}
|
|
79
|
-
const offset = N;
|
|
80
|
-
const delta = M - N;
|
|
81
|
-
const size = M + N + 1;
|
|
82
|
-
const fp: FarthestPoint[] = Array.from(
|
|
83
|
-
{ length: size },
|
|
84
|
-
() => ({ y: -1, id: -1 }),
|
|
85
|
-
);
|
|
86
|
-
/**
|
|
87
|
-
* INFO:
|
|
88
|
-
* This buffer is used to save memory and improve performance.
|
|
89
|
-
* The first half is used to save route and last half is used to save diff
|
|
90
|
-
* type.
|
|
91
|
-
* This is because, when I kept new uint8array area to save type,performance
|
|
92
|
-
* worsened.
|
|
93
|
-
*/
|
|
94
|
-
const routes = new Uint32Array((M * N + size + 1) * 2);
|
|
95
|
-
const diffTypesPtrOffset = routes.length / 2;
|
|
96
|
-
let ptr = 0;
|
|
97
|
-
let p = -1;
|
|
98
|
-
|
|
99
|
-
function backTrace<T>(
|
|
100
|
-
A: T[],
|
|
101
|
-
B: T[],
|
|
102
|
-
current: FarthestPoint,
|
|
103
|
-
swapped: boolean,
|
|
104
|
-
): Array<{
|
|
105
|
-
type: DiffType;
|
|
106
|
-
value: T;
|
|
107
|
-
}> {
|
|
108
|
-
const M = A.length;
|
|
109
|
-
const N = B.length;
|
|
110
|
-
const result = [];
|
|
111
|
-
let a = M - 1;
|
|
112
|
-
let b = N - 1;
|
|
113
|
-
let j = routes[current.id];
|
|
114
|
-
let type = routes[current.id + diffTypesPtrOffset];
|
|
115
|
-
while (true) {
|
|
116
|
-
if (!j && !type) break;
|
|
117
|
-
const prev = j;
|
|
118
|
-
if (type === REMOVED) {
|
|
119
|
-
result.unshift({
|
|
120
|
-
type: swapped ? DiffType.removed : DiffType.added,
|
|
121
|
-
value: B[b],
|
|
122
|
-
});
|
|
123
|
-
b -= 1;
|
|
124
|
-
} else if (type === ADDED) {
|
|
125
|
-
result.unshift({
|
|
126
|
-
type: swapped ? DiffType.added : DiffType.removed,
|
|
127
|
-
value: A[a],
|
|
128
|
-
});
|
|
129
|
-
a -= 1;
|
|
130
|
-
} else {
|
|
131
|
-
result.unshift({ type: DiffType.common, value: A[a] });
|
|
132
|
-
a -= 1;
|
|
133
|
-
b -= 1;
|
|
134
|
-
}
|
|
135
|
-
j = routes[prev];
|
|
136
|
-
type = routes[prev + diffTypesPtrOffset];
|
|
137
|
-
}
|
|
138
|
-
return result;
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
function createFP(
|
|
142
|
-
slide: FarthestPoint,
|
|
143
|
-
down: FarthestPoint,
|
|
144
|
-
k: number,
|
|
145
|
-
M: number,
|
|
146
|
-
): FarthestPoint {
|
|
147
|
-
if (slide && slide.y === -1 && down && down.y === -1) {
|
|
148
|
-
return { y: 0, id: 0 };
|
|
149
|
-
}
|
|
150
|
-
if (
|
|
151
|
-
(down && down.y === -1) ||
|
|
152
|
-
k === M ||
|
|
153
|
-
(slide && slide.y) > (down && down.y) + 1
|
|
154
|
-
) {
|
|
155
|
-
const prev = slide.id;
|
|
156
|
-
ptr++;
|
|
157
|
-
routes[ptr] = prev;
|
|
158
|
-
routes[ptr + diffTypesPtrOffset] = ADDED;
|
|
159
|
-
return { y: slide.y, id: ptr };
|
|
160
|
-
} else {
|
|
161
|
-
const prev = down.id;
|
|
162
|
-
ptr++;
|
|
163
|
-
routes[ptr] = prev;
|
|
164
|
-
routes[ptr + diffTypesPtrOffset] = REMOVED;
|
|
165
|
-
return { y: down.y + 1, id: ptr };
|
|
166
|
-
}
|
|
167
|
-
}
|
|
168
|
-
|
|
169
|
-
function snake<T>(
|
|
170
|
-
k: number,
|
|
171
|
-
slide: FarthestPoint,
|
|
172
|
-
down: FarthestPoint,
|
|
173
|
-
_offset: number,
|
|
174
|
-
A: T[],
|
|
175
|
-
B: T[],
|
|
176
|
-
): FarthestPoint {
|
|
177
|
-
const M = A.length;
|
|
178
|
-
const N = B.length;
|
|
179
|
-
if (k < -N || M < k) return { y: -1, id: -1 };
|
|
180
|
-
const fp = createFP(slide, down, k, M);
|
|
181
|
-
while (fp.y + k < M && fp.y < N && A[fp.y + k] === B[fp.y]) {
|
|
182
|
-
const prev = fp.id;
|
|
183
|
-
ptr++;
|
|
184
|
-
fp.id = ptr;
|
|
185
|
-
fp.y += 1;
|
|
186
|
-
routes[ptr] = prev;
|
|
187
|
-
routes[ptr + diffTypesPtrOffset] = COMMON;
|
|
188
|
-
}
|
|
189
|
-
return fp;
|
|
190
|
-
}
|
|
191
|
-
|
|
192
|
-
while (fp[delta + offset].y < N) {
|
|
193
|
-
p = p + 1;
|
|
194
|
-
for (let k = -p; k < delta; ++k) {
|
|
195
|
-
fp[k + offset] = snake(
|
|
196
|
-
k,
|
|
197
|
-
fp[k - 1 + offset],
|
|
198
|
-
fp[k + 1 + offset],
|
|
199
|
-
offset,
|
|
200
|
-
A,
|
|
201
|
-
B,
|
|
202
|
-
);
|
|
203
|
-
}
|
|
204
|
-
for (let k = delta + p; k > delta; --k) {
|
|
205
|
-
fp[k + offset] = snake(
|
|
206
|
-
k,
|
|
207
|
-
fp[k - 1 + offset],
|
|
208
|
-
fp[k + 1 + offset],
|
|
209
|
-
offset,
|
|
210
|
-
A,
|
|
211
|
-
B,
|
|
212
|
-
);
|
|
213
|
-
}
|
|
214
|
-
fp[delta + offset] = snake(
|
|
215
|
-
delta,
|
|
216
|
-
fp[delta - 1 + offset],
|
|
217
|
-
fp[delta + 1 + offset],
|
|
218
|
-
offset,
|
|
219
|
-
A,
|
|
220
|
-
B,
|
|
221
|
-
);
|
|
222
|
-
}
|
|
223
|
-
return [
|
|
224
|
-
...prefixCommon.map(
|
|
225
|
-
(c): DiffResult<typeof c> => ({ type: DiffType.common, value: c }),
|
|
226
|
-
),
|
|
227
|
-
...backTrace(A, B, fp[delta + offset], swapped),
|
|
228
|
-
...suffixCommon.map(
|
|
229
|
-
(c): DiffResult<typeof c> => ({ type: DiffType.common, value: c }),
|
|
230
|
-
),
|
|
231
|
-
];
|
|
232
|
-
}
|
|
233
|
-
|
|
234
|
-
/**
|
|
235
|
-
* Renders the differences between the actual and expected strings
|
|
236
|
-
* Partially inspired from https://github.com/kpdecker/jsdiff
|
|
237
|
-
* @param A Actual string
|
|
238
|
-
* @param B Expected string
|
|
239
|
-
*/
|
|
240
|
-
export function diffstr(A: string, B: string) {
|
|
241
|
-
function unescape(string: string): string {
|
|
242
|
-
// unescape invisible characters.
|
|
243
|
-
// ref: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String#escape_sequences
|
|
244
|
-
return string
|
|
245
|
-
.replaceAll("\b", "\\b")
|
|
246
|
-
.replaceAll("\f", "\\f")
|
|
247
|
-
.replaceAll("\t", "\\t")
|
|
248
|
-
.replaceAll("\v", "\\v")
|
|
249
|
-
.replaceAll( // does not remove line breaks
|
|
250
|
-
/\r\n|\r|\n/g,
|
|
251
|
-
(str) => str === "\r" ? "\\r" : str === "\n" ? "\\n\n" : "\\r\\n\r\n",
|
|
252
|
-
);
|
|
253
|
-
}
|
|
254
|
-
|
|
255
|
-
function tokenize(string: string, { wordDiff = false } = {}): string[] {
|
|
256
|
-
if (wordDiff) {
|
|
257
|
-
// Split string on whitespace symbols
|
|
258
|
-
const tokens = string.split(/([^\S\r\n]+|[()[\]{}'"\r\n]|\b)/);
|
|
259
|
-
// Extended Latin character set
|
|
260
|
-
const words =
|
|
261
|
-
/^[a-zA-Z\u{C0}-\u{FF}\u{D8}-\u{F6}\u{F8}-\u{2C6}\u{2C8}-\u{2D7}\u{2DE}-\u{2FF}\u{1E00}-\u{1EFF}]+$/u;
|
|
262
|
-
|
|
263
|
-
// Join boundary splits that we do not consider to be boundaries and merge empty strings surrounded by word chars
|
|
264
|
-
for (let i = 0; i < tokens.length - 1; i++) {
|
|
265
|
-
if (
|
|
266
|
-
!tokens[i + 1] && tokens[i + 2] && words.test(tokens[i]) &&
|
|
267
|
-
words.test(tokens[i + 2])
|
|
268
|
-
) {
|
|
269
|
-
tokens[i] += tokens[i + 2];
|
|
270
|
-
tokens.splice(i + 1, 2);
|
|
271
|
-
i--;
|
|
272
|
-
}
|
|
273
|
-
}
|
|
274
|
-
return tokens.filter((token) => token);
|
|
275
|
-
} else {
|
|
276
|
-
// Split string on new lines symbols
|
|
277
|
-
const tokens = [], lines = string.split(/(\n|\r\n)/);
|
|
278
|
-
|
|
279
|
-
// Ignore final empty token when text ends with a newline
|
|
280
|
-
if (!lines[lines.length - 1]) {
|
|
281
|
-
lines.pop();
|
|
282
|
-
}
|
|
283
|
-
|
|
284
|
-
// Merge the content and line separators into single tokens
|
|
285
|
-
for (let i = 0; i < lines.length; i++) {
|
|
286
|
-
if (i % 2) {
|
|
287
|
-
tokens[tokens.length - 1] += lines[i];
|
|
288
|
-
} else {
|
|
289
|
-
tokens.push(lines[i]);
|
|
290
|
-
}
|
|
291
|
-
}
|
|
292
|
-
return tokens;
|
|
293
|
-
}
|
|
294
|
-
}
|
|
295
|
-
|
|
296
|
-
// Create details by filtering relevant word-diff for current line
|
|
297
|
-
// and merge "space-diff" if surrounded by word-diff for cleaner displays
|
|
298
|
-
function createDetails(
|
|
299
|
-
line: DiffResult<string>,
|
|
300
|
-
tokens: Array<DiffResult<string>>,
|
|
301
|
-
) {
|
|
302
|
-
return tokens.filter(({ type }) =>
|
|
303
|
-
type === line.type || type === DiffType.common
|
|
304
|
-
).map((result, i, t) => {
|
|
305
|
-
if (
|
|
306
|
-
(result.type === DiffType.common) && (t[i - 1]) &&
|
|
307
|
-
(t[i - 1]?.type === t[i + 1]?.type) && /\s+/.test(result.value)
|
|
308
|
-
) {
|
|
309
|
-
result.type = t[i - 1].type;
|
|
310
|
-
}
|
|
311
|
-
return result;
|
|
312
|
-
});
|
|
313
|
-
}
|
|
314
|
-
|
|
315
|
-
// Compute multi-line diff
|
|
316
|
-
const diffResult = diff(
|
|
317
|
-
tokenize(`${unescape(A)}\n`),
|
|
318
|
-
tokenize(`${unescape(B)}\n`),
|
|
319
|
-
);
|
|
320
|
-
|
|
321
|
-
const added = [], removed = [];
|
|
322
|
-
for (const result of diffResult) {
|
|
323
|
-
if (result.type === DiffType.added) {
|
|
324
|
-
added.push(result);
|
|
325
|
-
}
|
|
326
|
-
if (result.type === DiffType.removed) {
|
|
327
|
-
removed.push(result);
|
|
328
|
-
}
|
|
329
|
-
}
|
|
330
|
-
|
|
331
|
-
// Compute word-diff
|
|
332
|
-
const aLines = added.length < removed.length ? added : removed;
|
|
333
|
-
const bLines = aLines === removed ? added : removed;
|
|
334
|
-
for (const a of aLines) {
|
|
335
|
-
let tokens = [] as Array<DiffResult<string>>,
|
|
336
|
-
b: undefined | DiffResult<string>;
|
|
337
|
-
// Search another diff line with at least one common token
|
|
338
|
-
while (bLines.length) {
|
|
339
|
-
b = bLines.shift();
|
|
340
|
-
tokens = diff(
|
|
341
|
-
tokenize(a.value, { wordDiff: true }),
|
|
342
|
-
tokenize(b?.value ?? "", { wordDiff: true }),
|
|
343
|
-
);
|
|
344
|
-
if (
|
|
345
|
-
tokens.some(({ type, value }) =>
|
|
346
|
-
type === DiffType.common && value.trim().length
|
|
347
|
-
)
|
|
348
|
-
) {
|
|
349
|
-
break;
|
|
350
|
-
}
|
|
351
|
-
}
|
|
352
|
-
// Register word-diff details
|
|
353
|
-
a.details = createDetails(a, tokens);
|
|
354
|
-
if (b) {
|
|
355
|
-
b.details = createDetails(b, tokens);
|
|
356
|
-
}
|
|
357
|
-
}
|
|
358
|
-
|
|
359
|
-
return diffResult;
|
|
360
|
-
}
|