@solcreek/adapter-creek 0.1.4 → 0.2.1
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/cache-handler.d.ts +1 -1
- package/dist/cache-handler.js +3 -3
- package/dist/index.js +28 -14
- package/dist/worker-entry.js +13 -4
- package/package.json +2 -1
package/dist/cache-handler.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { default } from "@solcreek/adapter-core/cache-handler";
|
|
1
|
+
export { default } from "@solcreek/adapter-next-core/cache-handler";
|
|
2
2
|
//# sourceMappingURL=cache-handler.d.ts.map
|
package/dist/cache-handler.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
// Re-export the shared in-memory Next.js ISR cache handler from
|
|
2
|
-
// @solcreek/adapter-core. The implementation
|
|
3
|
-
// adapter-creek and adapter-creekd
|
|
2
|
+
// @solcreek/adapter-next-core. The implementation lives there so
|
|
3
|
+
// both adapter-creek and adapter-creekd share a single tested copy.
|
|
4
4
|
//
|
|
5
5
|
// This file exists for backwards compatibility: users who set
|
|
6
6
|
// `cacheHandler: require.resolve("@solcreek/adapter-creek/cache-handler")`
|
|
7
7
|
// in their next.config continue to work without changes. New users
|
|
8
8
|
// can wire either path; both resolve to the same module at runtime.
|
|
9
|
-
export { default } from "@solcreek/adapter-core/cache-handler";
|
|
9
|
+
export { default } from "@solcreek/adapter-next-core/cache-handler";
|
|
10
10
|
//# sourceMappingURL=cache-handler.js.map
|
package/dist/index.js
CHANGED
|
@@ -1,17 +1,26 @@
|
|
|
1
1
|
import * as path from "node:path";
|
|
2
|
-
import {
|
|
2
|
+
import { createRequire } from "node:module";
|
|
3
3
|
import { copyFileSync, existsSync } from "node:fs";
|
|
4
|
-
import { applyBaseModifyConfig } from "@solcreek/adapter-core";
|
|
4
|
+
import { applyBaseModifyConfig } from "@solcreek/adapter-next-core";
|
|
5
5
|
import { handleBuild } from "./build.js";
|
|
6
|
-
//
|
|
7
|
-
//
|
|
8
|
-
//
|
|
9
|
-
//
|
|
10
|
-
//
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
6
|
+
// Path to the cache handler shipped by @solcreek/adapter-next-core, resolved
|
|
7
|
+
// from THIS module's location — not from the consumer project. The adapter is
|
|
8
|
+
// not always installed in the project's own node_modules: the Creek CLI
|
|
9
|
+
// lazy-installs it into <project>/.creek/node_modules, which is outside the
|
|
10
|
+
// project's require walk. Resolving from import.meta.url walks up from
|
|
11
|
+
// wherever the adapter actually lives, so it finds the dependency under npm
|
|
12
|
+
// hoisting, pnpm's content-addressed store, and the CLI's .creek install
|
|
13
|
+
// alike.
|
|
14
|
+
function resolveCacheHandlerPath() {
|
|
15
|
+
try {
|
|
16
|
+
return createRequire(import.meta.url).resolve("@solcreek/adapter-next-core/cache-handler");
|
|
17
|
+
}
|
|
18
|
+
catch {
|
|
19
|
+
// Last resort: assume a flat install in the consumer project.
|
|
20
|
+
return path.join(process.cwd(), "node_modules", "@solcreek", "adapter-next-core", "dist", "cache-handler.js");
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
const fallbackCacheHandlerPath = resolveCacheHandlerPath();
|
|
15
24
|
function mirrorCacheHandlerIntoProject(cacheHandlerPath) {
|
|
16
25
|
if (!existsSync(cacheHandlerPath))
|
|
17
26
|
return cacheHandlerPath;
|
|
@@ -41,9 +50,14 @@ const adapter = {
|
|
|
41
50
|
// for other phases, so guarding here matches its behaviour.
|
|
42
51
|
if (ctx.phase !== "phase-production-build")
|
|
43
52
|
return baseConfig;
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
53
|
+
// Keep the mirrored handler anchored to this adapter's dependency tree,
|
|
54
|
+
// not the consumer project's shared @solcreek/adapter-next-core copy.
|
|
55
|
+
// For Workers the project-local .solcreek-cache-handler.mjs path is a
|
|
56
|
+
// bundler sentinel: dynamic imports of that path are redirected to the
|
|
57
|
+
// inline CreekCacheHandler in worker-entry. If we mirror an arbitrary
|
|
58
|
+
// project copy here, Node App Page fetch-cache paths can bypass the
|
|
59
|
+
// Workers-specific runtime cache implementation.
|
|
60
|
+
const cacheHandlerPath = mirrorCacheHandlerIntoProject(fallbackCacheHandlerPath);
|
|
47
61
|
return {
|
|
48
62
|
...baseConfig,
|
|
49
63
|
// Next may dynamically import this cache handler on error/404 render
|
package/dist/worker-entry.js
CHANGED
|
@@ -2693,6 +2693,10 @@ function __creekValueWithCacheTags(value, tags) {
|
|
|
2693
2693
|
function __creekScopedCacheKey(key, ctx, value) {
|
|
2694
2694
|
const isFetchEntry = ctx?.kind === "FETCH" || value?.kind === "FETCH";
|
|
2695
2695
|
if (!isFetchEntry) return key;
|
|
2696
|
+
const ctxRuntime = ctx?.runtime;
|
|
2697
|
+
if (ctxRuntime === "edge" || ctxRuntime === "nodejs") {
|
|
2698
|
+
return "__fetch:" + ctxRuntime + ":" + key;
|
|
2699
|
+
}
|
|
2696
2700
|
try {
|
|
2697
2701
|
const runtime = __INTERNAL_FETCH_CONTEXT.getStore()?.handlerRuntime;
|
|
2698
2702
|
if (runtime === "edge" || runtime === "nodejs") {
|
|
@@ -3020,15 +3024,18 @@ function __creekOriginalFetchArgs(input, init) {
|
|
|
3020
3024
|
}
|
|
3021
3025
|
if (init && typeof init === "object") {
|
|
3022
3026
|
const fetchInit = { ...init };
|
|
3027
|
+
const hasOriginalBody = "_ogBody" in fetchInit;
|
|
3023
3028
|
if ("_ogBody" in fetchInit) {
|
|
3024
3029
|
fetchInit.body = fetchInit._ogBody;
|
|
3025
3030
|
delete fetchInit._ogBody;
|
|
3026
3031
|
}
|
|
3027
3032
|
delete fetchInit.next;
|
|
3028
3033
|
delete fetchInit.cache;
|
|
3029
|
-
|
|
3030
|
-
|
|
3031
|
-
|
|
3034
|
+
if (hasOriginalBody && fetchInit.body !== undefined && fetchInit.body !== null) {
|
|
3035
|
+
try {
|
|
3036
|
+
return [new Request(input, fetchInit), undefined];
|
|
3037
|
+
} catch {}
|
|
3038
|
+
}
|
|
3032
3039
|
return [input, fetchInit];
|
|
3033
3040
|
}
|
|
3034
3041
|
return [input, init];
|
|
@@ -3131,9 +3138,11 @@ function __creekWrapAppPageFetchCache(patchedFetch) {
|
|
|
3131
3138
|
if (!cacheKey) return patchedFetch(input, init);
|
|
3132
3139
|
|
|
3133
3140
|
const tags = Array.isArray(nextConfig?.tags) ? nextConfig.tags : [];
|
|
3141
|
+
const cacheRuntime = store?.handlerRuntime === "edge" ? "edge" : "nodejs";
|
|
3134
3142
|
const cache = new CreekCacheHandler();
|
|
3135
3143
|
const cacheCtx = {
|
|
3136
3144
|
kind: "FETCH",
|
|
3145
|
+
runtime: cacheRuntime,
|
|
3137
3146
|
revalidate,
|
|
3138
3147
|
fetchUrl,
|
|
3139
3148
|
tags,
|
|
@@ -8234,7 +8243,7 @@ async function __handleRequestInner(request, env, ctx) {
|
|
|
8234
8243
|
try {
|
|
8235
8244
|
const store = __INTERNAL_FETCH_CONTEXT.getStore();
|
|
8236
8245
|
if (store) {
|
|
8237
|
-
store.handlerRuntime = handler.runtime;
|
|
8246
|
+
store.handlerRuntime = handler.runtime === "edge" ? "edge" : "nodejs";
|
|
8238
8247
|
store.handlerType = handler.type;
|
|
8239
8248
|
}
|
|
8240
8249
|
} catch {}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@solcreek/adapter-creek",
|
|
3
|
-
"version": "0.1
|
|
3
|
+
"version": "0.2.1",
|
|
4
4
|
"description": "Next.js deployment adapter for Creek (Cloudflare Workers)",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -46,6 +46,7 @@
|
|
|
46
46
|
"dependencies": {
|
|
47
47
|
"@next/routing": "16.2.3",
|
|
48
48
|
"@solcreek/adapter-core": "^0.2.0",
|
|
49
|
+
"@solcreek/adapter-next-core": "^0.1.1",
|
|
49
50
|
"sql.js": "^1.14.1",
|
|
50
51
|
"wrangler": "^4.82.2"
|
|
51
52
|
},
|