@coaction/vue 2.0.0 → 2.1.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/README.md +3 -5
- package/dist/index.js +18 -0
- package/dist/index.mjs +18 -0
- package/package.json +11 -6
package/README.md
CHANGED
|
@@ -1,17 +1,15 @@
|
|
|
1
1
|
# @coaction/vue
|
|
2
2
|
|
|
3
|
-

|
|
4
|
-
[](https://www.npmjs.com/package/@coaction/vue)
|
|
5
|
-

|
|
3
|
+
 [](https://www.npmjs.com/package/@coaction/vue) 
|
|
6
4
|
|
|
7
5
|
A Coaction integration tool for Vue
|
|
8
6
|
|
|
9
7
|
## Installation
|
|
10
8
|
|
|
11
|
-
|
|
9
|
+
Install it with pnpm:
|
|
12
10
|
|
|
13
11
|
```sh
|
|
14
|
-
|
|
12
|
+
pnpm add coaction @coaction/vue
|
|
15
13
|
```
|
|
16
14
|
|
|
17
15
|
## Usage
|
package/dist/index.js
CHANGED
|
@@ -8,6 +8,7 @@ const isPlainObject = (value) => {
|
|
|
8
8
|
const prototype = Object.getPrototypeOf(value);
|
|
9
9
|
return prototype === Object.prototype || prototype === null;
|
|
10
10
|
};
|
|
11
|
+
const directMutationErrorMessage = "Direct state mutation is not allowed in immutable Coaction stores. Wrap mutations in set(() => { ... }).";
|
|
11
12
|
const createStateProxy = (store, version) => new Proxy({}, {
|
|
12
13
|
get(_, key) {
|
|
13
14
|
version.value;
|
|
@@ -29,6 +30,23 @@ const createStateProxy = (store, version) => new Proxy({}, {
|
|
|
29
30
|
...descriptor,
|
|
30
31
|
configurable: true
|
|
31
32
|
};
|
|
33
|
+
},
|
|
34
|
+
set(_, key, value) {
|
|
35
|
+
const state = store.getState();
|
|
36
|
+
state[key] = value;
|
|
37
|
+
return true;
|
|
38
|
+
},
|
|
39
|
+
deleteProperty(_, key) {
|
|
40
|
+
const state = store.getState();
|
|
41
|
+
if (!(key in state)) throw new TypeError(`Unknown state key '${String(key)}' cannot be deleted.`);
|
|
42
|
+
delete state[key];
|
|
43
|
+
return true;
|
|
44
|
+
},
|
|
45
|
+
defineProperty() {
|
|
46
|
+
throw new Error(directMutationErrorMessage);
|
|
47
|
+
},
|
|
48
|
+
setPrototypeOf() {
|
|
49
|
+
throw new Error(directMutationErrorMessage);
|
|
32
50
|
}
|
|
33
51
|
});
|
|
34
52
|
const createAutoSelector = (store, version) => {
|
package/dist/index.mjs
CHANGED
|
@@ -8,6 +8,7 @@ const isPlainObject = (value) => {
|
|
|
8
8
|
const prototype = Object.getPrototypeOf(value);
|
|
9
9
|
return prototype === Object.prototype || prototype === null;
|
|
10
10
|
};
|
|
11
|
+
const directMutationErrorMessage = "Direct state mutation is not allowed in immutable Coaction stores. Wrap mutations in set(() => { ... }).";
|
|
11
12
|
const createStateProxy = (store, version) => new Proxy({}, {
|
|
12
13
|
get(_, key) {
|
|
13
14
|
version.value;
|
|
@@ -29,6 +30,23 @@ const createStateProxy = (store, version) => new Proxy({}, {
|
|
|
29
30
|
...descriptor,
|
|
30
31
|
configurable: true
|
|
31
32
|
};
|
|
33
|
+
},
|
|
34
|
+
set(_, key, value) {
|
|
35
|
+
const state = store.getState();
|
|
36
|
+
state[key] = value;
|
|
37
|
+
return true;
|
|
38
|
+
},
|
|
39
|
+
deleteProperty(_, key) {
|
|
40
|
+
const state = store.getState();
|
|
41
|
+
if (!(key in state)) throw new TypeError(`Unknown state key '${String(key)}' cannot be deleted.`);
|
|
42
|
+
delete state[key];
|
|
43
|
+
return true;
|
|
44
|
+
},
|
|
45
|
+
defineProperty() {
|
|
46
|
+
throw new Error(directMutationErrorMessage);
|
|
47
|
+
},
|
|
48
|
+
setPrototypeOf() {
|
|
49
|
+
throw new Error(directMutationErrorMessage);
|
|
32
50
|
}
|
|
33
51
|
});
|
|
34
52
|
const createAutoSelector = (store, version) => {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@coaction/vue",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.1.0",
|
|
4
4
|
"description": "A Coaction integration tool for Vue",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"coaction",
|
|
@@ -29,9 +29,14 @@
|
|
|
29
29
|
"types": "dist/index.d.ts",
|
|
30
30
|
"exports": {
|
|
31
31
|
".": {
|
|
32
|
-
"
|
|
33
|
-
|
|
34
|
-
|
|
32
|
+
"import": {
|
|
33
|
+
"types": "./dist/index.d.mts",
|
|
34
|
+
"default": "./dist/index.mjs"
|
|
35
|
+
},
|
|
36
|
+
"require": {
|
|
37
|
+
"types": "./dist/index.d.ts",
|
|
38
|
+
"default": "./dist/index.js"
|
|
39
|
+
},
|
|
35
40
|
"default": "./dist/index.mjs"
|
|
36
41
|
},
|
|
37
42
|
"./package.json": "./package.json"
|
|
@@ -43,10 +48,10 @@
|
|
|
43
48
|
"devDependencies": {
|
|
44
49
|
"@testing-library/vue": "^8.1.0",
|
|
45
50
|
"vue": "^3.5.30",
|
|
46
|
-
"coaction": "2.
|
|
51
|
+
"coaction": "2.1.0"
|
|
47
52
|
},
|
|
48
53
|
"peerDependencies": {
|
|
49
|
-
"coaction": "
|
|
54
|
+
"coaction": ">=2.1.0 <3",
|
|
50
55
|
"vue": "^3.0.0"
|
|
51
56
|
},
|
|
52
57
|
"authors": [
|