@vue-storefront/next 7.0.0-next.3 → 7.0.0-next.5

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.
@@ -0,0 +1,223 @@
1
+ "use client";
2
+
3
+ //#region rolldown:runtime
4
+ var __create = Object.create;
5
+ var __defProp = Object.defineProperty;
6
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
7
+ var __getOwnPropNames = Object.getOwnPropertyNames;
8
+ var __getProtoOf = Object.getPrototypeOf;
9
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
13
+ key = keys[i];
14
+ if (!__hasOwnProp.call(to, key) && key !== except) {
15
+ __defProp(to, key, {
16
+ get: ((k) => from[k]).bind(null, key),
17
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
18
+ });
19
+ }
20
+ }
21
+ }
22
+ return to;
23
+ };
24
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
25
+ value: mod,
26
+ enumerable: true
27
+ }) : target, mod));
28
+
29
+ //#endregion
30
+ const require_env = require('./env-BxyAENtV.cjs');
31
+ let _alokai_instrumentation_next_component = require("@alokai/instrumentation-next-component");
32
+ let next_script = require("next/script");
33
+ next_script = __toESM(next_script);
34
+ let react = require("react");
35
+ react = __toESM(react);
36
+ let zustand = require("zustand");
37
+
38
+ //#region src/env/get-public-env.ts
39
+ /**
40
+ * Extracts all NEXT_PUBLIC_* environment variables from process.env
41
+ * This is used server-side to prepare env vars for injection into the client
42
+ *
43
+ * @returns Object containing all NEXT_PUBLIC_* environment variables
44
+ */
45
+ function getPublicEnv() {
46
+ const publicEnv = {};
47
+ for (const key in process.env) if (key.startsWith("NEXT_PUBLIC_")) publicEnv[key] = process.env[key];
48
+ return publicEnv;
49
+ }
50
+
51
+ //#endregion
52
+ //#region src/state.tsx
53
+ const createSfState = (initialData) => {
54
+ return (0, zustand.createStore)()((set) => require_env._objectSpread2(require_env._objectSpread2({
55
+ cart: null,
56
+ customer: null
57
+ }, initialData), {}, {
58
+ setCart: (cart) => set({ cart }),
59
+ setCurrencies: (currencies) => set({ currencies }),
60
+ setCurrency: (currency) => set({ currency }),
61
+ setCustomer: (customer) => set({ customer }),
62
+ setLocale: (locale) => set({ locale }),
63
+ setLocales: (locales) => set({ locales })
64
+ }));
65
+ };
66
+ function createSfStateProvider() {
67
+ const SfStateContext = (0, react.createContext)(null);
68
+ function SfStateProvider({ children, initialData }) {
69
+ const stateReference = (0, react.useRef)(null);
70
+ if (!stateReference.current) stateReference.current = createSfState(initialData);
71
+ return /* @__PURE__ */ react.default.createElement(SfStateContext.Provider, { value: stateReference.current }, children);
72
+ }
73
+ function getSfStateContext() {
74
+ const context = (0, react.useContext)(SfStateContext);
75
+ if (!context) throw new Error("Missing SfStateContext.Provider in the tree");
76
+ return context;
77
+ }
78
+ function useSfCurrencyState() {
79
+ const { currency, setCurrency } = (0, zustand.useStore)(getSfStateContext(), (state) => ({
80
+ currency: state.currency,
81
+ setCurrency: state.setCurrency
82
+ }));
83
+ return [currency, setCurrency];
84
+ }
85
+ function useSfCurrenciesState() {
86
+ const { currencies, setCurrencies } = (0, zustand.useStore)(getSfStateContext(), (state) => ({
87
+ currencies: state.currencies,
88
+ setCurrencies: state.setCurrencies
89
+ }));
90
+ return [currencies, setCurrencies];
91
+ }
92
+ function useSfLocaleState() {
93
+ const { locale, setLocale } = (0, zustand.useStore)(getSfStateContext(), (state) => ({
94
+ locale: state.locale,
95
+ setLocale: state.setLocale
96
+ }));
97
+ return [locale, setLocale];
98
+ }
99
+ function useSfLocalesState() {
100
+ const { locales, setLocales } = (0, zustand.useStore)(getSfStateContext(), (state) => ({
101
+ locales: state.locales,
102
+ setLocales: state.setLocales
103
+ }));
104
+ return [locales, setLocales];
105
+ }
106
+ function useSfCartState() {
107
+ const { cart, setCart } = (0, zustand.useStore)(getSfStateContext(), (state) => ({
108
+ cart: state.cart,
109
+ setCart: state.setCart
110
+ }));
111
+ return [cart, setCart];
112
+ }
113
+ function useSfCustomerState() {
114
+ const { customer, setCustomer } = (0, zustand.useStore)(getSfStateContext(), (state) => ({
115
+ customer: state.customer,
116
+ setCustomer: state.setCustomer
117
+ }));
118
+ return [customer, setCustomer];
119
+ }
120
+ return {
121
+ SfStateProvider,
122
+ useSfCartState,
123
+ useSfCurrenciesState,
124
+ useSfCurrencyState,
125
+ useSfCustomerState,
126
+ useSfLocalesState,
127
+ useSfLocaleState
128
+ };
129
+ }
130
+
131
+ //#endregion
132
+ //#region \0@oxc-project+runtime@0.107.0/helpers/objectWithoutPropertiesLoose.js
133
+ function _objectWithoutPropertiesLoose(r, e) {
134
+ if (null == r) return {};
135
+ var t = {};
136
+ for (var n in r) if ({}.hasOwnProperty.call(r, n)) {
137
+ if (e.includes(n)) continue;
138
+ t[n] = r[n];
139
+ }
140
+ return t;
141
+ }
142
+
143
+ //#endregion
144
+ //#region \0@oxc-project+runtime@0.107.0/helpers/objectWithoutProperties.js
145
+ function _objectWithoutProperties(e, t) {
146
+ if (null == e) return {};
147
+ var o, r, i = _objectWithoutPropertiesLoose(e, t);
148
+ if (Object.getOwnPropertySymbols) {
149
+ var s = Object.getOwnPropertySymbols(e);
150
+ for (r = 0; r < s.length; r++) o = s[r], t.includes(o) || {}.propertyIsEnumerable.call(e, o) && (i[o] = e[o]);
151
+ }
152
+ return i;
153
+ }
154
+
155
+ //#endregion
156
+ //#region src/alokai-provider.tsx
157
+ const _excluded = ["SfStateProvider"];
158
+ /**
159
+ * Creates a new Alokai context which is a combination of SDK and state contexts.
160
+ * This function is dedicated for the client-side usage.
161
+ *
162
+ * @example
163
+ * Create a new Alokai context somewhere in your application. It may be the `hooks/sdk.ts` file.
164
+ *
165
+ * ```tsx
166
+ * 'use client';
167
+ *
168
+ * import { createAlokaiContext } from "@vue-storefront/next/client";
169
+ * import type { Sdk } from './sdk.server';
170
+ * import type { SfContract } from 'storefront-middleware/types';
171
+ *
172
+ * export const {
173
+ * AlokaiProvider,
174
+ * useSdk,
175
+ * useSfCartState,
176
+ * useSfCurrenciesState,
177
+ * useSfCurrencyState,
178
+ * useSfCustomerState,
179
+ * } = createAlokaiContext<Sdk, SfContract>();
180
+ * ```
181
+ * This is also a place where you can import hooks for handling the state management.
182
+ * You can read more about the state management in the documentation https://docs.alokai.com/sdk/getting-started/state-management.
183
+ * Then use the `AlokaiProvider` in the root component of your application.
184
+ * For Pages Router it would be the `pages/_app.tsx` file,
185
+ * and for the App Router it would be the `app/layout.tsx` file.
186
+ * Finally, you can use the `useSdk` in any client component of your application.
187
+ * @returns AlokaiProvider - The Alokai Context Provider.
188
+ * @returns useSdk - The SDK provider and the `useSdk` hook.
189
+ * @returns useSfCartState - Hook that return Cart state with `SfCart` type.
190
+ * @returns useSfCurrenciesState - Hook that return Currencies state with `SfCurrency` type.
191
+ * @returns useSfCurrencyState - Hook that return Currency state with `SfCurrency[]` type.
192
+ * @returns useSfCustomerState - Hook that return Customer state with `SfCustomer` type.
193
+ */
194
+ function createAlokaiContext() {
195
+ const SdkContext = (0, react.createContext)(null);
196
+ const _createSfStateProvide = createSfStateProvider(), { SfStateProvider } = _createSfStateProvide, rest = _objectWithoutProperties(_createSfStateProvide, _excluded);
197
+ function AlokaiProvider({ children, initialData, sdk }) {
198
+ const publicEnv = typeof window === "undefined" ? getPublicEnv() : void 0;
199
+ const envScript = publicEnv ? `window['${require_env.PUBLIC_ENV_KEY}'] = ${JSON.stringify(publicEnv)};` : "";
200
+ return /* @__PURE__ */ react.default.createElement(SdkContext.Provider, { value: sdk }, /* @__PURE__ */ react.default.createElement("meta", {
201
+ content: "Alokai Storefront",
202
+ name: "generator"
203
+ }), publicEnv && /* @__PURE__ */ react.default.createElement(next_script.default, {
204
+ id: "alokaiEnv",
205
+ strategy: "beforeInteractive"
206
+ }, envScript), /* @__PURE__ */ react.default.createElement(_alokai_instrumentation_next_component.AlokaiInstrumentation, null), /* @__PURE__ */ react.default.createElement(SfStateProvider, { initialData }, children));
207
+ }
208
+ const useSdk = () => {
209
+ const contextSdk = (0, react.useContext)(SdkContext);
210
+ if (!contextSdk) throw new Error("useSdk must be used within a AlokaiProvider");
211
+ return contextSdk;
212
+ };
213
+ return require_env._objectSpread2({
214
+ AlokaiProvider,
215
+ useSdk
216
+ }, rest);
217
+ }
218
+
219
+ //#endregion
220
+ exports.__toESM = __toESM;
221
+ exports.createAlokaiContext = createAlokaiContext;
222
+ exports.createSfStateProvider = createSfStateProvider;
223
+ exports.env = require_env.env;
@@ -1,8 +1,7 @@
1
- import { SDKApi } from '@alokai/connect/sdk';
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
- import 'next/headers';
5
- import 'react';
1
+ import { c as SfContract, d as createSfStateProvider, l as SfState, r as CreateSdkContextReturn, s as Maybe, t as env, u as SfStateProps } from "./index-D1weTw7N.cjs";
2
+ import { SDKApi } from "@alokai/connect/sdk";
3
+
4
+ //#region src/alokai-provider.d.ts
6
5
 
