@difizen/libro-cofine-textmate 0.1.2

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 (68) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +3 -0
  3. package/es/data/monaco-themes/vscode/dark_defaults.json +23 -0
  4. package/es/data/monaco-themes/vscode/dark_editor.json +116 -0
  5. package/es/data/monaco-themes/vscode/dark_plus.json +180 -0
  6. package/es/data/monaco-themes/vscode/dark_vs.json +358 -0
  7. package/es/data/monaco-themes/vscode/hc_black.json +120 -0
  8. package/es/data/monaco-themes/vscode/hc_black_defaults.json +335 -0
  9. package/es/data/monaco-themes/vscode/hc_editor.json +7 -0
  10. package/es/data/monaco-themes/vscode/light_defaults.json +22 -0
  11. package/es/data/monaco-themes/vscode/light_editor.json +11 -0
  12. package/es/data/monaco-themes/vscode/light_plus.json +180 -0
  13. package/es/data/monaco-themes/vscode/light_vs.json +380 -0
  14. package/es/global.d.ts +7 -0
  15. package/es/index.d.ts +7 -0
  16. package/es/index.d.ts.map +1 -0
  17. package/es/index.js +6 -0
  18. package/es/monaco-grammar-registry.d.ts +15 -0
  19. package/es/monaco-grammar-registry.d.ts.map +1 -0
  20. package/es/monaco-grammar-registry.js +130 -0
  21. package/es/monaco-module.d.ts +4 -0
  22. package/es/monaco-module.d.ts.map +1 -0
  23. package/es/monaco-module.js +78 -0
  24. package/es/monaco-textmate-service.d.ts +29 -0
  25. package/es/monaco-textmate-service.d.ts.map +1 -0
  26. package/es/monaco-textmate-service.js +284 -0
  27. package/es/monaco-theme-registry.d.ts +33 -0
  28. package/es/monaco-theme-registry.d.ts.map +1 -0
  29. package/es/monaco-theme-registry.js +227 -0
  30. package/es/monaco-theme-types.d.ts +5 -0
  31. package/es/monaco-theme-types.d.ts.map +1 -0
  32. package/es/monaco-theme-types.js +1 -0
  33. package/es/textmate-contribution.d.ts +9 -0
  34. package/es/textmate-contribution.d.ts.map +1 -0
  35. package/es/textmate-contribution.js +6 -0
  36. package/es/textmate-registry.d.ts +32 -0
  37. package/es/textmate-registry.d.ts.map +1 -0
  38. package/es/textmate-registry.js +130 -0
  39. package/es/textmate-theme-contribution.d.ts +6 -0
  40. package/es/textmate-theme-contribution.d.ts.map +1 -0
  41. package/es/textmate-theme-contribution.js +50 -0
  42. package/es/textmate-tokenizer.d.ts +25 -0
  43. package/es/textmate-tokenizer.d.ts.map +1 -0
  44. package/es/textmate-tokenizer.js +32 -0
  45. package/package.json +59 -0
  46. package/src/data/monaco-themes/vscode/dark_defaults.json +23 -0
  47. package/src/data/monaco-themes/vscode/dark_editor.json +116 -0
  48. package/src/data/monaco-themes/vscode/dark_plus.json +180 -0
  49. package/src/data/monaco-themes/vscode/dark_vs.json +358 -0
  50. package/src/data/monaco-themes/vscode/hc_black.json +120 -0
  51. package/src/data/monaco-themes/vscode/hc_black_defaults.json +335 -0
  52. package/src/data/monaco-themes/vscode/hc_editor.json +7 -0
  53. package/src/data/monaco-themes/vscode/light_defaults.json +22 -0
  54. package/src/data/monaco-themes/vscode/light_editor.json +11 -0
  55. package/src/data/monaco-themes/vscode/light_plus.json +180 -0
  56. package/src/data/monaco-themes/vscode/light_vs.json +380 -0
  57. package/src/global.d.ts +7 -0
  58. package/src/index.spec.ts +8 -0
  59. package/src/index.ts +8 -0
  60. package/src/monaco-grammar-registry.ts +88 -0
  61. package/src/monaco-module.ts +59 -0
  62. package/src/monaco-textmate-service.ts +220 -0
  63. package/src/monaco-theme-registry.ts +201 -0
  64. package/src/monaco-theme-types.ts +5 -0
  65. package/src/textmate-contribution.ts +15 -0
  66. package/src/textmate-registry.ts +134 -0
  67. package/src/textmate-theme-contribution.ts +39 -0
  68. package/src/textmate-tokenizer.ts +55 -0
