nuxt-state 0.0.1 → 0.0.2
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 +13 -15
- package/dist/module.json +1 -1
- package/package.json +30 -28
package/README.md
CHANGED
|
@@ -7,10 +7,8 @@
|
|
|
7
7
|
```ts
|
|
8
8
|
defineState(() => {
|
|
9
9
|
// standard Vue Composition API
|
|
10
|
-
return {
|
|
11
|
-
|
|
12
|
-
};
|
|
13
|
-
});
|
|
10
|
+
return {/* public state */}
|
|
11
|
+
})
|
|
14
12
|
```
|
|
15
13
|
|
|
16
14
|
A regular composable runs its factory for every invocation. A composable created by
|
|
@@ -39,8 +37,8 @@ pnpm add nuxt-state
|
|
|
39
37
|
```ts
|
|
40
38
|
// nuxt.config.ts
|
|
41
39
|
export default defineNuxtConfig({
|
|
42
|
-
modules: [
|
|
43
|
-
})
|
|
40
|
+
modules: ['nuxt-state'],
|
|
41
|
+
})
|
|
44
42
|
```
|
|
45
43
|
|
|
46
44
|
The package has not been published yet; during development, use this repository as a
|
|
@@ -53,19 +51,19 @@ Create a state in Nuxt 4's application source directory:
|
|
|
53
51
|
```ts
|
|
54
52
|
// app/states/counter.ts
|
|
55
53
|
export const useCounter = defineState(() => {
|
|
56
|
-
const count = ref(0)
|
|
57
|
-
const double = computed(() => count.value * 2)
|
|
54
|
+
const count = ref(0)
|
|
55
|
+
const double = computed(() => count.value * 2)
|
|
58
56
|
|
|
59
57
|
function increment() {
|
|
60
|
-
count.value
|
|
58
|
+
count.value++
|
|
61
59
|
}
|
|
62
60
|
|
|
63
61
|
return {
|
|
64
62
|
count,
|
|
65
63
|
double,
|
|
66
64
|
increment,
|
|
67
|
-
}
|
|
68
|
-
})
|
|
65
|
+
}
|
|
66
|
+
})
|
|
69
67
|
```
|
|
70
68
|
|
|
71
69
|
Exports from `app/states/`, including nested directories and multiple exports per file,
|
|
@@ -74,11 +72,11 @@ as in `app/composables/`.
|
|
|
74
72
|
|
|
75
73
|
```vue
|
|
76
74
|
<script setup lang="ts">
|
|
77
|
-
const { count, double, increment } = useCounter()
|
|
75
|
+
const { count, double, increment } = useCounter()
|
|
78
76
|
|
|
79
|
-
count.value
|
|
80
|
-
increment()
|
|
81
|
-
console.log(double.value)
|
|
77
|
+
count.value++
|
|
78
|
+
increment()
|
|
79
|
+
console.log(double.value)
|
|
82
80
|
</script>
|
|
83
81
|
```
|
|
84
82
|
|
package/dist/module.json
CHANGED
package/package.json
CHANGED
|
@@ -1,31 +1,31 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "nuxt-state",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.2",
|
|
4
4
|
"description": "Define shared Nuxt state using the same Composition API you already use in composables.",
|
|
5
5
|
"keywords": [
|
|
6
|
+
"composable",
|
|
6
7
|
"nuxt",
|
|
7
8
|
"nuxt-module",
|
|
8
|
-
"vue",
|
|
9
9
|
"state",
|
|
10
|
-
"
|
|
10
|
+
"vue"
|
|
11
11
|
],
|
|
12
|
+
"homepage": "https://github.com/navidtm/nuxt-state#readme",
|
|
13
|
+
"bugs": {
|
|
14
|
+
"url": "https://github.com/navidtm/nuxt-state/issues"
|
|
15
|
+
},
|
|
12
16
|
"license": "MIT",
|
|
13
17
|
"author": "Navid Talebian",
|
|
14
|
-
"type": "module",
|
|
15
18
|
"repository": {
|
|
16
19
|
"type": "git",
|
|
17
20
|
"url": "git+https://github.com/navidtm/nuxt-state.git"
|
|
18
21
|
},
|
|
19
|
-
"
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
"import": "./dist/module.mjs"
|
|
27
|
-
}
|
|
28
|
-
},
|
|
22
|
+
"workspaces": [
|
|
23
|
+
"playground"
|
|
24
|
+
],
|
|
25
|
+
"files": [
|
|
26
|
+
"dist"
|
|
27
|
+
],
|
|
28
|
+
"type": "module",
|
|
29
29
|
"main": "./dist/module.mjs",
|
|
30
30
|
"typesVersions": {
|
|
31
31
|
"*": {
|
|
@@ -34,24 +34,18 @@
|
|
|
34
34
|
]
|
|
35
35
|
}
|
|
36
36
|
},
|
|
37
|
-
"
|
|
38
|
-
"
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
37
|
+
"exports": {
|
|
38
|
+
".": {
|
|
39
|
+
"types": "./dist/types.d.mts",
|
|
40
|
+
"import": "./dist/module.mjs"
|
|
41
|
+
}
|
|
42
|
+
},
|
|
43
43
|
"publishConfig": {
|
|
44
44
|
"access": "public"
|
|
45
45
|
},
|
|
46
|
-
"engines": {
|
|
47
|
-
"node": ">=22"
|
|
48
|
-
},
|
|
49
46
|
"dependencies": {
|
|
50
47
|
"@nuxt/kit": "^4.5.2"
|
|
51
48
|
},
|
|
52
|
-
"peerDependencies": {
|
|
53
|
-
"nuxt": "^4.0.0"
|
|
54
|
-
},
|
|
55
49
|
"devDependencies": {
|
|
56
50
|
"@nuxt/devtools": "^3.4.2",
|
|
57
51
|
"@nuxt/eslint-config": "^1.17.0",
|
|
@@ -60,20 +54,28 @@
|
|
|
60
54
|
"@nuxt/test-utils": "^4.1.0",
|
|
61
55
|
"@types/node": "latest",
|
|
62
56
|
"changelogen": "^0.6.2",
|
|
63
|
-
"eslint": "^10.9.0",
|
|
64
57
|
"happy-dom": "^20.8.3",
|
|
65
58
|
"nuxt": "^4.5.2",
|
|
59
|
+
"oxfmt": "^0.65.0",
|
|
60
|
+
"oxlint": "^1.80.0",
|
|
66
61
|
"typescript": "^6.0.3",
|
|
67
62
|
"vitest": "^4.1.11",
|
|
68
63
|
"vue": "^3.5.31",
|
|
69
64
|
"vue-tsc": "^3.3.11"
|
|
70
65
|
},
|
|
66
|
+
"engines": {
|
|
67
|
+
"node": ">=22"
|
|
68
|
+
},
|
|
71
69
|
"scripts": {
|
|
72
70
|
"dev": "pnpm dev:prepare && nuxt dev playground",
|
|
73
71
|
"dev:build": "nuxt build playground",
|
|
74
72
|
"dev:prepare": "nuxt-module-build build --stub && nuxt-module-build prepare && nuxt prepare playground",
|
|
75
|
-
"lint": "
|
|
73
|
+
"lint": "oxlint",
|
|
74
|
+
"lint:fix": "oxlint --fix",
|
|
75
|
+
"fmt": "oxfmt",
|
|
76
|
+
"fmt:check": "oxfmt --check",
|
|
76
77
|
"test": "vitest run",
|
|
78
|
+
"check": "pnpm run fmt && pnpm run lint",
|
|
77
79
|
"test:watch": "vitest",
|
|
78
80
|
"test:types": "vue-tsc --noEmit && pnpm --dir playground exec vue-tsc --noEmit"
|
|
79
81
|
}
|