@dcl/playground-assets 7.0.6-4177592674.commit-39cdc99 → 7.0.6-4183962432.commit-2fbe270

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
@@ -7580,6 +7580,12 @@
7580
7580
  create() {
7581
7581
  // TODO: this is a hack.
7582
7582
  return PBAnimator.decode(new Uint8Array());
7583
+ },
7584
+ jsonSchema: {
7585
+ type: "object",
7586
+ properties: {},
7587
+ serializationType: "protocol-buffer",
7588
+ protocolBuffer: "PBAnimator"
7583
7589
  }
7584
7590
  };
7585
7591
 
@@ -7659,6 +7665,12 @@
7659
7665
  create() {
7660
7666
  // TODO: this is a hack.
7661
7667
  return PBAudioSource.decode(new Uint8Array());
7668
+ },
7669
+ jsonSchema: {
7670
+ type: "object",
7671
+ properties: {},
7672
+ serializationType: "protocol-buffer",
7673
+ protocolBuffer: "PBAudioSource"
7662
7674
  }
7663
7675
  };
7664
7676
 
@@ -7726,6 +7738,12 @@
7726
7738
  create() {
7727
7739
  // TODO: this is a hack.
7728
7740
  return PBAudioStream.decode(new Uint8Array());
7741
+ },
7742
+ jsonSchema: {
7743
+ type: "object",
7744
+ properties: {},
7745
+ serializationType: "protocol-buffer",
7746
+ protocolBuffer: "PBAudioStream"
7729
7747
  }
7730
7748
  };
7731
7749
 
@@ -7797,6 +7815,12 @@
7797
7815
  create() {
7798
7816
  // TODO: this is a hack.
7799
7817
  return PBAvatarAttach.decode(new Uint8Array());
7818
+ },
7819
+ jsonSchema: {
7820
+ type: "object",
7821
+ properties: {},
7822
+ serializationType: "protocol-buffer",
7823
+ protocolBuffer: "PBAvatarAttach"
7800
7824
  }
7801
7825
  };
7802
7826
 
@@ -7930,6 +7954,12 @@
7930
7954
  create() {
7931
7955
  // TODO: this is a hack.
7932
7956
  return PBAvatarModifierArea.decode(new Uint8Array());
7957
+ },
7958
+ jsonSchema: {
7959
+ type: "object",
7960
+ properties: {},
7961
+ serializationType: "protocol-buffer",
7962
+ protocolBuffer: "PBAvatarModifierArea"
7933
7963
  }
7934
7964
  };
7935
7965
 
@@ -9517,6 +9547,12 @@
9517
9547
  create() {
9518
9548
  // TODO: this is a hack.
9519
9549
  return PBAvatarShape.decode(new Uint8Array());
9550
+ },
9551
+ jsonSchema: {
9552
+ type: "object",
9553
+ properties: {},
9554
+ serializationType: "protocol-buffer",
9555
+ protocolBuffer: "PBAvatarShape"
9520
9556
  }
9521
9557
  };
9522
9558
 
@@ -9583,6 +9619,12 @@
9583
9619
  create() {
9584
9620
  // TODO: this is a hack.
9585
9621
  return PBBillboard.decode(new Uint8Array());
9622
+ },
9623
+ jsonSchema: {
9624
+ type: "object",
9625
+ properties: {},
9626
+ serializationType: "protocol-buffer",
9627
+ protocolBuffer: "PBBillboard"
9586
9628
  }
9587
9629
  };
9588
9630
 
@@ -9638,6 +9680,12 @@
9638
9680
  create() {
9639
9681
  // TODO: this is a hack.
9640
9682
  return PBCameraMode.decode(new Uint8Array());
9683
+ },
9684
+ jsonSchema: {
9685
+ type: "object",
9686
+ properties: {},
9687
+ serializationType: "protocol-buffer",
9688
+ protocolBuffer: "PBCameraMode"
9641
9689
  }
9642
9690
  };
9643
9691
 
@@ -9699,6 +9747,12 @@
9699
9747
  create() {
9700
9748
  // TODO: this is a hack.
9701
9749
  return PBCameraModeArea.decode(new Uint8Array());
9750
+ },
9751
+ jsonSchema: {
9752
+ type: "object",
9753
+ properties: {},
9754
+ serializationType: "protocol-buffer",
9755
+ protocolBuffer: "PBCameraModeArea"
9702
9756
  }
9703
9757
  };
9704
9758
 
@@ -9754,6 +9808,12 @@
9754
9808
  create() {
9755
9809
  // TODO: this is a hack.
9756
9810
  return PBGltfContainer.decode(new Uint8Array());
9811
+ },
9812
+ jsonSchema: {
9813
+ type: "object",
9814
+ properties: {},
9815
+ serializationType: "protocol-buffer",
9816
+ protocolBuffer: "PBGltfContainer"
9757
9817
  }
9758
9818
  };
9759
9819
 
@@ -10224,6 +10284,12 @@
10224
10284
  create() {
10225
10285
  // TODO: this is a hack.
10226
10286
  return PBMaterial.decode(new Uint8Array());
10287
+ },
10288
+ jsonSchema: {
10289
+ type: "object",
10290
+ properties: {},
10291
+ serializationType: "protocol-buffer",
10292
+ protocolBuffer: "PBMaterial"
10227
10293
  }
10228
10294
  };
10229
10295
 
@@ -10436,6 +10502,12 @@
10436
10502
  create() {
10437
10503
  // TODO: this is a hack.
10438
10504
  return PBMeshCollider.decode(new Uint8Array());
10505
+ },
10506
+ jsonSchema: {
10507
+ type: "object",
10508
+ properties: {},
10509
+ serializationType: "protocol-buffer",
10510
+ protocolBuffer: "PBMeshCollider"
10439
10511
  }
10440
10512
  };
10441
10513
 
@@ -10665,6 +10737,12 @@
10665
10737
  create() {
10666
10738
  // TODO: this is a hack.
10667
10739
  return PBMeshRenderer.decode(new Uint8Array());
10740
+ },
10741
+ jsonSchema: {
10742
+ type: "object",
10743
+ properties: {},
10744
+ serializationType: "protocol-buffer",
10745
+ protocolBuffer: "PBMeshRenderer"
10668
10746
  }
10669
10747
  };
10670
10748
 
@@ -10761,6 +10839,12 @@
10761
10839
  create() {
10762
10840
  // TODO: this is a hack.
10763
10841
  return PBNftShape.decode(new Uint8Array());
10842
+ },
10843
+ jsonSchema: {
10844
+ type: "object",
10845
+ properties: {},
10846
+ serializationType: "protocol-buffer",
10847
+ protocolBuffer: "PBNftShape"
10764
10848
  }
10765
10849
  };
10766
10850
 
@@ -10918,6 +11002,12 @@
10918
11002
  create() {
10919
11003
  // TODO: this is a hack.
10920
11004
  return PBPointerEvents.decode(new Uint8Array());
11005
+ },
11006
+ jsonSchema: {
11007
+ type: "object",
11008
+ properties: {},
11009
+ serializationType: "protocol-buffer",
11010
+ protocolBuffer: "PBPointerEvents"
10921
11011
  }
10922
11012
  };
10923
11013
 
@@ -11080,40 +11170,6 @@
11080
11170
 
11081
11171
  /* eslint-disable */
