fezbox 0.0.1-security → 1.1.1
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.
- package/README.md +368 -3
- package/crypto.d.ts +1 -0
- package/crypto.js +1 -0
- package/data.d.ts +1 -0
- package/data.js +1 -0
- package/dist/crypto/decrypt.d.ts +8 -0
- package/dist/crypto/decrypt.d.ts.map +1 -0
- package/dist/crypto/index.cjs +1 -0
- package/dist/crypto/index.d.ts +2 -0
- package/dist/crypto/index.d.ts.map +1 -0
- package/dist/crypto/index.js +4 -0
- package/dist/crypto.d.ts +2 -0
- package/dist/data/clone.d.ts +7 -0
- package/dist/data/clone.d.ts.map +1 -0
- package/dist/data/index.cjs +1 -0
- package/dist/data/index.d.ts +2 -0
- package/dist/data/index.d.ts.map +1 -0
- package/dist/data/index.js +4 -0
- package/dist/data.d.ts +2 -0
- package/dist/decrypt-B6fiICsn.js +1 -0
- package/dist/decrypt-DwrxsWcv.mjs +11 -0
- package/dist/dom/index.cjs +1 -0
- package/dist/dom/index.d.ts +2 -0
- package/dist/dom/index.d.ts.map +1 -0
- package/dist/dom/index.js +28 -0
- package/dist/dom/outsideClick.d.ts +27 -0
- package/dist/dom/outsideClick.d.ts.map +1 -0
- package/dist/dom.d.ts +2 -0
- package/dist/fezbox.cjs +1 -0
- package/dist/fezbox.js +20 -0
- package/dist/file/fetch.d.ts +9 -0
- package/dist/file/fetch.d.ts.map +1 -0
- package/dist/file/format.d.ts +7 -0
- package/dist/file/format.d.ts.map +1 -0
- package/dist/file/index.cjs +1 -0
- package/dist/file/index.d.ts +4 -0
- package/dist/file/index.d.ts.map +1 -0
- package/dist/file/index.js +25 -0
- package/dist/file/upload.d.ts +12 -0
- package/dist/file/upload.d.ts.map +1 -0
- package/dist/file.d.ts +2 -0
- package/dist/index.d.ts +16 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/qr/index.cjs +1 -0
- package/dist/qr/index.d.ts +57 -0
- package/dist/qr/index.d.ts.map +1 -0
- package/dist/qr/index.js +178 -0
- package/dist/qr.d.ts +2 -0
- package/dist/relative-5TnWB4bl.js +1 -0
- package/dist/relative-D0OTNLYG.mjs +8 -0
- package/dist/time/index.cjs +1 -0
- package/dist/time/index.d.ts +2 -0
- package/dist/time/index.d.ts.map +1 -0
- package/dist/time/index.js +4 -0
- package/dist/time/relative.d.ts +8 -0
- package/dist/time/relative.d.ts.map +1 -0
- package/dist/time.d.ts +2 -0
- package/dist/url/index.cjs +1 -0
- package/dist/url/index.d.ts +2 -0
- package/dist/url/index.d.ts.map +1 -0
- package/dist/url/index.js +13 -0
- package/dist/url/query.d.ts +8 -0
- package/dist/url/query.d.ts.map +1 -0
- package/dist/url.d.ts +2 -0
- package/dom.d.ts +1 -0
- package/dom.js +1 -0
- package/eslint.config.js +46 -0
- package/file.d.ts +1 -0
- package/file.js +1 -0
- package/package.json +105 -3
- package/qr.d.ts +1 -0
- package/qr.js +1 -0
- package/time.d.ts +1 -0
- package/time.js +1 -0
- package/url.d.ts +1 -0
- package/url.js +1 -0
package/dist/index.d.ts
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
/**
|
2
|
+
* FezBox - 常用工具函数库
|
3
|
+
*
|
4
|
+
* 一个包含常用工具函数的 JavaScript/TypeScript 库
|
5
|
+
* 按功能模块分类,便于按需引入
|
6
|
+
*/
|
7
|
+
export { decryptAES } from './crypto';
|
8
|
+
export { deepClone } from './data';
|
9
|
+
export { outsideClick } from './dom';
|
10
|
+
export { formatFileSize, fetchFile, uploadFileByUrl } from './file';
|
11
|
+
export { relativeTime } from './time';
|
12
|
+
export { getQueryParam } from './url';
|
13
|
+
export { QRCodeScriptLoader } from './qr';
|
14
|
+
export type { QRCodeOptions, QRCodeLoaderOptions, QRCodeGenerateResult, QRCodeCapacityInfo, LogLevel } from './qr';
|
15
|
+
export declare const version = "1.0.0";
|
16
|
+
//# sourceMappingURL=index.d.ts.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAO,EAAE,UAAU,EAAE,MAAM,UAAU,CAAA;AAGrC,OAAO,EAAE,SAAS,EAAE,MAAM,QAAQ,CAAA;AAGlC,OAAO,EAAE,YAAY,EAAE,MAAM,OAAO,CAAA;AAGpC,OAAO,EAAE,cAAc,EAAE,SAAS,EAAE,eAAe,EAAE,MAAM,QAAQ,CAAA;AAGnE,OAAO,EAAE,YAAY,EAAE,MAAM,QAAQ,CAAA;AAGrC,OAAO,EAAE,aAAa,EAAE,MAAM,OAAO,CAAA;AAGrC,OAAO,EAAE,kBAAkB,EAAE,MAAM,MAAM,CAAA;AACzC,YAAY,EACV,aAAa,EACb,mBAAmB,EACnB,oBAAoB,EACpB,kBAAkB,EAClB,QAAQ,EACT,MAAM,MAAM,CAAA;AAGb,eAAO,MAAM,OAAO,UAAU,CAAA"}
|
@@ -0,0 +1 @@
|
|
1
|
+
"use strict";var h=Object.defineProperty;var g=(e,t,o)=>t in e?h(e,t,{enumerable:!0,configurable:!0,writable:!0,value:o}):e[t]=o;var c=(e,t,o)=>g(e,typeof t!="symbol"?t+"":t,o);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});class QRCodeScriptLoader{constructor(e={}){c(this,"options");c(this,"capacities");c(this,"correctLevels");c(this,"onLog",null);c(this,"onProgress",null);this.options={maxRetries:3,compressionLevel:9,autoCompress:!0,compress:!1,debug:!1,sandbox:!0,qrCodeOptions:{width:256,height:256,colorDark:"#000000",colorLight:"#ffffff"},...e},this.capacities={L:2953,M:2331,Q:1663,H:1273},this.correctLevels={L:0,M:1,Q:2,H:3}}async generateQRCodeData(e,t={}){const o={...this.options,...t};try{let s=e,n=!1;const i=this.getByteLength(e);if(this.log(`原始代码: ${e.length} 字符, ${i} 字节`,"info"),"compress"in t&&t.compress){s=await this.compressCode(e),n=!0;const l=this.getByteLength(s);this.log(`压缩后: ${s.length} 字符, ${l} 字节`,"info")}const r=this.getByteLength(s),a=this.selectCorrectLevel(r);if(r>this.capacities.L){if(!n&&o.autoCompress)return this.log("数据太长,自动尝试压缩...","info"),this.generateQRCodeData(e,{...o,compress:!0});throw new Error(`数据太长: ${r} 字节超过最大容量 ${this.capacities.L} 字节`)}return this.log(`使用纠错级别: ${a.name} (最大容量: ${a.capacity} 字节)`,"info"),{success:!0,data:s,originalLength:e.length,encodedLength:s.length,originalBytes:i,encodedBytes:r,compressed:n,correctLevel:a,qrCodeConfig:{text:s,...o.qrCodeOptions,correctLevel:this.correctLevels[a.name]}}}catch(s){const n=s instanceof Error?s.message:String(s);return this.log(`生成失败: ${n}`,"error"),{success:!1,error:n}}}async parseQRCodeFromImageData(e){try{if(typeof globalThis.jsQR=="undefined")throw new Error("jsQR 库未加载");const t=globalThis.jsQR(e.data,e.width,e.height);if(!t)throw new Error("无法识别二维码");let o=t.data;return o.startsWith("COMPRESSED:")&&(this.log("检测到压缩代码,正在解压...","info"),o=await this.decompressCode(o.substring(11)),this.log("解压成功!","info")),o}catch(t){const o=t instanceof Error?t.message:String(t);throw this.log(`解析失败: ${o}`,"error"),t}}executeCode(code,context={},options={}){const opts={...this.options,...options};try{if(this.log("开始执行代码...","info"),opts.sandbox){const e=this.executeInSandbox(code,context);return this.log("代码执行完成!","info"),e}else{const result=eval(code);return this.log("代码执行完成!","info"),result}}catch(e){const t=e instanceof Error?e.message:String(e);throw this.log(`执行错误: ${t}`,"error"),e}}async compressCode(e){if(typeof globalThis.pako=="undefined")throw new Error("pako 压缩库未加载");const o=globalThis.pako.deflate(new TextEncoder().encode(e),{level:this.options.compressionLevel});return"COMPRESSED:"+btoa(String.fromCharCode.apply(null,Array.from(o)))}async decompressCode(e){if(typeof globalThis.pako=="undefined")throw new Error("pako 压缩库未加载");const t=globalThis.pako,o=atob(e),s=new Uint8Array(o.length);for(let i=0;i<o.length;i++)s[i]=o.charCodeAt(i);const n=t.inflate(s);return new TextDecoder().decode(n)}selectCorrectLevel(e){return e<=this.capacities.H?{name:"H",capacity:this.capacities.H}:e<=this.capacities.Q?{name:"Q",capacity:this.capacities.Q}:e<=this.capacities.M?{name:"M",capacity:this.capacities.M}:{name:"L",capacity:this.capacities.L}}executeInSandbox(e,t={}){const o=this,s={console:{log:(...r)=>{o.log("[Console] "+r.join(" "),"normal")},error:(...r)=>{o.log("[Console] "+r.join(" "),"error")},warn:(...r)=>{o.log("[Console] "+r.join(" "),"warning")},info:(...r)=>{o.log("[Console] "+r.join(" "),"info")}},Math,Date,JSON,Array,Object,String,Number,Boolean,...t},n=Object.keys(s),i=Object.values(s);try{return new Function(...n,e).apply(null,i)}catch(r){const a=r instanceof Error?r.message:String(r);throw o.log("执行出错: "+a,"error"),r}}getByteLength(e){return new TextEncoder().encode(e).length}log(e,t="normal"){this.onLog&&this.onLog(e,t)}getCapacityInfo(){return{capacities:this.capacities,recommendations:{small:"< 500 字符:使用 H 级纠错",medium:"500-1500 字符:使用 M 或 Q 级纠错",large:"1500-2900 字符:使用 L 级纠错",veryLarge:"> 2900 字符:需要压缩或分片"}}}}exports.QRCodeScriptLoader=QRCodeScriptLoader;
|
@@ -0,0 +1,57 @@
|
|
1
|
+
export interface QRCodeOptions {
|
2
|
+
width?: number;
|
3
|
+
height?: number;
|
4
|
+
colorDark?: string;
|
5
|
+
colorLight?: string;
|
6
|
+
}
|
7
|
+
export interface QRCodeLoaderOptions {
|
8
|
+
maxRetries?: number;
|
9
|
+
compressionLevel?: number;
|
10
|
+
autoCompress?: boolean;
|
11
|
+
compress?: boolean;
|
12
|
+
debug?: boolean;
|
13
|
+
sandbox?: boolean;
|
14
|
+
qrCodeOptions?: QRCodeOptions;
|
15
|
+
}
|
16
|
+
export interface QRCodeGenerateResult {
|
17
|
+
success: boolean;
|
18
|
+
data?: string;
|
19
|
+
originalLength?: number;
|
20
|
+
encodedLength?: number;
|
21
|
+
originalBytes?: number;
|
22
|
+
encodedBytes?: number;
|
23
|
+
compressed?: boolean;
|
24
|
+
correctLevel?: {
|
25
|
+
name: string;
|
26
|
+
capacity: number;
|
27
|
+
};
|
28
|
+
qrCodeConfig?: {
|
29
|
+
text: string;
|
30
|
+
correctLevel: number;
|
31
|
+
} & QRCodeOptions;
|
32
|
+
error?: string;
|
33
|
+
}
|
34
|
+
export interface QRCodeCapacityInfo {
|
35
|
+
capacities: Record<string, number>;
|
36
|
+
recommendations: Record<string, string>;
|
37
|
+
}
|
38
|
+
export type LogLevel = 'normal' | 'info' | 'warning' | 'error';
|
39
|
+
export declare class QRCodeScriptLoader {
|
40
|
+
private options;
|
41
|
+
private capacities;
|
42
|
+
private correctLevels;
|
43
|
+
onLog: ((message: string, level: LogLevel) => void) | null;
|
44
|
+
onProgress: ((progress: number) => void) | null;
|
45
|
+
constructor(options?: QRCodeLoaderOptions);
|
46
|
+
generateQRCodeData(code: string, options?: Partial<QRCodeLoaderOptions>): Promise<QRCodeGenerateResult>;
|
47
|
+
parseQRCodeFromImageData(imageData: ImageData): Promise<string>;
|
48
|
+
executeCode(code: string, context?: Record<string, any>, options?: Partial<QRCodeLoaderOptions>): any;
|
49
|
+
compressCode(code: string): Promise<string>;
|
50
|
+
decompressCode(compressedData: string): Promise<string>;
|
51
|
+
private selectCorrectLevel;
|
52
|
+
private executeInSandbox;
|
53
|
+
private getByteLength;
|
54
|
+
private log;
|
55
|
+
getCapacityInfo(): QRCodeCapacityInfo;
|
56
|
+
}
|
57
|
+
//# sourceMappingURL=index.d.ts.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/qr/index.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,aAAa;IAC5B,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAED,MAAM,WAAW,mBAAmB;IAClC,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,aAAa,CAAC,EAAE,aAAa,CAAC;CAC/B;AAED,MAAM,WAAW,oBAAoB;IACnC,OAAO,EAAE,OAAO,CAAC;IACjB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,YAAY,CAAC,EAAE;QACb,IAAI,EAAE,MAAM,CAAC;QACb,QAAQ,EAAE,MAAM,CAAC;KAClB,CAAC;IACF,YAAY,CAAC,EAAE;QACb,IAAI,EAAE,MAAM,CAAC;QACb,YAAY,EAAE,MAAM,CAAC;KACtB,GAAG,aAAa,CAAC;IAClB,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,WAAW,kBAAkB;IACjC,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACnC,eAAe,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CACzC;AAED,MAAM,MAAM,QAAQ,GAAG,QAAQ,GAAG,MAAM,GAAG,SAAS,GAAG,OAAO,CAAC;AAE/D,qBAAa,kBAAkB;IAC7B,OAAO,CAAC,OAAO,CAAgC;IAC/C,OAAO,CAAC,UAAU,CAAyB;IAC3C,OAAO,CAAC,aAAa,CAAyB;IAEvC,KAAK,EAAE,CAAC,CAAC,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,QAAQ,KAAK,IAAI,CAAC,GAAG,IAAI,CAAQ;IAClE,UAAU,EAAE,CAAC,CAAC,QAAQ,EAAE,MAAM,KAAK,IAAI,CAAC,GAAG,IAAI,CAAQ;gBAElD,OAAO,GAAE,mBAAwB;IAgCvC,kBAAkB,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,GAAE,OAAO,CAAC,mBAAmB,CAAM,GAAG,OAAO,CAAC,oBAAoB,CAAC;IAwD3G,wBAAwB,CAAC,SAAS,EAAE,SAAS,GAAG,OAAO,CAAC,MAAM,CAAC;IA4BrE,WAAW,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,GAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAM,EAAE,OAAO,GAAE,OAAO,CAAC,mBAAmB,CAAM,GAAG,GAAG;IAsBvG,YAAY,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IAc3C,cAAc,CAAC,cAAc,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IAgB7D,OAAO,CAAC,kBAAkB;IAY1B,OAAO,CAAC,gBAAgB;IA0CxB,OAAO,CAAC,aAAa;IAIrB,OAAO,CAAC,GAAG;IAMX,eAAe,IAAI,kBAAkB;CAWtC"}
|
package/dist/qr/index.js
ADDED
@@ -0,0 +1,178 @@
|
|
1
|
+
var h = Object.defineProperty;
|
2
|
+
var g = (e, t, o) => t in e ? h(e, t, { enumerable: !0, configurable: !0, writable: !0, value: o }) : e[t] = o;
|
3
|
+
var c = (e, t, o) => g(e, typeof t != "symbol" ? t + "" : t, o);
|
4
|
+
class QRCodeScriptLoader {
|
5
|
+
constructor(e = {}) {
|
6
|
+
c(this, "options");
|
7
|
+
c(this, "capacities");
|
8
|
+
c(this, "correctLevels");
|
9
|
+
c(this, "onLog", null);
|
10
|
+
c(this, "onProgress", null);
|
11
|
+
this.options = {
|
12
|
+
maxRetries: 3,
|
13
|
+
compressionLevel: 9,
|
14
|
+
autoCompress: !0,
|
15
|
+
compress: !1,
|
16
|
+
debug: !1,
|
17
|
+
sandbox: !0,
|
18
|
+
qrCodeOptions: {
|
19
|
+
width: 256,
|
20
|
+
height: 256,
|
21
|
+
colorDark: "#000000",
|
22
|
+
colorLight: "#ffffff"
|
23
|
+
},
|
24
|
+
...e
|
25
|
+
}, this.capacities = {
|
26
|
+
L: 2953,
|
27
|
+
M: 2331,
|
28
|
+
Q: 1663,
|
29
|
+
H: 1273
|
30
|
+
}, this.correctLevels = {
|
31
|
+
L: 0,
|
32
|
+
M: 1,
|
33
|
+
Q: 2,
|
34
|
+
H: 3
|
35
|
+
};
|
36
|
+
}
|
37
|
+
async generateQRCodeData(e, t = {}) {
|
38
|
+
const o = { ...this.options, ...t };
|
39
|
+
try {
|
40
|
+
let s = e, n = !1;
|
41
|
+
const i = this.getByteLength(e);
|
42
|
+
if (this.log(`原始代码: ${e.length} 字符, ${i} 字节`, "info"), "compress" in t && t.compress) {
|
43
|
+
s = await this.compressCode(e), n = !0;
|
44
|
+
const l = this.getByteLength(s);
|
45
|
+
this.log(`压缩后: ${s.length} 字符, ${l} 字节`, "info");
|
46
|
+
}
|
47
|
+
const r = this.getByteLength(s), a = this.selectCorrectLevel(r);
|
48
|
+
if (r > this.capacities.L) {
|
49
|
+
if (!n && o.autoCompress)
|
50
|
+
return this.log("数据太长,自动尝试压缩...", "info"), this.generateQRCodeData(e, { ...o, compress: !0 });
|
51
|
+
throw new Error(`数据太长: ${r} 字节超过最大容量 ${this.capacities.L} 字节`);
|
52
|
+
}
|
53
|
+
return this.log(`使用纠错级别: ${a.name} (最大容量: ${a.capacity} 字节)`, "info"), {
|
54
|
+
success: !0,
|
55
|
+
data: s,
|
56
|
+
originalLength: e.length,
|
57
|
+
encodedLength: s.length,
|
58
|
+
originalBytes: i,
|
59
|
+
encodedBytes: r,
|
60
|
+
compressed: n,
|
61
|
+
correctLevel: a,
|
62
|
+
qrCodeConfig: {
|
63
|
+
text: s,
|
64
|
+
...o.qrCodeOptions,
|
65
|
+
correctLevel: this.correctLevels[a.name]
|
66
|
+
}
|
67
|
+
};
|
68
|
+
} catch (s) {
|
69
|
+
const n = s instanceof Error ? s.message : String(s);
|
70
|
+
return this.log(`生成失败: ${n}`, "error"), {
|
71
|
+
success: !1,
|
72
|
+
error: n
|
73
|
+
};
|
74
|
+
}
|
75
|
+
}
|
76
|
+
async parseQRCodeFromImageData(e) {
|
77
|
+
try {
|
78
|
+
if (typeof globalThis.jsQR == "undefined")
|
79
|
+
throw new Error("jsQR 库未加载");
|
80
|
+
const t = globalThis.jsQR(e.data, e.width, e.height);
|
81
|
+
if (!t)
|
82
|
+
throw new Error("无法识别二维码");
|
83
|
+
let o = t.data;
|
84
|
+
return o.startsWith("COMPRESSED:") && (this.log("检测到压缩代码,正在解压...", "info"), o = await this.decompressCode(o.substring(11)), this.log("解压成功!", "info")), o;
|
85
|
+
} catch (t) {
|
86
|
+
const o = t instanceof Error ? t.message : String(t);
|
87
|
+
throw this.log(`解析失败: ${o}`, "error"), t;
|
88
|
+
}
|
89
|
+
}
|
90
|
+
executeCode(code, context = {}, options = {}) {
|
91
|
+
const opts = { ...this.options, ...options };
|
92
|
+
try {
|
93
|
+
if (this.log("开始执行代码...", "info"), opts.sandbox) {
|
94
|
+
const e = this.executeInSandbox(code, context);
|
95
|
+
return this.log("代码执行完成!", "info"), e;
|
96
|
+
} else {
|
97
|
+
const result = eval(code);
|
98
|
+
return this.log("代码执行完成!", "info"), result;
|
99
|
+
}
|
100
|
+
} catch (e) {
|
101
|
+
const t = e instanceof Error ? e.message : String(e);
|
102
|
+
throw this.log(`执行错误: ${t}`, "error"), e;
|
103
|
+
}
|
104
|
+
}
|
105
|
+
async compressCode(e) {
|
106
|
+
if (typeof globalThis.pako == "undefined")
|
107
|
+
throw new Error("pako 压缩库未加载");
|
108
|
+
const o = globalThis.pako.deflate(new TextEncoder().encode(e), {
|
109
|
+
level: this.options.compressionLevel
|
110
|
+
});
|
111
|
+
return "COMPRESSED:" + btoa(String.fromCharCode.apply(null, Array.from(o)));
|
112
|
+
}
|
113
|
+
async decompressCode(e) {
|
114
|
+
if (typeof globalThis.pako == "undefined")
|
115
|
+
throw new Error("pako 压缩库未加载");
|
116
|
+
const t = globalThis.pako, o = atob(e), s = new Uint8Array(o.length);
|
117
|
+
for (let i = 0; i < o.length; i++)
|
118
|
+
s[i] = o.charCodeAt(i);
|
119
|
+
const n = t.inflate(s);
|
120
|
+
return new TextDecoder().decode(n);
|
121
|
+
}
|
122
|
+
selectCorrectLevel(e) {
|
123
|
+
return e <= this.capacities.H ? { name: "H", capacity: this.capacities.H } : e <= this.capacities.Q ? { name: "Q", capacity: this.capacities.Q } : e <= this.capacities.M ? { name: "M", capacity: this.capacities.M } : { name: "L", capacity: this.capacities.L };
|
124
|
+
}
|
125
|
+
executeInSandbox(e, t = {}) {
|
126
|
+
const o = this, s = {
|
127
|
+
console: {
|
128
|
+
log: (...r) => {
|
129
|
+
o.log("[Console] " + r.join(" "), "normal");
|
130
|
+
},
|
131
|
+
error: (...r) => {
|
132
|
+
o.log("[Console] " + r.join(" "), "error");
|
133
|
+
},
|
134
|
+
warn: (...r) => {
|
135
|
+
o.log("[Console] " + r.join(" "), "warning");
|
136
|
+
},
|
137
|
+
info: (...r) => {
|
138
|
+
o.log("[Console] " + r.join(" "), "info");
|
139
|
+
}
|
140
|
+
},
|
141
|
+
Math,
|
142
|
+
Date,
|
143
|
+
JSON,
|
144
|
+
Array,
|
145
|
+
Object,
|
146
|
+
String,
|
147
|
+
Number,
|
148
|
+
Boolean,
|
149
|
+
...t
|
150
|
+
}, n = Object.keys(s), i = Object.values(s);
|
151
|
+
try {
|
152
|
+
return new Function(...n, e).apply(null, i);
|
153
|
+
} catch (r) {
|
154
|
+
const a = r instanceof Error ? r.message : String(r);
|
155
|
+
throw o.log("执行出错: " + a, "error"), r;
|
156
|
+
}
|
157
|
+
}
|
158
|
+
getByteLength(e) {
|
159
|
+
return new TextEncoder().encode(e).length;
|
160
|
+
}
|
161
|
+
log(e, t = "normal") {
|
162
|
+
this.onLog && this.onLog(e, t);
|
163
|
+
}
|
164
|
+
getCapacityInfo() {
|
165
|
+
return {
|
166
|
+
capacities: this.capacities,
|
167
|
+
recommendations: {
|
168
|
+
small: "< 500 字符:使用 H 级纠错",
|
169
|
+
medium: "500-1500 字符:使用 M 或 Q 级纠错",
|
170
|
+
large: "1500-2900 字符:使用 L 级纠错",
|
171
|
+
veryLarge: "> 2900 字符:需要压缩或分片"
|
172
|
+
}
|
173
|
+
};
|
174
|
+
}
|
175
|
+
}
|
176
|
+
export {
|
177
|
+
QRCodeScriptLoader
|
178
|
+
};
|
package/dist/qr.d.ts
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
"use strict";const n=require("dayjs");function u(r){const e=n(),i=n(r),s=e.diff(i,"minute"),f=e.diff(i,"hour"),t=e.diff(i,"day");return s<60?"刚刚":f<24?`${f}小时前`:t<30?`${t}天前`:t<60?"1月前":"更早"}exports.relativeTime=u;
|
@@ -0,0 +1 @@
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("../relative-5TnWB4bl.js");exports.relativeTime=e.relativeTime;
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/time/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,YAAY,CAAA"}
|
@@ -0,0 +1,8 @@
|
|
1
|
+
import { default as dayjs } from 'dayjs';
|
2
|
+
/**
|
3
|
+
* 相对时间格式化
|
4
|
+
* @param date - 日期,可以是字符串、数字、Date 对象或 dayjs 对象
|
5
|
+
* @returns 相对时间字符串
|
6
|
+
*/
|
7
|
+
export declare function relativeTime(date: string | number | Date | dayjs.Dayjs | null | undefined): string;
|
8
|
+
//# sourceMappingURL=relative.d.ts.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"relative.d.ts","sourceRoot":"","sources":["../../src/time/relative.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAA;AAEzB;;;;GAIG;AACH,wBAAgB,YAAY,CAC1B,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,GAAG,KAAK,CAAC,KAAK,GAAG,IAAI,GAAG,SAAS,GAC5D,MAAM,CAkBR"}
|
package/dist/time.d.ts
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const d=(n,i)=>{const t=(i||(typeof window!="undefined"?window.location.href:"")).split("?")[1];if(!t)return;const r=t.split("&");for(let e=0;e<r.length;e++){const o=r[e].split("=");if(decodeURIComponent(o[0])===n)return decodeURIComponent(o[1]||"")}};exports.getQueryParam=d;
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/url/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,SAAS,CAAA"}
|
@@ -0,0 +1,13 @@
|
|
1
|
+
const s = (n, i) => {
|
2
|
+
const e = (i || (typeof window != "undefined" ? window.location.href : "")).split("?")[1];
|
3
|
+
if (!e) return;
|
4
|
+
const r = e.split("&");
|
5
|
+
for (let t = 0; t < r.length; t++) {
|
6
|
+
const o = r[t].split("=");
|
7
|
+
if (decodeURIComponent(o[0]) === n)
|
8
|
+
return decodeURIComponent(o[1] || "");
|
9
|
+
}
|
10
|
+
};
|
11
|
+
export {
|
12
|
+
s as getQueryParam
|
13
|
+
};
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"query.d.ts","sourceRoot":"","sources":["../../src/url/query.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,eAAO,MAAM,aAAa,GAAI,MAAM,MAAM,EAAE,MAAM,MAAM,KAAG,MAAM,GAAG,SAsBnE,CAAA"}
|
package/dist/url.d.ts
ADDED
package/dom.d.ts
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
export * from './dist/dom/index';
|
package/dom.js
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
module.exports = require('./dist/dom/index.cjs');
|
package/eslint.config.js
ADDED
@@ -0,0 +1,46 @@
|
|
1
|
+
import js from '@eslint/js'
|
2
|
+
import tseslint from '@typescript-eslint/eslint-plugin'
|
3
|
+
import tsparser from '@typescript-eslint/parser'
|
4
|
+
import prettierConfig from 'eslint-config-prettier'
|
5
|
+
import prettierPlugin from 'eslint-plugin-prettier'
|
6
|
+
|
7
|
+
export default [
|
8
|
+
js.configs.recommended,
|
9
|
+
{
|
10
|
+
files: ['**/*.{ts,tsx}'],
|
11
|
+
languageOptions: {
|
12
|
+
parser: tsparser,
|
13
|
+
parserOptions: {
|
14
|
+
ecmaVersion: 'latest',
|
15
|
+
sourceType: 'module'
|
16
|
+
},
|
17
|
+
globals: {
|
18
|
+
...globalThis,
|
19
|
+
document: 'readonly',
|
20
|
+
window: 'readonly',
|
21
|
+
console: 'readonly',
|
22
|
+
process: 'readonly',
|
23
|
+
Buffer: 'readonly',
|
24
|
+
__dirname: 'readonly',
|
25
|
+
__filename: 'readonly',
|
26
|
+
global: 'readonly'
|
27
|
+
}
|
28
|
+
},
|
29
|
+
plugins: {
|
30
|
+
'@typescript-eslint': tseslint,
|
31
|
+
prettier: prettierPlugin
|
32
|
+
},
|
33
|
+
rules: {
|
34
|
+
...tseslint.configs.recommended.rules,
|
35
|
+
...prettierConfig.rules,
|
36
|
+
'prettier/prettier': 'error',
|
37
|
+
'@typescript-eslint/no-unused-vars': 'error',
|
38
|
+
'@typescript-eslint/no-explicit-any': 'warn',
|
39
|
+
'@typescript-eslint/explicit-function-return-type': 'off',
|
40
|
+
'@typescript-eslint/explicit-module-boundary-types': 'off'
|
41
|
+
}
|
42
|
+
},
|
43
|
+
{
|
44
|
+
ignores: ['dist/', 'node_modules/', '*.config.js', '*.config.ts', 'coverage/']
|
45
|
+
}
|
46
|
+
]
|
package/file.d.ts
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
export * from './dist/file/index';
|
package/file.js
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
module.exports = require('./dist/file/index.cjs');
|
package/package.json
CHANGED
@@ -1,6 +1,108 @@
|
|
1
1
|
{
|
2
2
|
"name": "fezbox",
|
3
|
-
"version": "
|
4
|
-
"description": "
|
5
|
-
"
|
3
|
+
"version": "1.1.1",
|
4
|
+
"description": "A comprehensive JavaScript/TypeScript utility library with modular design, complete test coverage, and optimized performance",
|
5
|
+
"main": "./dist/fezbox.cjs",
|
6
|
+
"module": "./dist/fezbox.js",
|
7
|
+
"types": "./dist/index.d.ts",
|
8
|
+
"exports": {
|
9
|
+
".": {
|
10
|
+
"types": "./dist/index.d.ts",
|
11
|
+
"import": "./dist/fezbox.js",
|
12
|
+
"require": "./dist/fezbox.cjs"
|
13
|
+
},
|
14
|
+
"./crypto": {
|
15
|
+
"types": "./dist/crypto/index.d.ts",
|
16
|
+
"import": "./dist/crypto/index.js",
|
17
|
+
"require": "./dist/crypto/index.cjs"
|
18
|
+
},
|
19
|
+
"./data": {
|
20
|
+
"types": "./dist/data/index.d.ts",
|
21
|
+
"import": "./dist/data/index.js",
|
22
|
+
"require": "./dist/data/index.cjs"
|
23
|
+
},
|
24
|
+
"./dom": {
|
25
|
+
"types": "./dist/dom/index.d.ts",
|
26
|
+
"import": "./dist/dom/index.js",
|
27
|
+
"require": "./dist/dom/index.cjs"
|
28
|
+
},
|
29
|
+
"./file": {
|
30
|
+
"types": "./dist/file/index.d.ts",
|
31
|
+
"import": "./dist/file/index.js",
|
32
|
+
"require": "./dist/file/index.cjs"
|
33
|
+
},
|
34
|
+
"./time": {
|
35
|
+
"types": "./dist/time/index.d.ts",
|
36
|
+
"import": "./dist/time/index.js",
|
37
|
+
"require": "./dist/time/index.cjs"
|
38
|
+
},
|
39
|
+
"./url": {
|
40
|
+
"types": "./dist/url/index.d.ts",
|
41
|
+
"import": "./dist/url/index.js",
|
42
|
+
"require": "./dist/url/index.cjs"
|
43
|
+
},
|
44
|
+
"./qr": {
|
45
|
+
"types": "./dist/qr/index.d.ts",
|
46
|
+
"import": "./dist/qr/index.js",
|
47
|
+
"require": "./dist/qr/index.cjs"
|
48
|
+
},
|
49
|
+
"./package.json": "./package.json"
|
50
|
+
},
|
51
|
+
"typesVersions": {
|
52
|
+
"*": {
|
53
|
+
"*": [
|
54
|
+
"dist/*",
|
55
|
+
"dist/*/index.d.ts"
|
56
|
+
]
|
57
|
+
}
|
58
|
+
},
|
59
|
+
"files": [
|
60
|
+
"dist",
|
61
|
+
"README.md",
|
62
|
+
"*.js",
|
63
|
+
"*.d.ts"
|
64
|
+
],
|
65
|
+
"scripts": {
|
66
|
+
"build": "vite build",
|
67
|
+
"dev": "vitest --watch",
|
68
|
+
"docs": "vitepress dev docs",
|
69
|
+
"test": "vitest",
|
70
|
+
"test:coverage": "vitest --coverage",
|
71
|
+
"lint": "eslint src --ext .ts,.tsx,.js,.jsx",
|
72
|
+
"lint:fix": "eslint src --ext .ts,.tsx,.js,.jsx --fix",
|
73
|
+
"format": "prettier --write \"src/**/*.{ts,tsx,.js,jsx,json,md}\"",
|
74
|
+
"typecheck": "tsc --noEmit",
|
75
|
+
"prepublishOnly": "pnpm run build"
|
76
|
+
},
|
77
|
+
"keywords": [
|
78
|
+
"utils",
|
79
|
+
"typescript"
|
80
|
+
],
|
81
|
+
"author": "jane",
|
82
|
+
"license": "MIT",
|
83
|
+
"devDependencies": {
|
84
|
+
"@types/crypto-js": "^4.2.2",
|
85
|
+
"@typescript-eslint/eslint-plugin": "^8.40.0",
|
86
|
+
"@typescript-eslint/parser": "^8.40.0",
|
87
|
+
"@vitest/coverage-v8": "^3.2.4",
|
88
|
+
"eslint": "^9.33.0",
|
89
|
+
"eslint-config-prettier": "^10.1.8",
|
90
|
+
"eslint-plugin-prettier": "^5.0.0",
|
91
|
+
"jsdom": "^26.1.0",
|
92
|
+
"prettier": "^3.0.0",
|
93
|
+
"typescript": "^5.0.0",
|
94
|
+
"vite": "^7.1.2",
|
95
|
+
"vite-plugin-dts": "^4.5.4",
|
96
|
+
"vitepress": "^1.6.4",
|
97
|
+
"vitest": "^3.2.4"
|
98
|
+
},
|
99
|
+
"dependencies": {
|
100
|
+
"crypto-js": "^4.2.0",
|
101
|
+
"dayjs": "^1.11.0"
|
102
|
+
},
|
103
|
+
"packageManager": "pnpm@10.0.0",
|
104
|
+
"engines": {
|
105
|
+
"node": ">=18.0.0",
|
106
|
+
"pnpm": ">=9.0.0"
|
107
|
+
}
|
6
108
|
}
|
package/qr.d.ts
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
export * from './dist/qr/index';
|
package/qr.js
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
module.exports = require('./dist/qr/index.cjs');
|
package/time.d.ts
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
export * from './dist/time/index';
|
package/time.js
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
module.exports = require('./dist/time/index.cjs');
|
package/url.d.ts
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
export * from './dist/url/index';
|
package/url.js
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
module.exports = require('./dist/url/index.cjs');
|