7
6
  /**
8
7
  * Creates a new Alokai context which is a combination of SDK and state contexts.
@@ -41,5 +40,5 @@ import 'react';
41
40
  * @returns useSfCustomerState - Hook that return Customer state with `SfCustomer` type.
42
41
  */
43
42
  declare function createAlokaiContext<TSdk extends SDKApi<any>, TSfContract extends SfContract>(): CreateSdkContextReturn<TSdk, TSfContract>;
44
-
45
- export { CreateSdkContextReturn, SfContract, createAlokaiContext };
43
+ //#endregion
44
+ export { type CreateSdkContextReturn, Maybe, SfContract, SfState, SfStateProps, createAlokaiContext, createSfStateProvider, env };
package/dist/client.d.mts CHANGED
@@ -1,8 +1,7 @@
1
- import { SDKApi } from '@alokai/connect/sdk';
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
- import 'next/headers';
5
- import 'react';
1
+ import { c as SfContract, d as createSfStateProvider, l as SfState, r as CreateSdkContextReturn, s as Maybe, t as env, u as SfStateProps } from "./index-BXYjHxeC.mjs";
2
+ import { SDKApi } from "@alokai/connect/sdk";
3
+
4
+ //#region src/alokai-provider.d.ts
6
5
 
7
6
  /**
8
7
  * Creates a new Alokai context which is a combination of SDK and state contexts.
@@ -41,5 +40,5 @@ import 'react';
41
40
  * @returns useSfCustomerState - Hook that return Customer state with `SfCustomer` type.
42
41
  */
