@rnzeus/heimdall-sdk 0.2.3 → 0.2.4
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/core/connection/channel/generate.d.ts +0 -4
- package/dist/core/connection/channel/generate.js +3 -7
- package/dist/core/connection/socket/disconnect-socket.js +3 -23
- package/dist/core/connection/socket/handle-socket-lost.js +1 -0
- package/dist/core/network/headers.d.ts +0 -3
- package/dist/core/network/headers.js +2 -2
- package/dist/core/network/should-skip.js +2 -15
- package/dist/core/network/xhr-callbacks.d.ts +1 -1
- package/dist/core/network/xhr-callbacks.js +3 -2
- package/dist/core/network/xhr-error.d.ts +7 -0
- package/dist/core/network/xhr-error.js +12 -0
- package/dist/core/network/xhr-types.d.ts +3 -0
- package/dist/core/system/dev-server.d.ts +0 -5
- package/dist/core/system/dev-server.js +1 -1
- package/dist/core/websocket/patch-websocket.js +24 -60
- package/dist/core/websocket/should-skip.js +2 -16
- package/dist/public/prompt/ui/header.d.ts +1 -1
- package/dist/utils/body-snippet.d.ts +0 -6
- package/dist/utils/body-snippet.js +1 -1
- package/dist/utils/debug-log.d.ts +1 -1
- package/dist/utils/generate-random-id.d.ts +1 -1
- package/dist/utils/generate-random-id.js +2 -2
- package/dist/utils/index.d.ts +1 -0
- package/dist/utils/index.js +1 -0
- package/dist/utils/safe-serialize.d.ts +0 -5
- package/dist/utils/safe-serialize.js +1 -1
- package/dist/utils/url-filters.d.ts +2 -0
- package/dist/utils/url-filters.js +17 -0
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +6 -2
|
@@ -1,15 +1,11 @@
|
|
|
1
1
|
import { CHANNEL_SCHEME } from "./types.js";
|
|
2
2
|
import { sanitizeChannelSlug } from "./sanitize.js";
|
|
3
|
+
import { generateRandomId } from "../../../utils/index.js";
|
|
3
4
|
/**
|
|
4
5
|
* Generate a random short ID (default length = 6).
|
|
5
6
|
*/
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
let out = "";
|
|
9
|
-
for (let i = 0; i < length; i++) {
|
|
10
|
-
out += chars[Math.floor(Math.random() * chars.length)];
|
|
11
|
-
}
|
|
12
|
-
return out;
|
|
7
|
+
function generateShortId(length = 6) {
|
|
8
|
+
return generateRandomId(length, "abcdefghijklmnopqrstuvwxyz0123456789");
|
|
13
9
|
}
|
|
14
10
|
/**
|
|
15
11
|
* Generate a full Channel identifier:
|
|
@@ -1,26 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import { clearLastConnection, setCurrentSession } from "../session/index.js";
|
|
1
|
+
import { clearLastConnection } from "../session/index.js";
|
|
2
|
+
import { handleSocketLost } from "./handle-socket-lost.js";
|
|
4
3
|
export function disconnectSocket() {
|
|
5
|
-
|
|
6
|
-
const socket = getSocket();
|
|
7
|
-
if (socket) {
|
|
8
|
-
try {
|
|
9
|
-
// first remove listeners, then gracefully close, then hard close
|
|
10
|
-
(_a = socket.removeAllListeners) === null || _a === void 0 ? void 0 : _a.call(socket);
|
|
11
|
-
(_b = socket.end) === null || _b === void 0 ? void 0 : _b.call(socket);
|
|
12
|
-
socket.destroy();
|
|
13
|
-
}
|
|
14
|
-
catch {
|
|
15
|
-
// ignore any socket-level errors
|
|
16
|
-
}
|
|
17
|
-
finally {
|
|
18
|
-
setSocket(null);
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
setConnected(false);
|
|
22
|
-
setCurrentSession(null);
|
|
4
|
+
handleSocketLost();
|
|
23
5
|
clearLastConnection();
|
|
24
|
-
clearEarlyEvents();
|
|
25
|
-
disableCaptureEarlyEvents();
|
|
26
6
|
}
|
|
@@ -6,6 +6,7 @@ export function handleSocketLost() {
|
|
|
6
6
|
const socket = getSocket();
|
|
7
7
|
if (socket) {
|
|
8
8
|
try {
|
|
9
|
+
// first remove listeners, then gracefully close, then hard close
|
|
9
10
|
(_a = socket.removeAllListeners) === null || _a === void 0 ? void 0 : _a.call(socket);
|
|
10
11
|
(_b = socket.end) === null || _b === void 0 ? void 0 : _b.call(socket);
|
|
11
12
|
socket.destroy();
|
|
@@ -1,6 +1,3 @@
|
|
|
1
1
|
import type { HeadersMap } from "./xhr-types";
|
|
2
2
|
export declare function normaliseHeaderName(name: any): string | null;
|
|
3
|
-
export declare function normaliseHeaders(input: any): HeadersMap;
|
|
4
|
-
/** Parses the raw "name: value\r\n" block returned by getAllResponseHeaders(). */
|
|
5
|
-
export declare function parseRawHeaders(raw: string): HeadersMap;
|
|
6
3
|
export declare function normaliseResponseHeaders(input: any): HeadersMap;
|
|
@@ -11,7 +11,7 @@ export function normaliseHeaderName(name) {
|
|
|
11
11
|
return null;
|
|
12
12
|
return n;
|
|
13
13
|
}
|
|
14
|
-
|
|
14
|
+
function normaliseHeaders(input) {
|
|
15
15
|
const out = {};
|
|
16
16
|
if (!input || typeof input !== "object")
|
|
17
17
|
return out;
|
|
@@ -27,7 +27,7 @@ export function normaliseHeaders(input) {
|
|
|
27
27
|
return out;
|
|
28
28
|
}
|
|
29
29
|
/** Parses the raw "name: value\r\n" block returned by getAllResponseHeaders(). */
|
|
30
|
-
|
|
30
|
+
function parseRawHeaders(raw) {
|
|
31
31
|
const out = {};
|
|
32
32
|
for (const line of raw.split(/\r?\n/)) {
|
|
33
33
|
const index = line.indexOf(":");
|
|
@@ -1,10 +1,6 @@
|
|
|
1
1
|
import { isCloudHost } from "../cloud/state.js";
|
|
2
2
|
import { isDevServerHost } from "../system/index.js";
|
|
3
|
-
|
|
4
|
-
if (!list || list.length === 0)
|
|
5
|
-
return false;
|
|
6
|
-
return list.some((rule) => typeof rule === "string" ? value === rule : rule.test(value));
|
|
7
|
-
}
|
|
3
|
+
import { isExcludedByFilters } from "../../utils/index.js";
|
|
8
4
|
export function shouldSkip(url, host, path, filters) {
|
|
9
5
|
if (isCloudHost(host))
|
|
10
6
|
return true;
|
|
@@ -17,14 +13,5 @@ export function shouldSkip(url, host, path, filters) {
|
|
|
17
13
|
return true;
|
|
18
14
|
}
|
|
19
15
|
}
|
|
20
|
-
|
|
21
|
-
matchList(path, filters.ignoreUrls)) {
|
|
22
|
-
return true;
|
|
23
|
-
}
|
|
24
|
-
if (filters.allowedHosts && filters.allowedHosts.length > 0) {
|
|
25
|
-
if (!matchList(host, filters.allowedHosts)) {
|
|
26
|
-
return true;
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
return false;
|
|
16
|
+
return isExcludedByFilters(url, host, path, filters);
|
|
30
17
|
}
|
|
@@ -8,5 +8,5 @@ export declare function createXhrCallbacks(deps: {
|
|
|
8
8
|
requestHeadersCallback: (header: string, value: string, xhr: XHR) => void;
|
|
9
9
|
headerReceivedCallback: (responseContentType: string, responseSize: number, responseHeaders: HeadersMap, xhr: XHR) => void;
|
|
10
10
|
sendCallback: (data: any, xhr: XHR) => void;
|
|
11
|
-
responseCallback: (status: number,
|
|
11
|
+
responseCallback: (status: number, _timeout: number, response: any, responseURL: string, responseType: string, xhr: XHR) => void;
|
|
12
12
|
};
|
|
@@ -5,6 +5,7 @@ import { normaliseHeaderName, normaliseResponseHeaders, } from "./headers.js";
|
|
|
5
5
|
import { buildBodySnippet, debugLog } from "../../utils/index.js";
|
|
6
6
|
import { nextXhrIndex } from "./xhr-runtime-state.js";
|
|
7
7
|
import { readRNBlobAsText } from "./rn-blob.js";
|
|
8
|
+
import { xhrError } from "./xhr-error.js";
|
|
8
9
|
export function createXhrCallbacks(deps) {
|
|
9
10
|
const { requests, getFilters } = deps;
|
|
10
11
|
const openCallback = (method, url, xhr) => {
|
|
@@ -64,7 +65,7 @@ export function createXhrCallbacks(deps) {
|
|
|
64
65
|
meta.__requestBlob = undefined;
|
|
65
66
|
}
|
|
66
67
|
};
|
|
67
|
-
const responseCallback = (status,
|
|
68
|
+
const responseCallback = (status, _timeout, response, responseURL, responseType, xhr) => {
|
|
68
69
|
const meta = requests.get(xhr._index);
|
|
69
70
|
if (!meta)
|
|
70
71
|
return;
|
|
@@ -105,7 +106,7 @@ export function createXhrCallbacks(deps) {
|
|
|
105
106
|
status: typeof status === "number" ? status : undefined,
|
|
106
107
|
ok,
|
|
107
108
|
durationMs: tsEnd - (meta.tsStart || tsEnd),
|
|
108
|
-
error:
|
|
109
|
+
error: xhrError(xhr, ok),
|
|
109
110
|
requestHeaders: meta.requestHeaders,
|
|
110
111
|
responseHeaders,
|
|
111
112
|
requestContentType: meta.requestHeaders["content-type"],
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { XHR } from "./xhr-types";
|
|
2
|
+
/**
|
|
3
|
+
* Status 0 alone cannot tell an abort from a network failure, so read the
|
|
4
|
+
* XHR flags. The interceptor's `timeout` argument is the configured timeout,
|
|
5
|
+
* not a sign that it fired.
|
|
6
|
+
*/
|
|
7
|
+
export declare function xhrError(xhr: XHR, ok: boolean): string | undefined;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Status 0 alone cannot tell an abort from a network failure, so read the
|
|
3
|
+
* XHR flags. The interceptor's `timeout` argument is the configured timeout,
|
|
4
|
+
* not a sign that it fired.
|
|
5
|
+
*/
|
|
6
|
+
export function xhrError(xhr, ok) {
|
|
7
|
+
if (xhr._aborted)
|
|
8
|
+
return "xhr_aborted";
|
|
9
|
+
if (xhr._timedOut)
|
|
10
|
+
return "xhr_timeout";
|
|
11
|
+
return ok ? undefined : "xhr_error";
|
|
12
|
+
}
|
|
@@ -3,6 +3,9 @@ export type HeadersMap = Record<string, string>;
|
|
|
3
3
|
export type XHR = {
|
|
4
4
|
_index: number;
|
|
5
5
|
responseHeaders?: HeadersMap;
|
|
6
|
+
/** React Native XMLHttpRequest internals; still set when the interceptor reports DONE. */
|
|
7
|
+
_aborted?: boolean;
|
|
8
|
+
_timedOut?: boolean;
|
|
6
9
|
};
|
|
7
10
|
export type Meta = {
|
|
8
11
|
tsStart: number;
|
|
@@ -1,6 +1 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* host:port of the Metro server the bundle was loaded from (e.g. "127.0.0.1:8081"),
|
|
3
|
-
* or null for an embedded release bundle. Traffic to it is RN tooling, never app traffic.
|
|
4
|
-
*/
|
|
5
|
-
export declare function getDevServerHost(): string | null;
|
|
6
1
|
export declare function isDevServerHost(host: string): boolean;
|
|
@@ -26,7 +26,7 @@ const readScriptUrl = () => {
|
|
|
26
26
|
* host:port of the Metro server the bundle was loaded from (e.g. "127.0.0.1:8081"),
|
|
27
27
|
* or null for an embedded release bundle. Traffic to it is RN tooling, never app traffic.
|
|
28
28
|
*/
|
|
29
|
-
|
|
29
|
+
function getDevServerHost() {
|
|
30
30
|
if (cachedHost === undefined)
|
|
31
31
|
cachedHost = hostOf(readScriptUrl());
|
|
32
32
|
return cachedHost;
|
|
@@ -70,8 +70,24 @@ function buildWsFrame(meta, direction, data) {
|
|
|
70
70
|
dataContentType: undefined,
|
|
71
71
|
};
|
|
72
72
|
}
|
|
73
|
-
function sendWsEvent(
|
|
74
|
-
sendEvent(
|
|
73
|
+
function sendWsEvent(meta, fields) {
|
|
74
|
+
sendEvent({
|
|
75
|
+
id: generateRandomId(),
|
|
76
|
+
type: "ws",
|
|
77
|
+
transport: "websocket",
|
|
78
|
+
connectionId: meta.connectionId,
|
|
79
|
+
ts: now(),
|
|
80
|
+
url: meta.url,
|
|
81
|
+
...fields,
|
|
82
|
+
});
|
|
83
|
+
}
|
|
84
|
+
function sendWsFrame(meta, direction, data) {
|
|
85
|
+
var _a, _b, _c;
|
|
86
|
+
const frame = buildWsFrame(meta, direction, data);
|
|
87
|
+
const raw = typeof data === "string" ? previewString(data) : typeof data;
|
|
88
|
+
debugLog("ws", `frame(${direction}) connectionId=${meta.connectionId} bytes=${String((_b = (_a = frame.dataSize) !== null && _a !== void 0 ? _a : frame.dataSnippetBytes) !== null && _b !== void 0 ? _b : "?")} truncated=${String(frame.dataTruncated)} ct=${String(frame.dataContentType)} data=${String(raw)}`);
|
|
89
|
+
debugLog("ws", `sendEvent: frame(${direction}) connectionId=${meta.connectionId} bytes=${String((_c = frame.dataSize) !== null && _c !== void 0 ? _c : frame.dataSnippetBytes)}`);
|
|
90
|
+
sendWsEvent(meta, { kind: "frame", ...frame });
|
|
75
91
|
}
|
|
76
92
|
export function patchWebSocket(options) {
|
|
77
93
|
var _a;
|
|
@@ -136,27 +152,13 @@ export function patchWebSocket(options) {
|
|
|
136
152
|
attach("open", () => {
|
|
137
153
|
debugLog("ws", `open connectionId=${meta.connectionId}`);
|
|
138
154
|
debugLog("ws", `sendEvent: open connectionId=${meta.connectionId} url=${meta.url}`);
|
|
139
|
-
sendWsEvent({
|
|
140
|
-
id: generateRandomId(),
|
|
141
|
-
type: "ws",
|
|
142
|
-
transport: "websocket",
|
|
143
|
-
connectionId: meta.connectionId,
|
|
144
|
-
ts: now(),
|
|
145
|
-
url: meta.url,
|
|
146
|
-
kind: "open",
|
|
147
|
-
});
|
|
155
|
+
sendWsEvent(meta, { kind: "open" });
|
|
148
156
|
});
|
|
149
157
|
// close
|
|
150
158
|
attach("close", (ev) => {
|
|
151
159
|
debugLog("ws", `close connectionId=${meta.connectionId} code=${String(ev === null || ev === void 0 ? void 0 : ev.code)} reason=${String(ev === null || ev === void 0 ? void 0 : ev.reason)}`);
|
|
152
160
|
debugLog("ws", `sendEvent: close connectionId=${meta.connectionId} code=${String(ev === null || ev === void 0 ? void 0 : ev.code)}`);
|
|
153
|
-
sendWsEvent({
|
|
154
|
-
id: generateRandomId(),
|
|
155
|
-
type: "ws",
|
|
156
|
-
transport: "websocket",
|
|
157
|
-
connectionId: meta.connectionId,
|
|
158
|
-
ts: now(),
|
|
159
|
-
url: meta.url,
|
|
161
|
+
sendWsEvent(meta, {
|
|
160
162
|
kind: "close",
|
|
161
163
|
code: typeof (ev === null || ev === void 0 ? void 0 : ev.code) === "number" ? ev.code : undefined,
|
|
162
164
|
reason: typeof (ev === null || ev === void 0 ? void 0 : ev.reason) === "string" ? ev.reason : undefined,
|
|
@@ -171,57 +173,19 @@ export function patchWebSocket(options) {
|
|
|
171
173
|
"websocket_error";
|
|
172
174
|
debugLog("ws", `error connectionId=${meta.connectionId} msg=${msg}`);
|
|
173
175
|
debugLog("ws", `sendEvent: error connectionId=${meta.connectionId} msg=${msg}`);
|
|
174
|
-
sendWsEvent({
|
|
175
|
-
id: generateRandomId(),
|
|
176
|
-
type: "ws",
|
|
177
|
-
transport: "websocket",
|
|
178
|
-
connectionId: meta.connectionId,
|
|
179
|
-
ts: now(),
|
|
180
|
-
url: meta.url,
|
|
181
|
-
kind: "error",
|
|
182
|
-
error: msg,
|
|
183
|
-
});
|
|
176
|
+
sendWsEvent(meta, { kind: "error", error: msg });
|
|
184
177
|
});
|
|
185
178
|
// incoming frame
|
|
186
179
|
attach("message", (ev) => {
|
|
187
|
-
|
|
188
|
-
const frame = buildWsFrame(meta, "in", ev === null || ev === void 0 ? void 0 : ev.data);
|
|
189
|
-
const raw = typeof (ev === null || ev === void 0 ? void 0 : ev.data) === "string" ? previewString(ev.data) : typeof (ev === null || ev === void 0 ? void 0 : ev.data);
|
|
190
|
-
debugLog("ws", `frame(in) connectionId=${meta.connectionId} bytes=${String((_b = (_a = frame.dataSize) !== null && _a !== void 0 ? _a : frame.dataSnippetBytes) !== null && _b !== void 0 ? _b : "?")} truncated=${String(frame.dataTruncated)} ct=${String(frame.dataContentType)} data=${String(raw)}`);
|
|
191
|
-
debugLog("ws", `sendEvent: frame(in) connectionId=${meta.connectionId} bytes=${String((_c = frame.dataSize) !== null && _c !== void 0 ? _c : frame.dataSnippetBytes)}`);
|
|
192
|
-
sendWsEvent({
|
|
193
|
-
id: generateRandomId(),
|
|
194
|
-
type: "ws",
|
|
195
|
-
transport: "websocket",
|
|
196
|
-
connectionId: meta.connectionId,
|
|
197
|
-
ts: now(),
|
|
198
|
-
url: meta.url,
|
|
199
|
-
kind: "frame",
|
|
200
|
-
...frame,
|
|
201
|
-
});
|
|
180
|
+
sendWsFrame(meta, "in", ev === null || ev === void 0 ? void 0 : ev.data);
|
|
202
181
|
});
|
|
203
182
|
// outgoing frame
|
|
204
183
|
const originalSend = ws.send;
|
|
205
184
|
if (typeof originalSend === "function") {
|
|
206
185
|
ws.send = function patchedSend(data) {
|
|
207
|
-
var _a, _b, _c;
|
|
208
186
|
const m = wsMeta.get(ws);
|
|
209
|
-
if (m)
|
|
210
|
-
|
|
211
|
-
const raw = typeof data === "string" ? previewString(data) : typeof data;
|
|
212
|
-
debugLog("ws", `frame(out) connectionId=${m.connectionId} bytes=${String((_b = (_a = frame.dataSize) !== null && _a !== void 0 ? _a : frame.dataSnippetBytes) !== null && _b !== void 0 ? _b : "?")} truncated=${String(frame.dataTruncated)} ct=${String(frame.dataContentType)} data=${String(raw)}`);
|
|
213
|
-
debugLog("ws", `sendEvent: frame(out) connectionId=${m.connectionId} bytes=${String((_c = frame.dataSize) !== null && _c !== void 0 ? _c : frame.dataSnippetBytes)}`);
|
|
214
|
-
sendWsEvent({
|
|
215
|
-
id: generateRandomId(),
|
|
216
|
-
type: "ws",
|
|
217
|
-
transport: "websocket",
|
|
218
|
-
connectionId: m.connectionId,
|
|
219
|
-
ts: now(),
|
|
220
|
-
url: m.url,
|
|
221
|
-
kind: "frame",
|
|
222
|
-
...frame,
|
|
223
|
-
});
|
|
224
|
-
}
|
|
187
|
+
if (m)
|
|
188
|
+
sendWsFrame(m, "out", data);
|
|
225
189
|
return originalSend.call(ws, data);
|
|
226
190
|
};
|
|
227
191
|
}
|
|
@@ -1,22 +1,8 @@
|
|
|
1
1
|
import { isDevServerHost } from "../system/index.js";
|
|
2
|
-
|
|
3
|
-
if (!list || list.length === 0)
|
|
4
|
-
return false;
|
|
5
|
-
return list.some((rule) => typeof rule === "string" ? value === rule : rule.test(value));
|
|
6
|
-
}
|
|
2
|
+
import { isExcludedByFilters } from "../../utils/index.js";
|
|
7
3
|
export function shouldSkipWs(url, host, path, filters) {
|
|
8
4
|
// Metro HMR / debugger sockets
|
|
9
5
|
if (isDevServerHost(host))
|
|
10
6
|
return true;
|
|
11
|
-
|
|
12
|
-
if (matchList(url, filters.ignoreUrls) || matchList(path, filters.ignoreUrls)) {
|
|
13
|
-
return true;
|
|
14
|
-
}
|
|
15
|
-
// allowedHosts
|
|
16
|
-
if (filters.allowedHosts && filters.allowedHosts.length > 0) {
|
|
17
|
-
if (!matchList(host, filters.allowedHosts)) {
|
|
18
|
-
return true;
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
return false;
|
|
7
|
+
return isExcludedByFilters(url, host, path, filters);
|
|
22
8
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { JSX } from "react";
|
|
2
2
|
import type { PromptTheme } from "../theme";
|
|
3
|
-
|
|
3
|
+
type HeaderStatus = "idle" | "busy" | "connected" | "error";
|
|
4
4
|
type Props = {
|
|
5
5
|
title: string;
|
|
6
6
|
status: HeaderStatus;
|
|
@@ -1,9 +1,3 @@
|
|
|
1
|
-
export declare const NETWORK: {
|
|
2
|
-
MAX_BODY_BYTES_DEFAULT: number;
|
|
3
|
-
MAX_BODY_BYTES_JSON: number;
|
|
4
|
-
MAX_BODY_BYTES_TEXT: number;
|
|
5
|
-
MAX_JSON_MINIFY_BYTES: number;
|
|
6
|
-
};
|
|
7
1
|
export declare function tryMinifyJsonString(s: string): string | null;
|
|
8
2
|
export type BodySnippetResult = {
|
|
9
3
|
snippet?: string;
|
|
@@ -4,7 +4,7 @@ const MAX_BODY_BYTES_JSON = 500 * 1024; // 500 KB
|
|
|
4
4
|
const MAX_BODY_BYTES_TEXT = 200 * 1024; // 200 KB
|
|
5
5
|
// Safety gate: avoid JSON.parse+stringify for very large strings.
|
|
6
6
|
const MAX_JSON_MINIFY_BYTES = 1000000; // 1 MB
|
|
7
|
-
|
|
7
|
+
const NETWORK = {
|
|
8
8
|
MAX_BODY_BYTES_DEFAULT,
|
|
9
9
|
MAX_BODY_BYTES_JSON,
|
|
10
10
|
MAX_BODY_BYTES_TEXT,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare function generateRandomId(length?: number): string;
|
|
1
|
+
export declare function generateRandomId(length?: number, chars?: string): string;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
const ALPHANUMERIC = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
|
|
2
|
+
export function generateRandomId(length = 16, chars = ALPHANUMERIC) {
|
|
3
3
|
let out = "";
|
|
4
4
|
for (let i = 0; i < length; i++) {
|
|
5
5
|
out += chars[Math.floor(Math.random() * chars.length)];
|
package/dist/utils/index.d.ts
CHANGED
package/dist/utils/index.js
CHANGED
|
@@ -1,6 +1 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Converts any value into a JSON-safe snapshot with depth, width and string limits.
|
|
3
|
-
* Never throws: getters that throw and host objects become placeholders.
|
|
4
|
-
*/
|
|
5
|
-
export declare function toSafeValue(value: unknown, depth?: number, seen?: WeakSet<object>): unknown;
|
|
6
1
|
export declare function safeStringify(value: unknown): string;
|
|
@@ -6,7 +6,7 @@ const clip = (value) => value.length > MAX_STRING ? `${value.slice(0, MAX_STRING
|
|
|
6
6
|
* Converts any value into a JSON-safe snapshot with depth, width and string limits.
|
|
7
7
|
* Never throws: getters that throw and host objects become placeholders.
|
|
8
8
|
*/
|
|
9
|
-
|
|
9
|
+
function toSafeValue(value, depth = 0, seen = new WeakSet()) {
|
|
10
10
|
if (value === null || value === undefined)
|
|
11
11
|
return value !== null && value !== void 0 ? value : null;
|
|
12
12
|
const kind = typeof value;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
function matchList(value, list) {
|
|
2
|
+
if (!list || list.length === 0)
|
|
3
|
+
return false;
|
|
4
|
+
return list.some((rule) => typeof rule === "string" ? value === rule : rule.test(value));
|
|
5
|
+
}
|
|
6
|
+
export function isExcludedByFilters(url, host, path, filters) {
|
|
7
|
+
if (matchList(url, filters.ignoreUrls) ||
|
|
8
|
+
matchList(path, filters.ignoreUrls)) {
|
|
9
|
+
return true;
|
|
10
|
+
}
|
|
11
|
+
if (filters.allowedHosts && filters.allowedHosts.length > 0) {
|
|
12
|
+
if (!matchList(host, filters.allowedHosts)) {
|
|
13
|
+
return true;
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
return false;
|
|
17
|
+
}
|
package/dist/version.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const SDK_VERSION = "0.2.
|
|
1
|
+
export declare const SDK_VERSION = "0.2.4";
|
package/dist/version.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const SDK_VERSION = "0.2.
|
|
1
|
+
export const SDK_VERSION = "0.2.4";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rnzeus/heimdall-sdk",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.4",
|
|
4
4
|
"description": "React Native client for Heimdall — a desktop debug inspector for network, WebSocket, Zustand and console",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "Volodymyr Dudkevych",
|
|
@@ -54,7 +54,9 @@
|
|
|
54
54
|
"clean": "rimraf dist",
|
|
55
55
|
"build": "node scripts/write-version.mjs && yarn clean && tsc -p tsconfig.build.json && node scripts/fix-esm-extensions.mjs dist",
|
|
56
56
|
"dev": "tsc -p tsconfig.build.json -w",
|
|
57
|
-
"typecheck": "node scripts/write-version.mjs && tsc -p tsconfig.json --noEmit"
|
|
57
|
+
"typecheck": "node scripts/write-version.mjs && tsc -p tsconfig.json --noEmit",
|
|
58
|
+
"knip": "knip",
|
|
59
|
+
"dupes": "jscpd"
|
|
58
60
|
},
|
|
59
61
|
"peerDependencies": {
|
|
60
62
|
"react": ">=18.0.0",
|
|
@@ -74,6 +76,8 @@
|
|
|
74
76
|
"devDependencies": {
|
|
75
77
|
"@types/node": "^25.0.3",
|
|
76
78
|
"@types/react": "^18.3.12",
|
|
79
|
+
"jscpd": "5.4.1",
|
|
80
|
+
"knip": "6.41.0",
|
|
77
81
|
"react": "^18.3.1",
|
|
78
82
|
"react-native": "^0.79.0",
|
|
79
83
|
"react-native-mmkv": "^3.3.0",
|