@getpaseo/highlight 0.1.87 → 0.1.88
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.ts +2 -0
- package/dist/index.js +1 -0
- package/dist/parsers.js +4 -0
- package/dist/themes.d.ts +12 -0
- package/dist/themes.js +235 -0
- package/package.json +3 -1
package/dist/index.d.ts
CHANGED
|
@@ -2,4 +2,6 @@ export type { HighlightStyle, HighlightToken } from "./types.js";
|
|
|
2
2
|
export { getParserForFile, isLanguageSupported, getSupportedExtensions } from "./parsers.js";
|
|
3
3
|
export { highlightCode, highlightLine } from "./highlighter.js";
|
|
4
4
|
export { darkHighlightColors, lightHighlightColors } from "./colors.js";
|
|
5
|
+
export type { SyntaxThemeId, SyntaxThemeOption, SyntaxColors } from "./themes.js";
|
|
6
|
+
export { SYNTAX_THEME_IDS, SYNTAX_THEME_OPTIONS, isSyntaxThemeId, resolveSyntaxColors, } from "./themes.js";
|
|
5
7
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
export { getParserForFile, isLanguageSupported, getSupportedExtensions } from "./parsers.js";
|
|
2
2
|
export { highlightCode, highlightLine } from "./highlighter.js";
|
|
3
3
|
export { darkHighlightColors, lightHighlightColors } from "./colors.js";
|
|
4
|
+
export { SYNTAX_THEME_IDS, SYNTAX_THEME_OPTIONS, isSyntaxThemeId, resolveSyntaxColors, } from "./themes.js";
|
|
4
5
|
//# sourceMappingURL=index.js.map
|
package/dist/parsers.js
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { StreamLanguage } from "@codemirror/language";
|
|
2
|
+
import { swift } from "@codemirror/legacy-modes/mode/swift";
|
|
1
3
|
import { parser as jsParser } from "@lezer/javascript";
|
|
2
4
|
import { parser as jsonParser } from "@lezer/json";
|
|
3
5
|
import { parser as cssParser } from "@lezer/css";
|
|
@@ -53,6 +55,8 @@ const parsersByExtension = {
|
|
|
53
55
|
yml: yamlParser,
|
|
54
56
|
// Rust
|
|
55
57
|
rs: rustParser,
|
|
58
|
+
// Swift
|
|
59
|
+
swift: StreamLanguage.define(swift).parser,
|
|
56
60
|
// Elixir
|
|
57
61
|
ex: elixirParser,
|
|
58
62
|
exs: elixirParser,
|
package/dist/themes.d.ts
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { HighlightStyle } from "./types.js";
|
|
2
|
+
export type SyntaxThemeId = "github" | "catppuccin" | "dracula" | "tokyo-night" | "one" | "nord" | "gruvbox" | "solarized";
|
|
3
|
+
export declare const SYNTAX_THEME_IDS: readonly SyntaxThemeId[];
|
|
4
|
+
export interface SyntaxThemeOption {
|
|
5
|
+
id: SyntaxThemeId;
|
|
6
|
+
label: string;
|
|
7
|
+
}
|
|
8
|
+
export declare const SYNTAX_THEME_OPTIONS: readonly SyntaxThemeOption[];
|
|
9
|
+
export type SyntaxColors = Record<HighlightStyle, string>;
|
|
10
|
+
export declare function isSyntaxThemeId(value: string): value is SyntaxThemeId;
|
|
11
|
+
export declare function resolveSyntaxColors(id: SyntaxThemeId, colorScheme: "light" | "dark"): SyntaxColors;
|
|
12
|
+
//# sourceMappingURL=themes.d.ts.map
|
package/dist/themes.js
ADDED
|
@@ -0,0 +1,235 @@
|
|
|
1
|
+
import { darkHighlightColors, lightHighlightColors } from "./colors.js";
|
|
2
|
+
export const SYNTAX_THEME_IDS = [
|
|
3
|
+
"github",
|
|
4
|
+
"catppuccin",
|
|
5
|
+
"dracula",
|
|
6
|
+
"tokyo-night",
|
|
7
|
+
"one",
|
|
8
|
+
"nord",
|
|
9
|
+
"gruvbox",
|
|
10
|
+
"solarized",
|
|
11
|
+
];
|
|
12
|
+
export const SYNTAX_THEME_OPTIONS = [
|
|
13
|
+
{ id: "github", label: "GitHub" },
|
|
14
|
+
{ id: "catppuccin", label: "Catppuccin" },
|
|
15
|
+
{ id: "dracula", label: "Dracula" },
|
|
16
|
+
{ id: "tokyo-night", label: "Tokyo Night" },
|
|
17
|
+
{ id: "one", label: "One" },
|
|
18
|
+
{ id: "nord", label: "Nord" },
|
|
19
|
+
{ id: "gruvbox", label: "Gruvbox" },
|
|
20
|
+
{ id: "solarized", label: "Solarized" },
|
|
21
|
+
];
|
|
22
|
+
function expandRolePalette(r) {
|
|
23
|
+
return {
|
|
24
|
+
keyword: r.keyword,
|
|
25
|
+
comment: r.comment,
|
|
26
|
+
string: r.string,
|
|
27
|
+
number: r.number,
|
|
28
|
+
literal: r.number,
|
|
29
|
+
function: r.function,
|
|
30
|
+
definition: r.function,
|
|
31
|
+
class: r.type,
|
|
32
|
+
type: r.type,
|
|
33
|
+
tag: r.tag,
|
|
34
|
+
attribute: r.attribute,
|
|
35
|
+
property: r.attribute,
|
|
36
|
+
variable: r.base,
|
|
37
|
+
operator: r.operator,
|
|
38
|
+
punctuation: r.base,
|
|
39
|
+
regexp: r.string,
|
|
40
|
+
escape: r.number,
|
|
41
|
+
meta: r.comment,
|
|
42
|
+
heading: r.function,
|
|
43
|
+
link: r.string,
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
// --- Catppuccin (Latte light / Mocha dark) -------------------------------
|
|
47
|
+
const catppuccinLatte = {
|
|
48
|
+
base: "#4c4f69",
|
|
49
|
+
keyword: "#8839ef",
|
|
50
|
+
comment: "#8c8fa1",
|
|
51
|
+
string: "#40a02b",
|
|
52
|
+
number: "#fe640b",
|
|
53
|
+
function: "#1e66f5",
|
|
54
|
+
type: "#df8e1d",
|
|
55
|
+
tag: "#8839ef",
|
|
56
|
+
attribute: "#df8e1d",
|
|
57
|
+
operator: "#04a5e5",
|
|
58
|
+
};
|
|
59
|
+
const catppuccinMocha = {
|
|
60
|
+
base: "#cdd6f4",
|
|
61
|
+
keyword: "#cba6f7",
|
|
62
|
+
comment: "#9399b2",
|
|
63
|
+
string: "#a6e3a1",
|
|
64
|
+
number: "#fab387",
|
|
65
|
+
function: "#89b4fa",
|
|
66
|
+
type: "#f9e2af",
|
|
67
|
+
tag: "#cba6f7",
|
|
68
|
+
attribute: "#f9e2af",
|
|
69
|
+
operator: "#89dceb",
|
|
70
|
+
};
|
|
71
|
+
// --- Dracula (dark only) -------------------------------------------------
|
|
72
|
+
const dracula = {
|
|
73
|
+
base: "#f8f8f2",
|
|
74
|
+
keyword: "#ff79c6",
|
|
75
|
+
comment: "#6272a4",
|
|
76
|
+
string: "#f1fa8c",
|
|
77
|
+
number: "#bd93f9",
|
|
78
|
+
function: "#50fa7b",
|
|
79
|
+
type: "#8be9fd",
|
|
80
|
+
tag: "#ff79c6",
|
|
81
|
+
attribute: "#50fa7b",
|
|
82
|
+
operator: "#ff79c6",
|
|
83
|
+
};
|
|
84
|
+
// --- Tokyo Night (Day light / Night dark) --------------------------------
|
|
85
|
+
const tokyoDay = {
|
|
86
|
+
base: "#3760bf",
|
|
87
|
+
keyword: "#9854f1",
|
|
88
|
+
comment: "#848cb5",
|
|
89
|
+
string: "#587539",
|
|
90
|
+
number: "#b15c00",
|
|
91
|
+
function: "#2e7de9",
|
|
92
|
+
type: "#007197",
|
|
93
|
+
tag: "#f52a65",
|
|
94
|
+
attribute: "#8c6c3e",
|
|
95
|
+
operator: "#006a83",
|
|
96
|
+
};
|
|
97
|
+
const tokyoNight = {
|
|
98
|
+
base: "#c0caf5",
|
|
99
|
+
keyword: "#bb9af7",
|
|
100
|
+
comment: "#565f89",
|
|
101
|
+
string: "#9ece6a",
|
|
102
|
+
number: "#ff9e64",
|
|
103
|
+
function: "#7aa2f7",
|
|
104
|
+
type: "#2ac3de",
|
|
105
|
+
tag: "#f7768e",
|
|
106
|
+
attribute: "#e0af68",
|
|
107
|
+
operator: "#89ddff",
|
|
108
|
+
};
|
|
109
|
+
// --- One (One Light / One Dark) ------------------------------------------
|
|
110
|
+
const oneLight = {
|
|
111
|
+
base: "#383a42",
|
|
112
|
+
keyword: "#a626a4",
|
|
113
|
+
comment: "#a0a1a7",
|
|
114
|
+
string: "#50a14f",
|
|
115
|
+
number: "#986801",
|
|
116
|
+
function: "#4078f2",
|
|
117
|
+
type: "#c18401",
|
|
118
|
+
tag: "#e45649",
|
|
119
|
+
attribute: "#986801",
|
|
120
|
+
operator: "#0184bc",
|
|
121
|
+
};
|
|
122
|
+
const oneDark = {
|
|
123
|
+
base: "#abb2bf",
|
|
124
|
+
keyword: "#c678dd",
|
|
125
|
+
comment: "#5c6370",
|
|
126
|
+
string: "#98c379",
|
|
127
|
+
number: "#d19a66",
|
|
128
|
+
function: "#61afef",
|
|
129
|
+
type: "#e5c07b",
|
|
130
|
+
tag: "#e06c75",
|
|
131
|
+
attribute: "#d19a66",
|
|
132
|
+
operator: "#56b6c2",
|
|
133
|
+
};
|
|
134
|
+
// --- Nord (Snow Storm light / Polar Night dark) ---------------------------
|
|
135
|
+
const nordLight = {
|
|
136
|
+
base: "#2e3440",
|
|
137
|
+
keyword: "#5e81ac",
|
|
138
|
+
comment: "#6b7280",
|
|
139
|
+
string: "#4f6f3a",
|
|
140
|
+
number: "#8f5e91",
|
|
141
|
+
function: "#2e6f8e",
|
|
142
|
+
type: "#3b7f87",
|
|
143
|
+
tag: "#5e81ac",
|
|
144
|
+
attribute: "#8f5e91",
|
|
145
|
+
operator: "#5e81ac",
|
|
146
|
+
};
|
|
147
|
+
const nordDark = {
|
|
148
|
+
base: "#d8dee9",
|
|
149
|
+
keyword: "#81a1c1",
|
|
150
|
+
comment: "#616e88",
|
|
151
|
+
string: "#a3be8c",
|
|
152
|
+
number: "#b48ead",
|
|
153
|
+
function: "#88c0d0",
|
|
154
|
+
type: "#8fbcbb",
|
|
155
|
+
tag: "#81a1c1",
|
|
156
|
+
attribute: "#8fbcbb",
|
|
157
|
+
operator: "#81a1c1",
|
|
158
|
+
};
|
|
159
|
+
// --- Gruvbox (Light / Dark) ----------------------------------------------
|
|
160
|
+
const gruvboxLight = {
|
|
161
|
+
base: "#3c3836",
|
|
162
|
+
keyword: "#9d0006",
|
|
163
|
+
comment: "#928374",
|
|
164
|
+
string: "#79740e",
|
|
165
|
+
number: "#8f3f71",
|
|
166
|
+
function: "#427b58",
|
|
167
|
+
type: "#b57614",
|
|
168
|
+
tag: "#076678",
|
|
169
|
+
attribute: "#b57614",
|
|
170
|
+
operator: "#af3a03",
|
|
171
|
+
};
|
|
172
|
+
const gruvboxDark = {
|
|
173
|
+
base: "#ebdbb2",
|
|
174
|
+
keyword: "#fb4934",
|
|
175
|
+
comment: "#928374",
|
|
176
|
+
string: "#b8bb26",
|
|
177
|
+
number: "#d3869b",
|
|
178
|
+
function: "#8ec07c",
|
|
179
|
+
type: "#fabd2f",
|
|
180
|
+
tag: "#83a598",
|
|
181
|
+
attribute: "#fabd2f",
|
|
182
|
+
operator: "#fe8019",
|
|
183
|
+
};
|
|
184
|
+
// --- Solarized (Light / Dark — shared accents, different base/comment) ----
|
|
185
|
+
const solarizedLight = {
|
|
186
|
+
base: "#657b83",
|
|
187
|
+
keyword: "#859900",
|
|
188
|
+
comment: "#93a1a1",
|
|
189
|
+
string: "#2aa198",
|
|
190
|
+
number: "#d33682",
|
|
191
|
+
function: "#268bd2",
|
|
192
|
+
type: "#b58900",
|
|
193
|
+
tag: "#268bd2",
|
|
194
|
+
attribute: "#b58900",
|
|
195
|
+
operator: "#859900",
|
|
196
|
+
};
|
|
197
|
+
const solarizedDark = {
|
|
198
|
+
base: "#839496",
|
|
199
|
+
keyword: "#859900",
|
|
200
|
+
comment: "#586e75",
|
|
201
|
+
string: "#2aa198",
|
|
202
|
+
number: "#d33682",
|
|
203
|
+
function: "#268bd2",
|
|
204
|
+
type: "#b58900",
|
|
205
|
+
tag: "#268bd2",
|
|
206
|
+
attribute: "#b58900",
|
|
207
|
+
operator: "#859900",
|
|
208
|
+
};
|
|
209
|
+
export function isSyntaxThemeId(value) {
|
|
210
|
+
return SYNTAX_THEME_IDS.includes(value);
|
|
211
|
+
}
|
|
212
|
+
// Resolve a theme id + the app's color scheme to a full token palette. Only the
|
|
213
|
+
// light/dark axis is coupled to the app; the theme brand is the user's choice.
|
|
214
|
+
export function resolveSyntaxColors(id, colorScheme) {
|
|
215
|
+
const dark = colorScheme === "dark";
|
|
216
|
+
switch (id) {
|
|
217
|
+
case "github":
|
|
218
|
+
return dark ? darkHighlightColors : lightHighlightColors;
|
|
219
|
+
case "catppuccin":
|
|
220
|
+
return expandRolePalette(dark ? catppuccinMocha : catppuccinLatte);
|
|
221
|
+
case "dracula":
|
|
222
|
+
return expandRolePalette(dracula);
|
|
223
|
+
case "tokyo-night":
|
|
224
|
+
return expandRolePalette(dark ? tokyoNight : tokyoDay);
|
|
225
|
+
case "one":
|
|
226
|
+
return expandRolePalette(dark ? oneDark : oneLight);
|
|
227
|
+
case "nord":
|
|
228
|
+
return expandRolePalette(dark ? nordDark : nordLight);
|
|
229
|
+
case "gruvbox":
|
|
230
|
+
return expandRolePalette(dark ? gruvboxDark : gruvboxLight);
|
|
231
|
+
case "solarized":
|
|
232
|
+
return expandRolePalette(dark ? solarizedDark : solarizedLight);
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
//# sourceMappingURL=themes.js.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@getpaseo/highlight",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.88",
|
|
4
4
|
"files": [
|
|
5
5
|
"dist",
|
|
6
6
|
"!dist/**/*.map"
|
|
@@ -25,6 +25,8 @@
|
|
|
25
25
|
"typecheck": "tsgo --noEmit"
|
|
26
26
|
},
|
|
27
27
|
"dependencies": {
|
|
28
|
+
"@codemirror/language": "^6.12.3",
|
|
29
|
+
"@codemirror/legacy-modes": "^6.5.3",
|
|
28
30
|
"@lezer/common": "^1.5.0",
|
|
29
31
|
"@lezer/cpp": "^1.1.5",
|
|
30
32
|
"@lezer/css": "^1.3.0",
|