@vue-storefront/next 7.0.0-next.1 → 7.0.0-next.3
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/{chunk-WNQUEZJF.mjs → chunk-NSPLXZD5.mjs} +27 -1
- package/dist/client.d.mts +2 -2
- package/dist/client.d.ts +2 -2
- package/dist/client.js +30 -3
- package/dist/client.mjs +10 -4
- package/dist/index.d.mts +2 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.js +14 -0
- package/dist/index.mjs +4 -2
- package/dist/{types-B00HMKAX.d.mts → types-FGnrBhjy.d.mts} +33 -1
- package/dist/{types-B00HMKAX.d.ts → types-FGnrBhjy.d.ts} +33 -1
- package/package.json +5 -5
|
@@ -50,9 +50,35 @@ var __async = (__this, __arguments, generator) => {
|
|
|
50
50
|
});
|
|
51
51
|
};
|
|
52
52
|
|
|
53
|
+
// src/env/constants.ts
|
|
54
|
+
var PUBLIC_ENV_KEY = "__ALOKAI_ENV__";
|
|
55
|
+
|
|
56
|
+
// src/env/env.ts
|
|
57
|
+
function env(key) {
|
|
58
|
+
var _a;
|
|
59
|
+
if (typeof window === "undefined") {
|
|
60
|
+
return process.env[key];
|
|
61
|
+
}
|
|
62
|
+
return (_a = window[PUBLIC_ENV_KEY]) == null ? void 0 : _a[key];
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
// src/env/get-public-env.ts
|
|
66
|
+
function getPublicEnv() {
|
|
67
|
+
const publicEnv = {};
|
|
68
|
+
for (const key in process.env) {
|
|
69
|
+
if (key.startsWith("NEXT_PUBLIC_")) {
|
|
70
|
+
publicEnv[key] = process.env[key];
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
return publicEnv;
|
|
74
|
+
}
|
|
75
|
+
|
|
53
76
|
export {
|
|
54
77
|
__spreadValues,
|
|
55
78
|
__spreadProps,
|
|
56
79
|
__objRest,
|
|
57
|
-
__async
|
|
80
|
+
__async,
|
|
81
|
+
PUBLIC_ENV_KEY,
|
|
82
|
+
getPublicEnv,
|
|
83
|
+
env
|
|
58
84
|
};
|
package/dist/client.d.mts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { SDKApi } from '@alokai/connect/sdk';
|
|
2
|
-
import { S as SfContract, C as CreateSdkContextReturn } from './types-
|
|
3
|
-
export { M as Maybe, b as SfState, a as SfStateProps, c as createSfStateProvider } from './types-
|
|
2
|
+
import { S as SfContract, C as CreateSdkContextReturn } from './types-FGnrBhjy.mjs';
|
|
3
|
+
export { M as Maybe, b as SfState, a as SfStateProps, c as createSfStateProvider, e as env } from './types-FGnrBhjy.mjs';
|
|
4
4
|
import 'next/headers';
|
|
5
5
|
import 'react';
|
|
6
6
|
|
package/dist/client.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { SDKApi } from '@alokai/connect/sdk';
|
|
2
|
-
import { S as SfContract, C as CreateSdkContextReturn } from './types-
|
|
3
|
-
export { M as Maybe, b as SfState, a as SfStateProps, c as createSfStateProvider } from './types-
|
|
2
|
+
import { S as SfContract, C as CreateSdkContextReturn } from './types-FGnrBhjy.js';
|
|
3
|
+
export { M as Maybe, b as SfState, a as SfStateProps, c as createSfStateProvider, e as env } from './types-FGnrBhjy.js';
|
|
4
4
|
import 'next/headers';
|
|
5
5
|
import 'react';
|
|
6
6
|
|
package/dist/client.js
CHANGED
|
@@ -61,7 +61,8 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
61
61
|
var client_exports = {};
|
|
62
62
|
__export(client_exports, {
|
|
63
63
|
createAlokaiContext: () => createAlokaiContext,
|
|
64
|
-
createSfStateProvider: () => createSfStateProvider
|
|
64
|
+
createSfStateProvider: () => createSfStateProvider,
|
|
65
|
+
env: () => env
|
|
65
66
|
});
|
|
66
67
|
module.exports = __toCommonJS(client_exports);
|
|
67
68
|
|
|
@@ -70,6 +71,20 @@ var import_instrumentation_next_component = require("@alokai/instrumentation-nex
|
|
|
70
71
|
var import_script = __toESM(require("next/script"));
|
|
71
72
|
var import_react2 = __toESM(require("react"));
|
|
72
73
|
|
|
74
|
+
// src/env/constants.ts
|
|
75
|
+
var PUBLIC_ENV_KEY = "__ALOKAI_ENV__";
|
|
76
|
+
|
|
77
|
+
// src/env/get-public-env.ts
|
|
78
|
+
function getPublicEnv() {
|
|
79
|
+
const publicEnv = {};
|
|
80
|
+
for (const key in process.env) {
|
|
81
|
+
if (key.startsWith("NEXT_PUBLIC_")) {
|
|
82
|
+
publicEnv[key] = process.env[key];
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
return publicEnv;
|
|
86
|
+
}
|
|
87
|
+
|
|
73
88
|
// src/state.tsx
|
|
74
89
|
var import_react = __toESM(require("react"));
|
|
75
90
|
var import_zustand = require("zustand");
|
|
@@ -181,7 +196,9 @@ function createAlokaiContext() {
|
|
|
181
196
|
vsfMetaTag.setAttribute("content", "Alokai Storefront");
|
|
182
197
|
document.head.appendChild(vsfMetaTag);
|
|
183
198
|
`;
|
|
184
|
-
|
|
199
|
+
const publicEnv = typeof window === "undefined" ? getPublicEnv() : void 0;
|
|
200
|
+
const envScript = publicEnv ? `window['${PUBLIC_ENV_KEY}'] = ${JSON.stringify(publicEnv)};` : "";
|
|
201
|
+
return /* @__PURE__ */ import_react2.default.createElement(SdkContext.Provider, { value: sdk }, publicEnv && /* @__PURE__ */ import_react2.default.createElement(import_script.default, { id: "alokaiEnv", strategy: "beforeInteractive" }, envScript), /* @__PURE__ */ import_react2.default.createElement(import_script.default, { id: "vsfMetaTag", strategy: "beforeInteractive" }, `
|
|
185
202
|
${metaTagScript}
|
|
186
203
|
`), /* @__PURE__ */ import_react2.default.createElement(import_instrumentation_next_component.AlokaiInstrumentation, null), /* @__PURE__ */ import_react2.default.createElement(SfStateProvider, { initialData }, children));
|
|
187
204
|
}
|
|
@@ -194,8 +211,18 @@ function createAlokaiContext() {
|
|
|
194
211
|
};
|
|
195
212
|
return __spreadValues({ AlokaiProvider, useSdk }, rest);
|
|
196
213
|
}
|
|
214
|
+
|
|
215
|
+
// src/env/env.ts
|
|
216
|
+
function env(key) {
|
|
217
|
+
var _a;
|
|
218
|
+
if (typeof window === "undefined") {
|
|
219
|
+
return process.env[key];
|
|
220
|
+
}
|
|
221
|
+
return (_a = window[PUBLIC_ENV_KEY]) == null ? void 0 : _a[key];
|
|
222
|
+
}
|
|
197
223
|
// Annotate the CommonJS export names for ESM import in node:
|
|
198
224
|
0 && (module.exports = {
|
|
199
225
|
createAlokaiContext,
|
|
200
|
-
createSfStateProvider
|
|
226
|
+
createSfStateProvider,
|
|
227
|
+
env
|
|
201
228
|
});
|
package/dist/client.mjs
CHANGED
|
@@ -1,9 +1,12 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import {
|
|
3
|
+
PUBLIC_ENV_KEY,
|
|
3
4
|
__objRest,
|
|
4
5
|
__spreadProps,
|
|
5
|
-
__spreadValues
|
|
6
|
-
|
|
6
|
+
__spreadValues,
|
|
7
|
+
env,
|
|
8
|
+
getPublicEnv
|
|
9
|
+
} from "./chunk-NSPLXZD5.mjs";
|
|
7
10
|
|
|
8
11
|
// src/alokai-provider.tsx
|
|
9
12
|
import { AlokaiInstrumentation } from "@alokai/instrumentation-next-component";
|
|
@@ -125,7 +128,9 @@ function createAlokaiContext() {
|
|
|
125
128
|
vsfMetaTag.setAttribute("content", "Alokai Storefront");
|
|
126
129
|
document.head.appendChild(vsfMetaTag);
|
|
127
130
|
`;
|
|
128
|
-
|
|
131
|
+
const publicEnv = typeof window === "undefined" ? getPublicEnv() : void 0;
|
|
132
|
+
const envScript = publicEnv ? `window['${PUBLIC_ENV_KEY}'] = ${JSON.stringify(publicEnv)};` : "";
|
|
133
|
+
return /* @__PURE__ */ React2.createElement(SdkContext.Provider, { value: sdk }, publicEnv && /* @__PURE__ */ React2.createElement(Script, { id: "alokaiEnv", strategy: "beforeInteractive" }, envScript), /* @__PURE__ */ React2.createElement(Script, { id: "vsfMetaTag", strategy: "beforeInteractive" }, `
|
|
129
134
|
${metaTagScript}
|
|
130
135
|
`), /* @__PURE__ */ React2.createElement(AlokaiInstrumentation, null), /* @__PURE__ */ React2.createElement(SfStateProvider, { initialData }, children));
|
|
131
136
|
}
|
|
@@ -140,5 +145,6 @@ function createAlokaiContext() {
|
|
|
140
145
|
}
|
|
141
146
|
export {
|
|
142
147
|
createAlokaiContext,
|
|
143
|
-
createSfStateProvider
|
|
148
|
+
createSfStateProvider,
|
|
149
|
+
env
|
|
144
150
|
};
|
package/dist/index.d.mts
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
|
+
import { d as CreateSdkOptions, f as Config, g as CreateSdkReturn, I as InjectedContext } from './types-FGnrBhjy.mjs';
|
|
2
|
+
export { e as env } from './types-FGnrBhjy.mjs';
|
|
1
3
|
import * as _alokai_connect_logger from '@alokai/connect/logger';
|
|
2
4
|
import { NextRequest, NextResponse } from 'next/server';
|
|
3
5
|
import { buildModule } from '@alokai/connect/sdk';
|
|
4
6
|
export { defineGetConfigSwitcherHeader } from '@alokai/connect/sdk';
|
|
5
|
-
import { d as CreateSdkOptions, e as Config, f as CreateSdkReturn, I as InjectedContext } from './types-B00HMKAX.mjs';
|
|
6
7
|
import 'next/headers';
|
|
7
8
|
import 'react';
|
|
8
9
|
|
package/dist/index.d.ts
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
|
+
import { d as CreateSdkOptions, f as Config, g as CreateSdkReturn, I as InjectedContext } from './types-FGnrBhjy.js';
|
|
2
|
+
export { e as env } from './types-FGnrBhjy.js';
|
|
1
3
|
import * as _alokai_connect_logger from '@alokai/connect/logger';
|
|
2
4
|
import { NextRequest, NextResponse } from 'next/server';
|
|
3
5
|
import { buildModule } from '@alokai/connect/sdk';
|
|
4
6
|
export { defineGetConfigSwitcherHeader } from '@alokai/connect/sdk';
|
|
5
|
-
import { d as CreateSdkOptions, e as Config, f as CreateSdkReturn, I as InjectedContext } from './types-B00HMKAX.js';
|
|
6
7
|
import 'next/headers';
|
|
7
8
|
import 'react';
|
|
8
9
|
|
package/dist/index.js
CHANGED
|
@@ -63,10 +63,23 @@ __export(src_exports, {
|
|
|
63
63
|
defineGetConfigSwitcherHeader: () => import_sdk2.defineGetConfigSwitcherHeader,
|
|
64
64
|
defineSdkConfig: () => defineSdkConfig,
|
|
65
65
|
defineSdkModule: () => defineSdkModule,
|
|
66
|
+
env: () => env,
|
|
66
67
|
resolveSdkOptions: () => resolveSdkOptions
|
|
67
68
|
});
|
|
68
69
|
module.exports = __toCommonJS(src_exports);
|
|
69
70
|
|
|
71
|
+
// src/env/constants.ts
|
|
72
|
+
var PUBLIC_ENV_KEY = "__ALOKAI_ENV__";
|
|
73
|
+
|
|
74
|
+
// src/env/env.ts
|
|
75
|
+
function env(key) {
|
|
76
|
+
var _a;
|
|
77
|
+
if (typeof window === "undefined") {
|
|
78
|
+
return process.env[key];
|
|
79
|
+
}
|
|
80
|
+
return (_a = window[PUBLIC_ENV_KEY]) == null ? void 0 : _a[key];
|
|
81
|
+
}
|
|
82
|
+
|
|
70
83
|
// src/logger/index.ts
|
|
71
84
|
var import_logger = require("@alokai/connect/logger");
|
|
72
85
|
|
|
@@ -220,5 +233,6 @@ function buildModules(modules) {
|
|
|
220
233
|
defineGetConfigSwitcherHeader,
|
|
221
234
|
defineSdkConfig,
|
|
222
235
|
defineSdkModule,
|
|
236
|
+
env,
|
|
223
237
|
resolveSdkOptions
|
|
224
238
|
});
|
package/dist/index.mjs
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import {
|
|
2
2
|
__async,
|
|
3
3
|
__spreadProps,
|
|
4
|
-
__spreadValues
|
|
5
|
-
|
|
4
|
+
__spreadValues,
|
|
5
|
+
env
|
|
6
|
+
} from "./chunk-NSPLXZD5.mjs";
|
|
6
7
|
|
|
7
8
|
// src/logger/index.ts
|
|
8
9
|
import { LoggerFactory, LoggerType } from "@alokai/connect/logger";
|
|
@@ -156,5 +157,6 @@ export {
|
|
|
156
157
|
defineGetConfigSwitcherHeader,
|
|
157
158
|
defineSdkConfig,
|
|
158
159
|
defineSdkModule,
|
|
160
|
+
env,
|
|
159
161
|
resolveSdkOptions
|
|
160
162
|
};
|
|
@@ -206,4 +206,36 @@ type CreateSdkContextReturn<TSdk extends SDKApi<any>, TSfContract extends SfCont
|
|
|
206
206
|
useSfLocaleState: ReturnType<typeof createSfStateProvider<TSfContract>>["useSfLocaleState"];
|
|
207
207
|
}>;
|
|
208
208
|
|
|
209
|
-
|
|
209
|
+
/**
|
|
210
|
+
* Retrieves an environment variable value.
|
|
211
|
+
* On the server side, it reads from process.env.
|
|
212
|
+
* On the client side, it reads from window.__ALOKAI_ENV__ to support runtime environment variables.
|
|
213
|
+
*
|
|
214
|
+
* @param key - The environment variable key (e.g., "NEXT_PUBLIC_API_URL")
|
|
215
|
+
* @returns The environment variable value or undefined if not found
|
|
216
|
+
*
|
|
217
|
+
* @example
|
|
218
|
+
* ```tsx
|
|
219
|
+
* import { env } from "@vue-storefront/next/client";
|
|
220
|
+
*
|
|
221
|
+
* const apiUrl = env("NEXT_PUBLIC_API_URL");
|
|
222
|
+
* ```
|
|
223
|
+
*/
|
|
224
|
+
declare function env(key: string): string | undefined;
|
|
225
|
+
|
|
226
|
+
/**
|
|
227
|
+
* Type representing environment variables as key-value pairs
|
|
228
|
+
*/
|
|
229
|
+
interface PublicEnv {
|
|
230
|
+
[key: string]: string | undefined;
|
|
231
|
+
}
|
|
232
|
+
/**
|
|
233
|
+
* Extended window interface to include Alokai environment variables
|
|
234
|
+
*/
|
|
235
|
+
declare global {
|
|
236
|
+
interface Window {
|
|
237
|
+
__ALOKAI_ENV__?: PublicEnv;
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
export { type CreateSdkContextReturn as C, type InjectedContext as I, type Maybe as M, type SfContract as S, type SfStateProps as a, type SfState as b, createSfStateProvider as c, type CreateSdkOptions as d, env as e, type Config as f, type CreateSdkReturn as g };
|
|
@@ -206,4 +206,36 @@ type CreateSdkContextReturn<TSdk extends SDKApi<any>, TSfContract extends SfCont
|
|
|
206
206
|
useSfLocaleState: ReturnType<typeof createSfStateProvider<TSfContract>>["useSfLocaleState"];
|
|
207
207
|
}>;
|
|
208
208
|
|
|
209
|
-
|
|
209
|
+
/**
|
|
210
|
+
* Retrieves an environment variable value.
|
|
211
|
+
* On the server side, it reads from process.env.
|
|
212
|
+
* On the client side, it reads from window.__ALOKAI_ENV__ to support runtime environment variables.
|
|
213
|
+
*
|
|
214
|
+
* @param key - The environment variable key (e.g., "NEXT_PUBLIC_API_URL")
|
|
215
|
+
* @returns The environment variable value or undefined if not found
|
|
216
|
+
*
|
|
217
|
+
* @example
|
|
218
|
+
* ```tsx
|
|
219
|
+
* import { env } from "@vue-storefront/next/client";
|
|
220
|
+
*
|
|
221
|
+
* const apiUrl = env("NEXT_PUBLIC_API_URL");
|
|
222
|
+
* ```
|
|
223
|
+
*/
|
|
224
|
+
declare function env(key: string): string | undefined;
|
|
225
|
+
|
|
226
|
+
/**
|
|
227
|
+
* Type representing environment variables as key-value pairs
|
|
228
|
+
*/
|
|
229
|
+
interface PublicEnv {
|
|
230
|
+
[key: string]: string | undefined;
|
|
231
|
+
}
|
|
232
|
+
/**
|
|
233
|
+
* Extended window interface to include Alokai environment variables
|
|
234
|
+
*/
|
|
235
|
+
declare global {
|
|
236
|
+
interface Window {
|
|
237
|
+
__ALOKAI_ENV__?: PublicEnv;
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
export { type CreateSdkContextReturn as C, type InjectedContext as I, type Maybe as M, type SfContract as S, type SfStateProps as a, type SfState as b, createSfStateProvider as c, type CreateSdkOptions as d, env as e, type Config as f, type CreateSdkReturn as g };
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "@vue-storefront/next",
|
|
3
3
|
"description": "Alokai dedicated features for Next.js",
|
|
4
4
|
"license": "MIT",
|
|
5
|
-
"version": "7.0.0-next.
|
|
5
|
+
"version": "7.0.0-next.3",
|
|
6
6
|
"exports": {
|
|
7
7
|
".": {
|
|
8
8
|
"types": "./dist/index.d.ts",
|
|
@@ -27,15 +27,15 @@
|
|
|
27
27
|
"version": "cp CHANGELOG.md ../../docs/enterprise/content/storefront/6.change-log/next.md"
|
|
28
28
|
},
|
|
29
29
|
"dependencies": {
|
|
30
|
-
"@alokai/instrumentation-next-component": "1.0.0",
|
|
30
|
+
"@alokai/instrumentation-next-component": "1.0.1-next.0",
|
|
31
31
|
"zustand": "^4.5.4"
|
|
32
32
|
},
|
|
33
33
|
"devDependencies": {
|
|
34
|
-
"@alokai/connect": "^
|
|
34
|
+
"@alokai/connect": "^2.0.0-next.1",
|
|
35
35
|
"@types/react": "18.3.2",
|
|
36
36
|
"@types/react-dom": "18.3.0",
|
|
37
37
|
"eslint": "9.23.0",
|
|
38
|
-
"next": "15.5.
|
|
38
|
+
"next": "15.5.7",
|
|
39
39
|
"prettier": "3.3.2",
|
|
40
40
|
"react": "19.2.0",
|
|
41
41
|
"react-dom": "19.2.0",
|
|
@@ -44,7 +44,7 @@
|
|
|
44
44
|
"vitest": "2.1.9"
|
|
45
45
|
},
|
|
46
46
|
"peerDependencies": {
|
|
47
|
-
"@alokai/connect": "^
|
|
47
|
+
"@alokai/connect": "^2.0.0-next.1",
|
|
48
48
|
"next": "^15.0.0",
|
|
49
49
|
"react": "^19.0.0"
|
|
50
50
|
},
|