@@ -0,0 +1,380 @@
1
+ {
2
+ "$schema": "vscode://schemas/color-theme",
3
+ "name": "Light (Visual Studio)",
4
+ "include": "light_defaults.json",
5
+ "colors": {},
6
+ "tokenColors": [
7
+ {
8
+ "scope": ["meta.embedded", "source.groovy.embedded"],
9
+ "settings": {
10
+ "foreground": "#000000ff"
11
+ }
12
+ },
13
+ {
14
+ "scope": "emphasis",
15
+ "settings": {
16
+ "fontStyle": "italic"
17
+ }
18
+ },
19
+ {
20
+ "scope": "strong",
21
+ "settings": {
22
+ "fontStyle": "bold"
23
+ }
24
+ },
25
+ {
26
+ "scope": "meta.diff.header",
27
+ "settings": {
28
+ "foreground": "#000080"
29
+ }
30
+ },
31
+ {
32
+ "scope": "comment",
33
+ "settings": {
34
+ "foreground": "#008000"
35
+ }
36
+ },
37
+ {
38
+ "scope": "constant.language",
39
+ "settings": {
40
+ "foreground": "#0000ff"
41
+ }
42
+ },
43
+ {
44
+ "scope": [
45
+ "constant.numeric",
46
+ "entity.name.operator.custom-literal.number",
47
+ "variable.other.enummember",
48
+ "keyword.operator.plus.exponent",
49
+ "keyword.operator.minus.exponent"
50
+ ],
51
+ "settings": {
52
+ "foreground": "#09885a"
53
+ }
54
+ },
55
+ {
56
+ "scope": "constant.regexp",
57
+ "settings": {
58
+ "foreground": "#811f3f"
59
+ }
60
+ },
61
+ {
62
+ "name": "css tags in selectors, xml tags",
63
+ "scope": "entity.name.tag",
64
+ "settings": {
65
+ "foreground": "#800000"
66
+ }
67
+ },
68
+ {
69
+ "scope": "entity.name.selector",
70
+ "settings": {
71
+ "foreground": "#800000"
72
+ }
73
+ },
74
+ {
75
+ "scope": "entity.other.attribute-name",
76
+ "settings": {
77
+ "foreground": "#ff0000"
78
+ }
79
+ },
80
+ {
81
+ "scope": [
82
+ "entity.other.attribute-name.class.css",
83
+ "entity.other.attribute-name.class.mixin.css",
84
+ "entity.other.attribute-name.id.css",
85
+ "entity.other.attribute-name.parent-selector.css",
86
+ "entity.other.attribute-name.pseudo-class.css",
87
+ "entity.other.attribute-name.pseudo-element.css",
88
+ "source.css.less entity.other.attribute-name.id",
89
+ "entity.other.attribute-name.attribute.scss",
90
+ "entity.other.attribute-name.scss"
91
+ ],
92
+ "settings": {
93
+ "foreground": "#800000"
94
+ }
95
+ },
96
+ {
97
+ "scope": "invalid",
98
+ "settings": {
99
+ "foreground": "#cd3131"
100
+ }
101
+ },
102
+ {
103
+ "scope": "markup.underline",
104
+ "settings": {
105
+ "fontStyle": "underline"
106
+ }
107
+ },
108
+ {
109
+ "scope": "markup.bold",
110
+ "settings": {
111
+ "fontStyle": "bold",
112
+ "foreground": "#000080"
113
+ }
114
+ },
115
+ {
116
+ "scope": "markup.heading",
117
+ "settings": {
118
+ "fontStyle": "bold",
119
+ "foreground": "#800000"
120
+ }
121
+ },
122
+ {
123
+ "scope": "markup.italic",
124
+ "settings": {
125
+ "fontStyle": "italic"
126
+ }
127
+ },
128
+ {
129
+ "scope": "markup.inserted",
130
+ "settings": {
131
+ "foreground": "#09885a"
132
+ }
133
+ },
134
+ {
135
+ "scope": "markup.deleted",
136
+ "settings": {
137
+ "foreground": "#a31515"
138
+ }
139
+ },
140
+ {
141
+ "scope": "markup.changed",
142
+ "settings": {
143
+ "foreground": "#0451a5"
144
+ }
145
+ },
146
+ {
147
+ "scope": [
148
+ "punctuation.definition.quote.begin.markdown",
149
+ "punctuation.definition.list.begin.markdown"
150
+ ],
151
+ "settings": {
152
+ "foreground": "#0451a5"
153
+ }
154
+ },
155
+ {
156
+ "scope": "markup.inline.raw",
157
+ "settings": {
158
+ "foreground": "#800000"
159
+ }
160
+ },
161
+ {
162
+ "name": "brackets of XML/HTML tags",
163
+ "scope": "punctuation.definition.tag",
164
+ "settings": {
165
+ "foreground": "#800000"
166
+ }
167
+ },
168
+ {
169
+ "scope": ["meta.preprocessor", "entity.name.function.preprocessor"],
170
+ "settings": {
171
+ "foreground": "#0000ff"
172
+ }
173
+ },
174
+ {
175
+ "scope": "meta.preprocessor.string",
176
+ "settings": {
177
+ "foreground": "#a31515"
178
+ }
179
+ },
180
+ {
181
+ "scope": "meta.preprocessor.numeric",
182
+ "settings": {
183
+ "foreground": "#09885a"
184
+ }
185
+ },
186
+ {
187
+ "scope": "meta.structure.dictionary.key.python",
188
+ "settings": {
189
+ "foreground": "#0451a5"
190
+ }
191
+ },
192
+ {
193
+ "scope": "storage",
194
+ "settings": {
195
+ "foreground": "#0000ff"
196
+ }
197
+ },
198
+ {
199
+ "scope": "storage.type",
200
+ "settings": {
201
+ "foreground": "#0000ff"
202
+ }
203
+ },
204
+ {
205
+ "scope": ["storage.modifier", "keyword.operator.noexcept"],
206
+ "settings": {
207
+ "foreground": "#0000ff"
208
+ }
209
+ },
210
+ {
211
+ "scope": [
212
+ "string",
213
+ "entity.name.operator.custom-literal.string",
214
+ "meta.embedded.assembly"
215
+ ],
216
+ "settings": {
217
+ "foreground": "#a31515"
218
+ }
219
+ },
220
+ {
221
+ "scope": [
222
+ "string.comment.buffered.block.pug",
223
+ "string.quoted.pug",
224
+ "string.interpolated.pug",
225
+ "string.unquoted.plain.in.yaml",
226
+ "string.unquoted.plain.out.yaml",
227
+ "string.unquoted.block.yaml",
228
+ "string.quoted.single.yaml",
229
+ "string.quoted.double.xml",
230
+ "string.quoted.single.xml",
231
+ "string.unquoted.cdata.xml",
232
+ "string.quoted.double.html",
233
+ "string.quoted.single.html",
234
+ "string.unquoted.html",
235
+ "string.quoted.single.handlebars",
236
+ "string.quoted.double.handlebars"
237
+ ],
238
+ "settings": {
239
+ "foreground": "#0000ff"
240
+ }
241
+ },
242
+ {
243
+ "scope": "string.regexp",
244
+ "settings": {
245
+ "foreground": "#811f3f"
246
+ }
247
+ },
248
+ {
249
+ "name": "String interpolation",
250
+ "scope": [
251
+ "punctuation.definition.template-expression.begin",
252
+ "punctuation.definition.template-expression.end",
253
+ "punctuation.section.embedded"
254
+ ],
255
+ "settings": {
256
+ "foreground": "#0000ff"
257
+ }
258
+ },
259
+ {
260
+ "name": "Reset JavaScript string interpolation expression",
261
+ "scope": ["meta.template.expression"],
262
+ "settings": {
263
+ "foreground": "#000000"
264
+ }
265
+ },
266
+ {
267
+ "scope": [
268
+ "support.constant.property-value",
269
+ "support.constant.font-name",
270
+ "support.constant.media-type",
271
+ "support.constant.media",
272
+ "constant.other.color.rgb-value",
273
+ "constant.other.rgb-value",
274
+ "support.constant.color"
275
+ ],
276
+ "settings": {
277
+ "foreground": "#0451a5"
278
+ }
279
+ },
280
+ {
281
+ "scope": [
282
+ "support.type.vendored.property-name",
283
+ "support.type.property-name",
284
+ "variable.css",
285
+ "variable.scss",
286
+ "variable.other.less",
287
+ "source.coffee.embedded"
288
+ ],
289
+ "settings": {
290
+ "foreground": "#ff0000"
291
+ }
292
+ },
293
+ {
294
+ "scope": ["support.type.property-name.json"],
295
+ "settings": {
296
+ "foreground": "#0451a5"
297
+ }
298
+ },
299
+ {
300
+ "scope": "keyword",
301
+ "settings": {
302
+ "foreground": "#0000ff"
303
+ }
304
+ },
305
+ {
306
+ "scope": "keyword.control",
307
+ "settings": {
308
+ "foreground": "#0000ff"
309
+ }
310
+ },
311
+ {
312
+ "scope": "keyword.operator",
313
+ "settings": {
314
+ "foreground": "#000000"
315
+ }
316
+ },
317
+ {
318
+ "scope": [
319
+ "keyword.operator.new",
320
+ "keyword.operator.expression",
321
+ "keyword.operator.cast",
322
+ "keyword.operator.sizeof",
323
+ "keyword.operator.alignof",
324
+ "keyword.operator.typeid",
325
+ "keyword.operator.alignas",
326
+ "keyword.operator.instanceof",
327
+ "keyword.operator.logical.python",
328
+ "keyword.operator.wordlike"
329
+ ],
330
+ "settings": {
331
+ "foreground": "#0000ff"
332
+ }
333
+ },
334
+ {
335
+ "scope": "keyword.other.unit",
336
+ "settings": {
337
+ "foreground": "#09885a"
338
+ }
339
+ },
340
+ {
341
+ "scope": [
342
+ "punctuation.section.embedded.begin.php",
343
+ "punctuation.section.embedded.end.php"
344
+ ],
345
+ "settings": {
346
+ "foreground": "#800000"
347
+ }
348
+ },
349
+ {
350
+ "scope": "support.function.git-rebase",
351
+ "settings": {
352
+ "foreground": "#0451a5"
353
+ }
354
+ },
355
+ {
356
+ "scope": "constant.sha.git-rebase",
357
+ "settings": {
358
+ "foreground": "#09885a"
359
+ }
360
+ },
361
+ {
362
+ "name": "coloring of the Java import and package identifiers",
363
+ "scope": [
364
+ "storage.modifier.import.java",
365
+ "variable.language.wildcard.java",
366
+ "storage.modifier.package.java"
367
+ ],
368
+ "settings": {
369
+ "foreground": "#000000"
370
+ }
371
+ },
372
+ {
373
+ "name": "this.self",
374
+ "scope": "variable.language",
375
+ "settings": {
376
+ "foreground": "#0000ff"
377
+ }
378
+ }
379
+ ]
380
+ }
@@ -0,0 +1,7 @@
1
+ declare module '@difizen/monaco-editor-core/esm/vs/editor/standalone/browser/standaloneServices';
2
+ declare module '@difizen/monaco-editor-core/esm/vs/editor/standalone/common/standaloneTheme';
3
+ declare module '@difizen/monaco-editor-core/esm/vs/editor/common/languages/language';
4
+ declare module '@difizen/monaco-editor-core/esm/vs/editor/common/languages';
5
+ declare module '@difizen/monaco-editor-core/esm/vs/editor/standalone/browser/standaloneLanguages';
6
+ declare module '*.json';
7
+ declare module 'vscode-oniguruma/release/onig.wasm';
@@ -0,0 +1,8 @@
1
+ import 'reflect-metadata';
2
+ import assert from 'assert';
3
+
4
+ describe('libro-cofine-textmate', () => {
5
+ it('#import', () => {
6
+ assert(true);
7
+ });
8
+ });
package/src/index.ts ADDED
@@ -0,0 +1,8 @@
1
+ import { TextmateModule } from './monaco-module.js';
2
+
3
+ export * from './monaco-module.js';
4
+ export * from './monaco-textmate-service.js';
5
+ export * from './textmate-contribution.js';
6
+ export * from './textmate-registry.js';
7
+
8
+ export default TextmateModule;
@@ -0,0 +1,88 @@
1
+ import { inject, singleton } from '@difizen/mana-app';
2
+ import type { IOnigLib, IRawGrammar, IRawTheme } from 'vscode-textmate';
3
+ import { Registry, parseRawGrammar } from 'vscode-textmate';
4
+
5
+ import { TextmateRegistry } from './textmate-registry.js';
6
+
7
+ export const isBasicWasmSupported = typeof (window as any).WebAssembly !== 'undefined';
8
+ export const OnigurumaPromise = Symbol('OnigasmPromise');
9
+ export type OnigurumaPromise = Promise<IOnigLib>;
10
+
11
+ @singleton()
12
+ export class MonacoGrammarRegistry {
13
+ public registry?: Registry;
14
+ protected readonly textmateRegistry: TextmateRegistry;
15
+ protected readonly onigasmPromise: OnigurumaPromise;
16
+ constructor(
17
+ @inject(TextmateRegistry) textmateRegistry: TextmateRegistry,
18
+ @inject(OnigurumaPromise) onigasmPromise: OnigurumaPromise,
19
+ ) {
20
+ this.textmateRegistry = textmateRegistry;
21
+ this.onigasmPromise = onigasmPromise;
22
+ }
23
+
24
+ getRegistry(theme: IRawTheme): Registry {
25
+ return new Registry({
26
+ onigLib: this.onigasmPromise,
27
+ theme,
28
+ loadGrammar: async (scopeName: string) => {
29
+ const provider = this.textmateRegistry.getProvider(scopeName);
30
+ if (provider) {
31
+ const definition = await provider.getGrammarDefinition();
32
+ let rawGrammar: IRawGrammar;
33
+ if (typeof definition.content === 'string') {
34
+ rawGrammar = parseRawGrammar(
35
+ definition.content,
36
+ definition.format === 'json' ? 'grammar.json' : 'grammar.plist',
37
+ );
38
+ } else {
39
+ rawGrammar = definition.content as unknown as IRawGrammar;
40
+ }
41
+ return rawGrammar;
42
+ }
43
+ return undefined;
44
+ },
45
+ getInjections: (scopeName: string) => {
46
+ const provider = this.textmateRegistry.getProvider(scopeName);
47
+ if (provider && provider.getInjections) {
48
+ return provider.getInjections(scopeName);
49
+ }
50
+ return [];
51
+ },
52
+ });
53
+ }
54
+ setupRegistry(theme: IRawTheme): void {
55
+ if (this.registry) {
56
+ this.registry.setTheme(theme);
57
+ return;
58
+ }
59
+ this.registry = new Registry({
60
+ onigLib: this.onigasmPromise,
61
+ theme,
62
+ loadGrammar: async (scopeName: string) => {
63
+ const provider = this.textmateRegistry.getProvider(scopeName);
64
+ if (provider) {
65
+ const definition = await provider.getGrammarDefinition();
66
+ let rawGrammar: IRawGrammar;
67
+ if (typeof definition.content === 'string') {
68
+ rawGrammar = parseRawGrammar(
69
+ definition.content,
70
+ definition.format === 'json' ? 'grammar.json' : 'grammar.plist',
71
+ );
72
+ } else {
73
+ rawGrammar = definition.content as unknown as IRawGrammar;
74
+ }
75
+ return rawGrammar;
76
+ }
77
+ return undefined;
78
+ },
79
+ getInjections: (scopeName: string) => {
80
+ const provider = this.textmateRegistry.getProvider(scopeName);
81
+ if (provider && provider.getInjections) {
82
+ return provider.getInjections(scopeName);
83
+ }
84
+ return [];
85
+ },
86
+ });
87
+ }
88
+ }
@@ -0,0 +1,59 @@
1
+ /* eslint-disable func-names */
2
+ /* eslint-disable global-require */
3
+
4
+ import { Module } from '@difizen/mana-app';
5
+ import * as oniguruma from 'vscode-oniguruma';
6
+ import * as onig from 'vscode-oniguruma/release/onig.wasm';
7
+
8
+ import {
9
+ isBasicWasmSupported,
10
+ MonacoGrammarRegistry,
11
+ OnigurumaPromise,
12
+ } from './monaco-grammar-registry.js';
13
+ import { MonacoTextmateService } from './monaco-textmate-service.js';
14
+ import { MonacoThemeRegistry } from './monaco-theme-registry.js';
15
+ import { LanguageGrammarDefinitionContribution } from './textmate-contribution.js';
16
+ import { TextmateRegistry } from './textmate-registry.js';
17
+ import { TextmateThemeContribution } from './textmate-theme-contribution.js';
18
+
19
+ export async function fetchOniguruma(): Promise<ArrayBuffer | Response> {
20
+ // const onigurumaPath = 'https://unpkg.com/vscode-oniguruma@2.0.1/release/onig.wasm'; // webpack doing its magic here
21
+ const onigurumaPath = onig;
22
+ let onigurumaUrl = onigurumaPath;
23
+ if (typeof onigurumaPath !== 'string' && onigurumaPath.default) {
24
+ onigurumaUrl = onigurumaPath.default;
25
+ }
26
+
27
+ const response = await fetch(onigurumaUrl);
28
+ const contentType = response.headers.get('content-type');
29
+ if (contentType === 'application/wasm') {
30
+ return response;
31
+ }
32
+
33
+ // Using the response directly only works if the server sets the MIME type 'application/wasm'.
34
+ // Otherwise, a TypeError is thrown when using the streaming compiler.
35
+ // We therefore use the non-streaming compiler :(.
36
+ return await response.arrayBuffer();
37
+ }
38
+
39
+ const vscodeOnigurumaLib = fetchOniguruma().then(async (buffer) => {
40
+ await oniguruma.loadWASM(buffer);
41
+ return oniguruma;
42
+ });
43
+
44
+ export const TextmateModule = Module()
45
+ .register(
46
+ {
47
+ token: OnigurumaPromise,
48
+ useValue: isBasicWasmSupported
49
+ ? vscodeOnigurumaLib
50
+ : Promise.reject(new Error('wasm not supported')),
51
+ },
52
+ MonacoTextmateService,
53
+ TextmateRegistry,
54
+ MonacoThemeRegistry,
55
+ TextmateThemeContribution,
56
+ MonacoGrammarRegistry,
57
+ )
58
+ .contribution(LanguageGrammarDefinitionContribution);
59
+ export default TextmateModule;