@cyberalien/svg-utils 0.1.1 → 0.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.
Files changed (97) hide show
  1. package/lib/{svg-css/factory → components}/export/fs.d.ts +1 -1
  2. package/lib/{svg-css/factory → components}/export/merge.d.ts +1 -2
  3. package/lib/{svg-css/factory → components/helpers}/content/size.d.ts +1 -1
  4. package/lib/{svg-css/factory → components/helpers}/content/stringify.d.ts +2 -2
  5. package/lib/{svg-css/factory → components/helpers}/css/generate.d.ts +4 -4
  6. package/lib/components/helpers/filenames/asset.d.ts +10 -0
  7. package/lib/components/helpers/filenames/asset.js +16 -0
  8. package/lib/{svg-css/factory → components/helpers}/filenames/css.d.ts +1 -2
  9. package/lib/{svg-css/factory → components/helpers}/filenames/css.js +3 -4
  10. package/lib/components/helpers/filenames/path.d.ts +9 -0
  11. package/lib/{svg-css/factory → components/helpers}/filenames/path.js +5 -6
  12. package/lib/{svg-css/factory → components/helpers}/filenames/types.d.ts +2 -3
  13. package/lib/{svg-css/factory → components/helpers}/filenames/types.js +1 -1
  14. package/lib/components/helpers/functions/size.d.ts +8 -0
  15. package/lib/{svg-css/factory/components/shared → components/helpers/functions}/size.js +2 -2
  16. package/lib/{svg-css/factory → components/helpers}/imports/add.d.ts +1 -1
  17. package/lib/{svg-css/factory → components/helpers}/imports/create.d.ts +1 -1
  18. package/lib/{svg-css/factory → components/helpers}/imports/stringify.d.ts +1 -1
  19. package/lib/components/helpers/imports/types.d.ts +12 -0
  20. package/lib/{svg-css/factory → components/helpers}/props/object.d.ts +1 -1
  21. package/lib/{svg-css/factory → components/helpers}/props/stringify.d.ts +1 -1
  22. package/lib/{svg-css/factory/props/types.d.ts → components/helpers/props/ts.d.ts} +1 -1
  23. package/lib/components/helpers/vue/types.d.ts +9 -0
  24. package/lib/{svg-css/factory/components → components/helpers}/vue/types.js +2 -2
  25. package/lib/components/prepare/iconify.d.ts +17 -0
  26. package/lib/components/prepare/iconify.js +38 -0
  27. package/lib/{svg-css/factory/filenames → components/prepare}/options.js +5 -7
  28. package/lib/components/raw.d.ts +8 -0
  29. package/lib/{svg-css/factory/components → components}/raw.js +8 -8
  30. package/lib/components/types/component.d.ts +29 -0
  31. package/lib/{svg-css/factory → components}/types/data.d.ts +1 -1
  32. package/lib/{svg-css/factory → components}/types/options.d.ts +9 -3
  33. package/lib/{svg-css/factory → components}/types/source.d.ts +2 -2
  34. package/lib/components/vue-func.d.ts +8 -0
  35. package/lib/{svg-css/factory/components → components}/vue-func.js +11 -11
  36. package/lib/{svg-css/factory/components → components}/vue.d.ts +3 -3
  37. package/lib/{svg-css/factory/components → components}/vue.js +11 -11
  38. package/lib/index.d.ts +5 -7
  39. package/lib/index.js +3 -5
  40. package/lib/svg-css/animations/tags.d.ts +17 -0
  41. package/lib/svg-css/animations/tags.js +26 -0
  42. package/lib/svg-css/{convert/content.d.ts → content.d.ts} +1 -2
  43. package/lib/svg-css/{convert/content.js → content.js} +2 -2
  44. package/lib/svg-css/props/prop.js +9 -0
  45. package/lib/svg-css/props/props.d.ts +1 -1
  46. package/lib/svg-css/props/props.js +3 -7
  47. package/lib/svg-css/props/types.d.ts +9 -0
  48. package/lib/svg-css/{convert/root.d.ts → root.d.ts} +2 -2
  49. package/lib/svg-css/{convert/root.js → root.js} +4 -4
  50. package/lib/svg-css/types.d.ts +5 -9
  51. package/package.json +1 -1
  52. package/lib/svg-css/convert/types.d.ts +0 -5
  53. package/lib/svg-css/factory/code/iconify.d.ts +0 -11
  54. package/lib/svg-css/factory/code/iconify.js +0 -20
  55. package/lib/svg-css/factory/code/template.d.ts +0 -6
  56. package/lib/svg-css/factory/code/template.js +0 -15
  57. package/lib/svg-css/factory/components/raw.d.ts +0 -8
  58. package/lib/svg-css/factory/components/vue-func.d.ts +0 -8
  59. package/lib/svg-css/factory/filenames/asset.d.ts +0 -11
  60. package/lib/svg-css/factory/filenames/asset.js +0 -16
  61. package/lib/svg-css/factory/filenames/path.d.ts +0 -11
  62. package/lib/svg-css/factory/types/asset.d.ts +0 -8
  63. package/lib/svg-css/factory/types/component.d.ts +0 -39
  64. package/lib/svg-css/factory/types/file.d.ts +0 -14
  65. package/lib/svg-css/factory/types/props.js +0 -1
  66. /package/lib/{svg-css/factory → components}/export/exports.d.ts +0 -0
  67. /package/lib/{svg-css/factory → components}/export/exports.js +0 -0
  68. /package/lib/{svg-css/factory → components}/export/file.d.ts +0 -0
  69. /package/lib/{svg-css/factory → components}/export/file.js +0 -0
  70. /package/lib/{svg-css/factory/filenames/component.d.ts → components/export/filename.d.ts} +0 -0
  71. /package/lib/{svg-css/factory/filenames/component.js → components/export/filename.js} +0 -0
  72. /package/lib/{svg-css/factory → components}/export/fs.js +0 -0
  73. /package/lib/{svg-css/factory → components}/export/merge.js +0 -0
  74. /package/lib/{svg-css/factory/code/stringify.d.ts → components/helpers/code/lines.d.ts} +0 -0
  75. /package/lib/{svg-css/factory/code/stringify.js → components/helpers/code/lines.js} +0 -0
  76. /package/lib/{svg-css/factory → components/helpers}/content/size.js +0 -0
  77. /package/lib/{svg-css/factory → components/helpers}/content/stringify.js +0 -0
  78. /package/lib/{svg-css/factory → components/helpers}/css/generate.js +0 -0
  79. /package/lib/{svg-css/factory → components/helpers}/css/name.d.ts +0 -0
  80. /package/lib/{svg-css/factory → components/helpers}/css/name.js +0 -0
  81. /package/lib/{svg-css/factory → components/helpers}/imports/add.js +0 -0
  82. /package/lib/{svg-css/factory → components/helpers}/imports/create.js +0 -0
  83. /package/lib/{svg-css/factory → components/helpers}/imports/stringify.js +0 -0
  84. /package/lib/{svg-css/convert → components/helpers/imports}/types.js +0 -0
  85. /package/lib/{svg-css/factory → components/helpers}/props/object.js +0 -0
  86. /package/lib/{svg-css/factory → components/helpers}/props/stringify.js +0 -0
  87. /package/lib/{svg-css/factory/props/types.js → components/helpers/props/ts.js} +0 -0
  88. /package/lib/{svg-css/factory/types/props.d.ts → components/helpers/props/types.d.ts} +0 -0
  89. /package/lib/{svg-css/factory/types/asset.js → components/helpers/props/types.js} +0 -0
  90. /package/lib/{svg-css/factory/filenames → components/prepare}/options.d.ts +0 -0
  91. /package/lib/{svg-css/factory → components}/types/component.js +0 -0
  92. /package/lib/{svg-css/factory → components}/types/css.d.ts +0 -0
  93. /package/lib/{svg-css/factory → components}/types/css.js +0 -0
  94. /package/lib/{svg-css/factory → components}/types/data.js +0 -0
  95. /package/lib/{svg-css/factory → components}/types/options.js +0 -0
  96. /package/lib/{svg-css/factory → components}/types/source.js +0 -0
  97. /package/lib/svg-css/{factory/types/file.js → props/types.js} +0 -0
