@askrjs/lucide 0.3.0 → 0.4.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.
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"create-icon.d.ts","names":[],"sources":["../src/create-icon.tsx"],"mappings":";;
|
|
1
|
+
{"version":3,"file":"create-icon.d.ts","names":[],"sources":["../src/create-icon.tsx"],"mappings":";;wBA4EgB,WAAW,qBAAqB,UAAU;QAG7B,QAAA,+CAAS"}
|
package/dist/create-icon.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { jsx } from "@askrjs/askr/jsx-runtime";
|
|
2
2
|
import { IconBase } from "@askrjs/askr/foundations/icon";
|
|
3
3
|
//#region src/create-icon.tsx
|
|
4
|
-
const
|
|
4
|
+
const SAFE_TAG_SET = /* @__PURE__ */ new Set([
|
|
5
5
|
"circle",
|
|
6
6
|
"ellipse",
|
|
7
7
|
"g",
|
|
@@ -11,6 +11,7 @@ const SAFE_TAGS = /* @__PURE__ */ new Set([
|
|
|
11
11
|
"polyline",
|
|
12
12
|
"rect"
|
|
13
13
|
]);
|
|
14
|
+
const createSafeSvgNode = jsx;
|
|
14
15
|
const SAFE_ATTRIBUTES = /* @__PURE__ */ new Set([
|
|
15
16
|
"cx",
|
|
16
17
|
"cy",
|
|
@@ -34,7 +35,7 @@ const URL_VALUE = /url\s*\(/i;
|
|
|
34
35
|
function copyDefinition(displayName, iconNode) {
|
|
35
36
|
if (!Array.isArray(iconNode)) throw new TypeError(`${displayName}: icon definition must be an array`);
|
|
36
37
|
return iconNode.map((entry) => {
|
|
37
|
-
if (!Array.isArray(entry) || entry.length !== 2 || !
|
|
38
|
+
if (!Array.isArray(entry) || entry.length !== 2 || !SAFE_TAG_SET.has(entry[0])) throw new TypeError(`${displayName}: icon definition contains an unsafe SVG element`);
|
|
38
39
|
const attributes = entry[1];
|
|
39
40
|
if (!attributes || typeof attributes !== "object" || Array.isArray(attributes)) throw new TypeError(`${displayName}: icon definition attributes must be an object`);
|
|
40
41
|
const copied = Object.create(null);
|
|
@@ -51,7 +52,7 @@ function createIcon(displayName, iconNode) {
|
|
|
51
52
|
return IconBase({
|
|
52
53
|
...rest,
|
|
53
54
|
iconName: displayName,
|
|
54
|
-
children: definition.map(([tag, attrs], i) =>
|
|
55
|
+
children: definition.map(([tag, attrs], i) => createSafeSvgNode(tag, attrs, i))
|
|
55
56
|
});
|
|
56
57
|
}
|
|
57
58
|
Icon.displayName = displayName;
|
package/dist/create-icon.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"create-icon.js","names":["createSvgNode"],"sources":["../src/create-icon.tsx"],"sourcesContent":["import { jsx as createSvgNode } from \"@askrjs/askr/jsx-runtime\";\nimport { IconBase } from \"@askrjs/askr/foundations/icon\";\nimport type { IconNode, IconProps } from \"./types\";\n\nconst SAFE_TAGS =
|
|
1
|
+
{"version":3,"file":"create-icon.js","names":["createSvgNode"],"sources":["../src/create-icon.tsx"],"sourcesContent":["import { jsx as createSvgNode } from \"@askrjs/askr/jsx-runtime\";\nimport type { JSX } from \"@askrjs/askr/jsx-runtime\";\nimport { IconBase } from \"@askrjs/askr/foundations/icon\";\nimport type { IconNode, IconProps } from \"./types\";\n\nconst SAFE_TAGS = [\n \"circle\",\n \"ellipse\",\n \"g\",\n \"line\",\n \"path\",\n \"polygon\",\n \"polyline\",\n \"rect\",\n] as const;\ntype SafeSvgTag = (typeof SAFE_TAGS)[number];\nconst SAFE_TAG_SET: ReadonlySet<string> = new Set(SAFE_TAGS);\nconst createSafeSvgNode = createSvgNode as unknown as (\n type: SafeSvgTag,\n props: Record<string, unknown>,\n key?: string | number,\n) => JSX.Element;\nconst SAFE_ATTRIBUTES = new Set([\n \"cx\",\n \"cy\",\n \"d\",\n \"fill\",\n \"height\",\n \"points\",\n \"r\",\n \"rx\",\n \"ry\",\n \"width\",\n \"x\",\n \"x1\",\n \"x2\",\n \"y\",\n \"y1\",\n \"y2\",\n]);\nconst URL_ATTRIBUTE = /^(?:href|src|xlink:href)$/i;\nconst URL_VALUE = /url\\s*\\(/i;\n\nfunction copyDefinition(displayName: string, iconNode: IconNode): IconNode {\n if (!Array.isArray(iconNode)) {\n throw new TypeError(`${displayName}: icon definition must be an array`);\n }\n\n return iconNode.map((entry) => {\n if (!Array.isArray(entry) || entry.length !== 2 || !SAFE_TAG_SET.has(entry[0])) {\n throw new TypeError(`${displayName}: icon definition contains an unsafe SVG element`);\n }\n const attributes = entry[1];\n if (!attributes || typeof attributes !== \"object\" || Array.isArray(attributes)) {\n throw new TypeError(`${displayName}: icon definition attributes must be an object`);\n }\n const copied = Object.create(null) as Record<string, string>;\n for (const [name, value] of Object.entries(attributes)) {\n if (\n /^on/i.test(name) ||\n /^(?:__proto__|constructor|prototype)$/i.test(name) ||\n URL_ATTRIBUTE.test(name) ||\n !SAFE_ATTRIBUTES.has(name) ||\n typeof value !== \"string\" ||\n URL_VALUE.test(value)\n ) {\n throw new TypeError(\n `${displayName}: icon definition contains an unsafe SVG attribute (${name})`,\n );\n }\n copied[name] = value;\n }\n return [entry[0], Object.freeze(copied)] as const;\n });\n}\n\nexport function createIcon(displayName: string, iconNode: IconNode) {\n const definition = Object.freeze(copyDefinition(displayName, iconNode));\n\n function Icon({ ...rest }: IconProps) {\n return IconBase({\n ...rest,\n iconName: displayName,\n children: definition.map(([tag, attrs], i) =>\n createSafeSvgNode(tag as SafeSvgTag, attrs as Record<string, unknown>, i),\n ),\n });\n }\n\n Icon.displayName = displayName;\n return Icon;\n}\n"],"mappings":";;;AAgBA,MAAM,+BAAoC,IAAI,IAAI;CAVhD;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AAGwD,CAAC;AAC3D,MAAM,oBAAoBA;AAK1B,MAAM,kCAAkB,IAAI,IAAI;CAC9B;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF,CAAC;AACD,MAAM,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/lucide",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.4.0",
|
|
4
4
|
"description": "Thin Askr wrappers for the Lucide SVG icon set",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"askr",
|
|
@@ -66,7 +66,7 @@
|
|
|
66
66
|
"test:unit": "vp test run -c vitest.config.ts"
|
|
67
67
|
},
|
|
68
68
|
"devDependencies": {
|
|
69
|
-
"@askrjs/askr": ">=0.
|
|
69
|
+
"@askrjs/askr": ">=0.4.0 <0.5.0",
|
|
70
70
|
"@vitest/coverage-v8": "^4.1.11",
|
|
71
71
|
"jsdom": "^30.0.1",
|
|
72
72
|
"lucide": "1.34.0",
|
|
@@ -75,7 +75,7 @@
|
|
|
75
75
|
"vite-plus": "^0.3.1"
|
|
76
76
|
},
|
|
77
77
|
"peerDependencies": {
|
|
78
|
-
"@askrjs/askr": ">=0.
|
|
78
|
+
"@askrjs/askr": ">=0.4.0 <0.5.0"
|
|
79
79
|
},
|
|
80
80
|
"engines": {
|
|
81
81
|
"node": ">=24.0.0"
|