fezbox 0.0.1-security → 1.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.

Potentially problematic release.


This version of fezbox might be problematic. Click here for more details.

Files changed (78) hide show
  1. package/README.md +320 -3
  2. package/crypto.d.ts +1 -0
  3. package/crypto.js +1 -0
  4. package/data.d.ts +1 -0
  5. package/data.js +1 -0
  6. package/dist/crypto/decrypt.d.ts +8 -0
  7. package/dist/crypto/decrypt.d.ts.map +1 -0
  8. package/dist/crypto/index.cjs +1 -0
  9. package/dist/crypto/index.d.ts +2 -0
  10. package/dist/crypto/index.d.ts.map +1 -0
  11. package/dist/crypto/index.js +4 -0
  12. package/dist/crypto.d.ts +2 -0
  13. package/dist/data/clone.d.ts +7 -0
  14. package/dist/data/clone.d.ts.map +1 -0
  15. package/dist/data/index.cjs +1 -0
  16. package/dist/data/index.d.ts +2 -0
  17. package/dist/data/index.d.ts.map +1 -0
  18. package/dist/data/index.js +4 -0
  19. package/dist/data.d.ts +2 -0
  20. package/dist/decrypt-B6fiICsn.js +1 -0
  21. package/dist/decrypt-DwrxsWcv.mjs +11 -0
  22. package/dist/dom/index.cjs +1 -0
  23. package/dist/dom/index.d.ts +2 -0
  24. package/dist/dom/index.d.ts.map +1 -0
  25. package/dist/dom/index.js +28 -0
  26. package/dist/dom/outsideClick.d.ts +27 -0
  27. package/dist/dom/outsideClick.d.ts.map +1 -0
  28. package/dist/dom.d.ts +2 -0
  29. package/dist/fezbox.cjs +1 -0
  30. package/dist/fezbox.js +141 -0
  31. package/dist/file/fetch.d.ts +9 -0
  32. package/dist/file/fetch.d.ts.map +1 -0
  33. package/dist/file/format.d.ts +7 -0
  34. package/dist/file/format.d.ts.map +1 -0
  35. package/dist/file/index.cjs +1 -0
  36. package/dist/file/index.d.ts +4 -0
  37. package/dist/file/index.d.ts.map +1 -0
  38. package/dist/file/index.js +25 -0
  39. package/dist/file/upload.d.ts +12 -0
  40. package/dist/file/upload.d.ts.map +1 -0
  41. package/dist/file.d.ts +2 -0
  42. package/dist/index.d.ts +17 -0
  43. package/dist/index.d.ts.map +1 -0
  44. package/dist/qr/index.cjs +1 -0
  45. package/dist/qr/index.d.ts +94 -0
  46. package/dist/qr/index.d.ts.map +1 -0
  47. package/dist/qr/index.js +323 -0
  48. package/dist/qr.d.ts +2 -0
  49. package/dist/relative-5TnWB4bl.js +1 -0
  50. package/dist/relative-D0OTNLYG.mjs +8 -0
  51. package/dist/storage/index.d.ts +39 -0
  52. package/dist/storage/index.d.ts.map +1 -0
  53. package/dist/time/index.cjs +1 -0
  54. package/dist/time/index.d.ts +2 -0
  55. package/dist/time/index.d.ts.map +1 -0
  56. package/dist/time/index.js +4 -0
  57. package/dist/time/relative.d.ts +8 -0
  58. package/dist/time/relative.d.ts.map +1 -0
  59. package/dist/time.d.ts +2 -0
  60. package/dist/url/index.cjs +1 -0
  61. package/dist/url/index.d.ts +2 -0
  62. package/dist/url/index.d.ts.map +1 -0
  63. package/dist/url/index.js +19 -0
  64. package/dist/url/query.d.ts +51 -0
  65. package/dist/url/query.d.ts.map +1 -0
  66. package/dist/url.d.ts +2 -0
  67. package/dom.d.ts +1 -0
  68. package/dom.js +1 -0
  69. package/eslint.config.js +46 -0
  70. package/file.d.ts +1 -0
  71. package/file.js +1 -0
  72. package/package.json +109 -3
  73. package/qr.d.ts +1 -0
  74. package/qr.js +1 -0
  75. package/time.d.ts +1 -0
  76. package/time.js +1 -0
  77. package/url.d.ts +1 -0
  78. package/url.js +1 -0
package/README.md CHANGED
@@ -1,5 +1,322 @@
1
- # Security holding package
1
+ # FezBox
2
2
 
