@frak-labs/components 1.2.0 → 1.2.1
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.DdAIrKFw.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.Rl1oR1D4.js +89 -0
- package/cdn/components.js +1 -1
- package/cdn/loader.js +8 -52
- package/cdn/{useLightDomStyles.BLyrWEBn.js → useLightDomStyles.B7MVlVVJ.js} +1 -1
- package/dist/{GiftIcon-DI0rUKHp.js → GiftIcon-BmGGodb2.js} +1 -1
- package/dist/banner.d.ts +3 -4
- package/dist/banner.js +5 -5
- package/dist/buttonShare.d.ts +3 -4
- package/dist/buttonShare.js +25 -7
- package/dist/buttonWallet.d.ts +6 -10
- package/dist/buttonWallet.js +38 -43
- 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 +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/package.json +13 -13
- package/cdn/ButtonShare.BMW4Spt5.js +0 -1
- package/cdn/ButtonWallet.DL64Gv3j.js +0 -40
- package/cdn/OpenInAppButton.DYfr8q7L.js +0 -1
- package/cdn/PostPurchase.dHmBw1iX.js +0 -89
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 { t as useGlobalComponents } from "./useGlobalComponents-DFv33ujB.js";
|
|
3
|
-
import { t as useLightDomStyles } from "./useLightDomStyles-B_IbOqJZ.js";
|
|
1
|
+
import { i as useLang, o as useClientReady, s as registerWebComponent, t as usePlacement } from "./usePlacement-iFDQqtJn.js";
|
|
4
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
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 { t as useGlobalComponents } from "./useGlobalComponents-DFv33ujB.js";
|
|
3
|
-
import { t as useLightDomStyles } from "./useLightDomStyles-B_IbOqJZ.js";
|
|
1
|
+
import { c as openSharingPage, i as useLang, o as useClientReady, s as registerWebComponent, t as usePlacement } from "./usePlacement-iFDQqtJn.js";
|
|
4
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
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-
|
|
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
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 useGlobalComponents } from "./useGlobalComponents-DFv33ujB.js";
|
|
3
|
-
import { t as useLightDomStyles } from "./useLightDomStyles-B_IbOqJZ.js";
|
|
1
|
+
import { c as openSharingPage, i as useLang, o as useClientReady, s as registerWebComponent, t as usePlacement } from "./usePlacement-iFDQqtJn.js";
|
|
4
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";
|
|
@@ -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);
|
package/package.json
CHANGED
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
"url": "https://twitter.com/QNivelais"
|
|
12
12
|
}
|
|
13
13
|
],
|
|
14
|
-
"version": "1.2.
|
|
14
|
+
"version": "1.2.1",
|
|
15
15
|
"description": "Frak Wallet components, helping any person to interact with the Frak wallet.",
|
|
16
16
|
"repository": {
|
|
17
17
|
"url": "https://github.com/frak-id/wallet",
|
|
@@ -103,33 +103,33 @@
|
|
|
103
103
|
"publish": "echo 'Publishing components...'"
|
|
104
104
|
},
|
|
105
105
|
"dependencies": {
|
|
106
|
-
"@frak-labs/core-sdk": "1.
|
|
107
|
-
"@frak-labs/design-system": "0.0.0",
|
|
106
|
+
"@frak-labs/core-sdk": "1.4.1",
|
|
108
107
|
"@frak-labs/frame-connector": "1.3.0",
|
|
109
|
-
"preact": "^10.29.
|
|
108
|
+
"preact": "^10.29.8",
|
|
110
109
|
"preact-custom-element": "^4.6.0"
|
|
111
110
|
},
|
|
112
111
|
"devDependencies": {
|
|
112
|
+
"@frak-labs/design-system": "0.0.0",
|
|
113
113
|
"@frak-labs/test-foundation": "0.1.0",
|
|
114
114
|
"@preact/preset-vite": "^2.10.6",
|
|
115
115
|
"@rolldown/plugin-node-polyfills": "^1.0.3",
|
|
116
|
-
"@testing-library/jest-dom": "^7.0.
|
|
116
|
+
"@testing-library/jest-dom": "^7.0.1",
|
|
117
117
|
"@testing-library/preact": "^3.2.4",
|
|
118
|
-
"@testing-library/user-event": "^14.6.
|
|
119
|
-
"@types/jsdom": "^
|
|
118
|
+
"@testing-library/user-event": "^14.6.7",
|
|
119
|
+
"@types/jsdom": "^30.0.0",
|
|
120
120
|
"@types/node": "^25.9.5",
|
|
121
121
|
"@types/preact-custom-element": "^4.0.4",
|
|
122
122
|
"@typescript/native": "npm:typescript@^7.0.2",
|
|
123
123
|
"@vanilla-extract/css": "^1.21.2",
|
|
124
124
|
"@vanilla-extract/integration": "^8.0.10",
|
|
125
|
-
"@vanilla-extract/sprinkles": "^1.7.
|
|
125
|
+
"@vanilla-extract/sprinkles": "^1.7.1",
|
|
126
126
|
"@vanilla-extract/vite-plugin": "^5.2.6",
|
|
127
|
-
"@vitest/coverage-v8": "^
|
|
128
|
-
"@vitest/ui": "^
|
|
129
|
-
"jsdom": "^
|
|
127
|
+
"@vitest/coverage-v8": "^5.0.0",
|
|
128
|
+
"@vitest/ui": "^5.0.0",
|
|
129
|
+
"jsdom": "^30.0.1",
|
|
130
130
|
"rolldown": "~1.2.0",
|
|
131
|
-
"tsdown": "^0.
|
|
131
|
+
"tsdown": "^0.23.0",
|
|
132
132
|
"typescript": "^6.0.3",
|
|
133
|
-
"vitest": "^
|
|
133
|
+
"vitest": "^5.0.0"
|
|
134
134
|
}
|
|
135
135
|
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{S as e,l as t,r as n}from"./loader.js";import{a as r,h as i,m as a,n as o,p as s,s as c,t as l,u}from"./defaults.CmUvOlLQ.js";import{t as d}from"./useGlobalComponents.C7wnXWOg.js";import{t as f}from"./useLightDomStyles.BLyrWEBn.js";import{i as p}from"./rewards.0JylBHNY.js";import{t as m}from"./useReward.CaBorN5T.js";function h({placement:i,text:h,classname:g=``,noRewardText:_,targetInteraction:v,products:y,clickAction:b,preview:x}){let S=!!x,C=r(),w=o(i),T=d(),E=w?.components?.buttonShare??T?.buttonShare;f(`frak-button-share`,i,E?.css);let D=u(()=>w?.targetInteraction===void 0?v:w.targetInteraction,[w?.targetInteraction,v]),O=E?.text??h??l[C].buttonShare.text,k=E?.noRewardText??_,A=u(()=>O.includes(`{REWARD}`),[O]),j=u(()=>E?.clickAction??b??`sharing-page`,[E?.clickAction,b]),{shouldRender:M,isHidden:N,isClientReady:P}=c(),F=u(()=>t(y),[y]),{reward:I}=m(A&&P,D,void 0,F),L=u(()=>A?I?p(O,I):k??p(O,void 0):O,[A,O,k,I]),R=s(()=>{S||(e(window.FrakSetup.client,`share_button_clicked`,{placement:i,target_interaction:D,has_reward:!!I,click_action:j}),n(D,i,{products:F}))},[S,j,D,i,I,F]);if(!S&&(!M||N))return null;let z=[`button`,`button__fadeIn`,g].filter(Boolean).join(` `);return a(`button`,{type:`button`,disabled:!S&&!P,class:z,onClick:R,children:L})}i(h,`frak-button-share`,[`text`,`placement`,`classname`,`clickAction`,`noRewardText`,`targetInteraction`,`products`,`preview`],{shadow:!1});export{h as ButtonShare};
|
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
import{S as e,r as t}from"./loader.js";import{a as n,d as r,f as i,g as a,h as o,m as s,n as c,p as l,r as u,s as d,t as f,u as p}from"./defaults.CmUvOlLQ.js";import{t as m}from"./useReward.CaBorN5T.js";function h(e){return s(`svg`,{fill:`none`,height:`1em`,viewBox:`0 0 28 28`,width:`1em`,xmlns:`http://www.w3.org/2000/svg`,...e,children:[s(`title`,{children:`Gift icon`}),s(`path`,{d:`m23.14 14v11.43h-18.29v-11.43m9.14 11.43v-17.14m0 0h-5.14c-0.76 0-1.48-0.3-2.02-0.84s-0.84-1.26-0.84-2.020.3-1.480.84-2.02 1.26-0.84 2.02-0.84c4 0 5.14 5.71 5.14 5.71zm0 0h5.14c0.76 0 1.48-0.3 2.02-0.84s0.84-1.260.84-2.02-0.3-1.48-0.84-2.02-1.26-0.84-2.02-0.84c-4 0-5.14 5.71-5.14 5.71zm-11.43 0h22.86v5.71h-22.86z`,stroke:`#fff`,"stroke-linecap":`round`,"stroke-linejoin":`round`})]})}function g(){`vibrate`in navigator&&navigator.vibrate(10)}function _(e,n){g(),t(e,n)}function v({placement:t,classname:o=``,useReward:g,targetInteraction:v}){let y=n(),b=c(t),x=p(()=>b?.targetInteraction===void 0?v:b.targetInteraction,[b?.targetInteraction,v]),S=p(()=>g===!0,[g]),{shouldRender:C,isHidden:w,isClientReady:T}=d(),{reward:E}=m(S&&T,x),[D,O]=r(`right`),k=l(()=>{e(window.FrakSetup.client,`share_button_clicked`,{placement:t,target_interaction:x,has_reward:!!E,click_action:`sharing-page`}),_(x,t)},[t,x,E]);if(i(()=>{let e=b?.components?.buttonWallet?.position,t=window.FrakSetup?.modalWalletConfig?.metadata?.position;O(e??t??`right`)},[b?.components?.buttonWallet?.position]),!C||w)return null;let A=[`button`,`button__fadeIn`,D===`left`?`button__left`:`button__right`,o].filter(Boolean).join(` `);return s(a,{children:[s(`style`,{children:u(`
|
|
2
|
-
.button {
|
|
3
|
-
all: unset;
|
|
4
|
-
position: fixed;
|
|
5
|
-
bottom: 20px;
|
|
6
|
-
z-index: 2000000;
|
|
7
|
-
display: flex;
|
|
8
|
-
justify-content: center;
|
|
9
|
-
align-items: center;
|
|
10
|
-
background-color: #3e557e;
|
|
11
|
-
width: 45px;
|
|
12
|
-
height: 45px;
|
|
13
|
-
border-radius: 50%;
|
|
14
|
-
cursor: pointer;
|
|
15
|
-
text-align: center;
|
|
16
|
-
font-size: 24px;
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
.button__left {
|
|
20
|
-
left: 20px;
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
.button__right {
|
|
24
|
-
right: 20px;
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
.reward {
|
|
28
|
-
position: absolute;
|
|
29
|
-
top: -4px;
|
|
30
|
-
right: 27px;
|
|
31
|
-
padding: 2px 3px;
|
|
32
|
-
border-radius: 5px;
|
|
33
|
-
background: #ff3f3f;
|
|
34
|
-
font-size: 9px;
|
|
35
|
-
color: #fff;
|
|
36
|
-
font-weight: 600;
|
|
37
|
-
white-space: nowrap;
|
|
38
|
-
line-height: 9px;
|
|
39
|
-
}
|
|
40
|
-
`,b?.components?.buttonWallet?.css)}),s(`button`,{type:`button`,"aria-label":f[y].buttonWallet.ariaLabel,part:`button`,disabled:!T,class:A,onClick:k,children:[s(h,{}),E&&s(`span`,{class:`reward`,children:E})]})]})}o(v,`frak-button-wallet`,[`placement`,`classname`,`useReward`,`targetInteraction`],{shadow:!0});export{v as ButtonWallet};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{S as e,g as t,h as n,u as r}from"./loader.js";import{a as i,h as a,m as o,n as s,s as c,t as l,u}from"./defaults.CmUvOlLQ.js";import{t as d}from"./useLightDomStyles.BLyrWEBn.js";function f(n=`wallet`,i){let a=window.FrakSetup?.client;a&&e(a,`open_in_app_clicked`,{path:n,placement:i});let o=`${t}${n}`;r(o,{onFallback:()=>{a&&e(a,`app_not_installed`,{path:n,placement:i})}})}function p(){return{isMobile:u(()=>n(),[])}}function m({placement:e,text:t,classname:n=``}){let r=i(),a=s(e),{shouldRender:u,isHidden:m,isClientReady:h}=c(),{isMobile:g}=p();d(`frak-open-in-app`,e,a?.components?.openInApp?.css);let _=a?.components?.openInApp?.text??t??l[r].openInApp.text;if(!g||!u||m)return null;let v=()=>{f(void 0,e)},y=[`button`,`button__fadeIn`,n].filter(Boolean).join(` `);return o(`button`,{type:`button`,"aria-label":l[r].openInApp.ariaLabel,disabled:!h,class:y,onClick:v,children:_})}a(m,`frak-open-in-app`,[`text`,`placement`,`classname`],{shadow:!1});export{m as OpenInAppButton};
|