43
42
  declare function createAlokaiContext<TSdk extends SDKApi<any>, TSfContract extends SfContract>(): CreateSdkContextReturn<TSdk, TSfContract>;
44
-
45
- export { CreateSdkContextReturn, SfContract, createAlokaiContext };
43
+ //#endregion
44
+ export { type CreateSdkContextReturn, Maybe, SfContract, SfState, SfStateProps, createAlokaiContext, createSfStateProvider, env };
package/dist/client.mjs CHANGED
@@ -1,150 +1,191 @@
1
1
  "use client";
2
- import {
3
- PUBLIC_ENV_KEY,
4
- __objRest,
5
- __spreadProps,
6
- __spreadValues,
7
- env,
8
- getPublicEnv
9
- } from "./chunk-NSPLXZD5.mjs";
10
2
 
11
- // src/alokai-provider.tsx
3
+ import { n as _objectSpread2, r as PUBLIC_ENV_KEY, t as env } from "./env-BFUtR_CT.mjs";
12
4
  import { AlokaiInstrumentation } from "@alokai/instrumentation-next-component";
13
5
  import Script from "next/script";
14
- import React2, { createContext as createContext2, useContext as useContext2 } from "react";
15
-
16
- // src/state.tsx
17
- import React, {
18
- createContext,
19
- useContext,
20
- useRef
21
- } from "react";
6
+ import React, { createContext, useContext, useRef } from "react";
22
7
  import { createStore, useStore } from "zustand";
