@rocapine/react-native-onboarding 1.75.0 → 1.77.0
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/README.md +30 -4
- package/dist/OnboardingStudioClient.d.ts +18 -0
- package/dist/OnboardingStudioClient.d.ts.map +1 -1
- package/dist/OnboardingStudioClient.js +44 -17
- package/dist/OnboardingStudioClient.js.map +1 -1
- package/dist/index.d.ts +5 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +16 -2
- package/dist/index.js.map +1 -1
- package/dist/onboarding-example.d.ts +140 -0
- package/dist/onboarding-example.d.ts.map +1 -1
- package/dist/onboarding-example.js +41 -1
- package/dist/onboarding-example.js.map +1 -1
- package/dist/paywalls/PaywallProvider.d.ts +71 -5
- package/dist/paywalls/PaywallProvider.d.ts.map +1 -1
- package/dist/paywalls/PaywallProvider.js +237 -57
- package/dist/paywalls/PaywallProvider.js.map +1 -1
- package/dist/paywalls/customScreens.d.ts +31 -0
- package/dist/paywalls/customScreens.d.ts.map +1 -1
- package/dist/paywalls/observer.d.ts +129 -0
- package/dist/paywalls/observer.d.ts.map +1 -0
- package/dist/paywalls/observer.js +211 -0
- package/dist/paywalls/observer.js.map +1 -0
- package/dist/paywalls/present.d.ts +19 -15
- package/dist/paywalls/present.d.ts.map +1 -1
- package/dist/paywalls/present.js +21 -17
- package/dist/paywalls/present.js.map +1 -1
- package/dist/paywalls/types.d.ts +3 -1
- package/dist/paywalls/types.d.ts.map +1 -1
- package/dist/products/adapters/expoIap.d.ts +38 -1
- package/dist/products/adapters/expoIap.d.ts.map +1 -1
- package/dist/products/adapters/expoIap.js +509 -75
- package/dist/products/adapters/expoIap.js.map +1 -1
- package/dist/products/index.d.ts +1 -0
- package/dist/products/index.d.ts.map +1 -1
- package/dist/products/index.js.map +1 -1
- package/dist/products/types.d.ts +13 -0
- package/dist/products/types.d.ts.map +1 -1
- package/dist/requestIdentity.d.ts +41 -0
- package/dist/requestIdentity.d.ts.map +1 -0
- package/dist/requestIdentity.js +70 -0
- package/dist/requestIdentity.js.map +1 -0
- package/dist/screens/completingActions.d.ts +55 -3
- package/dist/screens/completingActions.d.ts.map +1 -1
- package/dist/screens/completingActions.js +209 -15
- package/dist/screens/completingActions.js.map +1 -1
- package/dist/screens/elementTypeRegistry.d.ts +14 -0
- package/dist/screens/elementTypeRegistry.d.ts.map +1 -1
- package/dist/screens/elementTypeRegistry.js +38 -1
- package/dist/screens/elementTypeRegistry.js.map +1 -1
- package/dist/screens/elements/ButtonElement.d.ts +3 -2
- package/dist/screens/elements/ButtonElement.d.ts.map +1 -1
- package/dist/screens/elements/ButtonElement.js +5 -1
- package/dist/screens/elements/ButtonElement.js.map +1 -1
- package/dist/screens/types.d.ts +2 -2
- package/dist/screens/types.d.ts.map +1 -1
- package/dist/screens/types.js +5 -1
- package/dist/screens/types.js.map +1 -1
- package/dist/screens/unknownKeys.d.ts +25 -4
- package/dist/screens/unknownKeys.d.ts.map +1 -1
- package/dist/screens/unknownKeys.js +81 -2
- package/dist/screens/unknownKeys.js.map +1 -1
- package/dist/steps/common.types.d.ts +178 -6
- package/dist/steps/common.types.d.ts.map +1 -1
- package/dist/steps/common.types.js +64 -3
- package/dist/steps/common.types.js.map +1 -1
- package/dist/types.d.ts +17 -0
- package/dist/types.d.ts.map +1 -1
- package/dist/userProperties/reserved.d.ts +16 -15
- package/dist/userProperties/reserved.d.ts.map +1 -1
- package/dist/userProperties/reserved.js +18 -14
- package/dist/userProperties/reserved.js.map +1 -1
- package/dist/version.d.ts +10 -0
- package/dist/version.d.ts.map +1 -0
- package/dist/version.js +13 -0
- package/dist/version.js.map +1 -0
- package/package.json +5 -1
- package/src/OnboardingStudioClient.ts +47 -19
- package/src/__tests__/authoringDocEscapes.test.ts +59 -0
- package/src/__tests__/completingActions.test.ts +371 -1
- package/src/__tests__/customActionHooks.test.ts +224 -0
- package/src/__tests__/getOnboarding.query.test.ts +30 -0
- package/src/__tests__/onboardingExampleElements.test.ts +47 -0
- package/src/__tests__/requestIdentity.client.test.ts +115 -0
- package/src/__tests__/requestIdentity.test.ts +112 -0
- package/src/__tests__/requestPermissionAction.test.ts +138 -0
- package/src/__tests__/retryIdempotencyDocs.test.ts +57 -0
- package/src/__tests__/unknownKeys.test.ts +110 -0
- package/src/index.ts +33 -1
- package/src/onboarding-example.ts +41 -1
- package/src/paywalls/PaywallProvider.tsx +370 -66
- package/src/paywalls/__tests__/PaywallProvider.observer.test.tsx +866 -0
- package/src/paywalls/__tests__/getPaywalls.test.ts +30 -0
- package/src/paywalls/__tests__/observer.test.ts +401 -0
- package/src/paywalls/__tests__/present.test.ts +0 -18
- package/src/paywalls/customScreens.ts +34 -1
- package/src/paywalls/observer.ts +308 -0
- package/src/paywalls/present.ts +24 -18
- package/src/paywalls/types.ts +3 -1
- package/src/products/adapters/__tests__/expoIap.contract.test.ts +648 -0
- package/src/products/adapters/__tests__/expoIap.test.ts +25 -11
- package/src/products/adapters/__tests__/expoIap5Fake.ts +288 -0
- package/src/products/adapters/expoIap.ts +609 -78
- package/src/products/index.ts +1 -0
- package/src/products/types.ts +13 -0
- package/src/requestIdentity.ts +101 -0
- package/src/screens/completingActions.ts +223 -15
- package/src/screens/elementTypeRegistry.ts +34 -0
- package/src/screens/elements/ButtonElement.ts +9 -1
- package/src/screens/types.ts +2 -2
- package/src/screens/unknownKeys.ts +113 -7
- package/src/steps/common.types.ts +213 -6
- package/src/types.ts +17 -0
- package/src/userProperties/__tests__/effectiveParams.test.ts +2 -2
- package/src/userProperties/__tests__/primitives.test.ts +1 -1
- package/src/userProperties/reserved.ts +18 -14
- package/src/version.ts +9 -0
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
import type { PresentResult } from "./types";
|
|
2
|
+
export type PaywallSurface = "present" | "paywall_step";
|
|
3
|
+
export interface PaywallPresentationInfo {
|
|
4
|
+
moment: string;
|
|
5
|
+
paywallId: string;
|
|
6
|
+
audienceId: string | null;
|
|
7
|
+
renderMode: "elements" | "custom";
|
|
8
|
+
billing: "store" | "stripe";
|
|
9
|
+
surface: PaywallSurface;
|
|
10
|
+
variantKey?: string;
|
|
11
|
+
deploymentId?: string;
|
|
12
|
+
onboardingRun?: {
|
|
13
|
+
runId: string;
|
|
14
|
+
stepKey: string;
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
export interface PaywallTransactionInfo {
|
|
18
|
+
/** The exact value the app passes to Rocalytics' `purchase` call: iOS StoreKit original transaction id (iOS join key); Android Play order id (GPA.…). */
|
|
19
|
+
originalTransactionIdentifier?: string;
|
|
20
|
+
/** Android only: the Play purchase token (RevenueCat `transaction.purchaseToken`). Android join key. */
|
|
21
|
+
purchaseToken?: string;
|
|
22
|
+
productId?: string;
|
|
23
|
+
/** True when the purchase only restored existing access. Not a conversion. */
|
|
24
|
+
restored?: boolean;
|
|
25
|
+
}
|
|
26
|
+
export interface PaywallPresentationEnd {
|
|
27
|
+
status: "purchased" | "dismissed" | "cancelled" | "error";
|
|
28
|
+
/** The host SDK's error reason; accepted as any string. */
|
|
29
|
+
reason?: string;
|
|
30
|
+
transaction?: PaywallTransactionInfo;
|
|
31
|
+
}
|
|
32
|
+
export interface PaywallPresentationHandle {
|
|
33
|
+
shown(): void;
|
|
34
|
+
end(outcome: PaywallPresentationEnd): void;
|
|
35
|
+
}
|
|
36
|
+
export interface PaywallObserver {
|
|
37
|
+
start(info: PaywallPresentationInfo): PaywallPresentationHandle | void;
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* The fields of a catalog `Paywall` a presentation report needs. Structural
|
|
41
|
+
* and lenient (`billing`/`products` optional, `renderMode` nullable) because
|
|
42
|
+
* the inline step reads the catalog as open wire data.
|
|
43
|
+
*/
|
|
44
|
+
export type PaywallPresentationSource = {
|
|
45
|
+
id: string;
|
|
46
|
+
moment: string;
|
|
47
|
+
audienceId?: number | null;
|
|
48
|
+
billing?: "store" | "stripe";
|
|
49
|
+
renderMode?: "elements" | "custom" | null;
|
|
50
|
+
products?: ReadonlyArray<{
|
|
51
|
+
key: string;
|
|
52
|
+
ios?: string;
|
|
53
|
+
android?: string;
|
|
54
|
+
}>;
|
|
55
|
+
};
|
|
56
|
+
/**
|
|
57
|
+
* What a surface holds for one presentation. Never throws, whatever the
|
|
58
|
+
* observer does: `shown()` reaches the observer at most once and never after
|
|
59
|
+
* `end()`; `end()` reaches it exactly once.
|
|
60
|
+
*
|
|
61
|
+
* `end` takes the SDK's own `PresentResult` plus the product key a purchase
|
|
62
|
+
* went through, and builds the observer's `PaywallPresentationEnd` itself — so
|
|
63
|
+
* the transaction rules (only with `purchased`, `productId` from the slot for
|
|
64
|
+
* the running platform) live here and not in each surface.
|
|
65
|
+
*
|
|
66
|
+
* `purchasedFrom` is the paywall the purchase was made ON, when that is not the
|
|
67
|
+
* one the presentation started with: a variant swap keeps one presentation open
|
|
68
|
+
* (credited to the variant shown first), but the bought slot's store id is the
|
|
69
|
+
* swapped-in variant's, and that id is what joins to revenue. Omitted, the
|
|
70
|
+
* started paywall is used.
|
|
71
|
+
*
|
|
72
|
+
* `reportedTransaction` is the `transaction` a custom paywall screen passed to
|
|
73
|
+
* `complete()` (#287). Typed `unknown` because it arrives from host code and is
|
|
74
|
+
* sanitized here (`sanitizePaywallTransaction`), the one place both surfaces
|
|
75
|
+
* share. The caller passes it only when the screen itself reported
|
|
76
|
+
* `purchased`; `buildPresentationEnd` documents how it meets a recorded
|
|
77
|
+
* purchase.
|
|
78
|
+
*/
|
|
79
|
+
export type PaywallPresentation = {
|
|
80
|
+
shown(): void;
|
|
81
|
+
end(result: Pick<PresentResult, "status" | "reason">, purchasedProductKey?: string | null, purchasedFrom?: PaywallPresentationSource | null, reportedTransaction?: unknown): void;
|
|
82
|
+
};
|
|
83
|
+
export declare const NOOP_PAYWALL_PRESENTATION: PaywallPresentation;
|
|
84
|
+
export declare const buildPresentationInfo: (paywall: PaywallPresentationSource, surface: PaywallSurface) => PaywallPresentationInfo;
|
|
85
|
+
/**
|
|
86
|
+
* A custom screen's `complete({ transaction })`, reduced to the contract: the
|
|
87
|
+
* three ids only when they are non-empty strings, `restored` only when it is
|
|
88
|
+
* exactly `true`, every other field dropped. `undefined` when the input is not
|
|
89
|
+
* a plain object or nothing survives, so the end carries no `transaction` at
|
|
90
|
+
* all, exactly as when none was passed.
|
|
91
|
+
*
|
|
92
|
+
* Never throws: the value is host data, and a throwing getter or a revoked
|
|
93
|
+
* `Proxy` (on which even `Array.isArray` throws) must cost only the
|
|
94
|
+
* transaction, never the end of the presentation it rides on.
|
|
95
|
+
*/
|
|
96
|
+
export declare const sanitizePaywallTransaction: (value: unknown) => PaywallTransactionInfo | undefined;
|
|
97
|
+
/**
|
|
98
|
+
* The end the observer receives.
|
|
99
|
+
*
|
|
100
|
+
* A transaction only ever accompanies a `purchased` end (contract rule P8).
|
|
101
|
+
* Its sources:
|
|
102
|
+
* - a purchase the SDK recorded (`purchasedProductKey`): `productId` from that
|
|
103
|
+
* slot for the running platform;
|
|
104
|
+
* - a custom screen's reported transaction (#287), sanitized.
|
|
105
|
+
*
|
|
106
|
+
* With no recorded purchase, the reported transaction is sent as it is.
|
|
107
|
+
*
|
|
108
|
+
* When a purchase IS recorded, the recorded purchase wins: the "first settled
|
|
109
|
+
* purchase sticks" rule `resolveEndedOutcome` applies to the outcome. The
|
|
110
|
+
* reported ids are added to it only when they provably describe it, i.e. the
|
|
111
|
+
* reported `productId` is present and equals the recorded slot's store id for
|
|
112
|
+
* this platform. `restored` is never added: the SDK's own purchase is a
|
|
113
|
+
* purchase, and a screen's flag must not relabel it. In every other case (an
|
|
114
|
+
* absent or different reported `productId`, or a recorded slot with no store
|
|
115
|
+
* id on this platform) the reported ids are dropped with a warning, and the
|
|
116
|
+
* end carries the recorded purchase's transaction alone (`{ productId }`, or
|
|
117
|
+
* none when its slot names nothing here). Pairing one purchase's transaction
|
|
118
|
+
* id with another's `productId` would corrupt the revenue join.
|
|
119
|
+
*/
|
|
120
|
+
export declare const buildPresentationEnd: (paywall: PaywallPresentationSource, result: Pick<PresentResult, "status" | "reason">, purchasedProductKey: string | null | undefined, platform: string, reportedTransaction?: unknown) => PaywallPresentationEnd;
|
|
121
|
+
/**
|
|
122
|
+
* Opens one observed presentation: calls `observer.start` now and returns the
|
|
123
|
+
* guarded handle. With no observer (or a malformed one) every call is a no-op.
|
|
124
|
+
*
|
|
125
|
+
* `platform` is `Platform.OS`, passed in rather than imported so this module
|
|
126
|
+
* stays testable without a react-native stub.
|
|
127
|
+
*/
|
|
128
|
+
export declare const openPaywallPresentation: (observer: PaywallObserver | undefined | null, paywall: PaywallPresentationSource, surface: PaywallSurface, platform: string) => PaywallPresentation;
|
|
129
|
+
//# sourceMappingURL=observer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"observer.d.ts","sourceRoot":"","sources":["../../src/paywalls/observer.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAU7C,MAAM,MAAM,cAAc,GAAG,SAAS,GAAG,cAAc,CAAC;AAExD,MAAM,WAAW,uBAAuB;IACtC,MAAM,EAAE,MAAM,CAAC;IACf,SAAS,EAAE,MAAM,CAAC;IAClB,UAAU,EAAE,MAAM,GAAG,IAAI,CAAC;IAC1B,UAAU,EAAE,UAAU,GAAG,QAAQ,CAAC;IAClC,OAAO,EAAE,OAAO,GAAG,QAAQ,CAAC;IAC5B,OAAO,EAAE,cAAc,CAAC;IACxB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,aAAa,CAAC,EAAE;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,CAAA;KAAE,CAAC;CACpD;AAED,MAAM,WAAW,sBAAsB;IACrC,yJAAyJ;IACzJ,6BAA6B,CAAC,EAAE,MAAM,CAAC;IACvC,wGAAwG;IACxG,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,SAAS,CAAC,EAAE,MAAM,CAA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AAC;AAEF,eAAO,MAAM,yBAAyB,EAAE,mBAGtC,CAAC;AA6BH,eAAO,MAAM,qBAAqB,GAChC,SAAS,yBAAyB,EAClC,SAAS,cAAc,KACtB,uBASD,CAAC;AAsBH;;;;;;;;;;GAUG;AACH,eAAO,MAAM,0BAA0B,GAAI,OAAO,OAAO,KAAG,sBAAsB,GAAG,SAOpF,CAAC;AAeF;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,eAAO,MAAM,oBAAoB,GAC/B,SAAS,yBAAyB,EAClC,QAAQ,IAAI,CAAC,aAAa,EAAE,QAAQ,GAAG,QAAQ,CAAC,EAChD,qBAAqB,MAAM,GAAG,IAAI,GAAG,SAAS,EAC9C,UAAU,MAAM,EAChB,sBAAsB,OAAO,KAC5B,sBA8BF,CAAC;AAEF;;;;;;GAMG;AACH,eAAO,MAAM,uBAAuB,GAClC,UAAU,eAAe,GAAG,SAAS,GAAG,IAAI,EAC5C,SAAS,yBAAyB,EAClC,SAAS,cAAc,EACvB,UAAU,MAAM,KACf,mBAiCF,CAAC"}
|
|
@@ -0,0 +1,211 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
3
|
+
var t = {};
|
|
4
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
5
|
+
t[p] = s[p];
|
|
6
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
7
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
8
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
9
|
+
t[p[i]] = s[p[i]];
|
|
10
|
+
}
|
|
11
|
+
return t;
|
|
12
|
+
};
|
|
13
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
14
|
+
exports.openPaywallPresentation = exports.buildPresentationEnd = exports.sanitizePaywallTransaction = exports.buildPresentationInfo = exports.NOOP_PAYWALL_PRESENTATION = void 0;
|
|
15
|
+
exports.NOOP_PAYWALL_PRESENTATION = Object.freeze({
|
|
16
|
+
shown: () => { },
|
|
17
|
+
end: () => { },
|
|
18
|
+
});
|
|
19
|
+
const warn = (what, error) => console.warn(`[paywalls] PaywallObserver.${what} threw; ignored so the paywall is unaffected:`, error);
|
|
20
|
+
/**
|
|
21
|
+
* Calls `fn`, swallowing a synchronous throw AND a rejected promise. An
|
|
22
|
+
* observer typed `void` can still be `async`, and its rejection would otherwise
|
|
23
|
+
* surface as an unhandled rejection in the host app.
|
|
24
|
+
*/
|
|
25
|
+
const guarded = (what, fn) => {
|
|
26
|
+
try {
|
|
27
|
+
const value = fn();
|
|
28
|
+
if (value && typeof value.then === "function") {
|
|
29
|
+
Promise.resolve(value).catch((error) => warn(what, error));
|
|
30
|
+
}
|
|
31
|
+
return value;
|
|
32
|
+
}
|
|
33
|
+
catch (error) {
|
|
34
|
+
warn(what, error);
|
|
35
|
+
return undefined;
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
const isHandle = (value) => typeof value === "object" &&
|
|
39
|
+
value !== null &&
|
|
40
|
+
typeof value.shown === "function" &&
|
|
41
|
+
typeof value.end === "function";
|
|
42
|
+
const buildPresentationInfo = (paywall, surface) => ({
|
|
43
|
+
moment: paywall.moment,
|
|
44
|
+
paywallId: paywall.id,
|
|
45
|
+
// The catalog carries a numeric id; the contract is a string.
|
|
46
|
+
audienceId: paywall.audienceId == null ? null : String(paywall.audienceId),
|
|
47
|
+
// Absent means "elements" — see `Paywall.renderMode`.
|
|
48
|
+
renderMode: paywall.renderMode === "custom" ? "custom" : "elements",
|
|
49
|
+
billing: paywall.billing === "stripe" ? "stripe" : "store",
|
|
50
|
+
surface,
|
|
51
|
+
});
|
|
52
|
+
exports.buildPresentationInfo = buildPresentationInfo;
|
|
53
|
+
/**
|
|
54
|
+
* `productId` is the store id of the purchased slot on the RUNNING platform.
|
|
55
|
+
* Undefined when nothing resolves (unknown key, a slot with no id for this
|
|
56
|
+
* platform, web), in which case the caller sends no `transaction` at all.
|
|
57
|
+
*/
|
|
58
|
+
const resolveProductId = (paywall, key, platform) => {
|
|
59
|
+
var _a;
|
|
60
|
+
if (!key)
|
|
61
|
+
return undefined;
|
|
62
|
+
const slot = (_a = paywall.products) === null || _a === void 0 ? void 0 : _a.find((p) => p.key === key);
|
|
63
|
+
if (!slot)
|
|
64
|
+
return undefined;
|
|
65
|
+
if (platform === "ios")
|
|
66
|
+
return slot.ios || undefined;
|
|
67
|
+
if (platform === "android")
|
|
68
|
+
return slot.android || undefined;
|
|
69
|
+
return undefined;
|
|
70
|
+
};
|
|
71
|
+
const nonEmptyString = (value) => typeof value === "string" && value.length > 0;
|
|
72
|
+
/**
|
|
73
|
+
* A custom screen's `complete({ transaction })`, reduced to the contract: the
|
|
74
|
+
* three ids only when they are non-empty strings, `restored` only when it is
|
|
75
|
+
* exactly `true`, every other field dropped. `undefined` when the input is not
|
|
76
|
+
* a plain object or nothing survives, so the end carries no `transaction` at
|
|
77
|
+
* all, exactly as when none was passed.
|
|
78
|
+
*
|
|
79
|
+
* Never throws: the value is host data, and a throwing getter or a revoked
|
|
80
|
+
* `Proxy` (on which even `Array.isArray` throws) must cost only the
|
|
81
|
+
* transaction, never the end of the presentation it rides on.
|
|
82
|
+
*/
|
|
83
|
+
const sanitizePaywallTransaction = (value) => {
|
|
84
|
+
try {
|
|
85
|
+
return readTransaction(value);
|
|
86
|
+
}
|
|
87
|
+
catch (error) {
|
|
88
|
+
console.warn("[paywalls] complete()'s transaction could not be read; it was dropped:", error);
|
|
89
|
+
return undefined;
|
|
90
|
+
}
|
|
91
|
+
};
|
|
92
|
+
exports.sanitizePaywallTransaction = sanitizePaywallTransaction;
|
|
93
|
+
const readTransaction = (value) => {
|
|
94
|
+
if (typeof value !== "object" || value === null || Array.isArray(value))
|
|
95
|
+
return undefined;
|
|
96
|
+
const raw = value;
|
|
97
|
+
const out = {};
|
|
98
|
+
if (nonEmptyString(raw.originalTransactionIdentifier)) {
|
|
99
|
+
out.originalTransactionIdentifier = raw.originalTransactionIdentifier;
|
|
100
|
+
}
|
|
101
|
+
if (nonEmptyString(raw.purchaseToken))
|
|
102
|
+
out.purchaseToken = raw.purchaseToken;
|
|
103
|
+
if (nonEmptyString(raw.productId))
|
|
104
|
+
out.productId = raw.productId;
|
|
105
|
+
if (raw.restored === true)
|
|
106
|
+
out.restored = true;
|
|
107
|
+
return Object.keys(out).length > 0 ? out : undefined;
|
|
108
|
+
};
|
|
109
|
+
/**
|
|
110
|
+
* The end the observer receives.
|
|
111
|
+
*
|
|
112
|
+
* A transaction only ever accompanies a `purchased` end (contract rule P8).
|
|
113
|
+
* Its sources:
|
|
114
|
+
* - a purchase the SDK recorded (`purchasedProductKey`): `productId` from that
|
|
115
|
+
* slot for the running platform;
|
|
116
|
+
* - a custom screen's reported transaction (#287), sanitized.
|
|
117
|
+
*
|
|
118
|
+
* With no recorded purchase, the reported transaction is sent as it is.
|
|
119
|
+
*
|
|
120
|
+
* When a purchase IS recorded, the recorded purchase wins: the "first settled
|
|
121
|
+
* purchase sticks" rule `resolveEndedOutcome` applies to the outcome. The
|
|
122
|
+
* reported ids are added to it only when they provably describe it, i.e. the
|
|
123
|
+
* reported `productId` is present and equals the recorded slot's store id for
|
|
124
|
+
* this platform. `restored` is never added: the SDK's own purchase is a
|
|
125
|
+
* purchase, and a screen's flag must not relabel it. In every other case (an
|
|
126
|
+
* absent or different reported `productId`, or a recorded slot with no store
|
|
127
|
+
* id on this platform) the reported ids are dropped with a warning, and the
|
|
128
|
+
* end carries the recorded purchase's transaction alone (`{ productId }`, or
|
|
129
|
+
* none when its slot names nothing here). Pairing one purchase's transaction
|
|
130
|
+
* id with another's `productId` would corrupt the revenue join.
|
|
131
|
+
*/
|
|
132
|
+
const buildPresentationEnd = (paywall, result, purchasedProductKey, platform, reportedTransaction) => {
|
|
133
|
+
var _a;
|
|
134
|
+
const end = { status: result.status };
|
|
135
|
+
if (result.reason !== undefined)
|
|
136
|
+
end.reason = result.reason;
|
|
137
|
+
if (result.status !== "purchased")
|
|
138
|
+
return end;
|
|
139
|
+
const productId = resolveProductId(paywall, purchasedProductKey, platform);
|
|
140
|
+
const reported = (0, exports.sanitizePaywallTransaction)(reportedTransaction);
|
|
141
|
+
if (reported && !purchasedProductKey) {
|
|
142
|
+
end.transaction = reported;
|
|
143
|
+
return end;
|
|
144
|
+
}
|
|
145
|
+
if (reported && productId && reported.productId === productId) {
|
|
146
|
+
const { restored } = reported, ids = __rest(reported, ["restored"]);
|
|
147
|
+
if (restored) {
|
|
148
|
+
console.warn("[paywalls] complete() reported `restored: true` for a purchase this presentation already " +
|
|
149
|
+
"recorded through the SDK; the flag was dropped and the purchase is reported as one.");
|
|
150
|
+
}
|
|
151
|
+
end.transaction = ids;
|
|
152
|
+
return end;
|
|
153
|
+
}
|
|
154
|
+
if (reported) {
|
|
155
|
+
console.warn(`[paywalls] complete() reported a transaction for ${JSON.stringify((_a = reported.productId) !== null && _a !== void 0 ? _a : null)}, ` +
|
|
156
|
+
`but this presentation already recorded a purchase of ${JSON.stringify(productId !== null && productId !== void 0 ? productId : null)}; ` +
|
|
157
|
+
"the recorded purchase is reported and the screen's transaction ids are dropped.");
|
|
158
|
+
}
|
|
159
|
+
if (productId)
|
|
160
|
+
end.transaction = { productId };
|
|
161
|
+
return end;
|
|
162
|
+
};
|
|
163
|
+
exports.buildPresentationEnd = buildPresentationEnd;
|
|
164
|
+
/**
|
|
165
|
+
* Opens one observed presentation: calls `observer.start` now and returns the
|
|
166
|
+
* guarded handle. With no observer (or a malformed one) every call is a no-op.
|
|
167
|
+
*
|
|
168
|
+
* `platform` is `Platform.OS`, passed in rather than imported so this module
|
|
169
|
+
* stays testable without a react-native stub.
|
|
170
|
+
*/
|
|
171
|
+
const openPaywallPresentation = (observer, paywall, surface, platform) => {
|
|
172
|
+
if (!observer || typeof observer.start !== "function") {
|
|
173
|
+
return exports.NOOP_PAYWALL_PRESENTATION;
|
|
174
|
+
}
|
|
175
|
+
const returned = guarded("start", () => observer.start((0, exports.buildPresentationInfo)(paywall, surface)));
|
|
176
|
+
// `start()` may legitimately return void; anything that is not a handle is
|
|
177
|
+
// treated the same way.
|
|
178
|
+
const handle = isHandle(returned) ? returned : null;
|
|
179
|
+
let shown = false;
|
|
180
|
+
let ended = false;
|
|
181
|
+
return {
|
|
182
|
+
shown: () => {
|
|
183
|
+
if (shown || ended)
|
|
184
|
+
return;
|
|
185
|
+
shown = true;
|
|
186
|
+
if (handle)
|
|
187
|
+
guarded("shown", () => handle.shown());
|
|
188
|
+
},
|
|
189
|
+
end: (result, purchasedProductKey, purchasedFrom, reportedTransaction) => {
|
|
190
|
+
if (ended)
|
|
191
|
+
return;
|
|
192
|
+
ended = true;
|
|
193
|
+
if (!handle)
|
|
194
|
+
return;
|
|
195
|
+
const source = purchasedFrom !== null && purchasedFrom !== void 0 ? purchasedFrom : paywall;
|
|
196
|
+
// The sanitizer never throws, but the end must reach the observer
|
|
197
|
+
// whatever the reported transaction does: fall back to the end without it.
|
|
198
|
+
let outcome;
|
|
199
|
+
try {
|
|
200
|
+
outcome = (0, exports.buildPresentationEnd)(source, result, purchasedProductKey, platform, reportedTransaction);
|
|
201
|
+
}
|
|
202
|
+
catch (error) {
|
|
203
|
+
warn("end (its transaction)", error);
|
|
204
|
+
outcome = (0, exports.buildPresentationEnd)(source, result, purchasedProductKey, platform);
|
|
205
|
+
}
|
|
206
|
+
guarded("end", () => handle.end(outcome));
|
|
207
|
+
},
|
|
208
|
+
};
|
|
209
|
+
};
|
|
210
|
+
exports.openPaywallPresentation = openPaywallPresentation;
|
|
211
|
+
//# sourceMappingURL=observer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"observer.js","sourceRoot":"","sources":["../../src/paywalls/observer.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AAsGa,QAAA,yBAAyB,GAAwB,MAAM,CAAC,MAAM,CAAC;IAC1E,KAAK,EAAE,GAAG,E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E,mBAAmB,EAAE,QAAQ,CAAC,CAAC;YAChF,CAAC;YACD,OAAO,CAAC,KAAK,EAAE,GAAG,EAAE,CAAC,MAAM,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC;QAC5C,CAAC;KACF,CAAC;AACJ,CAAC,CAAC;AAtCW,QAAA,uBAAuB,2BAsClC"}
|
|
@@ -138,22 +138,26 @@ export declare const purchaseOutcomeFromResult: (result: PurchaseResult) => Purc
|
|
|
138
138
|
*/
|
|
139
139
|
export declare const resolvePresentedOutcome: (reported: PresentResult, purchaseOutcome: PurchaseOutcomeDuringPresentation) => PresentResult;
|
|
140
140
|
/**
|
|
141
|
-
*
|
|
142
|
-
*
|
|
143
|
-
* `
|
|
144
|
-
*
|
|
145
|
-
*
|
|
146
|
-
* `
|
|
147
|
-
* the
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
*
|
|
152
|
-
*
|
|
153
|
-
*
|
|
154
|
-
*
|
|
141
|
+
* What a presentation ENDS with. A purchase that settled `purchased` during it
|
|
142
|
+
* sticks (owner ruling on #286): no later report overturns it — a dismissal,
|
|
143
|
+
* a host's `error` (`render-error`, `paywall-disappeared`), a custom screen's
|
|
144
|
+
* `cancelled`. The user paid, and `register()` must not deny them. Otherwise
|
|
145
|
+
* `resolvePresentedOutcome`'s rule. Recording keeps the same rule: once
|
|
146
|
+
* `purchased`, a later store result (`cancelled`, or a second `purchased`) is
|
|
147
|
+
* not recorded, so the end keeps the FIRST purchase's key and paywall.
|
|
148
|
+
*/
|
|
149
|
+
export declare const resolveEndedOutcome: (reported: PresentResult, purchaseOutcome: PurchaseOutcomeDuringPresentation) => PresentResult;
|
|
150
|
+
/**
|
|
151
|
+
* How long a presentation whose paywall left the catalog with a purchase in
|
|
152
|
+
* flight waits for that purchase before ending `dismissed`. Mirrors
|
|
153
|
+
* `DEFAULT_PURCHASE_TIMEOUT_MS` in `../products/adapters/expoIap.ts` (not
|
|
154
|
+
* imported: that module pulls in the adapter's own imports), which answers
|
|
155
|
+
* `pending` after the same wait counted from the purchase START, so it settles
|
|
156
|
+
* first and this only fires for a provider with no bound of its own. The UI's
|
|
157
|
+
* inline step has the same constant (`usePaywallStepObservation.ts`), held
|
|
158
|
+
* equal by its test.
|
|
155
159
|
*/
|
|
156
|
-
export declare const
|
|
160
|
+
export declare const LATE_PURCHASE_TIMEOUT_MS = 180000;
|
|
157
161
|
/**
|
|
158
162
|
* Which of the two resolved product runtimes to publish.
|
|
159
163
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"present.d.ts","sourceRoot":"","sources":["../../src/paywalls/present.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AACtE,OAAO,KAAK,EAAE,UAAU,EAAE,cAAc,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAGnG;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,kBAAkB,GAAI,SAAS,cAAc,GAAG,IAAI,KAAG,UAAU,EAa7E,CAAC;AAEF,+EAA+E;AAC/E,MAAM,MAAM,eAAe,GACvB;IAAE,IAAI,EAAE,OAAO,CAAC;IAAC,OAAO,EAAE,OAAO,CAAA;CAAE,GACnC;IAAE,IAAI,EAAE,WAAW,CAAC;IAAC,MAAM,EAAE,aAAa,CAAA;CAAE,CAAC;AAEjD;;;;;;;;;;;;;;;;GAgBG;AACH,eAAO,MAAM,sBAAsB,GACjC,SAAS,cAAc,GAAG,IAAI,EAC9B,cAAc,MAAM,GAAG,IAAI,EAC3B,QAAQ,MAAM,KACb,eAaF,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,eAAO,MAAM,4BAA4B,GACvC,iBAAiB,MAAM,GAAG,IAAI,EAC9B,kBAAkB,OAAO,EACzB,UAAU,OAAO,KAChB,OAAoE,CAAC;AAExE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA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AAc,CAAC;IAC9B,OAAO,EAAE,OAAO,GAAG,QAAQ,GAAG,SAAS,CAAC;IACxC,iBAAiB,EAAE,OAAO,CAAC;IAC3B,gBAAgB,EAAE,OAAO,CAAC;CAC3B,KAAG,cAKH,CAAC"}
|
package/dist/paywalls/present.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.selectActiveProductRuntime = exports.
|
|
3
|
+
exports.selectActiveProductRuntime = exports.LATE_PURCHASE_TIMEOUT_MS = exports.resolveEndedOutcome = exports.resolvePresentedOutcome = exports.purchaseOutcomeFromResult = exports.computeIsReady = exports.computeCatalogStatus = exports.shouldBreakPresentationWedge = exports.resolvePresentDecision = exports.collectProductRefs = void 0;
|
|
4
4
|
const refIdentity_1 = require("../products/refIdentity");
|
|
5
5
|
/**
|
|
6
6
|
* Union of every `paywall.products[]` across the WHOLE catalog, deduplicated
|
|
@@ -130,23 +130,27 @@ exports.purchaseOutcomeFromResult = purchaseOutcomeFromResult;
|
|
|
130
130
|
const resolvePresentedOutcome = (reported, purchaseOutcome) => reported.status === "dismissed" && purchaseOutcome ? { status: purchaseOutcome } : reported;
|
|
131
131
|
exports.resolvePresentedOutcome = resolvePresentedOutcome;
|
|
132
132
|
/**
|
|
133
|
-
*
|
|
134
|
-
*
|
|
135
|
-
* `
|
|
136
|
-
*
|
|
137
|
-
*
|
|
138
|
-
* `
|
|
139
|
-
* the
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
*
|
|
145
|
-
*
|
|
146
|
-
*
|
|
133
|
+
* What a presentation ENDS with. A purchase that settled `purchased` during it
|
|
134
|
+
* sticks (owner ruling on #286): no later report overturns it — a dismissal,
|
|
135
|
+
* a host's `error` (`render-error`, `paywall-disappeared`), a custom screen's
|
|
136
|
+
* `cancelled`. The user paid, and `register()` must not deny them. Otherwise
|
|
137
|
+
* `resolvePresentedOutcome`'s rule. Recording keeps the same rule: once
|
|
138
|
+
* `purchased`, a later store result (`cancelled`, or a second `purchased`) is
|
|
139
|
+
* not recorded, so the end keeps the FIRST purchase's key and paywall.
|
|
140
|
+
*/
|
|
141
|
+
const resolveEndedOutcome = (reported, purchaseOutcome) => purchaseOutcome === "purchased" ? { status: "purchased" } : (0, exports.resolvePresentedOutcome)(reported, purchaseOutcome);
|
|
142
|
+
exports.resolveEndedOutcome = resolveEndedOutcome;
|
|
143
|
+
/**
|
|
144
|
+
* How long a presentation whose paywall left the catalog with a purchase in
|
|
145
|
+
* flight waits for that purchase before ending `dismissed`. Mirrors
|
|
146
|
+
* `DEFAULT_PURCHASE_TIMEOUT_MS` in `../products/adapters/expoIap.ts` (not
|
|
147
|
+
* imported: that module pulls in the adapter's own imports), which answers
|
|
148
|
+
* `pending` after the same wait counted from the purchase START, so it settles
|
|
149
|
+
* first and this only fires for a provider with no bound of its own. The UI's
|
|
150
|
+
* inline step has the same constant (`usePaywallStepObservation.ts`), held
|
|
151
|
+
* equal by its test.
|
|
147
152
|
*/
|
|
148
|
-
|
|
149
|
-
exports.shouldRecordPurchaseOutcome = shouldRecordPurchaseOutcome;
|
|
153
|
+
exports.LATE_PURCHASE_TIMEOUT_MS = 180000;
|
|
150
154
|
/**
|
|
151
155
|
* Which of the two resolved product runtimes to publish.
|
|
152
156
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"present.js","sourceRoot":"","sources":["../../src/paywalls/present.ts"],"names":[],"mappings":";;;AAEA,yDAA6D;AAE7D;;;;;;;;;;;;GAYG;AACI,MAAM,kBAAkB,GAAG,CAAC,OAA8B,EAAgB,EAAE;IACjF,IAAI,CAAC,OAAO;QAAE,OAAO,EAAE,CAAC;IACxB,MAAM,IAAI,GAAG,IAAI,GAAG,EAAU,CAAC;IAC/B,MAAM,IAAI,GAAiB,EAAE,CAAC;IAC9B,KAAK,MAAM,OAAO,IAAI,MAAM,CAAC,MAAM,CAAC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AM,EAAE,eAAe,EAAE,CAAC,CAAC,CAAC,QAAQ,CAAC;AAJjF,QAAA,uBAAuB,2BAI0D;AAE9F;;;;;;;;GAQG;AACI,MAAM,mBAAmB,GAAG,CACjC,QAAuB,EACvB,eAAkD,EACnC,EAAE,CACjB,eAAe,KAAK,WAAW,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE,WAAW,EAAE,CAAC,CAAC,CAAC,IAAA,+BAAuB,EAAC,QAAQ,EAAE,eAAe,CAAC,CAAC;AAJpG,QAAA,mBAAmB,uBAIiF;AAEjH;;;;;;;;;GASG;AACU,QAAA,wBAAwB,GAAG,MAAO,CAAC;AAEhD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsCG;AACI,MAAM,0BAA0B,GAAG,CAAC,IAM1C,EAAkB,EAAE;IACnB,IAAI,IAAI,CAAC,OAAO,KAAK,QAAQ,IAAI,IAAI,CAAC,iBAAiB;QAAE,OAAO,IAAI,CAAC,aAAa,CAAC;IACnF,IAAI,IAAI,CAAC,OAAO,KAAK,SAAS;QAAE,OAAO,IAAI,CAAC,YAAY,CAAC;IACzD,IAAI,IAAI,CAAC,iBAAiB,IAAI,CAAC,IAAI,CAAC,gBAAgB;QAAE,OAAO,IAAI,CAAC,aAAa,CAAC;IAChF,OAAO,IAAI,CAAC,YAAY,CAAC;AAC3B,CAAC,CAAC;AAXW,QAAA,0BAA0B,8BAWrC"}
|
package/dist/paywalls/types.d.ts
CHANGED
|
@@ -201,7 +201,9 @@ export interface GetPaywallsResponseHeaders {
|
|
|
201
201
|
* (iOS will not present over an already-presenting view controller — another
|
|
202
202
|
* Modal, a `presentation: "modal"` route, a StoreKit alert).
|
|
203
203
|
* - `paywall-disappeared` — the moment vanished from the catalog while it
|
|
204
|
-
* was on screen (a studio publish, or a query-key change mid-presentation)
|
|
204
|
+
* was on screen (a studio publish, or a query-key change mid-presentation)
|
|
205
|
+
* and no purchase was made on it. A purchase wins: one that settled
|
|
206
|
+
* `purchased` resolves `purchased`, and one still in flight is waited for.
|
|
205
207
|
* - `unknown-custom-screen` — the paywall is `renderMode: "custom"` and names
|
|
206
208
|
* a `customScreenId` this host did not register (or names none at all), so
|
|
207
209
|
* there was nothing to render and the Modal was never opened. Deliberately
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/paywalls/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAE1D;;;;;;GAMG;AAEH;;;;;;;;GAQG;AACH,MAAM,MAAM,OAAO,GAAG;IACpB,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,CAAC;IACf,UAAU,EAAE,MAAM,GAAG,IAAI,CAAC;IAC1B,YAAY,EAAE,MAAM,GAAG,IAAI,CAAC;IAC5B,0FAA0F;IAC1F,QAAQ,EAAE,OAAO,EAAE,CAAC;IACpB;;;;;;;;OAQG;IACH,OAAO,EAAE,OAAO,GAAG,QAAQ,CAAC;IAC5B,QAAQ,EAAE,KAAK,CAAC;QACd,GAAG,EAAE,MAAM,CAAC;QACZ,GAAG,CAAC,EAAE,MAAM,CAAC;QACb,OAAO,CAAC,EAAE,MAAM,CAAC;QACjB,SAAS,CAAC,EAAE,MAAM,CAAC;QACnB,MAAM,CAAC,EAAE,gBAAgB,CAAC;KAC3B,CAAC,CAAC;IACH,aAAa,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,CAAC;IAC9C;;;;;;;;;;;;;;;OAeG;IACH,UAAU,CAAC,EAAE,UAAU,GAAG,QAAQ,CAAC;IACnC;;;;;;;;;OASG;IACH,cAAc,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC/B;;;;;;;;;;;;;;OAcG;IACH,aAAa,CAAC,EAAE,oBAAoB,CAAC;CACtC,CAAC;AAEF;;;;;;GAMG;AACH,MAAM,MAAM,o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EAAE,MAAM,GAAG,IAAI,CAAC;IACnC,kBAAkB,EAAE,MAAM,GAAG,IAAI,CAAC;CACnC;AAED;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH;;;;;;;;;;;;GAYG;AACH;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2CG;AACH,MAAM,MAAM,kBAAkB,GAC1B,gBAAgB,GAChB,oBAAoB,GACpB,aAAa,GACb,cAAc,GACd,sBAAsB,GACtB,qBAAqB,GACrB,uBAAuB,CAAC;AAE5B,MAAM,MAAM,aAAa,GAAG;IAC1B,MAAM,EAAE,WAAW,GAAG,WAAW,GAAG,WAAW,GAAG,OAAO,CAAC;IAC1D,uEAAuE;IACvE,MAAM,CAAC,EAAE,kBAAkB,CAAC;IAC5B;;;;OAIG;IACH,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB,CAAC"}
|
|
@@ -1,4 +1,41 @@
|
|
|
1
1
|
import type { ProductProvider } from "../types";
|
|
2
|
+
export type ExpoIapProviderOptions = {
|
|
3
|
+
/**
|
|
4
|
+
* How long to wait for the store's verdict before answering `"pending"`.
|
|
5
|
+
*
|
|
6
|
+
* The verdict is an event and nothing bounds how long a user spends in the
|
|
7
|
+
* store sheet — Ask to Buy, an SCA step-up, or adding a card inside the sheet
|
|
8
|
+
* routinely exceed the default — so this bounds only how long the CALLER
|
|
9
|
+
* waits. It does not end the transaction: the provider's listeners stay
|
|
10
|
+
* attached, and a verdict arriving after the timeout is still acknowledged.
|
|
11
|
+
* It resolves `"pending"`, never `"purchased"`.
|
|
12
|
+
*/
|
|
13
|
+
purchaseTimeoutMs?: number;
|
|
14
|
+
/**
|
|
15
|
+
* Honour a transaction this process never asked for, so it can be finished.
|
|
16
|
+
*
|
|
17
|
+
* StoreKit re-delivers an unfinished transaction on **every launch**, and a
|
|
18
|
+
* purchase can also arrive from an Ask to Buy approval, a promoted product,
|
|
19
|
+
* or a pending Play purchase that cleared while the app was closed. None of
|
|
20
|
+
* those has a caller waiting, and finishing one blind would take the money
|
|
21
|
+
* while granting nothing — destroying the very replay that lets the app
|
|
22
|
+
* recover. So the host decides: return `true` once entitlement is granted and
|
|
23
|
+
* the transaction is finished; return `false` (or leave this unset) and it is
|
|
24
|
+
* left alone to be re-delivered next launch.
|
|
25
|
+
*
|
|
26
|
+
* A purchase this provider DISPATCHED in this process never comes here — the
|
|
27
|
+
* caller was told about it, so acknowledging it needs no second opinion.
|
|
28
|
+
*/
|
|
29
|
+
onUnclaimedPurchase?: (purchase: any) => boolean | Promise<boolean>;
|
|
30
|
+
};
|
|
31
|
+
/**
|
|
32
|
+
* `dispose()` is additive to `ProductProvider`: hosts that never call it are
|
|
33
|
+
* unaffected, but a provider holds a store subscription for its lifetime, so a
|
|
34
|
+
* host that rebuilds one per render should tear the old one down.
|
|
35
|
+
*/
|
|
36
|
+
export type ExpoIapProvider = ProductProvider & {
|
|
37
|
+
dispose(): void;
|
|
38
|
+
};
|
|
2
39
|
/** Direct StoreKit / Play Billing provider, no vendor in the path. */
|
|
3
|
-
export declare const expoIapProductProvider: (Iap?: any) =>
|
|
40
|
+
export declare const expoIapProductProvider: (Iap?: any, options?: ExpoIapProviderOptions) => ExpoIapProvider;
|
|
4
41
|
//# sourceMappingURL=expoIap.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"expoIap.d.ts","sourceRoot":"","sources":["../../../src/products/adapters/expoIap.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"expoIap.d.ts","sourceRoot":"","sources":["../../../src/products/adapters/expoIap.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,eAAe,EAKhB,MAAM,UAAU,CAAC;AAmOlB,MAAM,MAAM,sBAAsB,GAAG;IACnC;;;;;;;;;OASG;IACH,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B;;;;;;;;;;;;;;OAcG;IACH,mBAAmB,CAAC,EAAE,CAAC,QAAQ,EAAE,GAAG,KAAK,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;CACrE,CAAC;AAEF;;;;GAIG;AACH,MAAM,MAAM,eAAe,GAAG,eAAe,GAAG;IAAE,OAAO,IAAI,IAAI,CAAA;CAAE,CAAC;AAIpE,sEAAsE;AACtE,eAAO,MAAM,sBAAsB,GACjC,MAAK,GAAS,EACd,UAAS,sBAA2B,KACnC,eA8cF,CAAC"}
|