- Fixed calling
onWriterepeatedly with the same function only subscribing once - Now supports Svelte 5 (-next.94 and later)
In Svelte 5, this package does not use runes and continues to use the original writable store interface, which is not deprecated. I may release a separate package that uses runes.
- When using a 3rd-party
StorageArea, the callbacks this package sends to it no longer throw ifchromeorchrome.runtimeare missing. This makes the package usable outside a WebExtension. - Updated
storageArea's JSDocs - Marked as compatible with Svelte 4.0.0-next.1 and up
- Breaking change: The signature of
webextStorageAdapteris now(storageArea, keys, {live}).onSetErrorhas been superceded byonWritebelow. - Breaking change: Required ECMAScript support increased from 6th Edition to 2020 Edition (Chrome 80+ or Firefox 74+)
- Breaking change: The default
live: trueoption now requires support forStorageArea.onChanged(Chrome 73+ or Firefox 101+) - Added:
storageAreacan now be a string, which is used to look up the object inchrome.storage. - Added: Use the
onWritemethod for store groups to get notified when StorageArea.set calls start, finish, or fail. - Changed: Setting a store to the primitive value it already had no longer re-saves that value to storage
If this update was useful for you, consider sending a tip!
Changes from 3.0.0 Beta 1 (published as `@next` February 4, 2023)
- Changed: Throw with a more useful error message if the first parameter is
undefinedor an incorrect string
Example migrations:
/* v2.0 */
let storeGroup = webextStorageAdapter(keys, {
storageArea: chrome.storage.local,
live: false,
});
/* v3.0 */
let storeGroup = webextStorageAdapter("local", keys, {live: false});
/* v2.0 */ let storeGroup = webextStorageAdapter(keys);
/* v3.0 */ let storeGroup = webextStorageAdapter("sync", keys);
/* v2.0 */
let storeGroup = webextStorageAdapter(keys, {onSetError: myErrorHandler});
/* v3.0 */
let storeGroup = webextStorageAdapter("sync", keys);
storeGroup.onWrite( (write) => {
write.catch( ({error, setItems}) => myErrorHandler(error, setItems) );
} );
/* Alternate v3.0 */
// The error will still be logged unless you call event.preventDefault()
let storeGroup = webextStorageAdapter("sync", keys);
window.addEventHandler("unhandledrejection", (event) => {
if ("setItems" in event.reason) {
let {error, setItems} = event.reason;
myErrorHandler(error, setItems);
}
});- Fixed
onSetErrornot receiving the correctsetItemsobject (#15)
No behavioral changes.
- Deleted the now-dead link about "invalid stores" from the readme's table of contents
- Breaking change: Using
webextStorageAdapter(null)now requires support forWeakRefandFinalizationRegistry - Improved: There is no longer any such thing as an "invalid store". A store's methods will not by themselves throw an error, regardless of circumstances.
- Breaking change: Using the default
live: trueoption with a 3rd-partystorageAreathat doesn't support it now throws an error. To continue using such an area, specifylive: falsein the options. - JSDocs now use Markdown [links] instead of JSDoc {@link}s, working around VSCode bugs with the latter
No behavioral changes.
- Added repository, exports, & sideEffects fields to package.json
No behavioral changes.
- Fixed an erroneously-placed link in the JSDocs for store group objects.
No behavioral changes.
- JSDocs added. TypeScript can get type info from JSDocs, so TypeScript is now partially supported!
- Readme's section on
svelte-writable-derivedhas been updated to use v2's API.
- Initial release