11082
11172
  function createBasePBPointerEventsResult() {
11083
- return { commands: [] };
11084
- }
11085
- /**
11086
- * @public
11087
- */
11088
- /**
11089
- * @internal
11090
- */
11091
- const PBPointerEventsResult = {
11092
- encode(message, writer = _m0.Writer.create()) {
11093
- for (const v of message.commands) {
11094
- PBPointerEventsResult_PointerCommand.encode(v, writer.uint32(10).fork()).ldelim();
11095
- }
11096
- return writer;
11097
- },
11098
- decode(input, length) {
11099
- const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input);
11100
- let end = length === undefined ? reader.len : reader.pos + length;
11101
- const message = createBasePBPointerEventsResult();
11102
- while (reader.pos < end) {
11103
- const tag = reader.uint32();
11104
- switch (tag >>> 3) {
11105
- case 1:
11106
- message.commands.push(PBPointerEventsResult_PointerCommand.decode(reader, reader.uint32()));
11107
- break;
11108
- default:
11109
- reader.skipType(tag & 7);
11110
- break;
11111
- }
11112
- }
11113
- return message;
11114
- },
11115
- };
11116
- function createBasePBPointerEventsResult_PointerCommand() {
11117
11173
  return { button: 0, hit: undefined, state: 0, timestamp: 0, analog: undefined };
11118
11174
  }
11119
11175
  /**
@@ -11122,7 +11178,7 @@
11122
11178
  /**
11123
11179
  * @internal
11124
11180
  */
11125
- const PBPointerEventsResult_PointerCommand = {
11181
+ const PBPointerEventsResult = {
11126
11182
  encode(message, writer = _m0.Writer.create()) {
11127
11183
  if (message.button !== 0) {
11128
11184
  writer.uint32(8).int32(message.button);
@@ -11144,7 +11200,7 @@
11144
11200
  decode(input, length) {
11145
11201
  const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input);
11146
11202
  let end = length === undefined ? reader.len : reader.pos + length;
11147
- const message = createBasePBPointerEventsResult_PointerCommand();
11203
+ const message = createBasePBPointerEventsResult();
11148
11204
  while (reader.pos < end) {
11149
11205
  const tag = reader.uint32();
11150
11206
  switch (tag >>> 3) {
@@ -11188,6 +11244,12 @@
11188
11244
  create() {
11189
11245
  // TODO: this is a hack.
11190
11246
  return PBPointerEventsResult.decode(new Uint8Array());
11247
+ },
11248
+ jsonSchema: {
11249
+ type: "object",
11250
+ properties: {},
11251
+ serializationType: "protocol-buffer",
11252
+ protocolBuffer: "PBPointerEventsResult"
11191
11253
  }
11192
11254
  };
11193
11255
 
@@ -11243,6 +11305,12 @@
11243
11305
  create() {
11244
11306
  // TODO: this is a hack.
11245
11307
  return PBPointerLock.decode(new Uint8Array());
11308
+ },
11309
+ jsonSchema: {
11310
+ type: "object",
11311
+ properties: {},
11312
+ serializationType: "protocol-buffer",
11313
+ protocolBuffer: "PBPointerLock"
11246
11314
  }
11247
11315
  };
11248
11316
 
@@ -11324,6 +11392,12 @@
11324
11392
  create() {
11325
11393
  // TODO: this is a hack.
11326
11394
  return PBRaycast.decode(new Uint8Array());
11395
+ },
11396
+ jsonSchema: {
11397
+ type: "object",
11398
+ properties: {},
11399
+ serializationType: "protocol-buffer",
11400
+ protocolBuffer: "PBRaycast"
11327
11401
  }
11328
11402
  };
11329
11403
 
@@ -11343,6 +11417,12 @@
11343
11417
  create() {
11344
11418
  // TODO: this is a hack.
11345
11419
  return PBRaycastResult.decode(new Uint8Array());
11420
+ },
11421
+ jsonSchema: {
11422
+ type: "object",
11423
+ properties: {},
11424
+ serializationType: "protocol-buffer",
11425
+ protocolBuffer: "PBRaycastResult"
11346
11426
  }
11347
11427
  };
11348
11428
 
@@ -11540,6 +11620,12 @@
11540
11620
  create() {
11541
11621
  // TODO: this is a hack.
11542
11622
  return PBTextShape.decode(new Uint8Array());
11623
+ },
11624
+ jsonSchema: {
11625
+ type: "object",
11626
+ properties: {},
11627
+ serializationType: "protocol-buffer",
11628
+ protocolBuffer: "PBTextShape"
11543
11629
  }
11544
11630
  };
11545
11631
 
@@ -11707,6 +11793,12 @@
11707
11793
  create() {
11708
11794
  // TODO: this is a hack.
11709
11795
  return PBUiBackground.decode(new Uint8Array());
11796
+ },
11797
+ jsonSchema: {
11798
+ type: "object",
11799
+ properties: {},
11800
+ serializationType: "protocol-buffer",
11801
+ protocolBuffer: "PBUiBackground"
11710
11802
  }
11711
11803
  };
11712
11804
 
@@ -11820,6 +11912,12 @@
11820
11912
  create() {
11821
11913
  // TODO: this is a hack.
11822
11914
  return PBUiDropdown.decode(new Uint8Array());
11915
+ },
11916
+ jsonSchema: {
11917
+ type: "object",
11918
+ properties: {},
11919
+ serializationType: "protocol-buffer",
11920
+ protocolBuffer: "PBUiDropdown"
11823
11921
  }
11824
11922
  };
11825
11923
 
@@ -11875,6 +11973,12 @@
11875
11973
  create() {
11876
11974
  // TODO: this is a hack.
11877
11975
  return PBUiDropdownResult.decode(new Uint8Array());
11976
+ },
11977
+ jsonSchema: {
11978
+ type: "object",
11979
+ properties: {},
11980
+ serializationType: "protocol-buffer",
11981
+ protocolBuffer: "PBUiDropdownResult"
11878
11982
  }
11879
11983
  };
11880
11984
 
@@ -11974,6 +12078,12 @@
11974
12078
  create() {
11975
12079
  // TODO: this is a hack.
11976
12080
  return PBUiInput.decode(new Uint8Array());
12081
+ },
12082
+ jsonSchema: {
12083
+ type: "object",
12084
+ properties: {},
12085
+ serializationType: "protocol-buffer",
12086
+ protocolBuffer: "PBUiInput"
11977
12087
  }
11978
12088
  };
11979
12089
 
@@ -12029,6 +12139,12 @@
12029
12139
  create() {
12030
12140
  // TODO: this is a hack.
12031
12141
  return PBUiInputResult.decode(new Uint8Array());
12142
+ },
12143
+ jsonSchema: {
12144
+ type: "object",
12145
+ properties: {},
12146
+ serializationType: "protocol-buffer",
12147
+ protocolBuffer: "PBUiInputResult"
12032
12148
  }
12033
12149
  };
12034
12150
 
@@ -12108,6 +12224,12 @@
12108
12224
  create() {
12109
12225
  // TODO: this is a hack.
12110
12226
  return PBUiText.decode(new Uint8Array());
12227
+ },
12228
+ jsonSchema: {
12229
+ type: "object",
12230
+ properties: {},
12231
+ serializationType: "protocol-buffer",
12232
+ protocolBuffer: "PBUiText"
12111
12233
  }
12112
12234
  };
12113
12235
 
@@ -12610,6 +12732,12 @@
12610
12732
  create() {
12611
12733
  // TODO: this is a hack.
12612
12734
  return PBUiTransform.decode(new Uint8Array());
12735
+ },
12736
+ jsonSchema: {
12737
+ type: "object",
12738
+ properties: {},
12739
+ serializationType: "protocol-buffer",
12740
+ protocolBuffer: "PBUiTransform"
12613
12741
  }
