@lace-cloud/canvas 0.31.0 → 0.31.2

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.
@@ -13591,6 +13591,36 @@ function withStage(stages, name) {
13591
13591
  function closeStages(stages) {
13592
13592
  return stages.map((s) => s.status === "done" ? s : { ...s, status: "done" });
13593
13593
  }
13594
+ var RECORDED_ENDS = /* @__PURE__ */ new Map([
13595
+ ["apply_succeeded", "succeeded"],
13596
+ ["apply_failed", "failed"],
13597
+ ["policy_blocked", "blocked"],
13598
+ ["cancelled", "cancelled"]
13599
+ ]);
13600
+ function runKind(run, ending) {
13601
+ const recorded = run ? RECORDED_ENDS.get(run.status) : void 0;
13602
+ if (recorded) return recorded;
13603
+ if ("result" in ending) return ending.result.error ? "running" : "succeeded";
13604
+ const { error } = ending;
13605
+ if (error instanceof CommandDetachedError || error instanceof CommandUnobservedError)
13606
+ return "detached";
13607
+ if (error instanceof CommandExitError) {
13608
+ if (error.code === 130) return run ? "detached" : "cancelled";
13609
+ if (error.code === 143) return "detached";
13610
+ if (error.code === 7) return "blocked";
13611
+ }
13612
+ return "failed";
13613
+ }
13614
+ function endSays(ending) {
13615
+ if ("error" in ending) return failureSays(ending.error);
13616
+ const { run, error } = ending.result;
13617
+ return { message: run.errorMessage ?? error ?? run.status };
13618
+ }
13619
+ function outcomeOf(end, ending, submitted) {
13620
+ if (end === "blocked" || end === "failed") return { kind: end, ...endSays(ending) };
13621
+ if (end === "detached") return { kind: end, submitted };
13622
+ return { kind: end };
13623
+ }
13594
13624
  function reduceRun(prev, token, event) {
13595
13625
  const carried = prev && prev.token === token ? prev : null;
13596
13626
  const run = event.type === "result" ? event.run : carried?.run ?? null;
@@ -13618,10 +13648,12 @@ function reduceRun(prev, token, event) {
13618
13648
  stages
13619
13649
  };
13620
13650
  }
13621
- if (!event.error)
13651
+ const ending = { result: event };
13652
+ const kind = runKind(run, ending);
13653
+ if (kind !== "running")
13622
13654
  return {
13623
13655
  token,
13624
- outcome: { kind: "succeeded" },
13656
+ outcome: outcomeOf(kind, ending, submitted),
13625
13657
  run,
13626
13658
  lastLog,
13627
13659
  submitted,
@@ -13653,31 +13685,9 @@ function settleRun(prev, token, error) {
13653
13685
  const lastLog = carried?.lastLog ?? null;
13654
13686
  const submitted = carried?.submitted ?? false;
13655
13687
  const stages = closeStages(carried?.stages ?? []);
13656
- if (error instanceof CommandDetachedError || error instanceof CommandUnobservedError)
13657
- return { token, outcome: { kind: "detached", submitted }, run, lastLog, submitted, stages };
13658
- if (error instanceof CommandExitError) {
13659
- if (error.code === 130)
13660
- return { token, outcome: { kind: "cancelled" }, run, lastLog, submitted, stages };
13661
- if (error.code === 143)
13662
- return { token, outcome: { kind: "detached", submitted }, run, lastLog, submitted, stages };
13663
- if (error.code === 7)
13664
- return {
13665
- token,
13666
- outcome: { kind: "blocked", ...failureSays(error) },
13667
- run,
13668
- lastLog,
13669
- submitted,
13670
- stages
13671
- };
13672
- }
13673
- return {
13674
- token,
13675
- outcome: { kind: "failed", ...failureSays(error) },
13676
- run,
13677
- lastLog,
13678
- submitted,
13679
- stages
13680
- };
13688
+ const ending = { error };
13689
+ const outcome = outcomeOf(runKind(run, ending), ending, submitted);
13690
+ return { token, outcome, run, lastLog, submitted, stages };
13681
13691
  }
13682
13692
  function reducePreview(_prev, token, event) {
13683
13693
  return { token, outcome: { kind: "succeeded", data: event } };
@@ -13878,6 +13888,10 @@ function lockfileOf(lock2) {
13878
13888
  function lockedIn(lock2) {
13879
13889
  return `${counted(lock2.providers.length, "provider")} in ${lockfileOf(lock2)}`;
13880
13890
  }
13891
+ function lockNotice(lock2) {
13892
+ return `Locked ${lockedIn(lock2)}. Commit it beside the tree.`;
13893
+ }
13894
+ var LOCK_LABEL = "Lock providers";
13881
13895
  function listed(parts) {
13882
13896
  return parts.length < 2 ? parts.join("") : `${parts.slice(0, -1).join(", ")} and ${parts.at(-1)}`;
13883
13897
  }
@@ -14042,10 +14056,7 @@ var lock = defineCommand({
14042
14056
  args: () => ({}),
14043
14057
  result: {
14044
14058
  kind: "notify",
14045
- consume: (rt, e) => rt.ports.presenter.notify(
14046
- "info",
14047
- `Locked ${lockedIn(e)}. Commit it beside the tree, then run the command again.`
14048
- )
14059
+ consume: (rt, e) => rt.ports.presenter.notify("info", `${lockNotice(e)} Then run the refused command again.`)
14049
14060
  }
14050
14061
  });
14051
14062
  var preview = defineCommand({
@@ -14170,7 +14181,7 @@ var STACK_COMMAND_ACTIONS = [
14170
14181
  // writes it.
14171
14182
  {
14172
14183
  id: "lock-missing",
14173
- label: "Lock providers",
14184
+ label: LOCK_LABEL,
14174
14185
  placement: { row: "failure" },
14175
14186
  requiredPorts: ["commands"],
14176
14187
  requiredContext: ["root"],
@@ -14864,6 +14875,12 @@ export {
14864
14875
  reduceFollow,
14865
14876
  createResultStore,
14866
14877
  defineCommand,
14878
+ lockFailed,
14879
+ DID_NOT_LOCK,
14880
+ lockfileOf,
14881
+ lockedIn,
14882
+ lockNotice,
14883
+ LOCK_LABEL,
14867
14884
  MODULE_COMMAND_ACTIONS,
14868
14885
  CORE_COMMAND_ACTIONS,
14869
14886
  isPlainObject,
@@ -14876,4 +14893,4 @@ export {
14876
14893
  AutosaveEndedError,
14877
14894
  autosave
14878
14895
  };
14879
- //# sourceMappingURL=chunk-MVOO7T3B.mjs.map
14896
+ //# sourceMappingURL=chunk-PABP6EXP.mjs.map