fontdue-js 2.21.0 → 2.22.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/CHANGELOG.md +6 -0
- package/dist/components/FontdueProvider/useAuxUIOwner.d.ts +1 -0
- package/dist/components/FontdueProvider/useAuxUIOwner.js +28 -0
- package/dist/components/TypeTester/TypeTesterFeatures.js +2 -1
- package/dist/components/TypeTester/TypeTesterFeaturesButton.js +5 -3
- package/dist/components/TypeTester/TypeTesterStandalone.d.ts +2 -2
- package/dist/components/TypeTester/TypeTesterStandalone.js +2 -1
- package/dist/components/TypeTester/TypeTesterStandalone.preload.d.ts +14 -0
- package/dist/components/TypeTester/TypeTesterStandalone.preload.js +19 -0
- package/dist/components/TypeTester/types.d.ts +2 -0
- package/dist/components/TypeTester/types.js +10 -1
- package/dist/components/TypeTesters/TypeTestersElement.d.ts +2 -1
- package/dist/components/TypeTesters/TypeTestersElement.js +3 -1
- package/dist/components/TypeTesters/index.d.ts +2 -0
- package/dist/components/TypeTesters/index.js +5 -2
- package/dist/config.d.ts +6 -0
- package/dist/config.js +20 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +1 -0
- package/dist-bundle/FontdueProvider.js +6 -0
- package/dist-bundle/FontdueProvider.js.map +1 -0
- package/dist-bundle/TypeTester.js +7 -0
- package/dist-bundle/TypeTester.js.map +1 -0
- package/dist-bundle/TypeTester.preload.js +75 -0
- package/dist-bundle/TypeTester.preload.js.map +1 -0
- package/dist-bundle/chunks/ComponentsContext-CmkN9J4X.js +20843 -0
- package/dist-bundle/chunks/ComponentsContext-CmkN9J4X.js.map +1 -0
- package/dist-bundle/chunks/CorsErrorModal-C1g_-3Re.js +95 -0
- package/dist-bundle/chunks/CorsErrorModal-C1g_-3Re.js.map +1 -0
- package/dist-bundle/chunks/TypeTesterStandalone-BMWuv8Ca.js +27486 -0
- package/dist-bundle/chunks/TypeTesterStandalone-BMWuv8Ca.js.map +1 -0
- package/dist-bundle/chunks/consent-DMvR5rEh.js +84 -0
- package/dist-bundle/chunks/consent-DMvR5rEh.js.map +1 -0
- package/dist-bundle/chunks/index-BNSbxp7B.js +78 -0
- package/dist-bundle/chunks/index-BNSbxp7B.js.map +1 -0
- package/dist-bundle/chunks/index-C4ak9qTL.js +423 -0
- package/dist-bundle/chunks/index-C4ak9qTL.js.map +1 -0
- package/dist-bundle/chunks/index-DsvF5W13.js +159 -0
- package/dist-bundle/chunks/index-DsvF5W13.js.map +1 -0
- package/dist-bundle/chunks/index-o29NNufd.js +131 -0
- package/dist-bundle/chunks/index-o29NNufd.js.map +1 -0
- package/dist-bundle/index.js +23 -0
- package/dist-bundle/index.js.map +1 -0
- package/package.json +1 -1
- package/dist/__generated__/CartItem_license.graphql.d.ts +0 -27
- package/dist/__generated__/CartItem_license.graphql.js +0 -76
- package/dist/__generated__/CartItem_licenseSelection.graphql.d.ts +0 -34
- package/dist/__generated__/CartItem_licenseSelection.graphql.js +0 -106
- package/dist/__generated__/CartItem_product.graphql.d.ts +0 -32
- package/dist/__generated__/CartItem_product.graphql.js +0 -124
- package/dist/__generated__/CartItem_variable.graphql.d.ts +0 -23
- package/dist/__generated__/CartItem_variable.graphql.js +0 -67
- package/dist/__generated__/CartItem_viewer.graphql.d.ts +0 -30
- package/dist/__generated__/CartItem_viewer.graphql.js +0 -87
- package/dist/__generated__/CartOrderApplyCouponMutation.graphql.d.ts +0 -21
- package/dist/__generated__/CartOrderApplyCouponMutation.graphql.js +0 -919
- package/dist/__generated__/CartStateApplyCouponMutation.graphql.d.ts +0 -21
- package/dist/__generated__/CartStateApplyCouponMutation.graphql.js +0 -274
- package/dist/__generated__/CartTotalsCreateSnapshotMutation.graphql.d.ts +0 -22
- package/dist/__generated__/CartTotalsCreateSnapshotMutation.graphql.js +0 -84
- package/dist/__generated__/Cart_viewer.graphql.d.ts +0 -20
- package/dist/__generated__/Cart_viewer.graphql.js +0 -49
- package/dist/__generated__/CharacterViewer_Query.graphql.d.ts +0 -21
- package/dist/__generated__/CharacterViewer_Query.graphql.js +0 -230
- package/dist/__generated__/CharacterViewer_SlugQuery.graphql.d.ts +0 -25
- package/dist/__generated__/CharacterViewer_SlugQuery.graphql.js +0 -257
- package/dist/__generated__/CouponCodeInput_Refetch_Query.graphql.d.ts +0 -17
- package/dist/__generated__/CouponCodeInput_Refetch_Query.graphql.js +0 -201
- package/dist/__generated__/CouponCodeInput_order.graphql.d.ts +0 -13
- package/dist/__generated__/CouponCodeInput_order.graphql.js +0 -28
- package/dist/__generated__/CouponCodeInput_viewer.graphql.d.ts +0 -25
- package/dist/__generated__/CouponCodeInput_viewer.graphql.js +0 -88
- package/dist/__generated__/CouponCodeRefetchQuery.graphql.d.ts +0 -22
- package/dist/__generated__/CouponCodeRefetchQuery.graphql.js +0 -178
- package/dist/__generated__/Family_viewer.graphql.d.ts +0 -17
- package/dist/__generated__/FontFamilies_node.graphql.d.ts +0 -20
- package/dist/__generated__/FontFamilies_node.graphql.js +0 -49
- package/dist/__generated__/NewsletterSignup_Query.graphql.d.ts +0 -21
- package/dist/__generated__/NewsletterSignup_Query.graphql.js +0 -99
- package/dist/__generated__/NewsletterSignup_viewer.graphql.d.ts +0 -20
- package/dist/__generated__/NewsletterSignup_viewer.graphql.js +0 -56
- package/dist/__generated__/OrderVariableSelectionMutation.graphql.d.ts +0 -69
- package/dist/__generated__/OrderVariableSelectionMutation_viewer.graphql.d.ts +0 -30
- package/dist/__generated__/PriceBarSection_RefetchQuery.graphql.d.ts +0 -26
- package/dist/__generated__/PriceBarSection_RefetchQuery.graphql.js +0 -168
- package/dist/__generated__/PriceBarSection_viewer.graphql.d.ts +0 -17
- package/dist/__generated__/PriceBar_viewer.graphql.d.ts +0 -17
- package/dist/__generated__/SKUPriceRefetchQuery.graphql.d.ts +0 -31
- package/dist/__generated__/SKUPriceRefetchQuery.graphql.js +0 -130
- package/dist/__generated__/SKUPriceUpdateQuery.graphql.d.ts +0 -29
- package/dist/__generated__/SKUPrice_RefetchQuery.graphql.d.ts +0 -26
- package/dist/__generated__/SKUPrice_RefetchQuery.graphql.js +0 -129
- package/dist/__generated__/SKUPrice_viewer.graphql.d.ts +0 -19
- package/dist/__generated__/SelectButton_viewer.graphql.d.ts +0 -17
- package/dist/__generated__/SpecimenLink_node.graphql.d.ts +0 -21
- package/dist/__generated__/SpecimenLink_node.graphql.js +0 -55
- package/dist/__generated__/StoreModalBundleButton_viewer.graphql.d.ts +0 -17
- package/dist/__generated__/StoreModalFamilyButton_viewer.graphql.d.ts +0 -17
- package/dist/__generated__/StoreModalFamily_viewer.graphql.d.ts +0 -17
- package/dist/__generated__/StoreModalOrderVariableSelectionHookQuery.graphql.d.ts +0 -26
- package/dist/__generated__/StoreModalOrderVariableSelectionOrderUpdateMutation.graphql.d.ts +0 -60
- package/dist/__generated__/StoreModalOrderVariableSelectionRefetchQuery.graphql.d.ts +0 -26
- package/dist/__generated__/StoreModalOrderVariableSelectionVariable_order.graphql.d.ts +0 -27
- package/dist/__generated__/StoreModalOrderVariableSelectionVariable_variable.graphql.d.ts +0 -24
- package/dist/__generated__/StoreModalProductContent_viewer.graphql.d.ts +0 -30
- package/dist/__generated__/StoreModalProductLicenseSelection_viewer.graphql.d.ts +0 -20
- package/dist/__generated__/StoreModalProductLicenseSelection_viewer.graphql.js +0 -51
- package/dist/__generated__/StoreModalProductViewerRefetchQuery.graphql.d.ts +0 -31
- package/dist/__generated__/StoreModalReviewCompleteOrderMutation.graphql.d.ts +0 -25
- package/dist/__generated__/StoreModalReviewCompleteOrderMutation.graphql.js +0 -442
- package/dist/__generated__/StoreModalReviewQuery.graphql.d.ts +0 -22
- package/dist/__generated__/StoreModalReviewQuery.graphql.js +0 -491
- package/dist/__generated__/StoreModalReviewUpdateOrderMutation.graphql.d.ts +0 -63
- package/dist/__generated__/StoreModalReviewUpdateOrderMutation.graphql.js +0 -445
- package/dist/__generated__/StoreModalReview_order.graphql.d.ts +0 -59
- package/dist/__generated__/StoreModalReview_order.graphql.js +0 -244
- package/dist/__generated__/StoreModalReview_viewer.graphql.d.ts +0 -19
- package/dist/__generated__/StoreModalReview_viewer.graphql.js +0 -47
- package/dist/__generated__/StoreModalStyleButton_viewer.graphql.d.ts +0 -17
- package/dist/__generated__/TestFontsForm_viewer.graphql.d.ts +0 -29
- package/dist/__generated__/TestFontsForm_viewer.graphql.js +0 -101
- package/dist/__generated__/TestModeBanner_viewer.graphql.d.ts +0 -23
- package/dist/__generated__/TestModeBanner_viewer.graphql.js +0 -64
- package/dist/__generated__/ThemeConfig_viewer.graphql.d.ts +0 -19
- package/dist/__generated__/ThemeConfig_viewer.graphql.js +0 -43
- package/dist/__generated__/TypeTesterStandalone_StyleQuery.graphql.d.ts +0 -32
- package/dist/__generated__/TypeTesterStandalone_StyleQuery.graphql.js +0 -385
- package/dist/__generated__/TypeTesterStyleSelect_family.graphql.d.ts +0 -33
- package/dist/__generated__/TypeTesterStyleSelect_fontStyle.graphql.d.ts +0 -27
- package/dist/__generated__/TypeTester_NewStyleQuery.graphql.d.ts +0 -41
- package/dist/__generated__/TypeTester_NewStyleQuery.graphql.js +0 -344
- package/dist/__generated__/TypeTester_sku.graphql.d.ts +0 -21
- package/dist/__generated__/TypeTester_sku.graphql.js +0 -57
- package/dist/__generated__/useOrderVariables_order.graphql.d.ts +0 -24
- package/dist/__tests__/collectionBundleSelection.test.d.ts +0 -1
- package/dist/components/BuyButton/BuyButton.server.d.ts +0 -3
- package/dist/components/BuyButton/BuyButton.server.js +0 -39
- package/dist/components/CartButton/index-server.d.ts +0 -3
- package/dist/components/CartButton/index-server.js +0 -18
- package/dist/components/OrderVariableSelection/OrderVariableSelectionMutation.d.ts +0 -7
- package/dist/components/SelectField/index.d.ts +0 -13
- package/dist/components/SelectField/index.js +0 -49
- package/dist/components/StoreModal/StoreModalReview.d.ts +0 -6
- package/dist/components/StoreModal/StoreModalReview.js +0 -221
- package/dist/components/StoreModal/StoreModalRouterContext.d.ts +0 -7
- package/dist/components/StoreModal/StoreModalRouterContext.js +0 -11
- package/dist/components/StoreModal/createRouter.d.ts +0 -41
- package/dist/components/StoreModal/createRouter.js +0 -48
- package/dist/components/StoreModalProductLicenseSelection/ContainerElement.d.ts +0 -9
- package/dist/components/StoreModalProductLicenseSelection/ContainerElement.js +0 -25
- package/dist/components/Stylesheet/index.d.ts +0 -7
- package/dist/components/Stylesheet/index.js +0 -43
- package/dist/components/TestModeBanner/index.server.d.ts +0 -2
- package/dist/components/TestModeBanner/index.server.js +0 -17
- package/dist/components/elements/StoreModalReviewConfirm/index.d.ts +0 -12
- package/dist/components/elements/StoreModalReviewConfirm/index.js +0 -50
- package/dist/components/elements/StoreModalReviewItem/index.d.ts +0 -9
- package/dist/components/elements/StoreModalReviewItem/index.js +0 -21
- package/dist/components/elements/StoreModalReviewLayout/index.d.ts +0 -17
- package/dist/components/elements/StoreModalReviewLayout/index.js +0 -59
- package/dist/components/useFontLoaded.d.ts +0 -24
- package/dist/components/useFontLoaded.js +0 -60
- package/dist/deepMerge.d.ts +0 -4
- package/dist/deepMerge.js +0 -24
- package/dist/hooks/useOrderVariables.d.ts +0 -5
- package/dist/relay-environment.d.ts +0 -7
- package/dist/relay-environment.js +0 -34
- package/dist/utils/interpolateOrderVariableDescription.d.ts +0 -36
- package/dist/utils/interpolateOrderVariableDescription.test.d.ts +0 -1
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
const CONSENT_COOKIE = '_fontdue_cc';
|
|
2
|
+
const CONSENT_EVENT = 'fontdue:consent';
|
|
3
|
+
const MAX_AGE = 60 * 60 * 24 * 365; // 1 year
|
|
4
|
+
|
|
5
|
+
/** Store the client-generated anonymous_id so it can be sent with consent events. */
|
|
6
|
+
let clientAnonymousId;
|
|
7
|
+
function setClientAnonymousId(id) {
|
|
8
|
+
clientAnonymousId = id;
|
|
9
|
+
}
|
|
10
|
+
function getClientAnonymousId() {
|
|
11
|
+
return clientAnonymousId;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
/** Parse the _fontdue_cc cookie and check if it contains the given category. */
|
|
15
|
+
function hasConsent(category) {
|
|
16
|
+
const match = document.cookie.match(new RegExp('(?:^|;\\s*)' + CONSENT_COOKIE + '=([^;]*)'));
|
|
17
|
+
if (!match) return false;
|
|
18
|
+
return match[1].split(',').includes(category);
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
/** Set the _fontdue_cc cookie with the given categories. */
|
|
22
|
+
function setConsent(categories) {
|
|
23
|
+
document.cookie = CONSENT_COOKIE + '=' + categories.join(',') + ';path=/;max-age=' + MAX_AGE + ';SameSite=Lax;Secure';
|
|
24
|
+
window.dispatchEvent(new CustomEvent(CONSENT_EVENT, {
|
|
25
|
+
detail: {
|
|
26
|
+
categories
|
|
27
|
+
}
|
|
28
|
+
}));
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* Call callback when the given consent category is granted.
|
|
33
|
+
* If already granted, calls immediately. Otherwise polls (500ms) and
|
|
34
|
+
* listens for the fontdue:consent event. Returns a cleanup function.
|
|
35
|
+
*/
|
|
36
|
+
function onConsent(category, callback) {
|
|
37
|
+
if (hasConsent(category)) {
|
|
38
|
+
callback();
|
|
39
|
+
return () => {};
|
|
40
|
+
}
|
|
41
|
+
let called = false;
|
|
42
|
+
const check = () => {
|
|
43
|
+
if (!called && hasConsent(category)) {
|
|
44
|
+
called = true;
|
|
45
|
+
callback();
|
|
46
|
+
cleanup();
|
|
47
|
+
}
|
|
48
|
+
};
|
|
49
|
+
const interval = setInterval(check, 500);
|
|
50
|
+
window.addEventListener(CONSENT_EVENT, check);
|
|
51
|
+
const cleanup = () => {
|
|
52
|
+
clearInterval(interval);
|
|
53
|
+
window.removeEventListener(CONSENT_EVENT, check);
|
|
54
|
+
};
|
|
55
|
+
return cleanup;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* Activate blocked scripts for the given consent category.
|
|
60
|
+
* Finds all <script type="text/plain" data-consent-category="<category>">
|
|
61
|
+
* elements and replaces them with executable copies.
|
|
62
|
+
*/
|
|
63
|
+
function activateScripts(category) {
|
|
64
|
+
const scripts = document.querySelectorAll(`script[type="text/plain"][data-consent-category="${category}"]`);
|
|
65
|
+
scripts.forEach(blocked => {
|
|
66
|
+
const script = document.createElement('script');
|
|
67
|
+
|
|
68
|
+
// Copy all attributes except type and data-consent-category
|
|
69
|
+
for (const attr of Array.from(blocked.attributes)) {
|
|
70
|
+
if (attr.name !== 'type' && attr.name !== 'data-consent-category') {
|
|
71
|
+
script.setAttribute(attr.name, attr.value);
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
// Copy inline content
|
|
76
|
+
if (blocked.textContent) {
|
|
77
|
+
script.textContent = blocked.textContent;
|
|
78
|
+
}
|
|
79
|
+
blocked.parentNode?.replaceChild(script, blocked);
|
|
80
|
+
});
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
export { activateScripts as a, setClientAnonymousId as b, getClientAnonymousId as g, hasConsent as h, onConsent as o, setConsent as s };
|
|
84
|
+
//# sourceMappingURL=consent-DMvR5rEh.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"consent-DMvR5rEh.js","sources":["../../src/components/ConsentBanner/consent.ts"],"sourcesContent":["const CONSENT_COOKIE = '_fontdue_cc';\nconst CONSENT_EVENT = 'fontdue:consent';\nconst MAX_AGE = 60 * 60 * 24 * 365; // 1 year\n\n/** Store the client-generated anonymous_id so it can be sent with consent events. */\nlet clientAnonymousId: string | undefined;\n\nexport function setClientAnonymousId(id: string): void {\n clientAnonymousId = id;\n}\n\nexport function getClientAnonymousId(): string | undefined {\n return clientAnonymousId;\n}\n\n/** Parse the _fontdue_cc cookie and check if it contains the given category. */\nexport function hasConsent(category: string): boolean {\n const match = document.cookie.match(\n new RegExp('(?:^|;\\\\s*)' + CONSENT_COOKIE + '=([^;]*)'),\n );\n if (!match) return false;\n return match[1].split(',').includes(category);\n}\n\n/** Set the _fontdue_cc cookie with the given categories. */\nexport function setConsent(categories: string[]): void {\n document.cookie =\n CONSENT_COOKIE +\n '=' +\n categories.join(',') +\n ';path=/;max-age=' +\n MAX_AGE +\n ';SameSite=Lax;Secure';\n\n window.dispatchEvent(new CustomEvent(CONSENT_EVENT, { detail: { categories } }));\n}\n\n/**\n * Call callback when the given consent category is granted.\n * If already granted, calls immediately. Otherwise polls (500ms) and\n * listens for the fontdue:consent event. Returns a cleanup function.\n */\nexport function onConsent(\n category: string,\n callback: () => void,\n): () => void {\n if (hasConsent(category)) {\n callback();\n return () => {};\n }\n\n let called = false;\n const check = () => {\n if (!called && hasConsent(category)) {\n called = true;\n callback();\n cleanup();\n }\n };\n\n const interval = setInterval(check, 500);\n window.addEventListener(CONSENT_EVENT, check);\n\n const cleanup = () => {\n clearInterval(interval);\n window.removeEventListener(CONSENT_EVENT, check);\n };\n\n return cleanup;\n}\n\n/**\n * Activate blocked scripts for the given consent category.\n * Finds all <script type=\"text/plain\" data-consent-category=\"<category>\">\n * elements and replaces them with executable copies.\n */\nexport function activateScripts(category: string): void {\n const scripts = document.querySelectorAll<HTMLScriptElement>(\n `script[type=\"text/plain\"][data-consent-category=\"${category}\"]`,\n );\n\n scripts.forEach((blocked) => {\n const script = document.createElement('script');\n\n // Copy all attributes except type and data-consent-category\n for (const attr of Array.from(blocked.attributes)) {\n if (attr.name !== 'type' && attr.name !== 'data-consent-category') {\n script.setAttribute(attr.name, attr.value);\n }\n }\n\n // Copy inline content\n if (blocked.textContent) {\n script.textContent = blocked.textContent;\n }\n\n blocked.parentNode?.replaceChild(script, blocked);\n });\n}\n"],"names":["CONSENT_COOKIE","CONSENT_EVENT","MAX_AGE","clientAnonymousId","setClientAnonymousId","id","getClientAnonymousId","hasConsent","category","match","document","cookie","RegExp","split","includes","setConsent","categories","join","window","dispatchEvent","CustomEvent","detail","onConsent","callback","called","check","cleanup","interval","setInterval","addEventListener","clearInterval","removeEventListener","activateScripts","scripts","querySelectorAll","forEach","blocked","script","createElement","attr","Array","from","attributes","name","setAttrib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ACU,WAAW;AAC1C,IAAA;IAEAV,OAAO,CAACW,UAAU,EAAEC,YAAY,CAACX,MAAM,EAAED,OAAO,CAAC;AACnD,EAAA,CAAC,CAAC;AACJ;;;;"}
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import React__default, { useContext, useState, useEffect } from 'react';
|
|
2
|
+
import { C as ConfigContext } from './ComponentsContext-CmkN9J4X.js';
|
|
3
|
+
import { u as useFontdueUrl } from './index-C4ak9qTL.js';
|
|
4
|
+
import { s as setConsent, a as activateScripts, g as getClientAnonymousId } from './consent-DMvR5rEh.js';
|
|
5
|
+
import '../index.js';
|
|
6
|
+
|
|
7
|
+
const DEFAULT_MESSAGE = 'We use cookies to analyze site usage and improve your\u00A0experience.';
|
|
8
|
+
const ConsentBanner = () => {
|
|
9
|
+
const config = useContext(ConfigContext);
|
|
10
|
+
const url = useFontdueUrl();
|
|
11
|
+
|
|
12
|
+
// Start dismissed to avoid hydration mismatch (server has no document.cookie).
|
|
13
|
+
// Check on the client in useEffect.
|
|
14
|
+
const [dismissed, setDismissed] = useState(true);
|
|
15
|
+
useEffect(() => {
|
|
16
|
+
if (!config.tracking.consentRequired) return;
|
|
17
|
+
if (!document.cookie.includes('_fontdue_cc=')) {
|
|
18
|
+
setDismissed(false);
|
|
19
|
+
}
|
|
20
|
+
}, [config.tracking.consentRequired]);
|
|
21
|
+
if (dismissed) return null;
|
|
22
|
+
const message = config.tracking.consentMessage || DEFAULT_MESSAGE;
|
|
23
|
+
const sendConsentEvent = categories => {
|
|
24
|
+
// Fire a tracking event so the server sets the _fontdue_state cookie
|
|
25
|
+
// on this response (rather than waiting for the next page load).
|
|
26
|
+
// Include the client anonymous_id so it gets synced to the cookie.
|
|
27
|
+
const body = {
|
|
28
|
+
event: 'Consent Granted',
|
|
29
|
+
properties: {
|
|
30
|
+
categories: categories.join(',')
|
|
31
|
+
}
|
|
32
|
+
};
|
|
33
|
+
const anonId = getClientAnonymousId();
|
|
34
|
+
if (anonId) body.anonymous_id = anonId;
|
|
35
|
+
fetch(`${url}/api/track`, {
|
|
36
|
+
method: 'POST',
|
|
37
|
+
headers: {
|
|
38
|
+
'Content-Type': 'application/json'
|
|
39
|
+
},
|
|
40
|
+
credentials: 'include',
|
|
41
|
+
body: JSON.stringify(body)
|
|
42
|
+
}).catch(() => {});
|
|
43
|
+
};
|
|
44
|
+
const handleAcceptAll = () => {
|
|
45
|
+
setConsent(['necessary', 'analytics']);
|
|
46
|
+
activateScripts('analytics');
|
|
47
|
+
if (config.tracking.enabled) {
|
|
48
|
+
sendConsentEvent(['necessary', 'analytics']);
|
|
49
|
+
}
|
|
50
|
+
setDismissed(true);
|
|
51
|
+
};
|
|
52
|
+
const handleReject = () => {
|
|
53
|
+
setConsent(['necessary']);
|
|
54
|
+
setDismissed(true);
|
|
55
|
+
};
|
|
56
|
+
return /*#__PURE__*/React__default.createElement("div", {
|
|
57
|
+
className: "fontdue-consent-banner",
|
|
58
|
+
role: "region",
|
|
59
|
+
"aria-label": "Cookie consent"
|
|
60
|
+
}, /*#__PURE__*/React__default.createElement("div", {
|
|
61
|
+
className: "fontdue-consent-banner__container"
|
|
62
|
+
}, /*#__PURE__*/React__default.createElement("p", {
|
|
63
|
+
className: "fontdue-consent-banner__message"
|
|
64
|
+
}, message), /*#__PURE__*/React__default.createElement("div", {
|
|
65
|
+
className: "fontdue-consent-banner__actions"
|
|
66
|
+
}, /*#__PURE__*/React__default.createElement("button", {
|
|
67
|
+
type: "button",
|
|
68
|
+
className: "fontdue-consent-banner__button fontdue-consent-banner__button--secondary",
|
|
69
|
+
onClick: handleReject
|
|
70
|
+
}, "Necessary only"), /*#__PURE__*/React__default.createElement("button", {
|
|
71
|
+
type: "button",
|
|
72
|
+
className: "fontdue-consent-banner__button fontdue-consent-banner__button--primary",
|
|
73
|
+
onClick: handleAcceptAll
|
|
74
|
+
}, "Accept all"))));
|
|
75
|
+
};
|
|
76
|
+
|
|
77
|
+
export { ConsentBanner as default };
|
|
78
|
+
//# sourceMappingURL=index-BNSbxp7B.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index-BNSbxp7B.js","sources":["../../src/components/ConsentBanner/index.tsx"],"sourcesContent":["import React, { useContext, useEffect, useState } from 'react';\nimport ConfigContext from '../ConfigContext';\nimport { useFontdueUrl } from '../UrlContext';\nimport { setConsent, activateScripts, getClientAnonymousId } from './consent';\n\nconst DEFAULT_MESSAGE =\n 'We use cookies to analyze site usage and improve your\\u00A0experience.';\n\nconst ConsentBanner = () => {\n const config = useContext(ConfigContext);\n const url = useFontdueUrl();\n\n // Start dismissed to avoid hydration mismatch (server has no document.cookie).\n // Check on the client in useEffect.\n const [dismissed, setDismissed] = useState(true);\n\n useEffect(() => {\n if (!config.tracking.consentRequired) return;\n if (!document.cookie.includes('_fontdue_cc=')) {\n setDismissed(false);\n }\n }, [config.tracking.consentRequired]);\n\n if (dismissed) return null;\n\n const message = config.tracking.consentMessage || DEFAULT_MESSAGE;\n\n const sendConsentEvent = (categories: string[]) => {\n // Fire a tracking event so the server sets the _fontdue_state cookie\n // on this response (rather than waiting for the next page load).\n // Include the client anonymous_id so it gets synced to the cookie.\n const body: Record<string, unknown> = {\n event: 'Consent Granted',\n properties: { categories: categories.join(',') },\n };\n const anonId = getClientAnonymousId();\n if (anonId) body.anonymous_id = anonId;\n\n fetch(`${url}/api/track`, {\n method: 'POST',\n headers: { 'Content-Type': 'application/json' },\n credentials: 'include',\n body: JSON.stringify(body),\n }).catch(() => {});\n };\n\n const handleAcceptAll = () => {\n setConsent(['necessary', 'analytics']);\n activateScripts('analytics');\n if (config.tracking.enabled) {\n sendConsentEvent(['necessary', 'analytics']);\n }\n setDismissed(true);\n };\n\n const handleReject = () => {\n setConsent(['necessary']);\n setDismissed(true);\n };\n\n return (\n <div className=\"fontdue-consent-banner\" role=\"region\" aria-label=\"Cookie consent\">\n <div className=\"fontdue-consent-banner__container\">\n <p className=\"fontdue-consent-banner__message\">{message}</p>\n <div className=\"fontdue-consent-banner__actions\">\n <button\n type=\"button\"\n className=\"fontdue-consent-banner__button fontdue-consent-banner__button--secondary\"\n onClick={handleReject}\n >\n Necessary only\n </button>\n <button\n type=\"button\"\n className=\"fontdue-consent-banner__button fontdue-consent-banner__button--primary\"\n onClick={handleAcceptAll}\n >\n Accept all\n </button>\n </div>\n </div>\n </div>\n );\n};\n\nexport default ConsentBanner;\n"],"names":["DEFAULT_MESSAGE","ConsentBanner","config","useContext","ConfigContext","url","useFontdueUrl","dismissed","setDismissed","useState","useEffect","tracking","consentRequired","document","cookie","includes","message","consentMessage","sendConsentEvent","categories","body","event","properties","join","anonId","getClientAnonymousId","anonymous_id","fetch","method","headers","credentials","JSON","stringify","catch","handleAcceptAll","setConsent","activateScripts","enabled","handleReject","React","createElement","className","role","type","onClick"],"mappings":";;;;;;AAKA,MAAMA,eAAe,GACnB,wEAAwE;AAE1E,MAAMC,aAAa,GAAGA,MAAM;AAC1B,EAAA,MAAMC,MAAM,GAAGC,UAAU,CAACC,aAAa,CAAC;AACxC,EAAA,MAAMC,GAAG,GAAGC,aAAa,EAAE;;AAE3B;AACA;EACA,MAAM,CAACC,SAAS,EAAEC,YAAY,CAAC,GAAGC,QAAQ,CAAC,IAAI,CAAC;AAEhDC,EAAAA,SAAS,CAAC,MAAM;AACd,IAAA,IAAI,CAACR,MAAM,CAACS,QAAQ,CAACC,eAAe,EAAE;IACtC,IAAI,CAACC,QAAQ,CAACC,MAAM,CAACC,QAAQ,CAAC,cAAc,CAAC,EAAE;MAC7CP,YAAY,CAAC,KAAK,CAAC;AACrB,IAAA;EACF,CAAC,EAAE,CAACN,MAAM,CAACS,QAAQ,CAACC,eAAe,CAAC,CAAC;EAErC,IAAIL,SAAS,EAAE,OAAO,IAAI;EAE1B,MAAMS,OAAO,GAAGd,MAAM,CAACS,QAAQ,CAACM,cAAc,IAAIjB,eAAe;EAEjE,MAAMkB,gBAAgB,GAAIC,UAAoB,IAAK;AACjD;AACA;AACA;AACA,IAAA,MAAMC,IA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;GAAmC,eAChDF,cAAA,CAAAC,aAAA,CAAA,GAAA,EAAA;AAAGC,IAAAA,SAAS,EAAC;AAAiC,GAAA,EAAEzB,OAAW,CAAC,eAC5DuB,cAAA,CAAAC,aAAA,CAAA,KAAA,EAAA;AAAKC,IAAAA,SAAS,EAAC;GAAiC,eAC9CF,cAAA,CAAAC,aAAA,CAAA,QAAA,EAAA;AACEG,IAAAA,IAAI,EAAC,QAAQ;AACbF,IAAAA,SAAS,EAAC,0EAA0E;AACpFG,IAAAA,OAAO,EAAEN;AAAa,GAAA,EACvB,gBAEO,CAAC,eACTC,cAAA,CAAAC,aAAA,CAAA,QAAA,EAAA;AACEG,IAAAA,IAAI,EAAC,QAAQ;AACbF,IAAAA,SAAS,EAAC,wEAAwE;AAClFG,IAAAA,OAAO,EAAEV;AAAgB,GAAA,EAC1B,YAEO,CACL,CACF,CACF,CAAC;AAEV;;;;"}
|
|
@@ -0,0 +1,423 @@
|
|
|
1
|
+
import { r as reactRelayExports, u as useCurrentEnvironment, m as makeConfig, P as Provider_default, C as ConfigContext, a as ComponentsContext, b as createDefaultStore, d as retryImport, _ as _extends } from './ComponentsContext-CmkN9J4X.js';
|
|
2
|
+
import React__default, { Component, createElement, createContext, useContext, Suspense, useRef, lazy, useState, useEffect } from 'react';
|
|
3
|
+
|
|
4
|
+
const ErrorBoundaryContext = createContext(null);
|
|
5
|
+
|
|
6
|
+
const initialState = {
|
|
7
|
+
didCatch: false,
|
|
8
|
+
error: null
|
|
9
|
+
};
|
|
10
|
+
class ErrorBoundary extends Component {
|
|
11
|
+
constructor(props) {
|
|
12
|
+
super(props);
|
|
13
|
+
this.resetErrorBoundary = this.resetErrorBoundary.bind(this);
|
|
14
|
+
this.state = initialState;
|
|
15
|
+
}
|
|
16
|
+
static getDerivedStateFromError(error) {
|
|
17
|
+
return {
|
|
18
|
+
didCatch: true,
|
|
19
|
+
error
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
resetErrorBoundary() {
|
|
23
|
+
const {
|
|
24
|
+
error
|
|
25
|
+
} = this.state;
|
|
26
|
+
if (error !== null) {
|
|
27
|
+
var _this$props$onReset, _this$props;
|
|
28
|
+
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
29
|
+
args[_key] = arguments[_key];
|
|
30
|
+
}
|
|
31
|
+
(_this$props$onReset = (_this$props = this.props).onReset) === null || _this$props$onReset === void 0 ? void 0 : _this$props$onReset.call(_this$props, {
|
|
32
|
+
args,
|
|
33
|
+
reason: "imperative-api"
|
|
34
|
+
});
|
|
35
|
+
this.setState(initialState);
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
componentDidCatch(error, info) {
|
|
39
|
+
var _this$props$onError, _this$props2;
|
|
40
|
+
(_this$props$onError = (_this$props2 = this.props).onError) === null || _this$props$onError === void 0 ? void 0 : _this$props$onError.call(_this$props2, error, info);
|
|
41
|
+
}
|
|
42
|
+
componentDidUpdate(prevProps, prevState) {
|
|
43
|
+
const {
|
|
44
|
+
didCatch
|
|
45
|
+
} = this.state;
|
|
46
|
+
const {
|
|
47
|
+
resetKeys
|
|
48
|
+
} = this.props;
|
|
49
|
+
|
|
50
|
+
// There's an edge case where if the thing that triggered the error happens to *also* be in the resetKeys array,
|
|
51
|
+
// we'd end up resetting the error boundary immediately.
|
|
52
|
+
// This would likely trigger a second error to be thrown.
|
|
53
|
+
// So we make sure that we don't check the resetKeys on the first call of cDU after the error is set.
|
|
54
|
+
|
|
55
|
+
if (didCatch && prevState.error !== null && hasArrayChanged(prevProps.resetKeys, resetKeys)) {
|
|
56
|
+
var _this$props$onReset2, _this$props3;
|
|
57
|
+
(_this$props$onReset2 = (_this$props3 = this.props).onReset) === null || _this$props$onReset2 === void 0 ? void 0 : _this$props$onReset2.call(_this$props3, {
|
|
58
|
+
next: resetKeys,
|
|
59
|
+
prev: prevProps.resetKeys,
|
|
60
|
+
reason: "keys"
|
|
61
|
+
});
|
|
62
|
+
this.setState(initialState);
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
render() {
|
|
66
|
+
const {
|
|
67
|
+
children,
|
|
68
|
+
fallbackRender,
|
|
69
|
+
FallbackComponent,
|
|
70
|
+
fallback
|
|
71
|
+
} = this.props;
|
|
72
|
+
const {
|
|
73
|
+
didCatch,
|
|
74
|
+
error
|
|
75
|
+
} = this.state;
|
|
76
|
+
let childToRender = children;
|
|
77
|
+
if (didCatch) {
|
|
78
|
+
const props = {
|
|
79
|
+
error,
|
|
80
|
+
resetErrorBoundary: this.resetErrorBoundary
|
|
81
|
+
};
|
|
82
|
+
if (typeof fallbackRender === "function") {
|
|
83
|
+
childToRender = fallbackRender(props);
|
|
84
|
+
} else if (FallbackComponent) {
|
|
85
|
+
childToRender = createElement(FallbackComponent, props);
|
|
86
|
+
} else if (fallback !== undefined) {
|
|
87
|
+
childToRender = fallback;
|
|
88
|
+
} else {
|
|
89
|
+
throw error;
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
return createElement(ErrorBoundaryContext.Provider, {
|
|
93
|
+
value: {
|
|
94
|
+
didCatch,
|
|
95
|
+
error,
|
|
96
|
+
resetErrorBoundary: this.resetErrorBoundary
|
|
97
|
+
}
|
|
98
|
+
}, childToRender);
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
function hasArrayChanged() {
|
|
102
|
+
let a = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
|
|
103
|
+
let b = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
|
|
104
|
+
return a.length !== b.length || a.some((item, index) => !Object.is(item, b[index]));
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
/**
|
|
108
|
+
* @generated SignedSource<<e395904ea5bda751df1ca67f9c74ac55>>
|
|
109
|
+
* @lightSyntaxTransform
|
|
110
|
+
* @nogrep
|
|
111
|
+
*/
|
|
112
|
+
|
|
113
|
+
/* tslint:disable */
|
|
114
|
+
/* eslint-disable */
|
|
115
|
+
// @ts-nocheck
|
|
116
|
+
|
|
117
|
+
const node$1 = function () {
|
|
118
|
+
var v0 = {
|
|
119
|
+
"alias": null,
|
|
120
|
+
"args": null,
|
|
121
|
+
"concreteType": "TestMode",
|
|
122
|
+
"kind": "LinkedField",
|
|
123
|
+
"name": "testMode",
|
|
124
|
+
"plural": false,
|
|
125
|
+
"selections": [{
|
|
126
|
+
"alias": null,
|
|
127
|
+
"args": null,
|
|
128
|
+
"kind": "ScalarField",
|
|
129
|
+
"name": "isActive",
|
|
130
|
+
"storageKey": null
|
|
131
|
+
}],
|
|
132
|
+
"storageKey": null
|
|
133
|
+
};
|
|
134
|
+
return {
|
|
135
|
+
"fragment": {
|
|
136
|
+
"argumentDefinitions": [],
|
|
137
|
+
"kind": "Fragment",
|
|
138
|
+
"metadata": null,
|
|
139
|
+
"name": "TestModeBannerQuery",
|
|
140
|
+
"selections": [{
|
|
141
|
+
"alias": null,
|
|
142
|
+
"args": null,
|
|
143
|
+
"concreteType": "Viewer",
|
|
144
|
+
"kind": "LinkedField",
|
|
145
|
+
"name": "viewer",
|
|
146
|
+
"plural": false,
|
|
147
|
+
"selections": [v0 /*: any*/],
|
|
148
|
+
"storageKey": null
|
|
149
|
+
}],
|
|
150
|
+
"type": "RootQueryType",
|
|
151
|
+
"abstractKey": null
|
|
152
|
+
},
|
|
153
|
+
"kind": "Request",
|
|
154
|
+
"operation": {
|
|
155
|
+
"argumentDefinitions": [],
|
|
156
|
+
"kind": "Operation",
|
|
157
|
+
"name": "TestModeBannerQuery",
|
|
158
|
+
"selections": [{
|
|
159
|
+
"alias": null,
|
|
160
|
+
"args": null,
|
|
161
|
+
"concreteType": "Viewer",
|
|
162
|
+
"kind": "LinkedField",
|
|
163
|
+
"name": "viewer",
|
|
164
|
+
"plural": false,
|
|
165
|
+
"selections": [v0 /*: any*/, {
|
|
166
|
+
"alias": null,
|
|
167
|
+
"args": null,
|
|
168
|
+
"kind": "ScalarField",
|
|
169
|
+
"name": "id",
|
|
170
|
+
"storageKey": null
|
|
171
|
+
}],
|
|
172
|
+
"storageKey": null
|
|
173
|
+
}]
|
|
174
|
+
},
|
|
175
|
+
"params": {
|
|
176
|
+
"cacheID": "2cb9255aeee9b1b3edd823ee2f62d8cc",
|
|
177
|
+
"id": null,
|
|
178
|
+
"metadata": {},
|
|
179
|
+
"name": "TestModeBannerQuery",
|
|
180
|
+
"operationKind": "query",
|
|
181
|
+
"text": "query TestModeBannerQuery {\n viewer {\n testMode {\n isActive\n }\n id\n }\n}\n"
|
|
182
|
+
}
|
|
183
|
+
};
|
|
184
|
+
}();
|
|
185
|
+
node$1.hash = "60ad67ee88ec6b74dd04bdf5572e7faf";
|
|
186
|
+
|
|
187
|
+
function TestModeBannerComponent({
|
|
188
|
+
data
|
|
189
|
+
}) {
|
|
190
|
+
const isActive = data?.viewer?.testMode?.isActive;
|
|
191
|
+
|
|
192
|
+
// hide the banner completely if we're in live mode
|
|
193
|
+
if (!isActive) return null;
|
|
194
|
+
return /*#__PURE__*/React__default.createElement("div", {
|
|
195
|
+
className: "test-mode-banner__banner",
|
|
196
|
+
"data-test-mode": isActive
|
|
197
|
+
}, /*#__PURE__*/React__default.createElement("div", {
|
|
198
|
+
className: "test-mode-banner__content"
|
|
199
|
+
}, /*#__PURE__*/React__default.createElement("div", {
|
|
200
|
+
className: "test-mode-banner__title"
|
|
201
|
+
}, "Viewing test data")));
|
|
202
|
+
}
|
|
203
|
+
const query$1 = (node$1.hash && node$1.hash !== "60ad67ee88ec6b74dd04bdf5572e7faf" && console.error("The definition of 'TestModeBannerQuery' appears to have changed. Run `relay-compiler` to update the generated files to receive the expected data."), node$1);
|
|
204
|
+
function TestModeBanner() {
|
|
205
|
+
const data = reactRelayExports.useLazyLoadQuery(query$1, {});
|
|
206
|
+
return /*#__PURE__*/React__default.createElement(TestModeBannerComponent, {
|
|
207
|
+
data: data
|
|
208
|
+
});
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
/**
|
|
212
|
+
* @generated SignedSource<<b292c0ac6583f7d2d7cd8979e5696b21>>
|
|
213
|
+
* @lightSyntaxTransform
|
|
214
|
+
* @nogrep
|
|
215
|
+
*/
|
|
216
|
+
|
|
217
|
+
/* tslint:disable */
|
|
218
|
+
/* eslint-disable */
|
|
219
|
+
// @ts-nocheck
|
|
220
|
+
|
|
221
|
+
const node = function () {
|
|
222
|
+
var v0 = {
|
|
223
|
+
"alias": null,
|
|
224
|
+
"args": null,
|
|
225
|
+
"concreteType": "ThemeConfig",
|
|
226
|
+
"kind": "LinkedField",
|
|
227
|
+
"name": "themeConfig",
|
|
228
|
+
"plural": false,
|
|
229
|
+
"selections": [{
|
|
230
|
+
"alias": null,
|
|
231
|
+
"args": null,
|
|
232
|
+
"kind": "ScalarField",
|
|
233
|
+
"name": "customProperties",
|
|
234
|
+
"storageKey": null
|
|
235
|
+
}],
|
|
236
|
+
"storageKey": null
|
|
237
|
+
};
|
|
238
|
+
return {
|
|
239
|
+
"fragment": {
|
|
240
|
+
"argumentDefinitions": [],
|
|
241
|
+
"kind": "Fragment",
|
|
242
|
+
"metadata": null,
|
|
243
|
+
"name": "ThemeConfigQuery",
|
|
244
|
+
"selections": [{
|
|
245
|
+
"alias": null,
|
|
246
|
+
"args": null,
|
|
247
|
+
"concreteType": "Viewer",
|
|
248
|
+
"kind": "LinkedField",
|
|
249
|
+
"name": "viewer",
|
|
250
|
+
"plural": false,
|
|
251
|
+
"selections": [v0 /*: any*/],
|
|
252
|
+
"storageKey": null
|
|
253
|
+
}],
|
|
254
|
+
"type": "RootQueryType",
|
|
255
|
+
"abstractKey": null
|
|
256
|
+
},
|
|
257
|
+
"kind": "Request",
|
|
258
|
+
"operation": {
|
|
259
|
+
"argumentDefinitions": [],
|
|
260
|
+
"kind": "Operation",
|
|
261
|
+
"name": "ThemeConfigQuery",
|
|
262
|
+
"selections": [{
|
|
263
|
+
"alias": null,
|
|
264
|
+
"args": null,
|
|
265
|
+
"concreteType": "Viewer",
|
|
266
|
+
"kind": "LinkedField",
|
|
267
|
+
"name": "viewer",
|
|
268
|
+
"plural": false,
|
|
269
|
+
"selections": [v0 /*: any*/, {
|
|
270
|
+
"alias": null,
|
|
271
|
+
"args": null,
|
|
272
|
+
"kind": "ScalarField",
|
|
273
|
+
"name": "id",
|
|
274
|
+
"storageKey": null
|
|
275
|
+
}],
|
|
276
|
+
"storageKey": null
|
|
277
|
+
}]
|
|
278
|
+
},
|
|
279
|
+
"params": {
|
|
280
|
+
"cacheID": "d1f54ccc72720516df3faf57461c20e1",
|
|
281
|
+
"id": null,
|
|
282
|
+
"metadata": {},
|
|
283
|
+
"name": "ThemeConfigQuery",
|
|
284
|
+
"operationKind": "query",
|
|
285
|
+
"text": "query ThemeConfigQuery {\n viewer {\n themeConfig {\n customProperties\n }\n id\n }\n}\n"
|
|
286
|
+
}
|
|
287
|
+
};
|
|
288
|
+
}();
|
|
289
|
+
node.hash = "c259bee038c4d2ea14c758fba3381f57";
|
|
290
|
+
|
|
291
|
+
// gets the custom properties entered by users in the admin panel,
|
|
292
|
+
// which also includes default values. we put the defaults there instead of
|
|
293
|
+
// every call to var() so that we have defaults all in one place
|
|
294
|
+
|
|
295
|
+
function ThemeConfigComponent({
|
|
296
|
+
data
|
|
297
|
+
}) {
|
|
298
|
+
const props = data.viewer.themeConfig?.customProperties ?? [];
|
|
299
|
+
return /*#__PURE__*/React__default.createElement("style", {
|
|
300
|
+
type: "text/css"
|
|
301
|
+
}, `:root { ${props.join(';')} }`);
|
|
302
|
+
}
|
|
303
|
+
const query = (node.hash && node.hash !== "c259bee038c4d2ea14c758fba3381f57" && console.error("The definition of 'ThemeConfigQuery' appears to have changed. Run `relay-compiler` to update the generated files to receive the expected data."), node);
|
|
304
|
+
function ThemeConfig() {
|
|
305
|
+
const data = reactRelayExports.useLazyLoadQuery(query, {});
|
|
306
|
+
return /*#__PURE__*/React__default.createElement(ThemeConfigComponent, {
|
|
307
|
+
data: data
|
|
308
|
+
});
|
|
309
|
+
}
|
|
310
|
+
|
|
311
|
+
const FONTDUE_URL = typeof process !== 'undefined' ? process.env.NEXT_PUBLIC_FONTDUE_URL : undefined;
|
|
312
|
+
const UrlContext = /*#__PURE__*/createContext(FONTDUE_URL ?? '');
|
|
313
|
+
function useFontdueUrl() {
|
|
314
|
+
return useContext(UrlContext);
|
|
315
|
+
}
|
|
316
|
+
|
|
317
|
+
const IS_SERVER = typeof window === typeof undefined;
|
|
318
|
+
|
|
319
|
+
// Client-side Redux store is a module-level singleton so multiple
|
|
320
|
+
// FontdueProviders on a page (e.g. one per Astro island) share cart state,
|
|
321
|
+
// user state, etc. Server-side stays per-render.
|
|
322
|
+
let clientStore = null;
|
|
323
|
+
function useSharedStore(providedStore, config) {
|
|
324
|
+
const ref = useRef(null);
|
|
325
|
+
if (providedStore) return providedStore;
|
|
326
|
+
if (IS_SERVER) {
|
|
327
|
+
if (ref.current == null) ref.current = createDefaultStore(config);
|
|
328
|
+
return ref.current;
|
|
329
|
+
}
|
|
330
|
+
if (clientStore == null) clientStore = createDefaultStore(config);
|
|
331
|
+
return clientStore;
|
|
332
|
+
}
|
|
333
|
+
const ConsentBanner = /*#__PURE__*/lazy(() => retryImport(() => import('./index-BNSbxp7B.js')));
|
|
334
|
+
const Tracking = /*#__PURE__*/lazy(() => retryImport(() => import('./index-DsvF5W13.js')));
|
|
335
|
+
const ServerConfigProvider = /*#__PURE__*/lazy(() => retryImport(() => import('./index-o29NNufd.js')));
|
|
336
|
+
function FontdueProviderClientComponent({
|
|
337
|
+
children,
|
|
338
|
+
url,
|
|
339
|
+
stripeIntegration,
|
|
340
|
+
config,
|
|
341
|
+
components,
|
|
342
|
+
store,
|
|
343
|
+
renderAuxUI
|
|
344
|
+
}) {
|
|
345
|
+
const environment = useCurrentEnvironment({
|
|
346
|
+
url,
|
|
347
|
+
stripeIntegration
|
|
348
|
+
});
|
|
349
|
+
const configValue = makeConfig(config);
|
|
350
|
+
const sharedStore = useSharedStore(store, config);
|
|
351
|
+
return /*#__PURE__*/React__default.createElement(reactRelayExports.RelayEnvironmentProvider, {
|
|
352
|
+
environment: environment
|
|
353
|
+
}, /*#__PURE__*/React__default.createElement(Provider_default, {
|
|
354
|
+
store: sharedStore
|
|
355
|
+
}, /*#__PURE__*/React__default.createElement(Suspense, {
|
|
356
|
+
fallback: null
|
|
357
|
+
}, /*#__PURE__*/React__default.createElement(ConfigContext.Provider, {
|
|
358
|
+
value: configValue
|
|
359
|
+
}, /*#__PURE__*/React__default.createElement(UrlContext.Provider, {
|
|
360
|
+
value: url ?? (typeof process !== 'undefined' ? process.env.NEXT_PUBLIC_FONTDUE_URL : undefined) ?? ''
|
|
361
|
+
}, /*#__PURE__*/React__default.createElement(ComponentsContext.Provider, {
|
|
362
|
+
value: components ?? {}
|
|
363
|
+
}, children, renderAuxUI && /*#__PURE__*/React__default.createElement(ErrorBoundary, {
|
|
364
|
+
fallback: null
|
|
365
|
+
}, /*#__PURE__*/React__default.createElement(Suspense, {
|
|
366
|
+
fallback: null
|
|
367
|
+
}, /*#__PURE__*/React__default.createElement(ServerConfigProvider, {
|
|
368
|
+
codeConfig: config
|
|
369
|
+
}, /*#__PURE__*/React__default.createElement(ConsentBanner, null), /*#__PURE__*/React__default.createElement(Tracking, null))))))))));
|
|
370
|
+
}
|
|
371
|
+
|
|
372
|
+
// Module-level claim: only one FontdueProvider on a page renders
|
|
373
|
+
// auxiliary UI (TestModeBanner, ThemeConfig, Tracking, ConsentBanner,
|
|
374
|
+
// ServerConfigProvider). Starts false on both server and client to avoid
|
|
375
|
+
// hydration mismatch; the first provider to run `useEffect` wins and flips
|
|
376
|
+
// its own state to true. Relinquishes the claim on unmount so HMR and
|
|
377
|
+
// route changes don't leak.
|
|
378
|
+
|
|
379
|
+
let ownerId = null;
|
|
380
|
+
function useAuxUIOwner() {
|
|
381
|
+
const [isOwner, setIsOwner] = useState(false);
|
|
382
|
+
useEffect(() => {
|
|
383
|
+
const myId = {};
|
|
384
|
+
if (ownerId == null) {
|
|
385
|
+
ownerId = myId;
|
|
386
|
+
setIsOwner(true);
|
|
387
|
+
}
|
|
388
|
+
return () => {
|
|
389
|
+
if (ownerId === myId) {
|
|
390
|
+
ownerId = null;
|
|
391
|
+
}
|
|
392
|
+
};
|
|
393
|
+
}, []);
|
|
394
|
+
return isOwner;
|
|
395
|
+
}
|
|
396
|
+
|
|
397
|
+
// Wrap each aux UI component in its own Suspense + ErrorBoundary so that its
|
|
398
|
+
// query suspending (useLazyLoadQuery fetches on first client render) or
|
|
399
|
+
// failing (CORS / offline / etc.) can't blank out the consumer's rendered
|
|
400
|
+
// children. Without this, TestModeBanner's TestModeBannerQuery suspends the
|
|
401
|
+
// whole provider subtree on hydration and the user sees a visible
|
|
402
|
+
// unmount/remount flash on the TypeTester.
|
|
403
|
+
function IsolatedAuxUI({
|
|
404
|
+
children
|
|
405
|
+
}) {
|
|
406
|
+
return /*#__PURE__*/React__default.createElement(ErrorBoundary, {
|
|
407
|
+
fallback: null
|
|
408
|
+
}, /*#__PURE__*/React__default.createElement(Suspense, {
|
|
409
|
+
fallback: null
|
|
410
|
+
}, children));
|
|
411
|
+
}
|
|
412
|
+
const FontdueProvider = ({
|
|
413
|
+
children,
|
|
414
|
+
...rest
|
|
415
|
+
}) => {
|
|
416
|
+
const isAuxOwner = useAuxUIOwner();
|
|
417
|
+
return /*#__PURE__*/React__default.createElement(FontdueProviderClientComponent, _extends({}, rest, {
|
|
418
|
+
renderAuxUI: isAuxOwner
|
|
419
|
+
}), isAuxOwner && /*#__PURE__*/React__default.createElement(IsolatedAuxUI, null, /*#__PURE__*/React__default.createElement(TestModeBanner, null)), isAuxOwner && /*#__PURE__*/React__default.createElement(IsolatedAuxUI, null, /*#__PURE__*/React__default.createElement(ThemeConfig, null)), children);
|
|
420
|
+
};
|
|
421
|
+
|
|
422
|
+
export { FontdueProvider as F, useFontdueUrl as u };
|
|
423
|
+
//# sourceMappingURL=index-C4ak9qTL.js.map
|