realStorage 2.0 is out

realStorage 2.0 is now officially released. For those that don't know, realStorage is a compatibility library that handles browser incompatibilities for the W3C Web Storage API as of August. What's new in this release and why I am specifically supporting the August version of the spec and not the newest one, read on.

The biggest deal in realStorage 2 is support for Chrome 4 dev and IE 8. I don't know when Chrome's dev channel flipped the bit to let web pages access localStorage, but I have it under OS X so I was able to verify support.

As for IE 8, supporting that browser required some API tweaking. Turns out the browser has no support for accessors on non-DOM objects. That meant I had to make the length property optional and add a getLength() function.

The other major addition is Gears support. I needed to benchmark some of my PhD work on Chrome before it had localStorage support, so I had to add support to use Gears to get any results. This back-end is provided mostly for transition purposes as it looks like Gears might be on its way out in favor of the Web Storage API.

Otherwise I took this new major release as a chance to rename some things and continue to try to optimize the code as much as possible.

One thing to keep in mind, though, is that realStorage currently only supports the Web Storage spec as of August. The reason I am using an old version is that after the August draft the API switched to accepting structured clones instead of only strings. This makes implementation exceedingly difficult as it would mean coming up with my own serialization format for things such as Regexp and ImageData objects. I don't want to deal with that, so realStorage sticks to the old spec.

I emailed the WHATWG about this and voiced my concerns. Some supported me in wanting to roll back to the strings-only version. Others wanted to drop the spec entirely, but since all current browsers support the API that was deemed unreasonable. Otherwise wanted to tweak it to make it asynchronous to avoid lockup edge cases that exist. In the end the thread kind of died out and it seems the Web Database spec will become the more focused one, especially since databases can be accessed in web workers and they standardized what SQL dialect to support (sqlite 3.16.9 specifically).

At this point I consider realStorage done until the next round of major browser updates comes around. If they support the new version of the spec I will update realStorage to 3.0 to accept only strings. Otherwise there is nothing critical left to add to this code.