board-game-engine-react 0.0.16 → 0.0.18

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/.nycrc.json ADDED
@@ -0,0 +1,8 @@
1
+ {
2
+ "temp-dir": ".nyc_output",
3
+ "report-dir": "coverage",
4
+ "include": ["src/**/*.js"],
5
+ "exclude": ["**/*.spec.js", "**/node_modules/**", "e2e/**", "test-app/**"],
6
+ "instrument": false,
7
+ "sourceMap": false
8
+ }
package/babel.config.js CHANGED
@@ -1,9 +1,14 @@
1
+ const coverage = process.env.COVERAGE === '1'
2
+
1
3
  module.exports = {
2
4
  presets: [
3
5
  '@babel/preset-react',
4
6
  ['@babel/preset-env', { targets: { node: 'current' } }]
5
7
  ],
6
8
  plugins: [
7
- '@babel/plugin-proposal-object-rest-spread'
9
+ '@babel/plugin-proposal-object-rest-spread',
10
+ ...(coverage
11
+ ? [['istanbul', { include: ['src/**/*.js'], exclude: ['**/*.spec.js', '**/node_modules/**', 'e2e/**'] }]]
12
+ : [])
8
13
  ]
9
14
  }
@@ -5651,6 +5651,11 @@ function Space({
5651
5651
  }))), !entities.length && space.attributes.name));
5652
5652
  }
5653
5653
 
5654
+ function sameEntity(a, b) {
5655
+ const idA = a.entityId ?? a.attributes?.entityId;
5656
+ const idB = b.entityId ?? b.attributes?.entityId;
5657
+ return idA != null && idB != null && idA === idB;
5658
+ }
5654
5659
  function Entity({
5655
5660
  entity
5656
5661
  }) {
@@ -5658,9 +5663,10 @@ function Entity({
5658
5663
  clickTarget,
5659
5664
  allClickable
5660
5665
  } = useGame();
5661
- const isClickable = allClickable.has(entity);
5666
+ const isClickable = [...allClickable].some(c => sameEntity(c, entity));
5662
5667
  const attributes = entity.attributes;
5663
- switch (attributes.type) {
5668
+ const entityType = attributes.entityType ?? attributes.type;
5669
+ switch (entityType) {
5664
5670
  case 'Grid':
5665
5671
  return /*#__PURE__*/React.createElement(Grid, {
5666
5672
  grid: entity,
@@ -5679,7 +5685,7 @@ function Entity({
5679
5685
  clickTarget(entity);
5680
5686
  }
5681
5687
  },
5682
- className: ['entity', attributes.player && `player-${attributes.player}`, allClickable.has(entity) && 'entity--clickable'].filter(Boolean).join(' ')
5688
+ className: ['entity', attributes.player && `player-${attributes.player}`, isClickable && 'entity--clickable'].filter(Boolean).join(' ')
5683
5689
  }, entity.rule.displayProperties?.map((property, i) => /*#__PURE__*/React.createElement("div", {
5684
5690
  key: i
5685
5691
  }, property, ": ", entity.attributes[property]?.toString())));
@@ -5746,6 +5752,7 @@ function Game({
5746
5752
  loading,
5747
5753
  isSpectator
5748
5754
  }) {
5755
+ console.log('gameConnection?.getState?.()', gameConnection?.getState?.());
5749
5756
  const G = gameConnection?.getState?.().state.G;
5750
5757
  return G ? /*#__PURE__*/React.createElement(GameProvider, {
5751
5758
  gameConnection: gameConnection,