@lace-cloud/canvas 0.36.0 → 0.37.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.
@@ -71,7 +71,9 @@ __export(engine_exports, {
71
71
  settleRun: () => settleRun,
72
72
  stackSlugRule: () => stackSlugRule,
73
73
  toArgv: () => toArgv,
74
- uniqueDiagnostics: () => uniqueDiagnostics
74
+ uniqueDiagnostics: () => uniqueDiagnostics,
75
+ wireEnd: () => wireEnd,
76
+ wireEndText: () => wireEndText
75
77
  });
76
78
  module.exports = __toCommonJS(engine_exports);
77
79
 
@@ -569,6 +571,7 @@ var Reason = /* @__PURE__ */ ((Reason3) => {
569
571
  Reason3[Reason3["REASON_IMPORT_UNDECLARED"] = 20] = "REASON_IMPORT_UNDECLARED";
570
572
  Reason3[Reason3["REASON_ALREADY_IMPORTED"] = 21] = "REASON_ALREADY_IMPORTED";
571
573
  Reason3[Reason3["REASON_NO_LOCKFILE"] = 22] = "REASON_NO_LOCKFILE";
574
+ Reason3[Reason3["REASON_NO_COMMIT"] = 23] = "REASON_NO_COMMIT";
572
575
  Reason3[Reason3["UNRECOGNIZED"] = -1] = "UNRECOGNIZED";
573
576
  return Reason3;
574
577
  })(Reason || {});
