@opennextjs/aws 4.1.14 → 4.1.16
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/adapters/cache.js +2 -1
- package/dist/adapters/composable-cache.d.ts +20 -0
- package/dist/adapters/composable-cache.js +33 -8
- package/dist/adapters/edge-adapter.js +2 -11
- package/dist/core/requestHandler.d.ts +17 -0
- package/dist/core/requestHandler.js +48 -18
- package/dist/core/revalidate.js +1 -0
- package/dist/core/routing/cacheInterceptor.js +28 -24
- package/dist/core/routing/matcher.d.ts +14 -1
- package/dist/core/routing/matcher.js +41 -9
- package/dist/core/routing/middleware.d.ts +4 -0
- package/dist/core/routing/middleware.js +22 -0
- package/dist/core/routing/routeParamPlaceholder.d.ts +14 -0
- package/dist/core/routing/routeParamPlaceholder.js +42 -0
- package/dist/core/routing/util.js +10 -2
- package/dist/core/routingHandler.d.ts +2 -0
- package/dist/core/routingHandler.js +39 -29
- package/dist/http/framing.d.ts +35 -0
- package/dist/http/framing.js +181 -0
- package/dist/http/util.d.ts +11 -0
- package/dist/http/util.js +26 -0
- package/dist/minimize-js.d.ts +9 -0
- package/dist/minimize-js.js +27 -26
- package/dist/overrides/proxyExternalRequest/fetch.js +5 -1
- package/dist/overrides/proxyExternalRequest/node.js +5 -0
- package/dist/overrides/wrappers/express-dev.js +3 -5
- package/dist/overrides/wrappers/node.js +2 -3
- package/dist/types/global.d.ts +12 -0
- package/dist/utils/cache.d.ts +14 -0
- package/dist/utils/cache.js +20 -0
- package/dist/utils/normalize-path.d.ts +15 -0
- package/dist/utils/normalize-path.js +32 -0
- package/package.json +5 -5
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { createServer } from "node:http";
|
|
2
|
+
import { writeResponseHead } from "../../http/framing.js";
|
|
2
3
|
import { debug, error } from "../../adapters/logger";
|
|
3
4
|
const wrapper = async (handler, converter) => {
|
|
4
5
|
const server = createServer(async (req, res) => {
|
|
@@ -7,9 +8,7 @@ const wrapper = async (handler, converter) => {
|
|
|
7
8
|
const streamCreator = {
|
|
8
9
|
writeHeaders: (prelude) => {
|
|
9
10
|
res.setHeader("Set-Cookie", prelude.cookies);
|
|
10
|
-
res.
|
|
11
|
-
res.flushHeaders();
|
|
12
|
-
return res;
|
|
11
|
+
return writeResponseHead(res, req.method, prelude.statusCode, prelude.headers);
|
|
13
12
|
},
|
|
14
13
|
abortSignal: abortController.signal,
|
|
15
14
|
};
|
package/dist/types/global.d.ts
CHANGED
|
@@ -52,7 +52,19 @@ interface OpenNextRequestContext {
|
|
|
52
52
|
pendingPromiseRunner: DetachedPromiseRunner;
|
|
53
53
|
isISRRevalidation?: boolean;
|
|
54
54
|
mergeHeadersPriority?: "middleware" | "handler";
|
|
55
|
+
/**
|
|
56
|
+
* Last modified time of the page (used in main functions, only available for ISR/SSG).
|
|
57
|
+
*
|
|
58
|
+
* `1` when the entry is stale by tag, so that the revalidation queue deduplicates every stale
|
|
59
|
+
* request for the same path. See `entryLastModified` for the time of the entry.
|
|
60
|
+
*/
|
|
55
61
|
lastModified?: number;
|
|
62
|
+
/**
|
|
63
|
+
* Last modified time of the cache entry, also when it is stale by tag (`lastModified` is then `1`).
|
|
64
|
+
*
|
|
65
|
+
* Sent to the revalidation queue in `MessageBody.lastModified`.
|
|
66
|
+
*/
|
|
67
|
+
entryLastModified?: number;
|
|
56
68
|
waitUntil?: WaitUntil;
|
|
57
69
|
/** We use this to deduplicate write of the tags*/
|
|
58
70
|
writtenTags: Set<string>;
|
package/dist/utils/cache.d.ts
CHANGED
|
@@ -1,4 +1,18 @@
|
|
|
1
1
|
import type { CacheValue, NextModeTagCacheWriteInput, OriginalTagCacheWriteInput, WithLastModified } from "../types/overrides.js";
|
|
2
|
+
/**
|
|
3
|
+
* Computes the key used to store a composable (`"use cache"`) entry.
|
|
4
|
+
*
|
|
5
|
+
* The cache key provided by Next.js embeds the serialized arguments of the cached function and may
|
|
6
|
+
* contain any UTF-16 string. Storage backends transform keys (path normalization, URL parsing,
|
|
7
|
+
* UTF-8 encoding, ...) which could map distinct Next.js keys to the same stored entry.
|
|
8
|
+
*
|
|
9
|
+
* The storage key is the sha256 of the exact UTF-16 code units of the cache key, as a 64 characters
|
|
10
|
+
* lowercase hex string that every backend can store as is.
|
|
11
|
+
*
|
|
12
|
+
* @param cacheKey The cache key provided by Next.js
|
|
13
|
+
* @returns The key to use for the incremental cache and the tag cache
|
|
14
|
+
*/
|
|
15
|
+
export declare function getComposableCacheStorageKey(cacheKey: string): string;
|
|
2
16
|
/**
|
|
3
17
|
*
|
|
4
18
|
* @param key The key for that specific cache entry
|
package/dist/utils/cache.js
CHANGED
|
@@ -1,6 +1,26 @@
|
|
|
1
|
+
import { Buffer } from "node:buffer";
|
|
2
|
+
import { createHash } from "node:crypto";
|
|
1
3
|
import { debug } from "../adapters/logger";
|
|
2
4
|
import { CACHE_TAGS_HEADER } from "./cacheHeaders";
|
|
3
5
|
import { compareSemver } from "./semver";
|
|
6
|
+
/**
|
|
7
|
+
* Computes the key used to store a composable (`"use cache"`) entry.
|
|
8
|
+
*
|
|
9
|
+
* The cache key provided by Next.js embeds the serialized arguments of the cached function and may
|
|
10
|
+
* contain any UTF-16 string. Storage backends transform keys (path normalization, URL parsing,
|
|
11
|
+
* UTF-8 encoding, ...) which could map distinct Next.js keys to the same stored entry.
|
|
12
|
+
*
|
|
13
|
+
* The storage key is the sha256 of the exact UTF-16 code units of the cache key, as a 64 characters
|
|
14
|
+
* lowercase hex string that every backend can store as is.
|
|
15
|
+
*
|
|
16
|
+
* @param cacheKey The cache key provided by Next.js
|
|
17
|
+
* @returns The key to use for the incremental cache and the tag cache
|
|
18
|
+
*/
|
|
19
|
+
export function getComposableCacheStorageKey(cacheKey) {
|
|
20
|
+
return createHash("sha256")
|
|
21
|
+
.update(Buffer.from(cacheKey, "utf16le"))
|
|
22
|
+
.digest("hex");
|
|
23
|
+
}
|
|
4
24
|
/**
|
|
5
25
|
*
|
|
6
26
|
* @param key The key for that specific cache entry
|
|
@@ -1,3 +1,18 @@
|
|
|
1
1
|
export declare function normalizePath(path: string): string;
|
|
2
2
|
export declare function normalizeRepeatedSlashes(url: URL): string;
|
|
3
|
+
/**
|
|
4
|
+
* Decodes a pathname the way Next.js does to key prerendered routes.
|
|
5
|
+
*
|
|
6
|
+
* Each segment is decoded while path delimiters (e.g. `%2F`) stay encoded,
|
|
7
|
+
* so that an encoded delimiter does not split a segment.
|
|
8
|
+
* Decoding must be atomic, as in Next.js: partially decoding a malformed path
|
|
9
|
+
* could select a different route than the one Next.js would select.
|
|
10
|
+
*
|
|
11
|
+
* See: https://github.com/vercel/next.js/blob/3403955/packages/next/src/server/lib/router-utils/decode-path-params.ts#L11-L26
|
|
12
|
+
*
|
|
13
|
+
* @param pathname The percent-encoded pathname
|
|
14
|
+
* @returns The decoded pathname
|
|
15
|
+
* @throws {URIError} When the pathname contains a malformed escape sequence
|
|
16
|
+
*/
|
|
17
|
+
export declare function decodePathParams(pathname: string): string;
|
|
3
18
|
export declare function getMonorepoRelativePath(relativePath?: string): string;
|
|
@@ -9,6 +9,38 @@ export function normalizeRepeatedSlashes(url) {
|
|
|
9
9
|
.replace(/\\/g, "/")
|
|
10
10
|
.replace(/\/\/+/g, "/")}${url.search}`;
|
|
11
11
|
}
|
|
12
|
+
/**
|
|
13
|
+
* Percent-encodes the path delimiters of a decoded path segment.
|
|
14
|
+
*
|
|
15
|
+
* See: https://github.com/vercel/next.js/blob/3403955/packages/next/src/shared/lib/router/utils/escape-path-delimiters.ts#L2-L10
|
|
16
|
+
*
|
|
17
|
+
* @param segment The decoded path segment
|
|
18
|
+
* @param escapeEncoded Whether to also escape already encoded delimiters (e.g. `%2F`)
|
|
19
|
+
* @returns The segment with its delimiters encoded
|
|
20
|
+
*/
|
|
21
|
+
function escapePathDelimiters(segment, escapeEncoded) {
|
|
22
|
+
return segment.replace(new RegExp(`([/#?]${escapeEncoded ? "|%(2f|23|3f|5c)" : ""})`, "gi"), (char) => encodeURIComponent(char));
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Decodes a pathname the way Next.js does to key prerendered routes.
|
|
26
|
+
*
|
|
27
|
+
* Each segment is decoded while path delimiters (e.g. `%2F`) stay encoded,
|
|
28
|
+
* so that an encoded delimiter does not split a segment.
|
|
29
|
+
* Decoding must be atomic, as in Next.js: partially decoding a malformed path
|
|
30
|
+
* could select a different route than the one Next.js would select.
|
|
31
|
+
*
|
|
32
|
+
* See: https://github.com/vercel/next.js/blob/3403955/packages/next/src/server/lib/router-utils/decode-path-params.ts#L11-L26
|
|
33
|
+
*
|
|
34
|
+
* @param pathname The percent-encoded pathname
|
|
35
|
+
* @returns The decoded pathname
|
|
36
|
+
* @throws {URIError} When the pathname contains a malformed escape sequence
|
|
37
|
+
*/
|
|
38
|
+
export function decodePathParams(pathname) {
|
|
39
|
+
return pathname
|
|
40
|
+
.split("/")
|
|
41
|
+
.map((segment) => escapePathDelimiters(decodeURIComponent(segment), true))
|
|
42
|
+
.join("/");
|
|
43
|
+
}
|
|
12
44
|
export function getMonorepoRelativePath(relativePath = "../..") {
|
|
13
45
|
return path.join(globalThis.monorepoPackagePath
|
|
14
46
|
.split("/")
|
package/package.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"access": "public"
|
|
4
4
|
},
|
|
5
5
|
"name": "@opennextjs/aws",
|
|
6
|
-
"version": "4.1.
|
|
6
|
+
"version": "4.1.16",
|
|
7
7
|
"bin": {
|
|
8
8
|
"open-next": "./dist/index.js"
|
|
9
9
|
},
|
|
@@ -39,8 +39,8 @@
|
|
|
39
39
|
"@aws-sdk/client-lambda": "3.984.0",
|
|
40
40
|
"@aws-sdk/client-s3": "3.984.0",
|
|
41
41
|
"@aws-sdk/client-sqs": "3.984.0",
|
|
42
|
-
"@node-minify/core": "^
|
|
43
|
-
"@node-minify/terser": "^
|
|
42
|
+
"@node-minify/core": "^10.5.0",
|
|
43
|
+
"@node-minify/terser": "^10.5.0",
|
|
44
44
|
"@tsconfig/node18": "^18.2.7",
|
|
45
45
|
"aws4fetch": "^1.0.20",
|
|
46
46
|
"chalk": "^5.6.2",
|
|
@@ -57,13 +57,13 @@
|
|
|
57
57
|
"@types/node": "20.17.6",
|
|
58
58
|
"concurrently": "^9.2.4",
|
|
59
59
|
"diff": "^9.0.0",
|
|
60
|
-
"next": "16.4.
|
|
60
|
+
"next": "16.4.5",
|
|
61
61
|
"tsc-alias": "^1.9.7",
|
|
62
62
|
"typescript": "5.9.3"
|
|
63
63
|
},
|
|
64
64
|
"peerDependencies": {
|
|
65
65
|
"diff": "^9.0.0",
|
|
66
|
-
"next": ">=15.5.
|
|
66
|
+
"next": ">=15.5.29 <16 || >=16.4.5"
|
|
67
67
|
},
|
|
68
68
|
"peerDependenciesMeta": {
|
|
69
69
|
"diff": {
|