@opennextjs/aws 4.1.7 → 4.1.8
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.
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
export declare const rule = "\nrule:\n kind: binary_expression\n all:\n - has:\n kind:
|
|
1
|
+
export declare const rule = "\nrule:\n kind: binary_expression\n # The names are mangled in the minified runtimes\n pattern: \"!$ENTRY.isStale || $CONTEXT.isPrefetch\"\n all:\n # It has to be the whole check, not a part of a bigger expression\n - not:\n inside:\n kind: binary_expression\n # It has to be guarded by the on-demand revalidation check\n - inside:\n kind: if_statement\n stopBy: end\n has:\n field: condition\n stopBy: end\n any:\n # Next 15.5+ and its minified runtime copies use the same context object\n - pattern: \"!$CONTEXT.isOnDemandRevalidate\"\n # Earlier unminified versions keep this flag in a local\n - pattern: \"!isOnDemandRevalidate\"\nfix:\n 'true'";
|
|
2
2
|
export declare const patchBackgroundRevalidation: {
|
|
3
3
|
name: string;
|
|
4
4
|
patches: {
|
|
5
5
|
versions: ">=14.1.0";
|
|
6
6
|
pathFilter: RegExp;
|
|
7
|
+
contentFilter: RegExp;
|
|
7
8
|
patchCode: import("../codePatcher.js").PatchCodeFn;
|
|
8
9
|
}[];
|
|
9
10
|
};
|
|
@@ -1,15 +1,31 @@
|
|
|
1
1
|
import { getCrossPlatformPathRegex } from "../../../utils/regex.js";
|
|
2
2
|
import { createPatchCode } from "../astCodePatcher.js";
|
|
3
|
+
// Matches the check that decides whether a cached entry can be served as is in `ResponseCache.get`:
|
|
4
|
+
// if (entry && !context.isOnDemandRevalidate) { ...; if (!entry.isStale || context.isPrefetch) return ... }
|
|
5
|
+
// which is minified in the compiled runtimes as:
|
|
6
|
+
// if ((a = ...) && !r.isOnDemandRevalidate && (n(a), i = !0, !a.isStale || r.isPrefetch)) return a;
|
|
3
7
|
export const rule = `
|
|
4
8
|
rule:
|
|
5
9
|
kind: binary_expression
|
|
10
|
+
# The names are mangled in the minified runtimes
|
|
11
|
+
pattern: "!$ENTRY.isStale || $CONTEXT.isPrefetch"
|
|
6
12
|
all:
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
+
# It has to be the whole check, not a part of a bigger expression
|
|
14
|
+
- not:
|
|
15
|
+
inside:
|
|
16
|
+
kind: binary_expression
|
|
17
|
+
# It has to be guarded by the on-demand revalidation check
|
|
18
|
+
- inside:
|
|
19
|
+
kind: if_statement
|
|
20
|
+
stopBy: end
|
|
21
|
+
has:
|
|
22
|
+
field: condition
|
|
23
|
+
stopBy: end
|
|
24
|
+
any:
|
|
25
|
+
# Next 15.5+ and its minified runtime copies use the same context object
|
|
26
|
+
- pattern: "!$CONTEXT.isOnDemandRevalidate"
|
|
27
|
+
# Earlier unminified versions keep this flag in a local
|
|
28
|
+
- pattern: "!isOnDemandRevalidate"
|
|
13
29
|
fix:
|
|
14
30
|
'true'`;
|
|
15
31
|
export const patchBackgroundRevalidation = {
|
|
@@ -18,7 +34,10 @@ export const patchBackgroundRevalidation = {
|
|
|
18
34
|
{
|
|
19
35
|
// TODO: test for earlier versions of Next
|
|
20
36
|
versions: ">=14.1.0",
|
|
21
|
-
|
|
37
|
+
// Since Next 15.5 route modules use their own `ResponseCache`, which is inlined (and minified)
|
|
38
|
+
// in `next/dist/compiled/next-server/*.runtime.prod.js`
|
|
39
|
+
pathFilter: getCrossPlatformPathRegex(String.raw `(server/response-cache/index\.js|\.runtime\.prod\.js)$`, { escape: false }),
|
|
40
|
+
contentFilter: /\.isStale\s*\|\|\s*[\w$]+\.isPrefetch/,
|
|
22
41
|
patchCode: createPatchCode(rule),
|
|
23
42
|
},
|
|
24
43
|
],
|
package/dist/utils/promise.d.ts
CHANGED
|
@@ -13,8 +13,25 @@ export declare class DetachedPromise<T = any> {
|
|
|
13
13
|
}
|
|
14
14
|
export declare class DetachedPromiseRunner {
|
|
15
15
|
private promises;
|
|
16
|
+
/**
|
|
17
|
+
* Create a deferred promise tracked by this runner.
|
|
18
|
+
*
|
|
19
|
+
* @returns The tracked promise and its resolve/reject functions.
|
|
20
|
+
*/
|
|
16
21
|
withResolvers<T>(): DetachedPromise<T>;
|
|
22
|
+
/**
|
|
23
|
+
* Track background work and handle failures immediately.
|
|
24
|
+
*
|
|
25
|
+
* @param promise Work to await, including work registered during an active drain.
|
|
26
|
+
* @returns Nothing; failures are logged rather than propagated.
|
|
27
|
+
*/
|
|
17
28
|
add<T>(promise: Promise<T>): void;
|
|
29
|
+
/**
|
|
30
|
+
* Drain tracked work, including additions made while earlier work is pending.
|
|
31
|
+
*
|
|
32
|
+
* Work started after the drain has settled still needs a new runtime waitUntil.
|
|
33
|
+
* @returns Resolves when all work registered during this drain has settled.
|
|
34
|
+
*/
|
|
18
35
|
await(): Promise<void>;
|
|
19
36
|
}
|
|
20
37
|
export declare function runWithOpenNextRequestContext<T>({ isISRRevalidation, waitUntil, requestId, }: {
|
package/dist/utils/promise.js
CHANGED
|
@@ -28,23 +28,41 @@ export class DetachedPromise {
|
|
|
28
28
|
}
|
|
29
29
|
export class DetachedPromiseRunner {
|
|
30
30
|
promises = [];
|
|
31
|
+
/**
|
|
32
|
+
* Create a deferred promise tracked by this runner.
|
|
33
|
+
*
|
|
34
|
+
* @returns The tracked promise and its resolve/reject functions.
|
|
35
|
+
*/
|
|
31
36
|
withResolvers() {
|
|
32
37
|
const detachedPromise = new DetachedPromise();
|
|
33
|
-
this.
|
|
38
|
+
this.add(detachedPromise.promise);
|
|
34
39
|
return detachedPromise;
|
|
35
40
|
}
|
|
41
|
+
/**
|
|
42
|
+
* Track background work and handle failures immediately.
|
|
43
|
+
*
|
|
44
|
+
* @param promise Work to await, including work registered during an active drain.
|
|
45
|
+
* @returns Nothing; failures are logged rather than propagated.
|
|
46
|
+
*/
|
|
36
47
|
add(promise) {
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
promise.then(
|
|
48
|
+
// A late promise may reject before the current batch finishes. Attach its
|
|
49
|
+
// rejection handler now so it cannot become an unhandled rejection.
|
|
50
|
+
this.promises.push(promise.then(() => { }, error));
|
|
40
51
|
}
|
|
52
|
+
/**
|
|
53
|
+
* Drain tracked work, including additions made while earlier work is pending.
|
|
54
|
+
*
|
|
55
|
+
* Work started after the drain has settled still needs a new runtime waitUntil.
|
|
56
|
+
* @returns Resolves when all work registered during this drain has settled.
|
|
57
|
+
*/
|
|
41
58
|
async await() {
|
|
42
59
|
debug(`Awaiting ${this.promises.length} detached promises`);
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
60
|
+
let awaited = 0;
|
|
61
|
+
while (awaited < this.promises.length) {
|
|
62
|
+
const batch = this.promises.slice(awaited);
|
|
63
|
+
awaited = this.promises.length;
|
|
64
|
+
await Promise.all(batch);
|
|
65
|
+
}
|
|
48
66
|
}
|
|
49
67
|
}
|
|
50
68
|
async function awaitAllDetachedPromise() {
|