@kotao/storefront 0.2.9 → 0.2.11
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 +20 -2
- package/dist/{chunk-PHEKJDFW.js → chunk-4OELOXCN.js} +17 -4
- package/dist/chunk-4OELOXCN.js.map +1 -0
- package/dist/{chunk-OGWYTYYS.js → chunk-GR4QJ7EC.js} +14 -22
- package/dist/chunk-GR4QJ7EC.js.map +1 -0
- package/dist/{chunk-S4HW5NH7.js → chunk-NRWS7HJ2.js} +65 -18
- package/dist/chunk-NRWS7HJ2.js.map +1 -0
- package/dist/{chunk-3YQXJNR7.js → chunk-PWVXOMDE.js} +18 -9
- package/dist/chunk-PWVXOMDE.js.map +1 -0
- package/dist/{client-D-M3Y1ul.d.ts → client-Bt8EEr-K.d.ts} +1 -1
- package/dist/editor.d.ts +1 -1
- package/dist/editor.js +1 -1
- package/dist/events-react.d.ts +2 -2
- package/dist/events.d.ts +2 -2
- package/dist/forms.d.ts +2 -2
- package/dist/image.d.ts +1 -1
- package/dist/image.js +1 -1
- package/dist/index.d.ts +19 -31
- package/dist/index.js +29 -86
- package/dist/index.js.map +1 -1
- package/dist/{pagination-DCrQk02Q.d.ts → pagination-CPgH3fAa.d.ts} +1 -1
- package/dist/product.d.ts +1 -1
- package/dist/react-router.d.ts +18 -6
- package/dist/react-router.js +43 -4
- package/dist/react-router.js.map +1 -1
- package/dist/react.d.ts +17 -7
- package/dist/react.js +50 -21
- package/dist/react.js.map +1 -1
- package/dist/{routing-BYc6JReb.d.ts → routing-hrvYWYEV.d.ts} +3 -1
- package/dist/{shop-keSWbFKV.d.ts → shop-wJdcWcVz.d.ts} +19 -9
- package/dist/{types-CSNXbGFW.d.ts → types-BTUTZXxJ.d.ts} +4 -3
- package/package.json +2 -2
- package/dist/chunk-3YQXJNR7.js.map +0 -1
- package/dist/chunk-OGWYTYYS.js.map +0 -1
- package/dist/chunk-PHEKJDFW.js.map +0 -1
- package/dist/chunk-S4HW5NH7.js.map +0 -1
package/dist/react.js
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import { getCartFormInput, createAnalyticsBus, collectAnalyticsAttribution, createPixelTransport } from './chunk-
|
|
2
|
-
export { useNonce } from './chunk-S4HW5NH7.js';
|
|
1
|
+
import { getCartFormInput, createAnalyticsBus, collectAnalyticsAttribution, createPixelTransport, createContentSecurityPolicy } from './chunk-NRWS7HJ2.js';
|
|
3
2
|
import { getPaginationInfo } from './chunk-5QOFKGKD.js';
|
|
4
|
-
import { CART_FORM_ACTIONS,
|
|
3
|
+
import { CART_FORM_ACTIONS, DENIED_CONSENT, mergeConsent, buildConsentCookie, readConsentCookie, CONSENT_COOKIE } from './chunk-GR4QJ7EC.js';
|
|
5
4
|
import { getSeoMeta, serializeJsonLd } from './chunk-SVMYFYIA.js';
|
|
6
5
|
export { REACT_SEAM_CART_DOCUMENTS, createStorefrontApiCartAdapter } from './chunk-WNXI3MPM.js';
|
|
7
6
|
import { resolveHydrogenEditorStyles } from './chunk-XXNCFWXT.js';
|
|
8
7
|
export { StorefrontForm, StorefrontFormFields } from './chunk-VV653S52.js';
|
|
9
8
|
import './chunk-IIOHENCG.js';
|
|
10
|
-
import { buildImageAttrs } from './chunk-
|
|
9
|
+
import { buildImageAttrs } from './chunk-PWVXOMDE.js';
|
|
10
|
+
import * as ReactRuntime from 'react';
|
|
11
11
|
import { createContext, useState, useRef, useMemo, useEffect, useCallback, useContext, useSyncExternalStore, Children, isValidElement, cloneElement, createElement } from 'react';
|
|
12
12
|
import { useFetcher } from 'react-router';
|
|
13
13
|
import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
@@ -159,9 +159,13 @@ var beaconSend = (endpoint, body) => {
|
|
|
159
159
|
}
|
|
160
160
|
};
|
|
161
161
|
var AnalyticsReactContext = createContext(null);
|
|
162
|
+
function nativeConsent() {
|
|
163
|
+
const api = typeof window === "undefined" ? void 0 : window.KotaoConsent;
|
|
164
|
+
return typeof api?.get === "function" && typeof api.hasDecision === "function" && typeof api.set === "function" ? api : void 0;
|
|
165
|
+
}
|
|
162
166
|
function AnalyticsProvider(props) {
|
|
163
|
-
const [consent, setConsentState] = useState(
|
|
164
|
-
const [decided, setDecided] = useState(
|
|
167
|
+
const [consent, setConsentState] = useState(DENIED_CONSENT);
|
|
168
|
+
const [decided, setDecided] = useState(false);
|
|
165
169
|
const [mounted, setMounted] = useState(false);
|
|
166
170
|
const consentRef = useRef(consent);
|
|
167
171
|
consentRef.current = consent;
|
|
@@ -213,21 +217,24 @@ function AnalyticsProvider(props) {
|
|
|
213
217
|
);
|
|
214
218
|
useEffect(() => {
|
|
215
219
|
setMounted(true);
|
|
216
|
-
const
|
|
217
|
-
|
|
218
|
-
const
|
|
219
|
-
consentRef.current =
|
|
220
|
-
setConsentState(
|
|
221
|
-
setDecided(
|
|
222
|
-
}
|
|
220
|
+
const sync = () => {
|
|
221
|
+
const api = nativeConsent();
|
|
222
|
+
const next = api?.get() ?? readConsentCookie(document.cookie);
|
|
223
|
+
consentRef.current = next;
|
|
224
|
+
setConsentState(next);
|
|
225
|
+
setDecided(api?.hasDecision() ?? document.cookie.includes(`${CONSENT_COOKIE}=v1.`));
|
|
226
|
+
};
|
|
227
|
+
sync();
|
|
228
|
+
document.addEventListener("kotao:consent-changed", sync);
|
|
229
|
+
return () => document.removeEventListener("kotao:consent-changed", sync);
|
|
223
230
|
}, []);
|
|
224
231
|
const setConsent = useCallback((patch) => {
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
232
|
+
const next = mergeConsent(consentRef.current, patch);
|
|
233
|
+
consentRef.current = next;
|
|
234
|
+
const api = nativeConsent();
|
|
235
|
+
if (api !== void 0) api.set(next);
|
|
236
|
+
else if (typeof document !== "undefined") document.cookie = buildConsentCookie(next);
|
|
237
|
+
setConsentState(next);
|
|
231
238
|
setDecided(true);
|
|
232
239
|
}, []);
|
|
233
240
|
useEffect(() => {
|
|
@@ -505,6 +512,28 @@ function Money({
|
|
|
505
512
|
const text = data == null ? "" : withoutCurrency === true ? useMoney(data).withoutTrailingZerosAndCurrency : withoutTrailingZeros === true ? useMoney(data).withoutTrailingZeros : useMoney(data).localizedString;
|
|
506
513
|
return /* @__PURE__ */ jsx(Component, { ...passthrough, children: text });
|
|
507
514
|
}
|
|
515
|
+
var NonceContext = createContext(void 0);
|
|
516
|
+
function createNonceProvider(nonce) {
|
|
517
|
+
return function BoundNonceProvider(props) {
|
|
518
|
+
return createElement(NonceContext.Provider, { value: nonce }, props.children);
|
|
519
|
+
};
|
|
520
|
+
}
|
|
521
|
+
function useNonce() {
|
|
522
|
+
if (!hasReactDispatcher()) return void 0;
|
|
523
|
+
return useContext(NonceContext);
|
|
524
|
+
}
|
|
525
|
+
function hasReactDispatcher() {
|
|
526
|
+
const runtime = ReactRuntime;
|
|
527
|
+
return Boolean(
|
|
528
|
+
runtime.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE?.H ?? runtime.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED?.ReactCurrentDispatcher?.current
|
|
529
|
+
);
|
|
530
|
+
}
|
|
531
|
+
|
|
532
|
+
// src/react/content-security-policy.ts
|
|
533
|
+
function createContentSecurityPolicy2(options = {}) {
|
|
534
|
+
const policy = createContentSecurityPolicy(options);
|
|
535
|
+
return { ...policy, NonceProvider: createNonceProvider(policy.nonce) };
|
|
536
|
+
}
|
|
508
537
|
function Pagination({
|
|
509
538
|
connection,
|
|
510
539
|
currentUrl,
|
|
@@ -1151,7 +1180,7 @@ var PAYMENT_ICON_SVGS = {
|
|
|
1151
1180
|
|
|
1152
1181
|
// ../smart-cart/src/widgets/trust-badges.ts
|
|
1153
1182
|
var KNOWN_KEYS = new Set(Object.keys(PAYMENT_ICON_SVGS));
|
|
1154
|
-
var DEFAULT_BADGES = ["visa", "mastercard", "amex"
|
|
1183
|
+
var DEFAULT_BADGES = ["visa", "mastercard", "amex"];
|
|
1155
1184
|
function readBadges(config) {
|
|
1156
1185
|
const raw = config.badges;
|
|
1157
1186
|
if (!Array.isArray(raw)) return null;
|
|
@@ -2334,6 +2363,6 @@ function HydrogenEditorSlot({
|
|
|
2334
2363
|
);
|
|
2335
2364
|
}
|
|
2336
2365
|
|
|
2337
|
-
export { Analytics, AnalyticsCartView, AnalyticsCollectionView, AnalyticsProductView, AnalyticsProvider, AnalyticsSearchView, CartDrawerOverlay, CartForm, ConsentBanner, HydrogenEditorBoundary, HydrogenEditorProvider, HydrogenEditorSlot, Image, MediaFile, Money, OptimisticInput, Pagination, Seo, ShopPayButton, ThemeSettingsProvider, openSmartCart, useAnalytics, useGlobalThemeTokens, useHydrogenEditorInstance, useHydrogenEditorSlot, useMoney, useOptimisticData, useSectionSettings, useThemeSettings };
|
|
2366
|
+
export { Analytics, AnalyticsCartView, AnalyticsCollectionView, AnalyticsProductView, AnalyticsProvider, AnalyticsSearchView, CartDrawerOverlay, CartForm, ConsentBanner, HydrogenEditorBoundary, HydrogenEditorProvider, HydrogenEditorSlot, Image, MediaFile, Money, OptimisticInput, Pagination, Seo, ShopPayButton, ThemeSettingsProvider, createContentSecurityPolicy2 as createContentSecurityPolicy, openSmartCart, useAnalytics, useGlobalThemeTokens, useHydrogenEditorInstance, useHydrogenEditorSlot, useMoney, useNonce, useOptimisticData, useSectionSettings, useThemeSettings };
|
|
2338
2367
|
//# sourceMappingURL=react.js.map
|
|
2339
2368
|
//# sourceMappingURL=react.js.map
|