@lace-cloud/proto 0.14.0 → 0.15.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.mjs CHANGED
@@ -3742,617 +3742,6 @@ var ProviderConfig_ConfigEntry = {
3742
3742
  return message;
3743
3743
  }
3744
3744
  };
3745
- function createBaseGraphLayout() {
3746
- return { nodes: {}, groups: {} };
3747
- }
3748
- var GraphLayout = {
3749
- encode(message, writer = new BinaryWriter2()) {
3750
- globalThis.Object.entries(message.nodes).forEach(([key, value]) => {
3751
- GraphLayout_NodesEntry.encode({ key, value }, writer.uint32(10).fork()).join();
3752
- });
3753
- globalThis.Object.entries(message.groups).forEach(([key, value]) => {
3754
- GraphLayout_GroupsEntry.encode({ key, value }, writer.uint32(18).fork()).join();
3755
- });
3756
- return writer;
3757
- },
3758
- decode(input, length) {
3759
- const reader = input instanceof BinaryReader2 ? input : new BinaryReader2(input);
3760
- const end = length === void 0 ? reader.len : reader.pos + length;
3761
- const message = createBaseGraphLayout();
3762
- while (reader.pos < end) {
3763
- const tag = reader.uint32();
3764
- switch (tag >>> 3) {
3765
- case 1: {
3766
- if (tag !== 10) {
3767
- break;
3768
- }
3769
- const entry1 = GraphLayout_NodesEntry.decode(reader, reader.uint32());
3770
- if (entry1.value !== void 0) {
3771
- message.nodes[entry1.key] = entry1.value;
3772
- }
3773
- continue;
3774
- }
3775
- case 2: {
3776
- if (tag !== 18) {
3777
- break;
3778
- }
3779
- const entry2 = GraphLayout_GroupsEntry.decode(reader, reader.uint32());
3780
- if (entry2.value !== void 0) {
3781
- message.groups[entry2.key] = entry2.value;
3782
- }
3783
- continue;
3784
- }
3785
- }
3786
- if ((tag & 7) === 4 || tag === 0) {
3787
- break;
3788
- }
3789
- reader.skip(tag & 7);
3790
- }
3791
- return message;
3792
- },
3793
- fromJSON(object) {
3794
- return {
3795
- nodes: isObject2(object.nodes) ? globalThis.Object.entries(object.nodes).reduce(
3796
- (acc, [key, value]) => {
3797
- acc[key] = NodeLayout.fromJSON(value);
3798
- return acc;
3799
- },
3800
- {}
3801
- ) : {},
3802
- groups: isObject2(object.groups) ? globalThis.Object.entries(object.groups).reduce(
3803
- (acc, [key, value]) => {
3804
- acc[key] = NodeGroup.fromJSON(value);
3805
- return acc;
3806
- },
3807
- {}
3808
- ) : {}
3809
- };
3810
- },
3811
- toJSON(message) {
3812
- const obj = {};
3813
- if (message.nodes) {
3814
- const entries = globalThis.Object.entries(message.nodes);
3815
- if (entries.length > 0) {
3816
- obj.nodes = {};
3817
- entries.forEach(([k, v]) => {
3818
- obj.nodes[k] = NodeLayout.toJSON(v);
3819
- });
3820
- }
3821
- }
3822
- if (message.groups) {
3823
- const entries = globalThis.Object.entries(message.groups);
3824
- if (entries.length > 0) {
3825
- obj.groups = {};
3826
- entries.forEach(([k, v]) => {
3827
- obj.groups[k] = NodeGroup.toJSON(v);
3828
- });
3829
- }
3830
- }
3831
- return obj;
3832
- },
3833
- create(base) {
3834
- return GraphLayout.fromPartial(base ?? {});
3835
- },
3836
- fromPartial(object) {
3837
- const message = createBaseGraphLayout();
3838
- message.nodes = globalThis.Object.entries(object.nodes ?? {}).reduce(
3839
- (acc, [key, value]) => {
3840
- if (value !== void 0) {
3841
- acc[key] = NodeLayout.fromPartial(value);
3842
- }
3843
- return acc;
3844
- },
3845
- {}
3846
- );
3847
- message.groups = globalThis.Object.entries(object.groups ?? {}).reduce(
3848
- (acc, [key, value]) => {
3849
- if (value !== void 0) {
3850
- acc[key] = NodeGroup.fromPartial(value);
3851
- }
3852
- return acc;
3853
- },
3854
- {}
3855
- );
3856
- return message;
3857
- }
3858
- };
3859
- function createBaseGraphLayout_NodesEntry() {
3860
- return { key: "", value: void 0 };
3861
- }
3862
- var GraphLayout_NodesEntry = {
3863
- encode(message, writer = new BinaryWriter2()) {
3864
- if (message.key !== "") {
3865
- writer.uint32(10).string(message.key);
3866
- }
3867
- if (message.value !== void 0) {
3868
- NodeLayout.encode(message.value, writer.uint32(18).fork()).join();
3869
- }
3870
- return writer;
3871
- },
3872
- decode(input, length) {
3873
- const reader = input instanceof BinaryReader2 ? input : new BinaryReader2(input);
3874
- const end = length === void 0 ? reader.len : reader.pos + length;
3875
- const message = createBaseGraphLayout_NodesEntry();
3876
- while (reader.pos < end) {
3877
- const tag = reader.uint32();
3878
- switch (tag >>> 3) {
3879
- case 1: {
3880
- if (tag !== 10) {
3881
- break;
3882
- }
3883
- message.key = reader.string();
3884
- continue;
3885
- }
3886
- case 2: {
3887
- if (tag !== 18) {
3888
- break;
3889
- }
3890
- message.value = NodeLayout.decode(reader, reader.uint32());
3891
- continue;
3892
- }
3893
- }
3894
- if ((tag & 7) === 4 || tag === 0) {
3895
- break;
3896
- }
3897
- reader.skip(tag & 7);
3898
- }
3899
- return message;
3900
- },
3901
- fromJSON(object) {
3902
- return {
3903
- key: isSet2(object.key) ? globalThis.String(object.key) : "",
3904
- value: isSet2(object.value) ? NodeLayout.fromJSON(object.value) : void 0
3905
- };
3906
- },
3907
- toJSON(message) {
3908
- const obj = {};
3909
- if (message.key !== "") {
3910
- obj.key = message.key;
3911
- }
3912
- if (message.value !== void 0) {
3913
- obj.value = NodeLayout.toJSON(message.value);
3914
- }
3915
- return obj;
3916
- },
3917
- create(base) {
3918
- return GraphLayout_NodesEntry.fromPartial(base ?? {});
3919
- },
3920
- fromPartial(object) {
3921
- const message = createBaseGraphLayout_NodesEntry();
3922
- message.key = object.key ?? "";
3923
- message.value = object.value !== void 0 && object.value !== null ? NodeLayout.fromPartial(object.value) : void 0;
3924
- return message;
3925
- }
3926
- };
3927
- function createBaseGraphLayout_GroupsEntry() {
3928
- return { key: "", value: void 0 };
3929
- }
3930
- var GraphLayout_GroupsEntry = {
3931
- encode(message, writer = new BinaryWriter2()) {
3932
- if (message.key !== "") {
3933
- writer.uint32(10).string(message.key);
3934
- }
3935
- if (message.value !== void 0) {
3936
- NodeGroup.encode(message.value, writer.uint32(18).fork()).join();
3937
- }
3938
- return writer;
3939
- },
3940
- decode(input, length) {
3941
- const reader = input instanceof BinaryReader2 ? input : new BinaryReader2(input);
3942
- const end = length === void 0 ? reader.len : reader.pos + length;
3943
- const message = createBaseGraphLayout_GroupsEntry();
3944
- while (reader.pos < end) {
3945
- const tag = reader.uint32();
3946
- switch (tag >>> 3) {
3947
- case 1: {
3948
- if (tag !== 10) {
3949
- break;
3950
- }
3951
- message.key = reader.string();
3952
- continue;
3953
- }
3954
- case 2: {
3955
- if (tag !== 18) {
3956
- break;
3957
- }
3958
- message.value = NodeGroup.decode(reader, reader.uint32());
3959
- continue;
3960
- }
3961
- }
3962
- if ((tag & 7) === 4 || tag === 0) {
3963
- break;
3964
- }
3965
- reader.skip(tag & 7);
3966
- }
3967
- return message;
3968
- },
3969
- fromJSON(object) {
3970
- return {
3971
- key: isSet2(object.key) ? globalThis.String(object.key) : "",
3972
- value: isSet2(object.value) ? NodeGroup.fromJSON(object.value) : void 0
3973
- };
3974
- },
3975
- toJSON(message) {
3976
- const obj = {};
3977
- if (message.key !== "") {
3978
- obj.key = message.key;
3979
- }
3980
- if (message.value !== void 0) {
3981
- obj.value = NodeGroup.toJSON(message.value);
3982
- }
3983
- return obj;
3984
- },
3985
- create(base) {
3986
- return GraphLayout_GroupsEntry.fromPartial(base ?? {});
3987
- },
3988
- fromPartial(object) {
3989
- const message = createBaseGraphLayout_GroupsEntry();
3990
- message.key = object.key ?? "";
3991
- message.value = object.value !== void 0 && object.value !== null ? NodeGroup.fromPartial(object.value) : void 0;
3992
- return message;
3993
- }
3994
- };
3995
- function createBaseNodeGroup() {
3996
- return { id: "", label: "", node_ids: [], collapsed: false };
3997
- }
3998
- var NodeGroup = {
3999
- encode(message, writer = new BinaryWriter2()) {
4000
- if (message.id !== "") {
4001
- writer.uint32(10).string(message.id);
4002
- }
4003
- if (message.label !== "") {
4004
- writer.uint32(18).string(message.label);
4005
- }
4006
- for (const v of message.node_ids) {
4007
- writer.uint32(26).string(v);
4008
- }
4009
- if (message.collapsed !== false) {
4010
- writer.uint32(32).bool(message.collapsed);
4011
- }
4012
- return writer;
4013
- },
4014
- decode(input, length) {
4015
- const reader = input instanceof BinaryReader2 ? input : new BinaryReader2(input);
4016
- const end = length === void 0 ? reader.len : reader.pos + length;
4017
- const message = createBaseNodeGroup();
4018
- while (reader.pos < end) {
4019
- const tag = reader.uint32();
4020
- switch (tag >>> 3) {
4021
- case 1: {
4022
- if (tag !== 10) {
4023
- break;
4024
- }
4025
- message.id = reader.string();
4026
- continue;
4027
- }
4028
- case 2: {
4029
- if (tag !== 18) {
4030
- break;
4031
- }
4032
- message.label = reader.string();
4033
- continue;
4034
- }
4035
- case 3: {
4036
- if (tag !== 26) {
4037
- break;
4038
- }
4039
- message.node_ids.push(reader.string());
4040
- continue;
4041
- }
4042
- case 4: {
4043
- if (tag !== 32) {
4044
- break;
4045
- }
4046
- message.collapsed = reader.bool();
4047
- continue;
4048
- }
4049
- }
4050
- if ((tag & 7) === 4 || tag === 0) {
4051
- break;
4052
- }
4053
- reader.skip(tag & 7);
4054
- }
4055
- return message;
4056
- },
4057
- fromJSON(object) {
4058
- return {
4059
- id: isSet2(object.id) ? globalThis.String(object.id) : "",
4060
- label: isSet2(object.label) ? globalThis.String(object.label) : "",
4061
- 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)) : [],
4062
- collapsed: isSet2(object.collapsed) ? globalThis.Boolean(object.collapsed) : false
4063
- };
4064
- },
4065
- toJSON(message) {
4066
- const obj = {};
4067
- if (message.id !== "") {
4068
- obj.id = message.id;
4069
- }
4070
- if (message.label !== "") {
4071
- obj.label = message.label;
4072
- }
4073
- if (message.node_ids?.length) {
4074
- obj.nodeIds = message.node_ids;
4075
- }
4076
- if (message.collapsed !== false) {
4077
- obj.collapsed = message.collapsed;
4078
- }
4079
- return obj;
4080
- },
4081
- create(base) {
4082
- return NodeGroup.fromPartial(base ?? {});
4083
- },
4084
- fromPartial(object) {
4085
- const message = createBaseNodeGroup();
4086
- message.id = object.id ?? "";
4087
- message.label = object.label ?? "";
4088
- message.node_ids = object.node_ids?.map((e) => e) || [];
4089
- message.collapsed = object.collapsed ?? false;
4090
- return message;
4091
- }
4092
- };
4093
- function createBaseNodeLayout() {
4094
- return { position: void 0 };
4095
- }
4096
- var NodeLayout = {
4097
- encode(message, writer = new BinaryWriter2()) {
4098
- if (message.position !== void 0) {
4099
- Position.encode(message.position, writer.uint32(10).fork()).join();
4100
- }
4101
- return writer;
4102
- },
4103
- decode(input, length) {
4104
- const reader = input instanceof BinaryReader2 ? input : new BinaryReader2(input);
4105
- const end = length === void 0 ? reader.len : reader.pos + length;
4106
- const message = createBaseNodeLayout();
4107
- while (reader.pos < end) {
4108
- const tag = reader.uint32();
4109
- switch (tag >>> 3) {
4110
- case 1: {
4111
- if (tag !== 10) {
4112
- break;
4113
- }
4114
- message.position = Position.decode(reader, reader.uint32());
4115
- continue;
4116
- }
4117
- }
4118
- if ((tag & 7) === 4 || tag === 0) {
4119
- break;
4120
- }
4121
- reader.skip(tag & 7);
4122
- }
4123
- return message;
4124
- },
4125
- fromJSON(object) {
4126
- return { position: isSet2(object.position) ? Position.fromJSON(object.position) : void 0 };
4127
- },
4128
- toJSON(message) {
4129
- const obj = {};
4130
- if (message.position !== void 0) {
4131
- obj.position = Position.toJSON(message.position);
4132
- }
4133
- return obj;
4134
- },
4135
- create(base) {
4136
- return NodeLayout.fromPartial(base ?? {});
4137
- },
4138
- fromPartial(object) {
4139
- const message = createBaseNodeLayout();
4140
- message.position = object.position !== void 0 && object.position !== null ? Position.fromPartial(object.position) : void 0;
4141
- return message;
4142
- }
4143
- };
4144
- function createBasePosition() {
4145
- return { x: 0, y: 0 };
4146
- }
4147
- var Position = {
4148
- encode(message, writer = new BinaryWriter2()) {
4149
- if (message.x !== 0) {
4150
- writer.uint32(9).double(message.x);
4151
- }
4152
- if (message.y !== 0) {
4153
- writer.uint32(17).double(message.y);
4154
- }
4155
- return writer;
4156
- },
4157
- decode(input, length) {
4158
- const reader = input instanceof BinaryReader2 ? input : new BinaryReader2(input);
4159
- const end = length === void 0 ? reader.len : reader.pos + length;
4160
- const message = createBasePosition();
4161
- while (reader.pos < end) {
4162
- const tag = reader.uint32();
4163
- switch (tag >>> 3) {
4164
- case 1: {
4165
- if (tag !== 9) {
4166
- break;
4167
- }
4168
- message.x = reader.double();
4169
- continue;
4170
- }
4171
- case 2: {
4172
- if (tag !== 17) {
4173
- break;
4174
- }
4175
- message.y = reader.double();
4176
- continue;
4177
- }
4178
- }
4179
- if ((tag & 7) === 4 || tag === 0) {
4180
- break;
4181
- }
4182
- reader.skip(tag & 7);
4183
- }
4184
- return message;
4185
- },
4186
- fromJSON(object) {
4187
- return {
4188
- x: isSet2(object.x) ? globalThis.Number(object.x) : 0,
4189
- y: isSet2(object.y) ? globalThis.Number(object.y) : 0
4190
- };
4191
- },
4192
- toJSON(message) {
4193
- const obj = {};
4194
- if (message.x !== 0) {
4195
- obj.x = message.x;
4196
- }
4197
- if (message.y !== 0) {
4198
- obj.y = message.y;
4199
- }
4200
- return obj;
4201
- },
4202
- create(base) {
4203
- return Position.fromPartial(base ?? {});
4204
- },
4205
- fromPartial(object) {
4206
- const message = createBasePosition();
4207
- message.x = object.x ?? 0;
4208
- message.y = object.y ?? 0;
4209
- return message;
4210
- }
4211
- };
4212
- function createBaseLayoutsMap() {
4213
- return { layouts: {} };
4214
- }
4215
- var LayoutsMap = {
4216
- encode(message, writer = new BinaryWriter2()) {
4217
- globalThis.Object.entries(message.layouts).forEach(([key, value]) => {
4218
- LayoutsMap_LayoutsEntry.encode({ key, value }, writer.uint32(10).fork()).join();
4219
- });
4220
- return writer;
4221
- },
4222
- decode(input, length) {
4223
- const reader = input instanceof BinaryReader2 ? input : new BinaryReader2(input);
4224
- const end = length === void 0 ? reader.len : reader.pos + length;
4225
- const message = createBaseLayoutsMap();
4226
- while (reader.pos < end) {
4227
- const tag = reader.uint32();
4228
- switch (tag >>> 3) {
4229
- case 1: {
4230
- if (tag !== 10) {
4231
- break;
4232
- }
4233
- const entry1 = LayoutsMap_LayoutsEntry.decode(reader, reader.uint32());
4234
- if (entry1.value !== void 0) {
4235
- message.layouts[entry1.key] = entry1.value;
4236
- }
4237
- continue;
4238
- }
4239
- }
4240
- if ((tag & 7) === 4 || tag === 0) {
4241
- break;
4242
- }
4243
- reader.skip(tag & 7);
4244
- }
4245
- return message;
4246
- },
4247
- fromJSON(object) {
4248
- return {
4249
- layouts: isObject2(object.layouts) ? globalThis.Object.entries(object.layouts).reduce(
4250
- (acc, [key, value]) => {
4251
- acc[key] = GraphLayout.fromJSON(value);
4252
- return acc;
4253
- },
4254
- {}
4255
- ) : {}
4256
- };
4257
- },
4258
- toJSON(message) {
4259
- const obj = {};
4260
- if (message.layouts) {
4261
- const entries = globalThis.Object.entries(message.layouts);
4262
- if (entries.length > 0) {
4263
- obj.layouts = {};
4264
- entries.forEach(([k, v]) => {
4265
- obj.layouts[k] = GraphLayout.toJSON(v);
4266
- });
4267
- }
4268
- }
4269
- return obj;
4270
- },
4271
- create(base) {
4272
- return LayoutsMap.fromPartial(base ?? {});
4273
- },
4274
- fromPartial(object) {
4275
- const message = createBaseLayoutsMap();
4276
- message.layouts = globalThis.Object.entries(object.layouts ?? {}).reduce(
4277
- (acc, [key, value]) => {
4278
- if (value !== void 0) {
4279
- acc[key] = GraphLayout.fromPartial(value);
4280
- }
4281
- return acc;
4282
- },
4283
- {}
4284
- );
4285
- return message;
4286
- }
4287
- };
4288
- function createBaseLayoutsMap_LayoutsEntry() {
4289
- return { key: "", value: void 0 };
4290
- }
4291
- var LayoutsMap_LayoutsEntry = {
4292
- encode(message, writer = new BinaryWriter2()) {
4293
- if (message.key !== "") {
4294
- writer.uint32(10).string(message.key);
4295
- }
4296
- if (message.value !== void 0) {
4297
- GraphLayout.encode(message.value, writer.uint32(18).fork()).join();
4298
- }
4299
- return writer;
4300
- },
4301
- decode(input, length) {
4302
- const reader = input instanceof BinaryReader2 ? input : new BinaryReader2(input);
4303
- const end = length === void 0 ? reader.len : reader.pos + length;
4304
- const message = createBaseLayoutsMap_LayoutsEntry();
4305
- while (reader.pos < end) {
4306
- const tag = reader.uint32();
4307
- switch (tag >>> 3) {
4308
- case 1: {
4309
- if (tag !== 10) {
4310
- break;
4311
- }
4312
- message.key = reader.string();
4313
- continue;
4314
- }
4315
- case 2: {
4316
- if (tag !== 18) {
4317
- break;
4318
- }
4319
- message.value = GraphLayout.decode(reader, reader.uint32());
4320
- continue;
4321
- }
4322
- }
4323
- if ((tag & 7) === 4 || tag === 0) {
4324
- break;
4325
- }
4326
- reader.skip(tag & 7);
4327
- }
4328
- return message;
4329
- },
4330
- fromJSON(object) {
4331
- return {
4332
- key: isSet2(object.key) ? globalThis.String(object.key) : "",
4333
- value: isSet2(object.value) ? GraphLayout.fromJSON(object.value) : void 0
4334
- };
4335
- },
4336
- toJSON(message) {
4337
- const obj = {};
4338
- if (message.key !== "") {
4339
- obj.key = message.key;
4340
- }
4341
- if (message.value !== void 0) {
4342
- obj.value = GraphLayout.toJSON(message.value);
4343
- }
4344
- return obj;
4345
- },
4346
- create(base) {
4347
- return LayoutsMap_LayoutsEntry.fromPartial(base ?? {});
4348
- },
4349
- fromPartial(object) {
4350
- const message = createBaseLayoutsMap_LayoutsEntry();
4351
- message.key = object.key ?? "";
4352
- message.value = object.value !== void 0 && object.value !== null ? GraphLayout.fromPartial(object.value) : void 0;
4353
- return message;
4354
- }
4355
- };
4356
3745
  function isObject2(value) {
4357
3746
  return typeof value === "object" && value !== null;
4358
3747
  }
