Next Iteration
This commit is contained in:
39
shared/src/contract.ts
Normal file
39
shared/src/contract.ts
Normal file
@@ -0,0 +1,39 @@
|
||||
import { contract, notificationContract, types } from "@hediet/typed-json-rpc";
|
||||
import { DataExtractionResult } from "@hediet/debug-visualizer-data-extraction";
|
||||
|
||||
function unchecked<T>(): types.Type<T, T, unknown> {
|
||||
return new types.Type<T, T, unknown>(
|
||||
"unchecked",
|
||||
(u): u is T => true,
|
||||
value => types.success(value as T),
|
||||
value => value
|
||||
);
|
||||
}
|
||||
|
||||
export type DataExtractionState =
|
||||
| { kind: "loading" }
|
||||
| { kind: "error"; message: string }
|
||||
| { kind: "noDebugSession" }
|
||||
| {
|
||||
kind: "data";
|
||||
result: DataExtractionResult;
|
||||
};
|
||||
|
||||
export const debugVisualizerUIContract = contract({
|
||||
client: {
|
||||
updateState: notificationContract({
|
||||
params: types.type({
|
||||
newState: unchecked<DataExtractionState>(),
|
||||
}),
|
||||
}),
|
||||
},
|
||||
server: {
|
||||
setExpression: notificationContract({
|
||||
params: types.type({
|
||||
newExpression: types.string,
|
||||
}),
|
||||
}),
|
||||
refresh: notificationContract({}),
|
||||
openInBrowser: notificationContract({}),
|
||||
},
|
||||
});
|
||||
1
shared/src/index.ts
Normal file
1
shared/src/index.ts
Normal file
@@ -0,0 +1 @@
|
||||
export * from "./contract";
|
||||
Reference in New Issue
Block a user