@ethicly/react-native 0.0.0-stage → 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/CHANGELOG.md +75 -0
- package/LICENSE +21 -0
- package/README.md +313 -2
- package/core/package.json +6 -0
- package/interstitial/package.json +6 -0
- package/lib/commonjs/core/adapters.js +287 -0
- package/lib/commonjs/core/beacons.js +70 -0
- package/lib/commonjs/core/cache.js +206 -0
- package/lib/commonjs/core/click.js +19 -0
- package/lib/commonjs/core/client.js +489 -0
- package/lib/commonjs/core/config.js +113 -0
- package/lib/commonjs/core/http.js +115 -0
- package/lib/commonjs/core/index.js +20 -0
- package/lib/commonjs/core/outbox.js +192 -0
- package/lib/commonjs/core/tracker.js +374 -0
- package/lib/commonjs/core/types.js +4 -0
- package/lib/commonjs/index.js +22 -0
- package/lib/commonjs/interstitial.js +7 -0
- package/lib/commonjs/react/EthiclyInterstitial.js +286 -0
- package/lib/commonjs/react/useEthiclyInterstitial.js +54 -0
- package/lib/commonjs/version.js +5 -0
- package/lib/module/core/adapters.js +276 -0
- package/lib/module/core/beacons.js +64 -0
- package/lib/module/core/cache.js +202 -0
- package/lib/module/core/click.js +15 -0
- package/lib/module/core/client.js +485 -0
- package/lib/module/core/config.js +104 -0
- package/lib/module/core/http.js +105 -0
- package/lib/module/core/index.js +6 -0
- package/lib/module/core/outbox.js +186 -0
- package/lib/module/core/tracker.js +370 -0
- package/lib/module/core/types.js +3 -0
- package/lib/module/index.js +4 -0
- package/lib/module/interstitial.js +3 -0
- package/lib/module/react/EthiclyInterstitial.js +260 -0
- package/lib/module/react/useEthiclyInterstitial.js +51 -0
- package/lib/module/version.js +2 -0
- package/lib/typescript/core/adapters.d.ts +138 -0
- package/lib/typescript/core/beacons.d.ts +32 -0
- package/lib/typescript/core/cache.d.ts +53 -0
- package/lib/typescript/core/click.d.ts +8 -0
- package/lib/typescript/core/client.d.ts +58 -0
- package/lib/typescript/core/config.d.ts +24 -0
- package/lib/typescript/core/http.d.ts +34 -0
- package/lib/typescript/core/index.d.ts +8 -0
- package/lib/typescript/core/outbox.d.ts +56 -0
- package/lib/typescript/core/tracker.d.ts +95 -0
- package/lib/typescript/core/types.d.ts +170 -0
- package/lib/typescript/index.d.ts +3 -0
- package/lib/typescript/interstitial.d.ts +2 -0
- package/lib/typescript/react/EthiclyInterstitial.d.ts +39 -0
- package/lib/typescript/react/useEthiclyInterstitial.d.ts +20 -0
- package/lib/typescript/version.d.ts +2 -0
- package/package.json +101 -4
- package/src/core/adapters.ts +337 -0
- package/src/core/beacons.ts +81 -0
- package/src/core/cache.ts +216 -0
- package/src/core/click.ts +16 -0
- package/src/core/client.ts +547 -0
- package/src/core/config.ts +111 -0
- package/src/core/http.ts +115 -0
- package/src/core/index.ts +14 -0
- package/src/core/outbox.ts +193 -0
- package/src/core/tracker.ts +371 -0
- package/src/core/types.ts +180 -0
- package/src/index.ts +5 -0
- package/src/interstitial.ts +4 -0
- package/src/react/EthiclyInterstitial.tsx +386 -0
- package/src/react/useEthiclyInterstitial.ts +74 -0
- package/src/version.ts +2 -0
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export { createEthicly, SESSION_TIMEOUT_MS } from './client';
|
|
2
|
+
export type { Ethicly, EthiclyOptions } from './client';
|
|
3
|
+
export { createMemoryStorage, createMemoryFileCache, createExpoFileCache, uuidv4, } from './adapters';
|
|
4
|
+
export type { AppStateLike, ExpoFileSystemLike, ExpoFileSystemModernLike } from './adapters';
|
|
5
|
+
export { appendClickToken, CLICK_TIMEOUT_MS } from './click';
|
|
6
|
+
export { compareVersions, BUNDLED_BASE_URL } from './config';
|
|
7
|
+
export { SDK_VERSION } from '../version';
|
|
8
|
+
export type { AudioPolicy, EthiclyAd, EthiclyAdMedia, EthiclyConfig, FetchLike, FileCacheAdapter, InterstitialResult, KeyValueStorage, Logger, NoFillReason, Platform, Tracker, } from './types';
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { type BeaconContext } from './beacons';
|
|
2
|
+
import type { ImpressionId, KeyValueStorage, Logger } from './types';
|
|
3
|
+
export declare const MAX_OUTBOX_RECORDS = 20;
|
|
4
|
+
export interface OutboxEvent {
|
|
5
|
+
event: string;
|
|
6
|
+
ms: number | null;
|
|
7
|
+
}
|
|
8
|
+
/** One rendered ad's unsent beacons. */
|
|
9
|
+
export interface OutboxRecord {
|
|
10
|
+
/** client_impression_id. */
|
|
11
|
+
cid: string;
|
|
12
|
+
/** Epoch ms the ad was shown. Every beacon below is dropped one hour later. */
|
|
13
|
+
shownAt: number;
|
|
14
|
+
/** The /impression body while it has no answer. */
|
|
15
|
+
impression?: Record<string, unknown>;
|
|
16
|
+
/** Known once /impression answered. */
|
|
17
|
+
impressionId?: ImpressionId;
|
|
18
|
+
viewableToken?: string | null;
|
|
19
|
+
/** viewable_ms of a /viewable still to send. */
|
|
20
|
+
viewableMs?: number;
|
|
21
|
+
events: OutboxEvent[];
|
|
22
|
+
}
|
|
23
|
+
export declare function outboxFor(storage: KeyValueStorage, apiKey: string, log: Required<Logger>): Outbox;
|
|
24
|
+
export declare class Outbox {
|
|
25
|
+
private storage;
|
|
26
|
+
private key;
|
|
27
|
+
private log;
|
|
28
|
+
private records;
|
|
29
|
+
/** Records a tracker or a replay in this runtime is already sending. */
|
|
30
|
+
private owned;
|
|
31
|
+
private loaded;
|
|
32
|
+
private dirty;
|
|
33
|
+
private writing;
|
|
34
|
+
constructor(storage: KeyValueStorage, key: string, log: Required<Logger>);
|
|
35
|
+
/** Read what a previous run left. Never rejects. */
|
|
36
|
+
load(): Promise<void>;
|
|
37
|
+
/** Save or replace a record owned by this runtime. */
|
|
38
|
+
put(rec: OutboxRecord): void;
|
|
39
|
+
remove(cid: string): void;
|
|
40
|
+
/**
|
|
41
|
+
* Unexpired records nobody in this runtime is sending, now owned by the
|
|
42
|
+
* caller. Expired ones are dropped.
|
|
43
|
+
*/
|
|
44
|
+
claimOrphans(now: number): OutboxRecord[];
|
|
45
|
+
/** Coalesced write of the whole outbox, after the stored one was read. Never rejects. */
|
|
46
|
+
private save;
|
|
47
|
+
/** Resolves when nothing is waiting to be written. For tests. */
|
|
48
|
+
flushed(): Promise<void>;
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Send what a previous run left for one ad, with the live tracker's rules:
|
|
52
|
+
* /impression first (same client_impression_id), then /viewable, then the
|
|
53
|
+
* video events. Anything the server refuses, or that is past one hour, is
|
|
54
|
+
* dropped. Never throws.
|
|
55
|
+
*/
|
|
56
|
+
export declare function replayRecord(ctx: BeaconContext, outbox: Outbox, rec: OutboxRecord): Promise<void>;
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import { type BeaconContext } from './beacons';
|
|
2
|
+
import type { Outbox } from './outbox';
|
|
3
|
+
import type { EthiclyAd, ImpressionId, Tracker } from './types';
|
|
4
|
+
export interface ServeContext {
|
|
5
|
+
publisherSiteId: number | null;
|
|
6
|
+
countryCode: string | null;
|
|
7
|
+
impressionToken: string | null;
|
|
8
|
+
}
|
|
9
|
+
export interface TrackerDeps {
|
|
10
|
+
ctx: BeaconContext;
|
|
11
|
+
ad: EthiclyAd;
|
|
12
|
+
serve: ServeContext;
|
|
13
|
+
viewableAfterMs: number;
|
|
14
|
+
flushIntervalS: number;
|
|
15
|
+
platform: string;
|
|
16
|
+
sdkVersion: string;
|
|
17
|
+
appVersion: string;
|
|
18
|
+
openUrl?: (url: string) => unknown;
|
|
19
|
+
/** Called once when the ad is shown, for the frequency caps. */
|
|
20
|
+
onShown(): void;
|
|
21
|
+
/** Keeps unsent beacons in storage so they survive the app being killed. */
|
|
22
|
+
outbox?: Outbox;
|
|
23
|
+
}
|
|
24
|
+
/** Doc "Still-image interstitials": /viewable after 1000 ms on screen. */
|
|
25
|
+
export declare const STILL_VIEWABLE_MS = 1000;
|
|
26
|
+
/**
|
|
27
|
+
* A wall-clock gap between two progress() calls longer than this breaks
|
|
28
|
+
* "continuous" playback: a host player that stops ticking while the app is in
|
|
29
|
+
* the background must not count the time it was away.
|
|
30
|
+
*/
|
|
31
|
+
export declare const MAX_TICK_GAP_MS = 1500;
|
|
32
|
+
interface Impression {
|
|
33
|
+
id: ImpressionId;
|
|
34
|
+
viewableToken: string | null;
|
|
35
|
+
at: number;
|
|
36
|
+
}
|
|
37
|
+
export declare class InterstitialTracker implements Tracker {
|
|
38
|
+
private d;
|
|
39
|
+
/** Exposed for tests and debug logs. */
|
|
40
|
+
clientImpressionId: string | null;
|
|
41
|
+
impression: Impression | null;
|
|
42
|
+
/** True when the impression can never bill (doc lifecycle rule 5, or a refused beacon). */
|
|
43
|
+
unbillable: boolean;
|
|
44
|
+
private impressionDone;
|
|
45
|
+
private viewableSent;
|
|
46
|
+
private continuousMs;
|
|
47
|
+
/** viewable_ms as measured when the threshold was crossed. */
|
|
48
|
+
private viewableMs;
|
|
49
|
+
private last;
|
|
50
|
+
private sentOnce;
|
|
51
|
+
private queue;
|
|
52
|
+
private timer;
|
|
53
|
+
private isClosed;
|
|
54
|
+
private clickUrl;
|
|
55
|
+
private pending;
|
|
56
|
+
private flushChain;
|
|
57
|
+
private shownAt;
|
|
58
|
+
/** The /impression body until it has an answer. */
|
|
59
|
+
private impressionBody;
|
|
60
|
+
/** viewable_ms of a /viewable not yet answered. */
|
|
61
|
+
private viewablePending;
|
|
62
|
+
/** Video events queued or in flight. */
|
|
63
|
+
private unsent;
|
|
64
|
+
constructor(d: TrackerDeps);
|
|
65
|
+
private get isVideo();
|
|
66
|
+
private track;
|
|
67
|
+
/** Resolves when every beacon in flight has settled. For tests and shutdown. */
|
|
68
|
+
settle(): Promise<void>;
|
|
69
|
+
isExpired(): boolean;
|
|
70
|
+
shown(size?: {
|
|
71
|
+
width?: number;
|
|
72
|
+
height?: number;
|
|
73
|
+
}): Promise<void>;
|
|
74
|
+
/**
|
|
75
|
+
* Mirror what this ad still owes the server into the outbox, or drop it
|
|
76
|
+
* there once nothing is owed. Never throws.
|
|
77
|
+
*/
|
|
78
|
+
private persist;
|
|
79
|
+
private sendImpression;
|
|
80
|
+
progress(positionMs: number, opts: {
|
|
81
|
+
visible: boolean;
|
|
82
|
+
durationMs?: number;
|
|
83
|
+
}): void;
|
|
84
|
+
private sendViewable;
|
|
85
|
+
private enqueueOnce;
|
|
86
|
+
complete(): void;
|
|
87
|
+
skipped(positionMs: number): void;
|
|
88
|
+
error(): void;
|
|
89
|
+
/** Send every queued video event, one request each (there is no batch route). */
|
|
90
|
+
flush(): Promise<void>;
|
|
91
|
+
clicked(): Promise<string>;
|
|
92
|
+
private resolveClickUrl;
|
|
93
|
+
closed(): Promise<void>;
|
|
94
|
+
}
|
|
95
|
+
export {};
|
|
@@ -0,0 +1,170 @@
|
|
|
1
|
+
export type Platform = 'ios' | 'android';
|
|
2
|
+
export type AudioPolicy = 'none' | 'optional' | 'on';
|
|
3
|
+
/** The /config body (doc "GET /config"). Unknown fields are ignored. */
|
|
4
|
+
export interface EthiclyConfig {
|
|
5
|
+
enabled: boolean;
|
|
6
|
+
min_sdk: {
|
|
7
|
+
ios: string;
|
|
8
|
+
android: string;
|
|
9
|
+
};
|
|
10
|
+
formats: string[];
|
|
11
|
+
interstitial: {
|
|
12
|
+
skip_after_ms: number;
|
|
13
|
+
max_per_session: number;
|
|
14
|
+
min_gap_s: number;
|
|
15
|
+
audio: AudioPolicy;
|
|
16
|
+
};
|
|
17
|
+
prefetch: {
|
|
18
|
+
max_cached_creatives: number;
|
|
19
|
+
max_cache_mb: number;
|
|
20
|
+
};
|
|
21
|
+
beacon: {
|
|
22
|
+
viewable_after_ms: number;
|
|
23
|
+
flush_interval_s: number;
|
|
24
|
+
};
|
|
25
|
+
endpoints: {
|
|
26
|
+
serve: string;
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
/** AsyncStorage-shaped key-value store. */
|
|
30
|
+
export interface KeyValueStorage {
|
|
31
|
+
getItem(key: string): Promise<string | null>;
|
|
32
|
+
setItem(key: string, value: string): Promise<void>;
|
|
33
|
+
removeItem?(key: string): Promise<void>;
|
|
34
|
+
}
|
|
35
|
+
/** expo-file-system-shaped creative store. */
|
|
36
|
+
export interface FileCacheAdapter {
|
|
37
|
+
/**
|
|
38
|
+
* Download `url` into the cache under `fileName`; resolve the local uri.
|
|
39
|
+
* Should abort (reject, leaving no file) once more than `maxBytes` would be written.
|
|
40
|
+
*/
|
|
41
|
+
download(url: string, fileName: string, opts?: {
|
|
42
|
+
maxBytes?: number;
|
|
43
|
+
}): Promise<{
|
|
44
|
+
uri: string;
|
|
45
|
+
bytes?: number;
|
|
46
|
+
}>;
|
|
47
|
+
exists(uri: string): Promise<boolean>;
|
|
48
|
+
delete(uri: string): Promise<void>;
|
|
49
|
+
/** Size in bytes, 0 when unknown. */
|
|
50
|
+
size(uri: string): Promise<number>;
|
|
51
|
+
/** Every file in the SDK's cache directory. Lets the cache sweep files it no longer indexes. */
|
|
52
|
+
list?(): Promise<string[]>;
|
|
53
|
+
/** The uri `download(url, fileName)` writes to, so an unfinished download can be deleted. */
|
|
54
|
+
uriFor?(fileName: string): string;
|
|
55
|
+
}
|
|
56
|
+
export interface Logger {
|
|
57
|
+
debug?(message: string, ...rest: unknown[]): void;
|
|
58
|
+
info?(message: string, ...rest: unknown[]): void;
|
|
59
|
+
warn?(message: string, ...rest: unknown[]): void;
|
|
60
|
+
error?(message: string, ...rest: unknown[]): void;
|
|
61
|
+
}
|
|
62
|
+
/** The subset of a fetch Response the SDK reads. */
|
|
63
|
+
export interface ResponseLike {
|
|
64
|
+
status: number;
|
|
65
|
+
headers: {
|
|
66
|
+
get(name: string): string | null;
|
|
67
|
+
};
|
|
68
|
+
text(): Promise<string>;
|
|
69
|
+
}
|
|
70
|
+
export interface RequestInitLike {
|
|
71
|
+
method?: string;
|
|
72
|
+
headers?: Record<string, string>;
|
|
73
|
+
body?: string;
|
|
74
|
+
signal?: unknown;
|
|
75
|
+
}
|
|
76
|
+
export type FetchLike = (url: string, init?: RequestInitLike) => Promise<ResponseLike>;
|
|
77
|
+
/** 64-bit impression id. A string when the value is beyond 2^53. */
|
|
78
|
+
export type ImpressionId = number | string;
|
|
79
|
+
/** Server no-ad reasons (doc "No-ad responses") plus the SDK's own. */
|
|
80
|
+
export type NoFillReason = 'publisher_not_approved' | 'publisher_paused' | 'publisher_blackout' | 'app_disabled' | 'sdk_unsupported' | 'interstitial_disabled' | 'classic_disabled' | 'no_approved_ads' | 'ads_query_error' | 'no_matching_ad' | 'publisher_mix' | 'test_unavailable' | 'ads_disabled' | 'frequency_capped' | 'unknown_key' | 'invalid_key' | 'rate_limited' | 'network_error' | 'server_error' | 'invalid_response' | (string & {});
|
|
81
|
+
export interface EthiclyAdMedia {
|
|
82
|
+
kind: 'video' | 'image';
|
|
83
|
+
/** The file to show: local file when cached, else the remote URL. */
|
|
84
|
+
uri: string;
|
|
85
|
+
/** Same as `uri` for a video, null for a still. */
|
|
86
|
+
videoUri: string | null;
|
|
87
|
+
/** Local or remote poster, null when the ad has none. */
|
|
88
|
+
posterUri: string | null;
|
|
89
|
+
durationMs: number | null;
|
|
90
|
+
mime: string | null;
|
|
91
|
+
width: number;
|
|
92
|
+
height: number;
|
|
93
|
+
/** True when `uri` points at a local cached file. */
|
|
94
|
+
cached: boolean;
|
|
95
|
+
}
|
|
96
|
+
export interface EthiclyAd {
|
|
97
|
+
id: number;
|
|
98
|
+
/** Button text: ad.cta_label, or "Learn more" when the server sends none. */
|
|
99
|
+
ctaLabel: string;
|
|
100
|
+
destinationUrl: string;
|
|
101
|
+
/** When the skip control may appear. The ad's value wins over /config. */
|
|
102
|
+
skipAfterMs: number;
|
|
103
|
+
media: EthiclyAdMedia;
|
|
104
|
+
/** interstitial.audio from /config. */
|
|
105
|
+
audio: AudioPolicy;
|
|
106
|
+
title: string | null;
|
|
107
|
+
/** True for a test-mode serve: nothing is stored or billed. */
|
|
108
|
+
test: boolean;
|
|
109
|
+
/** Epoch ms when the serve response arrived. */
|
|
110
|
+
servedAt: number;
|
|
111
|
+
/** Epoch ms after which the ad must not be shown (served + token_ttl_s). */
|
|
112
|
+
expiresAt: number;
|
|
113
|
+
}
|
|
114
|
+
export interface Tracker {
|
|
115
|
+
/** Call the moment the ad is rendered. Sends /impression immediately. */
|
|
116
|
+
shown(size?: {
|
|
117
|
+
width?: number;
|
|
118
|
+
height?: number;
|
|
119
|
+
}): Promise<void>;
|
|
120
|
+
/** Call on every player time update. */
|
|
121
|
+
progress(positionMs: number, opts: {
|
|
122
|
+
visible: boolean;
|
|
123
|
+
durationMs?: number;
|
|
124
|
+
}): void;
|
|
125
|
+
complete(): void;
|
|
126
|
+
skipped(positionMs: number): void;
|
|
127
|
+
error(): void;
|
|
128
|
+
/** POST /click (500 ms budget), then open the destination. Resolves with the URL opened. */
|
|
129
|
+
clicked(): Promise<string>;
|
|
130
|
+
/** Call when the ad screen goes away. Sends queued video events. */
|
|
131
|
+
closed(): Promise<void>;
|
|
132
|
+
/** True once the ad is older than token_ttl_s: it must not be shown. */
|
|
133
|
+
isExpired(): boolean;
|
|
134
|
+
}
|
|
135
|
+
export type InterstitialResult = {
|
|
136
|
+
ad: EthiclyAd;
|
|
137
|
+
tracker: Tracker;
|
|
138
|
+
reason?: undefined;
|
|
139
|
+
} | {
|
|
140
|
+
ad: null;
|
|
141
|
+
tracker: null;
|
|
142
|
+
reason: NoFillReason;
|
|
143
|
+
};
|
|
144
|
+
/** Raw serve-response ad (only the fields the SDK reads). */
|
|
145
|
+
export interface WireAd {
|
|
146
|
+
id: number;
|
|
147
|
+
title?: string | null;
|
|
148
|
+
destination_url?: string | null;
|
|
149
|
+
skip_after_ms?: number | null;
|
|
150
|
+
cta_label?: string | null;
|
|
151
|
+
media?: {
|
|
152
|
+
kind?: string;
|
|
153
|
+
url?: string | null;
|
|
154
|
+
poster_url?: string | null;
|
|
155
|
+
duration_ms?: number | null;
|
|
156
|
+
width?: number | null;
|
|
157
|
+
height?: number | null;
|
|
158
|
+
mime?: string | null;
|
|
159
|
+
} | null;
|
|
160
|
+
}
|
|
161
|
+
export interface WireServe {
|
|
162
|
+
ad: WireAd | null;
|
|
163
|
+
reason?: string;
|
|
164
|
+
publisher_site_id?: number;
|
|
165
|
+
country_code?: string;
|
|
166
|
+
impression_token?: string;
|
|
167
|
+
token_ttl_s?: number;
|
|
168
|
+
test?: boolean;
|
|
169
|
+
request_id?: string;
|
|
170
|
+
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { type StyleProp, type TextStyle, type ViewStyle } from 'react-native';
|
|
3
|
+
import type { EthiclyAd, Tracker } from '../core/types';
|
|
4
|
+
/** Safe-area insets in points, as react-native-safe-area-context reports them. */
|
|
5
|
+
export interface EthiclyInsets {
|
|
6
|
+
top: number;
|
|
7
|
+
bottom: number;
|
|
8
|
+
left: number;
|
|
9
|
+
right: number;
|
|
10
|
+
}
|
|
11
|
+
export interface EthiclyInterstitialProps {
|
|
12
|
+
ad: EthiclyAd;
|
|
13
|
+
tracker: Tracker;
|
|
14
|
+
/** Called after the ad is skipped or closed. Hide the screen here. */
|
|
15
|
+
onClose(): void;
|
|
16
|
+
/** Shows a "Remove ads" link under the button that calls this. */
|
|
17
|
+
onRemoveAds?(): void;
|
|
18
|
+
removeAdsLabel?: string;
|
|
19
|
+
/** Replaces the "Remove ads" link with anything the app wants. */
|
|
20
|
+
renderBelowButton?(): React.ReactNode;
|
|
21
|
+
/** Default true: wraps the screen in a fullscreen Modal. */
|
|
22
|
+
modal?: boolean;
|
|
23
|
+
/**
|
|
24
|
+
* Overrides for the skip control, merged over the default: a solid black
|
|
25
|
+
* pill reading "Skip in N", then "Skip Ad" with a skip-to-end icon.
|
|
26
|
+
*/
|
|
27
|
+
skipStyle?: StyleProp<ViewStyle>;
|
|
28
|
+
/** Overrides for the skip label (default white, "Skip in N" then "Skip Ad"). */
|
|
29
|
+
skipTextStyle?: StyleProp<TextStyle>;
|
|
30
|
+
/**
|
|
31
|
+
* Safe-area insets, for example `useSafeAreaInsets()`. Optional: without
|
|
32
|
+
* them the screen reads react-native-safe-area-context itself when the app
|
|
33
|
+
* has it, else the status bar height on Android. The controls never sit
|
|
34
|
+
* higher or lower than in 0.1 (56 from the top, 44 from the bottom); insets
|
|
35
|
+
* only move them inward.
|
|
36
|
+
*/
|
|
37
|
+
insets?: EthiclyInsets;
|
|
38
|
+
}
|
|
39
|
+
export declare function EthiclyInterstitial(props: EthiclyInterstitialProps): React.ReactElement;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { Ethicly } from '../core/client';
|
|
2
|
+
import type { EthiclyAd, NoFillReason, Tracker } from '../core/types';
|
|
3
|
+
export interface UseEthiclyInterstitialOptions {
|
|
4
|
+
/** Preload on mount and after each dismiss. Default true. */
|
|
5
|
+
preload?: boolean;
|
|
6
|
+
}
|
|
7
|
+
export interface EthiclyInterstitialState {
|
|
8
|
+
/** The ad to render, set by a successful show(). */
|
|
9
|
+
ad: EthiclyAd | null;
|
|
10
|
+
tracker: Tracker | null;
|
|
11
|
+
/** Why the last show() found no ad (show your house ad). */
|
|
12
|
+
reason: NoFillReason | null;
|
|
13
|
+
loading: boolean;
|
|
14
|
+
/** Load the ad to show now. Resolves true when `ad` is set, false on no fill. */
|
|
15
|
+
show(): Promise<boolean>;
|
|
16
|
+
/** Close the current ad: flushes queued events and preloads the next one. */
|
|
17
|
+
dismiss(): void;
|
|
18
|
+
canShow(): boolean;
|
|
19
|
+
}
|
|
20
|
+
export declare function useEthiclyInterstitial(ethicly: Ethicly, options?: UseEthiclyInterstitialOptions): EthiclyInterstitialState;
|
package/package.json
CHANGED
|
@@ -1,6 +1,103 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ethicly/react-native",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"version": "0.2.0",
|
|
4
|
+
"description": "Ethicly fullscreen video ads for React Native and Expo. Headless core plus an optional ready-made screen.",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"homepage": "https://ethicly.ch",
|
|
7
|
+
"publishConfig": {
|
|
8
|
+
"access": "public",
|
|
9
|
+
"registry": "https://registry.npmjs.org/"
|
|
10
|
+
},
|
|
11
|
+
"main": "lib/commonjs/index.js",
|
|
12
|
+
"module": "lib/module/index.js",
|
|
13
|
+
"types": "lib/typescript/index.d.ts",
|
|
14
|
+
"react-native": "src/index.ts",
|
|
15
|
+
"source": "src/index.ts",
|
|
16
|
+
"exports": {
|
|
17
|
+
".": {
|
|
18
|
+
"types": "./lib/typescript/index.d.ts",
|
|
19
|
+
"react-native": "./src/index.ts",
|
|
20
|
+
"import": "./lib/module/index.js",
|
|
21
|
+
"require": "./lib/commonjs/index.js"
|
|
22
|
+
},
|
|
23
|
+
"./core": {
|
|
24
|
+
"types": "./lib/typescript/core/index.d.ts",
|
|
25
|
+
"react-native": "./src/core/index.ts",
|
|
26
|
+
"import": "./lib/module/core/index.js",
|
|
27
|
+
"require": "./lib/commonjs/core/index.js"
|
|
28
|
+
},
|
|
29
|
+
"./interstitial": {
|
|
30
|
+
"types": "./lib/typescript/interstitial.d.ts",
|
|
31
|
+
"react-native": "./src/interstitial.ts",
|
|
32
|
+
"import": "./lib/module/interstitial.js",
|
|
33
|
+
"require": "./lib/commonjs/interstitial.js"
|
|
34
|
+
},
|
|
35
|
+
"./package.json": "./package.json"
|
|
36
|
+
},
|
|
37
|
+
"files": [
|
|
38
|
+
"src",
|
|
39
|
+
"lib",
|
|
40
|
+
"core",
|
|
41
|
+
"interstitial",
|
|
42
|
+
"CHANGELOG.md",
|
|
43
|
+
"LICENSE",
|
|
44
|
+
"!src/**/__tests__"
|
|
45
|
+
],
|
|
46
|
+
"sideEffects": false,
|
|
47
|
+
"scripts": {
|
|
48
|
+
"typecheck": "tsc --noEmit -p tsconfig.json",
|
|
49
|
+
"test": "jest",
|
|
50
|
+
"test:live": "npm run build && node scripts/live-test.mjs",
|
|
51
|
+
"prepare": "npm run build",
|
|
52
|
+
"build": "node scripts/clean.mjs && tsc -p tsconfig.build.json --module commonjs --outDir lib/commonjs && tsc -p tsconfig.build.json --module es2020 --outDir lib/module && tsc -p tsconfig.build.json --emitDeclarationOnly --declaration --outDir lib/typescript"
|
|
53
|
+
},
|
|
54
|
+
"peerDependencies": {
|
|
55
|
+
"@react-native-async-storage/async-storage": ">=1.17.0",
|
|
56
|
+
"expo-file-system": ">=16.0.0",
|
|
57
|
+
"expo-video": ">=2.0.0",
|
|
58
|
+
"react": ">=18.2.0",
|
|
59
|
+
"react-native": ">=0.72.0",
|
|
60
|
+
"react-native-safe-area-context": ">=4.0.0"
|
|
61
|
+
},
|
|
62
|
+
"peerDependenciesMeta": {
|
|
63
|
+
"@react-native-async-storage/async-storage": {
|
|
64
|
+
"optional": true
|
|
65
|
+
},
|
|
66
|
+
"expo-file-system": {
|
|
67
|
+
"optional": true
|
|
68
|
+
},
|
|
69
|
+
"expo-video": {
|
|
70
|
+
"optional": true
|
|
71
|
+
},
|
|
72
|
+
"react-native-safe-area-context": {
|
|
73
|
+
"optional": true
|
|
74
|
+
}
|
|
75
|
+
},
|
|
76
|
+
"engines": {
|
|
77
|
+
"node": ">=18"
|
|
78
|
+
},
|
|
79
|
+
"devDependencies": {
|
|
80
|
+
"@types/jest": "^29.5.14",
|
|
81
|
+
"@types/node": "^20.17.6",
|
|
82
|
+
"@types/react": "^18.3.12",
|
|
83
|
+
"@types/react-dom": "^18.3.1",
|
|
84
|
+
"expo-modules-core": "^2.2.3",
|
|
85
|
+
"expo-video": "^2.0.6",
|
|
86
|
+
"jest": "^29.7.0",
|
|
87
|
+
"jest-environment-jsdom": "^29.7.0",
|
|
88
|
+
"react": "^18.3.1",
|
|
89
|
+
"react-dom": "^18.3.1",
|
|
90
|
+
"react-native": "^0.76.9",
|
|
91
|
+
"ts-jest": "^29.2.5",
|
|
92
|
+
"typescript": "^5.6.3"
|
|
93
|
+
},
|
|
94
|
+
"keywords": [
|
|
95
|
+
"react-native",
|
|
96
|
+
"expo",
|
|
97
|
+
"ads",
|
|
98
|
+
"interstitial",
|
|
99
|
+
"video",
|
|
100
|
+
"privacy",
|
|
101
|
+
"ethicly"
|
|
102
|
+
]
|
|
103
|
+
}
|