@layers/react-native 1.4.11 → 2.0.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.
@@ -0,0 +1,19 @@
1
+ import "./att-BDPyE-Gs.mjs";
2
+ import "./skan-CAN-v1eU.mjs";
3
+ import { p as LayersReactNative } from "./index-CgWfOUd2.mjs";
4
+ import * as react_jsx_runtime0 from "react/jsx-runtime";
5
+
6
+ //#region src/debug-overlay.d.ts
7
+ interface LayersDebugOverlayProps {
8
+ /** Show or hide the overlay. */
9
+ visible: boolean;
10
+ /** The LayersReactNative SDK instance to read state from. */
11
+ layers: LayersReactNative;
12
+ }
13
+ declare function LayersDebugOverlay({
14
+ visible,
15
+ layers
16
+ }: LayersDebugOverlayProps): react_jsx_runtime0.JSX.Element | null;
17
+ //#endregion
18
+ export { LayersDebugOverlay, LayersDebugOverlayProps };
19
+ //# sourceMappingURL=debug-overlay.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"debug-overlay.d.mts","names":[],"sources":["../src/debug-overlay.tsx"],"sourcesContent":[],"mappings":";;;;;;UA4CiB,uBAAA;;;;UAIP;AAJV;AAuIgB,iBAAA,kBAAA,CAAkB;EAAA,OAAA;EAAA;AAAA,CAAA,EAAsB,uBAAtB,CAAA,EAA6C,kBAAA,CAAA,GAAA,CAAA,OAAA,GAA7C,IAAA"}
@@ -0,0 +1,19 @@
1
+ import "./att-BFy6dcWE.js";
2
+ import "./skan-DupmPyTn.js";
3
+ import { p as LayersReactNative } from "./index-DD43_S2s.js";
4
+ import * as react_jsx_runtime0 from "react/jsx-runtime";
5
+
6
+ //#region src/debug-overlay.d.ts
7
+ interface LayersDebugOverlayProps {
8
+ /** Show or hide the overlay. */
9
+ visible: boolean;
10
+ /** The LayersReactNative SDK instance to read state from. */
11
+ layers: LayersReactNative;
12
+ }
13
+ declare function LayersDebugOverlay({
14
+ visible,
15
+ layers
16
+ }: LayersDebugOverlayProps): react_jsx_runtime0.JSX.Element | null;
17
+ //#endregion
18
+ export { LayersDebugOverlay, LayersDebugOverlayProps };
19
+ //# sourceMappingURL=debug-overlay.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"debug-overlay.d.ts","names":[],"sources":["../src/debug-overlay.tsx"],"sourcesContent":[],"mappings":";;;;;;UA4CiB,uBAAA;;;;UAIP;AAJV;AAuIgB,iBAAA,kBAAA,CAAkB;EAAA,OAAA;EAAA;AAAA,CAAA,EAAsB,uBAAtB,CAAA,EAA6C,kBAAA,CAAA,GAAA,CAAA,OAAA,GAA7C,IAAA"}
@@ -0,0 +1,356 @@
1
+ const require_chunk = require('./chunk-nOFOJqeH.js');
2
+ let react_native = require("react-native");
3
+ react_native = require_chunk.__toESM(react_native);
4
+ let react = require("react");
5
+ react = require_chunk.__toESM(react);
6
+ let react_jsx_runtime = require("react/jsx-runtime");
7
+ react_jsx_runtime = require_chunk.__toESM(react_jsx_runtime);
8
+
9
+ //#region src/debug-overlay.tsx
10
+ const REFRESH_INTERVAL_MS = 1500;
11
+ const COLLAPSE_CHAR = "▼";
12
+ const EXPAND_CHAR = "▶";
13
+ const MAX_VISIBLE_EVENTS = 10;
14
+ function collectState(layers) {
15
+ let sdkVersion = "--";
16
+ let status = "Not initialized";
17
+ let environment = "--";
18
+ let appId = "--";
19
+ let userId = "(anonymous)";
20
+ let sessionId = "--";
21
+ let queueDepth = "--";
22
+ let installId = "--";
23
+ let consent = "--";
24
+ let network = "unknown";
25
+ let platform = "--";
26
+ let osVersion = "--";
27
+ let recentEvents = [];
28
+ try {
29
+ sdkVersion = layers.getSdkVersion();
30
+ } catch {}
31
+ try {
32
+ status = layers.isInitialized ? "Initialized" : "Not initialized";
33
+ } catch {}
34
+ try {
35
+ environment = layers.environment;
36
+ } catch {}
37
+ try {
38
+ appId = layers.appId;
39
+ } catch {}
40
+ try {
41
+ userId = layers.getAppUserId() ?? "(anonymous)";
42
+ } catch {}
43
+ try {
44
+ const sid = layers.getSessionId();
45
+ sessionId = sid.length > 8 ? `${sid.slice(0, 8)}...` : sid;
46
+ } catch {}
47
+ try {
48
+ queueDepth = String(layers.getQueueDepth());
49
+ } catch {}
50
+ try {
51
+ const ctx = layers.getDeviceContext();
52
+ if (ctx.installId) installId = ctx.installId.length > 8 ? `${ctx.installId.slice(0, 8)}...` : ctx.installId;
53
+ if (ctx.platform) platform = ctx.platform;
54
+ if (ctx.osVersion) osVersion = ctx.osVersion;
55
+ } catch {}
56
+ try {
57
+ const cs = layers.getConsentState();
58
+ const parts = [];
59
+ if (cs.analytics != null) parts.push(`analytics:${String(cs.analytics)}`);
60
+ if (cs.advertising != null) parts.push(`ads:${String(cs.advertising)}`);
61
+ consent = parts.length > 0 ? parts.join(", ") : "not set";
62
+ } catch {}
63
+ try {
64
+ network = layers.getNetworkStatus() ? "online" : "offline";
65
+ } catch {}
66
+ try {
67
+ recentEvents = layers.getRecentEvents();
68
+ } catch {}
69
+ return {
70
+ sdkVersion,
71
+ status,
72
+ environment,
73
+ appId,
74
+ userId,
75
+ sessionId,
76
+ queueDepth,
77
+ installId,
78
+ consent,
79
+ network,
80
+ platform,
81
+ osVersion,
82
+ recentEvents
83
+ };
84
+ }
85
+ function DataRow({ label, value, valueColor }) {
86
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_native.View, {
87
+ style: styles.row,
88
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(react_native.Text, {
89
+ style: styles.rowLabel,
90
+ children: label
91
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(react_native.Text, {
92
+ style: [styles.rowValue, valueColor ? { color: valueColor } : void 0],
93
+ numberOfLines: 1,
94
+ children: value
95
+ })]
96
+ });
97
+ }
98
+ function LayersDebugOverlay({ visible, layers }) {
99
+ const [collapsed, setCollapsed] = (0, react.useState)(false);
100
+ const [state, setState] = (0, react.useState)(() => collectState(layers));
101
+ const [flushing, setFlushing] = (0, react.useState)(false);
102
+ const pan = (0, react.useRef)(new react_native.Animated.ValueXY({
103
+ x: 16,
104
+ y: 80
105
+ })).current;
106
+ const isDragging = (0, react.useRef)(false);
107
+ const panResponder = (0, react.useRef)(react_native.PanResponder.create({
108
+ onStartShouldSetPanResponder: () => true,
109
+ onMoveShouldSetPanResponder: (_e, gs) => Math.abs(gs.dx) > 5 || Math.abs(gs.dy) > 5,
110
+ onPanResponderGrant: () => {
111
+ isDragging.current = false;
112
+ pan.setOffset({
113
+ x: pan.x._value,
114
+ y: pan.y._value
115
+ });
116
+ pan.setValue({
117
+ x: 0,
118
+ y: 0
119
+ });
120
+ },
121
+ onPanResponderMove: (e, gs) => {
122
+ if (Math.abs(gs.dx) > 5 || Math.abs(gs.dy) > 5) isDragging.current = true;
123
+ react_native.Animated.event([null, {
124
+ dx: pan.x,
125
+ dy: pan.y
126
+ }], { useNativeDriver: false })(e, gs);
127
+ },
128
+ onPanResponderRelease: () => {
129
+ pan.flattenOffset();
130
+ if (!isDragging.current) setCollapsed((c) => !c);
131
+ }
132
+ })).current;
133
+ (0, react.useEffect)(() => {
134
+ if (!visible) return;
135
+ const tick = () => {
136
+ setState(collectState(layers));
137
+ };
138
+ tick();
139
+ const id = setInterval(tick, REFRESH_INTERVAL_MS);
140
+ return () => clearInterval(id);
141
+ }, [visible, layers]);
142
+ if (!visible) return null;
143
+ const handleFlush = () => {
144
+ setFlushing(true);
145
+ layers.flush().finally(() => {
146
+ setFlushing(false);
147
+ setState(collectState(layers));
148
+ });
149
+ };
150
+ const statusColor = state.status === "Initialized" ? "#00ff88" : "#ff453a";
151
+ const networkColor = state.network === "online" ? "#00ff88" : "#ff453a";
152
+ const visibleEvents = state.recentEvents.slice(0, MAX_VISIBLE_EVENTS);
153
+ const AnimatedView = react_native.Animated.View;
154
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(AnimatedView, {
155
+ style: [styles.container, { transform: pan.getTranslateTransform() }],
156
+ ...panResponder.panHandlers,
157
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_native.View, {
158
+ style: styles.header,
159
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(react_native.Text, {
160
+ style: styles.headerTitle,
161
+ children: "Layers SDK Debug"
162
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(react_native.Text, {
163
+ style: styles.headerToggle,
164
+ children: collapsed ? EXPAND_CHAR : COLLAPSE_CHAR
165
+ })]
166
+ }), !collapsed && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_native.View, {
167
+ style: styles.content,
168
+ children: [
169
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)(DataRow, {
170
+ label: "SDK Version",
171
+ value: state.sdkVersion
172
+ }),
173
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)(DataRow, {
174
+ label: "Status",
175
+ value: state.status,
176
+ valueColor: statusColor
177
+ }),
178
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)(DataRow, {
179
+ label: "Environment",
180
+ value: state.environment
181
+ }),
182
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)(DataRow, {
183
+ label: "App ID",
184
+ value: state.appId
185
+ }),
186
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)(DataRow, {
187
+ label: "User ID",
188
+ value: state.userId
189
+ }),
190
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)(DataRow, {
191
+ label: "Session ID",
192
+ value: state.sessionId
193
+ }),
194
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)(DataRow, {
195
+ label: "Queue Depth",
196
+ value: state.queueDepth
197
+ }),
198
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)(DataRow, {
199
+ label: "Install ID",
200
+ value: state.installId
201
+ }),
202
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)(DataRow, {
203
+ label: "Consent",
204
+ value: state.consent
205
+ }),
206
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)(DataRow, {
207
+ label: "Network",
208
+ value: state.network,
209
+ valueColor: networkColor
210
+ }),
211
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)(DataRow, {
212
+ label: "Platform",
213
+ value: state.platform
214
+ }),
215
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)(DataRow, {
216
+ label: "OS Version",
217
+ value: state.osVersion
218
+ }),
219
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)(react_native.View, { style: styles.divider }),
220
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)(react_native.Text, {
221
+ style: styles.sectionHeader,
222
+ children: "Recent Events"
223
+ }),
224
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)(react_native.ScrollView, {
225
+ style: styles.eventsScroll,
226
+ nestedScrollEnabled: true,
227
+ children: visibleEvents.length === 0 ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(react_native.Text, {
228
+ style: styles.emptyEvents,
229
+ children: "(no events tracked)"
230
+ }) : visibleEvents.map((entry, i) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(react_native.Text, {
231
+ style: styles.eventRow,
232
+ numberOfLines: 1,
233
+ children: entry
234
+ }, `${entry}-${String(i)}`))
235
+ }),
236
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)(react_native.View, { style: styles.divider }),
237
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)(react_native.TouchableOpacity, {
238
+ style: [styles.flushButton, flushing ? styles.flushButtonDisabled : void 0],
239
+ onPress: handleFlush,
240
+ disabled: flushing,
241
+ activeOpacity: .7,
242
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(react_native.Text, {
243
+ style: styles.flushButtonText,
244
+ children: flushing ? "Flushing..." : "Flush Now"
245
+ })
246
+ })
247
+ ]
248
+ })]
249
+ });
250
+ }
251
+ const MONO_FONT = react_native.Platform.select({
252
+ ios: "Menlo",
253
+ android: "monospace",
254
+ default: "monospace"
255
+ });
256
+ const styles = react_native.StyleSheet.create({
257
+ container: {
258
+ position: "absolute",
259
+ top: 0,
260
+ left: 0,
261
+ zIndex: 99999,
262
+ backgroundColor: "rgba(28, 28, 30, 0.92)",
263
+ borderRadius: 8,
264
+ paddingHorizontal: 12,
265
+ paddingTop: 8,
266
+ paddingBottom: 12,
267
+ maxWidth: 340,
268
+ minWidth: 280,
269
+ shadowColor: "#000",
270
+ shadowOffset: {
271
+ width: 0,
272
+ height: 2
273
+ },
274
+ shadowOpacity: .4,
275
+ shadowRadius: 6,
276
+ elevation: 10
277
+ },
278
+ header: {
279
+ flexDirection: "row",
280
+ alignItems: "center",
281
+ paddingVertical: 2
282
+ },
283
+ headerTitle: {
284
+ flex: 1,
285
+ color: "#ffffff",
286
+ fontSize: 13,
287
+ fontFamily: MONO_FONT,
288
+ fontWeight: "bold"
289
+ },
290
+ headerToggle: {
291
+ color: "rgba(255, 255, 255, 0.7)",
292
+ fontSize: 13,
293
+ fontFamily: MONO_FONT
294
+ },
295
+ content: { paddingTop: 6 },
296
+ row: {
297
+ flexDirection: "row",
298
+ marginBottom: 2
299
+ },
300
+ rowLabel: {
301
+ color: "rgba(255, 255, 255, 0.63)",
302
+ fontSize: 10,
303
+ fontFamily: MONO_FONT,
304
+ width: 100
305
+ },
306
+ rowValue: {
307
+ flex: 1,
308
+ color: "#00ff88",
309
+ fontSize: 10,
310
+ fontFamily: MONO_FONT
311
+ },
312
+ divider: {
313
+ height: react_native.StyleSheet.hairlineWidth,
314
+ backgroundColor: "rgba(255, 255, 255, 0.24)",
315
+ marginTop: 6,
316
+ marginBottom: 4
317
+ },
318
+ sectionHeader: {
319
+ color: "rgba(255, 255, 255, 0.7)",
320
+ fontSize: 11,
321
+ fontFamily: MONO_FONT,
322
+ fontWeight: "bold",
323
+ paddingTop: 4,
324
+ paddingBottom: 2
325
+ },
326
+ eventsScroll: { maxHeight: 120 },
327
+ emptyEvents: {
328
+ color: "rgba(255, 255, 255, 0.47)",
329
+ fontSize: 9,
330
+ fontFamily: MONO_FONT
331
+ },
332
+ eventRow: {
333
+ color: "rgba(255, 255, 255, 0.78)",
334
+ fontSize: 9,
335
+ fontFamily: MONO_FONT,
336
+ paddingVertical: 1
337
+ },
338
+ flushButton: {
339
+ backgroundColor: "#007aff",
340
+ borderRadius: 4,
341
+ paddingVertical: 6,
342
+ paddingHorizontal: 12,
343
+ marginTop: 4,
344
+ alignItems: "center"
345
+ },
346
+ flushButtonDisabled: { opacity: .5 },
347
+ flushButtonText: {
348
+ color: "#ffffff",
349
+ fontSize: 12,
350
+ fontFamily: MONO_FONT,
351
+ fontWeight: "bold"
352
+ }
353
+ });
354
+
355
+ //#endregion
356
+ exports.LayersDebugOverlay = LayersDebugOverlay;