@dcl/ecs 7.20.2-22104870534.commit-0df3cc0 → 7.20.2-22169778016.commit-030cbfe

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.
Files changed (85) hide show
  1. package/dist/components/generated/component-names.gen.js +0 -2
  2. package/dist/components/generated/global.gen.d.ts +0 -4
  3. package/dist/components/generated/global.gen.js +0 -2
  4. package/dist/components/generated/index.gen.d.ts +0 -8
  5. package/dist/components/generated/index.gen.js +0 -10
  6. package/dist/components/generated/pb/decentraland/sdk/components/common/input_action.gen.d.ts +1 -2
  7. package/dist/components/generated/pb/decentraland/sdk/components/common/input_action.gen.js +0 -1
  8. package/dist/components/generated/pb/decentraland/sdk/components/virtual_camera.gen.d.ts +0 -3
  9. package/dist/components/generated/pb/decentraland/sdk/components/virtual_camera.gen.js +1 -10
  10. package/dist/components/index.d.ts +5 -4
  11. package/dist/components/index.js +5 -5
  12. package/dist/components/manual/CreatedBy.d.ts +9 -0
  13. package/dist/components/manual/CreatedBy.js +8 -0
  14. package/dist/components/manual/Transform.d.ts +9 -0
  15. package/dist/components/manual/Transform.js +3 -3
  16. package/dist/components/types.d.ts +1 -1
  17. package/dist/engine/component.d.ts +52 -1
  18. package/dist/engine/grow-only-value-set-component-definition.js +45 -2
  19. package/dist/engine/lww-element-set-component-definition.d.ts +3 -1
  20. package/dist/engine/lww-element-set-component-definition.js +65 -12
  21. package/dist/index.d.ts +2 -2
  22. package/dist/index.js +1 -1
  23. package/dist/serialization/crdt/authoritativePutComponent.d.ts +15 -0
  24. package/dist/serialization/crdt/authoritativePutComponent.js +47 -0
  25. package/dist/serialization/crdt/index.d.ts +1 -0
  26. package/dist/serialization/crdt/index.js +1 -0
  27. package/dist/serialization/crdt/types.d.ts +25 -3
  28. package/dist/serialization/crdt/types.js +3 -1
  29. package/dist/systems/crdt/index.d.ts +0 -1
  30. package/dist/systems/crdt/index.js +55 -146
  31. package/dist-cjs/components/generated/component-names.gen.js +0 -2
  32. package/dist-cjs/components/generated/global.gen.d.ts +0 -4
  33. package/dist-cjs/components/generated/global.gen.js +1 -3
  34. package/dist-cjs/components/generated/index.gen.d.ts +0 -8
  35. package/dist-cjs/components/generated/index.gen.js +2 -14
  36. package/dist-cjs/components/generated/pb/decentraland/sdk/components/common/input_action.gen.d.ts +1 -2
  37. package/dist-cjs/components/generated/pb/decentraland/sdk/components/common/input_action.gen.js +0 -1
  38. package/dist-cjs/components/generated/pb/decentraland/sdk/components/virtual_camera.gen.d.ts +0 -3
  39. package/dist-cjs/components/generated/pb/decentraland/sdk/components/virtual_camera.gen.js +1 -10
  40. package/dist-cjs/components/index.d.ts +5 -4
  41. package/dist-cjs/components/index.js +7 -7
  42. package/dist-cjs/components/manual/CreatedBy.d.ts +9 -0
  43. package/dist-cjs/components/manual/CreatedBy.js +10 -0
  44. package/dist-cjs/components/manual/Transform.d.ts +9 -0
  45. package/dist-cjs/components/manual/Transform.js +3 -3
  46. package/dist-cjs/components/types.d.ts +1 -1
  47. package/dist-cjs/engine/component.d.ts +52 -1
  48. package/dist-cjs/engine/grow-only-value-set-component-definition.js +44 -1
  49. package/dist-cjs/engine/lww-element-set-component-definition.d.ts +3 -1
  50. package/dist-cjs/engine/lww-element-set-component-definition.js +68 -13
  51. package/dist-cjs/index.d.ts +2 -2
  52. package/dist-cjs/index.js +2 -2
  53. package/dist-cjs/serialization/crdt/authoritativePutComponent.d.ts +15 -0
  54. package/dist-cjs/serialization/crdt/authoritativePutComponent.js +50 -0
  55. package/dist-cjs/serialization/crdt/index.d.ts +1 -0
  56. package/dist-cjs/serialization/crdt/index.js +1 -0
  57. package/dist-cjs/serialization/crdt/types.d.ts +25 -3
  58. package/dist-cjs/serialization/crdt/types.js +3 -1
  59. package/dist-cjs/systems/crdt/index.d.ts +0 -1
  60. package/dist-cjs/systems/crdt/index.js +55 -169
  61. package/package.json +2 -2
  62. package/dist/components/extended/AudioAnalysis.d.ts +0 -55
  63. package/dist/components/extended/AudioAnalysis.js +0 -66
  64. package/dist/components/generated/AudioAnalysis.gen.d.ts +0 -1
  65. package/dist/components/generated/AudioAnalysis.gen.js +0 -25
  66. package/dist/components/generated/AvatarLocomotionSettings.gen.d.ts +0 -1
  67. package/dist/components/generated/AvatarLocomotionSettings.gen.js +0 -25
  68. package/dist/components/generated/pb/decentraland/sdk/components/audio_analysis.gen.d.ts +0 -37
  69. package/dist/components/generated/pb/decentraland/sdk/components/audio_analysis.gen.js +0 -161
  70. package/dist/components/generated/pb/decentraland/sdk/components/avatar_locomotion_settings.gen.d.ts +0 -29
  71. package/dist/components/generated/pb/decentraland/sdk/components/avatar_locomotion_settings.gen.js +0 -93
  72. package/dist/serialization/crdt/network/utils.d.ts +0 -9
  73. package/dist/serialization/crdt/network/utils.js +0 -60
  74. package/dist-cjs/components/extended/AudioAnalysis.d.ts +0 -55
  75. package/dist-cjs/components/extended/AudioAnalysis.js +0 -70
  76. package/dist-cjs/components/generated/AudioAnalysis.gen.d.ts +0 -1
  77. package/dist-cjs/components/generated/AudioAnalysis.gen.js +0 -28
  78. package/dist-cjs/components/generated/AvatarLocomotionSettings.gen.d.ts +0 -1
  79. package/dist-cjs/components/generated/AvatarLocomotionSettings.gen.js +0 -28
  80. package/dist-cjs/components/generated/pb/decentraland/sdk/components/audio_analysis.gen.d.ts +0 -37
  81. package/dist-cjs/components/generated/pb/decentraland/sdk/components/audio_analysis.gen.js +0 -167
  82. package/dist-cjs/components/generated/pb/decentraland/sdk/components/avatar_locomotion_settings.gen.d.ts +0 -29
  83. package/dist-cjs/components/generated/pb/decentraland/sdk/components/avatar_locomotion_settings.gen.js +0 -99
  84. package/dist-cjs/serialization/crdt/network/utils.d.ts +0 -9
  85. package/dist-cjs/serialization/crdt/network/utils.js +0 -67
