@frak-labs/components 1.0.2 → 1.0.3-beta.473e9a7a
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/cdn/Banner.A9gO8oPK.js +164 -0
- package/cdn/ButtonShare.DNdo_eQJ.js +1 -0
- package/cdn/{ButtonWallet.Cwz9qFhE.js → ButtonWallet.CN2iHSTB.js} +1 -1
- package/cdn/{OpenInAppButton.Hq9EjwJE.js → OpenInAppButton.C1Yipwka.js} +1 -1
- package/cdn/PostPurchase.BvmSYSpL.js +52 -0
- package/cdn/components.js +1 -1
- package/cdn/formatReward.C7mU9_cV.js +1 -0
- package/cdn/loader.js +2 -2
- package/cdn/sharingPage.Do_xfrTN.js +1 -0
- package/cdn/{sprinkles.css.ts.vanilla.Ct795MMK.js → sprinkles.css.ts.vanilla.06k5OzG1.js} +1 -1
- package/cdn/useGlobalComponents.UJmjUUxk.js +1 -0
- package/cdn/{useLightDomStyles.DqYouFn3.js → useLightDomStyles.Gt7YUMDl.js} +1 -1
- package/cdn/{usePlacement.Di6eZ4ty.js → usePlacement.BJ7qe-pw.js} +1 -1
- package/cdn/{useReward.DWyyva4u.js → useReward.QsQc2c1D.js} +1 -1
- package/dist/{GiftIcon-4sr9xXyq.js → GiftIcon-c28NnqJ7.js} +1 -0
- package/dist/banner.js +4 -2
- package/dist/buttonShare.d.ts +9 -4
- package/dist/buttonShare.js +13 -177
- package/dist/openInApp.js +1 -1
- package/dist/postPurchase.d.ts +17 -1
- package/dist/postPurchase.js +96 -16
- package/dist/sharingPage-DFvQbviS.js +15 -0
- package/dist/useLightDomStyles-gbuSWvRx.js +89 -0
- package/package.json +3 -3
- package/cdn/Banner.1iUbfe7Z.js +0 -162
- package/cdn/ButtonShare.APhrT3sb.js +0 -1
- package/cdn/PostPurchase.gHQmp1c4.js +0 -52
- package/cdn/formatReward.BaR9pE50.js +0 -1
- package/cdn/useGlobalComponents.CLH7id-Y.js +0 -1
- package/cdn/useShareModal.pszXJ-rf.js +0 -1
- package/dist/useLightDomStyles-C3lcOwY2.js +0 -41
- package/dist/useShareModal-BEVkLrBP.js +0 -54
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
import { DebugInfoGatherer, trackEvent } from "@frak-labs/core-sdk";
|
|
2
|
-
import { modalBuilder } from "@frak-labs/core-sdk/actions";
|
|
3
|
-
import { useCallback, useState } from "preact/hooks";
|
|
4
|
-
import { FrakRpcError, RpcErrorCodes } from "@frak-labs/frame-connector";
|
|
5
|
-
//#region src/components/ButtonShare/hooks/useShareModal.ts
|
|
6
|
-
/**
|
|
7
|
-
* Open the share modal
|
|
8
|
-
*
|
|
9
|
-
* @description
|
|
10
|
-
* This function will open the share modal, lazily creating a modal builder on demand.
|
|
11
|
-
*/
|
|
12
|
-
function useShareModal(targetInteraction, placement, sharingLink) {
|
|
13
|
-
const [debugInfo, setDebugInfo] = useState(void 0);
|
|
14
|
-
const [isError, setIsError] = useState(false);
|
|
15
|
-
return {
|
|
16
|
-
handleShare: useCallback(async () => {
|
|
17
|
-
if (!window.FrakSetup?.client) {
|
|
18
|
-
console.error("Frak client not found");
|
|
19
|
-
setDebugInfo(DebugInfoGatherer.empty().formatDebugInfo("Frak client not found"));
|
|
20
|
-
setIsError(true);
|
|
21
|
-
return;
|
|
22
|
-
}
|
|
23
|
-
const builder = modalBuilder(window.FrakSetup.client, {});
|
|
24
|
-
try {
|
|
25
|
-
await builder.sharing(sharingLink ? { link: sharingLink } : {}).display((metadata) => ({
|
|
26
|
-
...metadata,
|
|
27
|
-
targetInteraction
|
|
28
|
-
}), placement);
|
|
29
|
-
} catch (e) {
|
|
30
|
-
if (e instanceof FrakRpcError && e.code === RpcErrorCodes.clientAborted) {
|
|
31
|
-
console.debug("User aborted the modal");
|
|
32
|
-
return;
|
|
33
|
-
}
|
|
34
|
-
const debugInfo = window.FrakSetup.client.debugInfo.formatDebugInfo(e);
|
|
35
|
-
trackEvent(window.FrakSetup.client, "share_modal_error", {
|
|
36
|
-
placement,
|
|
37
|
-
target_interaction: targetInteraction,
|
|
38
|
-
error: e instanceof Object && "message" in e ? e.message : "Unknown error"
|
|
39
|
-
});
|
|
40
|
-
setDebugInfo(debugInfo);
|
|
41
|
-
setIsError(true);
|
|
42
|
-
console.error("Error while opening the modal", e);
|
|
43
|
-
}
|
|
44
|
-
}, [
|
|
45
|
-
targetInteraction,
|
|
46
|
-
placement,
|
|
47
|
-
sharingLink
|
|
48
|
-
]),
|
|
49
|
-
isError,
|
|
50
|
-
debugInfo
|
|
51
|
-
};
|
|
52
|
-
}
|
|
53
|
-
//#endregion
|
|
54
|
-
export { useShareModal as t };
|