@movk/core 0.0.3
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 +204 -0
- package/dist/index.d.mts +1005 -0
- package/dist/index.d.ts +1005 -0
- package/dist/index.mjs +1 -0
- package/package.json +79 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 mhaibaraai
|
|
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,204 @@
|
|
|
1
|
+
# @movk/core
|
|
2
|
+
|
|
3
|
+
[](https://www.typescriptlang.org/)
|
|
4
|
+
[![npm version][npm-version-src]][npm-version-href]
|
|
5
|
+
[![npm downloads][npm-downloads-src]][npm-downloads-href]
|
|
6
|
+
[![bundle][bundle-src]][bundle-href]
|
|
7
|
+
[![JSDocs][jsdocs-src]][jsdocs-href]
|
|
8
|
+
[![License][license-src]][license-href]
|
|
9
|
+
|
|
10
|
+
现代化的 Vue.js 工具库和组合式函数集合,提供完整的 TypeScript 支持和类型安全。
|
|
11
|
+
|
|
12
|
+
## ✨ 特性
|
|
13
|
+
|
|
14
|
+
- 🔧 **丰富的工具函数** - 涵盖数组、对象、字符串、文件等各类操作
|
|
15
|
+
- 🎯 **Vue 组合式函数** - 开箱即用的 Vue 3 Composition API 工具
|
|
16
|
+
- 📊 **数据结构** - 高效的树形结构和其他数据结构实现
|
|
17
|
+
- 🎨 **框架预设** - Flex 布局和 OWL 模式的CSS框架预设
|
|
18
|
+
- 🛡️ **类型安全** - 完整的 TypeScript 支持和 Zod 验证
|
|
19
|
+
- ⚡ **现代化** - 基于最新的 ES 模块和构建工具
|
|
20
|
+
- 📦 **轻量级** - 按需导入,最小化打包体积
|
|
21
|
+
|
|
22
|
+
## 📦 安装
|
|
23
|
+
|
|
24
|
+
```bash
|
|
25
|
+
# npm
|
|
26
|
+
npm install @movk/core
|
|
27
|
+
|
|
28
|
+
# yarn
|
|
29
|
+
yarn add @movk/core
|
|
30
|
+
|
|
31
|
+
# pnpm
|
|
32
|
+
pnpm add @movk/core
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
## 🚀 快速开始
|
|
36
|
+
|
|
37
|
+
```ts
|
|
38
|
+
import { debounce, deepClone, TreeNode, useAppStorage } from '@movk/core'
|
|
39
|
+
|
|
40
|
+
// 使用应用存储
|
|
41
|
+
const { state, setItem } = useAppStorage({
|
|
42
|
+
key: 'app-config',
|
|
43
|
+
defaultValue: { theme: 'light' }
|
|
44
|
+
})
|
|
45
|
+
|
|
46
|
+
// 使用防抖函数
|
|
47
|
+
const debouncedSearch = debounce((query: string) => {
|
|
48
|
+
// 搜索逻辑
|
|
49
|
+
}, 300)
|
|
50
|
+
|
|
51
|
+
// 深度克隆对象
|
|
52
|
+
const cloned = deepClone(originalObject)
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
## 📚 功能模块
|
|
56
|
+
|
|
57
|
+
### 🎯 Composables
|
|
58
|
+
|
|
59
|
+
Vue 3 组合式函数,提供响应式的状态管理和通用功能。
|
|
60
|
+
|
|
61
|
+
- **`useAppStorage`** - 应用存储管理,支持 localStorage 和 sessionStorage
|
|
62
|
+
- **`useCopyCode`** - 代码复制功能,支持多种格式和自定义处理
|
|
63
|
+
|
|
64
|
+
```ts
|
|
65
|
+
import { useAppStorage } from '@movk/core'
|
|
66
|
+
|
|
67
|
+
const { state, setItem, getItem, removeItem } = useAppStorage({
|
|
68
|
+
key: 'user-preferences',
|
|
69
|
+
defaultValue: { theme: 'light', language: 'zh-CN' }
|
|
70
|
+
})
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
### 🛠️ Utils
|
|
74
|
+
|
|
75
|
+
全面的工具函数库,覆盖常见的开发需求。
|
|
76
|
+
|
|
77
|
+
#### 🔄 异步工具 (Async)
|
|
78
|
+
|
|
79
|
+
- **`debounce`** - 防抖函数
|
|
80
|
+
- **`throttle`** - 节流函数
|
|
81
|
+
- **`sleep`** - 睡眠延迟函数
|
|
82
|
+
|
|
83
|
+
#### 📊 数组操作 (Array)
|
|
84
|
+
|
|
85
|
+
- **`operations`** - 数组操作工具集
|
|
86
|
+
|
|
87
|
+
#### 📄 对象处理 (Object)
|
|
88
|
+
|
|
89
|
+
- **`deepClone`** - 深度克隆
|
|
90
|
+
- **`pick`** - 选择对象属性
|
|
91
|
+
- **`omit`** - 排除对象属性
|
|
92
|
+
- **`separate`** - 对象分离
|
|
93
|
+
- **`convert`** - 对象转换
|
|
94
|
+
|
|
95
|
+
#### 🔤 字符串处理 (String)
|
|
96
|
+
|
|
97
|
+
- **`case`** - 大小写转换工具
|
|
98
|
+
|
|
99
|
+
#### 📁 文件操作 (File)
|
|
100
|
+
|
|
101
|
+
- **`download`** - 文件下载
|
|
102
|
+
- **`formatFileSize`** - 文件大小格式化
|
|
103
|
+
- **`convertSvgToPng`** - SVG 转 PNG
|
|
104
|
+
- **`replaceCurrentColor`** - 替换当前颜色
|
|
105
|
+
|
|
106
|
+
#### 🔍 验证器 (Validator)
|
|
107
|
+
|
|
108
|
+
基于 Zod 的类型验证工具
|
|
109
|
+
|
|
110
|
+
### 📊 数据结构 (Data Structures)
|
|
111
|
+
|
|
112
|
+
高效的数据结构实现,针对常见场景优化。
|
|
113
|
+
|
|
114
|
+
- **`TreeNode`** - 树形数据结构,支持遍历、搜索、修改等操作
|
|
115
|
+
|
|
116
|
+
```ts
|
|
117
|
+
import { TreeNode } from '@movk/core'
|
|
118
|
+
|
|
119
|
+
const tree = new TreeNode('root', 'Root Node')
|
|
120
|
+
tree.addChild(new TreeNode('child1', 'Child 1'))
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
### 🎨 框架预设 (Framework)
|
|
124
|
+
|
|
125
|
+
CSS 框架和布局预设,提供常用的样式模式。
|
|
126
|
+
|
|
127
|
+
- **`preset-flex`** - Flexbox 布局预设
|
|
128
|
+
- **`preset-owl`** - OWL (Object - Where - Layout) 模式预设
|
|
129
|
+
|
|
130
|
+
## 🔧 开发
|
|
131
|
+
|
|
132
|
+
### 环境要求
|
|
133
|
+
|
|
134
|
+
- Node.js 18+
|
|
135
|
+
- pnpm 9+
|
|
136
|
+
|
|
137
|
+
### 开发命令
|
|
138
|
+
|
|
139
|
+
```bash
|
|
140
|
+
# 安装依赖
|
|
141
|
+
pnpm install
|
|
142
|
+
|
|
143
|
+
# 开发模式
|
|
144
|
+
pnpm dev
|
|
145
|
+
|
|
146
|
+
# 构建
|
|
147
|
+
pnpm build
|
|
148
|
+
|
|
149
|
+
# 运行测试
|
|
150
|
+
pnpm test
|
|
151
|
+
|
|
152
|
+
# 代码检查
|
|
153
|
+
pnpm lint
|
|
154
|
+
|
|
155
|
+
# 类型检查
|
|
156
|
+
pnpm typecheck
|
|
157
|
+
|
|
158
|
+
# 发布版本
|
|
159
|
+
pnpm release
|
|
160
|
+
```
|
|
161
|
+
|
|
162
|
+
### 项目结构
|
|
163
|
+
|
|
164
|
+
```tree
|
|
165
|
+
movk-core/
|
|
166
|
+
├── src/
|
|
167
|
+
│ ├── composables/ # Vue 组合式函数
|
|
168
|
+
│ ├── constants/ # 常量定义
|
|
169
|
+
│ ├── data-structures/ # 数据结构实现
|
|
170
|
+
│ ├── framework/ # 框架预设
|
|
171
|
+
│ ├── types/ # TypeScript 类型定义
|
|
172
|
+
│ └── utils/ # 工具函数
|
|
173
|
+
│ ├── array/ # 数组工具
|
|
174
|
+
│ ├── async/ # 异步工具
|
|
175
|
+
│ ├── file/ # 文件操作
|
|
176
|
+
│ ├── object/ # 对象处理
|
|
177
|
+
│ ├── string/ # 字符串处理
|
|
178
|
+
│ ├── utilities/ # 通用工具
|
|
179
|
+
│ └── validator/ # 验证器
|
|
180
|
+
├── tests/ # 测试文件
|
|
181
|
+
└── scripts/ # 构建脚本
|
|
182
|
+
```
|
|
183
|
+
|
|
184
|
+
## 📄 许可证
|
|
185
|
+
|
|
186
|
+
[MIT](./LICENSE) License © 2025 mhaibaraai
|
|
187
|
+
|
|
188
|
+
## 📞 支持
|
|
189
|
+
|
|
190
|
+
- [GitHub Issues](https://github.com/mhaibaraai/movk-core/issues)
|
|
191
|
+
- [文档](https://github.com/mhaibaraai/movk-core)
|
|
192
|
+
|
|
193
|
+
<!-- Badges -->
|
|
194
|
+
|
|
195
|
+
[npm-version-src]: https://img.shields.io/npm/v/@movk/core?style=flat&colorA=080f12&colorB=1fa669
|
|
196
|
+
[npm-version-href]: https://npmjs.com/package/@movk/core
|
|
197
|
+
[npm-downloads-src]: https://img.shields.io/npm/dm/@movk/core?style=flat&colorA=080f12&colorB=1fa669
|
|
198
|
+
[npm-downloads-href]: https://npmjs.com/package/@movk/core
|
|
199
|
+
[bundle-src]: https://img.shields.io/bundlephobia/minzip/@movk/core?style=flat&colorA=080f12&colorB=1fa669&label=minzip
|
|
200
|
+
[bundle-href]: https://bundlephobia.com/result?p=@movk/core
|
|
201
|
+
[license-src]: https://img.shields.io/github/license/mhaibaraai/movk-core.svg?style=flat&colorA=080f12&colorB=1fa669
|
|
202
|
+
[license-href]: https://github.com/mhaibaraai/movk-core/blob/main/LICENSE.md
|
|
203
|
+
[jsdocs-src]: https://img.shields.io/badge/jsdocs-reference-080f12?style=flat&colorA=080f12&colorB=1fa669
|
|
204
|
+
[jsdocs-href]: https://www.jsdocs.io/package/@movk/core
|