@@ -4374,8 +3763,49 @@ function isGroupUse(bundle, use) {
4374
3763
  return (target.modules?.length ?? 0) > 0;
4375
3764
  }
4376
3765
 
3766
+ // src/projection/compute-layout.ts
3767
+ var SPACING_X = 260;
3768
+ var SPACING_Y = 180;
3769
+ function gridPosition(index, n) {
3770
+ const cols = Math.max(2, Math.ceil(Math.sqrt(n)));
3771
+ const col = index % cols;
3772
+ const row = Math.floor(index / cols);
3773
+ return { x: col * SPACING_X, y: row * SPACING_Y };
3774
+ }
3775
+ function overlapsAny(candidate, occupied) {
3776
+ return occupied.some(
3777
+ (o) => candidate.x < o.x + SPACING_X && candidate.x + SPACING_X > o.x && candidate.y < o.y + SPACING_Y && candidate.y + SPACING_Y > o.y
3778
+ );
3779
+ }
3780
+ function resolveScopePositions(ids, arrangementNodes) {
3781
+ const positions = /* @__PURE__ */ new Map();
3782
+ const occupied = [];
3783
+ const unresolved = [];
3784
+ for (const id of ids) {
3785
+ const stored = arrangementNodes?.[id];
3786
+ if (stored) {
3787
+ positions.set(id, stored);
3788
+ occupied.push(stored);
3789
+ } else {
3790
+ unresolved.push(id);
3791
+ }
3792
+ }
3793
+ let slot = 0;
3794
+ for (const id of unresolved) {
3795
+ let candidate = gridPosition(slot, ids.length);
3796
+ while (overlapsAny(candidate, occupied)) {
3797
+ slot += 1;
3798
+ candidate = gridPosition(slot, ids.length);
3799
+ }
3800
+ positions.set(id, candidate);
3801
+ occupied.push(candidate);
3802
+ slot += 1;
3803
+ }
3804
+ return positions;
3805
+ }
3806
+
4377
3807
  // src/projection/derive-edges.ts