12614
12742
  };
12615
12743
 
@@ -12702,6 +12830,12 @@
12702
12830
  create() {
12703
12831
  // TODO: this is a hack.
12704
12832
  return PBVideoPlayer.decode(new Uint8Array());
12833
+ },
12834
+ jsonSchema: {
12835
+ type: "object",
12836
+ properties: {},
12837
+ serializationType: "protocol-buffer",
12838
+ protocolBuffer: "PBVideoPlayer"
12705
12839
  }
12706
12840
  };
12707
12841
 
@@ -12757,6 +12891,12 @@
12757
12891
  create() {
12758
12892
  // TODO: this is a hack.
12759
12893
  return PBVisibilityComponent.decode(new Uint8Array());
12894
+ },
12895
+ jsonSchema: {
12896
+ type: "object",
12897
+ properties: {},
12898
+ serializationType: "protocol-buffer",
12899
+ protocolBuffer: "PBVisibilityComponent"
12760
12900
  }
12761
12901
  };
12762
12902
 
@@ -12775,7 +12915,10 @@
12775
12915
  /** @public */ const MeshRenderer$2 = engine => engine.defineComponentFromSchema("core::MeshRenderer", MeshRendererSchema);
12776
12916
  /** @public */ const NftShape$1 = engine => engine.defineComponentFromSchema("core::NftShape", NftShapeSchema);
12777
12917
  /** @public */ const PointerEvents$1 = engine => engine.defineComponentFromSchema("core::PointerEvents", PointerEventsSchema);
12778
- /** @public */ const PointerEventsResult$1 = engine => engine.defineComponentFromSchema("core::PointerEventsResult", PointerEventsResultSchema);
12918
+ /** @public */ const PointerEventsResult$1 = (engine) => engine.defineValueSetComponentFromSchema("core::PointerEventsResult", PointerEventsResultSchema, {
12919
+ timestampFunction: (t) => t.timestamp,
12920
+ maxElements: 100
12921
+ });
12779
12922
  /** @public */ const PointerLock$1 = engine => engine.defineComponentFromSchema("core::PointerLock", PointerLockSchema);
12780
12923
  /** @public */ const Raycast$1 = engine => engine.defineComponentFromSchema("core::Raycast", RaycastSchema);
12781
12924
  /** @public */ const RaycastResult$1 = engine => engine.defineComponentFromSchema("core::RaycastResult", RaycastResultSchema);
@@ -13023,6 +13166,38 @@
13023
13166
  parent: 0,
13024
13167
  ...value
13025
13168
  };
13169
+ },
13170
+ jsonSchema: {
13171
+ type: 'object',
13172
+ properties: {
13173
+ position: {
13174
+ type: 'object',
13175
+ properties: {
13176
+ x: { type: 'number' },
13177
+ y: { type: 'number' },
13178
+ z: { type: 'number' }
13179
+ }
13180
+ },
13181
+ scale: {
13182
+ type: 'object',
13183
+ properties: {
13184
+ x: { type: 'number' },
13185
+ y: { type: 'number' },
13186
+ z: { type: 'number' }
13187
+ }
13188
+ },
13189
+ rotation: {
13190
+ type: 'object',
13191
+ properties: {
13192
+ x: { type: 'number' },
13193
+ y: { type: 'number' },
13194
+ z: { type: 'number' },
13195
+ w: { type: 'number' }
13196
+ }
13197
+ },
13198
+ parent: { type: 'integer' }
13199
+ },
13200
+ serializationType: 'transform'
13026
13201
  }
13027
13202
  };
13028
13203
  function defineTransformComponent(engine) {
@@ -13098,7 +13273,6 @@
13098
13273
  PBNftShape: PBNftShape,
13099
13274
  PBPointerEvents: PBPointerEvents,
13100
13275
  PBPointerEventsResult: PBPointerEventsResult,
13101
- PBPointerEventsResult_PointerCommand: PBPointerEventsResult_PointerCommand,
13102
13276
  PBPointerEvents_Entry: PBPointerEvents_Entry,
13103
13277
  PBPointerEvents_Info: PBPointerEvents_Info,
13104
13278
  PBPointerLock: PBPointerLock,
@@ -13239,8 +13413,13 @@
13239
13413
  return ((unsignedCRC32(bytes) + MAX_STATIC_COMPONENT) & 4294967295) >>> 0;
13240
13414
  }
13241
13415
 
13416
+ /* istanbul ignore file */
13417
+ const __DEV__ = (typeof DEBUG === 'boolean' && DEBUG) ||
13418
+ (typeof process === 'object' &&
13419
+ (process.env?.NODE_ENV !== 'production' || process.env?.NODE_ENV === 'development')) ||
13420
+ false;
13242
13421
  function checkNotThenable(t, error) {
13243
- if (globalThis.DEBUG) {
13422
+ if (__DEV__) {
13244
13423
  if (t && typeof t === 'object' && typeof t.then === 'function') {
13245
13424
  throw new Error(error);
13246
13425
  }
@@ -13269,6 +13448,11 @@
13269
13448
  },
13270
13449
  create() {
13271
13450
  return [];
13451
+ },
13452
+ jsonSchema: {
13453
+ type: 'array',
13454
+ items: type.jsonSchema,
13455
+ serializationType: 'array'
13272
13456
  }
13273
13457
  };
13274
13458
  };
@@ -13285,6 +13469,10 @@
13285
13469
  },
13286
13470
  create() {
13287
13471
  return false;
13472
+ },
13473
+ jsonSchema: {
13474
+ type: 'boolean',
13475
+ serializationType: 'boolean'
13288
13476
  }
13289
13477
  };
13290
13478
 
@@ -13300,6 +13488,10 @@
13300
13488
  },
13301
13489
  create() {
13302
13490
  return 0;
13491
+ },
13492
+ jsonSchema: {
13493
+ type: 'integer',
13494
+ serializationType: 'int64'
13303
13495
  }
13304
13496
  };
13305
13497
  /**
@@ -13314,6 +13506,10 @@
13314
13506
  },
13315
13507
  create() {
13316
13508
  return 0;
13509
+ },
13510
+ jsonSchema: {
13511
+ type: 'integer',
13512
+ serializationType: 'int32'
13317
13513
  }
13318
13514
  };
13319
13515
  /**
@@ -13328,6 +13524,10 @@
13328
13524
  },
13329
13525
  create() {
13330
13526
  return 0;
13527
+ },
13528
+ jsonSchema: {
13529
+ type: 'integer',
13530
+ serializationType: 'int16'
13331
13531
  }
13332
13532
  };
13333
13533
  /**
@@ -13342,6 +13542,10 @@
13342
13542
  },
13343
13543
  create() {
13344
13544
  return 0;
13545
+ },
13546
+ jsonSchema: {
13547
+ type: 'integer',
13548
+ serializationType: 'int8'
13345
13549
  }
13346
13550
  };
13347
13551
 
@@ -13357,6 +13561,10 @@
13357
13561
  },
13358
13562
  create() {
13359
13563
  return '';
13564
+ },
13565
+ jsonSchema: {
13566
+ type: 'string',
13567
+ serializationType: 'utf8-string'
13360
13568
  }
13361
13569
  };
13362
13570
  /**
@@ -13397,6 +13605,10 @@
13397
13605
  }
13398
13606
  }
13399
13607
  }
13608
+ /**
13609
+ * @internal
13610
+ */
13611
+ const IntEnumReflectionType = 'enum-int';
13400
13612
  /**
13401
13613
  * @internal
13402
13614
  */
