@pantoken/icons 0.1.9 → 0.2.1
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/dist/index.d.mts +28 -8
- package/dist/index.mjs +29 -1
- package/package.json +8 -8
package/dist/index.d.mts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { IconResolver } from "@pantoken/model";
|
|
1
|
+
import { IconResolver, PantokenPlugin } from "@pantoken/model";
|
|
2
2
|
//#region src/index.d.ts
|
|
3
3
|
/** A pantoken icon, derived from an `<image>` token. */
|
|
4
|
-
interface PantokenIcon {
|
|
4
|
+
export interface PantokenIcon {
|
|
5
5
|
/** The icon name, without the `--instui-icon-` prefix (e.g. `arrow-left`). */
|
|
6
6
|
name: string;
|
|
7
7
|
/** The `url('data:image/svg+xml;utf8,…')` value, as stored in the IR. */
|
|
@@ -30,7 +30,7 @@ interface PantokenIcon {
|
|
|
30
30
|
* icons.filter((i) => i.source === "lucide"); // just the Lucide glyphs
|
|
31
31
|
* ```
|
|
32
32
|
*/
|
|
33
|
-
declare const icons: PantokenIcon[];
|
|
33
|
+
export declare const icons: PantokenIcon[];
|
|
34
34
|
/**
|
|
35
35
|
* Every pantoken icon, keyed by name.
|
|
36
36
|
*
|
|
@@ -41,7 +41,7 @@ declare const icons: PantokenIcon[];
|
|
|
41
41
|
* iconsByName.get("arrow-left")?.svg; // inline SVG markup
|
|
42
42
|
* ```
|
|
43
43
|
*/
|
|
44
|
-
declare const iconsByName: Map<string, PantokenIcon>;
|
|
44
|
+
export declare const iconsByName: Map<string, PantokenIcon>;
|
|
45
45
|
/**
|
|
46
46
|
* Look up an icon by name.
|
|
47
47
|
*
|
|
@@ -53,7 +53,7 @@ declare const iconsByName: Map<string, PantokenIcon>;
|
|
|
53
53
|
* icon?.viewBox; // "0 0 24 24"
|
|
54
54
|
* ```
|
|
55
55
|
*/
|
|
56
|
-
declare function getIcon(name: string): PantokenIcon | undefined;
|
|
56
|
+
export declare function getIcon(name: string): PantokenIcon | undefined;
|
|
57
57
|
/**
|
|
58
58
|
* An {@link IconResolver} backed by the pantoken icon set (for the plugin/rehype stages).
|
|
59
59
|
*
|
|
@@ -64,6 +64,26 @@ declare function getIcon(name: string): PantokenIcon | undefined;
|
|
|
64
64
|
* resolve("arrow-left"); // { name, svg, viewBox, source } | undefined
|
|
65
65
|
* ```
|
|
66
66
|
*/
|
|
67
|
-
declare const resolve: IconResolver;
|
|
68
|
-
|
|
69
|
-
export
|
|
67
|
+
export declare const resolve: IconResolver;
|
|
68
|
+
/** Options shared by the icon-resolving renderers ({@link buildIconResolverChain}). */
|
|
69
|
+
export interface IconResolverChainOptions {
|
|
70
|
+
/** An explicit resolver, tried before the built-in pantoken icon set. */
|
|
71
|
+
resolve?: IconResolver;
|
|
72
|
+
/** Plugins whose `rehype` hooks contribute resolvers (tried first). */
|
|
73
|
+
plugins?: readonly PantokenPlugin[];
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* Build the shared icon-resolver chain: plugin `rehype` resolvers first, then an explicit
|
|
77
|
+
* `resolve`, then the built-in pantoken icon set. Used by `@pantoken/rehype` and
|
|
78
|
+
* `@pantoken/markdown-it` so the resolution order stays identical across renderers.
|
|
79
|
+
*
|
|
80
|
+
* @example
|
|
81
|
+
* ```ts
|
|
82
|
+
* import { buildIconResolverChain } from "@pantoken/icons";
|
|
83
|
+
*
|
|
84
|
+
* const resolveIcon = buildIconResolverChain({ plugins: [myBrandIconsPlugin] });
|
|
85
|
+
* resolveIcon("arrow-left"); // { name, svg, viewBox, source } | undefined
|
|
86
|
+
* ```
|
|
87
|
+
*/
|
|
88
|
+
export declare function buildIconResolverChain(options: IconResolverChainOptions): IconResolver;
|
|
89
|
+
//#endregion
|
package/dist/index.mjs
CHANGED
|
@@ -84,5 +84,33 @@ const resolve = (code) => {
|
|
|
84
84
|
source: icon.source
|
|
85
85
|
} : void 0;
|
|
86
86
|
};
|
|
87
|
+
/**
|
|
88
|
+
* Build the shared icon-resolver chain: plugin `rehype` resolvers first, then an explicit
|
|
89
|
+
* `resolve`, then the built-in pantoken icon set. Used by `@pantoken/rehype` and
|
|
90
|
+
* `@pantoken/markdown-it` so the resolution order stays identical across renderers.
|
|
91
|
+
*
|
|
92
|
+
* @example
|
|
93
|
+
* ```ts
|
|
94
|
+
* import { buildIconResolverChain } from "@pantoken/icons";
|
|
95
|
+
*
|
|
96
|
+
* const resolveIcon = buildIconResolverChain({ plugins: [myBrandIconsPlugin] });
|
|
97
|
+
* resolveIcon("arrow-left"); // { name, svg, viewBox, source } | undefined
|
|
98
|
+
* ```
|
|
99
|
+
*/
|
|
100
|
+
function buildIconResolverChain(options) {
|
|
101
|
+
const resolvers = [];
|
|
102
|
+
for (const plugin of options.plugins ?? []) {
|
|
103
|
+
const contributed = plugin.rehype?.({ resolve });
|
|
104
|
+
if (contributed?.resolve) resolvers.push(contributed.resolve);
|
|
105
|
+
}
|
|
106
|
+
if (options.resolve) resolvers.push(options.resolve);
|
|
107
|
+
resolvers.push(resolve);
|
|
108
|
+
return (code) => {
|
|
109
|
+
for (const resolver of resolvers) {
|
|
110
|
+
const hit = resolver(code);
|
|
111
|
+
if (hit) return hit;
|
|
112
|
+
}
|
|
113
|
+
};
|
|
114
|
+
}
|
|
87
115
|
//#endregion
|
|
88
|
-
export { getIcon, icons, iconsByName, resolve };
|
|
116
|
+
export { buildIconResolverChain, getIcon, icons, iconsByName, resolve };
|
package/package.json
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pantoken/icons",
|
|
3
|
-
"version": "0.1
|
|
3
|
+
"version": "0.2.1",
|
|
4
4
|
"description": "An ergonomic view over the pantoken IR's <image> tokens: decoded SVGs and per-icon metadata.",
|
|
5
|
-
"homepage": "https://pantoken.
|
|
5
|
+
"homepage": "https://pantoken.app",
|
|
6
6
|
"bugs": "https://github.com/thedannywahl/pantoken/issues",
|
|
7
7
|
"license": "MIT",
|
|
8
8
|
"repository": {
|
|
@@ -24,15 +24,15 @@
|
|
|
24
24
|
"provenance": true
|
|
25
25
|
},
|
|
26
26
|
"dependencies": {
|
|
27
|
-
"@pantoken/model": "0.3.
|
|
28
|
-
"@pantoken/tokens": "0.
|
|
29
|
-
"@pantoken/utils": "1.0.
|
|
27
|
+
"@pantoken/model": "0.3.2",
|
|
28
|
+
"@pantoken/tokens": "0.3.1",
|
|
29
|
+
"@pantoken/utils": "1.0.2"
|
|
30
30
|
},
|
|
31
31
|
"devDependencies": {
|
|
32
|
-
"@types/node": "^
|
|
32
|
+
"@types/node": "^26.5.0",
|
|
33
33
|
"typescript": "^7.0.2",
|
|
34
|
-
"vite": "npm:@voidzero-dev/vite-plus-core@0.
|
|
35
|
-
"vite-plus": "0.
|
|
34
|
+
"vite": "npm:@voidzero-dev/vite-plus-core@0.3.1",
|
|
35
|
+
"vite-plus": "0.3.1"
|
|
36
36
|
},
|
|
37
37
|
"engines": {
|
|
38
38
|
"node": ">=22.18.0"
|