dreaction-protocol 1.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.
- package/lib/command.d.ts +84 -0
- package/lib/command.d.ts.map +1 -0
- package/lib/command.js +36 -0
- package/lib/data.d.ts +6 -0
- package/lib/data.d.ts.map +1 -0
- package/lib/data.js +2 -0
- package/lib/index.d.ts +7 -0
- package/lib/index.d.ts.map +1 -0
- package/lib/index.js +22 -0
- package/lib/log.d.ts +21 -0
- package/lib/log.d.ts.map +1 -0
- package/lib/log.js +17 -0
- package/lib/network.d.ts +16 -0
- package/lib/network.d.ts.map +1 -0
- package/lib/network.js +2 -0
- package/lib/openInEditor.d.ts +5 -0
- package/lib/openInEditor.d.ts.map +1 -0
- package/lib/openInEditor.js +2 -0
- package/lib/reactotron-core-contract.d.ts +6 -0
- package/lib/reactotron-core-contract.d.ts.map +1 -0
- package/lib/reactotron-core-contract.js +21 -0
- package/lib/server-events.d.ts +109 -0
- package/lib/server-events.d.ts.map +1 -0
- package/lib/server-events.js +36 -0
- package/lib/state.d.ts +53 -0
- package/lib/state.d.ts.map +1 -0
- package/lib/state.js +2 -0
- package/package.json +32 -0
- package/src/command.ts +101 -0
- package/src/data.ts +5 -0
- package/src/index.ts +6 -0
- package/src/log.ts +43 -0
- package/src/network.ts +15 -0
- package/src/openInEditor.ts +4 -0
- package/src/server-events.ts +120 -0
- package/src/state.ts +62 -0
package/lib/command.d.ts
ADDED
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import { DataWatchPayload } from './data';
|
|
2
|
+
import type { LogPayload } from './log';
|
|
3
|
+
import { NetworkPayload } from './network';
|
|
4
|
+
import { EditorOpenPayload } from './openInEditor';
|
|
5
|
+
import type { StateActionCompletePayload, StateActionDispatchPayload, StateBackupRequestPayload, StateBackupResponsePayload, StateKeysRequestPayload, StateKeysResponsePayload, StateRestoreRequestPayload, StateValuesChangePayload, StateValuesRequestPayload, StateValuesResponsePayload, StateValuesSubscribePayload } from './state';
|
|
6
|
+
export declare const CommandType: {
|
|
7
|
+
readonly ApiResponse: "api.response";
|
|
8
|
+
readonly AsyncStorageMutation: "asyncStorage.mutation";
|
|
9
|
+
readonly Benchmark: "benchmark.report";
|
|
10
|
+
readonly ClientIntro: "client.intro";
|
|
11
|
+
readonly Display: "display";
|
|
12
|
+
readonly Image: "image";
|
|
13
|
+
readonly Log: "log";
|
|
14
|
+
readonly DataWatch: "dataWatch";
|
|
15
|
+
readonly SagaTaskComplete: "saga.task.complete";
|
|
16
|
+
readonly StateActionComplete: "state.action.complete";
|
|
17
|
+
readonly StateKeysResponse: "state.keys.response";
|
|
18
|
+
readonly StateValuesChange: "state.values.change";
|
|
19
|
+
readonly StateValuesResponse: "state.values.response";
|
|
20
|
+
readonly StateBackupResponse: "state.backup.response";
|
|
21
|
+
readonly StateBackupRequest: "state.backup.request";
|
|
22
|
+
readonly StateRestoreRequest: "state.restore.request";
|
|
23
|
+
readonly StateActionDispatch: "state.action.dispatch";
|
|
24
|
+
readonly StateValuesSubscribe: "state.values.subscribe";
|
|
25
|
+
readonly StateKeysRequest: "state.keys.request";
|
|
26
|
+
readonly StateValuesRequest: "state.values.request";
|
|
27
|
+
readonly CustomCommandRegister: "customCommand.register";
|
|
28
|
+
readonly CustomCommandUnregister: "customCommand.unregister";
|
|
29
|
+
readonly Clear: "clear";
|
|
30
|
+
readonly ReplLsResponse: "repl.ls.response";
|
|
31
|
+
readonly ReplExecuteResponse: "repl.execute.response";
|
|
32
|
+
readonly DevtoolsOpen: "devtools.open";
|
|
33
|
+
readonly DevtoolsReload: "devtools.reload";
|
|
34
|
+
readonly EditorOpen: "editor.open";
|
|
35
|
+
readonly Storybook: "storybook";
|
|
36
|
+
readonly Overlay: "overlay";
|
|
37
|
+
};
|
|
38
|
+
export type CommandTypeKey = (typeof CommandType)[keyof typeof CommandType];
|
|
39
|
+
export interface CommandMap {
|
|
40
|
+
[CommandType.ApiResponse]: NetworkPayload;
|
|
41
|
+
[CommandType.AsyncStorageMutation]: any;
|
|
42
|
+
[CommandType.Benchmark]: any;
|
|
43
|
+
[CommandType.ClientIntro]: any;
|
|
44
|
+
[CommandType.Display]: any;
|
|
45
|
+
[CommandType.Image]: any;
|
|
46
|
+
[CommandType.Log]: LogPayload;
|
|
47
|
+
[CommandType.DataWatch]: DataWatchPayload;
|
|
48
|
+
[CommandType.SagaTaskComplete]: any;
|
|
49
|
+
[CommandType.StateActionComplete]: StateActionCompletePayload;
|
|
50
|
+
[CommandType.StateKeysResponse]: StateKeysResponsePayload;
|
|
51
|
+
[CommandType.StateValuesChange]: StateValuesChangePayload;
|
|
52
|
+
[CommandType.StateValuesResponse]: StateValuesResponsePayload;
|
|
53
|
+
[CommandType.StateBackupResponse]: StateBackupResponsePayload;
|
|
54
|
+
[CommandType.StateBackupRequest]: StateBackupRequestPayload;
|
|
55
|
+
[CommandType.StateRestoreRequest]: StateRestoreRequestPayload;
|
|
56
|
+
[CommandType.StateActionDispatch]: StateActionDispatchPayload;
|
|
57
|
+
[CommandType.StateValuesSubscribe]: StateValuesSubscribePayload;
|
|
58
|
+
[CommandType.StateKeysRequest]: StateKeysRequestPayload;
|
|
59
|
+
[CommandType.StateValuesRequest]: StateValuesRequestPayload;
|
|
60
|
+
[CommandType.CustomCommandRegister]: any;
|
|
61
|
+
[CommandType.CustomCommandUnregister]: any;
|
|
62
|
+
[CommandType.Clear]: undefined;
|
|
63
|
+
[CommandType.ReplLsResponse]: any;
|
|
64
|
+
[CommandType.ReplExecuteResponse]: any;
|
|
65
|
+
[CommandType.DevtoolsOpen]: undefined;
|
|
66
|
+
[CommandType.DevtoolsReload]: undefined;
|
|
67
|
+
[CommandType.EditorOpen]: EditorOpenPayload;
|
|
68
|
+
[CommandType.Storybook]: boolean;
|
|
69
|
+
[CommandType.Overlay]: boolean;
|
|
70
|
+
}
|
|
71
|
+
export type Command = {
|
|
72
|
+
[Type in keyof CommandMap]: {
|
|
73
|
+
type: Type;
|
|
74
|
+
connectionId: number;
|
|
75
|
+
clientId?: string;
|
|
76
|
+
date: Date;
|
|
77
|
+
deltaTime: number;
|
|
78
|
+
important: boolean;
|
|
79
|
+
messageId: number;
|
|
80
|
+
payload: CommandMap[Type];
|
|
81
|
+
};
|
|
82
|
+
}[keyof CommandMap];
|
|
83
|
+
export type CommandEvent = (command: Command) => void;
|
|
84
|
+
//# sourceMappingURL=command.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"command.d.ts","sourceRoot":"","sources":["../src/command.ts"],"names":[],"mappings":"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"}
|
package/lib/command.js
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.CommandType = void 0;
|
|
4
|
+
exports.CommandType = {
|
|
5
|
+
ApiResponse: 'api.response',
|
|
6
|
+
AsyncStorageMutation: 'asyncStorage.mutation',
|
|
7
|
+
Benchmark: 'benchmark.report',
|
|
8
|
+
ClientIntro: 'client.intro',
|
|
9
|
+
Display: 'display',
|
|
10
|
+
Image: 'image',
|
|
11
|
+
Log: 'log',
|
|
12
|
+
DataWatch: 'dataWatch',
|
|
13
|
+
SagaTaskComplete: 'saga.task.complete',
|
|
14
|
+
StateActionComplete: 'state.action.complete',
|
|
15
|
+
StateKeysResponse: 'state.keys.response',
|
|
16
|
+
StateValuesChange: 'state.values.change',
|
|
17
|
+
StateValuesResponse: 'state.values.response',
|
|
18
|
+
StateBackupResponse: 'state.backup.response',
|
|
19
|
+
StateBackupRequest: 'state.backup.request',
|
|
20
|
+
StateRestoreRequest: 'state.restore.request',
|
|
21
|
+
StateActionDispatch: 'state.action.dispatch',
|
|
22
|
+
StateValuesSubscribe: 'state.values.subscribe',
|
|
23
|
+
StateKeysRequest: 'state.keys.request',
|
|
24
|
+
StateValuesRequest: 'state.values.request',
|
|
25
|
+
CustomCommandRegister: 'customCommand.register',
|
|
26
|
+
CustomCommandUnregister: 'customCommand.unregister',
|
|
27
|
+
Clear: 'clear',
|
|
28
|
+
ReplLsResponse: 'repl.ls.response',
|
|
29
|
+
ReplExecuteResponse: 'repl.execute.response',
|
|
30
|
+
// these technically are commands only in reactotron-react-native, but I felt lazy so they can live here
|
|
31
|
+
DevtoolsOpen: 'devtools.open',
|
|
32
|
+
DevtoolsReload: 'devtools.reload',
|
|
33
|
+
EditorOpen: 'editor.open',
|
|
34
|
+
Storybook: 'storybook',
|
|
35
|
+
Overlay: 'overlay',
|
|
36
|
+
};
|
package/lib/data.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"data.d.ts","sourceRoot":"","sources":["../src/data.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,gBAAgB;IAC/B,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,MAAM,CAAC;IAC/B,IAAI,EAAE,OAAO,CAAC;CACf"}
|
package/lib/data.js
ADDED
package/lib/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,WAAW,CAAC;AAC1B,cAAc,OAAO,CAAC;AACtB,cAAc,QAAQ,CAAC;AACvB,cAAc,gBAAgB,CAAC;AAC/B,cAAc,iBAAiB,CAAC;AAChC,cAAc,SAAS,CAAC"}
|
package/lib/index.js
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./command"), exports);
|
|
18
|
+
__exportStar(require("./log"), exports);
|
|
19
|
+
__exportStar(require("./data"), exports);
|
|
20
|
+
__exportStar(require("./openInEditor"), exports);
|
|
21
|
+
__exportStar(require("./server-events"), exports);
|
|
22
|
+
__exportStar(require("./state"), exports);
|
package/lib/log.d.ts
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
export interface ErrorStackFrame {
|
|
2
|
+
fileName: string;
|
|
3
|
+
functionName: string;
|
|
4
|
+
lineNumber: number;
|
|
5
|
+
columnNumber: number | null;
|
|
6
|
+
}
|
|
7
|
+
export declare const isErrorStackFrame: (value: unknown) => value is ErrorStackFrame;
|
|
8
|
+
export declare const isErrorStackFrameArray: (value: unknown) => value is ErrorStackFrame[];
|
|
9
|
+
export interface ErrorLogPayload {
|
|
10
|
+
level: 'error';
|
|
11
|
+
message: string;
|
|
12
|
+
stack: Error['stack'] | string[] | ErrorStackFrame[];
|
|
13
|
+
}
|
|
14
|
+
export type LogPayload = {
|
|
15
|
+
level: 'debug';
|
|
16
|
+
message: string;
|
|
17
|
+
} | {
|
|
18
|
+
level: 'warn';
|
|
19
|
+
message: string;
|
|
20
|
+
} | ErrorLogPayload;
|
|
21
|
+
//# sourceMappingURL=log.d.ts.map
|
package/lib/log.d.ts.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"log.d.ts","sourceRoot":"","sources":["../src/log.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,eAAe;IAC9B,QAAQ,EAAE,MAAM,CAAC;IACjB,YAAY,EAAE,MAAM,CAAC;IACrB,UAAU,EAAE,MAAM,CAAC;IACnB,YAAY,EAAE,MAAM,GAAG,IAAI,CAAC;CAC7B;AAED,eAAO,MAAM,iBAAiB,UAAW,OAAO,KAAG,KAAK,IAAI,eAazD,CAAC;AAEJ,eAAO,MAAM,sBAAsB,UAC1B,OAAO,KACb,KAAK,IAAI,eAAe,EAC6B,CAAC;AAEzD,MAAM,WAAW,eAAe;IAC9B,KAAK,EAAE,OAAO,CAAC;IACf,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,EAAE,KAAK,CAAC,OAAO,CAAC,GAAG,MAAM,EAAE,GAAG,eAAe,EAAE,CAAC;CACtD;AAED,MAAM,MAAM,UAAU,GAClB;IACE,KAAK,EAAE,OAAO,CAAC;IACf,OAAO,EAAE,MAAM,CAAC;CACjB,GACD;IACE,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,MAAM,CAAC;CACjB,GACD,eAAe,CAAC"}
|
package/lib/log.js
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.isErrorStackFrameArray = exports.isErrorStackFrame = void 0;
|
|
4
|
+
const isErrorStackFrame = (value) => Boolean(value &&
|
|
5
|
+
typeof value === 'object' &&
|
|
6
|
+
'fileName' in value &&
|
|
7
|
+
typeof value.fileName === 'string' &&
|
|
8
|
+
'functionName' in value &&
|
|
9
|
+
typeof value.functionName === 'string' &&
|
|
10
|
+
'lineNumber' in value &&
|
|
11
|
+
typeof value.lineNumber === 'number' &&
|
|
12
|
+
('columnNumber' in value
|
|
13
|
+
? value.columnNumber === null || typeof value.columnNumber === 'number'
|
|
14
|
+
: true));
|
|
15
|
+
exports.isErrorStackFrame = isErrorStackFrame;
|
|
16
|
+
const isErrorStackFrameArray = (value) => Array.isArray(value) && value.every(exports.isErrorStackFrame);
|
|
17
|
+
exports.isErrorStackFrameArray = isErrorStackFrameArray;
|
package/lib/network.d.ts
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export interface NetworkPayload {
|
|
2
|
+
request: {
|
|
3
|
+
url: string;
|
|
4
|
+
method: 'GET' | 'POST' | 'PUT' | 'DELETE' | 'PATCH' | 'OPTIONS';
|
|
5
|
+
data: any;
|
|
6
|
+
headers: Record<string, string>;
|
|
7
|
+
params: any;
|
|
8
|
+
};
|
|
9
|
+
response: {
|
|
10
|
+
status: number;
|
|
11
|
+
headers: Record<string, string>;
|
|
12
|
+
body: any;
|
|
13
|
+
};
|
|
14
|
+
duration: number;
|
|
15
|
+
}
|
|
16
|
+
//# sourceMappingURL=network.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"network.d.ts","sourceRoot":"","sources":["../src/network.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,cAAc;IAC7B,OAAO,EAAE;QACP,GAAG,EAAE,MAAM,CAAC;QACZ,MAAM,EAAE,KAAK,GAAG,MAAM,GAAG,KAAK,GAAG,QAAQ,GAAG,OAAO,GAAG,SAAS,CAAC;QAChE,IAAI,EAAE,GAAG,CAAC;QACV,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;QAChC,MAAM,EAAE,GAAG,CAAC;KACb,CAAC;IACF,QAAQ,EAAE;QACR,MAAM,EAAE,MAAM,CAAC;QACf,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;QAChC,IAAI,EAAE,GAAG,CAAC;KACX,CAAC;IACF,QAAQ,EAAE,MAAM,CAAC;CAClB"}
|
package/lib/network.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"openInEditor.d.ts","sourceRoot":"","sources":["../src/openInEditor.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,iBAAiB;IAChC,IAAI,EAAE,MAAM,CAAC;IACb,UAAU,EAAE,MAAM,CAAC;CACpB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"reactotron-core-contract.d.ts","sourceRoot":"","sources":["../src/reactotron-core-contract.ts"],"names":[],"mappings":"AAAA,cAAc,WAAW,CAAC;AAC1B,cAAc,OAAO,CAAC;AACtB,cAAc,gBAAgB,CAAC;AAC/B,cAAc,iBAAiB,CAAC;AAChC,cAAc,SAAS,CAAC"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./command"), exports);
|
|
18
|
+
__exportStar(require("./log"), exports);
|
|
19
|
+
__exportStar(require("./openInEditor"), exports);
|
|
20
|
+
__exportStar(require("./server-events"), exports);
|
|
21
|
+
__exportStar(require("./state"), exports);
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
import WebSocket from 'ws';
|
|
2
|
+
import { Command } from './command';
|
|
3
|
+
export interface PfxServerOptions {
|
|
4
|
+
/**
|
|
5
|
+
* Path to a PFX file.
|
|
6
|
+
*/
|
|
7
|
+
pathToPfx: string;
|
|
8
|
+
/**
|
|
9
|
+
* Passphrase, if required, of the PFX file.
|
|
10
|
+
*/
|
|
11
|
+
passphrase?: string;
|
|
12
|
+
}
|
|
13
|
+
export interface CertServerOptions {
|
|
14
|
+
/**
|
|
15
|
+
* Path to a signing cert file.
|
|
16
|
+
*/
|
|
17
|
+
pathToCert: string;
|
|
18
|
+
/**
|
|
19
|
+
* Path to a the corresponding key of the cert file.
|
|
20
|
+
*/
|
|
21
|
+
pathToKey: string;
|
|
22
|
+
/**
|
|
23
|
+
* Passphrase, if required, of the key file.
|
|
24
|
+
*/
|
|
25
|
+
passphrase?: string;
|
|
26
|
+
}
|
|
27
|
+
export type WssServerOptions = PfxServerOptions | CertServerOptions;
|
|
28
|
+
/**
|
|
29
|
+
* Configuration options for the Reactotron server.
|
|
30
|
+
*/
|
|
31
|
+
export interface ServerOptions {
|
|
32
|
+
/**
|
|
33
|
+
* Which port to listen to. Default: 9090.
|
|
34
|
+
*/
|
|
35
|
+
port: number;
|
|
36
|
+
/**
|
|
37
|
+
* Web Socket Secure Configuration
|
|
38
|
+
*/
|
|
39
|
+
wss?: WssServerOptions;
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* A client which is in the process of connecting.
|
|
43
|
+
*/
|
|
44
|
+
export interface PartialConnection {
|
|
45
|
+
/**
|
|
46
|
+
* The unique id of the client.
|
|
47
|
+
*/
|
|
48
|
+
id: number;
|
|
49
|
+
/**
|
|
50
|
+
* The ip address.
|
|
51
|
+
*/
|
|
52
|
+
address: string;
|
|
53
|
+
/**
|
|
54
|
+
* The connecting web socket.
|
|
55
|
+
*/
|
|
56
|
+
socket: WebSocket;
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* One of the events which be subscribed to.
|
|
60
|
+
*/
|
|
61
|
+
export declare const ServerEvent: {
|
|
62
|
+
/**
|
|
63
|
+
* When a command arrives from a client.
|
|
64
|
+
*/
|
|
65
|
+
readonly command: "command";
|
|
66
|
+
/**
|
|
67
|
+
* The server has started.
|
|
68
|
+
*/
|
|
69
|
+
readonly start: "start";
|
|
70
|
+
/**
|
|
71
|
+
* The server has stopped.
|
|
72
|
+
*/
|
|
73
|
+
readonly stop: "stop";
|
|
74
|
+
/**
|
|
75
|
+
* A client has connected.
|
|
76
|
+
*/
|
|
77
|
+
readonly connect: "connect";
|
|
78
|
+
/**
|
|
79
|
+
* A client has connected and provided us the initial detail we want.
|
|
80
|
+
*/
|
|
81
|
+
readonly connectionEstablished: "connectionEstablished";
|
|
82
|
+
/**
|
|
83
|
+
* A client has disconnected.
|
|
84
|
+
*/
|
|
85
|
+
readonly disconnect: "disconnect";
|
|
86
|
+
/**
|
|
87
|
+
* Port is already in use
|
|
88
|
+
*/
|
|
89
|
+
readonly portUnavailable: "portUnavailable";
|
|
90
|
+
};
|
|
91
|
+
export type ServerEventKey = keyof typeof ServerEvent;
|
|
92
|
+
type StartPayload = any;
|
|
93
|
+
type StopPayload = any;
|
|
94
|
+
type ConnectPayload = PartialConnection;
|
|
95
|
+
type ConnectionEstablishedPayload = any;
|
|
96
|
+
type DisconnectPayload = any;
|
|
97
|
+
type PortUnavailablePayload = any;
|
|
98
|
+
export type ServerEventMap = {
|
|
99
|
+
[ServerEvent.command]: Command;
|
|
100
|
+
[ServerEvent.start]: StartPayload;
|
|
101
|
+
[ServerEvent.stop]: StopPayload;
|
|
102
|
+
[ServerEvent.connect]: ConnectPayload;
|
|
103
|
+
[ServerEvent.connectionEstablished]: ConnectionEstablishedPayload;
|
|
104
|
+
[ServerEvent.disconnect]: DisconnectPayload;
|
|
105
|
+
[ServerEvent.portUnavailable]: PortUnavailablePayload;
|
|
106
|
+
};
|
|
107
|
+
export type WebSocketEvent = (socket: WebSocket) => void;
|
|
108
|
+
export {};
|
|
109
|
+
//# sourceMappingURL=server-events.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"server-events.d.ts","sourceRoot":"","sources":["../src/server-events.ts"],"names":[],"mappings":"AAAA,OAAO,SAAS,MAAM,IAAI,CAAC;AAC3B,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAEpC,MAAM,WAAW,gBAAgB;IAC/B;;OAEG;IACH,SAAS,EAAE,MAAM,CAAC;IAClB;;OAEG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAED,MAAM,WAAW,iBAAiB;IAChC;;OAEG;IACH,UAAU,EAAE,MAAM,CAAC;IACnB;;OAEG;IACH,SAAS,EAAE,MAAM,CAAC;IAClB;;OAEG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAED,MAAM,MAAM,gBAAgB,GAAG,gBAAgB,GAAG,iBAAiB,CAAC;AAEpE;;GAEG;AACH,MAAM,WAAW,aAAa;IAC5B;;OAEG;IACH,IAAI,EAAE,MAAM,CAAC;IAEb;;OAEG;IACH,GAAG,CAAC,EAAE,gBAAgB,CAAC;CACxB;AAED;;GAEG;AACH,MAAM,WAAW,iBAAiB;IAChC;;OAEG;IACH,EAAE,EAAE,MAAM,CAAC;IAEX;;OAEG;IACH,OAAO,EAAE,MAAM,CAAC;IAEhB;;OAEG;IACH,MAAM,EAAE,SAAS,CAAC;CACnB;AAED;;GAEG;AACH,eAAO,MAAM,WAAW;IACtB;;OAEG;;IAEH;;OAEG;;IAEH;;OAEG;;IAEH;;OAEG;;IAEH;;OAEG;;IAEH;;OAEG;;IAEH;;OAEG;;CAEK,CAAC;AAEX,MAAM,MAAM,cAAc,GAAG,MAAM,OAAO,WAAW,CAAC;AAEtD,KAAK,YAAY,GAAG,GAAG,CAAC;AACxB,KAAK,WAAW,GAAG,GAAG,CAAC;AACvB,KAAK,cAAc,GAAG,iBAAiB,CAAC;AACxC,KAAK,4BAA4B,GAAG,GAAG,CAAC;AACxC,KAAK,iBAAiB,GAAG,GAAG,CAAC;AAC7B,KAAK,sBAAsB,GAAG,GAAG,CAAC;AAElC,MAAM,MAAM,cAAc,GAAG;IAC3B,CAAC,WAAW,CAAC,OAAO,CAAC,EAAE,OAAO,CAAC;IAC/B,CAAC,WAAW,CAAC,KAAK,CAAC,EAAE,YAAY,CAAC;IAClC,CAAC,WAAW,CAAC,IAAI,CAAC,EAAE,WAAW,CAAC;IAChC,CAAC,WAAW,CAAC,OAAO,CAAC,EAAE,cAAc,CAAC;IACtC,CAAC,WAAW,CAAC,qBAAqB,CAAC,EAAE,4BAA4B,CAAC;IAClE,CAAC,WAAW,CAAC,UAAU,CAAC,EAAE,iBAAiB,CAAC;IAC5C,CAAC,WAAW,CAAC,eAAe,CAAC,EAAE,sBAAsB,CAAC;CACvD,CAAC;AAEF,MAAM,MAAM,cAAc,GAAG,CAAC,MAAM,EAAE,SAAS,KAAK,IAAI,CAAC"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ServerEvent = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* One of the events which be subscribed to.
|
|
6
|
+
*/
|
|
7
|
+
exports.ServerEvent = {
|
|
8
|
+
/**
|
|
9
|
+
* When a command arrives from a client.
|
|
10
|
+
*/
|
|
11
|
+
command: 'command',
|
|
12
|
+
/**
|
|
13
|
+
* The server has started.
|
|
14
|
+
*/
|
|
15
|
+
start: 'start',
|
|
16
|
+
/**
|
|
17
|
+
* The server has stopped.
|
|
18
|
+
*/
|
|
19
|
+
stop: 'stop',
|
|
20
|
+
/**
|
|
21
|
+
* A client has connected.
|
|
22
|
+
*/
|
|
23
|
+
connect: 'connect',
|
|
24
|
+
/**
|
|
25
|
+
* A client has connected and provided us the initial detail we want.
|
|
26
|
+
*/
|
|
27
|
+
connectionEstablished: 'connectionEstablished',
|
|
28
|
+
/**
|
|
29
|
+
* A client has disconnected.
|
|
30
|
+
*/
|
|
31
|
+
disconnect: 'disconnect',
|
|
32
|
+
/**
|
|
33
|
+
* Port is already in use
|
|
34
|
+
*/
|
|
35
|
+
portUnavailable: 'portUnavailable',
|
|
36
|
+
};
|
package/lib/state.d.ts
ADDED
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
export interface StateBackupRequestPayload {
|
|
2
|
+
state: Record<string, any>;
|
|
3
|
+
}
|
|
4
|
+
export interface StateBackupResponsePayload {
|
|
5
|
+
state: Record<string, any>;
|
|
6
|
+
}
|
|
7
|
+
export interface StateRestoreRequestPayload {
|
|
8
|
+
state: Record<string, any>;
|
|
9
|
+
}
|
|
10
|
+
export interface StateActionDispatchPayload {
|
|
11
|
+
action: {
|
|
12
|
+
type: string;
|
|
13
|
+
payload: Record<string, any>;
|
|
14
|
+
} | {
|
|
15
|
+
name: string;
|
|
16
|
+
path?: string;
|
|
17
|
+
args?: any[];
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
type Path = string;
|
|
21
|
+
type Value = any;
|
|
22
|
+
export interface StateKeysRequestPayload {
|
|
23
|
+
path: Path;
|
|
24
|
+
}
|
|
25
|
+
export interface StateKeysResponsePayload {
|
|
26
|
+
path: Path;
|
|
27
|
+
keys: string[];
|
|
28
|
+
valid: boolean;
|
|
29
|
+
}
|
|
30
|
+
export interface StateValuesRequestPayload {
|
|
31
|
+
path: Path;
|
|
32
|
+
}
|
|
33
|
+
export interface StateValuesResponsePayload {
|
|
34
|
+
path: Path;
|
|
35
|
+
value: Value;
|
|
36
|
+
valid: boolean;
|
|
37
|
+
}
|
|
38
|
+
export interface StateValuesChangePayload {
|
|
39
|
+
changes: {
|
|
40
|
+
path: Path;
|
|
41
|
+
value: Value;
|
|
42
|
+
}[];
|
|
43
|
+
}
|
|
44
|
+
export interface StateValuesSubscribePayload {
|
|
45
|
+
paths: Path[];
|
|
46
|
+
}
|
|
47
|
+
export interface StateActionCompletePayload {
|
|
48
|
+
name: string;
|
|
49
|
+
action: Record<string, any>;
|
|
50
|
+
ms?: number;
|
|
51
|
+
}
|
|
52
|
+
export {};
|
|
53
|
+
//# sourceMappingURL=state.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"state.d.ts","sourceRoot":"","sources":["../src/state.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,yBAAyB;IACxC,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;CAC5B;AAED,MAAM,WAAW,0BAA0B;IACzC,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;CAC5B;AAED,MAAM,WAAW,0BAA0B;IACzC,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;CAC5B;AAED,MAAM,WAAW,0BAA0B;IACzC,MAAM,EACF;QACE,IAAI,EAAE,MAAM,CAAC;QACb,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;KAC9B,GACD;QACE,IAAI,EAAE,MAAM,CAAC;QACb,IAAI,CAAC,EAAE,MAAM,CAAC;QACd,IAAI,CAAC,EAAE,GAAG,EAAE,CAAC;KACd,CAAC;CACP;AAED,KAAK,IAAI,GAAG,MAAM,CAAC;AAEnB,KAAK,KAAK,GAAG,GAAG,CAAC;AAEjB,MAAM,WAAW,uBAAuB;IACtC,IAAI,EAAE,IAAI,CAAC;CACZ;AAED,MAAM,WAAW,wBAAwB;IACvC,IAAI,EAAE,IAAI,CAAC;IACX,IAAI,EAAE,MAAM,EAAE,CAAC;IACf,KAAK,EAAE,OAAO,CAAC;CAChB;AAED,MAAM,WAAW,yBAAyB;IACxC,IAAI,EAAE,IAAI,CAAC;CACZ;AAED,MAAM,WAAW,0BAA0B;IACzC,IAAI,EAAE,IAAI,CAAC;IACX,KAAK,EAAE,KAAK,CAAC;IACb,KAAK,EAAE,OAAO,CAAC;CAChB;AAED,MAAM,WAAW,wBAAwB;IACvC,OAAO,EAAE;QAAE,IAAI,EAAE,IAAI,CAAC;QAAC,KAAK,EAAE,KAAK,CAAA;KAAE,EAAE,CAAC;CACzC;AAED,MAAM,WAAW,2BAA2B;IAC1C,KAAK,EAAE,IAAI,EAAE,CAAC;CACf;AAED,MAAM,WAAW,0BAA0B;IACzC,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IAC5B,EAAE,CAAC,EAAE,MAAM,CAAC;CACb"}
|
package/lib/state.js
ADDED
package/package.json
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "dreaction-protocol",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"private": false,
|
|
5
|
+
"description": "",
|
|
6
|
+
"main": "lib/index.js",
|
|
7
|
+
"files": [
|
|
8
|
+
"lib",
|
|
9
|
+
"src"
|
|
10
|
+
],
|
|
11
|
+
"keywords": [
|
|
12
|
+
"dreaction"
|
|
13
|
+
],
|
|
14
|
+
"author": "moonrailgun <moonrailgun@gmail.com>",
|
|
15
|
+
"license": "MIT",
|
|
16
|
+
"dependencies": {
|
|
17
|
+
"@types/ws": "^8.5.13",
|
|
18
|
+
"eventemitter-strict": "^1.0.1",
|
|
19
|
+
"ws": "^8.18.0"
|
|
20
|
+
},
|
|
21
|
+
"devDependencies": {
|
|
22
|
+
"@testing-library/dom": "^10.0.0",
|
|
23
|
+
"happy-dom": "15.11.6",
|
|
24
|
+
"msw": "^2.2.13",
|
|
25
|
+
"typescript": "^5.4.5",
|
|
26
|
+
"vitest": "^1.2.1"
|
|
27
|
+
},
|
|
28
|
+
"scripts": {
|
|
29
|
+
"build": "tsc",
|
|
30
|
+
"test": "vitest"
|
|
31
|
+
}
|
|
32
|
+
}
|
package/src/command.ts
ADDED
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
import { DataWatchPayload } from './data';
|
|
2
|
+
import type { LogPayload } from './log';
|
|
3
|
+
import { NetworkPayload } from './network';
|
|
4
|
+
import { EditorOpenPayload } from './openInEditor';
|
|
5
|
+
import type {
|
|
6
|
+
StateActionCompletePayload,
|
|
7
|
+
StateActionDispatchPayload,
|
|
8
|
+
StateBackupRequestPayload,
|
|
9
|
+
StateBackupResponsePayload,
|
|
10
|
+
StateKeysRequestPayload,
|
|
11
|
+
StateKeysResponsePayload,
|
|
12
|
+
StateRestoreRequestPayload,
|
|
13
|
+
StateValuesChangePayload,
|
|
14
|
+
StateValuesRequestPayload,
|
|
15
|
+
StateValuesResponsePayload,
|
|
16
|
+
StateValuesSubscribePayload,
|
|
17
|
+
} from './state';
|
|
18
|
+
|
|
19
|
+
export const CommandType = {
|
|
20
|
+
ApiResponse: 'api.response',
|
|
21
|
+
AsyncStorageMutation: 'asyncStorage.mutation',
|
|
22
|
+
Benchmark: 'benchmark.report',
|
|
23
|
+
ClientIntro: 'client.intro',
|
|
24
|
+
Display: 'display',
|
|
25
|
+
Image: 'image',
|
|
26
|
+
Log: 'log',
|
|
27
|
+
DataWatch: 'dataWatch',
|
|
28
|
+
SagaTaskComplete: 'saga.task.complete',
|
|
29
|
+
StateActionComplete: 'state.action.complete',
|
|
30
|
+
StateKeysResponse: 'state.keys.response',
|
|
31
|
+
StateValuesChange: 'state.values.change',
|
|
32
|
+
StateValuesResponse: 'state.values.response',
|
|
33
|
+
StateBackupResponse: 'state.backup.response',
|
|
34
|
+
StateBackupRequest: 'state.backup.request',
|
|
35
|
+
StateRestoreRequest: 'state.restore.request',
|
|
36
|
+
StateActionDispatch: 'state.action.dispatch',
|
|
37
|
+
StateValuesSubscribe: 'state.values.subscribe',
|
|
38
|
+
StateKeysRequest: 'state.keys.request',
|
|
39
|
+
StateValuesRequest: 'state.values.request',
|
|
40
|
+
CustomCommandRegister: 'customCommand.register',
|
|
41
|
+
CustomCommandUnregister: 'customCommand.unregister',
|
|
42
|
+
Clear: 'clear',
|
|
43
|
+
ReplLsResponse: 'repl.ls.response',
|
|
44
|
+
ReplExecuteResponse: 'repl.execute.response',
|
|
45
|
+
// these technically are commands only in reactotron-react-native, but I felt lazy so they can live here
|
|
46
|
+
DevtoolsOpen: 'devtools.open',
|
|
47
|
+
DevtoolsReload: 'devtools.reload',
|
|
48
|
+
EditorOpen: 'editor.open',
|
|
49
|
+
Storybook: 'storybook',
|
|
50
|
+
Overlay: 'overlay',
|
|
51
|
+
} as const;
|
|
52
|
+
|
|
53
|
+
export type CommandTypeKey = (typeof CommandType)[keyof typeof CommandType];
|
|
54
|
+
|
|
55
|
+
export interface CommandMap {
|
|
56
|
+
[CommandType.ApiResponse]: NetworkPayload;
|
|
57
|
+
[CommandType.AsyncStorageMutation]: any;
|
|
58
|
+
[CommandType.Benchmark]: any;
|
|
59
|
+
[CommandType.ClientIntro]: any;
|
|
60
|
+
[CommandType.Display]: any;
|
|
61
|
+
[CommandType.Image]: any;
|
|
62
|
+
[CommandType.Log]: LogPayload;
|
|
63
|
+
[CommandType.DataWatch]: DataWatchPayload;
|
|
64
|
+
[CommandType.SagaTaskComplete]: any;
|
|
65
|
+
[CommandType.StateActionComplete]: StateActionCompletePayload;
|
|
66
|
+
[CommandType.StateKeysResponse]: StateKeysResponsePayload;
|
|
67
|
+
[CommandType.StateValuesChange]: StateValuesChangePayload;
|
|
68
|
+
[CommandType.StateValuesResponse]: StateValuesResponsePayload;
|
|
69
|
+
[CommandType.StateBackupResponse]: StateBackupResponsePayload;
|
|
70
|
+
[CommandType.StateBackupRequest]: StateBackupRequestPayload;
|
|
71
|
+
[CommandType.StateRestoreRequest]: StateRestoreRequestPayload;
|
|
72
|
+
[CommandType.StateActionDispatch]: StateActionDispatchPayload;
|
|
73
|
+
[CommandType.StateValuesSubscribe]: StateValuesSubscribePayload;
|
|
74
|
+
[CommandType.StateKeysRequest]: StateKeysRequestPayload;
|
|
75
|
+
[CommandType.StateValuesRequest]: StateValuesRequestPayload;
|
|
76
|
+
[CommandType.CustomCommandRegister]: any;
|
|
77
|
+
[CommandType.CustomCommandUnregister]: any;
|
|
78
|
+
[CommandType.Clear]: undefined;
|
|
79
|
+
[CommandType.ReplLsResponse]: any;
|
|
80
|
+
[CommandType.ReplExecuteResponse]: any;
|
|
81
|
+
[CommandType.DevtoolsOpen]: undefined;
|
|
82
|
+
[CommandType.DevtoolsReload]: undefined;
|
|
83
|
+
[CommandType.EditorOpen]: EditorOpenPayload;
|
|
84
|
+
[CommandType.Storybook]: boolean;
|
|
85
|
+
[CommandType.Overlay]: boolean;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
export type Command = {
|
|
89
|
+
[Type in keyof CommandMap]: {
|
|
90
|
+
type: Type;
|
|
91
|
+
connectionId: number;
|
|
92
|
+
clientId?: string;
|
|
93
|
+
date: Date;
|
|
94
|
+
deltaTime: number;
|
|
95
|
+
important: boolean;
|
|
96
|
+
messageId: number;
|
|
97
|
+
payload: CommandMap[Type];
|
|
98
|
+
};
|
|
99
|
+
}[keyof CommandMap];
|
|
100
|
+
|
|
101
|
+
export type CommandEvent = (command: Command) => void;
|
package/src/data.ts
ADDED
package/src/index.ts
ADDED
package/src/log.ts
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
export interface ErrorStackFrame {
|
|
2
|
+
fileName: string;
|
|
3
|
+
functionName: string;
|
|
4
|
+
lineNumber: number;
|
|
5
|
+
columnNumber: number | null;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
export const isErrorStackFrame = (value: unknown): value is ErrorStackFrame =>
|
|
9
|
+
Boolean(
|
|
10
|
+
value &&
|
|
11
|
+
typeof value === 'object' &&
|
|
12
|
+
'fileName' in value &&
|
|
13
|
+
typeof value.fileName === 'string' &&
|
|
14
|
+
'functionName' in value &&
|
|
15
|
+
typeof value.functionName === 'string' &&
|
|
16
|
+
'lineNumber' in value &&
|
|
17
|
+
typeof value.lineNumber === 'number' &&
|
|
18
|
+
('columnNumber' in value
|
|
19
|
+
? value.columnNumber === null || typeof value.columnNumber === 'number'
|
|
20
|
+
: true)
|
|
21
|
+
);
|
|
22
|
+
|
|
23
|
+
export const isErrorStackFrameArray = (
|
|
24
|
+
value: unknown
|
|
25
|
+
): value is ErrorStackFrame[] =>
|
|
26
|
+
Array.isArray(value) && value.every(isErrorStackFrame);
|
|
27
|
+
|
|
28
|
+
export interface ErrorLogPayload {
|
|
29
|
+
level: 'error';
|
|
30
|
+
message: string;
|
|
31
|
+
stack: Error['stack'] | string[] | ErrorStackFrame[];
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export type LogPayload =
|
|
35
|
+
| {
|
|
36
|
+
level: 'debug';
|
|
37
|
+
message: string;
|
|
38
|
+
}
|
|
39
|
+
| {
|
|
40
|
+
level: 'warn';
|
|
41
|
+
message: string;
|
|
42
|
+
}
|
|
43
|
+
| ErrorLogPayload;
|
package/src/network.ts
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export interface NetworkPayload {
|
|
2
|
+
request: {
|
|
3
|
+
url: string;
|
|
4
|
+
method: 'GET' | 'POST' | 'PUT' | 'DELETE' | 'PATCH' | 'OPTIONS';
|
|
5
|
+
data: any;
|
|
6
|
+
headers: Record<string, string>;
|
|
7
|
+
params: any;
|
|
8
|
+
};
|
|
9
|
+
response: {
|
|
10
|
+
status: number;
|
|
11
|
+
headers: Record<string, string>;
|
|
12
|
+
body: any;
|
|
13
|
+
};
|
|
14
|
+
duration: number;
|
|
15
|
+
}
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
import WebSocket from 'ws';
|
|
2
|
+
import { Command } from './command';
|
|
3
|
+
|
|
4
|
+
export interface PfxServerOptions {
|
|
5
|
+
/**
|
|
6
|
+
* Path to a PFX file.
|
|
7
|
+
*/
|
|
8
|
+
pathToPfx: string;
|
|
9
|
+
/**
|
|
10
|
+
* Passphrase, if required, of the PFX file.
|
|
11
|
+
*/
|
|
12
|
+
passphrase?: string;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export interface CertServerOptions {
|
|
16
|
+
/**
|
|
17
|
+
* Path to a signing cert file.
|
|
18
|
+
*/
|
|
19
|
+
pathToCert: string;
|
|
20
|
+
/**
|
|
21
|
+
* Path to a the corresponding key of the cert file.
|
|
22
|
+
*/
|
|
23
|
+
pathToKey: string;
|
|
24
|
+
/**
|
|
25
|
+
* Passphrase, if required, of the key file.
|
|
26
|
+
*/
|
|
27
|
+
passphrase?: string;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export type WssServerOptions = PfxServerOptions | CertServerOptions;
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* Configuration options for the Reactotron server.
|
|
34
|
+
*/
|
|
35
|
+
export interface ServerOptions {
|
|
36
|
+
/**
|
|
37
|
+
* Which port to listen to. Default: 9090.
|
|
38
|
+
*/
|
|
39
|
+
port: number;
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* Web Socket Secure Configuration
|
|
43
|
+
*/
|
|
44
|
+
wss?: WssServerOptions;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* A client which is in the process of connecting.
|
|
49
|
+
*/
|
|
50
|
+
export interface PartialConnection {
|
|
51
|
+
/**
|
|
52
|
+
* The unique id of the client.
|
|
53
|
+
*/
|
|
54
|
+
id: number;
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* The ip address.
|
|
58
|
+
*/
|
|
59
|
+
address: string;
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* The connecting web socket.
|
|
63
|
+
*/
|
|
64
|
+
socket: WebSocket;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* One of the events which be subscribed to.
|
|
69
|
+
*/
|
|
70
|
+
export const ServerEvent = {
|
|
71
|
+
/**
|
|
72
|
+
* When a command arrives from a client.
|
|
73
|
+
*/
|
|
74
|
+
command: 'command',
|
|
75
|
+
/**
|
|
76
|
+
* The server has started.
|
|
77
|
+
*/
|
|
78
|
+
start: 'start',
|
|
79
|
+
/**
|
|
80
|
+
* The server has stopped.
|
|
81
|
+
*/
|
|
82
|
+
stop: 'stop',
|
|
83
|
+
/**
|
|
84
|
+
* A client has connected.
|
|
85
|
+
*/
|
|
86
|
+
connect: 'connect',
|
|
87
|
+
/**
|
|
88
|
+
* A client has connected and provided us the initial detail we want.
|
|
89
|
+
*/
|
|
90
|
+
connectionEstablished: 'connectionEstablished',
|
|
91
|
+
/**
|
|
92
|
+
* A client has disconnected.
|
|
93
|
+
*/
|
|
94
|
+
disconnect: 'disconnect',
|
|
95
|
+
/**
|
|
96
|
+
* Port is already in use
|
|
97
|
+
*/
|
|
98
|
+
portUnavailable: 'portUnavailable',
|
|
99
|
+
} as const;
|
|
100
|
+
|
|
101
|
+
export type ServerEventKey = keyof typeof ServerEvent;
|
|
102
|
+
|
|
103
|
+
type StartPayload = any;
|
|
104
|
+
type StopPayload = any;
|
|
105
|
+
type ConnectPayload = PartialConnection;
|
|
106
|
+
type ConnectionEstablishedPayload = any;
|
|
107
|
+
type DisconnectPayload = any;
|
|
108
|
+
type PortUnavailablePayload = any;
|
|
109
|
+
|
|
110
|
+
export type ServerEventMap = {
|
|
111
|
+
[ServerEvent.command]: Command;
|
|
112
|
+
[ServerEvent.start]: StartPayload;
|
|
113
|
+
[ServerEvent.stop]: StopPayload;
|
|
114
|
+
[ServerEvent.connect]: ConnectPayload;
|
|
115
|
+
[ServerEvent.connectionEstablished]: ConnectionEstablishedPayload;
|
|
116
|
+
[ServerEvent.disconnect]: DisconnectPayload;
|
|
117
|
+
[ServerEvent.portUnavailable]: PortUnavailablePayload;
|
|
118
|
+
};
|
|
119
|
+
|
|
120
|
+
export type WebSocketEvent = (socket: WebSocket) => void;
|
package/src/state.ts
ADDED
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
export interface StateBackupRequestPayload {
|
|
2
|
+
state: Record<string, any>;
|
|
3
|
+
}
|
|
4
|
+
|
|
5
|
+
export interface StateBackupResponsePayload {
|
|
6
|
+
state: Record<string, any>;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export interface StateRestoreRequestPayload {
|
|
10
|
+
state: Record<string, any>;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export interface StateActionDispatchPayload {
|
|
14
|
+
action:
|
|
15
|
+
| {
|
|
16
|
+
type: string;
|
|
17
|
+
payload: Record<string, any>;
|
|
18
|
+
}
|
|
19
|
+
| {
|
|
20
|
+
name: string;
|
|
21
|
+
path?: string;
|
|
22
|
+
args?: any[];
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
type Path = string;
|
|
27
|
+
|
|
28
|
+
type Value = any;
|
|
29
|
+
|
|
30
|
+
export interface StateKeysRequestPayload {
|
|
31
|
+
path: Path;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export interface StateKeysResponsePayload {
|
|
35
|
+
path: Path;
|
|
36
|
+
keys: string[];
|
|
37
|
+
valid: boolean;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
export interface StateValuesRequestPayload {
|
|
41
|
+
path: Path;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
export interface StateValuesResponsePayload {
|
|
45
|
+
path: Path;
|
|
46
|
+
value: Value;
|
|
47
|
+
valid: boolean;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
export interface StateValuesChangePayload {
|
|
51
|
+
changes: { path: Path; value: Value }[];
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
export interface StateValuesSubscribePayload {
|
|
55
|
+
paths: Path[];
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
export interface StateActionCompletePayload {
|
|
59
|
+
name: string;
|
|
60
|
+
action: Record<string, any>;
|
|
61
|
+
ms?: number;
|
|
62
|
+
}
|