@getmateo/highlight 0.0.0-stage → 0.19.8

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.
Files changed (56) hide show
  1. package/LICENSE +211 -0
  2. package/dist/astro/parser.d.ts +11 -0
  3. package/dist/astro/parser.js +129 -0
  4. package/dist/budgeted-highlighter.d.ts +12 -0
  5. package/dist/budgeted-highlighter.js +48 -0
  6. package/dist/colors.d.ts +4 -0
  7. package/dist/colors.js +45 -0
  8. package/dist/csharp/highlight.d.ts +2 -0
  9. package/dist/csharp/highlight.js +22 -0
  10. package/dist/csharp/language.d.ts +3 -0
  11. package/dist/csharp/language.js +21 -0
  12. package/dist/csharp/parser.d.ts +3 -0
  13. package/dist/csharp/parser.js +150 -0
  14. package/dist/csharp/terms.d.ts +7 -0
  15. package/dist/csharp/terms.js +12 -0
  16. package/dist/csharp/tokens.d.ts +4 -0
  17. package/dist/csharp/tokens.js +73 -0
  18. package/dist/highlighter.d.ts +6 -0
  19. package/dist/highlighter.js +125 -0
  20. package/dist/index.d.ts +9 -0
  21. package/dist/index.js +7 -0
  22. package/dist/js-scanner.d.ts +2 -0
  23. package/dist/js-scanner.js +104 -0
  24. package/dist/nix/highlight.d.ts +2 -0
  25. package/dist/nix/highlight.js +21 -0
  26. package/dist/nix/language.d.ts +3 -0
  27. package/dist/nix/language.js +32 -0
  28. package/dist/nix/parser.d.ts +3 -0
  29. package/dist/nix/parser.js +45 -0
  30. package/dist/nix/terms.d.ts +9 -0
  31. package/dist/nix/terms.js +14 -0
  32. package/dist/nix/tokens.d.ts +4 -0
  33. package/dist/nix/tokens.js +70 -0
  34. package/dist/parsers.d.ts +7 -0
  35. package/dist/parsers.js +104 -0
  36. package/dist/svelte/highlight.d.ts +2 -0
  37. package/dist/svelte/highlight.js +54 -0
  38. package/dist/svelte/nesting.d.ts +9 -0
  39. package/dist/svelte/nesting.js +97 -0
  40. package/dist/svelte/parser.d.ts +3 -0
  41. package/dist/svelte/parser.js +204 -0
  42. package/dist/svelte/terms.d.ts +24 -0
  43. package/dist/svelte/terms.js +24 -0
  44. package/dist/svelte/tokens.d.ts +16 -0
  45. package/dist/svelte/tokens.js +509 -0
  46. package/dist/syntax-roles.d.ts +10 -0
  47. package/dist/syntax-roles.js +50 -0
  48. package/dist/themes.d.ts +12 -0
  49. package/dist/themes.js +235 -0
  50. package/dist/types.d.ts +6 -0
  51. package/dist/types.js +2 -0
  52. package/dist/vue/parser.d.ts +2 -0
  53. package/dist/vue/parser.js +121 -0
  54. package/package.json +59 -4
  55. package/src/astro/LICENSE +21 -0
  56. package/README.md +0 -3
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
@@ -0,0 +1,6 @@
1
+ export type HighlightStyle = "keyword" | "comment" | "string" | "number" | "literal" | "function" | "definition" | "class" | "type" | "tag" | "attribute" | "property" | "variable" | "operator" | "punctuation" | "regexp" | "escape" | "meta" | "heading" | "link";
2
+ export interface HighlightToken {
3
+ text: string;
4
+ style: HighlightStyle | null;
5
+ }
6
+ //# sourceMappingURL=types.d.ts.map
package/dist/types.js ADDED
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1,2 @@
1
+ export declare const vueParser: import("@lezer/lr").LRParser;
2
+ //# sourceMappingURL=parser.d.ts.map
@@ -0,0 +1,121 @@
1
+ import { parseMixed, } from "@lezer/common";
2
+ import { parser as cssParser } from "@lezer/css";
3
+ import { parser as htmlParser } from "@lezer/html";
4
+ import { parser as jsParser } from "@lezer/javascript";
5
+ import { findClosingBrace } from "../js-scanner.js";
6
+ const typescriptParser = jsParser.configure({ dialect: "ts" });
7
+ const expressionParser = jsParser.configure({ top: "SingleExpression" });
8
+ function findInterpolationEnd(text, start) {
9
+ return findClosingBrace(text, start, (position) => text.charCodeAt(position + 1) === 125);
10
+ }
11
+ function findExpressions(text) {
12
+ const ranges = [];
13
+ for (let position = 0; position < text.length; position++) {
14
+ if (text.charCodeAt(position) !== 123)
15
+ continue;
16
+ if (text.charCodeAt(position + 1) !== 123)
17
+ continue;
18
+ const closing = findInterpolationEnd(text, position + 2);
19
+ if (closing < 0)
20
+ break;
21
+ // Lezer rejects empty inner ranges, so `{{}}` gets no nested parse.
22
+ if (closing > position + 2)
23
+ ranges.push({ from: position + 2, to: closing });
24
+ position = closing + 1;
25
+ }
26
+ return ranges;
27
+ }
28
+ function findDirectiveExpression(value) {
29
+ const quote = value[0];
30
+ const isQuoted = (quote === '"' || quote === "'") && value.length >= 2 && value.endsWith(quote);
31
+ const inner = isQuoted ? value.slice(1, -1) : value;
32
+ const trimmed = inner.trim();
33
+ if (!trimmed)
34
+ return null;
35
+ const from = (isQuoted ? 1 : 0) + inner.indexOf(trimmed);
36
+ return { from, to: from + trimmed.length };
37
+ }
38
+ function getOpenTagAttributes(node, input) {
39
+ const attributes = Object.create(null);
40
+ const openTag = node.getChild("OpenTag");
41
+ if (!openTag)
42
+ return attributes;
43
+ for (const attribute of openTag.getChildren("Attribute")) {
44
+ const name = attribute.getChild("AttributeName");
45
+ if (!name)
46
+ continue;
47
+ const value = attribute.getChild("AttributeValue") || attribute.getChild("UnquotedAttributeValue");
48
+ const key = input.read(name.from, name.to).toLowerCase();
49
+ attributes[key] = value ? input.read(value.from, value.to).replace(/^["']|["']$/g, "") : "";
50
+ }
51
+ return attributes;
52
+ }
53
+ function isDirectiveAttribute(attribute) {
54
+ return (attribute.startsWith("v-") ||
55
+ attribute.startsWith(":") ||
56
+ attribute.startsWith("@") ||
57
+ attribute.startsWith("."));
58
+ }
59
+ function directiveOverlay(node, parent, input) {
60
+ const attributeName = parent.getChild("AttributeName");
61
+ if (!attributeName)
62
+ return null;
63
+ if (!isDirectiveAttribute(input.read(attributeName.from, attributeName.to).toLowerCase())) {
64
+ return null;
65
+ }
66
+ const range = findDirectiveExpression(input.read(node.from, node.to));
67
+ if (!range)
68
+ return null;
69
+ return {
70
+ parser: expressionParser,
71
+ overlay: [{ from: node.from + range.from, to: node.from + range.to }],
72
+ };
73
+ }
74
+ function textOverlay(node, input) {
75
+ const overlays = findExpressions(input.read(node.from, node.to)).map(({ from, to }) => ({
76
+ from: node.from + from,
77
+ to: node.from + to,
78
+ }));
79
+ return overlays.length > 0 ? { parser: expressionParser, overlay: overlays } : null;
80
+ }
81
+ function templateOverlay(node, input) {
82
+ const parent = node.node.parent;
83
+ if (parent?.name === "Attribute")
84
+ return directiveOverlay(node, parent, input);
85
+ if (node.name !== "Text")
86
+ return null;
87
+ return textOverlay(node, input);
88
+ }
89
+ function scriptLanguage(attributes) {
90
+ if (attributes.src)
91
+ return null;
92
+ const language = (attributes.lang || attributes.type || "").toLowerCase();
93
+ if (language.includes("tsx"))
94
+ return { parser: jsParser.configure({ dialect: "ts jsx" }) };
95
+ if (language.includes("typescript") || language === "ts")
96
+ return { parser: typescriptParser };
97
+ if (language.includes("jsx"))
98
+ return { parser: jsParser.configure({ dialect: "jsx" }) };
99
+ return { parser: jsParser };
100
+ }
101
+ function scriptOverlay(node, input) {
102
+ const parent = node.node.parent;
103
+ if (!parent)
104
+ return null;
105
+ return scriptLanguage(getOpenTagAttributes(parent, input));
106
+ }
107
+ function nestedLanguage(node, input) {
108
+ const name = node.name;
109
+ if (name === "Text" || name === "UnquotedAttributeValue" || name === "AttributeValue") {
110
+ return templateOverlay(node, input);
111
+ }
112
+ if (name === "StyleText")
113
+ return { parser: cssParser };
114
+ if (name === "ScriptText")
115
+ return scriptOverlay(node, input);
116
+ return null;
117
+ }
118
+ export const vueParser = htmlParser.configure({
119
+ wrap: parseMixed(nestedLanguage),
120
+ });
121
+ //# sourceMappingURL=parser.js.map
package/package.json CHANGED
@@ -1,6 +1,61 @@
1
1
  {
2
2
  "name": "@getmateo/highlight",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "0.19.8",
4
+ "license": "Apache-2.0",
5
+ "repository": {
6
+ "type": "git",
7
+ "url": "git+https://github.com/x2x3studio/mateo.git",
8
+ "directory": "packages/highlight"
9
+ },
10
+ "files": [
11
+ "dist",
12
+ "!dist/**/*.map",
13
+ "src/astro/LICENSE"
14
+ ],
15
+ "type": "module",
16
+ "main": "./dist/index.js",
17
+ "types": "./dist/index.d.ts",
18
+ "exports": {
19
+ ".": {
20
+ "types": "./dist/index.d.ts",
21
+ "source": "./src/index.ts",
22
+ "default": "./dist/index.js"
23
+ }
24
+ },
25
+ "publishConfig": {
26
+ "access": "public"
27
+ },
28
+ "scripts": {
29
+ "clean": "node ../../scripts/clean-package-dist.mjs",
30
+ "build": "tsc -p tsconfig.json --incremental false",
31
+ "build:clean": "npm run clean && npm run build",
32
+ "prepack": "npm run build:clean",
33
+ "test": "vitest run",
34
+ "typecheck": "tsgo --noEmit"
35
+ },
36
+ "dependencies": {
37
+ "@codemirror/language": "6.13.1",
38
+ "@codemirror/legacy-modes": "6.5.5",
39
+ "@lezer/common": "^1.5.6",
40
+ "@lezer/cpp": "^1.1.5",
41
+ "@lezer/css": "^1.3.0",
42
+ "@lezer/go": "^1.0.1",
43
+ "@lezer/highlight": "^1.2.3",
44
+ "@lezer/html": "^1.3.13",
45
+ "@lezer/java": "^1.2.0",
46
+ "@lezer/javascript": "^1.5.4",
47
+ "@lezer/json": "^1.0.3",
48
+ "@lezer/lr": "^1.4.8",
49
+ "@lezer/markdown": "^1.6.2",
50
+ "@lezer/php": "^1.0.5",
51
+ "@lezer/python": "^1.1.18",
52
+ "@lezer/rust": "^1.0.2",
53
+ "@lezer/xml": "^1.0.6",
54
+ "@lezer/yaml": "^1.0.4",
55
+ "lezer-elixir": "^1.1.4"
56
+ },
57
+ "devDependencies": {
58
+ "typescript": "^5.9.2",
59
+ "vitest": "^4.1.12"
60
+ }
61
+ }
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Zulfazli (Fazelllyyy)
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/README.md DELETED
@@ -1,3 +0,0 @@
1
- # Temporary Holding Version
2
-
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.