@revenuecat/purchases-ui-js 4.8.10 → 4.8.11

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,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.11",
6
6
  "author": {
7
7
  "name": "RevenueCat, Inc."
8
8
  },