@@ -1,4 +1,4 @@
1
- import { GeneratedComponentFile } from "../types/file.js";
1
+ import { GeneratedComponentFile } from "../types/component.js";
2
2
  /**
3
3
  * Save exported files to filesystem
4
4
  */
@@ -1,5 +1,4 @@
1
- import { GeneratedComponentFile } from "../types/file.js";
2
- import { FactoryComponent } from "../types/component.js";
1
+ import { FactoryComponent, GeneratedComponentFile } from "../types/component.js";
3
2
  /**
4
3
  * Merge exported component files into single array
5
4
  */
@@ -1,5 +1,5 @@
1
1
  import { IconViewBox } from "../../../svg/viewbox/types.js";
2
- import { ComponentFactoryRenderingOptions } from "../types/options.js";
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 "../types/source.js";
2
- import { ComponentFactoryRenderingOptions } from "../types/options.js";
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 { ComponentFactorySource } from "../types/source.js";
2
- import { GeneratedAssetFile } from "../types/file.js";
3
- import { FactoryComponentImports } from "../types/component.js";
4
- import { ComponentFactoryOptions } from "../types/options.js";
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,5 +1,4 @@
1
- import { GeneratedAssetPath } from "../types/asset.js";
2
- import { ComponentFactoryOptions } from "../types/options.js";
1
+ import { ComponentFactoryOptions, GeneratedAssetPath } from "../../types/options.js";
3
2
  /**
4
3
  * Generate CSS filename based on options
5
4
  */
