@frak-labs/components 1.1.0-beta.49cfd58a → 1.1.0-beta.4bb73abc

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.
Files changed (34) hide show
  1. package/README.md +24 -2
  2. package/cdn/{Banner.Dh-KYDLv.js → Banner.Zaqy93tl.js} +3 -3
  3. package/cdn/ButtonShare.BnzCAsRy.js +1 -0
  4. package/cdn/ButtonWallet.DlzZbjCb.js +40 -0
  5. package/cdn/OpenInAppButton.d-omgD0k.js +1 -0
  6. package/cdn/PostPurchase._3t6CtvV.js +89 -0
  7. package/cdn/components.js +1 -1
  8. package/cdn/loader.js +8 -52
  9. package/cdn/rewards.0JylBHNY.js +1 -0
  10. package/cdn/{useLightDomStyles.BLyrWEBn.js → useLightDomStyles.B7MVlVVJ.js} +1 -1
  11. package/cdn/{useReward.fvxtDVaA.js → useReward.CaBorN5T.js} +1 -1
  12. package/dist/{GiftIcon-DI0rUKHp.js → GiftIcon-BmGGodb2.js} +1 -1
  13. package/dist/banner.d.ts +3 -4
  14. package/dist/banner.js +7 -7
  15. package/dist/buttonShare.d.ts +3 -4
  16. package/dist/buttonShare.js +8 -8
  17. package/dist/buttonWallet.d.ts +6 -10
  18. package/dist/buttonWallet.js +22 -44
  19. package/dist/i18n/defaults.d.ts +2 -3
  20. package/dist/openInApp.d.ts +4 -5
  21. package/dist/openInApp.js +4 -5
  22. package/dist/postPurchase.d.ts +3 -4
  23. package/dist/postPurchase.js +20 -6
  24. package/dist/{rewards-CZkWSndn.js → rewards-DoVY1pWr.js} +4 -4
  25. package/dist/{useGlobalComponents-DFv33ujB.js → useGlobalComponents-BB6djMbu.js} +1 -1
  26. package/dist/{useLightDomStyles-B_IbOqJZ.js → useLightDomStyles-0A0CeRlU.js} +1 -1
  27. package/dist/{usePlacement-DtwWaLHO.js → usePlacement-BzMOjNe0.js} +9 -39
  28. package/dist/{useReward-D5zzFR11.js → useReward-k7RF3DhH.js} +1 -1
  29. package/package.json +14 -14
  30. package/cdn/ButtonShare.CiEtGubR.js +0 -1
  31. package/cdn/ButtonWallet.B-80TBVO.js +0 -40
  32. package/cdn/OpenInAppButton.DYfr8q7L.js +0 -1
  33. package/cdn/PostPurchase.CxEoeBs_.js +0 -89
  34. 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-DtwWaLHO.js";
2
- import { t as useGlobalComponents } from "./useGlobalComponents-DFv33ujB.js";
3
- import { t as useLightDomStyles } from "./useLightDomStyles-B_IbOqJZ.js";
4
- import { i as w } from "./rewards-CZkWSndn.js";
5
- import { t as useReward } from "./useReward-D5zzFR11.js";
1
+ import { i as useLang, o as useClientReady, s as registerWebComponent, t as usePlacement } from "./usePlacement-BzMOjNe0.js";
2
+ import { i as w } from "./rewards-DoVY1pWr.js";
3
+ import { t as useGlobalComponents } from "./useGlobalComponents-BB6djMbu.js";
4
+ import { t as useLightDomStyles } from "./useLightDomStyles-0A0CeRlU.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-DI0rUKHp.js";
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;
@@ -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
@@ -1,8 +1,8 @@
1
- import { c as openSharingPage, i as useLang, o as useClientReady, s as registerWebComponent, t as usePlacement } from "./usePlacement-DtwWaLHO.js";
2
- import { t as useGlobalComponents } from "./useGlobalComponents-DFv33ujB.js";
3
- import { t as useLightDomStyles } from "./useLightDomStyles-B_IbOqJZ.js";
4
- import { i as w } from "./rewards-CZkWSndn.js";
5
- import { t as useReward } from "./useReward-D5zzFR11.js";
1
+ import { c as openSharingPage, i as useLang, o as useClientReady, s as registerWebComponent, t as usePlacement } from "./usePlacement-BzMOjNe0.js";
2
+ import { i as w } from "./rewards-DoVY1pWr.js";
3
+ import { t as useGlobalComponents } from "./useGlobalComponents-BB6djMbu.js";
4
+ import { t as useLightDomStyles } from "./useLightDomStyles-0A0CeRlU.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
8
  import { useCallback, useMemo } from "preact/hooks";
