@ait-kit/sdk 0.3.0 → 0.5.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 +197 -13
- 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 +30 -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/platform-loader.d.ts +16 -0
- package/dist/platform-loader.d.ts.map +1 -0
- package/dist/platform-loader.js +35 -0
- package/dist/promotion/adapter.d.ts +3 -0
- package/dist/promotion/adapter.d.ts.map +1 -0
- package/dist/promotion/adapter.js +128 -0
- package/dist/promotion/platform-contract.d.ts +37 -0
- package/dist/promotion/platform-contract.d.ts.map +1 -0
- package/dist/review/adapter.d.ts +3 -0
- package/dist/review/adapter.d.ts.map +1 -0
- package/dist/review/adapter.js +33 -0
- package/dist/review/platform-contract.d.ts +21 -0
- package/dist/review/platform-contract.d.ts.map +1 -0
- package/dist/review/platform-contract.js +1 -0
- package/dist/rn/ads.d.ts +7 -36
- package/dist/rn/ads.d.ts.map +1 -1
- package/dist/rn/ads.js +3 -229
- 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/framework-loader.d.ts.map +1 -1
- package/dist/rn/framework-loader.js +6 -17
- package/dist/rn/iap.d.ts +1 -1
- package/dist/rn/iap.d.ts.map +1 -1
- package/dist/rn/iap.js +10 -29
- package/dist/rn/identity.d.ts.map +1 -1
- package/dist/rn/identity.js +4 -21
- package/dist/rn/index.d.ts +2 -0
- package/dist/rn/index.d.ts.map +1 -1
- package/dist/rn/index.js +2 -0
- package/dist/rn/notify-share.d.ts.map +1 -1
- package/dist/rn/notify-share.js +6 -48
- package/dist/rn/official-module.d.ts +16 -0
- package/dist/rn/official-module.d.ts.map +1 -1
- package/dist/rn/official-module.js +20 -0
- package/dist/rn/platform-loader.d.ts +4 -0
- package/dist/rn/platform-loader.d.ts.map +1 -0
- package/dist/rn/platform-loader.js +5 -0
- package/dist/rn/promotion.d.ts +9 -0
- package/dist/rn/promotion.d.ts.map +1 -0
- package/dist/rn/promotion.js +11 -0
- package/dist/rn/review.d.ts +7 -0
- package/dist/rn/review.d.ts.map +1 -0
- package/dist/rn/review.js +10 -0
- package/dist/rn/storage.d.ts.map +1 -1
- package/dist/rn/storage.js +4 -24
- 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-contract.js +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/webview/framework-loader.js +16 -0
- 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/webview/identity.js +70 -0
- package/dist/webview/index.d.ts +62 -0
- package/dist/webview/index.d.ts.map +1 -0
- package/dist/webview/index.js +51 -0
- 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 +19 -59
- package/dist/webview/platform-loader.d.ts +4 -0
- package/dist/webview/platform-loader.d.ts.map +1 -0
- package/dist/webview/platform-loader.js +5 -0
- package/dist/webview/promotion.d.ts +13 -0
- package/dist/webview/promotion.d.ts.map +1 -0
- package/dist/webview/promotion.js +12 -0
- 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 +7 -3
- package/dist/web/framework-loader.d.ts.map +0 -1
- package/dist/web/framework-loader.js +0 -32
- 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/identity.js +0 -110
- package/dist/web/index.d.ts +0 -47
- package/dist/web/index.d.ts.map +0 -1
- package/dist/web/index.js +0 -43
- package/dist/web/notify-share.d.ts +0 -38
- package/dist/web/notify-share.d.ts.map +0 -1
- /package/dist/{web/iap-contract.js → promotion/platform-contract.js} +0 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"official-module.d.ts","sourceRoot":"","sources":["../../src/rn/official-module.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"official-module.d.ts","sourceRoot":"","sources":["../../src/rn/official-module.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,oBAAoB,EAAE,mBAAmB,EAAE,MAAM,mCAAmC,CAAC;AAEnG,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,kCAAkC,CAAC;AAC5E,OAAO,KAAK,EACV,2BAA2B,EAC3B,uBAAuB,EACxB,MAAM,sCAAsC,CAAC;AAC9C,OAAO,KAAK,EAAyB,gBAAgB,EAAE,MAAM,+BAA+B,CAAC;AAE7F;;;;;;;;;;;;;GAaG;AAEH,+EAA+E;AAC/E,MAAM,WAAW,sBAAsB;IACrC,iBAAiB,EAAE,MAAM,CAAC;IAC1B,QAAQ,EAAE,SAAS,GAAG,SAAS,CAAC;CACjC;AAED;;;;;GAKG;AACH,MAAM,WAAW,0BAA0B;IACzC,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;CACd;AAED,KAAK,gBAAgB,CAAC,CAAC,IAAI,CAAC,GAAG;IAAE,WAAW,CAAC,EAAE,MAAM,OAAO,CAAA;CAAE,CAAC;AAE/D,uEAAuE;AACvE,MAAM,WAAW,yBAAyB;IACxC,oBAAoB,CAAC,EAAE,gBAAgB,CAAC,CAAC,KAAK,EAAE;QAAE,MAAM,EAAE,mBAAmB,CAAA;KAAE,KAAK,OAAO,CACzF;QAAE,GAAG,EAAE,MAAM,CAAA;KAAE,GAAG;QAAE,IAAI,EAAE,MAAM,CAAA;KAAE,GAAG;QAAE,SAAS,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,CAAA;KAAE,GAAG,OAAO,GAAG,SAAS,CAClG,CAAC,CAAC;IACH,aAAa,CAAC,EAAE,gBAAgB,CAAC,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC;IACtD,QAAQ,CAAC,EAAE,gBAAgB,CAAC,MAAM,OAAO,CAAC,sBAAsB,CAAC,CAAC,CAAC;IACnE,eAAe,CAAC,EAAE,gBAAgB,CAChC,MAAM,OAAO,CAAC,0BAA0B,GAAG,OAAO,GAAG,SAAS,CAAC,CAChE,CAAC;IACF,4BAA4B,CAAC,EAAE,gBAAgB,CAC7C,CAAC,MAAM,EAAE,2BAA2B,KAAK,MAAM,IAAI,CACpD,CAAC;IACF,gBAAgB,CAAC,EAAE,gBAAgB,CAAC,CAAC,IAAI,EAAE,MAAM,EAAE,UAAU,CAAC,EAAE,MAAM,KAAK,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC;IAC5F,KAAK,CAAC,EAAE,gBAAgB,CAAC,CAAC,OAAO,EAAE;QAAE,OAAO,EAAE,MAAM,CAAA;KAAE,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC;CAC3E;AAkBD;;;;GAIG;AACH,wBAAgB,uBAAuB,CAAC,MAAM,EAAE,yBAAyB,GAAG,mBAAmB,CA6B9F;AAED;;;;;GAKG;AACH,wBAAgB,2BAA2B,CAAC,MAAM,EAAE,yBAAyB,GAAG,uBAAuB,CAWtG;AAED;;;;;GAKG;AACH,wBAAgB,oBAAoB,CAAC,MAAM,EAAE,yBAAyB,GAAG,gBAAgB,CAsBxF;AAED,8EAA8E;AAC9E,wBAAgB,qBAAqB,CAAC,MAAM,EAAE,yBAAyB,GAAG,OAAO,gCAAgC,EAAE,iBAAiB,CAKnI;AAED,oFAAoF;AACpF,wBAAgB,wBAAwB,CAAC,MAAM,EAAE,yBAAyB,GAAG,oBAAoB,CAUhG"}
|
|
@@ -84,3 +84,23 @@ export function adaptOfficialRnShare(module) {
|
|
|
84
84
|
}
|
|
85
85
|
return share;
|
|
86
86
|
}
|
|
87
|
+
/** Translate the official flat review function, preserving both receivers. */
|
|
88
|
+
export function adaptOfficialRnReview(module) {
|
|
89
|
+
const request = module.requestReview;
|
|
90
|
+
return typeof request === "function"
|
|
91
|
+
? { Review: { request: preserveSupport(request, () => request.call(module)) } }
|
|
92
|
+
: {};
|
|
93
|
+
}
|
|
94
|
+
/** Flat RN API uses a params wrapper and undefined for unsupported app versions. */
|
|
95
|
+
export function adaptOfficialRnPromotion(module) {
|
|
96
|
+
const grant = module.grantPromotionReward;
|
|
97
|
+
if (typeof grant !== "function")
|
|
98
|
+
return {};
|
|
99
|
+
return { Promotion: { grantReward: preserveSupport(grant, async (input) => {
|
|
100
|
+
const result = await grant.call(module, { params: input });
|
|
101
|
+
if (result === undefined) {
|
|
102
|
+
throw new SdkError("UNSUPPORTED", "the installed app version does not support direct promotion rewards");
|
|
103
|
+
}
|
|
104
|
+
return result;
|
|
105
|
+
}) } };
|
|
106
|
+
}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { type PlatformLoader, type PlatformLoadResult } from "../platform-loader.js";
|
|
2
|
+
/** Lazy platform-local import followed by capability-specific selection. */
|
|
3
|
+
export declare function createRnPlatformLoader<T>(select: (module: typeof import("@apps-in-toss/framework")) => PlatformLoadResult<T>, includeErrorDetails?: boolean): PlatformLoader<T>;
|
|
4
|
+
//# sourceMappingURL=platform-loader.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"platform-loader.d.ts","sourceRoot":"","sources":["../../src/rn/platform-loader.ts"],"names":[],"mappings":"AAAA,OAAO,EAAoD,KAAK,cAAc,EAAE,KAAK,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AACvI,4EAA4E;AAC5E,wBAAgB,sBAAsB,CAAC,CAAC,EACtC,MAAM,EAAE,CAAC,MAAM,EAAE,cAAc,yBAAyB,CAAC,KAAK,kBAAkB,CAAC,CAAC,CAAC,EACnF,mBAAmB,UAAO,GACzB,cAAc,CAAC,CAAC,CAAC,CAKnB"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { createCachedPlatformLoader, frameworkImportError } from "../platform-loader.js";
|
|
2
|
+
/** Lazy platform-local import followed by capability-specific selection. */
|
|
3
|
+
export function createRnPlatformLoader(select, includeErrorDetails = true) {
|
|
4
|
+
return createCachedPlatformLoader(async () => select(await import("@apps-in-toss/framework")), error => frameworkImportError("@apps-in-toss/framework", error, includeErrorDetails));
|
|
5
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { PromotionAdapter, PromotionPlatformLoader, PromotionPlatformSdk } from "../promotion/platform-contract.js";
|
|
2
|
+
export interface ReactNativePromotionOptions {
|
|
3
|
+
/** Shared Promotion contract or async loader; defaults to the official SDK. */
|
|
4
|
+
framework?: PromotionPlatformSdk | PromotionPlatformLoader;
|
|
5
|
+
/** Overall wait deadline; 0 (default) disables it. Timeout does not cancel payment. */
|
|
6
|
+
timeoutMs?: number;
|
|
7
|
+
}
|
|
8
|
+
export declare function createReactNativePromotion(options?: ReactNativePromotionOptions): PromotionAdapter;
|
|
9
|
+
//# sourceMappingURL=promotion.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"promotion.d.ts","sourceRoot":"","sources":["../../src/rn/promotion.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,gBAAgB,EAAE,uBAAuB,EAAE,oBAAoB,EAAE,MAAM,mCAAmC,CAAC;AAGzH,MAAM,WAAW,2BAA2B;IAC1C,+EAA+E;IAC/E,SAAS,CAAC,EAAE,oBAAoB,GAAG,uBAAuB,CAAC;IAC3D,uFAAuF;IACvF,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,wBAAgB,0BAA0B,CAAC,OAAO,GAAE,2BAAgC,GAAG,gBAAgB,CAEtG"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { resolvePlatformLoader } from "../platform-loader.js";
|
|
2
|
+
import { createRnPlatformLoader } from "./platform-loader.js";
|
|
3
|
+
import { createPromotionAdapter } from "../promotion/adapter.js";
|
|
4
|
+
import { adaptOfficialRnPromotion } from "./official-module.js";
|
|
5
|
+
export function createReactNativePromotion(options = {}) {
|
|
6
|
+
return createPromotionAdapter(resolvePlatformLoader(options.framework, createDefaultPromotionLoader), options.timeoutMs);
|
|
7
|
+
}
|
|
8
|
+
/** Keep import diagnostics redacted for direct-promotion operations. */
|
|
9
|
+
function createDefaultPromotionLoader() {
|
|
10
|
+
return createRnPlatformLoader(module => ({ available: true, module: adaptOfficialRnPromotion(module) }), false);
|
|
11
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { ReviewAdapter, ReviewPlatformLoader, ReviewPlatformSdk } from "../review/platform-contract.js";
|
|
2
|
+
export interface ReactNativeReviewOptions {
|
|
3
|
+
/** Shared contract injection, or a loader; defaults to the lazy official SDK. */
|
|
4
|
+
framework?: ReviewPlatformSdk | ReviewPlatformLoader;
|
|
5
|
+
}
|
|
6
|
+
export declare function createReactNativeReview(options?: ReactNativeReviewOptions): ReviewAdapter;
|
|
7
|
+
//# sourceMappingURL=review.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"review.d.ts","sourceRoot":"","sources":["../../src/rn/review.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,aAAa,EAAE,oBAAoB,EAAE,iBAAiB,EAAE,MAAM,gCAAgC,CAAC;AAG7G,MAAM,WAAW,wBAAwB;IACvC,iFAAiF;IACjF,SAAS,CAAC,EAAE,iBAAiB,GAAG,oBAAoB,CAAC;CACtD;AAED,wBAAgB,uBAAuB,CAAC,OAAO,GAAE,wBAA6B,GAAG,aAAa,CAE7F"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { resolvePlatformLoader } from "../platform-loader.js";
|
|
2
|
+
import { createRnPlatformLoader } from "./platform-loader.js";
|
|
3
|
+
import { createReviewAdapter } from "../review/adapter.js";
|
|
4
|
+
import { adaptOfficialRnReview } from "./official-module.js";
|
|
5
|
+
export function createReactNativeReview(options = {}) {
|
|
6
|
+
return createReviewAdapter(resolvePlatformLoader(options.framework, createDefaultReviewLoader));
|
|
7
|
+
}
|
|
8
|
+
function createDefaultReviewLoader() {
|
|
9
|
+
return createRnPlatformLoader(module => ({ available: true, module: adaptOfficialRnReview(module) }), false);
|
|
10
|
+
}
|
package/dist/rn/storage.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"storage.d.ts","sourceRoot":"","sources":["../../src/rn/storage.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"storage.d.ts","sourceRoot":"","sources":["../../src/rn/storage.ts"],"names":[],"mappings":"AAEA,OAAO,EAAY,KAAK,UAAU,EAAE,MAAM,aAAa,CAAC;AACxD,OAAO,EAEL,KAAK,qBAAqB,EAC1B,KAAK,kBAAkB,EACxB,MAAM,iCAAiC,CAAC;AAEzC,MAAM,WAAW,yBAAyB;IACxC;;;;OAIG;IACH,SAAS,CAAC,EAAE,kBAAkB,GAAG,qBAAqB,CAAC;CACxD;AAED;;;;GAIG;AACH,wBAAgB,wBAAwB,CACtC,OAAO,GAAE,yBAA8B,GACtC,UAAU,CA8BZ;AAED,wBAAgB,sBAAsB,CACpC,SAAS,EAAE,yBAAyB,CAAC,WAAW,CAAC,GAChD,qBAAqB,CAEvB"}
|
package/dist/rn/storage.js
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { resolvePlatformLoader } from "../platform-loader.js";
|
|
2
|
+
import { createRnPlatformLoader } from "./platform-loader.js";
|
|
1
3
|
import { SdkError } from "../index.js";
|
|
2
4
|
import { createSdkStorageFromPlatform } from "../storage/platform-contract.js";
|
|
3
5
|
/**
|
|
@@ -37,30 +39,8 @@ export function createReactNativeStorage(options = {}) {
|
|
|
37
39
|
};
|
|
38
40
|
}
|
|
39
41
|
export function normalizeStorageLoader(framework) {
|
|
40
|
-
|
|
41
|
-
return createDefaultRnStorageLoader();
|
|
42
|
-
}
|
|
43
|
-
if (typeof framework === "function") {
|
|
44
|
-
return framework;
|
|
45
|
-
}
|
|
46
|
-
return async () => ({ available: true, module: framework });
|
|
42
|
+
return resolvePlatformLoader(framework, createDefaultRnStorageLoader);
|
|
47
43
|
}
|
|
48
44
|
function createDefaultRnStorageLoader() {
|
|
49
|
-
|
|
50
|
-
return async () => {
|
|
51
|
-
if (cached) {
|
|
52
|
-
return { available: true, module: cached };
|
|
53
|
-
}
|
|
54
|
-
try {
|
|
55
|
-
// The official RN SDK exposes Storage under the same namespaced shape
|
|
56
|
-
// as the shared contract, so no conversion is needed.
|
|
57
|
-
const framework = await import("@apps-in-toss/framework");
|
|
58
|
-
cached = framework;
|
|
59
|
-
return { available: true, module: cached };
|
|
60
|
-
}
|
|
61
|
-
catch (error) {
|
|
62
|
-
const message = error instanceof Error ? error.message : String(error);
|
|
63
|
-
return { available: false, reason: `failed to import @apps-in-toss/framework: ${message}` };
|
|
64
|
-
}
|
|
65
|
-
};
|
|
45
|
+
return createRnPlatformLoader(module => ({ available: true, module: module }));
|
|
66
46
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { type SdkShareUiResult } from "../index.js";
|
|
2
2
|
/**
|
|
3
|
-
* Internal platform contract for the share adapter, shared by /rn and /
|
|
3
|
+
* Internal platform contract for the share adapter, shared by /rn and /webview.
|
|
4
4
|
*/
|
|
5
5
|
export interface ShareCreateLinkParams {
|
|
6
6
|
path: string;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { type SdkStorage } from "../index.js";
|
|
2
2
|
/**
|
|
3
3
|
* Internal platform contract for the storage adapters, shared by /rn and
|
|
4
|
-
* /
|
|
4
|
+
* /webview. Keys and string values pass through verbatim — the adapter adds no
|
|
5
5
|
* namespace prefix and performs no key transformation; consumers that want
|
|
6
6
|
* namespacing compose their own keys. Rejections from the underlying SDK
|
|
7
7
|
* propagate to the caller so storage failures stay observable.
|
|
@@ -0,0 +1,10 @@
|
|
|
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 WebViewAdsOptions extends Omit<AdsOptions, "loader"> {
|
|
5
|
+
/** Optional injected framework or loader; the default imports the platform SDK lazily. */
|
|
6
|
+
framework?: AdsPlatformLoader | FullScreenAdSupport;
|
|
7
|
+
}
|
|
8
|
+
export type WebViewAds = AdsAdapter;
|
|
9
|
+
export declare function createWebViewAds(options?: WebViewAdsOptions): WebViewAds;
|
|
10
|
+
//# sourceMappingURL=ads.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ads.d.ts","sourceRoot":"","sources":["../../src/webview/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,iBAAkB,SAAQ,IAAI,CAAC,UAAU,EAAE,QAAQ,CAAC;IACnE,0FAA0F;IAC1F,SAAS,CAAC,EAAE,iBAAiB,GAAG,mBAAmB,CAAC;CACrD;AACD,MAAM,MAAM,UAAU,GAAG,UAAU,CAAC;AAEpC,wBAAgB,gBAAgB,CAAC,OAAO,GAAE,iBAAsB,GAAG,UAAU,CAE5E"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { resolvePlatformLoader } from "../platform-loader.js";
|
|
2
|
+
import { createAdsAdapter } from "../ads/adapter.js";
|
|
3
|
+
import { createWebViewPlatformLoader } from "./platform-loader.js";
|
|
4
|
+
export function createWebViewAds(options = {}) {
|
|
5
|
+
return createAdsAdapter({ ...options, loader: resolvePlatformLoader(options.framework, createDefaultAdsLoader) });
|
|
6
|
+
}
|
|
7
|
+
function createDefaultAdsLoader() {
|
|
8
|
+
return createWebViewPlatformLoader(module => {
|
|
9
|
+
if (typeof module.loadFullScreenAd !== "function" || typeof module.showFullScreenAd !== "function") {
|
|
10
|
+
return { available: false, reason: "@apps-in-toss/web-framework does not expose the Ads APIs" };
|
|
11
|
+
}
|
|
12
|
+
return { available: true, module };
|
|
13
|
+
});
|
|
14
|
+
}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
export interface WebViewBannerEvent {
|
|
2
|
+
slotId: string;
|
|
3
|
+
adGroupId: string;
|
|
4
|
+
adMetadata: {
|
|
5
|
+
creativeId: string;
|
|
6
|
+
requestId: string;
|
|
7
|
+
};
|
|
8
|
+
}
|
|
9
|
+
export interface WebViewBannerError {
|
|
10
|
+
slotId: string;
|
|
11
|
+
adGroupId: string;
|
|
12
|
+
adMetadata: Record<string, never>;
|
|
13
|
+
error: {
|
|
14
|
+
code: number;
|
|
15
|
+
message: string;
|
|
16
|
+
domain?: string;
|
|
17
|
+
mediationId?: string;
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
export interface WebViewBannerCallbacks {
|
|
21
|
+
onAdRendered?: (payload: WebViewBannerEvent) => void;
|
|
22
|
+
onAdViewable?: (payload: WebViewBannerEvent) => void;
|
|
23
|
+
onAdClicked?: (payload: WebViewBannerEvent) => void;
|
|
24
|
+
onAdImpression?: (payload: WebViewBannerEvent) => void;
|
|
25
|
+
onAdFailedToRender?: (payload: WebViewBannerError) => void;
|
|
26
|
+
onNoFill?: (payload: {
|
|
27
|
+
slotId: string;
|
|
28
|
+
adGroupId: string;
|
|
29
|
+
adMetadata: Record<string, never>;
|
|
30
|
+
}) => void;
|
|
31
|
+
}
|
|
32
|
+
export interface WebViewBannerOptions {
|
|
33
|
+
theme?: "auto" | "light" | "dark";
|
|
34
|
+
tone?: "blackAndWhite" | "grey";
|
|
35
|
+
variant?: "card" | "expanded";
|
|
36
|
+
callbacks?: WebViewBannerCallbacks;
|
|
37
|
+
/** Cancels pending attachment and destroys this banner on abort. */
|
|
38
|
+
signal?: AbortSignal;
|
|
39
|
+
}
|
|
40
|
+
export interface WebViewBannerHandle {
|
|
41
|
+
destroy(): void;
|
|
42
|
+
}
|
|
43
|
+
type Supported<F> = F & {
|
|
44
|
+
isSupported?: () => boolean;
|
|
45
|
+
};
|
|
46
|
+
export interface WebViewBannerPlatform {
|
|
47
|
+
TossAds?: {
|
|
48
|
+
/** Must tolerate repeated calls after failures/timeouts, like official idempotent initialization. */
|
|
49
|
+
initialize?: Supported<(options: {
|
|
50
|
+
callbacks?: {
|
|
51
|
+
onInitialized?: () => void;
|
|
52
|
+
onInitializationFailed?: (error: Error) => void;
|
|
53
|
+
};
|
|
54
|
+
}) => void>;
|
|
55
|
+
attachBanner?: Supported<(adGroupId: string, target: string | HTMLElement, options?: Omit<WebViewBannerOptions, "signal">) => WebViewBannerHandle>;
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
export {};
|
|
59
|
+
//# sourceMappingURL=banner-contract.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"banner-contract.d.ts","sourceRoot":"","sources":["../../src/webview/banner-contract.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,kBAAkB;IACjC,MAAM,EAAE,MAAM,CAAC;IACf,SAAS,EAAE,MAAM,CAAC;IAClB,UAAU,EAAE;QAAE,UAAU,EAAE,MAAM,CAAC;QAAC,SAAS,EAAE,MAAM,CAAA;KAAE,CAAC;CACvD;AACD,MAAM,WAAW,kBAAkB;IACjC,MAAM,EAAE,MAAM,CAAC;IACf,SAAS,EAAE,MAAM,CAAC;IAClB,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC;IAClC,KAAK,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,CAAC;QAAC,MAAM,CAAC,EAAE,MAAM,CAAC;QAAC,WAAW,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC;CACjF;AACD,MAAM,WAAW,sBAAsB;IACrC,YAAY,CAAC,EAAE,CAAC,OAAO,EAAE,kBAAkB,KAAK,IAAI,CAAC;IACrD,YAAY,CAAC,EAAE,CAAC,OAAO,EAAE,kBAAkB,KAAK,IAAI,CAAC;IACrD,WAAW,CAAC,EAAE,CAAC,OAAO,EAAE,kBAAkB,KAAK,IAAI,CAAC;IACpD,cAAc,CAAC,EAAE,CAAC,OAAO,EAAE,kBAAkB,KAAK,IAAI,CAAC;IACvD,kBAAkB,CAAC,EAAE,CAAC,OAAO,EAAE,kBAAkB,KAAK,IAAI,CAAC;IAC3D,QAAQ,CAAC,EAAE,CAAC,OAAO,EAAE;QAAE,MAAM,EAAE,MAAM,CAAC;QAAC,SAAS,EAAE,MAAM,CAAC;QAAC,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,KAAK,CAAC,CAAA;KAAE,KAAK,IAAI,CAAC;CACxG;AACD,MAAM,WAAW,oBAAoB;IACnC,KAAK,CAAC,EAAE,MAAM,GAAG,OAAO,GAAG,MAAM,CAAC;IAClC,IAAI,CAAC,EAAE,eAAe,GAAG,MAAM,CAAC;IAChC,OAAO,CAAC,EAAE,MAAM,GAAG,UAAU,CAAC;IAC9B,SAAS,CAAC,EAAE,sBAAsB,CAAC;IACnC,oEAAoE;IACpE,MAAM,CAAC,EAAE,WAAW,CAAC;CACtB;AACD,MAAM,WAAW,mBAAmB;IAAG,OAAO,IAAI,IAAI,CAAC;CAAE;AACzD,KAAK,SAAS,CAAC,CAAC,IAAI,CAAC,GAAG;IAAE,WAAW,CAAC,EAAE,MAAM,OAAO,CAAA;CAAE,CAAC;AACxD,MAAM,WAAW,qBAAqB;IACpC,OAAO,CAAC,EAAE;QACR,qGAAqG;QACrG,UAAU,CAAC,EAAE,SAAS,CAAC,CAAC,OAAO,EAAE;YAAE,SAAS,CAAC,EAAE;gBAAE,aAAa,CAAC,EAAE,MAAM,IAAI,CAAC;gBAAC,sBAAsB,CAAC,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,IAAI,CAAA;aAAE,CAAA;SAAE,KAAK,IAAI,CAAC,CAAC;QAC3I,YAAY,CAAC,EAAE,SAAS,CAAC,CAAC,SAAS,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,WAAW,EAAE,OAAO,CAAC,EAAE,IAAI,CAAC,oBAAoB,EAAE,QAAQ,CAAC,KAAK,mBAAmB,CAAC,CAAC;KACpJ,CAAC;CACH"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { type PlatformLoader } from "../platform-loader.js";
|
|
2
|
+
import type { WebViewBannerHandle, WebViewBannerOptions, WebViewBannerPlatform } from "./banner-contract.js";
|
|
3
|
+
export type { WebViewBannerHandle, WebViewBannerOptions, WebViewBannerEvent, WebViewBannerError, WebViewBannerCallbacks, WebViewBannerPlatform } from "./banner-contract.js";
|
|
4
|
+
export interface WebViewBannerAdsOptions {
|
|
5
|
+
framework?: WebViewBannerPlatform | PlatformLoader<WebViewBannerPlatform>;
|
|
6
|
+
/** Overall initialization deadline including SDK import; integer 1..2147483647ms, default 15000ms. */
|
|
7
|
+
initializeTimeoutMs?: number;
|
|
8
|
+
}
|
|
9
|
+
export interface WebViewBannerAds {
|
|
10
|
+
initialize(): Promise<void>;
|
|
11
|
+
/** Resolves once attached, not once rendered. Own a distinct target per live handle. */
|
|
12
|
+
attachBanner(adGroupId: string, target: string | HTMLElement, options?: WebViewBannerOptions): Promise<WebViewBannerHandle>;
|
|
13
|
+
}
|
|
14
|
+
export declare function createWebViewBannerAds(options?: WebViewBannerAdsOptions): WebViewBannerAds;
|
|
15
|
+
//# sourceMappingURL=banner.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"banner.d.ts","sourceRoot":"","sources":["../../src/webview/banner.ts"],"names":[],"mappings":"AACA,OAAO,EAAyB,KAAK,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAEnF,OAAO,KAAK,EAAE,mBAAmB,EAAE,oBAAoB,EAAE,qBAAqB,EAA8C,MAAM,sBAAsB,CAAC;AACzJ,YAAY,EAAE,mBAAmB,EAAE,oBAAoB,EAAE,kBAAkB,EAAE,kBAAkB,EAAE,sBAAsB,EAAE,qBAAqB,EAAE,MAAM,sBAAsB,CAAC;AAE7K,MAAM,WAAW,uBAAuB;IACtC,SAAS,CAAC,EAAE,qBAAqB,GAAG,cAAc,CAAC,qBAAqB,CAAC,CAAC;IAC1E,sGAAsG;IACtG,mBAAmB,CAAC,EAAE,MAAM,CAAC;CAC9B;AACD,MAAM,WAAW,gBAAgB;IAC/B,UAAU,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;IAC5B,wFAAwF;IACxF,YAAY,CAAC,SAAS,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,WAAW,EAAE,OAAO,CAAC,EAAE,oBAAoB,GAAG,OAAO,CAAC,mBAAmB,CAAC,CAAC;CAC7H;AAID,wBAAgB,sBAAsB,CAAC,OAAO,GAAE,uBAA4B,GAAG,gBAAgB,CA+H9F"}
|
|
@@ -0,0 +1,188 @@
|
|
|
1
|
+
import { SdkError } from "../index.js";
|
|
2
|
+
import { resolvePlatformLoader } from "../platform-loader.js";
|
|
3
|
+
import { createWebViewPlatformLoader } from "./platform-loader.js";
|
|
4
|
+
// Prevent two adapter instances from claiming the provider's same-element shared handle.
|
|
5
|
+
const claimedTargets = new WeakSet();
|
|
6
|
+
export function createWebViewBannerAds(options = {}) {
|
|
7
|
+
const timeoutMs = options.initializeTimeoutMs ?? 15_000;
|
|
8
|
+
if (!Number.isSafeInteger(timeoutMs) || timeoutMs < 1 || timeoutMs > 2_147_483_647) {
|
|
9
|
+
throw new SdkError("INVALID_BANNER_INPUT", "initializeTimeoutMs must be an integer from 1 to 2147483647");
|
|
10
|
+
}
|
|
11
|
+
const loader = resolvePlatformLoader(options.framework, () => createWebViewPlatformLoader(module => ({ available: true, module })));
|
|
12
|
+
let initialized;
|
|
13
|
+
let pending;
|
|
14
|
+
const initialize = () => {
|
|
15
|
+
if (initialized)
|
|
16
|
+
return Promise.resolve();
|
|
17
|
+
if (pending)
|
|
18
|
+
return pending;
|
|
19
|
+
const started = now();
|
|
20
|
+
const operation = new Promise((resolve, reject) => {
|
|
21
|
+
let settled = false;
|
|
22
|
+
const finish = (error, module) => {
|
|
23
|
+
if (settled)
|
|
24
|
+
return;
|
|
25
|
+
settled = true;
|
|
26
|
+
clearTimeout(timer);
|
|
27
|
+
if (module === undefined)
|
|
28
|
+
reject(error);
|
|
29
|
+
else {
|
|
30
|
+
initialized = module;
|
|
31
|
+
resolve();
|
|
32
|
+
}
|
|
33
|
+
};
|
|
34
|
+
const expired = () => now() - started >= timeoutMs;
|
|
35
|
+
const timeout = () => new SdkError("BANNER_INIT_TIMEOUT", "banner initialization timed out");
|
|
36
|
+
const timer = setTimeout(() => finish(timeout()), timeoutMs);
|
|
37
|
+
Promise.resolve().then(loader).then(result => {
|
|
38
|
+
if (settled)
|
|
39
|
+
return;
|
|
40
|
+
if (expired()) {
|
|
41
|
+
finish(timeout());
|
|
42
|
+
return;
|
|
43
|
+
}
|
|
44
|
+
if (!result.available) {
|
|
45
|
+
finish(new SdkError("SDK_UNAVAILABLE", result.reason));
|
|
46
|
+
return;
|
|
47
|
+
}
|
|
48
|
+
const api = result.module.TossAds;
|
|
49
|
+
const init = api?.initialize;
|
|
50
|
+
if (!supported(init)) {
|
|
51
|
+
finish(new SdkError("UNSUPPORTED", "banner initialization is not supported"));
|
|
52
|
+
return;
|
|
53
|
+
}
|
|
54
|
+
if (expired()) {
|
|
55
|
+
finish(timeout());
|
|
56
|
+
return;
|
|
57
|
+
}
|
|
58
|
+
let registering = true;
|
|
59
|
+
let outcome;
|
|
60
|
+
const complete = (value) => {
|
|
61
|
+
if (outcome)
|
|
62
|
+
return;
|
|
63
|
+
outcome = value;
|
|
64
|
+
if (!registering)
|
|
65
|
+
settleOutcome();
|
|
66
|
+
};
|
|
67
|
+
const settleOutcome = () => {
|
|
68
|
+
if (expired())
|
|
69
|
+
finish(timeout());
|
|
70
|
+
else if (outcome?.ok)
|
|
71
|
+
finish(undefined, result.module);
|
|
72
|
+
else if (outcome)
|
|
73
|
+
finish(outcome.error);
|
|
74
|
+
};
|
|
75
|
+
init.call(api, { callbacks: {
|
|
76
|
+
onInitialized: () => complete({ ok: true }),
|
|
77
|
+
onInitializationFailed: error => complete({ ok: false, error })
|
|
78
|
+
} });
|
|
79
|
+
registering = false;
|
|
80
|
+
if (outcome)
|
|
81
|
+
settleOutcome();
|
|
82
|
+
}).catch(error => finish(error));
|
|
83
|
+
});
|
|
84
|
+
pending = operation;
|
|
85
|
+
void operation.then(() => { pending = undefined; }, () => { pending = undefined; });
|
|
86
|
+
return operation;
|
|
87
|
+
};
|
|
88
|
+
return { initialize, async attachBanner(adGroupId, target, attachOptions = {}) {
|
|
89
|
+
if (typeof adGroupId !== "string" || !adGroupId.trim())
|
|
90
|
+
throw new SdkError("INVALID_BANNER_INPUT", "adGroupId must be non-empty");
|
|
91
|
+
let element;
|
|
92
|
+
try {
|
|
93
|
+
element = typeof target === "string" ? (typeof document === "undefined" ? null : document.querySelector(target)) : target;
|
|
94
|
+
}
|
|
95
|
+
catch (error) {
|
|
96
|
+
throw new SdkError("INVALID_BANNER_INPUT", "banner target selector is invalid", { cause: error });
|
|
97
|
+
}
|
|
98
|
+
// Namespace validation also accepts HTML elements from another document realm.
|
|
99
|
+
if (!element || element.nodeType !== 1 || element.namespaceURI !== "http://www.w3.org/1999/xhtml") {
|
|
100
|
+
throw new SdkError("INVALID_BANNER_INPUT", "banner target must resolve to an HTML element");
|
|
101
|
+
}
|
|
102
|
+
if (claimedTargets.has(element))
|
|
103
|
+
throw new SdkError("BANNER_TARGET_IN_USE", "destroy the existing banner before reusing its target");
|
|
104
|
+
const { signal, callbacks, ...style } = attachOptions;
|
|
105
|
+
throwIfAborted(signal);
|
|
106
|
+
claimedTargets.add(element);
|
|
107
|
+
let destroyed = false;
|
|
108
|
+
let providerHandle;
|
|
109
|
+
const handle = { destroy() {
|
|
110
|
+
if (destroyed)
|
|
111
|
+
return;
|
|
112
|
+
destroyed = true;
|
|
113
|
+
signal?.removeEventListener("abort", onAbort);
|
|
114
|
+
try {
|
|
115
|
+
providerHandle?.destroy();
|
|
116
|
+
}
|
|
117
|
+
finally {
|
|
118
|
+
claimedTargets.delete(element);
|
|
119
|
+
}
|
|
120
|
+
} };
|
|
121
|
+
const onAbort = () => handle.destroy();
|
|
122
|
+
try {
|
|
123
|
+
await initialize();
|
|
124
|
+
throwIfAborted(signal);
|
|
125
|
+
const api = initialized?.TossAds;
|
|
126
|
+
const attach = api?.attachBanner;
|
|
127
|
+
if (!supported(attach))
|
|
128
|
+
throw new SdkError("UNSUPPORTED", "banner attachment is not supported");
|
|
129
|
+
let registering = true;
|
|
130
|
+
let registrationError;
|
|
131
|
+
// Capture the resource before invoking consumer callbacks, including
|
|
132
|
+
// callbacks the provider emits synchronously during registration.
|
|
133
|
+
const forward = (callback) => (payload) => {
|
|
134
|
+
if (callback)
|
|
135
|
+
queueMicrotask(() => { if (!destroyed)
|
|
136
|
+
callback(payload); });
|
|
137
|
+
};
|
|
138
|
+
const forwarded = {
|
|
139
|
+
onAdRendered: forward(callbacks?.onAdRendered),
|
|
140
|
+
onAdViewable: forward(callbacks?.onAdViewable),
|
|
141
|
+
onAdClicked: forward(callbacks?.onAdClicked),
|
|
142
|
+
onAdImpression: forward(callbacks?.onAdImpression),
|
|
143
|
+
onNoFill: forward(callbacks?.onNoFill),
|
|
144
|
+
onAdFailedToRender: payload => {
|
|
145
|
+
if (registering)
|
|
146
|
+
registrationError = payload;
|
|
147
|
+
forward(callbacks?.onAdFailedToRender)(payload);
|
|
148
|
+
}
|
|
149
|
+
};
|
|
150
|
+
let attached;
|
|
151
|
+
try {
|
|
152
|
+
attached = attach.call(api, adGroupId, element, { ...style, callbacks: forwarded });
|
|
153
|
+
}
|
|
154
|
+
catch (error) {
|
|
155
|
+
throw new SdkError("BANNER_ATTACH_FAILED", "provider threw during banner attachment", { cause: error });
|
|
156
|
+
}
|
|
157
|
+
registering = false;
|
|
158
|
+
if (!attached || typeof attached.destroy !== "function")
|
|
159
|
+
throw new SdkError("BANNER_ATTACH_FAILED", "provider returned no banner handle");
|
|
160
|
+
providerHandle = attached;
|
|
161
|
+
if (registrationError)
|
|
162
|
+
throw new SdkError("BANNER_ATTACH_FAILED", "provider rejected banner attachment", { cause: registrationError });
|
|
163
|
+
signal?.addEventListener("abort", onAbort, { once: true });
|
|
164
|
+
if (signal?.aborted) {
|
|
165
|
+
handle.destroy();
|
|
166
|
+
throwIfAborted(signal);
|
|
167
|
+
}
|
|
168
|
+
return handle;
|
|
169
|
+
}
|
|
170
|
+
catch (error) {
|
|
171
|
+
try {
|
|
172
|
+
handle.destroy();
|
|
173
|
+
}
|
|
174
|
+
catch (cleanupError) {
|
|
175
|
+
throw new AggregateError([error, cleanupError], "banner attachment and cleanup failed");
|
|
176
|
+
}
|
|
177
|
+
throw error;
|
|
178
|
+
}
|
|
179
|
+
} };
|
|
180
|
+
}
|
|
181
|
+
function supported(fn) {
|
|
182
|
+
return typeof fn === "function" && (typeof fn.isSupported !== "function" || fn.isSupported());
|
|
183
|
+
}
|
|
184
|
+
function now() { return typeof performance !== "undefined" ? performance.now() : Date.now(); }
|
|
185
|
+
function throwIfAborted(signal) {
|
|
186
|
+
if (signal?.aborted)
|
|
187
|
+
throw signal.reason ?? new DOMException("Banner attachment aborted", "AbortError");
|
|
188
|
+
}
|
|
@@ -5,5 +5,5 @@ import type { IapPlatformLoader } from "../iap/platform-contract.js";
|
|
|
5
5
|
* operation needs it. Failed imports are never cached, so a later call
|
|
6
6
|
* retries; successful loads are cached.
|
|
7
7
|
*/
|
|
8
|
-
export declare function
|
|
8
|
+
export declare function createDefaultWebViewFrameworkLoader(): IapPlatformLoader;
|
|
9
9
|
//# sourceMappingURL=framework-loader.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"framework-loader.d.ts","sourceRoot":"","sources":["../../src/webview/framework-loader.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,6BAA6B,CAAC;AAErE;;;;;GAKG;AACH,wBAAgB,mCAAmC,IAAI,iBAAiB,CAQvE"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { createWebViewPlatformLoader } from "./platform-loader.js";
|
|
2
|
+
/**
|
|
3
|
+
* Default lazy loader for the official web SDK: imports
|
|
4
|
+
* `@apps-in-toss/web-framework` (an optional peer) only when an IAP
|
|
5
|
+
* operation needs it. Failed imports are never cached, so a later call
|
|
6
|
+
* retries; successful loads are cached.
|
|
7
|
+
*/
|
|
8
|
+
export function createDefaultWebViewFrameworkLoader() {
|
|
9
|
+
return createWebViewPlatformLoader((framework) => {
|
|
10
|
+
const iap = framework.IAP;
|
|
11
|
+
if (typeof iap !== "object" || iap === null) {
|
|
12
|
+
return { available: false, reason: "@apps-in-toss/web-framework does not expose an IAP domain" };
|
|
13
|
+
}
|
|
14
|
+
return { available: true, module: iap };
|
|
15
|
+
});
|
|
16
|
+
}
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import type { IapPlatformSdk } from "../iap/platform-contract.js";
|
|
2
2
|
/**
|
|
3
3
|
* Structural contract for the official `@apps-in-toss/web-framework` IAP
|
|
4
|
-
* domain, declared from the published documentation so /
|
|
4
|
+
* domain, declared from the published documentation so /webview consumers
|
|
5
5
|
* type-check without the official web SDK installed. It is intentionally
|
|
6
6
|
* independent of the /rn contract — neither entry requires the other
|
|
7
7
|
* platform's package, in JavaScript or in generated declarations.
|
|
8
8
|
*/
|
|
9
|
-
export type
|
|
10
|
-
export type
|
|
11
|
-
IAP:
|
|
9
|
+
export type WebViewIapModule = IapPlatformSdk;
|
|
10
|
+
export type WebViewIapFramework = {
|
|
11
|
+
IAP: WebViewIapModule;
|
|
12
12
|
};
|
|
13
13
|
//# sourceMappingURL=iap-contract.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"iap-contract.d.ts","sourceRoot":"","sources":["../../src/webview/iap-contract.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,6BAA6B,CAAC;AAElE;;;;;;GAMG;AACH,MAAM,MAAM,gBAAgB,GAAG,cAAc,CAAC;AAE9C,MAAM,MAAM,mBAAmB,GAAG;IAChC,GAAG,EAAE,gBAAgB,CAAC;CACvB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { type SdkAnonymousKey, type SdkLoginResult, type SdkStorage } from "../index.js";
|
|
2
|
+
import { type IdentityPlatformLoader, type IdentityPlatformSdk } from "../identity/platform-contract.js";
|
|
3
|
+
import { type StoragePlatformLoader, type StoragePlatformSdk } from "../storage/platform-contract.js";
|
|
4
|
+
export interface WebViewIdentityOptions {
|
|
5
|
+
/**
|
|
6
|
+
* WebView framework injection: pass a module exposing TossAuth/User or a
|
|
7
|
+
* custom loader (tests, dev replacements). Defaults to the lazy
|
|
8
|
+
* `import("@apps-in-toss/web-framework")` loader. The default never
|
|
9
|
+
* guesses the environment or substitutes a fake login.
|
|
10
|
+
*/
|
|
11
|
+
framework?: IdentityPlatformSdk | IdentityPlatformLoader;
|
|
12
|
+
}
|
|
13
|
+
export interface WebViewIdentity {
|
|
14
|
+
/** Starts the platform login and validates/preserves the result. */
|
|
15
|
+
login(): Promise<SdkLoginResult>;
|
|
16
|
+
/** Looks up the SDK-issued anonymous key; never fabricates one. */
|
|
17
|
+
getAnonymousKey(): Promise<SdkAnonymousKey>;
|
|
18
|
+
}
|
|
19
|
+
export declare function createWebViewIdentity(options?: WebViewIdentityOptions): WebViewIdentity;
|
|
20
|
+
export interface WebViewStorageOptions {
|
|
21
|
+
/**
|
|
22
|
+
* WebView framework injection: pass a module exposing Storage or a custom
|
|
23
|
+
* loader. Defaults to the lazy `import("@apps-in-toss/web-framework")`
|
|
24
|
+
* loader.
|
|
25
|
+
*/
|
|
26
|
+
framework?: StoragePlatformSdk | StoragePlatformLoader;
|
|
27
|
+
}
|
|
28
|
+
/** SDK-backed storage for web with the same verbatim-key contract as /rn. */
|
|
29
|
+
export declare function createWebViewStorage(options?: WebViewStorageOptions): SdkStorage;
|
|
30
|
+
/** @deprecated Use createWebViewIdentity from @ait-kit/sdk/webview. */
|
|
31
|
+
export declare const createWebIdentity: typeof createWebViewIdentity;
|
|
32
|
+
/** @deprecated Use createWebViewStorage from @ait-kit/sdk/webview. */
|
|
33
|
+
export declare const createWebStorage: typeof createWebViewStorage;
|
|
34
|
+
/** @deprecated Use WebViewIdentity from @ait-kit/sdk/webview. */
|
|
35
|
+
export type WebIdentity = WebViewIdentity;
|
|
36
|
+
/** @deprecated Use WebViewIdentityOptions from @ait-kit/sdk/webview. */
|
|
37
|
+
export type WebIdentityOptions = WebViewIdentityOptions;
|
|
38
|
+
/** @deprecated Use WebViewStorageOptions from @ait-kit/sdk/webview. */
|
|
39
|
+
export type WebStorageOptions = WebViewStorageOptions;
|
|
40
|
+
//# sourceMappingURL=identity.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"identity.d.ts","sourceRoot":"","sources":["../../src/webview/identity.ts"],"names":[],"mappings":"AAEA,OAAO,EAAY,KAAK,eAAe,EAAE,KAAK,cAAc,EAAE,KAAK,UAAU,EAAE,MAAM,aAAa,CAAC;AACnG,OAAO,EACL,KAAK,sBAAsB,EAC3B,KAAK,mBAAmB,EAGzB,MAAM,kCAAkC,CAAC;AAC1C,OAAO,EAEL,KAAK,qBAAqB,EAC1B,KAAK,kBAAkB,EACxB,MAAM,iCAAiC,CAAC;AAEzC,MAAM,WAAW,sBAAsB;IACrC;;;;;OAKG;IACH,SAAS,CAAC,EAAE,mBAAmB,GAAG,sBAAsB,CAAC;CAC1D;AAED,MAAM,WAAW,eAAe;IAC9B,oEAAoE;IACpE,KAAK,IAAI,OAAO,CAAC,cAAc,CAAC,CAAC;IACjC,mEAAmE;IACnE,eAAe,IAAI,OAAO,CAAC,eAAe,CAAC,CAAC;CAC7C;AAED,wBAAgB,qBAAqB,CAAC,OAAO,GAAE,sBAA2B,GAAG,eAAe,CAa3F;AAED,MAAM,WAAW,qBAAqB;IACpC;;;;OAIG;IACH,SAAS,CAAC,EAAE,kBAAkB,GAAG,qBAAqB,CAAC;CACxD;AAED,6EAA6E;AAC7E,wBAAgB,oBAAoB,CAAC,OAAO,GAAE,qBAA0B,GAAG,UAAU,CA8BpF;AAyBD,uEAAuE;AACvE,eAAO,MAAM,iBAAiB,8BAAwB,CAAC;AACvD,sEAAsE;AACtE,eAAO,MAAM,gBAAgB,6BAAuB,CAAC;AACrD,iEAAiE;AACjE,MAAM,MAAM,WAAW,GAAG,eAAe,CAAC;AAC1C,wEAAwE;AACxE,MAAM,MAAM,kBAAkB,GAAG,sBAAsB,CAAC;AACxD,uEAAuE;AACvE,MAAM,MAAM,iBAAiB,GAAG,qBAAqB,CAAC"}
|