@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.
- package/LICENSE +21 -0
- package/README.md +3 -0
- package/es/data/monaco-themes/vscode/dark_defaults.json +23 -0
- package/es/data/monaco-themes/vscode/dark_editor.json +116 -0
- package/es/data/monaco-themes/vscode/dark_plus.json +180 -0
- package/es/data/monaco-themes/vscode/dark_vs.json +358 -0
- package/es/data/monaco-themes/vscode/hc_black.json +120 -0
- package/es/data/monaco-themes/vscode/hc_black_defaults.json +335 -0
- package/es/data/monaco-themes/vscode/hc_editor.json +7 -0
- package/es/data/monaco-themes/vscode/light_defaults.json +22 -0
- package/es/data/monaco-themes/vscode/light_editor.json +11 -0
- package/es/data/monaco-themes/vscode/light_plus.json +180 -0
- package/es/data/monaco-themes/vscode/light_vs.json +380 -0
- package/es/global.d.ts +7 -0
- package/es/index.d.ts +7 -0
- package/es/index.d.ts.map +1 -0
- package/es/index.js +6 -0
- package/es/monaco-grammar-registry.d.ts +15 -0
- package/es/monaco-grammar-registry.d.ts.map +1 -0
- package/es/monaco-grammar-registry.js +130 -0
- package/es/monaco-module.d.ts +4 -0
- package/es/monaco-module.d.ts.map +1 -0
- package/es/monaco-module.js +78 -0
- package/es/monaco-textmate-service.d.ts +29 -0
- package/es/monaco-textmate-service.d.ts.map +1 -0
- package/es/monaco-textmate-service.js +284 -0
- package/es/monaco-theme-registry.d.ts +33 -0
- package/es/monaco-theme-registry.d.ts.map +1 -0
- package/es/monaco-theme-registry.js +227 -0
- package/es/monaco-theme-types.d.ts +5 -0
- package/es/monaco-theme-types.d.ts.map +1 -0
- package/es/monaco-theme-types.js +1 -0
- package/es/textmate-contribution.d.ts +9 -0
- package/es/textmate-contribution.d.ts.map +1 -0
- package/es/textmate-contribution.js +6 -0
- package/es/textmate-registry.d.ts +32 -0
- package/es/textmate-registry.d.ts.map +1 -0
- package/es/textmate-registry.js +130 -0
- package/es/textmate-theme-contribution.d.ts +6 -0
- package/es/textmate-theme-contribution.d.ts.map +1 -0
- package/es/textmate-theme-contribution.js +50 -0
- package/es/textmate-tokenizer.d.ts +25 -0
- package/es/textmate-tokenizer.d.ts.map +1 -0
- package/es/textmate-tokenizer.js +32 -0
- package/package.json +59 -0
- package/src/data/monaco-themes/vscode/dark_defaults.json +23 -0
- package/src/data/monaco-themes/vscode/dark_editor.json +116 -0
- package/src/data/monaco-themes/vscode/dark_plus.json +180 -0
- package/src/data/monaco-themes/vscode/dark_vs.json +358 -0
- package/src/data/monaco-themes/vscode/hc_black.json +120 -0
- package/src/data/monaco-themes/vscode/hc_black_defaults.json +335 -0
- package/src/data/monaco-themes/vscode/hc_editor.json +7 -0
- package/src/data/monaco-themes/vscode/light_defaults.json +22 -0
- package/src/data/monaco-themes/vscode/light_editor.json +11 -0
- package/src/data/monaco-themes/vscode/light_plus.json +180 -0
- package/src/data/monaco-themes/vscode/light_vs.json +380 -0
- package/src/global.d.ts +7 -0
- package/src/index.spec.ts +8 -0
- package/src/index.ts +8 -0
- package/src/monaco-grammar-registry.ts +88 -0
- package/src/monaco-module.ts +59 -0
- package/src/monaco-textmate-service.ts +220 -0
- package/src/monaco-theme-registry.ts +201 -0
- package/src/monaco-theme-types.ts +5 -0
- package/src/textmate-contribution.ts +15 -0
- package/src/textmate-registry.ts +134 -0
- package/src/textmate-theme-contribution.ts +39 -0
- package/src/textmate-tokenizer.ts +55 -0
|
@@ -0,0 +1,227 @@
|
|
|
1
|
+
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
2
|
+
var _dec, _dec2, _class, _class2, _descriptor;
|
|
3
|
+
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
4
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
5
|
+
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
6
|
+
function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
|
|
7
|
+
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
|
|
8
|
+
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
9
|
+
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
10
|
+
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
|
|
11
|
+
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
|
|
12
|
+
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
|
13
|
+
function _initializerDefineProperty(target, property, descriptor, context) { if (!descriptor) return; Object.defineProperty(target, property, { enumerable: descriptor.enumerable, configurable: descriptor.configurable, writable: descriptor.writable, value: descriptor.initializer ? descriptor.initializer.call(context) : void 0 }); }
|
|
14
|
+
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
15
|
+
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }
|
|
16
|
+
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
|
17
|
+
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
|
|
18
|
+
function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
|
|
19
|
+
function _applyDecoratedDescriptor(target, property, decorators, descriptor, context) { var desc = {}; Object.keys(descriptor).forEach(function (key) { desc[key] = descriptor[key]; }); desc.enumerable = !!desc.enumerable; desc.configurable = !!desc.configurable; if ('value' in desc || desc.initializer) { desc.writable = true; } desc = decorators.slice().reverse().reduce(function (desc, decorator) { return decorator(target, property, desc) || desc; }, desc); if (context && desc.initializer !== void 0) { desc.value = desc.initializer ? desc.initializer.call(context) : void 0; desc.initializer = undefined; } if (desc.initializer === void 0) { Object.defineProperty(target, property, desc); desc = null; } return desc; }
|
|
20
|
+
function _initializerWarningHelper(descriptor, context) { throw new Error('Decorating class property failed. Please ensure that ' + 'transform-class-properties is enabled and runs after the decorators transform.'); }
|
|
21
|
+
import { MixedThemeRegistry, InitializeContribution } from '@difizen/libro-cofine-editor-core';
|
|
22
|
+
import { Emitter, inject, singleton } from '@difizen/mana-app';
|
|
23
|
+
import * as monaco from '@difizen/monaco-editor-core';
|
|
24
|
+
import { StandaloneServices } from '@difizen/monaco-editor-core/esm/vs/editor/standalone/browser/standaloneServices';
|
|
25
|
+
import { IStandaloneThemeService } from '@difizen/monaco-editor-core/esm/vs/editor/standalone/common/standaloneTheme';
|
|
26
|
+
import { MonacoGrammarRegistry } from "./monaco-grammar-registry.js";
|
|
27
|
+
export var MonacoThemeRegistry = (_dec = singleton({
|
|
28
|
+
contrib: [MixedThemeRegistry, InitializeContribution]
|
|
29
|
+
}), _dec2 = inject(MonacoGrammarRegistry), _dec(_class = (_class2 = /*#__PURE__*/function () {
|
|
30
|
+
function MonacoThemeRegistry() {
|
|
31
|
+
_classCallCheck(this, MonacoThemeRegistry);
|
|
32
|
+
_initializerDefineProperty(this, "grammarRegistry", _descriptor, this);
|
|
33
|
+
this.registedTheme = [];
|
|
34
|
+
this.themeChangedEmitter = new Emitter();
|
|
35
|
+
this.onThemeChanged = this.themeChangedEmitter.event;
|
|
36
|
+
}
|
|
37
|
+
_createClass(MonacoThemeRegistry, [{
|
|
38
|
+
key: "onInitialize",
|
|
39
|
+
value: function onInitialize() {
|
|
40
|
+
var _this = this;
|
|
41
|
+
var standaloneThemeService = StandaloneServices.get(IStandaloneThemeService);
|
|
42
|
+
standaloneThemeService.onDidColorThemeChange(function () {
|
|
43
|
+
_this.themeChangedEmitter.fire();
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
}, {
|
|
47
|
+
key: "getThemeData",
|
|
48
|
+
value: function getThemeData(name) {
|
|
49
|
+
var theme = this.doGetTheme(name);
|
|
50
|
+
return theme && theme.themeData;
|
|
51
|
+
}
|
|
52
|
+
}, {
|
|
53
|
+
key: "getTheme",
|
|
54
|
+
value: function getTheme(name) {
|
|
55
|
+
return this.doGetTheme(name);
|
|
56
|
+
}
|
|
57
|
+
}, {
|
|
58
|
+
key: "getMonacoThemeName",
|
|
59
|
+
value: function getMonacoThemeName() {
|
|
60
|
+
var standaloneThemeService = StandaloneServices.get(IStandaloneThemeService);
|
|
61
|
+
return standaloneThemeService.getColorTheme().themeName;
|
|
62
|
+
}
|
|
63
|
+
}, {
|
|
64
|
+
key: "doGetTheme",
|
|
65
|
+
value: function doGetTheme(name) {
|
|
66
|
+
var standaloneThemeService = StandaloneServices.get(IStandaloneThemeService);
|
|
67
|
+
var theme = !name ? standaloneThemeService.getTheme() : standaloneThemeService._knownThemes.get(name);
|
|
68
|
+
return theme;
|
|
69
|
+
}
|
|
70
|
+
}, {
|
|
71
|
+
key: "setTheme",
|
|
72
|
+
value: function setTheme(name, data) {
|
|
73
|
+
// monaco auto refreshes a theme with new data
|
|
74
|
+
monaco.editor.defineTheme(name, data);
|
|
75
|
+
}
|
|
76
|
+
}, {
|
|
77
|
+
key: "registerThemes",
|
|
78
|
+
value: function registerThemes(themeOptions, setTheme) {
|
|
79
|
+
var _this2 = this;
|
|
80
|
+
Object.keys(themeOptions).forEach(function (key) {
|
|
81
|
+
_this2.doRegisterThemes(themeOptions[key], themeOptions, setTheme);
|
|
82
|
+
});
|
|
83
|
+
}
|
|
84
|
+
}, {
|
|
85
|
+
key: "doRegisterThemes",
|
|
86
|
+
value: function doRegisterThemes(option, themeOptions, setTheme) {
|
|
87
|
+
var result = {
|
|
88
|
+
name: option.name,
|
|
89
|
+
base: option.base || 'vs',
|
|
90
|
+
inherit: true,
|
|
91
|
+
colors: {},
|
|
92
|
+
rules: [],
|
|
93
|
+
settings: []
|
|
94
|
+
};
|
|
95
|
+
if (typeof option.include !== 'undefined') {
|
|
96
|
+
var themeName = option.include.replaceAll('/', '').replaceAll('_', '-').replaceAll('.json', '');
|
|
97
|
+
var parentOption = themeOptions[themeName];
|
|
98
|
+
if (!parentOption || this.registedTheme.includes(parentOption.name)) {
|
|
99
|
+
console.error("Couldn't resolve includes theme ".concat(option.include, "."));
|
|
100
|
+
} else {
|
|
101
|
+
var _result$rules, _result$settings;
|
|
102
|
+
var parentTheme = this.doRegisterThemes(parentOption, themeOptions, setTheme);
|
|
103
|
+
Object.assign(result.colors, parentTheme.colors);
|
|
104
|
+
(_result$rules = result.rules).push.apply(_result$rules, _toConsumableArray(parentTheme.rules));
|
|
105
|
+
(_result$settings = result.settings).push.apply(_result$settings, _toConsumableArray(parentTheme.settings));
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
var tokenColors = option.tokenColors;
|
|
109
|
+
if (Array.isArray(tokenColors)) {
|
|
110
|
+
var _iterator = _createForOfIteratorHelper(tokenColors),
|
|
111
|
+
_step;
|
|
112
|
+
try {
|
|
113
|
+
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
114
|
+
var tokenColor = _step.value;
|
|
115
|
+
if (tokenColor.scope && tokenColor.settings) {
|
|
116
|
+
result.settings.push({
|
|
117
|
+
scope: tokenColor.scope,
|
|
118
|
+
settings: {
|
|
119
|
+
foreground: this.normalizeColor(tokenColor.settings.foreground),
|
|
120
|
+
background: this.normalizeColor(tokenColor.settings.background),
|
|
121
|
+
fontStyle: tokenColor.settings.fontStyle
|
|
122
|
+
}
|
|
123
|
+
});
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
} catch (err) {
|
|
127
|
+
_iterator.e(err);
|
|
128
|
+
} finally {
|
|
129
|
+
_iterator.f();
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
if (option.colors) {
|
|
133
|
+
Object.assign(result.colors, option.colors);
|
|
134
|
+
result.encodedTokensColors = Object.keys(result.colors).map(function (key) {
|
|
135
|
+
return result.colors[key];
|
|
136
|
+
});
|
|
137
|
+
}
|
|
138
|
+
if (option.name && option.base) {
|
|
139
|
+
var _iterator2 = _createForOfIteratorHelper(result.settings),
|
|
140
|
+
_step2;
|
|
141
|
+
try {
|
|
142
|
+
for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
|
|
143
|
+
var setting = _step2.value;
|
|
144
|
+
this.transform(setting, function (rule) {
|
|
145
|
+
return result.rules.push(rule);
|
|
146
|
+
});
|
|
147
|
+
}
|
|
148
|
+
} catch (err) {
|
|
149
|
+
_iterator2.e(err);
|
|
150
|
+
} finally {
|
|
151
|
+
_iterator2.f();
|
|
152
|
+
}
|
|
153
|
+
var standaloneThemeService = StandaloneServices.get(IStandaloneThemeService);
|
|
154
|
+
|
|
155
|
+
// the default rule (scope empty) is always the first rule. Ignore all other default rules.
|
|
156
|
+
var defaultTheme = standaloneThemeService._knownThemes.get(result.base);
|
|
157
|
+
var foreground = result.colors['editor.foreground'] || defaultTheme.getColor('editor.foreground');
|
|
158
|
+
var background = result.colors['editor.background'] || defaultTheme.getColor('editor.background');
|
|
159
|
+
result.settings.unshift({
|
|
160
|
+
settings: {
|
|
161
|
+
foreground: this.normalizeColor(foreground),
|
|
162
|
+
background: this.normalizeColor(background)
|
|
163
|
+
}
|
|
164
|
+
});
|
|
165
|
+
var reg = this.grammarRegistry.getRegistry(result);
|
|
166
|
+
reg.setTheme(result);
|
|
167
|
+
result.encodedTokensColors = reg.getColorMap();
|
|
168
|
+
// index 0 has to be set to null as it is 'undefined' by default, but monaco code expects it to be null
|
|
169
|
+
if (result.encodedTokensColors) {
|
|
170
|
+
result.encodedTokensColors[0] = null;
|
|
171
|
+
}
|
|
172
|
+
setTheme(option.name, result);
|
|
173
|
+
}
|
|
174
|
+
return result;
|
|
175
|
+
}
|
|
176
|
+
}, {
|
|
177
|
+
key: "transform",
|
|
178
|
+
value: function transform(tokenColor, acceptor) {
|
|
179
|
+
if (typeof tokenColor.scope === 'undefined') {
|
|
180
|
+
tokenColor.scope = [''];
|
|
181
|
+
} else if (typeof tokenColor.scope === 'string') {
|
|
182
|
+
tokenColor.scope = tokenColor.scope.split(',').map(function (scope) {
|
|
183
|
+
return scope.trim();
|
|
184
|
+
});
|
|
185
|
+
}
|
|
186
|
+
var _iterator3 = _createForOfIteratorHelper(tokenColor.scope),
|
|
187
|
+
_step3;
|
|
188
|
+
try {
|
|
189
|
+
for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
|
|
190
|
+
var scope = _step3.value;
|
|
191
|
+
acceptor(_objectSpread(_objectSpread({}, tokenColor.settings), {}, {
|
|
192
|
+
token: scope
|
|
193
|
+
}));
|
|
194
|
+
}
|
|
195
|
+
} catch (err) {
|
|
196
|
+
_iterator3.e(err);
|
|
197
|
+
} finally {
|
|
198
|
+
_iterator3.f();
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
}, {
|
|
202
|
+
key: "normalizeColor",
|
|
203
|
+
value: function normalizeColor(color) {
|
|
204
|
+
if (!color) {
|
|
205
|
+
return undefined;
|
|
206
|
+
}
|
|
207
|
+
var normalized = String(color).replace(/^#/, '').slice(0, 6);
|
|
208
|
+
if (normalized.length < 6 || !normalized.match(/^[0-9A-Fa-f]{6}$/)) {
|
|
209
|
+
// ignoring not normalized colors to avoid breaking token color indexes between monaco and vscode-textmate
|
|
210
|
+
console.error("Color '".concat(normalized, "' is NOT normalized, it must have 6 positions."));
|
|
211
|
+
return undefined;
|
|
212
|
+
}
|
|
213
|
+
return "#".concat(normalized);
|
|
214
|
+
}
|
|
215
|
+
}]);
|
|
216
|
+
return MonacoThemeRegistry;
|
|
217
|
+
}(), (_descriptor = _applyDecoratedDescriptor(_class2.prototype, "grammarRegistry", [_dec2], {
|
|
218
|
+
configurable: true,
|
|
219
|
+
enumerable: true,
|
|
220
|
+
writable: true,
|
|
221
|
+
initializer: null
|
|
222
|
+
})), _class2)) || _class);
|
|
223
|
+
(function (_MonacoThemeRegistry) {
|
|
224
|
+
var DARK_DEFAULT_THEME = _MonacoThemeRegistry.DARK_DEFAULT_THEME = 'e2-dark';
|
|
225
|
+
var LIGHT_DEFAULT_THEME = _MonacoThemeRegistry.LIGHT_DEFAULT_THEME = 'e2-light';
|
|
226
|
+
var HC_DEFAULT_THEME = _MonacoThemeRegistry.HC_DEFAULT_THEME = 'e2-hc';
|
|
227
|
+
})(MonacoThemeRegistry || (MonacoThemeRegistry = {}));
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"monaco-theme-types.d.ts","sourceRoot":"","sources":["../src/monaco-theme-types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,MAAM,6BAA6B,CAAC;AAE3D,MAAM,WAAW,WAAY,SAAQ,MAAM,CAAC,MAAM,CAAC,oBAAoB;IACrE,IAAI,EAAE,MAAM,CAAC;CACd"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { Syringe } from '@difizen/mana-app';
|
|
2
|
+
import type { TextmateRegistry } from './textmate-registry.js';
|
|
3
|
+
export declare const LanguageGrammarDefinitionContribution: Syringe.DefinedToken;
|
|
4
|
+
export interface LanguageGrammarDefinitionContribution {
|
|
5
|
+
registerTextmateLanguage: (registry: TextmateRegistry) => void;
|
|
6
|
+
_finishRegisterTextmateLanguage?: boolean;
|
|
7
|
+
}
|
|
8
|
+
export declare function getEncodedLanguageId(languageId: string): number;
|
|
9
|
+
//# sourceMappingURL=textmate-contribution.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"textmate-contribution.d.ts","sourceRoot":"","sources":["../src/textmate-contribution.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAG5C,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAE/D,eAAO,MAAM,qCAAqC,sBAEjD,CAAC;AACF,MAAM,WAAW,qCAAqC;IACpD,wBAAwB,EAAE,CAAC,QAAQ,EAAE,gBAAgB,KAAK,IAAI,CAAC;IAC/D,+BAA+B,CAAC,EAAE,OAAO,CAAC;CAC3C;AACD,wBAAgB,oBAAoB,CAAC,UAAU,EAAE,MAAM,GAAG,MAAM,CAE/D"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { Syringe } from '@difizen/mana-app';
|
|
2
|
+
import * as monaco from '@difizen/monaco-editor-core';
|
|
3
|
+
export var LanguageGrammarDefinitionContribution = Syringe.defineToken('LanguageGrammarDefinitionContribution');
|
|
4
|
+
export function getEncodedLanguageId(languageId) {
|
|
5
|
+
return monaco.languages.getEncodedLanguageId(languageId);
|
|
6
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { Disposable } from '@difizen/mana-app';
|
|
2
|
+
import type { IGrammarConfiguration } from 'vscode-textmate';
|
|
3
|
+
import type { TokenizerOption } from './textmate-tokenizer.js';
|
|
4
|
+
export interface TextmateGrammarConfiguration extends IGrammarConfiguration {
|
|
5
|
+
/**
|
|
6
|
+
* Optional options to further refine the tokenization of the grammar.
|
|
7
|
+
*/
|
|
8
|
+
readonly tokenizerOption?: TokenizerOption;
|
|
9
|
+
}
|
|
10
|
+
export interface GrammarDefinitionProvider {
|
|
11
|
+
getGrammarDefinition: () => Promise<GrammarDefinition>;
|
|
12
|
+
getInjections?: (scopeName: string) => string[];
|
|
13
|
+
}
|
|
14
|
+
export interface GrammarDefinition {
|
|
15
|
+
format: 'json' | 'plist';
|
|
16
|
+
content: Record<string, unknown> | string;
|
|
17
|
+
location?: string;
|
|
18
|
+
}
|
|
19
|
+
export declare class TextmateRegistry {
|
|
20
|
+
protected readonly scopeToProvider: Map<string, GrammarDefinitionProvider[]>;
|
|
21
|
+
protected readonly languageToConfig: Map<string, TextmateGrammarConfiguration[]>;
|
|
22
|
+
protected readonly languageIdToScope: Map<string, string[]>;
|
|
23
|
+
get languages(): IterableIterator<string>;
|
|
24
|
+
registerTextmateGrammarScope(scope: string, provider: GrammarDefinitionProvider): Disposable;
|
|
25
|
+
getProvider(scope: string): GrammarDefinitionProvider | undefined;
|
|
26
|
+
mapLanguageIdToTextmateGrammar(languageId: string, scope: string): Disposable;
|
|
27
|
+
getScope(languageId: string): string | undefined;
|
|
28
|
+
getLanguageId(scope: string): string | undefined;
|
|
29
|
+
registerGrammarConfiguration(languageId: string, config: TextmateGrammarConfiguration): Disposable;
|
|
30
|
+
getGrammarConfiguration(languageId: string): TextmateGrammarConfiguration;
|
|
31
|
+
}
|
|
32
|
+
//# sourceMappingURL=textmate-registry.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"textmate-registry.d.ts","sourceRoot":"","sources":["../src/textmate-registry.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAE/C,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,iBAAiB,CAAC;AAE7D,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAE/D,MAAM,WAAW,4BAA6B,SAAQ,qBAAqB;IACzE;;OAEG;IACH,QAAQ,CAAC,eAAe,CAAC,EAAE,eAAe,CAAC;CAC5C;AAED,MAAM,WAAW,yBAAyB;IACxC,oBAAoB,EAAE,MAAM,OAAO,CAAC,iBAAiB,CAAC,CAAC;IACvD,aAAa,CAAC,EAAE,CAAC,SAAS,EAAE,MAAM,KAAK,MAAM,EAAE,CAAC;CACjD;AAED,MAAM,WAAW,iBAAiB;IAChC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC;IACzB,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,MAAM,CAAC;IAC1C,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAED,qBACa,gBAAgB;IAC3B,SAAS,CAAC,QAAQ,CAAC,eAAe,2CAAkD;IACpF,SAAS,CAAC,QAAQ,CAAC,gBAAgB,8CAG/B;IACJ,SAAS,CAAC,QAAQ,CAAC,iBAAiB,wBAA+B;IAEnE,IAAI,SAAS,IAAI,gBAAgB,CAAC,MAAM,CAAC,CAExC;IAED,4BAA4B,CAC1B,KAAK,EAAE,MAAM,EACb,QAAQ,EAAE,yBAAyB,GAClC,UAAU;IA4Bb,WAAW,CAAC,KAAK,EAAE,MAAM,GAAG,yBAAyB,GAAG,SAAS;IAKjE,8BAA8B,CAAC,UAAU,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,UAAU;IAkB7E,QAAQ,CAAC,UAAU,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS;IAKhD,aAAa,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS;IAShD,4BAA4B,CAC1B,UAAU,EAAE,MAAM,EAClB,MAAM,EAAE,4BAA4B,GACnC,UAAU;IAkBb,uBAAuB,CAAC,UAAU,EAAE,MAAM,GAAG,4BAA4B;CAI1E"}
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
2
|
+
var _dec, _class;
|
|
3
|
+
function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
|
|
4
|
+
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
5
|
+
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
6
|
+
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
7
|
+
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
|
8
|
+
function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
|
|
9
|
+
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
10
|
+
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
11
|
+
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }
|
|
12
|
+
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
|
13
|
+
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
|
|
14
|
+
function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
|
|
15
|
+
/* eslint-disable no-console */
|
|
16
|
+
/* eslint-disable no-restricted-syntax */
|
|
17
|
+
|
|
18
|
+
import { Disposable } from '@difizen/mana-app';
|
|
19
|
+
import { singleton } from '@difizen/mana-app';
|
|
20
|
+
export var TextmateRegistry = (_dec = singleton(), _dec(_class = /*#__PURE__*/function () {
|
|
21
|
+
function TextmateRegistry() {
|
|
22
|
+
_classCallCheck(this, TextmateRegistry);
|
|
23
|
+
this.scopeToProvider = new Map();
|
|
24
|
+
this.languageToConfig = new Map();
|
|
25
|
+
this.languageIdToScope = new Map();
|
|
26
|
+
}
|
|
27
|
+
_createClass(TextmateRegistry, [{
|
|
28
|
+
key: "languages",
|
|
29
|
+
get: function get() {
|
|
30
|
+
return this.languageIdToScope.keys();
|
|
31
|
+
}
|
|
32
|
+
}, {
|
|
33
|
+
key: "registerTextmateGrammarScope",
|
|
34
|
+
value: function registerTextmateGrammarScope(scope, provider) {
|
|
35
|
+
var providers = this.scopeToProvider.get(scope) || [];
|
|
36
|
+
var existingProvider = providers[0];
|
|
37
|
+
if (existingProvider) {
|
|
38
|
+
Promise.all([existingProvider.getGrammarDefinition(), provider.getGrammarDefinition()]).then(function (_ref) {
|
|
39
|
+
var _ref2 = _slicedToArray(_ref, 2),
|
|
40
|
+
a = _ref2[0],
|
|
41
|
+
b = _ref2[1];
|
|
42
|
+
if (a.location !== b.location || !a.location && !b.location) {
|
|
43
|
+
console.warn("a registered grammar provider for '".concat(scope, "' scope is overridden"));
|
|
44
|
+
}
|
|
45
|
+
return;
|
|
46
|
+
}).catch(console.error);
|
|
47
|
+
}
|
|
48
|
+
providers.unshift(provider);
|
|
49
|
+
this.scopeToProvider.set(scope, providers);
|
|
50
|
+
return Disposable.create(function () {
|
|
51
|
+
var index = providers.indexOf(provider);
|
|
52
|
+
if (index !== -1) {
|
|
53
|
+
providers.splice(index, 1);
|
|
54
|
+
}
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
}, {
|
|
58
|
+
key: "getProvider",
|
|
59
|
+
value: function getProvider(scope) {
|
|
60
|
+
var providers = this.scopeToProvider.get(scope);
|
|
61
|
+
return providers && providers[0];
|
|
62
|
+
}
|
|
63
|
+
}, {
|
|
64
|
+
key: "mapLanguageIdToTextmateGrammar",
|
|
65
|
+
value: function mapLanguageIdToTextmateGrammar(languageId, scope) {
|
|
66
|
+
var scopes = this.languageIdToScope.get(languageId) || [];
|
|
67
|
+
var existingScope = scopes[0];
|
|
68
|
+
if (typeof existingScope === 'string') {
|
|
69
|
+
console.warn("'".concat(languageId, "' language is remapped from '").concat(existingScope, "' to '").concat(scope, "' scope"));
|
|
70
|
+
}
|
|
71
|
+
scopes.unshift(scope);
|
|
72
|
+
this.languageIdToScope.set(languageId, scopes);
|
|
73
|
+
return Disposable.create(function () {
|
|
74
|
+
var index = scopes.indexOf(scope);
|
|
75
|
+
if (index !== -1) {
|
|
76
|
+
scopes.splice(index, 1);
|
|
77
|
+
}
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
}, {
|
|
81
|
+
key: "getScope",
|
|
82
|
+
value: function getScope(languageId) {
|
|
83
|
+
var scopes = this.languageIdToScope.get(languageId);
|
|
84
|
+
return scopes && scopes[0];
|
|
85
|
+
}
|
|
86
|
+
}, {
|
|
87
|
+
key: "getLanguageId",
|
|
88
|
+
value: function getLanguageId(scope) {
|
|
89
|
+
var _iterator = _createForOfIteratorHelper(this.languageIdToScope.keys()),
|
|
90
|
+
_step;
|
|
91
|
+
try {
|
|
92
|
+
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
93
|
+
var languageId = _step.value;
|
|
94
|
+
if (this.getScope(languageId) === scope) {
|
|
95
|
+
return languageId;
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
} catch (err) {
|
|
99
|
+
_iterator.e(err);
|
|
100
|
+
} finally {
|
|
101
|
+
_iterator.f();
|
|
102
|
+
}
|
|
103
|
+
return undefined;
|
|
104
|
+
}
|
|
105
|
+
}, {
|
|
106
|
+
key: "registerGrammarConfiguration",
|
|
107
|
+
value: function registerGrammarConfiguration(languageId, config) {
|
|
108
|
+
var configs = this.languageToConfig.get(languageId) || [];
|
|
109
|
+
var existingConfig = configs[0];
|
|
110
|
+
if (existingConfig) {
|
|
111
|
+
console.warn("a registered grammar configuration for '".concat(languageId, "' language is overridden"));
|
|
112
|
+
}
|
|
113
|
+
configs.unshift(config);
|
|
114
|
+
this.languageToConfig.set(languageId, configs);
|
|
115
|
+
return Disposable.create(function () {
|
|
116
|
+
var index = configs.indexOf(config);
|
|
117
|
+
if (index !== -1) {
|
|
118
|
+
configs.splice(index, 1);
|
|
119
|
+
}
|
|
120
|
+
});
|
|
121
|
+
}
|
|
122
|
+
}, {
|
|
123
|
+
key: "getGrammarConfiguration",
|
|
124
|
+
value: function getGrammarConfiguration(languageId) {
|
|
125
|
+
var configs = this.languageToConfig.get(languageId);
|
|
126
|
+
return configs && configs[0] || {};
|
|
127
|
+
}
|
|
128
|
+
}]);
|
|
129
|
+
return TextmateRegistry;
|
|
130
|
+
}()) || _class);
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { ThemeRegistry } from '@difizen/libro-cofine-editor-core';
|
|
2
|
+
import { ThemeContribution } from '@difizen/libro-cofine-editor-core';
|
|
3
|
+
export declare class TextmateThemeContribution implements ThemeContribution {
|
|
4
|
+
registerItem(registry: ThemeRegistry): void;
|
|
5
|
+
}
|
|
6
|
+
//# sourceMappingURL=textmate-theme-contribution.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"textmate-theme-contribution.d.ts","sourceRoot":"","sources":["../src/textmate-theme-contribution.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,mCAAmC,CAAC;AACvE,OAAO,EAAE,iBAAiB,EAAE,MAAM,mCAAmC,CAAC;AAetE,qBACa,yBAA0B,YAAW,iBAAiB;IACjE,YAAY,CAAC,QAAQ,EAAE,aAAa,GAAG,IAAI;CAmB5C"}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
2
|
+
var _dec, _class;
|
|
3
|
+
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
4
|
+
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }
|
|
5
|
+
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
|
6
|
+
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
|
|
7
|
+
function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
|
|
8
|
+
/* eslint-disable global-require */
|
|
9
|
+
|
|
10
|
+
import { ThemeContribution } from '@difizen/libro-cofine-editor-core';
|
|
11
|
+
import { singleton } from '@difizen/mana-app';
|
|
12
|
+
import darkDefaults from "./data/monaco-themes/vscode/dark_defaults.json";
|
|
13
|
+
import darkEditor from "./data/monaco-themes/vscode/dark_editor.json";
|
|
14
|
+
import darkPlus from "./data/monaco-themes/vscode/dark_plus.json";
|
|
15
|
+
import darkVS from "./data/monaco-themes/vscode/dark_vs.json";
|
|
16
|
+
import HCBlack from "./data/monaco-themes/vscode/hc_black.json";
|
|
17
|
+
import HCBlackDefault from "./data/monaco-themes/vscode/hc_black_defaults.json";
|
|
18
|
+
import HCEditor from "./data/monaco-themes/vscode/hc_editor.json";
|
|
19
|
+
import lightDefaults from "./data/monaco-themes/vscode/light_defaults.json";
|
|
20
|
+
import lightEditor from "./data/monaco-themes/vscode/light_editor.json";
|
|
21
|
+
import lightPlus from "./data/monaco-themes/vscode/light_plus.json";
|
|
22
|
+
import lightVS from "./data/monaco-themes/vscode/light_vs.json";
|
|
23
|
+
export var TextmateThemeContribution = (_dec = singleton({
|
|
24
|
+
contrib: ThemeContribution
|
|
25
|
+
}), _dec(_class = /*#__PURE__*/function () {
|
|
26
|
+
function TextmateThemeContribution() {
|
|
27
|
+
_classCallCheck(this, TextmateThemeContribution);
|
|
28
|
+
}
|
|
29
|
+
_createClass(TextmateThemeContribution, [{
|
|
30
|
+
key: "registerItem",
|
|
31
|
+
value: function registerItem(registry) {
|
|
32
|
+
if (!registry.mixedThemeEnable) {
|
|
33
|
+
console.warn('cannot register textmate themes');
|
|
34
|
+
return;
|
|
35
|
+
}
|
|
36
|
+
registry.registerMixedTheme(darkDefaults, 'dark-defaults', 'vs-dark');
|
|
37
|
+
registry.registerMixedTheme(darkVS, 'dark-vs', 'vs-dark');
|
|
38
|
+
registry.registerMixedTheme(darkPlus, 'dark-plus', 'vs-dark');
|
|
39
|
+
registry.registerMixedTheme(darkEditor, 'e2-dark', 'vs-dark');
|
|
40
|
+
registry.registerMixedTheme(lightDefaults, 'light-defaults', 'vs');
|
|
41
|
+
registry.registerMixedTheme(lightVS, 'light-vs', 'vs');
|
|
42
|
+
registry.registerMixedTheme(lightPlus, 'light-plus', 'vs');
|
|
43
|
+
registry.registerMixedTheme(lightEditor, 'e2-light', 'vs');
|
|
44
|
+
registry.registerMixedTheme(HCBlackDefault, 'hc-black-defaults', 'hc-black');
|
|
45
|
+
registry.registerMixedTheme(HCBlack, 'hc-black', 'hc-black');
|
|
46
|
+
registry.registerMixedTheme(HCEditor, 'e2-hc', 'hc-black');
|
|
47
|
+
}
|
|
48
|
+
}]);
|
|
49
|
+
return TextmateThemeContribution;
|
|
50
|
+
}()) || _class);
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type monaco from '@difizen/monaco-editor-core';
|
|
2
|
+
import type { IGrammar } from 'vscode-textmate';
|
|
3
|
+
/**
|
|
4
|
+
* Options for the TextMate tokenizer.
|
|
5
|
+
*/
|
|
6
|
+
export interface TokenizerOption {
|
|
7
|
+
/**
|
|
8
|
+
* Maximum line length that will be handled by the TextMate tokenizer. If the length of the actual line exceeds this
|
|
9
|
+
* limit, the tokenizer terminates and the tokenization of any subsequent lines might be broken.
|
|
10
|
+
*
|
|
11
|
+
* If the `lineLimit` is not defined, it means, there are no line length limits. Otherwise, it must be a positive
|
|
12
|
+
* integer or an error will be thrown.
|
|
13
|
+
*/
|
|
14
|
+
lineLimit?: number;
|
|
15
|
+
}
|
|
16
|
+
export declare namespace TokenizerOption {
|
|
17
|
+
/**
|
|
18
|
+
* The default TextMate tokenizer option.
|
|
19
|
+
*
|
|
20
|
+
* @deprecated Use the current value of `editor.maxTokenizationLineLength` preference instead.
|
|
21
|
+
*/
|
|
22
|
+
const DEFAULT: TokenizerOption;
|
|
23
|
+
}
|
|
24
|
+
export declare function createTextmateTokenizer(grammar: IGrammar, options: TokenizerOption): monaco.languages.EncodedTokensProvider;
|
|
25
|
+
//# sourceMappingURL=textmate-tokenizer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"textmate-tokenizer.d.ts","sourceRoot":"","sources":["../src/textmate-tokenizer.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,MAAM,MAAM,6BAA6B,CAAC;AACtD,OAAO,KAAK,EAAE,QAAQ,EAAc,MAAM,iBAAiB,CAAC;AAG5D;;GAEG;AACH,MAAM,WAAW,eAAe;IAC9B;;;;;;OAMG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,yBAAiB,eAAe,CAAC;IAC/B;;;;OAIG;IACI,MAAM,OAAO,EAAE,eAErB,CAAC;CACH;AAED,wBAAgB,uBAAuB,CACrC,OAAO,EAAE,QAAQ,EACjB,OAAO,EAAE,eAAe,GACvB,MAAM,CAAC,SAAS,CAAC,qBAAqB,CAoBxC"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/* eslint-disable @typescript-eslint/no-namespace */
|
|
2
|
+
|
|
3
|
+
import { INITIAL } from 'vscode-textmate';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Options for the TextMate tokenizer.
|
|
7
|
+
*/
|
|
8
|
+
export var TokenizerOption;
|
|
9
|
+
(function (_TokenizerOption) {
|
|
10
|
+
var DEFAULT = _TokenizerOption.DEFAULT = {
|
|
11
|
+
lineLimit: 400
|
|
12
|
+
};
|
|
13
|
+
})(TokenizerOption || (TokenizerOption = {}));
|
|
14
|
+
export function createTextmateTokenizer(grammar, options) {
|
|
15
|
+
if (options.lineLimit !== undefined && (options.lineLimit <= 0 || !Number.isInteger(options.lineLimit))) {
|
|
16
|
+
throw new Error("The 'lineLimit' must be a positive integer. It was ".concat(options.lineLimit, "."));
|
|
17
|
+
}
|
|
18
|
+
return {
|
|
19
|
+
getInitialState: function getInitialState() {
|
|
20
|
+
return INITIAL;
|
|
21
|
+
},
|
|
22
|
+
tokenizeEncoded: function tokenizeEncoded(line, state) {
|
|
23
|
+
var tokenizeLineResult2 = grammar.tokenizeLine2(line, state);
|
|
24
|
+
var tokens = tokenizeLineResult2.tokens,
|
|
25
|
+
endState = tokenizeLineResult2.ruleStack;
|
|
26
|
+
return {
|
|
27
|
+
tokens: tokens,
|
|
28
|
+
endState: endState
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
};
|
|
32
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@difizen/libro-cofine-textmate",
|
|
3
|
+
"version": "0.1.2",
|
|
4
|
+
"description": "",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"libro",
|
|
7
|
+
"notebook",
|
|
8
|
+
"monaco"
|
|
9
|
+
],
|
|
10
|
+
"repository": "git@github.com:difizen/libro.git",
|
|
11
|
+
"license": "MIT",
|
|
12
|
+
"type": "module",
|
|
13
|
+
"exports": {
|
|
14
|
+
".": {
|
|
15
|
+
"typings": "./es/index.d.ts",
|
|
16
|
+
"default": "./es/index.js"
|
|
17
|
+
},
|
|
18
|
+
"./mock": {
|
|
19
|
+
"typings": "./es/mock/index.d.ts",
|
|
20
|
+
"default": "./es/mock/index.js"
|
|
21
|
+
},
|
|
22
|
+
"./es/mock": {
|
|
23
|
+
"typings": "./es/mock/index.d.ts",
|
|
24
|
+
"default": "./es/mock/index.js"
|
|
25
|
+
},
|
|
26
|
+
"./package.json": "./package.json"
|
|
27
|
+
},
|
|
28
|
+
"main": "es/index.js",
|
|
29
|
+
"module": "es/index.js",
|
|
30
|
+
"typings": "es/index.d.ts",
|
|
31
|
+
"files": [
|
|
32
|
+
"es",
|
|
33
|
+
"src"
|
|
34
|
+
],
|
|
35
|
+
"dependencies": {
|
|
36
|
+
"@difizen/libro-cofine-editor-core": "^0.1.2",
|
|
37
|
+
"@difizen/mana-app": "latest",
|
|
38
|
+
"fast-plist": "^0.1.2",
|
|
39
|
+
"vscode-oniguruma": "^1.5.1",
|
|
40
|
+
"vscode-textmate": "^9.0.0"
|
|
41
|
+
},
|
|
42
|
+
"devDependencies": {
|
|
43
|
+
"@difizen/monaco-editor-core": "latest",
|
|
44
|
+
"@types/debug": "^4.1.6"
|
|
45
|
+
},
|
|
46
|
+
"scripts": {
|
|
47
|
+
"setup": "father build",
|
|
48
|
+
"build": "father build",
|
|
49
|
+
"test": ": Note: lint task is delegated to test:* scripts",
|
|
50
|
+
"test:vitest": "vitest run",
|
|
51
|
+
"test:jest": "jest",
|
|
52
|
+
"coverage": ": Note: lint task is delegated to coverage:* scripts",
|
|
53
|
+
"coverage:vitest": "vitest run --coverage",
|
|
54
|
+
"coverage:jest": "jest --coverage",
|
|
55
|
+
"lint": ": Note: lint task is delegated to lint:* scripts",
|
|
56
|
+
"lint:eslint": "eslint src",
|
|
57
|
+
"lint:tsc": "tsc --noEmit"
|
|
58
|
+
}
|
|
59
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "vscode://schemas/color-theme",
|
|
3
|
+
"name": "Dark Default Colors",
|
|
4
|
+
"colors": {
|
|
5
|
+
"editor.background": "#1E1E1E",
|
|
6
|
+
"editor.foreground": "#D4D4D4",
|
|
7
|
+
"editor.inactiveSelectionBackground": "#3A3D41",
|
|
8
|
+
"editorIndentGuide.background": "#404040",
|
|
9
|
+
"editorIndentGuide.activeBackground": "#707070",
|
|
10
|
+
"editor.selectionHighlightBackground": "#ADD6FF26",
|
|
11
|
+
"list.dropBackground": "#383B3D",
|
|
12
|
+
"activityBarBadge.background": "#007ACC",
|
|
13
|
+
"sideBarTitle.foreground": "#BBBBBB",
|
|
14
|
+
"input.placeholderForeground": "#A6A6A6",
|
|
15
|
+
"settings.textInputBackground": "#292929",
|
|
16
|
+
"settings.numberInputBackground": "#292929",
|
|
17
|
+
"menu.background": "#252526",
|
|
18
|
+
"menu.foreground": "#CCCCCC",
|
|
19
|
+
"statusBarItem.remoteForeground": "#FFF",
|
|
20
|
+
"statusBarItem.remoteBackground": "#16825D"
|
|
21
|
+
},
|
|
22
|
+
"tokenColors": []
|
|
23
|
+
}
|