@cyberalien/svg-utils 1.0.3 → 1.0.5

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.
@@ -5,5 +5,5 @@ import { ComponentFactoryFileSystemOptions, GeneratedAssetPath } from "../../typ
5
5
  * @param options Factory options
6
6
  * @returns Asset path
7
7
  */
8
- declare function getFactoryRelativeRootPath(options: Pick<ComponentFactoryFileSystemOptions, 'doubleDirsForComponents' | 'prefixDirsForComponents'>): GeneratedAssetPath;
8
+ declare function getFactoryRelativeRootPath(options: Pick<ComponentFactoryFileSystemOptions, 'doubleDirsForComponents' | 'prefixDirsForComponents'>, pathPrefix?: string): GeneratedAssetPath;
9
9
  export { getFactoryRelativeRootPath };
@@ -4,13 +4,13 @@
4
4
  * @param options Factory options
5
5
  * @returns Asset path
6
6
  */
7
- function getFactoryRelativeRootPath(options) {
7
+ function getFactoryRelativeRootPath(options, pathPrefix) {
8
8
  const { prefixDirsForComponents } = options;
9
9
  const prefixDir = prefixDirsForComponents ? typeof prefixDirsForComponents === "string" ? prefixDirsForComponents : "prefix" : "";
10
10
  const parentCount = (prefixDir ? prefixDir.split("/").length : 0) + (options.doubleDirsForComponents ? 1 : 0);
11
11
  return {
12
12
  import: parentCount ? "../".repeat(parentCount - 1) + ".." : ".",
13
- filename: ""
13
+ filename: pathPrefix ?? ""
14
14
  };
15
15
  }
16
16
 
@@ -11,8 +11,9 @@ function getGeneratedComponentTypesFilename(icon, content, options) {
11
11
  length: 8
12
12
  })}.d.ts`, options.rootPath);
13
13
  const filename = getGeneratedComponentFilename(icon, ".d.ts", options);
14
+ const rootPath = options.rootPath.filename;
14
15
  return {
15
- filename,
16
+ filename: `${rootPath ? rootPath + "/" : ""}${filename}`,
16
17
  import: `./${filename.split("/").pop()}`
17
18
  };
18
19
  }
@@ -2,5 +2,5 @@ import { ComponentFactoryFileSystemOptions } from "../types/options.js";
2
2
  /**
3
3
  * Generate file system options
4
4
  */
5
- declare function componentFactoryFileSystemOptions(base: Partial<ComponentFactoryFileSystemOptions>): ComponentFactoryFileSystemOptions;
5
+ declare function componentFactoryFileSystemOptions(base: Partial<ComponentFactoryFileSystemOptions>, pathPrefix?: string): ComponentFactoryFileSystemOptions;
6
6
  export { componentFactoryFileSystemOptions };
@@ -4,14 +4,14 @@ import { getFactoryRelativeRootPath } from "../helpers/filenames/path.js";
4
4
  /**
5
5
  * Generate file system options
6
6
  */
7
- function componentFactoryFileSystemOptions(base) {
7
+ function componentFactoryFileSystemOptions(base, pathPrefix) {
8
8
  const doubleDirsForCSS = base.doubleDirsForCSS ?? true;
9
9
  const prefixDirsForComponents = base.prefixDirsForComponents ?? false;
10
10
  const doubleDirsForComponents = base.doubleDirsForComponents ?? true;
11
11
  const rootPath = base.rootPath ?? getFactoryRelativeRootPath({
12
12
  doubleDirsForComponents,
13
13
  prefixDirsForComponents
14
- });
14
+ }, pathPrefix);
15
15
  return {
16
16
  doubleDirsForCSS,
17
17
  prefixDirsForComponents,
@@ -22,12 +22,12 @@ function uniquePromise(key, callback) {
22
22
  }]
23
23
  };
24
24
  cache.push(newItem);
25
- function done(data, err) {
25
+ function done(success, result) {
26
26
  cache = cache.filter((item) => item !== newItem);
27
27
  newItem.callbacks.forEach((item) => {
28
28
  try {
29
- if (data === void 0) item.reject(err);
30
- else item.resolve(data);
29
+ if (success) item.resolve(result);
30
+ else item.reject(result);
31
31
  } catch (err2) {}
32
32
  });
33
33
  }
@@ -35,15 +35,15 @@ function uniquePromise(key, callback) {
35
35
  try {
36
36
  cb = callback();
37
37
  } catch (err) {
38
- done(void 0, err);
38
+ done(false, err);
39
39
  return;
40
40
  }
41
41
  if (cb instanceof Promise) cb.then((data) => {
42
- done(data);
42
+ done(true, data);
43
43
  }).catch((err) => {
44
- done(void 0, err);
44
+ done(false, err);
45
45
  });
46
- else done(cb);
46
+ else done(true, cb);
47
47
  });
48
48
  }
49
49
 
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "type": "module",
4
4
  "description": "Common functions for working with SVG used by various packages.",
5
5
  "author": "Vjacheslav Trushkin",
6
- "version": "1.0.3",
6
+ "version": "1.0.5",
7
7
  "license": "MIT",
8
8
  "bugs": "https://github.com/cyberalien/svg-utils/issues",
9
9
  "homepage": "https://cyberalien.dev/",