@unicom-cloud/utils 0.1.10 → 0.1.11

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 (127) hide show
  1. package/caseName.js +11 -0
  2. package/className.js +5 -0
  3. package/clipboardCopy.js +6 -0
  4. package/constant.js +4 -0
  5. package/contentDisposition.js +7 -0
  6. package/convert-time/index.js +61 -0
  7. package/convertTime.js +4 -0
  8. package/cookie.js +7 -0
  9. package/dayjs.js +5 -0
  10. package/decimal.js +5 -0
  11. package/eventEmitter.js +4 -0
  12. package/file.js +6 -0
  13. package/filesize.js +8 -0
  14. package/index.js +38 -30
  15. package/invariant.js +4 -0
  16. package/is.js +92 -0
  17. package/lunar-converter/index.js +641 -0
  18. package/lunarConverter.js +4 -0
  19. package/math.js +9 -0
  20. package/md5.js +4 -0
  21. package/mock.js +8 -0
  22. package/normalizeWheel.js +6 -0
  23. package/number-to-chinese/index.js +72 -0
  24. package/numberToChinese.js +4 -0
  25. package/nzh.js +4 -0
  26. package/object-keys-sort/index.js +7 -0
  27. package/objectKeysSort.js +2 -5
  28. package/package.json +1 -1
  29. package/random.js +15 -0
  30. package/screenfull.js +4 -0
  31. package/search-tree/index.js +54 -0
  32. package/searchTree.js +4 -0
  33. package/snapdom.js +6 -0
  34. package/tree.js +11 -0
  35. package/turboStream.js +6 -0
  36. package/types/case-name/index.d.ts +11 -0
  37. package/types/class-name/index.d.ts +2 -0
  38. package/types/clipboard-copy/index.d.ts +2 -0
  39. package/types/constant/address.d.ts +14 -0
  40. package/types/constant/chineseCharacters.d.ts +2 -0
  41. package/types/constant/constellations.d.ts +2 -0
  42. package/types/constant/domain.d.ts +2 -0
  43. package/types/constant/identity.d.ts +2 -0
  44. package/types/constant/index.d.ts +1 -0
  45. package/types/constant/keyboardCode.d.ts +158 -0
  46. package/types/constant/licensePlate.d.ts +2 -0
  47. package/types/constant/name.d.ts +4 -0
  48. package/types/constant/platform.d.ts +11 -0
  49. package/types/constant/protocol.d.ts +2 -0
  50. package/types/constant/ui.d.ts +14 -0
  51. package/types/content-disposition/index.d.ts +10 -0
  52. package/types/convert-time/index.d.ts +32 -0
  53. package/types/cookie/index.d.ts +4 -0
  54. package/types/cookie/src/index.d.ts +114 -0
  55. package/types/dayjs/index.d.ts +1 -0
  56. package/types/decimal/decimal.d.ts +4 -0
  57. package/types/decimal/index.d.ts +1 -0
  58. package/types/event-emitter/index.d.ts +17 -0
  59. package/types/file/fileToURL.d.ts +2 -0
  60. package/types/file/index.d.ts +3 -0
  61. package/types/file/saveAs.d.ts +2 -0
  62. package/types/filesize/index.d.ts +2 -0
  63. package/types/filesize/src/constants.d.ts +42 -0
  64. package/types/filesize/src/filesize.d.ts +47 -0
  65. package/types/index.d.ts +24 -0
  66. package/types/invariant/index.d.ts +2 -0
  67. package/types/is/index.d.ts +53 -0
  68. package/types/lunar-converter/index.d.ts +113 -0
  69. package/types/math/index.d.ts +11 -0
  70. package/types/md5/index.d.ts +2 -0
  71. package/types/mock/MockWebSocket.d.ts +17 -0
  72. package/types/mock/MockXMLHttpRequest.d.ts +17 -0
  73. package/types/mock/index.d.ts +2 -0
  74. package/types/normalize-wheel/ExecutionEnvironment.d.ts +9 -0
  75. package/types/normalize-wheel/UserAgent_DEPRECATED.d.ts +86 -0
  76. package/types/normalize-wheel/index.d.ts +115 -0
  77. package/types/normalize-wheel/isEventSupported.d.ts +16 -0
  78. package/types/number-to-chinese/index.d.ts +11 -0
  79. package/types/nzh/cn.d.ts +8 -0
  80. package/types/nzh/hk.d.ts +8 -0
  81. package/types/nzh/index.d.ts +1 -0
  82. package/types/nzh/nzh.d.ts +36 -0
  83. package/types/nzh/src/autoGet.d.ts +8 -0
  84. package/types/nzh/src/index.d.ts +34 -0
  85. package/types/nzh/src/langs/cn_b.d.ts +10 -0
  86. package/types/nzh/src/langs/cn_s.d.ts +7 -0
  87. package/types/nzh/src/langs/hk_b.d.ts +10 -0
  88. package/types/nzh/src/langs/hk_s.d.ts +7 -0
  89. package/types/nzh/src/utils.d.ts +65 -0
  90. package/types/object-keys-sort/index.d.ts +4 -0
  91. package/types/random/address.d.ts +8 -0
  92. package/types/random/constellation.d.ts +2 -0
  93. package/types/random/image.d.ts +5 -0
  94. package/types/random/index.d.ts +40 -0
  95. package/types/random/licensePlate.d.ts +2 -0
  96. package/types/random/name.d.ts +9 -0
  97. package/types/random/number.d.ts +6 -0
  98. package/types/random/text.d.ts +13 -0
  99. package/types/random/time.d.ts +2 -0
  100. package/types/random/web.d.ts +11 -0
  101. package/types/screenfull/index.d.ts +10 -0
  102. package/types/search-tree/index.d.ts +20 -0
  103. package/types/snapdom/index.d.ts +1 -0
  104. package/types/snapdom/src/api/preCache.d.ts +8 -0
  105. package/types/snapdom/src/api/snapdom.d.ts +26 -0
  106. package/types/snapdom/src/core/cache.d.ts +11 -0
  107. package/types/snapdom/src/core/capture.d.ts +17 -0
  108. package/types/snapdom/src/core/clone.d.ts +11 -0
  109. package/types/snapdom/src/core/prepare.d.ts +8 -0
  110. package/types/snapdom/src/index.browser.d.ts +1 -0
  111. package/types/snapdom/src/index.d.ts +2 -0
  112. package/types/snapdom/src/modules/background.d.ts +10 -0
  113. package/types/snapdom/src/modules/fonts.d.ts +25 -0
  114. package/types/snapdom/src/modules/images.d.ts +8 -0
  115. package/types/snapdom/src/modules/pseudo.d.ts +12 -0
  116. package/types/snapdom/src/modules/styles.d.ts +10 -0
  117. package/types/snapdom/src/utils/cssTools.d.ts +38 -0
  118. package/types/snapdom/src/utils/helpers.d.ts +71 -0
  119. package/types/tree/index.d.ts +8 -0
  120. package/types/turbo-stream/index.d.ts +1 -0
  121. package/types/turbo-stream/src/decode.d.ts +7 -0
  122. package/types/turbo-stream/src/encode.d.ts +27 -0
  123. package/types/turbo-stream/src/shared.d.ts +107 -0
  124. package/types/turbo-stream/src/turbo-stream.d.ts +4 -0
  125. package/types/url-toolkit/index.d.ts +2 -0
  126. package/types/url-toolkit/src/url-toolkit.d.ts +18 -0
  127. package/urlToolkit.js +8 -0
