mirror of
https://github.com/microsoft/monaco-editor.git
synced 2025-12-22 10:25:42 +01:00
Merge branch 'main' into main
This commit is contained in:
commit
75927c6de7
149 changed files with 92415 additions and 70714 deletions
|
|
@ -1,74 +1,74 @@
|
|||
|
||||
/// <reference path="../../references.js" />
|
||||
(function () {
|
||||
"use strict";
|
||||
|
||||
var deltaDecorations = function (oldDecorations, newDecorations) {
|
||||
/// <summary>
|
||||
/// Update oldDecorations to match newDecorations.
|
||||
/// It will remove old decorations which are not found in new decorations
|
||||
/// and add only the really new decorations.
|
||||
/// </summary>
|
||||
/// <param name="oldDecorations" type="Array">
|
||||
/// An array containing ids of existing decorations
|
||||
/// </param>
|
||||
/// <param name="newDecorations" type="Array">
|
||||
/// An array containing literal objects describing new decorations. A
|
||||
/// literal contains the following two fields:
|
||||
/// range
|
||||
/// options
|
||||
/// </param>
|
||||
/// <returns type="Array">
|
||||
/// Returns an array of decorations ids
|
||||
/// </returns>
|
||||
var hashFunc = function (range, options) {
|
||||
return range.startLineNumber + "," + range.startColumn + "-" + range.endLineNumber + "," + range.endColumn +
|
||||
"-" + options.hoverMessage + "-" + options.className + "-" + options.isOverlay + "-" + options.showInOverviewRuler;
|
||||
};
|
||||
return this.changeDecorations(function (changeAccessor) {
|
||||
var i, len, oldDecorationsMap = {}, hash;
|
||||
|
||||
// Record old decorations in a map
|
||||
// Two decorations can have the same hash
|
||||
for (i = 0, len = oldDecorations.length; i < len; i++) {
|
||||
hash = hashFunc(this.getDecorationRange(oldDecorations[i]), this.getDecorationOptions(oldDecorations[i]));
|
||||
oldDecorationsMap[hash] = oldDecorationsMap[hash] || [];
|
||||
oldDecorationsMap[hash].push(oldDecorations[i]);
|
||||
}
|
||||
|
||||
// Add only new decorations & mark reused ones
|
||||
var j, lenJ, result = [], usedOldDecorations = {}, oldDecorationsCandidates, reusedOldDecoration;
|
||||
for (i = 0, len = newDecorations.length; i < len; i++) {
|
||||
hash = hashFunc(newDecorations[i].range, newDecorations[i].options);
|
||||
reusedOldDecoration = false;
|
||||
if (oldDecorationsMap.hasOwnProperty(hash)) {
|
||||
oldDecorationsCandidates = oldDecorationsMap[hash];
|
||||
// We can try reusing an old decoration (if it hasn't been reused before)
|
||||
for (j = 0, lenJ = oldDecorationsCandidates.length; j < lenJ; j++) {
|
||||
if (!usedOldDecorations.hasOwnProperty(oldDecorationsCandidates[j])) {
|
||||
// Found an old decoration which can be reused & it hasn't been reused before
|
||||
reusedOldDecoration = true;
|
||||
usedOldDecorations[oldDecorationsCandidates[j]] = true;
|
||||
result.push(oldDecorationsCandidates[j]);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!reusedOldDecoration) {
|
||||
result.push(changeAccessor.addDecoration(newDecorations[i].range, newDecorations[i].options));
|
||||
}
|
||||
}
|
||||
|
||||
// Remove unused old decorations
|
||||
for (i = 0, len = oldDecorations.length; i < len; i++) {
|
||||
if (!usedOldDecorations.hasOwnProperty(oldDecorations[i])) {
|
||||
changeAccessor.removeDecoration(oldDecorations[i]);
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}.bind(this));
|
||||
};
|
||||
|
||||
})();
|
||||
|
||||
/// <reference path="../../references.js" />
|
||||
(function () {
|
||||
"use strict";
|
||||
|
||||
var deltaDecorations = function (oldDecorations, newDecorations) {
|
||||
/// <summary>
|
||||
/// Update oldDecorations to match newDecorations.
|
||||
/// It will remove old decorations which are not found in new decorations
|
||||
/// and add only the really new decorations.
|
||||
/// </summary>
|
||||
/// <param name="oldDecorations" type="Array">
|
||||
/// An array containing ids of existing decorations
|
||||
/// </param>
|
||||
/// <param name="newDecorations" type="Array">
|
||||
/// An array containing literal objects describing new decorations. A
|
||||
/// literal contains the following two fields:
|
||||
/// range
|
||||
/// options
|
||||
/// </param>
|
||||
/// <returns type="Array">
|
||||
/// Returns an array of decorations ids
|
||||
/// </returns>
|
||||
var hashFunc = function (range, options) {
|
||||
return range.startLineNumber + "," + range.startColumn + "-" + range.endLineNumber + "," + range.endColumn +
|
||||
"-" + options.hoverMessage + "-" + options.className + "-" + options.isOverlay + "-" + options.showInOverviewRuler;
|
||||
};
|
||||
return this.changeDecorations(function (changeAccessor) {
|
||||
var i, len, oldDecorationsMap = {}, hash;
|
||||
|
||||
// Record old decorations in a map
|
||||
// Two decorations can have the same hash
|
||||
for (i = 0, len = oldDecorations.length; i < len; i++) {
|
||||
hash = hashFunc(this.getDecorationRange(oldDecorations[i]), this.getDecorationOptions(oldDecorations[i]));
|
||||
oldDecorationsMap[hash] = oldDecorationsMap[hash] || [];
|
||||
oldDecorationsMap[hash].push(oldDecorations[i]);
|
||||
}
|
||||
|
||||
// Add only new decorations & mark reused ones
|
||||
var j, lenJ, result = [], usedOldDecorations = {}, oldDecorationsCandidates, reusedOldDecoration;
|
||||
for (i = 0, len = newDecorations.length; i < len; i++) {
|
||||
hash = hashFunc(newDecorations[i].range, newDecorations[i].options);
|
||||
reusedOldDecoration = false;
|
||||
if (oldDecorationsMap.hasOwnProperty(hash)) {
|
||||
oldDecorationsCandidates = oldDecorationsMap[hash];
|
||||
// We can try reusing an old decoration (if it hasn't been reused before)
|
||||
for (j = 0, lenJ = oldDecorationsCandidates.length; j < lenJ; j++) {
|
||||
if (!usedOldDecorations.hasOwnProperty(oldDecorationsCandidates[j])) {
|
||||
// Found an old decoration which can be reused & it hasn't been reused before
|
||||
reusedOldDecoration = true;
|
||||
usedOldDecorations[oldDecorationsCandidates[j]] = true;
|
||||
result.push(oldDecorationsCandidates[j]);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!reusedOldDecoration) {
|
||||
result.push(changeAccessor.addDecoration(newDecorations[i].range, newDecorations[i].options));
|
||||
}
|
||||
}
|
||||
|
||||
// Remove unused old decorations
|
||||
for (i = 0, len = oldDecorations.length; i < len; i++) {
|
||||
if (!usedOldDecorations.hasOwnProperty(oldDecorations[i])) {
|
||||
changeAccessor.removeDecoration(oldDecorations[i]);
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}.bind(this));
|
||||
};
|
||||
|
||||
})();
|
||||
|
|
|
|||
|
|
@ -1,61 +1,61 @@
|
|||
/// <reference path="../../references.js" />
|
||||
(function () {
|
||||
"use strict";
|
||||
|
||||
// Some useless comment
|
||||
|
||||
var deltaDecorations = function (oldDecorations, newDecorations) {
|
||||
/// <summary>
|
||||
/// Update oldDecorations to match newDecorations.
|
||||
/// It will remove old decorations which are not found in new decorations
|
||||
/// and add only the really new decorations.
|
||||
/// </summary>
|
||||
/// <param name="oldDecorations" type="Array">
|
||||
/// An array containing ids of existing decorations
|
||||
/// </param>
|
||||
/// <param name="newDecorations" type="Array">
|
||||
/// An array containing literal objects describing new decorations. A
|
||||
/// literal contains the following two fields:
|
||||
/// range
|
||||
/// options
|
||||
/// </param>
|
||||
/// <returns type="Array">
|
||||
/// Returns an array of decorations ids
|
||||
/// </returns>
|
||||
var hashFunc = function (range, options) {
|
||||
return range.startLineNumber + "," + range.startColumn + "-" + range.endLineNumber + "," + range.endColumn +
|
||||
"-" + options.hoverMessage + "-" + options.className + "-" + options.isOverlay + "-" + options.showInOverviewRuler;
|
||||
};
|
||||
return this.changeDecorations(function (changeAccessor) {
|
||||
var i, len, oldDecorationsMap = {}, hash;
|
||||
|
||||
// Record old decorations in a map
|
||||
for (i = 0, len = oldDecorations.length; i < len; i++) {
|
||||
hash = hashFunc(this.getDecorationRange(oldDecorations[i]), this.getDecorationOptions(oldDecorations[i]));
|
||||
oldDecorationsMap[hash] = i;
|
||||
}
|
||||
|
||||
// Add only new decorations & mark reused ones
|
||||
var result = [], usedOldDecorationsMap = {};
|
||||
for (i = 0, len = newDecorations.length; i < len; i++) {
|
||||
hash = hashFunc(newDecorations[i].range, newDecorations[i].options);
|
||||
if (oldDecorationsMap.hasOwnProperty(hash)) {
|
||||
usedOldDecorationsMap[oldDecorationsMap[hash]] = true;
|
||||
result.push(oldDecorations[oldDecorationsMap[hash]]);
|
||||
} else {
|
||||
result.push(changeAccessor.addDecoration(newDecorations[i].range, newDecorations[i].options));
|
||||
}
|
||||
}
|
||||
|
||||
// Remove unused old decorations
|
||||
for (i = 0, len = oldDecorations.length; i < len; i++) {
|
||||
if (!usedOldDecorationsMap.hasOwnProperty(i)) {
|
||||
changeAccessor.removeDecoration(oldDecorations[i]);
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}.bind(this));
|
||||
};
|
||||
|
||||
})();
|
||||
/// <reference path="../../references.js" />
|
||||
(function () {
|
||||
"use strict";
|
||||
|
||||
// Some useless comment
|
||||
|
||||
var deltaDecorations = function (oldDecorations, newDecorations) {
|
||||
/// <summary>
|
||||
/// Update oldDecorations to match newDecorations.
|
||||
/// It will remove old decorations which are not found in new decorations
|
||||
/// and add only the really new decorations.
|
||||
/// </summary>
|
||||
/// <param name="oldDecorations" type="Array">
|
||||
/// An array containing ids of existing decorations
|
||||
/// </param>
|
||||
/// <param name="newDecorations" type="Array">
|
||||
/// An array containing literal objects describing new decorations. A
|
||||
/// literal contains the following two fields:
|
||||
/// range
|
||||
/// options
|
||||
/// </param>
|
||||
/// <returns type="Array">
|
||||
/// Returns an array of decorations ids
|
||||
/// </returns>
|
||||
var hashFunc = function (range, options) {
|
||||
return range.startLineNumber + "," + range.startColumn + "-" + range.endLineNumber + "," + range.endColumn +
|
||||
"-" + options.hoverMessage + "-" + options.className + "-" + options.isOverlay + "-" + options.showInOverviewRuler;
|
||||
};
|
||||
return this.changeDecorations(function (changeAccessor) {
|
||||
var i, len, oldDecorationsMap = {}, hash;
|
||||
|
||||
// Record old decorations in a map
|
||||
for (i = 0, len = oldDecorations.length; i < len; i++) {
|
||||
hash = hashFunc(this.getDecorationRange(oldDecorations[i]), this.getDecorationOptions(oldDecorations[i]));
|
||||
oldDecorationsMap[hash] = i;
|
||||
}
|
||||
|
||||
// Add only new decorations & mark reused ones
|
||||
var result = [], usedOldDecorationsMap = {};
|
||||
for (i = 0, len = newDecorations.length; i < len; i++) {
|
||||
hash = hashFunc(newDecorations[i].range, newDecorations[i].options);
|
||||
if (oldDecorationsMap.hasOwnProperty(hash)) {
|
||||
usedOldDecorationsMap[oldDecorationsMap[hash]] = true;
|
||||
result.push(oldDecorations[oldDecorationsMap[hash]]);
|
||||
} else {
|
||||
result.push(changeAccessor.addDecoration(newDecorations[i].range, newDecorations[i].options));
|
||||
}
|
||||
}
|
||||
|
||||
// Remove unused old decorations
|
||||
for (i = 0, len = oldDecorations.length; i < len; i++) {
|
||||
if (!usedOldDecorationsMap.hasOwnProperty(i)) {
|
||||
changeAccessor.removeDecoration(oldDecorations[i]);
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}.bind(this));
|
||||
};
|
||||
|
||||
})();
|
||||
|
|
|
|||
|
|
@ -7,9 +7,9 @@
|
|||
|
||||
const esbuild = require('esbuild');
|
||||
const path = require('path');
|
||||
const { removeDir } = require('../../build/fs');
|
||||
const fs = require('fs');
|
||||
|
||||
removeDir('samples/browser-esm-esbuild/dist', (entry) => /index.html$/.test(entry));
|
||||
removeDir('dist', (entry) => /index.html$/.test(entry));
|
||||
|
||||
const workerEntryPoints = [
|
||||
'vs/language/json/json.worker.js',
|
||||
|
|
@ -50,3 +50,47 @@ function build(opts) {
|
|||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove a directory and all its contents.
|
||||
* @param {string} _dirPath
|
||||
* @param {(filename: string) => boolean} [keep]
|
||||
*/
|
||||
function removeDir(_dirPath, keep) {
|
||||
if (typeof keep === 'undefined') {
|
||||
keep = () => false;
|
||||
}
|
||||
const dirPath = path.join(__dirname, _dirPath);
|
||||
if (!fs.existsSync(dirPath)) {
|
||||
return;
|
||||
}
|
||||
rmDir(dirPath, _dirPath);
|
||||
console.log(`Deleted ${_dirPath}`);
|
||||
|
||||
/**
|
||||
* @param {string} dirPath
|
||||
* @param {string} relativeDirPath
|
||||
* @returns {boolean}
|
||||
*/
|
||||
function rmDir(dirPath, relativeDirPath) {
|
||||
let keepsFiles = false;
|
||||
const entries = fs.readdirSync(dirPath);
|
||||
for (const entry of entries) {
|
||||
const filePath = path.join(dirPath, entry);
|
||||
const relativeFilePath = path.join(relativeDirPath, entry);
|
||||
if (keep(relativeFilePath)) {
|
||||
keepsFiles = true;
|
||||
continue;
|
||||
}
|
||||
if (fs.statSync(filePath).isFile()) {
|
||||
fs.unlinkSync(filePath);
|
||||
} else {
|
||||
keepsFiles = rmDir(filePath, relativeFilePath) || keepsFiles;
|
||||
}
|
||||
}
|
||||
if (!keepsFiles) {
|
||||
fs.rmdirSync(dirPath);
|
||||
}
|
||||
return keepsFiles;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
7982
samples/browser-esm-parcel/package-lock.json
generated
7982
samples/browser-esm-parcel/package-lock.json
generated
File diff suppressed because it is too large
Load diff
|
|
@ -4,7 +4,7 @@
|
|||
"start": "parcel ./src/index.html"
|
||||
},
|
||||
"devDependencies": {
|
||||
"monaco-editor": "^0.31.0",
|
||||
"parcel": "^2.0.1"
|
||||
"monaco-editor": "^0.32.0",
|
||||
"parcel": "^2.2.1"
|
||||
}
|
||||
}
|
||||
|
|
|
|||
2126
samples/browser-esm-vite-react/package-lock.json
generated
2126
samples/browser-esm-vite-react/package-lock.json
generated
File diff suppressed because it is too large
Load diff
|
|
@ -8,13 +8,13 @@
|
|||
},
|
||||
"dependencies": {},
|
||||
"devDependencies": {
|
||||
"monaco-editor": "^0.31.0",
|
||||
"monaco-editor": "^0.32.0",
|
||||
"react": "^17.0.2",
|
||||
"react-dom": "^17.0.2",
|
||||
"@types/react": "^17.0.35",
|
||||
"@types/react": "^17.0.39",
|
||||
"@types/react-dom": "^17.0.11",
|
||||
"@vitejs/plugin-react": "^1.0.9",
|
||||
"typescript": "^4.4.4",
|
||||
"vite": "^2.6.14"
|
||||
"@vitejs/plugin-react": "^1.1.4",
|
||||
"typescript": "^4.5.5",
|
||||
"vite": "^2.7.13"
|
||||
}
|
||||
}
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load diff
|
|
@ -6,12 +6,12 @@
|
|||
},
|
||||
"dependencies": {},
|
||||
"devDependencies": {
|
||||
"@babel/core": "^7.16.0",
|
||||
"@babel/preset-env": "^7.16.0",
|
||||
"@babel/preset-react": "^7.16.0",
|
||||
"@babel/preset-typescript": "^7.16.0",
|
||||
"@pmmmwh/react-refresh-webpack-plugin": "^0.5.1",
|
||||
"@types/react": "^17.0.35",
|
||||
"@babel/core": "^7.17.0",
|
||||
"@babel/preset-env": "^7.16.11",
|
||||
"@babel/preset-react": "^7.16.7",
|
||||
"@babel/preset-typescript": "^7.16.7",
|
||||
"@pmmmwh/react-refresh-webpack-plugin": "^0.5.4",
|
||||
"@types/react": "^17.0.39",
|
||||
"@types/react-dom": "^17.0.11",
|
||||
"babel-loader": "^8.2.3",
|
||||
"react": "^17.0.2",
|
||||
|
|
|
|||
4
samples/browser-esm-webpack/.gitignore
vendored
4
samples/browser-esm-webpack/.gitignore
vendored
|
|
@ -1,2 +1,2 @@
|
|||
dist/*.js
|
||||
dist/*.ttf
|
||||
dist/*.js
|
||||
dist/*.ttf
|
||||
|
|
|
|||
4
samples/electron-esm-webpack/.gitignore
vendored
4
samples/electron-esm-webpack/.gitignore
vendored
|
|
@ -1,2 +1,2 @@
|
|||
/dist/*.js
|
||||
/dist/*.ttf
|
||||
/dist/*.js
|
||||
/dist/*.ttf
|
||||
|
|
|
|||
6327
samples/package-lock.json
generated
6327
samples/package-lock.json
generated
File diff suppressed because it is too large
Load diff
|
|
@ -11,19 +11,19 @@
|
|||
"license": "MIT",
|
||||
"devDependencies": {
|
||||
"css-loader": "^5.2.7",
|
||||
"electron": "^15.3.1",
|
||||
"electron": "^17.2.0",
|
||||
"file-loader": "^6.2.0",
|
||||
"glob": "^7.2.0",
|
||||
"html-webpack-plugin": "^5.5.0",
|
||||
"monaco-editor-webpack-plugin": "^7.0.1",
|
||||
"monaco-editor": "^0.31.1",
|
||||
"monaco-editor": "^0.32.1",
|
||||
"style-loader": "^3.3.1",
|
||||
"terser-webpack-plugin": "^5.2.5",
|
||||
"terser-webpack-plugin": "^5.3.1",
|
||||
"ts-loader": "^9.2.6",
|
||||
"typescript": "^4.4.4",
|
||||
"webpack-cli": "^4.9.1",
|
||||
"webpack-dev-server": "^4.5.0",
|
||||
"webpack": "^5.64.1",
|
||||
"typescript": "^4.5.5",
|
||||
"webpack-cli": "^4.9.2",
|
||||
"webpack-dev-server": "^4.7.4",
|
||||
"webpack": "^5.68.0",
|
||||
"yaserver": "^0.4.0"
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue