@codingame/monaco-vscode-standalone-html-language-features 23.1.1 → 23.2.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/common/initialize.js +11 -0
- package/common/workers.js +69 -0
- package/html.worker.js +8 -0
- package/index.js +21 -58
- package/language/common/lspLanguageFeatures.js +644 -0
- package/language/html/htmlMode.js +141 -0
- package/language/html/htmlWorker.js +126 -0
- package/language/html/workerManager.js +64 -0
- package/package.json +5 -2
- package/worker.js +2 -16155
- package/htmlMode.js +0 -2108
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import { editor } from 'monaco-editor';
|
|
2
|
+
|
|
3
|
+
function createTrustedTypesPolicy(policyName, policyOptions) {
|
|
4
|
+
const monacoEnvironment = globalThis.MonacoEnvironment;
|
|
5
|
+
if (monacoEnvironment?.createTrustedTypesPolicy) {
|
|
6
|
+
try {
|
|
7
|
+
return monacoEnvironment.createTrustedTypesPolicy(policyName, policyOptions);
|
|
8
|
+
} catch (err) {
|
|
9
|
+
console.error(err);
|
|
10
|
+
return void 0;
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
try {
|
|
14
|
+
return globalThis.trustedTypes?.createPolicy(policyName, policyOptions);
|
|
15
|
+
} catch (err) {
|
|
16
|
+
console.error(err);
|
|
17
|
+
return void 0;
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
let ttPolicy;
|
|
21
|
+
if (typeof self === "object" && self.constructor && self.constructor.name === "DedicatedWorkerGlobalScope" && globalThis.workerttPolicy !== void 0) {
|
|
22
|
+
ttPolicy = globalThis.workerttPolicy;
|
|
23
|
+
} else {
|
|
24
|
+
ttPolicy = createTrustedTypesPolicy("defaultWorkerFactory", {
|
|
25
|
+
createScriptURL: (value) => value
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
function getWorker(descriptor) {
|
|
29
|
+
const label = descriptor.label;
|
|
30
|
+
const monacoEnvironment = globalThis.MonacoEnvironment;
|
|
31
|
+
if (monacoEnvironment) {
|
|
32
|
+
if (typeof monacoEnvironment.getWorker === "function") {
|
|
33
|
+
return monacoEnvironment.getWorker("workerMain.js", label);
|
|
34
|
+
}
|
|
35
|
+
if (typeof monacoEnvironment.getWorkerUrl === "function") {
|
|
36
|
+
const workerUrl = monacoEnvironment.getWorkerUrl("workerMain.js", label);
|
|
37
|
+
return new Worker(
|
|
38
|
+
ttPolicy ? ttPolicy.createScriptURL(workerUrl) : workerUrl,
|
|
39
|
+
{ name: label, type: "module" }
|
|
40
|
+
);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
if (descriptor.createWorker) {
|
|
44
|
+
return descriptor.createWorker();
|
|
45
|
+
}
|
|
46
|
+
throw new Error(
|
|
47
|
+
`You must define a function MonacoEnvironment.getWorkerUrl or MonacoEnvironment.getWorker`
|
|
48
|
+
);
|
|
49
|
+
}
|
|
50
|
+
function createWebWorker(opts) {
|
|
51
|
+
const worker = Promise.resolve(
|
|
52
|
+
getWorker({
|
|
53
|
+
label: opts.label ?? "monaco-editor-worker",
|
|
54
|
+
moduleId: opts.moduleId,
|
|
55
|
+
createWorker: opts.createWorker
|
|
56
|
+
})
|
|
57
|
+
).then((w) => {
|
|
58
|
+
w.postMessage("ignore");
|
|
59
|
+
w.postMessage(opts.createData);
|
|
60
|
+
return w;
|
|
61
|
+
});
|
|
62
|
+
return editor.createWebWorker({
|
|
63
|
+
worker,
|
|
64
|
+
host: opts.host,
|
|
65
|
+
keepIdleModels: opts.keepIdleModels
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
export { createWebWorker };
|
package/html.worker.js
ADDED
package/index.js
CHANGED
|
@@ -1,34 +1,8 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { languages, Emitter } from 'monaco-editor';
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
5
|
-
* Version: 0.54.0(undefined)
|
|
6
|
-
* Released under the MIT license
|
|
7
|
-
* https://github.com/microsoft/monaco-editor/blob/main/LICENSE.txt
|
|
8
|
-
*-----------------------------------------------------------------------------*/
|
|
9
|
-
|
|
10
|
-
var __defProp = Object.defineProperty;
|
|
11
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
12
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
13
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
14
|
-
var __copyProps = (to, from, except, desc) => {
|
|
15
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
16
|
-
for (let key of __getOwnPropNames(from))
|
|
17
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
18
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
19
|
-
}
|
|
20
|
-
return to;
|
|
21
|
-
};
|
|
22
|
-
var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget);
|
|
23
|
-
|
|
24
|
-
// src/fillers/monaco-editor-core.ts
|
|
25
|
-
var monaco_editor_core_exports = {};
|
|
26
|
-
__reExport(monaco_editor_core_exports, monaco_editor_core_star);
|
|
27
|
-
|
|
28
|
-
// src/language/html/monaco.contribution.ts
|
|
29
|
-
var LanguageServiceDefaultsImpl = class {
|
|
3
|
+
class LanguageServiceDefaultsImpl {
|
|
30
4
|
constructor(languageId, options, modeConfiguration) {
|
|
31
|
-
this._onDidChange = new
|
|
5
|
+
this._onDidChange = new Emitter();
|
|
32
6
|
this._languageId = languageId;
|
|
33
7
|
this.setOptions(options);
|
|
34
8
|
this.setModeConfiguration(modeConfiguration);
|
|
@@ -53,8 +27,8 @@ var LanguageServiceDefaultsImpl = class {
|
|
|
53
27
|
this._modeConfiguration = modeConfiguration || /* @__PURE__ */ Object.create(null);
|
|
54
28
|
this._onDidChange.fire(this);
|
|
55
29
|
}
|
|
56
|
-
}
|
|
57
|
-
|
|
30
|
+
}
|
|
31
|
+
const formatDefaults = {
|
|
58
32
|
tabSize: 4,
|
|
59
33
|
insertSpaces: false,
|
|
60
34
|
wrapLineLength: 120,
|
|
@@ -68,7 +42,7 @@ var formatDefaults = {
|
|
|
68
42
|
extraLiners: "head, body, /html",
|
|
69
43
|
wrapAttributes: "auto"
|
|
70
44
|
};
|
|
71
|
-
|
|
45
|
+
const optionsDefault = {
|
|
72
46
|
format: formatDefaults,
|
|
73
47
|
suggest: {},
|
|
74
48
|
data: { useDefaultDataProvider: true }
|
|
@@ -92,53 +66,42 @@ function getConfigurationDefault(languageId) {
|
|
|
92
66
|
// turned off for Razor and Handlebar
|
|
93
67
|
};
|
|
94
68
|
}
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
69
|
+
const htmlLanguageId = "html";
|
|
70
|
+
const handlebarsLanguageId = "handlebars";
|
|
71
|
+
const razorLanguageId = "razor";
|
|
72
|
+
const htmlLanguageService = registerHTMLLanguageService(
|
|
99
73
|
htmlLanguageId,
|
|
100
74
|
optionsDefault,
|
|
101
75
|
getConfigurationDefault(htmlLanguageId)
|
|
102
76
|
);
|
|
103
|
-
|
|
104
|
-
|
|
77
|
+
const htmlDefaults = htmlLanguageService.defaults;
|
|
78
|
+
const handlebarLanguageService = registerHTMLLanguageService(
|
|
105
79
|
handlebarsLanguageId,
|
|
106
80
|
optionsDefault,
|
|
107
81
|
getConfigurationDefault(handlebarsLanguageId)
|
|
108
82
|
);
|
|
109
|
-
|
|
110
|
-
|
|
83
|
+
const handlebarDefaults = handlebarLanguageService.defaults;
|
|
84
|
+
const razorLanguageService = registerHTMLLanguageService(
|
|
111
85
|
razorLanguageId,
|
|
112
86
|
optionsDefault,
|
|
113
87
|
getConfigurationDefault(razorLanguageId)
|
|
114
88
|
);
|
|
115
|
-
|
|
116
|
-
monaco_editor_core_exports.languages.html = {
|
|
117
|
-
htmlDefaults,
|
|
118
|
-
razorDefaults,
|
|
119
|
-
handlebarDefaults,
|
|
120
|
-
htmlLanguageService,
|
|
121
|
-
handlebarLanguageService,
|
|
122
|
-
razorLanguageService,
|
|
123
|
-
registerHTMLLanguageService
|
|
124
|
-
};
|
|
89
|
+
const razorDefaults = razorLanguageService.defaults;
|
|
125
90
|
function getMode() {
|
|
126
|
-
|
|
127
|
-
return import('./htmlMode.js');
|
|
128
|
-
}
|
|
91
|
+
return import('./language/html/htmlMode.js');
|
|
129
92
|
}
|
|
130
93
|
function registerHTMLLanguageService(languageId, options = optionsDefault, modeConfiguration = getConfigurationDefault(languageId)) {
|
|
131
94
|
const defaults = new LanguageServiceDefaultsImpl(languageId, options, modeConfiguration);
|
|
132
|
-
let
|
|
133
|
-
const onLanguageListener =
|
|
134
|
-
|
|
95
|
+
let mode2;
|
|
96
|
+
const onLanguageListener = languages.onLanguage(languageId, async () => {
|
|
97
|
+
mode2 = (await getMode()).setupMode(defaults);
|
|
135
98
|
});
|
|
136
99
|
return {
|
|
137
100
|
defaults,
|
|
138
101
|
dispose() {
|
|
139
102
|
onLanguageListener.dispose();
|
|
140
|
-
|
|
141
|
-
|
|
103
|
+
mode2?.dispose();
|
|
104
|
+
mode2 = void 0;
|
|
142
105
|
}
|
|
143
106
|
};
|
|
144
107
|
}
|