@@ -13411,14 +13623,28 @@
13411
13623
  },
13412
13624
  create() {
13413
13625
  return defaultValue;
13626
+ },
13627
+ jsonSchema: {
13628
+ // JSON-schema
13629
+ type: 'integer',
13630
+ enum: Object.values(enumObject).filter((item) => Number.isInteger(item)),
13631
+ default: defaultValue,
13632
+ // @dcl/ecs Schema Spec
13633
+ serializationType: IntEnumReflectionType,
13634
+ enumObject
13414
13635
  }
13415
13636
  };
13416
13637
  };
13638
+ /**
13639
+ * @internal
13640
+ */
13641
+ const StringEnumReflectionType = 'enum-string';
13417
13642
  /**
13418
13643
  * @internal
13419
13644
  */
13420
13645
  const StringEnum = (enumObject, defaultValue) => {
13421
13646
  validateMemberValuesAreStrings(enumObject);
13647
+ // String enum has the exact mapping from key (our reference in code) to values
13422
13648
  return {
13423
13649
  serialize(value, builder) {
13424
13650
  FlatString.serialize(value, builder);
@@ -13428,6 +13654,15 @@
13428
13654
  },
13429
13655
  create() {
13430
13656
  return defaultValue;
13657
+ },
13658
+ jsonSchema: {
13659
+ // JSON-schema
13660
+ type: 'string',
13661
+ enum: Object.values(enumObject),
13662
+ default: defaultValue,
13663
+ // @dcl/ecs Schema Spec
13664
+ serializationType: StringEnumReflectionType,
13665
+ enumObject
13431
13666
  }
13432
13667
  };
13433
13668
  };
@@ -13444,6 +13679,10 @@
13444
13679
  },
13445
13680
  create() {
13446
13681
  return 0.0;
13682
+ },
13683
+ jsonSchema: {
13684
+ type: 'number',
13685
+ serializationType: 'float32'
13447
13686
  }
13448
13687
  };
13449
13688
  /**
@@ -13458,6 +13697,10 @@
13458
13697
  },
13459
13698
  create() {
13460
13699
  return 0.0;
13700
+ },
13701
+ jsonSchema: {
13702
+ type: 'number',
13703
+ serializationType: 'float64'
13461
13704
  }
13462
13705
  };
13463
13706
 
@@ -13479,6 +13722,15 @@
13479
13722
  },
13480
13723
  create() {
13481
13724
  return { r: 0, g: 0, b: 0 };
13725
+ },
13726
+ jsonSchema: {
13727
+ type: 'object',
13728
+ properties: {
13729
+ r: { type: 'number' },
13730
+ g: { type: 'number' },
13731
+ b: { type: 'number' }
13732
+ },
13733
+ serializationType: 'color3'
13482
13734
  }
13483
13735
  };
13484
13736
 
@@ -13502,6 +13754,16 @@
13502
13754
  },
13503
13755
  create() {
13504
13756
  return { r: 0, g: 0, b: 0, a: 0 };
13757
+ },
13758
+ jsonSchema: {
13759
+ type: 'object',
13760
+ properties: {
13761
+ r: { type: 'number' },
13762
+ g: { type: 'number' },
13763
+ b: { type: 'number' },
13764
+ a: { type: 'number' }
13765
+ },
13766
+ serializationType: 'color4'
13505
13767
  }
13506
13768
  };
13507
13769
 
@@ -13517,6 +13779,10 @@
13517
13779
  },
13518
13780
  create() {
13519
13781
  return 0;
13782
+ },
13783
+ jsonSchema: {
13784
+ type: 'integer',
13785
+ serializationType: 'entity'
13520
13786
  }
13521
13787
  };
13522
13788
 
@@ -13540,6 +13806,16 @@
13540
13806
  },
13541
13807
  create() {
13542
13808
  return { x: 0, y: 0, z: 0, w: 0 };
13809
+ },
13810
+ jsonSchema: {
13811
+ type: 'object',
13812
+ properties: {
13813
+ x: { type: 'number' },
13814
+ y: { type: 'number' },
13815
+ z: { type: 'number' },
13816
+ w: { type: 'number' }
13817
+ },
13818
+ serializationType: 'quaternion'
13543
13819
  }
13544
13820
  };
13545
13821
 
@@ -13561,6 +13837,16 @@
13561
13837
  },
13562
13838
  create() {
13563
13839
  return { x: 0, y: 0, z: 0 };
13840
+ },
13841
+ jsonSchema: {
13842
+ type: 'object',
13843
+ properties: {
13844
+ x: { type: 'number' },
13845
+ y: { type: 'number' },
13846
+ z: { type: 'number' },
13847
+ w: { type: 'number' }
13848
+ },
13849
+ serializationType: 'vector3'
13564
13850
  }
13565
13851
  };
13566
13852
 
@@ -13568,6 +13854,10 @@
13568
13854
  * @internal
13569
13855
  */
13570
13856
  const IMap = (spec, defaultValue) => {
13857
+ const specReflection = Object.keys(spec).reduce((specReflection, currentKey) => {
13858
+ specReflection[currentKey] = spec[currentKey].jsonSchema;
13859
+ return specReflection;
13860
+ }, {});
13571
13861
  return {
13572
13862
  serialize(value, builder) {
13573
13863
  for (const key in spec) {
@@ -13594,6 +13884,11 @@
13594
13884
  newValue[key] = spec[key].create();
13595
13885
  }
13596
13886
  return { ...newValue, ...defaultValue, ...base };
13887
+ },
13888
+ jsonSchema: {
13889
+ type: 'object',
13890
+ properties: specReflection,
13891
+ serializationType: 'map'
13597
13892
  }
13598
13893
  };
13599
13894
  };
@@ -13620,6 +13915,11 @@
13620
13915
  },
13621
13916
  create() {
13622
13917
  return undefined;
13918
+ },
13919
+ jsonSchema: {
13920
+ type: spec.jsonSchema.type,
13921
+ serializationType: 'optional',
13922
+ optionalJsonSchema: spec.jsonSchema
13623
13923
  }
13624
13924
  };
13625
13925
  };
@@ -14144,7 +14444,8 @@
14144
14444
  CrdtMessageType[CrdtMessageType["PUT_COMPONENT"] = 1] = "PUT_COMPONENT";
14145
14445
  CrdtMessageType[CrdtMessageType["DELETE_COMPONENT"] = 2] = "DELETE_COMPONENT";
14146
14446
  CrdtMessageType[CrdtMessageType["DELETE_ENTITY"] = 3] = "DELETE_ENTITY";
14147
- CrdtMessageType[CrdtMessageType["MAX_MESSAGE_TYPE"] = 4] = "MAX_MESSAGE_TYPE";
14447
+ CrdtMessageType[CrdtMessageType["APPEND_VALUE"] = 4] = "APPEND_VALUE";
14448
+ CrdtMessageType[CrdtMessageType["MAX_MESSAGE_TYPE"] = 5] = "MAX_MESSAGE_TYPE";
14148
14449
  })(exports.CrdtMessageType || (exports.CrdtMessageType = {}));