@@ -1,50 +1,20 @@
1
1
  "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || function (mod) {
19
- if (mod && mod.__esModule) return mod;
20
- var result = {};
21
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
- __setModuleDefault(result, mod);
23
- return result;
24
- };
25
2
  Object.defineProperty(exports, "__esModule", { value: true });
26
- exports.crdtSceneSystem = exports.LIVEKIT_MAX_SIZE = void 0;
3
+ exports.crdtSceneSystem = void 0;
27
4
  const entity_1 = require("../../engine/entity");
28
5
  const ByteBuffer_1 = require("../../serialization/ByteBuffer");
29
6
  const crdt_1 = require("../../serialization/crdt");
30
7
  const deleteComponent_1 = require("../../serialization/crdt/deleteComponent");
31
8
  const deleteEntity_1 = require("../../serialization/crdt/deleteEntity");
32
9
  const putComponent_1 = require("../../serialization/crdt/putComponent");
10
+ const authoritativePutComponent_1 = require("../../serialization/crdt/authoritativePutComponent");
33
11
  const types_1 = require("../../serialization/crdt/types");
34
- const putComponentNetwork_1 = require("../../serialization/crdt/network/putComponentNetwork");
35
- const components_1 = require("../../components");
36
- const networkUtils = __importStar(require("../../serialization/crdt/network/utils"));
37
- // NetworkMessages can only have a MAX_SIZE of 12kb. So we need to send it in chunks.
38
- exports.LIVEKIT_MAX_SIZE = 12;
39
12
  /**
40
13
  * @internal
41
14
  */
