@cimplify/sdk 0.51.0 → 0.51.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/server.js +6 -100
- package/dist/server.mjs +2 -96
- package/package.json +1 -1
package/dist/server.js
CHANGED
|
@@ -5,7 +5,8 @@ require('./chunk-VOWMB2KR.js');
|
|
|
5
5
|
require('./chunk-6RP6OPYO.js');
|
|
6
6
|
var chunkTKOTACKZ_js = require('./chunk-TKOTACKZ.js');
|
|
7
7
|
var react = require('react');
|
|
8
|
-
var
|
|
8
|
+
var internal = require('@opennextjs/cloudflare/overrides/internal');
|
|
9
|
+
var cloudflareContext = require('@opennextjs/cloudflare/cloudflare-context');
|
|
9
10
|
|
|
10
11
|
var DEFAULT_PROD_URL = "https://storefronts.cimplify.io";
|
|
11
12
|
var DEFAULT_DEV_URL = "http://127.0.0.1:8787";
|
|
@@ -67,107 +68,12 @@ var tags = {
|
|
|
67
68
|
// src/server/cache-life.ts
|
|
68
69
|
var CACHE_LIFE_DEFAULT = "max";
|
|
69
70
|
var CACHE_LIFE_PROBE = "seconds";
|
|
70
|
-
|
|
71
|
-
// ../node_modules/.bun/@opennextjs+cloudflare@1.19.11+2f5a8389dca7b522/node_modules/@opennextjs/cloudflare/dist/api/cloudflare-context.js
|
|
72
|
-
var cloudflareContextSymbol = /* @__PURE__ */ Symbol.for("__cloudflare-context__");
|
|
73
|
-
function getCloudflareContext(options = { async: false }) {
|
|
74
|
-
return options.async ? getCloudflareContextAsync() : getCloudflareContextSync();
|
|
75
|
-
}
|
|
76
|
-
function getCloudflareContextFromGlobalScope() {
|
|
77
|
-
const global = globalThis;
|
|
78
|
-
return global[cloudflareContextSymbol];
|
|
79
|
-
}
|
|
80
|
-
function inSSG() {
|
|
81
|
-
const global = globalThis;
|
|
82
|
-
return global.__NEXT_DATA__?.nextExport === true;
|
|
83
|
-
}
|
|
84
|
-
function getCloudflareContextSync() {
|
|
85
|
-
const cloudflareContext = getCloudflareContextFromGlobalScope();
|
|
86
|
-
if (cloudflareContext) {
|
|
87
|
-
return cloudflareContext;
|
|
88
|
-
}
|
|
89
|
-
if (inSSG()) {
|
|
90
|
-
throw new Error(`
|
|
91
|
-
|
|
92
|
-
ERROR: \`getCloudflareContext\` has been called in sync mode in either a static route or at the top level of a non-static one, both cases are not allowed but can be solved by either:
|
|
93
|
-
- make sure that the call is not at the top level and that the route is not static
|
|
94
|
-
- call \`getCloudflareContext({async: true})\` to use the \`async\` mode
|
|
95
|
-
- avoid calling \`getCloudflareContext\` in the route
|
|
96
|
-
`);
|
|
97
|
-
}
|
|
98
|
-
throw new Error(initOpenNextCloudflareForDevErrorMsg);
|
|
99
|
-
}
|
|
100
|
-
async function getCloudflareContextAsync() {
|
|
101
|
-
const cloudflareContext = getCloudflareContextFromGlobalScope();
|
|
102
|
-
if (cloudflareContext) {
|
|
103
|
-
return cloudflareContext;
|
|
104
|
-
}
|
|
105
|
-
const inNodejsRuntime = process.env.NEXT_RUNTIME === "nodejs";
|
|
106
|
-
if (inNodejsRuntime || inSSG()) {
|
|
107
|
-
const cloudflareContext2 = await getCloudflareContextFromWrangler();
|
|
108
|
-
addCloudflareContextToNodejsGlobal(cloudflareContext2);
|
|
109
|
-
return cloudflareContext2;
|
|
110
|
-
}
|
|
111
|
-
throw new Error(initOpenNextCloudflareForDevErrorMsg);
|
|
112
|
-
}
|
|
113
|
-
function addCloudflareContextToNodejsGlobal(cloudflareContext) {
|
|
114
|
-
const global = globalThis;
|
|
115
|
-
global[cloudflareContextSymbol] = cloudflareContext;
|
|
116
|
-
}
|
|
117
|
-
async function getCloudflareContextFromWrangler(options) {
|
|
118
|
-
const { getPlatformProxy } = await import(
|
|
119
|
-
/* webpackIgnore: true */
|
|
120
|
-
`${"__wrangler".replaceAll("_", "")}`
|
|
121
|
-
);
|
|
122
|
-
const environment = process.env.NEXT_DEV_WRANGLER_ENV;
|
|
123
|
-
const { env, cf, ctx } = await getPlatformProxy({
|
|
124
|
-
...options,
|
|
125
|
-
// The `env` passed to the fetch handler does not contain variables from `.env*` files.
|
|
126
|
-
// because we invoke wrangler with `CLOUDFLARE_LOAD_DEV_VARS_FROM_DOT_ENV`=`"false"`.
|
|
127
|
-
// Initializing `envFiles` with an empty list is the equivalent for this API call.
|
|
128
|
-
envFiles: [],
|
|
129
|
-
environment
|
|
130
|
-
});
|
|
131
|
-
return {
|
|
132
|
-
env,
|
|
133
|
-
cf,
|
|
134
|
-
ctx
|
|
135
|
-
};
|
|
136
|
-
}
|
|
137
|
-
var initOpenNextCloudflareForDevErrorMsg = `
|
|
138
|
-
|
|
139
|
-
ERROR: \`getCloudflareContext\` has been called without having called \`initOpenNextCloudflareForDev\` from the Next.js config file.
|
|
140
|
-
You should update your Next.js config file as shown below:
|
|
141
|
-
|
|
142
|
-
\`\`\`
|
|
143
|
-
// next.config.mjs
|
|
144
|
-
|
|
145
|
-
import { initOpenNextCloudflareForDev } from "@opennextjs/cloudflare";
|
|
146
|
-
|
|
147
|
-
initOpenNextCloudflareForDev();
|
|
148
|
-
|
|
149
|
-
const nextConfig = { ... };
|
|
150
|
-
export default nextConfig;
|
|
151
|
-
\`\`\`
|
|
152
|
-
|
|
153
|
-
`;
|
|
154
|
-
|
|
155
|
-
// ../node_modules/.bun/@opennextjs+cloudflare@1.19.11+2f5a8389dca7b522/node_modules/@opennextjs/cloudflare/dist/api/overrides/internal.js
|
|
156
|
-
var FALLBACK_BUILD_ID = "no-build-id";
|
|
157
|
-
var DEFAULT_PREFIX = "incremental-cache";
|
|
158
|
-
function computeCacheKey(key, options) {
|
|
159
|
-
const { cacheType = "cache", prefix = DEFAULT_PREFIX, buildId = FALLBACK_BUILD_ID } = options;
|
|
160
|
-
const hash = crypto$1.createHash("sha256").update(key).digest("hex");
|
|
161
|
-
return `${prefix}/${buildId}/${hash}.${cacheType}`.replace(/\/+/g, "/");
|
|
162
|
-
}
|
|
163
|
-
|
|
164
|
-
// src/server/overrides/evict-incremental-cache.ts
|
|
165
71
|
var R2_BUCKET_BINDING = "NEXT_INC_CACHE_R2_BUCKET";
|
|
166
72
|
var R2_PREFIX_ENV = "NEXT_INC_CACHE_R2_PREFIX";
|
|
167
73
|
var PATH_INDEX_BINDING = "CIMPLIFY_PATH_INDEX";
|
|
168
74
|
var CIMPLIFY_TAG_PREFIX = "cimplify:";
|
|
169
75
|
function r2Key(env, key, cacheType) {
|
|
170
|
-
return computeCacheKey(key, {
|
|
76
|
+
return internal.computeCacheKey(key, {
|
|
171
77
|
prefix: env[R2_PREFIX_ENV],
|
|
172
78
|
buildId: globalThis.process?.env?.OPEN_NEXT_BUILD_ID,
|
|
173
79
|
cacheType
|
|
@@ -185,7 +91,7 @@ function pathIndexFor(env) {
|
|
|
185
91
|
var evictIncrementalCache = {
|
|
186
92
|
name: "cimplify-evict-r2-cache",
|
|
187
93
|
async get(key, cacheType) {
|
|
188
|
-
const env = getCloudflareContext().env;
|
|
94
|
+
const env = cloudflareContext.getCloudflareContext().env;
|
|
189
95
|
const r2 = env[R2_BUCKET_BINDING];
|
|
190
96
|
if (!r2) return null;
|
|
191
97
|
try {
|
|
@@ -200,7 +106,7 @@ var evictIncrementalCache = {
|
|
|
200
106
|
}
|
|
201
107
|
},
|
|
202
108
|
async set(key, value, cacheType) {
|
|
203
|
-
const env = getCloudflareContext().env;
|
|
109
|
+
const env = cloudflareContext.getCloudflareContext().env;
|
|
204
110
|
const r2 = env[R2_BUCKET_BINDING];
|
|
205
111
|
if (!r2) return;
|
|
206
112
|
const k = r2Key(env, key, cacheType);
|
|
@@ -219,7 +125,7 @@ var evictIncrementalCache = {
|
|
|
219
125
|
}
|
|
220
126
|
},
|
|
221
127
|
async delete(key) {
|
|
222
|
-
const env = getCloudflareContext().env;
|
|
128
|
+
const env = cloudflareContext.getCloudflareContext().env;
|
|
223
129
|
const r2 = env[R2_BUCKET_BINDING];
|
|
224
130
|
if (!r2) return;
|
|
225
131
|
try {
|
package/dist/server.mjs
CHANGED
|
@@ -3,7 +3,8 @@ import './chunk-FXACV333.mjs';
|
|
|
3
3
|
import './chunk-XY2DFX5K.mjs';
|
|
4
4
|
export { CimplifyError } from './chunk-Z2AYLZDF.mjs';
|
|
5
5
|
import { cache } from 'react';
|
|
6
|
-
import {
|
|
6
|
+
import { computeCacheKey } from '@opennextjs/cloudflare/overrides/internal';
|
|
7
|
+
import { getCloudflareContext } from '@opennextjs/cloudflare/cloudflare-context';
|
|
7
8
|
|
|
8
9
|
var DEFAULT_PROD_URL = "https://storefronts.cimplify.io";
|
|
9
10
|
var DEFAULT_DEV_URL = "http://127.0.0.1:8787";
|
|
@@ -65,101 +66,6 @@ var tags = {
|
|
|
65
66
|
// src/server/cache-life.ts
|
|
66
67
|
var CACHE_LIFE_DEFAULT = "max";
|
|
67
68
|
var CACHE_LIFE_PROBE = "seconds";
|
|
68
|
-
|
|
69
|
-
// ../node_modules/.bun/@opennextjs+cloudflare@1.19.11+2f5a8389dca7b522/node_modules/@opennextjs/cloudflare/dist/api/cloudflare-context.js
|
|
70
|
-
var cloudflareContextSymbol = /* @__PURE__ */ Symbol.for("__cloudflare-context__");
|
|
71
|
-
function getCloudflareContext(options = { async: false }) {
|
|
72
|
-
return options.async ? getCloudflareContextAsync() : getCloudflareContextSync();
|
|
73
|
-
}
|
|
74
|
-
function getCloudflareContextFromGlobalScope() {
|
|
75
|
-
const global = globalThis;
|
|
76
|
-
return global[cloudflareContextSymbol];
|
|
77
|
-
}
|
|
78
|
-
function inSSG() {
|
|
79
|
-
const global = globalThis;
|
|
80
|
-
return global.__NEXT_DATA__?.nextExport === true;
|
|
81
|
-
}
|
|
82
|
-
function getCloudflareContextSync() {
|
|
83
|
-
const cloudflareContext = getCloudflareContextFromGlobalScope();
|
|
84
|
-
if (cloudflareContext) {
|
|
85
|
-
return cloudflareContext;
|
|
86
|
-
}
|
|
87
|
-
if (inSSG()) {
|
|
88
|
-
throw new Error(`
|
|
89
|
-
|
|
90
|
-
ERROR: \`getCloudflareContext\` has been called in sync mode in either a static route or at the top level of a non-static one, both cases are not allowed but can be solved by either:
|
|
91
|
-
- make sure that the call is not at the top level and that the route is not static
|
|
92
|
-
- call \`getCloudflareContext({async: true})\` to use the \`async\` mode
|
|
93
|
-
- avoid calling \`getCloudflareContext\` in the route
|
|
94
|
-
`);
|
|
95
|
-
}
|
|
96
|
-
throw new Error(initOpenNextCloudflareForDevErrorMsg);
|
|
97
|
-
}
|
|
98
|
-
async function getCloudflareContextAsync() {
|
|
99
|
-
const cloudflareContext = getCloudflareContextFromGlobalScope();
|
|
100
|
-
if (cloudflareContext) {
|
|
101
|
-
return cloudflareContext;
|
|
102
|
-
}
|
|
103
|
-
const inNodejsRuntime = process.env.NEXT_RUNTIME === "nodejs";
|
|
104
|
-
if (inNodejsRuntime || inSSG()) {
|
|
105
|
-
const cloudflareContext2 = await getCloudflareContextFromWrangler();
|
|
106
|
-
addCloudflareContextToNodejsGlobal(cloudflareContext2);
|
|
107
|
-
return cloudflareContext2;
|
|
108
|
-
}
|
|
109
|
-
throw new Error(initOpenNextCloudflareForDevErrorMsg);
|
|
110
|
-
}
|
|
111
|
-
function addCloudflareContextToNodejsGlobal(cloudflareContext) {
|
|
112
|
-
const global = globalThis;
|
|
113
|
-
global[cloudflareContextSymbol] = cloudflareContext;
|
|
114
|
-
}
|
|
115
|
-
async function getCloudflareContextFromWrangler(options) {
|
|
116
|
-
const { getPlatformProxy } = await import(
|
|
117
|
-
/* webpackIgnore: true */
|
|
118
|
-
`${"__wrangler".replaceAll("_", "")}`
|
|
119
|
-
);
|
|
120
|
-
const environment = process.env.NEXT_DEV_WRANGLER_ENV;
|
|
121
|
-
const { env, cf, ctx } = await getPlatformProxy({
|
|
122
|
-
...options,
|
|
123
|
-
// The `env` passed to the fetch handler does not contain variables from `.env*` files.
|
|
124
|
-
// because we invoke wrangler with `CLOUDFLARE_LOAD_DEV_VARS_FROM_DOT_ENV`=`"false"`.
|
|
125
|
-
// Initializing `envFiles` with an empty list is the equivalent for this API call.
|
|
126
|
-
envFiles: [],
|
|
127
|
-
environment
|
|
128
|
-
});
|
|
129
|
-
return {
|
|
130
|
-
env,
|
|
131
|
-
cf,
|
|
132
|
-
ctx
|
|
133
|
-
};
|
|
134
|
-
}
|
|
135
|
-
var initOpenNextCloudflareForDevErrorMsg = `
|
|
136
|
-
|
|
137
|
-
ERROR: \`getCloudflareContext\` has been called without having called \`initOpenNextCloudflareForDev\` from the Next.js config file.
|
|
138
|
-
You should update your Next.js config file as shown below:
|
|
139
|
-
|
|
140
|
-
\`\`\`
|
|
141
|
-
// next.config.mjs
|
|
142
|
-
|
|
143
|
-
import { initOpenNextCloudflareForDev } from "@opennextjs/cloudflare";
|
|
144
|
-
|
|
145
|
-
initOpenNextCloudflareForDev();
|
|
146
|
-
|
|
147
|
-
const nextConfig = { ... };
|
|
148
|
-
export default nextConfig;
|
|
149
|
-
\`\`\`
|
|
150
|
-
|
|
151
|
-
`;
|
|
152
|
-
|
|
153
|
-
// ../node_modules/.bun/@opennextjs+cloudflare@1.19.11+2f5a8389dca7b522/node_modules/@opennextjs/cloudflare/dist/api/overrides/internal.js
|
|
154
|
-
var FALLBACK_BUILD_ID = "no-build-id";
|
|
155
|
-
var DEFAULT_PREFIX = "incremental-cache";
|
|
156
|
-
function computeCacheKey(key, options) {
|
|
157
|
-
const { cacheType = "cache", prefix = DEFAULT_PREFIX, buildId = FALLBACK_BUILD_ID } = options;
|
|
158
|
-
const hash = createHash("sha256").update(key).digest("hex");
|
|
159
|
-
return `${prefix}/${buildId}/${hash}.${cacheType}`.replace(/\/+/g, "/");
|
|
160
|
-
}
|
|
161
|
-
|
|
162
|
-
// src/server/overrides/evict-incremental-cache.ts
|
|
163
69
|
var R2_BUCKET_BINDING = "NEXT_INC_CACHE_R2_BUCKET";
|
|
164
70
|
var R2_PREFIX_ENV = "NEXT_INC_CACHE_R2_PREFIX";
|
|
165
71
|
var PATH_INDEX_BINDING = "CIMPLIFY_PATH_INDEX";
|