@unicom-cloud/utils 0.1.11 → 0.1.13
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/date/index.js +22 -0
- package/date.js +9 -0
- package/filesize/src/constants.js +22 -22
- package/filesize/src/filesize.js +32 -33
- package/index.js +56 -54
- package/lunar/index.js +36 -0
- package/lunar/lib/Holiday.js +42 -0
- package/lunar/lib/HolidayUtil.js +128 -0
- package/lunar/lib/I18n.js +1005 -0
- package/lunar/lib/JieQi.js +40 -0
- package/lunar/lib/Lunar.js +1035 -0
- package/lunar/lib/LunarMonth.js +150 -0
- package/lunar/lib/LunarTime.js +138 -0
- package/lunar/lib/LunarUtil.js +1752 -0
- package/lunar/lib/LunarYear.js +616 -0
- package/lunar/lib/ShouXingUtil.js +6915 -0
- package/lunar/lib/Solar.js +311 -0
- package/lunar/lib/SolarHalfYear.js +45 -0
- package/lunar/lib/SolarMonth.js +55 -0
- package/lunar/lib/SolarSeason.js +42 -0
- package/lunar/lib/SolarUtil.js +256 -0
- package/lunar/lib/SolarWeek.js +153 -0
- package/lunar/lib/SolarYear.js +35 -0
- package/lunar/lib/index.js +35 -0
- package/lunar.js +36 -0
- package/package.json +1 -1
- package/snapdom/src/api/preCache.js +27 -37
- package/snapdom/src/api/snapdom.js +75 -58
- package/snapdom/src/core/cache.js +19 -8
- package/snapdom/src/core/capture.js +49 -48
- package/snapdom/src/core/clone.js +96 -31
- package/snapdom/src/core/prepare.js +43 -37
- package/snapdom/src/modules/background.js +29 -20
- package/snapdom/src/modules/fonts.js +94 -104
- package/snapdom/src/modules/iconFonts.js +28 -0
- package/snapdom/src/modules/images.js +6 -6
- package/snapdom/src/modules/pseudo.js +52 -50
- package/snapdom/src/modules/styles.js +26 -6
- package/snapdom/src/modules/svgDefs.js +26 -0
- package/snapdom/src/utils/cssTools.js +41 -41
- package/snapdom/src/utils/helpers.js +128 -84
- package/tinycolor/index.js +46 -0
- package/tinycolor/src/conversion.js +143 -0
- package/tinycolor/src/css-color-names.js +153 -0
- package/tinycolor/src/format-input.js +77 -0
- package/tinycolor/src/from-ratio.js +21 -0
- package/tinycolor/src/index.js +404 -0
- package/tinycolor/src/random.js +221 -0
- package/tinycolor/src/readability.js +37 -0
- package/tinycolor/src/to-ms-filter.js +15 -0
- package/tinycolor/src/util.js +32 -0
- package/tinycolor.js +46 -0
- package/tree/index.js +10 -8
- package/tree/search/index.js +90 -0
- package/tree.js +9 -7
- package/types/date/index.d.ts +4 -0
- package/types/filesize/src/constants.d.ts +12 -12
- package/types/filesize/src/filesize.d.ts +63 -22
- package/types/index.d.ts +4 -3
- package/types/lunar/index.d.ts +3 -0
- package/types/lunar/lib/Holiday.d.ts +17 -0
- package/types/lunar/lib/HolidayUtil.d.ts +23 -0
- package/types/lunar/lib/I18n.d.ts +23 -0
- package/types/lunar/lib/JieQi.d.ts +15 -0
- package/types/lunar/lib/Lunar.d.ts +245 -0
- package/types/lunar/lib/LunarMonth.d.ts +35 -0
- package/types/lunar/lib/LunarTime.d.ts +40 -0
- package/types/lunar/lib/LunarUtil.d.ts +128 -0
- package/types/lunar/lib/LunarYear.d.ts +61 -0
- package/types/lunar/lib/ShouXingUtil.d.ts +38 -0
- package/types/lunar/lib/Solar.d.ts +51 -0
- package/types/lunar/lib/SolarHalfYear.d.ts +15 -0
- package/types/lunar/lib/SolarMonth.d.ts +16 -0
- package/types/lunar/lib/SolarSeason.d.ts +15 -0
- package/types/lunar/lib/SolarUtil.d.ts +20 -0
- package/types/lunar/lib/SolarWeek.d.ts +23 -0
- package/types/lunar/lib/SolarYear.d.ts +12 -0
- package/types/lunar/lib/index.d.ts +17 -0
- package/types/snapdom/src/core/cache.d.ts +17 -11
- package/types/snapdom/src/core/capture.d.ts +4 -0
- package/types/snapdom/src/core/clone.d.ts +4 -5
- package/types/snapdom/src/core/prepare.d.ts +8 -1
- package/types/snapdom/src/modules/background.d.ts +1 -2
- package/types/snapdom/src/modules/fonts.d.ts +1 -3
- package/types/snapdom/src/modules/iconFonts.d.ts +2 -0
- package/types/snapdom/src/modules/pseudo.d.ts +1 -3
- package/types/snapdom/src/modules/styles.d.ts +1 -10
- package/types/snapdom/src/modules/svgDefs.d.ts +19 -0
- package/types/snapdom/src/utils/cssTools.d.ts +1 -2
- package/types/snapdom/src/utils/helpers.d.ts +1 -1
- package/types/tinycolor/index.d.ts +2 -0
- package/types/tinycolor/src/conversion.d.ts +79 -0
- package/types/tinycolor/src/css-color-names.d.ts +4 -0
- package/types/tinycolor/src/format-input.d.ts +38 -0
- package/types/tinycolor/src/from-ratio.d.ts +14 -0
- package/types/tinycolor/src/index.d.ts +214 -0
- package/types/tinycolor/src/interfaces.d.ts +57 -0
- package/types/tinycolor/src/public_api.d.ts +10 -0
- package/types/tinycolor/src/random.d.ts +24 -0
- package/types/tinycolor/src/readability.d.ts +46 -0
- package/types/tinycolor/src/to-ms-filter.d.ts +5 -0
- package/types/tinycolor/src/umd_api.d.ts +22 -0
- package/types/tinycolor/src/util.d.ts +36 -0
- package/types/tree/index.d.ts +1 -0
- package/types/tree/search/index.d.ts +80 -0
- package/types/ui-color/compareColorByRange.d.ts +2 -0
- package/types/ui-color/index.d.ts +208 -0
- package/ui-color/compareColorByRange.js +9 -0
- package/ui-color/index.js +162 -0
- package/uiColor.js +29 -0
- package/convertTime.js +0 -4
- package/dayjs/index.js +0 -15
- package/dayjs.js +0 -5
- package/lunar-converter/index.js +0 -641
- package/lunarConverter.js +0 -4
- package/search-tree/index.js +0 -54
- package/searchTree.js +0 -4
- package/types/dayjs/index.d.ts +0 -1
- package/types/lunar-converter/index.d.ts +0 -113
- package/types/search-tree/index.d.ts +0 -20
- /package/{convert-time/index.js → date/convertTime.js} +0 -0
- /package/types/{convert-time/index.d.ts → date/convertTime.d.ts} +0 -0
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { Lunar } from './Lunar';
|
|
2
|
+
import { SolarWeek } from './SolarWeek';
|
|
3
|
+
export declare class Solar {
|
|
4
|
+
static J2000: number;
|
|
5
|
+
private readonly _year;
|
|
6
|
+
private readonly _month;
|
|
7
|
+
private readonly _day;
|
|
8
|
+
private readonly _hour;
|
|
9
|
+
private readonly _minute;
|
|
10
|
+
private readonly _second;
|
|
11
|
+
static fromYmd(year: number, month: number, day: number): Solar;
|
|
12
|
+
static fromYmdHms(year: number, month: number, day: number, hour: number, minute: number, second: number): Solar;
|
|
13
|
+
static fromDate(date: Date): Solar;
|
|
14
|
+
static fromJulianDay(julianDay: number): Solar;
|
|
15
|
+
static fromBaZi(yearGanZhi: string, monthGanZhi: string, dayGanZhi: string, timeGanZhi: string, sect?: number, baseYear?: number): Solar[];
|
|
16
|
+
constructor(year: number, month: number, day: number, hour: number, minute: number, second: number);
|
|
17
|
+
getYear(): number;
|
|
18
|
+
getMonth(): number;
|
|
19
|
+
getDay(): number;
|
|
20
|
+
getHour(): number;
|
|
21
|
+
getMinute(): number;
|
|
22
|
+
getSecond(): number;
|
|
23
|
+
getWeek(): number;
|
|
24
|
+
getWeekInChinese(): string;
|
|
25
|
+
getSolarWeek(start: number): SolarWeek;
|
|
26
|
+
isLeapYear(): boolean;
|
|
27
|
+
getFestivals(): string[];
|
|
28
|
+
getOtherFestivals(): string[];
|
|
29
|
+
getXingzuo(): string;
|
|
30
|
+
getXingZuo(): string;
|
|
31
|
+
/**
|
|
32
|
+
* 获取薪资比例(感谢 https://gitee.com/smr1987)
|
|
33
|
+
* @returns 1 | 2 | 3 薪资比例
|
|
34
|
+
*/
|
|
35
|
+
getSalaryRate(): number;
|
|
36
|
+
toYmd(): string;
|
|
37
|
+
toYmdHms(): string;
|
|
38
|
+
toString(): string;
|
|
39
|
+
toFullString(): string;
|
|
40
|
+
nextYear(years: number): Solar;
|
|
41
|
+
nextMonth(months: number): Solar;
|
|
42
|
+
nextDay(days: number): Solar;
|
|
43
|
+
next(days: number, onlyWorkday?: boolean): Solar;
|
|
44
|
+
nextHour(hours: number): Solar;
|
|
45
|
+
getLunar(): Lunar;
|
|
46
|
+
getJulianDay(): number;
|
|
47
|
+
isBefore(solar: Solar): boolean;
|
|
48
|
+
isAfter(solar: Solar): boolean;
|
|
49
|
+
subtract(solar: Solar): number;
|
|
50
|
+
subtractMinute(solar: Solar): number;
|
|
51
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { SolarMonth } from './SolarMonth';
|
|
2
|
+
export declare class SolarHalfYear {
|
|
3
|
+
private readonly _year;
|
|
4
|
+
private readonly _month;
|
|
5
|
+
static fromYm(year: number, month: number): SolarHalfYear;
|
|
6
|
+
static fromDate(date: Date): SolarHalfYear;
|
|
7
|
+
constructor(year: number, month: number);
|
|
8
|
+
getYear(): number;
|
|
9
|
+
getMonth(): number;
|
|
10
|
+
getIndex(): number;
|
|
11
|
+
next(halfYears: number): SolarHalfYear;
|
|
12
|
+
getMonths(): SolarMonth[];
|
|
13
|
+
toString(): string;
|
|
14
|
+
toFullString(): string;
|
|
15
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { Solar } from './Solar';
|
|
2
|
+
import { SolarWeek } from './SolarWeek';
|
|
3
|
+
export declare class SolarMonth {
|
|
4
|
+
private readonly _year;
|
|
5
|
+
private readonly _month;
|
|
6
|
+
static fromYm(year: number, month: number): SolarMonth;
|
|
7
|
+
static fromDate(date: Date): SolarMonth;
|
|
8
|
+
constructor(year: number, month: number);
|
|
9
|
+
getYear(): number;
|
|
10
|
+
getMonth(): number;
|
|
11
|
+
next(months: number): SolarMonth;
|
|
12
|
+
getDays(): Solar[];
|
|
13
|
+
getWeeks(start: number): SolarWeek[];
|
|
14
|
+
toString(): string;
|
|
15
|
+
toFullString(): string;
|
|
16
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { SolarMonth } from './SolarMonth';
|
|
2
|
+
export declare class SolarSeason {
|
|
3
|
+
private readonly _year;
|
|
4
|
+
private readonly _month;
|
|
5
|
+
static fromYm(year: number, month: number): SolarSeason;
|
|
6
|
+
static fromDate(date: Date): SolarSeason;
|
|
7
|
+
constructor(year: number, month: number);
|
|
8
|
+
getYear(): number;
|
|
9
|
+
getMonth(): number;
|
|
10
|
+
getIndex(): number;
|
|
11
|
+
next(seasons: number): SolarSeason;
|
|
12
|
+
getMonths(): SolarMonth[];
|
|
13
|
+
toString(): string;
|
|
14
|
+
toFullString(): string;
|
|
15
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
export declare class SolarUtil {
|
|
2
|
+
static WEEK: string[];
|
|
3
|
+
static DAYS_OF_MONTH: number[];
|
|
4
|
+
static XINGZUO: string[];
|
|
5
|
+
static FESTIVAL: {
|
|
6
|
+
[key: string]: string;
|
|
7
|
+
};
|
|
8
|
+
static OTHER_FESTIVAL: {
|
|
9
|
+
[key: string]: string[];
|
|
10
|
+
};
|
|
11
|
+
static WEEK_FESTIVAL: {
|
|
12
|
+
[key: string]: string;
|
|
13
|
+
};
|
|
14
|
+
static isLeapYear(year: number): boolean;
|
|
15
|
+
static getDaysOfMonth(year: number, month: number): number;
|
|
16
|
+
static getDaysOfYear(year: number): number;
|
|
17
|
+
static getDaysInYear(year: number, month: number, day: number): number;
|
|
18
|
+
static getWeeksOfMonth(year: number, month: number, start: number): number;
|
|
19
|
+
static getDaysBetween(ay: number, am: number, ad: number, by: number, bm: number, bd: number): number;
|
|
20
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { Solar } from './Solar';
|
|
2
|
+
export declare class SolarWeek {
|
|
3
|
+
private readonly _year;
|
|
4
|
+
private readonly _month;
|
|
5
|
+
private readonly _day;
|
|
6
|
+
private readonly _start;
|
|
7
|
+
static fromYmd(year: number, month: number, day: number, start: number): SolarWeek;
|
|
8
|
+
static fromDate(date: Date, start: number): SolarWeek;
|
|
9
|
+
constructor(year: number, month: number, day: number, start: number);
|
|
10
|
+
getYear(): number;
|
|
11
|
+
getMonth(): number;
|
|
12
|
+
getDay(): number;
|
|
13
|
+
getStart(): number;
|
|
14
|
+
getIndex(): number;
|
|
15
|
+
getIndexInYear(): number;
|
|
16
|
+
next(weeks: number, separateMonth: boolean): SolarWeek;
|
|
17
|
+
getFirstDay(): Solar;
|
|
18
|
+
getFirstDayInMonth(): Solar;
|
|
19
|
+
getDays(): Solar[];
|
|
20
|
+
getDaysInMonth(): Solar[];
|
|
21
|
+
toString(): string;
|
|
22
|
+
toFullString(): string;
|
|
23
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { SolarMonth } from './SolarMonth';
|
|
2
|
+
export declare class SolarYear {
|
|
3
|
+
private readonly _year;
|
|
4
|
+
static fromYear(year: number): SolarYear;
|
|
5
|
+
static fromDate(date: Date): SolarYear;
|
|
6
|
+
constructor(year: number);
|
|
7
|
+
getYear(): number;
|
|
8
|
+
next(years: number): SolarYear;
|
|
9
|
+
getMonths(): SolarMonth[];
|
|
10
|
+
toString(): string;
|
|
11
|
+
toFullString(): string;
|
|
12
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { Holiday } from './Holiday';
|
|
2
|
+
import { HolidayUtil } from './HolidayUtil';
|
|
3
|
+
import { JieQi } from './JieQi';
|
|
4
|
+
import { Lunar } from './Lunar';
|
|
5
|
+
import { LunarUtil } from './LunarUtil';
|
|
6
|
+
import { Solar } from './Solar';
|
|
7
|
+
import { SolarUtil } from './SolarUtil';
|
|
8
|
+
import { SolarHalfYear } from './SolarHalfYear';
|
|
9
|
+
import { SolarMonth } from './SolarMonth';
|
|
10
|
+
import { SolarSeason } from './SolarSeason';
|
|
11
|
+
import { SolarWeek } from './SolarWeek';
|
|
12
|
+
import { SolarYear } from './SolarYear';
|
|
13
|
+
import { I18n } from './I18n';
|
|
14
|
+
import { LunarMonth } from './LunarMonth';
|
|
15
|
+
import { LunarTime } from './LunarTime';
|
|
16
|
+
import { LunarYear } from './LunarYear';
|
|
17
|
+
export { Holiday, HolidayUtil, I18n, JieQi, Lunar, LunarMonth, LunarTime, LunarUtil, LunarYear, Solar, SolarHalfYear, SolarMonth, SolarSeason, SolarUtil, SolarWeek, SolarYear, };
|
|
@@ -1,11 +1,17 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
export
|
|
6
|
-
export
|
|
7
|
-
export
|
|
8
|
-
export
|
|
9
|
-
export
|
|
10
|
-
export
|
|
11
|
-
export
|
|
1
|
+
export namespace cache {
|
|
2
|
+
export let image: Map<any, any>;
|
|
3
|
+
export let background: Map<any, any>;
|
|
4
|
+
export let resource: Map<any, any>;
|
|
5
|
+
export let defaultStyle: Map<any, any>;
|
|
6
|
+
export let baseStyle: Map<any, any>;
|
|
7
|
+
export let computedStyle: WeakMap<WeakKey, any>;
|
|
8
|
+
export let font: Set<any>;
|
|
9
|
+
export let snapshot: WeakMap<WeakKey, any>;
|
|
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
|
+
export { resetCache as reset };
|
|
15
|
+
}
|
|
16
|
+
declare function resetCache(): void;
|
|
17
|
+
export {};
|
|
@@ -7,6 +7,8 @@
|
|
|
7
7
|
* @param {boolean} [options.embedFonts=false] - Whether to embed custom fonts
|
|
8
8
|
* @param {boolean} [options.fast=true] - Whether to skip idle delay for faster results
|
|
9
9
|
* @param {number} [options.scale=1] - Output scale multiplier
|
|
10
|
+
* @param {string[]} [options.exclude] - CSS selectors for elements to exclude
|
|
11
|
+
* @param {Function} [options.filter] - Custom filter function
|
|
10
12
|
* @returns {Promise<string>} Promise that resolves to an SVG data URL
|
|
11
13
|
*/
|
|
12
14
|
export function captureDOM(element: Element, options?: {
|
|
@@ -14,4 +16,6 @@ export function captureDOM(element: Element, options?: {
|
|
|
14
16
|
embedFonts?: boolean | undefined;
|
|
15
17
|
fast?: boolean | undefined;
|
|
16
18
|
scale?: number | undefined;
|
|
19
|
+
exclude?: string[] | undefined;
|
|
20
|
+
filter?: Function | undefined;
|
|
17
21
|
}): Promise<string>;
|
|
@@ -2,10 +2,9 @@
|
|
|
2
2
|
* Creates a deep clone of a DOM node, including styles, shadow DOM, and special handling for excluded/placeholder/canvas nodes.
|
|
3
3
|
*
|
|
4
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
5
|
* @param {boolean} compress - Whether to compress style keys
|
|
9
|
-
* @
|
|
6
|
+
* @param {Object} [options={}] - Capture options including exclude and filter
|
|
7
|
+
* @param {Node} [originalRoot] - Original root element being captured
|
|
8
|
+
* @returns {Node|null} Cloned node with styles and shadow DOM content, or null for empty text nodes or filtered elements
|
|
10
9
|
*/
|
|
11
|
-
export function deepClone(node: Node,
|
|
10
|
+
export function deepClone(node: Node, compress: boolean, options?: Object, originalRoot?: Node): Node | null;
|
|
@@ -3,6 +3,13 @@
|
|
|
3
3
|
*
|
|
4
4
|
* @param {Element} element - Element to clone
|
|
5
5
|
* @param {boolean} [compress=false] - Whether to compress style keys
|
|
6
|
+
* @param {boolean} [embedFonts=false] - Whether to embed custom fonts
|
|
7
|
+
* @param {Object} [options={}] - Capture options
|
|
8
|
+
* @param {string[]} [options.exclude] - CSS selectors for elements to exclude
|
|
9
|
+
* @param {Function} [options.filter] - Custom filter function
|
|
6
10
|
* @returns {Promise<Object>} Object containing the clone, generated CSS, and style cache
|
|
7
11
|
*/
|
|
8
|
-
export function prepareClone(element: Element, compress?: boolean, embedFonts?: boolean
|
|
12
|
+
export function prepareClone(element: Element, compress?: boolean, embedFonts?: boolean, options?: {
|
|
13
|
+
exclude?: string[] | undefined;
|
|
14
|
+
filter?: Function | undefined;
|
|
15
|
+
}): Promise<Object>;
|
|
@@ -3,8 +3,7 @@
|
|
|
3
3
|
*
|
|
4
4
|
* @param {Element} source - Original element
|
|
5
5
|
* @param {Element} clone - Cloned element
|
|
6
|
-
* @param {WeakMap} styleCache - Cache of computed styles
|
|
7
6
|
* @param {Object} [options={}] - Options for image processing
|
|
8
7
|
* @returns {Promise<void>} Promise that resolves when all background images are processed
|
|
9
8
|
*/
|
|
10
|
-
export function inlineBackgroundImages(source: Element, clone: Element,
|
|
9
|
+
export function inlineBackgroundImages(source: Element, clone: Element, options?: Object): Promise<void>;
|
|
@@ -15,11 +15,9 @@ export function iconToImage(unicodeChar: string, fontFamily: string, fontWeight:
|
|
|
15
15
|
*
|
|
16
16
|
* @export
|
|
17
17
|
* @param {Object} options
|
|
18
|
-
* @param {boolean} [options.ignoreIconFonts=true] - Whether to skip icon fonts
|
|
19
18
|
* @param {boolean} [options.preCached=false] - Whether to use pre-cached resources
|
|
20
19
|
* @returns {Promise<string>} The inlined CSS for custom fonts
|
|
21
20
|
*/
|
|
22
|
-
export function embedCustomFonts({
|
|
23
|
-
ignoreIconFonts?: boolean | undefined;
|
|
21
|
+
export function embedCustomFonts({ preCached }?: {
|
|
24
22
|
preCached?: boolean | undefined;
|
|
25
23
|
}): Promise<string>;
|
|
@@ -3,10 +3,8 @@
|
|
|
3
3
|
*
|
|
4
4
|
* @param {Element} source - Original element
|
|
5
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
6
|
* @param {boolean} compress - Whether to compress style keys
|
|
9
7
|
* @param {boolean} embedFonts - Whether to embed icon fonts as images
|
|
10
8
|
* @returns {Promise} Promise that resolves when all pseudo-elements are processed
|
|
11
9
|
*/
|
|
12
|
-
export function inlinePseudoElements(source: Element, clone: Element,
|
|
10
|
+
export function inlinePseudoElements(source: Element, clone: Element, compress: boolean, embedFonts: boolean | undefined, useProxy: any): Promise<any>;
|
|
@@ -1,10 +1 @@
|
|
|
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;
|
|
1
|
+
export function inlineAllStyles(source: any, clone: any, compress: any): void;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Inlines external `<defs>` used by `<use xlink:href="#...">` or `<use href="#...">` inside SVGs,
|
|
3
|
+
* copying only the necessary definitions into each individual cloned SVG.
|
|
4
|
+
*
|
|
5
|
+
* This is needed because cloned SVGs using `<use>` may reference elements like `<symbol>`, `<path>`, etc.,
|
|
6
|
+
* defined elsewhere in the document (e.g., in a shared `<defs>` block that is not part of the cloned subtree).
|
|
7
|
+
*
|
|
8
|
+
* The function finds all `<use>` elements within `root`, extracts the referenced IDs,
|
|
9
|
+
* and embeds the required definitions at the top of each SVG.
|
|
10
|
+
*
|
|
11
|
+
* @function inlineExternalDef
|
|
12
|
+
* @param {ParentNode} root - The root node containing cloned SVGs (usually the result of a DOM snapshot).
|
|
13
|
+
* @returns {void}
|
|
14
|
+
*
|
|
15
|
+
* @example
|
|
16
|
+
* const { clone } = await prepareClone(element);
|
|
17
|
+
* inlineExternalDef(clone);
|
|
18
|
+
*/
|
|
19
|
+
export function inlineExternalDef(root: ParentNode): void;
|
|
@@ -32,7 +32,6 @@ export function generateDedupedBaseCSS(usedTagNames: string[]): string;
|
|
|
32
32
|
/**
|
|
33
33
|
* Generates CSS classes from a style map.
|
|
34
34
|
*
|
|
35
|
-
* @param {Map} styleMap - Map of elements to style keys
|
|
36
35
|
* @returns {Map} Map of style keys to class names
|
|
37
36
|
*/
|
|
38
|
-
export function generateCSSClasses(
|
|
37
|
+
export function generateCSSClasses(): Map<any, any>;
|
|
@@ -56,7 +56,7 @@ export function isIconFont(familyOrUrl: string): boolean;
|
|
|
56
56
|
* @param {number} [timeout=3000]
|
|
57
57
|
* @return {*}
|
|
58
58
|
*/
|
|
59
|
-
export function fetchImage(src: any, timeout
|
|
59
|
+
export function fetchImage(src: any, { timeout, useProxy }?: number): any;
|
|
60
60
|
/**
|
|
61
61
|
*
|
|
62
62
|
*
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import { HSL, HSV, Numberify, RGB } from './interfaces.js';
|
|
2
|
+
/**
|
|
3
|
+
* Handle bounds / percentage checking to conform to CSS color spec
|
|
4
|
+
* <http://www.w3.org/TR/css3-color/>
|
|
5
|
+
* *Assumes:* r, g, b in [0, 255] or [0, 1]
|
|
6
|
+
* *Returns:* { r, g, b } in [0, 255]
|
|
7
|
+
*/
|
|
8
|
+
export declare function rgbToRgb(r: number | string, g: number | string, b: number | string): Numberify<RGB>;
|
|
9
|
+
/**
|
|
10
|
+
* Converts an RGB color value to HSL.
|
|
11
|
+
* *Assumes:* r, g, and b are contained in [0, 255] or [0, 1]
|
|
12
|
+
* *Returns:* { h, s, l } in [0,1]
|
|
13
|
+
*/
|
|
14
|
+
export declare function rgbToHsl(r: number, g: number, b: number): Numberify<HSL>;
|
|
15
|
+
/**
|
|
16
|
+
* Converts an HSL color value to RGB.
|
|
17
|
+
*
|
|
18
|
+
* *Assumes:* h is contained in [0, 1] or [0, 360] and s and l are contained [0, 1] or [0, 100]
|
|
19
|
+
* *Returns:* { r, g, b } in the set [0, 255]
|
|
20
|
+
*/
|
|
21
|
+
export declare function hslToRgb(h: number | string, s: number | string, l: number | string): Numberify<RGB>;
|
|
22
|
+
/**
|
|
23
|
+
* Converts an RGB color value to HSV
|
|
24
|
+
*
|
|
25
|
+
* *Assumes:* r, g, and b are contained in the set [0, 255] or [0, 1]
|
|
26
|
+
* *Returns:* { h, s, v } in [0,1]
|
|
27
|
+
*/
|
|
28
|
+
export declare function rgbToHsv(r: number, g: number, b: number): Numberify<HSV>;
|
|
29
|
+
/**
|
|
30
|
+
* Converts an HSV color value to RGB.
|
|
31
|
+
*
|
|
32
|
+
* *Assumes:* h is contained in [0, 1] or [0, 360] and s and v are contained in [0, 1] or [0, 100]
|
|
33
|
+
* *Returns:* { r, g, b } in the set [0, 255]
|
|
34
|
+
*/
|
|
35
|
+
export declare function hsvToRgb(h: number | string, s: number | string, v: number | string): Numberify<RGB>;
|
|
36
|
+
/**
|
|
37
|
+
* Converts an RGB color to hex
|
|
38
|
+
*
|
|
39
|
+
* *Assumes:* r, g, and b are contained in the set [0, 255]
|
|
40
|
+
* *Returns:* a 3 or 6 character hex
|
|
41
|
+
*/
|
|
42
|
+
export declare function rgbToHex(r: number, g: number, b: number, allow3Char: boolean): string;
|
|
43
|
+
/**
|
|
44
|
+
* Converts an RGBA color plus alpha transparency to hex
|
|
45
|
+
*
|
|
46
|
+
* *Assumes:* r, g, b are contained in the set [0, 255] and a in [0, 1]
|
|
47
|
+
* *Returns:* a 4 or 8 character rgba hex
|
|
48
|
+
*/
|
|
49
|
+
export declare function rgbaToHex(r: number, g: number, b: number, a: number, allow4Char: boolean): string;
|
|
50
|
+
/**
|
|
51
|
+
* Converts an RGBA color to an ARGB Hex8 string
|
|
52
|
+
* Rarely used, but required for "toFilter()"
|
|
53
|
+
*
|
|
54
|
+
* *Assumes:* r, g, b are contained in the set [0, 255] and a in [0, 1]
|
|
55
|
+
* *Returns:* a 8 character argb hex
|
|
56
|
+
*/
|
|
57
|
+
export declare function rgbaToArgbHex(r: number, g: number, b: number, a: number): string;
|
|
58
|
+
/**
|
|
59
|
+
* Converts CMYK to RBG
|
|
60
|
+
* Assumes c, m, y, k are in the set [0, 100]
|
|
61
|
+
*/
|
|
62
|
+
export declare function cmykToRgb(c: number, m: number, y: number, k: number): {
|
|
63
|
+
r: number;
|
|
64
|
+
g: number;
|
|
65
|
+
b: number;
|
|
66
|
+
};
|
|
67
|
+
export declare function rgbToCmyk(r: number, g: number, b: number): {
|
|
68
|
+
c: number;
|
|
69
|
+
m: number;
|
|
70
|
+
y: number;
|
|
71
|
+
k: number;
|
|
72
|
+
};
|
|
73
|
+
/** Converts a decimal to a hex value */
|
|
74
|
+
export declare function convertDecimalToHex(d: string | number): string;
|
|
75
|
+
/** Converts a hex value to a decimal */
|
|
76
|
+
export declare function convertHexToDecimal(h: string): number;
|
|
77
|
+
/** Parse a base-16 hex value into a base-10 integer */
|
|
78
|
+
export declare function parseIntFromHex(val: string): number;
|
|
79
|
+
export declare function numberInputToObject(color: number): RGB;
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { CMYK, HSL, HSLA, HSV, HSVA, RGB, RGBA } from './interfaces.js';
|
|
2
|
+
/**
|
|
3
|
+
* Given a string or object, convert that input to RGB
|
|
4
|
+
*
|
|
5
|
+
* Possible string inputs:
|
|
6
|
+
* ```
|
|
7
|
+
* "red"
|
|
8
|
+
* "#f00" or "f00"
|
|
9
|
+
* "#ff0000" or "ff0000"
|
|
10
|
+
* "#ff000000" or "ff000000"
|
|
11
|
+
* "rgb 255 0 0" or "rgb (255, 0, 0)"
|
|
12
|
+
* "rgb 1.0 0 0" or "rgb (1, 0, 0)"
|
|
13
|
+
* "rgba (255, 0, 0, 1)" or "rgba 255, 0, 0, 1"
|
|
14
|
+
* "rgba (1.0, 0, 0, 1)" or "rgba 1.0, 0, 0, 1"
|
|
15
|
+
* "hsl(0, 100%, 50%)" or "hsl 0 100% 50%"
|
|
16
|
+
* "hsla(0, 100%, 50%, 1)" or "hsla 0 100% 50%, 1"
|
|
17
|
+
* "hsv(0, 100%, 100%)" or "hsv 0 100% 100%"
|
|
18
|
+
* "cmyk(0, 20, 0, 0)" or "cmyk 0 20 0 0"
|
|
19
|
+
* ```
|
|
20
|
+
*/
|
|
21
|
+
export declare function inputToRGB(color: string | RGB | RGBA | HSL | HSLA | HSV | HSVA | CMYK | any): {
|
|
22
|
+
ok: boolean;
|
|
23
|
+
format: any;
|
|
24
|
+
r: number;
|
|
25
|
+
g: number;
|
|
26
|
+
b: number;
|
|
27
|
+
a: number;
|
|
28
|
+
};
|
|
29
|
+
/**
|
|
30
|
+
* Permissive string parsing. Take in a number of formats, and output an object
|
|
31
|
+
* based on detected format. Returns `{ r, g, b }` or `{ h, s, l }` or `{ h, s, v}` or `{c, m, y, k}` or `{c, m, y, k, a}`
|
|
32
|
+
*/
|
|
33
|
+
export declare function stringInputToObject(color: string): any;
|
|
34
|
+
/**
|
|
35
|
+
* Check to see if it looks like a CSS unit
|
|
36
|
+
* (see `matchers` above for definition).
|
|
37
|
+
*/
|
|
38
|
+
export declare function isValidCSSUnit(color: string | number): boolean;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { TinyColor } from './index.js';
|
|
2
|
+
export interface RatioInput {
|
|
3
|
+
r: number | string;
|
|
4
|
+
g: number | string;
|
|
5
|
+
b: number | string;
|
|
6
|
+
a?: number | string;
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* If input is an object, force 1 into "1.0" to handle ratios properly
|
|
10
|
+
* String input requires "1.0" as input, so 1 will be treated as 1
|
|
11
|
+
*/
|
|
12
|
+
export declare function fromRatio(ratio: RatioInput, opts?: any): TinyColor;
|
|
13
|
+
/** old random function */
|
|
14
|
+
export declare function legacyRandom(): TinyColor;
|