@revenuecat/purchases-ui-js 4.8.10 → 4.8.12

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.
@@ -19,7 +19,13 @@
19
19
  const { stack, package_id, is_selected_by_default, name }: PackageProps =
20
20
  $props();
21
21
 
22
- setPackageIdContext(package_id);
22
+ // Expose the current package_id via a store so descendants stay in sync
23
+ // when this component is reused across tab switches
24
+ const packageIdStore = writable(package_id);
25
+ $effect(() => {
26
+ packageIdStore.set(package_id);
27
+ });
28
+ setPackageIdContext(packageIdStore);
23
29
 
24
30
  const {
25
31
  defaultPackageId,
@@ -5,6 +5,7 @@
5
5
  import { getPaywallContext } from "../../stores/paywall";
6
6
  import type { PurchaseButtonProps } from "../../types/components/purchase-button";
7
7
  import type { PurchaseButtonInteractionData } from "../../types/paywall-component-interaction";
8
+ import { get } from "svelte/store";
8
9
 
9
10
  const props: PurchaseButtonProps = $props();
10
11
  const { stack } = props;
@@ -68,7 +69,9 @@
68
69
  };
69
70
 
70
71
  const onclick = () => {
71
- const packageId = enclosingPackageId ?? $selectedPackageId;
72
+ const packageId =
73
+ (enclosingPackageId ? get(enclosingPackageId) : undefined) ??
74
+ $selectedPackageId;
72
75
  if (packageId !== undefined) {
73
76
  // Sync before purchasing so onPurchase reads this package, not a stale one.
74
77
  $selectedPackageId = packageId;
@@ -1,7 +1,14 @@
1
1
  <script module lang="ts">
2
2
  import WebView from "./WebView.svelte";
3
3
  import { componentDecorator } from "../../stories/component-decorator";
4
+ import type { WebViewProps } from "../../types/components/web-view";
4
5
  import { defineMeta } from "@storybook/addon-svelte-csf";
6
+ import type { ComponentProps } from "svelte";
7
+
8
+ // Cross-origin SVG (jsDelivr allows framing; no opaque page chrome). Parent
9
+ // checkerboard shows through and proves the host iframe is transparent.
10
+ const TRANSPARENT_CONTENT_URL =
11
+ "https://cdn.jsdelivr.net/gh/twitter/twemoji@14.0.2/assets/svg/2705.svg";
5
12
 
6
13
  const { Story } = defineMeta({
7
14
  title: "Components/WebView",
@@ -23,12 +30,36 @@
23
30
  width: { type: "fill" },
24
31
  height: { type: "fixed", value: 400 },
25
32
  },
26
- },
33
+ } satisfies WebViewProps,
27
34
  });
28
35
  </script>
29
36
 
37
+ {#snippet transparencyTemplate(props: ComponentProps<typeof WebView>)}
38
+ <div class="transparency-showcase">
39
+ <p class="transparency-showcase__caption">
40
+ Checkerboard behind the iframe — the parent should show through
41
+ transparent content (and around letterboxed SVG).
42
+ </p>
43
+ <div class="transparency-showcase__stage">
44
+ <WebView {...props} />
45
+ </div>
46
+ </div>
47
+ {/snippet}
48
+
30
49
  <Story name="Default" />
31
50
 
51
+ <Story
52
+ name="Transparent background"
53
+ args={{
54
+ url: TRANSPARENT_CONTENT_URL,
55
+ size: {
56
+ width: { type: "fixed", value: 320 },
57
+ height: { type: "fixed", value: 320 },
58
+ },
59
+ }}
60
+ template={transparencyTemplate}
61
+ />
62
+
32
63
  <Story
33
64
  name="Fill (full bleed)"
34
65
  args={{
@@ -103,3 +134,43 @@
103
134
  url: "http://insecure.example.com",
104
135
  }}
105
136
  />
137
+
138
+ <style>
139
+ .transparency-showcase {
140
+ display: flex;
141
+ flex-direction: column;
142
+ gap: 12px;
143
+ padding: 16px;
144
+ max-width: 640px;
145
+ }
146
+
147
+ .transparency-showcase__caption {
148
+ margin: 0;
149
+ font:
150
+ 14px/1.4 ui-sans-serif,
151
+ system-ui,
152
+ sans-serif;
153
+ color: #334155;
154
+ }
155
+
156
+ .transparency-showcase__stage {
157
+ display: flex;
158
+ align-items: center;
159
+ justify-content: center;
160
+ padding: 24px;
161
+ /* High-contrast checkerboard so iframe transparency is obvious. */
162
+ background-color: #cbd5e1;
163
+ background-image:
164
+ linear-gradient(45deg, #64748b 25%, transparent 25%),
165
+ linear-gradient(-45deg, #64748b 25%, transparent 25%),
166
+ linear-gradient(45deg, transparent 75%, #64748b 75%),
167
+ linear-gradient(-45deg, transparent 75%, #64748b 75%);
168
+ background-size: 24px 24px;
169
+ background-position:
170
+ 0 0,
171
+ 0 12px,
172
+ 12px -12px,
173
+ -12px 0;
174
+ border-radius: 8px;
175
+ }
176
+ </style>
@@ -175,6 +175,9 @@
175
175
  .web-view {
176
176
  position: relative;
177
177
  overflow: hidden;
178
+ background: transparent;
179
+ /* Match content's dual scheme so the UA keeps a transparent iframe canvas. */
180
+ color-scheme: light dark;
178
181
  }
179
182
 
180
183
  iframe {
@@ -182,5 +185,7 @@
182
185
  width: 100%;
183
186
  height: 100%;
184
187
  border: 0;
188
+ background: transparent;
189
+ color-scheme: light dark;
185
190
  }
186
191
  </style>
@@ -1,2 +1,3 @@
1
- export declare function setPackageIdContext(packageId: string): void;
2
- export declare function getOptionalPackageIdContext(): string | undefined;
1
+ import type { Readable } from "svelte/store";
2
+ export declare function setPackageIdContext(packageId: Readable<string>): void;
3
+ export declare function getOptionalPackageIdContext(): Readable<string> | undefined;
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@revenuecat/purchases-ui-js",
3
3
  "description": "Web components for Paywalls. Powered by RevenueCat",
4
4
  "private": false,
5
- "version": "4.8.10",
5
+ "version": "4.8.12",
6
6
  "author": {
7
7
  "name": "RevenueCat, Inc."
8
8
  },