ddan-js 2.10.4 → 2.10.6

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.
@@ -0,0 +1,37 @@
1
+ declare const dNode: {
2
+ Ecdh: typeof import("../modules/node/ecdh").default;
3
+ EcdhWeb: typeof import("../modules/node/ecdh-web").default;
4
+ Socks5: typeof import("../modules/node/socks5").Socks5;
5
+ rsa: {
6
+ generateKeys: () => Promise<{
7
+ publicKey: string;
8
+ publicKeyPem: string;
9
+ privateKey: string;
10
+ privateKeyPem: string;
11
+ }>;
12
+ encrypt: (data: string, publicKey: string) => Promise<string>;
13
+ decrypt: (encryptedBase64: string, privateKey: string) => Promise<string>;
14
+ encode: (data: string) => Promise<string>;
15
+ decode: (encryptedBase64: string) => Promise<string>;
16
+ };
17
+ getSystemProxy: () => Promise<{
18
+ ipaddress: string;
19
+ port: number;
20
+ } | undefined> | undefined;
21
+ toPacScript: (proxy: string, rules?: string[], defaultProxy?: string) => string;
22
+ toPacProxy: (ipaddress: string, port: number, options?: {
23
+ type?: "PROXY" | "SOCKS5" | "ALL" | undefined;
24
+ direct?: boolean | undefined;
25
+ } | undefined) => string;
26
+ pacScript: (host: string, port: number, options?: {
27
+ rules?: string[] | undefined;
28
+ type?: "PROXY" | "SOCKS5" | "ALL" | undefined;
29
+ useSystem?: boolean | undefined;
30
+ } | undefined) => Promise<string>;
31
+ child_exec: (cmd: string) => Promise<[any, string]>;
32
+ brotliCompress: typeof import("../modules/node/brotli").brotliCompress;
33
+ brotliDecompress: typeof import("../modules/node/brotli").brotliDecompress;
34
+ readDirectory: (dir: string, callback?: import("..").Ddan.Func1<string, any> | undefined) => Promise<unknown>;
35
+ readFiles: (dir: string, files: string[], callback?: import("..").Ddan.Func1<string, any> | undefined) => Promise<void>;
36
+ };
37
+ export default dNode;
@@ -0,0 +1,45 @@
1
+ import Store from '../class/store';
2
+ import Persist from '../class/persist';
3
+ declare const dCdn: {
4
+ cdn: {
5
+ ossImage: (url: string, options?: {
6
+ webp?: boolean | undefined;
7
+ resize?: number | undefined;
8
+ interlace?: boolean | undefined;
9
+ domain?: string | string[] | undefined;
10
+ }) => string;
11
+ ossSnapshot: (url: string, options?: {
12
+ t?: number | undefined;
13
+ w?: number | undefined;
14
+ h?: number | undefined;
15
+ m?: "" | "fast" | undefined;
16
+ f?: "jpg" | "png" | undefined;
17
+ ar?: "auto" | "h" | "w" | undefined;
18
+ }) => string;
19
+ ossBase64: (input: string) => string;
20
+ };
21
+ watermark: (bg: string, size?: {
22
+ width?: number | undefined;
23
+ height?: number | undefined;
24
+ } | undefined) => import("../class/watermark").DWatermark;
25
+ };
26
+ declare const dStore: {
27
+ Store: typeof Store;
28
+ storeRef: (source: import("..").Ddan.IDStore, persistConfig?: import("..").Ddan.IDPersistConfig | undefined) => any;
29
+ Persist: typeof Persist;
30
+ persistConfig: (key: string, fields: string[], storage: import("..").Ddan.IStorage) => import("..").Ddan.IDPersistConfig;
31
+ };
32
+ declare const dJoker: import("../class/joker").Joker;
33
+ declare const dTracker: import("../class/tracker").DTracker;
34
+ declare const dLogger: {
35
+ override: () => void;
36
+ log: (...args: any[]) => void;
37
+ info: (...args: any[]) => void;
38
+ warn: (...args: any[]) => void;
39
+ error: (...args: any[]) => void;
40
+ config: ({ tag, format }?: {
41
+ tag?: boolean | undefined;
42
+ format?: string | undefined;
43
+ }) => void;
44
+ };
45
+ export { dCdn, dStore, dJoker, dTracker, dLogger };
@@ -0,0 +1,233 @@
1
+ import Event from '../class/event';
2
+ declare const dUtil: {
3
+ Event: typeof Event;
4
+ includes: typeof import("../util/includes").default;
5
+ forof: (source: any, cb: (key: any, val: any) => void) => void;
6
+ singleton: <T>() => {
7
+ new (): {};
8
+ __instance__: any;
9
+ readonly Instance: T;
10
+ readonly I: T;
11
+ };
12
+ getset: <T_1 = any>(t?: T_1 | undefined) => import("..").Ddan.IGetset<T_1>;
13
+ copy: (source: any, options?: {
14
+ fields?: string[] | undefined;
15
+ camel?: boolean | undefined;
16
+ pure?: boolean | undefined;
17
+ } & import("..").Ddan.IIgnoreParams) => any;
18
+ clone: (source: any) => any;
19
+ merge: (target: any, source: any, options?: import("..").Ddan.IIgnoreParams) => {};
20
+ isEmpty: (source: any) => boolean;
21
+ parseValue: (source: any, { number, boolean }?: {
22
+ number?: boolean | undefined;
23
+ boolean?: boolean | undefined;
24
+ }) => any;
25
+ cloneClass: <T_2>(source: T_2) => T_2;
26
+ combine: (target: any, source: any, options?: import("..").Ddan.IIgnoreParams) => any;
27
+ combines: (objs: any[], options?: import("..").Ddan.IIgnoreParams) => {};
28
+ observe: (obj: any, key: any, watchFun: any, owner: any, deep?: boolean) => void;
29
+ find: (obj: any, cb: (k: string, v: any) => boolean) => [string, unknown] | undefined;
30
+ getTag: (value: any) => string;
31
+ getType: (value: any) => string;
32
+ toString: () => string;
33
+ hasOwnProperty: (v: PropertyKey) => boolean;
34
+ propertyIsEnumerable: (v: PropertyKey) => boolean;
35
+ is: (val: any, type: string) => boolean;
36
+ isNumber: (value: any) => boolean;
37
+ isString: (value: any) => boolean;
38
+ isObject: (value: any) => boolean;
39
+ isObjectLike: (value: any) => boolean;
40
+ isPlainObject: (value: any) => boolean;
41
+ isSymbol: (value: any) => boolean;
42
+ isFunction: (value: any) => boolean;
43
+ isArray: (arg: any) => arg is any[];
44
+ isArrayLikeObject: (value: any) => boolean;
45
+ isIndex: (value: any, length: number) => boolean;
46
+ isArrayLike: (value: any) => boolean;
47
+ isPrototype: (value: any) => boolean;
48
+ isArguments: (value: any) => boolean;
49
+ isPromise: (value: any) => boolean;
50
+ isBrowser: boolean;
51
+ isNode: boolean;
52
+ isBlobOrBuffer: (data: any) => boolean;
53
+ isUint8Array: (data: any) => boolean;
54
+ isArrayBuffer: (data: any) => boolean;
55
+ base64: {
56
+ encode: (input: string) => string;
57
+ decode: (base64Str: string) => string;
58
+ encodeByOss: (input: string) => string;
59
+ };
60
+ tea: {
61
+ TEAKey: string;
62
+ encrypt: (v: Uint32Array, teaKey: Uint32Array) => Uint32Array;
63
+ decrypt: (v: Uint32Array, teaKey: Uint32Array) => Uint32Array;
64
+ toTeaKey: (str: string) => Uint32Array;
65
+ encode: (plaintext: string, key: string) => string;
66
+ decode: (ciphertext: string, key: string) => string;
67
+ encodeBytes: (plainbytes: Uint8Array, key: string) => Uint8Array;
68
+ decodeBytes: (cipherbytes: Uint8Array, key: string) => Uint8Array;
69
+ };
70
+ uuid: (len?: number, radix?: number) => string;
71
+ guid: (len: number, prefix?: boolean, sep?: string) => string;
72
+ getHexString: (len: number) => string;
73
+ keyNumber: string;
74
+ keyLower: string;
75
+ keyUpper: string;
76
+ keyChars: string;
77
+ str2ab: (content?: string, base64?: boolean) => ArrayBuffer;
78
+ ab2str: (data: ArrayBuffer, base64?: boolean) => string;
79
+ utf8ToBase64: (str: string) => string;
80
+ base64ToUtf8: (base64Str: string) => string;
81
+ getRandomBytes: (length: number) => Uint8Array;
82
+ textEncode: (text: string) => Uint8Array;
83
+ textDecode: (buf: ArrayBufferLike) => string;
84
+ toDataUrl: (textOrBuf: string | ArrayBuffer, contentType?: string) => string;
85
+ md5: (input: string | Uint8Array) => string;
86
+ md5Base64: (input: string | Uint8Array) => string;
87
+ toBase64: (input?: string) => string;
88
+ fromBase64: (input?: string) => string;
89
+ bytesToBase64: (bytes: Uint8Array) => string;
90
+ base64ToBytes: (input?: string) => Uint8Array;
91
+ toUtf8: (content: string) => string;
92
+ fromUtf8: (utftext: string) => string;
93
+ toUtf8Bytes: (content: string) => Uint8Array;
94
+ fromUtf8Bytes: (utf8Bytes: Uint8Array) => string;
95
+ pkcs7Padding: (plaintext: Uint8Array, blockSize: number) => Uint8Array;
96
+ pkcs7Unpadding: (ciphertext: Uint8Array) => Uint8Array;
97
+ bytes2str: (bytes: Uint8Array) => string;
98
+ str2bytes: (str?: string) => Uint8Array;
99
+ str2hex: (str: string) => string;
100
+ hex2str: (hexstr: string) => string;
101
+ concatBytes: (...args: Uint8Array[]) => Uint8Array;
102
+ uint32ToBytes: (uint32: Uint32Array) => Uint8Array;
103
+ bytesToUint32: (bytes: Uint8Array) => Uint32Array;
104
+ hex2bytes: (hex: string) => Uint8Array;
105
+ bytes2hex: (bytes: Uint8Array) => string;
106
+ toUint32: (str: string) => Uint32Array;
107
+ fromUint32: (uint32: Uint32Array) => string;
108
+ flatten: <T_3>(data: T_3[], recursive?: boolean, list?: T_3[]) => T_3[];
109
+ gbk: {
110
+ gbkLength: (str: string) => number;
111
+ gbkCut: (source: string, len: number) => string;
112
+ };
113
+ math: {
114
+ random: (max: number) => number;
115
+ randomRange: (min: number, max: number) => number;
116
+ lerp: (start: number, end: number, t: number) => number;
117
+ randoms: (max: number, count?: number, repeat?: boolean) => number[];
118
+ strip: (num: string | number, digits?: number) => number;
119
+ float: (num: string | number, { digits, fixed }?: {
120
+ digits?: number | undefined;
121
+ fixed?: boolean | undefined;
122
+ }) => number;
123
+ radian2degree: (radians: number) => number;
124
+ degree2radian: (degrees: number) => number;
125
+ calcDataSize: (data: number) => {
126
+ gb: number;
127
+ mb: number;
128
+ kb: number;
129
+ b: number;
130
+ total: number;
131
+ desc: string;
132
+ };
133
+ };
134
+ list: {
135
+ stepAction: <T_4>(list: T_4[], func: import("..").Ddan.Task<T_4, void>, stepCount?: number) => void;
136
+ skip: <T_5>(list: T_5[], count: number) => T_5[];
137
+ take: <T_6>(list: T_6[], count: number, skip?: number) => T_6[];
138
+ distinct: <T_7>(list: T_7[]) => T_7[];
139
+ randoms: <T_8>(list: T_8[], count?: number, repeat?: boolean) => T_8[];
140
+ toKV: (list: import("..").Ddan.KV<any>[], key: string, value: string) => import("..").Ddan.KV<any>;
141
+ groupBy: <T_9>(list: T_9[], key: string) => Record<string, T_9[]>;
142
+ first: <T_10>(list: T_10[]) => T_10 | undefined;
143
+ last: <T_11>(list: T_11[]) => T_11 | undefined;
144
+ toList: <T_12>(val: T_12 | T_12[]) => T_12[];
145
+ };
146
+ string: {
147
+ toString: (value: any) => any;
148
+ startCase: (string: any) => any;
149
+ snakeCase: (string: any) => any;
150
+ kebabCase: (string: any) => any;
151
+ camelCase: (string: any) => any;
152
+ upperCase: (string: any) => any;
153
+ upperFirst: (string: any) => any;
154
+ lowerCase: (string: any) => any;
155
+ lowerFirst: (string: any) => any;
156
+ splitOnFirst: (string: any, separator: any) => string[];
157
+ parseValue: (value?: any, { number, boolean }?: {
158
+ number?: boolean | undefined;
159
+ boolean?: boolean | undefined;
160
+ }) => any;
161
+ replace: (source: string, rules: import("..").Ddan.IRegexRule | import("..").Ddan.IRegexRule[]) => string;
162
+ jsonFormat: (jsonString: string) => string;
163
+ toLines: (content: string, separator?: string | RegExp) => string[];
164
+ };
165
+ time: {
166
+ now: () => import("../modules/time/dtime").default;
167
+ isToday: (date: any) => any;
168
+ parseTimestamp: ({ year, month, date, hour, minute, second }: {
169
+ year?: number | undefined;
170
+ month?: number | undefined;
171
+ date?: number | undefined;
172
+ hour?: number | undefined;
173
+ minute?: number | undefined;
174
+ second?: number | undefined;
175
+ }) => number;
176
+ todayZero: () => number;
177
+ format: (time: string | number | Date, reg?: string) => string;
178
+ countdown: (endTime: string | number | Date, reg?: string) => "" | import("..").Ddan.ICountdown;
179
+ dtime: (time: string | number | Date) => import("../modules/time/dtime").default;
180
+ loopFrame: (interval?: number) => import("../modules/time/frame").default;
181
+ getTimezoneOffset: () => number;
182
+ getLocalTime: typeof import("../modules/time/dtime").default.getLocalTime;
183
+ oneDay: number;
184
+ oneHour: number;
185
+ oneMinute: number;
186
+ oneSecond: number;
187
+ };
188
+ obj: {
189
+ copy: (source: any, options?: {
190
+ fields?: string[] | undefined;
191
+ camel?: boolean | undefined;
192
+ pure?: boolean | undefined;
193
+ } & import("..").Ddan.IIgnoreParams) => any;
194
+ clone: (source: any) => any;
195
+ merge: (target: any, source: any, options?: import("..").Ddan.IIgnoreParams) => {};
196
+ isEmpty: (source: any) => boolean;
197
+ parseValue: (source: any, { number, boolean }?: {
198
+ number?: boolean | undefined;
199
+ boolean?: boolean | undefined;
200
+ }) => any;
201
+ cloneClass: <T_2>(source: T_2) => T_2;
202
+ combine: (target: any, source: any, options?: import("..").Ddan.IIgnoreParams) => any;
203
+ combines: (objs: any[], options?: import("..").Ddan.IIgnoreParams) => {};
204
+ observe: (obj: any, key: any, watchFun: any, owner: any, deep?: boolean) => void;
205
+ find: (obj: any, cb: (k: string, v: any) => boolean) => [string, unknown] | undefined;
206
+ };
207
+ rule: {
208
+ validateId: (content: any) => boolean;
209
+ validatePhone: (content: any) => boolean;
210
+ validator: (rules: import("../modules/rule/async-validator").Rules) => import("../modules/rule/async-validator").default;
211
+ validate: (rules: import("../modules/rule/async-validator").Rules, source_: import("../modules/rule/async-validator").Values, o?: any, oc?: any) => Promise<import("../modules/rule/async-validator").Values>;
212
+ isChinese: (content: string) => boolean;
213
+ isNumber: (content: string) => boolean;
214
+ isFloat: (content: string) => boolean;
215
+ isPhoneNumber: (content: any) => boolean;
216
+ };
217
+ regex: {
218
+ pattern: {
219
+ num: string;
220
+ zh: string;
221
+ en: string;
222
+ };
223
+ regex: (patt: string, modifiers?: "i" | "g" | "m" | undefined) => RegExp;
224
+ entire: {
225
+ chinese: RegExp;
226
+ real: RegExp;
227
+ cssReal: RegExp;
228
+ id: RegExp;
229
+ yyyyMMdd: RegExp;
230
+ };
231
+ };
232
+ };
233
+ export default dUtil;
@@ -0,0 +1,127 @@
1
+ import Http from '../modules/http';
2
+ declare const dWeb: {
3
+ Ecdh: typeof import("../modules/browser/ecdh").default;
4
+ fetch: {
5
+ getDataURL: (url: string, cache?: RequestCache | undefined) => Promise<[null, {
6
+ contentType: string;
7
+ dataUrl: string;
8
+ }] | [any, undefined]>;
9
+ getArrayBuffer: (url: string, cache?: RequestCache | undefined) => Promise<[any, undefined] | [null, ArrayBuffer]>;
10
+ getJson: (url: string, cache?: RequestCache | undefined) => Promise<[any, undefined] | [null, any]>;
11
+ download: (url: string, opts?: {
12
+ success?: ((buffer: Uint8Array) => void) | undefined;
13
+ progress?: ((percentage: number, current: number, total: number) => void) | undefined;
14
+ fail?: ((error: Error) => void) | undefined;
15
+ }) => Promise<Uint8Array | undefined>;
16
+ getText: (url: string, cache?: RequestCache | undefined) => Promise<[any, undefined] | [null, string]>;
17
+ cache: (url: string, cache?: RequestCache) => Promise<[any, undefined] | [null, boolean]>;
18
+ };
19
+ Http: typeof Http;
20
+ css: {
21
+ stringify: (styleObj: Record<string, string | number>) => string;
22
+ parse: (styleStr: string, { camel, pure }?: {
23
+ camel?: boolean | undefined;
24
+ pure?: boolean | undefined;
25
+ }) => {} | undefined;
26
+ fixValue: (value: string | number, unit?: string) => string | number;
27
+ style: (cssKV: Record<string, any>, unit?: string) => string;
28
+ commonFields: string[];
29
+ };
30
+ qs: {
31
+ parse: (qs: any, { sep, eq, max, multiple, uri, parseNumber, parseBoolean }?: {
32
+ sep?: string | undefined;
33
+ eq?: string | undefined;
34
+ max?: number | undefined;
35
+ multiple?: boolean | undefined;
36
+ uri?: boolean | undefined;
37
+ parseNumber?: boolean | undefined;
38
+ parseBoolean?: boolean | undefined;
39
+ }) => {};
40
+ stringify: (obj: any, { sep, eq, name, uri, cleanZero, cleanNull, cleanWhitespace }?: {
41
+ sep?: string | undefined;
42
+ eq?: string | undefined;
43
+ name?: null | undefined;
44
+ uri?: boolean | undefined;
45
+ cleanZero?: boolean | undefined;
46
+ cleanNull?: boolean | undefined;
47
+ cleanWhitespace?: boolean | undefined;
48
+ }) => string;
49
+ https: (url: string) => string;
50
+ parseUrl: (url: string) => {
51
+ pathname: string;
52
+ params: {};
53
+ route: string;
54
+ page: string;
55
+ name: string;
56
+ withoutExtension: string;
57
+ extname: string;
58
+ href: string;
59
+ url: string;
60
+ origin: string;
61
+ host: string;
62
+ protocol: string;
63
+ port: string;
64
+ query: string;
65
+ };
66
+ parsePath: (url: string) => {
67
+ route: string;
68
+ page: string;
69
+ name: string;
70
+ withoutExtension: string;
71
+ extname: string;
72
+ };
73
+ parseHost: (url: string) => import("..").Ddan.IHttpHost;
74
+ join: (...args: string[]) => string;
75
+ shExpMatch: (text: string, pattern: string) => boolean;
76
+ isLocalIpAddress: (addr: string) => boolean;
77
+ parseFileUrl: (url: string) => {
78
+ href: string;
79
+ file: string;
80
+ url: string;
81
+ protocol: string;
82
+ host: string;
83
+ query: string;
84
+ params: {};
85
+ };
86
+ };
87
+ icon: import("../class/icon").DIcon;
88
+ html: {
89
+ dataURLtoFile: (dataurl: any, filename: any) => File;
90
+ dataURLtoBlob: (dataurl: any) => Blob;
91
+ blobToFile: (blob: any, fileName: string) => any;
92
+ readAsDataURL: (file: any, cb: any) => void;
93
+ downloadUrl: (url: string, filename?: string, checkSomeOrigin?: boolean) => void;
94
+ download: (urlOrFile: string | Blob | MediaSource, filename?: string) => void;
95
+ downloadFile: (data: Blob | MediaSource, filename?: string) => void;
96
+ downloadImage: (url: string) => Promise<void> | undefined;
97
+ watermark: (text: string, { width, height, angle, fillStyle, font, textAlign, textBaseline, }?: {
98
+ width?: number | undefined;
99
+ height?: number | undefined;
100
+ angle?: number | undefined;
101
+ fillStyle?: string | undefined;
102
+ font?: string | undefined;
103
+ textAlign?: "center" | "end" | "left" | "right" | "start" | undefined;
104
+ textBaseline?: "alphabetic" | "bottom" | "hanging" | "ideographic" | "middle" | "top" | undefined;
105
+ }) => string;
106
+ copyText: (text: string, legacy?: boolean) => Promise<boolean>;
107
+ queryPermission: (name: string, def?: PermissionState) => Promise<PermissionState>;
108
+ isAllowed: (status: PermissionState | undefined, prompt?: boolean) => boolean;
109
+ legacyCopy: (text: string) => boolean;
110
+ takeHtmlLinks: (htmlContent: string) => never[];
111
+ takeHtml: (htmlContent: string, regex: RegExp) => string[];
112
+ toBlobUrl: (part: BlobPart, mime: "application/javascript") => string;
113
+ };
114
+ rsa: {
115
+ generateKeys: () => Promise<{
116
+ publicKey: string;
117
+ publicKeyPem: string;
118
+ privateKey: string;
119
+ privateKeyPem: string;
120
+ }>;
121
+ encrypt: (data: string, publicKey: string) => Promise<string>;
122
+ decrypt: (encryptedBase64: string, privateKey: string) => Promise<string>;
123
+ encode: (data: string) => Promise<string>;
124
+ decode: (encryptedBase64: string) => Promise<string>;
125
+ };
126
+ };
127
+ export default dWeb;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ddan-js",
3
- "version": "2.10.4",
3
+ "version": "2.10.6",
4
4
  "description": "",
5
5
  "keywords": [
6
6
  "ddan-js",