@lace-cloud/proto 0.37.1 → 0.38.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/index.cjs CHANGED
@@ -18,13 +18,12 @@ var __copyProps = (to, from, except, desc) => {
18
18
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
19
 
20
20
  // src/index.ts
21
- var index_exports = {};
22
- __export(index_exports, {
21
+ var src_exports = {};
22
+ __export(src_exports, {
23
23
  BRIDGE_METHODS: () => BRIDGE_METHODS,
24
24
  Bundle: () => Bundle,
25
25
  COLLAPSED_GROUP_WIDTH: () => COLLAPSED_GROUP_WIDTH,
26
26
  CONNECT_CODE_NAMES: () => CONNECT_CODE_NAMES,
27
- CanvasViewProto: () => CanvasViewProto,
28
27
  EMPTY_BUNDLE: () => EMPTY_BUNDLE,
29
28
  ENGINE_CONTRACT: () => ENGINE_CONTRACT,
30
29
  ENGINE_METHODS: () => ENGINE_METHODS,
@@ -35,9 +34,13 @@ __export(index_exports, {
35
34
  GROUP_PADDING: () => GROUP_PADDING,
36
35
  HOST_ONLY_METHODS: () => HOST_ONLY_METHODS,
37
36
  META_ARGUMENTS: () => META_ARGUMENTS,
37
+ Module: () => Module,
38
38
  NODE_HEADER_HEIGHT: () => NODE_HEADER_HEIGHT,
39
39
  NODE_ROW_HEIGHT: () => NODE_ROW_HEIGHT,
40
40
  NODE_WIDTH: () => NODE_WIDTH,
41
+ Reason: () => Reason,
42
+ Resource: () => Resource,
43
+ Use: () => Use,
41
44
  apiFields: () => apiFields,
42
45
  boxAt: () => boxAt,
43
46
  callText: () => callText,
@@ -64,6 +67,7 @@ __export(index_exports, {
64
67
  keepOrder: () => keepOrder,
65
68
  layoutByDepth: () => layoutByDepth,
66
69
  localIn: () => localIn,
70
+ moduleCallPath: () => moduleCallPath,
67
71
  nodeIdForAddress: () => nodeIdForAddress,
68
72
  nodeIdForDiagnostic: () => nodeIdForDiagnostic,
69
73
  nodeRows: () => nodeRows,
@@ -72,14 +76,15 @@ __export(index_exports, {
72
76
  parseModuleKey: () => parseModuleKey,
73
77
  projectCanvasView: () => projectCanvasView,
74
78
  reachRect: () => reachRect,
79
+ reasonFromJSON: () => reasonFromJSON,
80
+ reasonToJSON: () => reasonToJSON,
75
81
  resolveInstance: () => resolveInstance,
76
- resolveScopePath: () => resolveScopePath,
77
- resolveScopePositionsByDepth: () => resolveScopePositionsByDepth,
82
+ splitAddress: () => splitAddress,
78
83
  splitPath: () => splitPath,
79
84
  stepDown: () => stepDown,
80
85
  visibleInputs: () => visibleInputs
81
86
  });
82
- module.exports = __toCommonJS(index_exports);
87
+ module.exports = __toCommonJS(src_exports);
83
88
 
84
89
  // src/converters.ts
85
90
  var DIAGNOSTIC_SEVERITY_WARNING = 2;
@@ -155,7 +160,7 @@ var CONNECT_CODE_NAMES = [
155
160
  ];
156
161
 
157
162
  // src/engine-contract.gen.ts
158
- var GENERATED_ENGINE_CONTRACT = "109ee79179d90a6e2f31f1d52f9221f7f05b105afb6477c45507f2b969d8cc30";
163
+ var GENERATED_ENGINE_CONTRACT = "281dd21cda1ab94a9a6b4c92c5776505db9ffbfe24eecf864f4f087bdeba757e";
159
164
 
160
165
  // src/generated/service.ts
161
166
  var import_wire3 = require("@bufbuild/protobuf/wire");
@@ -586,6 +591,183 @@ function isSet(value) {
586
591
  return value !== null && value !== void 0;
587
592
  }
588
593
 
594
+ // src/generated/reason.ts
595
+ var Reason = /* @__PURE__ */ ((Reason3) => {
596
+ Reason3[Reason3["REASON_UNSPECIFIED"] = 0] = "REASON_UNSPECIFIED";
597
+ Reason3[Reason3["REASON_NOT_LACE_FORM"] = 1] = "REASON_NOT_LACE_FORM";
598
+ Reason3[Reason3["REASON_HASH_MISMATCH"] = 2] = "REASON_HASH_MISMATCH";
599
+ Reason3[Reason3["REASON_REGISTRY_UNAVAILABLE"] = 3] = "REASON_REGISTRY_UNAVAILABLE";
600
+ Reason3[Reason3["REASON_ROOT_LOCKED"] = 4] = "REASON_ROOT_LOCKED";
601
+ Reason3[Reason3["REASON_UNSAVED"] = 5] = "REASON_UNSAVED";
602
+ Reason3[Reason3["REASON_CONFLICT"] = 6] = "REASON_CONFLICT";
603
+ Reason3[Reason3["REASON_SOURCE_REFUSED"] = 7] = "REASON_SOURCE_REFUSED";
604
+ Reason3[Reason3["REASON_NOT_GIT_REPOSITORY"] = 8] = "REASON_NOT_GIT_REPOSITORY";
605
+ Reason3[Reason3["REASON_GENERATE_IN_PROGRESS"] = 9] = "REASON_GENERATE_IN_PROGRESS";
606
+ Reason3[Reason3["REASON_NO_ORGANIZATION"] = 10] = "REASON_NO_ORGANIZATION";
607
+ Reason3[Reason3["REASON_NO_TEAM"] = 11] = "REASON_NO_TEAM";
608
+ Reason3[Reason3["REASON_NO_CERTIFICATION"] = 12] = "REASON_NO_CERTIFICATION";
609
+ Reason3[Reason3["REASON_STALE_CERTIFICATION"] = 13] = "REASON_STALE_CERTIFICATION";
610
+ Reason3[Reason3["REASON_TOOL_MISSING"] = 14] = "REASON_TOOL_MISSING";
611
+ Reason3[Reason3["REASON_CROSS_SCOPE"] = 15] = "REASON_CROSS_SCOPE";
612
+ Reason3[Reason3["REASON_UNAUTHENTICATED"] = 16] = "REASON_UNAUTHENTICATED";
613
+ Reason3[Reason3["REASON_IMPORT_RESIDUAL"] = 17] = "REASON_IMPORT_RESIDUAL";
614
+ Reason3[Reason3["REASON_STACK_HAS_STATE"] = 18] = "REASON_STACK_HAS_STATE";
615
+ Reason3[Reason3["REASON_NO_ORIGIN_REMOTE"] = 19] = "REASON_NO_ORIGIN_REMOTE";
616
+ Reason3[Reason3["REASON_IMPORT_UNDECLARED"] = 20] = "REASON_IMPORT_UNDECLARED";
617
+ Reason3[Reason3["REASON_ALREADY_IMPORTED"] = 21] = "REASON_ALREADY_IMPORTED";
618
+ Reason3[Reason3["REASON_NO_LOCKFILE"] = 22] = "REASON_NO_LOCKFILE";
619
+ Reason3[Reason3["REASON_NO_COMMIT"] = 23] = "REASON_NO_COMMIT";
620
+ Reason3[Reason3["REASON_STALE_WORKING_STATE"] = 24] = "REASON_STALE_WORKING_STATE";
621
+ Reason3[Reason3["REASON_NO_STACK"] = 25] = "REASON_NO_STACK";
622
+ Reason3[Reason3["UNRECOGNIZED"] = -1] = "UNRECOGNIZED";
623
+ return Reason3;
624
+ })(Reason || {});
625
+ function reasonFromJSON(object) {
626
+ switch (object) {
627
+ case 0:
628
+ case "REASON_UNSPECIFIED":
629
+ return 0 /* REASON_UNSPECIFIED */;
630
+ case 1:
631
+ case "REASON_NOT_LACE_FORM":
632
+ return 1 /* REASON_NOT_LACE_FORM */;
633
+ case 2:
634
+ case "REASON_HASH_MISMATCH":
635
+ return 2 /* REASON_HASH_MISMATCH */;
636
+ case 3:
637
+ case "REASON_REGISTRY_UNAVAILABLE":
638
+ return 3 /* REASON_REGISTRY_UNAVAILABLE */;
639
+ case 4:
640
+ case "REASON_ROOT_LOCKED":
641
+ return 4 /* REASON_ROOT_LOCKED */;
642
+ case 5:
643
+ case "REASON_UNSAVED":
644
+ return 5 /* REASON_UNSAVED */;
645
+ case 6:
646
+ case "REASON_CONFLICT":
647
+ return 6 /* REASON_CONFLICT */;
648
+ case 7:
649
+ case "REASON_SOURCE_REFUSED":
650
+ return 7 /* REASON_SOURCE_REFUSED */;
651
+ case 8:
652
+ case "REASON_NOT_GIT_REPOSITORY":
653
+ return 8 /* REASON_NOT_GIT_REPOSITORY */;
654
+ case 9:
655
+ case "REASON_GENERATE_IN_PROGRESS":
656
+ return 9 /* REASON_GENERATE_IN_PROGRESS */;
657
+ case 10:
658
+ case "REASON_NO_ORGANIZATION":
659
+ return 10 /* REASON_NO_ORGANIZATION */;
660
+ case 11:
661
+ case "REASON_NO_TEAM":
662
+ return 11 /* REASON_NO_TEAM */;
663
+ case 12:
664
+ case "REASON_NO_CERTIFICATION":
665
+ return 12 /* REASON_NO_CERTIFICATION */;
666
+ case 13:
667
+ case "REASON_STALE_CERTIFICATION":
668
+ return 13 /* REASON_STALE_CERTIFICATION */;
669
+ case 14:
670
+ case "REASON_TOOL_MISSING":
671
+ return 14 /* REASON_TOOL_MISSING */;
672
+ case 15:
673
+ case "REASON_CROSS_SCOPE":
674
+ return 15 /* REASON_CROSS_SCOPE */;
675
+ case 16:
676
+ case "REASON_UNAUTHENTICATED":
677
+ return 16 /* REASON_UNAUTHENTICATED */;
678
+ case 17:
679
+ case "REASON_IMPORT_RESIDUAL":
680
+ return 17 /* REASON_IMPORT_RESIDUAL */;
681
+ case 18:
682
+ case "REASON_STACK_HAS_STATE":
683
+ return 18 /* REASON_STACK_HAS_STATE */;
684
+ case 19:
685
+ case "REASON_NO_ORIGIN_REMOTE":
686
+ return 19 /* REASON_NO_ORIGIN_REMOTE */;
687
+ case 20:
688
+ case "REASON_IMPORT_UNDECLARED":
689
+ return 20 /* REASON_IMPORT_UNDECLARED */;
690
+ case 21:
691
+ case "REASON_ALREADY_IMPORTED":
692
+ return 21 /* REASON_ALREADY_IMPORTED */;
693
+ case 22:
694
+ case "REASON_NO_LOCKFILE":
695
+ return 22 /* REASON_NO_LOCKFILE */;
696
+ case 23:
697
+ case "REASON_NO_COMMIT":
698
+ return 23 /* REASON_NO_COMMIT */;
699
+ case 24:
700
+ case "REASON_STALE_WORKING_STATE":
701
+ return 24 /* REASON_STALE_WORKING_STATE */;
702
+ case 25:
703
+ case "REASON_NO_STACK":
704
+ return 25 /* REASON_NO_STACK */;
705
+ case -1:
706
+ case "UNRECOGNIZED":
707
+ default:
708
+ return -1 /* UNRECOGNIZED */;
709
+ }
710
+ }
711
+ function reasonToJSON(object) {
712
+ switch (object) {
713
+ case 0 /* REASON_UNSPECIFIED */:
714
+ return "REASON_UNSPECIFIED";
715
+ case 1 /* REASON_NOT_LACE_FORM */:
716
+ return "REASON_NOT_LACE_FORM";
717
+ case 2 /* REASON_HASH_MISMATCH */:
718
+ return "REASON_HASH_MISMATCH";
719
+ case 3 /* REASON_REGISTRY_UNAVAILABLE */:
720
+ return "REASON_REGISTRY_UNAVAILABLE";
721
+ case 4 /* REASON_ROOT_LOCKED */:
722
+ return "REASON_ROOT_LOCKED";
723
+ case 5 /* REASON_UNSAVED */:
724
+ return "REASON_UNSAVED";
725
+ case 6 /* REASON_CONFLICT */:
726
+ return "REASON_CONFLICT";
727
+ case 7 /* REASON_SOURCE_REFUSED */:
728
+ return "REASON_SOURCE_REFUSED";
729
+ case 8 /* REASON_NOT_GIT_REPOSITORY */:
730
+ return "REASON_NOT_GIT_REPOSITORY";
731
+ case 9 /* REASON_GENERATE_IN_PROGRESS */:
732
+ return "REASON_GENERATE_IN_PROGRESS";
733
+ case 10 /* REASON_NO_ORGANIZATION */:
734
+ return "REASON_NO_ORGANIZATION";
735
+ case 11 /* REASON_NO_TEAM */:
736
+ return "REASON_NO_TEAM";
737
+ case 12 /* REASON_NO_CERTIFICATION */:
738
+ return "REASON_NO_CERTIFICATION";
739
+ case 13 /* REASON_STALE_CERTIFICATION */:
740
+ return "REASON_STALE_CERTIFICATION";
741
+ case 14 /* REASON_TOOL_MISSING */:
742
+ return "REASON_TOOL_MISSING";
743
+ case 15 /* REASON_CROSS_SCOPE */:
744
+ return "REASON_CROSS_SCOPE";
745
+ case 16 /* REASON_UNAUTHENTICATED */:
746
+ return "REASON_UNAUTHENTICATED";
747
+ case 17 /* REASON_IMPORT_RESIDUAL */:
748
+ return "REASON_IMPORT_RESIDUAL";
749
+ case 18 /* REASON_STACK_HAS_STATE */:
750
+ return "REASON_STACK_HAS_STATE";
751
+ case 19 /* REASON_NO_ORIGIN_REMOTE */:
752
+ return "REASON_NO_ORIGIN_REMOTE";
753
+ case 20 /* REASON_IMPORT_UNDECLARED */:
754
+ return "REASON_IMPORT_UNDECLARED";
755
+ case 21 /* REASON_ALREADY_IMPORTED */:
756
+ return "REASON_ALREADY_IMPORTED";
757
+ case 22 /* REASON_NO_LOCKFILE */:
758
+ return "REASON_NO_LOCKFILE";
759
+ case 23 /* REASON_NO_COMMIT */:
760
+ return "REASON_NO_COMMIT";
761
+ case 24 /* REASON_STALE_WORKING_STATE */:
762
+ return "REASON_STALE_WORKING_STATE";
763
+ case 25 /* REASON_NO_STACK */:
764
+ return "REASON_NO_STACK";
765
+ case -1 /* UNRECOGNIZED */:
766
+ default:
767
+ return "UNRECOGNIZED";
768
+ }
769
+ }
770
+
589
771
  // src/generated/state.ts
590
772
  var import_wire2 = require("@bufbuild/protobuf/wire");
591
773
  function createBaseBundle() {
@@ -3388,940 +3570,209 @@ function isSet2(value) {
3388
3570
  return value !== null && value !== void 0;
3389
3571
  }
3390
3572
 
3391
- // src/generated/service.ts
3392
- function nodeKindFromJSON(object) {
3393
- switch (object) {
3394
- case 0:
3395
- case "NODE_KIND_UNSPECIFIED":
3396
- return 0 /* NODE_KIND_UNSPECIFIED */;
3397
- case 1:
3398
- case "NODE_KIND_MODULE":
3399
- return 1 /* NODE_KIND_MODULE */;
3400
- case 2:
3401
- case "NODE_KIND_RESOURCE":
3402
- return 2 /* NODE_KIND_RESOURCE */;
3403
- case 3:
3404
- case "NODE_KIND_DATA":
3405
- return 3 /* NODE_KIND_DATA */;
3406
- case -1:
3407
- case "UNRECOGNIZED":
3408
- default:
3409
- return -1 /* UNRECOGNIZED */;
3573
+ // src/engine-identity.ts
3574
+ var ENGINE_PROTOCOL_VERSION = String(12 /* PROTOCOL_VERSION_CURRENT */);
3575
+ var ENGINE_CONTRACT = GENERATED_ENGINE_CONTRACT;
3576
+ var EngineIdentityMismatchError = class extends Error {
3577
+ constructor(engine, required) {
3578
+ const behind = engine.protocol === required.protocol ? void 0 : Number(engine.protocol) < Number(required.protocol) ? "engine" : "host";
3579
+ super(mismatchMessage(engine, required, behind));
3580
+ this.name = "EngineIdentityMismatchError";
3581
+ this.engineVersion = engine.version;
3582
+ this.engineProtocol = engine.protocol;
3583
+ this.engineContract = engine.contract;
3584
+ this.requiredProtocol = required.protocol;
3585
+ this.requiredContract = required.contract;
3586
+ this.behind = behind;
3587
+ }
3588
+ };
3589
+ function mismatchMessage(engine, required, behind) {
3590
+ const protocols = `Lace engine ${engine.version} speaks protocol ${engine.protocol}; this host speaks protocol ${required.protocol}`;
3591
+ switch (behind) {
3592
+ case "engine":
3593
+ return `${protocols}: update the Lace CLI`;
3594
+ case "host":
3595
+ return `${protocols}: update this host`;
3596
+ case void 0:
3597
+ return `this host and Lace engine ${engine.version} were built from different trees of protocol ${required.protocol}: rebuild both from one checkout, or install the Lace CLI release that matches this host`;
3410
3598
  }
3411
3599
  }
3412
- function nodeKindToJSON(object) {
3413
- switch (object) {
3414
- case 0 /* NODE_KIND_UNSPECIFIED */:
3415
- return "NODE_KIND_UNSPECIFIED";
3416
- case 1 /* NODE_KIND_MODULE */:
3417
- return "NODE_KIND_MODULE";
3418
- case 2 /* NODE_KIND_RESOURCE */:
3419
- return "NODE_KIND_RESOURCE";
3420
- case 3 /* NODE_KIND_DATA */:
3421
- return "NODE_KIND_DATA";
3422
- case -1 /* UNRECOGNIZED */:
3423
- default:
3424
- return "UNRECOGNIZED";
3600
+ function checkEngineIdentity(engine) {
3601
+ if (engine.protocol !== ENGINE_PROTOCOL_VERSION || engine.contract !== ENGINE_CONTRACT) {
3602
+ throw new EngineIdentityMismatchError(engine, {
3603
+ protocol: ENGINE_PROTOCOL_VERSION,
3604
+ contract: ENGINE_CONTRACT
3605
+ });
3425
3606
  }
3426
3607
  }
3427
- function createBaseCanvasView() {
3428
- return { module_name: "", nodes: [], edges: [], can_undo: false, can_redo: false, unsaved: false, groups: [] };
3608
+
3609
+ // src/projection/join-path.ts
3610
+ function joinPath(prefix, localId) {
3611
+ return prefix === "" ? localId : `${prefix}.${localId}`;
3612
+ }
3613
+ function splitPath(canvasPath) {
3614
+ const lastDot = canvasPath.lastIndexOf(".");
3615
+ if (lastDot === -1) return { parentPath: "", localId: canvasPath };
3616
+ return { parentPath: canvasPath.slice(0, lastDot), localId: canvasPath.slice(lastDot + 1) };
3429
3617
  }
3430
- var CanvasView = {
3431
- encode(message, writer = new import_wire3.BinaryWriter()) {
3432
- if (message.module_name !== "") {
3433
- writer.uint32(10).string(message.module_name);
3434
- }
3435
- for (const v of message.nodes) {
3436
- RenderNode.encode(v, writer.uint32(18).fork()).join();
3618
+ function callText(sourcePath) {
3619
+ return `module.${splitPath(sourcePath).localId}`;
3620
+ }
3621
+ function groupPinText(group, end, pin) {
3622
+ return `${group}.${end === "source" ? "inputs" : "outputs"}.${pin}`;
3623
+ }
3624
+
3625
+ // src/projection/address.ts
3626
+ function addressParts(address) {
3627
+ const parts = [];
3628
+ let current = "";
3629
+ let depth = 0;
3630
+ let quoted = false;
3631
+ let escaped = false;
3632
+ for (const ch of address) {
3633
+ if (quoted) {
3634
+ current += ch;
3635
+ if (escaped) escaped = false;
3636
+ else if (ch === "\\") escaped = true;
3637
+ else if (ch === '"') quoted = false;
3638
+ continue;
3437
3639
  }
3438
- for (const v of message.edges) {
3439
- RenderEdge.encode(v, writer.uint32(26).fork()).join();
3640
+ if (ch === "." && depth === 0) {
3641
+ parts.push(current);
3642
+ current = "";
3643
+ continue;
3440
3644
  }
3441
- if (message.can_undo !== false) {
3442
- writer.uint32(40).bool(message.can_undo);
3645
+ if (ch === '"') quoted = true;
3646
+ else if (ch === "[") depth++;
3647
+ else if (ch === "]") depth--;
3648
+ current += ch;
3649
+ }
3650
+ parts.push(current);
3651
+ return parts;
3652
+ }
3653
+ function splitAddress(address) {
3654
+ const parts = addressParts(address);
3655
+ const modules = [];
3656
+ let i = 0;
3657
+ while (i + 1 < parts.length && parts[i] === "module") {
3658
+ modules.push(parts[i + 1]);
3659
+ i += 2;
3660
+ }
3661
+ return { modules, resource: parts.slice(i).join(".") };
3662
+ }
3663
+ function callName(step) {
3664
+ const bracket = step.indexOf("[");
3665
+ return bracket === -1 ? step : step.slice(0, bracket);
3666
+ }
3667
+ function moduleCallPath(address) {
3668
+ return splitAddress(address).modules.map(callName).reduce(joinPath, "");
3669
+ }
3670
+
3671
+ // src/render.ts
3672
+ var META_ARGUMENTS = ["count", "for_each"];
3673
+
3674
+ // src/projection/classify-child.ts
3675
+ function isGroupUse(bundle, use) {
3676
+ const target = bundle.modules[use.module];
3677
+ return target !== void 0 && isGroupModule(target);
3678
+ }
3679
+ function isGroupModule(mod) {
3680
+ return (mod.modules?.length ?? 0) > 0;
3681
+ }
3682
+
3683
+ // src/projection/derive-edges.ts
3684
+ function emitEdgesFromBinding(binding, targetId, toInput, useIds, seen, edges) {
3685
+ if (binding.out?.module && binding.out.name) {
3686
+ edges.push({
3687
+ source_instance: binding.out.module,
3688
+ target_instance: targetId,
3689
+ from_output: binding.out.name,
3690
+ to_input: toInput
3691
+ });
3692
+ return;
3693
+ }
3694
+ for (const ref of binding.expr?.module_references ?? []) {
3695
+ if (!useIds.has(ref.call)) continue;
3696
+ const fromOutput = ref.output ?? "";
3697
+ const key = `${ref.call}:${targetId}:${fromOutput}:${toInput}`;
3698
+ if (seen.has(key)) continue;
3699
+ seen.add(key);
3700
+ edges.push({
3701
+ source_instance: ref.call,
3702
+ target_instance: targetId,
3703
+ from_output: fromOutput,
3704
+ to_input: toInput
3705
+ });
3706
+ }
3707
+ }
3708
+ function deriveEdges(uses) {
3709
+ const useIds = new Set(uses.map((u) => u.id));
3710
+ const edges = [];
3711
+ const seen = /* @__PURE__ */ new Set();
3712
+ for (const target of uses) {
3713
+ const inputs = target.inputs ?? {};
3714
+ for (const [inputName, binding] of Object.entries(inputs)) {
3715
+ emitEdgesFromBinding(binding, target.id, inputName, useIds, seen, edges);
3443
3716
  }
3444
- if (message.can_redo !== false) {
3445
- writer.uint32(48).bool(message.can_redo);
3717
+ for (const meta of META_ARGUMENTS) {
3718
+ const binding = target[meta];
3719
+ if (binding) emitEdgesFromBinding(binding, target.id, meta, useIds, seen, edges);
3446
3720
  }
3447
- if (message.unsaved !== false) {
3448
- writer.uint32(56).bool(message.unsaved);
3721
+ }
3722
+ return edges;
3723
+ }
3724
+ function addPin(index, call, pin) {
3725
+ if (!index.has(call)) index.set(call, /* @__PURE__ */ new Set());
3726
+ index.get(call).add(pin);
3727
+ }
3728
+ function indexWires(edges) {
3729
+ const inputs = /* @__PURE__ */ new Map();
3730
+ const outputs = /* @__PURE__ */ new Map();
3731
+ for (const e of edges) {
3732
+ addPin(inputs, e.target_instance, e.to_input);
3733
+ addPin(outputs, e.source_instance, e.from_output);
3734
+ }
3735
+ return { inputs, outputs };
3736
+ }
3737
+ function deriveInterfaceEdges(mod) {
3738
+ const uses = mod.modules ?? [];
3739
+ const useIds = new Set(uses.map((u) => u.id));
3740
+ const declaredIn = new Set((mod.interface?.inputs ?? []).map((i) => i.name));
3741
+ const declaredOut = new Set((mod.interface?.outputs ?? []).map((o) => o.name));
3742
+ const edges = [];
3743
+ const fromInput = (pin, target, toInput) => {
3744
+ if (!pin || !declaredIn.has(pin)) return;
3745
+ edges.push({
3746
+ source_instance: "",
3747
+ target_instance: target,
3748
+ from_output: pin,
3749
+ to_input: toInput,
3750
+ source_pin: true
3751
+ });
3752
+ };
3753
+ for (const use of uses) {
3754
+ for (const [name, binding] of Object.entries(use.inputs ?? {})) {
3755
+ fromInput(binding.var ?? "", use.id, name);
3449
3756
  }
3450
- for (const v of message.groups) {
3451
- RenderGroup.encode(v, writer.uint32(66).fork()).join();
3757
+ for (const meta of META_ARGUMENTS) fromInput(use[meta]?.var ?? "", use.id, meta);
3758
+ }
3759
+ const seen = /* @__PURE__ */ new Set();
3760
+ for (const [name, exported] of Object.entries(mod.exports?.outputs ?? {})) {
3761
+ if (!declaredOut.has(name)) continue;
3762
+ const read = [];
3763
+ emitEdgesFromBinding(exported, "", name, useIds, seen, read);
3764
+ for (const edge of read) {
3765
+ if (useIds.has(edge.source_instance)) edges.push({ ...edge, target_pin: true });
3452
3766
  }
3453
- return writer;
3454
- },
3455
- decode(input, length) {
3456
- const reader = input instanceof import_wire3.BinaryReader ? input : new import_wire3.BinaryReader(input);
3457
- const end = length === void 0 ? reader.len : reader.pos + length;
3458
- const message = createBaseCanvasView();
3459
- while (reader.pos < end) {
3460
- const tag = reader.uint32();
3461
- switch (tag >>> 3) {
3462
- case 1: {
3463
- if (tag !== 10) {
3464
- break;
3465
- }
3466
- message.module_name = reader.string();
3467
- continue;
3468
- }
3469
- case 2: {
3470
- if (tag !== 18) {
3471
- break;
3472
- }
3473
- message.nodes.push(RenderNode.decode(reader, reader.uint32()));
3474
- continue;
3475
- }
3476
- case 3: {
3477
- if (tag !== 26) {
3478
- break;
3479
- }
3480
- message.edges.push(RenderEdge.decode(reader, reader.uint32()));
3481
- continue;
3482
- }
3483
- case 5: {
3484
- if (tag !== 40) {
3485
- break;
3486
- }
3487
- message.can_undo = reader.bool();
3488
- continue;
3489
- }
3490
- case 6: {
3491
- if (tag !== 48) {
3492
- break;
3493
- }
3494
- message.can_redo = reader.bool();
3495
- continue;
3496
- }
3497
- case 7: {
3498
- if (tag !== 56) {
3499
- break;
3500
- }
3501
- message.unsaved = reader.bool();
3502
- continue;
3503
- }
3504
- case 8: {
3505
- if (tag !== 66) {
3506
- break;
3507
- }
3508
- message.groups.push(RenderGroup.decode(reader, reader.uint32()));
3509
- continue;
3510
- }
3511
- }
3512
- if ((tag & 7) === 4 || tag === 0) {
3513
- break;
3514
- }
3515
- reader.skip(tag & 7);
3516
- }
3517
- return message;
3518
- },
3519
- fromJSON(object) {
3520
- return {
3521
- module_name: isSet3(object.moduleName) ? globalThis.String(object.moduleName) : isSet3(object.module_name) ? globalThis.String(object.module_name) : "",
3522
- nodes: globalThis.Array.isArray(object?.nodes) ? object.nodes.map((e) => RenderNode.fromJSON(e)) : [],
3523
- edges: globalThis.Array.isArray(object?.edges) ? object.edges.map((e) => RenderEdge.fromJSON(e)) : [],
3524
- can_undo: isSet3(object.canUndo) ? globalThis.Boolean(object.canUndo) : isSet3(object.can_undo) ? globalThis.Boolean(object.can_undo) : false,
3525
- can_redo: isSet3(object.canRedo) ? globalThis.Boolean(object.canRedo) : isSet3(object.can_redo) ? globalThis.Boolean(object.can_redo) : false,
3526
- unsaved: isSet3(object.unsaved) ? globalThis.Boolean(object.unsaved) : false,
3527
- groups: globalThis.Array.isArray(object?.groups) ? object.groups.map((e) => RenderGroup.fromJSON(e)) : []
3528
- };
3529
- },
3530
- toJSON(message) {
3531
- const obj = {};
3532
- if (message.module_name !== "") {
3533
- obj.moduleName = message.module_name;
3534
- }
3535
- if (message.nodes?.length) {
3536
- obj.nodes = message.nodes.map((e) => RenderNode.toJSON(e));
3537
- }
3538
- if (message.edges?.length) {
3539
- obj.edges = message.edges.map((e) => RenderEdge.toJSON(e));
3540
- }
3541
- if (message.can_undo !== false) {
3542
- obj.canUndo = message.can_undo;
3543
- }
3544
- if (message.can_redo !== false) {
3545
- obj.canRedo = message.can_redo;
3546
- }
3547
- if (message.unsaved !== false) {
3548
- obj.unsaved = message.unsaved;
3549
- }
3550
- if (message.groups?.length) {
3551
- obj.groups = message.groups.map((e) => RenderGroup.toJSON(e));
3552
- }
3553
- return obj;
3554
- },
3555
- create(base) {
3556
- return CanvasView.fromPartial(base ?? {});
3557
- },
3558
- fromPartial(object) {
3559
- const message = createBaseCanvasView();
3560
- message.module_name = object.module_name ?? "";
3561
- message.nodes = object.nodes?.map((e) => RenderNode.fromPartial(e)) || [];
3562
- message.edges = object.edges?.map((e) => RenderEdge.fromPartial(e)) || [];
3563
- message.can_undo = object.can_undo ?? false;
3564
- message.can_redo = object.can_redo ?? false;
3565
- message.unsaved = object.unsaved ?? false;
3566
- message.groups = object.groups?.map((e) => RenderGroup.fromPartial(e)) || [];
3567
- return message;
3568
- }
3569
- };
3570
- function createBaseRenderGroup() {
3571
- return { id: "", label: "", node_ids: [], collapsed: false, module_key: "", inputs: [], outputs: [] };
3572
- }
3573
- var RenderGroup = {
3574
- encode(message, writer = new import_wire3.BinaryWriter()) {
3575
- if (message.id !== "") {
3576
- writer.uint32(10).string(message.id);
3577
- }
3578
- if (message.label !== "") {
3579
- writer.uint32(18).string(message.label);
3580
- }
3581
- for (const v of message.node_ids) {
3582
- writer.uint32(26).string(v);
3583
- }
3584
- if (message.collapsed !== false) {
3585
- writer.uint32(32).bool(message.collapsed);
3586
- }
3587
- if (message.module_key !== "") {
3588
- writer.uint32(42).string(message.module_key);
3589
- }
3590
- for (const v of message.inputs) {
3591
- NodePin.encode(v, writer.uint32(50).fork()).join();
3592
- }
3593
- for (const v of message.outputs) {
3594
- NodePin.encode(v, writer.uint32(58).fork()).join();
3595
- }
3596
- return writer;
3597
- },
3598
- decode(input, length) {
3599
- const reader = input instanceof import_wire3.BinaryReader ? input : new import_wire3.BinaryReader(input);
3600
- const end = length === void 0 ? reader.len : reader.pos + length;
3601
- const message = createBaseRenderGroup();
3602
- while (reader.pos < end) {
3603
- const tag = reader.uint32();
3604
- switch (tag >>> 3) {
3605
- case 1: {
3606
- if (tag !== 10) {
3607
- break;
3608
- }
3609
- message.id = reader.string();
3610
- continue;
3611
- }
3612
- case 2: {
3613
- if (tag !== 18) {
3614
- break;
3615
- }
3616
- message.label = reader.string();
3617
- continue;
3618
- }
3619
- case 3: {
3620
- if (tag !== 26) {
3621
- break;
3622
- }
3623
- message.node_ids.push(reader.string());
3624
- continue;
3625
- }
3626
- case 4: {
3627
- if (tag !== 32) {
3628
- break;
3629
- }
3630
- message.collapsed = reader.bool();
3631
- continue;
3632
- }
3633
- case 5: {
3634
- if (tag !== 42) {
3635
- break;
3636
- }
3637
- message.module_key = reader.string();
3638
- continue;
3639
- }
3640
- case 6: {
3641
- if (tag !== 50) {
3642
- break;
3643
- }
3644
- message.inputs.push(NodePin.decode(reader, reader.uint32()));
3645
- continue;
3646
- }
3647
- case 7: {
3648
- if (tag !== 58) {
3649
- break;
3650
- }
3651
- message.outputs.push(NodePin.decode(reader, reader.uint32()));
3652
- continue;
3653
- }
3654
- }
3655
- if ((tag & 7) === 4 || tag === 0) {
3656
- break;
3657
- }
3658
- reader.skip(tag & 7);
3659
- }
3660
- return message;
3661
- },
3662
- fromJSON(object) {
3663
- return {
3664
- id: isSet3(object.id) ? globalThis.String(object.id) : "",
3665
- label: isSet3(object.label) ? globalThis.String(object.label) : "",
3666
- node_ids: globalThis.Array.isArray(object?.nodeIds) ? object.nodeIds.map((e) => globalThis.String(e)) : globalThis.Array.isArray(object?.node_ids) ? object.node_ids.map((e) => globalThis.String(e)) : [],
3667
- collapsed: isSet3(object.collapsed) ? globalThis.Boolean(object.collapsed) : false,
3668
- module_key: isSet3(object.moduleKey) ? globalThis.String(object.moduleKey) : isSet3(object.module_key) ? globalThis.String(object.module_key) : "",
3669
- inputs: globalThis.Array.isArray(object?.inputs) ? object.inputs.map((e) => NodePin.fromJSON(e)) : [],
3670
- outputs: globalThis.Array.isArray(object?.outputs) ? object.outputs.map((e) => NodePin.fromJSON(e)) : []
3671
- };
3672
- },
3673
- toJSON(message) {
3674
- const obj = {};
3675
- if (message.id !== "") {
3676
- obj.id = message.id;
3677
- }
3678
- if (message.label !== "") {
3679
- obj.label = message.label;
3680
- }
3681
- if (message.node_ids?.length) {
3682
- obj.nodeIds = message.node_ids;
3683
- }
3684
- if (message.collapsed !== false) {
3685
- obj.collapsed = message.collapsed;
3686
- }
3687
- if (message.module_key !== "") {
3688
- obj.moduleKey = message.module_key;
3689
- }
3690
- if (message.inputs?.length) {
3691
- obj.inputs = message.inputs.map((e) => NodePin.toJSON(e));
3692
- }
3693
- if (message.outputs?.length) {
3694
- obj.outputs = message.outputs.map((e) => NodePin.toJSON(e));
3695
- }
3696
- return obj;
3697
- },
3698
- create(base) {
3699
- return RenderGroup.fromPartial(base ?? {});
3700
- },
3701
- fromPartial(object) {
3702
- const message = createBaseRenderGroup();
3703
- message.id = object.id ?? "";
3704
- message.label = object.label ?? "";
3705
- message.node_ids = object.node_ids?.map((e) => e) || [];
3706
- message.collapsed = object.collapsed ?? false;
3707
- message.module_key = object.module_key ?? "";
3708
- message.inputs = object.inputs?.map((e) => NodePin.fromPartial(e)) || [];
3709
- message.outputs = object.outputs?.map((e) => NodePin.fromPartial(e)) || [];
3710
- return message;
3711
- }
3712
- };
3713
- function createBaseRenderNode() {
3714
- return { id: "", label: "", kind: 0, module_key: "", icon_url: "", position: void 0, inputs: [], outputs: [] };
3715
- }
3716
- var RenderNode = {
3717
- encode(message, writer = new import_wire3.BinaryWriter()) {
3718
- if (message.id !== "") {
3719
- writer.uint32(10).string(message.id);
3720
- }
3721
- if (message.label !== "") {
3722
- writer.uint32(18).string(message.label);
3723
- }
3724
- if (message.kind !== 0) {
3725
- writer.uint32(24).int32(message.kind);
3726
- }
3727
- if (message.module_key !== "") {
3728
- writer.uint32(34).string(message.module_key);
3729
- }
3730
- if (message.icon_url !== "") {
3731
- writer.uint32(42).string(message.icon_url);
3732
- }
3733
- if (message.position !== void 0) {
3734
- Position.encode(message.position, writer.uint32(50).fork()).join();
3735
- }
3736
- for (const v of message.inputs) {
3737
- NodePin.encode(v, writer.uint32(74).fork()).join();
3738
- }
3739
- for (const v of message.outputs) {
3740
- NodePin.encode(v, writer.uint32(82).fork()).join();
3741
- }
3742
- return writer;
3743
- },
3744
- decode(input, length) {
3745
- const reader = input instanceof import_wire3.BinaryReader ? input : new import_wire3.BinaryReader(input);
3746
- const end = length === void 0 ? reader.len : reader.pos + length;
3747
- const message = createBaseRenderNode();
3748
- while (reader.pos < end) {
3749
- const tag = reader.uint32();
3750
- switch (tag >>> 3) {
3751
- case 1: {
3752
- if (tag !== 10) {
3753
- break;
3754
- }
3755
- message.id = reader.string();
3756
- continue;
3757
- }
3758
- case 2: {
3759
- if (tag !== 18) {
3760
- break;
3761
- }
3762
- message.label = reader.string();
3763
- continue;
3764
- }
3765
- case 3: {
3766
- if (tag !== 24) {
3767
- break;
3768
- }
3769
- message.kind = reader.int32();
3770
- continue;
3771
- }
3772
- case 4: {
3773
- if (tag !== 34) {
3774
- break;
3775
- }
3776
- message.module_key = reader.string();
3777
- continue;
3778
- }
3779
- case 5: {
3780
- if (tag !== 42) {
3781
- break;
3782
- }
3783
- message.icon_url = reader.string();
3784
- continue;
3785
- }
3786
- case 6: {
3787
- if (tag !== 50) {
3788
- break;
3789
- }
3790
- message.position = Position.decode(reader, reader.uint32());
3791
- continue;
3792
- }
3793
- case 9: {
3794
- if (tag !== 74) {
3795
- break;
3796
- }
3797
- message.inputs.push(NodePin.decode(reader, reader.uint32()));
3798
- continue;
3799
- }
3800
- case 10: {
3801
- if (tag !== 82) {
3802
- break;
3803
- }
3804
- message.outputs.push(NodePin.decode(reader, reader.uint32()));
3805
- continue;
3806
- }
3807
- }
3808
- if ((tag & 7) === 4 || tag === 0) {
3809
- break;
3810
- }
3811
- reader.skip(tag & 7);
3812
- }
3813
- return message;
3814
- },
3815
- fromJSON(object) {
3816
- return {
3817
- id: isSet3(object.id) ? globalThis.String(object.id) : "",
3818
- label: isSet3(object.label) ? globalThis.String(object.label) : "",
3819
- kind: isSet3(object.kind) ? nodeKindFromJSON(object.kind) : 0,
3820
- module_key: isSet3(object.moduleKey) ? globalThis.String(object.moduleKey) : isSet3(object.module_key) ? globalThis.String(object.module_key) : "",
3821
- icon_url: isSet3(object.iconUrl) ? globalThis.String(object.iconUrl) : isSet3(object.icon_url) ? globalThis.String(object.icon_url) : "",
3822
- position: isSet3(object.position) ? Position.fromJSON(object.position) : void 0,
3823
- inputs: globalThis.Array.isArray(object?.inputs) ? object.inputs.map((e) => NodePin.fromJSON(e)) : [],
3824
- outputs: globalThis.Array.isArray(object?.outputs) ? object.outputs.map((e) => NodePin.fromJSON(e)) : []
3825
- };
3826
- },
3827
- toJSON(message) {
3828
- const obj = {};
3829
- if (message.id !== "") {
3830
- obj.id = message.id;
3831
- }
3832
- if (message.label !== "") {
3833
- obj.label = message.label;
3834
- }
3835
- if (message.kind !== 0) {
3836
- obj.kind = nodeKindToJSON(message.kind);
3837
- }
3838
- if (message.module_key !== "") {
3839
- obj.moduleKey = message.module_key;
3840
- }
3841
- if (message.icon_url !== "") {
3842
- obj.iconUrl = message.icon_url;
3843
- }
3844
- if (message.position !== void 0) {
3845
- obj.position = Position.toJSON(message.position);
3846
- }
3847
- if (message.inputs?.length) {
3848
- obj.inputs = message.inputs.map((e) => NodePin.toJSON(e));
3849
- }
3850
- if (message.outputs?.length) {
3851
- obj.outputs = message.outputs.map((e) => NodePin.toJSON(e));
3852
- }
3853
- return obj;
3854
- },
3855
- create(base) {
3856
- return RenderNode.fromPartial(base ?? {});
3857
- },
3858
- fromPartial(object) {
3859
- const message = createBaseRenderNode();
3860
- message.id = object.id ?? "";
3861
- message.label = object.label ?? "";
3862
- message.kind = object.kind ?? 0;
3863
- message.module_key = object.module_key ?? "";
3864
- message.icon_url = object.icon_url ?? "";
3865
- message.position = object.position !== void 0 && object.position !== null ? Position.fromPartial(object.position) : void 0;
3866
- message.inputs = object.inputs?.map((e) => NodePin.fromPartial(e)) || [];
3867
- message.outputs = object.outputs?.map((e) => NodePin.fromPartial(e)) || [];
3868
- return message;
3869
- }
3870
- };
3871
- function createBaseNodePin() {
3872
- return { name: "", type: "", required: false, wired: false, description: "", sensitive: false };
3873
- }
3874
- var NodePin = {
3875
- encode(message, writer = new import_wire3.BinaryWriter()) {
3876
- if (message.name !== "") {
3877
- writer.uint32(10).string(message.name);
3878
- }
3879
- if (message.type !== "") {
3880
- writer.uint32(18).string(message.type);
3881
- }
3882
- if (message.required !== false) {
3883
- writer.uint32(24).bool(message.required);
3884
- }
3885
- if (message.wired !== false) {
3886
- writer.uint32(32).bool(message.wired);
3887
- }
3888
- if (message.description !== "") {
3889
- writer.uint32(42).string(message.description);
3890
- }
3891
- if (message.sensitive !== false) {
3892
- writer.uint32(48).bool(message.sensitive);
3893
- }
3894
- return writer;
3895
- },
3896
- decode(input, length) {
3897
- const reader = input instanceof import_wire3.BinaryReader ? input : new import_wire3.BinaryReader(input);
3898
- const end = length === void 0 ? reader.len : reader.pos + length;
3899
- const message = createBaseNodePin();
3900
- while (reader.pos < end) {
3901
- const tag = reader.uint32();
3902
- switch (tag >>> 3) {
3903
- case 1: {
3904
- if (tag !== 10) {
3905
- break;
3906
- }
3907
- message.name = reader.string();
3908
- continue;
3909
- }
3910
- case 2: {
3911
- if (tag !== 18) {
3912
- break;
3913
- }
3914
- message.type = reader.string();
3915
- continue;
3916
- }
3917
- case 3: {
3918
- if (tag !== 24) {
3919
- break;
3920
- }
3921
- message.required = reader.bool();
3922
- continue;
3923
- }
3924
- case 4: {
3925
- if (tag !== 32) {
3926
- break;
3927
- }
3928
- message.wired = reader.bool();
3929
- continue;
3930
- }
3931
- case 5: {
3932
- if (tag !== 42) {
3933
- break;
3934
- }
3935
- message.description = reader.string();
3936
- continue;
3937
- }
3938
- case 6: {
3939
- if (tag !== 48) {
3940
- break;
3941
- }
3942
- message.sensitive = reader.bool();
3943
- continue;
3944
- }
3945
- }
3946
- if ((tag & 7) === 4 || tag === 0) {
3947
- break;
3948
- }
3949
- reader.skip(tag & 7);
3950
- }
3951
- return message;
3952
- },
3953
- fromJSON(object) {
3954
- return {
3955
- name: isSet3(object.name) ? globalThis.String(object.name) : "",
3956
- type: isSet3(object.type) ? globalThis.String(object.type) : "",
3957
- required: isSet3(object.required) ? globalThis.Boolean(object.required) : false,
3958
- wired: isSet3(object.wired) ? globalThis.Boolean(object.wired) : false,
3959
- description: isSet3(object.description) ? globalThis.String(object.description) : "",
3960
- sensitive: isSet3(object.sensitive) ? globalThis.Boolean(object.sensitive) : false
3961
- };
3962
- },
3963
- toJSON(message) {
3964
- const obj = {};
3965
- if (message.name !== "") {
3966
- obj.name = message.name;
3967
- }
3968
- if (message.type !== "") {
3969
- obj.type = message.type;
3970
- }
3971
- if (message.required !== false) {
3972
- obj.required = message.required;
3973
- }
3974
- if (message.wired !== false) {
3975
- obj.wired = message.wired;
3976
- }
3977
- if (message.description !== "") {
3978
- obj.description = message.description;
3979
- }
3980
- if (message.sensitive !== false) {
3981
- obj.sensitive = message.sensitive;
3982
- }
3983
- return obj;
3984
- },
3985
- create(base) {
3986
- return NodePin.fromPartial(base ?? {});
3987
- },
3988
- fromPartial(object) {
3989
- const message = createBaseNodePin();
3990
- message.name = object.name ?? "";
3991
- message.type = object.type ?? "";
3992
- message.required = object.required ?? false;
3993
- message.wired = object.wired ?? false;
3994
- message.description = object.description ?? "";
3995
- message.sensitive = object.sensitive ?? false;
3996
- return message;
3997
- }
3998
- };
3999
- function createBaseRenderEdge() {
4000
- return { id: "", source: "", target: "", source_output: "", target_input: "" };
4001
- }
4002
- var RenderEdge = {
4003
- encode(message, writer = new import_wire3.BinaryWriter()) {
4004
- if (message.id !== "") {
4005
- writer.uint32(10).string(message.id);
4006
- }
4007
- if (message.source !== "") {
4008
- writer.uint32(18).string(message.source);
4009
- }
4010
- if (message.target !== "") {
4011
- writer.uint32(26).string(message.target);
4012
- }
4013
- if (message.source_output !== "") {
4014
- writer.uint32(34).string(message.source_output);
4015
- }
4016
- if (message.target_input !== "") {
4017
- writer.uint32(42).string(message.target_input);
4018
- }
4019
- return writer;
4020
- },
4021
- decode(input, length) {
4022
- const reader = input instanceof import_wire3.BinaryReader ? input : new import_wire3.BinaryReader(input);
4023
- const end = length === void 0 ? reader.len : reader.pos + length;
4024
- const message = createBaseRenderEdge();
4025
- while (reader.pos < end) {
4026
- const tag = reader.uint32();
4027
- switch (tag >>> 3) {
4028
- case 1: {
4029
- if (tag !== 10) {
4030
- break;
4031
- }
4032
- message.id = reader.string();
4033
- continue;
4034
- }
4035
- case 2: {
4036
- if (tag !== 18) {
4037
- break;
4038
- }
4039
- message.source = reader.string();
4040
- continue;
4041
- }
4042
- case 3: {
4043
- if (tag !== 26) {
4044
- break;
4045
- }
4046
- message.target = reader.string();
4047
- continue;
4048
- }
4049
- case 4: {
4050
- if (tag !== 34) {
4051
- break;
4052
- }
4053
- message.source_output = reader.string();
4054
- continue;
4055
- }
4056
- case 5: {
4057
- if (tag !== 42) {
4058
- break;
4059
- }
4060
- message.target_input = reader.string();
4061
- continue;
4062
- }
4063
- }
4064
- if ((tag & 7) === 4 || tag === 0) {
4065
- break;
4066
- }
4067
- reader.skip(tag & 7);
4068
- }
4069
- return message;
4070
- },
4071
- fromJSON(object) {
4072
- return {
4073
- id: isSet3(object.id) ? globalThis.String(object.id) : "",
4074
- source: isSet3(object.source) ? globalThis.String(object.source) : "",
4075
- target: isSet3(object.target) ? globalThis.String(object.target) : "",
4076
- source_output: isSet3(object.sourceOutput) ? globalThis.String(object.sourceOutput) : isSet3(object.source_output) ? globalThis.String(object.source_output) : "",
4077
- target_input: isSet3(object.targetInput) ? globalThis.String(object.targetInput) : isSet3(object.target_input) ? globalThis.String(object.target_input) : ""
4078
- };
4079
- },
4080
- toJSON(message) {
4081
- const obj = {};
4082
- if (message.id !== "") {
4083
- obj.id = message.id;
4084
- }
4085
- if (message.source !== "") {
4086
- obj.source = message.source;
4087
- }
4088
- if (message.target !== "") {
4089
- obj.target = message.target;
4090
- }
4091
- if (message.source_output !== "") {
4092
- obj.sourceOutput = message.source_output;
4093
- }
4094
- if (message.target_input !== "") {
4095
- obj.targetInput = message.target_input;
4096
- }
4097
- return obj;
4098
- },
4099
- create(base) {
4100
- return RenderEdge.fromPartial(base ?? {});
4101
- },
4102
- fromPartial(object) {
4103
- const message = createBaseRenderEdge();
4104
- message.id = object.id ?? "";
4105
- message.source = object.source ?? "";
4106
- message.target = object.target ?? "";
4107
- message.source_output = object.source_output ?? "";
4108
- message.target_input = object.target_input ?? "";
4109
- return message;
4110
- }
4111
- };
4112
- function createBasePosition() {
4113
- return { x: 0, y: 0 };
4114
- }
4115
- var Position = {
4116
- encode(message, writer = new import_wire3.BinaryWriter()) {
4117
- if (message.x !== 0) {
4118
- writer.uint32(9).double(message.x);
4119
- }
4120
- if (message.y !== 0) {
4121
- writer.uint32(17).double(message.y);
4122
- }
4123
- return writer;
4124
- },
4125
- decode(input, length) {
4126
- const reader = input instanceof import_wire3.BinaryReader ? input : new import_wire3.BinaryReader(input);
4127
- const end = length === void 0 ? reader.len : reader.pos + length;
4128
- const message = createBasePosition();
4129
- while (reader.pos < end) {
4130
- const tag = reader.uint32();
4131
- switch (tag >>> 3) {
4132
- case 1: {
4133
- if (tag !== 9) {
4134
- break;
4135
- }
4136
- message.x = reader.double();
4137
- continue;
4138
- }
4139
- case 2: {
4140
- if (tag !== 17) {
4141
- break;
4142
- }
4143
- message.y = reader.double();
4144
- continue;
4145
- }
4146
- }
4147
- if ((tag & 7) === 4 || tag === 0) {
4148
- break;
4149
- }
4150
- reader.skip(tag & 7);
4151
- }
4152
- return message;
4153
- },
4154
- fromJSON(object) {
4155
- return {
4156
- x: isSet3(object.x) ? globalThis.Number(object.x) : 0,
4157
- y: isSet3(object.y) ? globalThis.Number(object.y) : 0
4158
- };
4159
- },
4160
- toJSON(message) {
4161
- const obj = {};
4162
- if (message.x !== 0) {
4163
- obj.x = message.x;
4164
- }
4165
- if (message.y !== 0) {
4166
- obj.y = message.y;
4167
- }
4168
- return obj;
4169
- },
4170
- create(base) {
4171
- return Position.fromPartial(base ?? {});
4172
- },
4173
- fromPartial(object) {
4174
- const message = createBasePosition();
4175
- message.x = object.x ?? 0;
4176
- message.y = object.y ?? 0;
4177
- return message;
4178
- }
4179
- };
4180
- function isSet3(value) {
4181
- return value !== null && value !== void 0;
4182
- }
4183
-
4184
- // src/engine-identity.ts
4185
- var ENGINE_PROTOCOL_VERSION = String(11 /* PROTOCOL_VERSION_CURRENT */);
4186
- var ENGINE_CONTRACT = GENERATED_ENGINE_CONTRACT;
4187
- var EngineIdentityMismatchError = class extends Error {
4188
- constructor(engine, required) {
4189
- const behind = engine.protocol === required.protocol ? void 0 : Number(engine.protocol) < Number(required.protocol) ? "engine" : "host";
4190
- super(mismatchMessage(engine, required, behind));
4191
- this.name = "EngineIdentityMismatchError";
4192
- this.engineVersion = engine.version;
4193
- this.engineProtocol = engine.protocol;
4194
- this.engineContract = engine.contract;
4195
- this.requiredProtocol = required.protocol;
4196
- this.requiredContract = required.contract;
4197
- this.behind = behind;
4198
- }
4199
- };
4200
- function mismatchMessage(engine, required, behind) {
4201
- const protocols = `Lace engine ${engine.version} speaks protocol ${engine.protocol}; this host speaks protocol ${required.protocol}`;
4202
- switch (behind) {
4203
- case "engine":
4204
- return `${protocols}: update the Lace CLI`;
4205
- case "host":
4206
- return `${protocols}: update this host`;
4207
- case void 0:
4208
- return `this host and Lace engine ${engine.version} were built from different trees of protocol ${required.protocol}: rebuild both from one checkout, or install the Lace CLI release that matches this host`;
4209
- }
4210
- }
4211
- function checkEngineIdentity(engine) {
4212
- if (engine.protocol !== ENGINE_PROTOCOL_VERSION || engine.contract !== ENGINE_CONTRACT) {
4213
- throw new EngineIdentityMismatchError(engine, {
4214
- protocol: ENGINE_PROTOCOL_VERSION,
4215
- contract: ENGINE_CONTRACT
4216
- });
4217
- }
4218
- }
4219
-
4220
- // src/render.ts
4221
- var META_ARGUMENTS = ["count", "for_each"];
4222
-
4223
- // src/projection/classify-child.ts
4224
- function isGroupUse(bundle, use) {
4225
- const target = bundle.modules[use.module];
4226
- return target !== void 0 && isGroupModule(target);
4227
- }
4228
- function isGroupModule(mod) {
4229
- return (mod.modules?.length ?? 0) > 0;
4230
- }
4231
-
4232
- // src/projection/derive-edges.ts
4233
- function emitEdgesFromBinding(binding, targetId, toInput, useIds, seen, edges) {
4234
- if (binding.out?.module && binding.out.name) {
4235
- edges.push({
4236
- source_instance: binding.out.module,
4237
- target_instance: targetId,
4238
- from_output: binding.out.name,
4239
- to_input: toInput
4240
- });
4241
- return;
4242
- }
4243
- for (const ref of binding.expr?.module_references ?? []) {
4244
- if (!useIds.has(ref.call)) continue;
4245
- const fromOutput = ref.output ?? "";
4246
- const key = `${ref.call}:${targetId}:${fromOutput}:${toInput}`;
4247
- if (seen.has(key)) continue;
4248
- seen.add(key);
4249
- edges.push({
4250
- source_instance: ref.call,
4251
- target_instance: targetId,
4252
- from_output: fromOutput,
4253
- to_input: toInput
4254
- });
4255
- }
4256
- }
4257
- function deriveEdges(uses) {
4258
- const useIds = new Set(uses.map((u) => u.id));
4259
- const edges = [];
4260
- const seen = /* @__PURE__ */ new Set();
4261
- for (const target of uses) {
4262
- const inputs = target.inputs ?? {};
4263
- for (const [inputName, binding] of Object.entries(inputs)) {
4264
- emitEdgesFromBinding(binding, target.id, inputName, useIds, seen, edges);
4265
- }
4266
- for (const meta of META_ARGUMENTS) {
4267
- const binding = target[meta];
4268
- if (binding) emitEdgesFromBinding(binding, target.id, meta, useIds, seen, edges);
4269
- }
4270
- }
4271
- return edges;
4272
- }
4273
- function addPin(index, call, pin) {
4274
- if (!index.has(call)) index.set(call, /* @__PURE__ */ new Set());
4275
- index.get(call).add(pin);
4276
- }
4277
- function indexWires(edges) {
4278
- const inputs = /* @__PURE__ */ new Map();
4279
- const outputs = /* @__PURE__ */ new Map();
4280
- for (const e of edges) {
4281
- addPin(inputs, e.target_instance, e.to_input);
4282
- addPin(outputs, e.source_instance, e.from_output);
4283
- }
4284
- return { inputs, outputs };
4285
- }
4286
- function deriveInterfaceEdges(mod) {
4287
- const uses = mod.modules ?? [];
4288
- const useIds = new Set(uses.map((u) => u.id));
4289
- const declaredIn = new Set((mod.interface?.inputs ?? []).map((i) => i.name));
4290
- const declaredOut = new Set((mod.interface?.outputs ?? []).map((o) => o.name));
4291
- const edges = [];
4292
- const fromInput = (pin, target, toInput) => {
4293
- if (!pin || !declaredIn.has(pin)) return;
4294
- edges.push({
4295
- source_instance: "",
4296
- target_instance: target,
4297
- from_output: pin,
4298
- to_input: toInput,
4299
- source_pin: true
4300
- });
4301
- };
4302
- for (const use of uses) {
4303
- for (const [name, binding] of Object.entries(use.inputs ?? {})) {
4304
- fromInput(binding.var ?? "", use.id, name);
4305
- }
4306
- for (const meta of META_ARGUMENTS) fromInput(use[meta]?.var ?? "", use.id, meta);
4307
- }
4308
- const seen = /* @__PURE__ */ new Set();
4309
- for (const [name, exported] of Object.entries(mod.exports?.outputs ?? {})) {
4310
- if (!declaredOut.has(name)) continue;
4311
- const read = [];
4312
- emitEdgesFromBinding(exported, "", name, useIds, seen, read);
4313
- for (const edge of read) {
4314
- if (useIds.has(edge.source_instance)) edges.push({ ...edge, target_pin: true });
4315
- }
4316
- if (exported.var && declaredIn.has(exported.var)) {
4317
- edges.push({
4318
- source_instance: "",
4319
- target_instance: "",
4320
- from_output: exported.var,
4321
- to_input: name,
4322
- source_pin: true,
4323
- target_pin: true
4324
- });
3767
+ if (exported.var && declaredIn.has(exported.var)) {
3768
+ edges.push({
3769
+ source_instance: "",
3770
+ target_instance: "",
3771
+ from_output: exported.var,
3772
+ to_input: name,
3773
+ source_pin: true,
3774
+ target_pin: true
3775
+ });
4325
3776
  }
4326
3777
  }
4327
3778
  return edges;
@@ -4382,12 +3833,6 @@ function instanceAddress(bundle, id) {
4382
3833
  const resolved = resolveInstance(bundle, id);
4383
3834
  return resolved ? { scope: resolved.scopeKey, id: resolved.child.id } : { scope: bundle.entry, id };
4384
3835
  }
4385
- function resolveScopePath(bundle, path) {
4386
- if (path === "") {
4387
- return bundle.modules[bundle.entry] ? bundle.entry : null;
4388
- }
4389
- return resolveInstance(bundle, path)?.child.use?.module ?? null;
4390
- }
4391
3836
 
4392
3837
  // src/projection/inspect.ts
4393
3838
  function hclLiteralText(lit) {
@@ -4651,56 +4096,10 @@ function deriveSettingsConfig(bundle, moduleKey) {
4651
4096
  };
4652
4097
  }
4653
4098
 
4654
- // src/projection/join-path.ts
4655
- function joinPath(prefix, localId) {
4656
- return prefix === "" ? localId : `${prefix}.${localId}`;
4657
- }
4658
- function splitPath(canvasPath) {
4659
- const lastDot = canvasPath.lastIndexOf(".");
4660
- if (lastDot === -1) return { parentPath: "", localId: canvasPath };
4661
- return { parentPath: canvasPath.slice(0, lastDot), localId: canvasPath.slice(lastDot + 1) };
4662
- }
4663
- function callText(sourcePath) {
4664
- return `module.${splitPath(sourcePath).localId}`;
4665
- }
4666
- function groupPinText(group, end, pin) {
4667
- return `${group}.${end === "source" ? "inputs" : "outputs"}.${pin}`;
4668
- }
4669
-
4670
4099
  // src/projection/node-for-address.ts
4671
- var INSTANCE_KEY = /\[[^\]]*\]$/;
4672
- function tokenizeAddress(address) {
4673
- const tokens = [];
4674
- let current = "";
4675
- let depth = 0;
4676
- for (const ch of address) {
4677
- if (ch === "[") depth++;
4678
- else if (ch === "]") depth--;
4679
- if (ch === "." && depth === 0) {
4680
- tokens.push(current);
4681
- current = "";
4682
- } else {
4683
- current += ch;
4684
- }
4685
- }
4686
- tokens.push(current);
4687
- return tokens;
4688
- }
4689
4100
  function nodeIdForAddress(view, address) {
4690
- const tokens = tokenizeAddress(address);
4691
- const moduleNames = [];
4692
- let i = 0;
4693
- while (i + 1 < tokens.length && tokens[i] === "module") {
4694
- moduleNames.push(tokens[i + 1].replace(INSTANCE_KEY, ""));
4695
- i += 2;
4696
- }
4697
- if (moduleNames.length === 0) return null;
4698
- const known = /* @__PURE__ */ new Set();
4699
- for (const n of view.nodes) known.add(n.id);
4700
- for (const g of view.groups) known.add(g.id);
4701
- for (let k = moduleNames.length; k >= 1; k--) {
4702
- let path = "";
4703
- for (let j = 0; j < k; j++) path = joinPath(path, moduleNames[j]);
4101
+ const known = new Set([...view.nodes, ...view.groups].map((item) => item.id));
4102
+ for (let path = moduleCallPath(address); path !== ""; path = splitPath(path).parentPath) {
4704
4103
  if (known.has(path)) return path;
4705
4104
  }
4706
4105
  return null;
@@ -4869,18 +4268,6 @@ function freeSlot(extent, occupied) {
4869
4268
  occupied.map((r) => ({ x: r.x, y: r.y, ...slotOf(r) }))
4870
4269
  );
4871
4270
  }
4872
- function resolveScopePositionsByDepth(ids, arrangementNodes, edges) {
4873
- const stored = /* @__PURE__ */ new Map();
4874
- for (const id of ids) {
4875
- const at = arrangementNodes?.[id];
4876
- if (at) stored.set(id, at);
4877
- }
4878
- return layoutByDepth(
4879
- ids.map((id) => ({ id, size: ORDINARY })),
4880
- stored,
4881
- edges
4882
- );
4883
- }
4884
4271
  function layoutByDepth(items, stored, edges) {
4885
4272
  const byId = new Map(items.map((item) => [item.id, item]));
4886
4273
  const ids = items.map((item) => item.id);
@@ -5232,16 +4619,12 @@ function projectCanvasView(bundle, arrangement, meta) {
5232
4619
  groups
5233
4620
  };
5234
4621
  }
5235
-
5236
- // src/proto-messages.ts
5237
- var CanvasViewProto = CanvasView;
5238
4622
  // Annotate the CommonJS export names for ESM import in node:
5239
4623
  0 && (module.exports = {
5240
4624
  BRIDGE_METHODS,
5241
4625
  Bundle,
5242
4626
  COLLAPSED_GROUP_WIDTH,
5243
4627
  CONNECT_CODE_NAMES,
5244
- CanvasViewProto,
5245
4628
  EMPTY_BUNDLE,
5246
4629
  ENGINE_CONTRACT,
5247
4630
  ENGINE_METHODS,
@@ -5252,9 +4635,13 @@ var CanvasViewProto = CanvasView;
5252
4635
  GROUP_PADDING,
5253
4636
  HOST_ONLY_METHODS,
5254
4637
  META_ARGUMENTS,
4638
+ Module,
5255
4639
  NODE_HEADER_HEIGHT,
5256
4640
  NODE_ROW_HEIGHT,
5257
4641
  NODE_WIDTH,
4642
+ Reason,
4643
+ Resource,
4644
+ Use,
5258
4645
  apiFields,
5259
4646
  boxAt,
5260
4647
  callText,
@@ -5281,6 +4668,7 @@ var CanvasViewProto = CanvasView;
5281
4668
  keepOrder,
5282
4669
  layoutByDepth,
5283
4670
  localIn,
4671
+ moduleCallPath,
5284
4672
  nodeIdForAddress,
5285
4673
  nodeIdForDiagnostic,
5286
4674
  nodeRows,
@@ -5289,9 +4677,10 @@ var CanvasViewProto = CanvasView;
5289
4677
  parseModuleKey,
5290
4678
  projectCanvasView,
5291
4679
  reachRect,
4680
+ reasonFromJSON,
4681
+ reasonToJSON,
5292
4682
  resolveInstance,
5293
- resolveScopePath,
5294
- resolveScopePositionsByDepth,
4683
+ splitAddress,
5295
4684
  splitPath,
5296
4685
  stepDown,
5297
4686
  visibleInputs