|
1 | 1 | # CHANGELOG |
2 | 2 |
|
3 | | -## v3.0.0 (2025-06-XX) |
| 3 | +## v3.0.0 (2025-06-18) |
4 | 4 |
|
5 | 5 | ### BREAKING CHANGES |
6 | 6 |
|
7 | | -- The `WebStorage` module is now exclusively available as an ES module (ESM), aligning with the modern JavaScript module standard. Additionally, it is no longer the default export — you must import it using a named import. |
8 | | - **v2.x.x** |
9 | | - ```js |
10 | | - import WebStorage from '@georapbox/web-storage'; |
11 | | - ``` |
12 | | - |
13 | | - **v3.x.x** |
14 | | - ```js |
15 | | - import { WebStorage } from '@georapbox/web-storage'; |
16 | | - ``` |
17 | | -- All API methods now return `[value, error]` tuple-like values instead of accepting error callbacks. |
18 | | - This allows developers to handle errors in a clean, synchronous style without using `try/catch` or providing callbacks. For example: |
19 | | - |
20 | | - **v2.x.x** |
21 | | - ```js |
22 | | - const value = storage.getItem('key', value, (err) => { |
23 | | - console.error(err); |
24 | | - }); |
25 | | - ``` |
26 | | - |
27 | | - **v3.x.x** |
28 | | - ```js |
29 | | - const [value, error] = storage.getItem('key', value); |
30 | | - |
31 | | - if (error) { |
32 | | - console.error(error); |
33 | | - } |
34 | | - ``` |
35 | | -- Removed support for error callback functions in all methods (`getItem`, `setItem`, `removeItem`, `clear`, `keys`, `length`, `iterate`). Errors must now be handled via the returned tuple. |
36 | | -- Internal `_keyPrefix` and `_driver` fields are now private class fields (`#keyPrefix`, `#driver`). They are no longer accessible outside the class. |
| 7 | +#### Switch to ES modules and named exports |
| 8 | + |
| 9 | +The `WebStorage` module is now exclusively available as an ES module (ESM), aligning with the modern JavaScript module standard. Additionally, it is no longer the default export — you must import it using a named import. |
| 10 | + |
| 11 | +**v2.x.x** |
| 12 | +```js |
| 13 | +import WebStorage from '@georapbox/web-storage'; |
| 14 | +``` |
| 15 | + |
| 16 | +**v3.x.x** |
| 17 | +```js |
| 18 | +import { WebStorage } from '@georapbox/web-storage'; |
| 19 | +``` |
| 20 | + |
| 21 | +#### API methods return [value, error] tuples |
37 | 22 |
|
38 | | -## NEW FEATURES |
| 23 | +All API methods now return `[value, error]` tuple-like values instead of accepting error callbacks. This allows developers to handle errors in a clean, synchronous style without using `try/catch` or providing callbacks. For example: |
39 | 24 |
|
40 | | -- Export type declaration files (`.d.ts`) for TypeScript users, ensuring better type safety and autocompletion support in TypeScript projects. |
| 25 | +**v2.x.x** |
| 26 | +```js |
| 27 | +const value = storage.getItem('key', value, (err) => { |
| 28 | + console.error(err); |
| 29 | +}); |
| 30 | +``` |
| 31 | + |
| 32 | +**v3.x.x** |
| 33 | +```js |
| 34 | +const [value, error] = storage.getItem('key', value); |
| 35 | + |
| 36 | +if (error) { |
| 37 | + console.error(error); |
| 38 | +} |
| 39 | +``` |
| 40 | + |
| 41 | +#### Removed noop storage fallback |
| 42 | + |
| 43 | +In previous versions, if `localStorage` or `sessionStorage` was unavailable (e.g., due to privacy settings or Safari private mode), a silent in-memory fallback was used that mimicked the Storage API. This allowed methods like `setItem()` to return success even though no actual data was stored. |
| 44 | + |
| 45 | +This behavior has been removed to improve transparency and correctness. As of v3.0.0: |
| 46 | + |
| 47 | +- No fallback is used. |
| 48 | +- Errors are captured and returned via the `[_, error]` tuple-like value. |
| 49 | +- Developers can use `WebStorage.isAvailable()` for feature detection, or gracefully handle errors based on method output. |
| 50 | + |
| 51 | +This ensures failures are explicit and prevents false assumptions about persistence. |
| 52 | + |
| 53 | +### NEW FEATURES |
| 54 | + |
| 55 | +#### Type declarations for TypeScript |
| 56 | + |
| 57 | +Export type declaration files (`.d.ts`) for TypeScript users, ensuring better type safety and autocompletion support in TypeScript projects. |
41 | 58 |
|
42 | 59 | ### INTERNAL CHANGES |
43 | 60 |
|
44 | | -- Rewrite to use native class private fields. |
45 | | -- Internal noopStorage fallback now fully conforms to the Storage interface. |
| 61 | +- Update Node.js version requirement and dev dependencies to the latest versions. |
46 | 62 | - Drop Jest in favor of @web/test-runner and Playwright for testing. |
47 | 63 | - Drop rollup in favor of esbuild for bundling. |
48 | | -- Update Node.js version requirement to 22.x.x. |
49 | | -- Update dependencies to their latest versions. |
50 | 64 |
|
51 | 65 | ## v2.1.0 (2021-01-26) |
52 | 66 |
|
53 | 67 | - Generate minified versions for ESM and CommonJS exported bubdles. |
54 | 68 |
|
55 | | -### Internal changes |
| 69 | +### INTERNAL CHANGES |
56 | 70 |
|
57 | 71 | - Replace Mocha with Jest as testing framework. |
58 | 72 | - Replace Travis CI with Github actions. |
|
79 | 93 | - `WebStorage.isAvailable` static method, as of v2.x, accepts "localStorage" or "sessionStorage" strings as arguments. |
80 | 94 | - On initialization the library **throws** if `driver` option is anything other than "localStorage" or "sessionStorage" and if `keyPrefix` option is not of type `String`. |
81 | 95 |
|
82 | | -### OTHER CHANGES |
| 96 | +### INTERNAL CHANGES |
83 | 97 |
|
84 | 98 | - Keep `devDependencies` up to date. |
85 | 99 |
|
|
0 commit comments