@unicom-cloud/utils 0.1.16 → 0.1.17

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.
Files changed (63) hide show
  1. package/class-name/index.js +5 -5
  2. package/constant/index.js +24 -2
  3. package/constant/platform.js +13 -12
  4. package/constant.js +24 -2
  5. package/content-disposition/index.js +3 -3
  6. package/date/convertTime.js +4 -4
  7. package/event-emitter/index.js +2 -4
  8. package/filesize/types/constants.d.ts +81 -0
  9. package/filesize/types/filesize.d.ts +97 -0
  10. package/index.js +66 -60
  11. package/js-cookie/index.d.ts +116 -0
  12. package/js-cookie/index.js +4 -0
  13. package/js-cookie/src/api.js +56 -0
  14. package/js-cookie/src/assign.js +11 -0
  15. package/js-cookie/src/converter.js +14 -0
  16. package/jsCookie.js +4 -0
  17. package/lunar/lib/HolidayUtil.js +48 -49
  18. package/nzh/nzh.d.ts +74 -0
  19. package/package.json +1 -1
  20. package/query-string/base.d.ts +717 -0
  21. package/query-string/base.js +268 -0
  22. package/query-string/index.d.ts +16 -0
  23. package/query-string/index.js +4 -0
  24. package/query-string/splitOnFirst.js +14 -0
  25. package/queryString.js +4 -0
  26. package/random/index.js +56 -35
  27. package/snapdom/src/api/preCache.js +51 -28
  28. package/snapdom/src/core/cache.js +1 -4
  29. package/snapdom/src/core/capture.js +45 -44
  30. package/snapdom/src/core/clone.js +82 -66
  31. package/snapdom/src/core/prepare.js +167 -45
  32. package/snapdom/src/modules/background.js +29 -19
  33. package/snapdom/src/modules/fonts.js +158 -111
  34. package/snapdom/src/modules/images.js +14 -9
  35. package/snapdom/src/modules/pseudo.js +52 -47
  36. package/snapdom/src/modules/styles.js +22 -22
  37. package/snapdom/src/modules/svgDefs.js +39 -20
  38. package/snapdom/src/utils/cssTools.js +58 -51
  39. package/snapdom/src/utils/helpers.js +197 -140
  40. package/snapdom/types/snapdom.d.ts +101 -0
  41. package/types/constant/index.d.ts +11 -0
  42. package/types/constant/platform.d.ts +1 -0
  43. package/types/index.d.ts +3 -0
  44. package/types/js-cookie/index.d.ts +1 -0
  45. package/types/js-cookie/src/api.d.mts +2 -0
  46. package/types/js-cookie/src/assign.d.mts +1 -0
  47. package/types/js-cookie/src/converter.d.mts +5 -0
  48. package/types/query-string/base.d.ts +11 -0
  49. package/types/query-string/index.d.ts +2 -0
  50. package/types/query-string/splitOnFirst.d.ts +1 -0
  51. package/types/random/index.d.ts +14 -23
  52. package/types/snapdom/src/api/preCache.d.ts +2 -5
  53. package/types/snapdom/src/core/cache.d.ts +0 -3
  54. package/types/snapdom/src/core/clone.d.ts +1 -1
  55. package/types/snapdom/src/modules/background.d.ts +16 -6
  56. package/types/snapdom/src/modules/fonts.d.ts +5 -1
  57. package/types/snapdom/src/modules/pseudo.d.ts +1 -1
  58. package/types/snapdom/src/modules/styles.d.ts +1 -1
  59. package/types/snapdom/src/modules/svgDefs.d.ts +13 -13
  60. package/types/snapdom/src/utils/cssTools.d.ts +2 -10
  61. package/types/snapdom/src/utils/helpers.d.ts +13 -7
  62. package/types/turbo-stream/src/shared.d.ts +3 -3
  63. package/url-toolkit/src/url-toolkit.d.ts +22 -0
