@open-pioneer/local-storage 0.3.5 → 2.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +23 -0
- package/README.md +12 -12
- package/package.json +3 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,28 @@
|
|
|
1
1
|
# @open-pioneer/local-storage
|
|
2
2
|
|
|
3
|
+
## 2.2.0
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 39dad46: Switch to a new versioning strategy.
|
|
8
|
+
From now on, packages released by this repository share a common version number.
|
|
9
|
+
- Updated dependencies [39dad46]
|
|
10
|
+
- @open-pioneer/core@2.2.0
|
|
11
|
+
- @open-pioneer/runtime@2.2.0
|
|
12
|
+
|
|
13
|
+
## 0.3.6
|
|
14
|
+
|
|
15
|
+
### Patch Changes
|
|
16
|
+
|
|
17
|
+
- 5c62522: Update wording and harmonize structure
|
|
18
|
+
- Updated dependencies [5c62522]
|
|
19
|
+
- Updated dependencies [58ce24f]
|
|
20
|
+
- Updated dependencies [50550d3]
|
|
21
|
+
- Updated dependencies [e0b2fae]
|
|
22
|
+
- Updated dependencies [6cc7fcd]
|
|
23
|
+
- @open-pioneer/core@1.3.0
|
|
24
|
+
- @open-pioneer/runtime@2.1.7
|
|
25
|
+
|
|
3
26
|
## 0.3.5
|
|
4
27
|
|
|
5
28
|
### Patch Changes
|
package/README.md
CHANGED
|
@@ -5,9 +5,9 @@ This package provides access to the browser's [local storage](https://developer.
|
|
|
5
5
|
A single local storage key (configurable, see [Configuration](#configuration)) is used to keep track of the application's persistent data.
|
|
6
6
|
Packages using the `LocalStorageService` can work with arbitrary values (including nested data structures) through a convenient API.
|
|
7
7
|
|
|
8
|
-
> NOTE: The `LocalStorageService`
|
|
9
|
-
> Changes to that data made via the `LocalStorageService`
|
|
10
|
-
> Concurrent changes made to the browser's local storage **
|
|
8
|
+
> NOTE: The `LocalStorageService` reads the persistent data from the browser's local storage on application startup.
|
|
9
|
+
> Changes to that data made via the `LocalStorageService` are reflected in the browser's local storage immediately.
|
|
10
|
+
> Concurrent changes made to the browser's local storage **are not** reflected by the `LocalStorageService`.
|
|
11
11
|
> In other words, there is no two-way synchronization between the two systems while the application is running.
|
|
12
12
|
>
|
|
13
13
|
> You should not attempt to modify the local storage value managed by the `LocalStorageService` (see `storageId` in [Configuration](#configuration)) through the "raw" Browser APIs while the application is running.
|
|
@@ -27,14 +27,14 @@ const storageService = ...; // injected
|
|
|
27
27
|
console.log(storageService.isSupported);
|
|
28
28
|
```
|
|
29
29
|
|
|
30
|
-
If local storage is not supported, other methods (such as `get()` and `set()`)
|
|
30
|
+
If local storage is not supported, other methods (such as `get()` and `set()`) throw an error.
|
|
31
31
|
|
|
32
32
|
### Reading and writing values
|
|
33
33
|
|
|
34
34
|
In its most basic form, you can use the `LocalStorageService` similar to a map.
|
|
35
|
-
In the background, changes to the service
|
|
35
|
+
In the background, changes to the service are always persisted into local storage.
|
|
36
36
|
|
|
37
|
-
All keys and values used in the `LocalStorageService`
|
|
37
|
+
All keys and values used in the `LocalStorageService` are serialized to JSON via `JSON.stringify()`.
|
|
38
38
|
Thus, only values supported by JSON can be used.
|
|
39
39
|
|
|
40
40
|
Example:
|
|
@@ -57,11 +57,11 @@ storageService.clear();
|
|
|
57
57
|
|
|
58
58
|
You can use the `LocalStorageService` to manage hierarchical data, including objects and arrays (see above).
|
|
59
59
|
_Namespaces_ can help you treat an object as a group of (nested) properties.
|
|
60
|
-
Getting or setting entries in the namespace
|
|
60
|
+
Getting or setting entries in the namespace update an object behind the scenes.
|
|
61
61
|
|
|
62
62
|
To use a namespace, call `getNamespace(key)` on either the `LocalStorageService` or another `LocalStorageNamespace` object.
|
|
63
63
|
The `key` used in `getNamespace(key)` should either already be associated with an object or it should not be set to a value at all.
|
|
64
|
-
If `key` is not yet associated with an existing object, a new empty object
|
|
64
|
+
If `key` is not yet associated with an existing object, a new empty object is created.
|
|
65
65
|
|
|
66
66
|
Example:
|
|
67
67
|
|
|
@@ -82,13 +82,13 @@ const namespace = storageService.getNamespace("my-package-name");
|
|
|
82
82
|
namespace.set("my-state", "some-value-to-save");
|
|
83
83
|
```
|
|
84
84
|
|
|
85
|
-
> NOTE: Multiple namespace instances using the same `key`
|
|
85
|
+
> NOTE: Multiple namespace instances using the same `key` manipulate the same object and see each other's effects.
|
|
86
86
|
|
|
87
87
|
### Configuration
|
|
88
88
|
|
|
89
|
-
| Name | Type | Description
|
|
90
|
-
| ----------- | ------ |
|
|
91
|
-
| `storageId` | String | The key under which the persistent data
|
|
89
|
+
| Name | Type | Description |
|
|
90
|
+
| ----------- | ------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
|
|
91
|
+
| `storageId` | String | The key under which the persistent data is saved. This value should be configured to a reasonably unique value to avoid clashes with other applications at the same origin. Defaults to `trails-state` (with a warning). |
|
|
92
92
|
|
|
93
93
|
### Implementation notes
|
|
94
94
|
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"type": "module",
|
|
3
3
|
"name": "@open-pioneer/local-storage",
|
|
4
|
-
"version": "
|
|
4
|
+
"version": "2.2.0",
|
|
5
5
|
"description": "Provides access to the browser's local storage.",
|
|
6
6
|
"keywords": [
|
|
7
7
|
"open-pioneer-trails"
|
|
@@ -14,8 +14,8 @@
|
|
|
14
14
|
"directory": "src/packages/local-storage"
|
|
15
15
|
},
|
|
16
16
|
"peerDependencies": {
|
|
17
|
-
"@open-pioneer/
|
|
18
|
-
"@open-pioneer/
|
|
17
|
+
"@open-pioneer/runtime": "^2.2.0",
|
|
18
|
+
"@open-pioneer/core": "^2.2.0"
|
|
19
19
|
},
|
|
20
20
|
"exports": {
|
|
21
21
|
"./package.json": "./package.json",
|