thomasboyt / coquette-inspect

A Chrome DevTools extension for inspecting games made with the Coquette framework

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Better labeling for & handling of hidden objects in properties tree

thomasboyt opened this issue · comments

Labeling

Currently, they all say [[circular reference]] which is actually usually not even true, they're just objects already seen.

There's basically four reasons an object is hidden:

  1. It's not serializable, in which case it should say [object ObjectType]
  2. The object has already been serialized once (either a circular reference, or just a duplicate one). This is tricky, because e.g. [object hidden] may not be clear - may not be obvious where else in the tree it'll be. Right now, this just is [circular reference], so it should be able to stay that way for v0.1.
  3. It's another entity. It would actually be amazing if this could be a link to elsewhere in the tree, using the entity's ID! This could be formatted as e.g. [entity <uuid>]
  4. It's a coquette namespace, in which case it says [coquette namespace]
  1. and 4) should already be working, but 2) and 3) require some way to distinguish between each other so the serializer can set them correctly. I think the solution is to use the value of the entityMap/seen to indicate whether it's a previously serialized object (2), or another entity (3).

Handling

This goes in tandem with the above. One of the tricky bits about this is making sure that these fancy strings with fancy meanings don't end up conflicting with actual set strings, because there's going to be a regex match used against them to ensure that the UI doesn't allow them to be edited.

From the above, I could think of a few regexes to match:

  1. ^\[object\s[^\s]*]$ - matches [object Object], not [object], not [object object object]
  2. ^[circular reference]$
  3. ^[entity \s[^\s]*$ - similar to 1
  4. ^[coquette namespace]$

These should probably be in the docs somewhere, as a way of saying "make sure your strings don't match things!"

closed by 4d50407 + 934efe9 💥