@dcl/playground-assets 7.0.6-3874914632.commit-eb56237 → 7.0.6-3942933325.commit-70f967f

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.js CHANGED
@@ -12390,34 +12390,34 @@
12390
12390
  }
12391
12391
  };
12392
12392
 
12393
- /** @public */ const Animator$2 = engine => engine.defineComponentFromSchema(AnimatorSchema, AnimatorSchema.COMPONENT_ID);
12394
- /** @public */ const AudioSource$1 = engine => engine.defineComponentFromSchema(AudioSourceSchema, AudioSourceSchema.COMPONENT_ID);
12395
- /** @public */ const AudioStream$1 = engine => engine.defineComponentFromSchema(AudioStreamSchema, AudioStreamSchema.COMPONENT_ID);
12396
- /** @public */ const AvatarAttach$1 = engine => engine.defineComponentFromSchema(AvatarAttachSchema, AvatarAttachSchema.COMPONENT_ID);
12397
- /** @public */ const AvatarModifierArea$1 = engine => engine.defineComponentFromSchema(AvatarModifierAreaSchema, AvatarModifierAreaSchema.COMPONENT_ID);
12398
- /** @public */ const AvatarShape$1 = engine => engine.defineComponentFromSchema(AvatarShapeSchema, AvatarShapeSchema.COMPONENT_ID);
12399
- /** @public */ const Billboard$1 = engine => engine.defineComponentFromSchema(BillboardSchema, BillboardSchema.COMPONENT_ID);
12400
- /** @public */ const CameraMode$1 = engine => engine.defineComponentFromSchema(CameraModeSchema, CameraModeSchema.COMPONENT_ID);
12401
- /** @public */ const CameraModeArea$1 = engine => engine.defineComponentFromSchema(CameraModeAreaSchema, CameraModeAreaSchema.COMPONENT_ID);
12402
- /** @public */ const GltfContainer$1 = engine => engine.defineComponentFromSchema(GltfContainerSchema, GltfContainerSchema.COMPONENT_ID);
12403
- /** @public */ const Material$2 = engine => engine.defineComponentFromSchema(MaterialSchema, MaterialSchema.COMPONENT_ID);
12404
- /** @public */ const MeshCollider$2 = engine => engine.defineComponentFromSchema(MeshColliderSchema, MeshColliderSchema.COMPONENT_ID);
12405
- /** @public */ const MeshRenderer$2 = engine => engine.defineComponentFromSchema(MeshRendererSchema, MeshRendererSchema.COMPONENT_ID);
12406
- /** @public */ const NftShape$1 = engine => engine.defineComponentFromSchema(NftShapeSchema, NftShapeSchema.COMPONENT_ID);
12407
- /** @public */ const PointerEvents$1 = engine => engine.defineComponentFromSchema(PointerEventsSchema, PointerEventsSchema.COMPONENT_ID);
12408
- /** @public */ const PointerEventsResult$1 = engine => engine.defineComponentFromSchema(PointerEventsResultSchema, PointerEventsResultSchema.COMPONENT_ID);
12409
- /** @public */ const PointerLock$1 = engine => engine.defineComponentFromSchema(PointerLockSchema, PointerLockSchema.COMPONENT_ID);
12410
- /** @public */ const Raycast$1 = engine => engine.defineComponentFromSchema(RaycastSchema, RaycastSchema.COMPONENT_ID);
12411
- /** @public */ const RaycastResult$1 = engine => engine.defineComponentFromSchema(RaycastResultSchema, RaycastResultSchema.COMPONENT_ID);
12412
- /** @public */ const TextShape$1 = engine => engine.defineComponentFromSchema(TextShapeSchema, TextShapeSchema.COMPONENT_ID);
12413
- /** @public */ const UiBackground$1 = engine => engine.defineComponentFromSchema(UiBackgroundSchema, UiBackgroundSchema.COMPONENT_ID);
12414
- /** @public */ const UiDropdown$1 = engine => engine.defineComponentFromSchema(UiDropdownSchema, UiDropdownSchema.COMPONENT_ID);
12415
- /** @public */ const UiDropdownResult$1 = engine => engine.defineComponentFromSchema(UiDropdownResultSchema, UiDropdownResultSchema.COMPONENT_ID);
12416
- /** @public */ const UiInput$1 = engine => engine.defineComponentFromSchema(UiInputSchema, UiInputSchema.COMPONENT_ID);
12417
- /** @public */ const UiInputResult$1 = engine => engine.defineComponentFromSchema(UiInputResultSchema, UiInputResultSchema.COMPONENT_ID);
12418
- /** @public */ const UiText$1 = engine => engine.defineComponentFromSchema(UiTextSchema, UiTextSchema.COMPONENT_ID);
12419
- /** @public */ const UiTransform$1 = engine => engine.defineComponentFromSchema(UiTransformSchema, UiTransformSchema.COMPONENT_ID);
12420
- /** @public */ const VisibilityComponent$1 = engine => engine.defineComponentFromSchema(VisibilityComponentSchema, VisibilityComponentSchema.COMPONENT_ID);
12393
+ /** @public */ const Animator$2 = engine => engine.defineComponentFromSchema("core::Animator", AnimatorSchema);
12394
+ /** @public */ const AudioSource$1 = engine => engine.defineComponentFromSchema("core::AudioSource", AudioSourceSchema);
12395
+ /** @public */ const AudioStream$1 = engine => engine.defineComponentFromSchema("core::AudioStream", AudioStreamSchema);
12396
+ /** @public */ const AvatarAttach$1 = engine => engine.defineComponentFromSchema("core::AvatarAttach", AvatarAttachSchema);
12397
+ /** @public */ const AvatarModifierArea$1 = engine => engine.defineComponentFromSchema("core::AvatarModifierArea", AvatarModifierAreaSchema);
12398
+ /** @public */ const AvatarShape$1 = engine => engine.defineComponentFromSchema("core::AvatarShape", AvatarShapeSchema);
12399
+ /** @public */ const Billboard$1 = engine => engine.defineComponentFromSchema("core::Billboard", BillboardSchema);
12400
+ /** @public */ const CameraMode$1 = engine => engine.defineComponentFromSchema("core::CameraMode", CameraModeSchema);
12401
+ /** @public */ const CameraModeArea$1 = engine => engine.defineComponentFromSchema("core::CameraModeArea", CameraModeAreaSchema);
12402
+ /** @public */ const GltfContainer$1 = engine => engine.defineComponentFromSchema("core::GltfContainer", GltfContainerSchema);
12403
+ /** @public */ const Material$2 = engine => engine.defineComponentFromSchema("core::Material", MaterialSchema);
12404
+ /** @public */ const MeshCollider$2 = engine => engine.defineComponentFromSchema("core::MeshCollider", MeshColliderSchema);
12405
+ /** @public */ const MeshRenderer$2 = engine => engine.defineComponentFromSchema("core::MeshRenderer", MeshRendererSchema);
12406
+ /** @public */ const NftShape$1 = engine => engine.defineComponentFromSchema("core::NftShape", NftShapeSchema);
12407
+ /** @public */ const PointerEvents$1 = engine => engine.defineComponentFromSchema("core::PointerEvents", PointerEventsSchema);
12408
+ /** @public */ const PointerEventsResult$1 = engine => engine.defineComponentFromSchema("core::PointerEventsResult", PointerEventsResultSchema);
12409
+ /** @public */ const PointerLock$1 = engine => engine.defineComponentFromSchema("core::PointerLock", PointerLockSchema);
12410
+ /** @public */ const Raycast$1 = engine => engine.defineComponentFromSchema("core::Raycast", RaycastSchema);
12411
+ /** @public */ const RaycastResult$1 = engine => engine.defineComponentFromSchema("core::RaycastResult", RaycastResultSchema);
12412
+ /** @public */ const TextShape$1 = engine => engine.defineComponentFromSchema("core::TextShape", TextShapeSchema);
12413
+ /** @public */ const UiBackground$1 = engine => engine.defineComponentFromSchema("core::UiBackground", UiBackgroundSchema);
12414
+ /** @public */ const UiDropdown$1 = engine => engine.defineComponentFromSchema("core::UiDropdown", UiDropdownSchema);
12415
+ /** @public */ const UiDropdownResult$1 = engine => engine.defineComponentFromSchema("core::UiDropdownResult", UiDropdownResultSchema);
12416
+ /** @public */ const UiInput$1 = engine => engine.defineComponentFromSchema("core::UiInput", UiInputSchema);
12417
+ /** @public */ const UiInputResult$1 = engine => engine.defineComponentFromSchema("core::UiInputResult", UiInputResultSchema);
12418
+ /** @public */ const UiText$1 = engine => engine.defineComponentFromSchema("core::UiText", UiTextSchema);
12419
+ /** @public */ const UiTransform$1 = engine => engine.defineComponentFromSchema("core::UiTransform", UiTransformSchema);
12420
+ /** @public */ const VisibilityComponent$1 = engine => engine.defineComponentFromSchema("core::VisibilityComponent", VisibilityComponentSchema);
12421
12421
 
