@superwall/runtime 2.0.0 → 2.1.1

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.
@@ -7,6 +7,7 @@ import type { SuperwallNotificationsConfig } from "./notifications";
7
7
  import type { SuperwallPresentationConfig } from "./presentation";
8
8
  import type { SuperwallPostPurchase } from "./postPurchase";
9
9
  import type { SuperwallProductSlotInput } from "./products";
10
+ import type { SuperwallTeleportConfig } from "./teleport";
10
11
  export type SuperwallIntroductoryOfferEligibility = "automatic" | "eligible" | "ineligible";
11
12
  /**
12
13
  * A paywall's contract: product slots, presentation, gating, notifications,
@@ -74,6 +75,13 @@ export type SuperwallConfig<TLocale extends string = string, TStripeReference ex
74
75
  * `{ defaultLocale: "en" }`; file-based catalogs need no config.
75
76
  */
76
77
  localization?: SuperwallLocalizationConfig<TLocale>;
78
+ /**
79
+ * Continue the flow on the web when it is shown in an iOS app, and sell
80
+ * Stripe products there: `true` for every default, or the options to
81
+ * change. Default: off, every route runs in the app. See
82
+ * `SuperwallTeleportOptions`.
83
+ */
84
+ teleport?: SuperwallTeleportConfig<TStripeReference>;
77
85
  /**
78
86
  * Hosts this surface may reach over the network, as bare hostnames —
79
87
  * `["api.example.com"]`. Superwall and Stripe are always reachable;
@@ -91,4 +99,5 @@ export type { SuperwallNotificationsConfig, SuperwallTrialReminderConfig, Superw
91
99
  export { normalizePlatform, SUPERWALL_PLATFORMS, type SuperwallPlatform } from "./platforms";
92
100
  export { dismissesOnPurchase, type SuperwallPostPurchase } from "./postPurchase";
93
101
  export type { SuperwallPresentationConfig, SuperwallPresentationStyle } from "./presentation";
102
+ export { teleportOf, type ResolvedTeleport, type SuperwallTeleportConfig, type SuperwallTeleportOptions, } from "./teleport";
94
103
  export { isPlatformProductIds, productIdFor, type SuperwallPlatformProductIds, type SuperwallProductSlot, type SuperwallProductSlotInput, } from "./products";
@@ -4,4 +4,5 @@ export { checkoutManagedPaymentsOf, checkoutModeOf, checkoutPrefetchOf, } from "
4
4
  export { INSET_EDGES, insetsOf, } from "./insets";
5
5
  export { normalizePlatform, SUPERWALL_PLATFORMS } from "./platforms";
6
6
  export { dismissesOnPurchase } from "./postPurchase";
7
+ export { teleportOf, } from "./teleport";
7
8
  export { isPlatformProductIds, productIdFor, } from "./products";
@@ -0,0 +1,65 @@
1
+ import type { SuperwallIntroductoryOfferEligibility } from "./index";
2
+ /**
3
+ * How teleport behaves: from a route on, a flow shown in an iOS app
4
+ * continues on the web. `router.push(route, { teleport: true })`, a push to
5
+ * `route`, or buying a Stripe product opens the route in the shopper's
6
+ * browser on your project's web paywall domain, with the flow's
7
+ * `useQueryState` values carried along; the shopper pays there with Stripe
8
+ * and is sent back to the app, which is credited automatically. Needs
9
+ * SuperwallKit 4.18.0 or later; on an older SDK the route opens in the app as
10
+ * usual and a Stripe purchase goes to the hosted checkout page.
11
+ */
12
+ export type SuperwallTeleportOptions<TStripeReference extends string = string, TStoreReference extends string = string, TRoute extends string = string> = {
13
+ /**
14
+ * The route the web half opens on by default: a push to it teleports, a
15
+ * Stripe purchase teleports to it, and it is warmed when the paywall
16
+ * opens. Default: none — a Stripe purchase teleports the route it was
17
+ * tapped on, and only `router.push(route, { teleport: true })` teleports a
18
+ * push.
19
+ */
20
+ route?: TRoute;
21
+ /**
22
+ * Show Superwall's teleport screen over the paywall while the shopper is in
23
+ * the browser ("Finish in your browser", reopen, cancel). `false` keeps
24
+ * the paywall as it is, for a flow that leaves midway, or for your own
25
+ * screen drawn from `useTeleport()`. The purchase is watched either way.
26
+ * Default: `true`.
27
+ */
28
+ overlay?: boolean;
29
+ /**
30
+ * A store product the teleport screen offers in place of a Stripe one,
31
+ * keyed by the Stripe product's reference: "Continue In-App Instead" buys
32
+ * it through the store. Shown only once the store has priced it.
33
+ * Default: none.
34
+ */
35
+ fallbacks?: Partial<Record<TStripeReference, TStoreReference>>;
36
+ /**
37
+ * What the web page does once the purchase completes: `"confirmation"`
38
+ * shows "You're all set" with a Return to App button, `"direct"` opens the
39
+ * app at once. Either way the app is opened through its universal link,
40
+ * falling back to its URL scheme when the link doesn't open it.
41
+ * Default: `"confirmation"`.
42
+ */
43
+ completion?: "confirmation" | "direct";
44
+ /**
45
+ * Whether the web checkout offers the trial: `"automatic"` when the app's
46
+ * store says the shopper is eligible, `"eligible"` always, `"ineligible"`
47
+ * never. The App Store's trial history does not bind a Stripe purchase, so
48
+ * this is separate from the paywall's own `introductoryOfferEligibility`.
49
+ * Default: `"automatic"`.
50
+ */
51
+ introductoryOfferEligibility?: SuperwallIntroductoryOfferEligibility;
52
+ };
53
+ /**
54
+ * Turn teleport on: `true` for every default, or the options to change.
55
+ * Default: off.
56
+ */
57
+ export type SuperwallTeleportConfig<TStripeReference extends string = string, TStoreReference extends string = string, TRoute extends string = string> = boolean | SuperwallTeleportOptions<TStripeReference, TStoreReference, TRoute>;
58
+ export type ResolvedTeleport = {
59
+ route?: string;
60
+ overlay: boolean;
61
+ fallbacks: Partial<Record<string, string>>;
62
+ completion: "confirmation" | "direct";
63
+ introductoryOfferEligibility: SuperwallIntroductoryOfferEligibility;
64
+ };
65
+ export declare const teleportOf: (teleport: SuperwallTeleportConfig | undefined) => ResolvedTeleport | undefined;
@@ -0,0 +1,12 @@
1
+ export const teleportOf = (teleport) => {
2
+ if (teleport === undefined || teleport === false)
3
+ return undefined;
4
+ const options = teleport === true ? {} : teleport;
5
+ return {
6
+ ...(options.route === undefined ? {} : { route: options.route }),
7
+ overlay: options.overlay ?? true,
8
+ fallbacks: options.fallbacks ?? {},
9
+ completion: options.completion ?? "confirmation",
10
+ introductoryOfferEligibility: options.introductoryOfferEligibility ?? "automatic",
11
+ };
12
+ };
@@ -1,10 +1,28 @@
1
1
  import { permissionStateName } from "./requests";
