@frak-labs/components 1.1.0-beta.65694f73 → 1.1.0-beta.692dca6b
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 +24 -2
- package/cdn/{Banner.Dh-KYDLv.js → Banner.Zaqy93tl.js} +3 -3
- package/cdn/ButtonShare.rG47WQjf.js +1 -0
- package/cdn/ButtonWallet.C13UfI2G.js +40 -0
- package/cdn/OpenInAppButton.d-omgD0k.js +1 -0
- package/cdn/PostPurchase._3t6CtvV.js +89 -0
- package/cdn/components.js +1 -1
- package/cdn/loader.js +8 -52
- package/cdn/rewards.0JylBHNY.js +1 -0
- package/cdn/{useLightDomStyles.BLyrWEBn.js → useLightDomStyles.B7MVlVVJ.js} +1 -1
- package/cdn/{useReward.fvxtDVaA.js → useReward.CaBorN5T.js} +1 -1
- package/dist/{GiftIcon-DI0rUKHp.js → GiftIcon-BmGGodb2.js} +1 -1
- package/dist/banner.d.ts +3 -4
- package/dist/banner.js +7 -7
- package/dist/buttonShare.d.ts +3 -4
- package/dist/buttonShare.js +27 -9
- package/dist/buttonWallet.d.ts +6 -10
- package/dist/buttonWallet.js +39 -44
- package/dist/i18n/defaults.d.ts +2 -3
- package/dist/openInApp.d.ts +4 -5
- package/dist/openInApp.js +4 -5
- package/dist/postPurchase.d.ts +3 -4
- package/dist/postPurchase.js +20 -6
- package/dist/{rewards-CZkWSndn.js → rewards-DoVY1pWr.js} +4 -4
- package/dist/{useGlobalComponents-DFv33ujB.js → useGlobalComponents-Cj7uGBwD.js} +1 -1
- package/dist/{useLightDomStyles-B_IbOqJZ.js → useLightDomStyles-BW6DY5sC.js} +1 -1
- package/dist/{usePlacement-DtwWaLHO.js → usePlacement-iFDQqtJn.js} +14 -39
- package/dist/{useReward-D5zzFR11.js → useReward-k7RF3DhH.js} +1 -1
- package/package.json +14 -14
- package/cdn/ButtonShare.CiEtGubR.js +0 -1
- package/cdn/ButtonWallet.B-80TBVO.js +0 -40
- package/cdn/OpenInAppButton.DYfr8q7L.js +0 -1
- package/cdn/PostPurchase.CxEoeBs_.js +0 -89
- package/cdn/rewards.DjfrchZd.js +0 -1
package/dist/banner.d.ts
CHANGED
|
@@ -115,18 +115,17 @@ type BannerProps = {
|
|
|
115
115
|
* <frak-banner classname="my-custom-banner"></frak-banner>
|
|
116
116
|
* ```
|
|
117
117
|
*/
|
|
118
|
-
declare function Banner({ placement: placementId, classname, interaction, products, referralTitle: propReferralTitle, referralDescription: propReferralDescription, referralCta: propReferralCta, inappTitle: propInappTitle, inappDescription: propInappDescription, inappCta: propInappCta, imageUrl: propImageUrl, preview, previewMode, allowInappRedirect }: BannerProps): import("preact").JSX.Element | null;
|
|
118
|
+
export declare function Banner({ placement: placementId, classname, interaction, products, referralTitle: propReferralTitle, referralDescription: propReferralDescription, referralCta: propReferralCta, inappTitle: propInappTitle, inappDescription: propInappDescription, inappCta: propInappCta, imageUrl: propImageUrl, preview, previewMode, allowInappRedirect }: BannerProps): import("preact").JSX.Element | null;
|
|
119
119
|
//#endregion
|
|
120
120
|
//#region src/components/Banner/index.d.ts
|
|
121
121
|
/**
|
|
122
122
|
* Custom element interface for `<frak-banner>`.
|
|
123
123
|
* Combines standard {@link HTMLElement} with {@link BannerProps}.
|
|
124
124
|
*/
|
|
125
|
-
interface BannerElement extends HTMLElement, BannerProps {}
|
|
125
|
+
export interface BannerElement extends HTMLElement, BannerProps {}
|
|
126
126
|
declare global {
|
|
127
127
|
interface HTMLElementTagNameMap {
|
|
128
128
|
"frak-banner": BannerElement;
|
|
129
129
|
}
|
|
130
130
|
}
|
|
131
|
-
//#endregion
|
|
132
|
-
export { Banner, BannerElement };
|
|
131
|
+
//#endregion
|
package/dist/banner.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { i as useLang, o as useClientReady, s as registerWebComponent, t as usePlacement } from "./usePlacement-
|
|
2
|
-
import {
|
|
3
|
-
import { t as
|
|
4
|
-
import {
|
|
5
|
-
import { t as useReward } from "./useReward-
|
|
1
|
+
import { i as useLang, o as useClientReady, s as registerWebComponent, t as usePlacement } from "./usePlacement-iFDQqtJn.js";
|
|
2
|
+
import { i as w } from "./rewards-DoVY1pWr.js";
|
|
3
|
+
import { t as useGlobalComponents } from "./useGlobalComponents-Cj7uGBwD.js";
|
|
4
|
+
import { t as useLightDomStyles } from "./useLightDomStyles-BW6DY5sC.js";
|
|
5
|
+
import { t as useReward } from "./useReward-k7RF3DhH.js";
|
|
6
6
|
import { componentDefaults } from "./i18n/defaults.js";
|
|
7
|
-
import { a as ExternalLinkIcon, i as LogoFrakWithName, n as cssSource$5, o as CloseCircleIcon, r as WarningIcon, t as GiftIcon } from "./GiftIcon-
|
|
7
|
+
import { a as ExternalLinkIcon, i as LogoFrakWithName, n as cssSource$5, o as CloseCircleIcon, r as WarningIcon, t as GiftIcon } from "./GiftIcon-BmGGodb2.js";
|
|
8
8
|
import { isInAppBrowser, redirectToExternalBrowser, sanitizeProductDetailsList, trackEvent } from "@frak-labs/core-sdk";
|
|
9
9
|
import { REFERRAL_SUCCESS_EVENT, getMergeToken } from "@frak-labs/core-sdk/actions";
|
|
10
10
|
import { useCallback, useEffect, useMemo, useRef, useState } from "preact/hooks";
|
|
@@ -40,7 +40,7 @@ const cssSource$4 = `@keyframes keyframes_fadeIn__mnqmlt0 {
|
|
|
40
40
|
//#region \0ve-inline:../../packages/design-system/src/styles/inAppBanner.css.ts.vanilla.js
|
|
41
41
|
const cssSource$3 = `.inAppBanner_container__1ibpiy70 {
|
|
42
42
|
position: fixed;
|
|
43
|
-
top: max(8px, env(safe-area-inset-top));
|
|
43
|
+
top: max(8px, var(--safe-area-inset-top, env(safe-area-inset-top, 0px)));
|
|
44
44
|
left: 16px;
|
|
45
45
|
right: 16px;
|
|
46
46
|
z-index: 1000;
|
package/dist/buttonShare.d.ts
CHANGED
|
@@ -116,18 +116,17 @@ type ButtonShareProps = {
|
|
|
116
116
|
* @see {@link @frak-labs/core-sdk!actions.displaySharingPage | `displaySharingPage()`} for more info about the sharing-page flow
|
|
117
117
|
* @see {@link @frak-labs/core-sdk!actions.getMerchantInformation | `getMerchantInformation()`} for more info about the estimated reward fetching
|
|
118
118
|
*/
|
|
119
|
-
declare function ButtonShare({ placement: placementId, text, classname, noRewardText, targetInteraction, products, clickAction: rawClickAction, preview }: ButtonShareProps): import("preact").JSX.Element | null;
|
|
119
|
+
export declare function ButtonShare({ placement: placementId, text, classname, noRewardText, targetInteraction, products, clickAction: rawClickAction, preview }: ButtonShareProps): import("preact").JSX.Element | null;
|
|
120
120
|
//#endregion
|
|
121
121
|
//#region src/components/ButtonShare/index.d.ts
|
|
122
122
|
/**
|
|
123
123
|
* Custom element interface for `<frak-button-share>`.
|
|
124
124
|
* Combines standard {@link HTMLElement} with {@link ButtonShareProps}.
|
|
125
125
|
*/
|
|
126
|
-
interface ButtonShareElement extends HTMLElement, ButtonShareProps {}
|
|
126
|
+
export interface ButtonShareElement extends HTMLElement, ButtonShareProps {}
|
|
127
127
|
declare global {
|
|
128
128
|
interface HTMLElementTagNameMap {
|
|
129
129
|
"frak-button-share": ButtonShareElement;
|
|
130
130
|
}
|
|
131
131
|
}
|
|
132
|
-
//#endregion
|
|
133
|
-
export { ButtonShare, ButtonShareElement };
|
|
132
|
+
//#endregion
|
package/dist/buttonShare.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { c as openSharingPage, i as useLang, o as useClientReady, s as registerWebComponent, t as usePlacement } from "./usePlacement-
|
|
2
|
-
import {
|
|
3
|
-
import { t as
|
|
4
|
-
import {
|
|
5
|
-
import { t as useReward } from "./useReward-
|
|
1
|
+
import { c as openSharingPage, i as useLang, o as useClientReady, s as registerWebComponent, t as usePlacement } from "./usePlacement-iFDQqtJn.js";
|
|
2
|
+
import { i as w } from "./rewards-DoVY1pWr.js";
|
|
3
|
+
import { t as useGlobalComponents } from "./useGlobalComponents-Cj7uGBwD.js";
|
|
4
|
+
import { t as useLightDomStyles } from "./useLightDomStyles-BW6DY5sC.js";
|
|
5
|
+
import { t as useReward } from "./useReward-k7RF3DhH.js";
|
|
6
6
|
import { componentDefaults } from "./i18n/defaults.js";
|
|
7
7
|
import { sanitizeSharingProducts, trackEvent } from "@frak-labs/core-sdk";
|
|
8
|
-
import { useCallback, useMemo } from "preact/hooks";
|
|
8
|
+
import { useCallback, useEffect, useMemo, useRef } from "preact/hooks";
|
|
9
9
|
import { jsx } from "preact/jsx-runtime";
|
|
10
10
|
//#region src/components/ButtonShare/ButtonShare.tsx
|
|
11
11
|
/**
|
|
@@ -67,11 +67,11 @@ function ButtonShare({ placement: placementId, text, classname = "", noRewardTex
|
|
|
67
67
|
const globalComponents = useGlobalComponents();
|
|
68
68
|
const componentConfig = placement?.components?.buttonShare ?? globalComponents?.buttonShare;
|
|
69
69
|
useLightDomStyles("frak-button-share", placementId, componentConfig?.css);
|
|
70
|
-
const resolvedTargetInteraction =
|
|
70
|
+
const resolvedTargetInteraction = placement?.targetInteraction !== void 0 ? placement.targetInteraction : targetInteraction;
|
|
71
71
|
const resolvedText = componentConfig?.text ?? text ?? componentDefaults[lang].buttonShare.text;
|
|
72
72
|
const resolvedNoRewardText = componentConfig?.noRewardText ?? noRewardText;
|
|
73
|
-
const wantsReward =
|
|
74
|
-
const resolvedClickAction =
|
|
73
|
+
const wantsReward = resolvedText.includes("{REWARD}");
|
|
74
|
+
const resolvedClickAction = componentConfig?.clickAction ?? rawClickAction ?? "sharing-page";
|
|
75
75
|
const { shouldRender, isHidden, isClientReady } = useClientReady();
|
|
76
76
|
const parsedProducts = useMemo(() => sanitizeSharingProducts(products), [products]);
|
|
77
77
|
const { reward } = useReward(wantsReward && isClientReady, resolvedTargetInteraction, void 0, parsedProducts);
|
|
@@ -85,6 +85,24 @@ function ButtonShare({ placement: placementId, text, classname = "", noRewardTex
|
|
|
85
85
|
resolvedNoRewardText,
|
|
86
86
|
reward
|
|
87
87
|
]);
|
|
88
|
+
const trackedImpressionRef = useRef(false);
|
|
89
|
+
useEffect(() => {
|
|
90
|
+
if (isPreview || trackedImpressionRef.current) return;
|
|
91
|
+
if (!isClientReady || !shouldRender || isHidden) return;
|
|
92
|
+
trackEvent(window.FrakSetup?.client, "share_button_impression", {
|
|
93
|
+
placement: placementId,
|
|
94
|
+
target_interaction: resolvedTargetInteraction,
|
|
95
|
+
has_reward: Boolean(reward)
|
|
96
|
+
});
|
|
97
|
+
trackedImpressionRef.current = true;
|
|
98
|
+
}, [
|
|
99
|
+
isPreview,
|
|
100
|
+
isClientReady,
|
|
101
|
+
shouldRender,
|
|
102
|
+
isHidden,
|
|
103
|
+
placementId,
|
|
104
|
+
resolvedTargetInteraction
|
|
105
|
+
]);
|
|
88
106
|
const onClick = useCallback(() => {
|
|
89
107
|
if (isPreview) return;
|
|
90
108
|
trackEvent(window.FrakSetup.client, "share_button_clicked", {
|
package/dist/buttonWallet.d.ts
CHANGED
|
@@ -23,12 +23,9 @@ type ButtonWalletProps = {
|
|
|
23
23
|
//#endregion
|
|
24
24
|
//#region src/components/ButtonWallet/ButtonWallet.d.ts
|
|
25
25
|
/**
|
|
26
|
-
* Floating circular button that opens the Frak sharing page.
|
|
27
|
-
*
|
|
28
|
-
*
|
|
29
|
-
* retired, so the button now routes to the full-page sharing UI like every
|
|
30
|
-
* other share CTA. The `frak-button-wallet` tag name is kept because it is
|
|
31
|
-
* public API (merchant markup, Magento template).
|
|
26
|
+
* Floating circular button that opens the Frak sharing page. The
|
|
27
|
+
* `frak-button-wallet` tag name is public API (merchant markup, Magento
|
|
28
|
+
* template), so it stays even though it no longer names the surface.
|
|
32
29
|
*
|
|
33
30
|
* @param args
|
|
34
31
|
* @returns The wallet button with `<button>` tag
|
|
@@ -68,18 +65,17 @@ type ButtonWalletProps = {
|
|
|
68
65
|
* @see {@link @frak-labs/core-sdk!actions.displaySharingPage | `displaySharingPage()`} for more info about the sharing page
|
|
69
66
|
* @see {@link @frak-labs/core-sdk!actions.getMerchantInformation | `getMerchantInformation()`} for more info about the estimated reward fetching
|
|
70
67
|
*/
|
|
71
|
-
declare function ButtonWallet({ placement: placementId, classname, useReward: rawUseReward, targetInteraction }: ButtonWalletProps): import("preact").JSX.Element | null;
|
|
68
|
+
export declare function ButtonWallet({ placement: placementId, classname, useReward: rawUseReward, targetInteraction }: ButtonWalletProps): import("preact").JSX.Element | null;
|
|
72
69
|
//#endregion
|
|
73
70
|
//#region src/components/ButtonWallet/index.d.ts
|
|
74
71
|
/**
|
|
75
72
|
* Custom element interface for `<frak-button-wallet>`.
|
|
76
73
|
* Combines standard {@link HTMLElement} with {@link ButtonWalletProps}.
|
|
77
74
|
*/
|
|
78
|
-
interface ButtonWalletElement extends HTMLElement, ButtonWalletProps {}
|
|
75
|
+
export interface ButtonWalletElement extends HTMLElement, ButtonWalletProps {}
|
|
79
76
|
declare global {
|
|
80
77
|
interface HTMLElementTagNameMap {
|
|
81
78
|
"frak-button-wallet": ButtonWalletElement;
|
|
82
79
|
}
|
|
83
80
|
}
|
|
84
|
-
//#endregion
|
|
85
|
-
export { ButtonWallet, ButtonWalletElement };
|
|
81
|
+
//#endregion
|
package/dist/buttonWallet.js
CHANGED
|
@@ -1,11 +1,19 @@
|
|
|
1
|
-
import { c as openSharingPage, i as useLang, n as buildStyleContent, o as useClientReady, s as registerWebComponent, t as usePlacement } from "./usePlacement-
|
|
2
|
-
import { t as useReward } from "./useReward-
|
|
1
|
+
import { c as openSharingPage, i as useLang, n as buildStyleContent, o as useClientReady, s as registerWebComponent, t as usePlacement } from "./usePlacement-iFDQqtJn.js";
|
|
2
|
+
import { t as useReward } from "./useReward-k7RF3DhH.js";
|
|
3
3
|
import { componentDefaults } from "./i18n/defaults.js";
|
|
4
4
|
import { trackEvent } from "@frak-labs/core-sdk";
|
|
5
|
-
import { useCallback, useEffect,
|
|
5
|
+
import { useCallback, useEffect, useRef } from "preact/hooks";
|
|
6
6
|
import { Fragment, jsx, jsxs } from "preact/jsx-runtime";
|
|
7
|
-
//#region src/
|
|
8
|
-
|
|
7
|
+
//#region src/utils/browser/safeVibrate.ts
|
|
8
|
+
/**
|
|
9
|
+
* Attempt to vibrate the device
|
|
10
|
+
*/
|
|
11
|
+
function safeVibrate() {
|
|
12
|
+
if ("vibrate" in navigator) navigator.vibrate(10);
|
|
13
|
+
}
|
|
14
|
+
//#endregion
|
|
15
|
+
//#region src/components/ButtonWallet/assets/WalletGiftIcon.tsx
|
|
16
|
+
function WalletGiftIcon(props) {
|
|
9
17
|
return /* @__PURE__ */ jsxs("svg", {
|
|
10
18
|
fill: "none",
|
|
11
19
|
height: "1em",
|
|
@@ -22,29 +30,6 @@ function GiftIcon(props) {
|
|
|
22
30
|
});
|
|
23
31
|
}
|
|
24
32
|
//#endregion
|
|
25
|
-
//#region src/utils/browser/safeVibrate.ts
|
|
26
|
-
/**
|
|
27
|
-
* Attempt to vibrate the device
|
|
28
|
-
*/
|
|
29
|
-
function safeVibrate() {
|
|
30
|
-
if ("vibrate" in navigator) navigator.vibrate(10);
|
|
31
|
-
else console.log("Vibration not supported");
|
|
32
|
-
}
|
|
33
|
-
//#endregion
|
|
34
|
-
//#region src/components/ButtonWallet/utils.ts
|
|
35
|
-
/**
|
|
36
|
-
* Open the sharing surface behind `<frak-button-wallet>`.
|
|
37
|
-
*
|
|
38
|
-
* The button used to open the embedded wallet drawer; that surface was
|
|
39
|
-
* retired in favour of the full-page sharing UI, so the tag now routes
|
|
40
|
-
* there like every other share CTA. The tag name is kept because it is
|
|
41
|
-
* public API (merchant markup, Magento template).
|
|
42
|
-
*/
|
|
43
|
-
function openWalletModal(targetInteraction, placement) {
|
|
44
|
-
safeVibrate();
|
|
45
|
-
openSharingPage(targetInteraction, placement);
|
|
46
|
-
}
|
|
47
|
-
//#endregion
|
|
48
33
|
//#region src/components/ButtonWallet/ButtonWallet.tsx
|
|
49
34
|
const componentCss = `
|
|
50
35
|
.button {
|
|
@@ -87,12 +72,9 @@ const componentCss = `
|
|
|
87
72
|
}
|
|
88
73
|
`;
|
|
89
74
|
/**
|
|
90
|
-
* Floating circular button that opens the Frak sharing page.
|
|
91
|
-
*
|
|
92
|
-
*
|
|
93
|
-
* retired, so the button now routes to the full-page sharing UI like every
|
|
94
|
-
* other share CTA. The `frak-button-wallet` tag name is kept because it is
|
|
95
|
-
* public API (merchant markup, Magento template).
|
|
75
|
+
* Floating circular button that opens the Frak sharing page. The
|
|
76
|
+
* `frak-button-wallet` tag name is public API (merchant markup, Magento
|
|
77
|
+
* template), so it stays even though it no longer names the surface.
|
|
96
78
|
*
|
|
97
79
|
* @param args
|
|
98
80
|
* @returns The wallet button with `<button>` tag
|
|
@@ -135,11 +117,28 @@ const componentCss = `
|
|
|
135
117
|
function ButtonWallet({ placement: placementId, classname = "", useReward: rawUseReward, targetInteraction }) {
|
|
136
118
|
const lang = useLang();
|
|
137
119
|
const placement = usePlacement(placementId);
|
|
138
|
-
const resolvedTargetInteraction =
|
|
139
|
-
const shouldUseReward =
|
|
120
|
+
const resolvedTargetInteraction = placement?.targetInteraction !== void 0 ? placement.targetInteraction : targetInteraction;
|
|
121
|
+
const shouldUseReward = rawUseReward === true;
|
|
140
122
|
const { shouldRender, isHidden, isClientReady } = useClientReady();
|
|
141
123
|
const { reward } = useReward(shouldUseReward && isClientReady, resolvedTargetInteraction);
|
|
142
|
-
const
|
|
124
|
+
const position = placement?.components?.buttonWallet?.position ?? window.FrakSetup?.modalWalletConfig?.metadata?.position ?? "right";
|
|
125
|
+
const trackedImpressionRef = useRef(false);
|
|
126
|
+
useEffect(() => {
|
|
127
|
+
if (trackedImpressionRef.current) return;
|
|
128
|
+
if (!isClientReady || !shouldRender || isHidden) return;
|
|
129
|
+
trackEvent(window.FrakSetup?.client, "share_button_impression", {
|
|
130
|
+
placement: placementId,
|
|
131
|
+
target_interaction: resolvedTargetInteraction,
|
|
132
|
+
has_reward: Boolean(reward)
|
|
133
|
+
});
|
|
134
|
+
trackedImpressionRef.current = true;
|
|
135
|
+
}, [
|
|
136
|
+
isClientReady,
|
|
137
|
+
shouldRender,
|
|
138
|
+
isHidden,
|
|
139
|
+
placementId,
|
|
140
|
+
resolvedTargetInteraction
|
|
141
|
+
]);
|
|
143
142
|
const onClick = useCallback(() => {
|
|
144
143
|
trackEvent(window.FrakSetup.client, "share_button_clicked", {
|
|
145
144
|
placement: placementId,
|
|
@@ -147,17 +146,13 @@ function ButtonWallet({ placement: placementId, classname = "", useReward: rawUs
|
|
|
147
146
|
has_reward: Boolean(reward),
|
|
148
147
|
click_action: "sharing-page"
|
|
149
148
|
});
|
|
150
|
-
|
|
149
|
+
safeVibrate();
|
|
150
|
+
openSharingPage(resolvedTargetInteraction, placementId);
|
|
151
151
|
}, [
|
|
152
152
|
placementId,
|
|
153
153
|
resolvedTargetInteraction,
|
|
154
154
|
reward
|
|
155
155
|
]);
|
|
156
|
-
useEffect(() => {
|
|
157
|
-
const placementPosition = placement?.components?.buttonWallet?.position;
|
|
158
|
-
const configPosition = window.FrakSetup?.modalWalletConfig?.metadata?.position;
|
|
159
|
-
setPosition(placementPosition ?? configPosition ?? "right");
|
|
160
|
-
}, [placement?.components?.buttonWallet?.position]);
|
|
161
156
|
if (!shouldRender || isHidden) return null;
|
|
162
157
|
const buttonClass = [
|
|
163
158
|
"button",
|
|
@@ -172,7 +167,7 @@ function ButtonWallet({ placement: placementId, classname = "", useReward: rawUs
|
|
|
172
167
|
disabled: !isClientReady,
|
|
173
168
|
class: buttonClass,
|
|
174
169
|
onClick,
|
|
175
|
-
children: [/* @__PURE__ */ jsx(
|
|
170
|
+
children: [/* @__PURE__ */ jsx(WalletGiftIcon, {}), reward && /* @__PURE__ */ jsx("span", {
|
|
176
171
|
class: "reward",
|
|
177
172
|
children: reward
|
|
178
173
|
})]
|
package/dist/i18n/defaults.d.ts
CHANGED
|
@@ -50,6 +50,5 @@ type ComponentCopy = {
|
|
|
50
50
|
* the `Language` union in `@frak-labs/core-sdk` — no new dependency, no
|
|
51
51
|
* merchant action, no SDK API change.
|
|
52
52
|
*/
|
|
53
|
-
declare const componentDefaults: Record<Language, ComponentCopy>;
|
|
54
|
-
//#endregion
|
|
55
|
-
export { componentDefaults };
|
|
53
|
+
export declare const componentDefaults: Record<Language, ComponentCopy>;
|
|
54
|
+
//#endregion
|
package/dist/openInApp.d.ts
CHANGED
|
@@ -40,23 +40,22 @@ type OpenInAppButtonProps = {
|
|
|
40
40
|
* ```
|
|
41
41
|
*
|
|
42
42
|
* @example
|
|
43
|
-
*
|
|
43
|
+
* Using a custom class:
|
|
44
44
|
* ```html
|
|
45
45
|
* <frak-open-in-app classname="button button-primary"></frak-open-in-app>
|
|
46
46
|
* ```
|
|
47
47
|
*/
|
|
48
|
-
declare function OpenInAppButton({ placement: placementId, text, classname }: OpenInAppButtonProps): import("preact").JSX.Element | null;
|
|
48
|
+
export declare function OpenInAppButton({ placement: placementId, text, classname }: OpenInAppButtonProps): import("preact").JSX.Element | null;
|
|
49
49
|
//#endregion
|
|
50
50
|
//#region src/components/OpenInAppButton/index.d.ts
|
|
51
51
|
/**
|
|
52
52
|
* Custom element interface for `<frak-open-in-app>`.
|
|
53
53
|
* Combines standard {@link HTMLElement} with {@link OpenInAppButtonProps}.
|
|
54
54
|
*/
|
|
55
|
-
interface OpenInAppButtonElement extends HTMLElement, OpenInAppButtonProps {}
|
|
55
|
+
export interface OpenInAppButtonElement extends HTMLElement, OpenInAppButtonProps {}
|
|
56
56
|
declare global {
|
|
57
57
|
interface HTMLElementTagNameMap {
|
|
58
58
|
"frak-open-in-app": OpenInAppButtonElement;
|
|
59
59
|
}
|
|
60
60
|
}
|
|
61
|
-
//#endregion
|
|
62
|
-
export { OpenInAppButton, OpenInAppButtonElement };
|
|
61
|
+
//#endregion
|
package/dist/openInApp.js
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
import { i as useLang, o as useClientReady, s as registerWebComponent, t as usePlacement } from "./usePlacement-
|
|
2
|
-
import { t as useLightDomStyles } from "./useLightDomStyles-
|
|
1
|
+
import { i as useLang, o as useClientReady, s as registerWebComponent, t as usePlacement } from "./usePlacement-iFDQqtJn.js";
|
|
2
|
+
import { t as useLightDomStyles } from "./useLightDomStyles-BW6DY5sC.js";
|
|
3
3
|
import { componentDefaults } from "./i18n/defaults.js";
|
|
4
4
|
import { DEEP_LINK_SCHEME, isMobile, trackEvent, triggerDeepLinkWithFallback } from "@frak-labs/core-sdk";
|
|
5
|
-
import { useMemo } from "preact/hooks";
|
|
6
5
|
import { jsx } from "preact/jsx-runtime";
|
|
7
6
|
//#region src/actions/openInApp.ts
|
|
8
7
|
const DEFAULT_PATH = "wallet";
|
|
@@ -30,7 +29,7 @@ function openFrakWalletApp(path = DEFAULT_PATH, placement) {
|
|
|
30
29
|
//#endregion
|
|
31
30
|
//#region src/hooks/useIsMobile.ts
|
|
32
31
|
function useIsMobile() {
|
|
33
|
-
return { isMobile:
|
|
32
|
+
return { isMobile: isMobile() };
|
|
34
33
|
}
|
|
35
34
|
//#endregion
|
|
36
35
|
//#region src/components/OpenInAppButton/OpenInAppButton.tsx
|
|
@@ -55,7 +54,7 @@ function useIsMobile() {
|
|
|
55
54
|
* ```
|
|
56
55
|
*
|
|
57
56
|
* @example
|
|
58
|
-
*
|
|
57
|
+
* Using a custom class:
|
|
59
58
|
* ```html
|
|
60
59
|
* <frak-open-in-app classname="button button-primary"></frak-open-in-app>
|
|
61
60
|
* ```
|
package/dist/postPurchase.d.ts
CHANGED
|
@@ -121,18 +121,17 @@ type PostPurchaseProps = {
|
|
|
121
121
|
* ></frak-post-purchase>
|
|
122
122
|
* ```
|
|
123
123
|
*/
|
|
124
|
-
declare function PostPurchase({ customerId, orderId, token, sharingUrl, merchantId, placement: placementId, classname, variant: forcedVariant, badgeText: propBadgeText, referrerText: propReferrerText, refereeText: propRefereeText, ctaText: propCtaText, preview, previewVariant, products, imageUrl: propImageUrl }: PostPurchaseProps): import("preact").JSX.Element | null;
|
|
124
|
+
export declare function PostPurchase({ customerId, orderId, token, sharingUrl, merchantId, placement: placementId, classname, variant: forcedVariant, badgeText: propBadgeText, referrerText: propReferrerText, refereeText: propRefereeText, ctaText: propCtaText, preview, previewVariant, products, imageUrl: propImageUrl }: PostPurchaseProps): import("preact").JSX.Element | null;
|
|
125
125
|
//#endregion
|
|
126
126
|
//#region src/components/PostPurchase/index.d.ts
|
|
127
127
|
/**
|
|
128
128
|
* Custom element interface for `<frak-post-purchase>`.
|
|
129
129
|
* Combines standard {@link HTMLElement} with {@link PostPurchaseProps}.
|
|
130
130
|
*/
|
|
131
|
-
interface PostPurchaseElement extends HTMLElement, PostPurchaseProps {}
|
|
131
|
+
export interface PostPurchaseElement extends HTMLElement, PostPurchaseProps {}
|
|
132
132
|
declare global {
|
|
133
133
|
interface HTMLElementTagNameMap {
|
|
134
134
|
"frak-post-purchase": PostPurchaseElement;
|
|
135
135
|
}
|
|
136
136
|
}
|
|
137
|
-
//#endregion
|
|
138
|
-
export { PostPurchase, PostPurchaseElement };
|
|
137
|
+
//#endregion
|
package/dist/postPurchase.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { c as openSharingPage, i as useLang, o as useClientReady, s as registerWebComponent, t as usePlacement } from "./usePlacement-
|
|
2
|
-
import { t as
|
|
3
|
-
import { t as
|
|
4
|
-
import {
|
|
1
|
+
import { c as openSharingPage, i as useLang, o as useClientReady, s as registerWebComponent, t as usePlacement } from "./usePlacement-iFDQqtJn.js";
|
|
2
|
+
import { i as w, n as K, t as C } from "./rewards-DoVY1pWr.js";
|
|
3
|
+
import { t as useGlobalComponents } from "./useGlobalComponents-Cj7uGBwD.js";
|
|
4
|
+
import { t as useLightDomStyles } from "./useLightDomStyles-BW6DY5sC.js";
|
|
5
5
|
import { componentDefaults } from "./i18n/defaults.js";
|
|
6
|
-
import { i as LogoFrakWithName, n as cssSource$2, t as GiftIcon } from "./GiftIcon-
|
|
6
|
+
import { i as LogoFrakWithName, n as cssSource$2, t as GiftIcon } from "./GiftIcon-BmGGodb2.js";
|
|
7
7
|
import { sanitizeSharingProducts, trackEvent } from "@frak-labs/core-sdk";
|
|
8
8
|
import { getMerchantInformation, getUserReferralStatus, trackPurchaseStatus } from "@frak-labs/core-sdk/actions";
|
|
9
9
|
import { useCallback, useEffect, useMemo, useRef, useState } from "preact/hooks";
|
|
@@ -114,6 +114,20 @@ const cssSource = cssSource$1;
|
|
|
114
114
|
//#endregion
|
|
115
115
|
//#region src/components/PostPurchase/PostPurchase.tsx
|
|
116
116
|
/**
|
|
117
|
+
* `onChainMetadata.domain` is a bare host and `sharing-url` defaults to `""` in
|
|
118
|
+
* the WordPress shortcode; both would throw inside `FrakContextManager.update`.
|
|
119
|
+
*/
|
|
120
|
+
function resolveShareBaseUrl(value) {
|
|
121
|
+
const trimmed = value?.trim();
|
|
122
|
+
if (!trimmed) return void 0;
|
|
123
|
+
const candidate = /^https?:\/\//i.test(trimmed) ? trimmed : `https://${trimmed}`;
|
|
124
|
+
try {
|
|
125
|
+
return new URL(candidate).toString();
|
|
126
|
+
} catch {
|
|
127
|
+
return;
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
/**
|
|
117
131
|
* Given referral status and merchant info, compute the display variant
|
|
118
132
|
* and pick the appropriate purchase reward.
|
|
119
133
|
*/
|
|
@@ -217,7 +231,7 @@ function PostPurchase({ customerId, orderId, token, sharingUrl, merchantId, plac
|
|
|
217
231
|
}, [fetched, parsedProducts]);
|
|
218
232
|
const trackedImpressionVariantRef = useRef(null);
|
|
219
233
|
const resolvedVariant = forcedVariant ?? context?.variant ?? (isPreview ? previewVariant ?? "referrer" : void 0);
|
|
220
|
-
const resolvedSharingUrl = sharingUrl ?? context?.merchantDomain;
|
|
234
|
+
const resolvedSharingUrl = resolveShareBaseUrl(sharingUrl ?? context?.merchantDomain);
|
|
221
235
|
const rewardText = useMemo(() => {
|
|
222
236
|
if (!context?.reward) return void 0;
|
|
223
237
|
const currency = window.FrakSetup?.client?.config?.metadata?.currency;
|
|
@@ -176,7 +176,7 @@ function N(e, t) {
|
|
|
176
176
|
}
|
|
177
177
|
function P(e, t, n) {
|
|
178
178
|
if (!Array.isArray(n)) return e === `not_in`;
|
|
179
|
-
if (t
|
|
179
|
+
if (t == null) return;
|
|
180
180
|
let r = n.includes(t);
|
|
181
181
|
return e === `in` ? r : !r;
|
|
182
182
|
}
|
|
@@ -196,10 +196,10 @@ function I(e, t, n) {
|
|
|
196
196
|
}
|
|
197
197
|
function L(e, t) {
|
|
198
198
|
let n = j(t, e.field), { operator: r, value: i, valueTo: a } = e;
|
|
199
|
-
if (r === `exists`) return n
|
|
200
|
-
if (r === `not_exists`) return n
|
|
199
|
+
if (r === `exists`) return n != null;
|
|
200
|
+
if (r === `not_exists`) return n == null;
|
|
201
201
|
if (r === `in` || r === `not_in`) return P(r, n, i);
|
|
202
|
-
if (!(Array.isArray(i) || n
|
|
202
|
+
if (!(Array.isArray(i) || n == null || i == null)) {
|
|
203
203
|
if (T.has(r)) return F(r, n, i, a);
|
|
204
204
|
if (D.has(r)) return I(r, n, i);
|
|
205
205
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { a as subscribeSdkConfig } from "./usePlacement-
|
|
1
|
+
import { a as subscribeSdkConfig } from "./usePlacement-iFDQqtJn.js";
|
|
2
2
|
import { sdkConfigStore } from "@frak-labs/core-sdk";
|
|
3
3
|
import { useSyncExternalStore } from "preact/compat";
|
|
4
4
|
//#region src/hooks/useGlobalComponents.ts
|
|
@@ -66,9 +66,8 @@ function dispatchClientReadyEvent() {
|
|
|
66
66
|
window.dispatchEvent(event);
|
|
67
67
|
}
|
|
68
68
|
/**
|
|
69
|
-
* Add or remove an event listener for when the Frak client is ready
|
|
70
|
-
*
|
|
71
|
-
* @param callback
|
|
69
|
+
* Add or remove an event listener for when the Frak client is ready.
|
|
70
|
+
* An `add` on an already-ready client runs the callback immediately.
|
|
72
71
|
*/
|
|
73
72
|
function onClientReady(action, callback) {
|
|
74
73
|
if (window.FrakSetup?.client && action === "add") {
|
|
@@ -83,8 +82,6 @@ function onClientReady(action, callback) {
|
|
|
83
82
|
* Initializes the Frak SDK client and sets up necessary configurations.
|
|
84
83
|
* Uses withCache for inflight dedup — concurrent callers share the same promise.
|
|
85
84
|
* Failures are not cached, allowing retry on next call.
|
|
86
|
-
*
|
|
87
|
-
* @returns {Promise<void>}
|
|
88
85
|
*/
|
|
89
86
|
function initFrakSdk() {
|
|
90
87
|
window.FrakSetup.core = {
|
|
@@ -108,24 +105,17 @@ function initFrakSdk() {
|
|
|
108
105
|
*/
|
|
109
106
|
async function doInit() {
|
|
110
107
|
if (!window.FrakSetup?.config) throw new Error("[Frak SDK] Configuration not found. Please ensure window.FrakSetup.config is set.");
|
|
111
|
-
console.log("[Frak SDK] Starting initialization");
|
|
112
108
|
const client = await setupClient({ config: withDynamicPreload(window.FrakSetup.config) });
|
|
113
109
|
if (!client) throw new Error("[Frak SDK] Failed to create client");
|
|
114
110
|
window.FrakSetup.client = client;
|
|
115
|
-
console.log("[Frak SDK] Client initialized successfully");
|
|
116
111
|
dispatchClientReadyEvent();
|
|
117
112
|
coreSdkActions.setupReferral(client);
|
|
118
113
|
handleActionQueryParam();
|
|
119
114
|
}
|
|
120
115
|
/**
|
|
121
|
-
* Inject a dynamically-computed `preload` list
|
|
122
|
-
*
|
|
123
|
-
*
|
|
124
|
-
* Rationale: the listener iframe warms Ring 1/Ring 2 chunks based on the
|
|
125
|
-
* `#preload=...` hash. The components CDN entry can detect which Frak
|
|
126
|
-
* components are actually on the page and avoid the warm-up cost when none
|
|
127
|
-
* are mounted. An explicit `config.preload` (including `[]`) is respected
|
|
128
|
-
* as an escape hatch.
|
|
116
|
+
* Inject a dynamically-computed `preload` list, so the listener only warms the
|
|
117
|
+
* chunks the mounted components need. An explicit `config.preload` (including
|
|
118
|
+
* `[]`) is respected as an escape hatch.
|
|
129
119
|
*/
|
|
130
120
|
function withDynamicPreload(config) {
|
|
131
121
|
if (config.preload !== void 0) return config;
|
|
@@ -135,33 +125,14 @@ function withDynamicPreload(config) {
|
|
|
135
125
|
};
|
|
136
126
|
}
|
|
137
127
|
/**
|
|
138
|
-
*
|
|
139
|
-
*
|
|
140
|
-
*
|
|
141
|
-
*
|
|
142
|
-
* - `link` overrides the URL the sharing page generates outbound shares for.
|
|
143
|
-
* When omitted, the listener falls back to the merchant domain.
|
|
144
|
-
* - `products` is a base64-encoded compressed JSON payload of
|
|
145
|
-
* `SharingPageProduct[]` — produced by `compressJsonToB64(productsArray)`
|
|
146
|
-
* on the sender side (e.g. a Klaviyo email template). Used by
|
|
147
|
-
* post-purchase emails to surface the items the customer just bought as
|
|
148
|
-
* product cards on the sharing page.
|
|
149
|
-
* - `placement` lets the caller scope backend-driven CSS / config to a
|
|
150
|
-
* specific placement (mirrors the prop on the components).
|
|
151
|
-
*
|
|
152
|
-
* The four params are stripped from the URL via `history.replaceState` as
|
|
153
|
-
* soon as they are read, so refreshes / shares of the current URL do not
|
|
154
|
-
* re-trigger the auto-open. Matches the `fmt` (merge token) and `sso`
|
|
155
|
-
* cleanup patterns elsewhere in the SDK.
|
|
156
|
-
*
|
|
157
|
-
* Param keys and the `frakAction` keyword value are matched case-insensitively
|
|
158
|
-
* because some email tools and browsers lowercase the whole URL in transit
|
|
159
|
-
* (e.g. `?FrakAction=Share` → `?frakaction=share`).
|
|
128
|
+
* Auto-open the sharing page from `?frakAction=share`, optionally scoped by
|
|
129
|
+
* `link`, `placement` and a `compressJsonToB64` `products` payload. Keys and
|
|
130
|
+
* the keyword value are matched case-insensitively: email tools and browsers
|
|
131
|
+
* lowercase the whole URL in transit (`?FrakAction=Share`).
|
|
160
132
|
*/
|
|
161
133
|
function handleActionQueryParam() {
|
|
162
134
|
const url = new URL(window.location.href);
|
|
163
135
|
if (getQueryParamCaseInsensitive(url.searchParams, "frakAction")?.toLowerCase() !== "share") return;
|
|
164
|
-
console.log("[Frak SDK] Auto open share via query param");
|
|
165
136
|
const link = getQueryParamCaseInsensitive(url.searchParams, "link") ?? void 0;
|
|
166
137
|
const placement = getQueryParamCaseInsensitive(url.searchParams, "placement") ?? void 0;
|
|
167
138
|
const products = decodeProductsParam(getQueryParamCaseInsensitive(url.searchParams, "products"));
|
|
@@ -170,6 +141,11 @@ function handleActionQueryParam() {
|
|
|
170
141
|
deleteQueryParamCaseInsensitive(url.searchParams, "placement");
|
|
171
142
|
deleteQueryParamCaseInsensitive(url.searchParams, "products");
|
|
172
143
|
window.history.replaceState({}, "", url.toString());
|
|
144
|
+
trackEvent(window.FrakSetup?.client, "sharing_page_auto_opened", {
|
|
145
|
+
placement,
|
|
146
|
+
has_link: Boolean(link),
|
|
147
|
+
has_products: Boolean(products?.length)
|
|
148
|
+
});
|
|
173
149
|
openSharingPage(void 0, placement, {
|
|
174
150
|
link,
|
|
175
151
|
products
|
|
@@ -179,7 +155,6 @@ function handleActionQueryParam() {
|
|
|
179
155
|
//#region src/utils/browser/onDocumentReady.ts
|
|
180
156
|
/**
|
|
181
157
|
* When the document is ready, run the callback
|
|
182
|
-
* @param callback
|
|
183
158
|
*/
|
|
184
159
|
function onDocumentReady(callback) {
|
|
185
160
|
if (document.readyState === "complete" || document.readyState === "interactive") setTimeout(callback, 1);
|