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