4378
- var moduleRefPattern = /\bmodule\.([A-Za-z_][A-Za-z0-9_]*)\.([A-Za-z_][A-Za-z0-9_]*)/g;
3808
+ var moduleRefPattern = /\bmodule\.([A-Za-z_][A-Za-z0-9_-]*)\.([A-Za-z_][A-Za-z0-9_-]*)/g;
4379
3809
  function emitEdgesFromBinding(binding, targetId, toInput, useIds, seen, edges) {
4380
3810
  if (binding.out?.module && binding.out.name) {
4381
3811
  edges.push({
@@ -4439,11 +3869,11 @@ function joinPath(prefix, localId) {
4439
3869
  }
4440
3870
 
4441
3871
  // src/projection/project-group.ts
4442
- function projectGroup(use, target, fullId, parentLayout) {
3872
+ function projectGroup(use, target, fullId, parentArrangement) {
4443
3873
  const childIds = (target.modules ?? []).map((u) => joinPath(fullId, u.id));
4444
- const parentGroup = parentLayout?.groups?.[use.id];
3874
+ const parentGroup = parentArrangement?.groups?.[use.id];
4445
3875
  const collapsed = parentGroup ? parentGroup.collapsed : true;
4446
- const label = parentGroup && parentGroup.label !== "" ? parentGroup.label : use.id;
3876
+ const label = parentGroup?.label ? parentGroup.label : use.id;
4447
3877
  const inputs = (target.interface?.inputs ?? []).map((in_) => ({
4448
3878
  name: in_.name,
4449
3879
  type: in_.type,
@@ -4467,21 +3897,6 @@ function projectGroup(use, target, fullId, parentLayout) {
4467
3897
  };
4468
3898
  }
4469
3899
 
4470
- // src/projection/compute-layout.ts
4471
- var SPACING_X = 260;
4472
- var SPACING_Y = 180;
4473
- function gridPosition(index, n) {
4474
- const cols = Math.max(2, Math.ceil(Math.sqrt(n)));
4475
- const col = index % cols;
4476
- const row = Math.floor(index / cols);
4477
- return { x: col * SPACING_X, y: row * SPACING_Y };
4478
- }
4479
- function resolveChildPosition(childId, childIndex, totalChildren, existing) {
4480
- const stored = existing?.[childId]?.position;
4481
- if (stored) return stored;
4482
- return gridPosition(childIndex, totalChildren);
4483
- }
4484
-
4485
3900
  // src/projection/resolve-schema.ts
4486
3901
  function resolveSchema(bundle, use) {
4487
3902
  const target = bundle.modules[use.module];
@@ -4509,8 +3924,7 @@ function descendScope(bundle, scopeKey, segments) {
4509
3924
  }
4510
3925
 
4511
3926
  // src/projection/project-node.ts
4512
- function projectNode(bundle, use, fullId, childIndex, totalChildren, scopeLayout, wiredIn, wiredOut, errorsByInstance) {
4513
- const position = resolveChildPosition(use.id, childIndex, totalChildren, scopeLayout?.nodes);
3927
+ function projectNode(bundle, use, fullId, position, wiredIn, wiredOut, errorsByInstance) {
4514
3928
  const errorMessages = errorsByInstance.get(use.id) ?? [];
4515
3929
  const schema = resolveSchema(bundle, use);
4516
3930
  return {
@@ -4539,49 +3953,38 @@ function projectNode(bundle, use, fullId, childIndex, totalChildren, scopeLayout
4539
3953
  }
4540
3954
 
4541
3955
  // src/projection/project-scope.ts
4542
- function projectScope(bundle, mod, path, layouts, errorsByInstance) {
3956
+ function projectScope(bundle, mod, path, arrangement, errorsByInstance) {
4543
3957
  const uses = mod.modules ?? [];
4544
3958
  const derived = deriveEdges(uses);
4545
3959
  const { inputs: wiredIn, outputs: wiredOut } = indexWires(derived);
4546
3960
  const scopeKey = resolveScopePath(bundle, path);
4547
- const layout = scopeKey ? layouts[scopeKey] : void 0;
3961
+ const scopeArrangement = scopeKey ? arrangement?.[scopeKey] : void 0;
4548
3962
  const nodes = [];
4549
3963
  const groups = [];
4550
- const emittedGroupIds = /* @__PURE__ */ new Set();
4551
- uses.forEach((use, index) => {
3964
+ const classified = uses.map((use) => ({ use, group: isGroupUse(bundle, use) }));
3965
+ const nodeUseIds = classified.filter((c) => !c.group).map((c) => c.use.id);
3966
+ const positions = resolveScopePositions(nodeUseIds, scopeArrangement?.nodes);
3967
+ for (const { use, group } of classified) {
4552
3968
  const fullId = joinPath(path, use.id);
4553
- if (isGroupUse(bundle, use)) {
3969
+ if (group) {
4554
3970
  const target = bundle.modules[use.module];
4555
- if (target) {
4556
- groups.push(projectGroup(use, target, fullId, layout));
4557
- emittedGroupIds.add(use.id);
4558
- return;
4559
- }
3971
+ groups.push(projectGroup(use, target, fullId, scopeArrangement));
3972
+ continue;
4560
3973
  }
4561
3974
  nodes.push(
4562
3975
  projectNode(
4563
3976
  bundle,
4564
3977
  use,
4565
3978
  fullId,
4566
- index,
4567
- uses.length,
4568
- layout,
3979
+ // Every non-group use is in nodeUseIds, so resolveScopePositions
3980
+ // always has an entry for it — a fallback here would only mask a
3981
+ // classification bug, not handle a real gap.
3982
+ positions.get(use.id),
4569
3983
  wiredIn.get(use.id) ?? /* @__PURE__ */ new Set(),
4570
3984
  wiredOut.get(use.id) ?? /* @__PURE__ */ new Set(),
4571
3985
  errorsByInstance
4572
3986
  )
4573
3987
  );
4574
- });
4575
- if (layout?.groups) {
4576
- for (const [groupId, g] of Object.entries(layout.groups)) {
4577
- if (emittedGroupIds.has(groupId)) continue;
4578
- groups.push({
4579
- id: g.id,
4580
- label: g.label,
4581
- node_ids: g.node_ids.map((id) => joinPath(path, id)),
4582
- collapsed: g.collapsed
4583
- });
4584
- }
4585
3988
  }
4586
3989
  const edges = derived.map((de) => {
4587
3990
  const sourceId = joinPath(path, de.source_instance);
@@ -4628,25 +4031,6 @@ function danglingEdgeErrors(nodes, groups, edges) {
4628
4031
  }
4629
4032
  return errors;
4630
4033
  }
4631
- function overlappingGroupsWarnings(groups) {
4632
- const errors = [];
4633
- const userGroups = groups.filter((g) => !g.module_key);
4634
- for (let i = 0; i < userGroups.length; i++) {
4635
- for (let j = i + 1; j < userGroups.length; j++) {
4636
- const a = userGroups[i];
4637
- const b = userGroups[j];
4638
- const aSet = new Set(a.node_ids);
4639
- const overlap = b.node_ids.filter((id) => aSet.has(id));
4640
- if (overlap.length > 0) {
4641
- errors.push({
4642
- instance_id: a.id,
4643
- message: `Group "${a.label}" overlaps group "${b.label}" on ${overlap.length} member(s)`
4644
- });
4645
- }
4646
- }
4647
- }
4648
- return errors;
4649
- }
4650
4034
 
4651
4035
  // src/projection/walk-modules.ts
4652
4036
  function walk(bundle, visit) {
@@ -4665,21 +4049,20 @@ function walkFrom(bundle, mod, use, path, visit) {
4665
4049
  }
4666
4050
 
4667
4051
  // src/projection/project.ts
4668
- function projectCanvasView(bundle, layouts, meta) {
4052
+ function projectCanvasView(bundle, arrangement, meta) {
4669
4053
  const nodes = [];
4670
4054
  const edges = [];
4671
4055
  const groups = [];
4672
4056
  const errorsByInstance = /* @__PURE__ */ new Map();
4673
4057
  walk(bundle, (mod, _use, path) => {
4674
- const scope = projectScope(bundle, mod, path, layouts, errorsByInstance);
4058
+ const scope = projectScope(bundle, mod, path, arrangement, errorsByInstance);
4675
4059
  nodes.push(...scope.nodes);
4676
4060
  edges.push(...scope.edges);
4677
4061
  groups.push(...scope.groups);
4678
4062
  });
4679
4063
  const errors = [
4680
4064
  ...missingRequiredInputErrors(nodes),
4681
- ...danglingEdgeErrors(nodes, groups, edges),
4682
- ...overlappingGroupsWarnings(groups)
4065
+ ...danglingEdgeErrors(nodes, groups, edges)
4683
4066
  ];
4684
4067
  errors.sort((a, b) => {
4685
4068
  const ai = a.instance_id ?? "";
@@ -4690,8 +4073,6 @@ function projectCanvasView(bundle, layouts, meta) {
4690
4073
  if (an !== bn) return an < bn ? -1 : 1;
4691
4074
  return a.message < b.message ? -1 : a.message > b.message ? 1 : 0;
4692
4075
  });
4693
- const moduleGroups = groups.filter((g) => g.module_key);
4694
- const userGroups = groups.filter((g) => !g.module_key).sort((a, b) => a.id < b.id ? -1 : a.id > b.id ? 1 : 0);
4695
4076
  const moduleName = meta.moduleName ?? parseModuleKey(bundle.entry).id;
4696
4077
  return {
4697
4078
  module_name: moduleName,
@@ -4701,7 +4082,10 @@ function projectCanvasView(bundle, layouts, meta) {
4701
4082
  can_undo: meta.canUndo,
4702
4083
  can_redo: meta.canRedo,
4703
4084
  is_dirty: meta.isDirty,
4704
- groups: [...moduleGroups, ...userGroups]
4085
+ // Every group is now a Use whose target has sub-Uses (CreateGroupAction
4086
+ // mints a module); emission order already mirrors Use declaration order
4087
+ // via the walk, so no separate user-group sort is needed.
4088
+ groups
4705
4089
  };
4706
4090
  }
4707
4091
 
@@ -5212,7 +4596,7 @@ var RenderNode = {
5212
4596
  writer.uint32(42).string(message.icon_url);
5213
4597
  }
5214
4598
  if (message.position !== void 0) {
5215
- Position2.encode(message.position, writer.uint32(50).fork()).join();
4599
+ Position.encode(message.position, writer.uint32(50).fork()).join();
5216
4600
  }
5217
4601
  if (message.has_errors !== false) {
5218
4602
  writer.uint32(56).bool(message.has_errors);
@@ -5274,7 +4658,7 @@ var RenderNode = {
5274
4658
  if (tag !== 50) {
5275
4659
  break;
5276
4660
  }
5277
- message.position = Position2.decode(reader, reader.uint32());
4661
+ message.position = Position.decode(reader, reader.uint32());
5278
4662
  continue;
5279
4663
  }
5280
4664
  case 7: {
@@ -5320,7 +4704,7 @@ var RenderNode = {
5320
4704
  kind: isSet3(object.kind) ? nodeKindFromJSON(object.kind) : 0,
5321
4705
  module_key: isSet3(object.moduleKey) ? globalThis.String(object.moduleKey) : isSet3(object.module_key) ? globalThis.String(object.module_key) : "",
5322
4706
  icon_url: isSet3(object.iconUrl) ? globalThis.String(object.iconUrl) : isSet3(object.icon_url) ? globalThis.String(object.icon_url) : "",
5323
- position: isSet3(object.position) ? Position2.fromJSON(object.position) : void 0,
4707
+ position: isSet3(object.position) ? Position.fromJSON(object.position) : void 0,
5324
4708
  has_errors: isSet3(object.hasErrors) ? globalThis.Boolean(object.hasErrors) : isSet3(object.has_errors) ? globalThis.Boolean(object.has_errors) : false,
5325
4709
  error_messages: globalThis.Array.isArray(object?.errorMessages) ? object.errorMessages.map((e) => globalThis.String(e)) : globalThis.Array.isArray(object?.error_messages) ? object.error_messages.map((e) => globalThis.String(e)) : [],
5326
4710
  inputs: globalThis.Array.isArray(object?.inputs) ? object.inputs.map((e) => NodePin.fromJSON(e)) : [],
@@ -5345,7 +4729,7 @@ var RenderNode = {
5345
4729
  obj.iconUrl = message.icon_url;
5346
4730
  }
5347
4731
  if (message.position !== void 0) {
5348
- obj.position = Position2.toJSON(message.position);
4732
+ obj.position = Position.toJSON(message.position);
5349
4733
  }
5350
4734
  if (message.has_errors !== false) {
5351
4735
  obj.hasErrors = message.has_errors;
@@ -5371,7 +4755,7 @@ var RenderNode = {
5371
4755
  message.kind = object.kind ?? 0;
5372
4756
  message.module_key = object.module_key ?? "";
5373
4757
  message.icon_url = object.icon_url ?? "";
5374
- message.position = object.position !== void 0 && object.position !== null ? Position2.fromPartial(object.position) : void 0;
4758
+ message.position = object.position !== void 0 && object.position !== null ? Position.fromPartial(object.position) : void 0;
5375
4759
  message.has_errors = object.has_errors ?? false;
5376
4760
  message.error_messages = object.error_messages?.map((e) => e) || [];
5377
4761
  message.inputs = object.inputs?.map((e) => NodePin.fromPartial(e)) || [];
@@ -7397,10 +6781,10 @@ var RenderError = {
7397
6781
  return message;
7398
6782
  }
7399
6783
  };
7400
- function createBasePosition2() {
6784
+ function createBasePosition() {
7401
6785
  return { x: 0, y: 0 };
7402
6786
  }
7403
- var Position2 = {
6787
+ var Position = {
7404
6788
  encode(message, writer = new BinaryWriter3()) {
7405
6789
  if (message.x !== 0) {
7406
6790
  writer.uint32(9).double(message.x);
@@ -7413,7 +6797,7 @@ var Position2 = {
7413
6797
  decode(input, length) {
7414
6798
  const reader = input instanceof BinaryReader3 ? input : new BinaryReader3(input);
7415
6799
  const end = length === void 0 ? reader.len : reader.pos + length;
7416
- const message = createBasePosition2();
6800
+ const message = createBasePosition();
7417
6801
  while (reader.pos < end) {
7418
6802
  const tag = reader.uint32();
7419
6803
  switch (tag >>> 3) {
@@ -7456,10 +6840,10 @@ var Position2 = {
7456
6840
  return obj;
7457
6841
  },
7458
6842
  create(base) {
7459
- return Position2.fromPartial(base ?? {});
6843
+ return Position.fromPartial(base ?? {});
7460
6844
  },
7461
6845
  fromPartial(object) {
7462
- const message = createBasePosition2();
6846
+ const message = createBasePosition();
7463
6847
  message.x = object.x ?? 0;
7464
6848
  message.y = object.y ?? 0;
7465
6849
  return message;
@@ -7845,8 +7229,6 @@ export {
7845
7229
  Bundle,
7846
7230
  CanvasViewProto,
7847
7231
  EdgeConfigProto,
7848
- GraphLayout,
7849
- LayoutsMap,
7850
7232
  NodeConfigProto,
7851
7233
  SettingsConfigProto,
7852
7234
  convertCanvasView,
@@ -7862,6 +7244,8 @@ export {
7862
7244
  convertSettingsConfig,
7863
7245
  modeToInputMode,
7864
7246
  parseModuleKey,
7865
- projectCanvasView
7247
+ projectCanvasView,
7248
+ resolveScopePath,
7249
+ resolveScopePositions
7866
7250
  };
7867
7251
  //# sourceMappingURL=index.mjs.map