@kerdly/expo 0.0.0-stage → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +235 -2
- package/android/build.gradle +61 -0
- package/android/src/main/AndroidManifest.xml +19 -0
- package/android/src/main/java/com/kerdly/expo/KerdlySdkModule.kt +326 -0
- package/android/vendor/kerdly-sdk/.kerdly-sync.json +8 -0
- package/android/vendor/kerdly-sdk/consumer-rules.pro +15 -0
- package/android/vendor/kerdly-sdk/kerdly-sdk.properties +2 -0
- package/android/vendor/kerdly-sdk/kotlin/com/kerdly/sdk/Kerdly.kt +343 -0
- package/android/vendor/kerdly-sdk/kotlin/com/kerdly/sdk/KerdlyTypes.kt +89 -0
- package/android/vendor/kerdly-sdk/kotlin/com/kerdly/sdk/internal/Attribution.kt +39 -0
- package/android/vendor/kerdly-sdk/kotlin/com/kerdly/sdk/internal/Batch.kt +159 -0
- package/android/vendor/kerdly-sdk/kotlin/com/kerdly/sdk/internal/Core.kt +991 -0
- package/android/vendor/kerdly-sdk/kotlin/com/kerdly/sdk/internal/DeepLinks.kt +114 -0
- package/android/vendor/kerdly-sdk/kotlin/com/kerdly/sdk/internal/DeferredLinks.kt +110 -0
- package/android/vendor/kerdly-sdk/kotlin/com/kerdly/sdk/internal/DeviceContext.kt +137 -0
- package/android/vendor/kerdly-sdk/kotlin/com/kerdly/sdk/internal/EventQueue.kt +135 -0
- package/android/vendor/kerdly-sdk/kotlin/com/kerdly/sdk/internal/Events.kt +314 -0
- package/android/vendor/kerdly-sdk/kotlin/com/kerdly/sdk/internal/Json.kt +116 -0
- package/android/vendor/kerdly-sdk/kotlin/com/kerdly/sdk/internal/Logger.kt +49 -0
- package/android/vendor/kerdly-sdk/kotlin/com/kerdly/sdk/internal/Options.kt +47 -0
- package/android/vendor/kerdly-sdk/kotlin/com/kerdly/sdk/internal/Ports.kt +83 -0
- package/android/vendor/kerdly-sdk/kotlin/com/kerdly/sdk/internal/PublicIp.kt +120 -0
- package/android/vendor/kerdly-sdk/kotlin/com/kerdly/sdk/internal/Referrers.kt +137 -0
- package/android/vendor/kerdly-sdk/kotlin/com/kerdly/sdk/internal/RemoteConfig.kt +100 -0
- package/android/vendor/kerdly-sdk/kotlin/com/kerdly/sdk/internal/Storage.kt +271 -0
- package/android/vendor/kerdly-sdk/kotlin/com/kerdly/sdk/internal/android/AndroidPlatform.kt +274 -0
- package/android/vendor/kerdly-sdk/kotlin/com/kerdly/sdk/internal/android/AndroidRuntime.kt +187 -0
- package/android/vendor/kerdly-sdk/kotlin/com/kerdly/sdk/internal/android/PlayReferrerReader.kt +97 -0
- package/app.plugin.js +2 -0
- package/build/Kerdly.d.ts +106 -0
- package/build/Kerdly.d.ts.map +1 -0
- package/build/Kerdly.js +494 -0
- package/build/Kerdly.js.map +1 -0
- package/build/index.d.ts +4 -0
- package/build/index.d.ts.map +1 -0
- package/build/index.js +2 -0
- package/build/index.js.map +1 -0
- package/build/log.d.ts +13 -0
- package/build/log.d.ts.map +1 -0
- package/build/log.js +45 -0
- package/build/log.js.map +1 -0
- package/build/native.d.ts +74 -0
- package/build/native.d.ts.map +1 -0
- package/build/native.js +56 -0
- package/build/native.js.map +1 -0
- package/build/normalize.d.ts +8 -0
- package/build/normalize.d.ts.map +1 -0
- package/build/normalize.js +86 -0
- package/build/normalize.js.map +1 -0
- package/build/types.d.ts +134 -0
- package/build/types.d.ts.map +1 -0
- package/build/types.js +3 -0
- package/build/types.js.map +1 -0
- package/build/validation.d.ts +70 -0
- package/build/validation.d.ts.map +1 -0
- package/build/validation.js +349 -0
- package/build/validation.js.map +1 -0
- package/build/version.d.ts +4 -0
- package/build/version.d.ts.map +1 -0
- package/build/version.js +5 -0
- package/build/version.js.map +1 -0
- package/expo-module.config.json +9 -0
- package/ios/KerdlySDK/.kerdly-sync.json +7 -0
- package/ios/KerdlySDK/Core/Dependencies.swift +163 -0
- package/ios/KerdlySDK/Core/KerdlyCore+API.swift +117 -0
- package/ios/KerdlySDK/Core/KerdlyCore+Collectors.swift +410 -0
- package/ios/KerdlySDK/Core/KerdlyCore+DeferredLinks.swift +220 -0
- package/ios/KerdlySDK/Core/KerdlyCore+Delivery.swift +424 -0
- package/ios/KerdlySDK/Core/KerdlyCore.swift +557 -0
- package/ios/KerdlySDK/Core/Support.swift +95 -0
- package/ios/KerdlySDK/Logic/Backoff.swift +22 -0
- package/ios/KerdlySDK/Logic/Batch.swift +180 -0
- package/ios/KerdlySDK/Logic/Context.swift +85 -0
- package/ios/KerdlySDK/Logic/DeepLinks.swift +93 -0
- package/ios/KerdlySDK/Logic/DeferredLinks.swift +236 -0
- package/ios/KerdlySDK/Logic/Environment.swift +39 -0
- package/ios/KerdlySDK/Logic/EventQueue.swift +85 -0
- package/ios/KerdlySDK/Logic/EventValidator.swift +84 -0
- package/ios/KerdlySDK/Logic/Events.swift +102 -0
- package/ios/KerdlySDK/Logic/IPv6Address.swift +26 -0
- package/ios/KerdlySDK/Logic/InstallIdentity.swift +106 -0
- package/ios/KerdlySDK/Logic/JSONValue.swift +198 -0
- package/ios/KerdlySDK/Logic/Purchases.swift +84 -0
- package/ios/KerdlySDK/Logic/RemoteConfig.swift +185 -0
- package/ios/KerdlySDK/Logic/Skan.swift +343 -0
- package/ios/KerdlySDK/Logic/StandardEvents.swift +126 -0
- package/ios/KerdlySDK/Platform/AdSignals.swift +19 -0
- package/ios/KerdlySDK/Platform/DeferredLinkBundle.swift +25 -0
- package/ios/KerdlySDK/Platform/DeviceInfo.swift +82 -0
- package/ios/KerdlySDK/Platform/Lifecycle.swift +74 -0
- package/ios/KerdlySDK/Platform/PublicIp.swift +33 -0
- package/ios/KerdlySDK/Platform/SkanWriter.swift +70 -0
- package/ios/KerdlySDK/Platform/StoreKitAdapter.swift +185 -0
- package/ios/KerdlySDK/Platform/SystemStores.swift +200 -0
- package/ios/KerdlySDK/Platform/Tracking.swift +124 -0
- package/ios/KerdlySDK/Public/Kerdly.swift +202 -0
- package/ios/KerdlySDK/Public/KerdlyTypes.swift +130 -0
- package/ios/KerdlySDK/Resources/PrivacyInfo.xcprivacy +96 -0
- package/ios/KerdlySDK/Storage/PersistedState.swift +175 -0
- package/ios/KerdlySDK/Storage/StateStore.swift +36 -0
- package/ios/KerdlySdk.podspec +45 -0
- package/ios/KerdlySdkModule.swift +332 -0
- package/package.json +96 -4
- package/plugin/withKerdly.js +163 -0
- package/src/Kerdly.ts +524 -0
- package/src/index.ts +23 -0
- package/src/log.ts +49 -0
- package/src/native.ts +150 -0
- package/src/normalize.ts +82 -0
- package/src/types.ts +182 -0
- package/src/validation.ts +343 -0
- package/src/version.ts +5 -0
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import type { KerdlyDeepLinkSource, KerdlyEnvironment, KerdlyEventValue, KerdlyLogLevel } from './types';
|
|
2
|
+
/**
|
|
3
|
+
* The JS <-> native contract. ios/KerdlySdkModule.swift and
|
|
4
|
+
* android/src/main/java/com/kerdly/expo/KerdlySdkModule.kt implement exactly these functions (all
|
|
5
|
+
* `AsyncFunction`s on the main queue, so native calls run in JS call order) and the
|
|
6
|
+
* `onAttribution` event. Payloads coming back from native are `unknown` here and normalised in
|
|
7
|
+
* normalize.ts.
|
|
8
|
+
*/
|
|
9
|
+
export declare const NATIVE_MODULE_NAME = "KerdlySdk";
|
|
10
|
+
export declare const ATTRIBUTION_EVENT = "onAttribution";
|
|
11
|
+
export interface NativeConfigureOptions {
|
|
12
|
+
key: string;
|
|
13
|
+
endpoint: string;
|
|
14
|
+
environment: KerdlyEnvironment;
|
|
15
|
+
collectAdvertisingId: boolean;
|
|
16
|
+
/** Read by iOS only. */
|
|
17
|
+
skanWriter: boolean;
|
|
18
|
+
/** Read by Android only. */
|
|
19
|
+
metaAppId?: string;
|
|
20
|
+
logLevel: KerdlyLogLevel;
|
|
21
|
+
wrapper: string;
|
|
22
|
+
}
|
|
23
|
+
/** Union of both platforms' purchase fields; each bridge reads its own. */
|
|
24
|
+
export interface NativePurchase {
|
|
25
|
+
originalTransactionId?: string;
|
|
26
|
+
transactionId?: string;
|
|
27
|
+
productId?: string;
|
|
28
|
+
appAccountToken?: string;
|
|
29
|
+
purchaseToken?: string;
|
|
30
|
+
orderId?: string;
|
|
31
|
+
products?: string[];
|
|
32
|
+
purchaseTime?: number;
|
|
33
|
+
obfuscatedAccountId?: string;
|
|
34
|
+
obfuscatedProfileId?: string;
|
|
35
|
+
}
|
|
36
|
+
export interface NativeNetworkSend {
|
|
37
|
+
network: string;
|
|
38
|
+
event: string;
|
|
39
|
+
eventId?: string;
|
|
40
|
+
value?: number;
|
|
41
|
+
currency?: string;
|
|
42
|
+
flag?: string;
|
|
43
|
+
}
|
|
44
|
+
export interface KerdlySdkNativeModule {
|
|
45
|
+
configure(options: NativeConfigureOptions): Promise<void>;
|
|
46
|
+
setUserId(userId: string | null): Promise<void>;
|
|
47
|
+
track(name: string, properties: Record<string, KerdlyEventValue>): Promise<void>;
|
|
48
|
+
trackRegistration(method: string | null, properties: Record<string, KerdlyEventValue>): Promise<void>;
|
|
49
|
+
trackStartTrial(productId: string | null, value: number | null, currency: string | null, transactionId: string | null, properties: Record<string, KerdlyEventValue>): Promise<void>;
|
|
50
|
+
trackSubscribe(productId: string | null, value: number | null, currency: string | null, transactionId: string | null, properties: Record<string, KerdlyEventValue>): Promise<void>;
|
|
51
|
+
trackPurchase(productId: string | null, value: number | null, currency: string | null, quantity: number | null, transactionId: string | null, properties: Record<string, KerdlyEventValue>): Promise<void>;
|
|
52
|
+
setConsent(analytics: boolean | null, ads: boolean | null): Promise<void>;
|
|
53
|
+
handleUrl(url: string, source: KerdlyDeepLinkSource | null): Promise<unknown>;
|
|
54
|
+
setAppAccountToken(token: string | null): Promise<void>;
|
|
55
|
+
setPartnerIds(ids: Record<string, string>): Promise<void>;
|
|
56
|
+
notifyPurchase(purchase: NativePurchase | null): Promise<void>;
|
|
57
|
+
recordNetworkSend(send: NativeNetworkSend): Promise<void>;
|
|
58
|
+
getAttribution(): Promise<unknown>;
|
|
59
|
+
requestTrackingAuthorization(): Promise<unknown>;
|
|
60
|
+
flush(): Promise<void>;
|
|
61
|
+
getInstallId(): Promise<unknown>;
|
|
62
|
+
debugFetchDeferredLinks(tiktokAppId: string | null, storeAppId: string | null): Promise<unknown>;
|
|
63
|
+
addListener(eventName: typeof ATTRIBUTION_EVENT, listener: (payload: unknown) => void): {
|
|
64
|
+
remove(): void;
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
export type NativeMethod = Exclude<keyof KerdlySdkNativeModule, 'addListener'>;
|
|
68
|
+
export declare function getNativeModule(): KerdlySdkNativeModule | null;
|
|
69
|
+
/**
|
|
70
|
+
* Calls a native function. Never throws and never rejects: a missing module or method, a
|
|
71
|
+
* synchronous throw and a rejected promise all resolve to `undefined` (with a development warning).
|
|
72
|
+
*/
|
|
73
|
+
export declare function callNative<M extends NativeMethod>(method: M, ...args: Parameters<KerdlySdkNativeModule[M]>): Promise<Awaited<ReturnType<KerdlySdkNativeModule[M]>> | undefined>;
|
|
74
|
+
//# sourceMappingURL=native.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"native.d.ts","sourceRoot":"","sources":["../src/native.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,oBAAoB,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AAEzG;;;;;;GAMG;AACH,eAAO,MAAM,kBAAkB,cAAc,CAAC;AAC9C,eAAO,MAAM,iBAAiB,kBAAkB,CAAC;AAEjD,MAAM,WAAW,sBAAsB;IACrC,GAAG,EAAE,MAAM,CAAC;IACZ,QAAQ,EAAE,MAAM,CAAC;IACjB,WAAW,EAAE,iBAAiB,CAAC;IAC/B,oBAAoB,EAAE,OAAO,CAAC;IAC9B,wBAAwB;IACxB,UAAU,EAAE,OAAO,CAAC;IACpB,4BAA4B;IAC5B,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,QAAQ,EA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CAAC;IAC/D,iBAAiB,CAAC,IAAI,EAAE,iBAAiB,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAC1D,cAAc,IAAI,OAAO,CAAC,OAAO,CAAC,CAAC;IACnC,4BAA4B,IAAI,OAAO,CAAC,OAAO,CAAC,CAAC;IACjD,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;IACvB,YAAY,IAAI,OAAO,CAAC,OAAO,CAAC,CAAC;IACjC,uBAAuB,CAAC,WAAW,EAAE,MAAM,GAAG,IAAI,EAAE,UAAU,EAAE,MAAM,GAAG,IAAI,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;IACjG,WAAW,CAAC,SAAS,EAAE,OAAO,iBAAiB,EAAE,QAAQ,EAAE,CAAC,OAAO,EAAE,OAAO,KAAK,IAAI,GAAG;QACtF,MAAM,IAAI,IAAI,CAAC;KAChB,CAAC;CACH;AAED,MAAM,MAAM,YAAY,GAAG,OAAO,CAAC,MAAM,qBAAqB,EAAE,aAAa,CAAC,CAAC;AAK/E,wBAAgB,eAAe,IAAI,qBAAqB,GAAG,IAAI,CAgB9D;AAED;;;GAGG;AACH,wBAAgB,UAAU,CAAC,CAAC,SAAS,YAAY,EAC/C,MAAM,EAAE,CAAC,EACT,GAAG,IAAI,EAAE,UAAU,CAAC,qBAAqB,CAAC,CAAC,CAAC,CAAC,GAC5C,OAAO,CAAC,OAAO,CAAC,UAAU,CAAC,qBAAqB,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,SAAS,CAAC,CAwBpE"}
|
package/build/native.js
ADDED
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { requireOptionalNativeModule } from 'expo-modules-core';
|
|
2
|
+
import { devWarn, devWarnOnce } from './log';
|
|
3
|
+
/**
|
|
4
|
+
* The JS <-> native contract. ios/KerdlySdkModule.swift and
|
|
5
|
+
* android/src/main/java/com/kerdly/expo/KerdlySdkModule.kt implement exactly these functions (all
|
|
6
|
+
* `AsyncFunction`s on the main queue, so native calls run in JS call order) and the
|
|
7
|
+
* `onAttribution` event. Payloads coming back from native are `unknown` here and normalised in
|
|
8
|
+
* normalize.ts.
|
|
9
|
+
*/
|
|
10
|
+
export const NATIVE_MODULE_NAME = 'KerdlySdk';
|
|
11
|
+
export const ATTRIBUTION_EVENT = 'onAttribution';
|
|
12
|
+
// undefined = not looked up yet; null = not available (Expo Go, web, app not rebuilt).
|
|
13
|
+
let cached;
|
|
14
|
+
export function getNativeModule() {
|
|
15
|
+
if (cached !== undefined)
|
|
16
|
+
return cached;
|
|
17
|
+
try {
|
|
18
|
+
cached = requireOptionalNativeModule(NATIVE_MODULE_NAME) ?? null;
|
|
19
|
+
}
|
|
20
|
+
catch {
|
|
21
|
+
cached = null;
|
|
22
|
+
}
|
|
23
|
+
if (cached === null) {
|
|
24
|
+
devWarnOnce('native-missing', `The native module '${NATIVE_MODULE_NAME}' is not available, so every Kerdly call is a no-op. ` +
|
|
25
|
+
'Rebuild the native app after installing @kerdly/expo (npx expo prebuild, then ' +
|
|
26
|
+
'npx expo run:ios / run:android, or an EAS build). Expo Go and web do not include it.');
|
|
27
|
+
}
|
|
28
|
+
return cached;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Calls a native function. Never throws and never rejects: a missing module or method, a
|
|
32
|
+
* synchronous throw and a rejected promise all resolve to `undefined` (with a development warning).
|
|
33
|
+
*/
|
|
34
|
+
export function callNative(method, ...args) {
|
|
35
|
+
const native = getNativeModule();
|
|
36
|
+
if (!native)
|
|
37
|
+
return Promise.resolve(undefined);
|
|
38
|
+
try {
|
|
39
|
+
const fn = native[method];
|
|
40
|
+
if (typeof fn !== 'function') {
|
|
41
|
+
devWarnOnce(`native-method-${method}`, `The native module '${NATIVE_MODULE_NAME}' has no function '${method}'. ` +
|
|
42
|
+
'The JS and native parts of @kerdly/expo are out of sync: rebuild the native app.');
|
|
43
|
+
return Promise.resolve(undefined);
|
|
44
|
+
}
|
|
45
|
+
const result = fn.apply(native, args);
|
|
46
|
+
return Promise.resolve(result).catch((error) => {
|
|
47
|
+
devWarn(`Native ${method} failed:`, error);
|
|
48
|
+
return undefined;
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
catch (error) {
|
|
52
|
+
devWarn(`Native ${method} threw:`, error);
|
|
53
|
+
return Promise.resolve(undefined);
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
//# sourceMappingURL=native.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"native.js","sourceRoot":"","sources":["../src/native.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,2BAA2B,EAAE,MAAM,mBAAmB,CAAC;AAEhE,OAAO,EAAE,OAAO,EAAE,WAAW,EAAE,MAAM,OAAO,CAAC;AAG7C;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,kBAAkB,GAAG,WAAW,CAAC;AAC9C,MAAM,CAAC,MAAM,iBAAiB,GAAG,eAAe,CAAC;AAoFjD,uFAAuF;AACvF,IAAI,MAAgD,CAAC;AAErD,MAAM,UAAU,eAAe;IAC7B,IAAI,MAAM,KAAK,SAAS;QAAE,OAAO,MAAM,CAAC;IACxC,IAAI,CAAC;QACH,MAAM,GAAG,2BAA2B,CAAwB,kBAAkB,CAAC,IAAI,IAAI,CAAC;IAC1F,CAAC;IAAC,MAAM,CAAC;QACP,MAAM,GAAG,IAAI,CAAC;IAChB,CAAC;IACD,IAAI,MAAM,KAAK,IAAI,EAAE,CAAC;QACpB,WAAW,CACT,gBAAgB,EAChB,sBAAsB,kBAAkB,uDAAuD;YAC7F,gFAAgF;YAChF,sFAAsF,CACzF,CAAC;IACJ,CAAC;IACD,OAAO,MAAM,CAAC;AAChB,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,UAAU,CACxB,MAAS,EACT,GAAG,IAA0C;IAE7C,MAAM,MAAM,GAAG,eAAe,EAAE,CAAC;IACjC,IAAI,CAAC,MAAM;QAAE,OAAO,OAAO,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC;IAC/C,IAAI,CAAC;QACH,MAAM,EAAE,GAAG,MAAM,CAAC,MAAM,CAAY,CAAC;QACrC,IAAI,OAAO,EAAE,KAAK,UAAU,EAAE,CAAC;YAC7B,WAAW,CACT,iBAAiB,MAAM,EAAE,EACzB,sBAAsB,kBAAkB,sBAAsB,MAAM,KAAK;gBACvE,kFAAkF,CACrF,CAAC;YACF,OAAO,OAAO,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC;QACpC,CAAC;QACD,MAAM,MAAM,GAAI,EAAmC,CAAC,KAAK,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;QACxE,OAAO,OAAO,CAAC,OAAO,CAAC,MAAuD,CAAC,CAAC,KAAK,CACnF,CAAC,KAAc,EAAE,EAAE;YACjB,OAAO,CAAC,UAAU,MAAM,UAAU,EAAE,KAAK,CAAC,CAAC;YAC3C,OAAO,SAAS,CAAC;QACnB,CAAC,CACF,CAAC;IACJ,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,OAAO,CAAC,UAAU,MAAM,SAAS,EAAE,KAAK,CAAC,CAAC;QAC1C,OAAO,OAAO,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC;IACpC,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { KerdlyAttribution, KerdlyDeepLink } from './types';
|
|
2
|
+
export declare function normalizeDeepLink(payload: unknown): KerdlyDeepLink | null;
|
|
3
|
+
/**
|
|
4
|
+
* iOS sends `raw` as an object, Android as the JSON string (Kotlin `KerdlyAttribution.raw: String`);
|
|
5
|
+
* both become an object here.
|
|
6
|
+
*/
|
|
7
|
+
export declare function normalizeAttribution(payload: unknown): KerdlyAttribution | null;
|
|
8
|
+
//# sourceMappingURL=normalize.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"normalize.d.ts","sourceRoot":"","sources":["../src/normalize.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,iBAAiB,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AAoCjE,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,OAAO,GAAG,cAAc,GAAG,IAAI,CAYzE;AAED;;;GAGG;AACH,wBAAgB,oBAAoB,CAAC,OAAO,EAAE,OAAO,GAAG,iBAAiB,GAAG,IAAI,CA0B/E"}
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import { isPlainObject } from './validation';
|
|
2
|
+
// The bridges send camelCase keys. snake_case (the protocol's JSON names) is accepted too, so a
|
|
3
|
+
// payload that is the collector's raw attribution object still normalises.
|
|
4
|
+
function str(source, camel, snake) {
|
|
5
|
+
const value = source[camel] ?? (snake === undefined ? undefined : source[snake]);
|
|
6
|
+
if (typeof value === 'string')
|
|
7
|
+
return value;
|
|
8
|
+
if (typeof value === 'number' && Number.isFinite(value))
|
|
9
|
+
return String(value);
|
|
10
|
+
return null;
|
|
11
|
+
}
|
|
12
|
+
function millis(value) {
|
|
13
|
+
if (typeof value === 'number' && Number.isFinite(value))
|
|
14
|
+
return value;
|
|
15
|
+
if (typeof value === 'string' && value.length > 0) {
|
|
16
|
+
const asNumber = Number(value);
|
|
17
|
+
if (Number.isFinite(asNumber))
|
|
18
|
+
return asNumber;
|
|
19
|
+
const parsed = Date.parse(value);
|
|
20
|
+
return Number.isNaN(parsed) ? null : parsed;
|
|
21
|
+
}
|
|
22
|
+
return null;
|
|
23
|
+
}
|
|
24
|
+
function rawObject(value) {
|
|
25
|
+
if (isPlainObject(value))
|
|
26
|
+
return value;
|
|
27
|
+
if (typeof value === 'string' && value.length > 0) {
|
|
28
|
+
try {
|
|
29
|
+
const parsed = JSON.parse(value);
|
|
30
|
+
return isPlainObject(parsed) ? parsed : null;
|
|
31
|
+
}
|
|
32
|
+
catch {
|
|
33
|
+
return null;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
return null;
|
|
37
|
+
}
|
|
38
|
+
export function normalizeDeepLink(payload) {
|
|
39
|
+
if (!isPlainObject(payload))
|
|
40
|
+
return null;
|
|
41
|
+
const url = str(payload, 'url');
|
|
42
|
+
if (url === null)
|
|
43
|
+
return null;
|
|
44
|
+
return {
|
|
45
|
+
url,
|
|
46
|
+
cpp: str(payload, 'cpp'),
|
|
47
|
+
ppid: str(payload, 'ppid'),
|
|
48
|
+
clickId: str(payload, 'clickId', 'kerdly_c'),
|
|
49
|
+
visitId: str(payload, 'visitId', 'kerdly_v'),
|
|
50
|
+
campaignIds: str(payload, 'campaignIds', 'campaign_ids'),
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* iOS sends `raw` as an object, Android as the JSON string (Kotlin `KerdlyAttribution.raw: String`);
|
|
55
|
+
* both become an object here.
|
|
56
|
+
*/
|
|
57
|
+
export function normalizeAttribution(payload) {
|
|
58
|
+
if (!isPlainObject(payload))
|
|
59
|
+
return null;
|
|
60
|
+
const state = str(payload, 'state');
|
|
61
|
+
const network = str(payload, 'network');
|
|
62
|
+
const status = str(payload, 'status');
|
|
63
|
+
const method = str(payload, 'method');
|
|
64
|
+
if (state === null || network === null || status === null || method === null)
|
|
65
|
+
return null;
|
|
66
|
+
const { raw: rawField, ...fields } = payload;
|
|
67
|
+
return {
|
|
68
|
+
state,
|
|
69
|
+
network,
|
|
70
|
+
status,
|
|
71
|
+
method,
|
|
72
|
+
campaignId: str(payload, 'campaignId', 'campaign_id'),
|
|
73
|
+
campaign: str(payload, 'campaign'),
|
|
74
|
+
adsetId: str(payload, 'adsetId', 'adset_id'),
|
|
75
|
+
adset: str(payload, 'adset'),
|
|
76
|
+
adId: str(payload, 'adId', 'ad_id'),
|
|
77
|
+
ad: str(payload, 'ad'),
|
|
78
|
+
keywordId: str(payload, 'keywordId', 'keyword_id'),
|
|
79
|
+
keyword: str(payload, 'keyword'),
|
|
80
|
+
linkId: str(payload, 'linkId', 'link_id'),
|
|
81
|
+
cppId: str(payload, 'cppId', 'cpp_id'),
|
|
82
|
+
decidedAt: millis(payload.decidedAt ?? payload.decided_at),
|
|
83
|
+
raw: rawObject(rawField) ?? fields,
|
|
84
|
+
};
|
|
85
|
+
}
|
|
86
|
+
//# sourceMappingURL=normalize.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"normalize.js","sourceRoot":"","sources":["../src/normalize.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAG7C,gGAAgG;AAChG,2EAA2E;AAE3E,SAAS,GAAG,CAAC,MAA+B,EAAE,KAAa,EAAE,KAAc;IACzE,MAAM,KAAK,GAAG,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,KAAK,KAAK,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC;IACjF,IAAI,OAAO,KAAK,KAAK,QAAQ;QAAE,OAAO,KAAK,CAAC;IAC5C,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC;QAAE,OAAO,MAAM,CAAC,KAAK,CAAC,CAAC;IAC9E,OAAO,IAAI,CAAC;AACd,CAAC;AAED,SAAS,MAAM,CAAC,KAAc;IAC5B,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC;QAAE,OAAO,KAAK,CAAC;IACtE,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QAClD,MAAM,QAAQ,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC;QAC/B,IAAI,MAAM,CAAC,QAAQ,CAAC,QAAQ,CAAC;YAAE,OAAO,QAAQ,CAAC;QAC/C,MAAM,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;QACjC,OAAO,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,MAA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AS,CAAC,QAAQ,CAAC,IAAI,MAAM;KACnC,CAAC;AACJ,CAAC"}
|
package/build/types.d.ts
ADDED
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
/** `auto` lets the native SDK decide */
|
|
2
|
+
export type KerdlyEnvironment = 'auto' | 'production' | 'sandbox' | 'development';
|
|
3
|
+
export type KerdlyLogLevel = 'none' | 'error' | 'warn' | 'info' | 'debug';
|
|
4
|
+
/** App Tracking Transparency status. Android always reports `not_applicable`. */
|
|
5
|
+
export type KerdlyAttStatus = 'authorized' | 'denied' | 'restricted' | 'not_determined' | 'not_applicable';
|
|
6
|
+
/** Where a deep link came from: the URL that launched the app, or one received while running. */
|
|
7
|
+
export type KerdlyDeepLinkSource = 'initial' | 'runtime';
|
|
8
|
+
export interface KerdlyConfigureOptions {
|
|
9
|
+
/** The app's public key, `pk_live_…` or `pk_test_…`. */
|
|
10
|
+
key: string;
|
|
11
|
+
/** Base URL of the collector; `/v1/sdk/batch` etc. are appended by the native SDK. Default `https://app.kerdly.com/api`. */
|
|
12
|
+
endpoint?: string;
|
|
13
|
+
/** Default `auto`. */
|
|
14
|
+
environment?: KerdlyEnvironment;
|
|
15
|
+
/** Read IDFA (only when ATT is authorized) / GAID. Default `true`. */
|
|
16
|
+
collectAdvertisingId?: boolean;
|
|
17
|
+
/** iOS only: let the SDK write SKAdNetwork / AdAttributionKit conversion values. Default `false`. */
|
|
18
|
+
skanWriter?: boolean;
|
|
19
|
+
/**
|
|
20
|
+
* Android only: the Facebook app id, which enables the Meta Install Referrer read. When omitted,
|
|
21
|
+
* the `com.kerdly.sdk.META_APP_ID` manifest meta-data (written by the config plugin's `metaAppId`)
|
|
22
|
+
* is used.
|
|
23
|
+
*/
|
|
24
|
+
metaAppId?: string;
|
|
25
|
+
/** Native SDK log level, and the threshold for this package's development warnings. Default `warn`. */
|
|
26
|
+
logLevel?: KerdlyLogLevel;
|
|
27
|
+
/**
|
|
28
|
+
* Forward React Native `Linking` URLs to `handleUrl` automatically: the initial URL once
|
|
29
|
+
* (source `initial`) and every `url` event (source `runtime`). Default `true`.
|
|
30
|
+
*/
|
|
31
|
+
autoDeepLinks?: boolean;
|
|
32
|
+
}
|
|
33
|
+
/** What `handleUrl` parsed from a deep link's query string. */
|
|
34
|
+
export interface KerdlyDeepLink {
|
|
35
|
+
url: string;
|
|
36
|
+
cpp: string | null;
|
|
37
|
+
ppid: string | null;
|
|
38
|
+
/** The click id of the Kerdly link that opened the app (`kerdly_c`). */
|
|
39
|
+
clickId: string | null;
|
|
40
|
+
/** The web visit that link continues (`kerdly_v`). */
|
|
41
|
+
visitId: string | null;
|
|
42
|
+
campaignIds: string | null;
|
|
43
|
+
}
|
|
44
|
+
export interface KerdlyConsent {
|
|
45
|
+
analytics?: boolean;
|
|
46
|
+
ads?: boolean;
|
|
47
|
+
}
|
|
48
|
+
/** Custom event property value. */
|
|
49
|
+
export type KerdlyEventValue = string | number | boolean;
|
|
50
|
+
/** Custom event properties. `undefined` values are skipped. */
|
|
51
|
+
export type KerdlyEventProperties = Record<string, KerdlyEventValue | undefined>;
|
|
52
|
+
/** `Kerdly.trackRegistration` (standard event `registration`). Every field is optional. */
|
|
53
|
+
export interface KerdlyRegistrationEvent {
|
|
54
|
+
/** How the user signed up: `anonymous`, `apple`, `google`, `email`, … (cut to 64 characters). */
|
|
55
|
+
method?: string | null;
|
|
56
|
+
/** Extra custom props, under the custom-event rules. */
|
|
57
|
+
properties?: KerdlyEventProperties;
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* `Kerdly.trackStartTrial` and `Kerdly.trackSubscribe` (standard events `start_trial` and `subscribe`,
|
|
61
|
+
*Every field is optional.
|
|
62
|
+
*/
|
|
63
|
+
export interface KerdlyRevenueEvent {
|
|
64
|
+
/** The store product id (cut to 128 characters). */
|
|
65
|
+
productId?: string | null;
|
|
66
|
+
/** The price the user paid in `currency`: a finite number ≥ 0 (0 for a free trial). Dropped without a valid `currency`. */
|
|
67
|
+
value?: number | null;
|
|
68
|
+
/** ISO 4217 code, three letters; upper-cased. */
|
|
69
|
+
currency?: string | null;
|
|
70
|
+
/** The store transaction id (cut to 128 characters). */
|
|
71
|
+
transactionId?: string | null;
|
|
72
|
+
/** Extra custom props, under the custom-event rules. */
|
|
73
|
+
properties?: KerdlyEventProperties;
|
|
74
|
+
}
|
|
75
|
+
/** `Kerdly.trackPurchase` (standard event `purchase`). Every field is optional. */
|
|
76
|
+
export interface KerdlyPurchaseEvent extends KerdlyRevenueEvent {
|
|
77
|
+
/** An integer ≥ 1. */
|
|
78
|
+
quantity?: number | null;
|
|
79
|
+
}
|
|
80
|
+
/** iOS (StoreKit) purchase, as reported by the paywall SDK. */
|
|
81
|
+
export interface KerdlyIosPurchase {
|
|
82
|
+
originalTransactionId?: string | null;
|
|
83
|
+
transactionId?: string | null;
|
|
84
|
+
productId?: string | null;
|
|
85
|
+
/** The StoreKit `appAccountToken` (a UUID string). */
|
|
86
|
+
appAccountToken?: string | null;
|
|
87
|
+
}
|
|
88
|
+
/** Android (Play Billing) purchase. */
|
|
89
|
+
export interface KerdlyAndroidPurchase {
|
|
90
|
+
purchaseToken: string;
|
|
91
|
+
orderId?: string | null;
|
|
92
|
+
products?: string[];
|
|
93
|
+
/** Milliseconds since epoch. */
|
|
94
|
+
purchaseTime?: number | null;
|
|
95
|
+
obfuscatedAccountId?: string | null;
|
|
96
|
+
obfuscatedProfileId?: string | null;
|
|
97
|
+
}
|
|
98
|
+
/** Either platform's purchase shape; each native SDK reads the fields of its own platform. */
|
|
99
|
+
export type KerdlyPurchase = KerdlyIosPurchase | KerdlyAndroidPurchase;
|
|
100
|
+
/** A conversion event the app sent to an ad network itself (Meta SDK, TikTok SDK, …). */
|
|
101
|
+
export interface KerdlyNetworkSend {
|
|
102
|
+
network: string;
|
|
103
|
+
event: string;
|
|
104
|
+
eventId?: string | null;
|
|
105
|
+
value?: number | null;
|
|
106
|
+
currency?: string | null;
|
|
107
|
+
flag?: string | null;
|
|
108
|
+
}
|
|
109
|
+
/** The attribution object ofUnknown future values are passed through as strings. */
|
|
110
|
+
export interface KerdlyAttribution {
|
|
111
|
+
state: 'provisional' | 'final' | (string & {});
|
|
112
|
+
network: 'apple_ads' | 'meta' | 'tiktok' | 'google_ads' | 'reddit' | 'snap' | 'web' | 'organic' | 'unknown' | (string & {});
|
|
113
|
+
status: 'measured' | 'probabilistic' | 'view_through' | 'organic_measured' | 'organic_assumed' | (string & {});
|
|
114
|
+
method: 'asa_token' | 'play_referrer' | 'play_referrer_link' | 'meta_install_referrer' | 'cpp_deeplink' | 'visit_chain' | 'none' | (string & {});
|
|
115
|
+
campaignId: string | null;
|
|
116
|
+
campaign: string | null;
|
|
117
|
+
adsetId: string | null;
|
|
118
|
+
adset: string | null;
|
|
119
|
+
adId: string | null;
|
|
120
|
+
ad: string | null;
|
|
121
|
+
keywordId: string | null;
|
|
122
|
+
keyword: string | null;
|
|
123
|
+
linkId: string | null;
|
|
124
|
+
cppId: string | null;
|
|
125
|
+
/** Milliseconds since epoch. */
|
|
126
|
+
decidedAt: number | null;
|
|
127
|
+
/** The whole attribution JSON object as the collector sent it. */
|
|
128
|
+
raw: Record<string, unknown>;
|
|
129
|
+
}
|
|
130
|
+
export type KerdlyAttributionListener = (attribution: KerdlyAttribution) => void;
|
|
131
|
+
export interface KerdlySubscription {
|
|
132
|
+
remove(): void;
|
|
133
|
+
}
|
|
134
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAEA,wCAAwC;AACxC,MAAM,MAAM,iBAAiB,GAAG,MAAM,GAAG,YAAY,GAAG,SAAS,GAAG,aAAa,CAAC;AAElF,MAAM,MAAM,cAAc,GAAG,MAAM,GAAG,OAAO,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,CAAC;AAE1E,iFAAiF;AACjF,MAAM,MAAM,eAAe,GACvB,YAAY,GACZ,QAAQ,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MAAM,GAAG,IAAI,CAAC;IACrB,gCAAgC;IAChC,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;IACzB,kEAAkE;IAClE,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CAC9B;AAED,MAAM,MAAM,yBAAyB,GAAG,CAAC,WAAW,EAAE,iBAAiB,KAAK,IAAI,CAAC;AAEjF,MAAM,WAAW,kBAAkB;IACjC,MAAM,IAAI,IAAI,CAAC;CAChB"}
|
package/build/types.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,6FAA6F"}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import type { NativeNetworkSend, NativePurchase } from './native';
|
|
2
|
+
import type { KerdlyEventValue } from './types';
|
|
3
|
+
export declare const EVENT_NAME_PATTERN: RegExp;
|
|
4
|
+
export declare const PROP_KEY_PATTERN: RegExp;
|
|
5
|
+
export declare const MAX_PROPS = 25;
|
|
6
|
+
export declare const MAX_STRING_LENGTH = 256;
|
|
7
|
+
export declare const MAX_ID_LENGTH = 128;
|
|
8
|
+
export declare const MAX_METHOD_LENGTH = 64;
|
|
9
|
+
/** The native `Int` (32-bit on Android). */
|
|
10
|
+
export declare const MAX_QUANTITY = 2147483647;
|
|
11
|
+
export declare function isPlainObject(value: unknown): value is Record<string, unknown>;
|
|
12
|
+
export declare function isUuid(value: unknown): value is string;
|
|
13
|
+
/** Cuts to 256 UTF-16 units without leaving half of a surrogate pair at the end. */
|
|
14
|
+
export declare function truncate(value: string, max?: number): string;
|
|
15
|
+
export interface EventValidation {
|
|
16
|
+
/** `null` when the event must be dropped (invalid name or props argument). */
|
|
17
|
+
event: {
|
|
18
|
+
name: string;
|
|
19
|
+
properties: Record<string, KerdlyEventValue>;
|
|
20
|
+
} | null;
|
|
21
|
+
/** Human-readable reasons for everything that was dropped. */
|
|
22
|
+
problems: string[];
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Validates a custom event. An invalid name drops the event. Invalid props are
|
|
26
|
+
* dropped one by one; props beyond the 25th valid one are dropped; strings are truncated to 256
|
|
27
|
+
* characters. `undefined` values are skipped silently, like JSON does.
|
|
28
|
+
*/
|
|
29
|
+
export declare function validateEvent(name: unknown, properties: unknown): EventValidation;
|
|
30
|
+
export type StandardEventMethod = 'trackRegistration' | 'trackStartTrial' | 'trackSubscribe' | 'trackPurchase';
|
|
31
|
+
/** The typed fields after validation; `null` = omitted (fields an event does not have stay `null`). */
|
|
32
|
+
export type StandardFields = Record<'method' | 'productId' | 'currency' | 'transactionId', string | null> & Record<'value' | 'quantity', number | null>;
|
|
33
|
+
export interface StandardEventValidation {
|
|
34
|
+
/** `null` when the event must be dropped (the argument is not an object). */
|
|
35
|
+
event: {
|
|
36
|
+
fields: StandardFields;
|
|
37
|
+
properties: Record<string, KerdlyEventValue>;
|
|
38
|
+
} | null;
|
|
39
|
+
/** Human-readable reasons for everything that was dropped. */
|
|
40
|
+
problems: string[];
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Validates a standard event's typed fields. A malformed field is dropped, not the
|
|
44
|
+
* event: ids are non-empty strings (a safe integer is turned into one) cut to 128 characters,
|
|
45
|
+
* `method` a non-empty string cut to 64, `value` a finite number ≥ 0, `currency` three letters
|
|
46
|
+
* (upper-cased), `quantity` an integer ≥ 1. `value` is dropped without a valid `currency`.
|
|
47
|
+
* `properties` follows the custom-event rules; a key that is one of the event's typed props is
|
|
48
|
+
* dropped (the typed field sets it). The native SDK checks everything again.
|
|
49
|
+
*/
|
|
50
|
+
export declare function validateStandardEvent(method: StandardEventMethod, input: unknown): StandardEventValidation;
|
|
51
|
+
/**
|
|
52
|
+
* Keeps the fields of either purchase shape that have the right type, so a malformed field can't
|
|
53
|
+
* make the native argument conversion reject the whole purchase. Returns `null` for a missing
|
|
54
|
+
* purchase (on iOS that means "sweep current entitlements").
|
|
55
|
+
*/
|
|
56
|
+
export declare function sanitizePurchase(purchase: unknown): {
|
|
57
|
+
purchase: NativePurchase | null;
|
|
58
|
+
problems: string[];
|
|
59
|
+
};
|
|
60
|
+
/** `null` when `network` or `event` is missing; optional fields with the wrong type are dropped. */
|
|
61
|
+
export declare function sanitizeNetworkSend(send: unknown): {
|
|
62
|
+
send: NativeNetworkSend | null;
|
|
63
|
+
problems: string[];
|
|
64
|
+
};
|
|
65
|
+
/** Keeps the string -> string entries of a partner id map. */
|
|
66
|
+
export declare function sanitizePartnerIds(ids: unknown): {
|
|
67
|
+
ids: Record<string, string> | null;
|
|
68
|
+
problems: string[];
|
|
69
|
+
};
|
|
70
|
+
//# sourceMappingURL=validation.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"validation.d.ts","sourceRoot":"","sources":["../src/validation.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAClE,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAC;AAGhD,eAAO,MAAM,kBAAkB,QAA2B,CAAC;AAC3D,eAAO,MAAM,gBAAgB,QAA2B,CAAC;AACzD,eAAO,MAAM,SAAS,KAAK,CAAC;AAC5B,eAAO,MAAM,iBAAiB,MAAM,CAAC;AACrC,eAAO,MAAM,aAAa,MAAM,CAAC;AACjC,eAAO,MAAM,iBAAiB,KAAK,CAAC;AACpC,4CAA4C;AAC5C,eAAO,MAAM,YAAY,aAAgB,CAAC;AAK1C,wBAAgB,aAAa,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAI9E;AAED,wBAAgB,MAAM,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,MAAM,CAEtD;AAED,oFAAoF;AACpF,wBAAgB,QAAQ,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,SAAoB,GAAG,MAAM,CAMvE;AA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