@@ -1,8 +1,8 @@
1
- import o from "lodash/isPlainObject";
2
- function s(...e) {
3
- const n = " ", i = e.flat(1 / 0).map((t, r, f) => o(t) ? Object.keys(t).filter((a) => t[a]) : t).flat(1 / 0).filter(Boolean).join(n).split(n).filter(Boolean);
4
- return [...new Set(i)].join(n);
1
+ import a from "lodash/isPlainObject";
2
+ function l(...n) {
3
+ const e = n.flat(1 / 0).map((t, r, s) => a(t) ? Object.keys(t).filter((i) => t[i]) : t).flat(1 / 0).filter(Boolean).join(" ").split(" ").filter(Boolean);
4
+ return [...new Set(e)].join(" ");
5
5
  }
6
6
  export {
7
- s as default
7
+ l as default
8
8
  };
package/constant/index.js CHANGED
@@ -1,6 +1,28 @@
1
- const e = window.matchMedia(
1
+ import * as o from "./address.js";
2
+ import * as t from "./chineseCharacters.js";
3
+ import * as a from "./constellations.js";
4
+ import * as r from "./domain.js";
5
+ import * as s from "./identity.js";
6
+ import * as e from "./keyboardCode.js";
7
+ import * as n from "./licensePlate.js";
8
+ import * as m from "./name.js";
9
+ import * as p from "./platform.js";
10
+ import * as i from "./protocol.js";
11
+ import * as c from "./ui.js";
12
+ const _ = window.matchMedia(
2
13
  "(prefers-color-scheme: dark)"
3
14
  );
4
15
  export {
5
- e as MATCH_MEDIA_PREFERS_COLOR_SCHEME_DARK
16
+ _ as MATCH_MEDIA_PREFERS_COLOR_SCHEME_DARK,
17
+ t as chineseCharacters,
18
+ a as constellations,
19
+ o as date,
20
+ r as domain,
21
+ s as identity,
22
+ e as keyboardCode,
23
+ n as licensePlate,
24
+ m as name,
25
+ p as platform,
26
+ i as protocol,
27
+ c as ui
6
28
  };
@@ -1,18 +1,19 @@
1
- const i = navigator.userAgent.toLowerCase(), t = window.__wxjs_environment === "miniprogram" || !!window.wx?.getSystemInfoSync, e = /micromessenger/i.test(i), a = /dingtalk/i.test(i), r = /alipay|aliapp/i.test(i), o = /ipad|iphone|ipod/i.test(i), s = /android/i.test(i), w = /openharmony/i.test(i), c = /macintosh|mac os x/i.test(i), d = /windows|win32|win64|wow64/i.test(
1
+ const i = navigator.userAgent.toLowerCase(), t = window.__wxjs_environment === "miniprogram" || !!window.wx?.getSystemInfoSync, a = /micromessenger/i.test(i), r = /dingtalk/i.test(i), c = /alipay|aliapp/i.test(i), n = /ipad|iphone|ipod/i.test(i), e = /android/i.test(i), w = /openharmony/i.test(i), s = /macintosh|mac os x/i.test(i), d = n || s, m = /windows|win32|win64|wow64/i.test(
2
2
  i
3
- ), m = (o || s || /windows phone|blackberry|mobile|webos|iemobile|opera (mini|mobi)/i.test(
3
+ ), l = (n || e || /windows phone|blackberry|mobile|webos|iemobile|opera (mini|mobi)/i.test(
4
4
  i
5
- )) && ("ontouchend" in document || "ontouchend" in window), l = ["fullscreen", "standalone", "minimal-ui"].some((n) => window.matchMedia(`(display-mode: ${n})`).matches) || window.navigator.standalone === !0;
5
+ )) && ("ontouchend" in document || "ontouchend" in window), p = ["fullscreen", "standalone", "minimal-ui"].some((o) => window.matchMedia(`(display-mode: ${o})`).matches) || window.navigator.standalone === !0;
6
6
  export {
7
- r as isAlipayBrowser,
8
- s as isAndroidOS,
9
- a as isDingtalkBrowser,
7
+ c as isAlipayBrowser,
8
+ e as isAndroidOS,
9
+ d as isAppleDevice,
10
+ r as isDingtalkBrowser,
10
11
  w as isHarmony,
11
- o as isIOS_OS,
12
- c as isMacOS,
13
- m as isMobileDevice,
14
- l as isPWA,
15
- e as isWeChatBrowser,
12
+ n as isIOS_OS,
13
+ s as isMacOS,
14
+ l as isMobileDevice,
15
+ p as isPWA,
16
+ a as isWeChatBrowser,
16
17
  t as isWeChatMiniProgram,
17
- d as isWindowsOS
18
+ m as isWindowsOS
18
19
  };
package/constant.js CHANGED
@@ -1,4 +1,26 @@
1
- import { MATCH_MEDIA_PREFERS_COLOR_SCHEME_DARK as R } from "./constant/index.js";
1
+ import * as o from "./constant/address.js";
2
+ import * as t from "./constant/chineseCharacters.js";
3
+ import * as a from "./constant/constellations.js";
4
+ import * as r from "./constant/domain.js";
5
+ import * as s from "./constant/identity.js";
6
+ import * as e from "./constant/keyboardCode.js";
7
+ import * as n from "./constant/licensePlate.js";
8
+ import * as m from "./constant/name.js";
9
+ import * as p from "./constant/platform.js";
10
+ import * as i from "./constant/protocol.js";
11
+ import * as c from "./constant/ui.js";
12
+ import { MATCH_MEDIA_PREFERS_COLOR_SCHEME_DARK as l } from "./constant/index.js";
2
13
  export {
3
- R as MATCH_MEDIA_PREFERS_COLOR_SCHEME_DARK
14
+ l as MATCH_MEDIA_PREFERS_COLOR_SCHEME_DARK,
15
+ t as chineseCharacters,
16
+ a as constellations,
17
+ o as date,
18
+ r as domain,
19
+ s as identity,
20
+ e as keyboardCode,
21
+ n as licensePlate,
22
+ m as name,
23
+ p as platform,
24
+ i as protocol,
25
+ c as ui
4
26
  };
@@ -17,7 +17,7 @@ function p(t) {
17
17
  const c = f(n), i = r.slice(0, -1);
18
18
  e.parameters[i] || (e.parameters[i] = c), e.parameters[r] = c;
19
19
  } catch (c) {
20
- console.debug(`RFC5987解码失败: ${n}`, c), e.parameters[r] = n;
20
+ console.debug(`RFC5987解码失败:${n}`, c), e.parameters[r] = n;
21
21
  }
22
22
  else !e.parameters[r] && !e.parameters[`${r}*`] && (e.parameters[r] = n);
23
23
  }
@@ -31,9 +31,9 @@ function f(t) {
31
31
  const n = decodeURIComponent(
32
32
  r.replace(/%(?![0-9A-Fa-f]{2})/g, "%25")
33
33
  );
34
- return s && !/^utf-?8$/i.test(s) && console.warn(`非UTF-8编码暂未转换: ${s}`), n;
34
+ return s && !/^utf-?8$/i.test(s) && console.warn(`非UTF-8编码暂未转换:${s}`), n;
35
35
  } catch (n) {
36
- return console.warn(`RFC5987解码失败: ${t}`, n), t;
36
+ return console.warn(`RFC5987解码失败:${t}`, n), t;
37
37
  }
38
38
  }
