@cyberalien/svg-utils 1.2.3 → 1.2.4
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.
|
@@ -6,5 +6,5 @@ declare function addComponentDependencies(component: FactoryGeneratedComponent,
|
|
|
6
6
|
/**
|
|
7
7
|
* Create dependencies list for package.json
|
|
8
8
|
*/
|
|
9
|
-
declare function createDependenciesForPackage(dependencies: Set<string>): Record<string, string> | undefined;
|
|
9
|
+
declare function createDependenciesForPackage(dependencies: Set<string>, customVersions?: Record<string, string>): Record<string, string> | undefined;
|
|
10
10
|
export { addComponentDependencies, createDependenciesForPackage };
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
const latestVersions = {};
|
|
2
1
|
/**
|
|
3
2
|
* Add component dependencies to set
|
|
4
3
|
*/
|
|
@@ -8,10 +7,10 @@ function addComponentDependencies(component, dependencies) {
|
|
|
8
7
|
/**
|
|
9
8
|
* Create dependencies list for package.json
|
|
10
9
|
*/
|
|
11
|
-
function createDependenciesForPackage(dependencies) {
|
|
10
|
+
function createDependenciesForPackage(dependencies, customVersions) {
|
|
12
11
|
if (dependencies.size) {
|
|
13
12
|
const result = Object.create(null);
|
|
14
|
-
for (const dependency of dependencies) result[dependency] =
|
|
13
|
+
for (const dependency of dependencies) result[dependency] = customVersions?.[dependency] ?? "latest";
|
|
15
14
|
return result;
|
|
16
15
|
}
|
|
17
16
|
}
|
package/lib/components/jsx.js
CHANGED
|
@@ -175,9 +175,11 @@ function createJSXComponent(data, options) {
|
|
|
175
175
|
\t\t${stringifyFactoryPropsAsJSON(props, "\n ")}
|
|
176
176
|
\t});`);
|
|
177
177
|
const beforeFunction = componentExternalCode.length ? componentExternalCode.join("\n") + "\n\n" : "";
|
|
178
|
+
const propTypes = stringifyFactoryPropTypes(props);
|
|
179
|
+
const typesCode = useTS ? `interface Props {\n${propTypes}\n};\n\n` : propTypes ? `/** @type {{${propTypes.replace(/\s*\n\s*/g, " ").trim()}}} */\n` : "";
|
|
178
180
|
const usedProps = getUsedFactoryProps(props);
|
|
179
181
|
const propsDestricturing = usedProps.length ? `{${[...usedProps, "...props"].join(", ")}}` : "props";
|
|
180
|
-
const componentFunction =
|
|
182
|
+
const componentFunction = `${typesCode}function Component${useTS ? `<Props>` : ""}(${propsDestricturing}) {
|
|
181
183
|
\t${componentInternalCode.join("\n ")}
|
|
182
184
|
}
|
|
183
185
|
`;
|
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.2.
|
|
6
|
+
"version": "1.2.4",
|
|
7
7
|
"license": "MIT",
|
|
8
8
|
"bugs": "https://github.com/cyberalien/svg-utils/issues",
|
|
9
9
|
"homepage": "https://cyberalien.dev/",
|