zenon 0.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/LICENSE +21 -0
- package/README.md +110 -0
- package/dist/create.d.mts +7 -0
- package/dist/create.d.ts +7 -0
- package/dist/create.js +40 -0
- package/dist/create.mjs +15 -0
- package/dist/createStore.d.mts +10 -0
- package/dist/createStore.d.ts +10 -0
- package/dist/createStore.js +43 -0
- package/dist/createStore.mjs +18 -0
- package/package.json +45 -0
package/LICENSE
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
MIT License
|
2
|
+
|
3
|
+
Copyright (c) 2025 ์๊ตฌ๋ชฌ
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
13
|
+
copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
@@ -0,0 +1,110 @@
|
|
1
|
+
<p align="center">
|
2
|
+
<img width="800" src="https://github.com/ljlm0402/zenon/raw/images/logo.png" alt="zenon logo" />
|
3
|
+
</p>
|
4
|
+
|
5
|
+
<h1 align="center">Zenon</h1>
|
6
|
+
<p align="center">A minimalist, Zustand-inspired state manager for <b>Vue 3</b></p>
|
7
|
+
|
8
|
+
---
|
9
|
+
|
10
|
+
## โจ Features
|
11
|
+
|
12
|
+
- ๐ <b>Vue 3</b> Composition API ์ ์ฉ
|
13
|
+
- โก๏ธ <b>Zustand์ ๊ฑฐ์ ๋์ผํ DX</b>: set/get/selector ๋ชจ๋ ์ง์
|
14
|
+
- ๐งโ๐ป <b>TypeScript ์นํ์ </b>: ํ์
์ถ๋ก /๋ถ๋ฆฌ/์ก์
๋ชจ๋ ์ฌ์
|
15
|
+
- ๐ <b>์ด๊ฒฝ๋ & ์ฌํ</b>: 1-file store, ๋ฌ๋์ปค๋ธ ZERO
|
16
|
+
- ๐งฉ <b>๋ถ๋ถ๊ตฌ๋
(Selector)</b> ์ง์, ์ปดํฌ๋ํธ๋ณ ์ต์ ํ OK
|
17
|
+
|
18
|
+
---
|
19
|
+
|
20
|
+
## ๐ฆ ์ค์น
|
21
|
+
|
22
|
+
```bash
|
23
|
+
pnpm add zenon
|
24
|
+
# or
|
25
|
+
npm install zenon
|
26
|
+
# or
|
27
|
+
yarn add zenon
|
28
|
+
```
|
29
|
+
|
30
|
+
---
|
31
|
+
|
32
|
+
## โก๏ธ ๊ธฐ๋ณธ ์ฌ์ฉ๋ฒ
|
33
|
+
|
34
|
+
```ts
|
35
|
+
// stores/counter.ts
|
36
|
+
import { createStore } from "zenon";
|
37
|
+
|
38
|
+
type State = { count: number };
|
39
|
+
type Actions = {
|
40
|
+
increase: () => void;
|
41
|
+
reset: () => void;
|
42
|
+
};
|
43
|
+
|
44
|
+
export const useCounter = () =>
|
45
|
+
createStore<State & Actions>((set, get) => ({
|
46
|
+
count: 0,
|
47
|
+
increase: () => set({ count: get().count + 1 }),
|
48
|
+
reset: () => set({ count: 0 }),
|
49
|
+
}));
|
50
|
+
```
|
51
|
+
|
52
|
+
---
|
53
|
+
|
54
|
+
## ๐ฏ ์ปดํฌ๋ํธ์์ ์ฌ์ฉ
|
55
|
+
|
56
|
+
```vue
|
57
|
+
<template>
|
58
|
+
<div>
|
59
|
+
<h2>Zenon Counter</h2>
|
60
|
+
<p>Count: {{ count }}</p>
|
61
|
+
<button @click="increase">+1</button>
|
62
|
+
<button @click="reset">Reset</button>
|
63
|
+
</div>
|
64
|
+
</template>
|
65
|
+
|
66
|
+
<script setup lang="ts">
|
67
|
+
import { useCounter } from "@/stores/counter";
|
68
|
+
const store = useCounter();
|
69
|
+
const count = store.useSelector((s) => s.count);
|
70
|
+
const { increase, reset } = store;
|
71
|
+
</script>
|
72
|
+
```
|
73
|
+
|
74
|
+
---
|
75
|
+
|
76
|
+
## ๐ฆ Selector๋ก ๋ถ๋ถ ๊ตฌ๋
|
77
|
+
|
78
|
+
```ts
|
79
|
+
const store = useCounter();
|
80
|
+
const count = store.useSelector((s) => s.count); // count๋ง ๋ฐ์
|
81
|
+
const double = store.useSelector((s) => s.count * 2); // ํ์๊ฐ๋ OK
|
82
|
+
```
|
83
|
+
|
84
|
+
---
|
85
|
+
|
86
|
+
## ๐งโ๐ป ํ์
๋ถ๋ฆฌ ์์
|
87
|
+
|
88
|
+
```ts
|
89
|
+
type UserState = { name: string; age: number };
|
90
|
+
type UserActions = { setName: (name: string) => void };
|
91
|
+
|
92
|
+
export const useUser = () =>
|
93
|
+
createStore<UserState & UserActions>((set, get) => ({
|
94
|
+
name: "์๊ตฌ๋ชฌ",
|
95
|
+
age: 32,
|
96
|
+
setName: (name) => set({ name }),
|
97
|
+
}));
|
98
|
+
```
|
99
|
+
|
100
|
+
---
|
101
|
+
|
102
|
+
## ๐ License
|
103
|
+
|
104
|
+
MIT
|
105
|
+
|
106
|
+
---
|
107
|
+
|
108
|
+
## โญ๏ธ Star & Contribute
|
109
|
+
|
110
|
+
์์ด๋์ด, PR, ํผ๋๋ฐฑ ๋ชจ๋ ํ์ํฉ๋๋ค!
|
package/dist/create.d.ts
ADDED
package/dist/create.js
ADDED
@@ -0,0 +1,40 @@
|
|
1
|
+
"use strict";
|
2
|
+
var __defProp = Object.defineProperty;
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
6
|
+
var __export = (target, all) => {
|
7
|
+
for (var name in all)
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
9
|
+
};
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
12
|
+
for (let key of __getOwnPropNames(from))
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
15
|
+
}
|
16
|
+
return to;
|
17
|
+
};
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
19
|
+
|
20
|
+
// src/create.ts
|
21
|
+
var create_exports = {};
|
22
|
+
__export(create_exports, {
|
23
|
+
create: () => create
|
24
|
+
});
|
25
|
+
module.exports = __toCommonJS(create_exports);
|
26
|
+
var import_vue = require("vue");
|
27
|
+
function create(initializer) {
|
28
|
+
const state = (0, import_vue.reactive)({});
|
29
|
+
const set = (updater) => {
|
30
|
+
Object.assign(state, updater);
|
31
|
+
};
|
32
|
+
const get = () => state;
|
33
|
+
const initial = initializer(set, get);
|
34
|
+
Object.assign(state, initial);
|
35
|
+
return (0, import_vue.readonly)(state);
|
36
|
+
}
|
37
|
+
// Annotate the CommonJS export names for ESM import in node:
|
38
|
+
0 && (module.exports = {
|
39
|
+
create
|
40
|
+
});
|
package/dist/create.mjs
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
// src/create.ts
|
2
|
+
import { reactive, readonly } from "vue";
|
3
|
+
function create(initializer) {
|
4
|
+
const state = reactive({});
|
5
|
+
const set = (updater) => {
|
6
|
+
Object.assign(state, updater);
|
7
|
+
};
|
8
|
+
const get = () => state;
|
9
|
+
const initial = initializer(set, get);
|
10
|
+
Object.assign(state, initial);
|
11
|
+
return readonly(state);
|
12
|
+
}
|
13
|
+
export {
|
14
|
+
create
|
15
|
+
};
|
@@ -0,0 +1,10 @@
|
|
1
|
+
import { ComputedRef } from 'vue';
|
2
|
+
|
3
|
+
type StoreApi<T> = {
|
4
|
+
get: () => T;
|
5
|
+
set: (updater: Partial<T>) => void;
|
6
|
+
useSelector: <S>(selector: (state: T) => S) => ComputedRef<S>;
|
7
|
+
};
|
8
|
+
declare function createStore<T extends Record<string, any>>(initializer: (set: StoreApi<T>["set"], get: StoreApi<T>["get"]) => T): T & Pick<StoreApi<T>, "useSelector">;
|
9
|
+
|
10
|
+
export { type StoreApi, createStore };
|
@@ -0,0 +1,10 @@
|
|
1
|
+
import { ComputedRef } from 'vue';
|
2
|
+
|
3
|
+
type StoreApi<T> = {
|
4
|
+
get: () => T;
|
5
|
+
set: (updater: Partial<T>) => void;
|
6
|
+
useSelector: <S>(selector: (state: T) => S) => ComputedRef<S>;
|
7
|
+
};
|
8
|
+
declare function createStore<T extends Record<string, any>>(initializer: (set: StoreApi<T>["set"], get: StoreApi<T>["get"]) => T): T & Pick<StoreApi<T>, "useSelector">;
|
9
|
+
|
10
|
+
export { type StoreApi, createStore };
|
@@ -0,0 +1,43 @@
|
|
1
|
+
"use strict";
|
2
|
+
var __defProp = Object.defineProperty;
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
6
|
+
var __export = (target, all) => {
|
7
|
+
for (var name in all)
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
9
|
+
};
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
12
|
+
for (let key of __getOwnPropNames(from))
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
15
|
+
}
|
16
|
+
return to;
|
17
|
+
};
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
19
|
+
|
20
|
+
// src/createStore.ts
|
21
|
+
var createStore_exports = {};
|
22
|
+
__export(createStore_exports, {
|
23
|
+
createStore: () => createStore
|
24
|
+
});
|
25
|
+
module.exports = __toCommonJS(createStore_exports);
|
26
|
+
var import_vue = require("vue");
|
27
|
+
function createStore(initializer) {
|
28
|
+
const state = (0, import_vue.reactive)({});
|
29
|
+
const set = (updater) => {
|
30
|
+
Object.assign(state, updater);
|
31
|
+
};
|
32
|
+
const get = () => state;
|
33
|
+
const useSelector = (selector) => {
|
34
|
+
return (0, import_vue.computed)(() => selector(state));
|
35
|
+
};
|
36
|
+
const initial = initializer(set, get);
|
37
|
+
Object.assign(state, initial);
|
38
|
+
return Object.assign(state, { useSelector });
|
39
|
+
}
|
40
|
+
// Annotate the CommonJS export names for ESM import in node:
|
41
|
+
0 && (module.exports = {
|
42
|
+
createStore
|
43
|
+
});
|
@@ -0,0 +1,18 @@
|
|
1
|
+
// src/createStore.ts
|
2
|
+
import { reactive, computed } from "vue";
|
3
|
+
function createStore(initializer) {
|
4
|
+
const state = reactive({});
|
5
|
+
const set = (updater) => {
|
6
|
+
Object.assign(state, updater);
|
7
|
+
};
|
8
|
+
const get = () => state;
|
9
|
+
const useSelector = (selector) => {
|
10
|
+
return computed(() => selector(state));
|
11
|
+
};
|
12
|
+
const initial = initializer(set, get);
|
13
|
+
Object.assign(state, initial);
|
14
|
+
return Object.assign(state, { useSelector });
|
15
|
+
}
|
16
|
+
export {
|
17
|
+
createStore
|
18
|
+
};
|
package/package.json
ADDED
@@ -0,0 +1,45 @@
|
|
1
|
+
{
|
2
|
+
"name": "zenon",
|
3
|
+
"version": "0.1.0",
|
4
|
+
"description": "A minimalist Zustand-inspired state manager for Vue 3",
|
5
|
+
"author": "AGUMON <ljlm0402@gmail.com>",
|
6
|
+
"license": "MIT",
|
7
|
+
"keywords": [
|
8
|
+
"vue",
|
9
|
+
"state",
|
10
|
+
"zustand",
|
11
|
+
"composition-api",
|
12
|
+
"zenon",
|
13
|
+
"store",
|
14
|
+
"minimal"
|
15
|
+
],
|
16
|
+
"main": "dist/zenon.cjs.js",
|
17
|
+
"module": "dist/zenon.es.js",
|
18
|
+
"types": "dist/index.d.ts",
|
19
|
+
"exports": {
|
20
|
+
".": {
|
21
|
+
"import": "./dist/zenon.es.js",
|
22
|
+
"require": "./dist/zenon.cjs.js",
|
23
|
+
"types": "./dist/index.d.ts"
|
24
|
+
}
|
25
|
+
},
|
26
|
+
"files": [
|
27
|
+
"dist"
|
28
|
+
],
|
29
|
+
"scripts": {
|
30
|
+
"dev": "vite",
|
31
|
+
"build": "tsup src/createStore.ts --format cjs,esm --dts",
|
32
|
+
"prepare": "pnpm build"
|
33
|
+
},
|
34
|
+
"devDependencies": {
|
35
|
+
"@types/node": "^24.0.10",
|
36
|
+
"@vitejs/plugin-vue": "^5.0.0",
|
37
|
+
"tsup": "^7.3.0",
|
38
|
+
"typescript": "^5.3.0",
|
39
|
+
"vite": "^5.0.0",
|
40
|
+
"vue": "^3.4.0"
|
41
|
+
},
|
42
|
+
"peerDependencies": {
|
43
|
+
"vue": "^3.2.0"
|
44
|
+
}
|
45
|
+
}
|