39
39
  function l(t) {
@@ -14,13 +14,13 @@ const f = {
14
14
  }, r = [
15
15
  { name: "年", seconds: 365 * 24 * 60 * 60, max: 1 / 0 },
16
16
  // 年没有上限
17
- { name: "个月", seconds: 30 * 24 * 60 * 60, max: 12 },
17
+ { name: "个月", seconds: 720 * 60 * 60, max: 12 },
18
18
  // 月份最大12
19
- { name: "周", seconds: 7 * 24 * 60 * 60, max: 4 },
19
+ { name: "周", seconds: 10080 * 60, max: 4 },
20
20
  // 周最大4(约1个月)
21
- { name: "天", seconds: 24 * 60 * 60, max: 7 },
21
+ { name: "天", seconds: 1440 * 60, max: 7 },
22
22
  // 日最大7(1周)
23
- { name: "小时", seconds: 60 * 60, max: 24 },
23
+ { name: "小时", seconds: 3600, max: 24 },
24
24
  // 小时最大24
25
25
  { name: "分钟", seconds: 60, max: 60 },
26
26
  // 分钟最大60
@@ -20,15 +20,13 @@ class h {
20
20
  s.push(e), this.#t.set(t, s);
21
21
  }
22
22
  off(t, e) {
23
- if (!t)
24
- return;
23
+ if (!t) return;
25
24
  if (!e) {
26
25
  this.#t.delete(t);
27
26
  return;
28
27
  }
29
28
  const s = this.#t.get(t);
30
- if (!s)
31
- return;
29
+ if (!s) return;
32
30
  if (s.length === 0) {
33
31
  this.#t.delete(t);
34
32
  return;
@@ -0,0 +1,81 @@
1
+ // Error Messages
2
+ export const INVALID_NUMBER: 'Invalid number';
3
+ export const INVALID_ROUND: 'Invalid rounding method';
4
+
5
+ // Standard Types
6
+ export const IEC: 'iec';
7
+ export const JEDEC: 'jedec';
8
+ export const SI: 'si';
9
+
10
+ // Unit Types
11
+ export const BIT: 'bit';
12
+ export const BITS: 'bits';
13
+ export const BYTE: 'byte';
14
+ export const BYTES: 'bytes';
15
+ export const SI_KBIT: 'kbit';
16
+ export const SI_KBYTE: 'kB';
17
+
18
+ // Output Format Types
19
+ export const ARRAY: 'array';
20
+ export const FUNCTION: 'function';
21
+ export const OBJECT: 'object';
22
+ export const STRING: 'string';
23
+
24
+ // Processing Constants
25
+ export const EXPONENT: 'exponent';
26
+ export const ROUND: 'round';
27
+
28
+ // Special Characters and Values
29
+ export const EMPTY: '';
30
+ export const PERIOD: '.';
31
+ export const S: 's';
32
+ export const SPACE: ' ';
33
+ export const ZERO: '0';
34
+
35
+ // Data Structures
36
+ export const STRINGS: {
37
+ symbol: {
38
+ iec: {
39
+ bits: [
40
+ 'bit',
41
+ 'Kibit',
42
+ 'Mibit',
43
+ 'Gibit',
44
+ 'Tibit',
45
+ 'Pibit',
46
+ 'Eibit',
47
+ 'Zibit',
48
+ 'Yibit',
49
+ ];
50
+ bytes: ['B', 'KiB', 'MiB', 'GiB', 'TiB', 'PiB', 'EiB', 'ZiB', 'YiB'];
51
+ };
52
+ jedec: {
53
+ bits: [
54
+ 'bit',
55
+ 'Kbit',
56
+ 'Mbit',
57
+ 'Gbit',
58
+ 'Tbit',
59
+ 'Pbit',
60
+ 'Ebit',
61
+ 'Zbit',
62
+ 'Ybit',
63
+ ];
64
+ bytes: ['B', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB'];
65
+ };
66
+ };
67
+ fullform: {
68
+ iec: ['', 'kibi', 'mebi', 'gibi', 'tebi', 'pebi', 'exbi', 'zebi', 'yobi'];
69
+ jedec: [
70
+ '',
71
+ 'kilo',
72
+ 'mega',
73
+ 'giga',
74
+ 'tera',
75
+ 'peta',
76
+ 'exa',
77
+ 'zetta',
78
+ 'yotta',
79
+ ];
80
+ };
81
+ };
@@ -0,0 +1,97 @@
1
+ /**
2
+ * Options interface for configuring filesize behavior
3
+ */
4
+ export interface FilesizeOptions {
5
+ /** If true, calculates bits instead of bytes */
6
+ bits?: boolean;
7
+ /** If true, pads decimal places to match round parameter */
8
+ pad?: boolean;
9
+ /** Number base (2 for binary, 10 for decimal, -1 for auto) */
10
+ base?: number;
11
+ /** Number of decimal places to round to */
12
+ round?: number;
13
+ /** Locale for number formatting, true for system locale */
14
+ locale?: string | boolean;
15
+ /** Additional options for locale formatting */
16
+ localeOptions?: Intl.NumberFormatOptions;
17
+ /** Custom decimal separator */
18
+ separator?: string;
19
+ /** String to separate value and unit */
20
+ spacer?: string;
21
+ /** Custom unit symbols */
22
+ symbols?: Record<string, string>;
23
+ /** Unit standard to use (SI, IEC, JEDEC) */
24
+ standard?: 'si' | 'iec' | 'jedec' | '';
25
+ /** Output format: "string", "array", "object", or "exponent" */
26
+ output?: 'string' | 'array' | 'object' | 'exponent';
27
+ /** If true, uses full unit names instead of abbreviations */
28
+ fullform?: boolean;
29
+ /** Custom full unit names */
30
+ fullforms?: string[];
31
+ /** Force specific exponent (-1 for auto) */
32
+ exponent?: number;
33
+ /** Math rounding method to use */
34
+ roundingMethod?: 'round' | 'floor' | 'ceil';
35
+ /** Number of significant digits (0 for auto) */
36
+ precision?: number;
37
+ }
38
+
39
+ /**
40
+ * Object format return type when output is "object"
41
+ */
42
+ export interface FilesizeObject {
43
+ /** The numeric value */
44
+ value: number | string;
45
+ /** The unit symbol */
46
+ symbol: string;
47
+ /** The exponent used in calculation */
48
+ exponent: number;
49
+ /** The original unit before symbol customization */
50
+ unit: string;
51
+ }
52
+
53
+ /**
54
+ * Array format return type when output is "array"
55
+ */
56
+ export type FilesizeArray = [number | string, string];
57
+
58
+ /**
59
+ * Return type based on output option
60
+ */
61
+ export type FilesizeReturn<T extends FilesizeOptions = {}> =
62
+ T['output'] extends 'object'
63
+ ? FilesizeObject
64
+ : T['output'] extends 'array'
65
+ ? FilesizeArray
66
+ : T['output'] extends 'exponent'
67
+ ? number
68
+ : string;
69
+
70
+ /**
71
+ * Converts a file size in bytes to a human-readable string with appropriate units
72
+ * @param arg - The file size in bytes to convert
73
+ * @param options - Configuration options for formatting
74
+ * @returns Formatted file size based on output option
75
+ * @throws {TypeError} When arg is not a valid number or roundingMethod is invalid
76
+ * @example
77
+ * filesize(1024) // "1 KB"
78
+ * filesize(1024, {bits: true}) // "8 Kb"
79
+ * filesize(1024, {output: "object"}) // {value: 1, symbol: "KB", exponent: 1, unit: "KB"}
80
+ */
81
+ export function filesize<T extends FilesizeOptions = {}>(
82
+ arg: number | string | bigint,
83
+ options?: T,
84
+ ): FilesizeReturn<T>;
85
+
86
+ /**
87
+ * Creates a partially applied version of filesize with preset options
88
+ * @param options - Default options to apply to the returned function
89
+ * @returns A function that takes a file size and returns formatted output
90
+ * @example
91
+ * const formatBytes = partial({round: 1, standard: "iec"});
92
+ * formatBytes(1024) // "1.0 KiB"
93
+ * formatBytes(2048) // "2.0 KiB"
94
+ */
95
+ export function partial<T extends FilesizeOptions = {}>(
96
+ options?: T,
97
+ ): (arg: number | string | bigint) => FilesizeReturn<T>;
package/index.js CHANGED
@@ -1,62 +1,68 @@
1
- import * as o from "./date/index.js";
2
- import * as e from "./is/index.js";
3
- import * as r from "./math/index.js";
4
- import * as t from "./tree/index.js";
5
- import * as a from "./turbo-stream/index.js";
6
- import * as s from "./ui-color/index.js";
7
- import * as i from "./url-toolkit/index.js";
8
- import { default as l } from "./case-name/index.js";
9
- import { default as u } from "./class-name/index.js";
10
- import { default as C } from "./clipboard-copy/index.js";
11
- import { default as b, getContentDispositionFromHeader as h, getContentDispositionParametersFilenameFromHeader as T, getContentDispositionParametersFromHeader as g } from "./content-disposition/index.js";
12
- import { splitCookiesString as y } from "./cookie/index.js";
13
- import { default as D } from "./decimal/decimal.js";
14
- import { default as S } from "./event-emitter/index.js";
15
- import { fileToURL as H } from "./file/fileToURL.js";
16
- import { saveAs as N } from "./file/saveAs.js";
17
- import * as m from "./filesize/src/constants.js";
18
- import { filesize as j, partial as A } from "./filesize/src/filesize.js";
19
- import { default as K } from "./invariant/index.js";
20
- import * as p from "./lunar/lib/index.js";
21
- import { default as U } from "./md5/index.js";
22
- import { default as $ } from "./normalize-wheel/index.js";
23
- import { default as w } from "./number-to-chinese/index.js";
24
- import { default as G } from "./nzh/nzh.js";
25
- import { default as J } from "./object-keys-sort/index.js";
26
- import { default as O } from "./screenfull/index.js";
27
- import { TinyColor as V } from "./tinycolor/src/index.js";
28
- import * as f from "./cookie/src/index.js";
1
+ import * as o from "./constant/index.js";
2
+ import * as e from "./date/index.js";
3
+ import * as r from "./is/index.js";
4
+ import * as t from "./math/index.js";
5
+ import * as a from "./snapdom/index.js";
6
+ import * as s from "./tree/index.js";
7
+ import * as i from "./turbo-stream/index.js";
8
+ import * as m from "./ui-color/index.js";
9
+ import * as p from "./url-toolkit/index.js";
10
+ import { default as u } from "./case-name/index.js";
11
+ import { default as C } from "./class-name/index.js";
12
+ import { default as b } from "./clipboard-copy/index.js";
13
+ import { default as k, getContentDispositionFromHeader as T, getContentDispositionParametersFilenameFromHeader as g, getContentDispositionParametersFromHeader as y } from "./content-disposition/index.js";
14
+ import { splitCookiesString as D } from "./cookie/index.js";
15
+ import { default as S } from "./decimal/decimal.js";
16
+ import { default as H } from "./event-emitter/index.js";
17
+ import { fileToURL as L } from "./file/fileToURL.js";
18
+ import { saveAs as P } from "./file/saveAs.js";
19
+ import * as f from "./filesize/src/constants.js";
20
+ import { filesize as E, partial as K } from "./filesize/src/filesize.js";
21
+ import { default as U } from "./invariant/index.js";
22
+ import { default as $ } from "./js-cookie/src/api.js";
23
+ import * as n from "./lunar/lib/index.js";
24
+ import { default as w } from "./md5/index.js";
25
+ import { default as G } from "./normalize-wheel/index.js";
26
+ import { default as J } from "./number-to-chinese/index.js";
27
+ import { default as O } from "./nzh/nzh.js";
28
+ import { default as V } from "./object-keys-sort/index.js";
29
+ import { default as Y } from "./screenfull/index.js";
30
+ import { TinyColor as oo } from "./tinycolor/src/index.js";
31
+ import * as x from "./cookie/src/index.js";
29
32
  export {
30
- p as Lunar,
31
- l as caseName,
32
- u as className,
33
- C as clipboardCopy,
34
- b as contentDisposition,
35
- f as cookie,
36
- o as date,
37
- D as decimal,
38
- S as eventEmitter,
39
- H as fileToURL,
40
- j as filesize,
41
- m as filesizeConstants,
42
- h as getContentDispositionFromHeader,
43
- T as getContentDispositionParametersFilenameFromHeader,
44
- g as getContentDispositionParametersFromHeader,
45
- K as invariant,
46
- e as is,
47
- r as math,
48
- U as md5,
49
- $ as normalizeWheel,
50
- w as numberToChinese,
51
- G as nzh,
52
- J as objectKeysSort,
53
- A as partial,
54
- N as saveAs,
55
- O as screenfull,
56
- y as splitCookiesString,
57
- V as tinycolor,
58
- t as tree,
59
- a as turboStream,
60
- s as uiColor,
61
- i as urlToolkit
33
+ n as Lunar,
34
+ u as caseName,
35
+ C as className,
36
+ b as clipboardCopy,
37
+ o as constant,
38
+ k as contentDisposition,
39
+ x as cookie,
40
+ e as date,
41
+ S as decimal,
42
+ H as eventEmitter,
43
+ L as fileToURL,
44
+ E as filesize,
45
+ f as filesizeConstants,
46
+ T as getContentDispositionFromHeader,
47
+ g as getContentDispositionParametersFilenameFromHeader,
48
+ y as getContentDispositionParametersFromHeader,
49
+ U as invariant,
50
+ r as is,
51
+ $ as jsCookie,
52
+ t as math,
53
+ w as md5,
54
+ G as normalizeWheel,
55
+ J as numberToChinese,
56
+ O as nzh,
57
+ V as objectKeysSort,
58
+ K as partial,
59
+ P as saveAs,
60
+ Y as screenfull,
61
+ a as snapdom,
62
+ D as splitCookiesString,
63
+ oo as tinycolor,
64
+ s as tree,
65
+ i as turboStream,
66
+ m as uiColor,
67
+ p as urlToolkit
62
68
  };
@@ -0,0 +1,116 @@
1
+ declare namespace Cookies {
2
+ interface CookieAttributes {
3
+ /**
4
+ * Define when the cookie will be removed. Value can be a Number
5
+ * which will be interpreted as days from time of creation or a
6
+ * Date instance. If omitted, the cookie becomes a session cookie.
7
+ */
8
+ expires?: number | Date | undefined;
9
+
10
+ /**
11
+ * Define the path where the cookie is available. Defaults to '/'
12
+ */
13
+ path?: string | undefined;
14
+
15
+ /**
16
+ * Define the domain where the cookie is available. Defaults to
17
+ * the domain of the page where the cookie was created.
18
+ */
19
+ domain?: string | undefined;
20
+
21
+ /**
22
+ * A Boolean indicating if the cookie transmission requires a
23
+ * secure protocol (https). Defaults to false.
24
+ */
25
+ secure?: boolean | undefined;
26
+
27
+ /**
28
+ * Asserts that a cookie must not be sent with cross-origin requests,
29
+ * providing some protection against cross-site request forgery
30
+ * attacks (CSRF)
31
+ */
32
+ sameSite?:
33
+ | 'strict'
34
+ | 'Strict'
35
+ | 'lax'
36
+ | 'Lax'
37
+ | 'none'
38
+ | 'None'
39
+ | undefined;
40
+
41
+ /**
42
+ * An attribute which will be serialized, conformably to RFC 6265
43
+ * section 5.2.
44
+ */
45
+ [property: string]: any;
46
+ }
47
+
48
+ interface CookiesStatic<T = string> {
49
+ readonly attributes: CookieAttributes;
50
+ readonly converter: Required<Converter<string>>;
51
+ /**
52
+ * Create a cookie
53
+ */
54
+ set(
55
+ name: string,
56
+ value: string | T,
57
+ options?: CookieAttributes,
58
+ ): string | undefined;
59
+
60
+ /**
61
+ * Read cookie
62
+ */
63
+ get(name: string): string | T | undefined;
64
+
65
+ /**
66
+ * Read all available cookies
67
+ */
68
+ get(): { [key: string]: string };
69
+
70
+ /**
71
+ * Delete cookie
72
+ */
73
+ remove(name: string, options?: CookieAttributes): void;
74
+
75
+ /**
76
+ * Cookie attribute defaults can be set globally by creating an
77
+ * instance of the api via withAttributes(), or individually for
78
+ * each call to Cookies.set(...) by passing a plain object as the
79
+ * last argument. Per-call attributes override the default attributes.
80
+ */
81
+ withAttributes(attributes: CookieAttributes): CookiesStatic<T>;
82
+
83
+ /**
84
+ * Create a new instance of the api that overrides the default
85
+ * decoding implementation. All methods that rely in a proper
86
+ * decoding to work, such as Cookies.remove() and Cookies.get(),
87
+ * will run the converter first for each cookie. The returned
88
+ * string will be used as the cookie value.
89
+ */
90
+ withConverter<TConv = string>(
91
+ converter: Converter<TConv>,
92
+ ): CookiesStatic<TConv>;
93
+ }
94
+
95
+ interface Converter<TConv> {
96
+ write?: CookieWriteConverter<TConv> | undefined;
97
+ read?: CookieReadConverter<TConv> | undefined;
98
+ }
99
+
100
+ type CookieWriteConverter<T> = (value: string | T, name: string) => string;
101
+ type CookieReadConverter<T> = (value: string, name: string) => string | T;
102
+ }
103
+
104
+ declare const Cookies: Cookies.CookiesStatic & {
105
+ /**
106
+ * If there is any danger of a conflict with the namespace Cookies,
107
+ * the noConflict method will allow you to define a new namespace
108
+ * and preserve the original one. This is especially useful when
109
+ * running the script on third party sites e.g. as part of a widget
110
+ * or SDK. Note: The noConflict method is not necessary when using
111
+ * AMD or CommonJS, thus it is not exposed in those environments.
112
+ */
113
+ noConflict?(): Cookies.CookiesStatic;
114
+ };
115
+
116
+ export default Cookies;
@@ -0,0 +1,4 @@
1
+ import { default as o } from "./src/api.js";
2
+ export {
3
+ o as default
4
+ };
@@ -0,0 +1,56 @@
1
+ import t from "./assign.js";
2
+ import l from "./converter.js";
3
+ function p(f, s) {
4
+ function u(n, i, e) {
5
+ if (!(typeof document > "u")) {
6
+ e = t({}, s, e), typeof e.expires == "number" && (e.expires = new Date(Date.now() + e.expires * 864e5)), e.expires && (e.expires = e.expires.toUTCString()), n = encodeURIComponent(n).replace(/%(2[346B]|5E|60|7C)/g, decodeURIComponent).replace(/[()]/g, escape);
7
+ var r = "";
8
+ for (var o in e)
9
+ e[o] && (r += "; " + o, e[o] !== !0 && (r += "=" + e[o].split(";")[0]));
10
+ return document.cookie = n + "=" + f.write(i, n) + r;
11
+ }
12
+ }
13
+ function d(n) {
14
+ if (!(typeof document > "u" || arguments.length && !n)) {
15
+ for (var i = document.cookie ? document.cookie.split("; ") : [], e = {}, r = 0; r < i.length; r++) {
16
+ var o = i[r].split("="), v = o.slice(1).join("=");
17
+ try {
18
+ var c = decodeURIComponent(o[0]);
19
+ if (c in e || (e[c] = f.read(v, c)), n === c)
20
+ break;
21
+ } catch {
22
+ }
23
+ }
24
+ return n ? e[n] : e;
25
+ }
26
+ }
27
+ return Object.create(
28
+ {
29
+ set: u,
30
+ get: d,
31
+ remove: function(n, i) {
32
+ u(
33
+ n,
34
+ "",
35
+ t({}, i, {
36
+ expires: -1
37
+ })
38
+ );
39
+ },
40
+ withAttributes: function(n) {
41
+ return p(this.converter, t({}, this.attributes, n));
42
+ },
43
+ withConverter: function(n) {
44
+ return p(t({}, this.converter, n), this.attributes);
45
+ }
46
+ },
47
+ {
48
+ attributes: { value: Object.freeze(s) },
49
+ converter: { value: Object.freeze(f) }
50
+ }
51
+ );
52
+ }
53
+ const x = p(l, { path: "/" });
54
+ export {
55
+ x as default
56
+ };
@@ -0,0 +1,11 @@
1
+ function f(r) {
2
+ for (var n = 1; n < arguments.length; n++) {
3
+ var a = arguments[n];
4
+ for (var t in a)
5
+ r[t] = a[t];
6
+ }
7
+ return r;
8
+ }
9
+ export {
10
+ f as default
11
+ };