@cyberalien/svg-utils 1.1.0 → 1.1.2
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/lib/classname/{toggle.mjs → toggle.js} +1 -1
- package/lib/components/export/{exports.d.mts → exports.d.ts} +1 -1
- package/lib/components/export/{file.d.mts → file.d.ts} +3 -3
- package/lib/components/export/{file.mjs → file.js} +1 -1
- package/lib/components/export/{filename.d.mts → filename.d.ts} +2 -2
- package/lib/components/export/{fs.d.mts → fs.d.ts} +1 -1
- package/lib/components/export/{merge.d.mts → merge.d.ts} +1 -1
- package/lib/components/helpers/content/{ratio.d.mts → ratio.d.ts} +1 -1
- package/lib/components/helpers/content/{size.d.mts → size.d.ts} +2 -2
- package/lib/components/helpers/content/{size.mjs → size.js} +1 -1
- package/lib/components/helpers/content/{stringify.d.mts → stringify.d.ts} +2 -2
- package/lib/components/helpers/content/{stringify.mjs → stringify.js} +1 -1
- package/lib/components/helpers/css/{generate.d.mts → generate.d.ts} +4 -4
- package/lib/components/helpers/css/{generate.mjs → generate.js} +3 -3
- package/lib/components/helpers/css/{name.mjs → name.js} +1 -1
- package/lib/components/helpers/filenames/{asset.d.mts → asset.d.ts} +1 -1
- package/lib/components/helpers/filenames/{css.d.mts → css.d.ts} +1 -1
- package/lib/components/helpers/filenames/{css.mjs → css.js} +1 -1
- package/lib/components/helpers/filenames/{path.d.mts → path.d.ts} +1 -1
- package/lib/components/helpers/filenames/{types.d.mts → types.d.ts} +3 -3
- package/lib/components/helpers/filenames/{types.mjs → types.js} +3 -3
- package/lib/components/helpers/functions/{size.d.mts → size.d.ts} +3 -3
- package/lib/components/helpers/functions/{size.mjs → size.js} +1 -1
- package/lib/components/helpers/imports/{add.d.mts → add.d.ts} +1 -1
- package/lib/components/helpers/imports/{create.d.mts → create.d.ts} +1 -1
- package/lib/components/helpers/imports/{stringify.d.mts → stringify.d.ts} +1 -1
- package/lib/components/helpers/props/{object.d.mts → object.d.ts} +1 -1
- package/lib/components/helpers/props/{object.mjs → object.js} +1 -1
- package/lib/components/helpers/props/{stringify.d.mts → stringify.d.ts} +1 -1
- package/lib/components/helpers/props/{ts.d.mts → ts.d.ts} +1 -1
- package/lib/components/helpers/ts/jsx.d.ts +13 -0
- package/lib/components/helpers/ts/{jsx.mjs → jsx.js} +1 -1
- package/lib/components/helpers/ts/svelte.d.ts +9 -0
- package/lib/components/helpers/ts/{svelte.mjs → svelte.js} +1 -1
- package/lib/components/helpers/ts/vue.d.ts +9 -0
- package/lib/components/helpers/ts/{vue.mjs → vue.js} +1 -1
- package/lib/components/helpers/ts/wrapper.d.ts +9 -0
- package/lib/components/helpers/ts/{wrapper.mjs → wrapper.js} +2 -2
- package/lib/components/{jsx.d.mts → jsx.d.ts} +4 -4
- package/lib/components/{jsx.mjs → jsx.js} +13 -13
- package/lib/components/prepare/{iconify.d.mts → iconify.d.ts} +4 -4
- package/lib/components/prepare/{iconify.mjs → iconify.js} +3 -3
- package/lib/components/prepare/{options.d.mts → options.d.ts} +1 -1
- package/lib/components/prepare/{options.mjs → options.js} +2 -2
- package/lib/components/raw.d.ts +8 -0
- package/lib/components/{raw.mjs → raw.js} +8 -8
- package/lib/components/{svelte.d.mts → svelte.d.ts} +3 -3
- package/lib/components/{svelte.mjs → svelte.js} +13 -13
- package/lib/components/types/{data.d.mts → data.d.ts} +2 -2
- package/lib/components/types/{options.d.mts → options.d.ts} +2 -2
- package/lib/components/types/{source.d.mts → source.d.ts} +2 -2
- package/lib/components/vue-func.d.ts +8 -0
- package/lib/components/{vue-func.mjs → vue-func.js} +13 -13
- package/lib/components/{vue.d.mts → vue.d.ts} +3 -3
- package/lib/components/{vue.mjs → vue.js} +13 -13
- package/lib/css/{hash.d.mts → hash.d.ts} +1 -1
- package/lib/css/{hash.mjs → hash.js} +2 -2
- package/lib/css/{stringify.d.mts → stringify.d.ts} +1 -1
- package/lib/css/stylesheet.d.ts +16 -0
- package/lib/css/stylesheet.js +64 -0
- package/lib/css/types.d.ts +33 -0
- package/lib/helpers/hash/{context.d.mts → context.d.ts} +1 -1
- package/lib/helpers/hash/{unique.d.mts → unique.d.ts} +1 -1
- package/lib/helpers/hash/{unique.mjs → unique.js} +3 -3
- package/lib/helpers/misc/{compare.mjs → compare.js} +1 -1
- package/lib/helpers/misc/{keys.mjs → keys.js} +1 -1
- package/lib/helpers/misc/{promises.d.mts → promises.d.ts} +1 -1
- package/lib/helpers/misc/{promises.mjs → promises.js} +1 -1
- package/lib/iconify/icon/{nornalise.d.mts → nornalise.d.ts} +1 -1
- package/lib/iconify/icon/{nornalise.mjs → nornalise.js} +1 -1
- package/lib/iconify/icon/types.d.ts +6 -0
- package/lib/iconify/icon-set/{icon.mjs → icon.js} +1 -1
- package/lib/iconify/icon-set/{parse.d.mts → parse.d.ts} +1 -1
- package/lib/iconify/icon-set/{parse.mjs → parse.js} +1 -1
- package/lib/index.d.ts +30 -0
- package/lib/index.js +26 -0
- package/lib/svg/ids/{change.d.mts → change.d.ts} +2 -2
- package/lib/svg/ids/{change.mjs → change.js} +3 -3
- package/lib/svg/ids/{duplicate.d.mts → duplicate.d.ts} +2 -2
- package/lib/svg/ids/{duplicate.mjs → duplicate.js} +1 -1
- package/lib/svg/ids/{types.d.mts → types.d.ts} +2 -2
- package/lib/svg/ids/{unique.d.mts → unique.d.ts} +2 -2
- package/lib/svg/ids/{unique.mjs → unique.js} +2 -2
- package/lib/svg/ids/{unused.d.mts → unused.d.ts} +2 -2
- package/lib/svg/ids/{unused.mjs → unused.js} +1 -1
- package/lib/svg/viewbox/{minify.d.mts → minify.d.ts} +1 -1
- package/lib/svg/viewbox/{parse.d.mts → parse.d.ts} +1 -1
- package/lib/svg/viewbox/{square.d.mts → square.d.ts} +1 -1
- package/lib/svg/viewbox/{value.d.mts → value.d.ts} +1 -1
- package/lib/svg-css/{content.d.mts → content.d.ts} +1 -1
- package/lib/svg-css/{content.mjs → content.js} +3 -3
- package/lib/svg-css/props/{props.d.mts → props.d.ts} +2 -2
- package/lib/svg-css/props/{props.mjs → props.js} +3 -3
- package/lib/svg-css/props/{types.d.mts → types.d.ts} +1 -1
- package/lib/svg-css/{root.d.mts → root.d.ts} +3 -3
- package/lib/svg-css/{root.mjs → root.js} +4 -4
- package/lib/svg-css/{types.d.mts → types.d.ts} +2 -2
- package/lib/xml/{iterate.d.mts → iterate.d.ts} +1 -1
- package/lib/xml/{parse.d.mts → parse.d.ts} +1 -1
- package/lib/xml/{stringify.d.mts → stringify.d.ts} +1 -1
- package/package.json +7 -7
- package/lib/components/helpers/ts/jsx.d.mts +0 -13
- package/lib/components/helpers/ts/svelte.d.mts +0 -9
- package/lib/components/helpers/ts/vue.d.mts +0 -9
- package/lib/components/helpers/ts/wrapper.d.mts +0 -9
- package/lib/components/raw.d.mts +0 -8
- package/lib/components/vue-func.d.mts +0 -8
- package/lib/css/types.d.mts +0 -21
- package/lib/iconify/icon/types.d.mts +0 -6
- package/lib/index.d.mts +0 -28
- package/lib/index.mjs +0 -25
- /package/lib/classname/{const.d.mts → const.d.ts} +0 -0
- /package/lib/classname/{const.mjs → const.js} +0 -0
- /package/lib/classname/{toggle.d.mts → toggle.d.ts} +0 -0
- /package/lib/components/export/{exports.mjs → exports.js} +0 -0
- /package/lib/components/export/{filename.mjs → filename.js} +0 -0
- /package/lib/components/export/{fs.mjs → fs.js} +0 -0
- /package/lib/components/export/{merge.mjs → merge.js} +0 -0
- /package/lib/components/helpers/code/{lines.d.mts → lines.d.ts} +0 -0
- /package/lib/components/helpers/code/{lines.mjs → lines.js} +0 -0
- /package/lib/components/helpers/content/{ratio.mjs → ratio.js} +0 -0
- /package/lib/components/helpers/css/{name.d.mts → name.d.ts} +0 -0
- /package/lib/components/helpers/filenames/{asset.mjs → asset.js} +0 -0
- /package/lib/components/helpers/filenames/{path.mjs → path.js} +0 -0
- /package/lib/components/helpers/imports/{add.mjs → add.js} +0 -0
- /package/lib/components/helpers/imports/{create.mjs → create.js} +0 -0
- /package/lib/components/helpers/imports/{stringify.mjs → stringify.js} +0 -0
- /package/lib/components/helpers/imports/{types.d.mts → types.d.ts} +0 -0
- /package/lib/components/helpers/imports/{types.mjs → types.js} +0 -0
- /package/lib/components/helpers/props/{stringify.mjs → stringify.js} +0 -0
- /package/lib/components/helpers/props/{ts.mjs → ts.js} +0 -0
- /package/lib/components/helpers/props/{types.d.mts → types.d.ts} +0 -0
- /package/lib/components/helpers/props/{types.mjs → types.js} +0 -0
- /package/lib/components/types/{component.d.mts → component.d.ts} +0 -0
- /package/lib/components/types/{component.mjs → component.js} +0 -0
- /package/lib/components/types/{css.d.mts → css.d.ts} +0 -0
- /package/lib/components/types/{css.mjs → css.js} +0 -0
- /package/lib/components/types/{data.mjs → data.js} +0 -0
- /package/lib/components/types/{jsx.d.mts → jsx.d.ts} +0 -0
- /package/lib/components/types/{jsx.mjs → jsx.js} +0 -0
- /package/lib/components/types/{options.mjs → options.js} +0 -0
- /package/lib/components/types/{source.mjs → source.js} +0 -0
- /package/lib/css/{stringify.mjs → stringify.js} +0 -0
- /package/lib/css/{types.mjs → types.js} +0 -0
- /package/lib/helpers/hash/{context.mjs → context.js} +0 -0
- /package/lib/helpers/hash/{hash.d.mts → hash.d.ts} +0 -0
- /package/lib/helpers/hash/{hash.mjs → hash.js} +0 -0
- /package/lib/helpers/hash/{stringify.d.mts → stringify.d.ts} +0 -0
- /package/lib/helpers/hash/{stringify.mjs → stringify.js} +0 -0
- /package/lib/helpers/hash/{types.d.mts → types.d.ts} +0 -0
- /package/lib/helpers/hash/{types.mjs → types.js} +0 -0
- /package/lib/helpers/misc/{clone.d.mts → clone.d.ts} +0 -0
- /package/lib/helpers/misc/{clone.mjs → clone.js} +0 -0
- /package/lib/helpers/misc/{compare.d.mts → compare.d.ts} +0 -0
- /package/lib/helpers/misc/{keys.d.mts → keys.d.ts} +0 -0
- /package/lib/helpers/misc/{sort-object.d.mts → sort-object.d.ts} +0 -0
- /package/lib/helpers/misc/{sort-object.mjs → sort-object.js} +0 -0
- /package/lib/helpers/misc/{strings.d.mts → strings.d.ts} +0 -0
- /package/lib/helpers/misc/{strings.mjs → strings.js} +0 -0
- /package/lib/iconify/icon/{types.mjs → types.js} +0 -0
- /package/lib/iconify/icon-set/{defaults.d.mts → defaults.d.ts} +0 -0
- /package/lib/iconify/icon-set/{defaults.mjs → defaults.js} +0 -0
- /package/lib/iconify/icon-set/{icon.d.mts → icon.d.ts} +0 -0
- /package/lib/iconify/icon-set/{types.d.mts → types.d.ts} +0 -0
- /package/lib/iconify/icon-set/{types.mjs → types.js} +0 -0
- /package/lib/svg/content/{defs.d.mts → defs.d.ts} +0 -0
- /package/lib/svg/content/{defs.mjs → defs.js} +0 -0
- /package/lib/svg/ids/{string.d.mts → string.d.ts} +0 -0
- /package/lib/svg/ids/{string.mjs → string.js} +0 -0
- /package/lib/svg/ids/{types.mjs → types.js} +0 -0
- /package/lib/svg/props/{size.d.mts → size.d.ts} +0 -0
- /package/lib/svg/props/{size.mjs → size.js} +0 -0
- /package/lib/svg/props/{stringify.d.mts → stringify.d.ts} +0 -0
- /package/lib/svg/props/{stringify.mjs → stringify.js} +0 -0
- /package/lib/svg/viewbox/{minify.mjs → minify.js} +0 -0
- /package/lib/svg/viewbox/{parse.mjs → parse.js} +0 -0
- /package/lib/svg/viewbox/{square.mjs → square.js} +0 -0
- /package/lib/svg/viewbox/{types.d.mts → types.d.ts} +0 -0
- /package/lib/svg/viewbox/{types.mjs → types.js} +0 -0
- /package/lib/svg/viewbox/{value.mjs → value.js} +0 -0
- /package/lib/svg-css/props/{prop.d.mts → prop.d.ts} +0 -0
- /package/lib/svg-css/props/{prop.mjs → prop.js} +0 -0
- /package/lib/svg-css/props/{tags.d.mts → tags.d.ts} +0 -0
- /package/lib/svg-css/props/{tags.mjs → tags.js} +0 -0
- /package/lib/svg-css/props/{types.mjs → types.js} +0 -0
- /package/lib/svg-css/{types.mjs → types.js} +0 -0
- /package/lib/xml/{iterate.mjs → iterate.js} +0 -0
- /package/lib/xml/{parse.mjs → parse.js} +0 -0
- /package/lib/xml/{stringify.mjs → stringify.js} +0 -0
- /package/lib/xml/{types.d.mts → types.d.ts} +0 -0
- /package/lib/xml/{types.mjs → types.js} +0 -0
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { sortObject } from "../helpers/misc/sort-object.
|
|
2
|
-
import { getUniqueHash } from "../helpers/hash/unique.
|
|
1
|
+
import { sortObject } from "../helpers/misc/sort-object.js";
|
|
2
|
+
import { getUniqueHash } from "../helpers/hash/unique.js";
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* Get class name for CSS rules
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { CSSGeneratedStylesheet, CSSRules } from "./types.js";
|
|
2
|
+
/**
|
|
3
|
+
* Create empty stylesheet
|
|
4
|
+
*/
|
|
5
|
+
declare function createEmptyStylesheet(): CSSGeneratedStylesheet;
|
|
6
|
+
/**
|
|
7
|
+
* Add generated selector to stylesheet
|
|
8
|
+
*
|
|
9
|
+
* If item exists, it will be overwritten. Class names should be hashed to avoid conflicts, so this should not cause issues.
|
|
10
|
+
*/
|
|
11
|
+
declare function addGeneratedSelector(stylesheet: CSSGeneratedStylesheet, tree: string[], rules: CSSRules | string): void;
|
|
12
|
+
/**
|
|
13
|
+
* Stringify generated stylesheet to CSS string
|
|
14
|
+
*/
|
|
15
|
+
declare function stringifyStylesheet(stylesheet: CSSGeneratedStylesheet): string;
|
|
16
|
+
export { addGeneratedSelector, createEmptyStylesheet, stringifyStylesheet };
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { stringifyCSSKeyframes, stringifyCSSSelector } from "./stringify.js";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Create empty stylesheet
|
|
5
|
+
*/
|
|
6
|
+
function createEmptyStylesheet() {
|
|
7
|
+
return {
|
|
8
|
+
selectors: Object.create(null),
|
|
9
|
+
keyframes: Object.create(null)
|
|
10
|
+
};
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Add generated selector to stylesheet
|
|
14
|
+
*
|
|
15
|
+
* If item exists, it will be overwritten. Class names should be hashed to avoid conflicts, so this should not cause issues.
|
|
16
|
+
*/
|
|
17
|
+
function addGeneratedSelector(stylesheet, tree, rules) {
|
|
18
|
+
let parent = stylesheet.selectors;
|
|
19
|
+
for (let i = 0; i < tree.length; i++) {
|
|
20
|
+
const selector = tree[i];
|
|
21
|
+
if (!parent[selector]) parent[selector] = {};
|
|
22
|
+
const parentItem = parent[selector];
|
|
23
|
+
if (i === tree.length - 1) {
|
|
24
|
+
parentItem.rules = rules;
|
|
25
|
+
return;
|
|
26
|
+
}
|
|
27
|
+
if (!parentItem.nested) parentItem.nested = Object.create(null);
|
|
28
|
+
parent = parentItem.nested;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
function indent(depth) {
|
|
32
|
+
return " ".repeat(depth);
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Stringify generated selectors to CSS string
|
|
36
|
+
*/
|
|
37
|
+
function stringifySelectors(data, depth = 0) {
|
|
38
|
+
const lines = [];
|
|
39
|
+
for (const selector in data) {
|
|
40
|
+
const item = data[selector];
|
|
41
|
+
if (item.rules) lines.push(stringifyCSSSelector(selector, item.rules, depth));
|
|
42
|
+
if (item.nested) {
|
|
43
|
+
const nestedContent = stringifySelectors(item.nested, depth + 1);
|
|
44
|
+
if (nestedContent.length) lines.push(`${indent(depth)}${selector} {\n${nestedContent}${indent(depth)}}\n`);
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
return lines.join("\n");
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Stringify generated stylesheet to CSS string
|
|
51
|
+
*/
|
|
52
|
+
function stringifyStylesheet(stylesheet) {
|
|
53
|
+
const lines = [];
|
|
54
|
+
const selectors = stringifySelectors(stylesheet.selectors);
|
|
55
|
+
if (selectors.length) lines.push(selectors);
|
|
56
|
+
for (const animationName in stylesheet.keyframes) {
|
|
57
|
+
const keyframes = stylesheet.keyframes[animationName];
|
|
58
|
+
const keyframesContent = stringifyCSSKeyframes(animationName, keyframes);
|
|
59
|
+
if (keyframesContent.length) lines.push(keyframesContent);
|
|
60
|
+
}
|
|
61
|
+
return lines.join("\n");
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
export { addGeneratedSelector, createEmptyStylesheet, stringifyStylesheet };
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { UniqueHashPartialOptions } from "../helpers/hash/types.js";
|
|
2
|
+
/**
|
|
3
|
+
* CSS rules
|
|
4
|
+
*/
|
|
5
|
+
type CSSRules = Record<string, string>;
|
|
6
|
+
/**
|
|
7
|
+
* Animation keyframes
|
|
8
|
+
*/
|
|
9
|
+
interface CSSKeyframe {
|
|
10
|
+
time: number;
|
|
11
|
+
value: string;
|
|
12
|
+
}
|
|
13
|
+
interface CSSKeyframes {
|
|
14
|
+
prop: string;
|
|
15
|
+
frames: CSSKeyframe[];
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Hash options
|
|
19
|
+
*/
|
|
20
|
+
type CSSHashOptions = UniqueHashPartialOptions;
|
|
21
|
+
/**
|
|
22
|
+
* Generated stylesheet
|
|
23
|
+
*/
|
|
24
|
+
interface CSSGeneratedSelector {
|
|
25
|
+
rules?: CSSRules | string;
|
|
26
|
+
nested?: CSSGeneratedSelectors;
|
|
27
|
+
}
|
|
28
|
+
type CSSGeneratedSelectors = Record<string, CSSGeneratedSelector>;
|
|
29
|
+
interface CSSGeneratedStylesheet {
|
|
30
|
+
selectors: CSSGeneratedSelectors;
|
|
31
|
+
keyframes: Record<string, CSSKeyframes>;
|
|
32
|
+
}
|
|
33
|
+
export { CSSGeneratedSelector, CSSGeneratedSelectors, CSSGeneratedStylesheet, CSSHashOptions, CSSKeyframe, CSSKeyframes, CSSRules };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { sortObject } from "../misc/sort-object.
|
|
2
|
-
import { hashToString } from "./stringify.
|
|
3
|
-
import { hashString } from "./hash.
|
|
1
|
+
import { sortObject } from "../misc/sort-object.js";
|
|
2
|
+
import { hashToString } from "./stringify.js";
|
|
3
|
+
import { hashString } from "./hash.js";
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* Hash an object, make sure hash is unique
|
package/lib/index.d.ts
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { ClassProp, classProps, defaultClassProp } from "./classname/const.js";
|
|
2
|
+
import { splitClassName, toggleClassName } from "./classname/toggle.js";
|
|
3
|
+
import { HashContext, UniqueHashOptions, UniqueHashPartialOptions } from "./helpers/hash/types.js";
|
|
4
|
+
import { CSSGeneratedSelector, CSSGeneratedSelectors, CSSGeneratedStylesheet, CSSHashOptions, CSSKeyframe, CSSKeyframes, CSSRules } from "./css/types.js";
|
|
5
|
+
import { ParsedXMLNode, ParsedXMLTagElement, ParsedXMLTextElement, StringifyXMLOptions } from "./xml/types.js";
|
|
6
|
+
import { BaseConvertSVGContentOptions, ConvertSVGContentOptions, ConvertedSVGContent } from "./svg-css/types.js";
|
|
7
|
+
import { createCSSClassName } from "./css/hash.js";
|
|
8
|
+
import { stringifyCSSKeyframes, stringifyCSSRules, stringifyCSSSelector } from "./css/stringify.js";
|
|
9
|
+
import { addGeneratedSelector, createEmptyStylesheet, stringifyStylesheet } from "./css/stylesheet.js";
|
|
10
|
+
import { createUniqueHashContext } from "./helpers/hash/context.js";
|
|
11
|
+
import { hashString } from "./helpers/hash/hash.js";
|
|
12
|
+
import { hashToString } from "./helpers/hash/stringify.js";
|
|
13
|
+
import { getUniqueHash } from "./helpers/hash/unique.js";
|
|
14
|
+
import { cloneObject } from "./helpers/misc/clone.js";
|
|
15
|
+
import { compareSets, compareValues } from "./helpers/misc/compare.js";
|
|
16
|
+
import { ComparisonKey, compareKeys } from "./helpers/misc/keys.js";
|
|
17
|
+
import { uniquePromise } from "./helpers/misc/promises.js";
|
|
18
|
+
import { sortObject } from "./helpers/misc/sort-object.js";
|
|
19
|
+
import { iterateXMLContent } from "./xml/iterate.js";
|
|
20
|
+
import { parseXMLContent } from "./xml/parse.js";
|
|
21
|
+
import { stringifyXMLContent } from "./xml/stringify.js";
|
|
22
|
+
import { ChangeIDResult, UniqueIDOptions } from "./svg/ids/types.js";
|
|
23
|
+
import { changeIDInString } from "./svg/ids/string.js";
|
|
24
|
+
import { removeDuplicateIDs } from "./svg/ids/duplicate.js";
|
|
25
|
+
import { removeUnusedIDs } from "./svg/ids/unused.js";
|
|
26
|
+
import { changeSVGIDs } from "./svg/ids/change.js";
|
|
27
|
+
import { createUniqueIDs } from "./svg/ids/unique.js";
|
|
28
|
+
import { convertSVGRootToCSS } from "./svg-css/root.js";
|
|
29
|
+
import { convertSVGContentToCSSRules } from "./svg-css/content.js";
|
|
30
|
+
export { BaseConvertSVGContentOptions, CSSGeneratedSelector, CSSGeneratedSelectors, CSSGeneratedStylesheet, CSSHashOptions, CSSKeyframe, CSSKeyframes, CSSRules, ChangeIDResult, ClassProp, ComparisonKey, ConvertSVGContentOptions, ConvertedSVGContent, HashContext, ParsedXMLNode, ParsedXMLTagElement, ParsedXMLTextElement, StringifyXMLOptions, UniqueHashOptions, UniqueHashPartialOptions, UniqueIDOptions, addGeneratedSelector, changeIDInString, changeSVGIDs, classProps, cloneObject, compareKeys, compareSets, compareValues, convertSVGContentToCSSRules, convertSVGRootToCSS, createCSSClassName, createEmptyStylesheet, createUniqueHashContext, createUniqueIDs, defaultClassProp, getUniqueHash, hashString, hashToString, iterateXMLContent, parseXMLContent, removeDuplicateIDs, removeUnusedIDs, sortObject, splitClassName, stringifyCSSKeyframes, stringifyCSSRules, stringifyCSSSelector, stringifyStylesheet, stringifyXMLContent, toggleClassName, uniquePromise };
|
package/lib/index.js
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { cloneObject } from "./helpers/misc/clone.js";
|
|
2
|
+
import { sortObject } from "./helpers/misc/sort-object.js";
|
|
3
|
+
import { compareSets, compareValues } from "./helpers/misc/compare.js";
|
|
4
|
+
import { compareKeys } from "./helpers/misc/keys.js";
|
|
5
|
+
import { uniquePromise } from "./helpers/misc/promises.js";
|
|
6
|
+
import { createUniqueHashContext } from "./helpers/hash/context.js";
|
|
7
|
+
import { hashToString } from "./helpers/hash/stringify.js";
|
|
8
|
+
import { hashString } from "./helpers/hash/hash.js";
|
|
9
|
+
import { getUniqueHash } from "./helpers/hash/unique.js";
|
|
10
|
+
import { iterateXMLContent } from "./xml/iterate.js";
|
|
11
|
+
import { parseXMLContent } from "./xml/parse.js";
|
|
12
|
+
import { stringifyXMLContent } from "./xml/stringify.js";
|
|
13
|
+
import { createCSSClassName } from "./css/hash.js";
|
|
14
|
+
import { stringifyCSSKeyframes, stringifyCSSRules, stringifyCSSSelector } from "./css/stringify.js";
|
|
15
|
+
import { addGeneratedSelector, createEmptyStylesheet, stringifyStylesheet } from "./css/stylesheet.js";
|
|
16
|
+
import { classProps, defaultClassProp } from "./classname/const.js";
|
|
17
|
+
import { splitClassName, toggleClassName } from "./classname/toggle.js";
|
|
18
|
+
import { changeIDInString } from "./svg/ids/string.js";
|
|
19
|
+
import { removeDuplicateIDs } from "./svg/ids/duplicate.js";
|
|
20
|
+
import { removeUnusedIDs } from "./svg/ids/unused.js";
|
|
21
|
+
import { changeSVGIDs } from "./svg/ids/change.js";
|
|
22
|
+
import { createUniqueIDs } from "./svg/ids/unique.js";
|
|
23
|
+
import { convertSVGRootToCSS } from "./svg-css/root.js";
|
|
24
|
+
import { convertSVGContentToCSSRules } from "./svg-css/content.js";
|
|
25
|
+
|
|
26
|
+
export { addGeneratedSelector, changeIDInString, changeSVGIDs, classProps, cloneObject, compareKeys, compareSets, compareValues, convertSVGContentToCSSRules, convertSVGRootToCSS, createCSSClassName, createEmptyStylesheet, createUniqueHashContext, createUniqueIDs, defaultClassProp, getUniqueHash, hashString, hashToString, iterateXMLContent, parseXMLContent, removeDuplicateIDs, removeUnusedIDs, sortObject, splitClassName, stringifyCSSKeyframes, stringifyCSSRules, stringifyCSSSelector, stringifyStylesheet, stringifyXMLContent, toggleClassName, uniquePromise };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { ParsedXMLTagElement } from "../../xml/types.
|
|
2
|
-
import { ChangeIDResult } from "./types.
|
|
1
|
+
import { ParsedXMLTagElement } from "../../xml/types.js";
|
|
2
|
+
import { ChangeIDResult } from "./types.js";
|
|
3
3
|
type HashCallback = (id: string, content: string, tagName: string) => string;
|
|
4
4
|
/**
|
|
5
5
|
* Change IDs in SVG using a callback function
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { iterateXMLContent } from "../../xml/iterate.
|
|
2
|
-
import { stringifyXMLContent } from "../../xml/stringify.
|
|
3
|
-
import { changeIDInString } from "./string.
|
|
1
|
+
import { iterateXMLContent } from "../../xml/iterate.js";
|
|
2
|
+
import { stringifyXMLContent } from "../../xml/stringify.js";
|
|
3
|
+
import { changeIDInString } from "./string.js";
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* Change IDs in SVG using a callback function
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { UniqueHashPartialOptions } from "../../helpers/hash/types.
|
|
2
|
-
import { ParsedXMLTagElement } from "../../xml/types.
|
|
1
|
+
import { UniqueHashPartialOptions } from "../../helpers/hash/types.js";
|
|
2
|
+
import { ParsedXMLTagElement } from "../../xml/types.js";
|
|
3
3
|
interface ChangeIDResult {
|
|
4
4
|
map: Record<string, ParsedXMLTagElement[]>;
|
|
5
5
|
usage: Record<string, ParsedXMLTagElement[]>;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { parseXMLContent } from "../xml/parse.
|
|
2
|
-
import { stringifyXMLContent } from "../xml/stringify.
|
|
3
|
-
import { convertSVGRootToCSS } from "./root.
|
|
1
|
+
import { parseXMLContent } from "../xml/parse.js";
|
|
2
|
+
import { stringifyXMLContent } from "../xml/stringify.js";
|
|
3
|
+
import { convertSVGRootToCSS } from "./root.js";
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* Convert SVG content string to SVG+CSS
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { ParsedXMLTagElement } from "../../xml/types.
|
|
2
|
-
import { SVGConvertedToCSSProperties } from "./types.
|
|
1
|
+
import { ParsedXMLTagElement } from "../../xml/types.js";
|
|
2
|
+
import { SVGConvertedToCSSProperties } from "./types.js";
|
|
3
3
|
/**
|
|
4
4
|
* Extract SVG tag properties that can be converted to CSS
|
|
5
5
|
*
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { iterateXMLContent } from "../../xml/iterate.
|
|
2
|
-
import { convertSVGPropertyToCSS } from "./prop.
|
|
3
|
-
import { svgAnimateTransformTag, svgAnimationTag, svgSetTag } from "./tags.
|
|
1
|
+
import { iterateXMLContent } from "../../xml/iterate.js";
|
|
2
|
+
import { convertSVGPropertyToCSS } from "./prop.js";
|
|
3
|
+
import { svgAnimateTransformTag, svgAnimationTag, svgSetTag } from "./tags.js";
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* Extract SVG tag properties that can be converted to CSS
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { CSSRules } from "../css/types.
|
|
2
|
-
import { ParsedXMLTagElement } from "../xml/types.
|
|
3
|
-
import { BaseConvertSVGContentOptions } from "./types.
|
|
1
|
+
import { CSSRules } from "../css/types.js";
|
|
2
|
+
import { ParsedXMLTagElement } from "../xml/types.js";
|
|
3
|
+
import { BaseConvertSVGContentOptions } from "./types.js";
|
|
4
4
|
/**
|
|
5
5
|
* Convert SVG tags tree to SVG+CSS
|
|
6
6
|
*
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { iterateXMLContent } from "../xml/iterate.
|
|
2
|
-
import { createCSSClassName } from "../css/hash.
|
|
3
|
-
import { toggleClassName } from "../classname/toggle.
|
|
4
|
-
import { extractSVGTagPropertiesForCSS } from "./props/props.
|
|
1
|
+
import { iterateXMLContent } from "../xml/iterate.js";
|
|
2
|
+
import { createCSSClassName } from "../css/hash.js";
|
|
3
|
+
import { toggleClassName } from "../classname/toggle.js";
|
|
4
|
+
import { extractSVGTagPropertiesForCSS } from "./props/props.js";
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
7
|
* Convert SVG tags tree to SVG+CSS
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { CSSHashOptions, CSSKeyframes, CSSRules } from "../css/types.
|
|
2
|
-
import { StringifyXMLOptions } from "../xml/types.
|
|
1
|
+
import { CSSHashOptions, CSSKeyframes, CSSRules } from "../css/types.js";
|
|
2
|
+
import { StringifyXMLOptions } from "../xml/types.js";
|
|
3
3
|
/**
|
|
4
4
|
* Options for converting SVG tags to SVG+CSS
|
|
5
5
|
*/
|
package/package.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"type": "module",
|
|
4
4
|
"description": "Common functions for working with SVG used by various packages.",
|
|
5
5
|
"author": "Vjacheslav Trushkin",
|
|
6
|
-
"version": "1.1.
|
|
6
|
+
"version": "1.1.2",
|
|
7
7
|
"license": "MIT",
|
|
8
8
|
"bugs": "https://github.com/cyberalien/svg-utils/issues",
|
|
9
9
|
"homepage": "https://cyberalien.dev/",
|
|
@@ -25,14 +25,14 @@
|
|
|
25
25
|
"devDependencies": {
|
|
26
26
|
"@eslint/eslintrc": "^3.3.3",
|
|
27
27
|
"@eslint/js": "^9.39.2",
|
|
28
|
-
"@iconify-json/ri": "^1.2.
|
|
28
|
+
"@iconify-json/ri": "^1.2.10",
|
|
29
29
|
"@types/jest": "^30.0.0",
|
|
30
|
-
"@types/node": "^25.
|
|
31
|
-
"@typescript-eslint/eslint-plugin": "^8.
|
|
32
|
-
"@typescript-eslint/parser": "^8.
|
|
30
|
+
"@types/node": "^25.2.3",
|
|
31
|
+
"@typescript-eslint/eslint-plugin": "^8.55.0",
|
|
32
|
+
"@typescript-eslint/parser": "^8.55.0",
|
|
33
33
|
"eslint": "^9.39.2",
|
|
34
|
-
"globals": "^17.
|
|
35
|
-
"tsdown": "^0.20.
|
|
34
|
+
"globals": "^17.3.0",
|
|
35
|
+
"tsdown": "^0.20.3",
|
|
36
36
|
"typescript": "^5.9.3",
|
|
37
37
|
"vitest": "^4.0.18"
|
|
38
38
|
},
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { GeneratedAssetFile } from "../../types/component.mjs";
|
|
2
|
-
import { FactoryIconData } from "../../types/data.mjs";
|
|
3
|
-
import { ComponentFactoryOptions } from "../../types/options.mjs";
|
|
4
|
-
import { FactoryComponentProps } from "../props/types.mjs";
|
|
5
|
-
import { JSXMode } from "../../types/jsx.mjs";
|
|
6
|
-
interface Options extends ComponentFactoryOptions {
|
|
7
|
-
jsx: JSXMode;
|
|
8
|
-
}
|
|
9
|
-
/**
|
|
10
|
-
* Add JSX component types
|
|
11
|
-
*/
|
|
12
|
-
declare function addJSXComponentTypes(data: FactoryIconData, options: Options, assets: GeneratedAssetFile[], props: FactoryComponentProps): string;
|
|
13
|
-
export { addJSXComponentTypes };
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { GeneratedAssetFile } from "../../types/component.mjs";
|
|
2
|
-
import { FactoryIconData } from "../../types/data.mjs";
|
|
3
|
-
import { ComponentFactoryOptions } from "../../types/options.mjs";
|
|
4
|
-
import { FactoryComponentProps } from "../props/types.mjs";
|
|
5
|
-
/**
|
|
6
|
-
* Add Svelte component types
|
|
7
|
-
*/
|
|
8
|
-
declare const addSvelteComponentTypes: (data: FactoryIconData, options: ComponentFactoryOptions, assets: GeneratedAssetFile[], props: FactoryComponentProps) => string;
|
|
9
|
-
export { addSvelteComponentTypes };
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { GeneratedAssetFile } from "../../types/component.mjs";
|
|
2
|
-
import { FactoryIconData } from "../../types/data.mjs";
|
|
3
|
-
import { ComponentFactoryOptions } from "../../types/options.mjs";
|
|
4
|
-
import { FactoryComponentProps } from "../props/types.mjs";
|
|
5
|
-
/**
|
|
6
|
-
* Add Vue component types
|
|
7
|
-
*/
|
|
8
|
-
declare const addVueComponentTypes: (data: FactoryIconData, options: ComponentFactoryOptions, assets: GeneratedAssetFile[], props: FactoryComponentProps) => string;
|
|
9
|
-
export { addVueComponentTypes };
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { GeneratedAssetFile } from "../../types/component.mjs";
|
|
2
|
-
import { FactoryIconData } from "../../types/data.mjs";
|
|
3
|
-
import { ComponentFactoryOptions } from "../../types/options.mjs";
|
|
4
|
-
import { FactoryComponentProps } from "../props/types.mjs";
|
|
5
|
-
/**
|
|
6
|
-
* Add component types
|
|
7
|
-
*/
|
|
8
|
-
declare function addComponentTypes(template: string, data: FactoryIconData, options: ComponentFactoryOptions, assets: GeneratedAssetFile[], props: FactoryComponentProps): string;
|
|
9
|
-
export { addComponentTypes };
|
package/lib/components/raw.d.mts
DELETED
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { FactoryGeneratedComponent } from "./types/component.mjs";
|
|
2
|
-
import { FactoryIconData } from "./types/data.mjs";
|
|
3
|
-
import { ComponentFactoryOptions } from "./types/options.mjs";
|
|
4
|
-
/**
|
|
5
|
-
* Create raw component code
|
|
6
|
-
*/
|
|
7
|
-
declare function createRawComponent(data: FactoryIconData, options: ComponentFactoryOptions): FactoryGeneratedComponent;
|
|
8
|
-
export { createRawComponent };
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { FactoryGeneratedComponent } from "./types/component.mjs";
|
|
2
|
-
import { FactoryIconData } from "./types/data.mjs";
|
|
3
|
-
import { ComponentFactoryOptions } from "./types/options.mjs";
|
|
4
|
-
/**
|
|
5
|
-
* Create functional Vue component code
|
|
6
|
-
*/
|
|
7
|
-
declare function createVueFunctionalComponent(data: FactoryIconData, options: ComponentFactoryOptions): FactoryGeneratedComponent;
|
|
8
|
-
export { createVueFunctionalComponent };
|