@lace-cloud/proto 0.14.0 → 0.15.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -23,8 +23,6 @@ __export(index_exports, {
23
23
  Bundle: () => Bundle,
24
24
  CanvasViewProto: () => CanvasViewProto,
25
25
  EdgeConfigProto: () => EdgeConfigProto,
26
- GraphLayout: () => GraphLayout,
27
- LayoutsMap: () => LayoutsMap,
28
26
  NodeConfigProto: () => NodeConfigProto,
29
27
  SettingsConfigProto: () => SettingsConfigProto,
30
28
  convertCanvasView: () => convertCanvasView,
@@ -40,7 +38,9 @@ __export(index_exports, {
40
38
  convertSettingsConfig: () => convertSettingsConfig,
41
39
  modeToInputMode: () => modeToInputMode,
42
40
  parseModuleKey: () => parseModuleKey,
43
- projectCanvasView: () => projectCanvasView
41
+ projectCanvasView: () => projectCanvasView,
42
+ resolveScopePath: () => resolveScopePath,
43
+ resolveScopePositions: () => resolveScopePositions
44
44
  });
45
45
  module.exports = __toCommonJS(index_exports);
46
46
 
@@ -3788,617 +3788,6 @@ var ProviderConfig_ConfigEntry = {
3788
3788
  return message;
3789
3789
  }
3790
3790
  };
3791
- function createBaseGraphLayout() {
3792
- return { nodes: {}, groups: {} };
3793
- }
3794
- var GraphLayout = {
3795
- encode(message, writer = new import_wire2.BinaryWriter()) {
3796
- globalThis.Object.entries(message.nodes).forEach(([key, value]) => {
3797
- GraphLayout_NodesEntry.encode({ key, value }, writer.uint32(10).fork()).join();
3798
- });
3799
- globalThis.Object.entries(message.groups).forEach(([key, value]) => {
3800
- GraphLayout_GroupsEntry.encode({ key, value }, writer.uint32(18).fork()).join();
3801
- });
3802
- return writer;
3803
- },
3804
- decode(input, length) {
3805
- const reader = input instanceof import_wire2.BinaryReader ? input : new import_wire2.BinaryReader(input);
3806
- const end = length === void 0 ? reader.len : reader.pos + length;
3807
- const message = createBaseGraphLayout();
3808
- while (reader.pos < end) {
3809
- const tag = reader.uint32();
3810
- switch (tag >>> 3) {
3811
- case 1: {
3812
- if (tag !== 10) {
3813
- break;
3814
- }
3815
- const entry1 = GraphLayout_NodesEntry.decode(reader, reader.uint32());
3816
- if (entry1.value !== void 0) {
3817
- message.nodes[entry1.key] = entry1.value;
3818
- }
3819
- continue;
3820
- }
3821
- case 2: {
3822
- if (tag !== 18) {
3823
- break;
3824
- }
3825
- const entry2 = GraphLayout_GroupsEntry.decode(reader, reader.uint32());
3826
- if (entry2.value !== void 0) {
3827
- message.groups[entry2.key] = entry2.value;
3828
- }
3829
- continue;
3830
- }
3831
- }
3832
- if ((tag & 7) === 4 || tag === 0) {
3833
- break;
3834
- }
3835
- reader.skip(tag & 7);
3836
- }
3837
- return message;
3838
- },
3839
- fromJSON(object) {
3840
- return {
3841
- nodes: isObject2(object.nodes) ? globalThis.Object.entries(object.nodes).reduce(
3842
- (acc, [key, value]) => {
3843
- acc[key] = NodeLayout.fromJSON(value);
3844
- return acc;
3845
- },
3846
- {}
3847
- ) : {},
3848
- groups: isObject2(object.groups) ? globalThis.Object.entries(object.groups).reduce(
3849
- (acc, [key, value]) => {
3850
- acc[key] = NodeGroup.fromJSON(value);
3851
- return acc;
3852
- },
3853
- {}
3854
- ) : {}
3855
- };
3856
- },
3857
- toJSON(message) {
3858
- const obj = {};
3859
- if (message.nodes) {
3860
- const entries = globalThis.Object.entries(message.nodes);
3861
- if (entries.length > 0) {
3862
- obj.nodes = {};
3863
- entries.forEach(([k, v]) => {
3864
- obj.nodes[k] = NodeLayout.toJSON(v);
3865
- });
3866
- }
3867
- }
3868
- if (message.groups) {
3869
- const entries = globalThis.Object.entries(message.groups);
3870
- if (entries.length > 0) {
3871
- obj.groups = {};
3872
- entries.forEach(([k, v]) => {
3873
- obj.groups[k] = NodeGroup.toJSON(v);
3874
- });
3875
- }
3876
- }
3877
- return obj;
3878
- },
3879
- create(base) {
3880
- return GraphLayout.fromPartial(base ?? {});
3881
- },
3882
- fromPartial(object) {
3883
- const message = createBaseGraphLayout();
3884
- message.nodes = globalThis.Object.entries(object.nodes ?? {}).reduce(
3885
- (acc, [key, value]) => {
3886
- if (value !== void 0) {
3887
- acc[key] = NodeLayout.fromPartial(value);
3888
- }
3889
- return acc;
3890
- },
3891
- {}
3892
- );
3893
- message.groups = globalThis.Object.entries(object.groups ?? {}).reduce(
3894
- (acc, [key, value]) => {
3895
- if (value !== void 0) {
3896
- acc[key] = NodeGroup.fromPartial(value);
3897
- }
3898
- return acc;
3899
- },
3900
- {}
3901
- );
3902
- return message;
3903
- }
3904
- };
3905
- function createBaseGraphLayout_NodesEntry() {
3906
- return { key: "", value: void 0 };
3907
- }
3908
- var GraphLayout_NodesEntry = {
3909
- encode(message, writer = new import_wire2.BinaryWriter()) {
3910
- if (message.key !== "") {
3911
- writer.uint32(10).string(message.key);
3912
- }
3913
- if (message.value !== void 0) {
3914
- NodeLayout.encode(message.value, writer.uint32(18).fork()).join();
3915
- }
3916
- return writer;
3917
- },
3918
- decode(input, length) {
3919
- const reader = input instanceof import_wire2.BinaryReader ? input : new import_wire2.BinaryReader(input);
3920
- const end = length === void 0 ? reader.len : reader.pos + length;
3921
- const message = createBaseGraphLayout_NodesEntry();
3922
- while (reader.pos < end) {
3923
- const tag = reader.uint32();
3924
- switch (tag >>> 3) {
3925
- case 1: {
3926
- if (tag !== 10) {
3927
- break;
3928
- }
3929
- message.key = reader.string();
3930
- continue;
3931
- }
3932
- case 2: {
3933
- if (tag !== 18) {
3934
- break;
3935
- }
3936
- message.value = NodeLayout.decode(reader, reader.uint32());
3937
- continue;
3938
- }
3939
- }
3940
- if ((tag & 7) === 4 || tag === 0) {
3941
- break;
3942
- }
3943
- reader.skip(tag & 7);
3944
- }
3945
- return message;
3946
- },
3947
- fromJSON(object) {
3948
- return {
3949
- key: isSet2(object.key) ? globalThis.String(object.key) : "",
3950
- value: isSet2(object.value) ? NodeLayout.fromJSON(object.value) : void 0
3951
- };
3952
- },
3953
- toJSON(message) {
3954
- const obj = {};
3955
- if (message.key !== "") {
3956
- obj.key = message.key;
3957
- }
3958
- if (message.value !== void 0) {
3959
- obj.value = NodeLayout.toJSON(message.value);
3960
- }
3961
- return obj;
3962
- },
3963
- create(base) {
3964
- return GraphLayout_NodesEntry.fromPartial(base ?? {});
3965
- },
3966
- fromPartial(object) {
3967
- const message = createBaseGraphLayout_NodesEntry();
3968
- message.key = object.key ?? "";
3969
- message.value = object.value !== void 0 && object.value !== null ? NodeLayout.fromPartial(object.value) : void 0;
3970
- return message;
3971
- }
3972
- };
3973
- function createBaseGraphLayout_GroupsEntry() {
3974
- return { key: "", value: void 0 };
3975
- }
3976
- var GraphLayout_GroupsEntry = {
3977
- encode(message, writer = new import_wire2.BinaryWriter()) {
3978
- if (message.key !== "") {
3979
- writer.uint32(10).string(message.key);
3980
- }
3981
- if (message.value !== void 0) {
3982
- NodeGroup.encode(message.value, writer.uint32(18).fork()).join();
3983
- }
3984
- return writer;
3985
- },
3986
- decode(input, length) {
3987
- const reader = input instanceof import_wire2.BinaryReader ? input : new import_wire2.BinaryReader(input);
3988
- const end = length === void 0 ? reader.len : reader.pos + length;
3989
- const message = createBaseGraphLayout_GroupsEntry();
3990
- while (reader.pos < end) {
3991
- const tag = reader.uint32();
3992
- switch (tag >>> 3) {
3993
- case 1: {
3994
- if (tag !== 10) {
3995
- break;
3996
- }
3997
- message.key = reader.string();
3998
- continue;
3999
- }
4000
- case 2: {
4001
- if (tag !== 18) {
4002
- break;
4003
- }
4004
- message.value = NodeGroup.decode(reader, reader.uint32());
4005
- continue;
4006
- }
4007
- }
4008
- if ((tag & 7) === 4 || tag === 0) {
4009
- break;
4010
- }
4011
- reader.skip(tag & 7);
4012
- }
4013
- return message;
4014
- },
4015
- fromJSON(object) {
4016
- return {
4017
- key: isSet2(object.key) ? globalThis.String(object.key) : "",
4018
- value: isSet2(object.value) ? NodeGroup.fromJSON(object.value) : void 0
4019
- };
4020
- },
4021
- toJSON(message) {
4022
- const obj = {};
4023
- if (message.key !== "") {
4024
- obj.key = message.key;
4025
- }
4026
- if (message.value !== void 0) {
4027
- obj.value = NodeGroup.toJSON(message.value);
4028
- }
4029
- return obj;
4030
- },
4031
- create(base) {
4032
- return GraphLayout_GroupsEntry.fromPartial(base ?? {});
4033
- },
4034
- fromPartial(object) {
4035
- const message = createBaseGraphLayout_GroupsEntry();
4036
- message.key = object.key ?? "";
4037
- message.value = object.value !== void 0 && object.value !== null ? NodeGroup.fromPartial(object.value) : void 0;
4038
- return message;
4039
- }
4040
- };
4041
- function createBaseNodeGroup() {
4042
- return { id: "", label: "", node_ids: [], collapsed: false };
4043
- }
4044
- var NodeGroup = {
4045
- encode(message, writer = new import_wire2.BinaryWriter()) {
4046
- if (message.id !== "") {
4047
- writer.uint32(10).string(message.id);
4048
- }
4049
- if (message.label !== "") {
4050
- writer.uint32(18).string(message.label);
4051
- }
4052
- for (const v of message.node_ids) {
4053
- writer.uint32(26).string(v);
4054
- }
4055
- if (message.collapsed !== false) {
4056
- writer.uint32(32).bool(message.collapsed);
4057
- }
4058
- return writer;
4059
- },
4060
- decode(input, length) {
4061
- const reader = input instanceof import_wire2.BinaryReader ? input : new import_wire2.BinaryReader(input);
4062
- const end = length === void 0 ? reader.len : reader.pos + length;
4063
- const message = createBaseNodeGroup();
4064
- while (reader.pos < end) {
4065
- const tag = reader.uint32();
4066
- switch (tag >>> 3) {
4067
- case 1: {
4068
- if (tag !== 10) {
4069
- break;
4070
- }
4071
- message.id = reader.string();
4072
- continue;
4073
- }
4074
- case 2: {
4075
- if (tag !== 18) {
4076
- break;
4077
- }
4078
- message.label = reader.string();
4079
- continue;
4080
- }
4081
- case 3: {
4082
- if (tag !== 26) {
4083
- break;
4084
- }
4085
- message.node_ids.push(reader.string());
4086
- continue;
4087
- }
4088
- case 4: {
4089
- if (tag !== 32) {
4090
- break;
4091
- }
4092
- message.collapsed = reader.bool();
4093
- continue;
4094
- }
4095
- }
4096
- if ((tag & 7) === 4 || tag === 0) {
4097
- break;
4098
- }
4099
- reader.skip(tag & 7);
4100
- }
4101
- return message;
4102
- },
4103
- fromJSON(object) {
4104
- return {
4105
- id: isSet2(object.id) ? globalThis.String(object.id) : "",
4106
- label: isSet2(object.label) ? globalThis.String(object.label) : "",
4107
- 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)) : [],
4108
- collapsed: isSet2(object.collapsed) ? globalThis.Boolean(object.collapsed) : false
4109
- };
4110
- },
4111
- toJSON(message) {
4112
- const obj = {};
4113
- if (message.id !== "") {
4114
- obj.id = message.id;
4115
- }
4116
- if (message.label !== "") {
4117
- obj.label = message.label;
4118
- }
4119
- if (message.node_ids?.length) {
4120
- obj.nodeIds = message.node_ids;
4121
- }
4122
- if (message.collapsed !== false) {
4123
- obj.collapsed = message.collapsed;
4124
- }
4125
- return obj;
4126
- },
4127
- create(base) {
4128
- return NodeGroup.fromPartial(base ?? {});
4129
- },
4130
- fromPartial(object) {
4131
- const message = createBaseNodeGroup();
4132
- message.id = object.id ?? "";
4133
- message.label = object.label ?? "";
4134
- message.node_ids = object.node_ids?.map((e) => e) || [];
4135
- message.collapsed = object.collapsed ?? false;
4136
- return message;
4137
- }
4138
- };
4139
- function createBaseNodeLayout() {
4140
- return { position: void 0 };
4141
- }
4142
- var NodeLayout = {
4143
- encode(message, writer = new import_wire2.BinaryWriter()) {
4144
- if (message.position !== void 0) {
4145
- Position.encode(message.position, writer.uint32(10).fork()).join();
4146
- }
4147
- return writer;
4148
- },
4149
- decode(input, length) {
4150
- const reader = input instanceof import_wire2.BinaryReader ? input : new import_wire2.BinaryReader(input);
4151
- const end = length === void 0 ? reader.len : reader.pos + length;
4152
- const message = createBaseNodeLayout();
4153
- while (reader.pos < end) {
4154
- const tag = reader.uint32();
4155
- switch (tag >>> 3) {
4156
- case 1: {
4157
- if (tag !== 10) {
4158
- break;
4159
- }
4160
- message.position = Position.decode(reader, reader.uint32());
4161
- continue;
4162
- }
4163
- }
4164
- if ((tag & 7) === 4 || tag === 0) {
4165
- break;
4166
- }
4167
- reader.skip(tag & 7);
4168
- }
4169
- return message;
4170
- },
4171
- fromJSON(object) {
4172
- return { position: isSet2(object.position) ? Position.fromJSON(object.position) : void 0 };
4173
- },
4174
- toJSON(message) {
4175
- const obj = {};
4176
- if (message.position !== void 0) {
4177
- obj.position = Position.toJSON(message.position);
4178
- }
4179
- return obj;
4180
- },
4181
- create(base) {
4182
- return NodeLayout.fromPartial(base ?? {});
4183
- },
4184
- fromPartial(object) {
4185
- const message = createBaseNodeLayout();
4186
- message.position = object.position !== void 0 && object.position !== null ? Position.fromPartial(object.position) : void 0;
4187
- return message;
4188
- }
4189
- };
4190
- function createBasePosition() {
4191
- return { x: 0, y: 0 };
4192
- }
4193
- var Position = {
4194
- encode(message, writer = new import_wire2.BinaryWriter()) {
4195
- if (message.x !== 0) {
4196
- writer.uint32(9).double(message.x);
4197
- }
4198
- if (message.y !== 0) {
4199
- writer.uint32(17).double(message.y);
4200
- }
4201
- return writer;
4202
- },
4203
- decode(input, length) {
4204
- const reader = input instanceof import_wire2.BinaryReader ? input : new import_wire2.BinaryReader(input);
4205
- const end = length === void 0 ? reader.len : reader.pos + length;
4206
- const message = createBasePosition();
4207
- while (reader.pos < end) {
4208
- const tag = reader.uint32();
4209
- switch (tag >>> 3) {
4210
- case 1: {
4211
- if (tag !== 9) {
4212
- break;
4213
- }
4214
- message.x = reader.double();
4215
- continue;
4216
- }
4217
- case 2: {
4218
- if (tag !== 17) {
4219
- break;
4220
- }
4221
- message.y = reader.double();
4222
- continue;
4223
- }
4224
- }
4225
- if ((tag & 7) === 4 || tag === 0) {
4226
- break;
4227
- }
4228
- reader.skip(tag & 7);
4229
- }
4230
- return message;
4231
- },
4232
- fromJSON(object) {
4233
- return {
4234
- x: isSet2(object.x) ? globalThis.Number(object.x) : 0,
4235
- y: isSet2(object.y) ? globalThis.Number(object.y) : 0
4236
- };
4237
- },
4238
- toJSON(message) {
4239
- const obj = {};
4240
- if (message.x !== 0) {
4241
- obj.x = message.x;
4242
- }
4243
- if (message.y !== 0) {
4244
- obj.y = message.y;
4245
- }
4246
- return obj;
4247
- },
4248
- create(base) {
4249
- return Position.fromPartial(base ?? {});
4250
- },
4251
- fromPartial(object) {
4252
- const message = createBasePosition();
4253
- message.x = object.x ?? 0;
4254
- message.y = object.y ?? 0;
4255
- return message;
4256
- }
4257
- };
4258
- function createBaseLayoutsMap() {
4259
- return { layouts: {} };
4260
- }
4261
- var LayoutsMap = {
4262
- encode(message, writer = new import_wire2.BinaryWriter()) {
4263
- globalThis.Object.entries(message.layouts).forEach(([key, value]) => {
4264
- LayoutsMap_LayoutsEntry.encode({ key, value }, writer.uint32(10).fork()).join();
4265
- });
4266
- return writer;
4267
- },
4268
- decode(input, length) {
4269
- const reader = input instanceof import_wire2.BinaryReader ? input : new import_wire2.BinaryReader(input);
4270
- const end = length === void 0 ? reader.len : reader.pos + length;
4271
- const message = createBaseLayoutsMap();
4272
- while (reader.pos < end) {
4273
- const tag = reader.uint32();
4274
- switch (tag >>> 3) {
4275
- case 1: {
4276
- if (tag !== 10) {
4277
- break;
4278
- }
4279
- const entry1 = LayoutsMap_LayoutsEntry.decode(reader, reader.uint32());
4280
- if (entry1.value !== void 0) {
4281
- message.layouts[entry1.key] = entry1.value;
4282
- }
4283
- continue;
4284
- }
4285
- }
4286
- if ((tag & 7) === 4 || tag === 0) {
4287
- break;
4288
- }
4289
- reader.skip(tag & 7);
4290
- }
4291
- return message;
4292
- },
4293
- fromJSON(object) {
4294
- return {
4295
- layouts: isObject2(object.layouts) ? globalThis.Object.entries(object.layouts).reduce(
4296
- (acc, [key, value]) => {
4297
- acc[key] = GraphLayout.fromJSON(value);
4298
- return acc;
4299
- },
4300
- {}
4301
- ) : {}
4302
- };
4303
- },
4304
- toJSON(message) {
4305
- const obj = {};
4306
- if (message.layouts) {
4307
- const entries = globalThis.Object.entries(message.layouts);
4308
- if (entries.length > 0) {
4309
- obj.layouts = {};
4310
- entries.forEach(([k, v]) => {
4311
- obj.layouts[k] = GraphLayout.toJSON(v);
4312
- });
4313
- }
4314
- }
4315
- return obj;
4316
- },
4317
- create(base) {
4318
- return LayoutsMap.fromPartial(base ?? {});
4319
- },
4320
- fromPartial(object) {
4321
- const message = createBaseLayoutsMap();
4322
- message.layouts = globalThis.Object.entries(object.layouts ?? {}).reduce(
4323
- (acc, [key, value]) => {
4324
- if (value !== void 0) {
4325
- acc[key] = GraphLayout.fromPartial(value);
4326
- }
4327
- return acc;
4328
- },
4329
- {}
4330
- );
4331
- return message;
4332
- }
4333
- };
4334
- function createBaseLayoutsMap_LayoutsEntry() {
4335
- return { key: "", value: void 0 };
4336
- }
4337
- var LayoutsMap_LayoutsEntry = {
4338
- encode(message, writer = new import_wire2.BinaryWriter()) {
4339
- if (message.key !== "") {
4340
- writer.uint32(10).string(message.key);
4341
- }
4342
- if (message.value !== void 0) {
4343
- GraphLayout.encode(message.value, writer.uint32(18).fork()).join();
4344
- }
4345
- return writer;
4346
- },
4347
- decode(input, length) {
4348
- const reader = input instanceof import_wire2.BinaryReader ? input : new import_wire2.BinaryReader(input);
4349
- const end = length === void 0 ? reader.len : reader.pos + length;
4350
- const message = createBaseLayoutsMap_LayoutsEntry();
4351
- while (reader.pos < end) {
4352
- const tag = reader.uint32();
4353
- switch (tag >>> 3) {
4354
- case 1: {
4355
- if (tag !== 10) {
4356
- break;
4357
- }
4358
- message.key = reader.string();
4359
- continue;
4360
- }
4361
- case 2: {
4362
- if (tag !== 18) {
4363
- break;
4364
- }
4365
- message.value = GraphLayout.decode(reader, reader.uint32());
4366
- continue;
4367
- }
4368
- }
4369
- if ((tag & 7) === 4 || tag === 0) {
4370
- break;
4371
- }
4372
- reader.skip(tag & 7);
4373
- }
4374
- return message;
4375
- },
4376
- fromJSON(object) {
4377
- return {
4378
- key: isSet2(object.key) ? globalThis.String(object.key) : "",
4379
- value: isSet2(object.value) ? GraphLayout.fromJSON(object.value) : void 0
4380
- };
4381
- },
4382
- toJSON(message) {
4383
- const obj = {};
4384
- if (message.key !== "") {
4385
- obj.key = message.key;
4386
- }
4387
- if (message.value !== void 0) {
4388
- obj.value = GraphLayout.toJSON(message.value);
4389
- }
4390
- return obj;
4391
- },
4392
- create(base) {
4393
- return LayoutsMap_LayoutsEntry.fromPartial(base ?? {});
4394
- },
4395
- fromPartial(object) {
4396
- const message = createBaseLayoutsMap_LayoutsEntry();
4397
- message.key = object.key ?? "";
4398
- message.value = object.value !== void 0 && object.value !== null ? GraphLayout.fromPartial(object.value) : void 0;
4399
- return message;
4400
- }
4401
- };
4402
3791
  function isObject2(value) {
4403
3792
  return typeof value === "object" && value !== null;
4404
3793
  }
