设计tracer
This commit is contained in:
@@ -21,6 +21,6 @@ export class Commander {
|
||||
}
|
||||
|
||||
public output() {
|
||||
return this.commands;
|
||||
return JSON.stringify(this.commands);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,7 +20,7 @@ export class ArrayTracer<T> {
|
||||
commander.command({
|
||||
action: "define",
|
||||
tracer: null,
|
||||
params: {
|
||||
payload: {
|
||||
type: "ArrayTracer",
|
||||
id: arrayTracer.tracerId,
|
||||
desc: option.description,
|
||||
@@ -34,7 +34,7 @@ export class ArrayTracer<T> {
|
||||
commander.command({
|
||||
action: "preset",
|
||||
tracer: this.tracerId,
|
||||
params: array,
|
||||
payload: array,
|
||||
});
|
||||
}
|
||||
|
||||
@@ -43,7 +43,7 @@ export class ArrayTracer<T> {
|
||||
commander.command({
|
||||
action: "extend",
|
||||
tracer: this.tracerId,
|
||||
params: { size },
|
||||
payload: { size },
|
||||
});
|
||||
}
|
||||
|
||||
@@ -52,7 +52,7 @@ export class ArrayTracer<T> {
|
||||
commander.command({
|
||||
action: "shrink",
|
||||
tracer: this.tracerId,
|
||||
params: { size },
|
||||
payload: { size },
|
||||
});
|
||||
}
|
||||
|
||||
@@ -61,7 +61,7 @@ export class ArrayTracer<T> {
|
||||
commander.command({
|
||||
action: "pick",
|
||||
tracer: this.tracerId,
|
||||
params: { index },
|
||||
payload: { index },
|
||||
});
|
||||
}
|
||||
|
||||
@@ -70,7 +70,7 @@ export class ArrayTracer<T> {
|
||||
commander.command({
|
||||
action: "drop",
|
||||
tracer: this.tracerId,
|
||||
params: { index },
|
||||
payload: { index },
|
||||
});
|
||||
}
|
||||
|
||||
@@ -79,7 +79,7 @@ export class ArrayTracer<T> {
|
||||
commander.command({
|
||||
action: "patch",
|
||||
tracer: this.tracerId,
|
||||
params: { index, value },
|
||||
payload: { index, value },
|
||||
});
|
||||
}
|
||||
|
||||
@@ -88,7 +88,7 @@ export class ArrayTracer<T> {
|
||||
commander.command({
|
||||
action: "reset",
|
||||
tracer: this.tracerId,
|
||||
params: { index },
|
||||
payload: { index },
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,49 +1,49 @@
|
||||
export type ArrayTracerDefineCommand = {
|
||||
action: "define";
|
||||
tracer: null;
|
||||
params: { type: "ArrayTracer"; id: string; desc?: string };
|
||||
payload: { type: "ArrayTracer"; id: string; desc?: string };
|
||||
};
|
||||
|
||||
export type ArrayTracerPresetCommand<T = unknown> = {
|
||||
action: "preset";
|
||||
tracer: string;
|
||||
params: T[];
|
||||
payload: T[];
|
||||
};
|
||||
|
||||
export type ArrayTracerExtendCommand = {
|
||||
action: "extend";
|
||||
tracer: string;
|
||||
params: { size: number };
|
||||
payload: { size: number };
|
||||
};
|
||||
|
||||
export type ArrayTracerShrinkCommand = {
|
||||
action: "shrink";
|
||||
tracer: string;
|
||||
params: { size: number };
|
||||
payload: { size: number };
|
||||
};
|
||||
|
||||
export type ArrayTracerPickCommand = {
|
||||
action: "pick";
|
||||
tracer: string;
|
||||
params: { index: number };
|
||||
payload: { index: number };
|
||||
};
|
||||
|
||||
export type ArrayTracerDropCommand = {
|
||||
action: "drop";
|
||||
tracer: string;
|
||||
params: { index: number };
|
||||
payload: { index: number };
|
||||
};
|
||||
|
||||
export type ArrayTracerPatchCommand<T = unknown> = {
|
||||
action: "patch";
|
||||
tracer: string;
|
||||
params: { index: number; value: T };
|
||||
payload: { index: number; value: T };
|
||||
};
|
||||
|
||||
export type ArrayTracerResetCommand = {
|
||||
action: "reset";
|
||||
tracer: string;
|
||||
params: { index: number };
|
||||
payload: { index: number };
|
||||
};
|
||||
|
||||
export type ArrayTracerCommand<T = never> =
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import type { ArrayTracerDefineCommand } from "../command";
|
||||
|
||||
type ArrayTracer = ArrayTracerDefineCommand["params"]["type"];
|
||||
type ArrayTracer = ArrayTracerDefineCommand["payload"]["type"];
|
||||
|
||||
export type TracerType = ArrayTracer;
|
||||
|
||||
Reference in New Issue
Block a user