12422
12422
  function defineAnimatorComponent(engine) {
12423
12423
  const theComponent = Animator$2(engine);
@@ -12590,7 +12590,6 @@
12590
12590
  /**
12591
12591
  * @internal
12592
12592
  */
12593
- const COMPONENT_ID = 1;
12594
12593
  /** @internal */
12595
12594
  const TRANSFORM_LENGTH = 44;
12596
12595
  /** @internal */
@@ -12648,7 +12647,7 @@
12648
12647
  }
12649
12648
  };
12650
12649
  function defineTransformComponent(engine) {
12651
- const transformDef = engine.defineComponentFromSchema(TransformSchema, COMPONENT_ID);
12650
+ const transformDef = engine.defineComponentFromSchema('core::Transform', TransformSchema);
12652
12651
  return {
12653
12652
  ...transformDef,
12654
12653
  create(entity, val) {
@@ -12764,6 +12763,114 @@
12764
12763
  VisibilityComponent: VisibilityComponent$1
12765
12764
  });
12766
12765
 
12766
+ /**
12767
+ * Autogenerated mapping of core components to their component numbers
12768
+ */
12769
+ const coreComponentMappings = {
12770
+ "core::Transform": 1,
12771
+ "core::Animator": 1042,
12772
+ "core::AudioSource": 1020,
12773
+ "core::AudioStream": 1021,
12774
+ "core::AvatarAttach": 1073,
12775
+ "core::AvatarModifierArea": 1070,
12776
+ "core::AvatarShape": 1080,
12777
+ "core::Billboard": 1090,
12778
+ "core::CameraMode": 1072,
12779
+ "core::CameraModeArea": 1071,
12780
+ "core::GltfContainer": 1041,
12781
+ "core::Material": 1017,
12782
+ "core::MeshCollider": 1019,
12783
+ "core::MeshRenderer": 1018,
12784
+ "core::NftShape": 1040,
12785
+ "core::PointerEvents": 1062,
12786
+ "core::PointerEventsResult": 1063,
12787
+ "core::PointerLock": 1074,
12788
+ "core::Raycast": 1067,
12789
+ "core::RaycastResult": 1068,
12790
+ "core::TextShape": 1030,
12791
+ "core::UiBackground": 1053,
12792
+ "core::UiDropdown": 1094,
12793
+ "core::UiDropdownResult": 1096,
12794
+ "core::UiInput": 1093,
12795
+ "core::UiInputResult": 1095,
12796
+ "core::UiText": 1052,
12797
+ "core::UiTransform": 1050,
12798
+ "core::VisibilityComponent": 1081
12799
+ };
12800
+
12801
+ var utf8Exports = requireUtf8();
12802
+
12803
+ const CRC_TABLE = new Int32Array([
12804
+ 0x00000000, 0x77073096, 0xee0e612c, 0x990951ba, 0x076dc419, 0x706af48f,
12805
+ 0xe963a535, 0x9e6495a3, 0x0edb8832, 0x79dcb8a4, 0xe0d5e91e, 0x97d2d988,
12806
+ 0x09b64c2b, 0x7eb17cbd, 0xe7b82d07, 0x90bf1d91, 0x1db71064, 0x6ab020f2,
12807
+ 0xf3b97148, 0x84be41de, 0x1adad47d, 0x6ddde4eb, 0xf4d4b551, 0x83d385c7,
12808
+ 0x136c9856, 0x646ba8c0, 0xfd62f97a, 0x8a65c9ec, 0x14015c4f, 0x63066cd9,
12809
+ 0xfa0f3d63, 0x8d080df5, 0x3b6e20c8, 0x4c69105e, 0xd56041e4, 0xa2677172,
12810
+ 0x3c03e4d1, 0x4b04d447, 0xd20d85fd, 0xa50ab56b, 0x35b5a8fa, 0x42b2986c,
12811
+ 0xdbbbc9d6, 0xacbcf940, 0x32d86ce3, 0x45df5c75, 0xdcd60dcf, 0xabd13d59,
12812
+ 0x26d930ac, 0x51de003a, 0xc8d75180, 0xbfd06116, 0x21b4f4b5, 0x56b3c423,
12813
+ 0xcfba9599, 0xb8bda50f, 0x2802b89e, 0x5f058808, 0xc60cd9b2, 0xb10be924,
12814
+ 0x2f6f7c87, 0x58684c11, 0xc1611dab, 0xb6662d3d, 0x76dc4190, 0x01db7106,
12815
+ 0x98d220bc, 0xefd5102a, 0x71b18589, 0x06b6b51f, 0x9fbfe4a5, 0xe8b8d433,
12816
+ 0x7807c9a2, 0x0f00f934, 0x9609a88e, 0xe10e9818, 0x7f6a0dbb, 0x086d3d2d,
12817
+ 0x91646c97, 0xe6635c01, 0x6b6b51f4, 0x1c6c6162, 0x856530d8, 0xf262004e,
12818
+ 0x6c0695ed, 0x1b01a57b, 0x8208f4c1, 0xf50fc457, 0x65b0d9c6, 0x12b7e950,
12819
+ 0x8bbeb8ea, 0xfcb9887c, 0x62dd1ddf, 0x15da2d49, 0x8cd37cf3, 0xfbd44c65,
12820
+ 0x4db26158, 0x3ab551ce, 0xa3bc0074, 0xd4bb30e2, 0x4adfa541, 0x3dd895d7,
12821
+ 0xa4d1c46d, 0xd3d6f4fb, 0x4369e96a, 0x346ed9fc, 0xad678846, 0xda60b8d0,
12822
+ 0x44042d73, 0x33031de5, 0xaa0a4c5f, 0xdd0d7cc9, 0x5005713c, 0x270241aa,
12823
+ 0xbe0b1010, 0xc90c2086, 0x5768b525, 0x206f85b3, 0xb966d409, 0xce61e49f,
12824
+ 0x5edef90e, 0x29d9c998, 0xb0d09822, 0xc7d7a8b4, 0x59b33d17, 0x2eb40d81,
12825
+ 0xb7bd5c3b, 0xc0ba6cad, 0xedb88320, 0x9abfb3b6, 0x03b6e20c, 0x74b1d29a,
12826
+ 0xead54739, 0x9dd277af, 0x04db2615, 0x73dc1683, 0xe3630b12, 0x94643b84,
12827
+ 0x0d6d6a3e, 0x7a6a5aa8, 0xe40ecf0b, 0x9309ff9d, 0x0a00ae27, 0x7d079eb1,
12828
+ 0xf00f9344, 0x8708a3d2, 0x1e01f268, 0x6906c2fe, 0xf762575d, 0x806567cb,
12829
+ 0x196c3671, 0x6e6b06e7, 0xfed41b76, 0x89d32be0, 0x10da7a5a, 0x67dd4acc,
12830
+ 0xf9b9df6f, 0x8ebeeff9, 0x17b7be43, 0x60b08ed5, 0xd6d6a3e8, 0xa1d1937e,
12831
+ 0x38d8c2c4, 0x4fdff252, 0xd1bb67f1, 0xa6bc5767, 0x3fb506dd, 0x48b2364b,
12832
+ 0xd80d2bda, 0xaf0a1b4c, 0x36034af6, 0x41047a60, 0xdf60efc3, 0xa867df55,
12833
+ 0x316e8eef, 0x4669be79, 0xcb61b38c, 0xbc66831a, 0x256fd2a0, 0x5268e236,
12834
+ 0xcc0c7795, 0xbb0b4703, 0x220216b9, 0x5505262f, 0xc5ba3bbe, 0xb2bd0b28,
12835
+ 0x2bb45a92, 0x5cb36a04, 0xc2d7ffa7, 0xb5d0cf31, 0x2cd99e8b, 0x5bdeae1d,
12836
+ 0x9b64c2b0, 0xec63f226, 0x756aa39c, 0x026d930a, 0x9c0906a9, 0xeb0e363f,
12837
+ 0x72076785, 0x05005713, 0x95bf4a82, 0xe2b87a14, 0x7bb12bae, 0x0cb61b38,
12838
+ 0x92d28e9b, 0xe5d5be0d, 0x7cdcefb7, 0x0bdbdf21, 0x86d3d2d4, 0xf1d4e242,
12839
+ 0x68ddb3f8, 0x1fda836e, 0x81be16cd, 0xf6b9265b, 0x6fb077e1, 0x18b74777,
12840
+ 0x88085ae6, 0xff0f6a70, 0x66063bca, 0x11010b5c, 0x8f659eff, 0xf862ae69,
12841
+ 0x616bffd3, 0x166ccf45, 0xa00ae278, 0xd70dd2ee, 0x4e048354, 0x3903b3c2,
12842
+ 0xa7672661, 0xd06016f7, 0x4969474d, 0x3e6e77db, 0xaed16a4a, 0xd9d65adc,
12843
+ 0x40df0b66, 0x37d83bf0, 0xa9bcae53, 0xdebb9ec5, 0x47b2cf7f, 0x30b5ffe9,
12844
+ 0xbdbdf21c, 0xcabac28a, 0x53b39330, 0x24b4a3a6, 0xbad03605, 0xcdd70693,
12845
+ 0x54de5729, 0x23d967bf, 0xb3667a2e, 0xc4614ab8, 0x5d681b02, 0x2a6f2b94,
12846
+ 0xb40bbe37, 0xc30c8ea1, 0x5a05df1b, 0x2d02ef8d
12847
+ ]);
12848
+ function _crc32(buf, previous) {
12849
+ let crc = ~~previous ^ -1;
12850
+ for (let n = 0; n < buf.length; n++) {
12851
+ crc = CRC_TABLE[(crc ^ buf[n]) & 0xff] ^ (crc >>> 8);
12852
+ }
12853
+ return crc ^ -1;
12854
+ }
12855
+ function unsignedCRC32(data, prev = 0) {
12856
+ return _crc32(data, prev) >>> 0;
12857
+ }
12858
+
12859
+ // Max possible pre-defined (static) component.
12860
+ const MAX_STATIC_COMPONENT = 1 << 11; // 2048
12861
+ /**
12862
+ * All components that are not part of the coreComponentMappings MUST yield
12863
+ * a componentNumber (componentId) greather than MAX_STATIC_COMPONENT.
12864
+ * For that reason, we simply add MAX_STATIC_COMPONENT and trim to the domain 2^32
12865
+ */
12866
+ function componentNumberFromName(componentName) {
12867
+ if (coreComponentMappings[componentName])
12868
+ return coreComponentMappings[componentName];
12869
+ const bytes = new Uint8Array(128);
12870
+ utf8Exports.write(componentName, bytes, 0);
12871
+ return ((unsignedCRC32(bytes) + MAX_STATIC_COMPONENT) & 4294967295) >>> 0;
12872
+ }
12873
+
12767
12874
  function checkNotThenable(t, error) {
12768
12875
  if (globalThis.DEBUG) {
12769
12876
  if (t &&
@@ -13682,8 +13789,6 @@
13682
13789
  };
13683
13790
  }
13684
13791
 
13685
- var utf8Exports = requireUtf8();
13686
-
13687
13792
  var __classPrivateFieldGet = (globalThis && globalThis.__classPrivateFieldGet) || function (receiver, state, kind, f) {
13688
13793
  if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
13689
13794
  if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
@@ -13872,7 +13977,7 @@
13872
13977
  return this.view.getUint16(offset);
13873
13978
  }
13874
13979
  getUint32(offset) {
13875
- return this.view.getUint32(offset);
13980
+ return this.view.getUint32(offset) >>> 0;
13876
13981
  }
13877
13982
  getUint64(offset) {
13878
13983
  return this.view.getBigUint64(offset);
@@ -13972,7 +14077,7 @@
13972
14077
  const msg = {
13973
14078
  ...header,
13974
14079
  entityId: buf.readUint32(),
13975
- componentId: buf.readInt32(),
14080
+ componentId: buf.readUint32(),
13976
14081
  timestamp: Number(buf.readUint64())
13977
14082
  };
13978
14083
  // TODO: remove buffer length
@@ -14000,7 +14105,7 @@
14000
14105
  buf.setUint32(startMessageOffset + 4, exports.CrdtMessageType.PUT_COMPONENT);
14001
14106
  // Write ComponentOperation header
14002
14107
  buf.setUint32(startMessageOffset + 8, entity);
14003
- buf.setUint32(startMessageOffset + 12, componentDefinition._id);
14108
+ buf.setUint32(startMessageOffset + 12, componentDefinition.componentId);
14004
14109
  buf.setUint64(startMessageOffset + 16, BigInt(timestamp));
14005
14110
  const newLocal = messageLength - PutComponentOperation.MESSAGE_HEADER_LENGTH - CRDT_MESSAGE_HEADER_LENGTH;
14006
14111
  buf.setUint32(startMessageOffset + 24, newLocal);
@@ -14017,7 +14122,7 @@
14017
14122
  return {
14018
14123
  ...header,
14019
14124
  entityId: buf.readUint32(),
14020
- componentId: buf.readInt32(),
14125
+ componentId: buf.readUint32(),
14021
14126
  timestamp: Number(buf.readUint64()),
14022
14127
  data: buf.readBuffer()
14023
14128
  };
@@ -14233,7 +14338,7 @@
14233
14338
  // The state isn't updated because the dirty was set
14234
14339
  // out of the block of systems update between `receiveMessage` and `updateState`
14235
14340
  if (component?.isDirty(msg.entityId)) {
14236
- crdtClient.createComponentDataEvent(component._id, msg.entityId, component.toBinaryOrNull(msg.entityId)?.toBinary() || null);
14341
+ crdtClient.createComponentDataEvent(component.componentId, msg.entityId, component.toBinaryOrNull(msg.entityId)?.toBinary() || null);
14237
14342
  }
14238
14343
  const processResult = crdtClient.processMessage(crdtMessage);
14239
14344
  if (!component) {
@@ -14270,7 +14375,7 @@
14270
14375
  exports.PutComponentOperation.write(msg.entityId, ts, component, bufferForOutdated);
14271
14376
  }
14272
14377
  else {
14273
- exports.DeleteComponent.write(msg.entityId, component._id, ts, bufferForOutdated);
14378
+ exports.DeleteComponent.write(msg.entityId, component.componentId, ts, bufferForOutdated);
14274
14379
  }
14275
14380
  outdatedMessages.push({
14276
14381
  ...msg,
@@ -14320,7 +14425,7 @@
14320
14425
  const componentValue = component.toBinaryOrNull(entity)?.toBinary() ?? null;
14321
14426
  // TODO: do not emit event if componentValue equals the value didn't change
14322
14427
  // if update goes bad, the entity doesn't accept put anymore (it's added to deleted entities set)
14323
- if (crdtClient.createComponentDataEvent(component._id, entity, componentValue) === null) {
14428
+ if (crdtClient.createComponentDataEvent(component.componentId, entity, componentValue) === null) {
14324
14429
  component.deleteFrom(entity, false);
14325
14430
  }
14326
14431
  else {
@@ -14347,7 +14452,7 @@
14347
14452
  // Component will be always defined here since dirtyMap its an iterator of engine.componentsDefinition
14348
14453
  const { timestamp } = crdtClient
14349
14454
  .getState()
14350
- .components.get(component._id)
14455
+ .components.get(component.componentId)
14351
14456
  .get(entity);
14352
14457
  const offset = buffer.currentWriteOffset();
14353
14458
  const type = component.has(entity)
@@ -14356,7 +14461,7 @@
14356
14461
  const transportMessage = {
14357
14462
  type,
14358
14463
  entityId: entity,
14359
- componentId: component._id,
14464
+ componentId: component.componentId,
14360
14465
  timestamp
14361
14466
  };
14362
14467
  // Avoid creating messages if there is no transport that will handle it
@@ -14365,7 +14470,7 @@
14365
14470
  exports.PutComponentOperation.write(entity, timestamp, component, buffer);
14366
14471
  }
14367
14472
  else {
14368
- exports.DeleteComponent.write(entity, component._id, timestamp, buffer);
14473
+ exports.DeleteComponent.write(entity, component.componentId, timestamp, buffer);
14369
14474
  }
14370
14475
  crdtMessages.push({
14371
14476
  ...transportMessage,
@@ -14452,15 +14557,18 @@
14452
14557
  return Object.freeze({ ...val });
14453
14558
  }
14454
14559
 
14455
- function defineComponent(componentId, spec
14456
- // meta: { syncFlags }
14457
- ) {
14560
+ function createComponentDefinitionFromSchema(componentName, componentId, schema) {
14458
14561
  const data = new Map();
14459
14562
  const dirtyIterator = new Set();
14460
14563
  return {
14461
- _id: componentId,
14564
+ get componentId() {
14565
+ return componentId;
14566
+ },
14567
+ get componentName() {
14568
+ return componentName;
14569
+ },
14462
14570
  default() {
14463
- return spec.create();
14571
+ return schema.create();
14464
14572
  },
14465
14573
  isDirty(entity) {
14466
14574
  return dirtyIterator.has(entity);
@@ -14486,19 +14594,19 @@
14486
14594
  get(entity) {
14487
14595
  const component = data.get(entity);
14488
14596
  if (!component) {
14489
- throw new Error(`[getFrom] Component ${componentId} for entity #${entity} not found`);
14597
+ throw new Error(`[getFrom] Component ${componentName} for entity #${entity} not found`);
14490
14598
  }
14491
14599
  return deepReadonly(component);
14492
14600
  },
14493
14601
  create(entity, value) {
14494
14602
  const component = data.get(entity);
14495
14603
  if (component) {
14496
- throw new Error(`[create] Component ${componentId} for ${entity} already exists`);
14604
+ throw new Error(`[create] Component ${componentName} for ${entity} already exists`);
14497
14605
  }
14498
14606
  const usedValue = value === undefined
14499
- ? spec.create()
14500
- : spec.extend
14501
- ? spec.extend(value)
14607
+ ? schema.create()
14608
+ : schema.extend
14609
+ ? schema.extend(value)
14502
14610
  : value;
14503
14611
  data.set(entity, usedValue);
14504
14612
  dirtyIterator.add(entity);
@@ -14506,9 +14614,9 @@
14506
14614
  },
14507
14615
  createOrReplace(entity, value) {
14508
14616
  const usedValue = value === undefined
14509
- ? spec.create()
14510
- : spec.extend
14511
- ? spec.extend(value)
14617
+ ? schema.create()
14618
+ : schema.extend
14619
+ ? schema.extend(value)
14512
14620
  : value;
14513
14621
  data.set(entity, usedValue);
14514
14622
  dirtyIterator.add(entity);
@@ -14525,7 +14633,7 @@
14525
14633
  getMutable(entity) {
14526
14634
  const component = this.getMutableOrNull(entity);
14527
14635
  if (component === null) {
14528
- throw new Error(`[mutable] Component ${componentId} for ${entity} not found`);
14636
+ throw new Error(`[mutable] Component ${componentName} for ${entity} not found`);
14529
14637
  }
14530
14638
  return component;
14531
14639
  },
@@ -14542,10 +14650,10 @@
14542
14650
  toBinary(entity) {
14543
14651
  const component = data.get(entity);
14544
14652
  if (!component) {
14545
- throw new Error(`[toBinary] Component ${componentId} for ${entity} not found`);
14653
+ throw new Error(`[toBinary] Component ${componentName} for ${entity} not found`);
14546
14654
  }
14547
14655
  const writeBuffer = new ReadWriteByteBuffer();
14548
- spec.serialize(component, writeBuffer);
14656
+ schema.serialize(component, writeBuffer);
14549
14657
  return writeBuffer;
14550
14658
  },
14551
14659
  toBinaryOrNull(entity) {
@@ -14554,25 +14662,25 @@
14554
14662
  return null;
14555
14663
  }
14556
14664
  const writeBuffer = new ReadWriteByteBuffer();
14557
- spec.serialize(component, writeBuffer);
14665
+ schema.serialize(component, writeBuffer);
14558
14666
  return writeBuffer;
14559
14667
  },
14560
14668
  writeToByteBuffer(entity, buffer) {
14561
14669
  const component = data.get(entity);
14562
14670
  if (!component) {
14563
- throw new Error(`[writeToByteBuffer] Component ${componentId} for entity #${entity} not found`);
14671
+ throw new Error(`[writeToByteBuffer] Component ${componentName} for entity #${entity} not found`);
14564
14672
  }
14565
- spec.serialize(component, buffer);
14673
+ schema.serialize(component, buffer);
14566
14674
  },
14567
14675
  updateFromBinary(entity, buffer, markAsDirty = true) {
14568
14676
  const component = data.get(entity);
14569
14677
  if (!component) {
14570
- throw new Error(`[updateFromBinary] Component ${componentId} for ${entity} not found`);
14678
+ throw new Error(`[updateFromBinary] Component ${componentName} for ${entity} not found`);
14571
14679
  }
14572
14680
  return this.upsertFromBinary(entity, buffer, markAsDirty);
14573
14681
  },
14574
14682
  upsertFromBinary(entity, buffer, markAsDirty = true) {
14575
- const newValue = spec.deserialize(buffer);
14683
+ const newValue = schema.deserialize(buffer);
14576
14684
  data.set(entity, newValue);
14577
14685
  if (markAsDirty) {
14578
14686
  dirtyIterator.add(entity);
@@ -14583,7 +14691,7 @@
14583
14691
  return newValue;
14584
14692
  },
14585
14693
  deserialize(buffer) {
14586
- return spec.deserialize(buffer);
14694
+ return schema.deserialize(buffer);
14587
14695
  },
14588
14696
  clearDirty() {
14589
14697
  dirtyIterator.clear();
@@ -14659,12 +14767,11 @@
14659
14767
  ts: exports.Schemas.Number
14660
14768
  }))
14661
14769
  };
14662
- const InternalInputStateComponentId = 1500;
14663
14770
  const TimestampUpdateSystemPriority = 1 << 20;
14664
14771
  const ButtonStateUpdateSystemPriority = 0;
14665
14772
  function createInputSystem(engine) {
14666
14773
  const PointerEventsResult = PointerEventsResult$1(engine);
14667
- const InternalInputStateComponent = engine.defineComponent(InternalInputStateSchema, InternalInputStateComponentId);
14774
+ const InternalInputStateComponent = engine.defineComponent('@dcl/sdk/InternalInputStateSchema', InternalInputStateSchema);
14668
14775
  InternalInputStateComponent.create(engine.RootEntity, {
14669
14776
  buttonState: Array.from({ length: InputCommands.length }, () => ({
14670
14777
  ts: 0,
@@ -14795,6 +14902,7 @@
14795
14902
  const entityContainer = EntityContainer();
14796
14903
  const componentsDefinition = new Map();
14797
14904
  const systems = SystemContainer();
14905
+ let sealed = false;
14798
14906
  function addSystem(fn, priority = SYSTEMS_REGULAR_PRIORITY, name) {
14799
14907
  systems.add(fn, priority, name);
14800
14908
  }
@@ -14813,32 +14921,51 @@
14813
14921
  }
14814
14922
  return entityContainer.removeEntity(entity);
14815
14923
  }
14816
- function registerCustomComponent(component, componentId) {
14924
+ function registerComponentDefinition(componentName, component) {
14925
+ /* istanbul ignore next */
14926
+ if (sealed)
14927
+ throw new Error('Engine is already sealed. No components can be added at this stage');
14928
+ const componentId = componentNumberFromName(componentName);
14817
14929
  const prev = componentsDefinition.get(componentId);
14818
14930
  if (prev) {
14819
14931
  throw new Error(`Component number ${componentId} was already registered.`);
14820
14932
  }
14933
+ /* istanbul ignore next */
14934
+ if (component.componentName !== componentName) {
14935
+ throw new Error(`Component name doesn't match componentDefinition.componentName ${componentName} != ${component.componentName}`);
14936
+ }
14937
+ /* istanbul ignore next */
14938
+ if (component.componentId !== componentId) {
14939
+ throw new Error(`Component number doesn't match componentDefinition.componentId ${componentId} != ${component.componentId}`);
14940
+ }
14821
14941
  componentsDefinition.set(componentId, component);
14822
14942
  return component;
14823
14943
  }
14824
- function defineComponentFromSchema(spec, componentId) {
14944
+ function defineComponentFromSchema(componentName, schema) {
14945
+ /* istanbul ignore next */
14946
+ if (sealed)
14947
+ throw new Error('Engine is already sealed. No components can be added at this stage');
14948
+ const componentId = componentNumberFromName(componentName);
14825
14949
  const prev = componentsDefinition.get(componentId);
14826
14950
  if (prev) {
14827
14951
  // TODO: assert spec === prev.spec
14828
14952
  return prev;
14829
14953
  }
14830
- const newComponent = defineComponent(componentId, spec);
14954
+ const newComponent = createComponentDefinitionFromSchema(componentName, componentId, schema);
14831
14955
  componentsDefinition.set(componentId, newComponent);
14832
14956
  return newComponent;
14833
14957
  }
14834
- function defineComponent$1(mapSpec, componentId, constructorDefault) {
14958
+ function defineComponent(componentName, mapSpec, constructorDefault) {
14959
+ if (sealed)
14960
+ throw new Error('Engine is already sealed. No components can be added at this stage');
14961
+ const componentId = componentNumberFromName(componentName);
14835
14962
  const prev = componentsDefinition.get(componentId);
14836
14963
  if (prev) {
14837
14964
  // TODO: assert spec === prev.spec
14838
14965
  return prev;
14839
14966
  }
14840
14967
  const schemaSpec = exports.Schemas.Map(mapSpec, constructorDefault);
14841
- const def = defineComponent(componentId, schemaSpec);
14968
+ const def = createComponentDefinitionFromSchema(componentName, componentId, schemaSpec);
14842
14969
  const newComponent = {
14843
14970
  ...def,
14844
14971
  create(entity, val) {
@@ -14910,22 +15037,28 @@
14910
15037
  removeEntity(entity);
14911
15038
  }
14912
15039
  }
15040
+ function seal() {
15041
+ if (!sealed) {
15042
+ sealed = true;
15043
+ }
15044
+ }
14913
15045
  return {
14914
15046
  addEntity,
14915
15047
  removeEntity,
14916
15048
  addSystem,
14917
15049
  getSystems,
14918
15050
  removeSystem,
14919
- defineComponent: defineComponent$1,
15051
+ defineComponent,
14920
15052
  defineComponentFromSchema,
14921
15053
  getEntitiesWith,
14922
15054
  getComponent,
14923
15055
  getComponentOrNull,
14924
15056
  removeComponentDefinition,
14925
15057
  removeEntityWithChildren,
14926
- registerCustomComponent,
15058
+ registerComponentDefinition,
14927
15059
  entityContainer,
14928
- componentsIter
15060
+ componentsIter,
15061
+ seal
14929
15062
  };
14930
15063
  }
14931
15064
  /**
@@ -14955,12 +15088,13 @@
14955
15088
  removeSystem: engine.removeSystem,
14956
15089
  defineComponent: engine.defineComponent,
14957
15090
  defineComponentFromSchema: engine.defineComponentFromSchema,
14958
- registerCustomComponent: engine.registerCustomComponent,
15091
+ registerComponentDefinition: engine.registerComponentDefinition,
14959
15092
  getEntitiesWith: engine.getEntitiesWith,
14960
15093
  getComponent: engine.getComponent,
14961
15094
  getComponentOrNull: engine.getComponentOrNull,
14962
15095
  removeComponentDefinition: engine.removeComponentDefinition,
14963
15096
  componentsIter: engine.componentsIter,
15097
+ seal: engine.seal,
14964
15098
  update,
14965
15099
  RootEntity: 0,
14966
15100
  PlayerEntity: 1,
@@ -40978,11 +41112,11 @@
40978
41112
  const UiDropdownResult = UiDropdownResult$1(engine);
40979
41113
  // Component ID Helper
40980
41114
  const getComponentId = {
40981
- uiTransform: UiTransform._id,
40982
- uiText: UiText._id,
40983
- uiBackground: UiBackground._id,
40984
- uiInput: UiInput._id,
40985
- uiDropdown: UiDropdown._id
41115
+ uiTransform: UiTransform.componentId,
41116
+ uiText: UiText.componentId,
41117
+ uiBackground: UiBackground.componentId,
41118
+ uiInput: UiInput.componentId,
41119
+ uiDropdown: UiDropdown.componentId
40986
41120
  };
40987
41121
  function updateTree(instance, props) {
40988
41122
  upsertComponent(instance, props, 'uiTransform');
@@ -41176,8 +41310,8 @@
41176
41310
  return {
41177
41311
  update: function (component) {
41178
41312
  if (changeEvents.size) {
41179
- handleOnChange(UiInput._id, UiInputResult);
41180
- handleOnChange(UiDropdown._id, UiDropdownResult);
41313
+ handleOnChange(UiInput.componentId, UiInputResult);
41314
+ handleOnChange(UiDropdown.componentId, UiDropdownResult);
41181
41315
  }
41182
41316
  return reconciler.updateContainer(component, root, null);
41183
41317
  },
@@ -41546,43 +41680,6 @@
41546
41680
  return getEthereumProvider(EthereumController.sendAsync);
41547
41681
  }
41548
41682
 
41549
- /** @public */
41550
- var ECSComponentIDs;
41551
- (function (ECSComponentIDs) {
41552
- ECSComponentIDs[ECSComponentIDs["Transform"] = 1] = "Transform";
41553
- ECSComponentIDs[ECSComponentIDs["Animator"] = 1042] = "Animator";
41554
- ECSComponentIDs[ECSComponentIDs["AudioSource"] = 1020] = "AudioSource";
41555
- ECSComponentIDs[ECSComponentIDs["AudioStream"] = 1021] = "AudioStream";
41556
- ECSComponentIDs[ECSComponentIDs["AvatarAttach"] = 1073] = "AvatarAttach";
41557
- ECSComponentIDs[ECSComponentIDs["AvatarModifierArea"] = 1070] = "AvatarModifierArea";
41558
- ECSComponentIDs[ECSComponentIDs["AvatarShape"] = 1080] = "AvatarShape";
41559
- ECSComponentIDs[ECSComponentIDs["Billboard"] = 1090] = "Billboard";
41560
- ECSComponentIDs[ECSComponentIDs["CameraMode"] = 1072] = "CameraMode";
41561
- ECSComponentIDs[ECSComponentIDs["CameraModeArea"] = 1071] = "CameraModeArea";
41562
- ECSComponentIDs[ECSComponentIDs["GltfContainer"] = 1041] = "GltfContainer";
41563
- ECSComponentIDs[ECSComponentIDs["Material"] = 1017] = "Material";
41564
- ECSComponentIDs[ECSComponentIDs["MeshCollider"] = 1019] = "MeshCollider";
41565
- ECSComponentIDs[ECSComponentIDs["MeshRenderer"] = 1018] = "MeshRenderer";
41566
- ECSComponentIDs[ECSComponentIDs["NftShape"] = 1040] = "NftShape";
41567
- ECSComponentIDs[ECSComponentIDs["PointerEvents"] = 1062] = "PointerEvents";
41568
- ECSComponentIDs[ECSComponentIDs["PointerEventsResult"] = 1063] = "PointerEventsResult";
41569
- ECSComponentIDs[ECSComponentIDs["PointerLock"] = 1074] = "PointerLock";
41570
- ECSComponentIDs[ECSComponentIDs["Raycast"] = 1067] = "Raycast";
41571
- ECSComponentIDs[ECSComponentIDs["RaycastResult"] = 1068] = "RaycastResult";
41572
- ECSComponentIDs[ECSComponentIDs["TextShape"] = 1030] = "TextShape";
41573
- ECSComponentIDs[ECSComponentIDs["UiBackground"] = 1053] = "UiBackground";
41574
- ECSComponentIDs[ECSComponentIDs["UiDropdown"] = 1094] = "UiDropdown";
41575
- ECSComponentIDs[ECSComponentIDs["UiDropdownResult"] = 1096] = "UiDropdownResult";
41576
- ECSComponentIDs[ECSComponentIDs["UiInput"] = 1093] = "UiInput";
41577
- ECSComponentIDs[ECSComponentIDs["UiInputResult"] = 1095] = "UiInputResult";
41578
- ECSComponentIDs[ECSComponentIDs["UiText"] = 1052] = "UiText";
41579
- ECSComponentIDs[ECSComponentIDs["UiTransform"] = 1050] = "UiTransform";
41580
- ECSComponentIDs[ECSComponentIDs["VisibilityComponent"] = 1081] = "VisibilityComponent";
41581
- })(ECSComponentIDs || (ECSComponentIDs = {}));
41582
-
41583
- const componentIds = Object.values(ECSComponentIDs)
41584
- .filter((a) => typeof a === 'number')
41585
- .map(Number);
41586
41683
  function createRendererTransport(engineApi) {
41587
41684
  async function sendToRenderer(message) {
41588
41685
  const response = await engineApi.crdtSendToRenderer({
@@ -41609,7 +41706,7 @@
41609
41706
  filter(message) {
41610
41707
  if ((message.type === exports.CrdtMessageType.PUT_COMPONENT ||
41611
41708
  message.type === exports.CrdtMessageType.DELETE_COMPONENT) &&
41612
- !componentIds.includes(message.componentId)) {
41709
+ message.componentId > MAX_STATIC_COMPONENT) {
41613
41710
  return false;
41614
41711
  }
41615
41712
  return !!message;
@@ -41624,6 +41721,9 @@
41624
41721
  await engine.update(deltaTime);
41625
41722
  await pollEvents(EngineApi.sendBatch);
41626
41723
  }
41724
+ async function onStart() {
41725
+ await engine.seal();
41726
+ }
41627
41727
 
41628
41728
  exports.AMOUNT_VERSION_AVAILABLE = AMOUNT_VERSION_AVAILABLE;
41629
41729
  exports.Animator = Animator;
@@ -41727,6 +41827,7 @@
41727
41827
  exports.UiTransform = UiTransform;
41728
41828
  exports.VisibilityComponent = VisibilityComponent;
41729
41829
  exports.components = index;
41830
+ exports.createComponentDefinitionFromSchema = createComponentDefinitionFromSchema;
41730
41831
  exports.createEthereumProvider = createEthereumProvider;
41731
41832
  exports.createInputSystem = createInputSystem;
41732
41833
  exports.createPointerEventSystem = createPointerEventSystem;
@@ -41734,7 +41835,6 @@
41734
41835
  exports.createTaskSystem = createTaskSystem;
41735
41836
  exports.cyclicParentingChecker = cyclicParentingChecker;
41736
41837
  exports.deepReadonly = deepReadonly;
41737
- exports.defineComponent = defineComponent;
41738
41838
  exports.engine = engine;
41739
41839
  exports.executeTask = executeTask;
41740
41840
  exports.inputSystem = inputSystem;
@@ -41751,6 +41851,7 @@
41751
41851
  exports.onProfileChanged = onProfileChanged;
41752
41852
  exports.onRealmChangedObservable = onRealmChangedObservable;
41753
41853
  exports.onSceneReadyObservable = onSceneReadyObservable;
41854
+ exports.onStart = onStart;
41754
41855
  exports.onUpdate = onUpdate;
41755
41856
  exports.onVideoEvent = onVideoEvent;
41756
41857
  exports.pointerEventsSystem = pointerEventsSystem;