14149
14450
  /**
14150
14451
  * @public
@@ -14317,6 +14618,54 @@
14317
14618
  DeleteComponent.read = read;
14318
14619
  })(exports.DeleteComponent || (exports.DeleteComponent = {}));
14319
14620
 
14621
+ /**
14622
+ * @internal
14623
+ */
14624
+ exports.AppendValueOperation = void 0;
14625
+ (function (AppendValueOperation) {
14626
+ AppendValueOperation.MESSAGE_HEADER_LENGTH = 16;
14627
+ /**
14628
+ * Call this function for an optimal writing data passing the ByteBuffer
14629
+ * already allocated
14630
+ */
14631
+ function write(entity, timestamp, componentId, data, buf) {
14632
+ // reserve the beginning
14633
+ const startMessageOffset = buf.incrementWriteOffset(CRDT_MESSAGE_HEADER_LENGTH + AppendValueOperation.MESSAGE_HEADER_LENGTH);
14634
+ // write body
14635
+ buf.writeBuffer(data, false);
14636
+ const messageLength = buf.currentWriteOffset() - startMessageOffset;
14637
+ // Write CrdtMessage header
14638
+ buf.setUint32(startMessageOffset, messageLength);
14639
+ buf.setUint32(startMessageOffset + 4, exports.CrdtMessageType.APPEND_VALUE);
14640
+ // Write ComponentOperation header
14641
+ buf.setUint32(startMessageOffset + 8, entity);
14642
+ buf.setUint32(startMessageOffset + 12, componentId);
14643
+ buf.setUint32(startMessageOffset + 16, timestamp);
14644
+ const newLocal = messageLength - AppendValueOperation.MESSAGE_HEADER_LENGTH - CRDT_MESSAGE_HEADER_LENGTH;
14645
+ buf.setUint32(startMessageOffset + 20, newLocal);
14646
+ }
14647
+ AppendValueOperation.write = write;
14648
+ function read(buf) {
14649
+ const header = exports.CrdtMessageProtocol.readHeader(buf);
14650
+ /* istanbul ignore if */
14651
+ if (!header) {
14652
+ return null;
14653
+ }
14654
+ /* istanbul ignore if */
14655
+ if (header.type !== exports.CrdtMessageType.APPEND_VALUE) {
14656
+ throw new Error('AppendValueOperation tried to read another message type.');
14657
+ }
14658
+ return {
14659
+ ...header,
14660
+ entityId: buf.readUint32(),
14661
+ componentId: buf.readUint32(),
14662
+ timestamp: buf.readUint32(),
14663
+ data: buf.readBuffer()
14664
+ };
14665
+ }
14666
+ AppendValueOperation.read = read;
14667
+ })(exports.AppendValueOperation || (exports.AppendValueOperation = {}));
14668
+
14320
14669
  /**
14321
14670
  * @internal
14322
14671
  */