@@ -0,0 +1,36 @@
1
+ export default Nzh;
2
+ declare function Nzh(lang: any): void;
3
+ declare class Nzh {
4
+ constructor(lang: any);
5
+ lang: any;
6
+ encode: (...args: any[]) => string;
7
+ decode: (...args: any[]) => string | number;
8
+ toMoney: (...args: any[]) => string;
9
+ }
10
+ declare namespace Nzh {
11
+ export { langs };
12
+ export let cn: {
13
+ encodeS: (num: any, options: any) => string;
14
+ encodeB: (num: any, options: any) => string;
15
+ decodeS: (...args: any[]) => string | number;
16
+ decodeB: (...args: any[]) => string | number;
17
+ toMoney: (num: any, options: any) => string;
18
+ };
19
+ export let hk: {
20
+ encodeS: (num: any, options: any) => string;
21
+ encodeB: (num: any, options: any) => string;
22
+ decodeS: (...args: any[]) => string | number;
23
+ decodeB: (...args: any[]) => string | number;
24
+ toMoney: (num: any, options: any) => string;
25
+ };
26
+ }
27
+ declare namespace langs {
28
+ export { cn_s as s };
29
+ export { cn_b as b };
30
+ export { hk_s };
31
+ export { hk_b };
32
+ }
33
+ import cn_s from './src/langs/cn_s';
34
+ import cn_b from './src/langs/cn_b';
35
+ import hk_s from './src/langs/hk_s';
36
+ import hk_b from './src/langs/hk_b';
@@ -0,0 +1,8 @@
1
+ export function getNzhObjByLang(lang_s: any, lang_b: any): {
2
+ encodeS: (num: any, options: any) => string;
3
+ encodeB: (num: any, options: any) => string;
4
+ decodeS: (...args: any[]) => string | number;
5
+ decodeB: (...args: any[]) => string | number;
6
+ toMoney: (num: any, options: any) => string;
7
+ };
8
+ export default getNzhObjByLang;
@@ -0,0 +1,34 @@
1
+ /**
2
+ * 阿拉伯数字转中文数字
3
+ *
4
+ * @param {String} num 阿拉伯数字/字符串 , 科学记数法字符串
5
+ * @param {Object} opration 转换配置
6
+ * {
7
+ * ww: {万万化单位 | false}
8
+ * tenMin: {十的口语化 | false}
9
+ * }
10
+ * @returns String
11
+ */
12
+ export function CL(num: string, options: any): string;
13
+ /**
14
+ * 中文数字转阿拉伯数字
15
+ *
16
+ * @param {string} cnnumb 中文数字字符串
17
+ * @returns Number
18
+ */
19
+ export function unCL(cnnumb: string, options: any): string | number;
20
+ /**
21
+ * 阿拉伯数字转金额
22
+ *
23
+ * @param {String} num 阿拉伯数字/字符串 , 科学记数法字符串
24
+ * @param {Object} options 转换配置
25
+ * {
26
+ * ww:{万万化开关 | true},
27
+ * unOmitYuan: {整数为0时不省略元| false},
28
+ * complete:{完整金额格式 | false},
29
+ * outSymbol:{是否输出金额符号 | true}
30
+ * forceZheng:{以转换结果加“整” | false}
31
+ * }
32
+ * @returns String
33
+ */
34
+ export function toMoney(num: string, options: Object): string;
@@ -0,0 +1,10 @@
1
+ export default cn_b;
2
+ declare namespace cn_b {
3
+ let ch: string;
4
+ let ch_u: string;
5
+ let ch_f: string;
6
+ let ch_d: string;
7
+ let m_t: string;
8
+ let m_z: string;
9
+ let m_u: string;
10
+ }
@@ -0,0 +1,7 @@
1
+ export default cn_s;
2
+ declare namespace cn_s {
3
+ let ch: string;
4
+ let ch_u: string;
5
+ let ch_f: string;
6
+ let ch_d: string;
7
+ }
@@ -0,0 +1,10 @@
1
+ export default hk_b;
2
+ declare namespace hk_b {
3
+ let ch: string;
4
+ let ch_u: string;
5
+ let ch_f: string;
6
+ let ch_d: string;
7
+ let m_t: string;
8
+ let m_z: string;
9
+ let m_u: string;
10
+ }
@@ -0,0 +1,7 @@
1
+ export default hk_s;
2
+ declare namespace hk_s {
3
+ let ch: string;
4
+ let ch_u: string;
5
+ let ch_f: string;
6
+ let ch_d: string;
7
+ }
@@ -0,0 +1,65 @@
1
+ /**
2
+ * 科学计数法转十进制
3
+ *
4
+ * @param {string} num 科学记数法字符串
5
+ * @returns string
6
+ */
7
+ export function e2ten(num: string): string;
8
+ /**
9
+ * 分析数字字符串
10
+ *
11
+ * @param {string} num NumberString
12
+ * @returns object
13
+ */
14
+ export function getNumbResult(num: string): {
15
+ int: string;
16
+ decimal: string;
17
+ minus: boolean;
18
+ num: string;
19
+ } | undefined;
20
+ /**
21
+ * 数组归一 (按索引覆盖合并数组,并清空被合并的数组)
22
+ *
23
+ * @param {array} baseArray 基础数组
24
+ * @param {...array} array1
25
+ * @returns array
26
+ */
27
+ export function centerArray(baseArray: array, ...args: array[]): array;
28
+ /**
29
+ * 检查对像属性 (非原型链)
30
+ *
31
+ * @param {object} obj
32
+ * @param {string} key
33
+ * @returns
34
+ */
35
+ export function hasAttr(obj: object, key: string): boolean;
36
+ /**
37
+ * 扩展对像(浅复制)
38
+ *
39
+ * @param {object} obj
40
+ * @param {object} obj1
41
+ * @returns
42
+ */
43
+ export function extend(obj: object, ...args: any[]): any;
44
+ /**
45
+ * 获取真实数位
46
+ *
47
+ * @param {number} index 中文单位的索引
48
+ */
49
+ export function getDigit(index: number): number;
50
+ /**
51
+ * 往数组头部插入0
52
+ *
53
+ * @param {array} arr
54
+ * @param {number} n
55
+ */
56
+ export function unshiftZero(arr: array, n: number): void;
57
+ /**
58
+ * 清理多余"零"
59
+ *
60
+ * @param {any} str
61
+ * @param {any} zero "零"字符
62
+ * @param {any} type 清理模式 ^ - 开头, $ - 结尾, nto1 - 多个连续变一个
63
+ * @returns
64
+ */
65
+ export function clearZero(str: any, zero: any, type: any): any;
@@ -0,0 +1,4 @@
1
+ export default objectKeysSort;
2
+ declare function objectKeysSort(params: any): {
3
+ [k: string]: any;
4
+ };
@@ -0,0 +1,8 @@
1
+ export default address;
2
+ declare namespace address {
3
+ function region(): string | undefined;
4
+ function province(): string;
5
+ function city(prefix: any): string;
6
+ function county(prefix: any): string;
7
+ function zip(len: any): string;
8
+ }
@@ -0,0 +1,2 @@
1
+ export default constellation;
2
+ declare function constellation(): string | undefined;
@@ -0,0 +1,5 @@
1
+ export function generateImageDataURL(params?: {}): string;
2
+ export default image;
3
+ declare namespace image {
4
+ export { generateImageDataURL };
5
+ }
@@ -0,0 +1,40 @@
1
+ declare namespace _default {
2
+ export { number };
3
+ export let natural: (min?: number, max?: number) => number;
4
+ export let integer: (min?: number, max?: number) => number;
5
+ export let float: (min: any, max: any) => number;
6
+ export function boolean(): boolean;
7
+ export function sex(): string;
8
+ export { sample as pick };
9
+ export { text };
10
+ export let ctitle: (min: any, max: any) => string;
11
+ export let cparagraph: (min: any, max: any) => string;
12
+ export let csentence: (min: any, max: any) => string;
13
+ export let cword: (pool: any, min: any, max: any, ...args: any[]) => string;
14
+ export { name };
15
+ export let cname: () => string;
16
+ export { web };
17
+ export let phone: () => string;
18
+ export { address };
19
+ export function county(p: any): string;
20
+ export function company(): string;
21
+ export function project(): string;
22
+ export { time };
23
+ export { constellation };
24
+ export { licensePlate };
25
+ export function uuid(): string;
26
+ export function id(): number;
27
+ export function increment(step: any): number;
28
+ export { image };
29
+ }
30
+ export default _default;
31
+ import number from './number';
32
+ import sample from 'lodash/sample';
33
+ import text from './text';
34
+ import name from './name';
35
+ import web from './web';
36
+ import address from './address';
37
+ import time from './time';
38
+ import constellation from './constellation';
39
+ import licensePlate from './licensePlate';
40
+ import image from './image';
@@ -0,0 +1,2 @@
1
+ export default licensePlate;
2
+ declare function licensePlate(): string;
@@ -0,0 +1,9 @@
1
+ export default name;
2
+ declare namespace name {
3
+ function first(): string | undefined;
4
+ function last(): string | undefined;
5
+ function name(middle: any): string;
6
+ function cfirst(): string | undefined;
7
+ function clast(): string | undefined;
8
+ function cname(): string;
9
+ }
@@ -0,0 +1,6 @@
1
+ export default number;
2
+ declare namespace number {
3
+ function natural(min?: number, max?: number): number;
4
+ function integer(min?: number, max?: number): number;
5
+ function float(min: any, max: any): number;
6
+ }
@@ -0,0 +1,13 @@
1
+ export default text;
2
+ declare namespace text {
3
+ function paragraph(min: any, max: any): string;
4
+ function cparagraph(min: any, max: any): string;
5
+ function sentence(min: any, max: any): string;
6
+ function csentence(min: any, max: any): string;
7
+ function word(min: any, max: any): string;
8
+ function cword(pool: any, min: any, max: any, ...args: any[]): string;
9
+ function title(min: any, max: any): string;
10
+ function ctitle(min: any, max: any): string;
11
+ function character(pool: any): any;
12
+ function string(pool: any, min: any, max: any, ...args: any[]): string;
13
+ }
@@ -0,0 +1,2 @@
1
+ export default time;
2
+ declare function time(a: any, b: any): string;
@@ -0,0 +1,11 @@
1
+ export default web;
2
+ declare namespace web {
3
+ function url(v: any, host: any): string;
4
+ function protocol(): string | undefined;
5
+ function domain(v: any): string;
6
+ function tld(): string | undefined;
7
+ function email(domain: any): string;
8
+ function phone(): string;
9
+ function ip(): string;
10
+ function port(): number;
11
+ }
@@ -0,0 +1,10 @@
1
+ export default screenfull;
2
+ declare namespace screenfull {
3
+ export function request(element: HTMLElement | undefined, options: any): Promise<any>;
4
+ export function exit(): Promise<any>;
5
+ export function toggle(element: any, options: any): any;
6
+ export function on(event: any, callback: any): void;
7
+ export function off(event: any, callback: any): void;
8
+ export { nativeAPI as raw };
9
+ }
10
+ declare const nativeAPI: {};
@@ -0,0 +1,20 @@
1
+ type Primitive = string | number | boolean | symbol | null | undefined;
2
+ type ConditionValue<T = unknown> = Primitive | ((value: T) => boolean) | RegExp;
3
+ interface SearchOptions {
4
+ strategy?: 'BFS' | 'DFS';
5
+ childrenKey?: string;
6
+ strict?: boolean;
7
+ }
8
+ interface TreeNode {
9
+ [key: string]: unknown;
10
+ children?: TreeNode[];
11
+ }
12
+ /**
13
+ * 非递归树搜索算法
14
+ * @param {TreeNode[]} treeData - 树数据
15
+ * @param {Record<string, ConditionValue>} searchCondition - 搜索条件对象
16
+ * @param {SearchOptions} [options={}] - 配置选项
17
+ * @returns {TreeNode | null} 找到的节点或null
18
+ */
19
+ declare function searchTree(treeData: TreeNode[], searchCondition: Record<string, ConditionValue>, options?: SearchOptions): TreeNode | null;
20
+ export default searchTree;
@@ -0,0 +1 @@
1
+ export * from "./src";
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Preloads images, background images, and optionally fonts into cache before DOM capture.
3
+ *
4
+ * @param {Document|Element} [root=document] - The root node to search for resources
5
+ * @param {Object} [options={}] - Pre-caching options
6
+ * @returns {Promise<void>} Resolves when all resources are pre-cached
7
+ */
8
+ export function preCache(root?: Document | Element, options?: Object): Promise<void>;
@@ -0,0 +1,26 @@
1
+ /**
2
+ * Main entry point: captures a DOM element and returns an object with export methods.
3
+ *
4
+ * @param {Element} element - DOM element to capture
5
+ * @param {Object} [options={}] - Capture options
6
+ * @returns {Promise<Object>} Object with export methods (toRaw, toImg, toCanvas, etc.)
7
+ */
8
+ export function snapdom(element: Element, options?: Object): Promise<Object>;
9
+ export namespace snapdom {
10
+ /**
11
+ * Captures a DOM element and returns an object with export methods (internal use).
12
+ *
13
+ * @param {Element} el - DOM element to capture
14
+ * @param {Object} [options={}] - Capture options
15
+ * @returns {Promise<Object>} Object with export methods
16
+ */
17
+ function capture(el: Element, options?: Object): Promise<Object>;
18
+ function toRaw(el: any, options: any): Promise<any>;
19
+ function toImg(el: any, options: any): Promise<any>;
20
+ function toCanvas(el: any, options: any): Promise<any>;
21
+ function toBlob(el: any, options: any): Promise<any>;
22
+ function toPng(el: any, options: any): Promise<any>;
23
+ function toJpg(el: any, options: any): Promise<any>;
24
+ function toWebp(el: any, options: any): Promise<any>;
25
+ function download(el: any, options?: {}): Promise<any>;
26
+ }
@@ -0,0 +1,11 @@
1
+ /**
2
+ * Caches for images, backgrounds, resources, and computed styles used during DOM capture.
3
+ * @module cache
4
+ */
5
+ export const imageCache: Map<any, any>;
6
+ export const bgCache: Map<any, any>;
7
+ export const resourceCache: Map<any, any>;
8
+ export const defaultStylesCache: Map<any, any>;
9
+ export const baseCSSCache: Map<any, any>;
10
+ export const computedStyleCache: WeakMap<WeakKey, any>;
11
+ export const processedFontURLs: Set<any>;
@@ -0,0 +1,17 @@
1
+ /**
2
+ * Captures an HTML element as an SVG data URL, inlining styles, images, backgrounds, and optionally fonts.
3
+ *
4
+ * @param {Element} element - DOM element to capture
5
+ * @param {Object} [options={}] - Capture options
6
+ * @param {boolean} [options.compress=true] - Whether to compress style keys
7
+ * @param {boolean} [options.embedFonts=false] - Whether to embed custom fonts
8
+ * @param {boolean} [options.fast=true] - Whether to skip idle delay for faster results
9
+ * @param {number} [options.scale=1] - Output scale multiplier
10
+ * @returns {Promise<string>} Promise that resolves to an SVG data URL
11
+ */
12
+ export function captureDOM(element: Element, options?: {
13
+ compress?: boolean | undefined;
14
+ embedFonts?: boolean | undefined;
15
+ fast?: boolean | undefined;
16
+ scale?: number | undefined;
17
+ }): Promise<string>;
@@ -0,0 +1,11 @@
1
+ /**
2
+ * Creates a deep clone of a DOM node, including styles, shadow DOM, and special handling for excluded/placeholder/canvas nodes.
3
+ *
4
+ * @param {Node} node - Node to clone
5
+ * @param {Map} styleMap - Map to store element-to-style-key mappings
6
+ * @param {WeakMap} styleCache - Cache of computed styles
7
+ * @param {WeakMap} nodeMap - Map to track original-to-clone node relationships
8
+ * @param {boolean} compress - Whether to compress style keys
9
+ * @returns {Node|null} Cloned node with styles and shadow DOM content, or null for empty text nodes
10
+ */
11
+ export function deepClone(node: Node, styleMap: Map<any, any>, styleCache: WeakMap<any, any>, nodeMap: WeakMap<any, any>, compress: boolean): Node | null;
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Prepares a clone of an element for capture, inlining pseudo-elements and generating CSS classes.
3
+ *
4
+ * @param {Element} element - Element to clone
5
+ * @param {boolean} [compress=false] - Whether to compress style keys
6
+ * @returns {Promise<Object>} Object containing the clone, generated CSS, and style cache
7
+ */
8
+ export function prepareClone(element: Element, compress?: boolean, embedFonts?: boolean): Promise<Object>;
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,2 @@
1
+ export { preCache } from "./api/preCache.js";
2
+ export { snapdom } from "./api/snapdom.js";
@@ -0,0 +1,10 @@
1
+ /**
2
+ * Converts all background images in the cloned element tree to data URLs.
3
+ *
4
+ * @param {Element} source - Original element
5
+ * @param {Element} clone - Cloned element
6
+ * @param {WeakMap} styleCache - Cache of computed styles
7
+ * @param {Object} [options={}] - Options for image processing
8
+ * @returns {Promise<void>} Promise that resolves when all background images are processed
9
+ */
10
+ export function inlineBackgroundImages(source: Element, clone: Element, styleCache: WeakMap<any, any>, options?: Object): Promise<void>;
@@ -0,0 +1,25 @@
1
+ /**
2
+ * Converts a unicode character from an icon font into a data URL image.
3
+ *
4
+ * @export
5
+ * @param {string} unicodeChar - The unicode character to render
6
+ * @param {string} fontFamily - The font family name
7
+ * @param {string|number} fontWeight - The font weight
8
+ * @param {number} [fontSize=32] - The font size in pixels
9
+ * @param {string} [color="#000"] - The color to use
10
+ * @returns {Promise<string>} Data URL of the rendered icon
11
+ */
12
+ export function iconToImage(unicodeChar: string, fontFamily: string, fontWeight: string | number, fontSize?: number, color?: string): Promise<string>;
13
+ /**
14
+ * Embeds custom fonts found in the document as data URLs in CSS.
15
+ *
16
+ * @export
17
+ * @param {Object} options
18
+ * @param {boolean} [options.ignoreIconFonts=true] - Whether to skip icon fonts
19
+ * @param {boolean} [options.preCached=false] - Whether to use pre-cached resources
20
+ * @returns {Promise<string>} The inlined CSS for custom fonts
21
+ */
22
+ export function embedCustomFonts({ ignoreIconFonts, preCached, }?: {
23
+ ignoreIconFonts?: boolean | undefined;
24
+ preCached?: boolean | undefined;
25
+ }): Promise<string>;
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Converts all <img> elements in the clone to data URLs or replaces them with placeholders if loading fails.
3
+ *
4
+ * @param {Element} clone - Clone of the original element
5
+ * @param {Object} [options={}] - Options for image processing
6
+ * @returns {Promise<void>} Promise that resolves when all images are processed
7
+ */
8
+ export function inlineImages(clone: Element, options?: Object): Promise<void>;
@@ -0,0 +1,12 @@
1
+ /**
2
+ * Creates elements to represent ::before, ::after, and ::first-letter pseudo-elements, inlining their styles and content.
3
+ *
4
+ * @param {Element} source - Original element
5
+ * @param {Element} clone - Cloned element
6
+ * @param {Map} styleMap - Map to store element-to-style-key mappings
7
+ * @param {WeakMap} styleCache - Cache of computed styles
8
+ * @param {boolean} compress - Whether to compress style keys
9
+ * @param {boolean} embedFonts - Whether to embed icon fonts as images
10
+ * @returns {Promise} Promise that resolves when all pseudo-elements are processed
11
+ */
12
+ export function inlinePseudoElements(source: Element, clone: Element, styleMap: Map<any, any>, styleCache: WeakMap<any, any>, compress: boolean, embedFonts?: boolean): Promise<any>;
@@ -0,0 +1,10 @@
1
+ /**
2
+ * Records computed styles for an element to later generate CSS classes.
3
+ *
4
+ * @param {Element} source - Original element
5
+ * @param {Element} clone - Cloned element
6
+ * @param {Map} styleMap - Map to store element-to-style-key mappings
7
+ * @param {WeakMap} cache - Cache of computed styles
8
+ * @param {boolean} compress - Whether to compress style keys
9
+ */
10
+ export function inlineAllStyles(source: Element, clone: Element, styleMap: Map<any, any>, cache: WeakMap<any, any>, compress: boolean): void;
@@ -0,0 +1,38 @@
1
+ export function precacheCommonTags(): void;
2
+ /**
3
+ * Retrieves default CSS property values from a temporary element.
4
+ *
5
+ * @param {string} tagName - The tag name to get default styles for
6
+ * @returns {Object} Object containing default values for all CSS properties
7
+ */
8
+ export function getDefaultStyleForTag(tagName: string): Object;
9
+ /**
10
+ * Creates a unique key from an element's computed style that differs from defaults.
11
+ *
12
+ * @param {Object} snapshot - Computed style snapshot
13
+ * @param {string} tagName - The tag name of the element
14
+ * @param {boolean} [compress=false] - Whether to compress style keys
15
+ * @returns {string} Semi-colon separated list of non-default properties
16
+ */
17
+ export function getStyleKey(snapshot: Object, tagName: string, compress?: boolean): string;
18
+ /**
19
+ * Collects all unique tag names used in the DOM tree rooted at the given node.
20
+ *
21
+ * @param {Node} root - The root node to search
22
+ * @returns {string[]} Array of unique tag names
23
+ */
24
+ export function collectUsedTagNames(root: Node): string[];
25
+ /**
26
+ * Generates deduplicated base CSS for the given tag names.
27
+ *
28
+ * @param {string[]} usedTagNames - Array of tag names
29
+ * @returns {string} CSS string
30
+ */
31
+ export function generateDedupedBaseCSS(usedTagNames: string[]): string;
32
+ /**
33
+ * Generates CSS classes from a style map.
34
+ *
35
+ * @param {Map} styleMap - Map of elements to style keys
36
+ * @returns {Map} Map of style keys to class names
37
+ */
38
+ export function generateCSSClasses(styleMap: Map<any, any>): Map<any, any>;
@@ -0,0 +1,71 @@
1
+ /**
2
+ * Fetches and inlines a single background-image entry to a data URL (with caching).
3
+ * - If entry is a gradient or "none", returns unchanged.
4
+ * - If entry is a url(...), fetches the image as data URL and caches it.
5
+ *
6
+ * @param {string} entry - Single background-image entry (e.g., "url(...)").
7
+ * @param {Object} [options={}] - Options like crossOrigin.
8
+ * @param {boolean} [options.skipInline=false] - If true, only fetches & caches, doesn't return a replacement.
9
+ * @returns {Promise<string|void>} - The processed entry (unless skipInline is true).
10
+ */
11
+ export function inlineSingleBackgroundEntry(entry: string, options?: {
12
+ skipInline?: boolean | undefined;
13
+ }): Promise<string | void>;
14
+ /**
15
+ * Creates a promise that resolves after the specified delay
16
+ * @param {number} [ms=0] - Milliseconds to delay
17
+ * @returns {Promise<void>} Promise that resolves after the delay
18
+ */
19
+ export function idle(fn: any, { fast }?: {
20
+ fast?: boolean | undefined;
21
+ }): Promise<void>;
22
+ /**
23
+ * Gets the computed style for an element or pseudo-element, with caching.
24
+ *
25
+ * @param {Element} el - The element
26
+ * @param {string|null} [pseudo=null] - The pseudo-element
27
+ * @returns {CSSStyleDeclaration} The computed style
28
+ */
29
+ export function getStyle(el: Element, pseudo?: string | null): CSSStyleDeclaration;
30
+ /**
31
+ * Parses the CSS content property value, handling unicode escapes.
32
+ *
33
+ * @param {string} content - The CSS content value
34
+ * @returns {string} The parsed content
35
+ */
36
+ export function parseContent(content: string): string;
37
+ /**
38
+ * Extracts a URL from a CSS value like background-image.
39
+ *
40
+ * @param {string} value - The CSS value
41
+ * @returns {string|null} The extracted URL or null
42
+ */
43
+ export function extractURL(value: string): string | null;
44
+ /**
45
+ * Determines if a font family or URL is an icon font.
46
+ *
47
+ * @param {string} familyOrUrl - The font family or URL
48
+ * @returns {boolean} True if it is an icon font
49
+ */
50
+ export function isIconFont(familyOrUrl: string): boolean;
51
+ /**
52
+ *
53
+ *
54
+ * @export
55
+ * @param {*} src
56
+ * @param {number} [timeout=3000]
57
+ * @return {*}
58
+ */
59
+ export function fetchImage(src: any, timeout?: number, crossOrigin?: string): any;
60
+ /**
61
+ *
62
+ *
63
+ * @export
64
+ * @param {*} style
65
+ * @return {*}
66
+ */
67
+ export function snapshotComputedStyle(style: any): any;
68
+ export function isSafari(): boolean;
69
+ export function stripTranslate(transform: any): any;
70
+ export function safeEncodeURI(uri: any): any;
71
+ export function splitBackgroundImage(bg: any): any[];
@@ -0,0 +1,8 @@
1
+ export function findNodeBy(root: any, key: any, value: any, childrenKey?: string): any;
2
+ export function getItemBy(root: any, key: any, value: any, childrenKey?: string): any;
3
+ export function getItemBy3(root: any, key: any, value: any, childrenKey?: string): any;
4
+ export function getItemByID(root: any, value: any): any;
5
+ export function getLabelFromDictionaryByValue(a: any, value: any, 保底?: boolean): any;
6
+ export function getChildWithParentBy(root: any, key: any, value: any, childrenKey?: string): null | undefined;
7
+ export function getItemBy2(root: any, key: any, value: any, childrenKey?: string): any;
8
+ export default getItemBy;
@@ -0,0 +1 @@
1
+ export * from "./src/turbo-stream";
@@ -0,0 +1,7 @@
1
+ export type DecodePlugin = (type: string, ...data: unknown[]) => {
2
+ value: unknown;
3
+ } | false | null | undefined;
4
+ export type DecodeOptions = {
5
+ plugins?: DecodePlugin[];
6
+ };
7
+ export declare function decode<T>(stream: ReadableStream<string>, { plugins }?: DecodeOptions): Promise<T>;