@pantoken/icons 0.2.4 → 0.3.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/README.md +5 -1
- package/dist/index.d.mts +8 -3
- package/dist/index.mjs +10 -5
- package/package.json +7 -7
package/README.md
CHANGED
|
@@ -15,10 +15,12 @@ Also available as `pantoken/icons`.
|
|
|
15
15
|
## Usage
|
|
16
16
|
|
|
17
17
|
```ts
|
|
18
|
-
import {
|
|
18
|
+
import { customIcons, getIcon, icons, lucideIcons, resolve } from "@pantoken/icons";
|
|
19
19
|
|
|
20
20
|
getIcon("arrow-left"); // { name, dataUri, svg, viewBox, bidirectional, source }
|
|
21
21
|
icons.length; // the full set
|
|
22
|
+
lucideIcons.length; // canonical Lucide icons
|
|
23
|
+
customIcons.length; // Instructure-authored icons
|
|
22
24
|
|
|
23
25
|
resolve("arrow-left"); // IconResolver — for the plugin / rehype stages
|
|
24
26
|
```
|
|
@@ -29,6 +31,8 @@ plus the decoded `svg` and the original `dataUri`.
|
|
|
29
31
|
## API
|
|
30
32
|
|
|
31
33
|
- **`icons: PantokenIcon[]`** — every pantoken icon, sorted by name.
|
|
34
|
+
- **`lucideIcons: PantokenIcon[]`** — canonical Lucide icons.
|
|
35
|
+
- **`customIcons: PantokenIcon[]`** — Instructure-authored custom icons.
|
|
32
36
|
- **`iconsByName: Map<string, PantokenIcon>`** — every icon, keyed by name.
|
|
33
37
|
- **`getIcon(name): PantokenIcon | undefined`** — look up one icon by name.
|
|
34
38
|
- **`resolve: IconResolver`** — an `IconResolver` backed by the icon set, for the plugin and rehype
|
package/dist/index.d.mts
CHANGED
|
@@ -31,6 +31,10 @@ export interface PantokenIcon {
|
|
|
31
31
|
* ```
|
|
32
32
|
*/
|
|
33
33
|
export declare const icons: PantokenIcon[];
|
|
34
|
+
/** Every canonical Lucide icon. */
|
|
35
|
+
export declare const lucideIcons: PantokenIcon[];
|
|
36
|
+
/** Every Instructure-authored custom icon. */
|
|
37
|
+
export declare const customIcons: PantokenIcon[];
|
|
34
38
|
/**
|
|
35
39
|
* Every pantoken icon, keyed by name.
|
|
36
40
|
*
|
|
@@ -69,12 +73,13 @@ export declare const resolve: IconResolver;
|
|
|
69
73
|
export interface IconResolverChainOptions {
|
|
70
74
|
/** An explicit resolver, tried before the built-in pantoken icon set. */
|
|
71
75
|
resolve?: IconResolver;
|
|
72
|
-
/** Plugins whose `rehype` hooks contribute resolvers (tried
|
|
76
|
+
/** Plugins whose `rehype` hooks contribute resolvers (tried last, after the built-in set). */
|
|
73
77
|
plugins?: readonly PantokenPlugin[];
|
|
74
78
|
}
|
|
75
79
|
/**
|
|
76
|
-
* Build the shared icon-resolver chain:
|
|
77
|
-
*
|
|
80
|
+
* Build the shared icon-resolver chain: an explicit `resolve` first, then the built-in pantoken
|
|
81
|
+
* icon set, then plugin `rehype` resolvers (so a plugin can add codes the built-in set doesn't
|
|
82
|
+
* know, but never shadow a built-in icon name). Used by `@pantoken/rehype` and
|
|
78
83
|
* `@pantoken/markdown-it` so the resolution order stays identical across renderers.
|
|
79
84
|
*
|
|
80
85
|
* @example
|
package/dist/index.mjs
CHANGED
|
@@ -40,6 +40,10 @@ const icons = tokens.filter((t) => t.meta?.kind === "icon").map((t) => ({
|
|
|
40
40
|
bidirectional: Boolean(t.meta?.bidirectional),
|
|
41
41
|
source: t.meta?.source
|
|
42
42
|
}));
|
|
43
|
+
/** Every canonical Lucide icon. */
|
|
44
|
+
const lucideIcons = icons.filter((icon) => icon.source === "lucide");
|
|
45
|
+
/** Every Instructure-authored custom icon. */
|
|
46
|
+
const customIcons = icons.filter((icon) => icon.source === "custom");
|
|
43
47
|
/**
|
|
44
48
|
* Every pantoken icon, keyed by name.
|
|
45
49
|
*
|
|
@@ -85,8 +89,9 @@ const resolve = (code) => {
|
|
|
85
89
|
} : void 0;
|
|
86
90
|
};
|
|
87
91
|
/**
|
|
88
|
-
* Build the shared icon-resolver chain:
|
|
89
|
-
*
|
|
92
|
+
* Build the shared icon-resolver chain: an explicit `resolve` first, then the built-in pantoken
|
|
93
|
+
* icon set, then plugin `rehype` resolvers (so a plugin can add codes the built-in set doesn't
|
|
94
|
+
* know, but never shadow a built-in icon name). Used by `@pantoken/rehype` and
|
|
90
95
|
* `@pantoken/markdown-it` so the resolution order stays identical across renderers.
|
|
91
96
|
*
|
|
92
97
|
* @example
|
|
@@ -99,12 +104,12 @@ const resolve = (code) => {
|
|
|
99
104
|
*/
|
|
100
105
|
function buildIconResolverChain(options) {
|
|
101
106
|
const resolvers = [];
|
|
107
|
+
if (options.resolve) resolvers.push(options.resolve);
|
|
108
|
+
resolvers.push(resolve);
|
|
102
109
|
for (const plugin of options.plugins ?? []) {
|
|
103
110
|
const contributed = plugin.rehype?.({ resolve });
|
|
104
111
|
if (contributed?.resolve) resolvers.push(contributed.resolve);
|
|
105
112
|
}
|
|
106
|
-
if (options.resolve) resolvers.push(options.resolve);
|
|
107
|
-
resolvers.push(resolve);
|
|
108
113
|
return (code) => {
|
|
109
114
|
for (const resolver of resolvers) {
|
|
110
115
|
const hit = resolver(code);
|
|
@@ -113,4 +118,4 @@ function buildIconResolverChain(options) {
|
|
|
113
118
|
};
|
|
114
119
|
}
|
|
115
120
|
//#endregion
|
|
116
|
-
export { buildIconResolverChain, getIcon, icons, iconsByName, resolve };
|
|
121
|
+
export { buildIconResolverChain, customIcons, getIcon, icons, iconsByName, lucideIcons, resolve };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pantoken/icons",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.1",
|
|
4
4
|
"description": "An ergonomic view over the pantoken IR's <image> tokens: decoded SVGs and per-icon metadata.",
|
|
5
5
|
"homepage": "https://pantoken.app",
|
|
6
6
|
"bugs": "https://github.com/thedannywahl/pantoken/issues",
|
|
@@ -24,15 +24,15 @@
|
|
|
24
24
|
"provenance": true
|
|
25
25
|
},
|
|
26
26
|
"dependencies": {
|
|
27
|
-
"@pantoken/model": "0.
|
|
28
|
-
"@pantoken/tokens": "0.
|
|
29
|
-
"@pantoken/utils": "1.0
|
|
27
|
+
"@pantoken/model": "0.5.0",
|
|
28
|
+
"@pantoken/tokens": "0.7.0",
|
|
29
|
+
"@pantoken/utils": "1.2.0"
|
|
30
30
|
},
|
|
31
31
|
"devDependencies": {
|
|
32
|
-
"@types/node": "^26.
|
|
32
|
+
"@types/node": "^26.6.3",
|
|
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@1.0.0-rc.0",
|
|
35
|
+
"vite-plus": "1.0.0-rc.0"
|
|
36
36
|
},
|
|
37
37
|
"engines": {
|
|
38
38
|
"node": ">=22.18.0"
|