2
2
  import { recordFromVariables } from "./variables";
3
+ const PRESENTED_BY = ["placement", "event"];
4
+ const PRESENTATION_SOURCE_TYPES = ["implicit", "getPaywall", "register"];
5
+ const nonEmpty = (value) => value === undefined || value === "" ? undefined : value;
6
+ const presentationOf = (message) => {
7
+ const id = nonEmpty(message.presentation_id);
8
+ const presentedBy = PRESENTED_BY.find((value) => value === message.presented_by);
9
+ const sourceType = PRESENTATION_SOURCE_TYPES.find((value) => value === message.presentation_source_type);
10
+ const eventId = nonEmpty(message.presented_by_event_id);
11
+ const eventName = nonEmpty(message.presented_by_event_name);
12
+ return {
13
+ ...(id === undefined ? {} : { id }),
14
+ ...(presentedBy === undefined ? {} : { presentedBy }),
15
+ ...(sourceType === undefined ? {} : { sourceType }),
16
+ ...(eventId === undefined ? {} : { eventId }),
17
+ ...(eventName === undefined ? {} : { eventName }),
18
+ };
19
+ };
20
+ const withPresentation = (paywall, presentation) => Object.keys(presentation).length === 0 ? paywall : { ...paywall, presentation };
3
21
  export const snapshotPatchFor = (snapshot, message) => {
4
22
  switch (message.event_name) {
5
23
  case "paywall_open":
6
24
  return {
7
- paywall: { id: message.paywall_id, identifier: message.paywall_identifier },
25
+ paywall: withPresentation({ id: message.paywall_id, identifier: message.paywall_identifier }, presentationOf(message)),
8
26
  pendingPurchase: undefined,
9
27
  lastTransaction: undefined,
10
28
  lastPurchaseFailure: undefined,
@@ -18,14 +18,24 @@ const createSession = (options) => {
18
18
  const restores = createRestoreTracker();
19
19
  const requests = createRequestTracker();
20
20
  const derive = createProductDeriver();
21
- let raw = [];
21
+ const inline = options.inlineProducts ?? {};
22
+ let raw = Object.entries(inline).map(([reference, variables]) => {
23
+ const slot = options.config?.products?.[reference];
24
+ return createSuperwallProduct({
25
+ reference,
26
+ productId: slot === undefined ? undefined : productIdFor(slot),
27
+ variables,
28
+ source: "inline",
29
+ });
30
+ });
22
31
  let localeOverride;
23
32
  let translator = createTranslator(options.config?.localization, resolveLocale(undefined, options.config?.localization));
33
+ const seeded = derive(raw, languageCandidates(undefined));
24
34
  let snapshot = {
25
35
  status: "idle",
26
36
  config: options.config,
27
- products: [],
28
- productsByReference: {},
37
+ products: seeded,
38
+ productsByReference: productsByReference(seeded),
29
39
  variables: {},
30
40
  device: {},
31
41
  user: {},
@@ -129,6 +139,11 @@ const createSession = (options) => {
129
139
  break;
130
140
  case "template_variables": {
131
141
  const variables = productVariablesFromTemplateVariables(message.variables);
142
+ for (const [reference, delivered] of variables) {
143
+ const baked = inline[reference];
144
+ if (baked)
145
+ variables.set(reference, { ...baked, ...delivered });
146
+ }
132
147
  if (variables.size > 0)
133
148
  raw = mergeProductVariables(raw, variables);
134
149
  break;
@@ -1,15 +1,23 @@
1
1
  import type { ITransport, TEventTrackingBehavior, TIncomingMessage, TIncomingMessageCallbackResult, TIncomingMessageTransactionAbandon, TIncomingMessageTransactionComplete, TOutgoingMessage, TPermissionStatus, TPermissionTypeMessage, TransportKind } from "@superwall/protocol";
2
- import type { SuperwallConfig, SuperwallPostPurchase } from "../config";
2
+ import type { SuperwallCheckoutMode, SuperwallConfig, SuperwallPostPurchase } from "../config";
3
3
  import type { SuperwallTranslateValues } from "../localization";
4
- import type { SuperwallProduct, SuperwallProductInput } from "../products";
4
+ import type { SuperwallProduct, SuperwallProductInput, SuperwallProductVariables } from "../products";
5
5
  import type { Outgoing, PageViewInput } from "./outgoing";
6
6
  import type { CallbackBehavior } from "./requests";
7
7
  import type { SuperwallCallbackStates, SuperwallPermissionStatuses, SuperwallSdkState } from "./state";
8
8
  import type { SuperwallDeviceVariables, SuperwallExperiment, SuperwallPlacementParams, SuperwallUserVariables } from "./variables";
9
9
  export type SuperwallRuntimeStatus = "idle" | "listening";
10
+ export type SuperwallPresentation = {
11
+ id?: string;
12
+ presentedBy?: "placement" | "event";
13
+ sourceType?: "implicit" | "getPaywall" | "register";
14
+ eventId?: string;
15
+ eventName?: string;
16
+ };
10
17
  export type SuperwallPaywallIdentity = {
11
18
  id: string;
12
19
  identifier: string;
20
+ presentation?: SuperwallPresentation;
13
21
  };
14
22
  export type SuperwallPendingPurchase<out TProduct extends SuperwallProduct = SuperwallProduct> = {
15
23
  reference: string;
@@ -87,6 +95,15 @@ export type SuperwallPurchaseOptions = {
87
95
  * store purchases, which have no Stripe object to write to.
88
96
  */
89
97
  stripeMetadata?: Readonly<Record<string, string>>;
98
+ /**
99
+ * How this purchase checks out on the web when the product is a Stripe
100
+ * product, overriding the config's `checkout` mode for this call — a
101
+ * button that always opens the sheet on a paywall whose default is
102
+ * `"applePay"`. Inside an iOS app a Stripe purchase always opens the
103
+ * hosted checkout whatever this says. Ignored by store purchases.
104
+ * Default: the config's `checkout` mode.
105
+ */
106
+ checkout?: SuperwallCheckoutMode;
90
107
  };
91
108
  export type SuperwallCallbackOptions = {
92
109
  behavior?: CallbackBehavior;
@@ -103,6 +120,7 @@ export type SuperwallSessionStartOptions = {
103
120
  };
104
121
  export type SuperwallSessionOptions = {
105
122
  config?: SuperwallConfig;
123
+ inlineProducts?: Readonly<Record<string, SuperwallProductVariables>>;
106
124
  transport?: ITransport;
107
125
  transportKind?: TransportKind;
108
126
  onDecodeError?: (error: unknown) => void;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@superwall/runtime",
3
- "version": "2.0.0",
3
+ "version": "2.1.1",
4
4
  "description": "Framework-agnostic runtime for headless Superwall paywalls: bridge, session, products, localization, mock host.",
5
5
  "keywords": [
6
6
  "paywall",
@@ -39,7 +39,7 @@
39
39
  "clean": "rm -rf dist coverage"
40
40
  },
41
41
  "dependencies": {
42
- "@superwall/protocol": "2.0.0"
42
+ "@superwall/protocol": "2.1.1"
43
43
  },
44
44
  "devDependencies": {
45
45
  "@superwall/host": "workspace:*",
@@ -7,6 +7,7 @@ import type { SuperwallNotificationsConfig } from "./notifications";
7
7
  import type { SuperwallPresentationConfig } from "./presentation";
8
8
  import type { SuperwallPostPurchase } from "./postPurchase";
9
9
  import type { SuperwallProductSlotInput } from "./products";
10
+ import type { SuperwallTeleportConfig } from "./teleport";
10
11
 
11
12
  export type SuperwallIntroductoryOfferEligibility = "automatic" | "eligible" | "ineligible";
12
13
 
@@ -92,6 +93,14 @@ export type SuperwallConfig<
92
93
  */
93
94
  localization?: SuperwallLocalizationConfig<TLocale>;
94
95
 
96
+ /**
97
+ * Continue the flow on the web when it is shown in an iOS app, and sell
98
+ * Stripe products there: `true` for every default, or the options to
99
+ * change. Default: off, every route runs in the app. See
100
+ * `SuperwallTeleportOptions`.
101
+ */
102
+ teleport?: SuperwallTeleportConfig<TStripeReference>;
103
+
95
104
  /**
96
105
  * Hosts this surface may reach over the network, as bare hostnames —
97
106
  * `["api.example.com"]`. Superwall and Stripe are always reachable;
@@ -140,6 +149,12 @@ export type {
140
149
  export { normalizePlatform, SUPERWALL_PLATFORMS, type SuperwallPlatform } from "./platforms";
141
150
  export { dismissesOnPurchase, type SuperwallPostPurchase } from "./postPurchase";
142
151
  export type { SuperwallPresentationConfig, SuperwallPresentationStyle } from "./presentation";
152
+ export {
153
+ teleportOf,
154
+ type ResolvedTeleport,
155
+ type SuperwallTeleportConfig,
156
+ type SuperwallTeleportOptions,
157
+ } from "./teleport";
143
158
  export {
144
159
  isPlatformProductIds,
145
160
  productIdFor,
@@ -0,0 +1,89 @@
1
+ import type { SuperwallIntroductoryOfferEligibility } from "./index";
2
+
3
+ /**
4
+ * How teleport behaves: from a route on, a flow shown in an iOS app
5
+ * continues on the web. `router.push(route, { teleport: true })`, a push to
6
+ * `route`, or buying a Stripe product opens the route in the shopper's
7
+ * browser on your project's web paywall domain, with the flow's
8
+ * `useQueryState` values carried along; the shopper pays there with Stripe
9
+ * and is sent back to the app, which is credited automatically. Needs
10
+ * SuperwallKit 4.18.0 or later; on an older SDK the route opens in the app as
11
+ * usual and a Stripe purchase goes to the hosted checkout page.
12
+ */
13
+ export type SuperwallTeleportOptions<
14
+ TStripeReference extends string = string,
15
+ TStoreReference extends string = string,
16
+ TRoute extends string = string,
17
+ > = {
18
+ /**
19
+ * The route the web half opens on by default: a push to it teleports, a
20
+ * Stripe purchase teleports to it, and it is warmed when the paywall
21
+ * opens. Default: none — a Stripe purchase teleports the route it was
22
+ * tapped on, and only `router.push(route, { teleport: true })` teleports a
23
+ * push.
24
+ */
25
+ route?: TRoute;
26
+ /**
27
+ * Show Superwall's teleport screen over the paywall while the shopper is in
28
+ * the browser ("Finish in your browser", reopen, cancel). `false` keeps
29
+ * the paywall as it is, for a flow that leaves midway, or for your own
30
+ * screen drawn from `useTeleport()`. The purchase is watched either way.
31
+ * Default: `true`.
32
+ */
33
+ overlay?: boolean;
34
+ /**
35
+ * A store product the teleport screen offers in place of a Stripe one,
36
+ * keyed by the Stripe product's reference: "Continue In-App Instead" buys
37
+ * it through the store. Shown only once the store has priced it.
38
+ * Default: none.
39
+ */
40
+ fallbacks?: Partial<Record<TStripeReference, TStoreReference>>;
41
+ /**
42
+ * What the web page does once the purchase completes: `"confirmation"`
43
+ * shows "You're all set" with a Return to App button, `"direct"` opens the
44
+ * app at once. Either way the app is opened through its universal link,
45
+ * falling back to its URL scheme when the link doesn't open it.
46
+ * Default: `"confirmation"`.
47
+ */
48
+ completion?: "confirmation" | "direct";
49
+ /**
50
+ * Whether the web checkout offers the trial: `"automatic"` when the app's
51
+ * store says the shopper is eligible, `"eligible"` always, `"ineligible"`
52
+ * never. The App Store's trial history does not bind a Stripe purchase, so
53
+ * this is separate from the paywall's own `introductoryOfferEligibility`.
54
+ * Default: `"automatic"`.
55
+ */
56
+ introductoryOfferEligibility?: SuperwallIntroductoryOfferEligibility;
57
+ };
58
+
59
+ /**
60
+ * Turn teleport on: `true` for every default, or the options to change.
61
+ * Default: off.
62
+ */
63
+ export type SuperwallTeleportConfig<
64
+ TStripeReference extends string = string,
65
+ TStoreReference extends string = string,
66
+ TRoute extends string = string,
67
+ > = boolean | SuperwallTeleportOptions<TStripeReference, TStoreReference, TRoute>;
68
+
69
+ export type ResolvedTeleport = {
70
+ route?: string;
71
+ overlay: boolean;
72
+ fallbacks: Partial<Record<string, string>>;
73
+ completion: "confirmation" | "direct";
74
+ introductoryOfferEligibility: SuperwallIntroductoryOfferEligibility;
75
+ };
76
+
77
+ export const teleportOf = (
78
+ teleport: SuperwallTeleportConfig | undefined,
79
+ ): ResolvedTeleport | undefined => {
80
+ if (teleport === undefined || teleport === false) return undefined;
81
+ const options = teleport === true ? {} : teleport;
82
+ return {
83
+ ...(options.route === undefined ? {} : { route: options.route }),
84
+ overlay: options.overlay ?? true,
85
+ fallbacks: options.fallbacks ?? {},
86
+ completion: options.completion ?? "confirmation",
87
+ introductoryOfferEligibility: options.introductoryOfferEligibility ?? "automatic",
88
+ };
89
+ };
@@ -1,8 +1,43 @@
1
1
  import type { TIncomingMessage } from "@superwall/protocol";
2
2
  import { permissionStateName } from "./requests";
3
- import type { SuperwallRuntimeSnapshot } from "./types";
3
+ import type {
4
+ SuperwallPaywallIdentity,
5
+ SuperwallPresentation,
6
+ SuperwallRuntimeSnapshot,
7
+ } from "./types";
4
8
  import { recordFromVariables } from "./variables";
5
9
 
10
+ const PRESENTED_BY = ["placement", "event"] as const;
11
+ const PRESENTATION_SOURCE_TYPES = ["implicit", "getPaywall", "register"] as const;
12
+
13
+ const nonEmpty = (value: string | undefined): string | undefined =>
14
+ value === undefined || value === "" ? undefined : value;
15
+
16
+ const presentationOf = (
17
+ message: Extract<TIncomingMessage, { event_name: "paywall_open" }>,
18
+ ): SuperwallPresentation => {
19
+ const id = nonEmpty(message.presentation_id);
20
+ const presentedBy = PRESENTED_BY.find((value) => value === message.presented_by);
21
+ const sourceType = PRESENTATION_SOURCE_TYPES.find(
22
+ (value) => value === message.presentation_source_type,
23
+ );
24
+ const eventId = nonEmpty(message.presented_by_event_id);
25
+ const eventName = nonEmpty(message.presented_by_event_name);
26
+ return {
27
+ ...(id === undefined ? {} : { id }),
28
+ ...(presentedBy === undefined ? {} : { presentedBy }),
29
+ ...(sourceType === undefined ? {} : { sourceType }),
30
+ ...(eventId === undefined ? {} : { eventId }),
31
+ ...(eventName === undefined ? {} : { eventName }),
32
+ };
33
+ };
34
+
35
+ const withPresentation = (
36
+ paywall: SuperwallPaywallIdentity,
37
+ presentation: SuperwallPresentation,
38
+ ): SuperwallPaywallIdentity =>
39
+ Object.keys(presentation).length === 0 ? paywall : { ...paywall, presentation };
40
+
6
41
  export const snapshotPatchFor = (
7
42
  snapshot: SuperwallRuntimeSnapshot,
8
43
  message: TIncomingMessage,
@@ -10,7 +45,10 @@ export const snapshotPatchFor = (
10
45
  switch (message.event_name) {
11
46
  case "paywall_open":
12
47
  return {
13
- paywall: { id: message.paywall_id, identifier: message.paywall_identifier },
48
+ paywall: withPresentation(
49
+ { id: message.paywall_id, identifier: message.paywall_identifier },
50
+ presentationOf(message),
51
+ ),
14
52
  pendingPurchase: undefined,
15
53
  lastTransaction: undefined,
16
54
  lastPurchaseFailure: undefined,
@@ -54,18 +54,28 @@ const createSession = (options: SuperwallSessionOptions): SuperwallSession => {
54
54
  const requests = createRequestTracker();
55
55
  const derive = createProductDeriver();
56
56
 
57
- let raw: readonly SuperwallProduct[] = [];
57
+ const inline = options.inlineProducts ?? {};
58
+ let raw: readonly SuperwallProduct[] = Object.entries(inline).map(([reference, variables]) => {
59
+ const slot = options.config?.products?.[reference];
60
+ return createSuperwallProduct({
61
+ reference,
62
+ productId: slot === undefined ? undefined : productIdFor(slot),
63
+ variables,
64
+ source: "inline",
65
+ });
66
+ });
58
67
  let localeOverride: string | undefined;
59
68
  let translator = createTranslator(
60
69
  options.config?.localization,
61
70
  resolveLocale(undefined, options.config?.localization),
62
71
  );
72
+ const seeded = derive(raw, languageCandidates(undefined));
63
73
 
64
74
  let snapshot: SuperwallRuntimeSnapshot = {
65
75
  status: "idle",
66
76
  config: options.config,
67
- products: [],
68
- productsByReference: {},
77
+ products: seeded,
78
+ productsByReference: productsByReference(seeded),
69
79
  variables: {},
70
80
  device: {},
71
81
  user: {},
@@ -188,6 +198,10 @@ const createSession = (options: SuperwallSessionOptions): SuperwallSession => {
188
198
  break;
189
199
  case "template_variables": {
190
200
  const variables = productVariablesFromTemplateVariables(message.variables);
201
+ for (const [reference, delivered] of variables) {
202
+ const baked = inline[reference];
203
+ if (baked) variables.set(reference, { ...baked, ...delivered });
204
+ }
191
205
  if (variables.size > 0) raw = mergeProductVariables(raw, variables);
192
206
  break;
193
207
  }
@@ -10,9 +10,13 @@ import type {
10
10
  TPermissionTypeMessage,
11
11
  TransportKind,
12
12
  } from "@superwall/protocol";
13
- import type { SuperwallConfig, SuperwallPostPurchase } from "../config";
13
+ import type { SuperwallCheckoutMode, SuperwallConfig, SuperwallPostPurchase } from "../config";
14
14
  import type { SuperwallTranslateValues } from "../localization";
15
- import type { SuperwallProduct, SuperwallProductInput } from "../products";
15
+ import type {
16
+ SuperwallProduct,
17
+ SuperwallProductInput,
18
+ SuperwallProductVariables,
19
+ } from "../products";
16
20
  import type { Outgoing, PageViewInput } from "./outgoing";
17
21
  import type { CallbackBehavior } from "./requests";
18
22
  import type {
@@ -29,9 +33,18 @@ import type {
29
33
 
30
34
  export type SuperwallRuntimeStatus = "idle" | "listening";
31
35
 
36
+ export type SuperwallPresentation = {
37
+ id?: string;
38
+ presentedBy?: "placement" | "event";
39
+ sourceType?: "implicit" | "getPaywall" | "register";
40
+ eventId?: string;
41
+ eventName?: string;
42
+ };
43
+
32
44
  export type SuperwallPaywallIdentity = {
33
45
  id: string;
34
46
  identifier: string;
47
+ presentation?: SuperwallPresentation;
35
48
  };
36
49
 
37
50
  export type SuperwallPendingPurchase<out TProduct extends SuperwallProduct = SuperwallProduct> = {
@@ -121,6 +134,15 @@ export type SuperwallPurchaseOptions = {
121
134
  * store purchases, which have no Stripe object to write to.
122
135
  */
123
136
  stripeMetadata?: Readonly<Record<string, string>>;
137
+ /**
138
+ * How this purchase checks out on the web when the product is a Stripe
139
+ * product, overriding the config's `checkout` mode for this call — a
140
+ * button that always opens the sheet on a paywall whose default is
141
+ * `"applePay"`. Inside an iOS app a Stripe purchase always opens the
142
+ * hosted checkout whatever this says. Ignored by store purchases.
143
+ * Default: the config's `checkout` mode.
144
+ */
145
+ checkout?: SuperwallCheckoutMode;
124
146
  };
125
147
 
126
148
  export type SuperwallCallbackOptions = {
@@ -142,6 +164,7 @@ export type SuperwallSessionStartOptions = {
142
164
 
143
165
  export type SuperwallSessionOptions = {
144
166
  config?: SuperwallConfig;
167
+ inlineProducts?: Readonly<Record<string, SuperwallProductVariables>>;
145
168
  transport?: ITransport;
146
169
  transportKind?: TransportKind;
147
170
  onDecodeError?: (error: unknown) => void;