42
15
  function crdtSceneSystem(engine, onProcessEntityComponentChange) {
43
16
  const transports = [];
44
- // Components that we used on this system
45
- const NetworkEntity = (0, components_1.NetworkEntity)(engine);
46
- const NetworkParent = (0, components_1.NetworkParent)(engine);
47
- const Transform = (0, components_1.Transform)(engine);
17
+ // No network components needed - pure CRDT processing only
48
18
  // Messages that we received at transport.onMessage waiting to be processed
49
19
  const receivedMessages = [];
50
20
  // Messages already processed by the engine but that we need to broadcast to other transports.
@@ -69,27 +39,20 @@ function crdtSceneSystem(engine, onProcessEntityComponentChange) {
69
39
  if (header.type === types_1.CrdtMessageType.DELETE_COMPONENT) {
70
40
  message = deleteComponent_1.DeleteComponent.read(buffer);
71
41
  }
72
- else if (header.type === types_1.CrdtMessageType.DELETE_COMPONENT_NETWORK) {
73
- message = crdt_1.DeleteComponentNetwork.read(buffer);
74
- }
75
42
  else if (header.type === types_1.CrdtMessageType.PUT_COMPONENT) {
76
43
  message = putComponent_1.PutComponentOperation.read(buffer);
77
44
  }
78
- else if (header.type === types_1.CrdtMessageType.PUT_COMPONENT_NETWORK) {
79
- message = putComponentNetwork_1.PutNetworkComponentOperation.read(buffer);
45
+ else if (header.type === types_1.CrdtMessageType.AUTHORITATIVE_PUT_COMPONENT) {
46
+ message = authoritativePutComponent_1.AuthoritativePutComponentOperation.read(buffer);
80
47
  }
81
48
  else if (header.type === types_1.CrdtMessageType.DELETE_ENTITY) {
82
49
  message = deleteEntity_1.DeleteEntity.read(buffer);
83
50
  }
84
- else if (header.type === types_1.CrdtMessageType.DELETE_ENTITY_NETWORK) {
85
- message = crdt_1.DeleteEntityNetwork.read(buffer);
86
- }
87
51
  else if (header.type === types_1.CrdtMessageType.APPEND_VALUE) {
88
52
  message = crdt_1.AppendValueOperation.read(buffer);
89
- // Unknown message, we skip it
90
53
  }
91
54
  else {
92
- // consume the message
55
+ // Unknown message, we skip it (including NETWORK messages)
93
56
  buffer.incrementReadOffset(header.length);
94
57
  }
95
58
  if (message) {
@@ -110,22 +73,6 @@ function crdtSceneSystem(engine, onProcessEntityComponentChange) {
110
73
  const messagesToProcess = value.splice(0, value.length);
111
74
  return messagesToProcess;
112
75
  }
113
- /**
114
- * Find the local entityId associated to the network component message.
115
- * It's a mapping Network -> to Local
116
- * If it's not a network message, return the entityId received by the message
117
- */
118
- function findNetworkId(msg) {
119
- const hasNetworkId = 'networkId' in msg;
120
- if (hasNetworkId) {
121
- for (const [entityId, network] of engine.getEntitiesWith(NetworkEntity)) {
122
- if (network.networkId === msg.networkId && network.entityId === msg.entityId) {
123
- return { entityId, network };
124
- }
125
- }
126
- }
127
- return { entityId: msg.entityId };
128
- }
129
76
  /**
130
77
  * This fn will be called on every tick.
131
78
  * Process all the messages queue received by the transport
@@ -134,46 +81,52 @@ function crdtSceneSystem(engine, onProcessEntityComponentChange) {
134
81
  const messagesToProcess = getMessages(receivedMessages);
135
82
  const entitiesShouldBeCleaned = [];
136
83
  for (const msg of messagesToProcess) {
137
- let { entityId, network } = findNetworkId(msg);
138
- // We receive a new Entity. Create the localEntity and map it to the NetworkEntity component
139
- if (networkUtils.isNetworkMessage(msg) && !network) {
140
- entityId = engine.addEntity();
141
- network = { entityId: msg.entityId, networkId: msg.networkId };
142
- NetworkEntity.createOrReplace(entityId, network);
143
- }
144
- if (msg.type === types_1.CrdtMessageType.DELETE_ENTITY || msg.type === types_1.CrdtMessageType.DELETE_ENTITY_NETWORK) {
145
- entitiesShouldBeCleaned.push(entityId);
84
+ // Simple CRDT processing - no network logic
85
+ if (msg.type === types_1.CrdtMessageType.DELETE_ENTITY) {
86
+ entitiesShouldBeCleaned.push(msg.entityId);
146
87
  broadcastMessages.push(msg);
147
88
  }
148
89
  else {
149
- const entityState = engine.entityContainer.getEntityState(entityId);
150
- // Skip updates from removed entityes
90
+ const entityState = engine.entityContainer.getEntityState(msg.entityId);
91
+ // Skip updates from removed entities
151
92
  if (entityState === entity_1.EntityState.Removed)
152
93
  continue;
153
- // Entities with unknown entities should update its entity state
94
+ // Entities with unknown state should update its entity state
154
95
  if (entityState === entity_1.EntityState.Unknown) {
155
- engine.entityContainer.updateUsedEntity(entityId);
156
- }
157
- const component = engine.getComponentOrNull(msg.componentId);
158
- /* istanbul ignore else */
159
- if (component) {
160
- if (msg.type === types_1.CrdtMessageType.PUT_COMPONENT &&
161
- component.componentId === Transform.componentId &&
162
- NetworkEntity.has(entityId) &&
163
- NetworkParent.has(entityId)) {
164
- msg.data = networkUtils.fixTransformParent(msg);
96
+ engine.entityContainer.updateUsedEntity(msg.entityId);
97
+ }
98
+ // Only process component-related messages (not DELETE_ENTITY)
99
+ if ('componentId' in msg) {
100
+ const component = engine.getComponentOrNull(msg.componentId);
101
+ if (component) {
102
+ // Handle authoritative messages differently - they force the state regardless of timestamp
103
+ const tryUpdate = () => {
104
+ try {
105
+ return msg.type === types_1.CrdtMessageType.AUTHORITATIVE_PUT_COMPONENT
106
+ ? component.__forceUpdateFromCrdt(msg)
107
+ : component.updateFromCrdt(msg);
108
+ }
109
+ catch (e) {
110
+ console.error('[receiveMessages] ERROR processing message', msg, e);
111
+ return null;
112
+ }
113
+ };
114
+ const result = tryUpdate();
115
+ if (!result)
116
+ continue;
117
+ const [conflictMessage, value] = result;
118
+ if (!conflictMessage) {
119
+ // Add message to broadcast queue when no conflict
120
+ broadcastMessages.push(msg);
121
+ onProcessEntityComponentChange && onProcessEntityComponentChange(msg.entityId, msg.type, component, value);
122
+ }
165
123
  }
166
- const [conflictMessage, value] = component.updateFromCrdt({ ...msg, entityId });
167
- if (!conflictMessage) {
168
- // Add message to transport queue to be processed by others transports
124
+ else {
125
+ // Component not found - still broadcast for editor compatibility
126
+ /* istanbul ignore next */
169
127
  broadcastMessages.push(msg);
170
- onProcessEntityComponentChange && onProcessEntityComponentChange(entityId, msg.type, component, value);
171
128
  }
172
129
  }
173
- else {
174
- // TODO: test this line, it is fundammental to make the editor work
175
- broadcastMessages.push(msg);
176
- }
177
130
  }
178
131
  }
179
132
  // the last stage of the syncrhonization is to delete the entities
@@ -187,16 +140,17 @@ function crdtSceneSystem(engine, onProcessEntityComponentChange) {
187
140
  }
188
141
  }
189
142
  /**
190
- * Iterates the dirty map and generates crdt messages to be send
143
+ * Simple CRDT message broadcasting - no network-specific logic
191
144
  */
192
145
  async function sendMessages(entitiesDeletedThisTick) {
193
- // CRDT Messages will be the merge between the recieved transport messages and the new crdt messages
146
+ // Get messages from broadcast queue and component updates
194
147
  const crdtMessages = getMessages(broadcastMessages);
195
148
  const buffer = new ByteBuffer_1.ReadWriteByteBuffer();
149
+ // Generate CRDT messages from component updates
196
150
  for (const component of engine.componentsIter()) {
197
151
  for (const message of component.getCrdtUpdates()) {
198
152
  const offset = buffer.currentWriteOffset();
199
- // Avoid creating messages if there is no transport that will handle it
153
+ // Only create messages if there's a transport that will handle it
200
154
  if (transports.some((t) => t.filter(message))) {
201
155
  if (message.type === types_1.CrdtMessageType.PUT_COMPONENT) {
202
156
  putComponent_1.PutComponentOperation.write(message.entityId, message.timestamp, message.componentId, message.data, buffer);
@@ -220,7 +174,7 @@ function crdtSceneSystem(engine, onProcessEntityComponentChange) {
220
174
  }
221
175
  }
222
176
  }
223
- // After all updates, I execute the DeletedEntity messages
177
+ // Handle deleted entities
224
178
  for (const entityId of entitiesDeletedThisTick) {
225
179
  const offset = buffer.currentWriteOffset();
226
180
  deleteEntity_1.DeleteEntity.write(entityId, buffer);
@@ -231,87 +185,19 @@ function crdtSceneSystem(engine, onProcessEntityComponentChange) {
231
185
  });
232
186
  onProcessEntityComponentChange && onProcessEntityComponentChange(entityId, types_1.CrdtMessageType.DELETE_ENTITY);
233
187
  }
234
- // Send CRDT messages to transports
235
- const transportBuffer = new ByteBuffer_1.ReadWriteByteBuffer();
236
- for (const index in transports) {
237
- const __NetworkMessagesBuffer = [];
238
- const transportIndex = Number(index);
239
- const transport = transports[transportIndex];
240
- const isRendererTransport = transport.type === 'renderer';
241
- const isNetworkTransport = transport.type === 'network';
242
- // Reset Buffer for each Transport
243
- transportBuffer.resetBuffer();
244
- const buffer = new ByteBuffer_1.ReadWriteByteBuffer();
245
- // Then we send all the new crdtMessages that the transport needs to process
188
+ // Simple transport broadcasting - no network-specific transforms
189
+ for (const transport of transports) {
190
+ const transportBuffer = new ByteBuffer_1.ReadWriteByteBuffer();
246
191
  for (const message of crdtMessages) {
247
- // Check if adding this message would exceed the size limit
248
- const currentBufferSize = transportBuffer.toBinary().byteLength;
249
- const messageSize = message.messageBuffer.byteLength;
250
- if (isNetworkTransport && (currentBufferSize + messageSize) / 1024 > exports.LIVEKIT_MAX_SIZE) {
251
- // If the current buffer has content, save it as a chunk
252
- if (currentBufferSize > 0) {
253
- __NetworkMessagesBuffer.push(transportBuffer.toCopiedBinary());
254
- transportBuffer.resetBuffer();
255
- }
256
- // If the message itself is larger than the limit, we need to handle it specially
257
- // For now, we'll skip it to prevent infinite loops
258
- if (messageSize / 1024 > exports.LIVEKIT_MAX_SIZE) {
259
- console.error(`Message too large (${messageSize} bytes), skipping message for entity ${message.entityId}`);
260
- continue;
261
- }
262
- }
263
192
  // Avoid echo messages
264
- if (message.transportId === transportIndex)
265
- continue;
266
- // Redundant message for the transport
267
- if (!transport.filter(message))
268
- continue;
269
- const { entityId } = findNetworkId(message);
270
- const transformNeedsFix = 'componentId' in message &&
271
- message.componentId === Transform.componentId &&
272
- Transform.has(entityId) &&
273
- NetworkParent.has(entityId) &&
274
- NetworkEntity.has(entityId);
275
- // If there was a LOCAL change in the transform. Add the parent to that transform
276
- if (isRendererTransport && message.type === types_1.CrdtMessageType.PUT_COMPONENT && transformNeedsFix) {
277
- const parent = findNetworkId(NetworkParent.get(entityId));
278
- const transformData = networkUtils.fixTransformParent(message, Transform.get(entityId), parent.entityId);
279
- const offset = buffer.currentWriteOffset();
280
- putComponent_1.PutComponentOperation.write(entityId, message.timestamp, message.componentId, transformData, buffer);
281
- transportBuffer.writeBuffer(buffer.buffer().subarray(offset, buffer.currentWriteOffset()), false);
193
+ if (message.transportId === transports.indexOf(transport))
282
194
  continue;
195
+ // Check if transport wants this message
196
+ if (transport.filter(message)) {
197
+ transportBuffer.writeBuffer(message.messageBuffer, false);
283
198
  }
284
- if (isRendererTransport && networkUtils.isNetworkMessage(message)) {
285
- // If it's the renderer transport and its a NetworkMessage, we need to fix the entityId field and convert it to a known Message.
286
- // PUT_NETWORK_COMPONENT -> PUT_COMPONENT
287
- let transformData = 'data' in message ? message.data : new Uint8Array();
288
- if (transformNeedsFix) {
289
- const parent = findNetworkId(NetworkParent.get(entityId));
290
- transformData = networkUtils.fixTransformParent(message, Transform.get(entityId), parent.entityId);
291
- }
292
- networkUtils.networkMessageToLocal({ ...message, data: transformData }, entityId, buffer, transportBuffer);
293
- // Iterate the next message
294
- continue;
295
- }
296
- // If its a network transport and its a PUT_COMPONENT that has a NetworkEntity component, we need to send this message
297
- // through comms with the EntityID and NetworkID from ther NetworkEntity so everyone can recieve this message and map to their custom entityID.
298
- if (isNetworkTransport && !networkUtils.isNetworkMessage(message)) {
299
- const networkData = NetworkEntity.getOrNull(message.entityId);
300
- // If it has networkData convert the message to PUT_NETWORK_COMPONENT.
301
- if (networkData) {
302
- networkUtils.localMessageToNetwork(message, networkData, buffer, transportBuffer);
303
- // Iterate the next message
304
- continue;
305
- }
306
- }
307
- // Common message
308
- transportBuffer.writeBuffer(message.messageBuffer, false);
309
- }
310
- if (isNetworkTransport && transportBuffer.currentWriteOffset()) {
311
- __NetworkMessagesBuffer.push(transportBuffer.toBinary());
312
199
  }
313
- const message = isNetworkTransport ? __NetworkMessagesBuffer : transportBuffer.toBinary();
314
- await transport.send(message);
200
+ await transport.send(transportBuffer.toBinary());
315
201
  }
316
202
  }
317
203
  /**
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@dcl/ecs",
3
3
  "description": "Decentraland ECS",
4
- "version": "7.20.2-22104870534.commit-0df3cc0",
4
+ "version": "7.20.2-22169778016.commit-030cbfe",
5
5
  "author": "DCL",
6
6
  "bugs": "https://github.com/decentraland/ecs/issues",
7
7
  "files": [
@@ -33,5 +33,5 @@
33
33
  },
34
34
  "types": "./dist/index.d.ts",
35
35
  "typings": "./dist/index.d.ts",
36
- "commit": "0df3cc09f672669cf4f67ffc4f9946ca5b3ebeb7"
36
+ "commit": "030cbfee8a40495d9916ade20280282e63e3cc8b"
37
37
  }
@@ -1,55 +0,0 @@
1
- import { Entity, IEngine } from '../../engine';
2
- import { LastWriteWinElementSetComponentDefinition } from '../../engine/component';
3
- import { PBAudioAnalysis, PBAudioAnalysisMode } from '../generated/pb/decentraland/sdk/components/audio_analysis.gen';
4
- export interface AudioAnalysisComponentDefinitionExtended extends LastWriteWinElementSetComponentDefinition<PBAudioAnalysis> {
5
- /**
6
- * Reads the component data of `entity` into the provided `out` view.
7
- *
8
- * @throws Error if the entity does not have an AudioAnalysis component.
9
- * @param entity - The entity whose AudioAnalysis data will be read.
10
- * @param out - An existing AudioAnalysisView to populate with the latest values.
11
- */
12
- readIntoView(entity: Entity, out: AudioAnalysisView): void;
13
- /**
14
- * Attempts to read the component data of `entity` into the provided `out` view.
15
- *
16
- * @returns `true` if the component exists and data was written into `out`,
17
- * `false` if the entity does not have an AudioAnalysis component.
18
- * @param entity - The entity whose AudioAnalysis data will be read.
19
- * @param out - An existing AudioAnalysisView to populate.
20
- */
21
- tryReadIntoView(entity: Entity, out: AudioAnalysisView): boolean;
22
- /**
23
- * Creates an AudioAnalysis component for the given `entity`.
24
- *
25
- * If a component already exists on the entity, this call fails (does not replace).
26
- *
27
- * @param entity - The entity to attach the component to.
28
- * @param mode - Analysis mode. Defaults to `PBAudioAnalysisMode.MODE_LOGARITHMIC`.
29
- * @param amplitudeGain - Optional amplitude gain multiplier.
30
- * @param bandsGain - Optional gain multiplier applied to all frequency bands.
31
- */
32
- createAudioAnalysis(entity: Entity, mode?: PBAudioAnalysisMode, // default is PBAudioAnalysisMode.MODE_LOGARITHMIC
33
- amplitudeGain?: number, bandsGain?: number): void;
34
- /**
35
- * Creates the AudioAnalysis component if missing, or replaces the existing one.
36
- *
37
- * @param entity - The target entity.
38
- * @param mode - Analysis mode. Defaults to `PBAudioAnalysisMode.MODE_LOGARITHMIC`.
39
- * @param amplitudeGain - Optional amplitude gain multiplier.
40
- * @param bandsGain - Optional gain multiplier applied to the frequency bands.
41
- */
42
- createOrReplaceAudioAnalysis(entity: Entity, mode?: PBAudioAnalysisMode, // default is PBAudioAnalysisMode.MODE_LOGARITHMIC
43
- amplitudeGain?: number, bandsGain?: number): void;
44
- }
45
- /**
46
- * A read-only JavaScript-friendly view of AudioAnalysis ECS data.
47
- *
48
- * `amplitude` represents the aggregated signal strength.
49
- * `bands` represents the processed frequency bands.
50
- */
51
- export type AudioAnalysisView = {
52
- amplitude: number;
53
- bands: number[];
54
- };
55
- export declare function defineAudioAnalysisComponent(engine: Pick<IEngine, 'defineComponentFromSchema'>): AudioAnalysisComponentDefinitionExtended;
@@ -1,66 +0,0 @@
1
- import { AudioAnalysis } from '../generated/index.gen';
2
- export function defineAudioAnalysisComponent(engine) {
3
- const theComponent = AudioAnalysis(engine);
4
- return {
5
- ...theComponent,
6
- readIntoView(entity, out) {
7
- const audioAnalysis = theComponent.get(entity);
8
- out.amplitude = audioAnalysis.amplitude;
9
- out.bands[0] = audioAnalysis.band0;
10
- out.bands[1] = audioAnalysis.band1;
11
- out.bands[2] = audioAnalysis.band2;
12
- out.bands[3] = audioAnalysis.band3;
13
- out.bands[4] = audioAnalysis.band4;
14
- out.bands[5] = audioAnalysis.band5;
15
- out.bands[6] = audioAnalysis.band6;
16
- out.bands[7] = audioAnalysis.band7;
17
- },
18
- tryReadIntoView(entity, out) {
19
- const audioAnalysis = theComponent.getOrNull(entity);
20
- if (!audioAnalysis)
21
- return false;
22
- out.amplitude = audioAnalysis.amplitude;
23
- out.bands[0] = audioAnalysis.band0;
24
- out.bands[1] = audioAnalysis.band1;
25
- out.bands[2] = audioAnalysis.band2;
26
- out.bands[3] = audioAnalysis.band3;
27
- out.bands[4] = audioAnalysis.band4;
28
- out.bands[5] = audioAnalysis.band5;
29
- out.bands[6] = audioAnalysis.band6;
30
- out.bands[7] = audioAnalysis.band7;
31
- return true;
32
- },
33
- createAudioAnalysis(entity, mode, amplitudeGain, bandsGain) {
34
- theComponent.create(entity, {
35
- mode: mode || 1 /* PBAudioAnalysisMode.MODE_LOGARITHMIC */,
36
- amplitudeGain: amplitudeGain ?? undefined,
37
- bandsGain: bandsGain ?? undefined,
38
- amplitude: 0,
39
- band0: 0,
40
- band1: 0,
41
- band2: 0,
42
- band3: 0,
43
- band4: 0,
44
- band5: 0,
45
- band6: 0,
46
- band7: 0
47
- });
48
- },
49
- createOrReplaceAudioAnalysis(entity, mode, amplitudeGain, bandsGain) {
50
- theComponent.createOrReplace(entity, {
51
- mode: mode || 1 /* PBAudioAnalysisMode.MODE_LOGARITHMIC */,
52
- amplitudeGain: amplitudeGain ?? undefined,
53
- bandsGain: bandsGain ?? undefined,
54
- amplitude: 0,
55
- band0: 0,
56
- band1: 0,
57
- band2: 0,
58
- band3: 0,
59
- band4: 0,
60
- band5: 0,
61
- band6: 0,
62
- band7: 0
63
- });
64
- }
65
- };
66
- }
@@ -1 +0,0 @@
1
- export {};
@@ -1,25 +0,0 @@
1
- import { PBAudioAnalysis } from './pb/decentraland/sdk/components/audio_analysis.gen';
2
- /**
3
- * @internal
4
- */
5
- export const AudioAnalysisSchema = {
6
- COMPONENT_ID: 1212,
7
- serialize(value, builder) {
8
- const writer = PBAudioAnalysis.encode(value);
9
- const buffer = new Uint8Array(writer.finish(), 0, writer.len);
10
- builder.writeBuffer(buffer, false);
11
- },
12
- deserialize(reader) {
13
- return PBAudioAnalysis.decode(reader.buffer(), reader.remainingBytes());
14
- },
15
- create() {
16
- // TODO: this is a hack.
17
- return PBAudioAnalysis.decode(new Uint8Array());
18
- },
19
- jsonSchema: {
20
- type: "object",
21
- properties: {},
22
- serializationType: "protocol-buffer",
23
- protocolBuffer: "PBAudioAnalysis"
24
- }
25
- };
@@ -1,25 +0,0 @@
1
- import { PBAvatarLocomotionSettings } from './pb/decentraland/sdk/components/avatar_locomotion_settings.gen';
2
- /**
3
- * @internal
4
- */
5
- export const AvatarLocomotionSettingsSchema = {
6
- COMPONENT_ID: 1211,
7
- serialize(value, builder) {
8
- const writer = PBAvatarLocomotionSettings.encode(value);
9
- const buffer = new Uint8Array(writer.finish(), 0, writer.len);
10
- builder.writeBuffer(buffer, false);
11
- },
12
- deserialize(reader) {
13
- return PBAvatarLocomotionSettings.decode(reader.buffer(), reader.remainingBytes());
14
- },
15
- create() {
16
- // TODO: this is a hack.
17
- return PBAvatarLocomotionSettings.decode(new Uint8Array());
18
- },
19
- jsonSchema: {
20
- type: "object",
21
- properties: {},
22
- serializationType: "protocol-buffer",
23
- protocolBuffer: "PBAvatarLocomotionSettings"
24
- }
25
- };
@@ -1,37 +0,0 @@
1
- import _m0 from "protobufjs/minimal";
2
- /**
3
- * @public
4
- */
5
- export declare const enum PBAudioAnalysisMode {
6
- MODE_RAW = 0,
7
- MODE_LOGARITHMIC = 1
8
- }
9
- /**
10
- * @public
11
- */
12
- export interface PBAudioAnalysis {
13
- /** Parameters section */
14
- mode: PBAudioAnalysisMode;
15
- /** Used only when mode == MODE_LOGARITHMIC */
16
- amplitudeGain?: number | undefined;
17
- /** End when mode == MODE_LOGARITHMIC */
18
- bandsGain?: number | undefined;
19
- /** Result section */
20
- amplitude: number;
21
- /** Protobuf doesn't support fixed arrays -> 8 band fields */
22
- band0: number;
23
- band1: number;
24
- band2: number;
25
- band3: number;
26
- band4: number;
27
- band5: number;
28
- band6: number;
29
- band7: number;
30
- }
31
- /**
32
- * @public
33
- */
34
- export declare namespace PBAudioAnalysis {
35
- function encode(message: PBAudioAnalysis, writer?: _m0.Writer): _m0.Writer;
36
- function decode(input: _m0.Reader | Uint8Array, length?: number): PBAudioAnalysis;
37
- }