@@ -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 asset from component
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 getFactoryRelativeAssetPath(path, options) {
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: (parentCount ? "../".repeat(parentCount) : "./") + path,
14
- filename: path
12
+ import: parentCount ? "../".repeat(parentCount - 1) + ".." : ".",
13
+ filename: ""
15
14
  };
16
15
  }
17
16
 
18
- export { getFactoryRelativeAssetPath };
17
+ export { getFactoryRelativeRootPath };
@@ -1,6 +1,5 @@
1
- import { FactoryIconData } from "../types/data.js";
2
- import { GeneratedAssetPath } from "../types/asset.js";
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
  */
@@ -1,4 +1,4 @@
1
- import { getGeneratedComponentFilename } from "./component.js";
1
+ import { getGeneratedComponentFilename } from "../../export/filename.js";
2
2
 
3
3
  /**
4
4
  * Generate component types filename based on options
@@ -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 "../../filenames/asset.js";
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,
@@ -1,4 +1,4 @@
1
- import { FactoryComponentImports } from "../types/component.js";
1
+ import { FactoryComponentImports } from "./types.js";
2
2
  /**
3
3
  * Add named import
4
4
  */
@@ -1,4 +1,4 @@
1
- import { FactoryComponentImports } from "../types/component.js";
1
+ import { FactoryComponentImports } from "./types.js";
2
2
  /**
3
3
  * Create imports object
4
4
  */
@@ -1,4 +1,4 @@
1
- import { FactoryComponentImports } from "../types/component.js";
1
+ import { FactoryComponentImports } from "./types.js";
2
2
  /**
3
3
  * Export imports as string
4
4
  */
@@ -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 };
@@ -1,4 +1,4 @@
1
- import { FactoryComponentProps } from "../types/props.js";
1
+ import { FactoryComponentProps } from "./types.js";
2
2
  /**
3
3
  * Stringify properties for component as JS object
4
4
  */
@@ -1,4 +1,4 @@
1
- import { FactoryComponentProps } from "../types/props.js";
1
+ import { FactoryComponentProps } from "./types.js";
2
2
  /**
3
3
  * Template for property
4
4
  */
@@ -1,4 +1,4 @@
1
- import { FactoryComponentProps } from "../types/props.js";
1
+ import { FactoryComponentProps } from "./types.js";
2
2
  /**
3
3
  * Stringify properties for component
4
4
  */
