Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replaces the side debug bar with a live object view #781

Merged

Conversation

popey456963
Copy link
Contributor

@popey456963 popey456963 commented Aug 19, 2020

Fixes #775

This pull request replaces with the JSON.stringify() state and ctx sections with a live JSONTree view, which allows you to minimise / maximise attributes. This should help cases where the state is very large.

We use a custom package that is two lines different from the default to:

  • Expand objects by default.
  • Expand arrays that are less than 1024 characters in length by default.

Otherwise ctx and state start minimised even if they only contain a few elements which is infuriating. A ticket has been raised on the original project to ask if they can provide a solution in-package.

Note: This PR is currently a draft because it causes tests to fail.

@popey456963
Copy link
Contributor Author

popey456963 commented Aug 19, 2020

The latest commit replaces the import JSONTree from 'svelte-json-tree-auto'; line with import JSONTree from 'svelte-json-tree';, which is the default svelte-json-tree package available from the svelte team themselves. This is just to ensure that the issue is not caused by my packaging of the package.

Before this is merged, one of these should be removed from the package.json file.

Copy link
Member

@delucis delucis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for this @popey456963. And I think I’ve figured it out 🤞

src/client/debug/main/Main.svelte Outdated Show resolved Hide resolved
@delucis delucis marked this pull request as ready for review August 23, 2020 17:20
Copy link
Member

@delucis delucis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @popey456963 — I’ve merged in that change to use require instead of import when including the JSON Tree component, which has fixed the failing tests. Here are a few small changes to tidy this up and get it ready to merge. Cheers!

package.json Outdated Show resolved Hide resolved
package.json Outdated Show resolved Hide resolved
src/client/debug/main/Main.svelte Outdated Show resolved Hide resolved
src/client/debug/main/Main.svelte Outdated Show resolved Hide resolved
src/client/debug/main/Main.svelte Outdated Show resolved Hide resolved
src/client/debug/main/Main.svelte Outdated Show resolved Hide resolved
src/client/debug/main/Main.svelte Outdated Show resolved Hide resolved
@delucis delucis merged commit 88b0ee7 into boardgameio:master Aug 30, 2020
delucis added a commit that referenced this pull request Aug 31, 2020
`svelte-json-tree-auto` causes errors in tests (see #781). I think this 
might have something to do with the fact that the tree has circular 
dependencies, which perhaps the Jest transformer can’t handle. As it’s a 
third-party library, we can probably do without it during tests, and 
this change replaces it with an empty Svelte component for tests.
delucis added a commit that referenced this pull request Aug 31, 2020
* fix(debug): Import JSON tree Svelte component to fix runtime error

Relying on the compiled JavaScript of the JSON Tree component caused 
runtime errors. The best explanation I’ve read is here: 
<sveltejs/svelte#3671 (comment)>

* test(debug): Mock `svelte-json-tree-auto` in tests

`svelte-json-tree-auto` causes errors in tests (see #781). I think this 
might have something to do with the fact that the tree has circular 
dependencies, which perhaps the Jest transformer can’t handle. As it’s a 
third-party library, we can probably do without it during tests, and 
this change replaces it with an empty Svelte component for tests.

* test(debug): Add interactivity test for Debug panel
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Hide some parameters in debug menu
3 participants