@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.
- package/class-name/index.js +5 -5
- package/constant/index.js +24 -2
- package/constant/platform.js +13 -12
- package/constant.js +24 -2
- package/content-disposition/index.js +3 -3
- package/date/convertTime.js +4 -4
- package/event-emitter/index.js +2 -4
- package/filesize/types/constants.d.ts +81 -0
- package/filesize/types/filesize.d.ts +97 -0
- package/index.js +66 -60
- package/js-cookie/index.d.ts +116 -0
- package/js-cookie/index.js +4 -0
- package/js-cookie/src/api.js +56 -0
- package/js-cookie/src/assign.js +11 -0
- package/js-cookie/src/converter.js +14 -0
- package/jsCookie.js +4 -0
- package/lunar/lib/HolidayUtil.js +48 -49
- package/nzh/nzh.d.ts +74 -0
- package/package.json +1 -1
- package/query-string/base.d.ts +717 -0
- package/query-string/base.js +268 -0
- package/query-string/index.d.ts +16 -0
- package/query-string/index.js +4 -0
- package/query-string/splitOnFirst.js +14 -0
- package/queryString.js +4 -0
- package/random/index.js +56 -35
- package/snapdom/src/api/preCache.js +51 -28
- package/snapdom/src/core/cache.js +1 -4
- package/snapdom/src/core/capture.js +45 -44
- package/snapdom/src/core/clone.js +82 -66
- package/snapdom/src/core/prepare.js +167 -45
- package/snapdom/src/modules/background.js +29 -19
- package/snapdom/src/modules/fonts.js +158 -111
- package/snapdom/src/modules/images.js +14 -9
- package/snapdom/src/modules/pseudo.js +52 -47
- package/snapdom/src/modules/styles.js +22 -22
- package/snapdom/src/modules/svgDefs.js +39 -20
- package/snapdom/src/utils/cssTools.js +58 -51
- package/snapdom/src/utils/helpers.js +197 -140
- package/snapdom/types/snapdom.d.ts +101 -0
- package/types/constant/index.d.ts +11 -0
- package/types/constant/platform.d.ts +1 -0
- package/types/index.d.ts +3 -0
- package/types/js-cookie/index.d.ts +1 -0
- package/types/js-cookie/src/api.d.mts +2 -0
- package/types/js-cookie/src/assign.d.mts +1 -0
- package/types/js-cookie/src/converter.d.mts +5 -0
- package/types/query-string/base.d.ts +11 -0
- package/types/query-string/index.d.ts +2 -0
- package/types/query-string/splitOnFirst.d.ts +1 -0
- package/types/random/index.d.ts +14 -23
- package/types/snapdom/src/api/preCache.d.ts +2 -5
- package/types/snapdom/src/core/cache.d.ts +0 -3
- package/types/snapdom/src/core/clone.d.ts +1 -1
- package/types/snapdom/src/modules/background.d.ts +16 -6
- package/types/snapdom/src/modules/fonts.d.ts +5 -1
- package/types/snapdom/src/modules/pseudo.d.ts +1 -1
- package/types/snapdom/src/modules/styles.d.ts +1 -1
- package/types/snapdom/src/modules/svgDefs.d.ts +13 -13
- package/types/snapdom/src/utils/cssTools.d.ts +2 -10
- package/types/snapdom/src/utils/helpers.d.ts +13 -7
- package/types/turbo-stream/src/shared.d.ts +3 -3
- package/url-toolkit/src/url-toolkit.d.ts +22 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from "./src/api.mjs";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export default function _default(target: any, ...args: any[]): any;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export function extract(input: any): any;
|
|
2
|
+
export function parse(query: any, options: any): any;
|
|
3
|
+
export function stringify(object: any, options: any): string;
|
|
4
|
+
export function parseUrl(url: any, options: any): {
|
|
5
|
+
fragmentIdentifier?: any;
|
|
6
|
+
url: string;
|
|
7
|
+
query: any;
|
|
8
|
+
};
|
|
9
|
+
export function stringifyUrl(object: any, options: any): string;
|
|
10
|
+
export function pick(input: any, filter: any, options: any): string;
|
|
11
|
+
export function exclude(input: any, filter: any, options: any): string;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export default function splitOnFirst(string: any, separator: any): string[];
|
package/types/random/index.d.ts
CHANGED
|
@@ -1,21 +1,4 @@
|
|
|
1
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
2
|
export function county(p: any): string;
|
|
20
3
|
export function company(): string;
|
|
21
4
|
export function project(): string;
|
|
@@ -26,15 +9,23 @@ declare namespace _default {
|
|
|
26
9
|
export function id(): number;
|
|
27
10
|
export function increment(step: any): number;
|
|
28
11
|
export { image };
|
|
12
|
+
export { address };
|
|
13
|
+
export { web };
|
|
14
|
+
export { name };
|
|
15
|
+
export { text };
|
|
16
|
+
export function boolean(): boolean;
|
|
17
|
+
export function sex(): string;
|
|
18
|
+
export { sample as pick };
|
|
19
|
+
export { number };
|
|
29
20
|
}
|
|
30
21
|
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
22
|
import time from './time';
|
|
38
23
|
import constellation from './constellation';
|
|
39
24
|
import licensePlate from './licensePlate';
|
|
40
25
|
import image from './image';
|
|
26
|
+
import address from './address';
|
|
27
|
+
import web from './web';
|
|
28
|
+
import name from './name';
|
|
29
|
+
import text from './text';
|
|
30
|
+
import sample from 'lodash/sample';
|
|
31
|
+
import number from './number';
|
|
@@ -1,8 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
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
|
|
3
|
+
* Nunca deja promesas rechazadas sin manejar (evita unhandled rejections).
|
|
7
4
|
*/
|
|
8
|
-
export function preCache(root?: Document
|
|
5
|
+
export function preCache(root?: Document, options?: {}): Promise<void>;
|
|
@@ -8,9 +8,6 @@ export namespace cache {
|
|
|
8
8
|
export let font: Set<any>;
|
|
9
9
|
export let snapshot: WeakMap<WeakKey, any>;
|
|
10
10
|
export let snapshotKey: Map<any, any>;
|
|
11
|
-
export let preStyleMap: Map<any, any>;
|
|
12
|
-
export let preStyle: WeakMap<WeakKey, any>;
|
|
13
|
-
export let preNodeMap: Map<any, any>;
|
|
14
11
|
export { resetCache as reset };
|
|
15
12
|
}
|
|
16
13
|
declare function resetCache(): void;
|
|
@@ -7,4 +7,4 @@
|
|
|
7
7
|
* @param {Node} [originalRoot] - Original root element being captured
|
|
8
8
|
* @returns {Node|null} Cloned node with styles and shadow DOM content, or null for empty text nodes or filtered elements
|
|
9
9
|
*/
|
|
10
|
-
export function deepClone(node: Node, compress: boolean, options?: Object, originalRoot?: Node): Node | null;
|
|
10
|
+
export function deepClone(node: Node, styleMap: any, styleCache: any, nodeMap: any, compress: boolean, options?: Object, originalRoot?: Node): Node | null;
|
|
@@ -1,9 +1,19 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* Recursively inlines background-related images and masks from the source element to its clone.
|
|
3
3
|
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
4
|
+
* This function walks through the source DOM tree and its clone, copying inline styles for
|
|
5
|
+
* background images, masks, and border images to ensure the clone retains all visual image
|
|
6
|
+
* resources inline (e.g., data URLs), avoiding external dependencies.
|
|
7
|
+
*
|
|
8
|
+
* It also preserves the `background-color` property if it is not transparent.
|
|
9
|
+
*
|
|
10
|
+
* Special handling is done for `border-image` related properties: the
|
|
11
|
+
* `border-image-slice`, `border-image-width`, `border-image-outset`, and `border-image-repeat`
|
|
12
|
+
* are only copied if `border-image` or `border-image-source` are present and active.
|
|
13
|
+
*
|
|
14
|
+
* @param {HTMLElement} source The original source element from which styles are read.
|
|
15
|
+
* @param {HTMLElement} clone The cloned element to which inline styles are applied.
|
|
16
|
+
* @param {Object} [options={}] Optional parameters passed to image inlining functions.
|
|
17
|
+
* @returns {Promise<void>} Resolves when all inlining operations (including async image fetches) complete.
|
|
8
18
|
*/
|
|
9
|
-
export function inlineBackgroundImages(source:
|
|
19
|
+
export function inlineBackgroundImages(source: HTMLElement, clone: HTMLElement, styleCache: any, options?: Object): Promise<void>;
|
|
@@ -16,8 +16,12 @@ export function iconToImage(unicodeChar: string, fontFamily: string, fontWeight:
|
|
|
16
16
|
* @export
|
|
17
17
|
* @param {Object} options
|
|
18
18
|
* @param {boolean} [options.preCached=false] - Whether to use pre-cached resources
|
|
19
|
+
* @param {Object} [options.localFonts=[]] - Additional local fonts to embed
|
|
20
|
+
* @param {string} [options.useProxy=''] - Optional proxy for font fetching
|
|
19
21
|
* @returns {Promise<string>} The inlined CSS for custom fonts
|
|
20
22
|
*/
|
|
21
|
-
export function embedCustomFonts({ preCached }?: {
|
|
23
|
+
export function embedCustomFonts({ preCached, localFonts, useProxy, }?: {
|
|
22
24
|
preCached?: boolean | undefined;
|
|
25
|
+
localFonts?: Object | undefined;
|
|
26
|
+
useProxy?: string | undefined;
|
|
23
27
|
}): Promise<string>;
|
|
@@ -7,4 +7,4 @@
|
|
|
7
7
|
* @param {boolean} embedFonts - Whether to embed icon fonts as images
|
|
8
8
|
* @returns {Promise} Promise that resolves when all pseudo-elements are processed
|
|
9
9
|
*/
|
|
10
|
-
export function inlinePseudoElements(source: Element, clone: Element, options: any): Promise<any>;
|
|
10
|
+
export function inlinePseudoElements(source: Element, clone: Element, styleMap: any, styleCache: any, options: any): Promise<any>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export function inlineAllStyles(source: any, clone: any, compress: any): void;
|
|
1
|
+
export function inlineAllStyles(source: any, clone: any, styleMap: any, cache: any, compress: any): void;
|
|
@@ -1,19 +1,19 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
3
|
-
*
|
|
2
|
+
* Ensures that all external <symbol> or <defs> elements referenced by <use>
|
|
3
|
+
* inside the given root element are inlined into it.
|
|
4
4
|
*
|
|
5
|
-
* This is
|
|
6
|
-
*
|
|
5
|
+
* This is necessary when capturing or exporting an SVG fragment that relies on
|
|
6
|
+
* definitions existing elsewhere in the document, ensuring it remains
|
|
7
|
+
* self-contained and renders correctly.
|
|
7
8
|
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
9
|
+
* Process:
|
|
10
|
+
* 1. Collect all IDs referenced by <use> elements in the root.
|
|
11
|
+
* 2. Look up those IDs in the global document (outside the root).
|
|
12
|
+
* 3. Create or reuse a hidden <svg> container inside the root to hold inlined defs.
|
|
13
|
+
* 4. Only insert missing <symbol>/<defs> elements that are not already present.
|
|
10
14
|
*
|
|
11
|
-
*
|
|
12
|
-
* @param {ParentNode} root - The root node containing cloned SVGs (usually the result of a DOM snapshot).
|
|
13
|
-
* @returns {void}
|
|
15
|
+
* Existing definitions in the root are never modified or removed.
|
|
14
16
|
*
|
|
15
|
-
* @
|
|
16
|
-
* const { clone } = await prepareClone(element);
|
|
17
|
-
* inlineExternalDef(clone);
|
|
17
|
+
* @param {HTMLElement} rootElement - The root element being processed (typically the cloned DOM fragment).
|
|
18
18
|
*/
|
|
19
|
-
export function
|
|
19
|
+
export function inlineExternalDefsAndSymbols(rootElement: HTMLElement): void;
|
|
@@ -6,15 +6,7 @@ export function precacheCommonTags(): void;
|
|
|
6
6
|
* @returns {Object} Object containing default values for all CSS properties
|
|
7
7
|
*/
|
|
8
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;
|
|
9
|
+
export function getStyleKey(snapshot: any, tagName: any, compress?: boolean): string;
|
|
18
10
|
/**
|
|
19
11
|
* Collects all unique tag names used in the DOM tree rooted at the given node.
|
|
20
12
|
*
|
|
@@ -34,4 +26,4 @@ export function generateDedupedBaseCSS(usedTagNames: string[]): string;
|
|
|
34
26
|
*
|
|
35
27
|
* @returns {Map} Map of style keys to class names
|
|
36
28
|
*/
|
|
37
|
-
export function generateCSSClasses(): Map<any, any>;
|
|
29
|
+
export function generateCSSClasses(styleMap: any): Map<any, any>;
|
|
@@ -49,14 +49,20 @@ export function extractURL(value: string): string | null;
|
|
|
49
49
|
*/
|
|
50
50
|
export function isIconFont(familyOrUrl: string): boolean;
|
|
51
51
|
/**
|
|
52
|
-
*
|
|
53
|
-
*
|
|
54
|
-
* @
|
|
55
|
-
* @param {
|
|
56
|
-
* @
|
|
57
|
-
* @return {*}
|
|
52
|
+
* Fetch a resource with optional proxy fallback.
|
|
53
|
+
* @param {string} url - Resource URL
|
|
54
|
+
* @param {Object} [options]
|
|
55
|
+
* @param {string} [options.useProxy=''] - Proxy prefix
|
|
56
|
+
* @returns {Promise<Response>} The fetched response
|
|
58
57
|
*/
|
|
59
|
-
export function
|
|
58
|
+
export function fetchResource(url: string, { useProxy }?: {
|
|
59
|
+
useProxy?: string | undefined;
|
|
60
|
+
}): Promise<Response>;
|
|
61
|
+
export function fetchImage(src: any, { timeout, useProxy, errorTTL }?: {
|
|
62
|
+
timeout?: number | undefined;
|
|
63
|
+
useProxy?: string | undefined;
|
|
64
|
+
errorTTL?: number | undefined;
|
|
65
|
+
}): any;
|
|
60
66
|
/**
|
|
61
67
|
*
|
|
62
68
|
*
|
|
@@ -80,11 +80,11 @@ export declare class TurboBlob extends Blob {
|
|
|
80
80
|
text(): Promise<string>;
|
|
81
81
|
}
|
|
82
82
|
declare const FileBaseClass: {
|
|
83
|
-
new (fileBits: BlobPart[], fileName: string, options?: FilePropertyBag): File;
|
|
84
|
-
prototype: File;
|
|
85
|
-
} | {
|
|
86
83
|
new (blobParts?: BlobPart[], options?: BlobPropertyBag): Blob;
|
|
87
84
|
prototype: Blob;
|
|
85
|
+
} | {
|
|
86
|
+
new (fileBits: BlobPart[], fileName: string, options?: FilePropertyBag): File;
|
|
87
|
+
prototype: File;
|
|
88
88
|
};
|
|
89
89
|
export declare class TurboFile extends FileBaseClass {
|
|
90
90
|
#private;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
export as namespace URLToolkit;
|
|
2
|
+
|
|
3
|
+
export type URLParts = {
|
|
4
|
+
scheme: string;
|
|
5
|
+
netLoc: string;
|
|
6
|
+
path: string;
|
|
7
|
+
params: string;
|
|
8
|
+
query: string;
|
|
9
|
+
fragment: string;
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
export function buildAbsoluteURL(
|
|
13
|
+
baseURL: string,
|
|
14
|
+
relativeURL: string,
|
|
15
|
+
opts?: { alwaysNormalize?: boolean },
|
|
16
|
+
): string;
|
|
17
|
+
|
|
18
|
+
export function parseURL(url: string): URLParts | null;
|
|
19
|
+
|
|
20
|
+
export function normalizePath(path: string): string;
|
|
21
|
+
|
|
22
|
+
export function buildURLFromParts(parts: URLParts): string;
|