@ait-kit/sdk 0.2.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/LICENSE +21 -0
- package/README.md +236 -0
- package/dist/event-flow.d.ts +36 -0
- package/dist/event-flow.d.ts.map +1 -0
- package/dist/event-flow.js +101 -0
- package/dist/iap/adapter.d.ts +47 -0
- package/dist/iap/adapter.d.ts.map +1 -0
- package/dist/iap/adapter.js +175 -0
- package/dist/iap/grant-coordinator.d.ts +36 -0
- package/dist/iap/grant-coordinator.d.ts.map +1 -0
- package/dist/iap/grant-coordinator.js +69 -0
- package/dist/iap/platform-contract.d.ts +55 -0
- package/dist/iap/platform-contract.d.ts.map +1 -0
- package/dist/iap/platform-contract.js +26 -0
- package/dist/iap/purchase-flow.d.ts +34 -0
- package/dist/iap/purchase-flow.d.ts.map +1 -0
- package/dist/iap/purchase-flow.js +167 -0
- package/dist/identity/platform-contract.d.ts +44 -0
- package/dist/identity/platform-contract.d.ts.map +1 -0
- package/dist/identity/platform-contract.js +71 -0
- package/dist/index.d.ts +215 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +16 -0
- package/dist/notification/platform-contract.d.ts +43 -0
- package/dist/notification/platform-contract.d.ts.map +1 -0
- package/dist/notification/platform-contract.js +89 -0
- package/dist/rn/ads.d.ts +39 -0
- package/dist/rn/ads.d.ts.map +1 -0
- package/dist/rn/ads.js +226 -0
- package/dist/rn/framework-contract.d.ts +45 -0
- package/dist/rn/framework-contract.d.ts.map +1 -0
- package/dist/rn/framework-contract.js +7 -0
- package/dist/rn/framework-loader.d.ts +22 -0
- package/dist/rn/framework-loader.d.ts.map +1 -0
- package/dist/rn/framework-loader.js +26 -0
- package/dist/rn/iap.d.ts +19 -0
- package/dist/rn/iap.d.ts.map +1 -0
- package/dist/rn/iap.js +35 -0
- package/dist/rn/identity.d.ts +20 -0
- package/dist/rn/identity.d.ts.map +1 -0
- package/dist/rn/identity.js +42 -0
- package/dist/rn/index.d.ts +27 -0
- package/dist/rn/index.d.ts.map +1 -0
- package/dist/rn/index.js +24 -0
- package/dist/rn/notify-share.d.ts +42 -0
- package/dist/rn/notify-share.d.ts.map +1 -0
- package/dist/rn/notify-share.js +159 -0
- package/dist/rn/storage.d.ts +18 -0
- package/dist/rn/storage.d.ts.map +1 -0
- package/dist/rn/storage.js +64 -0
- package/dist/share/platform-contract.d.ts +41 -0
- package/dist/share/platform-contract.d.ts.map +1 -0
- package/dist/share/platform-contract.js +34 -0
- package/dist/storage/platform-contract.d.ts +26 -0
- package/dist/storage/platform-contract.d.ts.map +1 -0
- package/dist/storage/platform-contract.js +16 -0
- package/dist/web/framework-loader.d.ts +9 -0
- package/dist/web/framework-loader.d.ts.map +1 -0
- package/dist/web/framework-loader.js +32 -0
- package/dist/web/iap-contract.d.ts +13 -0
- package/dist/web/iap-contract.d.ts.map +1 -0
- package/dist/web/iap-contract.js +1 -0
- package/dist/web/identity.d.ts +30 -0
- package/dist/web/identity.d.ts.map +1 -0
- package/dist/web/identity.js +87 -0
- package/dist/web/index.d.ts +47 -0
- package/dist/web/index.d.ts.map +1 -0
- package/dist/web/index.js +43 -0
- package/dist/web/notify-share.d.ts +37 -0
- package/dist/web/notify-share.d.ts.map +1 -0
- package/dist/web/notify-share.js +154 -0
- package/package.json +66 -0
|
@@ -0,0 +1,45 @@
|
|
|
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
|
+
}
|
|
45
|
+
//# sourceMappingURL=framework-contract.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"framework-contract.d.ts","sourceRoot":"","sources":["../../src/rn/framework-contract.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,MAAM,WAAW,sBAAsB;IACrC,OAAO,EAAE;QAAE,SAAS,EAAE,MAAM,CAAA;KAAE,CAAC;IAC/B,OAAO,EAAE,CAAC,KAAK,EAAE;QAAE,IAAI,EAAE,QAAQ,CAAA;KAAE,KAAK,IAAI,CAAC;IAC7C,OAAO,EAAE,CAAC,KAAK,EAAE,OAAO,KAAK,IAAI,CAAC;CACnC;AAED,yFAAyF;AACzF,MAAM,MAAM,qBAAqB,GAC7B;IAAE,IAAI,EAAE,WAAW,GAAG,MAAM,GAAG,YAAY,GAAG,SAAS,GAAG,WAAW,GAAG,cAAc,CAAA;CAAE,GACxF;IAAE,IAAI,EAAE,kBAAkB,CAAC;IAAC,IAAI,EAAE;QAAE,QAAQ,EAAE,MAAM,CAAC;QAAC,UAAU,EAAE,MAAM,CAAA;KAAE,CAAA;CAAE,CAAC;AAEjF,MAAM,WAAW,sBAAsB;IACrC,OAAO,EAAE;QAAE,SAAS,EAAE,MAAM,CAAA;KAAE,CAAC;IAC/B,OAAO,EAAE,CAAC,KAAK,EAAE,qBAAqB,KAAK,IAAI,CAAC;IAChD,OAAO,EAAE,CAAC,KAAK,EAAE,OAAO,KAAK,IAAI,CAAC;CACnC;AAED,MAAM,WAAW,qBAAqB;IACpC,gBAAgB,CAAC,MAAM,EAAE,sBAAsB,GAAG,MAAM,IAAI,CAAC;IAC7D,gBAAgB,CAAC,MAAM,EAAE,sBAAsB,GAAG,MAAM,IAAI,CAAC;CAC9D;AAED,MAAM,WAAW,mBAAmB;IAClC,gBAAgB,EAAE,qBAAqB,CAAC,kBAAkB,CAAC,GAAG;QAC5D,WAAW,CAAC,EAAE,MAAM,OAAO,CAAC;KAC7B,CAAC;IACF,gBAAgB,EAAE,qBAAqB,CAAC,kBAAkB,CAAC,GAAG;QAC5D,WAAW,CAAC,EAAE,MAAM,OAAO,CAAC;KAC7B,CAAC;CACH"}
|
|
@@ -0,0 +1,7 @@
|
|
|
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 {};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { FullScreenAdSupport } from "./framework-contract.js";
|
|
2
|
+
/**
|
|
3
|
+
* Result of trying to load the official framework module. The boolean shape
|
|
4
|
+
* (instead of thrown errors) keeps call sites explicit about the "module
|
|
5
|
+
* missing" case, which is an expected condition for optional peers.
|
|
6
|
+
*/
|
|
7
|
+
export type FrameworkLoadResult = {
|
|
8
|
+
available: true;
|
|
9
|
+
module: FullScreenAdSupport;
|
|
10
|
+
} | {
|
|
11
|
+
available: false;
|
|
12
|
+
reason: string;
|
|
13
|
+
};
|
|
14
|
+
export type FrameworkLoader = () => Promise<FrameworkLoadResult>;
|
|
15
|
+
/**
|
|
16
|
+
* Default lazy loader: imports `@apps-in-toss/framework` only when an ad
|
|
17
|
+
* operation needs it. A failed import is never cached, so a later call
|
|
18
|
+
* retries (the module may appear after an update or late bundle load);
|
|
19
|
+
* successful loads are cached.
|
|
20
|
+
*/
|
|
21
|
+
export declare function createDefaultFrameworkLoader(): FrameworkLoader;
|
|
22
|
+
//# sourceMappingURL=framework-loader.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"framework-loader.d.ts","sourceRoot":"","sources":["../../src/rn/framework-loader.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,yBAAyB,CAAC;AAEnE;;;;GAIG;AACH,MAAM,MAAM,mBAAmB,GAC3B;IAAE,SAAS,EAAE,IAAI,CAAC;IAAC,MAAM,EAAE,mBAAmB,CAAA;CAAE,GAChD;IAAE,SAAS,EAAE,KAAK,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,CAAC;AAEzC,MAAM,MAAM,eAAe,GAAG,MAAM,OAAO,CAAC,mBAAmB,CAAC,CAAC;AAEjE;;;;;GAKG;AACH,wBAAgB,4BAA4B,IAAI,eAAe,CAkB9D"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Default lazy loader: imports `@apps-in-toss/framework` only when an ad
|
|
3
|
+
* operation needs it. A failed import is never cached, so a later call
|
|
4
|
+
* retries (the module may appear after an update or late bundle load);
|
|
5
|
+
* successful loads are cached.
|
|
6
|
+
*/
|
|
7
|
+
export function createDefaultFrameworkLoader() {
|
|
8
|
+
let cached;
|
|
9
|
+
return async () => {
|
|
10
|
+
if (cached) {
|
|
11
|
+
return { available: true, module: cached };
|
|
12
|
+
}
|
|
13
|
+
try {
|
|
14
|
+
const module = (await import("@apps-in-toss/framework"));
|
|
15
|
+
if (typeof module.loadFullScreenAd !== "function" || typeof module.showFullScreenAd !== "function") {
|
|
16
|
+
return { available: false, reason: "@apps-in-toss/framework does not expose the Ads APIs" };
|
|
17
|
+
}
|
|
18
|
+
cached = module;
|
|
19
|
+
return { available: true, module: cached };
|
|
20
|
+
}
|
|
21
|
+
catch (error) {
|
|
22
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
23
|
+
return { available: false, reason: `failed to import @apps-in-toss/framework: ${message}` };
|
|
24
|
+
}
|
|
25
|
+
};
|
|
26
|
+
}
|
package/dist/rn/iap.d.ts
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { type IapAdapterOptions, type IapRecoveryResult } from "../iap/adapter.js";
|
|
2
|
+
import type { IapPlatformLoader, PartialIapPlatformSdk } from "../iap/platform-contract.js";
|
|
3
|
+
/**
|
|
4
|
+
* IAP adapter for React Native over the official `@apps-in-toss/framework`
|
|
5
|
+
* (optional peer, imported lazily). The contract mirrors the web entry; the
|
|
6
|
+
* two entries share the internal engine but never each other's SDK.
|
|
7
|
+
*/
|
|
8
|
+
export interface ReactNativeIapOptions extends Omit<IapAdapterOptions, "loader"> {
|
|
9
|
+
/**
|
|
10
|
+
* Framework injection: pass an `IAP` module instance or a custom loader
|
|
11
|
+
* (tests/consumers). Defaults to the lazy
|
|
12
|
+
* `import("@apps-in-toss/framework")` loader.
|
|
13
|
+
*/
|
|
14
|
+
framework?: PartialIapPlatformSdk | IapPlatformLoader;
|
|
15
|
+
}
|
|
16
|
+
export type ReactNativeIap = ReturnType<typeof createReactNativeIap>;
|
|
17
|
+
export type { IapRecoveryResult };
|
|
18
|
+
export declare function createReactNativeIap(options: ReactNativeIapOptions): import("../iap/adapter.js").IapAdapter;
|
|
19
|
+
//# sourceMappingURL=iap.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"iap.d.ts","sourceRoot":"","sources":["../../src/rn/iap.ts"],"names":[],"mappings":"AAAA,OAAO,EAAoB,KAAK,iBAAiB,EAAE,KAAK,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AACrG,OAAO,KAAK,EAAE,iBAAiB,EAAE,qBAAqB,EAAE,MAAM,6BAA6B,CAAC;AAE5F;;;;GAIG;AACH,MAAM,WAAW,qBAAsB,SAAQ,IAAI,CAAC,iBAAiB,EAAE,QAAQ,CAAC;IAC9E;;;;OAIG;IACH,SAAS,CAAC,EAAE,qBAAqB,GAAG,iBAAiB,CAAC;CACvD;AAED,MAAM,MAAM,cAAc,GAAG,UAAU,CAAC,OAAO,oBAAoB,CAAC,CAAC;AACrE,YAAY,EAAE,iBAAiB,EAAE,CAAC;AAElC,wBAAgB,oBAAoB,CAAC,OAAO,EAAE,qBAAqB,0CAOlE"}
|
package/dist/rn/iap.js
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { createIapAdapter } from "../iap/adapter.js";
|
|
2
|
+
export function createReactNativeIap(options) {
|
|
3
|
+
const loader = !options.framework
|
|
4
|
+
? createDefaultRnIapLoader()
|
|
5
|
+
: typeof options.framework === "function"
|
|
6
|
+
? options.framework
|
|
7
|
+
: async () => ({ available: true, module: options.framework });
|
|
8
|
+
return createIapAdapter({ ...options, loader });
|
|
9
|
+
}
|
|
10
|
+
function createDefaultRnIapLoader() {
|
|
11
|
+
let cached;
|
|
12
|
+
return async () => {
|
|
13
|
+
if (cached) {
|
|
14
|
+
return { available: true, module: cached };
|
|
15
|
+
}
|
|
16
|
+
try {
|
|
17
|
+
const framework = (await import("@apps-in-toss/framework"));
|
|
18
|
+
const iap = framework.IAP;
|
|
19
|
+
if (typeof iap !== "object" || iap === null) {
|
|
20
|
+
return {
|
|
21
|
+
available: false,
|
|
22
|
+
reason: "@apps-in-toss/framework does not expose an IAP domain"
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
// Per-operation capability is validated at each call site: an
|
|
26
|
+
// installed version may expose some IAP functions but not others.
|
|
27
|
+
cached = iap;
|
|
28
|
+
return { available: true, module: cached };
|
|
29
|
+
}
|
|
30
|
+
catch (error) {
|
|
31
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
32
|
+
return { available: false, reason: `failed to import @apps-in-toss/framework: ${message}` };
|
|
33
|
+
}
|
|
34
|
+
};
|
|
35
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { type SdkAnonymousKey, type SdkLoginResult } from "../index.js";
|
|
2
|
+
import { type IdentityPlatformLoader, type IdentityPlatformSdk } from "../identity/platform-contract.js";
|
|
3
|
+
export interface ReactNativeIdentityOptions {
|
|
4
|
+
/**
|
|
5
|
+
* Framework injection: pass a module exposing TossAuth/User or a custom
|
|
6
|
+
* loader (tests, dev replacements). Defaults to the lazy
|
|
7
|
+
* `import("@apps-in-toss/framework")` loader. The default never guesses
|
|
8
|
+
* the environment or substitutes a fake login.
|
|
9
|
+
*/
|
|
10
|
+
framework?: IdentityPlatformSdk | IdentityPlatformLoader;
|
|
11
|
+
}
|
|
12
|
+
export interface ReactNativeIdentity {
|
|
13
|
+
/** Starts the platform login and validates/preserves the result. */
|
|
14
|
+
login(): Promise<SdkLoginResult>;
|
|
15
|
+
/** Looks up the SDK-issued anonymous key; never fabricates one. */
|
|
16
|
+
getAnonymousKey(): Promise<SdkAnonymousKey>;
|
|
17
|
+
}
|
|
18
|
+
export declare function createReactNativeIdentity(options?: ReactNativeIdentityOptions): ReactNativeIdentity;
|
|
19
|
+
export declare function normalizeIdentityLoader(framework: ReactNativeIdentityOptions["framework"]): IdentityPlatformLoader;
|
|
20
|
+
//# sourceMappingURL=identity.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"identity.d.ts","sourceRoot":"","sources":["../../src/rn/identity.ts"],"names":[],"mappings":"AAAA,OAAO,EAAY,KAAK,eAAe,EAAE,KAAK,cAAc,EAAE,MAAM,aAAa,CAAC;AAClF,OAAO,EACL,KAAK,sBAAsB,EAC3B,KAAK,mBAAmB,EAGzB,MAAM,kCAAkC,CAAC;AAE1C,MAAM,WAAW,0BAA0B;IACzC;;;;;OAKG;IACH,SAAS,CAAC,EAAE,mBAAmB,GAAG,sBAAsB,CAAC;CAC1D;AAED,MAAM,WAAW,mBAAmB;IAClC,oEAAoE;IACpE,KAAK,IAAI,OAAO,CAAC,cAAc,CAAC,CAAC;IACjC,mEAAmE;IACnE,eAAe,IAAI,OAAO,CAAC,eAAe,CAAC,CAAC;CAC7C;AAED,wBAAgB,yBAAyB,CAAC,OAAO,GAAE,0BAA+B,GAAG,mBAAmB,CAavG;AAED,wBAAgB,uBAAuB,CACrC,SAAS,EAAE,0BAA0B,CAAC,WAAW,CAAC,GACjD,sBAAsB,CAQxB"}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { SdkError } from "../index.js";
|
|
2
|
+
import { runSdkGetAnonymousKey, runSdkLogin } from "../identity/platform-contract.js";
|
|
3
|
+
export function createReactNativeIdentity(options = {}) {
|
|
4
|
+
const loader = normalizeIdentityLoader(options.framework);
|
|
5
|
+
const load = async () => {
|
|
6
|
+
const result = await loader();
|
|
7
|
+
if (!result.available) {
|
|
8
|
+
throw new SdkError("SDK_UNAVAILABLE", result.reason);
|
|
9
|
+
}
|
|
10
|
+
return result.module;
|
|
11
|
+
};
|
|
12
|
+
return {
|
|
13
|
+
login: async () => runSdkLogin(await load()),
|
|
14
|
+
getAnonymousKey: async () => runSdkGetAnonymousKey(await load())
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
export function normalizeIdentityLoader(framework) {
|
|
18
|
+
if (!framework) {
|
|
19
|
+
return createDefaultRnIdentityLoader();
|
|
20
|
+
}
|
|
21
|
+
if (typeof framework === "function") {
|
|
22
|
+
return framework;
|
|
23
|
+
}
|
|
24
|
+
return async () => ({ available: true, module: framework });
|
|
25
|
+
}
|
|
26
|
+
function createDefaultRnIdentityLoader() {
|
|
27
|
+
let cached;
|
|
28
|
+
return async () => {
|
|
29
|
+
if (cached) {
|
|
30
|
+
return { available: true, module: cached };
|
|
31
|
+
}
|
|
32
|
+
try {
|
|
33
|
+
const framework = (await import("@apps-in-toss/framework"));
|
|
34
|
+
cached = framework;
|
|
35
|
+
return { available: true, module: cached };
|
|
36
|
+
}
|
|
37
|
+
catch (error) {
|
|
38
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
39
|
+
return { available: false, reason: `failed to import @apps-in-toss/framework: ${message}` };
|
|
40
|
+
}
|
|
41
|
+
};
|
|
42
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* React Native adapters for `@ait-kit/sdk`.
|
|
3
|
+
*
|
|
4
|
+
* Requires the official `@apps-in-toss/framework` package (declared as an
|
|
5
|
+
* optional peer): it is imported lazily at first use, so plain Node bundles
|
|
6
|
+
* of the root entry never touch React Native code.
|
|
7
|
+
*
|
|
8
|
+
* ```ts
|
|
9
|
+
* import { createReactNativeAds } from "@ait-kit/sdk/rn";
|
|
10
|
+
*
|
|
11
|
+
* const ads = createReactNativeAds();
|
|
12
|
+
* await ads.loadFullScreenAd("AD_GROUP_ID");
|
|
13
|
+
* const result = await ads.showFullScreenAd("AD_GROUP_ID");
|
|
14
|
+
* if (result.status === "rewarded") {
|
|
15
|
+
* // Verify the reward against your server before crediting anything.
|
|
16
|
+
* }
|
|
17
|
+
* ```
|
|
18
|
+
*/
|
|
19
|
+
export { createReactNativeAds, type ReactNativeAds, type ReactNativeAdsOptions, type SdkAdType } from "./ads.js";
|
|
20
|
+
export { createReactNativeIap, type ReactNativeIap, type ReactNativeIapOptions } from "./iap.js";
|
|
21
|
+
export type { IapRecoveryResult } from "./iap.js";
|
|
22
|
+
export { createReactNativeIdentity, type ReactNativeIdentity, type ReactNativeIdentityOptions } from "./identity.js";
|
|
23
|
+
export { createReactNativeStorage, type ReactNativeStorageOptions } from "./storage.js";
|
|
24
|
+
export { createReactNativeNotification, createReactNativeShare, type ReactNativeNotification, type ReactNativeNotificationOptions, type ReactNativeShare, type ReactNativeShareOptions } from "./notify-share.js";
|
|
25
|
+
export { createDefaultFrameworkLoader, type FrameworkLoader } from "./framework-loader.js";
|
|
26
|
+
export type { FullScreenAdShowEvent, FullScreenAdSupport, LoadFullScreenAdParams, ShowFullScreenAdParams } from "./framework-contract.js";
|
|
27
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/rn/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AACH,OAAO,EACL,oBAAoB,EACpB,KAAK,cAAc,EACnB,KAAK,qBAAqB,EAC1B,KAAK,SAAS,EACf,MAAM,UAAU,CAAC;AAClB,OAAO,EACL,oBAAoB,EACpB,KAAK,cAAc,EACnB,KAAK,qBAAqB,EAC3B,MAAM,UAAU,CAAC;AAClB,YAAY,EAAE,iBAAiB,EAAE,MAAM,UAAU,CAAC;AAClD,OAAO,EACL,yBAAyB,EACzB,KAAK,mBAAmB,EACxB,KAAK,0BAA0B,EAChC,MAAM,eAAe,CAAC;AACvB,OAAO,EACL,wBAAwB,EACxB,KAAK,yBAAyB,EAC/B,MAAM,cAAc,CAAC;AACtB,OAAO,EACL,6BAA6B,EAC7B,sBAAsB,EACtB,KAAK,uBAAuB,EAC5B,KAAK,8BAA8B,EACnC,KAAK,gBAAgB,EACrB,KAAK,uBAAuB,EAC7B,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,4BAA4B,EAAE,KAAK,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAC3F,YAAY,EACV,qBAAqB,EACrB,mBAAmB,EACnB,sBAAsB,EACtB,sBAAsB,EACvB,MAAM,yBAAyB,CAAC"}
|
package/dist/rn/index.js
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* React Native adapters for `@ait-kit/sdk`.
|
|
3
|
+
*
|
|
4
|
+
* Requires the official `@apps-in-toss/framework` package (declared as an
|
|
5
|
+
* optional peer): it is imported lazily at first use, so plain Node bundles
|
|
6
|
+
* of the root entry never touch React Native code.
|
|
7
|
+
*
|
|
8
|
+
* ```ts
|
|
9
|
+
* import { createReactNativeAds } from "@ait-kit/sdk/rn";
|
|
10
|
+
*
|
|
11
|
+
* const ads = createReactNativeAds();
|
|
12
|
+
* await ads.loadFullScreenAd("AD_GROUP_ID");
|
|
13
|
+
* const result = await ads.showFullScreenAd("AD_GROUP_ID");
|
|
14
|
+
* if (result.status === "rewarded") {
|
|
15
|
+
* // Verify the reward against your server before crediting anything.
|
|
16
|
+
* }
|
|
17
|
+
* ```
|
|
18
|
+
*/
|
|
19
|
+
export { createReactNativeAds } from "./ads.js";
|
|
20
|
+
export { createReactNativeIap } from "./iap.js";
|
|
21
|
+
export { createReactNativeIdentity } from "./identity.js";
|
|
22
|
+
export { createReactNativeStorage } from "./storage.js";
|
|
23
|
+
export { createReactNativeNotification, createReactNativeShare } from "./notify-share.js";
|
|
24
|
+
export { createDefaultFrameworkLoader } from "./framework-loader.js";
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { type SdkNotificationAgreementResult, type SdkShareUiResult } from "../index.js";
|
|
2
|
+
import { type NotificationPlatformLoader, type NotificationPlatformSdk } from "../notification/platform-contract.js";
|
|
3
|
+
import { type SharePlatformLoader, type SharePlatformSdk } from "../share/platform-contract.js";
|
|
4
|
+
export interface ReactNativeNotificationOptions {
|
|
5
|
+
/**
|
|
6
|
+
* Framework injection: pass a module exposing Notification or a custom
|
|
7
|
+
* loader. Defaults to the lazy `import("@apps-in-toss/framework")` loader.
|
|
8
|
+
*/
|
|
9
|
+
framework?: NotificationPlatformSdk | NotificationPlatformLoader;
|
|
10
|
+
/** Overall deadline per agreement request (default 60000ms; 0 disables). */
|
|
11
|
+
timeoutMs?: number;
|
|
12
|
+
}
|
|
13
|
+
export interface ReactNativeNotification {
|
|
14
|
+
/**
|
|
15
|
+
* Requests agreement for one template. The result preserves the
|
|
16
|
+
* templateCode and the platform's raw event, and describes only this
|
|
17
|
+
* request — syncing consent state to a server is the consumer's job.
|
|
18
|
+
*/
|
|
19
|
+
requestAgreement(templateCode: string): Promise<SdkNotificationAgreementResult>;
|
|
20
|
+
}
|
|
21
|
+
export declare function createReactNativeNotification(options?: ReactNativeNotificationOptions): ReactNativeNotification;
|
|
22
|
+
export interface ReactNativeShareOptions {
|
|
23
|
+
/**
|
|
24
|
+
* Framework injection: pass a module exposing Share or a custom loader.
|
|
25
|
+
* Defaults to the lazy `import("@apps-in-toss/framework")` loader.
|
|
26
|
+
*/
|
|
27
|
+
framework?: SharePlatformSdk | SharePlatformLoader;
|
|
28
|
+
}
|
|
29
|
+
export interface ReactNativeShare {
|
|
30
|
+
/** Creates a share link for an `intoss://` deeplink path. */
|
|
31
|
+
createLink(path: string, ogImageUrl?: string): Promise<string>;
|
|
32
|
+
/**
|
|
33
|
+
* Opens the native share sheet. Resolving `closed` means the sheet flow
|
|
34
|
+
* ended — it does not prove the user shared and never grants reward
|
|
35
|
+
* eligibility.
|
|
36
|
+
*/
|
|
37
|
+
sendMessage(message: string): Promise<SdkShareUiResult>;
|
|
38
|
+
}
|
|
39
|
+
export declare function createReactNativeShare(options?: ReactNativeShareOptions): ReactNativeShare;
|
|
40
|
+
export declare function normalizeNotificationLoader(framework: ReactNativeNotificationOptions["framework"]): NotificationPlatformLoader;
|
|
41
|
+
export declare function normalizeShareLoader(framework: ReactNativeShareOptions["framework"]): SharePlatformLoader;
|
|
42
|
+
//# sourceMappingURL=notify-share.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"notify-share.d.ts","sourceRoot":"","sources":["../../src/rn/notify-share.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,KAAK,8BAA8B,EACnC,KAAK,gBAAgB,EACtB,MAAM,aAAa,CAAC;AACrB,OAAO,EACL,KAAK,0BAA0B,EAC/B,KAAK,uBAAuB,EAE7B,MAAM,sCAAsC,CAAC;AAC9C,OAAO,EACL,KAAK,mBAAmB,EACxB,KAAK,gBAAgB,EAGtB,MAAM,+BAA+B,CAAC;AAQvC,MAAM,WAAW,8BAA8B;IAC7C;;;OAGG;IACH,SAAS,CAAC,EAAE,uBAAuB,GAAG,0BAA0B,CAAC;IACjE,4EAA4E;IAC5E,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,MAAM,WAAW,uBAAuB;IACtC;;;;OAIG;IACH,gBAAgB,CAAC,YAAY,EAAE,MAAM,GAAG,OAAO,CAAC,8BAA8B,CAAC,CAAC;CACjF;AAED,wBAAgB,6BAA6B,CAC3C,OAAO,GAAE,8BAAmC,GAC3C,uBAAuB,CAazB;AAMD,MAAM,WAAW,uBAAuB;IACtC;;;OAGG;IACH,SAAS,CAAC,EAAE,gBAAgB,GAAG,mBAAmB,CAAC;CACpD;AAED,MAAM,WAAW,gBAAgB;IAC/B,6DAA6D;IAC7D,UAAU,CAAC,IAAI,EAAE,MAAM,EAAE,UAAU,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;IAC/D;;;;OAIG;IACH,WAAW,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,gBAAgB,CAAC,CAAC;CACzD;AAED,wBAAgB,sBAAsB,CACpC,OAAO,GAAE,uBAA4B,GACpC,gBAAgB,CAyClB;AAMD,wBAAgB,2BAA2B,CACzC,SAAS,EAAE,8BAA8B,CAAC,WAAW,CAAC,GACrD,0BAA0B,CAQ5B;AAED,wBAAgB,oBAAoB,CAClC,SAAS,EAAE,uBAAuB,CAAC,WAAW,CAAC,GAC9C,mBAAmB,CAQrB"}
|
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
import { SdkError } from "../index.js";
|
|
2
|
+
import { runRequestAgreement } from "../notification/platform-contract.js";
|
|
3
|
+
import { runShareUi, validateSharePath } from "../share/platform-contract.js";
|
|
4
|
+
const DEFAULT_AGREEMENT_TIMEOUT_MS = 60_000;
|
|
5
|
+
export function createReactNativeNotification(options = {}) {
|
|
6
|
+
const loader = normalizeNotificationLoader(options.framework);
|
|
7
|
+
const timeoutMs = options.timeoutMs ?? DEFAULT_AGREEMENT_TIMEOUT_MS;
|
|
8
|
+
return {
|
|
9
|
+
requestAgreement(templateCode) {
|
|
10
|
+
if (typeof templateCode !== "string" || !templateCode.trim()) {
|
|
11
|
+
return Promise.reject(new SdkError("UNSUPPORTED", "templateCode must be a non-empty string"));
|
|
12
|
+
}
|
|
13
|
+
return agreementWithLoaderDeadline(loader, templateCode, timeoutMs);
|
|
14
|
+
}
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
export function createReactNativeShare(options = {}) {
|
|
18
|
+
const loader = normalizeShareLoader(options.framework);
|
|
19
|
+
const load = async () => {
|
|
20
|
+
const result = await loader();
|
|
21
|
+
if (!result.available) {
|
|
22
|
+
throw new SdkError("SDK_UNAVAILABLE", result.reason);
|
|
23
|
+
}
|
|
24
|
+
return result.module;
|
|
25
|
+
};
|
|
26
|
+
return {
|
|
27
|
+
async createLink(path, ogImageUrl) {
|
|
28
|
+
const validated = validateSharePath(path);
|
|
29
|
+
const platform = await load();
|
|
30
|
+
const createLink = platform.Share?.createLink;
|
|
31
|
+
if (typeof createLink !== "function") {
|
|
32
|
+
throw new SdkError("UNSUPPORTED", "the installed SDK does not expose Share.createLink");
|
|
33
|
+
}
|
|
34
|
+
if (typeof createLink.isSupported === "function" && !createLink.isSupported()) {
|
|
35
|
+
throw new SdkError("UNSUPPORTED", "share links are not supported on this app version");
|
|
36
|
+
}
|
|
37
|
+
// Receiver-preserving member call; optional OG image only when present.
|
|
38
|
+
return platform.Share.createLink(ogImageUrl !== undefined ? { path: validated, ogImageUrl } : { path: validated });
|
|
39
|
+
},
|
|
40
|
+
async sendMessage(message) {
|
|
41
|
+
if (typeof message !== "string" || !message) {
|
|
42
|
+
throw new SdkError("UNSUPPORTED", "message must be a non-empty string");
|
|
43
|
+
}
|
|
44
|
+
const platform = await load();
|
|
45
|
+
const sendMessage = platform.Share?.sendMessage;
|
|
46
|
+
if (typeof sendMessage !== "function") {
|
|
47
|
+
throw new SdkError("UNSUPPORTED", "the installed SDK does not expose Share.sendMessage");
|
|
48
|
+
}
|
|
49
|
+
if (typeof sendMessage.isSupported === "function" && !sendMessage.isSupported()) {
|
|
50
|
+
throw new SdkError("UNSUPPORTED", "the share sheet is not supported on this app version");
|
|
51
|
+
}
|
|
52
|
+
return runShareUi(platform, message);
|
|
53
|
+
}
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
// ---------------------------------------------------------------------------
|
|
57
|
+
// Loaders
|
|
58
|
+
// ---------------------------------------------------------------------------
|
|
59
|
+
export function normalizeNotificationLoader(framework) {
|
|
60
|
+
if (!framework) {
|
|
61
|
+
return createDefaultRnModuleLoader();
|
|
62
|
+
}
|
|
63
|
+
if (typeof framework === "function") {
|
|
64
|
+
return framework;
|
|
65
|
+
}
|
|
66
|
+
return async () => ({ available: true, module: framework });
|
|
67
|
+
}
|
|
68
|
+
export function normalizeShareLoader(framework) {
|
|
69
|
+
if (!framework) {
|
|
70
|
+
return createDefaultRnModuleLoader();
|
|
71
|
+
}
|
|
72
|
+
if (typeof framework === "function") {
|
|
73
|
+
return framework;
|
|
74
|
+
}
|
|
75
|
+
return async () => ({ available: true, module: framework });
|
|
76
|
+
}
|
|
77
|
+
function createDefaultRnModuleLoader() {
|
|
78
|
+
let cached;
|
|
79
|
+
return async () => {
|
|
80
|
+
if (cached) {
|
|
81
|
+
return { available: true, module: cached };
|
|
82
|
+
}
|
|
83
|
+
try {
|
|
84
|
+
const framework = (await import("@apps-in-toss/framework"));
|
|
85
|
+
cached = framework;
|
|
86
|
+
return { available: true, module: cached };
|
|
87
|
+
}
|
|
88
|
+
catch (error) {
|
|
89
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
90
|
+
return {
|
|
91
|
+
available: false,
|
|
92
|
+
reason: `failed to import @apps-in-toss/framework: ${message}`
|
|
93
|
+
};
|
|
94
|
+
}
|
|
95
|
+
};
|
|
96
|
+
}
|
|
97
|
+
/**
|
|
98
|
+
* Runs one agreement under a deadline that also covers platform loading:
|
|
99
|
+
* a stalled loader cannot wedge the request, a loader resolving after the
|
|
100
|
+
* deadline never registers, and the flow owns the remaining budget.
|
|
101
|
+
*/
|
|
102
|
+
async function agreementWithLoaderDeadline(loader, templateCode, timeoutMs) {
|
|
103
|
+
const timedOut = () => ({
|
|
104
|
+
status: "timeout",
|
|
105
|
+
templateCode,
|
|
106
|
+
reason: `agreement request timed out after ${timeoutMs}ms; the user may still act — resolve the state server-side before retrying`
|
|
107
|
+
});
|
|
108
|
+
if (!(timeoutMs > 0)) {
|
|
109
|
+
return runRequestAgreement(await loadNotificationPlatform(loader), templateCode, 0);
|
|
110
|
+
}
|
|
111
|
+
const startedAt = Date.now();
|
|
112
|
+
let cancelled = false;
|
|
113
|
+
let timer;
|
|
114
|
+
const loadDeadline = new Promise((resolve) => {
|
|
115
|
+
timer = setTimeout(() => {
|
|
116
|
+
cancelled = true;
|
|
117
|
+
resolve(null);
|
|
118
|
+
}, timeoutMs);
|
|
119
|
+
});
|
|
120
|
+
let platform;
|
|
121
|
+
try {
|
|
122
|
+
platform = await Promise.race([
|
|
123
|
+
loadNotificationPlatform(loader).then((loaded) => (cancelled ? null : loaded)),
|
|
124
|
+
loadDeadline
|
|
125
|
+
]);
|
|
126
|
+
}
|
|
127
|
+
finally {
|
|
128
|
+
if (timer !== undefined)
|
|
129
|
+
clearTimeout(timer);
|
|
130
|
+
}
|
|
131
|
+
if (!platform || cancelled || Date.now() - startedAt >= timeoutMs) {
|
|
132
|
+
return timedOut();
|
|
133
|
+
}
|
|
134
|
+
const remainingMs = Math.max(1, timeoutMs - (Date.now() - startedAt));
|
|
135
|
+
// The public reason reports the CONFIGURED deadline, not the remainder
|
|
136
|
+
// left after loading; the remainder still bounds the actual flow.
|
|
137
|
+
const flow = runRequestAgreement(platform, templateCode, remainingMs);
|
|
138
|
+
const configured = timeoutMs;
|
|
139
|
+
return flow.then((result) => result.status === "timeout"
|
|
140
|
+
? {
|
|
141
|
+
...result,
|
|
142
|
+
reason: `agreement request timed out after ${configured}ms; the user may still act — resolve the state server-side before retrying`
|
|
143
|
+
}
|
|
144
|
+
: result);
|
|
145
|
+
}
|
|
146
|
+
async function loadNotificationPlatform(loader) {
|
|
147
|
+
const result = await loader();
|
|
148
|
+
if (!result.available) {
|
|
149
|
+
throw new SdkError("SDK_UNAVAILABLE", result.reason);
|
|
150
|
+
}
|
|
151
|
+
const request = result.module.Notification?.requestAgreement;
|
|
152
|
+
if (typeof request !== "function") {
|
|
153
|
+
throw new SdkError("UNSUPPORTED", "the installed SDK does not expose Notification.requestAgreement");
|
|
154
|
+
}
|
|
155
|
+
if (typeof request.isSupported === "function" && !request.isSupported()) {
|
|
156
|
+
throw new SdkError("UNSUPPORTED", "notification agreements are not supported on this app version");
|
|
157
|
+
}
|
|
158
|
+
return result.module;
|
|
159
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { type SdkStorage } from "../index.js";
|
|
2
|
+
import { type StoragePlatformLoader, type StoragePlatformSdk } from "../storage/platform-contract.js";
|
|
3
|
+
export interface ReactNativeStorageOptions {
|
|
4
|
+
/**
|
|
5
|
+
* Framework injection: pass a module exposing Storage or a custom loader
|
|
6
|
+
* (tests, dev replacements). Defaults to the lazy
|
|
7
|
+
* `import("@apps-in-toss/framework")` loader.
|
|
8
|
+
*/
|
|
9
|
+
framework?: StoragePlatformSdk | StoragePlatformLoader;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* SDK-backed storage for React Native. Keys and string values pass through
|
|
13
|
+
* verbatim (no namespace prefixing); get resolves null for missing keys and
|
|
14
|
+
* set/remove rejections propagate so failures stay observable.
|
|
15
|
+
*/
|
|
16
|
+
export declare function createReactNativeStorage(options?: ReactNativeStorageOptions): SdkStorage;
|
|
17
|
+
export declare function normalizeStorageLoader(framework: ReactNativeStorageOptions["framework"]): StoragePlatformLoader;
|
|
18
|
+
//# sourceMappingURL=storage.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"storage.d.ts","sourceRoot":"","sources":["../../src/rn/storage.ts"],"names":[],"mappings":"AAAA,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,CAQvB"}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { SdkError } from "../index.js";
|
|
2
|
+
import { createSdkStorageFromPlatform } from "../storage/platform-contract.js";
|
|
3
|
+
/**
|
|
4
|
+
* SDK-backed storage for React Native. Keys and string values pass through
|
|
5
|
+
* verbatim (no namespace prefixing); get resolves null for missing keys and
|
|
6
|
+
* set/remove rejections propagate so failures stay observable.
|
|
7
|
+
*/
|
|
8
|
+
export function createReactNativeStorage(options = {}) {
|
|
9
|
+
const loader = normalizeStorageLoader(options.framework);
|
|
10
|
+
let cached;
|
|
11
|
+
let resolving;
|
|
12
|
+
const resolve = () => {
|
|
13
|
+
if (cached) {
|
|
14
|
+
return Promise.resolve(cached);
|
|
15
|
+
}
|
|
16
|
+
// Concurrent initial calls share one loader invocation so custom
|
|
17
|
+
// loaders cannot hand out independent stores.
|
|
18
|
+
if (!resolving) {
|
|
19
|
+
resolving = (async () => {
|
|
20
|
+
const result = await loader();
|
|
21
|
+
if (!result.available) {
|
|
22
|
+
throw new SdkError("SDK_UNAVAILABLE", result.reason);
|
|
23
|
+
}
|
|
24
|
+
cached = createSdkStorageFromPlatform(result.module);
|
|
25
|
+
return cached;
|
|
26
|
+
})();
|
|
27
|
+
resolving.catch(() => {
|
|
28
|
+
resolving = undefined;
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
return resolving;
|
|
32
|
+
};
|
|
33
|
+
return {
|
|
34
|
+
get: async (key) => (await resolve()).get(key),
|
|
35
|
+
set: async (key, value) => (await resolve()).set(key, value),
|
|
36
|
+
remove: async (key) => (await resolve()).remove(key)
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
export function normalizeStorageLoader(framework) {
|
|
40
|
+
if (!framework) {
|
|
41
|
+
return createDefaultRnStorageLoader();
|
|
42
|
+
}
|
|
43
|
+
if (typeof framework === "function") {
|
|
44
|
+
return framework;
|
|
45
|
+
}
|
|
46
|
+
return async () => ({ available: true, module: framework });
|
|
47
|
+
}
|
|
48
|
+
function createDefaultRnStorageLoader() {
|
|
49
|
+
let cached;
|
|
50
|
+
return async () => {
|
|
51
|
+
if (cached) {
|
|
52
|
+
return { available: true, module: cached };
|
|
53
|
+
}
|
|
54
|
+
try {
|
|
55
|
+
const framework = (await import("@apps-in-toss/framework"));
|
|
56
|
+
cached = framework;
|
|
57
|
+
return { available: true, module: cached };
|
|
58
|
+
}
|
|
59
|
+
catch (error) {
|
|
60
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
61
|
+
return { available: false, reason: `failed to import @apps-in-toss/framework: ${message}` };
|
|
62
|
+
}
|
|
63
|
+
};
|
|
64
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { type SdkShareUiResult } from "../index.js";
|
|
2
|
+
/**
|
|
3
|
+
* Internal platform contract for the share adapter, shared by /rn and /web.
|
|
4
|
+
*/
|
|
5
|
+
export interface ShareCreateLinkParams {
|
|
6
|
+
path: string;
|
|
7
|
+
ogImageUrl?: string;
|
|
8
|
+
}
|
|
9
|
+
type FunctionWithSupport<F> = F & {
|
|
10
|
+
isSupported?: () => boolean;
|
|
11
|
+
};
|
|
12
|
+
export interface ShareLike {
|
|
13
|
+
createLink?: FunctionWithSupport<(params: ShareCreateLinkParams) => Promise<string>> | undefined;
|
|
14
|
+
sendMessage?: FunctionWithSupport<(message: {
|
|
15
|
+
message: string;
|
|
16
|
+
}) => Promise<void>> | undefined;
|
|
17
|
+
}
|
|
18
|
+
export interface SharePlatformSdk {
|
|
19
|
+
Share?: ShareLike;
|
|
20
|
+
}
|
|
21
|
+
export type SharePlatformLoader = () => Promise<{
|
|
22
|
+
available: true;
|
|
23
|
+
module: SharePlatformSdk;
|
|
24
|
+
} | {
|
|
25
|
+
available: false;
|
|
26
|
+
reason: string;
|
|
27
|
+
}>;
|
|
28
|
+
/**
|
|
29
|
+
* Validates the documented input contract (an `intoss://` deeplink path)
|
|
30
|
+
* before dispatching; the resolved share link passes through verbatim.
|
|
31
|
+
*/
|
|
32
|
+
export declare function validateSharePath(path: string): string;
|
|
33
|
+
/**
|
|
34
|
+
* Wraps the share-UI call: a resolution means the native share sheet flow
|
|
35
|
+
* ended normally ("closed") — it never proves the user actually shared and
|
|
36
|
+
* never grants reward eligibility. Rejections surface as failed with the
|
|
37
|
+
* platform's error code/message preserved.
|
|
38
|
+
*/
|
|
39
|
+
export declare function runShareUi(platform: SharePlatformSdk, message: string): Promise<SdkShareUiResult>;
|
|
40
|
+
export {};
|
|
41
|
+
//# sourceMappingURL=platform-contract.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"platform-contract.d.ts","sourceRoot":"","sources":["../../src/share/platform-contract.ts"],"names":[],"mappings":"AAAA,OAAO,EAAY,KAAK,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAG9D;;GAEG;AAEH,MAAM,WAAW,qBAAqB;IACpC,IAAI,EAAE,MAAM,CAAC;IACb,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAED,KAAK,mBAAmB,CAAC,CAAC,IAAI,CAAC,GAAG;IAAE,WAAW,CAAC,EAAE,MAAM,OAAO,CAAA;CAAE,CAAC;AAElE,MAAM,WAAW,SAAS;IACxB,UAAU,CAAC,EACP,mBAAmB,CAAC,CAAC,MAAM,EAAE,qBAAqB,KAAK,OAAO,CAAC,MAAM,CAAC,CAAC,GACvE,SAAS,CAAC;IACd,WAAW,CAAC,EACR,mBAAmB,CAAC,CAAC,OAAO,EAAE;QAAE,OAAO,EAAE,MAAM,CAAA;KAAE,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC,GACpE,SAAS,CAAC;CACf;AAED,MAAM,WAAW,gBAAgB;IAC/B,KAAK,CAAC,EAAE,SAAS,CAAC;CACnB;AAED,MAAM,MAAM,mBAAmB,GAAG,MAAM,OAAO,CAC7C;IAAE,SAAS,EAAE,IAAI,CAAC;IAAC,MAAM,EAAE,gBAAgB,CAAA;CAAE,GAAG;IAAE,SAAS,EAAE,KAAK,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,CACrF,CAAC;AAEF;;;GAGG;AACH,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAUtD;AAED;;;;;GAKG;AACH,wBAAsB,UAAU,CAC9B,QAAQ,EAAE,gBAAgB,EAC1B,OAAO,EAAE,MAAM,GACd,OAAO,CAAC,gBAAgB,CAAC,CAY3B"}
|