@kontextso/sdk-react-native 3.0.7-rc.3 → 4.0.0-rc.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/dist/index.d.mts +167 -4
- package/dist/index.d.ts +167 -4
- package/dist/index.js +471 -298
- package/dist/index.mjs +471 -294
- package/package.json +7 -9
- package/src/AbstractStream.ts +141 -0
- package/src/Configuration.ts +129 -0
- package/src/InlineAd.tsx +168 -0
- package/src/KontextAds.ts +40 -0
- package/src/Logger.ts +95 -0
- package/src/NativeStream.ts +20 -0
- package/src/Preload.ts +150 -0
- package/src/Session.ts +104 -0
- package/src/index.ts +2 -4
- package/src/utils/device.ts +89 -0
- package/src/utils/request.ts +73 -0
- package/src/utils/sdk.ts +16 -0
- package/src/utils/validation.ts +59 -0
- package/android/build.gradle +0 -88
- package/android/gradle.properties +0 -5
- package/android/src/main/AndroidManifest.xml +0 -2
- package/android/src/main/java/so/kontext/react/RNKontextModuleImpl.kt +0 -21
- package/android/src/newarch/java/so/kontext/react/RNKontextModule.kt +0 -22
- package/android/src/newarch/java/so/kontext/react/RNKontextPackage.kt +0 -32
- package/android/src/oldarch/java/so/kontext/react/RNKontextModule.kt +0 -25
- package/android/src/oldarch/java/so/kontext/react/RNKontextPacakge.kt +0 -16
- package/ios/KontextSDK.swift +0 -26
- package/ios/RNKontext.h +0 -13
- package/ios/RNKontext.mm +0 -36
- package/src/__tests__/util.test.ts +0 -9
- package/src/context/AdsProvider.tsx +0 -119
- package/src/formats/Format.tsx +0 -256
- package/src/formats/InlineAd.tsx +0 -8
- package/src/frame-webview.tsx +0 -43
package/dist/index.d.mts
CHANGED
|
@@ -1,8 +1,171 @@
|
|
|
1
1
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
-
import {
|
|
2
|
+
import { Message, SDK } from '@kontextso/sdk-common';
|
|
3
3
|
|
|
4
|
-
|
|
4
|
+
type Regulatory = {
|
|
5
|
+
/** Flag that indicates whether or not the request is subject to GDPR regulations 0 = No, 1 = Yes, omission indicates Unknown */
|
|
6
|
+
gdpr?: 0 | 1;
|
|
7
|
+
/** When GDPR regulations are in effect this attribute contains the Transparency and Consent Framework's Consent String data structure */
|
|
8
|
+
gdprConsent?: string;
|
|
9
|
+
/** Flag indicating if this request is subject to the COPPA regulations established by the USA FTC, where 0 = no, 1 = yes, omission indicates Unknown */
|
|
10
|
+
coppa?: 0 | 1;
|
|
11
|
+
/** Contains the Global Privacy Platform's consent string. See IAB-GPP spec for more details */
|
|
12
|
+
gpp?: string;
|
|
13
|
+
/** List of the section(s) of the GPP string which should be applied for this transaction */
|
|
14
|
+
gppSid?: number[];
|
|
15
|
+
/** Communicates signals regarding consumer privacy under US privacy regulation under CCPA and LSPA */
|
|
16
|
+
usPrivacy?: string;
|
|
17
|
+
};
|
|
18
|
+
interface Character {
|
|
19
|
+
/** Unique ID of the character */
|
|
20
|
+
id: string;
|
|
21
|
+
/** Name of the character */
|
|
22
|
+
name: string;
|
|
23
|
+
/** URL of the character’s avatar */
|
|
24
|
+
avatarUrl?: string;
|
|
25
|
+
/** Greeting of the character */
|
|
26
|
+
greeting?: string;
|
|
27
|
+
/** Description of the character’s personality */
|
|
28
|
+
persona?: string;
|
|
29
|
+
/** Tags of the character */
|
|
30
|
+
tags?: string[];
|
|
31
|
+
/** Whether the character is NSFW */
|
|
32
|
+
isNsfw?: boolean;
|
|
33
|
+
[key: string]: string | string[] | boolean | undefined;
|
|
34
|
+
}
|
|
35
|
+
interface ConfigOptions {
|
|
36
|
+
/** Your publisher token. This token is not secret and is visible in the browser’s developer console. */
|
|
37
|
+
publisherToken: string;
|
|
38
|
+
/** The SDK can be temporarily disabled by setting it to false (no ads will be rendered). */
|
|
39
|
+
userId: string;
|
|
40
|
+
/** Unique identifier of the conversation. */
|
|
41
|
+
conversationId: string;
|
|
42
|
+
/** Character information. */
|
|
43
|
+
character?: Character;
|
|
44
|
+
/** A list of allowed placement codes. */
|
|
45
|
+
placementCode?: string;
|
|
46
|
+
/** A variant ID that helps determine which type of ad to render. */
|
|
47
|
+
variantId?: string;
|
|
48
|
+
/** Device-specific identifier provided by the operating systems (IDFA/GAID) */
|
|
49
|
+
/** Regulatory features. */
|
|
50
|
+
regulatory?: Regulatory;
|
|
51
|
+
/** Local and remote logging settings. */
|
|
52
|
+
logLevel?: 'debug' | 'info' | 'log' | 'warn' | 'error' | 'silent';
|
|
53
|
+
/** The email of the user. */
|
|
54
|
+
userEmail?: string;
|
|
55
|
+
/** We can set a different server URL (usually used for testing). */
|
|
56
|
+
adServerUrl?: string;
|
|
57
|
+
}
|
|
58
|
+
declare class Configuration {
|
|
59
|
+
private config;
|
|
60
|
+
constructor(config: ConfigOptions);
|
|
61
|
+
get publisherToken(): string;
|
|
62
|
+
get userId(): string;
|
|
63
|
+
get conversationId(): string;
|
|
64
|
+
get character(): Character | undefined;
|
|
65
|
+
get placementCode(): string;
|
|
66
|
+
get variantId(): string | undefined;
|
|
67
|
+
get regulatory(): Regulatory | undefined;
|
|
68
|
+
get logLevel(): "info" | "debug" | "log" | "warn" | "error" | "silent";
|
|
69
|
+
get userEmail(): string | undefined;
|
|
70
|
+
get adServerUrl(): string;
|
|
71
|
+
}
|
|
5
72
|
|
|
6
|
-
|
|
73
|
+
type LogLevel = 'debug' | 'info' | 'log' | 'warn' | 'error' | 'silent';
|
|
74
|
+
declare class Logger {
|
|
75
|
+
private localLevel;
|
|
76
|
+
private remoteLevel;
|
|
77
|
+
private remoteConfig;
|
|
78
|
+
private levels;
|
|
79
|
+
getLocalLevel(): LogLevel;
|
|
80
|
+
setLocalLevel(level: LogLevel): void;
|
|
81
|
+
getRemoteLevel(): LogLevel;
|
|
82
|
+
setRemoteLevel(level: LogLevel): void;
|
|
83
|
+
configureRemote(url: string, params: Record<string, any>): void;
|
|
84
|
+
private shouldLog;
|
|
85
|
+
private logToConsole;
|
|
86
|
+
private logToRemote;
|
|
87
|
+
debug(...args: any[]): void;
|
|
88
|
+
info(...args: any[]): void;
|
|
89
|
+
log(...args: any[]): void;
|
|
90
|
+
warn(...args: any[]): void;
|
|
91
|
+
error(...args: any[]): void;
|
|
92
|
+
}
|
|
7
93
|
|
|
8
|
-
|
|
94
|
+
type Bid = {
|
|
95
|
+
bidId: string;
|
|
96
|
+
code: string;
|
|
97
|
+
};
|
|
98
|
+
declare class Preload {
|
|
99
|
+
readonly session: Session;
|
|
100
|
+
private messages;
|
|
101
|
+
private abortController;
|
|
102
|
+
private running;
|
|
103
|
+
private bid;
|
|
104
|
+
constructor(session: Session, messages: Message[]);
|
|
105
|
+
private setMessages;
|
|
106
|
+
hasBid(): boolean;
|
|
107
|
+
getBid(): Bid | null;
|
|
108
|
+
private setBid;
|
|
109
|
+
cancel(): void;
|
|
110
|
+
isRunning(): boolean;
|
|
111
|
+
private getPreloadBody;
|
|
112
|
+
private canRequestAd;
|
|
113
|
+
requestAd(): Promise<{
|
|
114
|
+
status: string;
|
|
115
|
+
message: string;
|
|
116
|
+
} | {
|
|
117
|
+
status: string;
|
|
118
|
+
}>;
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
interface SDKConfig {
|
|
122
|
+
name: Exclude<SDK, 'sdk'>;
|
|
123
|
+
platform: 'ios' | 'android' | 'web';
|
|
124
|
+
version: string;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
declare class Session {
|
|
128
|
+
readonly config: Configuration;
|
|
129
|
+
readonly logger: Logger;
|
|
130
|
+
readonly sdk: SDKConfig;
|
|
131
|
+
private sessionId;
|
|
132
|
+
private sessionDisabled;
|
|
133
|
+
private messages;
|
|
134
|
+
private bids;
|
|
135
|
+
private onUpdateBidsCallback;
|
|
136
|
+
private preloadInstance;
|
|
137
|
+
constructor(config: Configuration, { sdk }: {
|
|
138
|
+
sdk: SDKConfig;
|
|
139
|
+
});
|
|
140
|
+
setOnUpdateBids(callback: () => void): void;
|
|
141
|
+
isSessionDisabled(): boolean;
|
|
142
|
+
setSessionDisabled(disabled: boolean): void;
|
|
143
|
+
getSessionId(): string | null;
|
|
144
|
+
setSessionId(sessionId: string): void;
|
|
145
|
+
addMessage(message: Message): void;
|
|
146
|
+
getMessages(): Message[];
|
|
147
|
+
updateBids(): void;
|
|
148
|
+
preload(): Preload;
|
|
149
|
+
getLastBid(): {
|
|
150
|
+
bidId: string;
|
|
151
|
+
messageId: string;
|
|
152
|
+
} | undefined;
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
interface InlineAdProps {
|
|
156
|
+
messageId: string;
|
|
157
|
+
session: Session;
|
|
158
|
+
onDebugEvent: (name: string, data?: any) => void;
|
|
159
|
+
}
|
|
160
|
+
declare const InlineAd: ({ messageId, session, onDebugEvent }: InlineAdProps) => react_jsx_runtime.JSX.Element | null;
|
|
161
|
+
|
|
162
|
+
type GlobalConfig = Pick<ConfigOptions, 'publisherToken' | 'userId' | 'userEmail' | 'adServerUrl' | 'logLevel' | 'placementCode'>;
|
|
163
|
+
type SessionConfig = Pick<ConfigOptions, 'conversationId' | 'character' | 'variantId' | 'regulatory'>;
|
|
164
|
+
declare const KontextAds: (config: GlobalConfig) => {
|
|
165
|
+
createSession: (sessionConfig: SessionConfig) => {
|
|
166
|
+
addMessage: (message: Message) => void;
|
|
167
|
+
getInstance: () => Session;
|
|
168
|
+
};
|
|
169
|
+
};
|
|
170
|
+
|
|
171
|
+
export { InlineAd, KontextAds };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,8 +1,171 @@
|
|
|
1
1
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
-
import {
|
|
2
|
+
import { Message, SDK } from '@kontextso/sdk-common';
|
|
3
3
|
|
|
4
|
-
|
|
4
|
+
type Regulatory = {
|
|
5
|
+
/** Flag that indicates whether or not the request is subject to GDPR regulations 0 = No, 1 = Yes, omission indicates Unknown */
|
|
6
|
+
gdpr?: 0 | 1;
|
|
7
|
+
/** When GDPR regulations are in effect this attribute contains the Transparency and Consent Framework's Consent String data structure */
|
|
8
|
+
gdprConsent?: string;
|
|
9
|
+
/** Flag indicating if this request is subject to the COPPA regulations established by the USA FTC, where 0 = no, 1 = yes, omission indicates Unknown */
|
|
10
|
+
coppa?: 0 | 1;
|
|
11
|
+
/** Contains the Global Privacy Platform's consent string. See IAB-GPP spec for more details */
|
|
12
|
+
gpp?: string;
|
|
13
|
+
/** List of the section(s) of the GPP string which should be applied for this transaction */
|
|
14
|
+
gppSid?: number[];
|
|
15
|
+
/** Communicates signals regarding consumer privacy under US privacy regulation under CCPA and LSPA */
|
|
16
|
+
usPrivacy?: string;
|
|
17
|
+
};
|
|
18
|
+
interface Character {
|
|
19
|
+
/** Unique ID of the character */
|
|
20
|
+
id: string;
|
|
21
|
+
/** Name of the character */
|
|
22
|
+
name: string;
|
|
23
|
+
/** URL of the character’s avatar */
|
|
24
|
+
avatarUrl?: string;
|
|
25
|
+
/** Greeting of the character */
|
|
26
|
+
greeting?: string;
|
|
27
|
+
/** Description of the character’s personality */
|
|
28
|
+
persona?: string;
|
|
29
|
+
/** Tags of the character */
|
|
30
|
+
tags?: string[];
|
|
31
|
+
/** Whether the character is NSFW */
|
|
32
|
+
isNsfw?: boolean;
|
|
33
|
+
[key: string]: string | string[] | boolean | undefined;
|
|
34
|
+
}
|
|
35
|
+
interface ConfigOptions {
|
|
36
|
+
/** Your publisher token. This token is not secret and is visible in the browser’s developer console. */
|
|
37
|
+
publisherToken: string;
|
|
38
|
+
/** The SDK can be temporarily disabled by setting it to false (no ads will be rendered). */
|
|
39
|
+
userId: string;
|
|
40
|
+
/** Unique identifier of the conversation. */
|
|
41
|
+
conversationId: string;
|
|
42
|
+
/** Character information. */
|
|
43
|
+
character?: Character;
|
|
44
|
+
/** A list of allowed placement codes. */
|
|
45
|
+
placementCode?: string;
|
|
46
|
+
/** A variant ID that helps determine which type of ad to render. */
|
|
47
|
+
variantId?: string;
|
|
48
|
+
/** Device-specific identifier provided by the operating systems (IDFA/GAID) */
|
|
49
|
+
/** Regulatory features. */
|
|
50
|
+
regulatory?: Regulatory;
|
|
51
|
+
/** Local and remote logging settings. */
|
|
52
|
+
logLevel?: 'debug' | 'info' | 'log' | 'warn' | 'error' | 'silent';
|
|
53
|
+
/** The email of the user. */
|
|
54
|
+
userEmail?: string;
|
|
55
|
+
/** We can set a different server URL (usually used for testing). */
|
|
56
|
+
adServerUrl?: string;
|
|
57
|
+
}
|
|
58
|
+
declare class Configuration {
|
|
59
|
+
private config;
|
|
60
|
+
constructor(config: ConfigOptions);
|
|
61
|
+
get publisherToken(): string;
|
|
62
|
+
get userId(): string;
|
|
63
|
+
get conversationId(): string;
|
|
64
|
+
get character(): Character | undefined;
|
|
65
|
+
get placementCode(): string;
|
|
66
|
+
get variantId(): string | undefined;
|
|
67
|
+
get regulatory(): Regulatory | undefined;
|
|
68
|
+
get logLevel(): "info" | "debug" | "log" | "warn" | "error" | "silent";
|
|
69
|
+
get userEmail(): string | undefined;
|
|
70
|
+
get adServerUrl(): string;
|
|
71
|
+
}
|
|
5
72
|
|
|
6
|
-
|
|
73
|
+
type LogLevel = 'debug' | 'info' | 'log' | 'warn' | 'error' | 'silent';
|
|
74
|
+
declare class Logger {
|
|
75
|
+
private localLevel;
|
|
76
|
+
private remoteLevel;
|
|
77
|
+
private remoteConfig;
|
|
78
|
+
private levels;
|
|
79
|
+
getLocalLevel(): LogLevel;
|
|
80
|
+
setLocalLevel(level: LogLevel): void;
|
|
81
|
+
getRemoteLevel(): LogLevel;
|
|
82
|
+
setRemoteLevel(level: LogLevel): void;
|
|
83
|
+
configureRemote(url: string, params: Record<string, any>): void;
|
|
84
|
+
private shouldLog;
|
|
85
|
+
private logToConsole;
|
|
86
|
+
private logToRemote;
|
|
87
|
+
debug(...args: any[]): void;
|
|
88
|
+
info(...args: any[]): void;
|
|
89
|
+
log(...args: any[]): void;
|
|
90
|
+
warn(...args: any[]): void;
|
|
91
|
+
error(...args: any[]): void;
|
|
92
|
+
}
|
|
7
93
|
|
|
8
|
-
|
|
94
|
+
type Bid = {
|
|
95
|
+
bidId: string;
|
|
96
|
+
code: string;
|
|
97
|
+
};
|
|
98
|
+
declare class Preload {
|
|
99
|
+
readonly session: Session;
|
|
100
|
+
private messages;
|
|
101
|
+
private abortController;
|
|
102
|
+
private running;
|
|
103
|
+
private bid;
|
|
104
|
+
constructor(session: Session, messages: Message[]);
|
|
105
|
+
private setMessages;
|
|
106
|
+
hasBid(): boolean;
|
|
107
|
+
getBid(): Bid | null;
|
|
108
|
+
private setBid;
|
|
109
|
+
cancel(): void;
|
|
110
|
+
isRunning(): boolean;
|
|
111
|
+
private getPreloadBody;
|
|
112
|
+
private canRequestAd;
|
|
113
|
+
requestAd(): Promise<{
|
|
114
|
+
status: string;
|
|
115
|
+
message: string;
|
|
116
|
+
} | {
|
|
117
|
+
status: string;
|
|
118
|
+
}>;
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
interface SDKConfig {
|
|
122
|
+
name: Exclude<SDK, 'sdk'>;
|
|
123
|
+
platform: 'ios' | 'android' | 'web';
|
|
124
|
+
version: string;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
declare class Session {
|
|
128
|
+
readonly config: Configuration;
|
|
129
|
+
readonly logger: Logger;
|
|
130
|
+
readonly sdk: SDKConfig;
|
|
131
|
+
private sessionId;
|
|
132
|
+
private sessionDisabled;
|
|
133
|
+
private messages;
|
|
134
|
+
private bids;
|
|
135
|
+
private onUpdateBidsCallback;
|
|
136
|
+
private preloadInstance;
|
|
137
|
+
constructor(config: Configuration, { sdk }: {
|
|
138
|
+
sdk: SDKConfig;
|
|
139
|
+
});
|
|
140
|
+
setOnUpdateBids(callback: () => void): void;
|
|
141
|
+
isSessionDisabled(): boolean;
|
|
142
|
+
setSessionDisabled(disabled: boolean): void;
|
|
143
|
+
getSessionId(): string | null;
|
|
144
|
+
setSessionId(sessionId: string): void;
|
|
145
|
+
addMessage(message: Message): void;
|
|
146
|
+
getMessages(): Message[];
|
|
147
|
+
updateBids(): void;
|
|
148
|
+
preload(): Preload;
|
|
149
|
+
getLastBid(): {
|
|
150
|
+
bidId: string;
|
|
151
|
+
messageId: string;
|
|
152
|
+
} | undefined;
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
interface InlineAdProps {
|
|
156
|
+
messageId: string;
|
|
157
|
+
session: Session;
|
|
158
|
+
onDebugEvent: (name: string, data?: any) => void;
|
|
159
|
+
}
|
|
160
|
+
declare const InlineAd: ({ messageId, session, onDebugEvent }: InlineAdProps) => react_jsx_runtime.JSX.Element | null;
|
|
161
|
+
|
|
162
|
+
type GlobalConfig = Pick<ConfigOptions, 'publisherToken' | 'userId' | 'userEmail' | 'adServerUrl' | 'logLevel' | 'placementCode'>;
|
|
163
|
+
type SessionConfig = Pick<ConfigOptions, 'conversationId' | 'character' | 'variantId' | 'regulatory'>;
|
|
164
|
+
declare const KontextAds: (config: GlobalConfig) => {
|
|
165
|
+
createSession: (sessionConfig: SessionConfig) => {
|
|
166
|
+
addMessage: (message: Message) => void;
|
|
167
|
+
getInstance: () => Session;
|
|
168
|
+
};
|
|
169
|
+
};
|
|
170
|
+
|
|
171
|
+
export { InlineAd, KontextAds };
|