@pantoken/utils 0.2.4 → 0.2.6

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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Danny Wahl
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/dist/index.d.mts CHANGED
@@ -63,6 +63,13 @@ declare function focusOutlineRules(selector?: string): string;
63
63
  //#region src/index.d.ts
64
64
  /** The colour mode to collapse `light-dark()` to. */
65
65
  type Mode = "light" | "dark";
66
+ /**
67
+ * Strip `<script>` elements and event-handler attributes from SVG markup.
68
+ *
69
+ * Defense-in-depth for SVG decoded from vendored data URIs or contributed by plugins.
70
+ * Not a full HTML parser — relies on the upstream source being trusted and pinned.
71
+ */
72
+ declare function sanitizeSvg(svg: string): string;
66
73
  /** A `var(--custom-prop)` reference (optional fallback); capture group 1 is the property name. */
67
74
  declare const VAR_RE: RegExp;
68
75
  /** A `light-dark(<light>, <dark>)` value; capture groups 1 and 2 are the two branches. */
@@ -304,4 +311,4 @@ interface TokenUtilityGroup {
304
311
  */
305
312
  declare function tokenUtilitiesCss(groups: readonly TokenUtilityGroup[], options?: UtilityOptions): string;
306
313
  //#endregion
307
- export { ColorUtilityNames, ELEVATION_NAMES, FOCUSABLE_SELECTOR, LIGHT_DARK_RE, Mode, ResolveOptions, Rgba, TokenUtilityGroup, UtilityOptions, VAR_RE, camelCase, colorUtilitiesCss, danglingReferences, elevationDeclarations, extractInstuiRefs, focusOutlineDeclarations, focusOutlineRules, makeResolver, parseHexColor, resolveTokens, tokenNames, tokenUtilitiesCss, unknownReferences };
314
+ export { ColorUtilityNames, ELEVATION_NAMES, FOCUSABLE_SELECTOR, LIGHT_DARK_RE, Mode, ResolveOptions, Rgba, TokenUtilityGroup, UtilityOptions, VAR_RE, camelCase, colorUtilitiesCss, danglingReferences, elevationDeclarations, extractInstuiRefs, focusOutlineDeclarations, focusOutlineRules, makeResolver, parseHexColor, resolveTokens, sanitizeSvg, tokenNames, tokenUtilitiesCss, unknownReferences };
package/dist/index.mjs CHANGED
@@ -130,6 +130,25 @@ function focusOutlineRules(selector = FOCUSABLE_SELECTOR) {
130
130
  * @module
131
131
  * @beta
132
132
  */
133
+ /**
134
+ * Strip `<script>` elements and event-handler attributes from SVG markup.
135
+ *
136
+ * Defense-in-depth for SVG decoded from vendored data URIs or contributed by plugins.
137
+ * Not a full HTML parser — relies on the upstream source being trusted and pinned.
138
+ */
139
+ function sanitizeSvg(svg) {
140
+ let sanitized = svg;
141
+ let previous;
142
+ do {
143
+ previous = sanitized;
144
+ sanitized = sanitized.replace(/<script\b[^>]*>[\s\S]*?<\/script\b[^>]*>/gi, "");
145
+ } while (sanitized !== previous);
146
+ do {
147
+ previous = sanitized;
148
+ sanitized = sanitized.replace(/\son\w+\s*=\s*(?:"[^"]*"|'[^']*'|[^\s>]+)/gi, "");
149
+ } while (sanitized !== previous);
150
+ return sanitized;
151
+ }
133
152
  const VAR_SOURCE = "var\\(\\s*(--[\\w-]+)[^)]*\\)";
134
153
  const LIGHT_DARK_SOURCE = "^light-dark\\(\\s*(.+?)\\s*,\\s*(.+?)\\s*\\)$";
135
154
  /** A `var(--custom-prop)` reference (optional fallback); capture group 1 is the property name. */
@@ -401,4 +420,4 @@ function tokenUtilitiesCss(groups, options = {}) {
401
420
  })).join("\n")}\n`;
402
421
  }
403
422
  //#endregion
404
- export { ELEVATION_NAMES, FOCUSABLE_SELECTOR, LIGHT_DARK_RE, VAR_RE, camelCase, colorUtilitiesCss, danglingReferences, elevationDeclarations, extractInstuiRefs, focusOutlineDeclarations, focusOutlineRules, makeResolver, parseHexColor, resolveTokens, tokenNames, tokenUtilitiesCss, unknownReferences };
423
+ export { ELEVATION_NAMES, FOCUSABLE_SELECTOR, LIGHT_DARK_RE, VAR_RE, camelCase, colorUtilitiesCss, danglingReferences, elevationDeclarations, extractInstuiRefs, focusOutlineDeclarations, focusOutlineRules, makeResolver, parseHexColor, resolveTokens, sanitizeSvg, tokenNames, tokenUtilitiesCss, unknownReferences };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pantoken/utils",
3
- "version": "0.2.4",
3
+ "version": "0.2.6",
4
4
  "description": "Shared pantoken helpers: token reference resolver, typed regexes (arkregex), name-case, and hex-colour parsing.",
5
5
  "homepage": "https://pantoken.iywahl.com",
6
6
  "bugs": "https://github.com/thedannywahl/pantoken/issues",
@@ -23,22 +23,22 @@
23
23
  "access": "public",
24
24
  "provenance": true
25
25
  },
26
- "scripts": {
27
- "dev": "vp pack --watch",
28
- "test": "vp test",
29
- "check": "vp check"
30
- },
31
26
  "dependencies": {
32
- "@pantoken/model": "workspace:*",
33
- "arkregex": "catalog:"
27
+ "arkregex": "^0.0.8",
28
+ "@pantoken/model": "0.3.0"
34
29
  },
35
30
  "devDependencies": {
36
- "@types/node": "catalog:",
37
- "typescript": "catalog:",
38
- "vite": "catalog:",
39
- "vite-plus": "catalog:"
31
+ "@types/node": "^24.13.3",
32
+ "typescript": "^7.0.2",
33
+ "vite": "npm:@voidzero-dev/vite-plus-core@0.2.9",
34
+ "vite-plus": "0.2.9"
40
35
  },
41
36
  "engines": {
42
37
  "node": ">=22.18.0"
38
+ },
39
+ "scripts": {
40
+ "dev": "vp pack --watch",
41
+ "test": "vp test",
42
+ "check": "vp check"
43
43
  }
44
- }
44
+ }