@@ -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 = useMemo(() => placement?.targetInteraction !== void 0 ? placement.targetInteraction : targetInteraction, [placement?.targetInteraction, targetInteraction]);
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 = useMemo(() => resolvedText.includes("{REWARD}"), [resolvedText]);
74
- const resolvedClickAction = useMemo(() => componentConfig?.clickAction ?? rawClickAction ?? "sharing-page", [componentConfig?.clickAction, rawClickAction]);
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);
@@ -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
- * Historically this opened the embedded wallet drawer; that surface was
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
@@ -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-DtwWaLHO.js";
2
- import { t as useReward } from "./useReward-D5zzFR11.js";
1
+ import { c as openSharingPage, i as useLang, n as buildStyleContent, o as useClientReady, s as registerWebComponent, t as usePlacement } from "./usePlacement-BzMOjNe0.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, useMemo, useState } from "preact/hooks";
5
+ import { useCallback } from "preact/hooks";
6
6
  import { Fragment, jsx, jsxs } from "preact/jsx-runtime";
7
- //#region src/components/ButtonWallet/assets/GiftIcon.tsx
8
- function GiftIcon(props) {
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
- * Historically this opened the embedded wallet drawer; that surface was
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,11 @@ 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 = useMemo(() => placement?.targetInteraction !== void 0 ? placement.targetInteraction : targetInteraction, [placement?.targetInteraction, targetInteraction]);
139
- const shouldUseReward = useMemo(() => rawUseReward === true, [rawUseReward]);
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 [position, setPosition] = useState("right");
124
+ const position = placement?.components?.buttonWallet?.position ?? window.FrakSetup?.modalWalletConfig?.metadata?.position ?? "right";
143
125
  const onClick = useCallback(() => {
144
126
  trackEvent(window.FrakSetup.client, "share_button_clicked", {
145
127
  placement: placementId,
@@ -147,17 +129,13 @@ function ButtonWallet({ placement: placementId, classname = "", useReward: rawUs
147
129
  has_reward: Boolean(reward),
148
130
  click_action: "sharing-page"
149
131
  });
150
- openWalletModal(resolvedTargetInteraction, placementId);
132
+ safeVibrate();
133
+ openSharingPage(resolvedTargetInteraction, placementId);
151
134
  }, [
152
135
  placementId,
153
136
  resolvedTargetInteraction,
154
137
  reward
155
138
  ]);
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
139
  if (!shouldRender || isHidden) return null;
162
140
  const buttonClass = [
163
141
  "button",
@@ -172,7 +150,7 @@ function ButtonWallet({ placement: placementId, classname = "", useReward: rawUs
172
150
  disabled: !isClientReady,
173
151
  class: buttonClass,
174
152
  onClick,
175
- children: [/* @__PURE__ */ jsx(GiftIcon, {}), reward && /* @__PURE__ */ jsx("span", {
153
+ children: [/* @__PURE__ */ jsx(WalletGiftIcon, {}), reward && /* @__PURE__ */ jsx("span", {
176
154
  class: "reward",
177
155
  children: reward
178
156
  })]
@@ -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
@@ -40,23 +40,22 @@ type OpenInAppButtonProps = {
40
40
  * ```
41
41
  *
42
42
  * @example
43
- * With login action:
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-DtwWaLHO.js";
2
- 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-BzMOjNe0.js";
2
+ import { t as useLightDomStyles } from "./useLightDomStyles-0A0CeRlU.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: useMemo(() => 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
- * With login action:
57
+ * Using a custom class:
59
58
  * ```html
60
59
  * <frak-open-in-app classname="button button-primary"></frak-open-in-app>
61
60
  * ```
@@ -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
@@ -1,9 +1,9 @@
1
- import { c as openSharingPage, i as useLang, o as useClientReady, s as registerWebComponent, t as usePlacement } from "./usePlacement-DtwWaLHO.js";
2
- import { t as useGlobalComponents } from "./useGlobalComponents-DFv33ujB.js";
3
- import { t as useLightDomStyles } from "./useLightDomStyles-B_IbOqJZ.js";
4
- import { i as w, n as K, t as C } from "./rewards-CZkWSndn.js";
1
+ import { c as openSharingPage, i as useLang, o as useClientReady, s as registerWebComponent, t as usePlacement } from "./usePlacement-BzMOjNe0.js";
2
+ import { i as w, n as K, t as C } from "./rewards-DoVY1pWr.js";
3
+ import { t as useGlobalComponents } from "./useGlobalComponents-BB6djMbu.js";
4
+ import { t as useLightDomStyles } from "./useLightDomStyles-0A0CeRlU.js";
5
5
  import { componentDefaults } from "./i18n/defaults.js";
6
- import { i as LogoFrakWithName, n as cssSource$2, t as GiftIcon } from "./GiftIcon-DI0rUKHp.js";
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 === void 0) return;
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 !== void 0;
200
- if (r === `not_exists`) return n === void 0;
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 === void 0 || i === null)) {
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-DtwWaLHO.js";
1
+ import { a as subscribeSdkConfig } from "./usePlacement-BzMOjNe0.js";
2
2
  import { sdkConfigStore } from "@frak-labs/core-sdk";
3
3
  import { useSyncExternalStore } from "preact/compat";
4
4
  //#region src/hooks/useGlobalComponents.ts
@@ -1,4 +1,4 @@
1
- import { r as lightDomBaseCss } from "./usePlacement-DtwWaLHO.js";
1
+ import { r as lightDomBaseCss } from "./usePlacement-BzMOjNe0.js";
2
2
  import { useEffect } from "preact/hooks";
3
3
  //#region src/styles/styleManager.ts
4
4
  function ensureStyle(id, css) {
@@ -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
- * @param action
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 when the caller hasn't set
122
- * one explicitly.
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
- * Check the query param for an auto-opening of the Frak sharing page.
139
- *
140
- * Supported params (all optional except `frakAction`):
141
- * - `frakAction=share` triggers the auto-open.
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"));
@@ -179,7 +150,6 @@ function handleActionQueryParam() {
179
150
  //#region src/utils/browser/onDocumentReady.ts
180
151
  /**
181
152
  * When the document is ready, run the callback
182
- * @param callback
183
153
  */
184
154
  function onDocumentReady(callback) {
185
155
  if (document.readyState === "complete" || document.readyState === "interactive") setTimeout(callback, 1);
@@ -1,4 +1,4 @@
1
- import { r as q } from "./rewards-CZkWSndn.js";
1
+ import { r as q } from "./rewards-DoVY1pWr.js";
2
2
  import { getMerchantInformation } from "@frak-labs/core-sdk/actions";
3
3
  import { useEffect, useState } from "preact/hooks";
4
4
  //#region src/hooks/useReward.ts
package/package.json CHANGED
@@ -11,7 +11,7 @@
11
11
  "url": "https://twitter.com/QNivelais"
12
12
  }
13
13
  ],
14
- "version": "1.1.0-beta.49cfd58a",
14
+ "version": "1.1.0-beta.4bb73abc",
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.3.0-beta.49cfd58a",
107
- "@frak-labs/design-system": "0.0.0",
108
- "@frak-labs/frame-connector": "1.3.0-beta.49cfd58a",
109
- "preact": "^10.29.7",
106
+ "@frak-labs/core-sdk": "1.3.0-beta.4bb73abc",
107
+ "@frak-labs/frame-connector": "1.3.0-beta.4bb73abc",
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.0",
116
+ "@testing-library/jest-dom": "^7.0.1",
117
117
  "@testing-library/preact": "^3.2.4",
118
- "@testing-library/user-event": "^14.6.1",
119
- "@types/jsdom": "^28.0.3",
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.0",
125
+ "@vanilla-extract/sprinkles": "^1.7.1",
126
126
  "@vanilla-extract/vite-plugin": "^5.2.6",
127
- "@vitest/coverage-v8": "^4.1.10",
128
- "@vitest/ui": "^4.1.10",
129
- "jsdom": "^29.1.1",
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.22.14",
131
+ "tsdown": "^0.23.0",
132
132
  "typescript": "^6.0.3",
133
- "vitest": "^4.1.10"
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.DjfrchZd.js";import{t as m}from"./useReward.fvxtDVaA.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.fvxtDVaA.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):console.log(`Vibration not supported`)}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};