@vue-storefront/next 7.0.0-next.2 → 7.0.0-next.4
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/client.cjs +223 -0
- package/dist/{client.d.ts → client.d.cts} +6 -7
- package/dist/client.d.mts +6 -7
- package/dist/client.mjs +180 -139
- package/dist/env-Be9N7zqo.cjs +115 -0
- package/dist/env-XPpRDRcE.mjs +97 -0
- package/dist/index-BXYjHxeC.d.mts +250 -0
- package/dist/index-D1weTw7N.d.cts +250 -0
- package/dist/index.cjs +258 -0
- package/dist/{index.d.ts → index.d.cts} +18 -20
- package/dist/index.d.mts +18 -20
- package/dist/index.mjs +214 -131
- package/package.json +15 -15
- package/dist/chunk-NSPLXZD5.mjs +0 -84
- package/dist/client.js +0 -228
- package/dist/index.js +0 -238
- package/dist/types-FGnrBhjy.d.mts +0 -241
- package/dist/types-FGnrBhjy.d.ts +0 -241
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
|
|
2
|
+
//#region src/env/constants.ts
|
|
3
|
+
/**
|
|
4
|
+
* The key used to store public environment variables in the browser window object
|
|
5
|
+
*/
|
|
6
|
+
const PUBLIC_ENV_KEY = "__ALOKAI_ENV__";
|
|
7
|
+
|
|
8
|
+
//#endregion
|
|
9
|
+
//#region \0@oxc-project+runtime@0.101.0/helpers/typeof.js
|
|
10
|
+
function _typeof(o) {
|
|
11
|
+
"@babel/helpers - typeof";
|
|
12
|
+
return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o$1) {
|
|
13
|
+
return typeof o$1;
|
|
14
|
+
} : function(o$1) {
|
|
15
|
+
return o$1 && "function" == typeof Symbol && o$1.constructor === Symbol && o$1 !== Symbol.prototype ? "symbol" : typeof o$1;
|
|
16
|
+
}, _typeof(o);
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
//#endregion
|
|
20
|
+
//#region \0@oxc-project+runtime@0.101.0/helpers/toPrimitive.js
|
|
21
|
+
function toPrimitive(t, r) {
|
|
22
|
+
if ("object" != _typeof(t) || !t) return t;
|
|
23
|
+
var e = t[Symbol.toPrimitive];
|
|
24
|
+
if (void 0 !== e) {
|
|
25
|
+
var i = e.call(t, r || "default");
|
|
26
|
+
if ("object" != _typeof(i)) return i;
|
|
27
|
+
throw new TypeError("@@toPrimitive must return a primitive value.");
|
|
28
|
+
}
|
|
29
|
+
return ("string" === r ? String : Number)(t);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
//#endregion
|
|
33
|
+
//#region \0@oxc-project+runtime@0.101.0/helpers/toPropertyKey.js
|
|
34
|
+
function toPropertyKey(t) {
|
|
35
|
+
var i = toPrimitive(t, "string");
|
|
36
|
+
return "symbol" == _typeof(i) ? i : i + "";
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
//#endregion
|
|
40
|
+
//#region \0@oxc-project+runtime@0.101.0/helpers/defineProperty.js
|
|
41
|
+
function _defineProperty(e, r, t) {
|
|
42
|
+
return (r = toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
|
|
43
|
+
value: t,
|
|
44
|
+
enumerable: !0,
|
|
45
|
+
configurable: !0,
|
|
46
|
+
writable: !0
|
|
47
|
+
}) : e[r] = t, e;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
//#endregion
|
|
51
|
+
//#region \0@oxc-project+runtime@0.101.0/helpers/objectSpread2.js
|
|
52
|
+
function ownKeys(e, r) {
|
|
53
|
+
var t = Object.keys(e);
|
|
54
|
+
if (Object.getOwnPropertySymbols) {
|
|
55
|
+
var o = Object.getOwnPropertySymbols(e);
|
|
56
|
+
r && (o = o.filter(function(r$1) {
|
|
57
|
+
return Object.getOwnPropertyDescriptor(e, r$1).enumerable;
|
|
58
|
+
})), t.push.apply(t, o);
|
|
59
|
+
}
|
|
60
|
+
return t;
|
|
61
|
+
}
|
|
62
|
+
function _objectSpread2(e) {
|
|
63
|
+
for (var r = 1; r < arguments.length; r++) {
|
|
64
|
+
var t = null != arguments[r] ? arguments[r] : {};
|
|
65
|
+
r % 2 ? ownKeys(Object(t), !0).forEach(function(r$1) {
|
|
66
|
+
_defineProperty(e, r$1, t[r$1]);
|
|
67
|
+
}) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function(r$1) {
|
|
68
|
+
Object.defineProperty(e, r$1, Object.getOwnPropertyDescriptor(t, r$1));
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
return e;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
//#endregion
|
|
75
|
+
//#region src/env/env.ts
|
|
76
|
+
/**
|
|
77
|
+
* Retrieves an environment variable value.
|
|
78
|
+
* On the server side, it reads from process.env.
|
|
79
|
+
* On the client side, it reads from window.__ALOKAI_ENV__ to support runtime environment variables.
|
|
80
|
+
*
|
|
81
|
+
* @param key - The environment variable key (e.g., "NEXT_PUBLIC_API_URL")
|
|
82
|
+
* @returns The environment variable value or undefined if not found
|
|
83
|
+
*
|
|
84
|
+
* @example
|
|
85
|
+
* ```tsx
|
|
86
|
+
* import { env } from "@vue-storefront/next/client";
|
|
87
|
+
*
|
|
88
|
+
* const apiUrl = env("NEXT_PUBLIC_API_URL");
|
|
89
|
+
* ```
|
|
90
|
+
*/
|
|
91
|
+
function env(key) {
|
|
92
|
+
var _window$PUBLIC_ENV_KE;
|
|
93
|
+
if (typeof window === "undefined") return process.env[key];
|
|
94
|
+
return (_window$PUBLIC_ENV_KE = window[PUBLIC_ENV_KEY]) === null || _window$PUBLIC_ENV_KE === void 0 ? void 0 : _window$PUBLIC_ENV_KE[key];
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
//#endregion
|
|
98
|
+
Object.defineProperty(exports, 'PUBLIC_ENV_KEY', {
|
|
99
|
+
enumerable: true,
|
|
100
|
+
get: function () {
|
|
101
|
+
return PUBLIC_ENV_KEY;
|
|
102
|
+
}
|
|
103
|
+
});
|
|
104
|
+
Object.defineProperty(exports, '_objectSpread2', {
|
|
105
|
+
enumerable: true,
|
|
106
|
+
get: function () {
|
|
107
|
+
return _objectSpread2;
|
|
108
|
+
}
|
|
109
|
+
});
|
|
110
|
+
Object.defineProperty(exports, 'env', {
|
|
111
|
+
enumerable: true,
|
|
112
|
+
get: function () {
|
|
113
|
+
return env;
|
|
114
|
+
}
|
|
115
|
+
});
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
//#region src/env/constants.ts
|
|
2
|
+
/**
|
|
3
|
+
* The key used to store public environment variables in the browser window object
|
|
4
|
+
*/
|
|
5
|
+
const PUBLIC_ENV_KEY = "__ALOKAI_ENV__";
|
|
6
|
+
|
|
7
|
+
//#endregion
|
|
8
|
+
//#region \0@oxc-project+runtime@0.101.0/helpers/typeof.js
|
|
9
|
+
function _typeof(o) {
|
|
10
|
+
"@babel/helpers - typeof";
|
|
11
|
+
return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o$1) {
|
|
12
|
+
return typeof o$1;
|
|
13
|
+
} : function(o$1) {
|
|
14
|
+
return o$1 && "function" == typeof Symbol && o$1.constructor === Symbol && o$1 !== Symbol.prototype ? "symbol" : typeof o$1;
|
|
15
|
+
}, _typeof(o);
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
//#endregion
|
|
19
|
+
//#region \0@oxc-project+runtime@0.101.0/helpers/toPrimitive.js
|
|
20
|
+
function toPrimitive(t, r) {
|
|
21
|
+
if ("object" != _typeof(t) || !t) return t;
|
|
22
|
+
var e = t[Symbol.toPrimitive];
|
|
23
|
+
if (void 0 !== e) {
|
|
24
|
+
var i = e.call(t, r || "default");
|
|
25
|
+
if ("object" != _typeof(i)) return i;
|
|
26
|
+
throw new TypeError("@@toPrimitive must return a primitive value.");
|
|
27
|
+
}
|
|
28
|
+
return ("string" === r ? String : Number)(t);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
//#endregion
|
|
32
|
+
//#region \0@oxc-project+runtime@0.101.0/helpers/toPropertyKey.js
|
|
33
|
+
function toPropertyKey(t) {
|
|
34
|
+
var i = toPrimitive(t, "string");
|
|
35
|
+
return "symbol" == _typeof(i) ? i : i + "";
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
//#endregion
|
|
39
|
+
//#region \0@oxc-project+runtime@0.101.0/helpers/defineProperty.js
|
|
40
|
+
function _defineProperty(e, r, t) {
|
|
41
|
+
return (r = toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
|
|
42
|
+
value: t,
|
|
43
|
+
enumerable: !0,
|
|
44
|
+
configurable: !0,
|
|
45
|
+
writable: !0
|
|
46
|
+
}) : e[r] = t, e;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
//#endregion
|
|
50
|
+
//#region \0@oxc-project+runtime@0.101.0/helpers/objectSpread2.js
|
|
51
|
+
function ownKeys(e, r) {
|
|
52
|
+
var t = Object.keys(e);
|
|
53
|
+
if (Object.getOwnPropertySymbols) {
|
|
54
|
+
var o = Object.getOwnPropertySymbols(e);
|
|
55
|
+
r && (o = o.filter(function(r$1) {
|
|
56
|
+
return Object.getOwnPropertyDescriptor(e, r$1).enumerable;
|
|
57
|
+
})), t.push.apply(t, o);
|
|
58
|
+
}
|
|
59
|
+
return t;
|
|
60
|
+
}
|
|
61
|
+
function _objectSpread2(e) {
|
|
62
|
+
for (var r = 1; r < arguments.length; r++) {
|
|
63
|
+
var t = null != arguments[r] ? arguments[r] : {};
|
|
64
|
+
r % 2 ? ownKeys(Object(t), !0).forEach(function(r$1) {
|
|
65
|
+
_defineProperty(e, r$1, t[r$1]);
|
|
66
|
+
}) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function(r$1) {
|
|
67
|
+
Object.defineProperty(e, r$1, Object.getOwnPropertyDescriptor(t, r$1));
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
return e;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
//#endregion
|
|
74
|
+
//#region src/env/env.ts
|
|
75
|
+
/**
|
|
76
|
+
* Retrieves an environment variable value.
|
|
77
|
+
* On the server side, it reads from process.env.
|
|
78
|
+
* On the client side, it reads from window.__ALOKAI_ENV__ to support runtime environment variables.
|
|
79
|
+
*
|
|
80
|
+
* @param key - The environment variable key (e.g., "NEXT_PUBLIC_API_URL")
|
|
81
|
+
* @returns The environment variable value or undefined if not found
|
|
82
|
+
*
|
|
83
|
+
* @example
|
|
84
|
+
* ```tsx
|
|
85
|
+
* import { env } from "@vue-storefront/next/client";
|
|
86
|
+
*
|
|
87
|
+
* const apiUrl = env("NEXT_PUBLIC_API_URL");
|
|
88
|
+
* ```
|
|
89
|
+
*/
|
|
90
|
+
function env(key) {
|
|
91
|
+
var _window$PUBLIC_ENV_KE;
|
|
92
|
+
if (typeof window === "undefined") return process.env[key];
|
|
93
|
+
return (_window$PUBLIC_ENV_KE = window[PUBLIC_ENV_KEY]) === null || _window$PUBLIC_ENV_KE === void 0 ? void 0 : _window$PUBLIC_ENV_KE[key];
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
//#endregion
|
|
97
|
+
export { _objectSpread2 as n, PUBLIC_ENV_KEY as r, env as t };
|
|
@@ -0,0 +1,250 @@
|
|
|
1
|
+
import React, { JSX, PropsWithChildren, ReactNode } from "react";
|
|
2
|
+
import { SDKApi, buildModule, middlewareModule } from "@alokai/connect/sdk";
|
|
3
|
+
import { cookies } from "next/headers";
|
|
4
|
+
|
|
5
|
+
//#region src/state.d.ts
|
|
6
|
+
type Maybe<TType> = null | TType;
|
|
7
|
+
type SfContract = {
|
|
8
|
+
SfCart: unknown;
|
|
9
|
+
SfCurrency: unknown;
|
|
10
|
+
SfCustomer: unknown;
|
|
11
|
+
SfLocale: unknown;
|
|
12
|
+
};
|
|
13
|
+
interface SfStateProps<TSfContract extends SfContract> {
|
|
14
|
+
currencies: TSfContract["SfCurrency"][];
|
|
15
|
+
currency: TSfContract["SfCurrency"];
|
|
16
|
+
locale: TSfContract["SfLocale"];
|
|
17
|
+
locales: TSfContract["SfLocale"][];
|
|
18
|
+
}
|
|
19
|
+
interface SfState<TSfContract extends SfContract> extends SfStateProps<TSfContract> {
|
|
20
|
+
cart: null | TSfContract["SfCart"] | undefined;
|
|
21
|
+
customer: null | TSfContract["SfCustomer"] | undefined;
|
|
22
|
+
setCart: (cart?: null | TSfContract["SfCart"]) => void;
|
|
23
|
+
setCurrencies: (currencies: TSfContract["SfCurrency"][]) => void;
|
|
24
|
+
setCurrency: (currency: TSfContract["SfCurrency"]) => void;
|
|
25
|
+
setCustomer: (customer?: null | TSfContract["SfCustomer"]) => void;
|
|
26
|
+
setLocale: (locale: TSfContract["SfLocale"]) => void;
|
|
27
|
+
setLocales: (locales: TSfContract["SfLocale"][]) => void;
|
|
28
|
+
}
|
|
29
|
+
declare function createSfStateProvider<TSfContract extends SfContract>(): {
|
|
30
|
+
SfStateProvider: ({
|
|
31
|
+
children,
|
|
32
|
+
initialData
|
|
33
|
+
}: {
|
|
34
|
+
initialData: SfStateProps<TSfContract>;
|
|
35
|
+
} & PropsWithChildren) => React.JSX.Element;
|
|
36
|
+
useSfCartState: () => [null | TSfContract["SfCart"] | undefined, (cart?: null | TSfContract["SfCart"]) => void];
|
|
37
|
+
useSfCurrenciesState: () => [TSfContract["SfCurrency"][], (currencies: TSfContract["SfCurrency"][]) => void];
|
|
38
|
+
useSfCurrencyState: () => [TSfContract["SfCurrency"], (currency: TSfContract["SfCurrency"]) => void];
|
|
39
|
+
useSfCustomerState: () => [null | TSfContract["SfCustomer"] | undefined, (customer?: null | TSfContract["SfCustomer"]) => void];
|
|
40
|
+
useSfLocalesState: () => [TSfContract["SfLocale"][], (locales: TSfContract["SfLocale"][]) => void];
|
|
41
|
+
useSfLocaleState: () => [TSfContract["SfLocale"], (locale: TSfContract["SfLocale"]) => void];
|
|
42
|
+
};
|
|
43
|
+
//#endregion
|
|
44
|
+
//#region src/sdk/helpers/defaultConfigs.d.ts
|
|
45
|
+
declare const defaultMethodsRequestConfig: {
|
|
46
|
+
readonly unifiedCms: {
|
|
47
|
+
readonly middlewareModule: {
|
|
48
|
+
readonly getEntries: {
|
|
49
|
+
readonly method: "GET";
|
|
50
|
+
};
|
|
51
|
+
readonly getPage: {
|
|
52
|
+
readonly method: "GET";
|
|
53
|
+
};
|
|
54
|
+
};
|
|
55
|
+
};
|
|
56
|
+
readonly unifiedCommerce: {
|
|
57
|
+
readonly middlewareModule: {
|
|
58
|
+
readonly getCategories: {
|
|
59
|
+
readonly method: "GET";
|
|
60
|
+
};
|
|
61
|
+
readonly getCategory: {
|
|
62
|
+
readonly method: "GET";
|
|
63
|
+
};
|
|
64
|
+
readonly getCurrencies: {
|
|
65
|
+
readonly method: "GET";
|
|
66
|
+
};
|
|
67
|
+
readonly getProductDetails: {
|
|
68
|
+
readonly method: "GET";
|
|
69
|
+
};
|
|
70
|
+
readonly getProductReviews: {
|
|
71
|
+
readonly method: "GET";
|
|
72
|
+
};
|
|
73
|
+
readonly getProducts: {
|
|
74
|
+
readonly method: "GET";
|
|
75
|
+
};
|
|
76
|
+
readonly searchProducts: {
|
|
77
|
+
readonly method: "GET";
|
|
78
|
+
};
|
|
79
|
+
};
|
|
80
|
+
};
|
|
81
|
+
};
|
|
82
|
+
//#endregion
|
|
83
|
+
//#region src/sdk/types.d.ts
|
|
84
|
+
interface MiddlewareConfig {
|
|
85
|
+
/**
|
|
86
|
+
* The URL of the middleware.
|
|
87
|
+
* @example "http://localhost:4000"
|
|
88
|
+
*/
|
|
89
|
+
apiUrl: string;
|
|
90
|
+
/**
|
|
91
|
+
* This is identifier used to invalidate the cache on CDN when the assets change.
|
|
92
|
+
* Usually it's a commit hash.
|
|
93
|
+
* @example "2c106d9619c71c3082c9b59b1d72817363c8ecb9"
|
|
94
|
+
* @default "no-cache-busting-id-set"
|
|
95
|
+
*/
|
|
96
|
+
cdnCacheBustingId?: string;
|
|
97
|
+
/**
|
|
98
|
+
* The URL of the middleware for server-side rendering.
|
|
99
|
+
* @example "http://localhost:4000"
|
|
100
|
+
*/
|
|
101
|
+
ssrApiUrl: string;
|
|
102
|
+
}
|
|
103
|
+
interface MultistoreConfig {
|
|
104
|
+
/**
|
|
105
|
+
* Whether the multistore is enabled or not.
|
|
106
|
+
* @example false
|
|
107
|
+
* @default false
|
|
108
|
+
*/
|
|
109
|
+
enabled: boolean;
|
|
110
|
+
}
|
|
111
|
+
interface CreateSdkOptions {
|
|
112
|
+
middleware: MiddlewareConfig;
|
|
113
|
+
multistore?: MultistoreConfig;
|
|
114
|
+
}
|
|
115
|
+
type Cookies = Awaited<ReturnType<typeof cookies>>;
|
|
116
|
+
type RequestHeaders = {
|
|
117
|
+
cookies: Cookies;
|
|
118
|
+
headers: Headers;
|
|
119
|
+
} | Headers | undefined;
|
|
120
|
+
type GetSdkContext = {
|
|
121
|
+
/**
|
|
122
|
+
* A function that returns the current locale string;
|
|
123
|
+
*/
|
|
124
|
+
getLocale?: () => string;
|
|
125
|
+
/**
|
|
126
|
+
* A function that returns the request headers.
|
|
127
|
+
*/
|
|
128
|
+
getRequestHeaders?: () => Promise<RequestHeaders> | RequestHeaders;
|
|
129
|
+
};
|
|
130
|
+
type DynamicContext = {
|
|
131
|
+
getRequestHeaders: () => Promise<Record<string, string | string[]>>;
|
|
132
|
+
};
|
|
133
|
+
type StaticContext = {
|
|
134
|
+
buildModule: typeof buildModule;
|
|
135
|
+
config: {
|
|
136
|
+
apiUrl: string;
|
|
137
|
+
cdnCacheBustingId: string;
|
|
138
|
+
defaultMethodsRequestConfig: typeof defaultMethodsRequestConfig;
|
|
139
|
+
ssrApiUrl: string;
|
|
140
|
+
};
|
|
141
|
+
/**
|
|
142
|
+
* @deprecated Use `config.defaultMethodsRequestConfig` instead.
|
|
143
|
+
*/
|
|
144
|
+
defaults: typeof defaultMethodsRequestConfig;
|
|
145
|
+
middlewareModule: typeof middlewareModule;
|
|
146
|
+
};
|
|
147
|
+
type InjectedContext = DynamicContext & StaticContext;
|
|
148
|
+
type Config<TConfig> = (context: InjectedContext) => TConfig;
|
|
149
|
+
type AlokaiProviderProps<TSdk, TSfContract extends SfContract> = {
|
|
150
|
+
children: ReactNode;
|
|
151
|
+
initialData: SfStateProps<TSfContract>;
|
|
152
|
+
sdk: TSdk;
|
|
153
|
+
};
|
|
154
|
+
interface CreateSdkReturn<TConfig extends Record<string, any>> {
|
|
155
|
+
/**
|
|
156
|
+
* Creates a new SDK instance. This function is dedicated for server-side usage,
|
|
157
|
+
* where a new SDK instance should be created for each request.
|
|
158
|
+
* For the client side usage, use the `createSdkContext` function instead.
|
|
159
|
+
*
|
|
160
|
+
* @param dynamicContext - The dynamic, request-specific, context
|
|
161
|
+
*
|
|
162
|
+
* @returns The SDK instance.
|
|
163
|
+
*
|
|
164
|
+
* @example
|
|
165
|
+
* For the Pages Router, you can use the `getSdk` function in the `getServerSideProps` function:
|
|
166
|
+
* ```tsx
|
|
167
|
+
* import type { GetServerSideProps } from "next";
|
|
168
|
+
* import { getSdk } from "../../sdk.config";
|
|
169
|
+
*
|
|
170
|
+
* export const getServerSideProps: GetServerSideProps = async ({ req, locale }) => {
|
|
171
|
+
* const sdk = await getSdk({
|
|
172
|
+
* getRequestHeaders: () => Promise.resolve(req.headers),
|
|
173
|
+
* getLocale: () => locale,
|
|
174
|
+
* });
|
|
175
|
+
* const { products } = await sdk.unified.getProducts();
|
|
176
|
+
*
|
|
177
|
+
* return {
|
|
178
|
+
* props: {...}
|
|
179
|
+
* }
|
|
180
|
+
* };
|
|
181
|
+
* ```
|
|
182
|
+
*
|
|
183
|
+
* @example
|
|
184
|
+
* For the App Router, you can use the `getSdk` function in your React Server Component:
|
|
185
|
+
* ```tsx
|
|
186
|
+
* import { headers } from "next/headers";
|
|
187
|
+
* import { getSdk } from "../../sdk.config";
|
|
188
|
+
*
|
|
189
|
+
* export default async function SsrPage() {
|
|
190
|
+
* const locale = await getLocale();
|
|
191
|
+
* const sdk = await getSdk({
|
|
192
|
+
* getRequestHeaders: () => headers(),
|
|
193
|
+
* getLocale: () => locale,
|
|
194
|
+
* });
|
|
195
|
+
* const { products } = await sdk.unified.getProducts();
|
|
196
|
+
*
|
|
197
|
+
* return <div>...</div>
|
|
198
|
+
* };
|
|
199
|
+
* ```
|
|
200
|
+
*/
|
|
201
|
+
getSdk: (dynamicContext?: GetSdkContext) => SDKApi<TConfig>;
|
|
202
|
+
}
|
|
203
|
+
type CreateSdkContextReturn<TSdk extends SDKApi<any>, TSfContract extends SfContract> = Readonly<{
|
|
204
|
+
AlokaiProvider: ({
|
|
205
|
+
children
|
|
206
|
+
}: AlokaiProviderProps<TSdk, TSfContract>) => JSX.Element;
|
|
207
|
+
useSdk: () => TSdk;
|
|
208
|
+
useSfCartState: ReturnType<typeof createSfStateProvider<TSfContract>>["useSfCartState"];
|
|
209
|
+
useSfCurrenciesState: ReturnType<typeof createSfStateProvider<TSfContract>>["useSfCurrenciesState"];
|
|
210
|
+
useSfCurrencyState: ReturnType<typeof createSfStateProvider<TSfContract>>["useSfCurrencyState"];
|
|
211
|
+
useSfCustomerState: ReturnType<typeof createSfStateProvider<TSfContract>>["useSfCustomerState"];
|
|
212
|
+
useSfLocalesState: ReturnType<typeof createSfStateProvider<TSfContract>>["useSfLocalesState"];
|
|
213
|
+
useSfLocaleState: ReturnType<typeof createSfStateProvider<TSfContract>>["useSfLocaleState"];
|
|
214
|
+
}>;
|
|
215
|
+
//#endregion
|
|
216
|
+
//#region src/env/env.d.ts
|
|
217
|
+
/**
|
|
218
|
+
* Retrieves an environment variable value.
|
|
219
|
+
* On the server side, it reads from process.env.
|
|
220
|
+
* On the client side, it reads from window.__ALOKAI_ENV__ to support runtime environment variables.
|
|
221
|
+
*
|
|
222
|
+
* @param key - The environment variable key (e.g., "NEXT_PUBLIC_API_URL")
|
|
223
|
+
* @returns The environment variable value or undefined if not found
|
|
224
|
+
*
|
|
225
|
+
* @example
|
|
226
|
+
* ```tsx
|
|
227
|
+
* import { env } from "@vue-storefront/next/client";
|
|
228
|
+
*
|
|
229
|
+
* const apiUrl = env("NEXT_PUBLIC_API_URL");
|
|
230
|
+
* ```
|
|
231
|
+
*/
|
|
232
|
+
declare function env(key: string): string | undefined;
|
|
233
|
+
//#endregion
|
|
234
|
+
//#region src/env/types.d.ts
|
|
235
|
+
/**
|
|
236
|
+
* Type representing environment variables as key-value pairs
|
|
237
|
+
*/
|
|
238
|
+
interface PublicEnv {
|
|
239
|
+
[key: string]: string | undefined;
|
|
240
|
+
}
|
|
241
|
+
/**
|
|
242
|
+
* Extended window interface to include Alokai environment variables
|
|
243
|
+
*/
|
|
244
|
+
declare global {
|
|
245
|
+
interface Window {
|
|
246
|
+
__ALOKAI_ENV__?: PublicEnv;
|
|
247
|
+
}
|
|
248
|
+
}
|
|
249
|
+
//#endregion
|
|
250
|
+
export { CreateSdkReturn as a, SfContract as c, createSfStateProvider as d, CreateSdkOptions as i, SfState as l, Config as n, InjectedContext as o, CreateSdkContextReturn as r, Maybe as s, env as t, SfStateProps as u };
|