@commercengine/storefront-sdk-nextjs 0.1.0-alpha.0 → 0.1.0
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/README.md +534 -139
- package/dist/client.cjs +136 -0
- package/dist/client.d.cts +17 -0
- package/dist/client.d.cts.map +1 -0
- package/dist/client.d.ts +17 -0
- package/dist/client.d.ts.map +1 -0
- package/dist/client.js +44 -0
- package/dist/client.js.map +1 -0
- package/dist/index.cjs +128 -319
- package/dist/index.d.cts +34 -107
- package/dist/index.d.cts.map +1 -0
- package/dist/index.d.ts +34 -107
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +55 -303
- package/dist/index.js.map +1 -0
- package/dist/sdk-manager-B9xDQQuv.d.ts +141 -0
- package/dist/sdk-manager-B9xDQQuv.d.ts.map +1 -0
- package/dist/sdk-manager-CdgrfSVp.js +343 -0
- package/dist/sdk-manager-CdgrfSVp.js.map +1 -0
- package/dist/sdk-manager-D2ktqPrp.d.cts +141 -0
- package/dist/sdk-manager-D2ktqPrp.d.cts.map +1 -0
- package/dist/sdk-manager-NWADjRFW.cjs +400 -0
- package/dist/server.cjs +102 -0
- package/dist/server.d.cts +4 -0
- package/dist/server.d.ts +4 -0
- package/dist/server.js +6 -0
- package/package.json +21 -11
|
@@ -0,0 +1,400 @@
|
|
|
1
|
+
//#region rolldown:runtime
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __copyProps = (to, from, except, desc) => {
|
|
9
|
+
if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
|
|
10
|
+
key = keys[i];
|
|
11
|
+
if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
12
|
+
get: ((k) => from[k]).bind(null, key),
|
|
13
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
14
|
+
});
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
|
|
19
|
+
value: mod,
|
|
20
|
+
enumerable: true
|
|
21
|
+
}) : target, mod));
|
|
22
|
+
|
|
23
|
+
//#endregion
|
|
24
|
+
const react = __toESM(require("react"));
|
|
25
|
+
const __commercengine_storefront_sdk = __toESM(require("@commercengine/storefront-sdk"));
|
|
26
|
+
|
|
27
|
+
//#region src/token-storage.ts
|
|
28
|
+
/**
|
|
29
|
+
* Client-side token storage that uses document.cookie
|
|
30
|
+
*/
|
|
31
|
+
var ClientTokenStorage = class {
|
|
32
|
+
constructor(options = {}) {
|
|
33
|
+
const prefix = options.prefix || "ce_";
|
|
34
|
+
this.accessTokenKey = `${prefix}access_token`;
|
|
35
|
+
this.refreshTokenKey = `${prefix}refresh_token`;
|
|
36
|
+
this.options = {
|
|
37
|
+
maxAge: options.maxAge || 720 * 60 * 60,
|
|
38
|
+
path: options.path || "/",
|
|
39
|
+
domain: options.domain,
|
|
40
|
+
secure: options.secure ?? (typeof window !== "undefined" && window.location?.protocol === "https:"),
|
|
41
|
+
sameSite: options.sameSite || "Lax"
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
async getAccessToken() {
|
|
45
|
+
return this.getCookie(this.accessTokenKey);
|
|
46
|
+
}
|
|
47
|
+
async setAccessToken(token) {
|
|
48
|
+
this.setCookie(this.accessTokenKey, token);
|
|
49
|
+
}
|
|
50
|
+
async getRefreshToken() {
|
|
51
|
+
return this.getCookie(this.refreshTokenKey);
|
|
52
|
+
}
|
|
53
|
+
async setRefreshToken(token) {
|
|
54
|
+
this.setCookie(this.refreshTokenKey, token);
|
|
55
|
+
}
|
|
56
|
+
async clearTokens() {
|
|
57
|
+
this.deleteCookie(this.accessTokenKey);
|
|
58
|
+
this.deleteCookie(this.refreshTokenKey);
|
|
59
|
+
}
|
|
60
|
+
getCookie(name) {
|
|
61
|
+
if (typeof document === "undefined") return null;
|
|
62
|
+
const value = `; ${document.cookie}`;
|
|
63
|
+
const parts = value.split(`; ${name}=`);
|
|
64
|
+
if (parts.length === 2) {
|
|
65
|
+
const cookieValue = parts.pop()?.split(";").shift();
|
|
66
|
+
return cookieValue ? decodeURIComponent(cookieValue) : null;
|
|
67
|
+
}
|
|
68
|
+
return null;
|
|
69
|
+
}
|
|
70
|
+
setCookie(name, value) {
|
|
71
|
+
if (typeof document === "undefined") return;
|
|
72
|
+
const encodedValue = encodeURIComponent(value);
|
|
73
|
+
let cookieString = `${name}=${encodedValue}`;
|
|
74
|
+
if (this.options.maxAge) cookieString += `; Max-Age=${this.options.maxAge}`;
|
|
75
|
+
if (this.options.path) cookieString += `; Path=${this.options.path}`;
|
|
76
|
+
if (this.options.domain) cookieString += `; Domain=${this.options.domain}`;
|
|
77
|
+
if (this.options.secure) cookieString += `; Secure`;
|
|
78
|
+
if (this.options.sameSite) cookieString += `; SameSite=${this.options.sameSite}`;
|
|
79
|
+
document.cookie = cookieString;
|
|
80
|
+
}
|
|
81
|
+
deleteCookie(name) {
|
|
82
|
+
if (typeof document === "undefined") return;
|
|
83
|
+
let cookieString = `${name}=; Max-Age=0`;
|
|
84
|
+
if (this.options.path) cookieString += `; Path=${this.options.path}`;
|
|
85
|
+
if (this.options.domain) cookieString += `; Domain=${this.options.domain}`;
|
|
86
|
+
document.cookie = cookieString;
|
|
87
|
+
}
|
|
88
|
+
};
|
|
89
|
+
/**
|
|
90
|
+
* Server-side token storage that uses Next.js cookies API
|
|
91
|
+
*/
|
|
92
|
+
var ServerTokenStorage = class {
|
|
93
|
+
constructor(cookieStore, options = {}) {
|
|
94
|
+
const prefix = options.prefix || "ce_";
|
|
95
|
+
this.accessTokenKey = `${prefix}access_token`;
|
|
96
|
+
this.refreshTokenKey = `${prefix}refresh_token`;
|
|
97
|
+
this.cookieStore = cookieStore;
|
|
98
|
+
this.options = {
|
|
99
|
+
maxAge: options.maxAge || 720 * 60 * 60,
|
|
100
|
+
path: options.path || "/",
|
|
101
|
+
domain: options.domain,
|
|
102
|
+
secure: options.secure ?? process.env.NODE_ENV === "production",
|
|
103
|
+
sameSite: options.sameSite || "Lax"
|
|
104
|
+
};
|
|
105
|
+
}
|
|
106
|
+
async getAccessToken() {
|
|
107
|
+
try {
|
|
108
|
+
return this.cookieStore.get(this.accessTokenKey)?.value || null;
|
|
109
|
+
} catch (error) {
|
|
110
|
+
console.warn(`Could not get access token from server cookies:`, error);
|
|
111
|
+
return null;
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
async setAccessToken(token) {
|
|
115
|
+
try {
|
|
116
|
+
this.cookieStore.set(this.accessTokenKey, token, {
|
|
117
|
+
maxAge: this.options.maxAge,
|
|
118
|
+
path: this.options.path,
|
|
119
|
+
domain: this.options.domain,
|
|
120
|
+
secure: this.options.secure,
|
|
121
|
+
sameSite: this.options.sameSite?.toLowerCase(),
|
|
122
|
+
httpOnly: false
|
|
123
|
+
});
|
|
124
|
+
} catch (error) {
|
|
125
|
+
console.warn(`Could not set access token on server:`, error);
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
async getRefreshToken() {
|
|
129
|
+
try {
|
|
130
|
+
return this.cookieStore.get(this.refreshTokenKey)?.value || null;
|
|
131
|
+
} catch (error) {
|
|
132
|
+
console.warn(`Could not get refresh token from server cookies:`, error);
|
|
133
|
+
return null;
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
async setRefreshToken(token) {
|
|
137
|
+
try {
|
|
138
|
+
this.cookieStore.set(this.refreshTokenKey, token, {
|
|
139
|
+
maxAge: this.options.maxAge,
|
|
140
|
+
path: this.options.path,
|
|
141
|
+
domain: this.options.domain,
|
|
142
|
+
secure: this.options.secure,
|
|
143
|
+
sameSite: this.options.sameSite?.toLowerCase(),
|
|
144
|
+
httpOnly: false
|
|
145
|
+
});
|
|
146
|
+
} catch (error) {
|
|
147
|
+
console.warn(`Could not set refresh token on server:`, error);
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
async clearTokens() {
|
|
151
|
+
try {
|
|
152
|
+
this.cookieStore.delete(this.accessTokenKey);
|
|
153
|
+
this.cookieStore.delete(this.refreshTokenKey);
|
|
154
|
+
} catch (error) {
|
|
155
|
+
console.warn(`Could not clear tokens on server:`, error);
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
};
|
|
159
|
+
|
|
160
|
+
//#endregion
|
|
161
|
+
//#region src/build-token-cache.ts
|
|
162
|
+
const store = /* @__PURE__ */ new Map();
|
|
163
|
+
function isExpired(token) {
|
|
164
|
+
if (!token) return true;
|
|
165
|
+
if (!token.expiresAt) return false;
|
|
166
|
+
return Date.now() > token.expiresAt - 3e4;
|
|
167
|
+
}
|
|
168
|
+
function getCachedToken(key) {
|
|
169
|
+
const token = store.get(key);
|
|
170
|
+
return isExpired(token) ? null : token;
|
|
171
|
+
}
|
|
172
|
+
function setCachedToken(key, token) {
|
|
173
|
+
const expiresAt = token.ttlSeconds != null ? Date.now() + token.ttlSeconds * 1e3 : void 0;
|
|
174
|
+
store.set(key, {
|
|
175
|
+
accessToken: token.accessToken,
|
|
176
|
+
refreshToken: token.refreshToken ?? null,
|
|
177
|
+
expiresAt
|
|
178
|
+
});
|
|
179
|
+
}
|
|
180
|
+
function clearCachedToken(key) {
|
|
181
|
+
store.delete(key);
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
//#endregion
|
|
185
|
+
//#region src/build-caching-memory-storage.ts
|
|
186
|
+
const DEFAULT_TTL_SECONDS = 300;
|
|
187
|
+
/**
|
|
188
|
+
* Memory token storage that reuses tokens across the build process
|
|
189
|
+
* via an in-process cache. Only used during SSG/ISR builds.
|
|
190
|
+
*/
|
|
191
|
+
var BuildCachingMemoryTokenStorage = class {
|
|
192
|
+
constructor(cacheKey, ttlSeconds = DEFAULT_TTL_SECONDS) {
|
|
193
|
+
this.cacheKey = cacheKey;
|
|
194
|
+
this.ttlSeconds = ttlSeconds;
|
|
195
|
+
this.access = null;
|
|
196
|
+
this.refresh = null;
|
|
197
|
+
}
|
|
198
|
+
async getAccessToken() {
|
|
199
|
+
if (this.access) return this.access;
|
|
200
|
+
const cached = getCachedToken(this.cacheKey);
|
|
201
|
+
if (cached?.accessToken) {
|
|
202
|
+
this.access = cached.accessToken;
|
|
203
|
+
this.refresh = cached.refreshToken ?? null;
|
|
204
|
+
return this.access;
|
|
205
|
+
}
|
|
206
|
+
return null;
|
|
207
|
+
}
|
|
208
|
+
async setAccessToken(token) {
|
|
209
|
+
this.access = token;
|
|
210
|
+
setCachedToken(this.cacheKey, {
|
|
211
|
+
accessToken: token,
|
|
212
|
+
refreshToken: this.refresh,
|
|
213
|
+
ttlSeconds: this.ttlSeconds
|
|
214
|
+
});
|
|
215
|
+
}
|
|
216
|
+
async getRefreshToken() {
|
|
217
|
+
return this.refresh;
|
|
218
|
+
}
|
|
219
|
+
async setRefreshToken(token) {
|
|
220
|
+
this.refresh = token;
|
|
221
|
+
setCachedToken(this.cacheKey, {
|
|
222
|
+
accessToken: this.access ?? "",
|
|
223
|
+
refreshToken: token,
|
|
224
|
+
ttlSeconds: this.ttlSeconds
|
|
225
|
+
});
|
|
226
|
+
}
|
|
227
|
+
async clearTokens() {
|
|
228
|
+
this.access = null;
|
|
229
|
+
this.refresh = null;
|
|
230
|
+
clearCachedToken(this.cacheKey);
|
|
231
|
+
}
|
|
232
|
+
};
|
|
233
|
+
|
|
234
|
+
//#endregion
|
|
235
|
+
//#region src/sdk-manager.ts
|
|
236
|
+
/**
|
|
237
|
+
* Get configuration from environment variables merged with global config
|
|
238
|
+
* Precedence order: environment variables < global config
|
|
239
|
+
*/
|
|
240
|
+
function getConfig() {
|
|
241
|
+
const envStoreId = process.env.NEXT_PUBLIC_STORE_ID;
|
|
242
|
+
const envApiKey = process.env.NEXT_PUBLIC_API_KEY;
|
|
243
|
+
const envEnvironment = process.env.NEXT_PUBLIC_ENVIRONMENT;
|
|
244
|
+
const envBaseUrl = process.env.NEXT_PUBLIC_API_BASE_URL;
|
|
245
|
+
const envTimeout = process.env.NEXT_PUBLIC_API_TIMEOUT ? parseInt(process.env.NEXT_PUBLIC_API_TIMEOUT, 10) : void 0;
|
|
246
|
+
const envDebug = process.env.NEXT_PUBLIC_DEBUG_MODE === "true";
|
|
247
|
+
const envDefaultHeaders = {};
|
|
248
|
+
if (process.env.NEXT_PUBLIC_DEFAULT_CUSTOMER_GROUP_ID) envDefaultHeaders.customer_group_id = process.env.NEXT_PUBLIC_DEFAULT_CUSTOMER_GROUP_ID;
|
|
249
|
+
const storeId = globalStorefrontConfig?.storeId || envStoreId;
|
|
250
|
+
const apiKey = globalStorefrontConfig?.apiKey || envApiKey;
|
|
251
|
+
const environment = globalStorefrontConfig?.environment || (envEnvironment === "production" ? __commercengine_storefront_sdk.Environment.Production : __commercengine_storefront_sdk.Environment.Staging);
|
|
252
|
+
const baseUrl = globalStorefrontConfig?.baseUrl || envBaseUrl;
|
|
253
|
+
const timeout = globalStorefrontConfig?.timeout || envTimeout;
|
|
254
|
+
const debug = globalStorefrontConfig?.debug !== void 0 ? globalStorefrontConfig.debug : envDebug;
|
|
255
|
+
const defaultHeaders = {
|
|
256
|
+
...envDefaultHeaders,
|
|
257
|
+
...globalStorefrontConfig?.defaultHeaders
|
|
258
|
+
};
|
|
259
|
+
if (!storeId || !apiKey) throw new Error(`StorefrontSDK configuration missing! Please set the following environment variables:
|
|
260
|
+
|
|
261
|
+
NEXT_PUBLIC_STORE_ID=your-store-id
|
|
262
|
+
NEXT_PUBLIC_API_KEY=your-api-key
|
|
263
|
+
NEXT_PUBLIC_ENVIRONMENT=staging (or production)
|
|
264
|
+
|
|
265
|
+
These variables are required for both client and server contexts to work.`);
|
|
266
|
+
const config = {
|
|
267
|
+
storeId,
|
|
268
|
+
apiKey,
|
|
269
|
+
environment
|
|
270
|
+
};
|
|
271
|
+
if (baseUrl) config.baseUrl = baseUrl;
|
|
272
|
+
if (timeout) config.timeout = timeout;
|
|
273
|
+
if (debug) config.debug = debug;
|
|
274
|
+
const logger = globalStorefrontConfig?.logger;
|
|
275
|
+
const accessToken = globalStorefrontConfig?.accessToken;
|
|
276
|
+
const refreshToken = globalStorefrontConfig?.refreshToken;
|
|
277
|
+
const onTokensUpdated = globalStorefrontConfig?.onTokensUpdated;
|
|
278
|
+
const onTokensCleared = globalStorefrontConfig?.onTokensCleared;
|
|
279
|
+
const tokenStorageOptions = globalStorefrontConfig?.tokenStorageOptions;
|
|
280
|
+
if (logger) config.logger = logger;
|
|
281
|
+
if (accessToken) config.accessToken = accessToken;
|
|
282
|
+
if (refreshToken) config.refreshToken = refreshToken;
|
|
283
|
+
if (onTokensUpdated) config.onTokensUpdated = onTokensUpdated;
|
|
284
|
+
if (onTokensCleared) config.onTokensCleared = onTokensCleared;
|
|
285
|
+
if (Object.keys(defaultHeaders).length > 0) config.defaultHeaders = defaultHeaders;
|
|
286
|
+
if (tokenStorageOptions) config.tokenStorageOptions = tokenStorageOptions;
|
|
287
|
+
return config;
|
|
288
|
+
}
|
|
289
|
+
/**
|
|
290
|
+
* Global runtime configuration storage
|
|
291
|
+
* This gets bundled into both client and server bundles
|
|
292
|
+
*/
|
|
293
|
+
let globalStorefrontConfig = null;
|
|
294
|
+
/**
|
|
295
|
+
* Client-side SDK singleton (only lives in browser)
|
|
296
|
+
*/
|
|
297
|
+
let clientSDK = null;
|
|
298
|
+
/**
|
|
299
|
+
* Create appropriate token storage based on environment
|
|
300
|
+
*/
|
|
301
|
+
function createTokenStorage(cookieStore, options, config) {
|
|
302
|
+
if (typeof window !== "undefined") return new ClientTokenStorage(options);
|
|
303
|
+
if (cookieStore) return new ServerTokenStorage(cookieStore, options);
|
|
304
|
+
const shouldCache = process.env.NEXT_BUILD_CACHE_TOKENS === "true";
|
|
305
|
+
if (shouldCache && config) {
|
|
306
|
+
const cacheKey = `${config.storeId}:${config.environment || "production"}`;
|
|
307
|
+
return new BuildCachingMemoryTokenStorage(cacheKey);
|
|
308
|
+
}
|
|
309
|
+
return new __commercengine_storefront_sdk.MemoryTokenStorage();
|
|
310
|
+
}
|
|
311
|
+
/**
|
|
312
|
+
* Request-scoped server SDK factory using React cache
|
|
313
|
+
*/
|
|
314
|
+
const getServerSDKCached = (0, react.cache)((cookieStore) => {
|
|
315
|
+
const config = getConfig();
|
|
316
|
+
return new __commercengine_storefront_sdk.StorefrontSDK({
|
|
317
|
+
...config,
|
|
318
|
+
tokenStorage: createTokenStorage(cookieStore, config.tokenStorageOptions, config)
|
|
319
|
+
});
|
|
320
|
+
});
|
|
321
|
+
/**
|
|
322
|
+
* Memory-based SDK for SSG/build contexts (no request isolation needed)
|
|
323
|
+
*/
|
|
324
|
+
let buildTimeSDK = null;
|
|
325
|
+
function getBuildTimeSDK() {
|
|
326
|
+
const config = getConfig();
|
|
327
|
+
if (!buildTimeSDK) buildTimeSDK = new __commercengine_storefront_sdk.StorefrontSDK({
|
|
328
|
+
...config,
|
|
329
|
+
tokenStorage: createTokenStorage(void 0, config.tokenStorageOptions, config)
|
|
330
|
+
});
|
|
331
|
+
return buildTimeSDK;
|
|
332
|
+
}
|
|
333
|
+
function getStorefrontSDK(cookieStore) {
|
|
334
|
+
if (typeof window !== "undefined") {
|
|
335
|
+
if (cookieStore) console.warn("Cookie store passed in client environment - this will be ignored");
|
|
336
|
+
const config = getConfig();
|
|
337
|
+
if (!clientSDK) clientSDK = new __commercengine_storefront_sdk.StorefrontSDK({
|
|
338
|
+
...config,
|
|
339
|
+
tokenStorage: createTokenStorage(void 0, config.tokenStorageOptions, config)
|
|
340
|
+
});
|
|
341
|
+
return clientSDK;
|
|
342
|
+
}
|
|
343
|
+
if (cookieStore) return getServerSDKCached(cookieStore);
|
|
344
|
+
return getBuildTimeSDK();
|
|
345
|
+
}
|
|
346
|
+
/**
|
|
347
|
+
* Set global storefront configuration that applies to all SDK instances
|
|
348
|
+
* This gets bundled into both client and server contexts automatically
|
|
349
|
+
*/
|
|
350
|
+
function setGlobalStorefrontConfig(config) {
|
|
351
|
+
globalStorefrontConfig = config;
|
|
352
|
+
clientSDK = null;
|
|
353
|
+
buildTimeSDK = null;
|
|
354
|
+
}
|
|
355
|
+
/**
|
|
356
|
+
* Initialize the SDK (internal use)
|
|
357
|
+
* This should be called once in your app via StorefrontSDKInitializer
|
|
358
|
+
*/
|
|
359
|
+
function initializeStorefrontSDK() {
|
|
360
|
+
clientSDK = null;
|
|
361
|
+
buildTimeSDK = null;
|
|
362
|
+
}
|
|
363
|
+
|
|
364
|
+
//#endregion
|
|
365
|
+
Object.defineProperty(exports, 'ClientTokenStorage', {
|
|
366
|
+
enumerable: true,
|
|
367
|
+
get: function () {
|
|
368
|
+
return ClientTokenStorage;
|
|
369
|
+
}
|
|
370
|
+
});
|
|
371
|
+
Object.defineProperty(exports, 'ServerTokenStorage', {
|
|
372
|
+
enumerable: true,
|
|
373
|
+
get: function () {
|
|
374
|
+
return ServerTokenStorage;
|
|
375
|
+
}
|
|
376
|
+
});
|
|
377
|
+
Object.defineProperty(exports, '__toESM', {
|
|
378
|
+
enumerable: true,
|
|
379
|
+
get: function () {
|
|
380
|
+
return __toESM;
|
|
381
|
+
}
|
|
382
|
+
});
|
|
383
|
+
Object.defineProperty(exports, 'getStorefrontSDK', {
|
|
384
|
+
enumerable: true,
|
|
385
|
+
get: function () {
|
|
386
|
+
return getStorefrontSDK;
|
|
387
|
+
}
|
|
388
|
+
});
|
|
389
|
+
Object.defineProperty(exports, 'initializeStorefrontSDK', {
|
|
390
|
+
enumerable: true,
|
|
391
|
+
get: function () {
|
|
392
|
+
return initializeStorefrontSDK;
|
|
393
|
+
}
|
|
394
|
+
});
|
|
395
|
+
Object.defineProperty(exports, 'setGlobalStorefrontConfig', {
|
|
396
|
+
enumerable: true,
|
|
397
|
+
get: function () {
|
|
398
|
+
return setGlobalStorefrontConfig;
|
|
399
|
+
}
|
|
400
|
+
});
|
package/dist/server.cjs
ADDED
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
const require_sdk_manager = require('./sdk-manager-NWADjRFW.cjs');
|
|
2
|
+
const __commercengine_storefront_sdk = require_sdk_manager.__toESM(require("@commercengine/storefront-sdk"));
|
|
3
|
+
|
|
4
|
+
Object.defineProperty(exports, 'AuthClient', {
|
|
5
|
+
enumerable: true,
|
|
6
|
+
get: function () {
|
|
7
|
+
return __commercengine_storefront_sdk.AuthClient;
|
|
8
|
+
}
|
|
9
|
+
});
|
|
10
|
+
Object.defineProperty(exports, 'BrowserTokenStorage', {
|
|
11
|
+
enumerable: true,
|
|
12
|
+
get: function () {
|
|
13
|
+
return __commercengine_storefront_sdk.BrowserTokenStorage;
|
|
14
|
+
}
|
|
15
|
+
});
|
|
16
|
+
Object.defineProperty(exports, 'CartClient', {
|
|
17
|
+
enumerable: true,
|
|
18
|
+
get: function () {
|
|
19
|
+
return __commercengine_storefront_sdk.CartClient;
|
|
20
|
+
}
|
|
21
|
+
});
|
|
22
|
+
Object.defineProperty(exports, 'CatalogClient', {
|
|
23
|
+
enumerable: true,
|
|
24
|
+
get: function () {
|
|
25
|
+
return __commercengine_storefront_sdk.CatalogClient;
|
|
26
|
+
}
|
|
27
|
+
});
|
|
28
|
+
Object.defineProperty(exports, 'CookieTokenStorage', {
|
|
29
|
+
enumerable: true,
|
|
30
|
+
get: function () {
|
|
31
|
+
return __commercengine_storefront_sdk.CookieTokenStorage;
|
|
32
|
+
}
|
|
33
|
+
});
|
|
34
|
+
Object.defineProperty(exports, 'CustomerClient', {
|
|
35
|
+
enumerable: true,
|
|
36
|
+
get: function () {
|
|
37
|
+
return __commercengine_storefront_sdk.CustomerClient;
|
|
38
|
+
}
|
|
39
|
+
});
|
|
40
|
+
Object.defineProperty(exports, 'Environment', {
|
|
41
|
+
enumerable: true,
|
|
42
|
+
get: function () {
|
|
43
|
+
return __commercengine_storefront_sdk.Environment;
|
|
44
|
+
}
|
|
45
|
+
});
|
|
46
|
+
Object.defineProperty(exports, 'HelpersClient', {
|
|
47
|
+
enumerable: true,
|
|
48
|
+
get: function () {
|
|
49
|
+
return __commercengine_storefront_sdk.HelpersClient;
|
|
50
|
+
}
|
|
51
|
+
});
|
|
52
|
+
Object.defineProperty(exports, 'MemoryTokenStorage', {
|
|
53
|
+
enumerable: true,
|
|
54
|
+
get: function () {
|
|
55
|
+
return __commercengine_storefront_sdk.MemoryTokenStorage;
|
|
56
|
+
}
|
|
57
|
+
});
|
|
58
|
+
Object.defineProperty(exports, 'OrderClient', {
|
|
59
|
+
enumerable: true,
|
|
60
|
+
get: function () {
|
|
61
|
+
return __commercengine_storefront_sdk.OrderClient;
|
|
62
|
+
}
|
|
63
|
+
});
|
|
64
|
+
Object.defineProperty(exports, 'ResponseUtils', {
|
|
65
|
+
enumerable: true,
|
|
66
|
+
get: function () {
|
|
67
|
+
return __commercengine_storefront_sdk.ResponseUtils;
|
|
68
|
+
}
|
|
69
|
+
});
|
|
70
|
+
exports.ServerTokenStorage = require_sdk_manager.ServerTokenStorage;
|
|
71
|
+
Object.defineProperty(exports, 'ShippingClient', {
|
|
72
|
+
enumerable: true,
|
|
73
|
+
get: function () {
|
|
74
|
+
return __commercengine_storefront_sdk.ShippingClient;
|
|
75
|
+
}
|
|
76
|
+
});
|
|
77
|
+
Object.defineProperty(exports, 'StoreConfigClient', {
|
|
78
|
+
enumerable: true,
|
|
79
|
+
get: function () {
|
|
80
|
+
return __commercengine_storefront_sdk.StoreConfigClient;
|
|
81
|
+
}
|
|
82
|
+
});
|
|
83
|
+
Object.defineProperty(exports, 'StorefrontAPIClient', {
|
|
84
|
+
enumerable: true,
|
|
85
|
+
get: function () {
|
|
86
|
+
return __commercengine_storefront_sdk.StorefrontAPIClient;
|
|
87
|
+
}
|
|
88
|
+
});
|
|
89
|
+
Object.defineProperty(exports, 'StorefrontSDK', {
|
|
90
|
+
enumerable: true,
|
|
91
|
+
get: function () {
|
|
92
|
+
return __commercengine_storefront_sdk.StorefrontSDK;
|
|
93
|
+
}
|
|
94
|
+
});
|
|
95
|
+
exports.getStorefrontSDK = require_sdk_manager.getStorefrontSDK;
|
|
96
|
+
exports.initializeStorefrontSDK = require_sdk_manager.initializeStorefrontSDK;
|
|
97
|
+
Object.keys(__commercengine_storefront_sdk).forEach(function (k) {
|
|
98
|
+
if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {
|
|
99
|
+
enumerable: true,
|
|
100
|
+
get: function () { return __commercengine_storefront_sdk[k]; }
|
|
101
|
+
});
|
|
102
|
+
});
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { NextJSSDKConfig, NextJSTokenStorageOptions, ServerTokenStorage, getStorefrontSDK, initializeStorefrontSDK } from "./sdk-manager-D2ktqPrp.cjs";
|
|
2
|
+
import { AuthClient, BrowserTokenStorage, CartClient, CatalogClient, CookieTokenStorage, CustomerClient, Environment, HelpersClient, MemoryTokenStorage, OrderClient, ResponseUtils, ShippingClient, StoreConfigClient, StorefrontAPIClient, StorefrontSDK } from "@commercengine/storefront-sdk";
|
|
3
|
+
export * from "@commercengine/storefront-sdk";
|
|
4
|
+
export { AuthClient, BrowserTokenStorage, CartClient, CatalogClient, CookieTokenStorage, CustomerClient, Environment, HelpersClient, MemoryTokenStorage, type NextJSSDKConfig, type NextJSTokenStorageOptions, OrderClient, ResponseUtils, ServerTokenStorage, ShippingClient, StoreConfigClient, StorefrontAPIClient, StorefrontSDK, getStorefrontSDK, initializeStorefrontSDK };
|
package/dist/server.d.ts
ADDED
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { NextJSSDKConfig, NextJSTokenStorageOptions, ServerTokenStorage, getStorefrontSDK, initializeStorefrontSDK } from "./sdk-manager-B9xDQQuv.js";
|
|
2
|
+
import { AuthClient, BrowserTokenStorage, CartClient, CatalogClient, CookieTokenStorage, CustomerClient, Environment, HelpersClient, MemoryTokenStorage, OrderClient, ResponseUtils, ShippingClient, StoreConfigClient, StorefrontAPIClient, StorefrontSDK } from "@commercengine/storefront-sdk";
|
|
3
|
+
export * from "@commercengine/storefront-sdk";
|
|
4
|
+
export { AuthClient, BrowserTokenStorage, CartClient, CatalogClient, CookieTokenStorage, CustomerClient, Environment, HelpersClient, MemoryTokenStorage, type NextJSSDKConfig, type NextJSTokenStorageOptions, OrderClient, ResponseUtils, ServerTokenStorage, ShippingClient, StoreConfigClient, StorefrontAPIClient, StorefrontSDK, getStorefrontSDK, initializeStorefrontSDK };
|
package/dist/server.js
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { ServerTokenStorage, getStorefrontSDK, initializeStorefrontSDK } from "./sdk-manager-CdgrfSVp.js";
|
|
2
|
+
import { AuthClient, BrowserTokenStorage, CartClient, CatalogClient, CookieTokenStorage, CustomerClient, Environment, HelpersClient, MemoryTokenStorage, OrderClient, ResponseUtils, ShippingClient, StoreConfigClient, StorefrontAPIClient, StorefrontSDK } from "@commercengine/storefront-sdk";
|
|
3
|
+
|
|
4
|
+
export * from "@commercengine/storefront-sdk"
|
|
5
|
+
|
|
6
|
+
export { AuthClient, BrowserTokenStorage, CartClient, CatalogClient, CookieTokenStorage, CustomerClient, Environment, HelpersClient, MemoryTokenStorage, OrderClient, ResponseUtils, ServerTokenStorage, ShippingClient, StoreConfigClient, StorefrontAPIClient, StorefrontSDK, getStorefrontSDK, initializeStorefrontSDK };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@commercengine/storefront-sdk-nextjs",
|
|
3
|
-
"version": "0.1.0
|
|
3
|
+
"version": "0.1.0",
|
|
4
4
|
"description": "Next.js wrapper for the Commerce Engine Storefront SDK",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -10,6 +10,16 @@
|
|
|
10
10
|
"types": "./dist/index.d.ts",
|
|
11
11
|
"import": "./dist/index.js",
|
|
12
12
|
"require": "./dist/index.cjs"
|
|
13
|
+
},
|
|
14
|
+
"./server": {
|
|
15
|
+
"types": "./dist/server.d.ts",
|
|
16
|
+
"import": "./dist/server.js",
|
|
17
|
+
"require": "./dist/server.cjs"
|
|
18
|
+
},
|
|
19
|
+
"./client": {
|
|
20
|
+
"types": "./dist/client.d.ts",
|
|
21
|
+
"import": "./dist/client.js",
|
|
22
|
+
"require": "./dist/client.cjs"
|
|
13
23
|
}
|
|
14
24
|
},
|
|
15
25
|
"files": [
|
|
@@ -27,28 +37,28 @@
|
|
|
27
37
|
"author": "Commerce Engine",
|
|
28
38
|
"license": "All rights reserved",
|
|
29
39
|
"peerDependencies": {
|
|
30
|
-
"next": ">=
|
|
31
|
-
"react": ">=
|
|
32
|
-
"react-dom": ">=
|
|
40
|
+
"next": ">=15.0.0",
|
|
41
|
+
"react": ">=19.0.0",
|
|
42
|
+
"react-dom": ">=19.0.0"
|
|
33
43
|
},
|
|
34
44
|
"dependencies": {
|
|
35
|
-
"@commercengine/storefront-sdk": "0.8.
|
|
45
|
+
"@commercengine/storefront-sdk": "0.8.1"
|
|
36
46
|
},
|
|
37
47
|
"devDependencies": {
|
|
38
48
|
"@types/node": "^24.3.0",
|
|
39
|
-
"@types/react": "^
|
|
40
|
-
"next": ">=
|
|
41
|
-
"react": ">=
|
|
42
|
-
"react-dom": ">=
|
|
49
|
+
"@types/react": "^19.0.0",
|
|
50
|
+
"next": ">=15.0.0",
|
|
51
|
+
"react": ">=19.0.0",
|
|
52
|
+
"react-dom": ">=19.0.0",
|
|
43
53
|
"rimraf": "^6.0.1",
|
|
44
|
-
"
|
|
54
|
+
"tsdown": "^0.14.2",
|
|
45
55
|
"typescript": "^5.9.2"
|
|
46
56
|
},
|
|
47
57
|
"publishConfig": {
|
|
48
58
|
"access": "public"
|
|
49
59
|
},
|
|
50
60
|
"scripts": {
|
|
51
|
-
"build": "
|
|
61
|
+
"build": "tsdown",
|
|
52
62
|
"clean": "rimraf dist"
|
|
53
63
|
}
|
|
54
64
|
}
|