@rnzeus/heimdall-sdk 0.0.0-stage → 0.2.2
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 +210 -2
- package/dist/core/cloud/client.d.ts +44 -0
- package/dist/core/cloud/client.js +65 -0
- package/dist/core/cloud/index.d.ts +4 -0
- package/dist/core/cloud/index.js +4 -0
- package/dist/core/cloud/link-device.d.ts +14 -0
- package/dist/core/cloud/link-device.js +28 -0
- package/dist/core/cloud/state.d.ts +10 -0
- package/dist/core/cloud/state.js +21 -0
- package/dist/core/cloud/storage.d.ts +7 -0
- package/dist/core/cloud/storage.js +31 -0
- package/dist/core/connection/channel/generate.d.ts +10 -0
- package/dist/core/connection/channel/generate.js +22 -0
- package/dist/core/connection/channel/index.d.ts +4 -0
- package/dist/core/connection/channel/index.js +4 -0
- package/dist/core/connection/channel/parse.d.ts +9 -0
- package/dist/core/connection/channel/parse.js +27 -0
- package/dist/core/connection/channel/sanitize.d.ts +9 -0
- package/dist/core/connection/channel/sanitize.js +15 -0
- package/dist/core/connection/channel/types.d.ts +9 -0
- package/dist/core/connection/channel/types.js +1 -0
- package/dist/core/connection/index.d.ts +7 -0
- package/dist/core/connection/index.js +7 -0
- package/dist/core/connection/lifecycle/connect.d.ts +2 -0
- package/dist/core/connection/lifecycle/connect.js +46 -0
- package/dist/core/connection/lifecycle/destroy.d.ts +1 -0
- package/dist/core/connection/lifecycle/destroy.js +12 -0
- package/dist/core/connection/lifecycle/disconnect.d.ts +1 -0
- package/dist/core/connection/lifecycle/disconnect.js +10 -0
- package/dist/core/connection/lifecycle/early-events.d.ts +2 -0
- package/dist/core/connection/lifecycle/early-events.js +18 -0
- package/dist/core/connection/lifecycle/index.d.ts +5 -0
- package/dist/core/connection/lifecycle/index.js +5 -0
- package/dist/core/connection/lifecycle/keep-alive.d.ts +5 -0
- package/dist/core/connection/lifecycle/keep-alive.js +40 -0
- package/dist/core/connection/prompt/index.d.ts +1 -0
- package/dist/core/connection/prompt/index.js +1 -0
- package/dist/core/connection/prompt/prompt-state.d.ts +12 -0
- package/dist/core/connection/prompt/prompt-state.js +30 -0
- package/dist/core/connection/resolver/cloud.d.ts +4 -0
- package/dist/core/connection/resolver/cloud.js +29 -0
- package/dist/core/connection/resolver/index.d.ts +3 -0
- package/dist/core/connection/resolver/index.js +3 -0
- package/dist/core/connection/resolver/manual.d.ts +2 -0
- package/dist/core/connection/resolver/manual.js +3 -0
- package/dist/core/connection/resolver/types.d.ts +9 -0
- package/dist/core/connection/resolver/types.js +1 -0
- package/dist/core/connection/sdk-enabled.d.ts +3 -0
- package/dist/core/connection/sdk-enabled.js +10 -0
- package/dist/core/connection/session/clear-last-connection.d.ts +1 -0
- package/dist/core/connection/session/clear-last-connection.js +11 -0
- package/dist/core/connection/session/client-id.d.ts +3 -0
- package/dist/core/connection/session/client-id.js +25 -0
- package/dist/core/connection/session/constants.d.ts +14 -0
- package/dist/core/connection/session/constants.js +21 -0
- package/dist/core/connection/session/create-session.d.ts +3 -0
- package/dist/core/connection/session/create-session.js +21 -0
- package/dist/core/connection/session/index.d.ts +6 -0
- package/dist/core/connection/session/index.js +6 -0
- package/dist/core/connection/session/load-last-connection.d.ts +2 -0
- package/dist/core/connection/session/load-last-connection.js +16 -0
- package/dist/core/connection/session/state.d.ts +7 -0
- package/dist/core/connection/session/state.js +23 -0
- package/dist/core/connection/session/types.d.ts +12 -0
- package/dist/core/connection/session/types.js +1 -0
- package/dist/core/connection/socket/connect-socket.d.ts +3 -0
- package/dist/core/connection/socket/connect-socket.js +110 -0
- package/dist/core/connection/socket/constants.d.ts +4 -0
- package/dist/core/connection/socket/constants.js +4 -0
- package/dist/core/connection/socket/destroy-socket.d.ts +1 -0
- package/dist/core/connection/socket/destroy-socket.js +4 -0
- package/dist/core/connection/socket/disconnect-socket.d.ts +1 -0
- package/dist/core/connection/socket/disconnect-socket.js +26 -0
- package/dist/core/connection/socket/early-buffer.d.ts +7 -0
- package/dist/core/connection/socket/early-buffer.js +26 -0
- package/dist/core/connection/socket/flush-early-events.d.ts +1 -0
- package/dist/core/connection/socket/flush-early-events.js +18 -0
- package/dist/core/connection/socket/handle-socket-lost.d.ts +1 -0
- package/dist/core/connection/socket/handle-socket-lost.js +24 -0
- package/dist/core/connection/socket/index.d.ts +6 -0
- package/dist/core/connection/socket/index.js +6 -0
- package/dist/core/connection/socket/normalize-socket-error.d.ts +1 -0
- package/dist/core/connection/socket/normalize-socket-error.js +13 -0
- package/dist/core/connection/socket/send-event.d.ts +3 -0
- package/dist/core/connection/socket/send-event.js +45 -0
- package/dist/core/connection/socket/state.d.ts +8 -0
- package/dist/core/connection/socket/state.js +35 -0
- package/dist/core/console/index.d.ts +2 -0
- package/dist/core/console/index.js +2 -0
- package/dist/core/console/patch-console.d.ts +1 -0
- package/dist/core/console/patch-console.js +64 -0
- package/dist/core/console/restore-console.d.ts +1 -0
- package/dist/core/console/restore-console.js +28 -0
- package/dist/core/console/send-console-event.d.ts +8 -0
- package/dist/core/console/send-console-event.js +95 -0
- package/dist/core/console/state.d.ts +19 -0
- package/dist/core/console/state.js +25 -0
- package/dist/core/mmkv/index.d.ts +0 -0
- package/dist/core/mmkv/index.js +2 -0
- package/dist/core/network/get-interceptor.d.ts +11 -0
- package/dist/core/network/get-interceptor.js +19 -0
- package/dist/core/network/headers.d.ts +6 -0
- package/dist/core/network/headers.js +46 -0
- package/dist/core/network/index.d.ts +2 -0
- package/dist/core/network/index.js +2 -0
- package/dist/core/network/patch-xhr.d.ts +2 -0
- package/dist/core/network/patch-xhr.js +40 -0
- package/dist/core/network/restore-xhr.d.ts +1 -0
- package/dist/core/network/restore-xhr.js +40 -0
- package/dist/core/network/rn-blob.d.ts +1 -0
- package/dist/core/network/rn-blob.js +15 -0
- package/dist/core/network/should-skip.d.ts +2 -0
- package/dist/core/network/should-skip.js +30 -0
- package/dist/core/network/state.d.ts +5 -0
- package/dist/core/network/state.js +14 -0
- package/dist/core/network/xhr-callbacks.d.ts +12 -0
- package/dist/core/network/xhr-callbacks.js +169 -0
- package/dist/core/network/xhr-runtime-state.d.ts +4 -0
- package/dist/core/network/xhr-runtime-state.js +15 -0
- package/dist/core/network/xhr-types.d.ts +33 -0
- package/dist/core/network/xhr-types.js +1 -0
- package/dist/core/public.d.ts +2 -0
- package/dist/core/public.js +1 -0
- package/dist/core/react-query/index.d.ts +0 -0
- package/dist/core/react-query/index.js +2 -0
- package/dist/core/system/dev-server.d.ts +6 -0
- package/dist/core/system/dev-server.js +37 -0
- package/dist/core/system/device-info.d.ts +3 -0
- package/dist/core/system/device-info.js +46 -0
- package/dist/core/system/index.d.ts +2 -0
- package/dist/core/system/index.js +2 -0
- package/dist/core/websocket/index.d.ts +2 -0
- package/dist/core/websocket/index.js +2 -0
- package/dist/core/websocket/patch-websocket.d.ts +2 -0
- package/dist/core/websocket/patch-websocket.js +247 -0
- package/dist/core/websocket/restore-websocket.d.ts +1 -0
- package/dist/core/websocket/restore-websocket.js +16 -0
- package/dist/core/websocket/should-skip.d.ts +2 -0
- package/dist/core/websocket/should-skip.js +22 -0
- package/dist/core/websocket/state.d.ts +9 -0
- package/dist/core/websocket/state.js +21 -0
- package/dist/core/zustand/index.d.ts +1 -0
- package/dist/core/zustand/index.js +1 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.js +3 -0
- package/dist/public/copy-button/component.d.ts +9 -0
- package/dist/public/copy-button/component.js +13 -0
- package/dist/public/copy-button/index.d.ts +1 -0
- package/dist/public/copy-button/index.js +1 -0
- package/dist/public/copy-button/styles.d.ts +64 -0
- package/dist/public/copy-button/styles.js +52 -0
- package/dist/public/index.d.ts +1 -0
- package/dist/public/index.js +1 -0
- package/dist/public/prompt/component.d.ts +7 -0
- package/dist/public/prompt/component.js +56 -0
- package/dist/public/prompt/index.d.ts +1 -0
- package/dist/public/prompt/index.js +1 -0
- package/dist/public/prompt/prompt-mode.d.ts +3 -0
- package/dist/public/prompt/prompt-mode.js +19 -0
- package/dist/public/prompt/styles.d.ts +23 -0
- package/dist/public/prompt/styles.js +23 -0
- package/dist/public/prompt/theme.d.ts +16 -0
- package/dist/public/prompt/theme.js +32 -0
- package/dist/public/prompt/types.d.ts +12 -0
- package/dist/public/prompt/types.js +1 -0
- package/dist/public/prompt/ui/action-button.d.ts +11 -0
- package/dist/public/prompt/ui/action-button.js +23 -0
- package/dist/public/prompt/ui/footer.d.ts +7 -0
- package/dist/public/prompt/ui/footer.js +13 -0
- package/dist/public/prompt/ui/header.d.ts +10 -0
- package/dist/public/prompt/ui/header.js +17 -0
- package/dist/public/prompt/ui/report-link.d.ts +8 -0
- package/dist/public/prompt/ui/report-link.js +19 -0
- package/dist/public/prompt/use-connect-awaiter.d.ts +11 -0
- package/dist/public/prompt/use-connect-awaiter.js +45 -0
- package/dist/public/prompt/use-prompt-animation.d.ts +17 -0
- package/dist/public/prompt/use-prompt-animation.js +53 -0
- package/dist/public/prompt/use-prompt-ui.d.ts +3 -0
- package/dist/public/prompt/use-prompt-ui.js +99 -0
- package/dist/public/prompt/use-prompt.d.ts +11 -0
- package/dist/public/prompt/use-prompt.js +43 -0
- package/dist/public/prompt/views/cloud-view.d.ts +13 -0
- package/dist/public/prompt/views/cloud-view.js +19 -0
- package/dist/public/prompt/views/connected-view.d.ts +14 -0
- package/dist/public/prompt/views/connected-view.js +9 -0
- package/dist/public/prompt/views/manual-view.d.ts +16 -0
- package/dist/public/prompt/views/manual-view.js +21 -0
- package/dist/public/prompt/views/styles.d.ts +44 -0
- package/dist/public/prompt/views/styles.js +23 -0
- package/dist/public/prompt/views/use-cloud-view.d.ts +15 -0
- package/dist/public/prompt/views/use-cloud-view.js +103 -0
- package/dist/public/public.d.ts +1 -0
- package/dist/public/public.js +1 -0
- package/dist/types/index.d.ts +2 -0
- package/dist/types/index.js +2 -0
- package/dist/types/options.d.ts +30 -0
- package/dist/types/options.js +1 -0
- package/dist/types/protocol.d.ts +1 -0
- package/dist/types/protocol.js +1 -0
- package/dist/types/public.d.ts +1 -0
- package/dist/types/public.js +1 -0
- package/dist/utils/body-snippet.d.ts +19 -0
- package/dist/utils/body-snippet.js +186 -0
- package/dist/utils/debug-log.d.ts +26 -0
- package/dist/utils/debug-log.js +44 -0
- package/dist/utils/generate-random-id.d.ts +1 -0
- package/dist/utils/generate-random-id.js +8 -0
- package/dist/utils/index.d.ts +5 -0
- package/dist/utils/index.js +5 -0
- package/dist/utils/parse-url.d.ts +5 -0
- package/dist/utils/parse-url.js +32 -0
- package/dist/utils/safe-serialize.d.ts +6 -0
- package/dist/utils/safe-serialize.js +77 -0
- package/dist/version.d.ts +1 -0
- package/dist/version.js +1 -0
- package/dist/zustand/index.d.ts +1 -0
- package/dist/zustand/index.js +1 -0
- package/dist/zustand/middleware.d.ts +18 -0
- package/dist/zustand/middleware.js +77 -0
- package/package.json +88 -4
- package/zustand/index.d.ts +1 -0
- package/zustand/index.js +1 -0
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import { sendEvent, isSdkEnabled } from "../core/connection/index.js";
|
|
2
|
+
import { generateRandomId } from "../utils/index.js";
|
|
3
|
+
/**
|
|
4
|
+
* Heimdall middleware for Zustand.
|
|
5
|
+
*
|
|
6
|
+
* Usage:
|
|
7
|
+
*
|
|
8
|
+
* const useStore = create(
|
|
9
|
+
* heimdallZustand("connection", (set, get, api) => ({
|
|
10
|
+
* ...
|
|
11
|
+
* }))
|
|
12
|
+
* );
|
|
13
|
+
*
|
|
14
|
+
* Features:
|
|
15
|
+
* - Does not store history / diff in SDK.
|
|
16
|
+
* - Sends snapshots of the state to Heimdall.
|
|
17
|
+
* - Tries to determine the "action" by the name of the top-level function of the store.
|
|
18
|
+
*/
|
|
19
|
+
export function heimdallZustand(storeName, createState) {
|
|
20
|
+
let currentActionName;
|
|
21
|
+
const wrappedCreator = (set, get, api) => {
|
|
22
|
+
if (!isSdkEnabled()) {
|
|
23
|
+
return createState(set, get, api);
|
|
24
|
+
}
|
|
25
|
+
const initialState = createState(set, get, api);
|
|
26
|
+
const wrappedState = { ...initialState };
|
|
27
|
+
for (const key of Object.keys(wrappedState)) {
|
|
28
|
+
const value = wrappedState[key];
|
|
29
|
+
if (typeof value === "function") {
|
|
30
|
+
const original = value;
|
|
31
|
+
wrappedState[key] = (...args) => {
|
|
32
|
+
const prev = currentActionName;
|
|
33
|
+
currentActionName = key;
|
|
34
|
+
try {
|
|
35
|
+
return original(...args);
|
|
36
|
+
}
|
|
37
|
+
finally {
|
|
38
|
+
currentActionName = prev;
|
|
39
|
+
}
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
let prevState = wrappedState;
|
|
44
|
+
const unsubscribe = api.subscribe(() => {
|
|
45
|
+
if (!isSdkEnabled())
|
|
46
|
+
return;
|
|
47
|
+
const nextState = api.getState();
|
|
48
|
+
if (nextState === prevState)
|
|
49
|
+
return;
|
|
50
|
+
const payload = {
|
|
51
|
+
type: "zustand",
|
|
52
|
+
store: storeName,
|
|
53
|
+
id: generateRandomId(),
|
|
54
|
+
ts: Date.now(),
|
|
55
|
+
state: nextState,
|
|
56
|
+
prevState,
|
|
57
|
+
action: currentActionName !== null && currentActionName !== void 0 ? currentActionName : "UNKNOWN",
|
|
58
|
+
};
|
|
59
|
+
prevState = nextState;
|
|
60
|
+
sendEvent(payload);
|
|
61
|
+
});
|
|
62
|
+
api.__HEIMDALL_ZUSTAND_UNSUB__ = unsubscribe;
|
|
63
|
+
if (isSdkEnabled()) {
|
|
64
|
+
const initialPayload = {
|
|
65
|
+
type: "zustand",
|
|
66
|
+
store: storeName,
|
|
67
|
+
id: generateRandomId(),
|
|
68
|
+
ts: Date.now(),
|
|
69
|
+
state: prevState,
|
|
70
|
+
action: "INITIALIZED",
|
|
71
|
+
};
|
|
72
|
+
sendEvent(initialPayload);
|
|
73
|
+
}
|
|
74
|
+
return wrappedState;
|
|
75
|
+
};
|
|
76
|
+
return wrappedCreator;
|
|
77
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,90 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rnzeus/heimdall-sdk",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"version": "0.2.2",
|
|
4
|
+
"description": "React Native client for Heimdall — a desktop debug inspector for network, WebSocket, Zustand and console",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"author": "Volodymyr Dudkevych",
|
|
7
|
+
"homepage": "https://heimdall.rnzeus.dev",
|
|
8
|
+
"repository": {
|
|
9
|
+
"type": "git",
|
|
10
|
+
"url": "git+https://github.com/rnzeus/heimdall-sdk.git"
|
|
11
|
+
},
|
|
12
|
+
"bugs": {
|
|
13
|
+
"url": "https://github.com/rnzeus/heimdall-sdk/issues"
|
|
14
|
+
},
|
|
15
|
+
"keywords": [
|
|
16
|
+
"react-native",
|
|
17
|
+
"debugging",
|
|
18
|
+
"devtools",
|
|
19
|
+
"inspector",
|
|
20
|
+
"network",
|
|
21
|
+
"websocket",
|
|
22
|
+
"zustand",
|
|
23
|
+
"heimdall"
|
|
24
|
+
],
|
|
25
|
+
"publishConfig": {
|
|
26
|
+
"access": "public"
|
|
27
|
+
},
|
|
28
|
+
"type": "module",
|
|
29
|
+
"sideEffects": false,
|
|
30
|
+
"files": [
|
|
31
|
+
"dist",
|
|
32
|
+
"zustand"
|
|
33
|
+
],
|
|
34
|
+
"main": "dist/index.js",
|
|
35
|
+
"types": "dist/index.d.ts",
|
|
36
|
+
"react-native": "dist/index.js",
|
|
37
|
+
"exports": {
|
|
38
|
+
".": {
|
|
39
|
+
"types": "./dist/index.d.ts",
|
|
40
|
+
"react-native": "./dist/index.js",
|
|
41
|
+
"import": "./dist/index.js",
|
|
42
|
+
"require": "./dist/index.js",
|
|
43
|
+
"default": "./dist/index.js"
|
|
44
|
+
},
|
|
45
|
+
"./zustand": {
|
|
46
|
+
"types": "./zustand/index.d.ts",
|
|
47
|
+
"react-native": "./zustand/index.js",
|
|
48
|
+
"import": "./zustand/index.js",
|
|
49
|
+
"require": "./zustand/index.js",
|
|
50
|
+
"default": "./zustand/index.js"
|
|
51
|
+
}
|
|
52
|
+
},
|
|
53
|
+
"scripts": {
|
|
54
|
+
"clean": "rimraf dist",
|
|
55
|
+
"build": "node scripts/write-version.mjs && yarn clean && tsc -p tsconfig.build.json && node scripts/fix-esm-extensions.mjs dist",
|
|
56
|
+
"dev": "tsc -p tsconfig.build.json -w",
|
|
57
|
+
"typecheck": "node scripts/write-version.mjs && tsc -p tsconfig.json --noEmit"
|
|
58
|
+
},
|
|
59
|
+
"peerDependencies": {
|
|
60
|
+
"react": ">=18.0.0",
|
|
61
|
+
"react-native": ">=0.72.0",
|
|
62
|
+
"react-native-mmkv": ">=3",
|
|
63
|
+
"react-native-tcp-socket": ">=6",
|
|
64
|
+
"zustand": ">=3"
|
|
65
|
+
},
|
|
66
|
+
"peerDependenciesMeta": {
|
|
67
|
+
"zustand": {
|
|
68
|
+
"optional": true
|
|
69
|
+
}
|
|
70
|
+
},
|
|
71
|
+
"dependencies": {
|
|
72
|
+
"@rnzeus/heimdall-protocol": "^0.2.0"
|
|
73
|
+
},
|
|
74
|
+
"devDependencies": {
|
|
75
|
+
"@types/node": "^25.0.3",
|
|
76
|
+
"@types/react": "^18.3.12",
|
|
77
|
+
"react": "^18.3.1",
|
|
78
|
+
"react-native": "^0.79.0",
|
|
79
|
+
"react-native-mmkv": "^3.3.0",
|
|
80
|
+
"react-native-tcp-socket": "^6.3.0",
|
|
81
|
+
"rimraf": "^6.0.0",
|
|
82
|
+
"typescript": "^5.7.2",
|
|
83
|
+
"zustand": "^4.0.0"
|
|
84
|
+
},
|
|
85
|
+
"packageManager": "yarn@4.6.0",
|
|
86
|
+
"volta": {
|
|
87
|
+
"node": "22.14.0",
|
|
88
|
+
"yarn": "4.6.0"
|
|
89
|
+
}
|
|
90
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "../dist/zustand";
|
package/zustand/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "../dist/zustand/index.js";
|