@@ -4420,6 +3809,47 @@ function isGroupUse(bundle, use) {
4420
3809
  return (target.modules?.length ?? 0) > 0;
4421
3810
  }
4422
3811
 
3812
+ // src/projection/compute-layout.ts
3813
+ var SPACING_X = 260;
3814
+ var SPACING_Y = 180;
3815
+ function gridPosition(index, n) {
3816
+ const cols = Math.max(2, Math.ceil(Math.sqrt(n)));
3817
+ const col = index % cols;
3818
+ const row = Math.floor(index / cols);
3819
+ return { x: col * SPACING_X, y: row * SPACING_Y };
3820
+ }
3821
+ function overlapsAny(candidate, occupied) {
3822
+ return occupied.some(
3823
+ (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
3824
+ );
3825
+ }
3826
+ function resolveScopePositions(ids, arrangementNodes) {
3827
+ const positions = /* @__PURE__ */ new Map();
3828
+ const occupied = [];
3829
+ const unresolved = [];
3830
+ for (const id of ids) {
3831
+ const stored = arrangementNodes?.[id];
3832
+ if (stored) {
3833
+ positions.set(id, stored);
3834
+ occupied.push(stored);
3835
+ } else {
3836
+ unresolved.push(id);
3837
+ }
3838
+ }
3839
+ let slot = 0;
3840
+ for (const id of unresolved) {
3841
+ let candidate = gridPosition(slot, ids.length);
3842
+ while (overlapsAny(candidate, occupied)) {
3843
+ slot += 1;
3844
+ candidate = gridPosition(slot, ids.length);
3845
+ }
3846
+ positions.set(id, candidate);
3847
+ occupied.push(candidate);
3848
+ slot += 1;
3849
+ }
3850
+ return positions;
3851
+ }
3852
+
4423
3853
  // src/projection/derive-edges.ts
4424
3854
  var moduleRefPattern = /\bmodule\.([A-Za-z_][A-Za-z0-9_]*)\.([A-Za-z_][A-Za-z0-9_]*)/g;
4425
3855
  function emitEdgesFromBinding(binding, targetId, toInput, useIds, seen, edges) {
@@ -4485,11 +3915,11 @@ function joinPath(prefix, localId) {
4485
3915
  }
4486
3916
 
4487
3917
  // src/projection/project-group.ts
4488
- function projectGroup(use, target, fullId, parentLayout) {
3918
+ function projectGroup(use, target, fullId, parentArrangement) {
4489
3919
  const childIds = (target.modules ?? []).map((u) => joinPath(fullId, u.id));
4490
- const parentGroup = parentLayout?.groups?.[use.id];
3920
+ const parentGroup = parentArrangement?.groups?.[use.id];
4491
3921
  const collapsed = parentGroup ? parentGroup.collapsed : true;
4492
- const label = parentGroup && parentGroup.label !== "" ? parentGroup.label : use.id;
3922
+ const label = parentGroup?.label ? parentGroup.label : use.id;
4493
3923
  const inputs = (target.interface?.inputs ?? []).map((in_) => ({
4494
3924
  name: in_.name,
4495
3925
  type: in_.type,
@@ -4513,21 +3943,6 @@ function projectGroup(use, target, fullId, parentLayout) {
4513
3943
  };
4514
3944
  }
4515
3945
 
4516
- // src/projection/compute-layout.ts
4517
- var SPACING_X = 260;
4518
- var SPACING_Y = 180;
4519
- function gridPosition(index, n) {
4520
- const cols = Math.max(2, Math.ceil(Math.sqrt(n)));
4521
- const col = index % cols;
4522
- const row = Math.floor(index / cols);
4523
- return { x: col * SPACING_X, y: row * SPACING_Y };
4524
- }
4525
- function resolveChildPosition(childId, childIndex, totalChildren, existing) {
4526
- const stored = existing?.[childId]?.position;
4527
- if (stored) return stored;
4528
- return gridPosition(childIndex, totalChildren);
4529
- }
4530
-
4531
3946
  // src/projection/resolve-schema.ts
4532
3947
  function resolveSchema(bundle, use) {
4533
3948
  const target = bundle.modules[use.module];
@@ -4555,8 +3970,7 @@ function descendScope(bundle, scopeKey, segments) {
4555
3970
  }
4556
3971
 
4557
3972
  // src/projection/project-node.ts
4558
- function projectNode(bundle, use, fullId, childIndex, totalChildren, scopeLayout, wiredIn, wiredOut, errorsByInstance) {
4559
- const position = resolveChildPosition(use.id, childIndex, totalChildren, scopeLayout?.nodes);
3973
+ function projectNode(bundle, use, fullId, position, wiredIn, wiredOut, errorsByInstance) {
4560
3974
  const errorMessages = errorsByInstance.get(use.id) ?? [];
4561
3975
  const schema = resolveSchema(bundle, use);
4562
3976
  return {
@@ -4585,49 +3999,38 @@ function projectNode(bundle, use, fullId, childIndex, totalChildren, scopeLayout
4585
3999
  }
4586
4000
 
4587
4001
  // src/projection/project-scope.ts
4588
- function projectScope(bundle, mod, path, layouts, errorsByInstance) {
4002
+ function projectScope(bundle, mod, path, arrangement, errorsByInstance) {
4589
4003
  const uses = mod.modules ?? [];
4590
4004
  const derived = deriveEdges(uses);
4591
4005
  const { inputs: wiredIn, outputs: wiredOut } = indexWires(derived);
4592
4006
  const scopeKey = resolveScopePath(bundle, path);
4593
- const layout = scopeKey ? layouts[scopeKey] : void 0;
4007
+ const scopeArrangement = scopeKey ? arrangement?.[scopeKey] : void 0;
4594
4008
  const nodes = [];
4595
4009
  const groups = [];
4596
- const emittedGroupIds = /* @__PURE__ */ new Set();
4597
- uses.forEach((use, index) => {
4010
+ const classified = uses.map((use) => ({ use, group: isGroupUse(bundle, use) }));
4011
+ const nodeUseIds = classified.filter((c) => !c.group).map((c) => c.use.id);
4012
+ const positions = resolveScopePositions(nodeUseIds, scopeArrangement?.nodes);
4013
+ for (const { use, group } of classified) {
4598
4014
  const fullId = joinPath(path, use.id);
4599
- if (isGroupUse(bundle, use)) {
4015
+ if (group) {
4600
4016
  const target = bundle.modules[use.module];
4601
- if (target) {
4602
- groups.push(projectGroup(use, target, fullId, layout));
4603
- emittedGroupIds.add(use.id);
4604
- return;
4605
- }
4017
+ groups.push(projectGroup(use, target, fullId, scopeArrangement));
4018
+ continue;
4606
4019
  }
4607
4020
  nodes.push(
4608
4021
  projectNode(
4609
4022
  bundle,
4610
4023
  use,
4611
4024
  fullId,
4612
- index,
4613
- uses.length,
4614
- layout,
4025
+ // Every non-group use is in nodeUseIds, so resolveScopePositions
4026
+ // always has an entry for it — a fallback here would only mask a
4027
+ // classification bug, not handle a real gap.
4028
+ positions.get(use.id),
4615
4029
  wiredIn.get(use.id) ?? /* @__PURE__ */ new Set(),
4616
4030
  wiredOut.get(use.id) ?? /* @__PURE__ */ new Set(),
4617
4031
  errorsByInstance
4618
4032
  )
4619
4033
  );
4620
- });
4621
- if (layout?.groups) {
4622
- for (const [groupId, g] of Object.entries(layout.groups)) {
4623
- if (emittedGroupIds.has(groupId)) continue;
4624
- groups.push({
4625
- id: g.id,
4626
- label: g.label,
4627
- node_ids: g.node_ids.map((id) => joinPath(path, id)),
4628
- collapsed: g.collapsed
4629
- });
4630
- }
4631
4034
  }
4632
4035
  const edges = derived.map((de) => {
4633
4036
  const sourceId = joinPath(path, de.source_instance);
@@ -4674,25 +4077,6 @@ function danglingEdgeErrors(nodes, groups, edges) {
4674
4077
  }
4675
4078
  return errors;
4676
4079
  }
4677
- function overlappingGroupsWarnings(groups) {
4678
- const errors = [];
4679
- const userGroups = groups.filter((g) => !g.module_key);
4680
- for (let i = 0; i < userGroups.length; i++) {
4681
- for (let j = i + 1; j < userGroups.length; j++) {
4682
- const a = userGroups[i];
4683
- const b = userGroups[j];
4684
- const aSet = new Set(a.node_ids);
4685
- const overlap = b.node_ids.filter((id) => aSet.has(id));
4686
- if (overlap.length > 0) {
4687
- errors.push({
4688
- instance_id: a.id,
4689
- message: `Group "${a.label}" overlaps group "${b.label}" on ${overlap.length} member(s)`
4690
- });
4691
- }
4692
- }
4693
- }
4694
- return errors;
4695
- }
4696
4080
 
4697
4081
  // src/projection/walk-modules.ts
4698
4082
  function walk(bundle, visit) {
@@ -4711,21 +4095,20 @@ function walkFrom(bundle, mod, use, path, visit) {
4711
4095
  }
4712
4096
 
4713
4097
  // src/projection/project.ts
4714
- function projectCanvasView(bundle, layouts, meta) {
4098
+ function projectCanvasView(bundle, arrangement, meta) {
4715
4099
  const nodes = [];
4716
4100
  const edges = [];
4717
4101
  const groups = [];
4718
4102
  const errorsByInstance = /* @__PURE__ */ new Map();
4719
4103
  walk(bundle, (mod, _use, path) => {
4720
- const scope = projectScope(bundle, mod, path, layouts, errorsByInstance);
4104
+ const scope = projectScope(bundle, mod, path, arrangement, errorsByInstance);
4721
4105
  nodes.push(...scope.nodes);
4722
4106
  edges.push(...scope.edges);
4723
4107
  groups.push(...scope.groups);
4724
4108
  });
4725
4109
  const errors = [
4726
4110
  ...missingRequiredInputErrors(nodes),
4727
- ...danglingEdgeErrors(nodes, groups, edges),
4728
- ...overlappingGroupsWarnings(groups)
4111
+ ...danglingEdgeErrors(nodes, groups, edges)
4729
4112
  ];
4730
4113
  errors.sort((a, b) => {
4731
4114
  const ai = a.instance_id ?? "";
@@ -4736,8 +4119,6 @@ function projectCanvasView(bundle, layouts, meta) {
4736
4119
  if (an !== bn) return an < bn ? -1 : 1;
4737
4120
  return a.message < b.message ? -1 : a.message > b.message ? 1 : 0;
4738
4121
  });
4739
- const moduleGroups = groups.filter((g) => g.module_key);
4740
- const userGroups = groups.filter((g) => !g.module_key).sort((a, b) => a.id < b.id ? -1 : a.id > b.id ? 1 : 0);
4741
4122
  const moduleName = meta.moduleName ?? parseModuleKey(bundle.entry).id;
4742
4123
  return {
4743
4124
  module_name: moduleName,
@@ -4747,7 +4128,10 @@ function projectCanvasView(bundle, layouts, meta) {
4747
4128
  can_undo: meta.canUndo,
4748
4129
  can_redo: meta.canRedo,
4749
4130
  is_dirty: meta.isDirty,
4750
- groups: [...moduleGroups, ...userGroups]
4131
+ // Every group is now a Use whose target has sub-Uses (CreateGroupAction
4132
+ // mints a module); emission order already mirrors Use declaration order
4133
+ // via the walk, so no separate user-group sort is needed.
4134
+ groups
4751
4135
  };
4752
4136
  }
4753
4137
 
@@ -5258,7 +4642,7 @@ var RenderNode = {
5258
4642
  writer.uint32(42).string(message.icon_url);
5259
4643
  }
5260
4644
  if (message.position !== void 0) {
5261
- Position2.encode(message.position, writer.uint32(50).fork()).join();
4645
+ Position.encode(message.position, writer.uint32(50).fork()).join();
5262
4646
  }
5263
4647
  if (message.has_errors !== false) {
5264
4648
  writer.uint32(56).bool(message.has_errors);
@@ -5320,7 +4704,7 @@ var RenderNode = {
5320
4704
  if (tag !== 50) {
5321
4705
  break;
5322
4706
  }
5323
- message.position = Position2.decode(reader, reader.uint32());
4707
+ message.position = Position.decode(reader, reader.uint32());
5324
4708
  continue;
5325
4709
  }
5326
4710
  case 7: {
@@ -5366,7 +4750,7 @@ var RenderNode = {
5366
4750
  kind: isSet3(object.kind) ? nodeKindFromJSON(object.kind) : 0,
5367
4751
  module_key: isSet3(object.moduleKey) ? globalThis.String(object.moduleKey) : isSet3(object.module_key) ? globalThis.String(object.module_key) : "",
5368
4752
  icon_url: isSet3(object.iconUrl) ? globalThis.String(object.iconUrl) : isSet3(object.icon_url) ? globalThis.String(object.icon_url) : "",
5369
- position: isSet3(object.position) ? Position2.fromJSON(object.position) : void 0,
4753
+ position: isSet3(object.position) ? Position.fromJSON(object.position) : void 0,
5370
4754
  has_errors: isSet3(object.hasErrors) ? globalThis.Boolean(object.hasErrors) : isSet3(object.has_errors) ? globalThis.Boolean(object.has_errors) : false,
5371
4755
  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)) : [],
5372
4756
  inputs: globalThis.Array.isArray(object?.inputs) ? object.inputs.map((e) => NodePin.fromJSON(e)) : [],
@@ -5391,7 +4775,7 @@ var RenderNode = {
5391
4775
  obj.iconUrl = message.icon_url;
5392
4776
  }
5393
4777
  if (message.position !== void 0) {
5394
- obj.position = Position2.toJSON(message.position);
4778
+ obj.position = Position.toJSON(message.position);
5395
4779
  }
5396
4780
  if (message.has_errors !== false) {
5397
4781
  obj.hasErrors = message.has_errors;
@@ -5417,7 +4801,7 @@ var RenderNode = {
5417
4801
  message.kind = object.kind ?? 0;
5418
4802
  message.module_key = object.module_key ?? "";
5419
4803
  message.icon_url = object.icon_url ?? "";
5420
- message.position = object.position !== void 0 && object.position !== null ? Position2.fromPartial(object.position) : void 0;
4804
+ message.position = object.position !== void 0 && object.position !== null ? Position.fromPartial(object.position) : void 0;
5421
4805
  message.has_errors = object.has_errors ?? false;
5422
4806
  message.error_messages = object.error_messages?.map((e) => e) || [];
5423
4807
  message.inputs = object.inputs?.map((e) => NodePin.fromPartial(e)) || [];
@@ -7443,10 +6827,10 @@ var RenderError = {
7443
6827
  return message;
7444
6828
  }
7445
6829
  };
7446
- function createBasePosition2() {
6830
+ function createBasePosition() {
7447
6831
  return { x: 0, y: 0 };
7448
6832
  }
7449
- var Position2 = {
6833
+ var Position = {
7450
6834
  encode(message, writer = new import_wire3.BinaryWriter()) {
7451
6835
  if (message.x !== 0) {
7452
6836
  writer.uint32(9).double(message.x);
@@ -7459,7 +6843,7 @@ var Position2 = {
7459
6843
  decode(input, length) {
7460
6844
  const reader = input instanceof import_wire3.BinaryReader ? input : new import_wire3.BinaryReader(input);
7461
6845
  const end = length === void 0 ? reader.len : reader.pos + length;
7462
- const message = createBasePosition2();
6846
+ const message = createBasePosition();
7463
6847
  while (reader.pos < end) {
7464
6848
  const tag = reader.uint32();
7465
6849
  switch (tag >>> 3) {
@@ -7502,10 +6886,10 @@ var Position2 = {
7502
6886
  return obj;
7503
6887
  },
7504
6888
  create(base) {
7505
- return Position2.fromPartial(base ?? {});
6889
+ return Position.fromPartial(base ?? {});
7506
6890
  },
7507
6891
  fromPartial(object) {
7508
- const message = createBasePosition2();
6892
+ const message = createBasePosition();
7509
6893
  message.x = object.x ?? 0;
7510
6894
  message.y = object.y ?? 0;
7511
6895
  return message;
@@ -7892,8 +7276,6 @@ var SettingsConfigProto = SettingsConfig;
7892
7276
  Bundle,
7893
7277
  CanvasViewProto,
7894
7278
  EdgeConfigProto,
7895
- GraphLayout,
7896
- LayoutsMap,
7897
7279
  NodeConfigProto,
7898
7280
  SettingsConfigProto,
7899
7281
  convertCanvasView,
@@ -7909,6 +7291,8 @@ var SettingsConfigProto = SettingsConfig;
7909
7291
  convertSettingsConfig,
7910
7292
  modeToInputMode,
7911
7293
  parseModuleKey,
7912
- projectCanvasView
7294
+ projectCanvasView,
7295
+ resolveScopePath,
7296
+ resolveScopePositions
7913
7297
  });
7914
7298
  //# sourceMappingURL=index.cjs.map