3
- This package contained malicious code and was removed from the registry by the npm security team. A placeholder was published to ensure users are not affected in the future.
3
+ [![npm version](https://badge.fury.io/js/fezbox.svg)](https://badge.fury.io/js/fezbox)
4
+ [![Test Coverage](https://img.shields.io/badge/coverage-90.96%25-brightgreen.svg)]
5
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
6
+ [![Node.js Version](https://img.shields.io/badge/node-%3E%3D18.0.0-brightgreen.svg)](https://nodejs.org/)
4
7
 
5
- Please refer to www.npmjs.com/advisories?search=fezbox for more information.
8
+ 一个包含常用工具函数的 JavaScript/TypeScript 库,按功能模块分类,便于按需引入。
9
+
10
+ ## ✨ 特性
11
+
12
+ - 📦 **模块化设计** - 支持按需引入,减少包体积
13
+ - 🔒 **完整 TypeScript 支持** - 提供准确的类型定义
14
+ - 🧪 **高测试覆盖率** - 102个测试用例覆盖所有核心功能
15
+ - 🎯 **轻量级** - 仅依赖必要的 peer dependencies
16
+ - 📚 **详细文档** - 包含完整的使用示例和 API 说明
17
+ - 🚀 **高性能** - 优化的算法和实现
18
+ - 🔧 **易维护** - 清晰的代码结构和完整的测试
19
+
20
+ ## 安装
21
+
22
+ ```bash
23
+ # 使用 npm
24
+ npm install fezbox
25
+
26
+ # 使用 pnpm
27
+ pnpm add fezbox
28
+
29
+ # 使用 yarn
30
+ yarn add fezbox
31
+ ```
32
+
33
+ ## 🚀 快速开始
34
+
35
+ ### 完整引入
36
+
37
+ ```typescript
38
+ import { deepClone, formatFileSize, relativeTime, outsideClick, getQueryObject } from 'fezbox'
39
+
40
+ // 深拷贝对象
41
+ const original = { a: 1, b: { c: 2 } }
42
+ const cloned = deepClone(original)
43
+
44
+ // 格式化文件大小
45
+ const size = formatFileSize(1048576) // "1.00 Mb"
46
+
47
+ // 相对时间格式化
48
+ const time = relativeTime(new Date(Date.now() - 3600000)) // "1小时前"
49
+
50
+ // 获取所有查询参数
51
+ const params = getQueryObject('https://example.com?id=123&name=test')
52
+ console.log(params) // { id: '123', name: 'test' }
53
+
54
+ // 外部点击监听
55
+ const element = document.getElementById('myElement')
56
+ const unlisten = outsideClick.listen({
57
+ domRefs: element,
58
+ handler: () => console.log('点击了外部区域')
59
+ })
60
+ ```
61
+
62
+ ### 按需引入(推荐)
63
+
64
+ ```typescript
65
+ // 只引入需要的模块,减少包体积
66
+ import { deepClone } from 'fezbox/data'
67
+ import { formatFileSize, fetchFile, uploadFileByUrl } from 'fezbox/file'
68
+ import { relativeTime } from 'fezbox/time'
69
+ import { getQueryParam, getQueryObject } from 'fezbox/url'
70
+ import { decryptAES } from 'fezbox/crypto'
71
+ import { outsideClick } from 'fezbox/dom'
72
+ import { QRCodeScriptLoader } from 'fezbox/qr'
73
+ import { getLocalStorage, setCookie, getSessionStorage } from 'fezbox/storage'
74
+ ```
75
+
76
+ ## 📚 API 文档
77
+
78
+ ### 📊 Data 模块
79
+
80
+ 深拷贝函数,基于 JSON 序列化实现,支持对象和数组的深度复制。
81
+
82
+ ```typescript
83
+ import { deepClone } from 'fezbox/data'
84
+
85
+ const obj = { a: 1, b: { c: 2 } }
86
+ const cloned = deepClone(obj)
87
+ ```
88
+
89
+ ### 📁 File 模块
90
+
91
+ 文件操作相关工具,包括文件大小格式化、文件获取和上传。
92
+
93
+ ```typescript
94
+ import { formatFileSize, fetchFile, uploadFileByUrl } from 'fezbox/file'
95
+
96
+ // 格式化文件大小
97
+ formatFileSize(1048576) // "1.00 Mb"
98
+
99
+ // 获取文件
100
+ const file = await fetchFile('https://example.com/image.jpg', 'image.jpg')
101
+
102
+ // 上传文件
103
+ const uploadedUrl = await uploadFileByUrl(
104
+ 'https://example.com/image.jpg',
105
+ async (formData) => {
106
+ const response = await fetch('/upload', { method: 'POST', body: formData })
107
+ return await response.json()
108
+ }
109
+ )
110
+ ```
111
+
112
+ ### ⏰ Time 模块
113
+
114
+ 相对时间格式化,支持多种输入格式。
115
+
116
+ ```typescript
117
+ import { relativeTime } from 'fezbox/time'
118
+
119
+ relativeTime(new Date()) // "刚刚"
120
+ relativeTime(new Date(Date.now() - 3600000)) // "1小时前"
121
+ relativeTime(new Date(Date.now() - 86400000)) // "1天前"
122
+ ```
123
+
124
+ ### 🔗 URL 模块
125
+
126
+ URL 查询参数处理工具。
127
+
128
+ ```typescript
129
+ import { getQueryObject, getQueryParam } from 'fezbox/url'
130
+
131
+ // 获取所有查询参数
132
+ const params = getQueryObject('https://example.com?id=123&name=test')
133
+ // 返回: { id: '123', name: 'test' }
134
+
135
+ // 获取单个参数
136
+ const id = getQueryParam('id', 'https://example.com?id=123&name=test') // "123"
137
+ ```
138
+
139
+ ### 🔐 Crypto 模块
140
+
141
+ AES 解密功能。
142
+
143
+ ```typescript
144
+ import { decryptAES } from 'fezbox/crypto'
145
+
146
+ const decrypted = decryptAES('encryptedData', 'my-secret-key')
147
+ ```
148
+
149
+ ### 🎯 DOM 模块
150
+
151
+ DOM 操作相关工具。
152
+
153
+ ```typescript
154
+ import { outsideClick } from 'fezbox/dom'
155
+
156
+ const element = document.getElementById('dropdown')
157
+ const unlisten = outsideClick.listen({
158
+ domRefs: element,
159
+ handler: () => {
160
+ console.log('点击了下拉菜单外部')
161
+ element.classList.remove('open')
162
+ }
163
+ })
164
+ ```
165
+
166
+ ### 🔲 QR Code 模块
167
+
168
+ 二维码与 JavaScript 代码的双向转换工具,支持自动依赖管理。
169
+
170
+ **特性:**
171
+ - 🚀 **零配置启动** - 自动检测并加载缺失的依赖
172
+ - 📊 **渐进式功能** - 根据可用依赖启用不同功能
173
+ - 🔐 **沙箱执行** - 安全的代码执行环境
174
+ - 🗜️ **智能压缩** - 自动选择最优的数据压缩方案
175
+
176
+ ```typescript
177
+ import { QRCodeScriptLoader } from 'fezbox/qr'
178
+
179
+ // 零配置使用,依赖会自动加载
180
+ const loader = new QRCodeScriptLoader({
181
+ sandbox: true, // 沙箱模式(推荐)
182
+ autoCompress: true, // 自动压缩
183
+ debug: true // 调试模式
184
+ })
185
+
186
+ // 生成二维码数据
187
+ const result = await loader.generateQRCodeData('Hello World')
188
+ if (result.success) {
189
+ console.log('生成成功:', result.data)
190
+ } else {
191
+ console.log('生成失败:', result.error)
192
+ }
193
+
194
+ // 检查功能可用性
195
+ console.log('生成功能:', loader.isFeatureAvailable('generate'))
196
+ console.log('解析功能:', loader.isFeatureAvailable('parse'))
197
+ console.log('压缩功能:', loader.isFeatureAvailable('compress'))
198
+
199
+ // 从图片解析二维码
200
+ const code = await loader.parseQRCodeFromImageData(imageData)
201
+
202
+ ```
203
+
204
+ ### 💾 Storage 模块
205
+
206
+ 提供统一的本地存储解决方案,包括 localStorage、sessionStorage 和 Cookie 的操作。
207
+
208
+ **特性:**
209
+ - 统一的 API 设计
210
+ - 自动 JSON 序列化/反序列化
211
+ - 过期时间支持(localStorage 和 Cookie)
212
+ - SSR 兼容性
213
+ - 完整的错误处理
214
+ - TypeScript 类型安全
215
+
216
+ ```typescript
217
+ import { getLocalStorage, setLocalStorage, setSessionStorage, getSessionStorage, setCookie, getCookie } from 'fezbox/storage'
218
+
219
+ // localStorage 基本操作
220
+ setLocalStorage('user', { name: 'John', age: 25 })
221
+ const user = getLocalStorage('user')
222
+
223
+ // 带过期时间的存储(1小时后过期)
224
+ setLocalStorage('tempData', { session: 'abc123' }, {
225
+ expires: Date.now() + 60 * 60 * 1000
226
+ })
227
+
228
+ // sessionStorage 操作
229
+ setSessionStorage('formData', { name: 'John', email: 'john@example.com' })
230
+ const formData = getSessionStorage('formData')
231
+
232
+ // Cookie 操作
233
+ setCookie('theme', 'dark', { expires: 7, secure: true })
234
+ const theme = getCookie('theme')
235
+
236
+ // 类型安全
237
+ interface UserInfo { id: number; name: string }
238
+ const userInfo = getLocalStorage<UserInfo>('userInfo')
239
+ ```
240
+
241
+ > 📖 **完整API文档**: [查看 docs/api/ 目录](./docs/api/) 了解每个模块的详细使用说明
242
+
243
+ ## 📦 依赖
244
+
245
+ ### 运行时依赖
246
+ - `crypto-js` (用于加密功能)
247
+ - `dayjs` (用于时间处理)
248
+
249
+ ### 开发依赖
250
+ - `vitest` (测试框架)
251
+ - `typescript` (类型支持)
252
+ - `vite` (构建工具)
253
+ - `eslint` + `prettier` (代码质量)
254
+
255
+ ## 🛠️ 开发
256
+
257
+ ```bash
258
+ # 安装依赖
259
+ pnpm install
260
+
261
+ # 开发模式 (监听文件变化)
262
+ pnpm run dev
263
+
264
+ # 构建
265
+ pnpm run build
266
+
267
+ # 运行测试
268
+ pnpm test
269
+
270
+ # 生成覆盖率报告
271
+ pnpm run test:coverage
272
+
273
+ # 类型检查
274
+ pnpm run typecheck
275
+
276
+ # 代码格式化
277
+ pnpm run format
278
+
279
+ # 代码检查
280
+ pnpm run lint
281
+
282
+ # 修复代码问题
283
+ pnpm run lint:fix
284
+ ```
285
+
286
+ ## 📊 测试
287
+
288
+ 项目包含完整的测试覆盖:
289
+
290
+ - **102个测试用例** 覆盖所有核心功能
291
+ - **高代码覆盖率** 确保代码质量
292
+ - **10个测试文件** 按模块组织
293
+ - **自动化的 CI/CD** 集成
294
+
295
+ 运行测试并查看覆盖率报告:
296
+
297
+ ```bash
298
+ pnpm run test:coverage
299
+ ```
300
+
301
+ 覆盖率报告会生成在 `coverage/` 目录下。
302
+
303
+ ## 🤝 贡献
304
+
305
+ 欢迎提交 Issue 和 Pull Request!
306
+
307
+ ### 开发流程
308
+ 1. Fork 项目
309
+ 2. 创建功能分支 (`git checkout -b feature/AmazingFeature`)
310
+ 3. 提交更改 (`git commit -m 'Add some AmazingFeature'`)
311
+ 4. 推送到分支 (`git push origin feature/AmazingFeature`)
312
+ 5. 创建 Pull Request
313
+
314
+ ### 代码规范
315
+ - 使用 TypeScript 编写
316
+ - 遵循 ESLint 和 Prettier 规范
317
+ - 编写对应的测试用例
318
+ - 确保所有测试通过
319
+
320
+ ## 许可证
321
+
322
+ MIT
package/crypto.d.ts ADDED
@@ -0,0 +1 @@
1
+ export * from './dist/crypto/index';
package/crypto.js ADDED
@@ -0,0 +1 @@
1
+ module.exports = require('./dist/crypto/index.cjs');
package/data.d.ts ADDED
@@ -0,0 +1 @@
1
+ export * from './dist/data/index';
package/data.js ADDED
@@ -0,0 +1 @@
1
+ module.exports = require('./dist/data/index.cjs');
@@ -0,0 +1,8 @@
1
+ /**
2
+ * AES 解密函数
3
+ * @param data - 加密的数据字符串
4
+ * @param key - 解密密钥,会自动截取前16位
5
+ * @returns 解密后的字符串
6
+ */
7
+ export declare const decryptAES: (data: string, key: string | number) => string;
8
+ //# sourceMappingURL=decrypt.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"decrypt.d.ts","sourceRoot":"","sources":["../../src/crypto/decrypt.ts"],"names":[],"mappings":"AAEA;;;;;GAKG;AACH,eAAO,MAAM,UAAU,GAAI,MAAM,MAAM,EAAE,KAAK,MAAM,GAAG,MAAM,KAAG,MAO/D,CAAA"}
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("../decrypt-B6fiICsn.js");exports.decryptAES=e.decryptAES;
@@ -0,0 +1,2 @@
1
+ export { decryptAES } from './decrypt';
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/crypto/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,WAAW,CAAA"}
@@ -0,0 +1,4 @@
1
+ import { d as e } from "../decrypt-DwrxsWcv.mjs";
2
+ export {
3
+ e as decryptAES
4
+ };
@@ -0,0 +1,2 @@
1
+ export * from './crypto/index'
2
+ export {}
@@ -0,0 +1,7 @@
1
+ /**
2
+ * 深拷贝函数
3
+ * @param data - 需要深拷贝的数据,可以是对象或对象数组
4
+ * @returns 深拷贝后的数据
5
+ */
6
+ export declare const deepClone: <T>(data: T) => T;
7
+ //# sourceMappingURL=clone.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"clone.d.ts","sourceRoot":"","sources":["../../src/data/clone.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,eAAO,MAAM,SAAS,GAAI,CAAC,EAAE,MAAM,CAAC,KAAG,CAKtC,CAAA"}
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=e=>e==null?e:JSON.parse(JSON.stringify(e));exports.deepClone=r;
@@ -0,0 +1,2 @@
1
+ export { deepClone } from './clone';
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/data/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,SAAS,CAAA"}
@@ -0,0 +1,4 @@
1
+ const r = (e) => e == null ? e : JSON.parse(JSON.stringify(e));
2
+ export {
3
+ r as deepClone
4
+ };
package/dist/data.d.ts ADDED
@@ -0,0 +1,2 @@
1
+ export * from './data/index'
2
+ export {}
@@ -0,0 +1 @@
1
+ "use strict";const t=require("crypto-js"),n=(e,c)=>{const r=t.enc.Utf8.parse(String(c).slice(0,16)),s=t.AES.decrypt(e,r,{mode:t.mode.ECB,padding:t.pad.Pkcs7});return t.enc.Utf8.stringify(s)};exports.decryptAES=n;
@@ -0,0 +1,11 @@
1
+ import t from "crypto-js";
2
+ const s = (e, r) => {
3
+ const c = t.enc.Utf8.parse(String(r).slice(0, 16)), n = t.AES.decrypt(e, c, {
4
+ mode: t.mode.ECB,
5
+ padding: t.pad.Pkcs7
6
+ });
7
+ return t.enc.Utf8.stringify(n);
8
+ };
9
+ export {
10
+ s as d
11
+ };
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const n={listeners:new WeakMap,listen({domRefs:e,handler:t}){if(this.listeners.has(t))return()=>this.unlisten(t);const i=s=>{e&&!(e===s.target||e.contains(s.target))&&t()};return document.addEventListener("click",i),this.listeners.set(t,i),()=>this.unlisten(t)},unlisten(e){const t=this.listeners.get(e);t&&(document.removeEventListener("click",t),this.listeners.delete(e))}};exports.outsideClick=n;
@@ -0,0 +1,2 @@
1
+ export { outsideClick } from './outsideClick';
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/dom/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAA"}
@@ -0,0 +1,28 @@
1
+ const n = {
2
+ listeners: /* @__PURE__ */ new WeakMap(),
3
+ // 存储 handler 和对应的 listener
4
+ /**
5
+ * 监听外部点击事件
6
+ * @param {OutsideClickListener} param0 - 包含 domRefs 和 handler 的对象
7
+ * @returns {() => void} 返回一个解绑函数,用于在不需要监听时解绑事件
8
+ */
9
+ listen({ domRefs: e, handler: t }) {
10
+ if (this.listeners.has(t))
11
+ return () => this.unlisten(t);
12
+ const s = (i) => {
13
+ e && !(e === i.target || e.contains(i.target)) && t();
14
+ };
15
+ return document.addEventListener("click", s), this.listeners.set(t, s), () => this.unlisten(t);
16
+ },
17
+ /**
18
+ * 解绑外部点击事件
19
+ * @param {() => void} handler - 需要解绑的处理函数
20
+ */
21
+ unlisten(e) {
22
+ const t = this.listeners.get(e);
23
+ t && (document.removeEventListener("click", t), this.listeners.delete(e));
24
+ }
25
+ };
26
+ export {
27
+ n as outsideClick
28
+ };
@@ -0,0 +1,27 @@
1
+ /**
2
+ * 外部点击监听器接口
3
+ */
4
+ interface OutsideClickListener {
5
+ domRefs: HTMLElement | null;
6
+ handler: () => void;
7
+ }
8
+ /**
9
+ * outsideClick 工具方法
10
+ * 用于监听外部点击事件,并在点击外部时执行指定的处理函数。
11
+ */
12
+ export declare const outsideClick: {
13
+ listeners: WeakMap<() => void, (event: Event) => void>;
14
+ /**
15
+ * 监听外部点击事件
16
+ * @param {OutsideClickListener} param0 - 包含 domRefs 和 handler 的对象
17
+ * @returns {() => void} 返回一个解绑函数,用于在不需要监听时解绑事件
18
+ */
19
+ listen({ domRefs, handler }: OutsideClickListener): () => void;
20
+ /**
21
+ * 解绑外部点击事件
22
+ * @param {() => void} handler - 需要解绑的处理函数
23
+ */
24
+ unlisten(handler: () => void): void;
25
+ };
26
+ export {};
27
+ //# sourceMappingURL=outsideClick.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"outsideClick.d.ts","sourceRoot":"","sources":["../../src/dom/outsideClick.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,UAAU,oBAAoB;IAC5B,OAAO,EAAE,WAAW,GAAG,IAAI,CAAA;IAC3B,OAAO,EAAE,MAAM,IAAI,CAAA;CACpB;AAED;;;GAGG;AACH,eAAO,MAAM,YAAY;6BACM,IAAI,UAAU,KAAK,KAAK,IAAI;IAEzD;;;;OAIG;iCAC0B,oBAAoB,GAAG,MAAM,IAAI;IAkB9D;;;OAGG;sBACe,MAAM,IAAI;CAO7B,CAAA"}
package/dist/dom.d.ts ADDED
@@ -0,0 +1,2 @@
1
+ export * from './dom/index'
2
+ export {}
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const g=require("./decrypt-B6fiICsn.js"),m=require("./data/index.cjs"),p=require("./dom/index.cjs"),i=require("./file/index.cjs"),y=require("./relative-5TnWB4bl.js"),u=require("./url/index.cjs"),h=require("./qr/index.cjs"),w=(e,t)=>{if(typeof window=="undefined")return t;try{const r=localStorage.getItem(e);if(!r)return t;const o=JSON.parse(r);return typeof o=="object"&&o!==null&&"expires"in o?o.expires&&Date.now()>o.expires?(localStorage.removeItem(e),t):o.value:o}catch(r){return t}},C=(e,t,r={})=>{if(typeof window=="undefined")return!1;try{const o=r.expires?{value:t,expires:r.expires}:t;return localStorage.setItem(e,JSON.stringify(o)),!0}catch(o){return!1}},v=e=>{if(typeof window=="undefined")return!1;try{return localStorage.removeItem(e),!0}catch(t){return!1}},k=()=>{if(typeof window=="undefined")return!1;try{return localStorage.clear(),!0}catch(e){return!1}},x=e=>{if(typeof window=="undefined")return!1;try{const t=localStorage.getItem(e);if(!t)return!1;const r=JSON.parse(t);return typeof r=="object"&&r!==null&&"expires"in r&&r.expires&&Date.now()>r.expires?(localStorage.removeItem(e),!1):!0}catch(t){return!1}},I=(e,t)=>{if(typeof window=="undefined")return t;try{const r=sessionStorage.getItem(e);return r?JSON.parse(r):t}catch(r){return t}},L=(e,t)=>{if(typeof window=="undefined")return!1;try{return sessionStorage.setItem(e,JSON.stringify(t)),!0}catch(r){return!1}},O=e=>{if(typeof window=="undefined")return!1;try{return sessionStorage.removeItem(e),!0}catch(t){return!1}},q=()=>{if(typeof window=="undefined")return!1;try{return sessionStorage.clear(),!0}catch(e){return!1}},$=e=>{if(typeof window=="undefined")return!1;try{return sessionStorage.getItem(e)!==null}catch(t){return!1}},f=(e,t)=>{if(typeof document=="undefined")return t;try{const r=document.cookie.match(new RegExp(`(?:^|; )${e}=([^;]*)`));return r?decodeURIComponent(r[1]):t}catch(r){return t}},l=(e,t,r={})=>{if(typeof document=="undefined")return!1;try{const{expires:o,path:s="/",domain:a,secure:d,sameSite:c,httpOnly:S}=r;let n=`${e}=${encodeURIComponent(t)}`;return o&&(n+=`; expires=${new Date(Date.now()+o*864e5).toUTCString()}`),s&&(n+=`; path=${s}`),a&&(n+=`; domain=${a}`),d&&(n+="; secure"),c&&(n+=`; samesite=${c}`),S&&(n+="; httponly"),document.cookie=n,!0}catch(o){return!1}},b=(e,t={})=>l(e,"",{...t,expires:-1}),F=()=>{if(typeof document=="undefined")return{};try{const e={};return document.cookie&&document.cookie.split(";").forEach(t=>{const[r,o]=t.trim().split("=");r&&o!==void 0&&(e[r]=o?decodeURIComponent(o):"")}),e}catch(e){return{}}},Q=e=>f(e)!==void 0;exports.decryptAES=g.decryptAES;exports.deepClone=m.deepClone;exports.outsideClick=p.outsideClick;exports.fetchFile=i.fetchFile;exports.formatFileSize=i.formatFileSize;exports.uploadFileByUrl=i.uploadFileByUrl;exports.relativeTime=y.relativeTime;exports.getQueryObject=u.getQueryObject;exports.getQueryParam=u.getQueryParam;exports.QRCodeScriptLoader=h.QRCodeScriptLoader;exports.clearLocalStorage=k;exports.clearSessionStorage=q;exports.getAllCookies=F;exports.getCookie=f;exports.getLocalStorage=w;exports.getSessionStorage=I;exports.hasCookie=Q;exports.hasLocalStorage=x;exports.hasSessionStorage=$;exports.removeCookie=b;exports.removeLocalStorage=v;exports.removeSessionStorage=O;exports.setCookie=l;exports.setLocalStorage=C;exports.setSessionStorage=L;
package/dist/fezbox.js ADDED
@@ -0,0 +1,141 @@
1
+ import { d as L } from "./decrypt-DwrxsWcv.mjs";
2
+ import { deepClone as N } from "./data/index.js";
3
+ import { outsideClick as U } from "./dom/index.js";
4
+ import { fetchFile as b, formatFileSize as j, uploadFileByUrl as E } from "./file/index.js";
5
+ import { r as Q } from "./relative-D0OTNLYG.mjs";
6
+ import { getQueryObject as T, getQueryParam as z } from "./url/index.js";
7
+ import { QRCodeScriptLoader as P } from "./qr/index.js";
8
+ const l = (e, t) => {
9
+ if (typeof window == "undefined") return t;
10
+ try {
11
+ const r = localStorage.getItem(e);
12
+ if (!r) return t;
13
+ const o = JSON.parse(r);
14
+ return typeof o == "object" && o !== null && "expires" in o ? o.expires && Date.now() > o.expires ? (localStorage.removeItem(e), t) : o.value : o;
15
+ } catch (r) {
16
+ return t;
17
+ }
18
+ }, p = (e, t, r = {}) => {
19
+ if (typeof window == "undefined") return !1;
20
+ try {
21
+ const o = r.expires ? { value: t, expires: r.expires } : t;
22
+ return localStorage.setItem(e, JSON.stringify(o)), !0;
23
+ } catch (o) {
24
+ return !1;
25
+ }
26
+ }, m = (e) => {
27
+ if (typeof window == "undefined") return !1;
28
+ try {
29
+ return localStorage.removeItem(e), !0;
30
+ } catch (t) {
31
+ return !1;
32
+ }
33
+ }, S = () => {
34
+ if (typeof window == "undefined") return !1;
35
+ try {
36
+ return localStorage.clear(), !0;
37
+ } catch (e) {
38
+ return !1;
39
+ }
40
+ }, g = (e) => {
41
+ if (typeof window == "undefined") return !1;
42
+ try {
43
+ const t = localStorage.getItem(e);
44
+ if (!t) return !1;
45
+ const r = JSON.parse(t);
46
+ return typeof r == "object" && r !== null && "expires" in r && r.expires && Date.now() > r.expires ? (localStorage.removeItem(e), !1) : !0;
47
+ } catch (t) {
48
+ return !1;
49
+ }
50
+ }, y = (e, t) => {
51
+ if (typeof window == "undefined") return t;
52
+ try {
53
+ const r = sessionStorage.getItem(e);
54
+ return r ? JSON.parse(r) : t;
55
+ } catch (r) {
56
+ return t;
57
+ }
58
+ }, w = (e, t) => {
59
+ if (typeof window == "undefined") return !1;
60
+ try {
61
+ return sessionStorage.setItem(e, JSON.stringify(t)), !0;
62
+ } catch (r) {
63
+ return !1;
64
+ }
65
+ }, h = (e) => {
66
+ if (typeof window == "undefined") return !1;
67
+ try {
68
+ return sessionStorage.removeItem(e), !0;
69
+ } catch (t) {
70
+ return !1;
71
+ }
72
+ }, x = () => {
73
+ if (typeof window == "undefined") return !1;
74
+ try {
75
+ return sessionStorage.clear(), !0;
76
+ } catch (e) {
77
+ return !1;
78
+ }
79
+ }, I = (e) => {
80
+ if (typeof window == "undefined") return !1;
81
+ try {
82
+ return sessionStorage.getItem(e) !== null;
83
+ } catch (t) {
84
+ return !1;
85
+ }
86
+ }, u = (e, t) => {
87
+ if (typeof document == "undefined") return t;
88
+ try {
89
+ const r = document.cookie.match(new RegExp(`(?:^|; )${e}=([^;]*)`));
90
+ return r ? decodeURIComponent(r[1]) : t;
91
+ } catch (r) {
92
+ return t;
93
+ }
94
+ }, d = (e, t, r = {}) => {
95
+ if (typeof document == "undefined") return !1;
96
+ try {
97
+ const { expires: o, path: i = "/", domain: s, secure: a, sameSite: c, httpOnly: f } = r;
98
+ let n = `${e}=${encodeURIComponent(t)}`;
99
+ return o && (n += `; expires=${new Date(Date.now() + o * 864e5).toUTCString()}`), i && (n += `; path=${i}`), s && (n += `; domain=${s}`), a && (n += "; secure"), c && (n += `; samesite=${c}`), f && (n += "; httponly"), document.cookie = n, !0;
100
+ } catch (o) {
101
+ return !1;
102
+ }
103
+ }, C = (e, t = {}) => d(e, "", { ...t, expires: -1 }), v = () => {
104
+ if (typeof document == "undefined") return {};
105
+ try {
106
+ const e = {};
107
+ return document.cookie && document.cookie.split(";").forEach((t) => {
108
+ const [r, o] = t.trim().split("=");
109
+ r && o !== void 0 && (e[r] = o ? decodeURIComponent(o) : "");
110
+ }), e;
111
+ } catch (e) {
112
+ return {};
113
+ }
114
+ }, k = (e) => u(e) !== void 0;
115
+ export {
116
+ P as QRCodeScriptLoader,
117
+ S as clearLocalStorage,
118
+ x as clearSessionStorage,
119
+ L as decryptAES,
120
+ N as deepClone,
121
+ b as fetchFile,
122
+ j as formatFileSize,
123
+ v as getAllCookies,
124
+ u as getCookie,
125
+ l as getLocalStorage,
126
+ T as getQueryObject,
127
+ z as getQueryParam,
128
+ y as getSessionStorage,
129
+ k as hasCookie,
130
+ g as hasLocalStorage,
131
+ I as hasSessionStorage,
132
+ U as outsideClick,
133
+ Q as relativeTime,
134
+ C as removeCookie,
135
+ m as removeLocalStorage,
136
+ h as removeSessionStorage,
137
+ d as setCookie,
138
+ p as setLocalStorage,
139
+ w as setSessionStorage,
140
+ E as uploadFileByUrl
141
+ };
@@ -0,0 +1,9 @@
1
+ /**
2
+ * 通过 URL 获取文件
3
+ * @param url - 文件 URL
4
+ * @param fileName - 文件名
5
+ * @param fetchFn - 自定义 fetch 函数,可选
6
+ * @returns Promise<File> 返回文件对象
7
+ */
8
+ export declare const fetchFile: (url: string, fileName: string, fetchFn?: typeof fetch) => Promise<File>;
9
+ //# sourceMappingURL=fetch.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fetch.d.ts","sourceRoot":"","sources":["../../src/file/fetch.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,eAAO,MAAM,SAAS,GACpB,KAAK,MAAM,EACX,UAAU,MAAM,EAChB,UAAS,OAAO,KAAwB,KACvC,OAAO,CAAC,IAAI,CAYd,CAAA"}
@@ -0,0 +1,7 @@
1
+ /**
2
+ * 格式化文件大小
3
+ * @param sizeInBytes - 文件大小(字节),可以是字符串或数字
4
+ * @returns 格式化后的文件大小字符串
5
+ */
6
+ export declare const formatFileSize: (sizeInBytes: string | number) => string;
7
+ //# sourceMappingURL=format.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"format.d.ts","sourceRoot":"","sources":["../../src/file/format.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,eAAO,MAAM,cAAc,GAAI,aAAa,MAAM,GAAG,MAAM,KAAG,MAe7D,CAAA"}