23
- var createSfState = (initialData) => {
24
- return createStore()((set) => __spreadProps(__spreadValues({
25
- cart: null,
26
- customer: null
27
- }, initialData), {
28
- setCart: (cart) => set({ cart }),
29
- setCurrencies: (currencies) => set({ currencies }),
30
- setCurrency: (currency) => set({ currency }),
31
- setCustomer: (customer) => set({ customer }),
32
- setLocale: (locale) => set({ locale }),
33
- setLocales: (locales) => set({ locales })
34
- }));
8
+
9
+ //#region src/env/get-public-env.ts
10
+ /**
11
+ * Extracts all NEXT_PUBLIC_* environment variables from process.env
12
+ * This is used server-side to prepare env vars for injection into the client
13
+ *
14
+ * @returns Object containing all NEXT_PUBLIC_* environment variables
15
+ */
16
+ function getPublicEnv() {
17
+ const publicEnv = {};
18
+ for (const key in process.env) if (key.startsWith("NEXT_PUBLIC_")) publicEnv[key] = process.env[key];
19
+ return publicEnv;
20
+ }
21
+
22
+ //#endregion
23
+ //#region src/state.tsx
24
+ const createSfState = (initialData) => {
25
+ return createStore()((set) => _objectSpread2(_objectSpread2({
26
+ cart: null,
27
+ customer: null
28
+ }, initialData), {}, {
29
+ setCart: (cart) => set({ cart }),
30
+ setCurrencies: (currencies) => set({ currencies }),
31
+ setCurrency: (currency) => set({ currency }),
32
+ setCustomer: (customer) => set({ customer }),
33
+ setLocale: (locale) => set({ locale }),
34
+ setLocales: (locales) => set({ locales })
35
+ }));
35
36
  };
36
37
  function createSfStateProvider() {
37
- const SfStateContext = createContext(null);
38
- function SfStateProvider({
39
- children,
40
- initialData
41
- }) {
42
- const stateReference = useRef();
43
- if (!stateReference.current) {
44
- stateReference.current = createSfState(initialData);
45
- }
46
- return /* @__PURE__ */ React.createElement(SfStateContext.Provider, { value: stateReference.current }, children);
47
- }
48
- function getSfStateContext() {
49
- const context = useContext(SfStateContext);
50
- if (!context)
51
- throw new Error("Missing SfStateContext.Provider in the tree");
52
- return context;
53
- }
54
- function useSfCurrencyState() {
55
- const { currency, setCurrency } = useStore(
56
- getSfStateContext(),
57
- (state) => ({
58
- currency: state.currency,
59
- setCurrency: state.setCurrency
60
- })
61
- );
62
- return [currency, setCurrency];
63
- }
64
- function useSfCurrenciesState() {
65
- const { currencies, setCurrencies } = useStore(
66
- getSfStateContext(),
67
- (state) => ({
68
- currencies: state.currencies,
69
- setCurrencies: state.setCurrencies
70
- })
71
- );
72
- return [currencies, setCurrencies];
73
- }
74
- function useSfLocaleState() {
75
- const { locale, setLocale } = useStore(getSfStateContext(), (state) => ({
76
- locale: state.locale,
77
- setLocale: state.setLocale
78
- }));
79
- return [locale, setLocale];
80
- }
81
- function useSfLocalesState() {
82
- const { locales, setLocales } = useStore(getSfStateContext(), (state) => ({
83
- locales: state.locales,
84
- setLocales: state.setLocales
85
- }));
86
- return [locales, setLocales];
87
- }
88
- function useSfCartState() {
89
- const { cart, setCart } = useStore(getSfStateContext(), (state) => ({
90
- cart: state.cart,
91
- setCart: state.setCart
92
- }));
93
- return [cart, setCart];
94
- }
95
- function useSfCustomerState() {
96
- const { customer, setCustomer } = useStore(
97
- getSfStateContext(),
98
- (state) => ({
99
- customer: state.customer,
100
- setCustomer: state.setCustomer
101
- })
102
- );
103
- return [customer, setCustomer];
104
- }
105
- return {
106
- SfStateProvider,
107
- useSfCartState,
108
- useSfCurrenciesState,
109
- useSfCurrencyState,
110
- useSfCustomerState,
111
- useSfLocalesState,
112
- useSfLocaleState
113
- };
38
+ const SfStateContext = createContext(null);
39
+ function SfStateProvider({ children, initialData }) {
40
+ const stateReference = useRef(null);
41
+ if (!stateReference.current) stateReference.current = createSfState(initialData);
42
+ return /* @__PURE__ */ React.createElement(SfStateContext.Provider, { value: stateReference.current }, children);
43
+ }
44
+ function getSfStateContext() {
45
+ const context = useContext(SfStateContext);
46
+ if (!context) throw new Error("Missing SfStateContext.Provider in the tree");
47
+ return context;
48
+ }
49
+ function useSfCurrencyState() {
50
+ const { currency, setCurrency } = useStore(getSfStateContext(), (state) => ({
51
+ currency: state.currency,
52
+ setCurrency: state.setCurrency
53
+ }));
54
+ return [currency, setCurrency];
55
+ }
56
+ function useSfCurrenciesState() {
57
+ const { currencies, setCurrencies } = useStore(getSfStateContext(), (state) => ({
58
+ currencies: state.currencies,
59
+ setCurrencies: state.setCurrencies
60
+ }));
61
+ return [currencies, setCurrencies];
62
+ }
63
+ function useSfLocaleState() {
64
+ const { locale, setLocale } = useStore(getSfStateContext(), (state) => ({
65
+ locale: state.locale,
66
+ setLocale: state.setLocale
67
+ }));
68
+ return [locale, setLocale];
69
+ }
70
+ function useSfLocalesState() {
71
+ const { locales, setLocales } = useStore(getSfStateContext(), (state) => ({
72
+ locales: state.locales,
73
+ setLocales: state.setLocales
74
+ }));
75
+ return [locales, setLocales];
76
+ }
77
+ function useSfCartState() {
78
+ const { cart, setCart } = useStore(getSfStateContext(), (state) => ({
79
+ cart: state.cart,
80
+ setCart: state.setCart
81
+ }));
82
+ return [cart, setCart];
83
+ }
84
+ function useSfCustomerState() {
85
+ const { customer, setCustomer } = useStore(getSfStateContext(), (state) => ({
86
+ customer: state.customer,
87
+ setCustomer: state.setCustomer
88
+ }));
89
+ return [customer, setCustomer];
90
+ }
91
+ return {
92
+ SfStateProvider,
93
+ useSfCartState,
94
+ useSfCurrenciesState,
95
+ useSfCurrencyState,
96
+ useSfCustomerState,
97
+ useSfLocalesState,
98
+ useSfLocaleState
99
+ };
100
+ }
101
+
102
+ //#endregion
103
+ //#region \0@oxc-project+runtime@0.107.0/helpers/objectWithoutPropertiesLoose.js
104
+ function _objectWithoutPropertiesLoose(r, e) {
105
+ if (null == r) return {};
106
+ var t = {};
107
+ for (var n in r) if ({}.hasOwnProperty.call(r, n)) {
108
+ if (e.includes(n)) continue;
109
+ t[n] = r[n];
110
+ }
111
+ return t;
112
+ }
113
+
114
+ //#endregion
115
+ //#region \0@oxc-project+runtime@0.107.0/helpers/objectWithoutProperties.js
116
+ function _objectWithoutProperties(e, t) {
117
+ if (null == e) return {};
118
+ var o, r, i = _objectWithoutPropertiesLoose(e, t);
119
+ if (Object.getOwnPropertySymbols) {
120
+ var s = Object.getOwnPropertySymbols(e);
121
+ for (r = 0; r < s.length; r++) o = s[r], t.includes(o) || {}.propertyIsEnumerable.call(e, o) && (i[o] = e[o]);
122
+ }
123
+ return i;
114
124
  }
115
125
 
116
- // src/alokai-provider.tsx
126
+ //#endregion
127
+ //#region src/alokai-provider.tsx
128
+ const _excluded = ["SfStateProvider"];
129
+ /**
130
+ * Creates a new Alokai context which is a combination of SDK and state contexts.
131
+ * This function is dedicated for the client-side usage.
132
+ *
133
+ * @example
134
+ * Create a new Alokai context somewhere in your application. It may be the `hooks/sdk.ts` file.
135
+ *
136
+ * ```tsx
137
+ * 'use client';
138
+ *
139
+ * import { createAlokaiContext } from "@vue-storefront/next/client";
140
+ * import type { Sdk } from './sdk.server';
141
+ * import type { SfContract } from 'storefront-middleware/types';
142
+ *
143
+ * export const {
144
+ * AlokaiProvider,
145
+ * useSdk,
146
+ * useSfCartState,
147
+ * useSfCurrenciesState,
148
+ * useSfCurrencyState,
149
+ * useSfCustomerState,
150
+ * } = createAlokaiContext<Sdk, SfContract>();
151
+ * ```
152
+ * This is also a place where you can import hooks for handling the state management.
153
+ * You can read more about the state management in the documentation https://docs.alokai.com/sdk/getting-started/state-management.
154
+ * Then use the `AlokaiProvider` in the root component of your application.
155
+ * For Pages Router it would be the `pages/_app.tsx` file,
156
+ * and for the App Router it would be the `app/layout.tsx` file.
157
+ * Finally, you can use the `useSdk` in any client component of your application.
158
+ * @returns AlokaiProvider - The Alokai Context Provider.
159
+ * @returns useSdk - The SDK provider and the `useSdk` hook.
160
+ * @returns useSfCartState - Hook that return Cart state with `SfCart` type.
161
+ * @returns useSfCurrenciesState - Hook that return Currencies state with `SfCurrency` type.
162
+ * @returns useSfCurrencyState - Hook that return Currency state with `SfCurrency[]` type.
163
+ * @returns useSfCustomerState - Hook that return Customer state with `SfCustomer` type.
164
+ */
117
165
  function createAlokaiContext() {
118
- const SdkContext = createContext2(null);
119
- const _a = createSfStateProvider(), { SfStateProvider } = _a, rest = __objRest(_a, ["SfStateProvider"]);
120
- function AlokaiProvider({
121
- children,
122
- initialData,
123
- sdk
124
- }) {
125
- const metaTagScript = `
126
- const vsfMetaTag = document.createElement("meta");
127
- vsfMetaTag.setAttribute("name", "generator");
128
- vsfMetaTag.setAttribute("content", "Alokai Storefront");
129
- document.head.appendChild(vsfMetaTag);
130
- `;
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" }, `
134
- ${metaTagScript}
135
- `), /* @__PURE__ */ React2.createElement(AlokaiInstrumentation, null), /* @__PURE__ */ React2.createElement(SfStateProvider, { initialData }, children));
136
- }
137
- const useSdk = () => {
138
- const contextSdk = useContext2(SdkContext);
139
- if (!contextSdk) {
140
- throw new Error("useSdk must be used within a AlokaiProvider");
141
- }
142
- return contextSdk;
143
- };
144
- return __spreadValues({ AlokaiProvider, useSdk }, rest);
166
+ const SdkContext = createContext(null);
167
+ const _createSfStateProvide = createSfStateProvider(), { SfStateProvider } = _createSfStateProvide, rest = _objectWithoutProperties(_createSfStateProvide, _excluded);
168
+ function AlokaiProvider({ children, initialData, sdk }) {
169
+ const publicEnv = typeof window === "undefined" ? getPublicEnv() : void 0;
170
+ const envScript = publicEnv ? `window['${PUBLIC_ENV_KEY}'] = ${JSON.stringify(publicEnv)};` : "";
171
+ return /* @__PURE__ */ React.createElement(SdkContext.Provider, { value: sdk }, /* @__PURE__ */ React.createElement("meta", {
172
+ content: "Alokai Storefront",
173
+ name: "generator"
174
+ }), publicEnv && /* @__PURE__ */ React.createElement(Script, {
175
+ id: "alokaiEnv",
176
+ strategy: "beforeInteractive"
177
+ }, envScript), /* @__PURE__ */ React.createElement(AlokaiInstrumentation, null), /* @__PURE__ */ React.createElement(SfStateProvider, { initialData }, children));
178
+ }
179
+ const useSdk = () => {
180
+ const contextSdk = useContext(SdkContext);
181
+ if (!contextSdk) throw new Error("useSdk must be used within a AlokaiProvider");
182
+ return contextSdk;
183
+ };
184
+ return _objectSpread2({
185
+ AlokaiProvider,
186
+ useSdk
187
+ }, rest);
145
188
  }
146
- export {
147
- createAlokaiContext,
148
- createSfStateProvider,
149
- env
150
- };
189
+
190
+ //#endregion
191
+ export { createAlokaiContext, createSfStateProvider, env };