@cyberalien/svg-utils 0.1.1 → 0.1.3
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/{svg-css/factory → components}/export/fs.d.ts +1 -1
- package/lib/{svg-css/factory → components}/export/merge.d.ts +1 -2
- package/lib/{svg-css/factory → components/helpers}/content/size.d.ts +1 -1
- package/lib/{svg-css/factory → components/helpers}/content/stringify.d.ts +2 -2
- package/lib/{svg-css/factory → components/helpers}/css/generate.d.ts +4 -4
- package/lib/components/helpers/filenames/asset.d.ts +10 -0
- package/lib/components/helpers/filenames/asset.js +16 -0
- package/lib/{svg-css/factory → components/helpers}/filenames/css.d.ts +1 -2
- package/lib/{svg-css/factory → components/helpers}/filenames/css.js +3 -4
- package/lib/components/helpers/filenames/path.d.ts +9 -0
- package/lib/{svg-css/factory → components/helpers}/filenames/path.js +5 -6
- package/lib/{svg-css/factory → components/helpers}/filenames/types.d.ts +2 -3
- package/lib/{svg-css/factory → components/helpers}/filenames/types.js +1 -1
- package/lib/components/helpers/functions/size.d.ts +8 -0
- package/lib/{svg-css/factory/components/shared → components/helpers/functions}/size.js +2 -2
- package/lib/{svg-css/factory → components/helpers}/imports/add.d.ts +1 -1
- package/lib/{svg-css/factory → components/helpers}/imports/create.d.ts +1 -1
- package/lib/{svg-css/factory → components/helpers}/imports/stringify.d.ts +1 -1
- package/lib/components/helpers/imports/types.d.ts +12 -0
- package/lib/{svg-css/factory → components/helpers}/props/object.d.ts +1 -1
- package/lib/{svg-css/factory → components/helpers}/props/stringify.d.ts +1 -1
- package/lib/{svg-css/factory/props/types.d.ts → components/helpers/props/ts.d.ts} +1 -1
- package/lib/components/helpers/vue/types.d.ts +9 -0
- package/lib/{svg-css/factory/components → components/helpers}/vue/types.js +2 -2
- package/lib/components/prepare/iconify.d.ts +17 -0
- package/lib/components/prepare/iconify.js +38 -0
- package/lib/{svg-css/factory/filenames → components/prepare}/options.js +5 -7
- package/lib/components/raw.d.ts +8 -0
- package/lib/{svg-css/factory/components → components}/raw.js +8 -8
- package/lib/components/types/component.d.ts +29 -0
- package/lib/{svg-css/factory → components}/types/data.d.ts +1 -1
- package/lib/{svg-css/factory → components}/types/options.d.ts +9 -3
- package/lib/{svg-css/factory → components}/types/source.d.ts +2 -2
- package/lib/components/vue-func.d.ts +8 -0
- package/lib/{svg-css/factory/components → components}/vue-func.js +11 -11
- package/lib/{svg-css/factory/components → components}/vue.d.ts +3 -3
- package/lib/{svg-css/factory/components → components}/vue.js +11 -11
- package/lib/css/hash.d.ts +2 -2
- package/lib/css/hash.js +3 -2
- package/lib/css/types.d.ts +6 -1
- package/lib/index.d.ts +6 -8
- package/lib/index.js +3 -5
- package/lib/svg-css/animations/tags.d.ts +17 -0
- package/lib/svg-css/animations/tags.js +26 -0
- package/lib/svg-css/{convert/content.d.ts → content.d.ts} +1 -2
- package/lib/svg-css/{convert/content.js → content.js} +3 -3
- package/lib/svg-css/props/prop.js +9 -0
- package/lib/svg-css/props/props.d.ts +1 -1
- package/lib/svg-css/props/props.js +3 -7
- package/lib/svg-css/props/types.d.ts +9 -0
- package/lib/svg-css/root.d.ts +9 -0
- package/lib/svg-css/{convert/root.js → root.js} +6 -6
- package/lib/svg-css/types.d.ts +7 -10
- package/package.json +1 -1
- package/lib/svg-css/convert/root.d.ts +0 -9
- package/lib/svg-css/convert/types.d.ts +0 -5
- package/lib/svg-css/factory/code/iconify.d.ts +0 -11
- package/lib/svg-css/factory/code/iconify.js +0 -20
- package/lib/svg-css/factory/code/template.d.ts +0 -6
- package/lib/svg-css/factory/code/template.js +0 -15
- package/lib/svg-css/factory/components/raw.d.ts +0 -8
- package/lib/svg-css/factory/components/vue-func.d.ts +0 -8
- package/lib/svg-css/factory/filenames/asset.d.ts +0 -11
- package/lib/svg-css/factory/filenames/asset.js +0 -16
- package/lib/svg-css/factory/filenames/path.d.ts +0 -11
- package/lib/svg-css/factory/types/asset.d.ts +0 -8
- package/lib/svg-css/factory/types/component.d.ts +0 -39
- package/lib/svg-css/factory/types/file.d.ts +0 -14
- package/lib/svg-css/factory/types/props.js +0 -1
- /package/lib/{svg-css/factory → components}/export/exports.d.ts +0 -0
- /package/lib/{svg-css/factory → components}/export/exports.js +0 -0
- /package/lib/{svg-css/factory → components}/export/file.d.ts +0 -0
- /package/lib/{svg-css/factory → components}/export/file.js +0 -0
- /package/lib/{svg-css/factory/filenames/component.d.ts → components/export/filename.d.ts} +0 -0
- /package/lib/{svg-css/factory/filenames/component.js → components/export/filename.js} +0 -0
- /package/lib/{svg-css/factory → components}/export/fs.js +0 -0
- /package/lib/{svg-css/factory → components}/export/merge.js +0 -0
- /package/lib/{svg-css/factory/code/stringify.d.ts → components/helpers/code/lines.d.ts} +0 -0
- /package/lib/{svg-css/factory/code/stringify.js → components/helpers/code/lines.js} +0 -0
- /package/lib/{svg-css/factory → components/helpers}/content/size.js +0 -0
- /package/lib/{svg-css/factory → components/helpers}/content/stringify.js +0 -0
- /package/lib/{svg-css/factory → components/helpers}/css/generate.js +0 -0
- /package/lib/{svg-css/factory → components/helpers}/css/name.d.ts +0 -0
- /package/lib/{svg-css/factory → components/helpers}/css/name.js +0 -0
- /package/lib/{svg-css/factory → components/helpers}/imports/add.js +0 -0
- /package/lib/{svg-css/factory → components/helpers}/imports/create.js +0 -0
- /package/lib/{svg-css/factory → components/helpers}/imports/stringify.js +0 -0
- /package/lib/{svg-css/convert → components/helpers/imports}/types.js +0 -0
- /package/lib/{svg-css/factory → components/helpers}/props/object.js +0 -0
- /package/lib/{svg-css/factory → components/helpers}/props/stringify.js +0 -0
- /package/lib/{svg-css/factory/props/types.js → components/helpers/props/ts.js} +0 -0
- /package/lib/{svg-css/factory/types/props.d.ts → components/helpers/props/types.d.ts} +0 -0
- /package/lib/{svg-css/factory/types/asset.js → components/helpers/props/types.js} +0 -0
- /package/lib/{svg-css/factory/filenames → components/prepare}/options.d.ts +0 -0
- /package/lib/{svg-css/factory → components}/types/component.js +0 -0
- /package/lib/{svg-css/factory → components}/types/css.d.ts +0 -0
- /package/lib/{svg-css/factory → components}/types/css.js +0 -0
- /package/lib/{svg-css/factory → components}/types/data.js +0 -0
- /package/lib/{svg-css/factory → components}/types/options.js +0 -0
- /package/lib/{svg-css/factory → components}/types/source.js +0 -0
- /package/lib/svg-css/{factory/types/file.js → props/types.js} +0 -0
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { IconViewBox } from "../../../svg/viewbox/types.js";
|
|
2
|
-
import { ComponentFactoryRenderingOptions } from "
|
|
2
|
+
import { ComponentFactoryRenderingOptions } from "../../types/options.js";
|
|
3
3
|
interface SizeResult {
|
|
4
4
|
width: string;
|
|
5
5
|
height: string;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { ComponentFactorySource } from "
|
|
2
|
-
import { ComponentFactoryRenderingOptions } from "
|
|
1
|
+
import { ComponentFactorySource } from "../../types/source.js";
|
|
2
|
+
import { ComponentFactoryRenderingOptions } from "../../types/options.js";
|
|
3
3
|
/**
|
|
4
4
|
* Convert icon content to a string literal
|
|
5
5
|
*/
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
1
|
+
import { GeneratedAssetFile } from "../../types/component.js";
|
|
2
|
+
import { ComponentFactorySource } from "../../types/source.js";
|
|
3
|
+
import { ComponentFactoryOptions } from "../../types/options.js";
|
|
4
|
+
import { FactoryComponentImports } from "../imports/types.js";
|
|
5
5
|
/**
|
|
6
6
|
* Generate CSS files for component
|
|
7
7
|
*
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { GeneratedAssetPath } from "../../types/options.js";
|
|
2
|
+
/**
|
|
3
|
+
* Generate asset filename based on options
|
|
4
|
+
*
|
|
5
|
+
* @param filename - Filename without path
|
|
6
|
+
* @param rootPath - Root path
|
|
7
|
+
* @returns Asset path
|
|
8
|
+
*/
|
|
9
|
+
declare function getGeneratedAssetFilename(filename: string, rootPath: GeneratedAssetPath): GeneratedAssetPath;
|
|
10
|
+
export { getGeneratedAssetFilename };
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Generate asset filename based on options
|
|
3
|
+
*
|
|
4
|
+
* @param filename - Filename without path
|
|
5
|
+
* @param rootPath - Root path
|
|
6
|
+
* @returns Asset path
|
|
7
|
+
*/
|
|
8
|
+
function getGeneratedAssetFilename(filename, rootPath) {
|
|
9
|
+
const basePath = rootPath.filename;
|
|
10
|
+
return {
|
|
11
|
+
import: `${rootPath.import}/${filename}`,
|
|
12
|
+
filename: `${basePath ? basePath + "/" : ""}${filename}`
|
|
13
|
+
};
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export { getGeneratedAssetFilename };
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { getGeneratedAssetFilename } from "./asset.js";
|
|
2
|
+
|
|
1
3
|
/**
|
|
2
4
|
* Generate CSS filename based on options
|
|
3
5
|
*/
|
|
@@ -5,10 +7,7 @@ function getGeneratedCSSFilename(name, options) {
|
|
|
5
7
|
const { cssPath, doubleDirsForCSS, cssMode } = options;
|
|
6
8
|
const baseName = doubleDirsForCSS ? `${name.slice(0, 1).toLowerCase()}/${name}` : name;
|
|
7
9
|
const filename = cssMode === "module" ? `${baseName}.module.css` : `${baseName}.css`;
|
|
8
|
-
return
|
|
9
|
-
import: `${cssPath.import}/${filename}`,
|
|
10
|
-
filename: `${cssPath.filename}/${filename}`
|
|
11
|
-
};
|
|
10
|
+
return getGeneratedAssetFilename(filename, cssPath);
|
|
12
11
|
}
|
|
13
12
|
|
|
14
13
|
export { getGeneratedCSSFilename };
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { ComponentFactoryFileSystemOptions, GeneratedAssetPath } from "../../types/options.js";
|
|
2
|
+
/**
|
|
3
|
+
* Get relative path to root directory from component
|
|
4
|
+
*
|
|
5
|
+
* @param options Factory options
|
|
6
|
+
* @returns Asset path
|
|
7
|
+
*/
|
|
8
|
+
declare function getFactoryRelativeRootPath(options: Pick<ComponentFactoryFileSystemOptions, 'doubleDirsForComponents' | 'prefixDirsForComponents'>): GeneratedAssetPath;
|
|
9
|
+
export { getFactoryRelativeRootPath };
|
|
@@ -1,18 +1,17 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Get relative path to
|
|
2
|
+
* Get relative path to root directory from component
|
|
3
3
|
*
|
|
4
|
-
* @param path Path to asset, without trailing slash
|
|
5
4
|
* @param options Factory options
|
|
6
5
|
* @returns Asset path
|
|
7
6
|
*/
|
|
8
|
-
function
|
|
7
|
+
function getFactoryRelativeRootPath(options) {
|
|
9
8
|
const { prefixDirsForComponents } = options;
|
|
10
9
|
const prefixDir = prefixDirsForComponents ? typeof prefixDirsForComponents === "string" ? prefixDirsForComponents : "prefix" : "";
|
|
11
10
|
const parentCount = (prefixDir ? prefixDir.split("/").length : 0) + (options.doubleDirsForComponents ? 1 : 0);
|
|
12
11
|
return {
|
|
13
|
-
import:
|
|
14
|
-
filename:
|
|
12
|
+
import: parentCount ? "../".repeat(parentCount - 1) + ".." : ".",
|
|
13
|
+
filename: ""
|
|
15
14
|
};
|
|
16
15
|
}
|
|
17
16
|
|
|
18
|
-
export {
|
|
17
|
+
export { getFactoryRelativeRootPath };
|
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import { FactoryIconData } from "
|
|
2
|
-
import { GeneratedAssetPath } from "
|
|
3
|
-
import { ComponentFactoryFileSystemOptions } from "../types/options.js";
|
|
1
|
+
import { FactoryIconData } from "../../types/data.js";
|
|
2
|
+
import { ComponentFactoryFileSystemOptions, GeneratedAssetPath } from "../../types/options.js";
|
|
4
3
|
/**
|
|
5
4
|
* Generate component types filename based on options
|
|
6
5
|
*/
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { GeneratedAssetFile } from "../../types/component.js";
|
|
2
|
+
import { ComponentFactoryOptions } from "../../types/options.js";
|
|
3
|
+
import { FactoryComponentImports } from "../imports/types.js";
|
|
4
|
+
/**
|
|
5
|
+
* Adds getSizeProps() function to assets
|
|
6
|
+
*/
|
|
7
|
+
declare function addSizeFunctionAsset(imports: FactoryComponentImports, assets: GeneratedAssetFile[], options: Pick<ComponentFactoryOptions, 'rootPath'>): string;
|
|
8
|
+
export { addSizeFunctionAsset };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { getGeneratedAssetFilename } from "
|
|
1
|
+
import { getGeneratedAssetFilename } from "../filenames/asset.js";
|
|
2
2
|
|
|
3
3
|
const functionName = "getSizeProps";
|
|
4
4
|
const functionContent = `
|
|
@@ -67,7 +67,7 @@ export { ${functionName} };
|
|
|
67
67
|
* Adds getSizeProps() function to assets
|
|
68
68
|
*/
|
|
69
69
|
function addSizeFunctionAsset(imports, assets, options) {
|
|
70
|
-
const filename = getGeneratedAssetFilename("size.js", options);
|
|
70
|
+
const filename = getGeneratedAssetFilename("helpers/size.js", options.rootPath);
|
|
71
71
|
imports.named[filename.import] = new Set([functionName]);
|
|
72
72
|
assets.push({
|
|
73
73
|
...filename,
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* List of imports for component
|
|
3
|
+
*/
|
|
4
|
+
interface FactoryComponentImports {
|
|
5
|
+
default: Record<string, string>;
|
|
6
|
+
named: Record<string, Set<string>>;
|
|
7
|
+
types: Record<string, Set<string>>;
|
|
8
|
+
full: Set<string>;
|
|
9
|
+
css: Set<string>;
|
|
10
|
+
modules: Record<string, string>;
|
|
11
|
+
}
|
|
12
|
+
export { FactoryComponentImports };
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { GeneratedAssetFile } from "../../types/component.js";
|
|
2
|
+
import { FactoryIconData } from "../../types/data.js";
|
|
3
|
+
import { ComponentFactoryOptions } from "../../types/options.js";
|
|
4
|
+
import { FactoryComponentProps } from "../props/types.js";
|
|
5
|
+
/**
|
|
6
|
+
* Add Vue component types
|
|
7
|
+
*/
|
|
8
|
+
declare function addVueComponentTypes(data: FactoryIconData, options: ComponentFactoryOptions, assets: GeneratedAssetFile[], props: FactoryComponentProps): string;
|
|
9
|
+
export { addVueComponentTypes };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { getGeneratedComponentTypesFilename } from "
|
|
2
|
-
import { stringifyFactoryPropTypes } from "
|
|
1
|
+
import { getGeneratedComponentTypesFilename } from "../filenames/types.js";
|
|
2
|
+
import { stringifyFactoryPropTypes } from "../props/ts.js";
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* Add Vue component types
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { GeneratedAssetFile } from "../types/component.js";
|
|
2
|
+
import { ConvertSVGContentOptions } from "../../svg-css/types.js";
|
|
3
|
+
import { FactoryIconData } from "../types/data.js";
|
|
4
|
+
import { GeneratedAssetPath } from "../types/options.js";
|
|
5
|
+
import { IconifyIcon, IconifyJSON } from "@iconify/types";
|
|
6
|
+
interface Options extends ConvertSVGContentOptions {
|
|
7
|
+
fallback?: string | boolean;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Convert IconifyIcon data to FactoryIconData
|
|
11
|
+
*/
|
|
12
|
+
declare function convertIconifyIconToFactoryContent(icon: IconifyIcon, prefix: string, name: string, options?: Options): FactoryIconData;
|
|
13
|
+
/**
|
|
14
|
+
* Create metadata assets for an icon set
|
|
15
|
+
*/
|
|
16
|
+
declare function getIconifyIconsetMetadataAsset(iconSet: Pick<IconifyJSON, 'prefix' | 'info' | 'lastModified'>, rootPath: GeneratedAssetPath): GeneratedAssetFile[];
|
|
17
|
+
export { convertIconifyIconToFactoryContent, getIconifyIconsetMetadataAsset };
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { convertSVGContentToCSSRules } from "../../svg-css/content.js";
|
|
2
|
+
import { getGeneratedAssetFilename } from "../helpers/filenames/asset.js";
|
|
3
|
+
import { normaliseIconifyIcon } from "../../iconify/icon/nornalise.js";
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Convert IconifyIcon data to FactoryIconData
|
|
7
|
+
*/
|
|
8
|
+
function convertIconifyIconToFactoryContent(icon, prefix, name, options) {
|
|
9
|
+
const { body, viewBox } = normaliseIconifyIcon(icon);
|
|
10
|
+
const fallbackOption = options?.fallback ?? true;
|
|
11
|
+
const fallback = typeof fallbackOption === "string" ? fallbackOption : fallbackOption ? `${prefix}:${name}` : void 0;
|
|
12
|
+
return {
|
|
13
|
+
prefix,
|
|
14
|
+
name,
|
|
15
|
+
viewBox,
|
|
16
|
+
icon: convertSVGContentToCSSRules(body, options),
|
|
17
|
+
fallback
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Create metadata assets for an icon set
|
|
22
|
+
*/
|
|
23
|
+
function getIconifyIconsetMetadataAsset(iconSet, rootPath) {
|
|
24
|
+
const assets = [];
|
|
25
|
+
const { prefix, info, lastModified } = iconSet;
|
|
26
|
+
const metadata = {
|
|
27
|
+
prefix,
|
|
28
|
+
info,
|
|
29
|
+
lastModified
|
|
30
|
+
};
|
|
31
|
+
assets.push({
|
|
32
|
+
...getGeneratedAssetFilename("iconify.json", rootPath),
|
|
33
|
+
content: JSON.stringify(metadata, null, " ") + "\n"
|
|
34
|
+
});
|
|
35
|
+
return assets;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export { convertIconifyIconToFactoryContent, getIconifyIconsetMetadataAsset };
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { getGeneratedAssetFilename } from "../helpers/filenames/asset.js";
|
|
2
|
+
import { getFactoryRelativeRootPath } from "../helpers/filenames/path.js";
|
|
2
3
|
|
|
3
4
|
/**
|
|
4
5
|
* Generate file system options
|
|
@@ -7,19 +8,16 @@ function componentFactoryFileSystemOptions(base) {
|
|
|
7
8
|
const doubleDirsForCSS = base.doubleDirsForCSS ?? true;
|
|
8
9
|
const prefixDirsForComponents = base.prefixDirsForComponents ?? false;
|
|
9
10
|
const doubleDirsForComponents = base.doubleDirsForComponents ?? true;
|
|
10
|
-
const
|
|
11
|
-
doubleDirsForComponents,
|
|
12
|
-
prefixDirsForComponents
|
|
13
|
-
});
|
|
14
|
-
const cssPath = base.cssPath ?? getFactoryRelativeAssetPath("css", {
|
|
11
|
+
const rootPath = base.rootPath ?? getFactoryRelativeRootPath({
|
|
15
12
|
doubleDirsForComponents,
|
|
16
13
|
prefixDirsForComponents
|
|
17
14
|
});
|
|
15
|
+
const cssPath = base.cssPath ?? getGeneratedAssetFilename("css", rootPath);
|
|
18
16
|
return {
|
|
19
17
|
doubleDirsForCSS,
|
|
20
18
|
prefixDirsForComponents,
|
|
21
19
|
doubleDirsForComponents,
|
|
22
|
-
|
|
20
|
+
rootPath,
|
|
23
21
|
cssPath
|
|
24
22
|
};
|
|
25
23
|
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { FactoryGeneratedComponent } from "./types/component.js";
|
|
2
|
+
import { FactoryIconData } from "./types/data.js";
|
|
3
|
+
import { ComponentFactoryOptions } from "./types/options.js";
|
|
4
|
+
/**
|
|
5
|
+
* Create raw component code
|
|
6
|
+
*/
|
|
7
|
+
declare function createRawComponent(data: FactoryIconData, options: ComponentFactoryOptions): FactoryGeneratedComponent;
|
|
8
|
+
export { createRawComponent };
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import { createFactoryImports } from "
|
|
6
|
-
import { generateCSSFilesForComponent } from "
|
|
7
|
-
import { stringifyFactoryImports } from "
|
|
8
|
-
import { factoryPropTemplate, stringifyFactoryProps } from "
|
|
1
|
+
import { getComponentSizeValues } from "./helpers/content/size.js";
|
|
2
|
+
import { stringifyFactoryIconContent } from "./helpers/content/stringify.js";
|
|
3
|
+
import { getGeneratedComponentTypesFilename } from "./helpers/filenames/types.js";
|
|
4
|
+
import { getIconViewBox } from "../svg/viewbox/value.js";
|
|
5
|
+
import { createFactoryImports } from "./helpers/imports/create.js";
|
|
6
|
+
import { generateCSSFilesForComponent } from "./helpers/css/generate.js";
|
|
7
|
+
import { stringifyFactoryImports } from "./helpers/imports/stringify.js";
|
|
8
|
+
import { factoryPropTemplate, stringifyFactoryProps } from "./helpers/props/stringify.js";
|
|
9
9
|
|
|
10
10
|
/**
|
|
11
11
|
* Create raw component code
|
|
@@ -0,0 +1,29 @@
|
|
|
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
|
+
/**
|
|
15
|
+
* Generated component
|
|
16
|
+
*/
|
|
17
|
+
interface FactoryGeneratedComponent {
|
|
18
|
+
assets: GeneratedAssetFile[];
|
|
19
|
+
content: string;
|
|
20
|
+
types?: string;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Component data with filename
|
|
24
|
+
*/
|
|
25
|
+
interface FactoryComponent extends Omit<FactoryGeneratedComponent, 'ext' | 'forceExtension'> {
|
|
26
|
+
icon: string;
|
|
27
|
+
filename: string;
|
|
28
|
+
}
|
|
29
|
+
export { FactoryComponent, FactoryGeneratedComponent, GeneratedAssetFile, GeneratedComponentFile };
|
|
@@ -1,5 +1,11 @@
|
|
|
1
|
-
import { GeneratedAssetPath } from "./asset.js";
|
|
2
1
|
import { CSSExportMode } from "./css.js";
|
|
2
|
+
/**
|
|
3
|
+
* Asset path, generated from configuration
|
|
4
|
+
*/
|
|
5
|
+
interface GeneratedAssetPath {
|
|
6
|
+
filename: string;
|
|
7
|
+
import: string;
|
|
8
|
+
}
|
|
3
9
|
/**
|
|
4
10
|
* File system options for component factory
|
|
5
11
|
*/
|
|
@@ -7,7 +13,7 @@ interface ComponentFactoryFileSystemOptions {
|
|
|
7
13
|
doubleDirsForCSS: boolean;
|
|
8
14
|
prefixDirsForComponents: boolean | string;
|
|
9
15
|
doubleDirsForComponents: boolean;
|
|
10
|
-
|
|
16
|
+
rootPath: GeneratedAssetPath;
|
|
11
17
|
cssPath: GeneratedAssetPath;
|
|
12
18
|
}
|
|
13
19
|
/**
|
|
@@ -23,4 +29,4 @@ interface ComponentFactoryRenderingOptions {
|
|
|
23
29
|
* Options for component factory
|
|
24
30
|
*/
|
|
25
31
|
interface ComponentFactoryOptions extends ComponentFactoryFileSystemOptions, ComponentFactoryRenderingOptions {}
|
|
26
|
-
export { ComponentFactoryFileSystemOptions, ComponentFactoryOptions, ComponentFactoryRenderingOptions };
|
|
32
|
+
export { ComponentFactoryFileSystemOptions, ComponentFactoryOptions, ComponentFactoryRenderingOptions, GeneratedAssetPath };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { CSSKeyframes, CSSRules } from "
|
|
2
|
-
import { ConvertedSVGContent } from "../../types.js";
|
|
1
|
+
import { CSSKeyframes, CSSRules } from "../../css/types.js";
|
|
2
|
+
import { ConvertedSVGContent } from "../../svg-css/types.js";
|
|
3
3
|
/**
|
|
4
4
|
* Content for component factory
|
|
5
5
|
*/
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { FactoryGeneratedComponent } from "./types/component.js";
|
|
2
|
+
import { FactoryIconData } from "./types/data.js";
|
|
3
|
+
import { ComponentFactoryOptions } from "./types/options.js";
|
|
4
|
+
/**
|
|
5
|
+
* Create functional Vue component code
|
|
6
|
+
*/
|
|
7
|
+
declare function createVueFunctionalComponent(data: FactoryIconData, options: ComponentFactoryOptions): FactoryGeneratedComponent;
|
|
8
|
+
export { createVueFunctionalComponent };
|
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
1
|
+
import { getComponentSizeValues } from "./helpers/content/size.js";
|
|
2
|
+
import { stringifyFactoryIconContent } from "./helpers/content/stringify.js";
|
|
3
|
+
import { getIconViewBox } from "../svg/viewbox/value.js";
|
|
4
|
+
import { createFactoryImports } from "./helpers/imports/create.js";
|
|
5
|
+
import { generateCSSFilesForComponent } from "./helpers/css/generate.js";
|
|
6
|
+
import { stringifyFactoryImports } from "./helpers/imports/stringify.js";
|
|
7
|
+
import { getUsedFactoryProps } from "./helpers/props/ts.js";
|
|
8
|
+
import { addVueComponentTypes } from "./helpers/vue/types.js";
|
|
9
|
+
import { addSizeFunctionAsset } from "./helpers/functions/size.js";
|
|
10
|
+
import { stringifyFactoryPropsAsJSON } from "./helpers/props/object.js";
|
|
11
|
+
import { makeSquareViewBox } from "../svg/viewbox/square.js";
|
|
12
12
|
|
|
13
13
|
/**
|
|
14
14
|
* Create functional Vue component code
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import { ComponentFactoryOptions } from "
|
|
1
|
+
import { FactoryGeneratedComponent } from "./types/component.js";
|
|
2
|
+
import { FactoryIconData } from "./types/data.js";
|
|
3
|
+
import { ComponentFactoryOptions } from "./types/options.js";
|
|
4
4
|
interface VueOptions extends ComponentFactoryOptions {
|
|
5
5
|
ts?: boolean;
|
|
6
6
|
}
|
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
1
|
+
import { getComponentSizeValues } from "./helpers/content/size.js";
|
|
2
|
+
import { stringifyFactoryIconContent } from "./helpers/content/stringify.js";
|
|
3
|
+
import { getIconViewBox } from "../svg/viewbox/value.js";
|
|
4
|
+
import { createFactoryImports } from "./helpers/imports/create.js";
|
|
5
|
+
import { generateCSSFilesForComponent } from "./helpers/css/generate.js";
|
|
6
|
+
import { stringifyFactoryImports } from "./helpers/imports/stringify.js";
|
|
7
|
+
import { stringifyFactoryProps } from "./helpers/props/stringify.js";
|
|
8
|
+
import { getUsedFactoryProps, stringifyFactoryPropTypes } from "./helpers/props/ts.js";
|
|
9
|
+
import { addVueComponentTypes } from "./helpers/vue/types.js";
|
|
10
|
+
import { addSizeFunctionAsset } from "./helpers/functions/size.js";
|
|
11
|
+
import { makeSquareViewBox } from "../svg/viewbox/square.js";
|
|
12
12
|
|
|
13
13
|
/**
|
|
14
14
|
* Create Vue component code
|
package/lib/css/hash.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { CSSRules } from "./types.js";
|
|
1
|
+
import { CSSHashOptions, CSSRules } from "./types.js";
|
|
2
2
|
/**
|
|
3
3
|
* Get class name for CSS rules
|
|
4
4
|
*/
|
|
5
|
-
declare function createCSSClassName(rules: CSSRules, prefix?: string): string;
|
|
5
|
+
declare function createCSSClassName(rules: CSSRules, prefix?: string, options?: CSSHashOptions): string;
|
|
6
6
|
export { createCSSClassName };
|
package/lib/css/hash.js
CHANGED
|
@@ -5,12 +5,13 @@ const length = 6;
|
|
|
5
5
|
/**
|
|
6
6
|
* Get class name for CSS rules
|
|
7
7
|
*/
|
|
8
|
-
function createCSSClassName(rules, prefix = "") {
|
|
8
|
+
function createCSSClassName(rules, prefix = "", options) {
|
|
9
9
|
const sorted = sortObject(rules);
|
|
10
10
|
return getUniqueHash(sorted, {
|
|
11
11
|
css: true,
|
|
12
12
|
length,
|
|
13
|
-
prefix
|
|
13
|
+
prefix,
|
|
14
|
+
...options
|
|
14
15
|
});
|
|
15
16
|
}
|
|
16
17
|
|
package/lib/css/types.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { UniqueHashOptions } from "../helpers/hash/types.js";
|
|
1
2
|
/**
|
|
2
3
|
* CSS rules
|
|
3
4
|
*/
|
|
@@ -13,4 +14,8 @@ interface CSSKeyframes {
|
|
|
13
14
|
prop: string;
|
|
14
15
|
frames: CSSKeyframe[];
|
|
15
16
|
}
|
|
16
|
-
|
|
17
|
+
/**
|
|
18
|
+
* Hash options
|
|
19
|
+
*/
|
|
20
|
+
type CSSHashOptions = Partial<Pick<UniqueHashOptions, 'length' | 'lengths' | 'throwOnCollision'>>;
|
|
21
|
+
export { CSSHashOptions, CSSKeyframe, CSSKeyframes, CSSRules };
|
package/lib/index.d.ts
CHANGED
|
@@ -1,15 +1,16 @@
|
|
|
1
1
|
import { ClassProp, classProps, defaultClassProp } from "./classname/const.js";
|
|
2
2
|
import { splitClassName, toggleClassName } from "./classname/toggle.js";
|
|
3
|
+
import { UniqueHashOptions } from "./helpers/hash/types.js";
|
|
4
|
+
import { ParsedXMLNode, ParsedXMLTagElement, ParsedXMLTextElement, StringifyXMLOptions } from "./xml/types.js";
|
|
5
|
+
import { ConvertSVGContentOptions, ConvertedSVGContent } from "./svg-css/types.js";
|
|
3
6
|
import { createCSSClassName } from "./css/hash.js";
|
|
4
7
|
import { stringifyCSSKeyframes, stringifyCSSRules, stringifyCSSSelector } from "./css/stringify.js";
|
|
5
8
|
import { hashString } from "./helpers/hash/hash.js";
|
|
6
9
|
import { hashToString } from "./helpers/hash/stringify.js";
|
|
7
|
-
import { UniqueHashOptions } from "./helpers/hash/types.js";
|
|
8
10
|
import { getUniqueHash } from "./helpers/hash/unique.js";
|
|
9
11
|
import { cloneObject } from "./helpers/misc/clone.js";
|
|
10
12
|
import { compareSets, compareValues } from "./helpers/misc/compare.js";
|
|
11
13
|
import { sortObject } from "./helpers/misc/sort-object.js";
|
|
12
|
-
import { ParsedXMLNode, ParsedXMLTagElement, ParsedXMLTextElement, StringifyXMLOptions } from "./xml/types.js";
|
|
13
14
|
import { iterateXMLContent } from "./xml/iterate.js";
|
|
14
15
|
import { parseXMLContent } from "./xml/parse.js";
|
|
15
16
|
import { stringifyXMLContent } from "./xml/stringify.js";
|
|
@@ -19,9 +20,6 @@ import { removeDuplicateIDs } from "./svg/ids/duplicate.js";
|
|
|
19
20
|
import { removeUnusedIDs } from "./svg/ids/unused.js";
|
|
20
21
|
import { changeSVGIDs } from "./svg/ids/change.js";
|
|
21
22
|
import { createUniqueIDs } from "./svg/ids/unique.js";
|
|
22
|
-
import {
|
|
23
|
-
import {
|
|
24
|
-
|
|
25
|
-
import { convertSVGRootToCSS } from "./svg-css/convert/root.js";
|
|
26
|
-
import { convertSVGContentToCSSRules } from "./svg-css/convert/content.js";
|
|
27
|
-
export { ChangeIDResult, ClassProp, ConvertedSVGContent, ParsedXMLNode, ParsedXMLTagElement, ParsedXMLTextElement, SVGConvertedToCSSProperties, SVGPropertyType, StringifyXMLOptions, UniqueHashOptions, changeIDInString, changeSVGIDs, classProps, cloneObject, compareSets, compareValues, convertSVGContentToCSSRules, convertSVGPropertyToCSS, convertSVGRootToCSS, createCSSClassName, createUniqueIDs, defaultClassProp, extractSVGTagPropertiesForCSS, getUniqueHash, hashString, hashToString, iterateXMLContent, parseXMLContent, removeDuplicateIDs, removeUnusedIDs, sortObject, splitClassName, stringifyCSSKeyframes, stringifyCSSRules, stringifyCSSSelector, stringifyXMLContent, toggleClassName };
|
|
23
|
+
import { convertSVGRootToCSS } from "./svg-css/root.js";
|
|
24
|
+
import { convertSVGContentToCSSRules } from "./svg-css/content.js";
|
|
25
|
+
export { ChangeIDResult, ClassProp, ConvertSVGContentOptions, ConvertedSVGContent, ParsedXMLNode, ParsedXMLTagElement, ParsedXMLTextElement, StringifyXMLOptions, UniqueHashOptions, changeIDInString, changeSVGIDs, classProps, cloneObject, compareSets, compareValues, convertSVGContentToCSSRules, convertSVGRootToCSS, createCSSClassName, createUniqueIDs, defaultClassProp, getUniqueHash, hashString, hashToString, iterateXMLContent, parseXMLContent, removeDuplicateIDs, removeUnusedIDs, sortObject, splitClassName, stringifyCSSKeyframes, stringifyCSSRules, stringifyCSSSelector, stringifyXMLContent, toggleClassName };
|
package/lib/index.js
CHANGED
|
@@ -16,9 +16,7 @@ import { removeDuplicateIDs } from "./svg/ids/duplicate.js";
|
|
|
16
16
|
import { removeUnusedIDs } from "./svg/ids/unused.js";
|
|
17
17
|
import { changeSVGIDs } from "./svg/ids/change.js";
|
|
18
18
|
import { createUniqueIDs } from "./svg/ids/unique.js";
|
|
19
|
-
import {
|
|
20
|
-
import {
|
|
21
|
-
import { convertSVGRootToCSS } from "./svg-css/convert/root.js";
|
|
22
|
-
import { convertSVGContentToCSSRules } from "./svg-css/convert/content.js";
|
|
19
|
+
import { convertSVGRootToCSS } from "./svg-css/root.js";
|
|
20
|
+
import { convertSVGContentToCSSRules } from "./svg-css/content.js";
|
|
23
21
|
|
|
24
|
-
export { changeIDInString, changeSVGIDs, classProps, cloneObject, compareSets, compareValues, convertSVGContentToCSSRules,
|
|
22
|
+
export { changeIDInString, changeSVGIDs, classProps, cloneObject, compareSets, compareValues, convertSVGContentToCSSRules, convertSVGRootToCSS, createCSSClassName, createUniqueIDs, defaultClassProp, getUniqueHash, hashString, hashToString, iterateXMLContent, parseXMLContent, removeDuplicateIDs, removeUnusedIDs, sortObject, splitClassName, stringifyCSSKeyframes, stringifyCSSRules, stringifyCSSSelector, stringifyXMLContent, toggleClassName };
|