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