@lace-cloud/proto 0.35.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.
package/dist/index.mjs CHANGED
@@ -71,8 +71,11 @@ var CONNECT_CODE_NAMES = [
71
71
  "unauthenticated"
72
72
  ];
73
73
 
74
- // src/generated/state.ts
75
- import { BinaryReader as BinaryReader2, BinaryWriter as BinaryWriter2 } from "@bufbuild/protobuf/wire";
74
+ // src/engine-contract.gen.ts
75
+ var GENERATED_ENGINE_CONTRACT = "1cb0669ae6ff4b61580feed0bab111b8d54fdfffb2fe54d6fb22f5fe9c33a3d5";
76
+
77
+ // src/generated/service.ts
78
+ import { BinaryReader as BinaryReader3, BinaryWriter as BinaryWriter3 } from "@bufbuild/protobuf/wire";
76
79
 
77
80
  // src/generated/google/protobuf/struct.ts
78
81
  import { BinaryReader, BinaryWriter } from "@bufbuild/protobuf/wire";
@@ -501,6 +504,7 @@ function isSet(value) {
501
504
  }
502
505
 
503
506
  // src/generated/state.ts
507
+ import { BinaryReader as BinaryReader2, BinaryWriter as BinaryWriter2 } from "@bufbuild/protobuf/wire";
504
508
  function createBaseBundle() {
505
509
  return { schema_version: "", kind: "", entry: "", modules: {} };
506
510
  }
@@ -3301,1138 +3305,332 @@ function isSet2(value) {
3301
3305
  return value !== null && value !== void 0;
3302
3306
  }
3303
3307
 
