@cyberalien/svg-utils 0.0.17 → 0.1.0
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/css/stringify.d.ts +6 -2
- package/lib/css/stringify.js +21 -1
- package/lib/css/types.d.ts +12 -1
- package/lib/helpers/misc/strings.js +2 -4
- package/lib/iconify/icon/nornalise.d.ts +7 -0
- package/lib/iconify/icon/nornalise.js +63 -0
- package/lib/iconify/icon/types.d.ts +6 -0
- package/lib/iconify/icon/types.js +1 -0
- package/lib/iconify/icon-set/defaults.d.ts +6 -0
- package/lib/iconify/icon-set/defaults.js +19 -0
- package/lib/iconify/icon-set/icon.d.ts +6 -0
- package/lib/iconify/icon-set/icon.js +24 -0
- package/lib/iconify/icon-set/parse.d.ts +7 -0
- package/lib/iconify/icon-set/parse.js +31 -0
- package/lib/iconify/icon-set/types.d.ts +6 -0
- package/lib/index.d.ts +2 -2
- package/lib/index.js +2 -2
- package/lib/svg/content/defs.d.ts +20 -0
- package/lib/svg/content/defs.js +44 -0
- package/lib/svg/ids/duplicate.js +1 -4
- package/lib/svg/ids/unused.js +1 -2
- package/lib/svg/props/size.d.ts +8 -0
- package/lib/svg/props/size.js +34 -0
- package/lib/svg/props/stringify.d.ts +5 -0
- package/lib/svg/props/stringify.js +8 -0
- package/lib/svg/viewbox/minify.d.ts +6 -0
- package/lib/svg/viewbox/minify.js +15 -0
- package/lib/svg/viewbox/parse.d.ts +6 -0
- package/lib/svg/viewbox/parse.js +17 -0
- package/lib/svg/viewbox/square.d.ts +6 -0
- package/lib/svg/viewbox/square.js +24 -0
- package/lib/svg-css/convert/content.d.ts +2 -5
- package/lib/svg-css/convert/types.d.ts +5 -0
- package/lib/svg-css/convert/types.js +1 -0
- package/lib/svg-css/factory/code/iconify.d.ts +11 -0
- package/lib/svg-css/factory/code/iconify.js +20 -0
- package/lib/svg-css/factory/code/stringify.d.ts +5 -0
- package/lib/svg-css/factory/code/stringify.js +9 -0
- package/lib/svg-css/factory/code/template.d.ts +6 -0
- package/lib/svg-css/factory/code/template.js +15 -0
- package/lib/svg-css/factory/components/raw.d.ts +8 -0
- package/lib/svg-css/factory/components/raw.js +41 -0
- package/lib/svg-css/factory/components/shared/size.js +79 -0
- package/lib/svg-css/factory/components/vue/types.js +25 -0
- package/lib/svg-css/factory/components/vue.d.ts +8 -0
- package/lib/svg-css/factory/components/vue.js +103 -0
- package/lib/svg-css/factory/content/size.d.ts +11 -0
- package/lib/svg-css/factory/content/size.js +22 -0
- package/lib/svg-css/factory/content/stringify.d.ts +7 -0
- package/lib/svg-css/factory/content/stringify.js +17 -0
- package/lib/svg-css/factory/css/generate.d.ts +11 -0
- package/lib/svg-css/factory/css/generate.js +45 -0
- package/lib/svg-css/factory/css/name.d.ts +7 -0
- package/lib/svg-css/factory/css/name.js +12 -0
- package/lib/svg-css/factory/export/exports.d.ts +10 -0
- package/lib/svg-css/factory/export/exports.js +11 -0
- package/lib/svg-css/factory/export/file.d.ts +6 -0
- package/lib/svg-css/factory/export/file.js +12 -0
- package/lib/svg-css/factory/export/fs.d.ts +2 -2
- package/lib/svg-css/factory/export/merge.d.ts +7 -0
- package/lib/svg-css/factory/export/merge.js +23 -0
- package/lib/svg-css/factory/filenames/asset.d.ts +11 -0
- package/lib/svg-css/factory/filenames/asset.js +16 -0
- package/lib/svg-css/factory/filenames/component.d.ts +12 -0
- package/lib/svg-css/factory/filenames/component.js +14 -0
- package/lib/svg-css/factory/filenames/css.d.ts +7 -0
- package/lib/svg-css/factory/filenames/css.js +14 -0
- package/lib/svg-css/factory/filenames/options.d.ts +6 -0
- package/lib/svg-css/factory/filenames/options.js +27 -0
- package/lib/svg-css/factory/filenames/path.d.ts +11 -0
- package/lib/svg-css/factory/filenames/path.js +15 -0
- package/lib/svg-css/factory/filenames/types.d.ts +8 -0
- package/lib/svg-css/factory/filenames/types.js +14 -0
- package/lib/svg-css/factory/imports/add.d.ts +10 -0
- package/lib/svg-css/factory/imports/add.js +18 -0
- package/lib/svg-css/factory/imports/create.d.ts +6 -0
- package/lib/svg-css/factory/imports/create.js +15 -0
- package/lib/svg-css/factory/imports/stringify.d.ts +6 -0
- package/lib/svg-css/factory/imports/stringify.js +47 -0
- package/lib/svg-css/factory/props/object.d.ts +6 -0
- package/lib/svg-css/factory/props/object.js +10 -0
- package/lib/svg-css/factory/props/stringify.d.ts +10 -0
- package/lib/svg-css/factory/props/stringify.js +21 -0
- package/lib/svg-css/factory/props/types.d.ts +6 -0
- package/lib/svg-css/factory/props/types.js +16 -0
- package/lib/svg-css/factory/types/asset.d.ts +8 -0
- package/lib/svg-css/factory/types/asset.js +1 -0
- package/lib/svg-css/factory/types/component.d.ts +38 -0
- package/lib/svg-css/factory/types/component.js +1 -0
- package/lib/svg-css/factory/types/css.d.ts +5 -0
- package/lib/svg-css/factory/types/css.js +1 -0
- package/lib/svg-css/factory/types/data.d.ts +13 -0
- package/lib/svg-css/factory/types/data.js +1 -0
- package/lib/svg-css/factory/types/file.d.ts +14 -0
- package/lib/svg-css/factory/types/file.js +1 -0
- package/lib/svg-css/factory/types/options.d.ts +26 -0
- package/lib/svg-css/factory/types/options.js +1 -0
- package/lib/svg-css/factory/types/props.d.ts +14 -0
- package/lib/svg-css/factory/types/props.js +1 -0
- package/lib/svg-css/factory/types/source.d.ts +10 -0
- package/lib/svg-css/factory/types/source.js +1 -0
- package/lib/svg-css/types.d.ts +2 -1
- package/lib/xml/parse.js +2 -4
- package/package.json +11 -9
- package/lib/svg-css/factory/helpers/add-css.d.ts +0 -8
- package/lib/svg-css/factory/helpers/add-css.js +0 -32
- package/lib/svg-css/factory/helpers/component-name.d.ts +0 -9
- package/lib/svg-css/factory/helpers/component-name.js +0 -17
- package/lib/svg-css/factory/helpers/component-path.d.ts +0 -5
- package/lib/svg-css/factory/helpers/component-path.js +0 -9
- package/lib/svg-css/factory/helpers/css-filename.d.ts +0 -5
- package/lib/svg-css/factory/helpers/css-filename.js +0 -10
- package/lib/svg-css/factory/helpers/exports.d.ts +0 -6
- package/lib/svg-css/factory/helpers/exports.js +0 -10
- package/lib/svg-css/factory/helpers/merge.d.ts +0 -6
- package/lib/svg-css/factory/helpers/merge.js +0 -19
- package/lib/svg-css/factory/helpers/options.d.ts +0 -6
- package/lib/svg-css/factory/helpers/options.js +0 -12
- package/lib/svg-css/factory/helpers/prefix.d.ts +0 -6
- package/lib/svg-css/factory/helpers/prefix.js +0 -8
- package/lib/svg-css/factory/iconify/vue.d.ts +0 -6
- package/lib/svg-css/factory/iconify/vue.js +0 -72
- package/lib/svg-css/factory/types.d.ts +0 -48
- /package/lib/{svg-css/factory → iconify/icon-set}/types.js +0 -0
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { getGeneratedComponentFilename } from "./component.js";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Generate component types filename based on options
|
|
5
|
+
*/
|
|
6
|
+
function getGeneratedComponentTypesFilename(icon, options) {
|
|
7
|
+
const filename = getGeneratedComponentFilename(icon, ".d.ts", options);
|
|
8
|
+
return {
|
|
9
|
+
filename,
|
|
10
|
+
import: `./${filename.split("/").pop()}`
|
|
11
|
+
};
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export { getGeneratedComponentTypesFilename };
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { FactoryComponentImports } from "../types/component.js";
|
|
2
|
+
/**
|
|
3
|
+
* Add named import
|
|
4
|
+
*/
|
|
5
|
+
declare function addNamedImport(data: FactoryComponentImports, source: string, names: string | string[]): void;
|
|
6
|
+
/**
|
|
7
|
+
* Add type import
|
|
8
|
+
*/
|
|
9
|
+
declare function addTypeImport(data: FactoryComponentImports, source: string, types: string | string[]): void;
|
|
10
|
+
export { addNamedImport, addTypeImport };
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
function addToSet(set, names) {
|
|
2
|
+
if (Array.isArray(names)) for (const name of names) set.add(name);
|
|
3
|
+
else set.add(names);
|
|
4
|
+
}
|
|
5
|
+
/**
|
|
6
|
+
* Add named import
|
|
7
|
+
*/
|
|
8
|
+
function addNamedImport(data, source, names) {
|
|
9
|
+
addToSet(data.named[source] ??= /* @__PURE__ */ new Set(), names);
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Add type import
|
|
13
|
+
*/
|
|
14
|
+
function addTypeImport(data, source, types) {
|
|
15
|
+
addToSet(data.types[source] ??= /* @__PURE__ */ new Set(), types);
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export { addNamedImport, addTypeImport };
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Create imports object
|
|
3
|
+
*/
|
|
4
|
+
function createFactoryImports() {
|
|
5
|
+
return {
|
|
6
|
+
default: Object.create(null),
|
|
7
|
+
named: Object.create(null),
|
|
8
|
+
types: Object.create(null),
|
|
9
|
+
full: /* @__PURE__ */ new Set(),
|
|
10
|
+
css: /* @__PURE__ */ new Set(),
|
|
11
|
+
modules: Object.create(null)
|
|
12
|
+
};
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export { createFactoryImports };
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Split relative and absolute imports
|
|
3
|
+
*/
|
|
4
|
+
function split(imports, relative) {
|
|
5
|
+
function isRelative(path) {
|
|
6
|
+
return path.startsWith(".") || path.startsWith("~") || path.startsWith("@/") || path.startsWith("virtual:");
|
|
7
|
+
}
|
|
8
|
+
function shouldInclude(path) {
|
|
9
|
+
return isRelative(path) === relative;
|
|
10
|
+
}
|
|
11
|
+
function filterObject(data) {
|
|
12
|
+
return Object.fromEntries(Object.entries(data).filter(([key]) => shouldInclude(key)));
|
|
13
|
+
}
|
|
14
|
+
return {
|
|
15
|
+
default: filterObject(imports.default),
|
|
16
|
+
named: filterObject(imports.named),
|
|
17
|
+
types: filterObject(imports.types),
|
|
18
|
+
modules: filterObject(imports.modules),
|
|
19
|
+
full: new Set([...imports.full].filter(shouldInclude)),
|
|
20
|
+
css: new Set([...imports.css].filter(shouldInclude))
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Export imports as string
|
|
25
|
+
*/
|
|
26
|
+
function stringifyFactoryImports(imports, includeTypes = true) {
|
|
27
|
+
const lines = [];
|
|
28
|
+
for (const isRelative of [false, true]) {
|
|
29
|
+
const data = split(imports, isRelative);
|
|
30
|
+
for (const source of data.full) lines.push(`import '${source}';`);
|
|
31
|
+
for (const source in data.default) lines.push(`import ${data.default[source]} from '${source}';`);
|
|
32
|
+
for (const source in data.named) {
|
|
33
|
+
const items = [...data.named[source]].sort().join(", ");
|
|
34
|
+
lines.push(`import { ${items} } from '${source}';`);
|
|
35
|
+
}
|
|
36
|
+
if (includeTypes) for (const source in data.types) {
|
|
37
|
+
const items = [...data.types[source]].sort().join(", ");
|
|
38
|
+
lines.push(`import type { ${items} } from '${source}';`);
|
|
39
|
+
}
|
|
40
|
+
for (const source of data.css) lines.push(`import '${source}';`);
|
|
41
|
+
for (const source in data.modules) lines.push(`import ${data.modules[source]} from '${source}';`);
|
|
42
|
+
}
|
|
43
|
+
if (lines.length) lines.push("");
|
|
44
|
+
return lines.join("\n");
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
export { stringifyFactoryImports };
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { stringifyFactoryProps } from "./stringify.js";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Stringify properties for component as JS object
|
|
5
|
+
*/
|
|
6
|
+
function stringifyFactoryPropsAsJSON(props, separator = "\n ") {
|
|
7
|
+
return stringifyFactoryProps(props, "\"{prop}\": {value},", "\"{prop}\": \"{value}\",", separator);
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export { stringifyFactoryPropsAsJSON };
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { FactoryComponentProps } from "../types/props.js";
|
|
2
|
+
/**
|
|
3
|
+
* Template for property
|
|
4
|
+
*/
|
|
5
|
+
declare const factoryPropTemplate = "{prop}=\"{value}\"";
|
|
6
|
+
/**
|
|
7
|
+
* Stringify properties for component
|
|
8
|
+
*/
|
|
9
|
+
declare function stringifyFactoryProps(props: FactoryComponentProps, dynamicTemplate: string, staticTemplate?: string, separator?: string): string;
|
|
10
|
+
export { factoryPropTemplate, stringifyFactoryProps };
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Template for property
|
|
3
|
+
*/
|
|
4
|
+
const factoryPropTemplate = "{prop}=\"{value}\"";
|
|
5
|
+
/**
|
|
6
|
+
* Stringify properties for component
|
|
7
|
+
*/
|
|
8
|
+
function stringifyFactoryProps(props, dynamicTemplate, staticTemplate = factoryPropTemplate, separator = " ") {
|
|
9
|
+
const result = [];
|
|
10
|
+
for (const key in props) {
|
|
11
|
+
const value = props[key];
|
|
12
|
+
const actualValue = typeof value === "string" ? value : value.value;
|
|
13
|
+
if (actualValue !== void 0) {
|
|
14
|
+
const template = typeof value === "string" ? staticTemplate : value.template ?? dynamicTemplate;
|
|
15
|
+
if (template) result.push(template.replace("{prop}", key).replace("{value}", actualValue));
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
return result.join(separator);
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export { factoryPropTemplate, stringifyFactoryProps };
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Stringify properties for component
|
|
3
|
+
*/
|
|
4
|
+
function stringifyFactoryPropTypes(props) {
|
|
5
|
+
const result = [];
|
|
6
|
+
for (const key in props) {
|
|
7
|
+
const value = props[key];
|
|
8
|
+
if (typeof value !== "string") {
|
|
9
|
+
const type = value.type;
|
|
10
|
+
if (type) result.push(`\t${key}${value.required ? "" : "?"}: ${type};`);
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
return result.join("\n");
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export { stringifyFactoryPropTypes };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { };
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { GeneratedAssetFile } from "./file.js";
|
|
2
|
+
/**
|
|
3
|
+
* List of imports for component
|
|
4
|
+
*/
|
|
5
|
+
interface FactoryComponentImports {
|
|
6
|
+
default: Record<string, string>;
|
|
7
|
+
named: Record<string, Set<string>>;
|
|
8
|
+
types: Record<string, Set<string>>;
|
|
9
|
+
full: Set<string>;
|
|
10
|
+
css: Set<string>;
|
|
11
|
+
modules: Record<string, string>;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Parts of template
|
|
15
|
+
*/
|
|
16
|
+
interface FactoryComponentTemplate {
|
|
17
|
+
tag: string;
|
|
18
|
+
hardcoded: Record<string, string>;
|
|
19
|
+
vars: Record<string, string>;
|
|
20
|
+
spread: string[];
|
|
21
|
+
propTypes: Record<string, string>;
|
|
22
|
+
optionalProps: string[];
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Generated component
|
|
26
|
+
*/
|
|
27
|
+
interface FactoryGeneratedComponent {
|
|
28
|
+
assets: GeneratedAssetFile[];
|
|
29
|
+
content: string;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Component data with filename
|
|
33
|
+
*/
|
|
34
|
+
interface FactoryComponent extends Omit<FactoryGeneratedComponent, 'ext' | 'forceExtension'> {
|
|
35
|
+
icon: string;
|
|
36
|
+
filename: string;
|
|
37
|
+
}
|
|
38
|
+
export { FactoryComponent, FactoryComponentImports, FactoryComponentTemplate, FactoryGeneratedComponent };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { };
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { IconViewBox } from "../../../svg/viewbox/types.js";
|
|
2
|
+
import { ComponentFactorySource } from "./source.js";
|
|
3
|
+
/**
|
|
4
|
+
* Icon data
|
|
5
|
+
*/
|
|
6
|
+
interface FactoryIconData {
|
|
7
|
+
prefix: string;
|
|
8
|
+
name: string;
|
|
9
|
+
icon: ComponentFactorySource;
|
|
10
|
+
viewBox: IconViewBox;
|
|
11
|
+
fallback?: string;
|
|
12
|
+
}
|
|
13
|
+
export { FactoryIconData };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { };
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* File generated by component factory
|
|
3
|
+
*/
|
|
4
|
+
interface GeneratedComponentFile {
|
|
5
|
+
filename: string;
|
|
6
|
+
content: string;
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* Asset generated by component factory
|
|
10
|
+
*/
|
|
11
|
+
interface GeneratedAssetFile extends GeneratedComponentFile {
|
|
12
|
+
import: string;
|
|
13
|
+
}
|
|
14
|
+
export { GeneratedAssetFile, GeneratedComponentFile };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { };
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { GeneratedAssetPath } from "./asset.js";
|
|
2
|
+
import { CSSExportMode } from "./css.js";
|
|
3
|
+
/**
|
|
4
|
+
* File system options for component factory
|
|
5
|
+
*/
|
|
6
|
+
interface ComponentFactoryFileSystemOptions {
|
|
7
|
+
doubleDirsForCSS: boolean;
|
|
8
|
+
prefixDirsForComponents: boolean;
|
|
9
|
+
doubleDirsForComponents: boolean;
|
|
10
|
+
chunksPath: GeneratedAssetPath;
|
|
11
|
+
cssPath: GeneratedAssetPath;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Rendering options for component factory
|
|
15
|
+
*/
|
|
16
|
+
interface ComponentFactoryRenderingOptions {
|
|
17
|
+
square?: boolean;
|
|
18
|
+
cssMode: CSSExportMode;
|
|
19
|
+
width?: string;
|
|
20
|
+
height?: string;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Options for component factory
|
|
24
|
+
*/
|
|
25
|
+
interface ComponentFactoryOptions extends ComponentFactoryFileSystemOptions, ComponentFactoryRenderingOptions {}
|
|
26
|
+
export { ComponentFactoryFileSystemOptions, ComponentFactoryOptions, ComponentFactoryRenderingOptions };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { };
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Dynamic property value
|
|
3
|
+
*/
|
|
4
|
+
interface FactoryComponentDynamicProp {
|
|
5
|
+
type?: string;
|
|
6
|
+
required?: boolean;
|
|
7
|
+
value?: string;
|
|
8
|
+
template?: string;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Properties for component
|
|
12
|
+
*/
|
|
13
|
+
type FactoryComponentProps = Record<string, string | FactoryComponentDynamicProp>;
|
|
14
|
+
export { FactoryComponentDynamicProp, FactoryComponentProps };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { };
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { CSSKeyframes, CSSRules } from "../../../css/types.js";
|
|
2
|
+
import { ConvertedSVGContent } from "../../types.js";
|
|
3
|
+
/**
|
|
4
|
+
* Content for component factory
|
|
5
|
+
*/
|
|
6
|
+
interface ComponentFactorySource extends Omit<ConvertedSVGContent, 'classes' | 'keyframes'> {
|
|
7
|
+
classes?: Record<string, CSSRules | string>;
|
|
8
|
+
keyframes?: Record<string, CSSKeyframes | string>;
|
|
9
|
+
}
|
|
10
|
+
export { ComponentFactorySource };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { };
|
package/lib/svg-css/types.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { CSSRules } from "../css/types.js";
|
|
1
|
+
import { CSSKeyframes, CSSRules } from "../css/types.js";
|
|
2
2
|
/**
|
|
3
3
|
* SVG property types
|
|
4
4
|
*/
|
|
@@ -16,5 +16,6 @@ interface SVGConvertedToCSSProperties {
|
|
|
16
16
|
interface ConvertedSVGContent {
|
|
17
17
|
content: string;
|
|
18
18
|
classes?: Record<string, CSSRules>;
|
|
19
|
+
keyframes?: Record<string, CSSKeyframes>;
|
|
19
20
|
}
|
|
20
21
|
export { ConvertedSVGContent, SVGConvertedToCSSProperties, SVGPropertyType };
|
package/lib/xml/parse.js
CHANGED
|
@@ -12,8 +12,7 @@ function parseXMLContent(content, trim = true) {
|
|
|
12
12
|
const start = content.indexOf("<", startIndex);
|
|
13
13
|
const end = start === -1 ? -1 : content.indexOf(">", start);
|
|
14
14
|
if (start === -1 || end === -1) {
|
|
15
|
-
|
|
16
|
-
if (text$1 || parentNode || !rootNodes.length) return null;
|
|
15
|
+
if (content.slice(startIndex).trim() || parentNode || !rootNodes.length) return null;
|
|
17
16
|
return rootNodes;
|
|
18
17
|
}
|
|
19
18
|
if (content.slice(start, start + 4) === "<!--") {
|
|
@@ -66,8 +65,7 @@ function parseXMLContent(content, trim = true) {
|
|
|
66
65
|
}
|
|
67
66
|
startIndex = end + 1;
|
|
68
67
|
if (tagName === "style" && !selfClosing) {
|
|
69
|
-
const
|
|
70
|
-
const end$1 = content.indexOf(match, startIndex);
|
|
68
|
+
const end$1 = content.indexOf("</style>", startIndex);
|
|
71
69
|
if (end$1 === -1) return null;
|
|
72
70
|
const css = content.slice(startIndex, end$1).trim();
|
|
73
71
|
if (css.length) parentNode.children.push({
|
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": "0.0
|
|
6
|
+
"version": "0.1.0",
|
|
7
7
|
"license": "MIT",
|
|
8
8
|
"bugs": "https://github.com/cyberalien/svg-utils/issues",
|
|
9
9
|
"homepage": "https://cyberalien.dev/",
|
|
@@ -24,15 +24,17 @@
|
|
|
24
24
|
},
|
|
25
25
|
"devDependencies": {
|
|
26
26
|
"@eslint/eslintrc": "^3.3.1",
|
|
27
|
-
"@eslint/js": "^9.
|
|
28
|
-
"@
|
|
29
|
-
"@types/
|
|
30
|
-
"@
|
|
31
|
-
"eslint": "^
|
|
32
|
-
"
|
|
33
|
-
"
|
|
27
|
+
"@eslint/js": "^9.35.0",
|
|
28
|
+
"@iconify-json/ri": "^1.2.5",
|
|
29
|
+
"@types/jest": "^30.0.0",
|
|
30
|
+
"@types/node": "^24.5.2",
|
|
31
|
+
"@typescript-eslint/eslint-plugin": "^8.44.0",
|
|
32
|
+
"@typescript-eslint/parser": "^8.44.0",
|
|
33
|
+
"eslint": "^9.35.0",
|
|
34
|
+
"globals": "^16.4.0",
|
|
35
|
+
"tsdown": "^0.15.2",
|
|
34
36
|
"typescript": "^5.9.2",
|
|
35
|
-
"vitest": "^2.
|
|
37
|
+
"vitest": "^3.2.4"
|
|
36
38
|
},
|
|
37
39
|
"scripts": {
|
|
38
40
|
"lint": "eslint --fix src/**/*.ts",
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { ExportedComponentFile, SVGPreParsedContent } from "../types.js";
|
|
2
|
-
/**
|
|
3
|
-
* Add CSS imports and files to component
|
|
4
|
-
*
|
|
5
|
-
* Returns true if CSS was added
|
|
6
|
-
*/
|
|
7
|
-
declare function addCSSToComponent(parsedContent: SVGPreParsedContent, addImportsTo: string[], files: ExportedComponentFile[], rootPath: string, classNamePrefix: string): boolean;
|
|
8
|
-
export { addCSSToComponent };
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
import { stringifyCSSSelector } from "../../../css/stringify.js";
|
|
2
|
-
import { getCSSFilename } from "./css-filename.js";
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* Add CSS imports and files to component
|
|
6
|
-
*
|
|
7
|
-
* Returns true if CSS was added
|
|
8
|
-
*/
|
|
9
|
-
function addCSSToComponent(parsedContent, addImportsTo, files, rootPath, classNamePrefix) {
|
|
10
|
-
let hasCSS = false;
|
|
11
|
-
if (parsedContent.css) for (const className in parsedContent.css) {
|
|
12
|
-
hasCSS = true;
|
|
13
|
-
const filename = getCSSFilename(className, classNamePrefix);
|
|
14
|
-
addImportsTo.push(`import '${rootPath}${filename}';`);
|
|
15
|
-
files.push({
|
|
16
|
-
filename,
|
|
17
|
-
content: parsedContent.css[className]
|
|
18
|
-
});
|
|
19
|
-
}
|
|
20
|
-
if (parsedContent.classes) for (const className in parsedContent.classes) {
|
|
21
|
-
hasCSS = true;
|
|
22
|
-
const filename = getCSSFilename(className, classNamePrefix);
|
|
23
|
-
addImportsTo.push(`import '${rootPath}${filename}';`);
|
|
24
|
-
files.push({
|
|
25
|
-
filename,
|
|
26
|
-
content: stringifyCSSSelector(`.${className}`, parsedContent.classes[className])
|
|
27
|
-
});
|
|
28
|
-
}
|
|
29
|
-
return hasCSS;
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
export { addCSSToComponent };
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
interface Options {
|
|
2
|
-
pascalCase?: boolean;
|
|
3
|
-
ucPrefix?: boolean;
|
|
4
|
-
}
|
|
5
|
-
/**
|
|
6
|
-
* Get icon component name in camelCase or PascalCase if `pascalCase` is true
|
|
7
|
-
*/
|
|
8
|
-
declare function camelCaseIconComponentName(name: string, options: Options, prefix?: string): string;
|
|
9
|
-
export { camelCaseIconComponentName };
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import { camelize, pascalize } from "../../../helpers/misc/strings.js";
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Get icon component name in camelCase or PascalCase if `pascalCase` is true
|
|
5
|
-
*/
|
|
6
|
-
function camelCaseIconComponentName(name, options, prefix) {
|
|
7
|
-
name = `${name}-icon`;
|
|
8
|
-
const { pascalCase, ucPrefix } = options;
|
|
9
|
-
if (prefix) {
|
|
10
|
-
if (!pascalCase) return camelize(`${prefix}-${name}`);
|
|
11
|
-
if (pascalCase && (ucPrefix || ucPrefix === void 0 && prefix.length < 5)) return prefix.toUpperCase() + pascalize(name);
|
|
12
|
-
name = `${prefix}-${name}`;
|
|
13
|
-
}
|
|
14
|
-
return pascalCase ? pascalize(name) : camelize(name);
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
export { camelCaseIconComponentName };
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Get filename for CSS file
|
|
3
|
-
*/
|
|
4
|
-
function getCSSFilename(className, classNamePrefix) {
|
|
5
|
-
const matchLength = className.startsWith(classNamePrefix) ? classNamePrefix.length : 0;
|
|
6
|
-
const firstPart = className.slice(0, matchLength + 1);
|
|
7
|
-
return `css/${firstPart}/${className}.css`;
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
export { getCSSFilename };
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import { ExportedComponent } from "../types.js";
|
|
2
|
-
/**
|
|
3
|
-
* Add exports for main files to object
|
|
4
|
-
*/
|
|
5
|
-
declare function createExportsForMainFiles(data: ExportedComponent[], result?: Record<string, string>): Record<string, string>;
|
|
6
|
-
export { createExportsForMainFiles };
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Add exports for main files to object
|
|
3
|
-
*/
|
|
4
|
-
function createExportsForMainFiles(data, result) {
|
|
5
|
-
result = result || Object.create(null);
|
|
6
|
-
for (const { prefix, name, main } of data) result[`./${prefix ? `${prefix}/${name}` : name}`] = `./${main.filename}`;
|
|
7
|
-
return result;
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
export { createExportsForMainFiles };
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Merge all files
|
|
3
|
-
*/
|
|
4
|
-
function mergeExportedComponentFiles(data) {
|
|
5
|
-
const files = [];
|
|
6
|
-
const added = /* @__PURE__ */ new Set();
|
|
7
|
-
function add(file) {
|
|
8
|
-
if (added.has(file.filename)) return;
|
|
9
|
-
added.add(file.filename);
|
|
10
|
-
files.push(file);
|
|
11
|
-
}
|
|
12
|
-
for (const item of data) {
|
|
13
|
-
add(item.main);
|
|
14
|
-
item.shared.forEach(add);
|
|
15
|
-
}
|
|
16
|
-
return files;
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
export { mergeExportedComponentFiles };
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import { ComponentFactoryIconData, ComponentFactoryOptions } from "../types.js";
|
|
2
|
-
/**
|
|
3
|
-
* Get default options for component factory
|
|
4
|
-
*/
|
|
5
|
-
declare function getDefaultComponentFactoryOptions(options: Partial<ComponentFactoryOptions>, data: ComponentFactoryIconData): ComponentFactoryOptions;
|
|
6
|
-
export { getDefaultComponentFactoryOptions };
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Get default options for component factory
|
|
3
|
-
*/
|
|
4
|
-
function getDefaultComponentFactoryOptions(options, data) {
|
|
5
|
-
return {
|
|
6
|
-
addPrefixToFilenames: !!data.prefix,
|
|
7
|
-
classNamePrefix: "",
|
|
8
|
-
...options
|
|
9
|
-
};
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
export { getDefaultComponentFactoryOptions };
|