@@ -14423,7 +14772,6 @@
14423
14772
  if (header.type === exports.CrdtMessageType.DELETE_COMPONENT) {
14424
14773
  const message = exports.DeleteComponent.read(buffer);
14425
14774
  receivedMessages.push({
14426
- ...header,
14427
14775
  ...message,
14428
14776
  transportId,
14429
14777
  messageBuffer: buffer.buffer().subarray(offset, buffer.currentReadOffset())
@@ -14432,7 +14780,6 @@
14432
14780
  else if (header.type === exports.CrdtMessageType.PUT_COMPONENT) {
14433
14781
  const message = exports.PutComponentOperation.read(buffer);
14434
14782
  receivedMessages.push({
14435
- ...header,
14436
14783
  ...message,
14437
14784
  transportId,
14438
14785
  messageBuffer: buffer.buffer().subarray(offset, buffer.currentReadOffset())
@@ -14441,7 +14788,14 @@
14441
14788
  else if (header.type === exports.CrdtMessageType.DELETE_ENTITY) {
14442
14789
  const message = exports.DeleteEntity.read(buffer);
14443
14790
  receivedMessages.push({
14444
- ...header,
14791
+ ...message,
14792
+ transportId,
14793
+ messageBuffer: buffer.buffer().subarray(offset, buffer.currentReadOffset())
14794
+ });
14795
+ }
14796
+ else if (header.type === exports.CrdtMessageType.APPEND_VALUE) {
14797
+ const message = exports.AppendValueOperation.read(buffer);
14798
+ receivedMessages.push({
14445
14799
  ...message,
14446
14800
  transportId,
14447
14801
  messageBuffer: buffer.buffer().subarray(offset, buffer.currentReadOffset())
@@ -14487,13 +14841,13 @@
14487
14841
  }
14488
14842
  const component = engine.getComponentOrNull(msg.componentId);
14489
14843
  if (component) {
14490
- const [conflictMessage] = component.updateFromCrdt(msg);
14844
+ const [conflictMessage, value] = component.updateFromCrdt(msg);
14491
14845
  if (conflictMessage) {
14492
14846
  const offset = bufferForOutdated.currentWriteOffset();
14493
14847
  if (conflictMessage.type === exports.CrdtMessageType.PUT_COMPONENT) {
14494
14848
  exports.PutComponentOperation.write(msg.entityId, conflictMessage.timestamp, conflictMessage.componentId, conflictMessage.data, bufferForOutdated);
14495
14849
  }
14496
- else {
14850
+ else if (conflictMessage.type === exports.CrdtMessageType.DELETE_COMPONENT) {
14497
14851
  exports.DeleteComponent.write(msg.entityId, component.componentId, conflictMessage.timestamp, bufferForOutdated);
14498
14852
  }
14499
14853
  outdatedMessages.push({
@@ -14504,7 +14858,7 @@
14504
14858
  else {
14505
14859
  // Add message to transport queue to be processed by others transports
14506
14860
  broadcastMessages.push(msg);
14507
- onProcessEntityComponentChange && onProcessEntityComponentChange(msg.entityId, msg.type, component);
14861
+ onProcessEntityComponentChange && onProcessEntityComponentChange(msg.entityId, msg.type, component, value);
14508
14862
  }
14509
14863
  }
14510
14864
  }
@@ -14543,11 +14897,19 @@
14543
14897
  else if (message.type === exports.CrdtMessageType.DELETE_COMPONENT) {
14544
14898
  exports.DeleteComponent.write(message.entityId, component.componentId, message.timestamp, buffer);
14545
14899
  }
14900
+ else if (message.type === exports.CrdtMessageType.APPEND_VALUE) {
14901
+ exports.AppendValueOperation.write(message.entityId, message.timestamp, message.componentId, message.data, buffer);
14902
+ }
14546
14903
  crdtMessages.push({
14547
14904
  ...message,
14548
14905
  messageBuffer: buffer.buffer().subarray(offset, buffer.currentWriteOffset())
14549
14906
  });
14550
- onProcessEntityComponentChange && onProcessEntityComponentChange(message.entityId, message.type, component);
14907
+ if (onProcessEntityComponentChange) {
14908
+ const rawValue = message.type === exports.CrdtMessageType.PUT_COMPONENT || message.type === exports.CrdtMessageType.APPEND_VALUE
14909
+ ? component.get(message.entityId)
14910
+ : undefined;
14911
+ onProcessEntityComponentChange(message.entityId, message.type, component, rawValue);
14912
+ }
14551
14913
  }
14552
14914
  }
14553
14915
  }
@@ -14658,7 +15020,7 @@
14658
15020
  timestamps.set(entity, newTimestamp);
14659
15021
  return newTimestamp;
14660
15022
  }
14661
- function createUpdateFromCrdt(componentId, timestamps, schema, data) {
15023
+ function createUpdateLwwFromCrdt(componentId, timestamps, schema, data) {
14662
15024
  /**
14663
15025
  * Process the received message only if the lamport number recieved is higher
14664
15026
  * than the stored one. If its lower, we spread it to the network to correct the peer.
@@ -14759,7 +15121,7 @@
14759
15121
  return [null, data.get(entity)];
14760
15122
  };
14761
15123
  }
14762
- function createGetCrdtMessages(componentId, timestamps, dirtyIterator, schema, data) {
15124
+ function createGetCrdtMessagesForLww(componentId, timestamps, dirtyIterator, schema, data) {
14763
15125
  return function* () {
14764
15126
  for (const entity of dirtyIterator) {
14765
15127
  const newTimestamp = incrementTimestamp(entity, timestamps);
@@ -14802,12 +15164,11 @@
14802
15164
  get componentName() {
14803
15165
  return componentName;
14804
15166
  },
14805
- default() {
14806
- return schema.create();
14807
- },
14808
- isDirty(entity) {
14809
- return dirtyIterator.has(entity);
15167
+ get componentType() {
15168
+ // a getter is used here to prevent accidental changes
15169
+ return 0 /* ComponentType.LastWriteWinElementSet */;
14810
15170
  },
15171
+ schema,
14811
15172
  has(entity) {
14812
15173
  return data.has(entity);
14813
15174
  },
@@ -14875,20 +15236,8 @@
14875
15236
  yield entity;
14876
15237
  }
14877
15238
  },
14878
- getCrdtUpdates: createGetCrdtMessages(componentId, timestamps, dirtyIterator, schema, data),
14879
- toBinary(entity) {
14880
- const component = data.get(entity);
14881
- if (!component) {
14882
- throw new Error(`[toBinary] Component ${componentName} for ${entity} not found`);
14883
- }
14884
- const writeBuffer = new ReadWriteByteBuffer();
14885
- schema.serialize(component, writeBuffer);
14886
- return writeBuffer;
14887
- },
14888
- updateFromCrdt: createUpdateFromCrdt(componentId, timestamps, schema, data),
14889
- deserialize(buffer) {
14890
- return schema.deserialize(buffer);
14891
- }
15239
+ getCrdtUpdates: createGetCrdtMessagesForLww(componentId, timestamps, dirtyIterator, schema, data),
15240
+ updateFromCrdt: createUpdateLwwFromCrdt(componentId, timestamps, schema, data)
14892
15241
  };
14893
15242
  }
14894
15243
 
@@ -14937,6 +15286,135 @@
14937
15286
  };
14938
15287
  }
14939
15288
 
15289
+ const emptyReadonlySet = freezeSet(new Set());
15290
+ function frozenError() {
15291
+ throw new Error('The set is frozen');
15292
+ }
15293
+ function freezeSet(set) {
15294
+ set.add = frozenError;
15295
+ set.clear = frozenError;
15296
+ return set;
15297
+ }
15298
+ function sortByTimestamp(a, b) {
15299
+ return a.timestamp > b.timestamp ? 1 : -1;
15300
+ }
15301
+ /**
15302
+ * @internal
15303
+ */
15304
+ function createValueSetComponentDefinitionFromSchema(componentName, componentId, schema, options) {
15305
+ const data = new Map();
15306
+ const dirtyIterator = new Set();
15307
+ const queuedCommands = [];
15308
+ // only sort the array if the latest (N) element has a timestamp <= N-1
15309
+ function shouldSort(row) {
15310
+ const len = row.raw.length;
15311
+ if (len > 1 && row.raw[len - 1].timestamp <= row.raw[len - 2].timestamp) {
15312
+ return true;
15313
+ }
15314
+ return false;
15315
+ }
15316
+ function gotUpdated(entity) {
15317
+ const row = data.get(entity);
15318
+ /* istanbul ignore else */
15319
+ if (row) {
15320
+ if (shouldSort(row)) {
15321
+ row.raw.sort(sortByTimestamp);
15322
+ }
15323
+ while (row.raw.length > options.maxElements) {
15324
+ row.raw.shift();
15325
+ }
15326
+ const frozenSet = freezeSet(new Set(row?.raw.map(($) => $.value)));
15327
+ row.frozenSet = frozenSet;
15328
+ return frozenSet;
15329
+ }
15330
+ else {
15331
+ /* istanbul ignore next */
15332
+ return emptyReadonlySet;
15333
+ }
15334
+ }
15335
+ function append(entity, value) {
15336
+ let row = data.get(entity);
15337
+ if (!row) {
15338
+ row = { raw: [], frozenSet: emptyReadonlySet };
15339
+ data.set(entity, row);
15340
+ }
15341
+ const usedValue = schema.extend ? schema.extend(value) : value;
15342
+ const timestamp = options.timestampFunction(usedValue);
15343
+ if (__DEV__) {
15344
+ // only freeze the objects in dev mode to warn the developers because
15345
+ // it is an expensive operation
15346
+ Object.freeze(usedValue);
15347
+ }
15348
+ row.raw.push({ value: usedValue, timestamp });
15349
+ return { set: gotUpdated(entity), value: usedValue };
15350
+ }
15351
+ const ret = {
15352
+ get componentId() {
15353
+ return componentId;
15354
+ },
15355
+ get componentName() {
15356
+ return componentName;
15357
+ },
15358
+ get componentType() {
15359
+ // a getter is used here to prevent accidental changes
15360
+ return 1 /* ComponentType.GrowOnlyValueSet */;
15361
+ },
15362
+ schema,
15363
+ has(entity) {
15364
+ return data.has(entity);
15365
+ },
15366
+ entityDeleted(entity) {
15367
+ data.delete(entity);
15368
+ },
15369
+ get(entity) {
15370
+ const values = data.get(entity);
15371
+ if (values) {
15372
+ return values.frozenSet;
15373
+ }
15374
+ else {
15375
+ return emptyReadonlySet;
15376
+ }
15377
+ },
15378
+ addValue(entity, rawValue) {
15379
+ const { set, value } = append(entity, rawValue);
15380
+ dirtyIterator.add(entity);
15381
+ const buf = new ReadWriteByteBuffer();
15382
+ schema.serialize(value, buf);
15383
+ queuedCommands.push({
15384
+ componentId,
15385
+ data: buf.toBinary(),
15386
+ entityId: entity,
15387
+ timestamp: 0,
15388
+ type: exports.CrdtMessageType.APPEND_VALUE
15389
+ });
15390
+ return set;
15391
+ },
15392
+ *iterator() {
15393
+ for (const [entity, component] of data) {
15394
+ yield [entity, component.frozenSet];
15395
+ }
15396
+ },
15397
+ *dirtyIterator() {
15398
+ for (const entity of dirtyIterator) {
15399
+ yield entity;
15400
+ }
15401
+ },
15402
+ getCrdtUpdates() {
15403
+ // return a copy of the commands, and then clear the local copy
15404
+ dirtyIterator.clear();
15405
+ return queuedCommands.splice(0, queuedCommands.length);
15406
+ },
15407
+ updateFromCrdt(_body) {
15408
+ if (_body.type === exports.CrdtMessageType.APPEND_VALUE) {
15409
+ const buf = new ReadWriteByteBuffer(_body.data);
15410
+ append(_body.entityId, schema.deserialize(buf));
15411
+ }
15412
+ return [null, undefined];
15413
+ }
15414
+ };
15415
+ return ret;
15416
+ }
15417
+
14940
15418
  const InputCommands = [
14941
15419
  0 /* InputAction.IA_POINTER */,
14942
15420
  1 /* InputAction.IA_PRIMARY */,
@@ -14952,69 +15430,71 @@
14952
15430
  12 /* InputAction.IA_ACTION_5 */,
14953
15431
  13 /* InputAction.IA_ACTION_6 */
14954
15432
  ];
14955
- const InternalInputStateSchema = {
14956
- timestampLastUpdate: exports.Schemas.Number,
14957
- currentTimestamp: exports.Schemas.Number,
14958
- buttonState: exports.Schemas.Array(exports.Schemas.Map({
14959
- value: exports.Schemas.Boolean,
14960
- ts: exports.Schemas.Number
14961
- }))
14962
- };
14963
- const TimestampUpdateSystemPriority = 1 << 20;
14964
- const ButtonStateUpdateSystemPriority = 0;
15433
+ const InputStateUpdateSystemPriority = 1 << 20;
14965
15434
  /**
14966
15435
  * @internal
14967
15436
  */
14968
15437
  function createInputSystem(engine) {
14969
15438
  const PointerEventsResult = PointerEventsResult$1(engine);
14970
- const InternalInputStateComponent = engine.defineComponent('@dcl/sdk/InternalInputStateSchema', InternalInputStateSchema);
14971
- InternalInputStateComponent.create(engine.RootEntity, {
14972
- buttonState: Array.from({ length: InputCommands.length }, () => ({
14973
- ts: 0,
14974
- value: false
14975
- }))
14976
- });
14977
- function timestampUpdateSystem() {
14978
- const state = InternalInputStateComponent.get(engine.RootEntity);
14979
- if (state.currentTimestamp > state.timestampLastUpdate) {
14980
- InternalInputStateComponent.getMutable(engine.RootEntity).timestampLastUpdate = state.currentTimestamp;
14981
- }
14982
- }
14983
- function* commandIterator() {
14984
- for (const [, value] of engine.getEntitiesWith(PointerEventsResult)) {
14985
- yield* value.commands;
15439
+ const globalState = {
15440
+ previousFrameMaxTimestamp: 0,
15441
+ currentFrameMaxTimestamp: 0,
15442
+ buttonState: new Map()
15443
+ };
15444
+ function findLastAction(pointerEventType, inputAction, entity) {
15445
+ const ascendingTimestampIterator = PointerEventsResult.get(entity);
15446
+ for (const command of Array.from(ascendingTimestampIterator).reverse()) {
15447
+ if (command.button === inputAction && command.state === pointerEventType) {
15448
+ return command;
15449
+ }
14986
15450
  }
14987
15451
  }
14988
- function findLastAction(pointerEventType, inputAction, entity) {
14989
- let commandToReturn = undefined;
14990
- for (const command of commandIterator()) {
14991
- if (command.button === inputAction &&
14992
- command.state === pointerEventType &&
14993
- (!entity || (command.hit && entity === command.hit.entityId))) {
14994
- if (!commandToReturn || command.timestamp >= commandToReturn.timestamp)
14995
- commandToReturn = command;
15452
+ function* findCommandsByActionDescending(inputAction, entity) {
15453
+ const ascendingTimestampIterator = PointerEventsResult.get(entity);
15454
+ for (const command of Array.from(ascendingTimestampIterator).reverse()) {
15455
+ if (command.button === inputAction) {
15456
+ yield command;
14996
15457
  }
14997
15458
  }
14998
- return commandToReturn;
14999
15459
  }
15000
15460
  function buttonStateUpdateSystem() {
15001
- const component = PointerEventsResult.getOrNull(engine.RootEntity);
15002
- if (!component)
15003
- return;
15004
- const state = InternalInputStateComponent.getMutable(engine.RootEntity);
15005
- for (const command of commandIterator()) {
15006
- if (command.timestamp > state.buttonState[command.button].ts) {
15007
- if (command.state === 1 /* PointerEventType.PET_DOWN */) {
15008
- state.buttonState[command.button].value = true;
15461
+ // first store the previous' frame timestamp
15462
+ let maxTimestamp = globalState.currentFrameMaxTimestamp;
15463
+ globalState.previousFrameMaxTimestamp = maxTimestamp;
15464
+ // then iterate over all new commands
15465
+ for (const [, commands] of engine.getEntitiesWith(PointerEventsResult)) {
15466
+ // TODO: adapt the gset component to have a cached "reversed" option by default
15467
+ const arrayCommands = Array.from(commands);
15468
+ for (let i = arrayCommands.length - 1; i >= 0; i--) {
15469
+ const command = arrayCommands[i];
15470
+ if (command.timestamp > maxTimestamp) {
15471
+ maxTimestamp = command.timestamp;
15009
15472
  }
15010
- else if (command.state === 0 /* PointerEventType.PET_UP */) {
15011
- state.buttonState[command.button].value = false;
15473
+ if (command.state === 0 /* PointerEventType.PET_UP */ || command.state === 1 /* PointerEventType.PET_DOWN */) {
15474
+ const prevCommand = globalState.buttonState.get(command.button);
15475
+ if (!prevCommand || command.timestamp > prevCommand.timestamp) {
15476
+ globalState.buttonState.set(command.button, command);
15477
+ }
15478
+ else {
15479
+ // since we are iterating a descending array, we can early finish the
15480
+ // loop
15481
+ break;
15482
+ }
15012
15483
  }
15013
15484
  }
15014
15485
  }
15486
+ // update current frame's max timestamp
15487
+ globalState.currentFrameMaxTimestamp = maxTimestamp;
15488
+ }
15489
+ engine.addSystem(buttonStateUpdateSystem, InputStateUpdateSystemPriority, '@dcl/ecs#inputSystem');
15490
+ function timestampIsCurrentFrame(timestamp) {
15491
+ if (timestamp > globalState.previousFrameMaxTimestamp && timestamp <= globalState.currentFrameMaxTimestamp) {
15492
+ return true;
15493
+ }
15494
+ else {
15495
+ return false;
15496
+ }
15015
15497
  }
15016
- engine.addSystem(buttonStateUpdateSystem, ButtonStateUpdateSystemPriority, '@dcl/ecs#buttonStateUpdateSystem');
15017
- engine.addSystem(timestampUpdateSystem, TimestampUpdateSystemPriority, '@dcl/ecs#timestampUpdateSystem');
15018
15498
  function getClick(inputAction, entity) {
15019
15499
  if (inputAction !== 3 /* InputAction.IA_ANY */) {
15020
15500
  return findClick(inputAction, entity);
@@ -15027,18 +15507,27 @@
15027
15507
  return null;
15028
15508
  }
15029
15509
  function findClick(inputAction, entity) {
15030
- // We search the last DOWN command sorted by timestamp
15031
- const down = findLastAction(1 /* PointerEventType.PET_DOWN */, inputAction, entity);
15032
- // We search the last UP command sorted by timestamp
15033
- if (!down)
15034
- return null;
15035
- const up = findLastAction(0 /* PointerEventType.PET_UP */, inputAction, entity);
15036
- if (!up)
15510
+ let down = null;
15511
+ let up = null;
15512
+ // We search the last UP & DOWN command sorted by timestamp descending
15513
+ for (const it of findCommandsByActionDescending(inputAction, entity)) {
15514
+ if (!up) {
15515
+ if (it.state === 0 /* PointerEventType.PET_UP */) {
15516
+ up = it;
15517
+ continue;
15518
+ }
15519
+ }
15520
+ else if (!down) {
15521
+ if (it.state === 1 /* PointerEventType.PET_DOWN */) {
15522
+ down = it;
15523
+ break;
15524
+ }
15525
+ }
15526
+ }
15527
+ if (!up || !down)
15037
15528
  return null;
15038
- const state = InternalInputStateComponent.get(engine.RootEntity);
15039
15529
  // If the DOWN command has happen before the UP commands, it means that that a clicked has happen
15040
- if (down.timestamp < up.timestamp && up.timestamp > state.timestampLastUpdate) {
15041
- InternalInputStateComponent.getMutable(engine.RootEntity).currentTimestamp = Math.max(up.timestamp, state.currentTimestamp);
15530
+ if (down.timestamp < up.timestamp && timestampIsCurrentFrame(up.timestamp)) {
15042
15531
  return { up, down };
15043
15532
  }
15044
15533
  return null;
@@ -15059,38 +15548,45 @@
15059
15548
  const command = findLastAction(pointerEventType, inputAction, entity);
15060
15549
  if (!command)
15061
15550
  return null;
15062
- const state = InternalInputStateComponent.get(engine.RootEntity);
15063
- if (command.timestamp > state.timestampLastUpdate) {
15064
- InternalInputStateComponent.getMutable(engine.RootEntity).currentTimestamp = Math.max(command.timestamp, state.currentTimestamp);
15551
+ if (timestampIsCurrentFrame(command.timestamp)) {
15065
15552
  return command;
15066
15553
  }
15067
15554
  else {
15068
15555
  return null;
15069
15556
  }
15070
15557
  }
15558
+ // returns true if there was a DOWN (in any past frame), and then an UP in the last frame
15071
15559
  function isClicked(inputAction, entity) {
15072
15560
  return getClick(inputAction, entity) !== null;
15073
15561
  }
15562
+ // returns true if the provided last action was triggered in the last frame
15074
15563
  function isTriggered(inputAction, pointerEventType, entity) {
15075
- return getInputCommand(inputAction, pointerEventType, entity) !== null;
15564
+ const command = findLastAction(pointerEventType, inputAction, entity);
15565
+ return (command && timestampIsCurrentFrame(command.timestamp)) || false;
15076
15566
  }
15567
+ // returns the global state of the input. This global state is updated from the system
15077
15568
  function isPressed(inputAction) {
15078
- return InternalInputStateComponent.get(engine.RootEntity).buttonState[inputAction].value;
15569
+ return globalState.buttonState.get(inputAction)?.state === 1 /* PointerEventType.PET_DOWN */;
15079
15570
  }
15080
15571
  return {
15081
- // @public
15082
15572
  isPressed,
15083
- // @internal
15084
15573
  getClick,
15085
- // @public
15086
15574
  getInputCommand,
15087
- // @internal
15088
15575
  isClicked,
15089
- // @public
15090
15576
  isTriggered
15091
15577
  };
15092
15578
  }
15093
15579
 
15580
+ /**
15581
+ * Component types are used to pick the wire protocol and the conflict resolution algorithm
15582
+ * @public
15583
+ */
15584
+ exports.ComponentType = void 0;
15585
+ (function (ComponentType) {
15586
+ ComponentType[ComponentType["LastWriteWinElementSet"] = 0] = "LastWriteWinElementSet";
15587
+ ComponentType[ComponentType["GrowOnlyValueSet"] = 1] = "GrowOnlyValueSet";
15588
+ })(exports.ComponentType || (exports.ComponentType = {}));
15589
+
15094
15590
  function preEngine() {
15095
15591
  const entityContainer = EntityContainer();
15096
15592
  const componentsDefinition = new Map();
@@ -15146,6 +15642,20 @@
15146
15642
  componentsDefinition.set(componentId, newComponent);
15147
15643
  return newComponent;
15148
15644
  }
15645
+ function defineValueSetComponentFromSchema(componentName, schema, options) {
15646
+ /* istanbul ignore next */
15647
+ if (sealed)
15648
+ throw new Error('Engine is already sealed. No components can be added at this stage');
15649
+ const componentId = componentNumberFromName(componentName);
15650
+ const prev = componentsDefinition.get(componentId);
15651
+ if (prev) {
15652
+ // TODO: assert spec === prev.spec
15653
+ return prev;
15654
+ }
15655
+ const newComponent = createValueSetComponentDefinitionFromSchema(componentName, componentId, schema, options);
15656
+ componentsDefinition.set(componentId, newComponent);
15657
+ return newComponent;
15658
+ }
15149
15659
  function defineComponent(componentName, mapSpec, constructorDefault) {
15150
15660
  if (sealed)
15151
15661
  throw new Error('Engine is already sealed. No components can be added at this stage');
@@ -15241,6 +15751,7 @@
15241
15751
  removeSystem,
15242
15752
  defineComponent,
15243
15753
  defineComponentFromSchema,
15754
+ defineValueSetComponentFromSchema,
15244
15755
  getEntitiesWith,
15245
15756
  getComponent,
15246
15757
  getComponentOrNull,
@@ -15276,6 +15787,7 @@
15276
15787
  removeSystem: partialEngine.removeSystem,
15277
15788
  defineComponent: partialEngine.defineComponent,
15278
15789
  defineComponentFromSchema: partialEngine.defineComponentFromSchema,
15790
+ defineValueSetComponentFromSchema: partialEngine.defineValueSetComponentFromSchema,
15279
15791
  registerComponentDefinition: partialEngine.registerComponentDefinition,
15280
15792
  getEntitiesWith: partialEngine.getEntitiesWith,
15281
15793
  getComponent: partialEngine.getComponent,
@@ -42180,8 +42692,7 @@
42180
42692
  }
42181
42693
  },
42182
42694
  filter(message) {
42183
- if ((message.type === exports.CrdtMessageType.PUT_COMPONENT || message.type === exports.CrdtMessageType.DELETE_COMPONENT) &&
42184
- message.componentId > MAX_STATIC_COMPONENT) {
42695
+ if (message.componentId > MAX_STATIC_COMPONENT) {
42185
42696
  return false;
42186
42697
  }
42187
42698
  return !!message;
@@ -42268,7 +42779,6 @@
42268
42779
  exports.PBNftShape = PBNftShape;
42269
42780
  exports.PBPointerEvents = PBPointerEvents;
42270
42781
  exports.PBPointerEventsResult = PBPointerEventsResult;
42271
- exports.PBPointerEventsResult_PointerCommand = PBPointerEventsResult_PointerCommand;
42272
42782
  exports.PBPointerEvents_Entry = PBPointerEvents_Entry;
42273
42783
  exports.PBPointerEvents_Info = PBPointerEvents_Info;
42274
42784
  exports.PBPointerLock = PBPointerLock;
@@ -42312,19 +42822,15 @@
42312
42822
  exports.VideoTexture = VideoTexture;
42313
42823
  exports.VisibilityComponent = VisibilityComponent;
42314
42824
  exports.components = index;
42315
- exports.createComponentDefinitionFromSchema = createComponentDefinitionFromSchema;
42316
42825
  exports.createEthereumProvider = createEthereumProvider;
42317
- exports.createGetCrdtMessages = createGetCrdtMessages;
42318
42826
  exports.createInputSystem = createInputSystem;
42319
42827
  exports.createPointerEventSystem = createPointerEventSystem;
42320
42828
  exports.createReactBasedUiSystem = createReactBasedUiSystem;
42321
42829
  exports.createTaskSystem = createTaskSystem;
42322
- exports.createUpdateFromCrdt = createUpdateFromCrdt;
42323
42830
  exports.cyclicParentingChecker = cyclicParentingChecker;
42324
42831
  exports.deepReadonly = deepReadonly;
42325
42832
  exports.engine = engine;
42326
42833
  exports.executeTask = executeTask;
42327
- exports.incrementTimestamp = incrementTimestamp;
42328
42834
  exports.inputSystem = inputSystem;
42329
42835
  exports.isListener = isListener;
42330
42836
  exports.onCommsMessage = onCommsMessage;