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

Serialize strategy for entities

thomasboyt opened this issue · comments

Concerns:

  • postMessage can handle circular dependencies. It's unclear if chrome.runtime.sendMessage can do so as well. Hopefully, it can, since this will remove the need for a lib that handles circular refs, and will allow the object to be unpacked in a circular manner
  • postMessage cannot handle (per MDN) DOM nodes, functions, and errors

It seems like, before being sent through postMessage, an entity needs to be cleaned of unserializable parts. It seems like the only clean way to do this is to piggy-back off of an existing in-JS structured clone implementation.

Possible options:

Whoops, chrome's port.postMessage is a TOTALLY DIFFERENT API from window.postMessage, and internally uses JSON.stringfy instead of a structured clone algorithm! Gross.

Will need to rethink.

current status: fuckit.js