@riebeckite/plugin-icons 0.0.0-stage → 0.0.33
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 +201 -0
- package/README.md +168 -2
- package/README_ja.md +169 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.js +1735 -0
- package/dist/src/color.d.ts +3 -0
- package/dist/src/emoji.d.ts +2 -0
- package/dist/src/iconic.d.ts +13 -0
- package/dist/src/iconize.d.ts +12 -0
- package/dist/src/remark.d.ts +11 -0
- package/dist/src/render.d.ts +15 -0
- package/dist/src/resolve.d.ts +20 -0
- package/dist/src/settings.d.ts +29 -0
- package/dist/src/types.d.ts +132 -0
- package/package.json +61 -3
- package/style.css +46 -0
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { IconicData, IconicRule, IconTarget } from "./types.js";
|
|
2
|
+
type IconicResolution = {
|
|
3
|
+
readonly icon?: string;
|
|
4
|
+
readonly color?: string;
|
|
5
|
+
readonly rule?: string;
|
|
6
|
+
};
|
|
7
|
+
export type IconicDiagnosticReporter = (rule: IconicRule, message: string) => void;
|
|
8
|
+
export declare function resolveIconic(data: IconicData, target: IconTarget, options: {
|
|
9
|
+
readonly colors: boolean;
|
|
10
|
+
readonly report: IconicDiagnosticReporter;
|
|
11
|
+
}): IconicResolution | undefined;
|
|
12
|
+
export declare function resolveIconicReference(icon: string): string;
|
|
13
|
+
export {};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { type IconPacks } from "./settings.js";
|
|
2
|
+
import type { IconizeData, IconTarget } from "./types.js";
|
|
3
|
+
type IconizeResolution = {
|
|
4
|
+
readonly icon: string;
|
|
5
|
+
readonly color?: string;
|
|
6
|
+
};
|
|
7
|
+
export declare function resolveIconize(data: IconizeData, target: IconTarget, options: {
|
|
8
|
+
readonly colors: boolean;
|
|
9
|
+
readonly packs: IconPacks;
|
|
10
|
+
}): IconizeResolution | undefined;
|
|
11
|
+
export declare function parseIconReference(value: string, packNames: Iterable<string>): string | undefined;
|
|
12
|
+
export {};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { ContentIcon } from "@riebeckite/core";
|
|
2
|
+
import type { Root } from "mdast";
|
|
3
|
+
type InlineIconOptions = {
|
|
4
|
+
readonly identifier: string;
|
|
5
|
+
readonly resolve: (name: string) => ContentIcon | undefined;
|
|
6
|
+
};
|
|
7
|
+
type SourceFile = {
|
|
8
|
+
readonly value: unknown;
|
|
9
|
+
};
|
|
10
|
+
export declare function remarkIcons(options: InlineIconOptions): (tree: Root, file: SourceFile) => void;
|
|
11
|
+
export {};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { type ContentIcon } from "@riebeckite/core";
|
|
2
|
+
import { type LoadedIconsSettings } from "./settings.js";
|
|
3
|
+
import type { IconPrecedence } from "./types.js";
|
|
4
|
+
type IconRenderOptions = {
|
|
5
|
+
readonly source: IconPrecedence;
|
|
6
|
+
readonly target: string;
|
|
7
|
+
readonly color?: string;
|
|
8
|
+
readonly label?: string;
|
|
9
|
+
};
|
|
10
|
+
export declare class IconRenderer {
|
|
11
|
+
#private;
|
|
12
|
+
constructor(settings: LoadedIconsSettings);
|
|
13
|
+
render(reference: string, options: IconRenderOptions): ContentIcon | undefined;
|
|
14
|
+
}
|
|
15
|
+
export {};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { ConfigValidationIssue, ContentIcon, ContentManifestEntry } from "@riebeckite/core";
|
|
2
|
+
import { type IconicDiagnosticReporter } from "./iconic.js";
|
|
3
|
+
import { type LoadedIconsSettings } from "./settings.js";
|
|
4
|
+
import type { IconsOptions, ResolvedIconsOptions } from "./types.js";
|
|
5
|
+
export declare function resolveIconsOptions(options: IconsOptions | undefined): ResolvedIconsOptions;
|
|
6
|
+
export declare function validateIconsOptions(options: IconsOptions | undefined): readonly ConfigValidationIssue[] | undefined;
|
|
7
|
+
export type IconResolver = {
|
|
8
|
+
readonly identifier: string;
|
|
9
|
+
forEntry(entry: ContentManifestEntry): ContentIcon | undefined;
|
|
10
|
+
forFolder(folder: string): ContentIcon | undefined;
|
|
11
|
+
forTag(tag: string): ContentIcon | undefined;
|
|
12
|
+
forProperty(property: string): ContentIcon | undefined;
|
|
13
|
+
inline(name: string): ContentIcon | undefined;
|
|
14
|
+
warnings(): readonly string[];
|
|
15
|
+
};
|
|
16
|
+
export declare function createIconResolver(input: {
|
|
17
|
+
readonly settings: LoadedIconsSettings;
|
|
18
|
+
readonly options: ResolvedIconsOptions;
|
|
19
|
+
readonly reportRule: IconicDiagnosticReporter;
|
|
20
|
+
}): IconResolver;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { type ResolvedRiebeckiteConfig } from "@riebeckite/core";
|
|
2
|
+
import type { IconicData, IconizeData, ResolvedIconsOptions } from "./types.js";
|
|
3
|
+
type IconDiagnostic = {
|
|
4
|
+
readonly code: string;
|
|
5
|
+
readonly severity: "info" | "warning";
|
|
6
|
+
readonly message: string;
|
|
7
|
+
readonly meta?: Readonly<Record<string, unknown>>;
|
|
8
|
+
};
|
|
9
|
+
type IconPackFile = {
|
|
10
|
+
readonly name: string;
|
|
11
|
+
readonly filePath: string;
|
|
12
|
+
readonly size: number;
|
|
13
|
+
readonly modified: number;
|
|
14
|
+
};
|
|
15
|
+
export type IconPacks = ReadonlyMap<string, ReadonlyMap<string, IconPackFile>>;
|
|
16
|
+
export type LoadedIconsSettings = {
|
|
17
|
+
readonly iconize?: IconizeData;
|
|
18
|
+
readonly iconic?: IconicData;
|
|
19
|
+
readonly iconPacks: IconPacks;
|
|
20
|
+
readonly iconPacksRoot?: string;
|
|
21
|
+
readonly vaultPrefix: string;
|
|
22
|
+
readonly fingerprint: string;
|
|
23
|
+
readonly diagnostics: readonly IconDiagnostic[];
|
|
24
|
+
};
|
|
25
|
+
export declare function loadIconsSettings(options: ResolvedIconsOptions, config: ResolvedRiebeckiteConfig | undefined): Promise<LoadedIconsSettings>;
|
|
26
|
+
export declare function findIconPackFile(packs: IconPacks, packName: string, iconName: string): IconPackFile | undefined;
|
|
27
|
+
export declare function normalizeIconName(name: string): string;
|
|
28
|
+
export declare function normalizeVaultPath(value: string): string | undefined;
|
|
29
|
+
export {};
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
import type { ContentIcon } from "@riebeckite/core";
|
|
2
|
+
export type IconSource = "iconize" | "iconic";
|
|
3
|
+
export type IconPrecedence = "config" | "frontmatter" | IconSource;
|
|
4
|
+
export type IconOverride = string | {
|
|
5
|
+
icon: string;
|
|
6
|
+
color?: string;
|
|
7
|
+
};
|
|
8
|
+
export type IconsOptions = {
|
|
9
|
+
/** Sources to read. Defaults to both Iconize and Iconic. */
|
|
10
|
+
sources?: readonly IconSource[];
|
|
11
|
+
/** Resolve colon-delimited inline icons in Markdown. Defaults to `true`. */
|
|
12
|
+
inline?: boolean;
|
|
13
|
+
/** Read the icon field from frontmatter. Defaults to `true`. */
|
|
14
|
+
frontmatter?: boolean;
|
|
15
|
+
/** Apply configured icon colors. Defaults to `true`. */
|
|
16
|
+
colors?: boolean;
|
|
17
|
+
/** Per-surface source order. Defaults to config, frontmatter, iconic, iconize. */
|
|
18
|
+
precedence?: readonly IconPrecedence[];
|
|
19
|
+
/** Explicit icons keyed by vault-relative file or folder path. */
|
|
20
|
+
overrides?: Readonly<Record<string, IconOverride>>;
|
|
21
|
+
/** Obsidian vault root. Detected from the content directory when omitted. */
|
|
22
|
+
vaultRoot?: string;
|
|
23
|
+
/** Vault path prefix for the content directory, for example `"content/"`. */
|
|
24
|
+
vaultPrefix?: string;
|
|
25
|
+
iconize?: {
|
|
26
|
+
enabled?: boolean;
|
|
27
|
+
dataFile?: string;
|
|
28
|
+
iconPacks?: string;
|
|
29
|
+
};
|
|
30
|
+
iconic?: {
|
|
31
|
+
enabled?: boolean;
|
|
32
|
+
dataFile?: string;
|
|
33
|
+
};
|
|
34
|
+
};
|
|
35
|
+
export type ResolvedIconsOptions = {
|
|
36
|
+
sources: readonly IconSource[];
|
|
37
|
+
inline: boolean;
|
|
38
|
+
frontmatter: boolean;
|
|
39
|
+
colors: boolean;
|
|
40
|
+
precedence: readonly IconPrecedence[];
|
|
41
|
+
overrides: Readonly<Record<string, IconOverride>>;
|
|
42
|
+
vaultRoot?: string;
|
|
43
|
+
vaultPrefix?: string;
|
|
44
|
+
iconize: {
|
|
45
|
+
enabled: boolean;
|
|
46
|
+
dataFile?: string;
|
|
47
|
+
iconPacks?: string;
|
|
48
|
+
};
|
|
49
|
+
iconic: {
|
|
50
|
+
enabled: boolean;
|
|
51
|
+
dataFile?: string;
|
|
52
|
+
};
|
|
53
|
+
};
|
|
54
|
+
export type IconizeSettings = {
|
|
55
|
+
iconPacksPath: string;
|
|
56
|
+
iconColor: string | null;
|
|
57
|
+
iconInFrontmatterEnabled: boolean;
|
|
58
|
+
iconInFrontmatterFieldName: string;
|
|
59
|
+
iconColorInFrontmatterFieldName: string;
|
|
60
|
+
iconsInNotesEnabled: boolean;
|
|
61
|
+
iconInLinksEnabled: boolean;
|
|
62
|
+
iconIdentifier: string;
|
|
63
|
+
lucideIconPackType: "none" | "custom" | "native";
|
|
64
|
+
emojiStyle: "native" | "twemoji";
|
|
65
|
+
rules: readonly IconizeRule[];
|
|
66
|
+
};
|
|
67
|
+
export type IconizeRule = {
|
|
68
|
+
rule: string;
|
|
69
|
+
icon: string;
|
|
70
|
+
order: number;
|
|
71
|
+
color?: string | null;
|
|
72
|
+
useFilePath?: boolean;
|
|
73
|
+
for?: "everything" | "files" | "folders";
|
|
74
|
+
};
|
|
75
|
+
export type IconizeValue = {
|
|
76
|
+
iconName: string | null;
|
|
77
|
+
iconColor?: string;
|
|
78
|
+
};
|
|
79
|
+
export type IconizeData = {
|
|
80
|
+
settings: IconizeSettings;
|
|
81
|
+
icons: ReadonlyMap<string, IconizeValue>;
|
|
82
|
+
};
|
|
83
|
+
export type IconicValue = {
|
|
84
|
+
icon?: string;
|
|
85
|
+
color?: string;
|
|
86
|
+
};
|
|
87
|
+
type IconicCondition = {
|
|
88
|
+
source?: string;
|
|
89
|
+
operator?: string;
|
|
90
|
+
value?: string;
|
|
91
|
+
};
|
|
92
|
+
export type IconicRule = {
|
|
93
|
+
id?: string;
|
|
94
|
+
name?: string;
|
|
95
|
+
icon?: string;
|
|
96
|
+
color?: string;
|
|
97
|
+
match?: "all" | "any" | "none";
|
|
98
|
+
conditions?: readonly IconicCondition[];
|
|
99
|
+
enabled?: boolean;
|
|
100
|
+
};
|
|
101
|
+
export type IconicData = {
|
|
102
|
+
fileIcons: Readonly<Record<string, IconicValue>>;
|
|
103
|
+
tagIcons: Readonly<Record<string, IconicValue>>;
|
|
104
|
+
propertyIcons: Readonly<Record<string, IconicValue>>;
|
|
105
|
+
fileRules: readonly IconicRule[];
|
|
106
|
+
folderRules: readonly IconicRule[];
|
|
107
|
+
};
|
|
108
|
+
type IconTargetKind = "file" | "folder";
|
|
109
|
+
export type IconTarget = {
|
|
110
|
+
kind: IconTargetKind;
|
|
111
|
+
/** Vault-relative path. Files include their extension. */
|
|
112
|
+
path: string;
|
|
113
|
+
/** Slug for files, folder path for folders. */
|
|
114
|
+
slug: string;
|
|
115
|
+
frontmatter?: Readonly<Record<string, unknown>>;
|
|
116
|
+
tags?: readonly string[];
|
|
117
|
+
links?: readonly string[];
|
|
118
|
+
embeds?: readonly string[];
|
|
119
|
+
created?: Date;
|
|
120
|
+
modified?: Date;
|
|
121
|
+
};
|
|
122
|
+
export type ResolvedIconSpec = {
|
|
123
|
+
/** Namespaced icon reference, for example `lucide:rocket` or `emoji:smile`. */
|
|
124
|
+
id: string;
|
|
125
|
+
source: IconPrecedence;
|
|
126
|
+
kind: ContentIcon["kind"];
|
|
127
|
+
/** Vault path, tag, or property the icon applies to. */
|
|
128
|
+
target: string;
|
|
129
|
+
color?: string;
|
|
130
|
+
label?: string;
|
|
131
|
+
};
|
|
132
|
+
export {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,64 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@riebeckite/plugin-icons",
|
|
3
|
-
"version": "0.0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
3
|
+
"version": "0.0.33",
|
|
4
|
+
"license": "Apache-2.0",
|
|
5
|
+
"main": "./dist/index.js",
|
|
6
|
+
"types": "./dist/index.d.ts",
|
|
7
|
+
"dependencies": {
|
|
8
|
+
"@riebeckite/core": "0.0.33",
|
|
9
|
+
"@types/mdast": "^4.0.4",
|
|
10
|
+
"lucide-static": "^1.61.0",
|
|
11
|
+
"sanitize-html": "^2.18.1"
|
|
12
|
+
},
|
|
13
|
+
"devDependencies": {
|
|
14
|
+
"@types/sanitize-html": "^2.16.2",
|
|
15
|
+
"remark-parse": "^11.0.0",
|
|
16
|
+
"unified": "^11.0.5"
|
|
17
|
+
},
|
|
18
|
+
"publishConfig": {
|
|
19
|
+
"access": "public"
|
|
20
|
+
},
|
|
21
|
+
"files": [
|
|
22
|
+
"LICENSE",
|
|
23
|
+
"README.md",
|
|
24
|
+
"README_ja.md",
|
|
25
|
+
"dist",
|
|
26
|
+
"style.css"
|
|
27
|
+
],
|
|
28
|
+
"exports": {
|
|
29
|
+
".": {
|
|
30
|
+
"types": "./dist/index.d.ts",
|
|
31
|
+
"import": "./dist/index.js",
|
|
32
|
+
"source": "./index.ts",
|
|
33
|
+
"default": "./dist/index.js"
|
|
34
|
+
},
|
|
35
|
+
"./style.css": "./style.css"
|
|
36
|
+
},
|
|
37
|
+
"repository": {
|
|
38
|
+
"type": "git",
|
|
39
|
+
"url": "https://github.com/Rerurate514/riebeckite.git",
|
|
40
|
+
"directory": "packages/plugins/icons"
|
|
41
|
+
},
|
|
42
|
+
"homepage": "https://github.com/Rerurate514/riebeckite#readme",
|
|
43
|
+
"bugs": {
|
|
44
|
+
"url": "https://github.com/Rerurate514/riebeckite/issues"
|
|
45
|
+
},
|
|
46
|
+
"description": "Obsidian Iconize and Iconic icons for Riebeckite navigation, notes, tags, and properties.",
|
|
47
|
+
"keywords": [
|
|
48
|
+
"riebeckite",
|
|
49
|
+
"plugin",
|
|
50
|
+
"icons",
|
|
51
|
+
"obsidian",
|
|
52
|
+
"lucide"
|
|
53
|
+
],
|
|
54
|
+
"engines": {
|
|
55
|
+
"node": "^20.19.0 || >=22.12.0"
|
|
56
|
+
},
|
|
57
|
+
"sideEffects": [
|
|
58
|
+
"./style.css"
|
|
59
|
+
],
|
|
60
|
+
"scripts": {
|
|
61
|
+
"build": "node ../../../scripts/build_package.mjs",
|
|
62
|
+
"test": "node --import tsx --test \"test/*.test.ts\""
|
|
63
|
+
}
|
|
6
64
|
}
|
package/style.css
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
:root {
|
|
2
|
+
--rr-icon-red: var(--rb-color-danger, #c0392b);
|
|
3
|
+
--rr-icon-orange: var(--rb-color-warning, #d68910);
|
|
4
|
+
--rr-icon-yellow: var(--rb-color-warning, #b7950b);
|
|
5
|
+
--rr-icon-green: var(--rb-color-success, #1e8449);
|
|
6
|
+
--rr-icon-cyan: var(--rb-color-info, #117a8b);
|
|
7
|
+
--rr-icon-blue: var(--rb-color-info, #1f618d);
|
|
8
|
+
--rr-icon-purple: var(--rb-color-accent, #7d3c98);
|
|
9
|
+
--rr-icon-pink: var(--rb-color-accent, #a93267);
|
|
10
|
+
--rr-icon-gray: var(--rb-color-muted, #707070);
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
.rr-icon {
|
|
14
|
+
display: inline-flex;
|
|
15
|
+
flex: none;
|
|
16
|
+
align-items: center;
|
|
17
|
+
justify-content: center;
|
|
18
|
+
width: 1em;
|
|
19
|
+
height: 1em;
|
|
20
|
+
line-height: 1;
|
|
21
|
+
vertical-align: -0.125em;
|
|
22
|
+
color: inherit;
|
|
23
|
+
overflow: visible;
|
|
24
|
+
margin-inline-end: 0.25em;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
.rr-icon > svg {
|
|
28
|
+
display: block;
|
|
29
|
+
width: 100%;
|
|
30
|
+
height: 100%;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
.rr-icon--emoji,
|
|
34
|
+
.rr-icon--text {
|
|
35
|
+
width: auto;
|
|
36
|
+
min-width: 1em;
|
|
37
|
+
font-family:
|
|
38
|
+
"Apple Color Emoji", "Segoe UI Emoji", "Noto Color Emoji", sans-serif;
|
|
39
|
+
font-size: 1em;
|
|
40
|
+
line-height: 1;
|
|
41
|
+
vertical-align: -0.1em;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
.rr-icon--text {
|
|
45
|
+
font-family: inherit;
|
|
46
|
+
}
|