@ait-kit/sdk 0.4.0 → 0.5.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.
- package/README.md +95 -21
- package/dist/ads/adapter.d.ts +36 -0
- package/dist/ads/adapter.d.ts.map +1 -0
- package/dist/ads/adapter.js +219 -0
- package/dist/ads/platform-contract.d.ts +45 -0
- package/dist/ads/platform-contract.d.ts.map +1 -0
- package/dist/ads/platform-contract.js +7 -0
- package/dist/iap/adapter.d.ts +11 -1
- package/dist/iap/adapter.d.ts.map +1 -1
- package/dist/iap/adapter.js +13 -0
- package/dist/iap/order-history.d.ts +6 -0
- package/dist/iap/order-history.d.ts.map +1 -0
- package/dist/iap/order-history.js +54 -0
- package/dist/iap/platform-contract.d.ts +9 -1
- package/dist/iap/platform-contract.d.ts.map +1 -1
- package/dist/iap/platform-contract.js +1 -1
- package/dist/iap/purchase-flow.d.ts +1 -1
- package/dist/iap/purchase-flow.js +1 -1
- package/dist/iap/subscription-info.d.ts +6 -0
- package/dist/iap/subscription-info.d.ts.map +1 -0
- package/dist/iap/subscription-info.js +38 -0
- package/dist/identity/platform-contract.d.ts +1 -1
- package/dist/index.d.ts +28 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/notification/platform-contract.d.ts +1 -1
- package/dist/rn/ads.d.ts +7 -36
- package/dist/rn/ads.d.ts.map +1 -1
- package/dist/rn/ads.js +2 -223
- package/dist/rn/framework-contract.d.ts +1 -44
- package/dist/rn/framework-contract.d.ts.map +1 -1
- package/dist/rn/framework-contract.js +0 -6
- package/dist/rn/iap.d.ts +1 -1
- package/dist/rn/iap.d.ts.map +1 -1
- package/dist/rn/iap.js +1 -1
- package/dist/share/platform-contract.d.ts +1 -1
- package/dist/storage/platform-contract.d.ts +1 -1
- package/dist/webview/ads.d.ts +10 -0
- package/dist/webview/ads.d.ts.map +1 -0
- package/dist/webview/ads.js +14 -0
- package/dist/webview/banner-contract.d.ts +59 -0
- package/dist/webview/banner-contract.d.ts.map +1 -0
- package/dist/webview/banner.d.ts +15 -0
- package/dist/webview/banner.d.ts.map +1 -0
- package/dist/webview/banner.js +188 -0
- package/dist/{web → webview}/framework-loader.d.ts +1 -1
- package/dist/webview/framework-loader.d.ts.map +1 -0
- package/dist/{web → webview}/framework-loader.js +3 -3
- package/dist/{web → webview}/iap-contract.d.ts +4 -4
- package/dist/webview/iap-contract.d.ts.map +1 -0
- package/dist/webview/iap-contract.js +1 -0
- package/dist/webview/identity.d.ts +40 -0
- package/dist/webview/identity.d.ts.map +1 -0
- package/dist/{web → webview}/identity.js +17 -13
- package/dist/webview/index.d.ts +62 -0
- package/dist/webview/index.d.ts.map +1 -0
- package/dist/{web → webview}/index.js +20 -11
- package/dist/webview/notify-share.d.ts +50 -0
- package/dist/webview/notify-share.d.ts.map +1 -0
- package/dist/{web → webview}/notify-share.js +18 -14
- package/dist/webview/platform-loader.d.ts +4 -0
- package/dist/webview/platform-loader.d.ts.map +1 -0
- package/dist/{web → webview}/platform-loader.js +1 -1
- package/dist/webview/promotion.d.ts +13 -0
- package/dist/webview/promotion.d.ts.map +1 -0
- package/dist/{web → webview}/promotion.js +5 -3
- package/dist/webview/review.d.ts +11 -0
- package/dist/webview/review.d.ts.map +1 -0
- package/dist/webview/review.js +11 -0
- package/package.json +11 -3
- package/dist/web/framework-loader.d.ts.map +0 -1
- package/dist/web/iap-contract.d.ts.map +0 -1
- package/dist/web/identity.d.ts +0 -30
- package/dist/web/identity.d.ts.map +0 -1
- package/dist/web/index.d.ts +0 -49
- package/dist/web/index.d.ts.map +0 -1
- package/dist/web/notify-share.d.ts +0 -38
- package/dist/web/notify-share.d.ts.map +0 -1
- package/dist/web/platform-loader.d.ts +0 -4
- package/dist/web/platform-loader.d.ts.map +0 -1
- package/dist/web/promotion.d.ts +0 -9
- package/dist/web/promotion.d.ts.map +0 -1
- package/dist/web/review.d.ts +0 -7
- package/dist/web/review.d.ts.map +0 -1
- package/dist/web/review.js +0 -9
- /package/dist/{web/iap-contract.js → webview/banner-contract.js} +0 -0
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { SdkError } from "../index.js";
|
|
2
|
+
import { toIapErrorCode } from "./platform-contract.js";
|
|
3
|
+
export async function queryOrderHistory(load, pagination, params) {
|
|
4
|
+
if (params !== undefined && (!isRecord(params) || Array.isArray(params))) {
|
|
5
|
+
throw new SdkError("INVALID_IAP_INPUT", "history params must be an object with an optional key");
|
|
6
|
+
}
|
|
7
|
+
const key = params?.key;
|
|
8
|
+
if (key !== undefined && key !== null && (typeof key !== "string" || !key.trim())) {
|
|
9
|
+
throw new SdkError("INVALID_IAP_INPUT", "history key must be a non-empty string or null");
|
|
10
|
+
}
|
|
11
|
+
if (pagination === "first_page_only" && key !== undefined && key !== null) {
|
|
12
|
+
throw new SdkError("UNSUPPORTED", "the WebView SDK only supports the first order history page");
|
|
13
|
+
}
|
|
14
|
+
const platform = await load();
|
|
15
|
+
const query = platform.getCompletedOrRefundedOrders;
|
|
16
|
+
if (typeof query !== "function" || (typeof query.isSupported === "function" && !query.isSupported())) {
|
|
17
|
+
throw new SdkError("UNSUPPORTED", "order history is not supported on this app version");
|
|
18
|
+
}
|
|
19
|
+
let result;
|
|
20
|
+
try {
|
|
21
|
+
// WebView's official function takes no arguments; never send a fabricated cursor.
|
|
22
|
+
result = pagination === "cursor" && key !== undefined
|
|
23
|
+
? await query.call(platform, { key })
|
|
24
|
+
: await query.call(platform);
|
|
25
|
+
}
|
|
26
|
+
catch (error) {
|
|
27
|
+
if (toIapErrorCode(error) === "UNSUPPORTED_APP_VERSION") {
|
|
28
|
+
throw new SdkError("UNSUPPORTED", "order history is not supported on this app version", { cause: error });
|
|
29
|
+
}
|
|
30
|
+
throw error;
|
|
31
|
+
}
|
|
32
|
+
if (result === undefined)
|
|
33
|
+
throw new SdkError("UNSUPPORTED", "order history is not supported on this app version");
|
|
34
|
+
if (!isRecord(result) || typeof result.hasNext !== "boolean" || !Array.isArray(result.orders) ||
|
|
35
|
+
(result.nextKey !== undefined && result.nextKey !== null &&
|
|
36
|
+
(typeof result.nextKey !== "string" || !result.nextKey.trim())) ||
|
|
37
|
+
!result.orders.every(isOrder)) {
|
|
38
|
+
throw new SdkError("INVALID_IAP_RESULT", "the provider returned malformed order history");
|
|
39
|
+
}
|
|
40
|
+
return {
|
|
41
|
+
orders: result.orders.map(order => ({ orderId: order.orderId, sku: order.sku, status: order.status, date: order.date })),
|
|
42
|
+
hasNext: result.hasNext,
|
|
43
|
+
...(result.nextKey !== undefined ? { nextKey: result.nextKey } : {}),
|
|
44
|
+
pagination
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
function isRecord(value) {
|
|
48
|
+
return typeof value === "object" && value !== null;
|
|
49
|
+
}
|
|
50
|
+
function isOrder(value) {
|
|
51
|
+
return isRecord(value) && typeof value.orderId === "string" && !!value.orderId.trim() &&
|
|
52
|
+
typeof value.sku === "string" && !!value.sku.trim() && typeof value.date === "string" && !!value.date.trim() &&
|
|
53
|
+
(value.status === "COMPLETED" || value.status === "REFUNDED");
|
|
54
|
+
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Internal platform contract shared by the /rn and /
|
|
2
|
+
* Internal platform contract shared by the /rn and /webview IAP adapters.
|
|
3
3
|
* Each entry point declares its own structural copy of the official SDK
|
|
4
4
|
* surface (they are different npm packages with identical Domains API
|
|
5
5
|
* shapes); this module is the common, platform-neutral engine boundary and
|
|
@@ -20,6 +20,14 @@ type WithSupport<F> = F & {
|
|
|
20
20
|
isSupported?: () => boolean;
|
|
21
21
|
};
|
|
22
22
|
export interface IapPlatformSdk {
|
|
23
|
+
getCompletedOrRefundedOrders: WithSupport<(params?: {
|
|
24
|
+
key?: string | null;
|
|
25
|
+
}) => Promise<unknown>>;
|
|
26
|
+
getSubscriptionInfo: WithSupport<(args: {
|
|
27
|
+
params: {
|
|
28
|
+
orderId: string;
|
|
29
|
+
};
|
|
30
|
+
}) => Promise<unknown>>;
|
|
23
31
|
getProductItemList: WithSupport<() => Promise<{
|
|
24
32
|
products: IapProduct[];
|
|
25
33
|
}>>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"platform-contract.d.ts","sourceRoot":"","sources":["../../src/iap/platform-contract.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EACV,wBAAwB,EACxB,eAAe,EACf,UAAU,EACV,6BAA6B,EAC9B,MAAM,aAAa,CAAC;AAErB,MAAM,WAAW,WAAW;IAC1B,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED,MAAM,MAAM,cAAc,GAAG;IAC3B,OAAO,EAAE,MAAM,CAAC;IAChB,GAAG,EAAE,MAAM,CAAC;IACZ,cAAc,CAAC,EAAE,MAAM,CAAC;CACzB,CAAC;AAEF,2EAA2E;AAC3E,KAAK,WAAW,CAAC,CAAC,IAAI,CAAC,GAAG;IAAE,WAAW,CAAC,EAAE,MAAM,OAAO,CAAA;CAAE,CAAC;AAE1D,MAAM,WAAW,cAAc;IAC7B,kBAAkB,EAAE,WAAW,CAAC,MAAM,OAAO,CAAC;QAAE,QAAQ,EAAE,UAAU,EAAE,CAAA;KAAE,CAAC,CAAC,CAAC;IAC3E,0BAA0B,EAAE,WAAW,CAAC,CAAC,MAAM,EAAE,wBAAwB,KAAK,MAAM,IAAI,CAAC,CAAC;IAC1F,+BAA+B,EAAE,WAAW,CAC1C,CAAC,MAAM,EAAE,6BAA6B,KAAK,MAAM,IAAI,CACtD,CAAC;IACF,gBAAgB,EAAE,WAAW,CAAC,MAAM,OAAO,CAAC;QAAE,MAAM,EAAE,eAAe,EAAE,CAAA;KAAE,CAAC,CAAC,CAAC;IAC5E,oBAAoB,EAAE,WAAW,CAC/B,CAAC,IAAI,EAAE;QAAE,MAAM,EAAE;YAAE,OAAO,EAAE,MAAM,CAAA;SAAE,CAAA;KAAE,KAAK,OAAO,CAA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,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Internal platform contract shared by the /rn and /
|
|
2
|
+
* Internal platform contract shared by the /rn and /webview IAP adapters.
|
|
3
3
|
* Each entry point declares its own structural copy of the official SDK
|
|
4
4
|
* surface (they are different npm packages with identical Domains API
|
|
5
5
|
* shapes); this module is the common, platform-neutral engine boundary and
|
|
@@ -11,7 +11,7 @@ export interface PurchaseFlowOptions {
|
|
|
11
11
|
timeoutMs: number;
|
|
12
12
|
}
|
|
13
13
|
/**
|
|
14
|
-
* Shared purchase flow for the /rn and /
|
|
14
|
+
* Shared purchase flow for the /rn and /webview IAP adapters, built on the
|
|
15
15
|
* common event-flow base:
|
|
16
16
|
*
|
|
17
17
|
* - The platform's `processProductGrant` slot wraps the consumer-injected
|
|
@@ -2,7 +2,7 @@ import { runEventFlow } from "../event-flow.js";
|
|
|
2
2
|
import {} from "./grant-coordinator.js";
|
|
3
3
|
import { toIapErrorCode, toIapErrorMessage } from "./platform-contract.js";
|
|
4
4
|
/**
|
|
5
|
-
* Shared purchase flow for the /rn and /
|
|
5
|
+
* Shared purchase flow for the /rn and /webview IAP adapters, built on the
|
|
6
6
|
* common event-flow base:
|
|
7
7
|
*
|
|
8
8
|
* - The platform's `processProductGrant` slot wraps the consumer-injected
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { type IapSubscriptionInfo } from "../index.js";
|
|
2
|
+
import { type PartialIapPlatformSdk } from "./platform-contract.js";
|
|
3
|
+
export declare function querySubscriptionInfo(platform: PartialIapPlatformSdk, orderId: string): Promise<{
|
|
4
|
+
subscription: IapSubscriptionInfo;
|
|
5
|
+
}>;
|
|
6
|
+
//# sourceMappingURL=subscription-info.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"subscription-info.d.ts","sourceRoot":"","sources":["../../src/iap/subscription-info.ts"],"names":[],"mappings":"AAAA,OAAO,EAAY,KAAK,mBAAmB,EAAE,MAAM,aAAa,CAAC;AACjE,OAAO,EAAkB,KAAK,qBAAqB,EAAE,MAAM,wBAAwB,CAAC;AAEpF,wBAAsB,qBAAqB,CAAC,QAAQ,EAAE,qBAAqB,EAAE,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC;IAAE,YAAY,EAAE,mBAAmB,CAAA;CAAE,CAAC,CA2B5I"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { SdkError } from "../index.js";
|
|
2
|
+
import { toIapErrorCode } from "./platform-contract.js";
|
|
3
|
+
export async function querySubscriptionInfo(platform, orderId) {
|
|
4
|
+
let result;
|
|
5
|
+
try {
|
|
6
|
+
result = await platform.getSubscriptionInfo({ params: { orderId } });
|
|
7
|
+
}
|
|
8
|
+
catch (error) {
|
|
9
|
+
if (toIapErrorCode(error) === "UNSUPPORTED_APP_VERSION") {
|
|
10
|
+
throw new SdkError("UNSUPPORTED", "subscription queries are not supported on this app version", { cause: error });
|
|
11
|
+
}
|
|
12
|
+
throw error;
|
|
13
|
+
}
|
|
14
|
+
// The RN SDK returns undefined on unsupported host versions.
|
|
15
|
+
if (result === undefined)
|
|
16
|
+
throw new SdkError("UNSUPPORTED", "subscription queries are not supported on this app version");
|
|
17
|
+
const info = isRecord(result) ? result.subscription : undefined;
|
|
18
|
+
if (!isRecord(info) || typeof info.catalogId !== "number" || !Number.isFinite(info.catalogId) ||
|
|
19
|
+
typeof info.status !== "string" || !info.status.trim() ||
|
|
20
|
+
!nullableString(info.expiresAt) || !nullableString(info.gracePeriodExpiresAt) ||
|
|
21
|
+
typeof info.isAutoRenew !== "boolean" || typeof info.isAccessible !== "boolean") {
|
|
22
|
+
throw new SdkError("INVALID_IAP_RESULT", "the provider returned malformed subscription information");
|
|
23
|
+
}
|
|
24
|
+
return { subscription: {
|
|
25
|
+
catalogId: info.catalogId,
|
|
26
|
+
status: info.status,
|
|
27
|
+
expiresAt: info.expiresAt,
|
|
28
|
+
isAutoRenew: info.isAutoRenew,
|
|
29
|
+
gracePeriodExpiresAt: info.gracePeriodExpiresAt,
|
|
30
|
+
isAccessible: info.isAccessible
|
|
31
|
+
} };
|
|
32
|
+
}
|
|
33
|
+
function isRecord(value) {
|
|
34
|
+
return typeof value === "object" && value !== null;
|
|
35
|
+
}
|
|
36
|
+
function nullableString(value) {
|
|
37
|
+
return value === null || typeof value === "string";
|
|
38
|
+
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { type SdkAnonymousKey, type SdkLoginResult } from "../index.js";
|
|
2
2
|
/**
|
|
3
3
|
* Internal platform contract for the login/anonymous-identity adapters,
|
|
4
|
-
* shared by /rn and /
|
|
4
|
+
* shared by /rn and /webview. Each entry declares its own structural copy of
|
|
5
5
|
* the official SDK surface; this module is the common engine boundary and
|
|
6
6
|
* is never exported from a public subpath.
|
|
7
7
|
*/
|
package/dist/index.d.ts
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
*
|
|
4
4
|
* The root entry is runtime-neutral: common types and errors only, with no
|
|
5
5
|
* imports of any official runtime SDK. Runtime adapters live in subpaths —
|
|
6
|
-
* `@ait-kit/sdk/rn` for React Native
|
|
6
|
+
* `@ait-kit/sdk/rn` for React Native and `@ait-kit/sdk/webview` for WebView.
|
|
7
7
|
*/
|
|
8
8
|
/** Reward payload reported by rewarded ad flows. */
|
|
9
9
|
export interface AdReward {
|
|
@@ -28,7 +28,7 @@ export type AdShowResult = {
|
|
|
28
28
|
reason?: string;
|
|
29
29
|
};
|
|
30
30
|
/** Stable error codes for SDK adapter failures. */
|
|
31
|
-
export type SdkErrorCode = "SDK_UNAVAILABLE" | "UNSUPPORTED" | "AD_NOT_LOADED" | "AD_ALREADY_SHOWING" | "AD_LOAD_FAILED" | "AD_LOAD_TIMEOUT" | "INVALID_LOGIN_RESULT" | "INVALID_ANONYMOUS_KEY" | "INVALID_PROMOTION_INPUT" | "PROMOTION_IN_PROGRESS" | "INVALID_SHARE_PATH";
|
|
31
|
+
export type SdkErrorCode = "SDK_UNAVAILABLE" | "UNSUPPORTED" | "AD_NOT_LOADED" | "AD_ALREADY_SHOWING" | "AD_LOAD_FAILED" | "AD_LOAD_TIMEOUT" | "INVALID_BANNER_INPUT" | "BANNER_INIT_TIMEOUT" | "BANNER_TARGET_IN_USE" | "BANNER_ATTACH_FAILED" | "INVALID_IAP_INPUT" | "INVALID_IAP_RESULT" | "INVALID_LOGIN_RESULT" | "INVALID_ANONYMOUS_KEY" | "INVALID_PROMOTION_INPUT" | "PROMOTION_IN_PROGRESS" | "INVALID_SHARE_PATH";
|
|
32
32
|
/** Terminal agreement outcomes delivered by the platform event. */
|
|
33
33
|
export type SdkNotificationAgreementType = "newAgreement" | "alreadyAgreed" | "agreementRejected";
|
|
34
34
|
/**
|
|
@@ -95,7 +95,7 @@ export interface SdkAnonymousKey {
|
|
|
95
95
|
type: "HASH";
|
|
96
96
|
hash: string;
|
|
97
97
|
}
|
|
98
|
-
/** Minimal storage contract shared by the /rn and /
|
|
98
|
+
/** Minimal storage contract shared by the /rn and /webview adapters. */
|
|
99
99
|
export interface SdkStorage {
|
|
100
100
|
/** Resolves the stored string, or null when the key has no value. */
|
|
101
101
|
get(key: string): Promise<string | null>;
|
|
@@ -216,4 +216,29 @@ export declare class SdkError extends Error {
|
|
|
216
216
|
}
|
|
217
217
|
export type { ReviewAdapter } from "./review/platform-contract.js";
|
|
218
218
|
export type { PromotionAdapter, PromotionSupport, PromotionGrantInput, PromotionGrantResult } from "./promotion/platform-contract.js";
|
|
219
|
+
/** Provider subscription state; unknown future states are preserved without inference. */
|
|
220
|
+
export type IapSubscriptionStatus = "ACTIVE" | "EXPIRED" | "IN_GRACE_PERIOD" | "ON_HOLD" | "PAUSED" | "REVOKED" | (string & {});
|
|
221
|
+
/** Provider snapshot only; server verification remains the source of entitlement decisions. */
|
|
222
|
+
export interface IapSubscriptionInfo {
|
|
223
|
+
catalogId: number;
|
|
224
|
+
status: IapSubscriptionStatus;
|
|
225
|
+
expiresAt: string | null;
|
|
226
|
+
isAutoRenew: boolean;
|
|
227
|
+
gracePeriodExpiresAt: string | null;
|
|
228
|
+
isAccessible: boolean;
|
|
229
|
+
}
|
|
230
|
+
/** One completed purchase or refund reported by the provider. */
|
|
231
|
+
export interface IapCompletedOrRefundedOrder {
|
|
232
|
+
orderId: string;
|
|
233
|
+
sku: string;
|
|
234
|
+
status: "COMPLETED" | "REFUNDED";
|
|
235
|
+
date: string;
|
|
236
|
+
}
|
|
237
|
+
export interface IapOrderHistoryPage {
|
|
238
|
+
orders: IapCompletedOrRefundedOrder[];
|
|
239
|
+
hasNext: boolean;
|
|
240
|
+
nextKey?: string | null;
|
|
241
|
+
/** WebView currently exposes only the first page, even when hasNext is true. */
|
|
242
|
+
pagination: "cursor" | "first_page_only";
|
|
243
|
+
}
|
|
219
244
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,oDAAoD;AACpD,MAAM,WAAW,QAAQ;IACvB,QAAQ,EAAE,MAAM,CAAC;IACjB,UAAU,EAAE,MAAM,CAAC;CACpB;AAED;;;;;;;GAOG;AACH,MAAM,MAAM,YAAY,GACpB;IAAE,MAAM,EAAE,UAAU,CAAC;IAAC,MAAM,EAAE,QAAQ,CAAA;CAAE,GACxC;IAAE,MAAM,EAAE,WAAW,CAAA;CAAE,GACvB;IAAE,MAAM,EAAE,QAAQ,CAAC;IAAC,MAAM,CAAC,EAAE,MAAM,CAAA;CAAE,CAAC;AAE1C,mDAAmD;AACnD,MAAM,MAAM,YAAY,GACpB,iBAAiB,GACjB,aAAa,GACb,eAAe,GACf,oBAAoB,GACpB,gBAAgB,GAChB,iBAAiB,GACjB,sBAAsB,GACtB,uBAAuB,GACvB,yBAAyB,GACzB,uBAAuB,GACvB,oBAAoB,CAAC;AAMzB,mEAAmE;AACnE,MAAM,MAAM,4BAA4B,GAAG,cAAc,GAAG,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AAU,EAAE,QAAQ,GAAG,iBAAiB,CAAC;CAC1C"}
|
package/dist/index.js
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
*
|
|
4
4
|
* The root entry is runtime-neutral: common types and errors only, with no
|
|
5
5
|
* imports of any official runtime SDK. Runtime adapters live in subpaths —
|
|
6
|
-
* `@ait-kit/sdk/rn` for React Native
|
|
6
|
+
* `@ait-kit/sdk/rn` for React Native and `@ait-kit/sdk/webview` for WebView.
|
|
7
7
|
*/
|
|
8
8
|
/** Typed error surfaced by the SDK adapters. */
|
|
9
9
|
export class SdkError extends Error {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { SdkNotificationAgreementResult } from "../index.js";
|
|
2
2
|
/**
|
|
3
3
|
* Internal platform contract for the notification-agreement adapter,
|
|
4
|
-
* shared by /rn and /
|
|
4
|
+
* shared by /rn and /webview (never exported from a public subpath).
|
|
5
5
|
*/
|
|
6
6
|
export interface NotificationAgreementParams {
|
|
7
7
|
options: {
|
package/dist/rn/ads.d.ts
CHANGED
|
@@ -1,39 +1,10 @@
|
|
|
1
|
-
import { type
|
|
2
|
-
import type { FullScreenAdSupport } from "
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* Framework loader. Defaults to a lazy `import("@apps-in-toss/framework")`
|
|
9
|
-
* that retries after failures; tests and consumers can inject a loader or
|
|
10
|
-
* a module instance directly.
|
|
11
|
-
*/
|
|
12
|
-
framework?: FrameworkLoader | FullScreenAdSupport;
|
|
13
|
-
/** Overall deadline for the show flow (default 60000ms; 0 disables). */
|
|
14
|
-
showTimeoutMs?: number;
|
|
15
|
-
/**
|
|
16
|
-
* Overall deadline for each load, covering framework acquisition and the
|
|
17
|
-
* provider load flow (default 30000ms; 0 disables).
|
|
18
|
-
*/
|
|
19
|
-
loadTimeoutMs?: number;
|
|
1
|
+
import { type AdsAdapter, type AdsOptions, type AdsPlatformLoader } from "../ads/adapter.js";
|
|
2
|
+
import type { FullScreenAdSupport } from "../ads/platform-contract.js";
|
|
3
|
+
export type { SdkAdType } from "../ads/adapter.js";
|
|
4
|
+
export interface ReactNativeAdsOptions extends Omit<AdsOptions, "loader"> {
|
|
5
|
+
/** Optional injected framework or loader; the default imports the platform SDK lazily. */
|
|
6
|
+
framework?: AdsPlatformLoader | FullScreenAdSupport;
|
|
20
7
|
}
|
|
21
|
-
export
|
|
22
|
-
/** Loads (or joins an in-flight load of) the full-screen ad for adGroupId. */
|
|
23
|
-
loadFullScreenAd(adGroupId: string): Promise<void>;
|
|
24
|
-
/**
|
|
25
|
-
* Shows the full-screen ad whose load already completed and resolves with
|
|
26
|
-
* its terminal outcome. The ad is single-use and claimed synchronously:
|
|
27
|
-
* once a show starts, the unit needs a fresh load for the next attempt.
|
|
28
|
-
*/
|
|
29
|
-
showFullScreenAd(adGroupId: string): Promise<AdShowResult>;
|
|
30
|
-
}
|
|
31
|
-
/**
|
|
32
|
-
* React Native ad adapter over `@apps-in-toss/framework`. Load state is
|
|
33
|
-
* tracked per ad type + ad unit, in-flight duplicate loads share one
|
|
34
|
-
* request, and rewards come only from the provider's `userEarnedReward`
|
|
35
|
-
* event. The adapter produces ad outcomes; server-side reward requests,
|
|
36
|
-
* session checks, and ledger handling belong to the consumer.
|
|
37
|
-
*/
|
|
8
|
+
export type ReactNativeAds = AdsAdapter;
|
|
38
9
|
export declare function createReactNativeAds(options?: ReactNativeAdsOptions): ReactNativeAds;
|
|
39
10
|
//# sourceMappingURL=ads.d.ts.map
|
package/dist/rn/ads.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ads.d.ts","sourceRoot":"","sources":["../../src/rn/ads.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"ads.d.ts","sourceRoot":"","sources":["../../src/rn/ads.ts"],"names":[],"mappings":"AACA,OAAO,EAAoB,KAAK,UAAU,EAAE,KAAK,UAAU,EAAE,KAAK,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AAC/G,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,6BAA6B,CAAC;AAGvE,YAAY,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AACnD,MAAM,WAAW,qBAAsB,SAAQ,IAAI,CAAC,UAAU,EAAE,QAAQ,CAAC;IACvE,0FAA0F;IAC1F,SAAS,CAAC,EAAE,iBAAiB,GAAG,mBAAmB,CAAC;CACrD;AACD,MAAM,MAAM,cAAc,GAAG,UAAU,CAAC;AAExC,wBAAgB,oBAAoB,CAAC,OAAO,GAAE,qBAA0B,GAAG,cAAc,CAExF"}
|
package/dist/rn/ads.js
CHANGED
|
@@ -1,227 +1,6 @@
|
|
|
1
1
|
import { resolvePlatformLoader } from "../platform-loader.js";
|
|
2
|
-
|
|
3
|
-
// the /rn entry and the root entry share one SdkError constructor and
|
|
4
|
-
// `instanceof` holds for consumers importing either entry.
|
|
5
|
-
import { SdkError } from "../index.js";
|
|
6
|
-
import { runEventFlow } from "../event-flow.js";
|
|
2
|
+
import { createAdsAdapter } from "../ads/adapter.js";
|
|
7
3
|
import { createDefaultFrameworkLoader } from "./framework-loader.js";
|
|
8
|
-
const DEFAULT_SHOW_TIMEOUT_MS = 60_000;
|
|
9
|
-
const DEFAULT_LOAD_TIMEOUT_MS = 30_000;
|
|
10
|
-
function createAdDeadline(timeoutMs, now = monotonicNow) {
|
|
11
|
-
if (!(timeoutMs > 0)) {
|
|
12
|
-
return { remainingMs: () => undefined, race: (promise) => promise };
|
|
13
|
-
}
|
|
14
|
-
const startedAt = now();
|
|
15
|
-
return {
|
|
16
|
-
remainingMs: () => timeoutMs - (now() - startedAt),
|
|
17
|
-
race: (promise) => new Promise((resolve, reject) => {
|
|
18
|
-
const timer = setTimeout(() => resolve(undefined), timeoutMs);
|
|
19
|
-
// Attaching handlers also sinks a settlement that happens after the
|
|
20
|
-
// deadline already won; the no-op reject/resolve after settling is
|
|
21
|
-
// ignored by promise semantics.
|
|
22
|
-
promise.then((value) => {
|
|
23
|
-
clearTimeout(timer);
|
|
24
|
-
resolve(value);
|
|
25
|
-
}, (error) => {
|
|
26
|
-
clearTimeout(timer);
|
|
27
|
-
reject(error);
|
|
28
|
-
});
|
|
29
|
-
})
|
|
30
|
-
};
|
|
31
|
-
}
|
|
32
|
-
/**
|
|
33
|
-
* Monotonic elapsed time: a system wall-clock correction while the loader
|
|
34
|
-
* is pending must not shrink or stretch the remaining budget.
|
|
35
|
-
*/
|
|
36
|
-
function monotonicNow() {
|
|
37
|
-
return typeof performance !== "undefined" && typeof performance.now === "function"
|
|
38
|
-
? performance.now()
|
|
39
|
-
: Date.now();
|
|
40
|
-
}
|
|
41
|
-
/**
|
|
42
|
-
* React Native ad adapter over `@apps-in-toss/framework`. Load state is
|
|
43
|
-
* tracked per ad type + ad unit, in-flight duplicate loads share one
|
|
44
|
-
* request, and rewards come only from the provider's `userEarnedReward`
|
|
45
|
-
* event. The adapter produces ad outcomes; server-side reward requests,
|
|
46
|
-
* session checks, and ledger handling belong to the consumer.
|
|
47
|
-
*/
|
|
48
4
|
export function createReactNativeAds(options = {}) {
|
|
49
|
-
|
|
50
|
-
const showTimeoutMs = options.showTimeoutMs ?? DEFAULT_SHOW_TIMEOUT_MS;
|
|
51
|
-
const loadTimeoutMs = options.loadTimeoutMs ?? DEFAULT_LOAD_TIMEOUT_MS;
|
|
52
|
-
const slots = new Map();
|
|
53
|
-
const showing = new Set();
|
|
54
|
-
const adKey = (adType, adGroupId) => `${adType}:${adGroupId}`;
|
|
55
|
-
const load = (adGroupId) => {
|
|
56
|
-
const id = adKey("fullscreen", adGroupId);
|
|
57
|
-
const existing = slots.get(id);
|
|
58
|
-
// Duplicate loads join the in-flight request, and an already-completed
|
|
59
|
-
// load stays loaded until a show claims it - neither re-registers.
|
|
60
|
-
if (existing) {
|
|
61
|
-
return existing.kind === "loaded" ? Promise.resolve() : existing.promise;
|
|
62
|
-
}
|
|
63
|
-
// Slot updates run inside this promise's settlement — before the
|
|
64
|
-
// caller's await/catch continuation — so a caller that immediately
|
|
65
|
-
// retries after a failure starts a fresh registration, and a caller
|
|
66
|
-
// that immediately shows after a success finds the slot loaded. The
|
|
67
|
-
// identity check keeps a stale task from touching a newer task's slot.
|
|
68
|
-
const promise = new Promise((resolve, reject) => {
|
|
69
|
-
runLoad(adGroupId).then(() => {
|
|
70
|
-
const current = slots.get(id);
|
|
71
|
-
if (current?.kind === "loading" && current.promise === promise) {
|
|
72
|
-
slots.set(id, { kind: "loaded" });
|
|
73
|
-
}
|
|
74
|
-
resolve();
|
|
75
|
-
}, (error) => {
|
|
76
|
-
const current = slots.get(id);
|
|
77
|
-
if (current?.kind === "loading" && current.promise === promise) {
|
|
78
|
-
slots.delete(id);
|
|
79
|
-
}
|
|
80
|
-
reject(error);
|
|
81
|
-
});
|
|
82
|
-
});
|
|
83
|
-
slots.set(id, { kind: "loading", promise });
|
|
84
|
-
return promise;
|
|
85
|
-
};
|
|
86
|
-
const show = (adGroupId) => {
|
|
87
|
-
const id = adKey("fullscreen", adGroupId);
|
|
88
|
-
if (showing.has(id)) {
|
|
89
|
-
return Promise.reject(new SdkError("AD_ALREADY_SHOWING", `ad group ${adGroupId} is already being shown`));
|
|
90
|
-
}
|
|
91
|
-
const slot = slots.get(id);
|
|
92
|
-
if (!slot || slot.kind === "loading") {
|
|
93
|
-
return Promise.reject(new SdkError("AD_NOT_LOADED", `loadFullScreenAd must complete before showing ad group ${adGroupId}`));
|
|
94
|
-
}
|
|
95
|
-
// Claim synchronously: the loaded marker is consumed the moment the show
|
|
96
|
-
// starts, so a concurrent reload registers fresh instead of aliasing a
|
|
97
|
-
// marker this show will never own again.
|
|
98
|
-
slots.delete(id);
|
|
99
|
-
showing.add(id);
|
|
100
|
-
return (async () => {
|
|
101
|
-
const timedOut = () => ({ status: "failed", reason: "ad show flow timed out" });
|
|
102
|
-
try {
|
|
103
|
-
// The whole show shares one budget: the loader races it, the event
|
|
104
|
-
// flow gets what remains, and the flow's own deadline produces the
|
|
105
|
-
// timeout result — its subscription cleanup completes before this
|
|
106
|
-
// promise settles, so `showing` is only released after the
|
|
107
|
-
// subscription is gone.
|
|
108
|
-
const deadline = createAdDeadline(showTimeoutMs);
|
|
109
|
-
const framework = await deadline.race(loadFramework());
|
|
110
|
-
if (!framework) {
|
|
111
|
-
return timedOut();
|
|
112
|
-
}
|
|
113
|
-
if (typeof framework.showFullScreenAd.isSupported === "function" &&
|
|
114
|
-
!framework.showFullScreenAd.isSupported()) {
|
|
115
|
-
throw new SdkError("UNSUPPORTED", "full-screen ads are not supported on this app version");
|
|
116
|
-
}
|
|
117
|
-
const remaining = deadline.remainingMs();
|
|
118
|
-
if (remaining !== undefined && remaining <= 0) {
|
|
119
|
-
return timedOut();
|
|
120
|
-
}
|
|
121
|
-
let reward;
|
|
122
|
-
return await runEventFlow({
|
|
123
|
-
register: (emit) => framework.showFullScreenAd({
|
|
124
|
-
options: { adGroupId },
|
|
125
|
-
onEvent: emit,
|
|
126
|
-
onError: (error) => emit({ type: "sdkError", error })
|
|
127
|
-
}),
|
|
128
|
-
reduce: (event) => {
|
|
129
|
-
if (event.type === "sdkError") {
|
|
130
|
-
const message = errorMessage(event.error);
|
|
131
|
-
return {
|
|
132
|
-
done: true,
|
|
133
|
-
result: { status: "failed", reason: `full-screen ad show failed: ${message}` }
|
|
134
|
-
};
|
|
135
|
-
}
|
|
136
|
-
return reduceShowEvent(event, () => reward, (value) => (reward = value));
|
|
137
|
-
},
|
|
138
|
-
onTimeout: timedOut,
|
|
139
|
-
timeoutMs: remaining ?? 0
|
|
140
|
-
});
|
|
141
|
-
}
|
|
142
|
-
finally {
|
|
143
|
-
showing.delete(id);
|
|
144
|
-
}
|
|
145
|
-
})();
|
|
146
|
-
};
|
|
147
|
-
async function runLoad(adGroupId) {
|
|
148
|
-
// One deadline covers framework acquisition AND the provider flow. A
|
|
149
|
-
// loader that wins the race only just — or too late — leaves no budget
|
|
150
|
-
// for the provider registration, which is then skipped entirely.
|
|
151
|
-
const deadline = createAdDeadline(loadTimeoutMs);
|
|
152
|
-
const framework = await deadline.race(loadFramework());
|
|
153
|
-
if (!framework) {
|
|
154
|
-
throw new SdkError("AD_LOAD_TIMEOUT", "full-screen ad load timed out");
|
|
155
|
-
}
|
|
156
|
-
if (typeof framework.loadFullScreenAd.isSupported === "function" &&
|
|
157
|
-
!framework.loadFullScreenAd.isSupported()) {
|
|
158
|
-
throw new SdkError("UNSUPPORTED", "full-screen ads are not supported on this app version");
|
|
159
|
-
}
|
|
160
|
-
const remaining = deadline.remainingMs();
|
|
161
|
-
if (remaining !== undefined && remaining <= 0) {
|
|
162
|
-
throw new SdkError("AD_LOAD_TIMEOUT", "full-screen ad load timed out");
|
|
163
|
-
}
|
|
164
|
-
const outcome = await runEventFlow({
|
|
165
|
-
register: (emit) => framework.loadFullScreenAd({
|
|
166
|
-
options: { adGroupId },
|
|
167
|
-
onEvent: emit,
|
|
168
|
-
onError: (error) => emit({ type: "sdkError", error })
|
|
169
|
-
}),
|
|
170
|
-
reduce: (event) => event.type === "loaded"
|
|
171
|
-
? { done: true, result: undefined }
|
|
172
|
-
: { done: true, result: loadFailure(event.error) },
|
|
173
|
-
onTimeout: () => new SdkError("AD_LOAD_TIMEOUT", "full-screen ad load timed out"),
|
|
174
|
-
timeoutMs: remaining ?? 0
|
|
175
|
-
});
|
|
176
|
-
if (outcome instanceof SdkError) {
|
|
177
|
-
throw outcome;
|
|
178
|
-
}
|
|
179
|
-
}
|
|
180
|
-
async function loadFramework() {
|
|
181
|
-
const result = await loader();
|
|
182
|
-
if (!result.available) {
|
|
183
|
-
throw new SdkError("SDK_UNAVAILABLE", result.reason);
|
|
184
|
-
}
|
|
185
|
-
return result.module;
|
|
186
|
-
}
|
|
187
|
-
return { loadFullScreenAd: load, showFullScreenAd: show };
|
|
188
|
-
}
|
|
189
|
-
function reduceShowEvent(event, getReward, setReward) {
|
|
190
|
-
switch (event.type) {
|
|
191
|
-
case "userEarnedReward": {
|
|
192
|
-
// Runtime guard against payload-shape drift; the typed contract marks
|
|
193
|
-
// data as required.
|
|
194
|
-
if (event.data) {
|
|
195
|
-
setReward({ unitType: event.data.unitType, unitAmount: event.data.unitAmount });
|
|
196
|
-
}
|
|
197
|
-
return { done: false };
|
|
198
|
-
}
|
|
199
|
-
case "dismissed": {
|
|
200
|
-
const earned = getReward();
|
|
201
|
-
// Reward only when the provider actually emitted userEarnedReward;
|
|
202
|
-
// dismissal alone never grants anything.
|
|
203
|
-
return earned
|
|
204
|
-
? { done: true, result: { status: "rewarded", reward: earned } }
|
|
205
|
-
: { done: true, result: { status: "dismissed" } };
|
|
206
|
-
}
|
|
207
|
-
case "failedToShow":
|
|
208
|
-
return { done: true, result: { status: "failed", reason: "failedToShow" } };
|
|
209
|
-
default:
|
|
210
|
-
// requested / show / impression / clicked keep the flow running.
|
|
211
|
-
return { done: false };
|
|
212
|
-
}
|
|
213
|
-
}
|
|
214
|
-
/** Transient provider failures are retryable and must not read as UNSUPPORTED. */
|
|
215
|
-
function loadFailure(error) {
|
|
216
|
-
if (error instanceof SdkError)
|
|
217
|
-
return error;
|
|
218
|
-
return new SdkError("AD_LOAD_FAILED", `full-screen ad load failed: ${errorMessage(error)}`, {
|
|
219
|
-
cause: error
|
|
220
|
-
});
|
|
221
|
-
}
|
|
222
|
-
function errorMessage(error) {
|
|
223
|
-
return error instanceof Error ? error.message : String(error);
|
|
224
|
-
}
|
|
225
|
-
function normalizeLoader(framework) {
|
|
226
|
-
return resolvePlatformLoader(framework, createDefaultFrameworkLoader);
|
|
5
|
+
return createAdsAdapter({ ...options, loader: resolvePlatformLoader(options.framework, createDefaultFrameworkLoader) });
|
|
227
6
|
}
|
|
@@ -1,45 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
* Structural contract for the official `@apps-in-toss/framework` Ads APIs,
|
|
3
|
-
* declared from the published documentation so this package type-checks and
|
|
4
|
-
* ships without requiring the official SDK to be installed. The runtime
|
|
5
|
-
* module stays an optional peer dependency.
|
|
6
|
-
*/
|
|
7
|
-
export interface LoadFullScreenAdParams {
|
|
8
|
-
options: {
|
|
9
|
-
adGroupId: string;
|
|
10
|
-
};
|
|
11
|
-
onEvent: (event: {
|
|
12
|
-
type: "loaded";
|
|
13
|
-
}) => void;
|
|
14
|
-
onError: (error: unknown) => void;
|
|
15
|
-
}
|
|
16
|
-
/** Discriminated union per the provider contract: only userEarnedReward carries data. */
|
|
17
|
-
export type FullScreenAdShowEvent = {
|
|
18
|
-
type: "requested" | "show" | "impression" | "clicked" | "dismissed" | "failedToShow";
|
|
19
|
-
} | {
|
|
20
|
-
type: "userEarnedReward";
|
|
21
|
-
data: {
|
|
22
|
-
unitType: string;
|
|
23
|
-
unitAmount: number;
|
|
24
|
-
};
|
|
25
|
-
};
|
|
26
|
-
export interface ShowFullScreenAdParams {
|
|
27
|
-
options: {
|
|
28
|
-
adGroupId: string;
|
|
29
|
-
};
|
|
30
|
-
onEvent: (event: FullScreenAdShowEvent) => void;
|
|
31
|
-
onError: (error: unknown) => void;
|
|
32
|
-
}
|
|
33
|
-
export interface FullScreenAdFunctions {
|
|
34
|
-
loadFullScreenAd(params: LoadFullScreenAdParams): () => void;
|
|
35
|
-
showFullScreenAd(params: ShowFullScreenAdParams): () => void;
|
|
36
|
-
}
|
|
37
|
-
export interface FullScreenAdSupport {
|
|
38
|
-
loadFullScreenAd: FullScreenAdFunctions["loadFullScreenAd"] & {
|
|
39
|
-
isSupported?: () => boolean;
|
|
40
|
-
};
|
|
41
|
-
showFullScreenAd: FullScreenAdFunctions["showFullScreenAd"] & {
|
|
42
|
-
isSupported?: () => boolean;
|
|
43
|
-
};
|
|
44
|
-
}
|
|
1
|
+
export type { LoadFullScreenAdParams, FullScreenAdShowEvent, ShowFullScreenAdParams, FullScreenAdFunctions, FullScreenAdSupport } from "../ads/platform-contract.js";
|
|
45
2
|
//# sourceMappingURL=framework-contract.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"framework-contract.d.ts","sourceRoot":"","sources":["../../src/rn/framework-contract.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"framework-contract.d.ts","sourceRoot":"","sources":["../../src/rn/framework-contract.ts"],"names":[],"mappings":"AAAA,YAAY,EAAE,sBAAsB,EAAE,qBAAqB,EAAE,sBAAsB,EAAE,qBAAqB,EAAE,mBAAmB,EAAE,MAAM,6BAA6B,CAAC"}
|
|
@@ -1,7 +1 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Structural contract for the official `@apps-in-toss/framework` Ads APIs,
|
|
3
|
-
* declared from the published documentation so this package type-checks and
|
|
4
|
-
* ships without requiring the official SDK to be installed. The runtime
|
|
5
|
-
* module stays an optional peer dependency.
|
|
6
|
-
*/
|
|
7
1
|
export {};
|
package/dist/rn/iap.d.ts
CHANGED
|
@@ -5,7 +5,7 @@ import type { IapPlatformLoader, PartialIapPlatformSdk } from "../iap/platform-c
|
|
|
5
5
|
* (optional peer, imported lazily). The contract mirrors the web entry; the
|
|
6
6
|
* two entries share the internal engine but never each other's SDK.
|
|
7
7
|
*/
|
|
8
|
-
export interface ReactNativeIapOptions extends Omit<IapAdapterOptions, "loader"> {
|
|
8
|
+
export interface ReactNativeIapOptions extends Omit<IapAdapterOptions, "loader" | "orderHistoryPagination"> {
|
|
9
9
|
/**
|
|
10
10
|
* Framework injection: pass an `IAP` module instance or a custom loader
|
|
11
11
|
* (tests/consumers). Defaults to the lazy
|