@dcl/ecs 7.1.4-4670008948.commit-217b840 → 7.1.4-4672664161.commit-7ba5d40
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/components/generated/pb/decentraland/common/border_rect.gen.js +21 -8
- package/dist/components/generated/pb/decentraland/common/colors.gen.js +38 -15
- package/dist/components/generated/pb/decentraland/common/texture.gen.js +78 -36
- package/dist/components/generated/pb/decentraland/common/vectors.gen.js +47 -20
- package/dist/components/generated/pb/decentraland/sdk/components/animator.gen.js +42 -16
- package/dist/components/generated/pb/decentraland/sdk/components/audio_source.gen.js +25 -9
- package/dist/components/generated/pb/decentraland/sdk/components/audio_stream.gen.js +17 -7
- package/dist/components/generated/pb/decentraland/sdk/components/avatar_attach.gen.js +13 -6
- package/dist/components/generated/pb/decentraland/sdk/components/avatar_modifier_area.gen.js +19 -10
- package/dist/components/generated/pb/decentraland/sdk/components/avatar_shape.gen.js +49 -15
- package/dist/components/generated/pb/decentraland/sdk/components/billboard.gen.js +9 -5
- package/dist/components/generated/pb/decentraland/sdk/components/camera_mode.gen.js +9 -5
- package/dist/components/generated/pb/decentraland/sdk/components/camera_mode_area.gen.js +13 -6
- package/dist/components/generated/pb/decentraland/sdk/components/common/raycast_hit.gen.js +33 -11
- package/dist/components/generated/pb/decentraland/sdk/components/gltf_container.gen.js +9 -5
- package/dist/components/generated/pb/decentraland/sdk/components/material.gen.js +110 -39
- package/dist/components/generated/pb/decentraland/sdk/components/mesh_collider.gen.js +66 -38
- package/dist/components/generated/pb/decentraland/sdk/components/mesh_renderer.gen.js +74 -45
- package/dist/components/generated/pb/decentraland/sdk/components/nft_shape.gen.js +17 -7
- package/dist/components/generated/pb/decentraland/sdk/components/pointer_events.gen.js +43 -19
- package/dist/components/generated/pb/decentraland/sdk/components/pointer_events_result.gen.js +25 -9
- package/dist/components/generated/pb/decentraland/sdk/components/pointer_lock.gen.js +9 -5
- package/dist/components/generated/pb/decentraland/sdk/components/raycast.gen.js +58 -25
- package/dist/components/generated/pb/decentraland/sdk/components/raycast_result.gen.js +21 -8
- package/dist/components/generated/pb/decentraland/sdk/components/text_shape.gen.js +89 -25
- package/dist/components/generated/pb/decentraland/sdk/components/ui_background.gen.js +27 -12
- package/dist/components/generated/pb/decentraland/sdk/components/ui_dropdown.gen.js +41 -13
- package/dist/components/generated/pb/decentraland/sdk/components/ui_dropdown_result.gen.js +9 -5
- package/dist/components/generated/pb/decentraland/sdk/components/ui_input.gen.js +37 -12
- package/dist/components/generated/pb/decentraland/sdk/components/ui_input_result.gen.js +9 -5
- package/dist/components/generated/pb/decentraland/sdk/components/ui_text.gen.js +25 -9
- package/dist/components/generated/pb/decentraland/sdk/components/ui_transform.gen.js +209 -55
- package/dist/components/generated/pb/decentraland/sdk/components/video_player.gen.js +29 -10
- package/dist/components/generated/pb/decentraland/sdk/components/visibility_component.gen.js +9 -5
- package/dist/components/generated/pb/google/protobuf/descriptor.gen.js +579 -226
- package/dist/composite/instance.js +11 -1
- package/dist/composite/proto/gen/composite.gen.js +64 -31
- package/dist/composite/proto/gen/google/protobuf/struct.gen.js +88 -47
- package/dist/engine/component.d.ts +7 -0
- package/dist/engine/lww-element-set-component-definition.js +10 -0
- package/dist/schemas/buildSchema.d.ts +4 -0
- package/dist/schemas/buildSchema.js +34 -0
- package/dist/schemas/index.d.ts +17 -0
- package/dist/schemas/index.js +15 -1
- package/package.json +3 -3
|
@@ -142,10 +142,20 @@ export function instanceComposite(engine, compositeResource, compositeProvider,
|
|
|
142
142
|
if (transform.parent) {
|
|
143
143
|
transform.parent = getCompositeEntity(transform.parent);
|
|
144
144
|
}
|
|
145
|
+
else {
|
|
146
|
+
transform.parent = getCompositeEntity(0);
|
|
147
|
+
}
|
|
145
148
|
// TODO: is it going to be necessary to remap assets? e.g. src param from AudioSource and GltfContainer
|
|
146
149
|
}
|
|
147
150
|
else {
|
|
148
|
-
|
|
151
|
+
Schemas.mutateNestedValues(componentDefinition.schema.jsonSchema, componentValue, (value, valueType) => {
|
|
152
|
+
if (valueType.serializationType === 'entity') {
|
|
153
|
+
return { changed: true, value: getCompositeEntity(value) };
|
|
154
|
+
}
|
|
155
|
+
else {
|
|
156
|
+
return { changed: false };
|
|
157
|
+
}
|
|
158
|
+
});
|
|
149
159
|
}
|
|
150
160
|
}
|
|
151
161
|
}
|
|
@@ -13,31 +13,40 @@ function createBaseComponentData() {
|
|
|
13
13
|
*/
|
|
14
14
|
export const ComponentData = {
|
|
15
15
|
encode(message, writer = _m0.Writer.create()) {
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
16
|
+
switch (message.data?.$case) {
|
|
17
|
+
case "json":
|
|
18
|
+
Value.encode(Value.wrap(message.data.json), writer.uint32(10).fork()).ldelim();
|
|
19
|
+
break;
|
|
20
|
+
case "binary":
|
|
21
|
+
writer.uint32(18).bytes(message.data.binary);
|
|
22
|
+
break;
|
|
21
23
|
}
|
|
22
24
|
return writer;
|
|
23
25
|
},
|
|
24
26
|
decode(input, length) {
|
|
25
|
-
const reader = input instanceof _m0.Reader ? input :
|
|
27
|
+
const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input);
|
|
26
28
|
let end = length === undefined ? reader.len : reader.pos + length;
|
|
27
29
|
const message = createBaseComponentData();
|
|
28
30
|
while (reader.pos < end) {
|
|
29
31
|
const tag = reader.uint32();
|
|
30
32
|
switch (tag >>> 3) {
|
|
31
33
|
case 1:
|
|
34
|
+
if (tag != 10) {
|
|
35
|
+
break;
|
|
36
|
+
}
|
|
32
37
|
message.data = { $case: "json", json: Value.unwrap(Value.decode(reader, reader.uint32())) };
|
|
33
|
-
|
|
38
|
+
continue;
|
|
34
39
|
case 2:
|
|
40
|
+
if (tag != 18) {
|
|
41
|
+
break;
|
|
42
|
+
}
|
|
35
43
|
message.data = { $case: "binary", binary: reader.bytes() };
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
44
|
+
continue;
|
|
45
|
+
}
|
|
46
|
+
if ((tag & 7) == 4 || tag == 0) {
|
|
47
|
+
break;
|
|
40
48
|
}
|
|
49
|
+
reader.skipType(tag & 7);
|
|
41
50
|
}
|
|
42
51
|
return message;
|
|
43
52
|
},
|
|
@@ -75,34 +84,44 @@ export const CompositeComponent = {
|
|
|
75
84
|
if (message.jsonSchema !== undefined) {
|
|
76
85
|
Value.encode(Value.wrap(message.jsonSchema), writer.uint32(18).fork()).ldelim();
|
|
77
86
|
}
|
|
78
|
-
message.data.forEach((value, key) => {
|
|
87
|
+
(message.data).forEach((value, key) => {
|
|
79
88
|
CompositeComponent_DataEntry.encode({ key: key, value }, writer.uint32(26).fork()).ldelim();
|
|
80
89
|
});
|
|
81
90
|
return writer;
|
|
82
91
|
},
|
|
83
92
|
decode(input, length) {
|
|
84
|
-
const reader = input instanceof _m0.Reader ? input :
|
|
93
|
+
const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input);
|
|
85
94
|
let end = length === undefined ? reader.len : reader.pos + length;
|
|
86
95
|
const message = createBaseCompositeComponent();
|
|
87
96
|
while (reader.pos < end) {
|
|
88
97
|
const tag = reader.uint32();
|
|
89
98
|
switch (tag >>> 3) {
|
|
90
99
|
case 1:
|
|
100
|
+
if (tag != 10) {
|
|
101
|
+
break;
|
|
102
|
+
}
|
|
91
103
|
message.name = reader.string();
|
|
92
|
-
|
|
104
|
+
continue;
|
|
93
105
|
case 2:
|
|
106
|
+
if (tag != 18) {
|
|
107
|
+
break;
|
|
108
|
+
}
|
|
94
109
|
message.jsonSchema = Value.unwrap(Value.decode(reader, reader.uint32()));
|
|
95
|
-
|
|
110
|
+
continue;
|
|
96
111
|
case 3:
|
|
112
|
+
if (tag != 26) {
|
|
113
|
+
break;
|
|
114
|
+
}
|
|
97
115
|
const entry3 = CompositeComponent_DataEntry.decode(reader, reader.uint32());
|
|
98
116
|
if (entry3.value !== undefined) {
|
|
99
117
|
message.data.set(entry3.key, entry3.value);
|
|
100
118
|
}
|
|
101
|
-
|
|
102
|
-
default:
|
|
103
|
-
reader.skipType(tag & 7);
|
|
104
|
-
break;
|
|
119
|
+
continue;
|
|
105
120
|
}
|
|
121
|
+
if ((tag & 7) == 4 || tag == 0) {
|
|
122
|
+
break;
|
|
123
|
+
}
|
|
124
|
+
reader.skipType(tag & 7);
|
|
106
125
|
}
|
|
107
126
|
return message;
|
|
108
127
|
},
|
|
@@ -151,22 +170,29 @@ export const CompositeComponent_DataEntry = {
|
|
|
151
170
|
return writer;
|
|
152
171
|
},
|
|
153
172
|
decode(input, length) {
|
|
154
|
-
const reader = input instanceof _m0.Reader ? input :
|
|
173
|
+
const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input);
|
|
155
174
|
let end = length === undefined ? reader.len : reader.pos + length;
|
|
156
175
|
const message = createBaseCompositeComponent_DataEntry();
|
|
157
176
|
while (reader.pos < end) {
|
|
158
177
|
const tag = reader.uint32();
|
|
159
178
|
switch (tag >>> 3) {
|
|
160
179
|
case 1:
|
|
180
|
+
if (tag != 8) {
|
|
181
|
+
break;
|
|
182
|
+
}
|
|
161
183
|
message.key = reader.int32();
|
|
162
|
-
|
|
184
|
+
continue;
|
|
163
185
|
case 2:
|
|
186
|
+
if (tag != 18) {
|
|
187
|
+
break;
|
|
188
|
+
}
|
|
164
189
|
message.value = ComponentData.decode(reader, reader.uint32());
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
190
|
+
continue;
|
|
191
|
+
}
|
|
192
|
+
if ((tag & 7) == 4 || tag == 0) {
|
|
193
|
+
break;
|
|
169
194
|
}
|
|
195
|
+
reader.skipType(tag & 7);
|
|
170
196
|
}
|
|
171
197
|
return message;
|
|
172
198
|
},
|
|
@@ -203,22 +229,29 @@ export const CompositeDefinition = {
|
|
|
203
229
|
return writer;
|
|
204
230
|
},
|
|
205
231
|
decode(input, length) {
|
|
206
|
-
const reader = input instanceof _m0.Reader ? input :
|
|
232
|
+
const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input);
|
|
207
233
|
let end = length === undefined ? reader.len : reader.pos + length;
|
|
208
234
|
const message = createBaseCompositeDefinition();
|
|
209
235
|
while (reader.pos < end) {
|
|
210
236
|
const tag = reader.uint32();
|
|
211
237
|
switch (tag >>> 3) {
|
|
212
238
|
case 1:
|
|
239
|
+
if (tag != 8) {
|
|
240
|
+
break;
|
|
241
|
+
}
|
|
213
242
|
message.version = reader.int32();
|
|
214
|
-
|
|
243
|
+
continue;
|
|
215
244
|
case 2:
|
|
245
|
+
if (tag != 18) {
|
|
246
|
+
break;
|
|
247
|
+
}
|
|
216
248
|
message.components.push(CompositeComponent.decode(reader, reader.uint32()));
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
249
|
+
continue;
|
|
250
|
+
}
|
|
251
|
+
if ((tag & 7) == 4 || tag == 0) {
|
|
252
|
+
break;
|
|
221
253
|
}
|
|
254
|
+
reader.skipType(tag & 7);
|
|
222
255
|
}
|
|
223
256
|
return message;
|
|
224
257
|
},
|
|
@@ -49,7 +49,7 @@ function createBaseStruct() {
|
|
|
49
49
|
*/
|
|
50
50
|
export const Struct = {
|
|
51
51
|
encode(message, writer = _m0.Writer.create()) {
|
|
52
|
-
message.fields.forEach((value, key) => {
|
|
52
|
+
(message.fields).forEach((value, key) => {
|
|
53
53
|
if (value !== undefined) {
|
|
54
54
|
Struct_FieldsEntry.encode({ key: key, value }, writer.uint32(10).fork()).ldelim();
|
|
55
55
|
}
|
|
@@ -57,22 +57,26 @@ export const Struct = {
|
|
|
57
57
|
return writer;
|
|
58
58
|
},
|
|
59
59
|
decode(input, length) {
|
|
60
|
-
const reader = input instanceof _m0.Reader ? input :
|
|
60
|
+
const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input);
|
|
61
61
|
let end = length === undefined ? reader.len : reader.pos + length;
|
|
62
62
|
const message = createBaseStruct();
|
|
63
63
|
while (reader.pos < end) {
|
|
64
64
|
const tag = reader.uint32();
|
|
65
65
|
switch (tag >>> 3) {
|
|
66
66
|
case 1:
|
|
67
|
+
if (tag != 10) {
|
|
68
|
+
break;
|
|
69
|
+
}
|
|
67
70
|
const entry1 = Struct_FieldsEntry.decode(reader, reader.uint32());
|
|
68
71
|
if (entry1.value !== undefined) {
|
|
69
72
|
message.fields.set(entry1.key, entry1.value);
|
|
70
73
|
}
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
74
|
+
continue;
|
|
75
|
+
}
|
|
76
|
+
if ((tag & 7) == 4 || tag == 0) {
|
|
77
|
+
break;
|
|
75
78
|
}
|
|
79
|
+
reader.skipType(tag & 7);
|
|
76
80
|
}
|
|
77
81
|
return message;
|
|
78
82
|
},
|
|
@@ -133,22 +137,29 @@ export const Struct_FieldsEntry = {
|
|
|
133
137
|
return writer;
|
|
134
138
|
},
|
|
135
139
|
decode(input, length) {
|
|
136
|
-
const reader = input instanceof _m0.Reader ? input :
|
|
140
|
+
const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input);
|
|
137
141
|
let end = length === undefined ? reader.len : reader.pos + length;
|
|
138
142
|
const message = createBaseStruct_FieldsEntry();
|
|
139
143
|
while (reader.pos < end) {
|
|
140
144
|
const tag = reader.uint32();
|
|
141
145
|
switch (tag >>> 3) {
|
|
142
146
|
case 1:
|
|
147
|
+
if (tag != 10) {
|
|
148
|
+
break;
|
|
149
|
+
}
|
|
143
150
|
message.key = reader.string();
|
|
144
|
-
|
|
151
|
+
continue;
|
|
145
152
|
case 2:
|
|
153
|
+
if (tag != 18) {
|
|
154
|
+
break;
|
|
155
|
+
}
|
|
146
156
|
message.value = Value.unwrap(Value.decode(reader, reader.uint32()));
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
157
|
+
continue;
|
|
158
|
+
}
|
|
159
|
+
if ((tag & 7) == 4 || tag == 0) {
|
|
160
|
+
break;
|
|
151
161
|
}
|
|
162
|
+
reader.skipType(tag & 7);
|
|
152
163
|
}
|
|
153
164
|
return message;
|
|
154
165
|
},
|
|
@@ -173,55 +184,76 @@ function createBaseValue() {
|
|
|
173
184
|
*/
|
|
174
185
|
export const Value = {
|
|
175
186
|
encode(message, writer = _m0.Writer.create()) {
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
187
|
+
switch (message.kind?.$case) {
|
|
188
|
+
case "nullValue":
|
|
189
|
+
writer.uint32(8).int32(message.kind.nullValue);
|
|
190
|
+
break;
|
|
191
|
+
case "numberValue":
|
|
192
|
+
writer.uint32(17).double(message.kind.numberValue);
|
|
193
|
+
break;
|
|
194
|
+
case "stringValue":
|
|
195
|
+
writer.uint32(26).string(message.kind.stringValue);
|
|
196
|
+
break;
|
|
197
|
+
case "boolValue":
|
|
198
|
+
writer.uint32(32).bool(message.kind.boolValue);
|
|
199
|
+
break;
|
|
200
|
+
case "structValue":
|
|
201
|
+
Struct.encode(Struct.wrap(message.kind.structValue), writer.uint32(42).fork()).ldelim();
|
|
202
|
+
break;
|
|
203
|
+
case "listValue":
|
|
204
|
+
ListValue.encode(ListValue.wrap(message.kind.listValue), writer.uint32(50).fork()).ldelim();
|
|
205
|
+
break;
|
|
193
206
|
}
|
|
194
207
|
return writer;
|
|
195
208
|
},
|
|
196
209
|
decode(input, length) {
|
|
197
|
-
const reader = input instanceof _m0.Reader ? input :
|
|
210
|
+
const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input);
|
|
198
211
|
let end = length === undefined ? reader.len : reader.pos + length;
|
|
199
212
|
const message = createBaseValue();
|
|
200
213
|
while (reader.pos < end) {
|
|
201
214
|
const tag = reader.uint32();
|
|
202
215
|
switch (tag >>> 3) {
|
|
203
216
|
case 1:
|
|
217
|
+
if (tag != 8) {
|
|
218
|
+
break;
|
|
219
|
+
}
|
|
204
220
|
message.kind = { $case: "nullValue", nullValue: reader.int32() };
|
|
205
|
-
|
|
221
|
+
continue;
|
|
206
222
|
case 2:
|
|
223
|
+
if (tag != 17) {
|
|
224
|
+
break;
|
|
225
|
+
}
|
|
207
226
|
message.kind = { $case: "numberValue", numberValue: reader.double() };
|
|
208
|
-
|
|
227
|
+
continue;
|
|
209
228
|
case 3:
|
|
229
|
+
if (tag != 26) {
|
|
230
|
+
break;
|
|
231
|
+
}
|
|
210
232
|
message.kind = { $case: "stringValue", stringValue: reader.string() };
|
|
211
|
-
|
|
233
|
+
continue;
|
|
212
234
|
case 4:
|
|
235
|
+
if (tag != 32) {
|
|
236
|
+
break;
|
|
237
|
+
}
|
|
213
238
|
message.kind = { $case: "boolValue", boolValue: reader.bool() };
|
|
214
|
-
|
|
239
|
+
continue;
|
|
215
240
|
case 5:
|
|
241
|
+
if (tag != 42) {
|
|
242
|
+
break;
|
|
243
|
+
}
|
|
216
244
|
message.kind = { $case: "structValue", structValue: Struct.unwrap(Struct.decode(reader, reader.uint32())) };
|
|
217
|
-
|
|
245
|
+
continue;
|
|
218
246
|
case 6:
|
|
247
|
+
if (tag != 50) {
|
|
248
|
+
break;
|
|
249
|
+
}
|
|
219
250
|
message.kind = { $case: "listValue", listValue: ListValue.unwrap(ListValue.decode(reader, reader.uint32())) };
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
251
|
+
continue;
|
|
252
|
+
}
|
|
253
|
+
if ((tag & 7) == 4 || tag == 0) {
|
|
254
|
+
break;
|
|
224
255
|
}
|
|
256
|
+
reader.skipType(tag & 7);
|
|
225
257
|
}
|
|
226
258
|
return message;
|
|
227
259
|
},
|
|
@@ -319,19 +351,23 @@ export const ListValue = {
|
|
|
319
351
|
return writer;
|
|
320
352
|
},
|
|
321
353
|
decode(input, length) {
|
|
322
|
-
const reader = input instanceof _m0.Reader ? input :
|
|
354
|
+
const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input);
|
|
323
355
|
let end = length === undefined ? reader.len : reader.pos + length;
|
|
324
356
|
const message = createBaseListValue();
|
|
325
357
|
while (reader.pos < end) {
|
|
326
358
|
const tag = reader.uint32();
|
|
327
359
|
switch (tag >>> 3) {
|
|
328
360
|
case 1:
|
|
361
|
+
if (tag != 10) {
|
|
362
|
+
break;
|
|
363
|
+
}
|
|
329
364
|
message.values.push(Value.unwrap(Value.decode(reader, reader.uint32())));
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
365
|
+
continue;
|
|
366
|
+
}
|
|
367
|
+
if ((tag & 7) == 4 || tag == 0) {
|
|
368
|
+
break;
|
|
334
369
|
}
|
|
370
|
+
reader.skipType(tag & 7);
|
|
335
371
|
}
|
|
336
372
|
return message;
|
|
337
373
|
},
|
|
@@ -348,13 +384,18 @@ export const ListValue = {
|
|
|
348
384
|
}
|
|
349
385
|
return obj;
|
|
350
386
|
},
|
|
351
|
-
wrap(
|
|
387
|
+
wrap(array) {
|
|
352
388
|
const result = createBaseListValue();
|
|
353
|
-
result.values =
|
|
389
|
+
result.values = array ?? [];
|
|
354
390
|
return result;
|
|
355
391
|
},
|
|
356
392
|
unwrap(message) {
|
|
357
|
-
|
|
393
|
+
if (message?.hasOwnProperty("values") && Array.isArray(message.values)) {
|
|
394
|
+
return message.values;
|
|
395
|
+
}
|
|
396
|
+
else {
|
|
397
|
+
return message;
|
|
398
|
+
}
|
|
358
399
|
},
|
|
359
400
|
};
|
|
360
401
|
var tsProtoGlobalThis = (() => {
|
|
@@ -115,6 +115,13 @@ export interface LastWriteWinElementSetComponentDefinition<T> extends BaseCompon
|
|
|
115
115
|
* @param entity - Entity to get the component from
|
|
116
116
|
*/
|
|
117
117
|
getMutableOrNull(entity: Entity): T | null;
|
|
118
|
+
/**
|
|
119
|
+
* Get the mutable component of the entity. If the entity doesn't have the component, it's created.
|
|
120
|
+
* - Internal comment: This method adds the <entity,component> to the list to be reviewed next frame
|
|
121
|
+
* @param entity - Entity to get the component from
|
|
122
|
+
* @param val - The initial value if it doesn't exist
|
|
123
|
+
*/
|
|
124
|
+
getOrCreateMutable(entity: Entity, initialValue?: T): T;
|
|
118
125
|
}
|
|
119
126
|
/**
|
|
120
127
|
* @public
|
|
@@ -222,6 +222,16 @@ export function createComponentDefinitionFromSchema(componentName, componentId,
|
|
|
222
222
|
dirtyIterator.add(entity);
|
|
223
223
|
return component;
|
|
224
224
|
},
|
|
225
|
+
getOrCreateMutable(entity, value) {
|
|
226
|
+
const component = data.get(entity);
|
|
227
|
+
if (!component) {
|
|
228
|
+
return this.create(entity, value);
|
|
229
|
+
}
|
|
230
|
+
else {
|
|
231
|
+
dirtyIterator.add(entity);
|
|
232
|
+
return component;
|
|
233
|
+
}
|
|
234
|
+
},
|
|
225
235
|
getMutable(entity) {
|
|
226
236
|
const component = this.getMutableOrNull(entity);
|
|
227
237
|
if (component === null) {
|
|
@@ -5,3 +5,7 @@ import { ISchema, JsonSchemaExtended } from './ISchema';
|
|
|
5
5
|
* @returns a ISchema or fail for unsupported json-schema
|
|
6
6
|
*/
|
|
7
7
|
export declare function jsonSchemaToSchema(jsonSchema: JsonSchemaExtended): ISchema<any>;
|
|
8
|
+
export declare function mutateValues(jsonSchema: JsonSchemaExtended, value: unknown, mutateFn: (value: unknown, valueType: JsonSchemaExtended) => {
|
|
9
|
+
changed: boolean;
|
|
10
|
+
value?: any;
|
|
11
|
+
}): void;
|
|
@@ -61,3 +61,37 @@ export function jsonSchemaToSchema(jsonSchema) {
|
|
|
61
61
|
}
|
|
62
62
|
throw new Error(`${jsonSchema.serializationType} is not supported as reverse schema generation.`);
|
|
63
63
|
}
|
|
64
|
+
export function mutateValues(jsonSchema, value, mutateFn) {
|
|
65
|
+
if (jsonSchema.serializationType === 'map') {
|
|
66
|
+
const mapJsonSchema = jsonSchema;
|
|
67
|
+
const mapValue = value;
|
|
68
|
+
for (const key in mapJsonSchema.properties) {
|
|
69
|
+
const valueType = mapJsonSchema.properties[key];
|
|
70
|
+
if (valueType.serializationType === 'array' || valueType.serializationType === 'map') {
|
|
71
|
+
mutateValues(mapJsonSchema.properties[key], mapValue[key], mutateFn);
|
|
72
|
+
}
|
|
73
|
+
else {
|
|
74
|
+
const newValue = mutateFn(mapValue[key], valueType);
|
|
75
|
+
if (newValue.changed) {
|
|
76
|
+
mapValue[key] = newValue.value;
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
else if (jsonSchema.serializationType === 'array') {
|
|
82
|
+
const withItemsJsonSchema = jsonSchema;
|
|
83
|
+
const arrayValue = value;
|
|
84
|
+
const nestedMutateValues = withItemsJsonSchema.items.serializationType === 'array' || withItemsJsonSchema.items.serializationType === 'map';
|
|
85
|
+
for (let i = 0, n = arrayValue.length; i < n; i++) {
|
|
86
|
+
if (nestedMutateValues) {
|
|
87
|
+
mutateValues(withItemsJsonSchema.items, arrayValue[i], mutateFn);
|
|
88
|
+
}
|
|
89
|
+
else {
|
|
90
|
+
const newValue = mutateFn(arrayValue[i], withItemsJsonSchema.items);
|
|
91
|
+
if (newValue.changed) {
|
|
92
|
+
arrayValue[i] = newValue.value;
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
}
|
package/dist/schemas/index.d.ts
CHANGED
|
@@ -55,4 +55,21 @@ export declare namespace Schemas {
|
|
|
55
55
|
* @returns a ISchema or fail for unsupported json-schema
|
|
56
56
|
*/
|
|
57
57
|
const fromJson: (json: JsonSchemaExtended) => ISchema<unknown>;
|
|
58
|
+
/**
|
|
59
|
+
* @public
|
|
60
|
+
*
|
|
61
|
+
* Traverses and mutates values in a JSON schema-based structure, applying the given mutation function to each value.
|
|
62
|
+
* The function is designed to work with nested maps and arrays, recursively processing each element.
|
|
63
|
+
*
|
|
64
|
+
* @param jsonSchema - The JSON schema object that describes the structure of the value.
|
|
65
|
+
* It must have a serializationType of 'map', 'array', or other custom types like 'entity'.
|
|
66
|
+
* @param value - The value to be mutated, which should conform to the provided JSON schema.
|
|
67
|
+
* @param mutateFn - A function that takes a value and its corresponding valueType (JsonSchemaExtended) as arguments
|
|
68
|
+
* and returns a tuple [boolean, any]. The boolean indicates whether the mutation should be applied,
|
|
69
|
+
* and the second element is the mutated value.
|
|
70
|
+
*/
|
|
71
|
+
const mutateNestedValues: (jsonSchema: JsonSchemaExtended, value: unknown, mutateFn: (value: unknown, valueType: JsonSchemaExtended) => {
|
|
72
|
+
changed: boolean;
|
|
73
|
+
value?: any;
|
|
74
|
+
}) => void;
|
|
58
75
|
}
|
package/dist/schemas/index.js
CHANGED
|
@@ -11,7 +11,7 @@ import { QuaternionSchema } from './custom/Quaternion';
|
|
|
11
11
|
import { Vector3Schema } from './custom/Vector3';
|
|
12
12
|
import { IMap } from './Map';
|
|
13
13
|
import { IOptional } from './Optional';
|
|
14
|
-
import { jsonSchemaToSchema } from './buildSchema';
|
|
14
|
+
import { jsonSchemaToSchema, mutateValues } from './buildSchema';
|
|
15
15
|
/**
|
|
16
16
|
* @public
|
|
17
17
|
*/
|
|
@@ -61,4 +61,18 @@ export var Schemas;
|
|
|
61
61
|
* @returns a ISchema or fail for unsupported json-schema
|
|
62
62
|
*/
|
|
63
63
|
Schemas.fromJson = jsonSchemaToSchema;
|
|
64
|
+
/**
|
|
65
|
+
* @public
|
|
66
|
+
*
|
|
67
|
+
* Traverses and mutates values in a JSON schema-based structure, applying the given mutation function to each value.
|
|
68
|
+
* The function is designed to work with nested maps and arrays, recursively processing each element.
|
|
69
|
+
*
|
|
70
|
+
* @param jsonSchema - The JSON schema object that describes the structure of the value.
|
|
71
|
+
* It must have a serializationType of 'map', 'array', or other custom types like 'entity'.
|
|
72
|
+
* @param value - The value to be mutated, which should conform to the provided JSON schema.
|
|
73
|
+
* @param mutateFn - A function that takes a value and its corresponding valueType (JsonSchemaExtended) as arguments
|
|
74
|
+
* and returns a tuple [boolean, any]. The boolean indicates whether the mutation should be applied,
|
|
75
|
+
* and the second element is the mutated value.
|
|
76
|
+
*/
|
|
77
|
+
Schemas.mutateNestedValues = mutateValues;
|
|
64
78
|
})(Schemas || (Schemas = {}));
|
package/package.json
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dcl/ecs",
|
|
3
3
|
"description": "Decentraland ECS",
|
|
4
|
-
"version": "7.1.4-
|
|
4
|
+
"version": "7.1.4-4672664161.commit-7ba5d40",
|
|
5
5
|
"author": "DCL",
|
|
6
6
|
"bugs": "https://github.com/decentraland/ecs/issues",
|
|
7
7
|
"dependencies": {
|
|
8
|
-
"@dcl/js-runtime": "7.1.4-
|
|
8
|
+
"@dcl/js-runtime": "7.1.4-4672664161.commit-7ba5d40"
|
|
9
9
|
},
|
|
10
10
|
"devDependencies": {
|
|
11
11
|
"ts-proto": "^1.122.0"
|
|
@@ -34,5 +34,5 @@
|
|
|
34
34
|
},
|
|
35
35
|
"types": "./dist/index.d.ts",
|
|
36
36
|
"typings": "./dist/index.d.ts",
|
|
37
|
-
"commit": "
|
|
37
|
+
"commit": "7ba5d4034c725e90e5c8ca8e37275bbb5e20b297"
|
|
38
38
|
}
|