3304
- // src/render.ts
3305
- var META_ARGUMENTS = ["count", "for_each"];
3306
-
3307
- // src/projection/derive-edges.ts
3308
- function emitEdgesFromBinding(binding, targetId, toInput, useIds, seen, edges) {
3309
- if (binding.out?.module && binding.out.name) {
3310
- edges.push({
3311
- source_instance: binding.out.module,
3312
- target_instance: targetId,
3313
- from_output: binding.out.name,
3314
- to_input: toInput
3315
- });
3316
- return;
3317
- }
3318
- for (const ref of binding.expr?.module_references ?? []) {
3319
- if (!useIds.has(ref.call)) continue;
3320
- const fromOutput = ref.output ?? "";
3321
- const key = `${ref.call}:${targetId}:${fromOutput}:${toInput}`;
3322
- if (seen.has(key)) continue;
3323
- seen.add(key);
3324
- edges.push({
3325
- source_instance: ref.call,
3326
- target_instance: targetId,
3327
- from_output: fromOutput,
3328
- to_input: toInput
3329
- });
3330
- }
3331
- }
3332
- function deriveEdges(uses) {
3333
- const useIds = new Set(uses.map((u) => u.id));
3334
- const edges = [];
3335
- const seen = /* @__PURE__ */ new Set();
3336
- for (const target of uses) {
3337
- const inputs = target.inputs ?? {};
3338
- for (const [inputName, binding] of Object.entries(inputs)) {
3339
- emitEdgesFromBinding(binding, target.id, inputName, useIds, seen, edges);
3340
- }
3341
- for (const meta of META_ARGUMENTS) {
3342
- const binding = target[meta];
3343
- if (binding) emitEdgesFromBinding(binding, target.id, meta, useIds, seen, edges);
3344
- }
3308
+ // src/generated/service.ts
3309
+ function nodeKindFromJSON(object) {
3310
+ switch (object) {
3311
+ case 0:
3312
+ case "NODE_KIND_UNSPECIFIED":
3313
+ return 0 /* NODE_KIND_UNSPECIFIED */;
3314
+ case 1:
3315
+ case "NODE_KIND_MODULE":
3316
+ return 1 /* NODE_KIND_MODULE */;
3317
+ case 2:
3318
+ case "NODE_KIND_RESOURCE":
3319
+ return 2 /* NODE_KIND_RESOURCE */;
3320
+ case 3:
3321
+ case "NODE_KIND_DATA":
3322
+ return 3 /* NODE_KIND_DATA */;
3323
+ case -1:
3324
+ case "UNRECOGNIZED":
3325
+ default:
3326
+ return -1 /* UNRECOGNIZED */;
3345
3327
  }
3346
- return edges;
3347
3328
  }
3348
- function indexWires(edges) {
3349
- const inputs = /* @__PURE__ */ new Map();
3350
- const outputs = /* @__PURE__ */ new Map();
3351
- for (const e of edges) {
3352
- if (!inputs.has(e.target_instance)) inputs.set(e.target_instance, /* @__PURE__ */ new Set());
3353
- inputs.get(e.target_instance).add(e.to_input);
3354
- if (!outputs.has(e.source_instance)) outputs.set(e.source_instance, /* @__PURE__ */ new Set());
3355
- outputs.get(e.source_instance).add(e.from_output);
3329
+ function nodeKindToJSON(object) {
3330
+ switch (object) {
3331
+ case 0 /* NODE_KIND_UNSPECIFIED */:
3332
+ return "NODE_KIND_UNSPECIFIED";
3333
+ case 1 /* NODE_KIND_MODULE */:
3334
+ return "NODE_KIND_MODULE";
3335
+ case 2 /* NODE_KIND_RESOURCE */:
3336
+ return "NODE_KIND_RESOURCE";
3337
+ case 3 /* NODE_KIND_DATA */:
3338
+ return "NODE_KIND_DATA";
3339
+ case -1 /* UNRECOGNIZED */:
3340
+ default:
3341
+ return "UNRECOGNIZED";
3356
3342
  }
3357
- return { inputs, outputs };
3358
- }
3359
- function callWires(wiredIn, wiredOut) {
3360
- return {
3361
- call_wired: wiredOut.has(""),
3362
- meta_wired: META_ARGUMENTS.filter((meta) => wiredIn.has(meta))
3363
- };
3364
3343
  }
3365
-
3366
- // src/projection/resolve-schema.ts
3367
- function resolveSchema(bundle, use, readOutputs) {
3368
- const target = bundle.modules[use.module];
3369
- if (!target) return { inputs: [], outputs: [] };
3370
- if (target.interface) {
3371
- return { inputs: target.interface.inputs, outputs: target.interface.outputs };
3372
- }
3373
- return {
3374
- inputs: Object.keys(use.inputs ?? {}).sort().map((name) => InputDef.create({ name })),
3375
- outputs: [...new Set(readOutputs)].filter((name) => name !== "").sort().map((name) => OutputDef.create({ name }))
3376
- };
3344
+ function createBaseCanvasView() {
3345
+ return { module_name: "", nodes: [], edges: [], can_undo: false, can_redo: false, unsaved: false, groups: [] };
3377
3346
  }
3378
- function findChild(mod, id) {
3379
- for (const use of mod.modules ?? []) {
3380
- if (use.id === id) return { id, use };
3381
- }
3382
- for (const resource of mod.resources ?? []) {
3383
- if (resource.id === id) return { id, resource };
3347
+ var CanvasView = {
3348
+ encode(message, writer = new BinaryWriter3()) {
3349
+ if (message.module_name !== "") {
3350
+ writer.uint32(10).string(message.module_name);
3351
+ }
3352
+ for (const v of message.nodes) {
3353
+ RenderNode.encode(v, writer.uint32(18).fork()).join();
3354
+ }
3355
+ for (const v of message.edges) {
3356
+ RenderEdge.encode(v, writer.uint32(26).fork()).join();
3357
+ }
3358
+ if (message.can_undo !== false) {
3359
+ writer.uint32(40).bool(message.can_undo);
3360
+ }
3361
+ if (message.can_redo !== false) {
3362
+ writer.uint32(48).bool(message.can_redo);
3363
+ }
3364
+ if (message.unsaved !== false) {
3365
+ writer.uint32(56).bool(message.unsaved);
3366
+ }
3367
+ for (const v of message.groups) {
3368
+ RenderGroup.encode(v, writer.uint32(66).fork()).join();
3369
+ }
3370
+ return writer;
3371
+ },
3372
+ decode(input, length) {
3373
+ const reader = input instanceof BinaryReader3 ? input : new BinaryReader3(input);
3374
+ const end = length === void 0 ? reader.len : reader.pos + length;
3375
+ const message = createBaseCanvasView();
3376
+ while (reader.pos < end) {
3377
+ const tag = reader.uint32();
3378
+ switch (tag >>> 3) {
3379
+ case 1: {
3380
+ if (tag !== 10) {
3381
+ break;
3382
+ }
3383
+ message.module_name = reader.string();
3384
+ continue;
3385
+ }
3386
+ case 2: {
3387
+ if (tag !== 18) {
3388
+ break;
3389
+ }
3390
+ message.nodes.push(RenderNode.decode(reader, reader.uint32()));
3391
+ continue;
3392
+ }
3393
+ case 3: {
3394
+ if (tag !== 26) {
3395
+ break;
3396
+ }
3397
+ message.edges.push(RenderEdge.decode(reader, reader.uint32()));
3398
+ continue;
3399
+ }
3400
+ case 5: {
3401
+ if (tag !== 40) {
3402
+ break;
3403
+ }
3404
+ message.can_undo = reader.bool();
3405
+ continue;
3406
+ }
3407
+ case 6: {
3408
+ if (tag !== 48) {
3409
+ break;
3410
+ }
3411
+ message.can_redo = reader.bool();
3412
+ continue;
3413
+ }
3414
+ case 7: {
3415
+ if (tag !== 56) {
3416
+ break;
3417
+ }
3418
+ message.unsaved = reader.bool();
3419
+ continue;
3420
+ }
3421
+ case 8: {
3422
+ if (tag !== 66) {
3423
+ break;
3424
+ }
3425
+ message.groups.push(RenderGroup.decode(reader, reader.uint32()));
3426
+ continue;
3427
+ }
3428
+ }
3429
+ if ((tag & 7) === 4 || tag === 0) {
3430
+ break;
3431
+ }
3432
+ reader.skip(tag & 7);
3433
+ }
3434
+ return message;
3435
+ },
3436
+ fromJSON(object) {
3437
+ return {
3438
+ module_name: isSet3(object.moduleName) ? globalThis.String(object.moduleName) : isSet3(object.module_name) ? globalThis.String(object.module_name) : "",
3439
+ nodes: globalThis.Array.isArray(object?.nodes) ? object.nodes.map((e) => RenderNode.fromJSON(e)) : [],
3440
+ edges: globalThis.Array.isArray(object?.edges) ? object.edges.map((e) => RenderEdge.fromJSON(e)) : [],
3441
+ can_undo: isSet3(object.canUndo) ? globalThis.Boolean(object.canUndo) : isSet3(object.can_undo) ? globalThis.Boolean(object.can_undo) : false,
3442
+ can_redo: isSet3(object.canRedo) ? globalThis.Boolean(object.canRedo) : isSet3(object.can_redo) ? globalThis.Boolean(object.can_redo) : false,
3443
+ unsaved: isSet3(object.unsaved) ? globalThis.Boolean(object.unsaved) : false,
3444
+ groups: globalThis.Array.isArray(object?.groups) ? object.groups.map((e) => RenderGroup.fromJSON(e)) : []
3445
+ };
3446
+ },
3447
+ toJSON(message) {
3448
+ const obj = {};
3449
+ if (message.module_name !== "") {
3450
+ obj.moduleName = message.module_name;
3451
+ }
3452
+ if (message.nodes?.length) {
3453
+ obj.nodes = message.nodes.map((e) => RenderNode.toJSON(e));
3454
+ }
3455
+ if (message.edges?.length) {
3456
+ obj.edges = message.edges.map((e) => RenderEdge.toJSON(e));
3457
+ }
3458
+ if (message.can_undo !== false) {
3459
+ obj.canUndo = message.can_undo;
3460
+ }
3461
+ if (message.can_redo !== false) {
3462
+ obj.canRedo = message.can_redo;
3463
+ }
3464
+ if (message.unsaved !== false) {
3465
+ obj.unsaved = message.unsaved;
3466
+ }
3467
+ if (message.groups?.length) {
3468
+ obj.groups = message.groups.map((e) => RenderGroup.toJSON(e));
3469
+ }
3470
+ return obj;
3471
+ },
3472
+ create(base) {
3473
+ return CanvasView.fromPartial(base ?? {});
3474
+ },
3475
+ fromPartial(object) {
3476
+ const message = createBaseCanvasView();
3477
+ message.module_name = object.module_name ?? "";
3478
+ message.nodes = object.nodes?.map((e) => RenderNode.fromPartial(e)) || [];
3479
+ message.edges = object.edges?.map((e) => RenderEdge.fromPartial(e)) || [];
3480
+ message.can_undo = object.can_undo ?? false;
3481
+ message.can_redo = object.can_redo ?? false;
3482
+ message.unsaved = object.unsaved ?? false;
3483
+ message.groups = object.groups?.map((e) => RenderGroup.fromPartial(e)) || [];
3484
+ return message;
3384
3485
  }
3385
- return null;
3386
- }
3387
- function resolveInstance(bundle, id) {
3388
- return resolveFrom(bundle, bundle.entry, id);
3486
+ };
3487
+ function createBaseRenderGroup() {
3488
+ return { id: "", label: "", node_ids: [], collapsed: false, module_key: "", inputs: [], outputs: [] };
3389
3489
  }
3390
- function resolveFrom(bundle, scopeKey, id) {
3391
- const scope = bundle.modules[scopeKey];
3392
- if (!scope) return null;
3393
- for (const use of scope.modules ?? []) {
3394
- if (!id.startsWith(`${use.id}.`)) continue;
3395
- const nested = resolveFrom(bundle, use.module, id.slice(use.id.length + 1));
3396
- if (nested) return nested;
3397
- }
3398
- const child = findChild(scope, id);
3399
- return child ? { scopeKey, scope, child } : null;
3400
- }
3401
- function instanceAddress(bundle, id) {
3402
- const resolved = resolveInstance(bundle, id);
3403
- return resolved ? { scope: resolved.scopeKey, id: resolved.child.id } : { scope: bundle.entry, id };
3404
- }
3405
- function resolveScopePath(bundle, path) {
3406
- if (path === "") {
3407
- return bundle.modules[bundle.entry] ? bundle.entry : null;
3408
- }
3409
- return resolveInstance(bundle, path)?.child.use?.module ?? null;
3410
- }
3411
-
3412
- // src/projection/inspect.ts
3413
- function hclLiteralText(lit) {
3414
- if (typeof lit === "string") return quoteHclString(lit);
3415
- if (typeof lit === "number" || typeof lit === "boolean") return String(lit);
3416
- if (Array.isArray(lit)) return `[${lit.map(hclLiteralText).join(", ")}]`;
3417
- if (lit !== null && typeof lit === "object") {
3418
- return hclObjectText(lit);
3419
- }
3420
- return String(lit);
3421
- }
3422
- function quoteHclString(s) {
3423
- let out = "";
3424
- for (let i = 0; i < s.length; i++) {
3425
- const c = s[i];
3426
- switch (c) {
3427
- case "\\":
3428
- out += "\\\\";
3429
- break;
3430
- case '"':
3431
- out += '\\"';
3432
- break;
3433
- case "\n":
3434
- out += "\\n";
3435
- break;
3436
- case "\r":
3437
- out += "\\r";
3438
- break;
3439
- case " ":
3440
- out += "\\t";
3441
- break;
3442
- case "$":
3443
- case "%":
3444
- out += s[i + 1] === "{" ? c + c : c;
3490
+ var RenderGroup = {
3491
+ encode(message, writer = new BinaryWriter3()) {
3492
+ if (message.id !== "") {
3493
+ writer.uint32(10).string(message.id);
3494
+ }
3495
+ if (message.label !== "") {
3496
+ writer.uint32(18).string(message.label);
3497
+ }
3498
+ for (const v of message.node_ids) {
3499
+ writer.uint32(26).string(v);
3500
+ }
3501
+ if (message.collapsed !== false) {
3502
+ writer.uint32(32).bool(message.collapsed);
3503
+ }
3504
+ if (message.module_key !== "") {
3505
+ writer.uint32(42).string(message.module_key);
3506
+ }
3507
+ for (const v of message.inputs) {
3508
+ NodePin.encode(v, writer.uint32(50).fork()).join();
3509
+ }
3510
+ for (const v of message.outputs) {
3511
+ NodePin.encode(v, writer.uint32(58).fork()).join();
3512
+ }
3513
+ return writer;
3514
+ },
3515
+ decode(input, length) {
3516
+ const reader = input instanceof BinaryReader3 ? input : new BinaryReader3(input);
3517
+ const end = length === void 0 ? reader.len : reader.pos + length;
3518
+ const message = createBaseRenderGroup();
3519
+ while (reader.pos < end) {
3520
+ const tag = reader.uint32();
3521
+ switch (tag >>> 3) {
3522
+ case 1: {
3523
+ if (tag !== 10) {
3524
+ break;
3525
+ }
3526
+ message.id = reader.string();
3527
+ continue;
3528
+ }
3529
+ case 2: {
3530
+ if (tag !== 18) {
3531
+ break;
3532
+ }
3533
+ message.label = reader.string();
3534
+ continue;
3535
+ }
3536
+ case 3: {
3537
+ if (tag !== 26) {
3538
+ break;
3539
+ }
3540
+ message.node_ids.push(reader.string());
3541
+ continue;
3542
+ }
3543
+ case 4: {
3544
+ if (tag !== 32) {
3545
+ break;
3546
+ }
3547
+ message.collapsed = reader.bool();
3548
+ continue;
3549
+ }
3550
+ case 5: {
3551
+ if (tag !== 42) {
3552
+ break;
3553
+ }
3554
+ message.module_key = reader.string();
3555
+ continue;
3556
+ }
3557
+ case 6: {
3558
+ if (tag !== 50) {
3559
+ break;
3560
+ }
3561
+ message.inputs.push(NodePin.decode(reader, reader.uint32()));
3562
+ continue;
3563
+ }
3564
+ case 7: {
3565
+ if (tag !== 58) {
3566
+ break;
3567
+ }
3568
+ message.outputs.push(NodePin.decode(reader, reader.uint32()));
3569
+ continue;
3570
+ }
3571
+ }
3572
+ if ((tag & 7) === 4 || tag === 0) {
3445
3573
  break;
3446
- default:
3447
- out += c;
3574
+ }
3575
+ reader.skip(tag & 7);
3576
+ }
3577
+ return message;
3578
+ },
3579
+ fromJSON(object) {
3580
+ return {
3581
+ id: isSet3(object.id) ? globalThis.String(object.id) : "",
3582
+ label: isSet3(object.label) ? globalThis.String(object.label) : "",
3583
+ 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)) : [],
3584
+ collapsed: isSet3(object.collapsed) ? globalThis.Boolean(object.collapsed) : false,
3585
+ module_key: isSet3(object.moduleKey) ? globalThis.String(object.moduleKey) : isSet3(object.module_key) ? globalThis.String(object.module_key) : "",
3586
+ inputs: globalThis.Array.isArray(object?.inputs) ? object.inputs.map((e) => NodePin.fromJSON(e)) : [],
3587
+ outputs: globalThis.Array.isArray(object?.outputs) ? object.outputs.map((e) => NodePin.fromJSON(e)) : []
3588
+ };
3589
+ },
3590
+ toJSON(message) {
3591
+ const obj = {};
3592
+ if (message.id !== "") {
3593
+ obj.id = message.id;
3448
3594
  }
3595
+ if (message.label !== "") {
3596
+ obj.label = message.label;
3597
+ }
3598
+ if (message.node_ids?.length) {
3599
+ obj.nodeIds = message.node_ids;
3600
+ }
3601
+ if (message.collapsed !== false) {
3602
+ obj.collapsed = message.collapsed;
3603
+ }
3604
+ if (message.module_key !== "") {
3605
+ obj.moduleKey = message.module_key;
3606
+ }
3607
+ if (message.inputs?.length) {
3608
+ obj.inputs = message.inputs.map((e) => NodePin.toJSON(e));
3609
+ }
3610
+ if (message.outputs?.length) {
3611
+ obj.outputs = message.outputs.map((e) => NodePin.toJSON(e));
3612
+ }
3613
+ return obj;
3614
+ },
3615
+ create(base) {
3616
+ return RenderGroup.fromPartial(base ?? {});
3617
+ },
3618
+ fromPartial(object) {
3619
+ const message = createBaseRenderGroup();
3620
+ message.id = object.id ?? "";
3621
+ message.label = object.label ?? "";
3622
+ message.node_ids = object.node_ids?.map((e) => e) || [];
3623
+ message.collapsed = object.collapsed ?? false;
3624
+ message.module_key = object.module_key ?? "";
3625
+ message.inputs = object.inputs?.map((e) => NodePin.fromPartial(e)) || [];
3626
+ message.outputs = object.outputs?.map((e) => NodePin.fromPartial(e)) || [];
3627
+ return message;
3449
3628
  }
3450
- return `"${out}"`;
3451
- }
3452
- function hclObjectText(obj) {
3453
- const entries = Object.entries(obj).sort(([a], [b]) => a < b ? -1 : a > b ? 1 : 0);
3454
- if (entries.length === 0) return "{}";
3455
- const width = Math.max(...entries.map(([k]) => k.length)) + 1;
3456
- const lines = entries.map(([k, v]) => ` ${k.padEnd(width)}= ${hclLiteralText(v)}`);
3457
- return `{
3458
- ${lines.join("\n")}
3459
- }`;
3460
- }
3461
- function bindingText(b) {
3462
- if (!b) return "";
3463
- if (b.lit !== void 0 && b.lit !== null) return hclLiteralText(b.lit);
3464
- if (b.var) return `var.${b.var}`;
3465
- if (b.out) return `module.${b.out.module}.${b.out.name}`;
3466
- if (b.expr) return b.expr.value;
3467
- return "";
3468
- }
3469
- function exportText(e) {
3470
- if (!e) return "";
3471
- if (e.out) return `${childReference(e.out.module)}.${e.out.name}`;
3472
- return bindingText({ lit: e.lit, var: e.var, out: void 0, expr: e.expr });
3473
- }
3474
- function childReference(id) {
3475
- if (id.startsWith("resource.")) return id.slice("resource.".length);
3476
- if (id.startsWith("data.")) return id;
3477
- return `module.${id}`;
3478
- }
3479
- function bindingMode(b) {
3480
- if (!b) return { mode: "empty" };
3481
- if (b.out) return { mode: "wired", wired_source: bindingText(b) };
3482
- if (b.var) return { mode: "variable", variable: b.var };
3483
- if (b.expr) return { mode: "expression", expression: b.expr.value };
3484
- if (b.lit !== void 0 && b.lit !== null) return { mode: "literal", value: b.lit };
3485
- return { mode: "empty" };
3629
+ };
3630
+ function createBaseRenderNode() {
3631
+ return { id: "", label: "", kind: 0, module_key: "", icon_url: "", position: void 0, inputs: [], outputs: [] };
3486
3632
  }
3487
- function deriveNodeConfig(bundle, instanceId) {
3488
- const resolved = resolveInstance(bundle, instanceId);
3489
- if (!resolved) return null;
3490
- const { scope, child } = resolved;
3491
- const readOutputs = indexWires(deriveEdges(scope.modules ?? [])).outputs.get(child.id) ?? [];
3492
- const schema = child.use ? resolveSchema(bundle, child.use, readOutputs) : { inputs: [], outputs: [] };
3493
- const schemaInputs = schema.inputs;
3494
- const schemaOutputs = schema.outputs;
3495
- const boundInputs = child.use?.inputs ?? child.resource?.inputs ?? {};
3496
- const inputs = schemaInputs.map((def) => ({
3497
- name: def.name,
3498
- type: def.type,
3499
- required: def.required,
3500
- description: def.description || void 0,
3501
- default_value: def.default_value,
3502
- validation: def.validation?.[0] ? { condition: def.validation[0].condition, error_message: def.validation[0].error_message } : void 0,
3503
- ...bindingMode(boundInputs[def.name])
3504
- }));
3505
- const outputs = schemaOutputs.map((def) => ({
3506
- name: def.name,
3507
- type: def.type,
3508
- description: def.description || void 0,
3509
- sensitive: def.sensitive || void 0
3510
- }));
3511
- const dependencyOptions = [
3512
- ...(scope.modules ?? []).map((u) => u.id),
3513
- ...(scope.resources ?? []).map((r) => r.id)
3514
- ].filter((id) => id !== child.id).map(childReference);
3515
- const dependsOn = child.use?.depends_on ?? child.resource?.depends_on ?? [];
3516
- const providers = child.use?.providers ?? {};
3517
- const meta = child.use ?? child.resource;
3518
- const availableVariables = (scope.interface?.inputs ?? []).map((v) => ({
3519
- name: v.name,
3520
- type: v.type
3521
- }));
3522
- return {
3523
- instance_id: instanceId,
3524
- module_key: child.use?.module,
3525
- source: child.use ? callSource(bundle, resolved.scopeKey, child.use.module) : void 0,
3526
- inputs,
3527
- outputs,
3528
- dependency_options: dependencyOptions,
3529
- depends_on: dependsOn,
3530
- providers,
3531
- count: bindingText(meta?.count),
3532
- for_each: bindingText(meta?.for_each),
3533
- available_variables: availableVariables
3534
- };
3535
- }
3536
- function callSource(bundle, scopeKey, moduleKey) {
3537
- const from = dirOf(bundle, scopeKey);
3538
- const to = sourceDir(bundle, moduleKey);
3539
- if (from !== void 0 && to !== void 0) return memberSourcePath(from, to);
3540
- const source = bundle.modules[moduleKey]?.source;
3541
- return source ? sourceText(source) : "";
3542
- }
3543
- function isMemberDir(id) {
3544
- return id !== "" && id !== "." && id !== ".." && !id.startsWith("./") && !id.startsWith("../") && !id.startsWith("/");
3545
- }
3546
- function dirOf(bundle, key) {
3547
- if (key === bundle.entry) return "";
3548
- const mod = bundle.modules[key];
3549
- if (!mod || mod.source || !isMemberDir(mod.id)) return void 0;
3550
- return mod.id;
3551
- }
3552
- function sourceDir(bundle, key) {
3553
- const dir = dirOf(bundle, key);
3554
- if (dir !== void 0) return dir;
3555
- const mod = bundle.modules[key];
3556
- return mod?.source?.kind === "local" && isMemberDir(mod.id) ? mod.id : void 0;
3557
- }
3558
- function memberSourcePath(from, to) {
3559
- const base = from === "" ? [] : from.split("/");
3560
- const target = to.split("/");
3561
- let shared = 0;
3562
- while (shared < base.length && shared < target.length && base[shared] === target[shared]) {
3563
- shared++;
3564
- }
3565
- const rel = [...base.slice(shared).map(() => ".."), ...target.slice(shared)].join("/") || ".";
3566
- return rel.startsWith("../") ? rel : `./${rel}`;
3567
- }
3568
- function sourceText(source) {
3569
- if (source.kind === "git") {
3570
- const subdir = source.subdir ? `//${source.subdir}` : "";
3571
- const ref = source.ref ? `?ref=${source.ref}` : "";
3572
- return `git::${source.repo}${subdir}${ref}`;
3573
- }
3574
- return source.kind === "local" ? source.subdir : source.ref;
3575
- }
3576
- function defaultText(value) {
3577
- return value === void 0 || value === null ? "null" : hclLiteralText(value);
3578
- }
3579
- function blockConfigs(blocks) {
3580
- return (blocks ?? []).map((b) => ({
3581
- type: b.type,
3582
- labels: [...b.labels],
3583
- attributes: b.attributes.map((a) => ({ name: a.name, value: bindingText(a.value) })),
3584
- blocks: blockConfigs(b.blocks)
3585
- }));
3586
- }
3587
- function resourceConfig(r) {
3588
- const kind = r.kind === "data" ? "data" : "resource";
3589
- return {
3590
- id: r.id,
3591
- kind,
3592
- type: r.type,
3593
- name: r.id.slice(`${kind}.${r.type}.`.length),
3594
- arguments: Object.keys(r.inputs ?? {}).sort().map((name) => ({ name, value: bindingText(r.inputs[name]) })),
3595
- blocks: blockConfigs(r.blocks),
3596
- count: bindingText(r.count),
3597
- for_each: bindingText(r.for_each),
3598
- provider: r.provider_ref,
3599
- depends_on: [...r.depends_on ?? []]
3600
- };
3601
- }
3602
- function deriveSettingsConfig(bundle, moduleKey) {
3603
- const mod = bundle.modules[moduleKey];
3604
- if (!mod) return null;
3605
- const terraform = mod.terraform ? {
3606
- required_version: mod.terraform.required_version,
3607
- required_providers: Object.entries(mod.terraform.required_providers ?? {}).map(
3608
- ([name, req]) => ({
3609
- name,
3610
- source: req.source,
3611
- version: req.version,
3612
- configuration_aliases: req.configuration_aliases
3613
- })
3614
- )
3615
- } : { required_version: "", required_providers: [] };
3616
- const providers = (mod.providers ?? []).map((p) => {
3617
- const config = {};
3618
- for (const [k, v] of Object.entries(p.config ?? {})) {
3619
- config[k] = bindingText(v);
3620
- }
3621
- return { name: p.name, alias: p.alias, config, blocks: blockConfigs(p.blocks) };
3622
- });
3623
- const locals = (mod.locals ?? []).map((l) => ({ name: l.name, value: bindingText(l.value) }));
3624
- const variables = (mod.interface?.inputs ?? []).map((v) => ({
3625
- name: v.name,
3626
- type: v.type,
3627
- required: v.required,
3628
- description: v.description || void 0,
3629
- default_value: v.default_value,
3630
- validation: v.validation?.map((b) => ({
3631
- condition: b.condition,
3632
- error_message: b.error_message
3633
- })),
3634
- ephemeral: v.ephemeral,
3635
- sensitive: v.sensitive || void 0,
3636
- nullable: v.nullable,
3637
- default: v.required ? "" : defaultText(v.default_value)
3638
- }));
3639
- const outputs = (mod.interface?.outputs ?? []).map((o) => ({
3640
- name: o.name,
3641
- type: o.type,
3642
- value: exportText(mod.exports?.outputs?.[o.name]),
3643
- description: o.description || void 0,
3644
- sensitive: o.sensitive || void 0,
3645
- depends_on: o.depends_on
3646
- }));
3647
- const read = indexWires(deriveEdges(mod.modules ?? [])).outputs;
3648
- const callOutputs = (mod.modules ?? []).flatMap(
3649
- (use) => resolveSchema(bundle, use, read.get(use.id) ?? []).outputs.map(
3650
- (o) => `module.${use.id}.${o.name}`
3651
- )
3652
- );
3653
- const resources = (mod.resources ?? []).map(resourceConfig);
3654
- const leaf = !mod.source && moduleKey !== bundle.entry && (mod.modules ?? []).length === 0;
3655
- return {
3656
- module_key: moduleKey,
3657
- reference: mod.source ? { source: sourceText(mod.source), version: mod.version } : void 0,
3658
- terraform,
3659
- providers,
3660
- locals,
3661
- variables,
3662
- outputs,
3663
- resources,
3664
- holds_managed_resources: resources.some((r) => r.kind === "resource") || leaf,
3665
- directives: blockConfigs(mod.top_level_blocks),
3666
- call_outputs: callOutputs,
3667
- dependency_options: [
3668
- ...(mod.modules ?? []).map((u) => childReference(u.id)),
3669
- ...(mod.resources ?? []).map((r) => childReference(r.id))
3670
- ]
3671
- };
3672
- }
3673
-
3674
- // src/projection/join-path.ts
3675
- function joinPath(prefix, localId) {
3676
- return prefix === "" ? localId : `${prefix}.${localId}`;
3677
- }
3678
- function splitPath(canvasPath) {
3679
- const lastDot = canvasPath.lastIndexOf(".");
3680
- if (lastDot === -1) return { parentPath: "", localId: canvasPath };
3681
- return { parentPath: canvasPath.slice(0, lastDot), localId: canvasPath.slice(lastDot + 1) };
3682
- }
3683
- function callText(sourcePath) {
3684
- return `module.${splitPath(sourcePath).localId}`;
3685
- }
3686
-
3687
- // src/projection/node-for-address.ts
3688
- var INSTANCE_KEY = /\[[^\]]*\]$/;
3689
- function tokenizeAddress(address) {
3690
- const tokens = [];
3691
- let current = "";
3692
- let depth = 0;
3693
- for (const ch of address) {
3694
- if (ch === "[") depth++;
3695
- else if (ch === "]") depth--;
3696
- if (ch === "." && depth === 0) {
3697
- tokens.push(current);
3698
- current = "";
3699
- } else {
3700
- current += ch;
3701
- }
3702
- }
3703
- tokens.push(current);
3704
- return tokens;
3705
- }
3706
- function nodeIdForAddress(view, address) {
3707
- const tokens = tokenizeAddress(address);
3708
- const moduleNames = [];
3709
- let i = 0;
3710
- while (i + 1 < tokens.length && tokens[i] === "module") {
3711
- moduleNames.push(tokens[i + 1].replace(INSTANCE_KEY, ""));
3712
- i += 2;
3713
- }
3714
- if (moduleNames.length === 0) return null;
3715
- const known = /* @__PURE__ */ new Set();
3716
- for (const n of view.nodes) known.add(n.id);
3717
- for (const g of view.groups) known.add(g.id);
3718
- for (let k = moduleNames.length; k >= 1; k--) {
3719
- let path = "";
3720
- for (let j = 0; j < k; j++) path = joinPath(path, moduleNames[j]);
3721
- if (known.has(path)) return path;
3722
- }
3723
- return null;
3724
- }
3725
-
3726
- // src/projection/node-for-diagnostic.ts
3727
- function buildScopeIndex(view) {
3728
- const byModuleKey = /* @__PURE__ */ new Map();
3729
- const known = /* @__PURE__ */ new Set();
3730
- for (const n of view.nodes) known.add(n.id);
3731
- for (const g of view.groups) {
3732
- known.add(g.id);
3733
- if (g.module_key) {
3734
- const ids = byModuleKey.get(g.module_key);
3735
- if (ids) ids.push(g.id);
3736
- else byModuleKey.set(g.module_key, [g.id]);
3737
- }
3738
- }
3739
- return { byModuleKey, known };
3740
- }
3741
- function nodeIdForDiagnostic(view, diagnostic) {
3742
- if (diagnostic.address) return nodeIdForAddress(view, diagnostic.address);
3743
- if (!diagnostic.instance_id) return null;
3744
- const index = buildScopeIndex(view);
3745
- const scopeIds = diagnostic.module_key ? index.byModuleKey.get(diagnostic.module_key) : void 0;
3746
- if (!scopeIds || scopeIds.length === 0) {
3747
- return index.known.has(diagnostic.instance_id) ? diagnostic.instance_id : null;
3748
- }
3749
- if (scopeIds.length > 1) return null;
3750
- const nodeId = `${scopeIds[0]}.${diagnostic.instance_id}`;
3751
- return index.known.has(nodeId) ? nodeId : null;
3752
- }
3753
-
3754
- // src/projection/geometry.ts
3755
- var NODE_WIDTH = 200;
3756
- var NODE_HEADER_HEIGHT = 28;
3757
- var NODE_ROW_HEIGHT = 22;
3758
- var GROUP_PADDING = { x: 40, top: 60, bottom: 20 };
3759
- var GROUP_HEADER_HEIGHT = 32;
3760
- var COLLAPSED_GROUP_WIDTH = 220;
3761
- function visibleInputs(inputs) {
3762
- return inputs.filter((pin) => pin.required || pin.wired);
3763
- }
3764
- function nodeRows(node) {
3765
- const shown = visibleInputs(node.inputs);
3766
- const folded = node.inputs.length > shown.length ? 1 : 0;
3767
- return Math.max(shown.length + folded, node.outputs.length);
3768
- }
3769
- function nodeSize(node) {
3770
- return { width: NODE_WIDTH, height: NODE_HEADER_HEIGHT + nodeRows(node) * NODE_ROW_HEIGHT };
3771
- }
3772
- function inputPinY(node, name) {
3773
- const row = visibleInputs(node.inputs).findIndex((pin) => pin.name === name);
3774
- return row < 0 ? NODE_HEADER_HEIGHT / 2 : NODE_HEADER_HEIGHT + (row + 0.5) * NODE_ROW_HEIGHT;
3775
- }
3776
- function extentOf(rects) {
3777
- if (rects.length === 0) return { x: 0, y: 0, width: 0, height: 0 };
3778
- const x = Math.min(...rects.map((r) => r.x));
3779
- const y = Math.min(...rects.map((r) => r.y));
3780
- return {
3781
- x,
3782
- y,
3783
- width: Math.max(...rects.map((r) => r.x + r.width)) - x,
3784
- height: Math.max(...rects.map((r) => r.y + r.height)) - y
3785
- };
3786
- }
3787
- function groupBoxSize(content) {
3788
- return {
3789
- width: content.width + 2 * GROUP_PADDING.x,
3790
- height: GROUP_PADDING.top + content.height + GROUP_PADDING.bottom
3791
- };
3792
- }
3793
- function collapsedGroupSize(pins) {
3794
- const rows = Math.max(pins.inputs?.length ?? 0, pins.outputs?.length ?? 0);
3795
- return { width: COLLAPSED_GROUP_WIDTH, height: GROUP_HEADER_HEIGHT + rows * NODE_ROW_HEIGHT };
3796
- }
3797
- function groupPinY(row) {
3798
- return GROUP_HEADER_HEIGHT + (row + 0.5) * NODE_ROW_HEIGHT;
3799
- }
3800
- function groupInputPinY(group, name) {
3801
- const row = (group.inputs ?? []).findIndex((pin) => pin.name === name);
3802
- return row < 0 ? GROUP_HEADER_HEIGHT / 2 : groupPinY(row);
3803
- }
3804
- function groupFootprint(group, box) {
3805
- return group.collapsed ? collapsedGroupSize(group) : box;
3806
- }
3807
- function groupReach(pins, box) {
3808
- const card = collapsedGroupSize(pins);
3809
- return { width: Math.max(card.width, box.width), height: Math.max(card.height, box.height) };
3810
- }
3811
-
3812
- // src/projection/frames.ts
3813
- var ZERO = { x: 0, y: 0 };
3814
- function boxAt(origin, min = ZERO) {
3815
- return { x: origin.x + min.x - GROUP_PADDING.x, y: origin.y + min.y - GROUP_PADDING.top };
3816
- }
3817
- function originAt(box, min = ZERO) {
3818
- return { x: box.x - min.x + GROUP_PADDING.x, y: box.y - min.y + GROUP_PADDING.top };
3819
- }
3820
- function drawnAt(view, canvasPath) {
3821
- return view.nodes.find((n) => n.id === canvasPath)?.position ?? view.groups.find((g) => g.id === canvasPath)?.position;
3822
- }
3823
- function drawnRect(view, canvasPath) {
3824
- const node = view.nodes.find((n) => n.id === canvasPath);
3825
- if (node) return { ...node.position, ...nodeSize(node) };
3826
- const group = view.groups.find((g) => g.id === canvasPath);
3827
- return group ? { ...group.position, ...groupFootprint(group, group.size) } : void 0;
3828
- }
3829
- function reachRect(view, canvasPath) {
3830
- const group = view.groups.find((g) => g.id === canvasPath);
3831
- if (!group) return drawnRect(view, canvasPath);
3832
- return { ...group.position, ...groupReach(group, group.size) };
3833
- }
3834
- function frameOf(view, canvasPath) {
3835
- const { parentPath } = splitPath(canvasPath);
3836
- if (parentPath === "") return ZERO;
3837
- return view.groups.find((g) => g.id === parentPath)?.origin ?? ZERO;
3838
- }
3839
- function localIn(view, canvasPath, drawn, frame = frameOf(view, canvasPath)) {
3840
- const group = view.groups.find((g) => g.id === canvasPath);
3841
- if (!group) return { x: drawn.x - frame.x, y: drawn.y - frame.y };
3842
- const anchor = boxAt(group.origin);
3843
- return {
3844
- x: drawn.x - (group.position.x - anchor.x) - frame.x,
3845
- y: drawn.y - (group.position.y - anchor.y) - frame.y
3846
- };
3847
- }
3848
-
3849
- // src/projection/parse-module-key.ts
3850
- function parseModuleKey(key) {
3851
- const at = key.lastIndexOf("@");
3852
- if (at < 0) return { id: key, version: "" };
3853
- return { id: key.slice(0, at), version: key.slice(at + 1) };
3854
- }
3855
-
3856
- // src/projection/classify-child.ts
3857
- function isGroupUse(bundle, use) {
3858
- const target = bundle.modules[use.module];
3859
- if (!target) return false;
3860
- return (target.modules?.length ?? 0) > 0;
3861
- }
3862
-
3863
- // src/projection/compute-layout.ts
3864
- var SPACING_X = 260;
3865
- var SPACING_Y = 180;
3866
- var GAP_X = 60;
3867
- var GAP_Y = 40;
3868
- var ORDINARY = { width: NODE_WIDTH, height: SPACING_Y - GAP_Y };
3869
- function slotOf(size) {
3870
- return {
3871
- width: Math.max(SPACING_X, size.width + GAP_X),
3872
- height: Math.max(SPACING_Y, size.height + GAP_Y)
3873
- };
3874
- }
3875
- function overlaps(a, b) {
3876
- return a.x < b.x + b.width && a.x + a.width > b.x && a.y < b.y + b.height && a.y + a.height > b.y;
3877
- }
3878
- function stepDown(at, size, taken) {
3879
- let candidate = at;
3880
- const blocking = () => taken.filter((r) => overlaps({ ...candidate, ...size }, r));
3881
- for (let inWay = blocking(); inWay.length > 0; inWay = blocking()) {
3882
- candidate = { x: candidate.x, y: Math.max(...inWay.map((r) => r.y + r.height)) };
3883
- }
3884
- return candidate;
3885
- }
3886
- function keepOrder(a, b) {
3887
- return a.y - b.y || a.x - b.x || a.declared - b.declared;
3888
- }
3889
- function freeSlot(extent, occupied) {
3890
- return stepDown(
3891
- { x: 0, y: 0 },
3892
- slotOf(extent),
3893
- occupied.map((r) => ({ x: r.x, y: r.y, ...slotOf(r) }))
3894
- );
3895
- }
3896
- function resolveScopePositionsByDepth(ids, arrangementNodes, edges) {
3897
- const stored = /* @__PURE__ */ new Map();
3898
- for (const id of ids) {
3899
- const at = arrangementNodes?.[id];
3900
- if (at) stored.set(id, at);
3901
- }
3902
- return layoutByDepth(
3903
- ids.map((id) => ({ id, size: ORDINARY })),
3904
- stored,
3905
- edges
3906
- );
3907
- }
3908
- function layoutByDepth(items, stored, edges) {
3909
- const byId = new Map(items.map((item) => [item.id, item]));
3910
- const ids = items.map((item) => item.id);
3911
- const slots = new Map(items.map((item) => [item.id, slotOf(item.size)]));
3912
- const slotOfId = (id) => slots.get(id) ?? slotOf(ORDINARY);
3913
- const declared = new Map(ids.map((id, i) => [id, i]));
3914
- const keyOf = (id, at) => ({ ...at, declared: declared.get(id) ?? 0 });
3915
- const inOrder = [...stored].sort(([p, a], [q, b]) => keepOrder(keyOf(p, a), keyOf(q, b)));
3916
- const kept = /* @__PURE__ */ new Map();
3917
- const keptRects = [];
3918
- const keptSlots = [];
3919
- for (const [id, wanted] of inOrder) {
3920
- const item = byId.get(id);
3921
- if (!item) continue;
3922
- const slot = slotOfId(id);
3923
- const clear = !keptRects.some((r) => overlaps({ ...wanted, ...item.size }, r));
3924
- const at = clear ? wanted : stepDown(wanted, slot, keptSlots);
3925
- kept.set(id, at);
3926
- keptRects.push({ ...at, ...item.size });
3927
- keptSlots.push({ ...at, ...slot });
3928
- }
3929
- const columns = columnByDepth(ids, edges);
3930
- const columnX = /* @__PURE__ */ new Map();
3931
- {
3932
- const widths = /* @__PURE__ */ new Map();
3933
- for (const id of ids) {
3934
- const c = columns.get(id) ?? 0;
3935
- widths.set(c, Math.max(widths.get(c) ?? SPACING_X, slotOfId(id).width));
3936
- }
3937
- const last = Math.max(0, ...widths.keys());
3938
- let x = 0;
3939
- for (let c = 0; c <= last; c += 1) {
3940
- columnX.set(c, x);
3941
- x += widths.get(c) ?? SPACING_X;
3942
- }
3943
- }
3944
- const feeders = /* @__PURE__ */ new Map();
3945
- const fed = /* @__PURE__ */ new Map();
3946
- for (const edge of edges) {
3947
- if (edge.source_instance === edge.target_instance) continue;
3948
- if (!byId.has(edge.source_instance) || !byId.has(edge.target_instance)) continue;
3949
- feeders.set(edge.target_instance, [
3950
- ...feeders.get(edge.target_instance) ?? [],
3951
- edge.source_instance
3952
- ]);
3953
- fed.set(edge.source_instance, [...fed.get(edge.source_instance) ?? [], edge]);
3954
- }
3955
- const byColumn = /* @__PURE__ */ new Map();
3956
- for (const id of ids) {
3957
- if (kept.has(id)) continue;
3958
- const column = columns.get(id) ?? 0;
3959
- byColumn.set(column, [...byColumn.get(column) ?? [], id]);
3960
- }
3961
- const heightOf = (id) => byId.get(id)?.size.height ?? 0;
3962
- const mean = (values) => values.reduce((sum, v) => sum + v, 0) / values.length;
3963
- const place = (unfedOrder2) => {
3964
- const rank = new Map(unfedOrder2.map((id, i) => [id, i]));
3965
- const positions = new Map(kept);
3966
- const taken = [...keptSlots];
3967
- for (const column of [...byColumn.keys()].sort((p, q) => p - q)) {
3968
- const members = [...byColumn.get(column) ?? []].sort(
3969
- (p, q) => (rank.get(p) ?? 0) - (rank.get(q) ?? 0)
3970
- );
3971
- const tops = /* @__PURE__ */ new Map();
3972
- let stacked = 0;
3973
- for (const id of members) {
3974
- const from = (feeders.get(id) ?? []).flatMap((f) => {
3975
- const at = positions.get(f);
3976
- return at ? [at.y + heightOf(f) / 2] : [];
3977
- });
3978
- if (from.length > 0) {
3979
- tops.set(id, mean(from) - heightOf(id) / 2);
3980
- } else {
3981
- tops.set(id, stacked);
3982
- stacked += slotOfId(id).height;
3983
- }
3984
- }
3985
- const sorted = [...members].sort((p, q) => (tops.get(p) ?? 0) - (tops.get(q) ?? 0));
3986
- if (sorted.length > 1) {
3987
- const offsets = [];
3988
- let run = 0;
3989
- for (const id of sorted) {
3990
- offsets.push(run);
3991
- run += slotOfId(id).height;
3992
- }
3993
- const first = mean(sorted.map((id) => tops.get(id) ?? 0)) - mean(offsets);
3994
- for (const [i, id] of sorted.entries()) tops.set(id, first + offsets[i]);
3995
- }
3996
- const x = columnX.get(column) ?? 0;
3997
- for (const id of sorted) {
3998
- const slot = slotOfId(id);
3999
- const at = stepDown({ x, y: tops.get(id) ?? 0 }, slot, taken);
4000
- positions.set(id, at);
4001
- taken.push({ ...at, ...slot });
4002
- }
4003
- }
4004
- return positions;
4005
- };
4006
- const provisional = place(ids);
4007
- const landing = (id) => {
4008
- const out = fed.get(id) ?? [];
4009
- const at = provisional.get(id);
4010
- if (out.length === 0) return (at?.y ?? 0) + slotOfId(id).height / 2;
4011
- const ys = out.map((edge) => {
4012
- const target = byId.get(edge.target_instance);
4013
- const top = provisional.get(edge.target_instance)?.y ?? 0;
4014
- const pin = target?.pinY && edge.to_input !== void 0 ? target.pinY(edge.to_input) : 0;
4015
- return top + pin;
4016
- });
4017
- return mean(ys);
4018
- };
4019
- const unfedOrder = [...ids].sort(
4020
- (p, q) => landing(p) - landing(q) || (declared.get(p) ?? 0) - (declared.get(q) ?? 0)
4021
- );
4022
- return place(unfedOrder);
4023
- }
4024
- function columnByDepth(ids, edges) {
4025
- const present = new Set(ids);
4026
- const real = edges.filter(
4027
- (e) => e.source_instance !== e.target_instance && present.has(e.source_instance) && present.has(e.target_instance)
4028
- );
4029
- const depth = new Map(ids.map((id) => [id, 0]));
4030
- for (let round = 0; round < ids.length; round += 1) {
4031
- let moved = false;
4032
- for (const e of real) {
4033
- const want = (depth.get(e.source_instance) ?? 0) + 1;
4034
- if (want > (depth.get(e.target_instance) ?? 0)) {
4035
- depth.set(e.target_instance, want);
4036
- moved = true;
4037
- }
4038
- }
4039
- if (!moved) break;
4040
- }
4041
- return depth;
4042
- }
4043
-
4044
- // src/projection/project-group.ts
4045
- function projectGroup(use, target, fullId, parentArrangement, wiredIn, wiredOut) {
4046
- const childIds = (target.modules ?? []).map((u) => joinPath(fullId, u.id));
4047
- const parentGroup = parentArrangement?.groups?.[use.id];
4048
- const collapsed = parentGroup ? parentGroup.collapsed : true;
4049
- return {
4050
- id: fullId,
4051
- label: use.id,
4052
- node_ids: childIds,
4053
- collapsed,
4054
- module_key: use.module,
4055
- ...groupPins(target),
4056
- ...callWires(wiredIn, wiredOut)
4057
- };
4058
- }
4059
- function groupPins(target) {
4060
- return {
4061
- inputs: (target.interface?.inputs ?? []).map((in_) => ({
4062
- name: in_.name,
4063
- type: in_.type,
4064
- required: in_.required,
4065
- description: in_.description
4066
- })),
4067
- outputs: (target.interface?.outputs ?? []).map((out) => ({
4068
- name: out.name,
4069
- type: out.type,
4070
- description: out.description,
4071
- sensitive: out.sensitive
4072
- }))
4073
- };
4074
- }
4075
-
4076
- // src/projection/project-node.ts
4077
- function projectNode(bundle, use, fullId, wiredIn, wiredOut) {
4078
- const schema = resolveSchema(bundle, use, wiredOut);
4079
- return {
4080
- id: fullId,
4081
- label: use.id,
4082
- kind: "module",
4083
- module_key: use.module,
4084
- inputs: schema.inputs.map((in_) => ({
4085
- name: in_.name,
4086
- type: in_.type,
4087
- required: in_.required,
4088
- wired: wiredIn.has(in_.name),
4089
- description: in_.description
4090
- })),
4091
- outputs: schema.outputs.map((out) => ({
4092
- name: out.name,
4093
- type: out.type,
4094
- wired: wiredOut.has(out.name),
4095
- description: out.description,
4096
- sensitive: out.sensitive
4097
- })),
4098
- ...callWires(wiredIn, wiredOut)
4099
- };
4100
- }
4101
-
4102
- // src/projection/project-scope.ts
4103
- function projectScope(bundle, mod, use, path, arrangement, children) {
4104
- const uses = mod.modules ?? [];
4105
- const derived = deriveEdges(uses);
4106
- const { inputs: wiredIn, outputs: wiredOut } = indexWires(derived);
4107
- const scopeArrangement = arrangement?.[use ? use.module : bundle.entry];
4108
- const cards = [];
4109
- const groups = [];
4110
- const items = [];
4111
- const boxMin = /* @__PURE__ */ new Map();
4112
- for (const child of uses) {
4113
- const fullId = joinPath(path, child.id);
4114
- if (isGroupUse(bundle, child)) {
4115
- const group = projectGroup(
4116
- child,
4117
- bundle.modules[child.module],
4118
- fullId,
4119
- scopeArrangement,
4120
- wiredIn.get(child.id) ?? /* @__PURE__ */ new Set(),
4121
- wiredOut.get(child.id) ?? /* @__PURE__ */ new Set()
4122
- );
4123
- const content = children.get(fullId);
4124
- if (!content) throw new Error(`projectScope: no layout for group "${fullId}"`);
4125
- groups.push(group);
4126
- boxMin.set(child.id, content.min);
4127
- items.push({
4128
- id: child.id,
4129
- size: groupFootprint(group, content.box),
4130
- pinY: (input) => groupInputPinY(group, input)
4131
- });
4132
- continue;
4133
- }
4134
- const node = projectNode(
4135
- bundle,
4136
- child,
4137
- fullId,
4138
- wiredIn.get(child.id) ?? /* @__PURE__ */ new Set(),
4139
- wiredOut.get(child.id) ?? /* @__PURE__ */ new Set()
4140
- );
4141
- cards.push(node);
4142
- items.push({ id: child.id, size: nodeSize(node), pinY: (input) => inputPinY(node, input) });
4143
- }
4144
- const stored = /* @__PURE__ */ new Map();
4145
- for (const child of uses) {
4146
- const at = scopeArrangement?.nodes?.[child.id];
4147
- if (!at) continue;
4148
- const min = boxMin.get(child.id);
4149
- stored.set(child.id, min ? boxAt(originAt(at), min) : at);
4150
- }
4151
- const local = layoutByDepth(items, stored, derived);
4152
- const placedAt = (useId) => {
4153
- const at = local.get(useId);
4154
- if (!at) throw new Error(`projectScope: no position for "${joinPath(path, useId)}"`);
4155
- return at;
4156
- };
4157
- const nodes = cards.map((card) => ({ ...card, position: placedAt(splitPath(card.id).localId) }));
4158
- const extent = extentOf([
4159
- { x: 0, y: 0, width: 0, height: 0 },
4160
- ...items.map((item) => ({ ...placedAt(item.id), ...item.size }))
4161
- ]);
4162
- const edges = derived.map((de) => {
4163
- const sourceId = joinPath(path, de.source_instance);
4164
- const targetId = joinPath(path, de.target_instance);
4165
- return {
4166
- id: `${sourceId}-${targetId}-${de.from_output}-${de.to_input}`,
4167
- source: sourceId,
4168
- target: targetId,
4169
- source_output: de.from_output,
4170
- target_input: de.to_input
4171
- };
4172
- });
4173
- return {
4174
- nodes,
4175
- groups,
4176
- edges,
4177
- local,
4178
- min: { x: extent.x, y: extent.y },
4179
- box: groupBoxSize(extent)
4180
- };
4181
- }
4182
-
4183
- // src/projection/walk-modules.ts
4184
- function walk(bundle, visit) {
4185
- if (!bundle) return;
4186
- const entry = bundle.modules[bundle.entry];
4187
- if (!entry) return;
4188
- walkFrom(bundle, entry, null, "", visit);
4189
- }
4190
- function walkFrom(bundle, mod, use, path, visit) {
4191
- visit(mod, use, path);
4192
- for (const u of mod.modules ?? []) {
4193
- const child = bundle.modules[u.module];
4194
- if (!child) continue;
4195
- walkFrom(bundle, child, u, joinPath(path, u.id), visit);
4196
- }
4197
- }
4198
-
4199
- // src/projection/project.ts
4200
- var EMPTY_BUNDLE = Bundle.fromPartial({
4201
- entry: "root@v1",
4202
- modules: { "root@v1": { id: "root", version: "v1.0.0" } }
4203
- });
4204
- function projectCanvasView(bundle, arrangement, meta) {
4205
- const scopes = [];
4206
- walk(bundle, (mod, use, path) => {
4207
- scopes.push({ mod, use, path });
4208
- });
4209
- const layouts = /* @__PURE__ */ new Map();
4210
- for (const { mod, use, path } of [...scopes].reverse()) {
4211
- layouts.set(path, projectScope(bundle, mod, use, path, arrangement, layouts));
4212
- }
4213
- const nodes = [];
4214
- const edges = [];
4215
- const groups = [];
4216
- const origins = /* @__PURE__ */ new Map([["", { x: 0, y: 0 }]]);
4217
- for (const { path } of scopes) {
4218
- const layout = layouts.get(path);
4219
- const origin = origins.get(path);
4220
- if (!layout || !origin) continue;
4221
- const at = (local) => ({ x: origin.x + local.x, y: origin.y + local.y });
4222
- for (const node of layout.nodes) nodes.push({ ...node, position: at(node.position) });
4223
- for (const group of layout.groups) {
4224
- const content = layouts.get(group.id);
4225
- const box = layout.local.get(splitPath(group.id).localId);
4226
- if (!content || !box)
4227
- throw new Error(`projectCanvasView: group "${group.id}" was not laid out`);
4228
- const position = at(box);
4229
- const membersAt = originAt(position, content.min);
4230
- origins.set(group.id, membersAt);
4231
- groups.push({ ...group, position, size: content.box, origin: membersAt });
4232
- }
4233
- edges.push(...layout.edges);
4234
- }
4235
- const moduleName = meta.moduleName ?? parseModuleKey(bundle.entry).id;
4236
- return {
4237
- module_name: moduleName,
4238
- nodes,
4239
- edges,
4240
- can_undo: meta.canUndo,
4241
- can_redo: meta.canRedo,
4242
- unsaved: meta.unsaved,
4243
- conflict: meta.conflict,
4244
- ungenerated: meta.ungenerated ?? false,
4245
- // Every group is a Use whose target has sub-Uses (CreateGroupAction
4246
- // mints a module); emission order already mirrors Use declaration order
4247
- // via the walk, so no separate user-group sort is needed.
4248
- groups
4249
- };
4250
- }
4251
-
4252
- // src/generated/service.ts
4253
- import { BinaryReader as BinaryReader3, BinaryWriter as BinaryWriter3 } from "@bufbuild/protobuf/wire";
4254
- function nodeKindFromJSON(object) {
4255
- switch (object) {
4256
- case 0:
4257
- case "NODE_KIND_UNSPECIFIED":
4258
- return 0 /* NODE_KIND_UNSPECIFIED */;
4259
- case 1:
4260
- case "NODE_KIND_MODULE":
4261
- return 1 /* NODE_KIND_MODULE */;
4262
- case 2:
4263
- case "NODE_KIND_RESOURCE":
4264
- return 2 /* NODE_KIND_RESOURCE */;
4265
- case 3:
4266
- case "NODE_KIND_DATA":
4267
- return 3 /* NODE_KIND_DATA */;
4268
- case -1:
4269
- case "UNRECOGNIZED":
4270
- default:
4271
- return -1 /* UNRECOGNIZED */;
4272
- }
4273
- }
4274
- function nodeKindToJSON(object) {
4275
- switch (object) {
4276
- case 0 /* NODE_KIND_UNSPECIFIED */:
4277
- return "NODE_KIND_UNSPECIFIED";
4278
- case 1 /* NODE_KIND_MODULE */:
4279
- return "NODE_KIND_MODULE";
4280
- case 2 /* NODE_KIND_RESOURCE */:
4281
- return "NODE_KIND_RESOURCE";
4282
- case 3 /* NODE_KIND_DATA */:
4283
- return "NODE_KIND_DATA";
4284
- case -1 /* UNRECOGNIZED */:
4285
- default:
4286
- return "UNRECOGNIZED";
4287
- }
4288
- }
4289
- function createBaseCanvasView() {
4290
- return { module_name: "", nodes: [], edges: [], can_undo: false, can_redo: false, unsaved: false, groups: [] };
4291
- }
4292
- var CanvasView = {
4293
- encode(message, writer = new BinaryWriter3()) {
4294
- if (message.module_name !== "") {
4295
- writer.uint32(10).string(message.module_name);
4296
- }
4297
- for (const v of message.nodes) {
4298
- RenderNode.encode(v, writer.uint32(18).fork()).join();
4299
- }
4300
- for (const v of message.edges) {
4301
- RenderEdge.encode(v, writer.uint32(26).fork()).join();
4302
- }
4303
- if (message.can_undo !== false) {
4304
- writer.uint32(40).bool(message.can_undo);
4305
- }
4306
- if (message.can_redo !== false) {
4307
- writer.uint32(48).bool(message.can_redo);
4308
- }
4309
- if (message.unsaved !== false) {
4310
- writer.uint32(56).bool(message.unsaved);
4311
- }
4312
- for (const v of message.groups) {
4313
- RenderGroup.encode(v, writer.uint32(66).fork()).join();
4314
- }
4315
- return writer;
4316
- },
4317
- decode(input, length) {
4318
- const reader = input instanceof BinaryReader3 ? input : new BinaryReader3(input);
4319
- const end = length === void 0 ? reader.len : reader.pos + length;
4320
- const message = createBaseCanvasView();
4321
- while (reader.pos < end) {
4322
- const tag = reader.uint32();
4323
- switch (tag >>> 3) {
4324
- case 1: {
4325
- if (tag !== 10) {
4326
- break;
4327
- }
4328
- message.module_name = reader.string();
4329
- continue;
4330
- }
4331
- case 2: {
4332
- if (tag !== 18) {
4333
- break;
4334
- }
4335
- message.nodes.push(RenderNode.decode(reader, reader.uint32()));
4336
- continue;
4337
- }
4338
- case 3: {
4339
- if (tag !== 26) {
4340
- break;
4341
- }
4342
- message.edges.push(RenderEdge.decode(reader, reader.uint32()));
4343
- continue;
4344
- }
4345
- case 5: {
4346
- if (tag !== 40) {
4347
- break;
4348
- }
4349
- message.can_undo = reader.bool();
4350
- continue;
4351
- }
4352
- case 6: {
4353
- if (tag !== 48) {
4354
- break;
4355
- }
4356
- message.can_redo = reader.bool();
4357
- continue;
4358
- }
4359
- case 7: {
4360
- if (tag !== 56) {
4361
- break;
4362
- }
4363
- message.unsaved = reader.bool();
4364
- continue;
4365
- }
4366
- case 8: {
4367
- if (tag !== 66) {
4368
- break;
4369
- }
4370
- message.groups.push(RenderGroup.decode(reader, reader.uint32()));
4371
- continue;
4372
- }
4373
- }
4374
- if ((tag & 7) === 4 || tag === 0) {
4375
- break;
4376
- }
4377
- reader.skip(tag & 7);
4378
- }
4379
- return message;
4380
- },
4381
- fromJSON(object) {
4382
- return {
4383
- module_name: isSet3(object.moduleName) ? globalThis.String(object.moduleName) : isSet3(object.module_name) ? globalThis.String(object.module_name) : "",
4384
- nodes: globalThis.Array.isArray(object?.nodes) ? object.nodes.map((e) => RenderNode.fromJSON(e)) : [],
4385
- edges: globalThis.Array.isArray(object?.edges) ? object.edges.map((e) => RenderEdge.fromJSON(e)) : [],
4386
- can_undo: isSet3(object.canUndo) ? globalThis.Boolean(object.canUndo) : isSet3(object.can_undo) ? globalThis.Boolean(object.can_undo) : false,
4387
- can_redo: isSet3(object.canRedo) ? globalThis.Boolean(object.canRedo) : isSet3(object.can_redo) ? globalThis.Boolean(object.can_redo) : false,
4388
- unsaved: isSet3(object.unsaved) ? globalThis.Boolean(object.unsaved) : false,
4389
- groups: globalThis.Array.isArray(object?.groups) ? object.groups.map((e) => RenderGroup.fromJSON(e)) : []
4390
- };
4391
- },
4392
- toJSON(message) {
4393
- const obj = {};
4394
- if (message.module_name !== "") {
4395
- obj.moduleName = message.module_name;
4396
- }
4397
- if (message.nodes?.length) {
4398
- obj.nodes = message.nodes.map((e) => RenderNode.toJSON(e));
4399
- }
4400
- if (message.edges?.length) {
4401
- obj.edges = message.edges.map((e) => RenderEdge.toJSON(e));
4402
- }
4403
- if (message.can_undo !== false) {
4404
- obj.canUndo = message.can_undo;
4405
- }
4406
- if (message.can_redo !== false) {
4407
- obj.canRedo = message.can_redo;
4408
- }
4409
- if (message.unsaved !== false) {
4410
- obj.unsaved = message.unsaved;
4411
- }
4412
- if (message.groups?.length) {
4413
- obj.groups = message.groups.map((e) => RenderGroup.toJSON(e));
4414
- }
4415
- return obj;
4416
- },
4417
- create(base) {
4418
- return CanvasView.fromPartial(base ?? {});
4419
- },
4420
- fromPartial(object) {
4421
- const message = createBaseCanvasView();
4422
- message.module_name = object.module_name ?? "";
4423
- message.nodes = object.nodes?.map((e) => RenderNode.fromPartial(e)) || [];
4424
- message.edges = object.edges?.map((e) => RenderEdge.fromPartial(e)) || [];
4425
- message.can_undo = object.can_undo ?? false;
4426
- message.can_redo = object.can_redo ?? false;
4427
- message.unsaved = object.unsaved ?? false;
4428
- message.groups = object.groups?.map((e) => RenderGroup.fromPartial(e)) || [];
4429
- return message;
4430
- }
4431
- };
4432
- function createBaseRenderGroup() {
4433
- return { id: "", label: "", node_ids: [], collapsed: false, module_key: "", inputs: [], outputs: [] };
4434
- }
4435
- var RenderGroup = {
3633
+ var RenderNode = {
4436
3634
  encode(message, writer = new BinaryWriter3()) {
4437
3635
  if (message.id !== "") {
4438
3636
  writer.uint32(10).string(message.id);
@@ -4440,27 +3638,30 @@ var RenderGroup = {
4440
3638
  if (message.label !== "") {
4441
3639
  writer.uint32(18).string(message.label);
4442
3640
  }
4443
- for (const v of message.node_ids) {
4444
- writer.uint32(26).string(v);
4445
- }
4446
- if (message.collapsed !== false) {
4447
- writer.uint32(32).bool(message.collapsed);
3641
+ if (message.kind !== 0) {
3642
+ writer.uint32(24).int32(message.kind);
4448
3643
  }
4449
3644
  if (message.module_key !== "") {
4450
- writer.uint32(42).string(message.module_key);
3645
+ writer.uint32(34).string(message.module_key);
3646
+ }
3647
+ if (message.icon_url !== "") {
3648
+ writer.uint32(42).string(message.icon_url);
3649
+ }
3650
+ if (message.position !== void 0) {
3651
+ Position.encode(message.position, writer.uint32(50).fork()).join();
4451
3652
  }
4452
3653
  for (const v of message.inputs) {
4453
- NodePin.encode(v, writer.uint32(50).fork()).join();
3654
+ NodePin.encode(v, writer.uint32(74).fork()).join();
4454
3655
  }
4455
3656
  for (const v of message.outputs) {
4456
- NodePin.encode(v, writer.uint32(58).fork()).join();
3657
+ NodePin.encode(v, writer.uint32(82).fork()).join();
4457
3658
  }
4458
3659
  return writer;
4459
3660
  },
4460
3661
  decode(input, length) {
4461
3662
  const reader = input instanceof BinaryReader3 ? input : new BinaryReader3(input);
4462
3663
  const end = length === void 0 ? reader.len : reader.pos + length;
4463
- const message = createBaseRenderGroup();
3664
+ const message = createBaseRenderNode();
4464
3665
  while (reader.pos < end) {
4465
3666
  const tag = reader.uint32();
4466
3667
  switch (tag >>> 3) {
@@ -4479,35 +3680,42 @@ var RenderGroup = {
4479
3680
  continue;
4480
3681
  }
4481
3682
  case 3: {
4482
- if (tag !== 26) {
3683
+ if (tag !== 24) {
4483
3684
  break;
4484
3685
  }
4485
- message.node_ids.push(reader.string());
3686
+ message.kind = reader.int32();
4486
3687
  continue;
4487
3688
  }
4488
3689
  case 4: {
4489
- if (tag !== 32) {
3690
+ if (tag !== 34) {
4490
3691
  break;
4491
3692
  }
4492
- message.collapsed = reader.bool();
3693
+ message.module_key = reader.string();
4493
3694
  continue;
4494
3695
  }
4495
3696
  case 5: {
4496
3697
  if (tag !== 42) {
4497
3698
  break;
4498
3699
  }
4499
- message.module_key = reader.string();
3700
+ message.icon_url = reader.string();
4500
3701
  continue;
4501
3702
  }
4502
3703
  case 6: {
4503
3704
  if (tag !== 50) {
4504
3705
  break;
4505
3706
  }
3707
+ message.position = Position.decode(reader, reader.uint32());
3708
+ continue;
3709
+ }
3710
+ case 9: {
3711
+ if (tag !== 74) {
3712
+ break;
3713
+ }
4506
3714
  message.inputs.push(NodePin.decode(reader, reader.uint32()));
4507
3715
  continue;
4508
3716
  }
4509
- case 7: {
4510
- if (tag !== 58) {
3717
+ case 10: {
3718
+ if (tag !== 82) {
4511
3719
  break;
4512
3720
  }
4513
3721
  message.outputs.push(NodePin.decode(reader, reader.uint32()));
@@ -4525,9 +3733,10 @@ var RenderGroup = {
4525
3733
  return {
4526
3734
  id: isSet3(object.id) ? globalThis.String(object.id) : "",
4527
3735
  label: isSet3(object.label) ? globalThis.String(object.label) : "",
4528
- 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)) : [],
4529
- collapsed: isSet3(object.collapsed) ? globalThis.Boolean(object.collapsed) : false,
3736
+ kind: isSet3(object.kind) ? nodeKindFromJSON(object.kind) : 0,
4530
3737
  module_key: isSet3(object.moduleKey) ? globalThis.String(object.moduleKey) : isSet3(object.module_key) ? globalThis.String(object.module_key) : "",
3738
+ icon_url: isSet3(object.iconUrl) ? globalThis.String(object.iconUrl) : isSet3(object.icon_url) ? globalThis.String(object.icon_url) : "",
3739
+ position: isSet3(object.position) ? Position.fromJSON(object.position) : void 0,
4531
3740
  inputs: globalThis.Array.isArray(object?.inputs) ? object.inputs.map((e) => NodePin.fromJSON(e)) : [],
4532
3741
  outputs: globalThis.Array.isArray(object?.outputs) ? object.outputs.map((e) => NodePin.fromJSON(e)) : []
4533
3742
  };
@@ -4540,15 +3749,18 @@ var RenderGroup = {
4540
3749
  if (message.label !== "") {
4541
3750
  obj.label = message.label;
4542
3751
  }
4543
- if (message.node_ids?.length) {
4544
- obj.nodeIds = message.node_ids;
4545
- }
4546
- if (message.collapsed !== false) {
4547
- obj.collapsed = message.collapsed;
3752
+ if (message.kind !== 0) {
3753
+ obj.kind = nodeKindToJSON(message.kind);
4548
3754
  }
4549
3755
  if (message.module_key !== "") {
4550
3756
  obj.moduleKey = message.module_key;
4551
3757
  }
3758
+ if (message.icon_url !== "") {
3759
+ obj.iconUrl = message.icon_url;
3760
+ }
3761
+ if (message.position !== void 0) {
3762
+ obj.position = Position.toJSON(message.position);
3763
+ }
4552
3764
  if (message.inputs?.length) {
4553
3765
  obj.inputs = message.inputs.map((e) => NodePin.toJSON(e));
4554
3766
  }
@@ -4558,55 +3770,50 @@ var RenderGroup = {
4558
3770
  return obj;
4559
3771
  },
4560
3772
  create(base) {
4561
- return RenderGroup.fromPartial(base ?? {});
3773
+ return RenderNode.fromPartial(base ?? {});
4562
3774
  },
4563
3775
  fromPartial(object) {
4564
- const message = createBaseRenderGroup();
3776
+ const message = createBaseRenderNode();
4565
3777
  message.id = object.id ?? "";
4566
3778
  message.label = object.label ?? "";
4567
- message.node_ids = object.node_ids?.map((e) => e) || [];
4568
- message.collapsed = object.collapsed ?? false;
3779
+ message.kind = object.kind ?? 0;
4569
3780
  message.module_key = object.module_key ?? "";
3781
+ message.icon_url = object.icon_url ?? "";
3782
+ message.position = object.position !== void 0 && object.position !== null ? Position.fromPartial(object.position) : void 0;
4570
3783
  message.inputs = object.inputs?.map((e) => NodePin.fromPartial(e)) || [];
4571
3784
  message.outputs = object.outputs?.map((e) => NodePin.fromPartial(e)) || [];
4572
3785
  return message;
4573
3786
  }
4574
3787
  };
4575
- function createBaseRenderNode() {
4576
- return { id: "", label: "", kind: 0, module_key: "", icon_url: "", position: void 0, inputs: [], outputs: [] };
3788
+ function createBaseNodePin() {
3789
+ return { name: "", type: "", required: false, wired: false, description: "", sensitive: false };
4577
3790
  }
4578
- var RenderNode = {
3791
+ var NodePin = {
4579
3792
  encode(message, writer = new BinaryWriter3()) {
4580
- if (message.id !== "") {
4581
- writer.uint32(10).string(message.id);
4582
- }
4583
- if (message.label !== "") {
4584
- writer.uint32(18).string(message.label);
4585
- }
4586
- if (message.kind !== 0) {
4587
- writer.uint32(24).int32(message.kind);
3793
+ if (message.name !== "") {
3794
+ writer.uint32(10).string(message.name);
4588
3795
  }
4589
- if (message.module_key !== "") {
4590
- writer.uint32(34).string(message.module_key);
3796
+ if (message.type !== "") {
3797
+ writer.uint32(18).string(message.type);
4591
3798
  }
4592
- if (message.icon_url !== "") {
4593
- writer.uint32(42).string(message.icon_url);
3799
+ if (message.required !== false) {
3800
+ writer.uint32(24).bool(message.required);
4594
3801
  }
4595
- if (message.position !== void 0) {
4596
- Position.encode(message.position, writer.uint32(50).fork()).join();
3802
+ if (message.wired !== false) {
3803
+ writer.uint32(32).bool(message.wired);
4597
3804
  }
4598
- for (const v of message.inputs) {
4599
- NodePin.encode(v, writer.uint32(74).fork()).join();
3805
+ if (message.description !== "") {
3806
+ writer.uint32(42).string(message.description);
4600
3807
  }
4601
- for (const v of message.outputs) {
4602
- NodePin.encode(v, writer.uint32(82).fork()).join();
3808
+ if (message.sensitive !== false) {
3809
+ writer.uint32(48).bool(message.sensitive);
4603
3810
  }
4604
3811
  return writer;
4605
3812
  },
4606
3813
  decode(input, length) {
4607
3814
  const reader = input instanceof BinaryReader3 ? input : new BinaryReader3(input);
4608
3815
  const end = length === void 0 ? reader.len : reader.pos + length;
4609
- const message = createBaseRenderNode();
3816
+ const message = createBaseNodePin();
4610
3817
  while (reader.pos < end) {
4611
3818
  const tag = reader.uint32();
4612
3819
  switch (tag >>> 3) {
@@ -4614,56 +3821,160 @@ var RenderNode = {
4614
3821
  if (tag !== 10) {
4615
3822
  break;
4616
3823
  }
4617
- message.id = reader.string();
3824
+ message.name = reader.string();
4618
3825
  continue;
4619
3826
  }
4620
3827
  case 2: {
4621
3828
  if (tag !== 18) {
4622
3829
  break;
4623
3830
  }
4624
- message.label = reader.string();
3831
+ message.type = reader.string();
4625
3832
  continue;
4626
3833
  }
4627
3834
  case 3: {
4628
3835
  if (tag !== 24) {
4629
3836
  break;
4630
3837
  }
4631
- message.kind = reader.int32();
3838
+ message.required = reader.bool();
4632
3839
  continue;
4633
3840
  }
4634
3841
  case 4: {
4635
- if (tag !== 34) {
3842
+ if (tag !== 32) {
4636
3843
  break;
4637
3844
  }
4638
- message.module_key = reader.string();
3845
+ message.wired = reader.bool();
4639
3846
  continue;
4640
3847
  }
4641
3848
  case 5: {
4642
3849
  if (tag !== 42) {
4643
3850
  break;
4644
3851
  }
4645
- message.icon_url = reader.string();
3852
+ message.description = reader.string();
4646
3853
  continue;
4647
3854
  }
4648
3855
  case 6: {
4649
- if (tag !== 50) {
3856
+ if (tag !== 48) {
4650
3857
  break;
4651
3858
  }
4652
- message.position = Position.decode(reader, reader.uint32());
3859
+ message.sensitive = reader.bool();
4653
3860
  continue;
4654
3861
  }
4655
- case 9: {
4656
- if (tag !== 74) {
3862
+ }
3863
+ if ((tag & 7) === 4 || tag === 0) {
3864
+ break;
3865
+ }
3866
+ reader.skip(tag & 7);
3867
+ }
3868
+ return message;
3869
+ },
3870
+ fromJSON(object) {
3871
+ return {
3872
+ name: isSet3(object.name) ? globalThis.String(object.name) : "",
3873
+ type: isSet3(object.type) ? globalThis.String(object.type) : "",
3874
+ required: isSet3(object.required) ? globalThis.Boolean(object.required) : false,
3875
+ wired: isSet3(object.wired) ? globalThis.Boolean(object.wired) : false,
3876
+ description: isSet3(object.description) ? globalThis.String(object.description) : "",
3877
+ sensitive: isSet3(object.sensitive) ? globalThis.Boolean(object.sensitive) : false
3878
+ };
3879
+ },
3880
+ toJSON(message) {
3881
+ const obj = {};
3882
+ if (message.name !== "") {
3883
+ obj.name = message.name;
3884
+ }
3885
+ if (message.type !== "") {
3886
+ obj.type = message.type;
3887
+ }
3888
+ if (message.required !== false) {
3889
+ obj.required = message.required;
3890
+ }
3891
+ if (message.wired !== false) {
3892
+ obj.wired = message.wired;
3893
+ }
3894
+ if (message.description !== "") {
3895
+ obj.description = message.description;
3896
+ }
3897
+ if (message.sensitive !== false) {
3898
+ obj.sensitive = message.sensitive;
3899
+ }
3900
+ return obj;
3901
+ },
3902
+ create(base) {
3903
+ return NodePin.fromPartial(base ?? {});
3904
+ },
3905
+ fromPartial(object) {
3906
+ const message = createBaseNodePin();
3907
+ message.name = object.name ?? "";
3908
+ message.type = object.type ?? "";
3909
+ message.required = object.required ?? false;
3910
+ message.wired = object.wired ?? false;
3911
+ message.description = object.description ?? "";
3912
+ message.sensitive = object.sensitive ?? false;
3913
+ return message;
3914
+ }
3915
+ };
3916
+ function createBaseRenderEdge() {
3917
+ return { id: "", source: "", target: "", source_output: "", target_input: "" };
3918
+ }
3919
+ var RenderEdge = {
3920
+ encode(message, writer = new BinaryWriter3()) {
3921
+ if (message.id !== "") {
3922
+ writer.uint32(10).string(message.id);
3923
+ }
3924
+ if (message.source !== "") {
3925
+ writer.uint32(18).string(message.source);
3926
+ }
3927
+ if (message.target !== "") {
3928
+ writer.uint32(26).string(message.target);
3929
+ }
3930
+ if (message.source_output !== "") {
3931
+ writer.uint32(34).string(message.source_output);
3932
+ }
3933
+ if (message.target_input !== "") {
3934
+ writer.uint32(42).string(message.target_input);
3935
+ }
3936
+ return writer;
3937
+ },
3938
+ decode(input, length) {
3939
+ const reader = input instanceof BinaryReader3 ? input : new BinaryReader3(input);
3940
+ const end = length === void 0 ? reader.len : reader.pos + length;
3941
+ const message = createBaseRenderEdge();
3942
+ while (reader.pos < end) {
3943
+ const tag = reader.uint32();
3944
+ switch (tag >>> 3) {
3945
+ case 1: {
3946
+ if (tag !== 10) {
4657
3947
  break;
4658
3948
  }
4659
- message.inputs.push(NodePin.decode(reader, reader.uint32()));
3949
+ message.id = reader.string();
4660
3950
  continue;
4661
3951
  }
4662
- case 10: {
4663
- if (tag !== 82) {
3952
+ case 2: {
3953
+ if (tag !== 18) {
4664
3954
  break;
4665
3955
  }
4666
- message.outputs.push(NodePin.decode(reader, reader.uint32()));
3956
+ message.source = reader.string();
3957
+ continue;
3958
+ }
3959
+ case 3: {
3960
+ if (tag !== 26) {
3961
+ break;
3962
+ }
3963
+ message.target = reader.string();
3964
+ continue;
3965
+ }
3966
+ case 4: {
3967
+ if (tag !== 34) {
3968
+ break;
3969
+ }
3970
+ message.source_output = reader.string();
3971
+ continue;
3972
+ }
3973
+ case 5: {
3974
+ if (tag !== 42) {
3975
+ break;
3976
+ }
3977
+ message.target_input = reader.string();
4667
3978
  continue;
4668
3979
  }
4669
3980
  }
@@ -4677,13 +3988,10 @@ var RenderNode = {
4677
3988
  fromJSON(object) {
4678
3989
  return {
4679
3990
  id: isSet3(object.id) ? globalThis.String(object.id) : "",
4680
- label: isSet3(object.label) ? globalThis.String(object.label) : "",
4681
- kind: isSet3(object.kind) ? nodeKindFromJSON(object.kind) : 0,
4682
- module_key: isSet3(object.moduleKey) ? globalThis.String(object.moduleKey) : isSet3(object.module_key) ? globalThis.String(object.module_key) : "",
4683
- icon_url: isSet3(object.iconUrl) ? globalThis.String(object.iconUrl) : isSet3(object.icon_url) ? globalThis.String(object.icon_url) : "",
4684
- position: isSet3(object.position) ? Position.fromJSON(object.position) : void 0,
4685
- inputs: globalThis.Array.isArray(object?.inputs) ? object.inputs.map((e) => NodePin.fromJSON(e)) : [],
4686
- outputs: globalThis.Array.isArray(object?.outputs) ? object.outputs.map((e) => NodePin.fromJSON(e)) : []
3991
+ source: isSet3(object.source) ? globalThis.String(object.source) : "",
3992
+ target: isSet3(object.target) ? globalThis.String(object.target) : "",
3993
+ source_output: isSet3(object.sourceOutput) ? globalThis.String(object.sourceOutput) : isSet3(object.source_output) ? globalThis.String(object.source_output) : "",
3994
+ target_input: isSet3(object.targetInput) ? globalThis.String(object.targetInput) : isSet3(object.target_input) ? globalThis.String(object.target_input) : ""
4687
3995
  };
4688
3996
  },
4689
3997
  toJSON(message) {
@@ -4691,386 +3999,1159 @@ var RenderNode = {
4691
3999
  if (message.id !== "") {
4692
4000
  obj.id = message.id;
4693
4001
  }
4694
- if (message.label !== "") {
4695
- obj.label = message.label;
4696
- }
4697
- if (message.kind !== 0) {
4698
- obj.kind = nodeKindToJSON(message.kind);
4699
- }
4700
- if (message.module_key !== "") {
4701
- obj.moduleKey = message.module_key;
4702
- }
4703
- if (message.icon_url !== "") {
4704
- obj.iconUrl = message.icon_url;
4002
+ if (message.source !== "") {
4003
+ obj.source = message.source;
4705
4004
  }
4706
- if (message.position !== void 0) {
4707
- obj.position = Position.toJSON(message.position);
4005
+ if (message.target !== "") {
4006
+ obj.target = message.target;
4708
4007
  }
4709
- if (message.inputs?.length) {
4710
- obj.inputs = message.inputs.map((e) => NodePin.toJSON(e));
4008
+ if (message.source_output !== "") {
4009
+ obj.sourceOutput = message.source_output;
4711
4010
  }
4712
- if (message.outputs?.length) {
4713
- obj.outputs = message.outputs.map((e) => NodePin.toJSON(e));
4011
+ if (message.target_input !== "") {
4012
+ obj.targetInput = message.target_input;
4714
4013
  }
4715
4014
  return obj;
4716
4015
  },
4717
4016
  create(base) {
4718
- return RenderNode.fromPartial(base ?? {});
4017
+ return RenderEdge.fromPartial(base ?? {});
4719
4018
  },
4720
4019
  fromPartial(object) {
4721
- const message = createBaseRenderNode();
4020
+ const message = createBaseRenderEdge();
4722
4021
  message.id = object.id ?? "";
4723
- message.label = object.label ?? "";
4724
- message.kind = object.kind ?? 0;
4725
- message.module_key = object.module_key ?? "";
4726
- message.icon_url = object.icon_url ?? "";
4727
- message.position = object.position !== void 0 && object.position !== null ? Position.fromPartial(object.position) : void 0;
4728
- message.inputs = object.inputs?.map((e) => NodePin.fromPartial(e)) || [];
4729
- message.outputs = object.outputs?.map((e) => NodePin.fromPartial(e)) || [];
4022
+ message.source = object.source ?? "";
4023
+ message.target = object.target ?? "";
4024
+ message.source_output = object.source_output ?? "";
4025
+ message.target_input = object.target_input ?? "";
4730
4026
  return message;
4731
4027
  }
4732
4028
  };
4733
- function createBaseNodePin() {
4734
- return { name: "", type: "", required: false, wired: false, description: "", sensitive: false };
4029
+ function createBasePosition() {
4030
+ return { x: 0, y: 0 };
4735
4031
  }
4736
- var NodePin = {
4032
+ var Position = {
4737
4033
  encode(message, writer = new BinaryWriter3()) {
4738
- if (message.name !== "") {
4739
- writer.uint32(10).string(message.name);
4740
- }
4741
- if (message.type !== "") {
4742
- writer.uint32(18).string(message.type);
4743
- }
4744
- if (message.required !== false) {
4745
- writer.uint32(24).bool(message.required);
4746
- }
4747
- if (message.wired !== false) {
4748
- writer.uint32(32).bool(message.wired);
4749
- }
4750
- if (message.description !== "") {
4751
- writer.uint32(42).string(message.description);
4034
+ if (message.x !== 0) {
4035
+ writer.uint32(9).double(message.x);
4752
4036
  }
4753
- if (message.sensitive !== false) {
4754
- writer.uint32(48).bool(message.sensitive);
4037
+ if (message.y !== 0) {
4038
+ writer.uint32(17).double(message.y);
4755
4039
  }
4756
4040
  return writer;
4757
4041
  },
4758
4042
  decode(input, length) {
4759
4043
  const reader = input instanceof BinaryReader3 ? input : new BinaryReader3(input);
4760
4044
  const end = length === void 0 ? reader.len : reader.pos + length;
4761
- const message = createBaseNodePin();
4045
+ const message = createBasePosition();
4762
4046
  while (reader.pos < end) {
4763
4047
  const tag = reader.uint32();
4764
4048
  switch (tag >>> 3) {
4765
4049
  case 1: {
4766
- if (tag !== 10) {
4050
+ if (tag !== 9) {
4767
4051
  break;
4768
4052
  }
4769
- message.name = reader.string();
4053
+ message.x = reader.double();
4770
4054
  continue;
4771
4055
  }
4772
4056
  case 2: {
4773
- if (tag !== 18) {
4774
- break;
4775
- }
4776
- message.type = reader.string();
4777
- continue;
4778
- }
4779
- case 3: {
4780
- if (tag !== 24) {
4781
- break;
4782
- }
4783
- message.required = reader.bool();
4784
- continue;
4785
- }
4786
- case 4: {
4787
- if (tag !== 32) {
4788
- break;
4789
- }
4790
- message.wired = reader.bool();
4791
- continue;
4792
- }
4793
- case 5: {
4794
- if (tag !== 42) {
4795
- break;
4796
- }
4797
- message.description = reader.string();
4798
- continue;
4799
- }
4800
- case 6: {
4801
- if (tag !== 48) {
4057
+ if (tag !== 17) {
4802
4058
  break;
4803
4059
  }
4804
- message.sensitive = reader.bool();
4060
+ message.y = reader.double();
4805
4061
  continue;
4806
4062
  }
4807
4063
  }
4808
4064
  if ((tag & 7) === 4 || tag === 0) {
4809
4065
  break;
4810
- }
4811
- reader.skip(tag & 7);
4812
- }
4813
- return message;
4814
- },
4815
- fromJSON(object) {
4816
- return {
4817
- name: isSet3(object.name) ? globalThis.String(object.name) : "",
4818
- type: isSet3(object.type) ? globalThis.String(object.type) : "",
4819
- required: isSet3(object.required) ? globalThis.Boolean(object.required) : false,
4820
- wired: isSet3(object.wired) ? globalThis.Boolean(object.wired) : false,
4821
- description: isSet3(object.description) ? globalThis.String(object.description) : "",
4822
- sensitive: isSet3(object.sensitive) ? globalThis.Boolean(object.sensitive) : false
4823
- };
4824
- },
4825
- toJSON(message) {
4826
- const obj = {};
4827
- if (message.name !== "") {
4828
- obj.name = message.name;
4829
- }
4830
- if (message.type !== "") {
4831
- obj.type = message.type;
4832
- }
4833
- if (message.required !== false) {
4834
- obj.required = message.required;
4066
+ }
4067
+ reader.skip(tag & 7);
4068
+ }
4069
+ return message;
4070
+ },
4071
+ fromJSON(object) {
4072
+ return {
4073
+ x: isSet3(object.x) ? globalThis.Number(object.x) : 0,
4074
+ y: isSet3(object.y) ? globalThis.Number(object.y) : 0
4075
+ };
4076
+ },
4077
+ toJSON(message) {
4078
+ const obj = {};
4079
+ if (message.x !== 0) {
4080
+ obj.x = message.x;
4081
+ }
4082
+ if (message.y !== 0) {
4083
+ obj.y = message.y;
4084
+ }
4085
+ return obj;
4086
+ },
4087
+ create(base) {
4088
+ return Position.fromPartial(base ?? {});
4089
+ },
4090
+ fromPartial(object) {
4091
+ const message = createBasePosition();
4092
+ message.x = object.x ?? 0;
4093
+ message.y = object.y ?? 0;
4094
+ return message;
4095
+ }
4096
+ };
4097
+ function isSet3(value) {
4098
+ return value !== null && value !== void 0;
4099
+ }
4100
+
4101
+ // src/engine-identity.ts
4102
+ var ENGINE_PROTOCOL_VERSION = String(10 /* PROTOCOL_VERSION_CURRENT */);
4103
+ var ENGINE_CONTRACT = GENERATED_ENGINE_CONTRACT;
4104
+ var EngineIdentityMismatchError = class extends Error {
4105
+ constructor(engine, required) {
4106
+ const behind = engine.protocol === required.protocol ? void 0 : Number(engine.protocol) < Number(required.protocol) ? "engine" : "host";
4107
+ super(mismatchMessage(engine, required, behind));
4108
+ this.name = "EngineIdentityMismatchError";
4109
+ this.engineVersion = engine.version;
4110
+ this.engineProtocol = engine.protocol;
4111
+ this.engineContract = engine.contract;
4112
+ this.requiredProtocol = required.protocol;
4113
+ this.requiredContract = required.contract;
4114
+ this.behind = behind;
4115
+ }
4116
+ };
4117
+ function mismatchMessage(engine, required, behind) {
4118
+ const protocols = `Lace engine ${engine.version} speaks protocol ${engine.protocol}; this host speaks protocol ${required.protocol}`;
4119
+ switch (behind) {
4120
+ case "engine":
4121
+ return `${protocols}: update the Lace CLI`;
4122
+ case "host":
4123
+ return `${protocols}: update this host`;
4124
+ case void 0:
4125
+ 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`;
4126
+ }
4127
+ }
4128
+ function checkEngineIdentity(engine) {
4129
+ if (engine.protocol !== ENGINE_PROTOCOL_VERSION || engine.contract !== ENGINE_CONTRACT) {
4130
+ throw new EngineIdentityMismatchError(engine, {
4131
+ protocol: ENGINE_PROTOCOL_VERSION,
4132
+ contract: ENGINE_CONTRACT
4133
+ });
4134
+ }
4135
+ }
4136
+
4137
+ // src/render.ts
4138
+ var META_ARGUMENTS = ["count", "for_each"];
4139
+
4140
+ // src/projection/classify-child.ts
4141
+ function isGroupUse(bundle, use) {
4142
+ const target = bundle.modules[use.module];
4143
+ return target !== void 0 && isGroupModule(target);
4144
+ }
4145
+ function isGroupModule(mod) {
4146
+ return (mod.modules?.length ?? 0) > 0;
4147
+ }
4148
+
4149
+ // src/projection/derive-edges.ts
4150
+ function emitEdgesFromBinding(binding, targetId, toInput, useIds, seen, edges) {
4151
+ if (binding.out?.module && binding.out.name) {
4152
+ edges.push({
4153
+ source_instance: binding.out.module,
4154
+ target_instance: targetId,
4155
+ from_output: binding.out.name,
4156
+ to_input: toInput
4157
+ });
4158
+ return;
4159
+ }
4160
+ for (const ref of binding.expr?.module_references ?? []) {
4161
+ if (!useIds.has(ref.call)) continue;
4162
+ const fromOutput = ref.output ?? "";
4163
+ const key = `${ref.call}:${targetId}:${fromOutput}:${toInput}`;
4164
+ if (seen.has(key)) continue;
4165
+ seen.add(key);
4166
+ edges.push({
4167
+ source_instance: ref.call,
4168
+ target_instance: targetId,
4169
+ from_output: fromOutput,
4170
+ to_input: toInput
4171
+ });
4172
+ }
4173
+ }
4174
+ function deriveEdges(uses) {
4175
+ const useIds = new Set(uses.map((u) => u.id));
4176
+ const edges = [];
4177
+ const seen = /* @__PURE__ */ new Set();
4178
+ for (const target of uses) {
4179
+ const inputs = target.inputs ?? {};
4180
+ for (const [inputName, binding] of Object.entries(inputs)) {
4181
+ emitEdgesFromBinding(binding, target.id, inputName, useIds, seen, edges);
4182
+ }
4183
+ for (const meta of META_ARGUMENTS) {
4184
+ const binding = target[meta];
4185
+ if (binding) emitEdgesFromBinding(binding, target.id, meta, useIds, seen, edges);
4186
+ }
4187
+ }
4188
+ return edges;
4189
+ }
4190
+ function addPin(index, call, pin) {
4191
+ if (!index.has(call)) index.set(call, /* @__PURE__ */ new Set());
4192
+ index.get(call).add(pin);
4193
+ }
4194
+ function indexWires(edges) {
4195
+ const inputs = /* @__PURE__ */ new Map();
4196
+ const outputs = /* @__PURE__ */ new Map();
4197
+ for (const e of edges) {
4198
+ addPin(inputs, e.target_instance, e.to_input);
4199
+ addPin(outputs, e.source_instance, e.from_output);
4200
+ }
4201
+ return { inputs, outputs };
4202
+ }
4203
+ function deriveInterfaceEdges(mod) {
4204
+ const uses = mod.modules ?? [];
4205
+ const useIds = new Set(uses.map((u) => u.id));
4206
+ const declaredIn = new Set((mod.interface?.inputs ?? []).map((i) => i.name));
4207
+ const declaredOut = new Set((mod.interface?.outputs ?? []).map((o) => o.name));
4208
+ const edges = [];
4209
+ const fromInput = (pin, target, toInput) => {
4210
+ if (!pin || !declaredIn.has(pin)) return;
4211
+ edges.push({
4212
+ source_instance: "",
4213
+ target_instance: target,
4214
+ from_output: pin,
4215
+ to_input: toInput,
4216
+ source_pin: true
4217
+ });
4218
+ };
4219
+ for (const use of uses) {
4220
+ for (const [name, binding] of Object.entries(use.inputs ?? {})) {
4221
+ fromInput(binding.var ?? "", use.id, name);
4222
+ }
4223
+ for (const meta of META_ARGUMENTS) fromInput(use[meta]?.var ?? "", use.id, meta);
4224
+ }
4225
+ const seen = /* @__PURE__ */ new Set();
4226
+ for (const [name, exported] of Object.entries(mod.exports?.outputs ?? {})) {
4227
+ if (!declaredOut.has(name)) continue;
4228
+ const read = [];
4229
+ emitEdgesFromBinding(exported, "", name, useIds, seen, read);
4230
+ for (const edge of read) {
4231
+ if (useIds.has(edge.source_instance)) edges.push({ ...edge, target_pin: true });
4232
+ }
4233
+ if (exported.var && declaredIn.has(exported.var)) {
4234
+ edges.push({
4235
+ source_instance: "",
4236
+ target_instance: "",
4237
+ from_output: exported.var,
4238
+ to_input: name,
4239
+ source_pin: true,
4240
+ target_pin: true
4241
+ });
4242
+ }
4243
+ }
4244
+ return edges;
4245
+ }
4246
+ function scopeWires(mod, entry) {
4247
+ const derived = deriveEdges(mod.modules ?? []);
4248
+ const interfaceEdges = !entry && isGroupModule(mod) ? deriveInterfaceEdges(mod) : [];
4249
+ const { inputs, outputs } = indexWires(derived);
4250
+ for (const e of interfaceEdges) {
4251
+ if (!e.target_pin) addPin(inputs, e.target_instance, e.to_input);
4252
+ if (!e.source_pin) addPin(outputs, e.source_instance, e.from_output);
4253
+ }
4254
+ return { derived, interfaceEdges, inputs, outputs };
4255
+ }
4256
+ function callWires(wiredIn, wiredOut) {
4257
+ return {
4258
+ call_wired: wiredOut.has(""),
4259
+ meta_wired: META_ARGUMENTS.filter((meta) => wiredIn.has(meta))
4260
+ };
4261
+ }
4262
+
4263
+ // src/projection/resolve-schema.ts
4264
+ function resolveSchema(bundle, use, readOutputs) {
4265
+ const target = bundle.modules[use.module];
4266
+ if (!target) return { inputs: [], outputs: [] };
4267
+ if (target.interface) {
4268
+ return { inputs: target.interface.inputs, outputs: target.interface.outputs };
4269
+ }
4270
+ return {
4271
+ inputs: Object.keys(use.inputs ?? {}).sort().map((name) => InputDef.create({ name })),
4272
+ outputs: [...new Set(readOutputs)].filter((name) => name !== "").sort().map((name) => OutputDef.create({ name }))
4273
+ };
4274
+ }
4275
+ function findChild(mod, id) {
4276
+ for (const use of mod.modules ?? []) {
4277
+ if (use.id === id) return { id, use };
4278
+ }
4279
+ for (const resource of mod.resources ?? []) {
4280
+ if (resource.id === id) return { id, resource };
4281
+ }
4282
+ return null;
4283
+ }
4284
+ function resolveInstance(bundle, id) {
4285
+ return resolveFrom(bundle, bundle.entry, id);
4286
+ }
4287
+ function resolveFrom(bundle, scopeKey, id) {
4288
+ const scope = bundle.modules[scopeKey];
4289
+ if (!scope) return null;
4290
+ for (const use of scope.modules ?? []) {
4291
+ if (!id.startsWith(`${use.id}.`)) continue;
4292
+ const nested = resolveFrom(bundle, use.module, id.slice(use.id.length + 1));
4293
+ if (nested) return nested;
4294
+ }
4295
+ const child = findChild(scope, id);
4296
+ return child ? { scopeKey, scope, child } : null;
4297
+ }
4298
+ function instanceAddress(bundle, id) {
4299
+ const resolved = resolveInstance(bundle, id);
4300
+ return resolved ? { scope: resolved.scopeKey, id: resolved.child.id } : { scope: bundle.entry, id };
4301
+ }
4302
+ function resolveScopePath(bundle, path) {
4303
+ if (path === "") {
4304
+ return bundle.modules[bundle.entry] ? bundle.entry : null;
4305
+ }
4306
+ return resolveInstance(bundle, path)?.child.use?.module ?? null;
4307
+ }
4308
+
4309
+ // src/projection/inspect.ts
4310
+ function hclLiteralText(lit) {
4311
+ if (typeof lit === "string") return quoteHclString(lit);
4312
+ if (typeof lit === "number" || typeof lit === "boolean") return String(lit);
4313
+ if (Array.isArray(lit)) return `[${lit.map(hclLiteralText).join(", ")}]`;
4314
+ if (lit !== null && typeof lit === "object") {
4315
+ return hclObjectText(lit);
4316
+ }
4317
+ return String(lit);
4318
+ }
4319
+ function quoteHclString(s) {
4320
+ let out = "";
4321
+ for (let i = 0; i < s.length; i++) {
4322
+ const c = s[i];
4323
+ switch (c) {
4324
+ case "\\":
4325
+ out += "\\\\";
4326
+ break;
4327
+ case '"':
4328
+ out += '\\"';
4329
+ break;
4330
+ case "\n":
4331
+ out += "\\n";
4332
+ break;
4333
+ case "\r":
4334
+ out += "\\r";
4335
+ break;
4336
+ case " ":
4337
+ out += "\\t";
4338
+ break;
4339
+ case "$":
4340
+ case "%":
4341
+ out += s[i + 1] === "{" ? c + c : c;
4342
+ break;
4343
+ default:
4344
+ out += c;
4835
4345
  }
4836
- if (message.wired !== false) {
4837
- obj.wired = message.wired;
4346
+ }
4347
+ return `"${out}"`;
4348
+ }
4349
+ function hclObjectText(obj) {
4350
+ const entries = Object.entries(obj).sort(([a], [b]) => a < b ? -1 : a > b ? 1 : 0);
4351
+ if (entries.length === 0) return "{}";
4352
+ const width = Math.max(...entries.map(([k]) => k.length)) + 1;
4353
+ const lines = entries.map(([k, v]) => ` ${k.padEnd(width)}= ${hclLiteralText(v)}`);
4354
+ return `{
4355
+ ${lines.join("\n")}
4356
+ }`;
4357
+ }
4358
+ function bindingText(b) {
4359
+ if (!b) return "";
4360
+ if (b.lit !== void 0 && b.lit !== null) return hclLiteralText(b.lit);
4361
+ if (b.var) return `var.${b.var}`;
4362
+ if (b.out) return `module.${b.out.module}.${b.out.name}`;
4363
+ if (b.expr) return b.expr.value;
4364
+ return "";
4365
+ }
4366
+ function exportText(e) {
4367
+ if (!e) return "";
4368
+ if (e.out) return `${childReference(e.out.module)}.${e.out.name}`;
4369
+ return bindingText({ lit: e.lit, var: e.var, out: void 0, expr: e.expr });
4370
+ }
4371
+ function childReference(id) {
4372
+ if (id.startsWith("resource.")) return id.slice("resource.".length);
4373
+ if (id.startsWith("data.")) return id;
4374
+ return `module.${id}`;
4375
+ }
4376
+ function bindingMode(b) {
4377
+ if (!b) return { mode: "empty" };
4378
+ if (b.out) return { mode: "wired", wired_source: bindingText(b) };
4379
+ if (b.var) return { mode: "variable", variable: b.var };
4380
+ if (b.expr) return { mode: "expression", expression: b.expr.value };
4381
+ if (b.lit !== void 0 && b.lit !== null) return { mode: "literal", value: b.lit };
4382
+ return { mode: "empty" };
4383
+ }
4384
+ function deriveNodeConfig(bundle, instanceId) {
4385
+ const resolved = resolveInstance(bundle, instanceId);
4386
+ if (!resolved) return null;
4387
+ const { scope, child } = resolved;
4388
+ const readOutputs = scopeWires(scope, resolved.scopeKey === bundle.entry).outputs.get(child.id) ?? [];
4389
+ const schema = child.use ? resolveSchema(bundle, child.use, readOutputs) : { inputs: [], outputs: [] };
4390
+ const schemaInputs = schema.inputs;
4391
+ const schemaOutputs = schema.outputs;
4392
+ const boundInputs = child.use?.inputs ?? child.resource?.inputs ?? {};
4393
+ const inputs = schemaInputs.map((def) => ({
4394
+ name: def.name,
4395
+ type: def.type,
4396
+ required: def.required,
4397
+ description: def.description || void 0,
4398
+ default_value: def.default_value,
4399
+ validation: def.validation?.[0] ? { condition: def.validation[0].condition, error_message: def.validation[0].error_message } : void 0,
4400
+ ...bindingMode(boundInputs[def.name])
4401
+ }));
4402
+ const outputs = schemaOutputs.map((def) => ({
4403
+ name: def.name,
4404
+ type: def.type,
4405
+ description: def.description || void 0,
4406
+ sensitive: def.sensitive || void 0
4407
+ }));
4408
+ const dependencyOptions = [
4409
+ ...(scope.modules ?? []).map((u) => u.id),
4410
+ ...(scope.resources ?? []).map((r) => r.id)
4411
+ ].filter((id) => id !== child.id).map(childReference);
4412
+ const dependsOn = child.use?.depends_on ?? child.resource?.depends_on ?? [];
4413
+ const providers = child.use?.providers ?? {};
4414
+ const meta = child.use ?? child.resource;
4415
+ const availableVariables = (scope.interface?.inputs ?? []).map((v) => ({
4416
+ name: v.name,
4417
+ type: v.type
4418
+ }));
4419
+ return {
4420
+ instance_id: instanceId,
4421
+ module_key: child.use?.module,
4422
+ source: child.use ? callSource(bundle, resolved.scopeKey, child.use.module) : void 0,
4423
+ inputs,
4424
+ outputs,
4425
+ dependency_options: dependencyOptions,
4426
+ depends_on: dependsOn,
4427
+ providers,
4428
+ count: bindingText(meta?.count),
4429
+ for_each: bindingText(meta?.for_each),
4430
+ available_variables: availableVariables
4431
+ };
4432
+ }
4433
+ function callSource(bundle, scopeKey, moduleKey) {
4434
+ const from = dirOf(bundle, scopeKey);
4435
+ const to = sourceDir(bundle, moduleKey);
4436
+ if (from !== void 0 && to !== void 0) return memberSourcePath(from, to);
4437
+ const source = bundle.modules[moduleKey]?.source;
4438
+ return source ? sourceText(source) : "";
4439
+ }
4440
+ function isMemberDir(id) {
4441
+ return id !== "" && id !== "." && id !== ".." && !id.startsWith("./") && !id.startsWith("../") && !id.startsWith("/");
4442
+ }
4443
+ function dirOf(bundle, key) {
4444
+ if (key === bundle.entry) return "";
4445
+ const mod = bundle.modules[key];
4446
+ if (!mod || mod.source || !isMemberDir(mod.id)) return void 0;
4447
+ return mod.id;
4448
+ }
4449
+ function sourceDir(bundle, key) {
4450
+ const dir = dirOf(bundle, key);
4451
+ if (dir !== void 0) return dir;
4452
+ const mod = bundle.modules[key];
4453
+ return mod?.source?.kind === "local" && isMemberDir(mod.id) ? mod.id : void 0;
4454
+ }
4455
+ function memberSourcePath(from, to) {
4456
+ const base = from === "" ? [] : from.split("/");
4457
+ const target = to.split("/");
4458
+ let shared = 0;
4459
+ while (shared < base.length && shared < target.length && base[shared] === target[shared]) {
4460
+ shared++;
4461
+ }
4462
+ const rel = [...base.slice(shared).map(() => ".."), ...target.slice(shared)].join("/") || ".";
4463
+ return rel.startsWith("../") ? rel : `./${rel}`;
4464
+ }
4465
+ function sourceText(source) {
4466
+ if (source.kind === "git") {
4467
+ const subdir = source.subdir ? `//${source.subdir}` : "";
4468
+ const ref = source.ref ? `?ref=${source.ref}` : "";
4469
+ return `git::${source.repo}${subdir}${ref}`;
4470
+ }
4471
+ return source.kind === "local" ? source.subdir : source.ref;
4472
+ }
4473
+ function defaultText(value) {
4474
+ return value === void 0 || value === null ? "null" : hclLiteralText(value);
4475
+ }
4476
+ function blockConfigs(blocks) {
4477
+ return (blocks ?? []).map((b) => ({
4478
+ type: b.type,
4479
+ labels: [...b.labels],
4480
+ attributes: b.attributes.map((a) => ({ name: a.name, value: bindingText(a.value) })),
4481
+ blocks: blockConfigs(b.blocks)
4482
+ }));
4483
+ }
4484
+ function resourceConfig(r) {
4485
+ const kind = r.kind === "data" ? "data" : "resource";
4486
+ return {
4487
+ id: r.id,
4488
+ kind,
4489
+ type: r.type,
4490
+ name: r.id.slice(`${kind}.${r.type}.`.length),
4491
+ arguments: Object.keys(r.inputs ?? {}).sort().map((name) => ({ name, value: bindingText(r.inputs[name]) })),
4492
+ blocks: blockConfigs(r.blocks),
4493
+ count: bindingText(r.count),
4494
+ for_each: bindingText(r.for_each),
4495
+ provider: r.provider_ref,
4496
+ depends_on: [...r.depends_on ?? []]
4497
+ };
4498
+ }
4499
+ function deriveSettingsConfig(bundle, moduleKey) {
4500
+ const mod = bundle.modules[moduleKey];
4501
+ if (!mod) return null;
4502
+ const terraform = mod.terraform ? {
4503
+ required_version: mod.terraform.required_version,
4504
+ required_providers: Object.entries(mod.terraform.required_providers ?? {}).map(
4505
+ ([name, req]) => ({
4506
+ name,
4507
+ source: req.source,
4508
+ version: req.version,
4509
+ configuration_aliases: req.configuration_aliases
4510
+ })
4511
+ )
4512
+ } : { required_version: "", required_providers: [] };
4513
+ const providers = (mod.providers ?? []).map((p) => {
4514
+ const config = {};
4515
+ for (const [k, v] of Object.entries(p.config ?? {})) {
4516
+ config[k] = bindingText(v);
4838
4517
  }
4839
- if (message.description !== "") {
4840
- obj.description = message.description;
4518
+ return { name: p.name, alias: p.alias, config, blocks: blockConfigs(p.blocks) };
4519
+ });
4520
+ const locals = (mod.locals ?? []).map((l) => ({ name: l.name, value: bindingText(l.value) }));
4521
+ const variables = (mod.interface?.inputs ?? []).map((v) => ({
4522
+ name: v.name,
4523
+ type: v.type,
4524
+ required: v.required,
4525
+ description: v.description || void 0,
4526
+ default_value: v.default_value,
4527
+ validation: v.validation?.map((b) => ({
4528
+ condition: b.condition,
4529
+ error_message: b.error_message
4530
+ })),
4531
+ ephemeral: v.ephemeral,
4532
+ sensitive: v.sensitive || void 0,
4533
+ nullable: v.nullable,
4534
+ default: v.required ? "" : defaultText(v.default_value)
4535
+ }));
4536
+ const outputs = (mod.interface?.outputs ?? []).map((o) => ({
4537
+ name: o.name,
4538
+ type: o.type,
4539
+ value: exportText(mod.exports?.outputs?.[o.name]),
4540
+ description: o.description || void 0,
4541
+ sensitive: o.sensitive || void 0,
4542
+ depends_on: o.depends_on
4543
+ }));
4544
+ const read = scopeWires(mod, moduleKey === bundle.entry).outputs;
4545
+ const callOutputs = (mod.modules ?? []).flatMap(
4546
+ (use) => resolveSchema(bundle, use, read.get(use.id) ?? []).outputs.map(
4547
+ (o) => `module.${use.id}.${o.name}`
4548
+ )
4549
+ );
4550
+ const resources = (mod.resources ?? []).map(resourceConfig);
4551
+ const leaf = !mod.source && moduleKey !== bundle.entry && (mod.modules ?? []).length === 0;
4552
+ return {
4553
+ module_key: moduleKey,
4554
+ reference: mod.source ? { source: sourceText(mod.source), version: mod.version } : void 0,
4555
+ terraform,
4556
+ providers,
4557
+ locals,
4558
+ variables,
4559
+ outputs,
4560
+ resources,
4561
+ holds_managed_resources: resources.some((r) => r.kind === "resource") || leaf,
4562
+ directives: blockConfigs(mod.top_level_blocks),
4563
+ call_outputs: callOutputs,
4564
+ dependency_options: [
4565
+ ...(mod.modules ?? []).map((u) => childReference(u.id)),
4566
+ ...(mod.resources ?? []).map((r) => childReference(r.id))
4567
+ ]
4568
+ };
4569
+ }
4570
+
4571
+ // src/projection/join-path.ts
4572
+ function joinPath(prefix, localId) {
4573
+ return prefix === "" ? localId : `${prefix}.${localId}`;
4574
+ }
4575
+ function splitPath(canvasPath) {
4576
+ const lastDot = canvasPath.lastIndexOf(".");
4577
+ if (lastDot === -1) return { parentPath: "", localId: canvasPath };
4578
+ return { parentPath: canvasPath.slice(0, lastDot), localId: canvasPath.slice(lastDot + 1) };
4579
+ }
4580
+ function callText(sourcePath) {
4581
+ return `module.${splitPath(sourcePath).localId}`;
4582
+ }
4583
+ function groupPinText(group, end, pin) {
4584
+ return `${group}.${end === "source" ? "inputs" : "outputs"}.${pin}`;
4585
+ }
4586
+
4587
+ // src/projection/node-for-address.ts
4588
+ var INSTANCE_KEY = /\[[^\]]*\]$/;
4589
+ function tokenizeAddress(address) {
4590
+ const tokens = [];
4591
+ let current = "";
4592
+ let depth = 0;
4593
+ for (const ch of address) {
4594
+ if (ch === "[") depth++;
4595
+ else if (ch === "]") depth--;
4596
+ if (ch === "." && depth === 0) {
4597
+ tokens.push(current);
4598
+ current = "";
4599
+ } else {
4600
+ current += ch;
4841
4601
  }
4842
- if (message.sensitive !== false) {
4843
- obj.sensitive = message.sensitive;
4602
+ }
4603
+ tokens.push(current);
4604
+ return tokens;
4605
+ }
4606
+ function nodeIdForAddress(view, address) {
4607
+ const tokens = tokenizeAddress(address);
4608
+ const moduleNames = [];
4609
+ let i = 0;
4610
+ while (i + 1 < tokens.length && tokens[i] === "module") {
4611
+ moduleNames.push(tokens[i + 1].replace(INSTANCE_KEY, ""));
4612
+ i += 2;
4613
+ }
4614
+ if (moduleNames.length === 0) return null;
4615
+ const known = /* @__PURE__ */ new Set();
4616
+ for (const n of view.nodes) known.add(n.id);
4617
+ for (const g of view.groups) known.add(g.id);
4618
+ for (let k = moduleNames.length; k >= 1; k--) {
4619
+ let path = "";
4620
+ for (let j = 0; j < k; j++) path = joinPath(path, moduleNames[j]);
4621
+ if (known.has(path)) return path;
4622
+ }
4623
+ return null;
4624
+ }
4625
+
4626
+ // src/projection/node-for-diagnostic.ts
4627
+ function buildScopeIndex(view) {
4628
+ const byModuleKey = /* @__PURE__ */ new Map();
4629
+ const known = /* @__PURE__ */ new Set();
4630
+ for (const n of view.nodes) known.add(n.id);
4631
+ for (const g of view.groups) {
4632
+ known.add(g.id);
4633
+ if (g.module_key) {
4634
+ const ids = byModuleKey.get(g.module_key);
4635
+ if (ids) ids.push(g.id);
4636
+ else byModuleKey.set(g.module_key, [g.id]);
4844
4637
  }
4845
- return obj;
4846
- },
4847
- create(base) {
4848
- return NodePin.fromPartial(base ?? {});
4849
- },
4850
- fromPartial(object) {
4851
- const message = createBaseNodePin();
4852
- message.name = object.name ?? "";
4853
- message.type = object.type ?? "";
4854
- message.required = object.required ?? false;
4855
- message.wired = object.wired ?? false;
4856
- message.description = object.description ?? "";
4857
- message.sensitive = object.sensitive ?? false;
4858
- return message;
4859
4638
  }
4860
- };
4861
- function createBaseRenderEdge() {
4862
- return { id: "", source: "", target: "", source_output: "", target_input: "" };
4639
+ return { byModuleKey, known };
4640
+ }
4641
+ function nodeIdForDiagnostic(view, diagnostic) {
4642
+ if (diagnostic.address) return nodeIdForAddress(view, diagnostic.address);
4643
+ if (!diagnostic.instance_id) return null;
4644
+ const index = buildScopeIndex(view);
4645
+ const scopeIds = diagnostic.module_key ? index.byModuleKey.get(diagnostic.module_key) : void 0;
4646
+ if (!scopeIds || scopeIds.length === 0) {
4647
+ return index.known.has(diagnostic.instance_id) ? diagnostic.instance_id : null;
4648
+ }
4649
+ if (scopeIds.length > 1) return null;
4650
+ const nodeId = `${scopeIds[0]}.${diagnostic.instance_id}`;
4651
+ return index.known.has(nodeId) ? nodeId : null;
4652
+ }
4653
+
4654
+ // src/projection/geometry.ts
4655
+ var NODE_WIDTH = 200;
4656
+ var NODE_HEADER_HEIGHT = 28;
4657
+ var NODE_ROW_HEIGHT = 22;
4658
+ var GROUP_PADDING = { x: 40, top: 60, bottom: 20 };
4659
+ var GROUP_HEADER_HEIGHT = 32;
4660
+ var COLLAPSED_GROUP_WIDTH = 220;
4661
+ function visibleInputs(inputs) {
4662
+ return inputs.filter((pin) => pin.required || pin.wired);
4663
+ }
4664
+ function nodeRows(node) {
4665
+ const shown = visibleInputs(node.inputs);
4666
+ const folded = node.inputs.length > shown.length ? 1 : 0;
4667
+ return Math.max(shown.length + folded, node.outputs.length);
4668
+ }
4669
+ function nodeSize(node) {
4670
+ return { width: NODE_WIDTH, height: NODE_HEADER_HEIGHT + nodeRows(node) * NODE_ROW_HEIGHT };
4671
+ }
4672
+ function inputPinY(node, name) {
4673
+ const row = visibleInputs(node.inputs).findIndex((pin) => pin.name === name);
4674
+ return row < 0 ? NODE_HEADER_HEIGHT / 2 : NODE_HEADER_HEIGHT + (row + 0.5) * NODE_ROW_HEIGHT;
4675
+ }
4676
+ function extentOf(rects) {
4677
+ if (rects.length === 0) return { x: 0, y: 0, width: 0, height: 0 };
4678
+ const x = Math.min(...rects.map((r) => r.x));
4679
+ const y = Math.min(...rects.map((r) => r.y));
4680
+ return {
4681
+ x,
4682
+ y,
4683
+ width: Math.max(...rects.map((r) => r.x + r.width)) - x,
4684
+ height: Math.max(...rects.map((r) => r.y + r.height)) - y
4685
+ };
4686
+ }
4687
+ function groupBoxSize(content) {
4688
+ return {
4689
+ width: content.width + 2 * GROUP_PADDING.x,
4690
+ height: GROUP_PADDING.top + content.height + GROUP_PADDING.bottom
4691
+ };
4692
+ }
4693
+ function collapsedGroupSize(pins) {
4694
+ const rows = Math.max(pins.inputs?.length ?? 0, pins.outputs?.length ?? 0);
4695
+ return { width: COLLAPSED_GROUP_WIDTH, height: GROUP_HEADER_HEIGHT + rows * NODE_ROW_HEIGHT };
4696
+ }
4697
+ function groupPinY(row) {
4698
+ return GROUP_HEADER_HEIGHT + (row + 0.5) * NODE_ROW_HEIGHT;
4699
+ }
4700
+ function groupInputPinY(group, name) {
4701
+ const row = (group.inputs ?? []).findIndex((pin) => pin.name === name);
4702
+ return row < 0 ? GROUP_HEADER_HEIGHT / 2 : groupPinY(row);
4703
+ }
4704
+ function groupFootprint(group, box) {
4705
+ return group.collapsed ? collapsedGroupSize(group) : box;
4706
+ }
4707
+ function groupReach(pins, box) {
4708
+ const card = collapsedGroupSize(pins);
4709
+ return { width: Math.max(card.width, box.width), height: Math.max(card.height, box.height) };
4710
+ }
4711
+
4712
+ // src/projection/frames.ts
4713
+ var ZERO = { x: 0, y: 0 };
4714
+ function boxAt(origin, min = ZERO) {
4715
+ return { x: origin.x + min.x - GROUP_PADDING.x, y: origin.y + min.y - GROUP_PADDING.top };
4716
+ }
4717
+ function originAt(box, min = ZERO) {
4718
+ return { x: box.x - min.x + GROUP_PADDING.x, y: box.y - min.y + GROUP_PADDING.top };
4719
+ }
4720
+ function drawnAt(view, canvasPath) {
4721
+ return view.nodes.find((n) => n.id === canvasPath)?.position ?? view.groups.find((g) => g.id === canvasPath)?.position;
4722
+ }
4723
+ function drawnRect(view, canvasPath) {
4724
+ const node = view.nodes.find((n) => n.id === canvasPath);
4725
+ if (node) return { ...node.position, ...nodeSize(node) };
4726
+ const group = view.groups.find((g) => g.id === canvasPath);
4727
+ return group ? { ...group.position, ...groupFootprint(group, group.size) } : void 0;
4728
+ }
4729
+ function reachRect(view, canvasPath) {
4730
+ const group = view.groups.find((g) => g.id === canvasPath);
4731
+ if (!group) return drawnRect(view, canvasPath);
4732
+ return { ...group.position, ...groupReach(group, group.size) };
4733
+ }
4734
+ function frameOf(view, canvasPath) {
4735
+ const { parentPath } = splitPath(canvasPath);
4736
+ if (parentPath === "") return ZERO;
4737
+ return view.groups.find((g) => g.id === parentPath)?.origin ?? ZERO;
4738
+ }
4739
+ function localIn(view, canvasPath, drawn, frame = frameOf(view, canvasPath)) {
4740
+ const group = view.groups.find((g) => g.id === canvasPath);
4741
+ if (!group) return { x: drawn.x - frame.x, y: drawn.y - frame.y };
4742
+ const anchor = boxAt(group.origin);
4743
+ return {
4744
+ x: drawn.x - (group.position.x - anchor.x) - frame.x,
4745
+ y: drawn.y - (group.position.y - anchor.y) - frame.y
4746
+ };
4747
+ }
4748
+
4749
+ // src/projection/parse-module-key.ts
4750
+ function parseModuleKey(key) {
4751
+ const at = key.lastIndexOf("@");
4752
+ if (at < 0) return { id: key, version: "" };
4753
+ return { id: key.slice(0, at), version: key.slice(at + 1) };
4754
+ }
4755
+
4756
+ // src/projection/compute-layout.ts
4757
+ var SPACING_X = 260;
4758
+ var SPACING_Y = 180;
4759
+ var GAP_X = 60;
4760
+ var GAP_Y = 40;
4761
+ var ORDINARY = { width: NODE_WIDTH, height: SPACING_Y - GAP_Y };
4762
+ function slotOf(size) {
4763
+ return {
4764
+ width: Math.max(SPACING_X, size.width + GAP_X),
4765
+ height: Math.max(SPACING_Y, size.height + GAP_Y)
4766
+ };
4767
+ }
4768
+ function overlaps(a, b) {
4769
+ return a.x < b.x + b.width && a.x + a.width > b.x && a.y < b.y + b.height && a.y + a.height > b.y;
4770
+ }
4771
+ function stepDown(at, size, taken) {
4772
+ let candidate = at;
4773
+ const blocking = () => taken.filter((r) => overlaps({ ...candidate, ...size }, r));
4774
+ for (let inWay = blocking(); inWay.length > 0; inWay = blocking()) {
4775
+ candidate = { x: candidate.x, y: Math.max(...inWay.map((r) => r.y + r.height)) };
4776
+ }
4777
+ return candidate;
4778
+ }
4779
+ function keepOrder(a, b) {
4780
+ return a.y - b.y || a.x - b.x || a.declared - b.declared;
4781
+ }
4782
+ function freeSlot(extent, occupied) {
4783
+ return stepDown(
4784
+ { x: 0, y: 0 },
4785
+ slotOf(extent),
4786
+ occupied.map((r) => ({ x: r.x, y: r.y, ...slotOf(r) }))
4787
+ );
4863
4788
  }
4864
- var RenderEdge = {
4865
- encode(message, writer = new BinaryWriter3()) {
4866
- if (message.id !== "") {
4867
- writer.uint32(10).string(message.id);
4868
- }
4869
- if (message.source !== "") {
4870
- writer.uint32(18).string(message.source);
4871
- }
4872
- if (message.target !== "") {
4873
- writer.uint32(26).string(message.target);
4874
- }
4875
- if (message.source_output !== "") {
4876
- writer.uint32(34).string(message.source_output);
4877
- }
4878
- if (message.target_input !== "") {
4879
- writer.uint32(42).string(message.target_input);
4880
- }
4881
- return writer;
4882
- },
4883
- decode(input, length) {
4884
- const reader = input instanceof BinaryReader3 ? input : new BinaryReader3(input);
4885
- const end = length === void 0 ? reader.len : reader.pos + length;
4886
- const message = createBaseRenderEdge();
4887
- while (reader.pos < end) {
4888
- const tag = reader.uint32();
4889
- switch (tag >>> 3) {
4890
- case 1: {
4891
- if (tag !== 10) {
4892
- break;
4893
- }
4894
- message.id = reader.string();
4895
- continue;
4896
- }
4897
- case 2: {
4898
- if (tag !== 18) {
4899
- break;
4900
- }
4901
- message.source = reader.string();
4902
- continue;
4903
- }
4904
- case 3: {
4905
- if (tag !== 26) {
4906
- break;
4907
- }
4908
- message.target = reader.string();
4909
- continue;
4910
- }
4911
- case 4: {
4912
- if (tag !== 34) {
4913
- break;
4914
- }
4915
- message.source_output = reader.string();
4916
- continue;
4917
- }
4918
- case 5: {
4919
- if (tag !== 42) {
4920
- break;
4921
- }
4922
- message.target_input = reader.string();
4923
- continue;
4924
- }
4925
- }
4926
- if ((tag & 7) === 4 || tag === 0) {
4927
- break;
4928
- }
4929
- reader.skip(tag & 7);
4930
- }
4931
- return message;
4932
- },
4933
- fromJSON(object) {
4934
- return {
4935
- id: isSet3(object.id) ? globalThis.String(object.id) : "",
4936
- source: isSet3(object.source) ? globalThis.String(object.source) : "",
4937
- target: isSet3(object.target) ? globalThis.String(object.target) : "",
4938
- source_output: isSet3(object.sourceOutput) ? globalThis.String(object.sourceOutput) : isSet3(object.source_output) ? globalThis.String(object.source_output) : "",
4939
- target_input: isSet3(object.targetInput) ? globalThis.String(object.targetInput) : isSet3(object.target_input) ? globalThis.String(object.target_input) : ""
4940
- };
4941
- },
4942
- toJSON(message) {
4943
- const obj = {};
4944
- if (message.id !== "") {
4945
- obj.id = message.id;
4946
- }
4947
- if (message.source !== "") {
4948
- obj.source = message.source;
4949
- }
4950
- if (message.target !== "") {
4951
- obj.target = message.target;
4952
- }
4953
- if (message.source_output !== "") {
4954
- obj.sourceOutput = message.source_output;
4955
- }
4956
- if (message.target_input !== "") {
4957
- obj.targetInput = message.target_input;
4958
- }
4959
- return obj;
4960
- },
4961
- create(base) {
4962
- return RenderEdge.fromPartial(base ?? {});
4963
- },
4964
- fromPartial(object) {
4965
- const message = createBaseRenderEdge();
4966
- message.id = object.id ?? "";
4967
- message.source = object.source ?? "";
4968
- message.target = object.target ?? "";
4969
- message.source_output = object.source_output ?? "";
4970
- message.target_input = object.target_input ?? "";
4971
- return message;
4789
+ function resolveScopePositionsByDepth(ids, arrangementNodes, edges) {
4790
+ const stored = /* @__PURE__ */ new Map();
4791
+ for (const id of ids) {
4792
+ const at = arrangementNodes?.[id];
4793
+ if (at) stored.set(id, at);
4972
4794
  }
4973
- };
4974
- function createBasePosition() {
4975
- return { x: 0, y: 0 };
4795
+ return layoutByDepth(
4796
+ ids.map((id) => ({ id, size: ORDINARY })),
4797
+ stored,
4798
+ edges
4799
+ );
4976
4800
  }
4977
- var Position = {
4978
- encode(message, writer = new BinaryWriter3()) {
4979
- if (message.x !== 0) {
4980
- writer.uint32(9).double(message.x);
4801
+ function layoutByDepth(items, stored, edges) {
4802
+ const byId = new Map(items.map((item) => [item.id, item]));
4803
+ const ids = items.map((item) => item.id);
4804
+ const slots = new Map(items.map((item) => [item.id, slotOf(item.size)]));
4805
+ const slotOfId = (id) => slots.get(id) ?? slotOf(ORDINARY);
4806
+ const declared = new Map(ids.map((id, i) => [id, i]));
4807
+ const keyOf = (id, at) => ({ ...at, declared: declared.get(id) ?? 0 });
4808
+ const inOrder = [...stored].sort(([p, a], [q, b]) => keepOrder(keyOf(p, a), keyOf(q, b)));
4809
+ const kept = /* @__PURE__ */ new Map();
4810
+ const keptRects = [];
4811
+ const keptSlots = [];
4812
+ for (const [id, wanted] of inOrder) {
4813
+ const item = byId.get(id);
4814
+ if (!item) continue;
4815
+ const slot = slotOfId(id);
4816
+ const clear = !keptRects.some((r) => overlaps({ ...wanted, ...item.size }, r));
4817
+ const at = clear ? wanted : stepDown(wanted, slot, keptSlots);
4818
+ kept.set(id, at);
4819
+ keptRects.push({ ...at, ...item.size });
4820
+ keptSlots.push({ ...at, ...slot });
4821
+ }
4822
+ const columns = columnByDepth(ids, edges);
4823
+ const columnX = /* @__PURE__ */ new Map();
4824
+ {
4825
+ const widths = /* @__PURE__ */ new Map();
4826
+ for (const id of ids) {
4827
+ const c = columns.get(id) ?? 0;
4828
+ widths.set(c, Math.max(widths.get(c) ?? SPACING_X, slotOfId(id).width));
4981
4829
  }
4982
- if (message.y !== 0) {
4983
- writer.uint32(17).double(message.y);
4830
+ const last = Math.max(0, ...widths.keys());
4831
+ let x = 0;
4832
+ for (let c = 0; c <= last; c += 1) {
4833
+ columnX.set(c, x);
4834
+ x += widths.get(c) ?? SPACING_X;
4984
4835
  }
4985
- return writer;
4986
- },
4987
- decode(input, length) {
4988
- const reader = input instanceof BinaryReader3 ? input : new BinaryReader3(input);
4989
- const end = length === void 0 ? reader.len : reader.pos + length;
4990
- const message = createBasePosition();
4991
- while (reader.pos < end) {
4992
- const tag = reader.uint32();
4993
- switch (tag >>> 3) {
4994
- case 1: {
4995
- if (tag !== 9) {
4996
- break;
4997
- }
4998
- message.x = reader.double();
4999
- continue;
5000
- }
5001
- case 2: {
5002
- if (tag !== 17) {
5003
- break;
5004
- }
5005
- message.y = reader.double();
5006
- continue;
4836
+ }
4837
+ const feeders = /* @__PURE__ */ new Map();
4838
+ const fed = /* @__PURE__ */ new Map();
4839
+ for (const edge of edges) {
4840
+ if (edge.source_instance === edge.target_instance) continue;
4841
+ if (!byId.has(edge.source_instance) || !byId.has(edge.target_instance)) continue;
4842
+ feeders.set(edge.target_instance, [
4843
+ ...feeders.get(edge.target_instance) ?? [],
4844
+ edge.source_instance
4845
+ ]);
4846
+ fed.set(edge.source_instance, [...fed.get(edge.source_instance) ?? [], edge]);
4847
+ }
4848
+ const byColumn = /* @__PURE__ */ new Map();
4849
+ for (const id of ids) {
4850
+ if (kept.has(id)) continue;
4851
+ const column = columns.get(id) ?? 0;
4852
+ byColumn.set(column, [...byColumn.get(column) ?? [], id]);
4853
+ }
4854
+ const heightOf = (id) => byId.get(id)?.size.height ?? 0;
4855
+ const mean = (values) => values.reduce((sum, v) => sum + v, 0) / values.length;
4856
+ const place = (unfedOrder2) => {
4857
+ const rank = new Map(unfedOrder2.map((id, i) => [id, i]));
4858
+ const positions = new Map(kept);
4859
+ const taken = [...keptSlots];
4860
+ for (const column of [...byColumn.keys()].sort((p, q) => p - q)) {
4861
+ const members = [...byColumn.get(column) ?? []].sort(
4862
+ (p, q) => (rank.get(p) ?? 0) - (rank.get(q) ?? 0)
4863
+ );
4864
+ const tops = /* @__PURE__ */ new Map();
4865
+ let stacked = 0;
4866
+ for (const id of members) {
4867
+ const from = (feeders.get(id) ?? []).flatMap((f) => {
4868
+ const at = positions.get(f);
4869
+ return at ? [at.y + heightOf(f) / 2] : [];
4870
+ });
4871
+ if (from.length > 0) {
4872
+ tops.set(id, mean(from) - heightOf(id) / 2);
4873
+ } else {
4874
+ tops.set(id, stacked);
4875
+ stacked += slotOfId(id).height;
5007
4876
  }
5008
4877
  }
5009
- if ((tag & 7) === 4 || tag === 0) {
5010
- break;
4878
+ const sorted = [...members].sort((p, q) => (tops.get(p) ?? 0) - (tops.get(q) ?? 0));
4879
+ if (sorted.length > 1) {
4880
+ const offsets = [];
4881
+ let run = 0;
4882
+ for (const id of sorted) {
4883
+ offsets.push(run);
4884
+ run += slotOfId(id).height;
4885
+ }
4886
+ const first = mean(sorted.map((id) => tops.get(id) ?? 0)) - mean(offsets);
4887
+ for (const [i, id] of sorted.entries()) tops.set(id, first + offsets[i]);
4888
+ }
4889
+ const x = columnX.get(column) ?? 0;
4890
+ for (const id of sorted) {
4891
+ const slot = slotOfId(id);
4892
+ const at = stepDown({ x, y: tops.get(id) ?? 0 }, slot, taken);
4893
+ positions.set(id, at);
4894
+ taken.push({ ...at, ...slot });
5011
4895
  }
5012
- reader.skip(tag & 7);
5013
- }
5014
- return message;
5015
- },
5016
- fromJSON(object) {
5017
- return {
5018
- x: isSet3(object.x) ? globalThis.Number(object.x) : 0,
5019
- y: isSet3(object.y) ? globalThis.Number(object.y) : 0
5020
- };
5021
- },
5022
- toJSON(message) {
5023
- const obj = {};
5024
- if (message.x !== 0) {
5025
- obj.x = message.x;
5026
4896
  }
5027
- if (message.y !== 0) {
5028
- obj.y = message.y;
4897
+ return positions;
4898
+ };
4899
+ const provisional = place(ids);
4900
+ const landing = (id) => {
4901
+ const out = fed.get(id) ?? [];
4902
+ const at = provisional.get(id);
4903
+ if (out.length === 0) return (at?.y ?? 0) + slotOfId(id).height / 2;
4904
+ const ys = out.map((edge) => {
4905
+ const target = byId.get(edge.target_instance);
4906
+ const top = provisional.get(edge.target_instance)?.y ?? 0;
4907
+ const pin = target?.pinY && edge.to_input !== void 0 ? target.pinY(edge.to_input) : 0;
4908
+ return top + pin;
4909
+ });
4910
+ return mean(ys);
4911
+ };
4912
+ const unfedOrder = [...ids].sort(
4913
+ (p, q) => landing(p) - landing(q) || (declared.get(p) ?? 0) - (declared.get(q) ?? 0)
4914
+ );
4915
+ return place(unfedOrder);
4916
+ }
4917
+ function columnByDepth(ids, edges) {
4918
+ const present = new Set(ids);
4919
+ const real = edges.filter(
4920
+ (e) => e.source_instance !== e.target_instance && present.has(e.source_instance) && present.has(e.target_instance)
4921
+ );
4922
+ const depth = new Map(ids.map((id) => [id, 0]));
4923
+ for (let round = 0; round < ids.length; round += 1) {
4924
+ let moved = false;
4925
+ for (const e of real) {
4926
+ const want = (depth.get(e.source_instance) ?? 0) + 1;
4927
+ if (want > (depth.get(e.target_instance) ?? 0)) {
4928
+ depth.set(e.target_instance, want);
4929
+ moved = true;
4930
+ }
5029
4931
  }
5030
- return obj;
5031
- },
5032
- create(base) {
5033
- return Position.fromPartial(base ?? {});
5034
- },
5035
- fromPartial(object) {
5036
- const message = createBasePosition();
5037
- message.x = object.x ?? 0;
5038
- message.y = object.y ?? 0;
5039
- return message;
4932
+ if (!moved) break;
5040
4933
  }
5041
- };
5042
- function isSet3(value) {
5043
- return value !== null && value !== void 0;
4934
+ return depth;
5044
4935
  }
5045
4936
 
5046
- // src/proto-messages.ts
5047
- var CanvasViewProto = CanvasView;
4937
+ // src/projection/project-group.ts
4938
+ function projectGroup(use, target, fullId, parentArrangement, wiredIn, wiredOut) {
4939
+ const childIds = (target.modules ?? []).map((u) => joinPath(fullId, u.id));
4940
+ const parentGroup = parentArrangement?.groups?.[use.id];
4941
+ const collapsed = parentGroup ? parentGroup.collapsed : true;
4942
+ return {
4943
+ id: fullId,
4944
+ label: use.id,
4945
+ node_ids: childIds,
4946
+ collapsed,
4947
+ module_key: use.module,
4948
+ ...groupPins(target),
4949
+ ...callWires(wiredIn, wiredOut)
4950
+ };
4951
+ }
4952
+ function groupPins(target) {
4953
+ return {
4954
+ inputs: (target.interface?.inputs ?? []).map((in_) => ({
4955
+ name: in_.name,
4956
+ type: in_.type,
4957
+ required: in_.required,
4958
+ description: in_.description
4959
+ })),
4960
+ outputs: (target.interface?.outputs ?? []).map((out) => ({
4961
+ name: out.name,
4962
+ type: out.type,
4963
+ description: out.description,
4964
+ sensitive: out.sensitive
4965
+ }))
4966
+ };
4967
+ }
4968
+
4969
+ // src/projection/project-node.ts
4970
+ function projectNode(bundle, use, fullId, wiredIn, wiredOut) {
4971
+ const schema = resolveSchema(bundle, use, wiredOut);
4972
+ return {
4973
+ id: fullId,
4974
+ label: use.id,
4975
+ kind: "module",
4976
+ module_key: use.module,
4977
+ inputs: schema.inputs.map((in_) => ({
4978
+ name: in_.name,
4979
+ type: in_.type,
4980
+ required: in_.required,
4981
+ wired: wiredIn.has(in_.name),
4982
+ description: in_.description
4983
+ })),
4984
+ outputs: schema.outputs.map((out) => ({
4985
+ name: out.name,
4986
+ type: out.type,
4987
+ wired: wiredOut.has(out.name),
4988
+ description: out.description,
4989
+ sensitive: out.sensitive
4990
+ })),
4991
+ ...callWires(wiredIn, wiredOut)
4992
+ };
4993
+ }
5048
4994
 
5049
- // src/protocol-version.ts
5050
- var ENGINE_PROTOCOL_VERSION = String(8 /* PROTOCOL_VERSION_CURRENT */);
5051
- var EngineProtocolMismatchError = class extends Error {
5052
- constructor(engineVersion, engineProtocol, requiredProtocol) {
5053
- super(
5054
- `Lace engine ${engineVersion} speaks protocol ${engineProtocol}; this host speaks protocol ${requiredProtocol}`
4995
+ // src/projection/project-scope.ts
4996
+ function projectScope(bundle, mod, use, path, arrangement, children) {
4997
+ const uses = mod.modules ?? [];
4998
+ const {
4999
+ derived,
5000
+ interfaceEdges,
5001
+ inputs: wiredIn,
5002
+ outputs: wiredOut
5003
+ } = scopeWires(mod, use === null);
5004
+ const scopeArrangement = arrangement?.[use ? use.module : bundle.entry];
5005
+ const cards = [];
5006
+ const groups = [];
5007
+ const items = [];
5008
+ const boxMin = /* @__PURE__ */ new Map();
5009
+ for (const child of uses) {
5010
+ const fullId = joinPath(path, child.id);
5011
+ if (isGroupUse(bundle, child)) {
5012
+ const group = projectGroup(
5013
+ child,
5014
+ bundle.modules[child.module],
5015
+ fullId,
5016
+ scopeArrangement,
5017
+ wiredIn.get(child.id) ?? /* @__PURE__ */ new Set(),
5018
+ wiredOut.get(child.id) ?? /* @__PURE__ */ new Set()
5019
+ );
5020
+ const content = children.get(fullId);
5021
+ if (!content) throw new Error(`projectScope: no layout for group "${fullId}"`);
5022
+ groups.push(group);
5023
+ boxMin.set(child.id, content.min);
5024
+ items.push({
5025
+ id: child.id,
5026
+ size: groupFootprint(group, content.box),
5027
+ pinY: (input) => groupInputPinY(group, input)
5028
+ });
5029
+ continue;
5030
+ }
5031
+ const node = projectNode(
5032
+ bundle,
5033
+ child,
5034
+ fullId,
5035
+ wiredIn.get(child.id) ?? /* @__PURE__ */ new Set(),
5036
+ wiredOut.get(child.id) ?? /* @__PURE__ */ new Set()
5055
5037
  );
5056
- this.engineVersion = engineVersion;
5057
- this.engineProtocol = engineProtocol;
5058
- this.requiredProtocol = requiredProtocol;
5059
- this.name = "EngineProtocolMismatchError";
5038
+ cards.push(node);
5039
+ items.push({ id: child.id, size: nodeSize(node), pinY: (input) => inputPinY(node, input) });
5060
5040
  }
5061
- /**
5062
- * The engine is the side that is behind: a newer Lace CLI speaks this
5063
- * host's protocol. False when the engine is ahead of the host.
5064
- */
5065
- get engineTooOld() {
5066
- return Number(this.engineProtocol) < Number(this.requiredProtocol);
5041
+ const stored = /* @__PURE__ */ new Map();
5042
+ for (const child of uses) {
5043
+ const at = scopeArrangement?.nodes?.[child.id];
5044
+ if (!at) continue;
5045
+ const min = boxMin.get(child.id);
5046
+ stored.set(child.id, min ? boxAt(originAt(at), min) : at);
5067
5047
  }
5068
- };
5069
- function checkEngineProtocol(engineVersion, engineProtocol) {
5070
- if (engineProtocol !== ENGINE_PROTOCOL_VERSION) {
5071
- throw new EngineProtocolMismatchError(engineVersion, engineProtocol, ENGINE_PROTOCOL_VERSION);
5048
+ const local = layoutByDepth(items, stored, derived);
5049
+ const placedAt = (useId) => {
5050
+ const at = local.get(useId);
5051
+ if (!at) throw new Error(`projectScope: no position for "${joinPath(path, useId)}"`);
5052
+ return at;
5053
+ };
5054
+ const nodes = cards.map((card) => ({ ...card, position: placedAt(splitPath(card.id).localId) }));
5055
+ const extent = extentOf([
5056
+ { x: 0, y: 0, width: 0, height: 0 },
5057
+ ...items.map((item) => ({ ...placedAt(item.id), ...item.size }))
5058
+ ]);
5059
+ const wires = [...derived, ...interfaceEdges];
5060
+ const edges = wires.map((de) => {
5061
+ const { source_pin, target_pin } = de;
5062
+ const sourceId = source_pin ? path : joinPath(path, de.source_instance);
5063
+ const targetId = target_pin ? path : joinPath(path, de.target_instance);
5064
+ return {
5065
+ id: `${sourceId}-${targetId}-${de.from_output}-${de.to_input}`,
5066
+ source: sourceId,
5067
+ target: targetId,
5068
+ source_output: de.from_output,
5069
+ target_input: de.to_input,
5070
+ source_pin,
5071
+ target_pin
5072
+ };
5073
+ });
5074
+ return {
5075
+ nodes,
5076
+ groups,
5077
+ edges,
5078
+ local,
5079
+ min: { x: extent.x, y: extent.y },
5080
+ box: groupBoxSize(extent)
5081
+ };
5082
+ }
5083
+
5084
+ // src/projection/walk-modules.ts
5085
+ function walk(bundle, visit) {
5086
+ if (!bundle) return;
5087
+ const entry = bundle.modules[bundle.entry];
5088
+ if (!entry) return;
5089
+ walkFrom(bundle, entry, null, "", visit);
5090
+ }
5091
+ function walkFrom(bundle, mod, use, path, visit) {
5092
+ visit(mod, use, path);
5093
+ for (const u of mod.modules ?? []) {
5094
+ const child = bundle.modules[u.module];
5095
+ if (!child) continue;
5096
+ walkFrom(bundle, child, u, joinPath(path, u.id), visit);
5097
+ }
5098
+ }
5099
+
5100
+ // src/projection/project.ts
5101
+ var EMPTY_BUNDLE = Bundle.fromPartial({
5102
+ entry: "root@v1",
5103
+ modules: { "root@v1": { id: "root", version: "v1.0.0" } }
5104
+ });
5105
+ function projectCanvasView(bundle, arrangement, meta) {
5106
+ const scopes = [];
5107
+ walk(bundle, (mod, use, path) => {
5108
+ scopes.push({ mod, use, path });
5109
+ });
5110
+ const layouts = /* @__PURE__ */ new Map();
5111
+ for (const { mod, use, path } of [...scopes].reverse()) {
5112
+ layouts.set(path, projectScope(bundle, mod, use, path, arrangement, layouts));
5113
+ }
5114
+ const nodes = [];
5115
+ const edges = [];
5116
+ const groups = [];
5117
+ const origins = /* @__PURE__ */ new Map([["", { x: 0, y: 0 }]]);
5118
+ for (const { path } of scopes) {
5119
+ const layout = layouts.get(path);
5120
+ const origin = origins.get(path);
5121
+ if (!layout || !origin) continue;
5122
+ const at = (local) => ({ x: origin.x + local.x, y: origin.y + local.y });
5123
+ for (const node of layout.nodes) nodes.push({ ...node, position: at(node.position) });
5124
+ for (const group of layout.groups) {
5125
+ const content = layouts.get(group.id);
5126
+ const box = layout.local.get(splitPath(group.id).localId);
5127
+ if (!content || !box)
5128
+ throw new Error(`projectCanvasView: group "${group.id}" was not laid out`);
5129
+ const position = at(box);
5130
+ const membersAt = originAt(position, content.min);
5131
+ origins.set(group.id, membersAt);
5132
+ groups.push({ ...group, position, size: content.box, origin: membersAt });
5133
+ }
5134
+ edges.push(...layout.edges);
5072
5135
  }
5136
+ const moduleName = meta.moduleName ?? parseModuleKey(bundle.entry).id;
5137
+ return {
5138
+ module_name: moduleName,
5139
+ nodes,
5140
+ edges,
5141
+ can_undo: meta.canUndo,
5142
+ can_redo: meta.canRedo,
5143
+ unsaved: meta.unsaved,
5144
+ conflict: meta.conflict,
5145
+ ungenerated: meta.ungenerated ?? false,
5146
+ // Every group is a Use whose target has sub-Uses (CreateGroupAction
5147
+ // mints a module); emission order already mirrors Use declaration order
5148
+ // via the walk, so no separate user-group sort is needed.
5149
+ groups
5150
+ };
5073
5151
  }
5152
+
5153
+ // src/proto-messages.ts
5154
+ var CanvasViewProto = CanvasView;
5074
5155
  export {
5075
5156
  BRIDGE_METHODS,
5076
5157
  Bundle,
@@ -5078,10 +5159,11 @@ export {
5078
5159
  CONNECT_CODE_NAMES,
5079
5160
  CanvasViewProto,
5080
5161
  EMPTY_BUNDLE,
5162
+ ENGINE_CONTRACT,
5081
5163
  ENGINE_METHODS,
5082
5164
  ENGINE_PROTOCOL_VERSION,
5083
5165
  ENGINE_STREAM_METHODS,
5084
- EngineProtocolMismatchError,
5166
+ EngineIdentityMismatchError,
5085
5167
  GROUP_HEADER_HEIGHT,
5086
5168
  GROUP_PADDING,
5087
5169
  HOST_ONLY_METHODS,
@@ -5092,7 +5174,7 @@ export {
5092
5174
  apiFields,
5093
5175
  boxAt,
5094
5176
  callText,
5095
- checkEngineProtocol,
5177
+ checkEngineIdentity,
5096
5178
  collapsedGroupSize,
5097
5179
  convertDiagnostic,
5098
5180
  deriveNodeConfig,
@@ -5105,6 +5187,7 @@ export {
5105
5187
  groupBoxSize,
5106
5188
  groupFootprint,
5107
5189
  groupInputPinY,
5190
+ groupPinText,
5108
5191
  groupPinY,
5109
5192
  groupPins,
5110
5193
  groupReach,