From 6255a314240b1d36a8735f3dc7eb1672e16bac1a Mon Sep 17 00:00:00 2001 From: Kevin Ingersoll Date: Tue, 22 Aug 2023 02:09:39 -0700 Subject: [PATCH] chore: delete ecs-browser package (#1339) --- .changeset/khaki-doors-refuse.md | 5 + packages/ecs-browser/.gitignore | 1 - packages/ecs-browser/.npmignore | 7 - packages/ecs-browser/CHANGELOG.md | 462 ------------------ packages/ecs-browser/README.md | 3 - packages/ecs-browser/package.json | 38 +- packages/ecs-browser/src/Browser.tsx | 63 --- packages/ecs-browser/src/ComponentEditor.tsx | 46 -- .../ecs-browser/src/ComponentValueEditor.tsx | 36 -- .../ecs-browser/src/DraggableNumberLabel.tsx | 52 -- packages/ecs-browser/src/EntityEditor.tsx | 86 ---- .../src/QueryBuilder/QueryBuilder.tsx | 236 --------- .../src/QueryBuilder/StyledComponents.ts | 15 - .../ecs-browser/src/QueryBuilder/index.ts | 1 - packages/ecs-browser/src/StyledComponents.ts | 116 ----- packages/ecs-browser/src/ValueEditor.tsx | 135 ----- packages/ecs-browser/src/constants.ts | 1 - .../src/createBrowserDevComponents.ts | 17 - packages/ecs-browser/src/hooks.ts | 43 -- packages/ecs-browser/src/index.ts | 2 - packages/ecs-browser/src/shared.ts | 22 - packages/ecs-browser/src/types.ts | 14 - packages/ecs-browser/tsconfig.json | 17 - packages/ecs-browser/tsup.config.js | 11 - pnpm-lock.yaml | 83 +--- 25 files changed, 9 insertions(+), 1503 deletions(-) create mode 100644 .changeset/khaki-doors-refuse.md delete mode 100644 packages/ecs-browser/.gitignore delete mode 100644 packages/ecs-browser/.npmignore delete mode 100644 packages/ecs-browser/CHANGELOG.md delete mode 100644 packages/ecs-browser/README.md delete mode 100644 packages/ecs-browser/src/Browser.tsx delete mode 100644 packages/ecs-browser/src/ComponentEditor.tsx delete mode 100644 packages/ecs-browser/src/ComponentValueEditor.tsx delete mode 100644 packages/ecs-browser/src/DraggableNumberLabel.tsx delete mode 100644 packages/ecs-browser/src/EntityEditor.tsx delete mode 100644 packages/ecs-browser/src/QueryBuilder/QueryBuilder.tsx delete mode 100644 packages/ecs-browser/src/QueryBuilder/StyledComponents.ts delete mode 100644 packages/ecs-browser/src/QueryBuilder/index.ts delete mode 100644 packages/ecs-browser/src/StyledComponents.ts delete mode 100644 packages/ecs-browser/src/ValueEditor.tsx delete mode 100644 packages/ecs-browser/src/constants.ts delete mode 100644 packages/ecs-browser/src/createBrowserDevComponents.ts delete mode 100644 packages/ecs-browser/src/hooks.ts delete mode 100644 packages/ecs-browser/src/index.ts delete mode 100644 packages/ecs-browser/src/shared.ts delete mode 100644 packages/ecs-browser/src/types.ts delete mode 100644 packages/ecs-browser/tsconfig.json delete mode 100644 packages/ecs-browser/tsup.config.js diff --git a/.changeset/khaki-doors-refuse.md b/.changeset/khaki-doors-refuse.md new file mode 100644 index 0000000000..5220a732db --- /dev/null +++ b/.changeset/khaki-doors-refuse.md @@ -0,0 +1,5 @@ +--- +"@latticexyz/ecs-browser": major +--- + +Removes `ecs-browser` package. This has now been replaced by `dev-tools`, which comes out-of-the-box when creating a new MUD app from the templates (`pnpm create mud@next your-app-name`). We'll be adding deeper RECS support (querying for entities) in a future release. diff --git a/packages/ecs-browser/.gitignore b/packages/ecs-browser/.gitignore deleted file mode 100644 index 53c37a1660..0000000000 --- a/packages/ecs-browser/.gitignore +++ /dev/null @@ -1 +0,0 @@ -dist \ No newline at end of file diff --git a/packages/ecs-browser/.npmignore b/packages/ecs-browser/.npmignore deleted file mode 100644 index 2ceadb8f3a..0000000000 --- a/packages/ecs-browser/.npmignore +++ /dev/null @@ -1,7 +0,0 @@ -* - -!dist/** -!src/** -!package.json -!README.md -!CHANGELOG.md \ No newline at end of file diff --git a/packages/ecs-browser/CHANGELOG.md b/packages/ecs-browser/CHANGELOG.md deleted file mode 100644 index af746eeae1..0000000000 --- a/packages/ecs-browser/CHANGELOG.md +++ /dev/null @@ -1,462 +0,0 @@ -# Change Log - -## 2.0.0-next.3 - -### Patch Changes - -- Updated dependencies [[`331f0d63`](https://github.com/latticexyz/mud/commit/331f0d636f6f327824307570a63fb301d9b897d1)]: - - @latticexyz/std-client@2.0.0-next.3 - - @latticexyz/recs@2.0.0-next.3 - - @latticexyz/utils@2.0.0-next.3 - -## 2.0.0-next.2 - -### Patch Changes - -- Updated dependencies [[`48c51b52`](https://github.com/latticexyz/mud/commit/48c51b52acab147a2ed97903c43bafa9b6769473), [`b8a6158d`](https://github.com/latticexyz/mud/commit/b8a6158d63738ebfc1e7eb221909436d050c7e39)]: - - @latticexyz/std-client@2.0.0-next.2 - - @latticexyz/recs@2.0.0-next.2 - - @latticexyz/utils@2.0.0-next.2 - -## 2.0.0-next.1 - -### Patch Changes - -- Updated dependencies [[`e259ef79`](https://github.com/latticexyz/mud/commit/e259ef79f4d9026353176d0f74628cae50c2f69b), [`60cfd089`](https://github.com/latticexyz/mud/commit/60cfd089fc7a17b98864b631d265f36718df35a9), [`6c673325`](https://github.com/latticexyz/mud/commit/6c6733256f91cddb0e913217cbd8e02e6bc484c7), [`afdba793`](https://github.com/latticexyz/mud/commit/afdba793fd84abf17eef5ef59dd56fabe353c8bd)]: - - @latticexyz/std-client@2.0.0-next.1 - - @latticexyz/recs@2.0.0-next.1 - - @latticexyz/utils@2.0.0-next.1 - -## 2.0.0-next.0 - -### Patch Changes - -- Updated dependencies [[`1e2ad78e`](https://github.com/latticexyz/mud/commit/1e2ad78e277b551dd1b8efb0e4438fb10441644c), [`4e4a3415`](https://github.com/latticexyz/mud/commit/4e4a34150aeae988c8e61e25d55c227afb6c2d4b), [`53522998`](https://github.com/latticexyz/mud/commit/535229984565539e6168042150b45fe0f9b48b0f)]: - - @latticexyz/recs@2.0.0-next.0 - - @latticexyz/utils@2.0.0-next.0 - - @latticexyz/std-client@2.0.0-next.0 - -All notable changes to this project will be documented in this file. -See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. - -# [1.42.0](https://github.com/latticexyz/mud/compare/v1.41.0...v1.42.0) (2023-04-13) - -### Features - -- v2 event decoding ([#415](https://github.com/latticexyz/mud/issues/415)) ([374ed54](https://github.com/latticexyz/mud/commit/374ed542c3387a4ec2b36ab68ae534419aa58763)) - -# [1.41.0](https://github.com/latticexyz/mud/compare/v1.40.0...v1.41.0) (2023-03-09) - -**Note:** Version bump only for package @latticexyz/ecs-browser - -# [1.40.0](https://github.com/latticexyz/mud/compare/v1.39.0...v1.40.0) (2023-03-03) - -### Bug Fixes - -- **ecs-browser:** fix some errors in ecs-browser ([#420](https://github.com/latticexyz/mud/issues/420)) ([2a7ce21](https://github.com/latticexyz/mud/commit/2a7ce210553b2b9a6b2dffddac069be24802645f)) - -# [1.39.0](https://github.com/latticexyz/mud/compare/v1.38.0...v1.39.0) (2023-02-22) - -**Note:** Version bump only for package @latticexyz/ecs-browser - -# [1.38.0](https://github.com/latticexyz/mud/compare/v1.37.1...v1.38.0) (2023-02-22) - -**Note:** Version bump only for package @latticexyz/ecs-browser - -## [1.37.1](https://github.com/latticexyz/mud/compare/v1.37.0...v1.37.1) (2023-02-17) - -**Note:** Version bump only for package @latticexyz/ecs-browser - -# [1.37.0](https://github.com/latticexyz/mud/compare/v1.36.1...v1.37.0) (2023-02-16) - -### Bug Fixes - -- package entry points, peer dep versions ([#409](https://github.com/latticexyz/mud/issues/409)) ([66a7fd6](https://github.com/latticexyz/mud/commit/66a7fd6f74620ce02c60e3d55701d4740cc65251)) - -### Reverts - -- Revert "chore(release): publish v1.37.0" ([c934f53](https://github.com/latticexyz/mud/commit/c934f5388c1e56f2fe6390fdda30f5b9b1ea1c20)) - -## [1.36.1](https://github.com/latticexyz/mud/compare/v1.36.0...v1.36.1) (2023-02-16) - -**Note:** Version bump only for package @latticexyz/ecs-browser - -# [1.35.0](https://github.com/latticexyz/mud/compare/v1.34.0...v1.35.0) (2023-02-15) - -**Note:** Version bump only for package @latticexyz/ecs-browser - -# [1.34.0](https://github.com/latticexyz/mud/compare/v1.33.1...v1.34.0) (2023-01-29) - -**Note:** Version bump only for package @latticexyz/ecs-browser - -## [1.33.1](https://github.com/latticexyz/mud/compare/v1.33.0...v1.33.1) (2023-01-12) - -**Note:** Version bump only for package @latticexyz/ecs-browser - -# [1.33.0](https://github.com/latticexyz/mud/compare/v1.32.0...v1.33.0) (2023-01-12) - -**Note:** Version bump only for package @latticexyz/ecs-browser - -# [1.32.0](https://github.com/latticexyz/mud/compare/v1.31.3...v1.32.0) (2023-01-06) - -### Features - -- **ecs-browser:** replace react syntax highlighter with shiki and bundler with tsup ([#262](https://github.com/latticexyz/mud/issues/262)) ([915506d](https://github.com/latticexyz/mud/commit/915506d7e7ca0b5a68afb646388bb9d4bb689879)) - -## [1.31.3](https://github.com/latticexyz/mud/compare/v1.31.2...v1.31.3) (2022-12-16) - -**Note:** Version bump only for package @latticexyz/ecs-browser - -## [1.31.2](https://github.com/latticexyz/mud/compare/v1.31.1...v1.31.2) (2022-12-15) - -**Note:** Version bump only for package @latticexyz/ecs-browser - -## [1.31.1](https://github.com/latticexyz/mud/compare/v1.31.0...v1.31.1) (2022-12-15) - -**Note:** Version bump only for package @latticexyz/ecs-browser - -# [1.31.0](https://github.com/latticexyz/mud/compare/v1.30.1...v1.31.0) (2022-12-14) - -**Note:** Version bump only for package @latticexyz/ecs-browser - -## [1.30.1](https://github.com/latticexyz/mud/compare/v1.30.0...v1.30.1) (2022-12-02) - -**Note:** Version bump only for package @latticexyz/ecs-browser - -# [1.30.0](https://github.com/latticexyz/mud/compare/v1.29.0...v1.30.0) (2022-12-02) - -**Note:** Version bump only for package @latticexyz/ecs-browser - -# [1.29.0](https://github.com/latticexyz/mud/compare/v1.28.1...v1.29.0) (2022-11-29) - -**Note:** Version bump only for package @latticexyz/ecs-browser - -## [1.28.1](https://github.com/latticexyz/mud/compare/v1.28.0...v1.28.1) (2022-11-24) - -### Bug Fixes - -- typescript errors ([#253](https://github.com/latticexyz/mud/issues/253)) ([83e0c7a](https://github.com/latticexyz/mud/commit/83e0c7a1eda900d254a73115446c4ce38b531645)) - -# [1.28.0](https://github.com/latticexyz/mud/compare/v1.27.1...v1.28.0) (2022-11-20) - -**Note:** Version bump only for package @latticexyz/ecs-browser - -# [1.27.0](https://github.com/latticexyz/mud/compare/v1.26.0...v1.27.0) (2022-11-15) - -### Code Refactoring - -- **ecs-browser:** make dev components optional, remove unnecessary dependencies ([#235](https://github.com/latticexyz/mud/issues/235)) ([868ae02](https://github.com/latticexyz/mud/commit/868ae02d3707238403156d4457aef683da43f5bf)), closes [#231](https://github.com/latticexyz/mud/issues/231) - -### BREAKING CHANGES - -- **ecs-browser:** changes how props are handled, no longer are entities or other devComponent props - required, these are inferred or set as optional and the handling is conditonal now - -- Update packages/ecs-browser/src/ComponentEditor.tsx - -Co-authored-by: alvarius <89248902+alvrs@users.noreply.github.com> - -- Update packages/ecs-browser/src/ComponentEditor.tsx - -Co-authored-by: alvarius <89248902+alvrs@users.noreply.github.com> - -- feat(ecs-browser): migrate browser dev components to own function - -Move creation of the dev components needed for the Browser to be created outside of the Browser for -easier hooking into - -- fix(ecs-browser): remove unused import - -- fix(ecs-browser): fix from Kooshaba - -Co-authored-by: alvarius <89248902+alvrs@users.noreply.github.com> - -# [1.26.0](https://github.com/latticexyz/mud/compare/v1.25.1...v1.26.0) (2022-11-07) - -**Note:** Version bump only for package @latticexyz/ecs-browser - -## [1.25.1](https://github.com/latticexyz/mud/compare/v1.25.0...v1.25.1) (2022-11-03) - -**Note:** Version bump only for package @latticexyz/ecs-browser - -# [1.25.0](https://github.com/latticexyz/mud/compare/v1.24.1...v1.25.0) (2022-11-03) - -**Note:** Version bump only for package @latticexyz/ecs-browser - -## [1.24.1](https://github.com/latticexyz/mud/compare/v1.24.0...v1.24.1) (2022-10-29) - -**Note:** Version bump only for package @latticexyz/ecs-browser - -# [1.24.0](https://github.com/latticexyz/mud/compare/v1.23.1...v1.24.0) (2022-10-28) - -**Note:** Version bump only for package @latticexyz/ecs-browser - -## [1.23.1](https://github.com/latticexyz/mud/compare/v1.23.0...v1.23.1) (2022-10-28) - -**Note:** Version bump only for package @latticexyz/ecs-browser - -# [1.23.0](https://github.com/latticexyz/mud/compare/v1.22.0...v1.23.0) (2022-10-26) - -**Note:** Version bump only for package @latticexyz/ecs-browser - -# [1.22.0](https://github.com/latticexyz/mud/compare/v1.21.0...v1.22.0) (2022-10-26) - -**Note:** Version bump only for package @latticexyz/ecs-browser - -# [1.21.0](https://github.com/latticexyz/mud/compare/v1.20.0...v1.21.0) (2022-10-26) - -**Note:** Version bump only for package @latticexyz/ecs-browser - -# [1.20.0](https://github.com/latticexyz/mud/compare/v1.19.0...v1.20.0) (2022-10-22) - -**Note:** Version bump only for package @latticexyz/ecs-browser - -# [1.19.0](https://github.com/latticexyz/mud/compare/v1.18.0...v1.19.0) (2022-10-21) - -**Note:** Version bump only for package @latticexyz/ecs-browser - -# [1.18.0](https://github.com/latticexyz/mud/compare/v1.17.0...v1.18.0) (2022-10-21) - -### Bug Fixes - -- **ecs-browser:** remove component on contract from ecs-browser ([#205](https://github.com/latticexyz/mud/issues/205)) ([f08c6d1](https://github.com/latticexyz/mud/commit/f08c6d17af7201c81dff40d0a007a201f2b3bd00)) - -# [1.17.0](https://github.com/latticexyz/mud/compare/v1.16.0...v1.17.0) (2022-10-19) - -**Note:** Version bump only for package @latticexyz/ecs-browser - -# [1.16.0](https://github.com/latticexyz/mud/compare/v1.15.0...v1.16.0) (2022-10-19) - -**Note:** Version bump only for package @latticexyz/ecs-browser - -# [1.15.0](https://github.com/latticexyz/mud/compare/v1.14.2...v1.15.0) (2022-10-18) - -**Note:** Version bump only for package @latticexyz/ecs-browser - -## [1.14.2](https://github.com/latticexyz/mud/compare/v1.14.1...v1.14.2) (2022-10-18) - -**Note:** Version bump only for package @latticexyz/ecs-browser - -## [1.14.1](https://github.com/latticexyz/mud/compare/v1.14.0...v1.14.1) (2022-10-18) - -**Note:** Version bump only for package @latticexyz/ecs-browser - -# [1.14.0](https://github.com/latticexyz/mud/compare/v1.13.0...v1.14.0) (2022-10-18) - -**Note:** Version bump only for package @latticexyz/ecs-browser - -# [1.13.0](https://github.com/latticexyz/mud/compare/v1.12.0...v1.13.0) (2022-10-15) - -**Note:** Version bump only for package @latticexyz/ecs-browser - -# [1.12.0](https://github.com/latticexyz/mud/compare/v1.11.0...v1.12.0) (2022-10-12) - -**Note:** Version bump only for package @latticexyz/ecs-browser - -# [1.11.0](https://github.com/latticexyz/mud/compare/v1.10.0...v1.11.0) (2022-10-11) - -**Note:** Version bump only for package @latticexyz/ecs-browser - -# [1.10.0](https://github.com/latticexyz/mud/compare/v1.9.0...v1.10.0) (2022-10-11) - -### Features - -- **ecs-browser:** add support for modifying boolean values ([1dba52e](https://github.com/latticexyz/mud/commit/1dba52e6f50947786328ff37bb4a2b9c9b3fb877)) - -# [1.9.0](https://github.com/latticexyz/mud/compare/v1.8.0...v1.9.0) (2022-10-11) - -**Note:** Version bump only for package @latticexyz/ecs-browser - -# [1.8.0](https://github.com/latticexyz/mud/compare/v1.7.1...v1.8.0) (2022-10-07) - -**Note:** Version bump only for package @latticexyz/ecs-browser - -## [1.7.1](https://github.com/latticexyz/mud/compare/v1.7.0...v1.7.1) (2022-10-06) - -**Note:** Version bump only for package @latticexyz/ecs-browser - -# [1.7.0](https://github.com/latticexyz/mud/compare/v1.6.0...v1.7.0) (2022-10-06) - -### Bug Fixes - -- **ecs-browser:** do not early return for entity 0 ([bf36cc0](https://github.com/latticexyz/mud/commit/bf36cc0288449f0f7dce72e35a49b6c6f6a8fa2b)) - -# [1.6.0](https://github.com/latticexyz/mud/compare/v1.5.1...v1.6.0) (2022-10-04) - -**Note:** Version bump only for package @latticexyz/ecs-browser - -## [1.5.1](https://github.com/latticexyz/mud/compare/v1.5.0...v1.5.1) (2022-10-03) - -**Note:** Version bump only for package @latticexyz/ecs-browser - -# [1.5.0](https://github.com/latticexyz/mud/compare/v1.4.1...v1.5.0) (2022-10-03) - -**Note:** Version bump only for package @latticexyz/ecs-browser - -## [1.4.1](https://github.com/latticexyz/mud/compare/v1.4.0...v1.4.1) (2022-10-03) - -**Note:** Version bump only for package @latticexyz/ecs-browser - -# [1.4.0](https://github.com/latticexyz/mud/compare/v1.3.0...v1.4.0) (2022-10-03) - -**Note:** Version bump only for package @latticexyz/ecs-browser - -# [1.3.0](https://github.com/latticexyz/mud/compare/v1.2.0...v1.3.0) (2022-09-30) - -**Note:** Version bump only for package @latticexyz/ecs-browser - -# [1.2.0](https://github.com/latticexyz/mud/compare/v1.1.0...v1.2.0) (2022-09-29) - -**Note:** Version bump only for package @latticexyz/ecs-browser - -# [1.1.0](https://github.com/latticexyz/mud/compare/v1.0.0...v1.1.0) (2022-09-28) - -### Features - -- **ecs-browser:** make nameComponent and spawnPrototypeAt optional ([7822d53](https://github.com/latticexyz/mud/commit/7822d53f03862a146b2a58aac3a024b2b274d614)) - -# [1.0.0](https://github.com/latticexyz/mud/compare/v0.16.4...v1.0.0) (2022-09-27) - -**Note:** Version bump only for package @latticexyz/ecs-browser - -## [0.16.4](https://github.com/latticexyz/mud/compare/v0.16.3...v0.16.4) (2022-09-26) - -**Note:** Version bump only for package @latticexyz/ecs-browser - -## [0.16.3](https://github.com/latticexyz/mud/compare/v0.16.2...v0.16.3) (2022-09-26) - -**Note:** Version bump only for package @latticexyz/ecs-browser - -## [0.16.2](https://github.com/latticexyz/mud/compare/v0.16.1...v0.16.2) (2022-09-26) - -**Note:** Version bump only for package @latticexyz/ecs-browser - -## [0.16.1](https://github.com/latticexyz/mud/compare/v0.16.0...v0.16.1) (2022-09-26) - -**Note:** Version bump only for package @latticexyz/ecs-browser - -# [0.16.0](https://github.com/latticexyz/mud/compare/v0.15.1...v0.16.0) (2022-09-26) - -**Note:** Version bump only for package @latticexyz/ecs-browser - -## [0.15.1](https://github.com/latticexyz/mud/compare/v0.15.0...v0.15.1) (2022-09-23) - -**Note:** Version bump only for package @latticexyz/ecs-browser - -# [0.15.0](https://github.com/latticexyz/mud/compare/v0.14.2...v0.15.0) (2022-09-21) - -**Note:** Version bump only for package @latticexyz/ecs-browser - -## [0.14.2](https://github.com/latticexyz/mud/compare/v0.14.1...v0.14.2) (2022-09-21) - -**Note:** Version bump only for package @latticexyz/ecs-browser - -## [0.14.1](https://github.com/latticexyz/mud/compare/v0.14.0...v0.14.1) (2022-09-21) - -**Note:** Version bump only for package @latticexyz/ecs-browser - -# [0.14.0](https://github.com/latticexyz/mud/compare/v0.13.0...v0.14.0) (2022-09-20) - -**Note:** Version bump only for package @latticexyz/ecs-browser - -# [0.13.0](https://github.com/latticexyz/mud/compare/v0.12.0...v0.13.0) (2022-09-19) - -### Features - -- various tweaks for mudwar ([#151](https://github.com/latticexyz/mud/issues/151)) ([53bc3cc](https://github.com/latticexyz/mud/commit/53bc3cc4405c7916821d219963e592e09b51db2a)) - -# [0.12.0](https://github.com/latticexyz/mud/compare/v0.11.1...v0.12.0) (2022-09-16) - -**Note:** Version bump only for package @latticexyz/ecs-browser - -## [0.11.1](https://github.com/latticexyz/mud/compare/v0.11.0...v0.11.1) (2022-09-15) - -### Bug Fixes - -- do not run prepack multiple times when publishing ([4f6f4c3](https://github.com/latticexyz/mud/commit/4f6f4c35a53c105951b32a071e47a748b2502cda)) - -# [0.11.0](https://github.com/latticexyz/mud/compare/v0.10.0...v0.11.0) (2022-09-15) - -**Note:** Version bump only for package @latticexyz/ecs-browser - -# [0.10.0](https://github.com/latticexyz/mud/compare/v0.9.0...v0.10.0) (2022-09-14) - -**Note:** Version bump only for package @latticexyz/ecs-browser - -# [0.9.0](https://github.com/latticexyz/mud/compare/v0.8.1...v0.9.0) (2022-09-13) - -**Note:** Version bump only for package @latticexyz/ecs-browser - -## [0.8.1](https://github.com/latticexyz/mud/compare/v0.8.0...v0.8.1) (2022-08-22) - -### Bug Fixes - -- start from initialBlockNumber, build settings, fix github actions, and other minor additions ([#137](https://github.com/latticexyz/mud/issues/137)) ([08eab5c](https://github.com/latticexyz/mud/commit/08eab5c6b0d99a9ffa8a315e16454ecc9306f410)) - -# [0.8.0](https://github.com/latticexyz/mud/compare/v0.7.0...v0.8.0) (2022-08-22) - -**Note:** Version bump only for package @latticexyz/ecs-browser - -# [0.7.0](https://github.com/latticexyz/mud/compare/v0.6.0...v0.7.0) (2022-08-19) - -**Note:** Version bump only for package @latticexyz/ecs-browser - -# [0.6.0](https://github.com/latticexyz/mud/compare/v0.5.1...v0.6.0) (2022-08-15) - -**Note:** Version bump only for package @latticexyz/ecs-browser - -## [0.5.1](https://github.com/latticexyz/mud/compare/v0.5.0...v0.5.1) (2022-08-05) - -### Bug Fixes - -- only render prototype creator if required components are provided ([#124](https://github.com/latticexyz/mud/issues/124)) ([d877b39](https://github.com/latticexyz/mud/commit/d877b39ceab44f3b6f0144e02575efba670b7e72)) - -# [0.5.0](https://github.com/latticexyz/mud/compare/v0.4.3...v0.5.0) (2022-08-05) - -### Bug Fixes - -- CacheWorker ([#118](https://github.com/latticexyz/mud/issues/118)) ([bfe006e](https://github.com/latticexyz/mud/commit/bfe006e6adf064982a14d5dc1541d39b1b6016e2)) -- optimism, cancel action if gas check fails, add noise utils, fix ecs-browser entry point ([#119](https://github.com/latticexyz/mud/issues/119)) ([f35d3c3](https://github.com/latticexyz/mud/commit/f35d3c3cc7fc9385a215dfda6762a2a825c9fd6d)) - -### Features - -- **ecs-browser:** Allow spawning of prototypes at arbitrary locations ([#117](https://github.com/latticexyz/mud/issues/117)) ([b31bfcd](https://github.com/latticexyz/mud/commit/b31bfcdd800214908e669b021e4865a68efee795)) - -## [0.4.3](https://github.com/latticexyz/mud/compare/v0.4.2...v0.4.3) (2022-07-30) - -**Note:** Version bump only for package @latticexyz/ecs-browser - -## [0.4.2](https://github.com/latticexyz/mud/compare/v0.4.1...v0.4.2) (2022-07-29) - -**Note:** Version bump only for package @latticexyz/ecs-browser - -## [0.4.1](https://github.com/latticexyz/mud/compare/v0.4.0...v0.4.1) (2022-07-29) - -**Note:** Version bump only for package @latticexyz/ecs-browser - -# [0.4.0](https://github.com/latticexyz/mud/compare/v0.3.2...v0.4.0) (2022-07-29) - -### Features - -- add 3d components ([d230339](https://github.com/latticexyz/mud/commit/d230339bdf3fbfaf4596de759a25fb616a7ab572)) - -## [0.3.2](https://github.com/latticexyz/mud/compare/v0.3.1...v0.3.2) (2022-07-26) - -**Note:** Version bump only for package @latticexyz/ecs-browser - -## [0.3.1](https://github.com/latticexyz/mud/compare/v0.3.0...v0.3.1) (2022-07-26) - -**Note:** Version bump only for package @latticexyz/ecs-browser - -# [0.3.0](https://github.com/latticexyz/mud/compare/v0.2.0...v0.3.0) (2022-07-26) - -### Features - -- mudwar prototype (nyc sprint 2) ([#59](https://github.com/latticexyz/mud/issues/59)) ([a3db20e](https://github.com/latticexyz/mud/commit/a3db20e14c641b8b456775ee191eca6f016d47f5)), closes [#58](https://github.com/latticexyz/mud/issues/58) [#61](https://github.com/latticexyz/mud/issues/61) [#64](https://github.com/latticexyz/mud/issues/64) [#62](https://github.com/latticexyz/mud/issues/62) [#66](https://github.com/latticexyz/mud/issues/66) [#69](https://github.com/latticexyz/mud/issues/69) [#72](https://github.com/latticexyz/mud/issues/72) [#73](https://github.com/latticexyz/mud/issues/73) [#74](https://github.com/latticexyz/mud/issues/74) [#76](https://github.com/latticexyz/mud/issues/76) [#75](https://github.com/latticexyz/mud/issues/75) [#77](https://github.com/latticexyz/mud/issues/77) [#78](https://github.com/latticexyz/mud/issues/78) [#79](https://github.com/latticexyz/mud/issues/79) [#80](https://github.com/latticexyz/mud/issues/80) [#82](https://github.com/latticexyz/mud/issues/82) [#86](https://github.com/latticexyz/mud/issues/86) [#83](https://github.com/latticexyz/mud/issues/83) [#81](https://github.com/latticexyz/mud/issues/81) [#85](https://github.com/latticexyz/mud/issues/85) [#84](https://github.com/latticexyz/mud/issues/84) [#87](https://github.com/latticexyz/mud/issues/87) [#91](https://github.com/latticexyz/mud/issues/91) [#88](https://github.com/latticexyz/mud/issues/88) [#90](https://github.com/latticexyz/mud/issues/90) [#92](https://github.com/latticexyz/mud/issues/92) [#93](https://github.com/latticexyz/mud/issues/93) [#89](https://github.com/latticexyz/mud/issues/89) [#94](https://github.com/latticexyz/mud/issues/94) [#95](https://github.com/latticexyz/mud/issues/95) [#98](https://github.com/latticexyz/mud/issues/98) [#100](https://github.com/latticexyz/mud/issues/100) [#97](https://github.com/latticexyz/mud/issues/97) [#101](https://github.com/latticexyz/mud/issues/101) [#105](https://github.com/latticexyz/mud/issues/105) [#106](https://github.com/latticexyz/mud/issues/106) - -# [0.2.0](https://github.com/latticexyz/mud/compare/v0.1.8...v0.2.0) (2022-07-05) - -### Features - -- component browser 📈 ([#16](https://github.com/latticexyz/mud/issues/16)) ([37af75e](https://github.com/latticexyz/mud/commit/37af75ecb11266e5877d04cb3224698605b87646)) -- on-chain maps (nyc sprint 1) ([#38](https://github.com/latticexyz/mud/issues/38)) ([089c46d](https://github.com/latticexyz/mud/commit/089c46d7c0e112d1670e3bcd01a35f08ee21d593)), closes [#17](https://github.com/latticexyz/mud/issues/17) [#20](https://github.com/latticexyz/mud/issues/20) [#18](https://github.com/latticexyz/mud/issues/18) [#25](https://github.com/latticexyz/mud/issues/25) [#26](https://github.com/latticexyz/mud/issues/26) [#27](https://github.com/latticexyz/mud/issues/27) [#28](https://github.com/latticexyz/mud/issues/28) [#29](https://github.com/latticexyz/mud/issues/29) [#30](https://github.com/latticexyz/mud/issues/30) [#31](https://github.com/latticexyz/mud/issues/31) [#33](https://github.com/latticexyz/mud/issues/33) [#32](https://github.com/latticexyz/mud/issues/32) [#34](https://github.com/latticexyz/mud/issues/34) [#35](https://github.com/latticexyz/mud/issues/35) [#36](https://github.com/latticexyz/mud/issues/36) [#37](https://github.com/latticexyz/mud/issues/37) [#39](https://github.com/latticexyz/mud/issues/39) [#40](https://github.com/latticexyz/mud/issues/40) [#41](https://github.com/latticexyz/mud/issues/41) [#42](https://github.com/latticexyz/mud/issues/42) [#43](https://github.com/latticexyz/mud/issues/43) [#44](https://github.com/latticexyz/mud/issues/44) [#45](https://github.com/latticexyz/mud/issues/45) [#46](https://github.com/latticexyz/mud/issues/46) [#48](https://github.com/latticexyz/mud/issues/48) [#49](https://github.com/latticexyz/mud/issues/49) [#50](https://github.com/latticexyz/mud/issues/50) diff --git a/packages/ecs-browser/README.md b/packages/ecs-browser/README.md deleted file mode 100644 index a9e0cc5a71..0000000000 --- a/packages/ecs-browser/README.md +++ /dev/null @@ -1,3 +0,0 @@ -# ECS Browser - -Unity style Component Browser sidebar for debugging / development diff --git a/packages/ecs-browser/package.json b/packages/ecs-browser/package.json index 15fe88dbe8..a2167092dd 100644 --- a/packages/ecs-browser/package.json +++ b/packages/ecs-browser/package.json @@ -1,41 +1,5 @@ { "name": "@latticexyz/ecs-browser", "version": "2.0.0-next.3", - "description": "Component Browser for RECS", - "repository": { - "type": "git", - "url": "https://github.com/latticexyz/mud.git", - "directory": "packages/ecs-browser" - }, - "license": "MIT", - "type": "module", - "exports": { - ".": "./dist/index.js" - }, - "types": "src/index.ts", - "scripts": { - "build": "pnpm run build:js", - "build:js": "tsup", - "clean": "pnpm run clean:js", - "clean:js": "rimraf dist", - "dev": "tsup --watch", - "test": "tsc --noEmit" - }, - "dependencies": { - "@latticexyz/recs": "workspace:*", - "@latticexyz/std-client": "workspace:*", - "@latticexyz/utils": "workspace:*", - "goober": "^2.1.11", - "lodash": "^4.17.21", - "mobx": "^6.7.0", - "mobx-react-lite": "^3.4.0", - "react": "^18.2.0", - "shiki": "^0.11.1" - }, - "devDependencies": { - "@types/lodash": "^4.14.182", - "@types/react": "^18.2.6", - "tsup": "^6.7.0" - }, - "gitHead": "914a1e0ae4a573d685841ca2ea921435057deb8f" + "private": true } diff --git a/packages/ecs-browser/src/Browser.tsx b/packages/ecs-browser/src/Browser.tsx deleted file mode 100644 index 872a59ddea..0000000000 --- a/packages/ecs-browser/src/Browser.tsx +++ /dev/null @@ -1,63 +0,0 @@ -import React, { useState } from "react"; -import { Layers, Type, Component, Schema, World, Entity } from "@latticexyz/recs"; -import { BrowserContainer, SmallHeadline } from "./StyledComponents"; -import { SetContractComponentFunction } from "./types"; -import { EntityEditor } from "./EntityEditor"; -import { QueryBuilder } from "./QueryBuilder"; -import { useClearDevHighlights } from "./hooks"; -import { observer } from "mobx-react-lite"; -import { Coord } from "./shared"; -import { createBrowserDevComponents } from "./createBrowserDevComponents"; - -/** - * An Entity Browser for viewing/editiing Component values. - */ -export const Browser = observer( - ({ - layers, - setContractComponentValue, - world, - devHighlightComponent, - }: { - layers: Layers; - setContractComponentValue?: SetContractComponentFunction; - prototypeComponent?: Component<{ value: Type.StringArray }>; - nameComponent?: Component<{ value: Type.String }>; - spawnPrototypeAt?: (prototypeId: Entity, position: Coord) => void; - world: World; - devHighlightComponent: ReturnType["devHighlightComponent"]; - hoverHighlightComponent: ReturnType["hoverHighlightComponent"]; - }) => { - const [filteredEntities, setFilteredEntities] = useState([]); - const [overflow, setOverflow] = useState(0); - const clearDevHighlights = useClearDevHighlights(devHighlightComponent); - - return ( - - - - Showing {filteredEntities.length} of {filteredEntities.length + overflow} entities - - {filteredEntities.map((entity) => ( - - ))} - - ); - } -); diff --git a/packages/ecs-browser/src/ComponentEditor.tsx b/packages/ecs-browser/src/ComponentEditor.tsx deleted file mode 100644 index c852837aca..0000000000 --- a/packages/ecs-browser/src/ComponentEditor.tsx +++ /dev/null @@ -1,46 +0,0 @@ -import React from "react"; -import { Layers, removeComponent } from "@latticexyz/recs"; -import { AnyComponent, Entity, Schema } from "@latticexyz/recs/src/types"; -import { ComponentBrowserButton, ComponentEditorContainer, ComponentTitle } from "./StyledComponents"; -import { ComponentValueEditor } from "./ComponentValueEditor"; -import { hasContract, SetContractComponentFunction } from "./types"; -import { useComponentValueStream } from "@latticexyz/std-client/deprecated"; - -export const ComponentEditor = ({ - entity, - component, - layers, - setContractComponentValue, -}: { - entity: Entity; - component: AnyComponent; - layers: Layers; - setContractComponentValue?: SetContractComponentFunction; -}) => { - const value = useComponentValueStream(component, entity); - if (!value) return null; - - return ( - - - {component.id} - { - removeComponent(component, entity); - - if (setContractComponentValue && hasContract(component)) setContractComponentValue(entity, component, {}); - }} - > - Remove - - - - - ); -}; diff --git a/packages/ecs-browser/src/ComponentValueEditor.tsx b/packages/ecs-browser/src/ComponentValueEditor.tsx deleted file mode 100644 index bf7b056d63..0000000000 --- a/packages/ecs-browser/src/ComponentValueEditor.tsx +++ /dev/null @@ -1,36 +0,0 @@ -import React from "react"; -import { AnyComponent, ComponentValue, Schema, Layers, Entity } from "@latticexyz/recs"; -import { SetContractComponentFunction } from "./types"; -import { ValueEditor } from "./ValueEditor"; - -export const ComponentValueEditor = ({ - entity, - component, - componentValue, - layers, - setContractComponentValue, -}: { - entity: Entity; - component: AnyComponent; - componentValue: ComponentValue; - layers: Layers; - setContractComponentValue?: SetContractComponentFunction; -}) => { - return ( -
- {Object.keys(componentValue).map((propName) => { - return ( - - ); - })} -
- ); -}; diff --git a/packages/ecs-browser/src/DraggableNumberLabel.tsx b/packages/ecs-browser/src/DraggableNumberLabel.tsx deleted file mode 100644 index b6c2b126f6..0000000000 --- a/packages/ecs-browser/src/DraggableNumberLabel.tsx +++ /dev/null @@ -1,52 +0,0 @@ -import React, { useMemo } from "react"; -import { useCallback, useEffect, useState } from "react"; -import { DraggableNumberLabelContainer } from "./StyledComponents"; - -export function DraggableNumberLabel({ - label, - value, - setValue, - persistValue, -}: { - label: string; - value: string | null; - setValue: (n: string | null) => void; - persistValue: (e: Event | React.SyntheticEvent, value: string | null) => void; -}) { - const numberValue = useMemo(() => parseInt(value ?? "0"), [value]); - const [snapshot, setSnapshot] = useState(numberValue); - const [startMouseX, setStartMouseX] = useState(0); - - const onStart = useCallback( - (event: React.MouseEvent) => { - setStartMouseX(event.clientX); - setSnapshot(numberValue); - }, - [numberValue] - ); - - useEffect(() => { - function onMouseMove(this: Document, event: MouseEvent) { - if (startMouseX) { - const change = Math.round((event.clientX - startMouseX) / 25) + snapshot; - setValue(change.toString()); - } - } - - const onDragEnd = (e: Event) => { - if (startMouseX) { - setStartMouseX(0); - persistValue(e, value?.toString() || null); - } - }; - - document.addEventListener("mousemove", onMouseMove); - document.addEventListener("mouseup", onDragEnd); - return () => { - document.removeEventListener("mousemove", onMouseMove); - document.removeEventListener("mouseup", onDragEnd); - }; - }, [startMouseX, setValue, snapshot, value]); - - return {label}; -} diff --git a/packages/ecs-browser/src/EntityEditor.tsx b/packages/ecs-browser/src/EntityEditor.tsx deleted file mode 100644 index 1e291d31ab..0000000000 --- a/packages/ecs-browser/src/EntityEditor.tsx +++ /dev/null @@ -1,86 +0,0 @@ -import React, { useEffect, useState } from "react"; -import { - Layers, - setComponent, - Type, - AnyComponent, - Component, - Schema, - World, - getEntityComponents, - Entity, -} from "@latticexyz/recs"; -import { Collapse, ComponentBrowserButton, EntityEditorContainer } from "./StyledComponents"; -import { SetContractComponentFunction } from "./types"; -import { ComponentEditor } from "./ComponentEditor"; -import { observer } from "mobx-react-lite"; - -export const EntityEditor = observer( - ({ - entityId, - layers, - setContractComponentValue, - devHighlightComponent, - world, - clearDevHighlights, - }: { - entityId: Entity; - layers: Layers; - setContractComponentValue?: SetContractComponentFunction; - devHighlightComponent: Component<{ value: Type.OptionalNumber }>; - world: World; - clearDevHighlights: () => void; - }) => { - const [opened, setOpened] = useState(false); - - const [entityComponents, setEntityComponents] = useState([]); - useEffect(() => { - if (opened) { - const components = getEntityComponents(world, entityId); - setEntityComponents(components); - } - }, [opened, world, entityId, setEntityComponents]); - - return ( - { - clearDevHighlights(); - setComponent(devHighlightComponent, entityId, { - value: undefined, - }); - }} - onMouseLeave={() => clearDevHighlights()} - > -
setOpened(!opened)} style={{ cursor: "pointer" }}> -
-

Entity {entityId}

- { - e.stopPropagation(); - navigator.clipboard.writeText(entityId); - }} - > - Click to copy Entity ID - -
- setOpened(!opened)}> - {opened ? <>▼ : <>▶} - -
- - {[...entityComponents.values()] - .filter((c) => c.id !== devHighlightComponent.id) - .map((c) => ( - - ))} - -
- ); - } -); diff --git a/packages/ecs-browser/src/QueryBuilder/QueryBuilder.tsx b/packages/ecs-browser/src/QueryBuilder/QueryBuilder.tsx deleted file mode 100644 index dc2aaaad47..0000000000 --- a/packages/ecs-browser/src/QueryBuilder/QueryBuilder.tsx +++ /dev/null @@ -1,236 +0,0 @@ -import React, { useState, useRef, useCallback, useEffect } from "react"; -import { - Layers, - setComponent, - Type, - AnyComponent, - Component, - World, - defineQuery, - EntityQueryFragment, - Entity, -} from "@latticexyz/recs"; -import { ComponentBrowserButton, ComponentBrowserInput, SyntaxHighlighterWrapper } from "../StyledComponents"; -import { QueryBuilderForm, QueryShortcutContainer } from "./StyledComponents"; -import * as recs from "@latticexyz/recs"; -import flatten from "lodash/flatten"; -import orderBy from "lodash/orderBy"; -import throttle from "lodash/throttle"; -import { MAX_ENTITIES } from "../constants"; -import { observe } from "mobx"; -import { useShiki } from "../hooks"; - -const SyntaxHighlighter = ({ code }: { code: string }) => { - const { html } = useShiki(code, "js"); - - if (!html) { - return ( - -
-      
-    );
-  }
-
-  return ;
-};
-
-export const QueryBuilder = ({
-  allEntities,
-  setFilteredEntities,
-  layers,
-  world,
-  devHighlightComponent,
-  clearDevHighlights,
-  setOverflow,
-}: {
-  world: World;
-  layers: Layers;
-  allEntities: Entity[];
-  setFilteredEntities: (es: Entity[]) => void;
-  devHighlightComponent: Component<{ value: Type.OptionalNumber }>;
-  clearDevHighlights: () => void;
-  setOverflow: (overflow: number) => void;
-}) => {
-  const queryInputRef = useRef(null);
-  const [componentFilters, setComponentFilters] = useState([]);
-  const [isManuallyEditing, setIsManuallyEditing] = useState(true);
-  const [entityQueryText, setEntityQueryText] = useState("");
-  const [errorMessage, setErrorMessage] = useState("");
-
-  const allComponents = flatten(Object.values(layers).map((layer) => Object.values(layer.components)));
-
-  const resetFilteredEntities = useCallback(() => {
-    setFilteredEntities([]);
-    setComponentFilters([]);
-    setErrorMessage("");
-  }, [setFilteredEntities, setErrorMessage, allEntities]);
-
-  // If there is no filter present, view no entities.
-  useEffect(() => {
-    if (!entityQueryText) {
-      resetFilteredEntities();
-    }
-  }, [setFilteredEntities, resetFilteredEntities, allEntities, entityQueryText]);
-
-  // If the user is not manually typing a query, build a query
-  // based on the selected Component filters
-  useEffect(() => {
-    if (isManuallyEditing) return;
-
-    const hasFilters = componentFilters.map((c) => `Has(${c.id})`);
-    const query = `[${hasFilters.join(",")}]`;
-    setEntityQueryText(query);
-  }, [componentFilters, isManuallyEditing]);
-
-  // When the user edits a query manually,
-  // clear the selectable filters
-  const editQuery = useCallback((text: string) => {
-    setIsManuallyEditing(true);
-    setEntityQueryText(text);
-    setComponentFilters([]);
-  }, []);
-
-  const cancelObserver = useRef<() => void>(() => void 0);
-  // Cancel outstanding observers on unmount
-  useEffect(() => {
-    return () => {
-      if (cancelObserver.current) cancelObserver.current();
-    };
-  }, []);
-
-  const executeFilter = useCallback(
-    (e: React.SyntheticEvent) => {
-      e.preventDefault();
-      setErrorMessage("");
-
-      // Do not throw an error if there is no query
-      if (!entityQueryText) {
-        resetFilteredEntities();
-        return;
-      }
-
-      // Create local variables that include all the things necessary to
-      // construct custom Entity queries.
-      // eslint-disable-next-line @typescript-eslint/no-unused-vars
-      const q = { ...recs };
-      // eslint-disable-next-line @typescript-eslint/no-unused-vars
-      const c = Object.values(layers).reduce>((allComponents, layer) => {
-        for (const [componentName, component] of Object.entries(layer.components)) {
-          allComponents[componentName] = component;
-        }
-        return allComponents;
-      }, {});
-
-      try {
-        const assignQueryVars = Object.keys(q)
-          .map((key) => `const ${key} = q["${key}"]; `)
-          .join("");
-
-        const assignComponentVars = Object.keys(c)
-          .map((key) => `const ${key} = c["${key}"]; `)
-          .join("");
-
-        const evalString = `
-        (() => {
-          ${assignQueryVars}
-          ${assignComponentVars}
-          return (${entityQueryText});
-        })()
-        `;
-
-        const queryArray = eval(evalString) as EntityQueryFragment[];
-        if (!queryArray || queryArray.length === 0 || !Array.isArray(queryArray)) {
-          resetFilteredEntities();
-          throw new Error("Invalid query");
-        }
-
-        cancelObserver.current();
-        const queryResult = defineQuery(queryArray, { runOnInit: true });
-        const subscription = queryResult.update$.subscribe();
-        const selectEntities = throttle(
-          () => {
-            const selectedEntities = [...queryResult.matching].slice(0, MAX_ENTITIES);
-            setOverflow(queryResult.matching.size - selectedEntities.length);
-            setFilteredEntities(selectedEntities);
-            clearDevHighlights();
-            selectedEntities.forEach((idx) => setComponent(devHighlightComponent, idx, { value: 0x0000ff }));
-          },
-          1000,
-          { leading: true }
-        );
-        selectEntities();
-        const cancelObserve = observe(queryResult.matching, selectEntities);
-        cancelObserver.current = () => {
-          cancelObserve();
-          selectEntities.cancel();
-          subscription?.unsubscribe();
-        };
-      } catch (e: unknown) {
-        setErrorMessage((e as Error).message);
-        console.error(e);
-      }
-    },
-    [entityQueryText, setEntityQueryText, setFilteredEntities, resetFilteredEntities, setErrorMessage, allEntities]
-  );
-
-  return (
-    <>
-      
-        
-        {errorMessage && }
-        
-         {
-            if (errorMessage) setErrorMessage("");
-            editQuery(e.target.value);
-          }}
-          onFocus={(e) => e.target.select()}
-        />
-      
-
-      
-

Filter by Component

- - {orderBy(allComponents, (c) => c.id) - .filter((c) => !c.id.includes("-")) - .map((component) => { - const filterActive = componentFilters.includes(component); - - return ( - { - setIsManuallyEditing(false); - queryInputRef.current?.focus(); - - if (filterActive) { - setComponentFilters((f) => f.filter((f) => f !== component)); - } else { - setComponentFilters((f) => [...f, component]); - } - }} - > - Has({component.id}) - - ); - })} - -
- - ); -}; diff --git a/packages/ecs-browser/src/QueryBuilder/StyledComponents.ts b/packages/ecs-browser/src/QueryBuilder/StyledComponents.ts deleted file mode 100644 index 738af4f2a6..0000000000 --- a/packages/ecs-browser/src/QueryBuilder/StyledComponents.ts +++ /dev/null @@ -1,15 +0,0 @@ -import { styled } from "goober"; - -export const QueryBuilderForm = styled("form")` - padding: 8px; - border-bottom: 2px grey solid; - margin-bottom: 8px; - width: 100%; -`; - -export const QueryShortcutContainer = styled("div")` - flex: "row wrap"; - margin-top: "8px"; - height: 200px; - overflow: auto; -`; diff --git a/packages/ecs-browser/src/QueryBuilder/index.ts b/packages/ecs-browser/src/QueryBuilder/index.ts deleted file mode 100644 index 21c2deec4a..0000000000 --- a/packages/ecs-browser/src/QueryBuilder/index.ts +++ /dev/null @@ -1 +0,0 @@ -export * from "./QueryBuilder"; diff --git a/packages/ecs-browser/src/StyledComponents.ts b/packages/ecs-browser/src/StyledComponents.ts deleted file mode 100644 index 4af477ca48..0000000000 --- a/packages/ecs-browser/src/StyledComponents.ts +++ /dev/null @@ -1,116 +0,0 @@ -import { setup, styled } from "goober"; -import React from "react"; -import { createElement } from "react"; - -setup(createElement); - -export const ComponentBrowserInput = styled("input", React.forwardRef)` - background-color: #383c4a; - color: #8c91a0; - border: 1px rgba(0, 0, 0, 0.5) solid; - border-radius: 4px; - padding: 4px; - padding-left: 8px; - margin: 8px 0; - - &:focus { - outline: none; - border: 1px #8c91a0 solid; - } - ::selection { - color: white; - background: rgba(70, 89, 182, 0.9); - } -`; - -export const ComponentBrowserButton = styled("button")<{ active?: string }>` - background-color: ${({ active }) => (active === "true" ? "#8c91a0" : "#383c4a")}; - color: ${({ active }) => (active === "true" ? "#383c4a" : "#8c91a0")}; - border: 1px rgba(0, 0, 0, 0.5) solid; - border-radius: 4px; - padding: 4px; - cursor: pointer; - - &:hover { - background-color: #8c91a0; - color: #383c4a; - } -`; - -export const ComponentBrowserSelect = styled("select")` - width: 180px; - background-color: #383c4a; - color: #8c91a0; - border: 1px rgba(0, 0, 0, 0.5) solid; - border-radius: 4px; - padding: 4px; -`; - -export const ValueForm = styled("form")` - display: flex; - flex-direction: row; - justify-content: space-between; - align-items: center; -`; - -export const ComponentEditorContainer = styled("div")` - margin: 8px auto; -`; - -export const ComponentTitle = styled("div")` - color: white; - font-weight: bold; - display: flex; - flex-direction: row; - align-items: center; - justify-content: space-between; -`; - -export const EntityEditorContainer = styled("div")` - border-bottom: 1px #8c91a0 solid; - padding: 8px; -`; - -export const BrowserContainer = styled("div")` - overflow: auto; - background-color: rgba(27, 28, 32, 1); - color: #8c91a0; - height: 100%; - pointer-events: all; -`; - -export const DraggableNumberLabelContainer = styled("label")` - cursor: ew-resize; - user-select: none; - color: #8c91a0; -`; - -export const SmallHeadline = styled("p")` - padding: 8px; - font-size: 14px; -`; - -export const Collapse = styled("div")<{ opened: string }>` - height: ${({ opened }) => (opened === "true" ? "auto" : "0px")}; - overflow: ${({ opened }) => (opened === "true" ? "initial" : "hidden")}; -`; - -export const SyntaxHighlighterWrapper = styled("div")` - .shiki { - background-color: #282a36; - - font-family: Consolas, Monaco, "Andale Mono", "Ubuntu Mono", monospace; - - line-height: 1.5; - tab-size: 4; - hyphens: none; - padding: 1em; - margin: 0.5em 0px; - overflow: auto; - border-radius: 0.3em; - overflow: auto; - overflow-wrap: break-word; - white-space: pre-wrap; - text-shadow: rgba(0, 0, 0, 0.3) 0px 1px; - } -`; diff --git a/packages/ecs-browser/src/ValueEditor.tsx b/packages/ecs-browser/src/ValueEditor.tsx deleted file mode 100644 index 6e130f3f27..0000000000 --- a/packages/ecs-browser/src/ValueEditor.tsx +++ /dev/null @@ -1,135 +0,0 @@ -import React, { useState, useEffect, useCallback, useMemo } from "react"; -import { Entity, getComponentValueStrict, Layers, Type, updateComponent } from "@latticexyz/recs"; -import { - AnyComponent, - ComponentValue, - isArrayType, - isEntityType, - isNumberType, - isOptionalType, - Schema, -} from "@latticexyz/recs"; -import startCase from "lodash/startCase"; -import { ComponentBrowserInput, ComponentBrowserSelect, ValueForm } from "./StyledComponents"; -import { DraggableNumberLabel } from "./DraggableNumberLabel"; -import { hasContract, SetContractComponentFunction } from "./types"; - -export const ValueEditor = ({ - entity, - component, - componentValue, - valueProp, - layers, - setContractComponentValue, -}: { - entity: Entity; - component: AnyComponent; - componentValue: ComponentValue; - valueProp: string; - layers: Layers; - setContractComponentValue?: SetContractComponentFunction; -}) => { - const [value, setValue] = useState(componentValue[valueProp]?.toString() as string | null); - - useEffect(() => { - const v = componentValue[valueProp]; - setValue(v as string | null); - }, [componentValue, valueProp]); - - const inputType = useMemo(() => { - const type = component.schema[valueProp]; - if (isNumberType(type)) { - return "number"; - } else if (isEntityType(type)) { - return "select"; - } else { - return "text"; - } - }, [component, valueProp]); - - const persistValue = useCallback( - (e: Event | React.SyntheticEvent, value: string | null) => { - e.preventDefault(); - - const valueType = component.schema[valueProp]; - - if (value == null || value === "") { - if (isOptionalType(valueType)) { - updateComponent(component, entity, { [valueProp]: undefined }); - return; - } - - const currentValue = getComponentValueStrict(component, entity); - setValue(currentValue[valueProp] as string); - return; - } - - let parsedValue; - if (isNumberType(valueType)) { - parsedValue = parseInt(value); - } else if (isArrayType(valueType)) { - parsedValue = value.split(","); - } else if (valueType === Type.Boolean) { - parsedValue = value === "true"; - } else { - parsedValue = value; - } - - if (hasContract(component) && setContractComponentValue) { - const currentValue = getComponentValueStrict(component, entity); - setContractComponentValue(entity, component, { - ...currentValue, - [valueProp]: parsedValue, - }); - } else { - updateComponent(component, entity, { [valueProp]: parsedValue }); - } - }, - [entity, component, valueProp, layers, inputType] - ); - - return ( - persistValue(e, value)}> - {isNumberType(component.schema[valueProp]) ? ( - - ) : ( - - )} - {inputType === "select" ? ( - { - setValue(e.target.value); - persistValue(e, e.target.value); - }} - > - - {[...Object.values(layers)[0].world.getEntities()].map((entity) => ( - - ))} - - ) : ( - e.target.select()} - onChange={(e) => { - setValue(e.target.value); - }} - onBlur={(e) => persistValue(e, value)} - /> - )} - - ); -}; diff --git a/packages/ecs-browser/src/constants.ts b/packages/ecs-browser/src/constants.ts deleted file mode 100644 index 3f96ec7709..0000000000 --- a/packages/ecs-browser/src/constants.ts +++ /dev/null @@ -1 +0,0 @@ -export const MAX_ENTITIES = 1000; diff --git a/packages/ecs-browser/src/createBrowserDevComponents.ts b/packages/ecs-browser/src/createBrowserDevComponents.ts deleted file mode 100644 index 5b19ec64e1..0000000000 --- a/packages/ecs-browser/src/createBrowserDevComponents.ts +++ /dev/null @@ -1,17 +0,0 @@ -import { defineComponent, Type, World } from "@latticexyz/recs"; - -export function createBrowserDevComponents(world: World) { - const devHighlightComponent = defineComponent(world, { - value: Type.OptionalNumber, - }); - - const hoverHighlightComponent = defineComponent(world, { - x: Type.OptionalNumber, - y: Type.OptionalNumber, - }); - - return { - devHighlightComponent, - hoverHighlightComponent, - }; -} diff --git a/packages/ecs-browser/src/hooks.ts b/packages/ecs-browser/src/hooks.ts deleted file mode 100644 index 64126a12c7..0000000000 --- a/packages/ecs-browser/src/hooks.ts +++ /dev/null @@ -1,43 +0,0 @@ -import { Component, Has, removeComponent } from "@latticexyz/recs"; -import { useQuery } from "@latticexyz/std-client/deprecated"; -import { useCallback, useEffect, useState } from "react"; -import type { Lang, IThemedToken } from "shiki"; - -export function useClearDevHighlights(devHighlightComponent: Component) { - const highlightedEntities = useQuery([Has(devHighlightComponent)]); - - return useCallback(() => { - if (!highlightedEntities) return; - for (const entity of highlightedEntities) { - removeComponent(devHighlightComponent, entity); - } - }, [highlightedEntities]); -} - -export function useShiki(code: string, lang: Lang) { - const [html, htmlSet] = useState(); - const [tokens, tokenSet] = useState(); - - useEffect(() => { - async function handler() { - try { - const shiki = await import("shiki"); - - shiki.setCDN("https://unpkg.com/shiki/"); - - const highlighter = await shiki.getHighlighter({ theme: "dracula-soft", langs: [lang] }); - - htmlSet(highlighter.codeToHtml(code, { lang })); - tokenSet(highlighter.codeToThemedTokens(code, lang)); - } catch (error) { - console.error(error); - } - } - handler(); - }, [code]); - - return { - html, - tokens, - }; -} diff --git a/packages/ecs-browser/src/index.ts b/packages/ecs-browser/src/index.ts deleted file mode 100644 index 7fb49ed93c..0000000000 --- a/packages/ecs-browser/src/index.ts +++ /dev/null @@ -1,2 +0,0 @@ -export { Browser } from "./Browser"; -export { createBrowserDevComponents } from "./createBrowserDevComponents"; diff --git a/packages/ecs-browser/src/shared.ts b/packages/ecs-browser/src/shared.ts deleted file mode 100644 index 4c60e382c6..0000000000 --- a/packages/ecs-browser/src/shared.ts +++ /dev/null @@ -1,22 +0,0 @@ -/** - * @see phaserx src/types - */ - -export type Coord = { - x: number; - y: number; -}; - -type PixelCoord = Coord; -type WorldCoord = Coord; - -/** - * @see phaserx src/coords - */ - -export function pixelCoordToTileCoord(pixelCoord: PixelCoord, tileWidth: number, tileHeight: number): WorldCoord { - return { - x: Math.floor(pixelCoord.x / tileWidth), - y: Math.floor(pixelCoord.y / tileHeight), - }; -} diff --git a/packages/ecs-browser/src/types.ts b/packages/ecs-browser/src/types.ts deleted file mode 100644 index 985b511716..0000000000 --- a/packages/ecs-browser/src/types.ts +++ /dev/null @@ -1,14 +0,0 @@ -import { Component, ComponentValue, Entity, Schema } from "@latticexyz/recs"; -import { AnyComponent } from "@latticexyz/recs"; - -export type SetContractComponentFunction = ( - entity: Entity, - component: Component, - newValue: ComponentValue -) => void; - -export type AnyComponentWithContract = Component; - -export function hasContract(component: AnyComponent): component is AnyComponentWithContract { - return component.metadata?.contractId !== undefined; -} diff --git a/packages/ecs-browser/tsconfig.json b/packages/ecs-browser/tsconfig.json deleted file mode 100644 index 74c26f022e..0000000000 --- a/packages/ecs-browser/tsconfig.json +++ /dev/null @@ -1,17 +0,0 @@ -{ - "compilerOptions": { - "target": "es2020", - "module": "esnext", - "moduleResolution": "node", - "resolveJsonModule": true, - "declaration": true, - "sourceMap": true, - "outDir": "dist", - "isolatedModules": true, - "esModuleInterop": true, - "forceConsistentCasingInFileNames": true, - "strict": true, - "skipLibCheck": true, - "jsx": "react-jsx" - } -} diff --git a/packages/ecs-browser/tsup.config.js b/packages/ecs-browser/tsup.config.js deleted file mode 100644 index 519f886191..0000000000 --- a/packages/ecs-browser/tsup.config.js +++ /dev/null @@ -1,11 +0,0 @@ -import { defineConfig } from "tsup"; - -export default defineConfig({ - entry: ["src/index.ts"], - outDir: "dist", - format: ["esm"], - dts: false, - sourcemap: true, - clean: true, - minify: true, -}); diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 79b04639c8..fa5ba642d0 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -387,45 +387,7 @@ importers: specifier: 0.31.4 version: 0.31.4(jsdom@22.1.0) - packages/ecs-browser: - dependencies: - '@latticexyz/recs': - specifier: workspace:* - version: link:../recs - '@latticexyz/std-client': - specifier: workspace:* - version: link:../std-client - '@latticexyz/utils': - specifier: workspace:* - version: link:../utils - goober: - specifier: ^2.1.11 - version: 2.1.11(csstype@3.1.2) - lodash: - specifier: ^4.17.21 - version: 4.17.21 - mobx: - specifier: ^6.7.0 - version: 6.9.0 - mobx-react-lite: - specifier: ^3.4.0 - version: 3.4.0(mobx@6.9.0)(react@18.2.0) - react: - specifier: ^18.2.0 - version: 18.2.0 - shiki: - specifier: ^0.11.1 - version: 0.11.1 - devDependencies: - '@types/lodash': - specifier: ^4.14.182 - version: 4.14.182 - '@types/react': - specifier: ^18.2.6 - version: 18.2.6 - tsup: - specifier: ^6.7.0 - version: 6.7.0(postcss@8.4.23)(typescript@5.1.6) + packages/ecs-browser: {} packages/gas-report: dependencies: @@ -5021,6 +4983,7 @@ packages: /csstype@3.1.2: resolution: {integrity: sha512-I7K1Uu0MBPzaFKg4nI5Q7Vs2t+3gWWW648spaF+Rg7pI9ds18Ugn+lvg4SHczUdKlHI5LWBXyqfS8+DufyBsgQ==} + dev: true /csv-generate@3.4.3: resolution: {integrity: sha512-w/T+rqR0vwvHqWs/1ZyMDWtHHSJaN06klRqJXBEpDJaM/+dZkso0OKh1VcuuYvK3XM53KysVNq8Ko/epCK8wOw==} @@ -6589,14 +6552,6 @@ packages: merge2: 1.4.1 slash: 3.0.0 - /goober@2.1.11(csstype@3.1.2): - resolution: {integrity: sha512-5SS2lmxbhqH0u9ABEWq7WPU69a4i2pYcHeCxqaNq6Cw3mnrF0ghWNM4tEGid4dKy8XNIAUbuThuozDHHKJVh3A==} - peerDependencies: - csstype: ^3.0.10 - dependencies: - csstype: 3.1.2 - dev: false - /google-protobuf@3.21.2: resolution: {integrity: sha512-3MSOYFO5U9mPGikIYCzK0SaThypfGgS6bHqrUGXG3DPHCrb+txNqeEcns1W0lkGfk0rCyNXm7xB9rMxnCiZOoA==} dev: false @@ -7850,6 +7805,7 @@ packages: /jsonc-parser@3.2.0: resolution: {integrity: sha512-gfFQZrcTc8CnKXp6Y4/CBT3fTc0OVuDofpre4aEeEpSBPV5X5v4+Vmx+8snU7RLPrNHPKSgLxGo9YuQzz20o+w==} + dev: true /jsonfile@2.4.0: resolution: {integrity: sha512-PKllAqbgLgxHaj8TElYymKCAgrASebJrWpTnEkOaTowt23VKXXN0sUeriJ+eh7y6ufb/CC5ap11pz71/cM0hUw==} @@ -8536,23 +8492,6 @@ packages: obliterator: 2.0.4 dev: false - /mobx-react-lite@3.4.0(mobx@6.9.0)(react@18.2.0): - resolution: {integrity: sha512-bRuZp3C0itgLKHu/VNxi66DN/XVkQG7xtoBVWxpvC5FhAqbOCP21+nPhULjnzEqd7xBMybp6KwytdUpZKEgpIQ==} - peerDependencies: - mobx: ^6.1.0 - react: ^16.8.0 || ^17 || ^18 - react-dom: '*' - react-native: '*' - peerDependenciesMeta: - react-dom: - optional: true - react-native: - optional: true - dependencies: - mobx: 6.9.0 - react: 18.2.0 - dev: false - /mobx@6.9.0: resolution: {integrity: sha512-HdKewQEREEJgsWnErClfbFoVebze6rGazxFLU/XUyrII8dORfVszN1V0BMRnQSzcgsNNtkX8DHj3nC6cdWE9YQ==} dev: false @@ -10013,14 +9952,6 @@ packages: resolution: {integrity: sha512-7++dFhtcx3353uBaq8DDR4NuxBetBzC7ZQOhmTQInHEd6bSrXdiEyzCvG07Z44UYdLShWUyXt5M/yhz8ekcb1A==} engines: {node: '>=8'} - /shiki@0.11.1: - resolution: {integrity: sha512-EugY9VASFuDqOexOgXR18ZV+TbFrQHeCpEYaXamO+SZlsnT/2LxuLBX25GGtIrwaEVFXUAbUQ601SWE2rMwWHA==} - dependencies: - jsonc-parser: 3.2.0 - vscode-oniguruma: 1.7.0 - vscode-textmate: 6.0.0 - dev: false - /side-channel@1.0.4: resolution: {integrity: sha512-q5XPytqFEIKHkGdiMIrY10mvLRvnQh42/+GoBlFW3b2LXLE2xxJpZFdm94we0BaoV3RwJyGqg5wS7epxTv0Zvw==} dependencies: @@ -11347,14 +11278,6 @@ packages: - terser dev: true - /vscode-oniguruma@1.7.0: - resolution: {integrity: sha512-L9WMGRfrjOhgHSdOYgCt/yRMsXzLDJSL7BPrOZt73gU0iWO4mpqzqQzOz5srxqTvMBaR0XZTSrVWo4j55Rc6cA==} - dev: false - - /vscode-textmate@6.0.0: - resolution: {integrity: sha512-gu73tuZfJgu+mvCSy4UZwd2JXykjK9zAZsfmDeut5dx/1a7FeTk0XwJsSuqQn+cuMCGVbIBfl+s53X4T19DnzQ==} - dev: false - /w3c-xmlserializer@4.0.0: resolution: {integrity: sha512-d+BFHzbiCx6zGfz0HyQ6Rg69w9k19nviJspaj4yNscGjrHu94sVP+aRm75yEbCh+r2/yR+7q6hux9LVtbuTGBw==} engines: {node: '>=14'}