@frak-labs/components 1.0.3 → 1.0.4-beta.f27f8229

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 (42) hide show
  1. package/cdn/Banner.CIxY6tCU.js +178 -0
  2. package/cdn/{ButtonShare.FHUOd26e.js → ButtonShare.DNELNwqD.js} +1 -1
  3. package/cdn/{ButtonWallet.CN2iHSTB.js → ButtonWallet.BUUPX0gO.js} +1 -1
  4. package/cdn/GiftIcon.eRNTGQ_r.js +1 -0
  5. package/cdn/OpenInAppButton.Dgb-qhM8.js +1 -0
  6. package/cdn/PostPurchase.C3IH-LUy.js +89 -0
  7. package/cdn/components.js +1 -1
  8. package/cdn/formatReward.B1ZyoceC.js +1 -0
  9. package/cdn/loader.js +154 -14
  10. package/cdn/replay-V6FXES7X.CNozpSRg.js +1 -0
  11. package/cdn/sharingPage.Dt8QZhlR.js +1 -0
  12. package/cdn/useGlobalComponents.TG9kIYSc.js +1 -0
  13. package/cdn/useLightDomStyles.tjNBKcOr.js +1 -0
  14. package/cdn/usePlacement.BgMXY5CX.js +58 -0
  15. package/cdn/useReward.B530suzR.js +1 -0
  16. package/dist/GiftIcon-BIp9FTJs.js +338 -0
  17. package/dist/banner.d.ts +25 -1
  18. package/dist/banner.js +77 -45
  19. package/dist/buttonShare.js +6 -6
  20. package/dist/buttonWallet.js +2 -2
  21. package/dist/{formatReward-Bub6Z6eY.js → formatReward-Cf2KpA3x.js} +1 -1
  22. package/dist/openInApp.js +9 -26
  23. package/dist/postPurchase.d.ts +9 -1
  24. package/dist/postPurchase.js +93 -1382
  25. package/dist/{sharingPage-DFvQbviS.js → sharingPage-D6fQEXV9.js} +1 -1
  26. package/dist/useLightDomStyles-DVe5UDg6.js +48 -0
  27. package/dist/{usePlacement-V7NrKoub.js → usePlacement-DzEuVg_u.js} +7 -7
  28. package/dist/{useReward-DU3_yP8Q.js → useReward-ClVShg45.js} +1 -1
  29. package/package.json +4 -4
  30. package/cdn/Banner.BTj-CQM6.js +0 -162
  31. package/cdn/OpenInAppButton.C1Yipwka.js +0 -1
  32. package/cdn/PostPurchase.u0s94KFf.js +0 -52
  33. package/cdn/formatReward.C7mU9_cV.js +0 -1
  34. package/cdn/sharingPage.CvUkxEML.js +0 -1
  35. package/cdn/sprinkles.css.ts.vanilla.06k5OzG1.js +0 -1175
  36. package/cdn/useGlobalComponents.UJmjUUxk.js +0 -1
  37. package/cdn/useLightDomStyles.Gt7YUMDl.js +0 -1
  38. package/cdn/usePlacement.BJ7qe-pw.js +0 -58
  39. package/cdn/useReward.QsQc2c1D.js +0 -1
  40. package/dist/GiftIcon-c28NnqJ7.js +0 -1502
  41. package/dist/useLightDomStyles-gbuSWvRx.js +0 -89
  42. /package/dist/{useGlobalComponents-Cmfszr7v.js → useGlobalComponents-mSs9unyN.js} +0 -0
@@ -1,89 +0,0 @@
1
- import { r as lightDomBaseCss } from "./usePlacement-V7NrKoub.js";
2
- import { useEffect } from "preact/hooks";
3
- //#region src/utils/styleManager.ts
4
- /**
5
- * Tracks every base CSS rule (by exact cssText) already injected into <head>.
6
- *
7
- * Each Light DOM component (frak-banner, frak-post-purchase, …) ships a
8
- * `cssSource` string that contains both component-specific rules AND shared
9
- * design-system rules (reset, sprinkles, theme tokens) pulled in transitively
10
- * by vanilla-extract. Without dedup, every component re-emits the same reset
11
- * class definitions in its own <style> tag, and whichever stylesheet is
12
- * appended LAST wins for those shared selectors — flipping the cascade order
13
- * non-deterministically across mount orders.
14
- *
15
- * Deduplicating rule-by-rule guarantees that shared rules appear exactly once
16
- * (in the first component's stylesheet) and component-specific rules always
17
- * come AFTER them in document order, so component styles win deterministically.
18
- */
19
- const injectedRules = /* @__PURE__ */ new Set();
20
- function ensureStyle(id, css) {
21
- const existing = document.getElementById(id);
22
- if (existing) {
23
- if (existing.textContent !== css) existing.textContent = css;
24
- return;
25
- }
26
- const style = document.createElement("style");
27
- style.id = id;
28
- style.textContent = css;
29
- document.head.appendChild(style);
30
- }
31
- /**
32
- * Parses `css` and returns a new string containing only rules that have not
33
- * already been injected into <head>. Tracks injected rules in `injectedRules`.
34
- *
35
- * Falls back to the raw input if the browser lacks the constructable
36
- * `CSSStyleSheet` API or parsing fails — preserves correctness over dedup.
37
- */
38
- function dedupeAgainstInjected(css) {
39
- if (typeof CSSStyleSheet !== "function") return css;
40
- let sheet;
41
- try {
42
- sheet = new CSSStyleSheet();
43
- sheet.replaceSync(css);
44
- } catch {
45
- return css;
46
- }
47
- let out = "";
48
- for (let i = 0; i < sheet.cssRules.length; i++) {
49
- const ruleText = sheet.cssRules[i].cssText;
50
- if (injectedRules.has(ruleText)) continue;
51
- injectedRules.add(ruleText);
52
- out += `${ruleText}\n`;
53
- }
54
- return out;
55
- }
56
- function injectBase(tag, css) {
57
- const id = `frak-base-${tag}`;
58
- if (document.getElementById(id)) return;
59
- const deduped = dedupeAgainstInjected(css);
60
- if (!deduped) return;
61
- const style = document.createElement("style");
62
- style.id = id;
63
- style.textContent = deduped;
64
- document.head.appendChild(style);
65
- }
66
- function injectPlacement(tag, placementId, scopedCss) {
67
- ensureStyle(`frak-placement-${tag}-${placementId}`, scopedCss);
68
- }
69
- const styleManager = {
70
- injectBase,
71
- injectPlacement
72
- };
73
- //#endregion
74
- //#region src/hooks/useLightDomStyles.ts
75
- function useLightDomStyles(tag, placementId, placementCss, baseCss) {
76
- useEffect(() => {
77
- styleManager.injectBase(tag, baseCss ?? lightDomBaseCss);
78
- }, [tag]);
79
- useEffect(() => {
80
- if (!placementId || !placementCss) return;
81
- styleManager.injectPlacement(tag, placementId, placementCss);
82
- }, [
83
- tag,
84
- placementId,
85
- placementCss
86
- ]);
87
- }
88
- //#endregion
89
- export { useLightDomStyles as t };