@mica-js/editor 0.8.4 → 0.9.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/dist/fused.d.ts CHANGED
@@ -375,6 +375,8 @@ export declare interface IWorkbenchCommandMap {
375
375
  'simulation.pause': IWorkbenchCommand;
376
376
  /** Host-only resume of the mounted run session; no-op when already running. */
377
377
  'simulation.resume': IWorkbenchCommand;
378
+ /** Host-only restart of the mounted run session: rebuilds the models, then advances. */
379
+ 'simulation.restart': IWorkbenchCommand;
378
380
  'canvas.fit': IWorkbenchCommand;
379
381
  'canvas.zoom': IWorkbenchCommand<{
380
382
  readonly factor: number;
package/dist/fused.js CHANGED
@@ -3264,6 +3264,11 @@ function createSimulationControl(onDidChangeStatus) {
3264
3264
  await active.resume();
3265
3265
  if (runtime === active && !closed) publish(active.getState().status);
3266
3266
  },
3267
+ async restart() {
3268
+ const active = requireSession("restart");
3269
+ await active.reset();
3270
+ if (runtime === active && !closed) publish(active.getState().status);
3271
+ },
3267
3272
  dispose() {
3268
3273
  if (closed) return;
3269
3274
  closed = true;
@@ -4484,8 +4489,6 @@ function ToolbarPart(props) {
4484
4489
  const visible = items.slice(0, layout.count);
4485
4490
  const overflow = items.slice(layout.count);
4486
4491
  const runMode = props.state.mode === "run";
4487
- const paused = props.state.simulationStatus === "paused";
4488
- const canControl = !runMode || paused || props.state.simulationStatus === "running";
4489
4492
  const control = (action) => {
4490
4493
  setMore(false);
4491
4494
  setControlling(true);
@@ -4546,14 +4549,14 @@ function ToolbarPart(props) {
4546
4549
  "aria-label": "仿真控制",
4547
4550
  children: [/* @__PURE__ */ jsxs("button", {
4548
4551
  className: "is-primary",
4549
- disabled: props.state.busy || controlling || !canControl,
4550
- onClick: () => control(() => !runMode ? props.context.workbench.setMode("run") : props.context.workbench.executeCommand(paused ? "simulation.resume" : "simulation.pause")),
4551
- children: [/* @__PURE__ */ jsx(Icon, { name: runMode && !paused ? "debug-pause" : "play" }), runMode ? paused ? "继续" : "暂停" : "运行"]
4552
+ disabled: props.state.busy || controlling,
4553
+ onClick: () => control(() => props.context.workbench.setMode(runMode ? "edit" : "run")),
4554
+ children: [/* @__PURE__ */ jsx(Icon, { name: runMode ? "debug-stop" : "play" }), runMode ? "停止" : "运行"]
4552
4555
  }), runMode && /* @__PURE__ */ jsxs("button", {
4553
4556
  disabled: props.state.busy || controlling,
4554
- title: "结束仿真并返回编辑",
4555
- onClick: () => control(() => props.context.workbench.setMode("edit")),
4556
- children: [/* @__PURE__ */ jsx(Icon, { name: "debug-restart" }), "复位"]
4557
+ title: "重启仿真",
4558
+ onClick: () => control(() => props.context.workbench.executeCommand("simulation.restart")),
4559
+ children: [/* @__PURE__ */ jsx(Icon, { name: "debug-restart" }), "重启"]
4557
4560
  })]
4558
4561
  }),
4559
4562
  items.length > 0 && /* @__PURE__ */ jsxs(Fragment, { children: [
@@ -6717,6 +6720,7 @@ async function createWorkbench(options) {
6717
6720
  "workbench.setMode": ({ mode }) => setMode(mode),
6718
6721
  "simulation.pause": () => controlSimulation("pause"),
6719
6722
  "simulation.resume": () => controlSimulation("resume"),
6723
+ "simulation.restart": () => controlSimulation("restart"),
6720
6724
  "canvas.fit": async () => {
6721
6725
  canvas?.fit();
6722
6726
  },