@@ -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 "../../filenames/types.js";
2
- import { stringifyFactoryPropTypes } from "../../props/types.js";
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 { getFactoryRelativeAssetPath } from "./path.js";
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 chunksPath = base.chunksPath ?? getFactoryRelativeAssetPath("assets", {
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
- chunksPath,
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 { getIconViewBox } from "../../../svg/viewbox/value.js";
2
- import { getComponentSizeValues } from "../content/size.js";
3
- import { stringifyFactoryIconContent } from "../content/stringify.js";
4
- import { getGeneratedComponentTypesFilename } from "../filenames/types.js";
5
- import { createFactoryImports } from "../imports/create.js";
6
- import { generateCSSFilesForComponent } from "../css/generate.js";
7
- import { stringifyFactoryImports } from "../imports/stringify.js";
8
- import { factoryPropTemplate, stringifyFactoryProps } from "../props/stringify.js";
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,4 +1,4 @@
1
- import { IconViewBox } from "../../../svg/viewbox/types.js";
1
+ import { IconViewBox } from "../../svg/viewbox/types.js";
2
2
  import { ComponentFactorySource } from "./source.js";
3
3
  /**
4
4
  * Icon data
@@ -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
- chunksPath: GeneratedAssetPath;
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 "../../../css/types.js";
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 { makeSquareViewBox } from "../../../svg/viewbox/square.js";
2
- import { getIconViewBox } from "../../../svg/viewbox/value.js";
3
- import { getComponentSizeValues } from "../content/size.js";
4
- import { stringifyFactoryIconContent } from "../content/stringify.js";
5
- import { createFactoryImports } from "../imports/create.js";
6
- import { generateCSSFilesForComponent } from "../css/generate.js";
7
- import { stringifyFactoryImports } from "../imports/stringify.js";
8
- import { getUsedFactoryProps } from "../props/types.js";
9
- import { addVueComponentTypes } from "./vue/types.js";
10
- import { addSizeFunctionAsset } from "./shared/size.js";
11
- import { stringifyFactoryPropsAsJSON } from "../props/object.js";
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 { FactoryIconData } from "../types/data.js";
2
- import { FactoryGeneratedComponent } from "../types/component.js";
3
- import { ComponentFactoryOptions } from "../types/options.js";
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 { makeSquareViewBox } from "../../../svg/viewbox/square.js";
2
- import { getIconViewBox } from "../../../svg/viewbox/value.js";
3
- import { getComponentSizeValues } from "../content/size.js";
4
- import { stringifyFactoryIconContent } from "../content/stringify.js";
5
- import { createFactoryImports } from "../imports/create.js";
6
- import { generateCSSFilesForComponent } from "../css/generate.js";
7
- import { stringifyFactoryImports } from "../imports/stringify.js";
8
- import { stringifyFactoryProps } from "../props/stringify.js";
9
- import { getUsedFactoryProps, stringifyFactoryPropTypes } from "../props/types.js";
10
- import { addVueComponentTypes } from "./vue/types.js";
11
- import { addSizeFunctionAsset } from "./shared/size.js";
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/index.d.ts CHANGED
@@ -1,5 +1,7 @@
1
1
  import { ClassProp, classProps, defaultClassProp } from "./classname/const.js";
2
2
  import { splitClassName, toggleClassName } from "./classname/toggle.js";
3
+ import { ParsedXMLNode, ParsedXMLTagElement, ParsedXMLTextElement, StringifyXMLOptions } from "./xml/types.js";
4
+ import { ConvertSVGContentOptions, ConvertedSVGContent } from "./svg-css/types.js";
3
5
  import { createCSSClassName } from "./css/hash.js";
4
6
  import { stringifyCSSKeyframes, stringifyCSSRules, stringifyCSSSelector } from "./css/stringify.js";
5
7
  import { hashString } from "./helpers/hash/hash.js";
@@ -9,7 +11,6 @@ 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 { ConvertedSVGContent, SVGConvertedToCSSProperties, SVGPropertyType } from "./svg-css/types.js";
23
- import { convertSVGPropertyToCSS } from "./svg-css/props/prop.js";
24
- import { extractSVGTagPropertiesForCSS } from "./svg-css/props/props.js";
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 { convertSVGPropertyToCSS } from "./svg-css/props/prop.js";
20
- import { extractSVGTagPropertiesForCSS } from "./svg-css/props/props.js";
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, convertSVGPropertyToCSS, convertSVGRootToCSS, createCSSClassName, createUniqueIDs, defaultClassProp, extractSVGTagPropertiesForCSS, getUniqueHash, hashString, hashToString, iterateXMLContent, parseXMLContent, removeDuplicateIDs, removeUnusedIDs, sortObject, splitClassName, stringifyCSSKeyframes, stringifyCSSRules, stringifyCSSSelector, stringifyXMLContent, toggleClassName };
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 };
@@ -0,0 +1,17 @@
1
+ /**
2
+ * Tags for animating one attribute in SVG
3
+ */
4
+ declare const svgSimpleAnimationTags: string[];
5
+ /**
6
+ * Tag for animating transformations in SVG
7
+ */
8
+ declare const svgAnimateTransformTag = "animateTransform";
9
+ /**
10
+ * Tag for animating motion in SVG
11
+ */
12
+ declare const svgAnimateMotionTag = "animateMotion";
13
+ /**
14
+ * All tags for animating SVG
15
+ */
16
+ declare const svgAnimationTags: string[];
17
+ export { svgAnimateMotionTag, svgAnimateTransformTag, svgAnimationTags, svgSimpleAnimationTags };
@@ -0,0 +1,26 @@
1
+ /**
2
+ * Tags for animating one attribute in SVG
3
+ */
4
+ const svgSimpleAnimationTags = [
5
+ "animate",
6
+ "set",
7
+ "discard"
8
+ ];
9
+ /**
10
+ * Tag for animating transformations in SVG
11
+ */
12
+ const svgAnimateTransformTag = "animateTransform";
13
+ /**
14
+ * Tag for animating motion in SVG
15
+ */
16
+ const svgAnimateMotionTag = "animateMotion";
17
+ /**
18
+ * All tags for animating SVG
19
+ */
20
+ const svgAnimationTags = [
21
+ ...svgSimpleAnimationTags,
22
+ svgAnimateTransformTag,
23
+ svgAnimateMotionTag
24
+ ];
25
+
26
+ export { svgAnimateMotionTag, svgAnimateTransformTag, svgAnimationTags, svgSimpleAnimationTags };
@@ -1,5 +1,4 @@
1
- import { ConvertedSVGContent } from "../types.js";
2
- import { ConvertSVGContentOptions } from "./types.js";
1
+ import { ConvertSVGContentOptions, ConvertedSVGContent } from "./types.js";
3
2
  /**
4
3
  * Convert SVG content string to SVG+CSS
5
4
  */
@@ -1,5 +1,5 @@
1
- import { parseXMLContent } from "../../xml/parse.js";
2
- import { stringifyXMLContent } from "../../xml/stringify.js";
1
+ import { parseXMLContent } from "../xml/parse.js";
2
+ import { stringifyXMLContent } from "../xml/stringify.js";
3
3
  import { convertSVGRootToCSS } from "./root.js";
4
4
 
5
5
  /**
@@ -1,8 +1,14 @@
1
+ /**
2
+ * SVG property types
3
+ */
1
4
  const propTypes = [
2
5
  "path",
3
6
  "px",
4
7
  "raw"
5
8
  ];
9
+ /**
10
+ * Props shared between multiple shapes
11
+ */
6
12
  const commonShapes = { px: [
7
13
  "width",
8
14
  "height",
@@ -14,6 +20,9 @@ const commonShapes = { px: [
14
20
  "rx",
15
21
  "ry"
16
22
  ] };
23
+ /**
24
+ * Shape specific properties that can be converted to CSS
25
+ */
17
26
  const props = {
18
27
  "*": {
19
28
  px: ["stroke-width"],
@@ -1,5 +1,5 @@
1
1
  import { ParsedXMLTagElement } from "../../xml/types.js";
2
- import { SVGConvertedToCSSProperties } from "../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,11 +1,7 @@
1
1
  import { iterateXMLContent } from "../../xml/iterate.js";
2
2
  import { convertSVGPropertyToCSS } from "./prop.js";
3
+ import { svgAnimateTransformTag, svgSimpleAnimationTags } from "../animations/tags.js";
3
4
 
4
- const animationTags = [
5
- "animate",
6
- "set",
7
- "discard"
8
- ];
9
5
  /**
10
6
  * Extract SVG tag properties that can be converted to CSS
11
7
  *
@@ -19,11 +15,11 @@ function extractSVGTagPropertiesForCSS(tag) {
19
15
  const animatedProps = /* @__PURE__ */ new Set();
20
16
  iterateXMLContent(tag.children, (node) => {
21
17
  if (node.type === "tag") {
22
- if (animationTags.includes(node.tag)) {
18
+ if (svgSimpleAnimationTags.includes(node.tag)) {
23
19
  const prop = node.attribs.attributeName;
24
20
  if (typeof prop === "string") animatedProps.add(prop);
25
21
  }
26
- if (node.tag === "animateTransform") animatedProps.add("transform");
22
+ if (node.tag === svgAnimateTransformTag) animatedProps.add("transform");
27
23
  }
28
24
  });
29
25
  for (const prop in tag.attribs) if (!animatedProps.has(prop)) {
@@ -0,0 +1,9 @@
1
+ import { CSSRules } from "../../css/types.js";
2
+ /**
3
+ * Result of converting SVG properties to CSS
4
+ */
5
+ interface SVGConvertedToCSSProperties {
6
+ props: string[];
7
+ rules: CSSRules;
8
+ }
9
+ export { SVGConvertedToCSSProperties };
@@ -1,5 +1,5 @@
1
- import { CSSRules } from "../../css/types.js";
2
- import { ParsedXMLTagElement } from "../../xml/types.js";
1
+ import { CSSRules } from "../css/types.js";
2
+ import { ParsedXMLTagElement } from "../xml/types.js";
3
3
  /**
4
4
  * Convert SVG tags tree to SVG+CSS
5
5
  *
@@ -1,7 +1,7 @@
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";
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,14 +1,10 @@
1
1
  import { CSSKeyframes, CSSRules } from "../css/types.js";
2
+ import { StringifyXMLOptions } from "../xml/types.js";
2
3
  /**
3
- * SVG property types
4
+ * Options for converting SVG content to SVG+CSS
4
5
  */
5
- type SVGPropertyType = 'path' | 'px' | 'raw';
6
- /**
7
- * Result of converting SVG properties to CSS
8
- */
9
- interface SVGConvertedToCSSProperties {
10
- props: string[];
11
- rules: CSSRules;
6
+ interface ConvertSVGContentOptions extends StringifyXMLOptions {
7
+ classNamePrefix?: string;
12
8
  }
13
9
  /**
14
10
  * Result of converting SVG content to SVG+CSS
@@ -18,4 +14,4 @@ interface ConvertedSVGContent {
18
14
  classes?: Record<string, CSSRules>;
19
15
  keyframes?: Record<string, CSSKeyframes>;
20
16
  }
21
- export { ConvertedSVGContent, SVGConvertedToCSSProperties, SVGPropertyType };
17
+ export { ConvertSVGContentOptions, ConvertedSVGContent };
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.1.1",
6
+ "version": "0.1.2",
7
7
  "license": "MIT",
8
8
  "bugs": "https://github.com/cyberalien/svg-utils/issues",
9
9
  "homepage": "https://cyberalien.dev/",
@@ -1,5 +0,0 @@
1
- import { StringifyXMLOptions } from "../../xml/types.js";
2
- interface ConvertSVGContentOptions extends StringifyXMLOptions {
3
- classNamePrefix?: string;
4
- }
5
- export { ConvertSVGContentOptions };
@@ -1,11 +0,0 @@
1
- import { ConvertSVGContentOptions } from "../../convert/types.js";
2
- import { FactoryIconData } from "../types/data.js";
3
- import { IconifyIcon } from "@iconify/types";
4
- interface Options extends ConvertSVGContentOptions {
5
- fallback?: string | boolean;
6
- }
7
- /**
8
- * Convert IconifyIcon data to FactoryIconData
9
- */
10
- declare function convertIconifyIconToFactoryContent(icon: IconifyIcon, prefix: string, name: string, options?: Options): FactoryIconData;
11
- export { convertIconifyIconToFactoryContent };
@@ -1,20 +0,0 @@
1
- import { convertSVGContentToCSSRules } from "../../convert/content.js";
2
- import { normaliseIconifyIcon } from "../../../iconify/icon/nornalise.js";
3
-
4
- /**
5
- * Convert IconifyIcon data to FactoryIconData
6
- */
7
- function convertIconifyIconToFactoryContent(icon, prefix, name, options) {
8
- const { body, viewBox } = normaliseIconifyIcon(icon);
9
- const fallbackOption = options?.fallback ?? true;
10
- const fallback = typeof fallbackOption === "string" ? fallbackOption : fallbackOption ? `${prefix}:${name}` : void 0;
11
- return {
12
- prefix,
13
- name,
14
- viewBox,
15
- icon: convertSVGContentToCSSRules(body, options),
16
- fallback
17
- };
18
- }
19
-
20
- export { convertIconifyIconToFactoryContent };
@@ -1,6 +0,0 @@
1
- import { FactoryComponentTemplate } from "../types/component.js";
2
- /**
3
- * Create empty code object
4
- */
5
- declare function createFactoryCodeTemplate(): FactoryComponentTemplate;
6
- export { createFactoryCodeTemplate };
@@ -1,15 +0,0 @@
1
- /**
2
- * Create empty code object
3
- */
4
- function createFactoryCodeTemplate() {
5
- return {
6
- tag: "",
7
- hardcoded: Object.create(null),
8
- vars: Object.create(null),
9
- spread: [],
10
- propTypes: Object.create(null),
11
- optionalProps: []
12
- };
13
- }
14
-
15
- export { createFactoryCodeTemplate };
@@ -1,8 +0,0 @@
1
- import { FactoryIconData } from "../types/data.js";
2
- import { FactoryGeneratedComponent } from "../types/component.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,8 +0,0 @@
1
- import { FactoryIconData } from "../types/data.js";
2
- import { FactoryGeneratedComponent } from "../types/component.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,11 +0,0 @@
1
- import { GeneratedAssetPath } from "../types/asset.js";
2
- import { ComponentFactoryFileSystemOptions } from "../types/options.js";
3
- /**
4
- * Generate asset filename based on options
5
- *
6
- * @param filename - Filename without path
7
- * @param options - Options to generate path
8
- * @returns Asset path
9
- */
10
- declare function getGeneratedAssetFilename(filename: string, options: Pick<ComponentFactoryFileSystemOptions, 'chunksPath'>): GeneratedAssetPath;
11
- export { getGeneratedAssetFilename };
@@ -1,16 +0,0 @@
1
- /**
2
- * Generate asset filename based on options
3
- *
4
- * @param filename - Filename without path
5
- * @param options - Options to generate path
6
- * @returns Asset path
7
- */
8
- function getGeneratedAssetFilename(filename, options) {
9
- const { chunksPath } = options;
10
- return {
11
- import: `${chunksPath.import}/${filename}`,
12
- filename: `${chunksPath.filename}/${filename}`
13
- };
14
- }
15
-
16
- export { getGeneratedAssetFilename };
@@ -1,11 +0,0 @@
1
- import { GeneratedAssetPath } from "../types/asset.js";
2
- import { ComponentFactoryFileSystemOptions } from "../types/options.js";
3
- /**
4
- * Get relative path to asset from component
5
- *
6
- * @param path Path to asset, without trailing slash
7
- * @param options Factory options
8
- * @returns Asset path
9
- */
10
- declare function getFactoryRelativeAssetPath(path: string, options: Pick<ComponentFactoryFileSystemOptions, 'doubleDirsForComponents' | 'prefixDirsForComponents'>): GeneratedAssetPath;
11
- export { getFactoryRelativeAssetPath };
@@ -1,8 +0,0 @@
1
- /**
2
- * Asset path, generated from configuration
3
- */
4
- interface GeneratedAssetPath {
5
- filename: string;
6
- import: string;
7
- }
8
- export { GeneratedAssetPath };
@@ -1,39 +0,0 @@
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
- types?: string;
31
- }
32
- /**
33
- * Component data with filename
34
- */
35
- interface FactoryComponent extends Omit<FactoryGeneratedComponent, 'ext' | 'forceExtension'> {
36
- icon: string;
37
- filename: string;
38
- }
39
- export { FactoryComponent, FactoryComponentImports, FactoryComponentTemplate, FactoryGeneratedComponent };
@@ -1,14 +0,0 @@
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 };
@@ -1 +0,0 @@
1
- export { };