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.
package/bin/browser.d.ts CHANGED
@@ -1,512 +1,10 @@
1
1
  export type { Ddan } from './typings';
2
- import Http from './modules/http';
3
2
  import Event from './class/event';
4
- import Store from './class/store';
5
- import Persist from './class/persist';
6
3
  import KValue from './class/kvalue';
7
4
  import Mapping from './class/mapping';
8
5
  import dHook from './tiny/hook';
9
- declare const dUtil: {
10
- Event: typeof Event;
11
- includes: typeof import("./util/includes").default;
12
- forof: (source: any, cb: (key: any, val: any) => void) => void;
13
- singleton: <T>() => {
14
- new (): {};
15
- __instance__: any;
16
- readonly Instance: T;
17
- readonly I: T;
18
- };
19
- getset: <T_1 = any>(t?: T_1 | undefined) => import("./typings").Ddan.IGetset<T_1>;
20
- copy: (source: any, options?: {
21
- fields?: string[] | undefined;
22
- camel?: boolean | undefined;
23
- pure?: boolean | undefined;
24
- } & import("./typings").Ddan.IIgnoreParams) => any;
25
- clone: (source: any) => any;
26
- merge: (target: any, source: any, options?: import("./typings").Ddan.IIgnoreParams) => {};
27
- isEmpty: (source: any) => boolean;
28
- parseValue: (source: any, { number, boolean }?: {
29
- number?: boolean | undefined;
30
- boolean?: boolean | undefined;
31
- }) => any;
32
- cloneClass: <T_2>(source: T_2) => T_2;
33
- combine: (target: any, source: any, options?: import("./typings").Ddan.IIgnoreParams) => any;
34
- combines: (objs: any[], options?: import("./typings").Ddan.IIgnoreParams) => {};
35
- observe: (obj: any, key: any, watchFun: any, owner: any, deep?: boolean) => void;
36
- find: (obj: any, cb: (k: string, v: any) => boolean) => [string, unknown] | undefined;
37
- getTag: (value: any) => string;
38
- getType: (value: any) => string;
39
- toString: () => string;
40
- hasOwnProperty: (v: PropertyKey) => boolean;
41
- propertyIsEnumerable: (v: PropertyKey) => boolean;
42
- is: (val: any, type: string) => boolean;
43
- isNumber: (value: any) => boolean;
44
- isString: (value: any) => boolean;
45
- isObject: (value: any) => boolean;
46
- isObjectLike: (value: any) => boolean;
47
- isPlainObject: (value: any) => boolean;
48
- isSymbol: (value: any) => boolean;
49
- isFunction: (value: any) => boolean;
50
- isArray: (arg: any) => arg is any[];
51
- isArrayLikeObject: (value: any) => boolean;
52
- isIndex: (value: any, length: number) => boolean;
53
- isArrayLike: (value: any) => boolean;
54
- isPrototype: (value: any) => boolean;
55
- isArguments: (value: any) => boolean;
56
- isPromise: (value: any) => boolean;
57
- isBrowser: boolean;
58
- isNode: boolean;
59
- isBlobOrBuffer: (data: any) => boolean;
60
- isUint8Array: (data: any) => boolean;
61
- isArrayBuffer: (data: any) => boolean;
62
- base64: {
63
- encode: (input: string) => string;
64
- decode: (base64Str: string) => string;
65
- encodeByOss: (input: string) => string;
66
- };
67
- tea: {
68
- TEAKey: string;
69
- encrypt: (v: Uint32Array, teaKey: Uint32Array) => Uint32Array;
70
- decrypt: (v: Uint32Array, teaKey: Uint32Array) => Uint32Array;
71
- toTeaKey: (str: string) => Uint32Array;
72
- encode: (plaintext: string, key: string) => string;
73
- decode: (ciphertext: string, key: string) => string;
74
- encodeBytes: (plainbytes: Uint8Array, key: string) => Uint8Array;
75
- decodeBytes: (cipherbytes: Uint8Array, key: string) => Uint8Array;
76
- };
77
- uuid: (len?: number, radix?: number) => string;
78
- guid: (len: number, prefix?: boolean, sep?: string) => string;
79
- getHexString: (len: number) => string;
80
- keyNumber: string;
81
- keyLower: string;
82
- keyUpper: string;
83
- keyChars: string;
84
- str2ab: (content?: string, base64?: boolean) => ArrayBuffer;
85
- ab2str: (data: ArrayBuffer, base64?: boolean) => string;
86
- utf8ToBase64: (str: string) => string;
87
- base64ToUtf8: (base64Str: string) => string;
88
- getRandomBytes: (length: number) => Uint8Array;
89
- textEncode: (text: string) => Uint8Array;
90
- textDecode: (buf: ArrayBufferLike) => string;
91
- toDataUrl: (textOrBuf: string | ArrayBuffer, contentType?: string) => string;
92
- md5: (input: string | Uint8Array) => string;
93
- md5Base64: (input: string | Uint8Array) => string;
94
- toBase64: (input?: string) => string;
95
- fromBase64: (input?: string) => string;
96
- bytesToBase64: (bytes: Uint8Array) => string;
97
- base64ToBytes: (input?: string) => Uint8Array;
98
- toUtf8: (content: string) => string;
99
- fromUtf8: (utftext: string) => string;
100
- toUtf8Bytes: (content: string) => Uint8Array;
101
- fromUtf8Bytes: (utf8Bytes: Uint8Array) => string;
102
- pkcs7Padding: (plaintext: Uint8Array, blockSize: number) => Uint8Array;
103
- pkcs7Unpadding: (ciphertext: Uint8Array) => Uint8Array;
104
- bytes2str: (bytes: Uint8Array) => string;
105
- str2bytes: (str?: string) => Uint8Array;
106
- str2hex: (str: string) => string;
107
- hex2str: (hexstr: string) => string;
108
- concatBytes: (...args: Uint8Array[]) => Uint8Array;
109
- uint32ToBytes: (uint32: Uint32Array) => Uint8Array;
110
- bytesToUint32: (bytes: Uint8Array) => Uint32Array;
111
- hex2bytes: (hex: string) => Uint8Array;
112
- bytes2hex: (bytes: Uint8Array) => string;
113
- toUint32: (str: string) => Uint32Array;
114
- fromUint32: (uint32: Uint32Array) => string;
115
- flatten: <T_3>(data: T_3[], recursive?: boolean, list?: T_3[]) => T_3[];
116
- gbk: {
117
- gbkLength: (str: string) => number;
118
- gbkCut: (source: string, len: number) => string;
119
- };
120
- math: {
121
- random: (max: number) => number;
122
- randomRange: (min: number, max: number) => number;
123
- lerp: (start: number, end: number, t: number) => number;
124
- randoms: (max: number, count?: number, repeat?: boolean) => number[];
125
- strip: (num: string | number, digits?: number) => number;
126
- float: (num: string | number, { digits, fixed }?: {
127
- digits?: number | undefined;
128
- fixed?: boolean | undefined;
129
- }) => number;
130
- radian2degree: (radians: number) => number;
131
- degree2radian: (degrees: number) => number;
132
- calcDataSize: (data: number) => {
133
- gb: number;
134
- mb: number;
135
- kb: number;
136
- b: number;
137
- total: number;
138
- desc: string;
139
- };
140
- };
141
- list: {
142
- stepAction: <T_4>(list: T_4[], func: import("./typings").Ddan.Task<T_4, void>, stepCount?: number) => void;
143
- skip: <T_5>(list: T_5[], count: number) => T_5[];
144
- take: <T_6>(list: T_6[], count: number, skip?: number) => T_6[];
145
- distinct: <T_7>(list: T_7[]) => T_7[];
146
- randoms: <T_8>(list: T_8[], count?: number, repeat?: boolean) => T_8[];
147
- toKV: (list: import("./typings").Ddan.KV<any>[], key: string, value: string) => import("./typings").Ddan.KV<any>;
148
- groupBy: <T_9>(list: T_9[], key: string) => Record<string, T_9[]>;
149
- first: <T_10>(list: T_10[]) => T_10 | undefined;
150
- last: <T_11>(list: T_11[]) => T_11 | undefined;
151
- toList: <T_12>(val: T_12 | T_12[]) => T_12[];
152
- };
153
- string: {
154
- toString: (value: any) => any;
155
- startCase: (string: any) => any;
156
- snakeCase: (string: any) => any;
157
- kebabCase: (string: any) => any;
158
- camelCase: (string: any) => any;
159
- upperCase: (string: any) => any;
160
- upperFirst: (string: any) => any;
161
- lowerCase: (string: any) => any;
162
- lowerFirst: (string: any) => any;
163
- splitOnFirst: (string: any, separator: any) => string[];
164
- parseValue: (value?: any, { number, boolean }?: {
165
- number?: boolean | undefined;
166
- boolean?: boolean | undefined;
167
- }) => any;
168
- replace: (source: string, rules: import("./typings").Ddan.IRegexRule | import("./typings").Ddan.IRegexRule[]) => string;
169
- jsonFormat: (jsonString: string) => string;
170
- toLines: (content: string, separator?: string | RegExp) => string[];
171
- };
172
- time: {
173
- now: () => import("./modules/time/dtime").default;
174
- isToday: (date: any) => any;
175
- parseTimestamp: ({ year, month, date, hour, minute, second }: {
176
- year?: number | undefined;
177
- month?: number | undefined;
178
- date?: number | undefined;
179
- hour?: number | undefined;
180
- minute?: number | undefined;
181
- second?: number | undefined;
182
- }) => number;
183
- todayZero: () => number;
184
- format: (time: string | number | Date, reg?: string) => string;
185
- countdown: (endTime: string | number | Date, reg?: string) => "" | import("./typings").Ddan.ICountdown;
186
- dtime: (time: string | number | Date) => import("./modules/time/dtime").default;
187
- loopFrame: (interval?: number) => import("./modules/time/frame").default;
188
- getTimezoneOffset: () => number;
189
- getLocalTime: typeof import("./modules/time/dtime").default.getLocalTime;
190
- oneDay: number;
191
- oneHour: number;
192
- oneMinute: number;
193
- oneSecond: number;
194
- };
195
- obj: {
196
- copy: (source: any, options?: {
197
- fields?: string[] | undefined;
198
- camel?: boolean | undefined;
199
- pure?: boolean | undefined;
200
- } & import("./typings").Ddan.IIgnoreParams) => any;
201
- clone: (source: any) => any;
202
- merge: (target: any, source: any, options?: import("./typings").Ddan.IIgnoreParams) => {};
203
- isEmpty: (source: any) => boolean;
204
- parseValue: (source: any, { number, boolean }?: {
205
- number?: boolean | undefined;
206
- boolean?: boolean | undefined;
207
- }) => any;
208
- cloneClass: <T_2>(source: T_2) => T_2;
209
- combine: (target: any, source: any, options?: import("./typings").Ddan.IIgnoreParams) => any;
210
- combines: (objs: any[], options?: import("./typings").Ddan.IIgnoreParams) => {};
211
- observe: (obj: any, key: any, watchFun: any, owner: any, deep?: boolean) => void;
212
- find: (obj: any, cb: (k: string, v: any) => boolean) => [string, unknown] | undefined;
213
- };
214
- rule: {
215
- validateId: (content: any) => boolean;
216
- validatePhone: (content: any) => boolean;
217
- validator: (rules: import("./modules/rule/async-validator").Rules) => import("./modules/rule/async-validator").default;
218
- 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>;
219
- isChinese: (content: string) => boolean;
220
- isNumber: (content: string) => boolean;
221
- isFloat: (content: string) => boolean;
222
- isPhoneNumber: (content: any) => boolean;
223
- };
224
- regex: {
225
- pattern: {
226
- num: string;
227
- zh: string;
228
- en: string;
229
- };
230
- regex: (patt: string, modifiers?: "g" | "i" | "m" | undefined) => RegExp;
231
- entire: {
232
- chinese: RegExp;
233
- real: RegExp;
234
- cssReal: RegExp;
235
- id: RegExp;
236
- yyyyMMdd: RegExp;
237
- };
238
- };
239
- };
240
- declare const dMini: {
241
- mini: {
242
- diff: typeof import("./modules/mini/diff").default;
243
- promixify: (miniapi: any) => any;
244
- run: (func: any, args?: {}) => Promise<[any, undefined] | [null, any]>;
245
- formatList: (lists: any[], start: any, name: any) => any;
246
- ruleValidator: (_: any, value: any) => boolean;
247
- Http: typeof import("./modules/mini/http").default;
248
- setWatcher: (page: any) => void;
249
- };
250
- css: {
251
- stringify: (styleObj: Record<string, string | number>) => string;
252
- parse: (styleStr: string, { camel, pure }?: {
253
- camel?: boolean | undefined;
254
- pure?: boolean | undefined;
255
- }) => {} | undefined;
256
- fixValue: (value: string | number, unit?: string) => string | number;
257
- style: (cssKV: Record<string, any>, unit?: string) => string;
258
- commonFields: string[];
259
- };
260
- qs: {
261
- parse: (qs: any, { sep, eq, max, multiple, uri, parseNumber, parseBoolean }?: {
262
- sep?: string | undefined;
263
- eq?: string | undefined;
264
- max?: number | undefined;
265
- multiple?: boolean | undefined;
266
- uri?: boolean | undefined;
267
- parseNumber?: boolean | undefined;
268
- parseBoolean?: boolean | undefined;
269
- }) => {};
270
- stringify: (obj: any, { sep, eq, name, uri, cleanZero, cleanNull, cleanWhitespace }?: {
271
- sep?: string | undefined;
272
- eq?: string | undefined;
273
- name?: null | undefined;
274
- uri?: boolean | undefined;
275
- cleanZero?: boolean | undefined;
276
- cleanNull?: boolean | undefined;
277
- cleanWhitespace?: boolean | undefined;
278
- }) => string;
279
- https: (url: string) => string;
280
- parseUrl: (url: string) => {
281
- pathname: string;
282
- params: {};
283
- route: string;
284
- page: string;
285
- name: string;
286
- withoutExtension: string;
287
- extname: string;
288
- href: string;
289
- url: string;
290
- origin: string;
291
- host: string;
292
- protocol: string;
293
- port: string;
294
- query: string;
295
- };
296
- parsePath: (url: string) => {
297
- route: string;
298
- page: string;
299
- name: string;
300
- withoutExtension: string;
301
- extname: string;
302
- };
303
- parseHost: (url: string) => import("./typings").Ddan.IHttpHost;
304
- join: (...args: string[]) => string;
305
- shExpMatch: (text: string, pattern: string) => boolean;
306
- isLocalIpAddress: (addr: string) => boolean;
307
- parseFileUrl: (url: string) => {
308
- href: string;
309
- file: string;
310
- url: string;
311
- protocol: string;
312
- host: string;
313
- query: string;
314
- params: {};
315
- };
316
- };
317
- icon: import("./class/icon").DIcon;
318
- html: {
319
- dataURLtoFile: (dataurl: any, filename: any) => File;
320
- dataURLtoBlob: (dataurl: any) => Blob;
321
- blobToFile: (blob: any, fileName: string) => any;
322
- readAsDataURL: (file: any, cb: any) => void;
323
- downloadUrl: (url: string, filename?: string, checkSomeOrigin?: boolean) => void;
324
- download: (urlOrFile: string | Blob | MediaSource, filename?: string) => void;
325
- downloadFile: (data: Blob | MediaSource, filename?: string) => void;
326
- downloadImage: (url: string) => Promise<void> | undefined;
327
- watermark: (text: string, { width, height, angle, fillStyle, font, textAlign, textBaseline, }?: {
328
- width?: number | undefined;
329
- height?: number | undefined;
330
- angle?: number | undefined;
331
- fillStyle?: string | undefined;
332
- font?: string | undefined;
333
- textAlign?: "center" | "end" | "left" | "right" | "start" | undefined;
334
- textBaseline?: "alphabetic" | "bottom" | "hanging" | "ideographic" | "middle" | "top" | undefined;
335
- }) => string;
336
- copyText: (text: string, legacy?: boolean) => Promise<boolean>;
337
- queryPermission: (name: string, def?: PermissionState) => Promise<PermissionState>;
338
- isAllowed: (status: PermissionState | undefined, prompt?: boolean) => boolean;
339
- legacyCopy: (text: string) => boolean;
340
- takeHtmlLinks: (htmlContent: string) => never[];
341
- takeHtml: (htmlContent: string, regex: RegExp) => string[];
342
- toBlobUrl: (part: BlobPart, mime: "application/javascript") => string;
343
- };
344
- };
345
- declare const dCdn: {
346
- cdn: {
347
- ossImage: (url: string, options?: {
348
- webp?: boolean | undefined;
349
- resize?: number | undefined;
350
- interlace?: boolean | undefined;
351
- domain?: string | string[] | undefined;
352
- }) => string;
353
- ossSnapshot: (url: string, options?: {
354
- t?: number | undefined;
355
- w?: number | undefined;
356
- h?: number | undefined;
357
- m?: "" | "fast" | undefined;
358
- f?: "jpg" | "png" | undefined;
359
- ar?: "auto" | "h" | "w" | undefined;
360
- }) => string;
361
- ossBase64: (input: string) => string;
362
- };
363
- watermark: (bg: string, size?: {
364
- width?: number | undefined;
365
- height?: number | undefined;
366
- } | undefined) => import("./class/watermark").DWatermark;
367
- };
368
- declare const dStore: {
369
- Store: typeof Store;
370
- storeRef: (source: import("./typings").Ddan.IDStore, persistConfig?: import("./typings").Ddan.IDPersistConfig | undefined) => any;
371
- Persist: typeof Persist;
372
- persistConfig: (key: string, fields: string[], storage: import("./typings").Ddan.IStorage) => import("./typings").Ddan.IDPersistConfig;
373
- };
374
- declare const dJoker: import("./class/joker").Joker;
375
- declare const dTracker: import("./class/tracker").DTracker;
376
- declare const dLogger: {
377
- override: () => void;
378
- log: (...args: any[]) => void;
379
- info: (...args: any[]) => void;
380
- warn: (...args: any[]) => void;
381
- error: (...args: any[]) => void;
382
- config: ({ tag, format }?: {
383
- tag?: boolean | undefined;
384
- format?: string | undefined;
385
- }) => void;
386
- };
387
- declare const dWeb: {
388
- Ecdh: typeof import("./modules/browser/ecdh").default;
389
- fetch: {
390
- getDataURL: (url: string, cache?: RequestCache | undefined) => Promise<[any, undefined] | [null, {
391
- contentType: string;
392
- dataUrl: string;
393
- }]>;
394
- getArrayBuffer: (url: string, cache?: RequestCache | undefined) => Promise<[any, undefined] | [null, ArrayBuffer]>;
395
- getJson: (url: string, cache?: RequestCache | undefined) => Promise<[any, undefined] | [null, any]>;
396
- download: (url: string, opts?: {
397
- success?: ((buffer: Uint8Array) => void) | undefined;
398
- progress?: ((percentage: number, current: number, total: number) => void) | undefined;
399
- fail?: ((error: Error) => void) | undefined;
400
- }) => Promise<Uint8Array | undefined>;
401
- getText: (url: string, cache?: RequestCache | undefined) => Promise<[any, undefined] | [null, string]>;
402
- cache: (url: string, cache?: RequestCache) => Promise<[any, undefined] | [null, boolean]>;
403
- };
404
- Http: typeof Http;
405
- css: {
406
- stringify: (styleObj: Record<string, string | number>) => string;
407
- parse: (styleStr: string, { camel, pure }?: {
408
- camel?: boolean | undefined;
409
- pure?: boolean | undefined;
410
- }) => {} | undefined;
411
- fixValue: (value: string | number, unit?: string) => string | number;
412
- style: (cssKV: Record<string, any>, unit?: string) => string;
413
- commonFields: string[];
414
- };
415
- qs: {
416
- parse: (qs: any, { sep, eq, max, multiple, uri, parseNumber, parseBoolean }?: {
417
- sep?: string | undefined;
418
- eq?: string | undefined;
419
- max?: number | undefined;
420
- multiple?: boolean | undefined;
421
- uri?: boolean | undefined;
422
- parseNumber?: boolean | undefined;
423
- parseBoolean?: boolean | undefined;
424
- }) => {};
425
- stringify: (obj: any, { sep, eq, name, uri, cleanZero, cleanNull, cleanWhitespace }?: {
426
- sep?: string | undefined;
427
- eq?: string | undefined;
428
- name?: null | undefined;
429
- uri?: boolean | undefined;
430
- cleanZero?: boolean | undefined;
431
- cleanNull?: boolean | undefined;
432
- cleanWhitespace?: boolean | undefined;
433
- }) => string;
434
- https: (url: string) => string;
435
- parseUrl: (url: string) => {
436
- pathname: string;
437
- params: {};
438
- route: string;
439
- page: string;
440
- name: string;
441
- withoutExtension: string;
442
- extname: string;
443
- href: string;
444
- url: string;
445
- origin: string;
446
- host: string;
447
- protocol: string;
448
- port: string;
449
- query: string;
450
- };
451
- parsePath: (url: string) => {
452
- route: string;
453
- page: string;
454
- name: string;
455
- withoutExtension: string;
456
- extname: string;
457
- };
458
- parseHost: (url: string) => import("./typings").Ddan.IHttpHost;
459
- join: (...args: string[]) => string;
460
- shExpMatch: (text: string, pattern: string) => boolean;
461
- isLocalIpAddress: (addr: string) => boolean;
462
- parseFileUrl: (url: string) => {
463
- href: string;
464
- file: string;
465
- url: string;
466
- protocol: string;
467
- host: string;
468
- query: string;
469
- params: {};
470
- };
471
- };
472
- icon: import("./class/icon").DIcon;
473
- html: {
474
- dataURLtoFile: (dataurl: any, filename: any) => File;
475
- dataURLtoBlob: (dataurl: any) => Blob;
476
- blobToFile: (blob: any, fileName: string) => any;
477
- readAsDataURL: (file: any, cb: any) => void;
478
- downloadUrl: (url: string, filename?: string, checkSomeOrigin?: boolean) => void;
479
- download: (urlOrFile: string | Blob | MediaSource, filename?: string) => void;
480
- downloadFile: (data: Blob | MediaSource, filename?: string) => void;
481
- downloadImage: (url: string) => Promise<void> | undefined;
482
- watermark: (text: string, { width, height, angle, fillStyle, font, textAlign, textBaseline, }?: {
483
- width?: number | undefined;
484
- height?: number | undefined;
485
- angle?: number | undefined;
486
- fillStyle?: string | undefined;
487
- font?: string | undefined;
488
- textAlign?: "center" | "end" | "left" | "right" | "start" | undefined;
489
- textBaseline?: "alphabetic" | "bottom" | "hanging" | "ideographic" | "middle" | "top" | undefined;
490
- }) => string;
491
- copyText: (text: string, legacy?: boolean) => Promise<boolean>;
492
- queryPermission: (name: string, def?: PermissionState) => Promise<PermissionState>;
493
- isAllowed: (status: PermissionState | undefined, prompt?: boolean) => boolean;
494
- legacyCopy: (text: string) => boolean;
495
- takeHtmlLinks: (htmlContent: string) => never[];
496
- takeHtml: (htmlContent: string, regex: RegExp) => string[];
497
- toBlobUrl: (part: BlobPart, mime: "application/javascript") => string;
498
- };
499
- rsa: {
500
- generateKeys: () => Promise<{
501
- publicKey: string;
502
- publicKeyPem: string;
503
- privateKey: string;
504
- privateKeyPem: string;
505
- }>;
506
- encrypt: (data: string, publicKey: string) => Promise<string>;
507
- decrypt: (encryptedBase64: string, privateKey: string) => Promise<string>;
508
- encode: (data: string) => Promise<string>;
509
- decode: (encryptedBase64: string) => Promise<string>;
510
- };
511
- };
6
+ import dUtil from './tiny/utils';
7
+ import dMini from './tiny/mini';
8
+ import dWeb from './tiny/web';
9
+ import { dCdn, dJoker, dLogger, dStore, dTracker } from './tiny/tools';
512
10
  export { dUtil, dHook, dWeb, dMini, dCdn, dStore, dJoker, dTracker, dLogger, Event, KValue, Mapping, };