设计tracer

This commit is contained in:
2025-11-10 02:49:58 +08:00
parent 9c99af4781
commit 8f5493eaf0
2 changed files with 51 additions and 9 deletions

View File

@@ -21,8 +21,8 @@ export class ArrayTracer<T> {
registry.register("ArrayTracer", arrayTracer.tracerId);
const commander = Commander.getInstance();
commander.command({
tracer: null,
action: "define",
tracer: null,
params: {
type: "ArrayTracer",
id: arrayTracer.tracerId,
@@ -35,21 +35,63 @@ export class ArrayTracer<T> {
public preset(array: T[]) {
const commander = Commander.getInstance();
commander.command({
tracer: this.tracerId,
action: "preset",
tracer: this.tracerId,
params: array,
});
}
public extend(size: number) {}
public extend(size: number) {
const commander = Commander.getInstance();
commander.command({
action: "extend",
tracer: this.tracerId,
params: { size },
});
}
public shrink(size: number) {}
public shrink(size: number) {
const commander = Commander.getInstance();
commander.command({
action: "shrink",
tracer: this.tracerId,
params: { size },
});
}
public pick(index: number) {}
public pick(index: number) {
const commander = Commander.getInstance();
commander.command({
action: "pick",
tracer: this.tracerId,
params: { index },
});
}
public drop(index: number) {}
public drop(index: number) {
const commander = Commander.getInstance();
commander.command({
action: "drop",
tracer: this.tracerId,
params: { index },
});
}
public patch(index: number, value: T) {}
public patch(index: number, value: T) {
const commander = Commander.getInstance();
commander.command({
action: "patch",
tracer: this.tracerId,
params: { index, value },
});
}
public reset(index: number) {}
public reset(index: number) {
const commander = Commander.getInstance();
commander.command({
action: "reset",
tracer: this.tracerId,
params: { index },
});
}
}

View File

@@ -43,7 +43,7 @@ export type ArrayTracerPatchCommand<T = unknown> = {
export type ArrayTracerResetCommand = {
action: "reset";
tracer: string;
params: null;
params: { index: number };
};
export type ArrayTracerCommand<T = never> =