@@ -643,6 +646,9 @@ function reasonFromJSON(object) {
643
646
  case 22:
644
647
  case "REASON_NO_LOCKFILE":
645
648
  return 22 /* REASON_NO_LOCKFILE */;
649
+ case 23:
650
+ case "REASON_NO_COMMIT":
651
+ return 23 /* REASON_NO_COMMIT */;
646
652
  case -1:
647
653
  case "UNRECOGNIZED":
648
654
  default:
@@ -697,6 +703,8 @@ function reasonToJSON(object) {
697
703
  return "REASON_ALREADY_IMPORTED";
698
704
  case 22 /* REASON_NO_LOCKFILE */:
699
705
  return "REASON_NO_LOCKFILE";
706
+ case 23 /* REASON_NO_COMMIT */:
707
+ return "REASON_NO_COMMIT";
700
708
  case -1 /* UNRECOGNIZED */:
701
709
  default:
702
710
  return "UNRECOGNIZED";
@@ -9377,7 +9385,7 @@ var BundleApplyResult = {
9377
9385
  }
9378
9386
  };
9379
9387
  function createBaseCreatedRef() {
9380
- return { scope: "", id: "", module_key: "", source_id: "" };
9388
+ return { scope: "", id: "", module_key: "", source_id: "", group_id: "" };
9381
9389
  }
9382
9390
  var CreatedRef = {
9383
9391
  encode(message, writer = new import_wire4.BinaryWriter()) {
@@ -9393,6 +9401,9 @@ var CreatedRef = {
9393
9401
  if (message.source_id !== "") {
9394
9402
  writer.uint32(34).string(message.source_id);
9395
9403
  }
9404
+ if (message.group_id !== "") {
9405
+ writer.uint32(42).string(message.group_id);
9406
+ }
9396
9407
  return writer;
9397
9408
  },
9398
9409
  decode(input, length) {
@@ -9430,6 +9441,13 @@ var CreatedRef = {
9430
9441
  message.source_id = reader.string();
9431
9442
  continue;
9432
9443
  }
9444
+ case 5: {
9445
+ if (tag !== 42) {
9446
+ break;
9447
+ }
9448
+ message.group_id = reader.string();
9449
+ continue;
9450
+ }
9433
9451
  }
9434
9452
  if ((tag & 7) === 4 || tag === 0) {
9435
9453
  break;
@@ -9443,7 +9461,8 @@ var CreatedRef = {
9443
9461
  scope: isSet3(object.scope) ? globalThis.String(object.scope) : "",
9444
9462
  id: isSet3(object.id) ? globalThis.String(object.id) : "",
9445
9463
  module_key: isSet3(object.moduleKey) ? globalThis.String(object.moduleKey) : isSet3(object.module_key) ? globalThis.String(object.module_key) : "",
9446
- source_id: isSet3(object.sourceId) ? globalThis.String(object.sourceId) : isSet3(object.source_id) ? globalThis.String(object.source_id) : ""
9464
+ source_id: isSet3(object.sourceId) ? globalThis.String(object.sourceId) : isSet3(object.source_id) ? globalThis.String(object.source_id) : "",
9465
+ group_id: isSet3(object.groupId) ? globalThis.String(object.groupId) : isSet3(object.group_id) ? globalThis.String(object.group_id) : ""
9447
9466
  };
9448
9467
  },
9449
9468
  toJSON(message) {
@@ -9460,6 +9479,9 @@ var CreatedRef = {
9460
9479
  if (message.source_id !== "") {
9461
9480
  obj.sourceId = message.source_id;
9462
9481
  }
9482
+ if (message.group_id !== "") {
9483
+ obj.groupId = message.group_id;
9484
+ }
9463
9485
  return obj;
9464
9486
  },
9465
9487
  create(base) {
@@ -9471,6 +9493,7 @@ var CreatedRef = {
9471
9493
  message.id = object.id ?? "";
9472
9494
  message.module_key = object.module_key ?? "";
9473
9495
  message.source_id = object.source_id ?? "";
9496
+ message.group_id = object.group_id ?? "";
9474
9497
  return message;
9475
9498
  }
9476
9499
  };
@@ -12332,6 +12355,27 @@ var COMMANDS = {
12332
12355
  "hidden": false,
12333
12356
  "yes": false
12334
12357
  },
12358
+ "stack validate": {
12359
+ "path": "stack validate",
12360
+ "positionals": [],
12361
+ "flags": {
12362
+ "output": {
12363
+ "type": "string",
12364
+ "values": [
12365
+ "table",
12366
+ "json"
12367
+ ],
12368
+ "short": "o"
12369
+ },
12370
+ "source": {
12371
+ "type": "string",
12372
+ "required": true
12373
+ }
12374
+ },
12375
+ "effect": "read",
12376
+ "hidden": false,
12377
+ "yes": false
12378
+ },
12335
12379
  "team current": {
12336
12380
  "path": "team current",
12337
12381
  "positionals": [],
@@ -13140,6 +13184,7 @@ var SCHEMAS = {
13140
13184
  "stack destroy": runEventSchema,
13141
13185
  "drift scan": driftScanSchema,
13142
13186
  "stack create": stackSchema,
13187
+ "stack validate": stackSourceSchema,
13143
13188
  "module import": moduleImportSchema,
13144
13189
  "run get": runSchema,
13145
13190
  "run plan": runPlanSchema,
@@ -13565,7 +13610,13 @@ function convertGraphError(e) {
13565
13610
  };
13566
13611
  }
13567
13612
  function convertCreatedRef(r) {
13568
- return { scope: r.scope, id: r.id, moduleKey: r.module_key, sourceId: r.source_id };
13613
+ return {
13614
+ scope: r.scope,
13615
+ id: r.id,
13616
+ moduleKey: r.module_key,
13617
+ sourceId: r.source_id,
13618
+ groupId: r.group_id
13619
+ };
13569
13620
  }
13570
13621
 
13571
13622
  // src/utils/counted.ts
@@ -13806,6 +13857,14 @@ function failureSays(error) {
13806
13857
  }
13807
13858
  return { message: error instanceof Error ? error.message : String(error) };
13808
13859
  }
13860
+ function notifyFailure(presenter, error, label) {
13861
+ const { message, failure } = failureSays(error);
13862
+ presenter.notify(
13863
+ "error",
13864
+ label ? `${label}: ${message}` : message,
13865
+ ...failure ? [failure] : []
13866
+ );
13867
+ }
13809
13868
  function settleRun(prev, token, error) {
13810
13869
  const carried = prev && prev.token === token ? prev : null;
13811
13870
  const run = carried?.run ?? null;
@@ -13950,6 +14009,7 @@ function defineCommand(binding) {
13950
14009
  kind: "command",
13951
14010
  path: binding.path,
13952
14011
  confirms: binding.confirm !== void 0,
14012
+ preflightPath: binding.preflight?.path,
13953
14013
  resultKind: binding.result.kind,
13954
14014
  invalidates: binding.invalidates,
13955
14015
  partialArgs(ctx, target) {
@@ -13961,6 +14021,24 @@ function defineCommand(binding) {
13961
14021
  if (!merged.ok) return void 0;
13962
14022
  return binding.confirm(ctx, merged.args, target);
13963
14023
  },
14024
+ async preflight(rt, ctx, target, signal) {
14025
+ const commands = rt.ports.commands;
14026
+ if (!binding.preflight || !commands) return true;
14027
+ const { path, args } = binding.preflight;
14028
+ const merged = completeArgs(path, args(ctx, target));
14029
+ if (!merged.ok) return true;
14030
+ try {
14031
+ const events = commands.invoke(path, merged.args, signal, rt.cwd).events;
14032
+ const read = events[Symbol.asyncIterator]();
14033
+ let step = await read.next();
14034
+ while (!step.done) step = await read.next();
14035
+ return true;
14036
+ } catch (err) {
14037
+ if (err instanceof CommandDetachedError) return false;
14038
+ notifyFailure(rt.ports.presenter, err);
14039
+ return false;
14040
+ }
14041
+ },
13964
14042
  async start(rt, ctx, target, formArgs, signal) {
13965
14043
  const merged = completeArgs(binding.path, { ...binding.args(ctx, target), ...formArgs });
13966
14044
  if (!merged.ok) return null;
@@ -13980,8 +14058,7 @@ function defineCommand(binding) {
13980
14058
  } catch (err) {
13981
14059
  const settledByDocument = rendered && binding.result.kind === "notify" && (err instanceof CommandExitError || err instanceof CommandUnobservedError);
13982
14060
  if (!rt.fail(err) && !(err instanceof CommandDetachedError) && !settledByDocument) {
13983
- const { message, failure } = failureSays(err);
13984
- rt.ports.presenter.notify("error", message, ...failure ? [failure] : []);
14061
+ notifyFailure(rt.ports.presenter, err);
13985
14062
  }
13986
14063
  if (binding.invalidates) rt.tick();
13987
14064
  } finally {
@@ -14088,6 +14165,7 @@ var create = defineCommand({
14088
14165
  kind: "command",
14089
14166
  path: "stack create",
14090
14167
  args: (ctx) => ({ source: ctx.root }),
14168
+ preflight: { path: "stack validate", args: (ctx) => ({ source: ctx.root }) },
14091
14169
  invalidates: true,
14092
14170
  result: {
14093
14171
  kind: "notify",
@@ -14371,6 +14449,11 @@ function inEntryScope(view, ids) {
14371
14449
  return ids.filter((id) => entry.has(id));
14372
14450
  }
14373
14451
 
14452
+ // src/utils/handleId.ts
14453
+ function isDisconnectable(e) {
14454
+ return !e.target_pin;
14455
+ }
14456
+
14374
14457
  // src/registry.ts
14375
14458
  var CONTEXT_NEEDS = {
14376
14459
  root: "an authoring root",
@@ -14389,6 +14472,7 @@ var CONTEXT_NEEDS = {
14389
14472
  "selection.oneScope": "selected nodes that share one scope",
14390
14473
  "selection.edge": "one selected connection",
14391
14474
  "selection.edges": "selected connections",
14475
+ "selection.disconnectable": "a selected connection that feeds an input",
14392
14476
  diagnostics: "diagnostics to show",
14393
14477
  settingsOpen: "the settings panel open",
14394
14478
  generateIdle: "no Generate running",
@@ -14442,6 +14526,10 @@ function keySatisfied(ctx, key) {
14442
14526
  return ctx.view !== void 0 && ctx.selection !== void 0 && inOneScope(ctx.view, ctx.selection.nodes);
14443
14527
  if (key === "selection.edge") return wiresAlone(ctx) === 1;
14444
14528
  if (key === "selection.edges") return wiresAlone(ctx) > 0;
14529
+ if (key === "selection.disconnectable")
14530
+ return wiresAlone(ctx) > 0 && (ctx.view?.edges ?? []).some(
14531
+ (e) => ctx.selection?.edges.includes(e.id) && isDisconnectable(e)
14532
+ );
14445
14533
  if (key === "diagnostics") return ctx.diagnostics !== void 0 && ctx.diagnostics.length > 0;
14446
14534
  if (key === "settingsOpen") return ctx.settingsOpen === true;
14447
14535
  if (key === "generateIdle") return ctx.generating === false;
@@ -14498,8 +14586,13 @@ function unmetRequirement(action, ports, ctx, target) {
14498
14586
  if (target.failure === void 0) return `${label} needs ${TARGET_NEEDS.failure}`;
14499
14587
  if (!answersFailure(action, target.failure)) return `${label} does not answer this failure`;
14500
14588
  }
14501
- if (binding.kind === "command" && !availableCommands(ports).has(binding.path)) {
14502
- return `${label} runs lace ${binding.path}, which this host does not route`;
14589
+ if (binding.kind === "command") {
14590
+ const available = availableCommands(ports);
14591
+ for (const path of [binding.path, binding.preflightPath]) {
14592
+ if (path !== void 0 && !available.has(path)) {
14593
+ return `${label} runs lace ${path}, which this host does not route`;
14594
+ }
14595
+ }
14503
14596
  }
14504
14597
  return void 0;
14505
14598
  }
@@ -14537,6 +14630,8 @@ function createActionRunner(ports, store, options = {}) {
14537
14630
  const tokens = /* @__PURE__ */ new Map();
14538
14631
  const clipboard = createClipboardStore();
14539
14632
  const notifyControllers = /* @__PURE__ */ new Map();
14633
+ const preflighting = /* @__PURE__ */ new Set();
14634
+ const preflightControllers = /* @__PURE__ */ new Set();
14540
14635
  let edits = 0;
14541
14636
  const editingListeners = /* @__PURE__ */ new Set();
14542
14637
  const tickListeners = /* @__PURE__ */ new Set();
@@ -14611,6 +14706,15 @@ function createActionRunner(ports, store, options = {}) {
14611
14706
  settled: onSettle
14612
14707
  };
14613
14708
  }
14709
+ function invocationOf(action, binding, ctx, target, on) {
14710
+ const token = {};
14711
+ const run = { token, path: binding.path, resultKind: binding.resultKind, ctx, target };
14712
+ const started = { target, on, path: binding.path, label: action.label };
14713
+ return {
14714
+ token,
14715
+ runtime: (onSettle) => runtimeFor(token, readOverOf(ctx), cwdOf(action, ctx), { run, started }, onSettle)
14716
+ };
14717
+ }
14614
14718
  function readOverOf(ctx) {
14615
14719
  return { stack: ctx.stack?.id };
14616
14720
  }
@@ -14643,7 +14747,7 @@ function createActionRunner(ports, store, options = {}) {
14643
14747
  }
14644
14748
  function tellFailure(error) {
14645
14749
  if (error instanceof CommandDetachedError) return;
14646
- ports.presenter.notify("error", error instanceof Error ? error.message : String(error));
14750
+ notifyFailure(ports.presenter, error);
14647
14751
  }
14648
14752
  async function startCommand(action, ctx, target, formArgs) {
14649
14753
  const binding = action.binding;
@@ -14655,16 +14759,12 @@ function createActionRunner(ports, store, options = {}) {
14655
14759
  ports.presenter.notify("warn", busyReason(busy));
14656
14760
  return;
14657
14761
  }
14658
- const readOver = readOverOf(ctx);
14659
- const cwd = cwdOf(action, ctx);
14660
- const token = {};
14661
- const run = { token, path: binding.path, resultKind: binding.resultKind, ctx, target };
14662
- const started = { target, on, path: binding.path, label: action.label };
14762
+ const { token, runtime } = invocationOf(action, binding, ctx, target, on);
14663
14763
  const controller = new AbortController();
14664
14764
  if (binding.resultKind === "notify") {
14665
14765
  notifyControllers.set(controller, token);
14666
14766
  await binding.start(
14667
- runtimeFor(token, readOver, cwd, { run, started }, () => {
14767
+ runtime(() => {
14668
14768
  notifyControllers.delete(controller);
14669
14769
  store.detach("notify", token);
14670
14770
  }),
@@ -14678,18 +14778,33 @@ function createActionRunner(ports, store, options = {}) {
14678
14778
  detachSlot(binding.resultKind);
14679
14779
  controllers.set(binding.resultKind, controller);
14680
14780
  tokens.set(binding.resultKind, token);
14681
- const handle = await binding.start(
14682
- runtimeFor(token, readOver, cwd, { run, started }),
14683
- ctx,
14684
- target,
14685
- formArgs,
14686
- controller.signal
14687
- );
14781
+ const handle = await binding.start(runtime(), ctx, target, formArgs, controller.signal);
14688
14782
  if (handle) handles.set(binding.resultKind, handle);
14689
14783
  }
14690
14784
  async function runCommand(action, ctx, target) {
14691
14785
  const binding = action.binding;
14692
14786
  if (binding.kind !== "command") return;
14787
+ if (binding.preflightPath !== void 0) {
14788
+ if (preflighting.has(action.id)) return;
14789
+ preflighting.add(action.id);
14790
+ const { token, runtime } = invocationOf(
14791
+ action,
14792
+ binding,
14793
+ ctx,
14794
+ target,
14795
+ runsOn(action, ctx, target)
14796
+ );
14797
+ const rt = runtime(() => store.detach("notify", token));
14798
+ const controller = new AbortController();
14799
+ preflightControllers.add(controller);
14800
+ if (binding.resultKind === "notify") rt.begin();
14801
+ const proceed = await binding.preflight(rt, ctx, target, controller.signal).finally(() => {
14802
+ if (binding.resultKind === "notify") rt.settled?.();
14803
+ preflighting.delete(action.id);
14804
+ preflightControllers.delete(controller);
14805
+ });
14806
+ if (!proceed) return;
14807
+ }
14693
14808
  const completion = completeArgs(binding.path, binding.partialArgs(ctx, target));
14694
14809
  if (!completion.ok) {
14695
14810
  if (!options.onPendingFormChange) {
@@ -14725,6 +14840,7 @@ function createActionRunner(ports, store, options = {}) {
14725
14840
  ctx,
14726
14841
  target,
14727
14842
  clipboard,
14843
+ dissolved: options.onDissolved,
14728
14844
  ...envExtras
14729
14845
  };
14730
14846
  if (binding.result === "apply") {
@@ -14822,6 +14938,7 @@ function createActionRunner(ports, store, options = {}) {
14822
14938
  store.detach("notify", token);
14823
14939
  }
14824
14940
  notifyControllers.clear();
14941
+ for (const controller of preflightControllers) controller.abort();
14825
14942
  tickListeners.clear();
14826
14943
  }
14827
14944
  };
@@ -14845,6 +14962,28 @@ function proposeStackSlug(folder) {
14845
14962
  return "";
14846
14963
  }
14847
14964
 
14965
+ // src/utils/wire-end.ts
14966
+ var import_proto3 = require("@lace-cloud/proto");
14967
+ function wireEnd(wire, end) {
14968
+ const source = end === "source";
14969
+ const node = source ? wire.source : wire.target;
14970
+ const pin = source ? wire.source_output : wire.target_input;
14971
+ if (source ? wire.source_pin : wire.target_pin) return { kind: "group-pin", node, pin };
14972
+ if (source && !pin) return { kind: "call", node };
14973
+ return { kind: "pin", node, pin };
14974
+ }
14975
+ function wireEndText(wire, end, pinText) {
14976
+ const part = wireEnd(wire, end);
14977
+ switch (part.kind) {
14978
+ case "group-pin":
14979
+ return (0, import_proto3.groupPinText)(part.node, end, part.pin);
14980
+ case "call":
14981
+ return (0, import_proto3.callText)(part.node);
14982
+ case "pin":
14983
+ return pinText(part.node, part.pin, end);
14984
+ }
14985
+ }
14986
+
14848
14987
  // src/engine/autosave.ts
14849
14988
  var AutosaveEndedError = class extends Error {
14850
14989
  constructor(reason) {
@@ -14984,6 +15123,8 @@ function autosave(source, save, policy, report) {
14984
15123
  settleRun,
14985
15124
  stackSlugRule,
14986
15125
  toArgv,
14987
- uniqueDiagnostics
15126
+ uniqueDiagnostics,
15127
+ wireEnd,
15128
+ wireEndText
14988
15129
  });
14989
15130
  //# sourceMappingURL=index.cjs.map