@virgo-nsh/highlighter 0.0.0-stage → 0.1.0
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 +21 -0
- package/README.md +70 -2
- package/dist/catalog/index.d.ts +1 -0
- package/dist/catalog/index.js +2 -0
- package/dist/highlighter.d.ts +32 -0
- package/dist/highlighter.js +134 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/internal/browser/ONNX-RUNTIME-LICENSE.txt +21 -0
- package/dist/internal/browser/assets.d.ts +52 -0
- package/dist/internal/browser/assets.js +181 -0
- package/dist/internal/browser/decode.d.ts +16 -0
- package/dist/internal/browser/decode.js +75 -0
- package/dist/internal/browser/engine.d.ts +4 -0
- package/dist/internal/browser/engine.js +107 -0
- package/dist/internal/browser/index.d.ts +13 -0
- package/dist/internal/browser/index.js +135 -0
- package/dist/internal/browser/ort-wasm-simd-threaded.mjs +60 -0
- package/dist/internal/browser/ort-wasm-simd-threaded.wasm +0 -0
- package/dist/internal/browser/sessions.d.ts +9 -0
- package/dist/internal/browser/sessions.js +57 -0
- package/dist/internal/browser/structured.d.ts +9 -0
- package/dist/internal/browser/structured.js +88 -0
- package/dist/internal/browser/types.d.ts +37 -0
- package/dist/internal/browser/types.js +1 -0
- package/dist/internal/browser/windowing.d.ts +7 -0
- package/dist/internal/browser/windowing.js +81 -0
- package/dist/internal/browser/worker.d.ts +1 -0
- package/dist/internal/browser/worker.js +22 -0
- package/dist/internal/core/catalog/code.d.ts +2 -0
- package/dist/internal/core/catalog/code.js +371 -0
- package/dist/internal/core/catalog/formats.d.ts +2 -0
- package/dist/internal/core/catalog/formats.js +144 -0
- package/dist/internal/core/catalog/index.d.ts +15 -0
- package/dist/internal/core/catalog/index.js +64 -0
- package/dist/internal/core/catalog/types.d.ts +20 -0
- package/dist/internal/core/catalog/types.js +1 -0
- package/dist/internal/core/composition/html.d.ts +11 -0
- package/dist/internal/core/composition/html.js +61 -0
- package/dist/internal/core/composition/markdown.d.ts +10 -0
- package/dist/internal/core/composition/markdown.js +66 -0
- package/dist/internal/core/composition/php.d.ts +9 -0
- package/dist/internal/core/composition/php.js +54 -0
- package/dist/internal/core/composition/svelte.d.ts +9 -0
- package/dist/internal/core/composition/svelte.js +67 -0
- package/dist/internal/core/composition/vue.d.ts +9 -0
- package/dist/internal/core/composition/vue.js +69 -0
- package/dist/internal/core/highlighter.d.ts +11 -0
- package/dist/internal/core/highlighter.js +26 -0
- package/dist/internal/core/index.d.ts +7 -0
- package/dist/internal/core/index.js +3 -0
- package/dist/internal/core/language.d.ts +2 -0
- package/dist/internal/core/language.js +2 -0
- package/dist/internal/core/manifest.d.ts +8 -0
- package/dist/internal/core/manifest.js +1 -0
- package/dist/internal/core/pack.d.ts +23 -0
- package/dist/internal/core/pack.js +1 -0
- package/dist/internal/core/registry.d.ts +6 -0
- package/dist/internal/core/registry.js +14 -0
- package/dist/internal/core/result.d.ts +30 -0
- package/dist/internal/core/result.js +1 -0
- package/dist/internal/core/schema.d.ts +10 -0
- package/dist/internal/core/schema.js +1 -0
- package/dist/internal/html/index.d.ts +1 -0
- package/dist/internal/html/index.js +1 -0
- package/dist/internal/html/render.d.ts +8 -0
- package/dist/internal/html/render.js +71 -0
- package/dist/model-assets.d.ts +14 -0
- package/dist/model-assets.js +895 -0
- package/dist/remote.d.ts +24 -0
- package/dist/remote.js +129 -0
- package/dist/theme.css +1344 -0
- package/dist/themes/all.css +2150 -0
- package/dist/themes/base.css +942 -0
- package/dist/themes/contrast.css +1344 -0
- package/dist/themes/default.css +1344 -0
- package/dist/themes/index.d.ts +2 -0
- package/dist/themes/index.js +17 -0
- package/dist/themes/languages/typescript.css +2 -0
- package/dist/themes/muted.css +1344 -0
- package/package.json +42 -4
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import { argmax } from "./decode.js";
|
|
2
|
+
export function validateWindowing(policy, context) {
|
|
3
|
+
if (context !== 512 ||
|
|
4
|
+
policy.format !== "nsh-overlap-logits-v1" ||
|
|
5
|
+
![128, 256].includes(policy.strideBytes) ||
|
|
6
|
+
policy.edgeWeightCap !== 128 ||
|
|
7
|
+
![0, 0.5].includes(policy.adaptiveWeight))
|
|
8
|
+
throw new Error("Invalid neural window-fusion policy");
|
|
9
|
+
}
|
|
10
|
+
/** Fuse neural logits at original byte/character positions; no source grammar. */
|
|
11
|
+
export async function windowLogits(model, raw, starts, run) {
|
|
12
|
+
const policy = model.inferenceWindowing;
|
|
13
|
+
validateWindowing(policy, model.contextBytes);
|
|
14
|
+
const widths = [3, model.schema.tokenTypes.length, model.schema.modifiers.length];
|
|
15
|
+
const count = starts.length - 1;
|
|
16
|
+
const values = widths.map((width) => new Float64Array(count * width));
|
|
17
|
+
const counts = new Float64Array(count);
|
|
18
|
+
let begin = 0;
|
|
19
|
+
while (begin < count) {
|
|
20
|
+
let end = begin + 1;
|
|
21
|
+
while (end + 1 < starts.length && starts[end + 1] <= starts[begin] + model.contextBytes)
|
|
22
|
+
end++;
|
|
23
|
+
const output = await run(raw.subarray(starts[begin], starts[end]));
|
|
24
|
+
for (let i = begin; i < end; i++) {
|
|
25
|
+
const offset = starts[i] - starts[begin];
|
|
26
|
+
const weight = Math.min(offset + 1, starts[end] - starts[i], policy.edgeWeightCap);
|
|
27
|
+
counts[i] += weight;
|
|
28
|
+
for (let head = 0; head < widths.length; head++)
|
|
29
|
+
for (let column = 0; column < widths[head]; column++)
|
|
30
|
+
values[head][i * widths[head] + column] +=
|
|
31
|
+
output[head][offset * widths[head] + column] * weight;
|
|
32
|
+
}
|
|
33
|
+
if (end === count)
|
|
34
|
+
break;
|
|
35
|
+
const limit = starts[begin] + policy.strideBytes;
|
|
36
|
+
let next = begin;
|
|
37
|
+
while (next + 1 < starts.length && starts[next + 1] <= limit)
|
|
38
|
+
next++;
|
|
39
|
+
if (next <= begin)
|
|
40
|
+
throw new Error("Overlapping inference cursor made no progress");
|
|
41
|
+
begin = next;
|
|
42
|
+
}
|
|
43
|
+
for (let i = 0; i < count; i++)
|
|
44
|
+
for (let head = 0; head < widths.length; head++)
|
|
45
|
+
for (let column = 0; column < widths[head]; column++)
|
|
46
|
+
values[head][i * widths[head] + column] =
|
|
47
|
+
(values[head][i * widths[head] + column] / counts[i]) * (1 - policy.adaptiveWeight);
|
|
48
|
+
if (policy.adaptiveWeight) {
|
|
49
|
+
begin = 0;
|
|
50
|
+
while (begin < count) {
|
|
51
|
+
let end = begin + 1;
|
|
52
|
+
while (end + 1 < starts.length && starts[end + 1] <= starts[begin] + model.contextBytes)
|
|
53
|
+
end++;
|
|
54
|
+
const output = await run(raw.subarray(starts[begin], starts[end]));
|
|
55
|
+
let commit = end === count ? end : end - 1;
|
|
56
|
+
if (end < count && argmax(output[0], (starts[commit] - starts[begin]) * 3, 3) === 2) {
|
|
57
|
+
for (let i = commit - 1; i >= begin; i--) {
|
|
58
|
+
const label = argmax(output[0], (starts[i] - starts[begin]) * 3, 3);
|
|
59
|
+
if (label === 1) {
|
|
60
|
+
if (i > begin)
|
|
61
|
+
commit = i;
|
|
62
|
+
break;
|
|
63
|
+
}
|
|
64
|
+
if (label !== 2)
|
|
65
|
+
break;
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
if (commit <= begin)
|
|
69
|
+
throw new Error("Browser inference cursor made no progress");
|
|
70
|
+
for (let i = begin; i < commit; i++) {
|
|
71
|
+
const offset = starts[i] - starts[begin];
|
|
72
|
+
for (let head = 0; head < widths.length; head++)
|
|
73
|
+
for (let column = 0; column < widths[head]; column++)
|
|
74
|
+
values[head][i * widths[head] + column] +=
|
|
75
|
+
output[head][offset * widths[head] + column] * policy.adaptiveWeight;
|
|
76
|
+
}
|
|
77
|
+
begin = commit;
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
return values;
|
|
81
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { ModelAssetError } from "./assets.js";
|
|
2
|
+
import { highlight } from "./engine.js";
|
|
3
|
+
const scope = self;
|
|
4
|
+
let queue = Promise.resolve();
|
|
5
|
+
scope.addEventListener("message", (event) => {
|
|
6
|
+
const { id, model, source, runtime } = event.data;
|
|
7
|
+
queue = queue.then(async () => {
|
|
8
|
+
try {
|
|
9
|
+
scope.postMessage({ id, result: await highlight(model, source, runtime) });
|
|
10
|
+
}
|
|
11
|
+
catch (error) {
|
|
12
|
+
scope.postMessage({
|
|
13
|
+
id,
|
|
14
|
+
error: error instanceof ModelAssetError
|
|
15
|
+
? error.toJSON()
|
|
16
|
+
: error instanceof Error
|
|
17
|
+
? error.message
|
|
18
|
+
: String(error),
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
});
|
|
22
|
+
});
|
|
@@ -0,0 +1,371 @@
|
|
|
1
|
+
export const codeTypes = [
|
|
2
|
+
{
|
|
3
|
+
id: "typescript",
|
|
4
|
+
label: "TypeScript",
|
|
5
|
+
category: "code",
|
|
6
|
+
aliases: ["ts"],
|
|
7
|
+
modelId: "typescript",
|
|
8
|
+
extensions: [".ts", ".mts", ".cts", ".d.ts", ".d.mts", ".d.cts"],
|
|
9
|
+
fileVariants: [
|
|
10
|
+
{
|
|
11
|
+
id: "typescript-esm",
|
|
12
|
+
extensions: [".mts"],
|
|
13
|
+
},
|
|
14
|
+
{
|
|
15
|
+
id: "typescript-commonjs",
|
|
16
|
+
extensions: [".cts"],
|
|
17
|
+
},
|
|
18
|
+
{
|
|
19
|
+
id: "typescript-declaration",
|
|
20
|
+
extensions: [".d.ts"],
|
|
21
|
+
},
|
|
22
|
+
{
|
|
23
|
+
id: "typescript-esm-declaration",
|
|
24
|
+
extensions: [".d.mts"],
|
|
25
|
+
},
|
|
26
|
+
{
|
|
27
|
+
id: "typescript-commonjs-declaration",
|
|
28
|
+
extensions: [".d.cts"],
|
|
29
|
+
},
|
|
30
|
+
],
|
|
31
|
+
frameworks: ["React"],
|
|
32
|
+
iconId: "typescript",
|
|
33
|
+
},
|
|
34
|
+
{
|
|
35
|
+
id: "tsx",
|
|
36
|
+
label: "TSX",
|
|
37
|
+
category: "code",
|
|
38
|
+
aliases: [],
|
|
39
|
+
modelId: "typescript",
|
|
40
|
+
extensions: [".tsx"],
|
|
41
|
+
frameworks: ["React"],
|
|
42
|
+
iconId: "typescript",
|
|
43
|
+
},
|
|
44
|
+
{
|
|
45
|
+
id: "javascript",
|
|
46
|
+
label: "JavaScript",
|
|
47
|
+
category: "code",
|
|
48
|
+
aliases: ["js"],
|
|
49
|
+
modelId: "typescript",
|
|
50
|
+
extensions: [".js", ".mjs", ".cjs"],
|
|
51
|
+
fileVariants: [
|
|
52
|
+
{
|
|
53
|
+
id: "javascript-esm",
|
|
54
|
+
extensions: [".mjs"],
|
|
55
|
+
},
|
|
56
|
+
{
|
|
57
|
+
id: "javascript-commonjs",
|
|
58
|
+
extensions: [".cjs"],
|
|
59
|
+
},
|
|
60
|
+
],
|
|
61
|
+
frameworks: ["React"],
|
|
62
|
+
iconId: "javascript",
|
|
63
|
+
},
|
|
64
|
+
{
|
|
65
|
+
id: "jsx",
|
|
66
|
+
label: "JSX",
|
|
67
|
+
category: "code",
|
|
68
|
+
aliases: [],
|
|
69
|
+
modelId: "typescript",
|
|
70
|
+
extensions: [".jsx"],
|
|
71
|
+
frameworks: ["React"],
|
|
72
|
+
iconId: "javascript",
|
|
73
|
+
},
|
|
74
|
+
{
|
|
75
|
+
id: "go",
|
|
76
|
+
label: "Go",
|
|
77
|
+
category: "code",
|
|
78
|
+
aliases: [],
|
|
79
|
+
modelId: "go",
|
|
80
|
+
extensions: [".go"],
|
|
81
|
+
iconId: "go",
|
|
82
|
+
},
|
|
83
|
+
{
|
|
84
|
+
id: "css",
|
|
85
|
+
label: "CSS",
|
|
86
|
+
category: "code",
|
|
87
|
+
aliases: [],
|
|
88
|
+
modelId: "css",
|
|
89
|
+
extensions: [".css"],
|
|
90
|
+
iconId: "css",
|
|
91
|
+
},
|
|
92
|
+
{
|
|
93
|
+
id: "scss",
|
|
94
|
+
label: "SCSS",
|
|
95
|
+
category: "code",
|
|
96
|
+
aliases: [],
|
|
97
|
+
modelId: "css",
|
|
98
|
+
extensions: [".scss"],
|
|
99
|
+
iconId: "scss",
|
|
100
|
+
},
|
|
101
|
+
{
|
|
102
|
+
id: "less",
|
|
103
|
+
label: "Less",
|
|
104
|
+
category: "code",
|
|
105
|
+
aliases: [],
|
|
106
|
+
modelId: "css",
|
|
107
|
+
extensions: [".less"],
|
|
108
|
+
iconId: "less",
|
|
109
|
+
},
|
|
110
|
+
{
|
|
111
|
+
id: "html",
|
|
112
|
+
label: "HTML",
|
|
113
|
+
category: "code",
|
|
114
|
+
aliases: [],
|
|
115
|
+
modelId: "html",
|
|
116
|
+
extensions: [".html", ".htm"],
|
|
117
|
+
modelDependencies: ["typescript", "css"],
|
|
118
|
+
iconId: "html",
|
|
119
|
+
},
|
|
120
|
+
{
|
|
121
|
+
id: "vue",
|
|
122
|
+
label: "Vue",
|
|
123
|
+
category: "code",
|
|
124
|
+
aliases: [],
|
|
125
|
+
modelId: "vue",
|
|
126
|
+
extensions: [".vue"],
|
|
127
|
+
modelDependencies: ["typescript", "css"],
|
|
128
|
+
iconId: "vue",
|
|
129
|
+
},
|
|
130
|
+
{
|
|
131
|
+
id: "python",
|
|
132
|
+
label: "Python",
|
|
133
|
+
category: "code",
|
|
134
|
+
aliases: ["py"],
|
|
135
|
+
modelId: "python",
|
|
136
|
+
extensions: [".py", ".pyw", ".pyi"],
|
|
137
|
+
iconId: "python",
|
|
138
|
+
},
|
|
139
|
+
{
|
|
140
|
+
id: "bash",
|
|
141
|
+
label: "Shell",
|
|
142
|
+
category: "code",
|
|
143
|
+
aliases: ["sh", "shell", "zsh", "csh", "tcsh"],
|
|
144
|
+
modelId: "bash",
|
|
145
|
+
extensions: [".sh", ".bash", ".zsh", ".csh", ".tcsh"],
|
|
146
|
+
iconId: "bash",
|
|
147
|
+
},
|
|
148
|
+
{
|
|
149
|
+
id: "perl",
|
|
150
|
+
label: "Perl",
|
|
151
|
+
category: "code",
|
|
152
|
+
aliases: [],
|
|
153
|
+
modelId: "perl",
|
|
154
|
+
extensions: [".pl", ".pm", ".t", ".perl"],
|
|
155
|
+
iconId: "perl",
|
|
156
|
+
},
|
|
157
|
+
{
|
|
158
|
+
id: "awk",
|
|
159
|
+
label: "AWK",
|
|
160
|
+
category: "code",
|
|
161
|
+
aliases: [],
|
|
162
|
+
modelId: "awk",
|
|
163
|
+
extensions: [".awk", ".gawk"],
|
|
164
|
+
iconId: "awk",
|
|
165
|
+
},
|
|
166
|
+
{
|
|
167
|
+
id: "sql",
|
|
168
|
+
label: "SQL",
|
|
169
|
+
category: "code",
|
|
170
|
+
aliases: [],
|
|
171
|
+
modelId: "sql",
|
|
172
|
+
extensions: [".sql", ".psql", ".pgsql", ".plsql"],
|
|
173
|
+
iconId: "sql",
|
|
174
|
+
},
|
|
175
|
+
{
|
|
176
|
+
id: "powershell",
|
|
177
|
+
label: "PowerShell",
|
|
178
|
+
category: "code",
|
|
179
|
+
aliases: ["pwsh", "ps1"],
|
|
180
|
+
modelId: "powershell",
|
|
181
|
+
extensions: [".ps1", ".psm1", ".psd1"],
|
|
182
|
+
iconId: "powershell",
|
|
183
|
+
},
|
|
184
|
+
{
|
|
185
|
+
id: "bat",
|
|
186
|
+
label: "BAT / CMD",
|
|
187
|
+
category: "code",
|
|
188
|
+
aliases: ["cmd"],
|
|
189
|
+
modelId: "bat",
|
|
190
|
+
extensions: [".bat", ".cmd"],
|
|
191
|
+
iconId: "bat",
|
|
192
|
+
},
|
|
193
|
+
{
|
|
194
|
+
id: "assembly",
|
|
195
|
+
label: "Assembly",
|
|
196
|
+
category: "code",
|
|
197
|
+
aliases: ["asm", "nasm", "masm", "gas"],
|
|
198
|
+
modelId: "assembly",
|
|
199
|
+
extensions: [".asm", ".ASM", ".nasm", ".masm", ".s", ".S", ".inc"],
|
|
200
|
+
iconId: "assembly",
|
|
201
|
+
},
|
|
202
|
+
{
|
|
203
|
+
id: "java",
|
|
204
|
+
label: "Java",
|
|
205
|
+
category: "code",
|
|
206
|
+
aliases: [],
|
|
207
|
+
modelId: "java",
|
|
208
|
+
extensions: [".java"],
|
|
209
|
+
iconId: "java",
|
|
210
|
+
},
|
|
211
|
+
{
|
|
212
|
+
id: "csharp",
|
|
213
|
+
label: "C#",
|
|
214
|
+
category: "code",
|
|
215
|
+
aliases: ["cs", "c#"],
|
|
216
|
+
modelId: "csharp",
|
|
217
|
+
extensions: [".cs"],
|
|
218
|
+
iconId: "csharp",
|
|
219
|
+
},
|
|
220
|
+
{
|
|
221
|
+
id: "c",
|
|
222
|
+
label: "C",
|
|
223
|
+
category: "code",
|
|
224
|
+
aliases: [],
|
|
225
|
+
modelId: "c",
|
|
226
|
+
extensions: [".c", ".h"],
|
|
227
|
+
iconId: "c",
|
|
228
|
+
},
|
|
229
|
+
{
|
|
230
|
+
id: "cpp",
|
|
231
|
+
label: "C++",
|
|
232
|
+
category: "code",
|
|
233
|
+
aliases: ["c++", "cxx"],
|
|
234
|
+
modelId: "cpp",
|
|
235
|
+
extensions: [
|
|
236
|
+
".cpp",
|
|
237
|
+
".cc",
|
|
238
|
+
".cxx",
|
|
239
|
+
".c++",
|
|
240
|
+
".C",
|
|
241
|
+
".hpp",
|
|
242
|
+
".hh",
|
|
243
|
+
".hxx",
|
|
244
|
+
".h++",
|
|
245
|
+
".ipp",
|
|
246
|
+
".tpp",
|
|
247
|
+
],
|
|
248
|
+
iconId: "cpp",
|
|
249
|
+
},
|
|
250
|
+
{
|
|
251
|
+
id: "php",
|
|
252
|
+
label: "PHP",
|
|
253
|
+
category: "code",
|
|
254
|
+
aliases: [],
|
|
255
|
+
modelId: "php",
|
|
256
|
+
extensions: [".php", ".phtml"],
|
|
257
|
+
modelDependencies: ["html"],
|
|
258
|
+
iconId: "php",
|
|
259
|
+
},
|
|
260
|
+
{
|
|
261
|
+
id: "svelte",
|
|
262
|
+
label: "Svelte",
|
|
263
|
+
category: "code",
|
|
264
|
+
aliases: [],
|
|
265
|
+
modelId: "svelte",
|
|
266
|
+
extensions: [".svelte"],
|
|
267
|
+
modelDependencies: ["typescript", "css"],
|
|
268
|
+
iconId: "svelte",
|
|
269
|
+
},
|
|
270
|
+
{
|
|
271
|
+
id: "rust",
|
|
272
|
+
label: "Rust",
|
|
273
|
+
category: "code",
|
|
274
|
+
aliases: ["rs"],
|
|
275
|
+
modelId: "rust",
|
|
276
|
+
extensions: [".rs"],
|
|
277
|
+
iconId: "rust",
|
|
278
|
+
},
|
|
279
|
+
{
|
|
280
|
+
id: "zig",
|
|
281
|
+
label: "Zig",
|
|
282
|
+
category: "code",
|
|
283
|
+
aliases: [],
|
|
284
|
+
modelId: "zig",
|
|
285
|
+
extensions: [".zig"],
|
|
286
|
+
iconId: "zig",
|
|
287
|
+
},
|
|
288
|
+
{
|
|
289
|
+
id: "dart",
|
|
290
|
+
label: "Dart",
|
|
291
|
+
category: "code",
|
|
292
|
+
aliases: [],
|
|
293
|
+
modelId: "dart",
|
|
294
|
+
extensions: [".dart"],
|
|
295
|
+
iconId: "dart",
|
|
296
|
+
},
|
|
297
|
+
{
|
|
298
|
+
id: "flutter",
|
|
299
|
+
label: "Flutter",
|
|
300
|
+
category: "code",
|
|
301
|
+
aliases: [],
|
|
302
|
+
modelId: "dart",
|
|
303
|
+
extensions: [],
|
|
304
|
+
documentKind: "dart",
|
|
305
|
+
iconId: "flutter",
|
|
306
|
+
},
|
|
307
|
+
{
|
|
308
|
+
id: "swift",
|
|
309
|
+
label: "Swift",
|
|
310
|
+
category: "code",
|
|
311
|
+
aliases: [],
|
|
312
|
+
modelId: "swift",
|
|
313
|
+
extensions: [".swift"],
|
|
314
|
+
frameworks: ["SwiftUI"],
|
|
315
|
+
iconId: "swift",
|
|
316
|
+
},
|
|
317
|
+
{
|
|
318
|
+
id: "kotlin",
|
|
319
|
+
label: "Kotlin",
|
|
320
|
+
category: "code",
|
|
321
|
+
aliases: ["kt", "kts", "kotlin-script"],
|
|
322
|
+
modelId: "kotlin",
|
|
323
|
+
extensions: [".kt", ".kts"],
|
|
324
|
+
iconId: "kotlin",
|
|
325
|
+
},
|
|
326
|
+
{
|
|
327
|
+
id: "r",
|
|
328
|
+
label: "R",
|
|
329
|
+
category: "code",
|
|
330
|
+
aliases: [],
|
|
331
|
+
modelId: "r",
|
|
332
|
+
extensions: [".R", ".r", ".Rprofile"],
|
|
333
|
+
iconId: "r",
|
|
334
|
+
},
|
|
335
|
+
{
|
|
336
|
+
id: "scala",
|
|
337
|
+
label: "Scala",
|
|
338
|
+
category: "code",
|
|
339
|
+
aliases: [],
|
|
340
|
+
modelId: "scala",
|
|
341
|
+
extensions: [".scala", ".sc", ".sbt"],
|
|
342
|
+
iconId: "scala",
|
|
343
|
+
},
|
|
344
|
+
{
|
|
345
|
+
id: "ruby",
|
|
346
|
+
label: "Ruby",
|
|
347
|
+
category: "code",
|
|
348
|
+
aliases: ["rb", "rake", "gemspec", "gemfile", "rakefile"],
|
|
349
|
+
modelId: "ruby",
|
|
350
|
+
extensions: [".rb", ".rake", ".gemspec", "Gemfile", "Rakefile"],
|
|
351
|
+
iconId: "ruby",
|
|
352
|
+
},
|
|
353
|
+
{
|
|
354
|
+
id: "lua",
|
|
355
|
+
label: "Lua",
|
|
356
|
+
category: "code",
|
|
357
|
+
aliases: [],
|
|
358
|
+
modelId: "lua",
|
|
359
|
+
extensions: [".lua"],
|
|
360
|
+
iconId: "lua",
|
|
361
|
+
},
|
|
362
|
+
{
|
|
363
|
+
id: "graphql",
|
|
364
|
+
label: "GraphQL",
|
|
365
|
+
category: "code",
|
|
366
|
+
aliases: ["gql"],
|
|
367
|
+
modelId: "graphql",
|
|
368
|
+
extensions: [".graphql", ".gql"],
|
|
369
|
+
iconId: "graphql",
|
|
370
|
+
},
|
|
371
|
+
];
|
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
export const fileFormats = [
|
|
2
|
+
{
|
|
3
|
+
id: "json",
|
|
4
|
+
label: "JSON",
|
|
5
|
+
category: "formats",
|
|
6
|
+
aliases: [],
|
|
7
|
+
modelId: "json",
|
|
8
|
+
extensions: [".json"],
|
|
9
|
+
iconId: "json",
|
|
10
|
+
},
|
|
11
|
+
{
|
|
12
|
+
id: "jsonc",
|
|
13
|
+
label: "JSONC",
|
|
14
|
+
category: "formats",
|
|
15
|
+
aliases: [],
|
|
16
|
+
modelId: "json",
|
|
17
|
+
extensions: [".jsonc", ".code-workspace"],
|
|
18
|
+
iconId: "json",
|
|
19
|
+
},
|
|
20
|
+
{
|
|
21
|
+
id: "yaml",
|
|
22
|
+
label: "YAML",
|
|
23
|
+
category: "formats",
|
|
24
|
+
aliases: ["yml"],
|
|
25
|
+
modelId: "yaml",
|
|
26
|
+
extensions: [".yaml", ".yml"],
|
|
27
|
+
iconId: "yaml",
|
|
28
|
+
},
|
|
29
|
+
{
|
|
30
|
+
id: "toml",
|
|
31
|
+
label: "TOML",
|
|
32
|
+
category: "formats",
|
|
33
|
+
aliases: [],
|
|
34
|
+
modelId: "toml",
|
|
35
|
+
extensions: [".toml"],
|
|
36
|
+
iconId: "toml",
|
|
37
|
+
},
|
|
38
|
+
{
|
|
39
|
+
id: "ini",
|
|
40
|
+
label: "INI",
|
|
41
|
+
category: "formats",
|
|
42
|
+
aliases: ["cfg", "editorconfig"],
|
|
43
|
+
modelId: "ini",
|
|
44
|
+
extensions: [".ini", ".INI", ".cfg", ".CFG", ".editorconfig"],
|
|
45
|
+
iconId: "ini",
|
|
46
|
+
},
|
|
47
|
+
{
|
|
48
|
+
id: "dotenv",
|
|
49
|
+
label: ".env",
|
|
50
|
+
category: "formats",
|
|
51
|
+
aliases: ["env", ".env"],
|
|
52
|
+
modelId: "dotenv",
|
|
53
|
+
extensions: [
|
|
54
|
+
".env",
|
|
55
|
+
".dotenv",
|
|
56
|
+
".env.example",
|
|
57
|
+
".env.sample",
|
|
58
|
+
".env.template",
|
|
59
|
+
".env.local",
|
|
60
|
+
".env.development",
|
|
61
|
+
".env.production",
|
|
62
|
+
".env.test",
|
|
63
|
+
".env.staging",
|
|
64
|
+
".env.development.local",
|
|
65
|
+
".env.production.local",
|
|
66
|
+
],
|
|
67
|
+
iconId: "dotenv",
|
|
68
|
+
},
|
|
69
|
+
{
|
|
70
|
+
id: "xml",
|
|
71
|
+
label: "XML",
|
|
72
|
+
category: "formats",
|
|
73
|
+
aliases: [],
|
|
74
|
+
modelId: "xml",
|
|
75
|
+
extensions: [
|
|
76
|
+
".xml",
|
|
77
|
+
".xsd",
|
|
78
|
+
".xsl",
|
|
79
|
+
".xslt",
|
|
80
|
+
".wsdl",
|
|
81
|
+
".rss",
|
|
82
|
+
".atom",
|
|
83
|
+
".plist",
|
|
84
|
+
".csproj",
|
|
85
|
+
".props",
|
|
86
|
+
".targets",
|
|
87
|
+
],
|
|
88
|
+
iconId: "xml",
|
|
89
|
+
},
|
|
90
|
+
{
|
|
91
|
+
id: "svg",
|
|
92
|
+
label: "SVG",
|
|
93
|
+
category: "formats",
|
|
94
|
+
aliases: [],
|
|
95
|
+
modelId: "xml",
|
|
96
|
+
extensions: [".svg"],
|
|
97
|
+
iconId: "svg",
|
|
98
|
+
},
|
|
99
|
+
{
|
|
100
|
+
id: "markdown",
|
|
101
|
+
label: "Markdown",
|
|
102
|
+
category: "formats",
|
|
103
|
+
aliases: ["md", "mdown", "mkd"],
|
|
104
|
+
modelId: "markdown",
|
|
105
|
+
extensions: [".md", ".markdown", ".mdown", ".mkd"],
|
|
106
|
+
iconId: "markdown",
|
|
107
|
+
},
|
|
108
|
+
{
|
|
109
|
+
id: "dockerfile",
|
|
110
|
+
label: "Dockerfile",
|
|
111
|
+
category: "formats",
|
|
112
|
+
aliases: ["docker", "containerfile"],
|
|
113
|
+
modelId: "dockerfile",
|
|
114
|
+
extensions: ["Dockerfile", ".dockerfile", "Containerfile", ".containerfile"],
|
|
115
|
+
iconId: "docker",
|
|
116
|
+
},
|
|
117
|
+
{
|
|
118
|
+
id: "makefile",
|
|
119
|
+
label: "Makefile",
|
|
120
|
+
category: "formats",
|
|
121
|
+
aliases: ["make", "mk", "mak", "gnumake", "gnumakefile"],
|
|
122
|
+
modelId: "makefile",
|
|
123
|
+
extensions: ["Makefile", "makefile", "GNUmakefile", ".mk", ".mak"],
|
|
124
|
+
iconId: "makefile",
|
|
125
|
+
},
|
|
126
|
+
{
|
|
127
|
+
id: "protobuf",
|
|
128
|
+
label: "Protobuf",
|
|
129
|
+
category: "formats",
|
|
130
|
+
aliases: ["proto", "protocol-buffers"],
|
|
131
|
+
modelId: "protobuf",
|
|
132
|
+
extensions: [".proto"],
|
|
133
|
+
iconId: "protobuf",
|
|
134
|
+
},
|
|
135
|
+
{
|
|
136
|
+
id: "diff",
|
|
137
|
+
label: "Diff/Patch",
|
|
138
|
+
category: "formats",
|
|
139
|
+
aliases: ["patch", "udiff", "unified-diff", "git-diff"],
|
|
140
|
+
modelId: "diff",
|
|
141
|
+
extensions: [".diff", ".patch"],
|
|
142
|
+
iconId: "diff",
|
|
143
|
+
},
|
|
144
|
+
];
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { ContentType } from "./types.js";
|
|
2
|
+
export type { ContentCategory, ContentType } from "./types.js";
|
|
3
|
+
export declare const contentCategories: readonly (Readonly<{
|
|
4
|
+
id: "code";
|
|
5
|
+
label: "Code languages";
|
|
6
|
+
}> | Readonly<{
|
|
7
|
+
id: "formats";
|
|
8
|
+
label: "File formats";
|
|
9
|
+
}>)[];
|
|
10
|
+
export declare const contentTypes: readonly ContentType[];
|
|
11
|
+
/** Resolve only explicitly registered names; unknown names remain unsupported. */
|
|
12
|
+
export declare function normalizeLanguageId(language: string): string;
|
|
13
|
+
export declare function getContentType(name: string): ContentType | undefined;
|
|
14
|
+
/** Explicit filename helper, not content/language auto-detection by the highlighter. */
|
|
15
|
+
export declare function documentKindForFilename(filename: string, contentTypeId?: string): string | undefined;
|