Skip to content

Commit

Permalink
Merge pull request #475 from CodinGame/vscode-1.92
Browse files Browse the repository at this point in the history
Update to VSCode 1.92
  • Loading branch information
CGNonofr authored Aug 7, 2024
2 parents eb4a325 + 23a1c24 commit 407ab69
Show file tree
Hide file tree
Showing 71 changed files with 2,257 additions and 2,078 deletions.
2,714 changes: 1,563 additions & 1,151 deletions demo/package-lock.json

Large diffs are not rendered by default.

11 changes: 7 additions & 4 deletions demo/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,14 @@
"devDependencies": {
"@codingame/esbuild-import-meta-url-plugin": "^1.0.2",
"@codingame/monaco-vscode-rollup-vsix-plugin": "file:../dist/rollup-vsix-plugin",
"@types/dockerode": "^3.3.29",
"@types/dockerode": "^3.3.31",
"@types/express": "^4.17.21",
"@types/node": "^20.11.4",
"@types/wicg-file-system-access": "^2023.10.5",
"@types/ws": "^8.5.10",
"@types/ws": "^8.5.12",
"ts-node": "^10.9.2",
"typescript": "~5.5.3",
"vite": "~5.3.3"
"typescript": "~5.5.4",
"vite": "~5.3.5"
},
"dependencies": {
"@codingame/monaco-vscode-accessibility-service-override": "file:../dist/service-override-accessibility",
Expand Down Expand Up @@ -192,6 +192,9 @@
"vscode": "file:../dist/main",
"ws": "^8.18.0"
},
"overrides": {
"esbuild": "0.21.5"
},
"volta": {
"node": "18.19.0",
"npm": "10.7.0"
Expand Down
256 changes: 128 additions & 128 deletions package-lock.json

Large diffs are not rendered by default.

38 changes: 19 additions & 19 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@
},
"config": {
"vscode": {
"version": "1.91.1",
"ref": "1.91.1",
"commit": "f1e16e1e6214d7c44d078b1f0607b2388f29d729"
"version": "1.92.0",
"ref": "1.92.0",
"commit": "b1c0a14de1414fcdaa400695b4db1c0799bc3124"
},
"monaco": {
"ref": "v0.50.0",
Expand All @@ -60,7 +60,7 @@
"@types/mime-types": "^2.1.4",
"@types/node": "18.19.8",
"@types/semver": "^7.5.8",
"@types/vscode": "~1.91.0",
"@types/vscode": "~1.92.0",
"@types/vscode-marked": "npm:@types/marked@^3.0.2",
"@types/vscode-semver": "npm:@types/semver@=5.5.0",
"@types/yargs": "^17.0.32",
Expand All @@ -78,17 +78,17 @@
"fast-glob": "^3.3.2",
"graceful-fs": "^4.2.11",
"js-cleanup": "^1.2.0",
"package-json": "^10.0.0",
"package-json": "^10.0.1",
"param-case": "^3.0.4",
"pascal-case": "^3.1.2",
"patch-package": "^8.0.0",
"recast": "^0.23.9",
"rollup": "^4.18.0",
"rollup": "^4.19.2",
"rollup-plugin-copy": "^3.5.0",
"rollup-plugin-dts": "^6.1.1",
"rollup-plugin-styles": "^4.0.0",
"semantic-release": "23.1.1",
"semver": "^7.6.2",
"semver": "^7.6.3",
"ts-morph": "^22.0.0",
"ts-node": "^10.9.2",
"type-fest": "^4.21.0",
Expand All @@ -104,24 +104,24 @@
"@parcel/watcher": "2.1.0",
"@rollup/pluginutils": "^5.1.0",
"@vscode/iconv-lite-umd": "0.7.0",
"@vscode/proxy-agent": "^0.21.0",
"@vscode/proxy-agent": "^0.22.0",
"@vscode/ripgrep": "^1.15.9",
"@vscode/spdlog": "^0.15.0",
"@vscode/vscode-languagedetection": "npm:@codingame/[email protected]",
"@vscode/windows-process-tree": "^0.6.0",
"@vscode/windows-registry": "^1.1.0",
"@xterm/addon-clipboard": "0.2.0-beta.4",
"@xterm/addon-image": "0.9.0-beta.21",
"@xterm/addon-search": "0.16.0-beta.21",
"@xterm/addon-serialize": "0.14.0-beta.21",
"@xterm/addon-unicode11": "0.9.0-beta.21",
"@xterm/addon-webgl": "0.19.0-beta.21",
"@xterm/headless": "5.6.0-beta.21",
"@xterm/xterm": "5.6.0-beta.21",
"@xterm/addon-clipboard": "0.2.0-beta.22",
"@xterm/addon-image": "0.9.0-beta.39",
"@xterm/addon-search": "0.16.0-beta.39",
"@xterm/addon-serialize": "0.14.0-beta.39",
"@xterm/addon-unicode11": "0.9.0-beta.39",
"@xterm/addon-webgl": "0.19.0-beta.39",
"@xterm/headless": "5.6.0-beta.39",
"@xterm/xterm": "5.6.0-beta.39",
"cookie": "^0.4.0",
"css-url-parser": "^1.1.3",
"jschardet": "3.1.2",
"kerberos": "^2.0.1",
"jschardet": "3.1.3",
"kerberos": "2.1.1-alpha.0",
"keytar": "^7.9.0",
"memfs": "^4.9.3",
"mime-types": "^2.1.35",
Expand All @@ -136,7 +136,7 @@
"typescript": "$typescript",
"rollup": "$rollup",
"recast": "$recast",
"@xterm/xterm": "5.6.0-beta.21",
"@xterm/xterm": "5.6.0-beta.39",
"eslint-plugin-n": "$eslint-plugin-n"
},
"volta": {
Expand Down
49 changes: 25 additions & 24 deletions rollup/rollup.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,6 @@ const PURE_FUNCTIONS = new Set([
'createDecorator',
'localize',
'localize2',
'localizeWithPath',
'localize2WithPath',
'Registry.as',
'Object.freeze',
'URI.parse',
Expand Down Expand Up @@ -158,9 +156,14 @@ function isCallPure (file: string, functionName: string, node: recast.types.name
return PURE_OR_TO_REMOVE_FUNCTIONS.has(functionName)
}

const moduleNlsKeys: Record<string, string[]> = {}
const nlsKeys: [moduleId: string, keys: string[]][] = []
let nlsIndex = -1

function transformVSCodeCode (id: string, code: string) {
const translationPath = nodePath.relative(id.startsWith(OVERRIDE_PATH) ? OVERRIDE_PATH : VSCODE_SRC_DIR, id)
.slice(0, -3) // remove extension
.replace(/\._[^/.]*/g, '') // remove own refactor module suffixes

// HACK: assign typescript decorator result to a decorated class field so rollup doesn't remove them
// before:
// __decorate([
Expand All @@ -174,6 +177,8 @@ function transformVSCodeCode (id: string, code: string) {

let patchedCode = code.replace(/(^__decorate\(\[\n.*\n\], (.*).prototype)/gm, '$2.__decorator = $1')

const moduleNlsKeys: string[] = []

const ast = recast.parse(patchedCode, {
parser: babylonParser
})
Expand All @@ -199,15 +204,12 @@ function transformVSCodeCode (id: string, code: string) {
const node = path.node
const name = node.callee.type === 'MemberExpression' || node.callee.type === 'Identifier' ? getMemberExpressionPath(node.callee) : null

if (name != null && (name.endsWith('localizeWithPath') || name.endsWith('localize2WithPath'))) {
const translationPath = nodePath.relative(id.startsWith(OVERRIDE_PATH) ? OVERRIDE_PATH : VSCODE_SRC_DIR, id)
.slice(0, -3) // remove extension
.replace(/\._[^/.]*/g, '') // remove own refactor module suffixes
if (name != null && (name.endsWith('localize') || name.endsWith('localize2'))) {
let localizationKey: string
if (path.node.arguments[1]?.type === 'StringLiteral') {
localizationKey = path.node.arguments[1].value
} else if (path.node.arguments[1]?.type === 'ObjectExpression') {
const properties = path.node.arguments[1].properties
if (path.node.arguments[0]?.type === 'StringLiteral') {
localizationKey = path.node.arguments[0].value
} else if (path.node.arguments[0]?.type === 'ObjectExpression') {
const properties = path.node.arguments[0].properties
const keyProperty = properties.find<recast.types.namedTypes.ObjectProperty>((prop): prop is recast.types.namedTypes.ObjectProperty => prop.type === 'ObjectProperty' && prop.key.type === 'Identifier' && prop.key.name === 'key')
if (keyProperty == null) {
throw new Error('No key property')
Expand All @@ -216,25 +218,19 @@ function transformVSCodeCode (id: string, code: string) {
throw new Error('Key property is not literal')
}
localizationKey = keyProperty.value.value
} else if (path.node.arguments[1]?.type === 'TemplateLiteral' && path.node.arguments[1].expressions.length === 0 && path.node.arguments[1].quasis.length === 1) {
localizationKey = path.node.arguments[1].quasis[0]!.value.raw
} else if (path.node.arguments[0]?.type === 'TemplateLiteral' && path.node.arguments[0].expressions.length === 0 && path.node.arguments[0].quasis.length === 1) {
localizationKey = path.node.arguments[0].quasis[0]!.value.raw
} else {
throw new Error('Unable to extract translation key')
}
let nlsKeys = moduleNlsKeys[translationPath]
if (nlsKeys == null) {
nlsKeys = []
moduleNlsKeys[translationPath] = nlsKeys
}

let index = nlsKeys.indexOf(localizationKey)
if (index < 0) {
index = nlsKeys.length
nlsKeys.push(localizationKey)
if (!moduleNlsKeys.includes(localizationKey)) {
moduleNlsKeys.push(localizationKey)
nlsIndex++
}
path.replace(recast.types.builders.callExpression(
path.node.callee,
[path.node.arguments[0]!, recast.types.builders.numericLiteral(index), ...path.node.arguments.slice(2)]
[recast.types.builders.numericLiteral(nlsIndex), ...path.node.arguments.slice(1)]
))
transformed = true
} else if (node.callee.type === 'MemberExpression') {
Expand Down Expand Up @@ -319,6 +315,11 @@ function transformVSCodeCode (id: string, code: string) {
patchedCode = recast.print(ast).code
patchedCode = patchedCode.replace(/\/\*#__PURE__\*\/\s+/g, '/*#__PURE__*/ ') // Remove space after PURE comment
}

if (moduleNlsKeys.length > 0) {
nlsKeys.push([translationPath, moduleNlsKeys])
}

return patchedCode
}

Expand Down Expand Up @@ -468,7 +469,7 @@ export default (args: Record<string, string>): rollup.RollupOptions[] => {
return code.replaceAll("'./keyboardLayouts/layout.contribution.' + platform", "'./keyboardLayouts/layout.contribution.' + platform + '.js'")
},
async writeBundle () {
await fs.promises.writeFile(nodePath.resolve(DIST_DIR, 'nls.metadata.json'), JSON.stringify(moduleNlsKeys, null, 2))
await fs.promises.writeFile(nodePath.resolve(DIST_DIR, 'nls.keys.json'), JSON.stringify(nlsKeys, null, 2))
}
},
{
Expand Down
13 changes: 5 additions & 8 deletions rollup/rollup.language-packs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ const locExtensions = fs.readdirSync(LOC_PATH, { withFileTypes: true })
.filter(f => f.isDirectory() && fs.existsSync(path.resolve(LOC_PATH, f.name, 'package.json')))
.map(f => f.name)

const nlsMetadata: Record<string, string[]> = JSON.parse((await fs.promises.readFile(path.resolve(DIST_DIR, 'nls.metadata.json'))).toString())
const nlsKeys: [string, string[]][] = JSON.parse((await fs.promises.readFile(path.resolve(DIST_DIR, 'nls.keys.json'))).toString())

export default rollup.defineConfig([
...locExtensions.map(name => (<rollup.RollupOptions>{
Expand Down Expand Up @@ -88,13 +88,10 @@ ${Object.entries(translationAssets).map(([id, assetRef]) => ` '${id}': new URL(

const parsed: Record<string, Record<string, string>> = JSON.parse(code).contents

const encoded = Object.fromEntries(Object.entries(nlsMetadata).map(([moduleId, keys]) => {
const values = parsed[moduleId] ?? {}
return [
moduleId,
keys.map(key => values[key])
]
}))
const encoded = nlsKeys.flatMap(([moduleId, keys]) => {
const moduleValues = parsed[moduleId]
return keys.map(key => moduleValues?.[key])
})

return {
code: dataToEsm(encoded, {
Expand Down
4 changes: 3 additions & 1 deletion scripts/install-vscode
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ cp -R .build/web/extensions "$extension_output_directory"
# Remove useless files
cd src
rm -rf `find . -name '*.test.ts' -o -name 'test' -o -name 'electron-browser'`
rm -f bootstrap*.js *main.js *cli.js
rm -rf vs/code
cd ..

Expand Down Expand Up @@ -90,11 +91,12 @@ mkdir -p $output_directory
echo $vscodeRef > $version_info

echo "Building vscode..."
NODE_OPTIONS=--max-old-space-size=8192 npx tsc --declaration --importHelpers --module es2020 --preserveConstEnums --outDir "$output_directory"
NODE_OPTIONS=--max-old-space-size=8192 npx tsc --declaration --importHelpers --module es2020 --preserveConstEnums --outDir "$output_directory/src" --rootDir .
# Copy files that are already built and assets
find ./ \( -name '*.js' -o -name '*.d.ts' -o -name '*.ttf' -o -name '*.css' -o -name '*.mp3' -o -name '*.svg' -o -name '*.png' -o -name '*.html' -o -name '*.sh' -o -name '*.zsh' -o -name '*.ps1' \) -exec rsync -R \{\} "$output_directory/src" \;

cd ..
cp package.json $output_directory
# Copy editor types
cp out-monaco-editor-core/esm/vs/editor/editor.api.d.ts $output_directory/src/vs/editor/editor.api.d.ts

Expand Down
Loading

1 comment on commit 407ab69

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.