Skip to content

Commit

Permalink
Add xml highlighting for ui & qrc files
Browse files Browse the repository at this point in the history
* Update package.json scripts for `esbuild.mjs`
* Add `esbuild.mjs`. Since webview ui toolkit is used, it needs to be
build as a module separately.
* Use xml highlighting for ui and qrc files
* Add icons
* Remove redundant `file-ext-qrc.ts` file
* Remove redundant nolint usage
* Remove activations events for `.pro` files
* Make `prettier` silent

Change-Id: I51f9a5a4b1682df43b898850a562912181743a87
Reviewed-by: Marcus Tillmanns <marcus.tillmanns@qt.io>
  • Loading branch information
OrkunTokdemir committed Mar 21, 2024
1 parent 80a5b8e commit 48f0c73
Show file tree
Hide file tree
Showing 19 changed files with 1,380 additions and 44 deletions.
1 change: 1 addition & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
.eslintrc.cjs
esbuild.mjs
62 changes: 62 additions & 0 deletions esbuild.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
// Copyright (C) 2024 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only

import { build, context} from 'esbuild';

/** @type BuildOptions */
const baseConfig = {
bundle: true,
minify: process.env.NODE_ENV === 'production',
sourcemap: process.env.NODE_ENV !== 'production'
};

// Config for extension source code (to be run in a Node-based context)
/** @type BuildOptions */
const extensionConfig = {
...baseConfig,
platform: 'node',
mainFields: ['module', 'main'],
tsconfig: './tsconfig.json',
format: 'cjs',
entryPoints: ['./src/extension.ts'],
outfile: './out/extension.js',
external: ['vscode']
};

// Config for webview source code (to be run in a web-based context)
/** @type BuildOptions */
const webviewConfig = {
...baseConfig,
target: 'es2020',
format: 'esm',
entryPoints: ['./src/editors/ui/webview-ui/main.ts'],
outfile: './out/editors/ui/webview-ui/main.js'
};

// Build script
(async () => {
const args = process.argv.slice(2);
try {
if (args.includes('--watch')) {
const extCtx = await context({
...extensionConfig
});
await extCtx.watch();
await extCtx.dispose();
const webCtx = await context({
...webviewConfig
});
await webCtx.watch();
await webCtx.dispose();
console.log('[watch] build finished');
} else {
// Build extension and webview code
await build(extensionConfig);
await build(webviewConfig);
console.log('build complete');
}
} catch (err) {
process.stderr.write(err.stderr);
process.exit(1);
}
})();
102 changes: 101 additions & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

53 changes: 42 additions & 11 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@
"Other"
],
"activationEvents": [
"workspaceContains:*.pro",
"workspaceContains:*.qrc",
"workspaceContains:*.qdoc",
"workspaceContains:*.ui",
"onCommand:cmake.activeFolderName",
"onCommand:cmake.activeFolderPath",
"onCommand:cmake.activeConfigurePresetName",
Expand Down Expand Up @@ -164,6 +164,21 @@
]
}
],
"customEditors": [
{
"viewType": "qt.uiEditor",
"displayName": "Qt UI Editor",
"extensions": [
".ui"
],
"priority": "default",
"selector": [
{
"filenamePattern": "*.ui"
}
]
}
],
"languages": [
{
"id": "pro",
Expand All @@ -176,13 +191,18 @@
},
{
"id": "qrc",
"configuration": "./res/lang/qrc/language-configuration.json",
"extensions": [
".qrc",
".qrc.cmakein"
],
"aliases": [
"Qrc"
]
],
"icon": {
"light": "res/icons/qrc.png",
"dark": "res/icons/qrc.png"
}
},
{
"id": "qdoc",
Expand All @@ -200,15 +220,16 @@
},
{
"id": "ui",
"configuration": "./res/lang/ui/language-configuration.json",
"extensions": [
".ui"
],
"aliases": [
"Ui"
"ui"
],
"icon": {
"light": "res/icons/qt.svg",
"dark": "res/icons/qt.svg"
"light": "res/icons/ui.svg",
"dark": "res/icons/ui.svg"
}
}
],
Expand Down Expand Up @@ -244,6 +265,16 @@
"language": "qdoc",
"scopeName": "source.qdoc",
"path": "./res/lang/qdoc/qdoc.tmLanguage.json"
},
{
"language": "ui",
"scopeName": "source.ui",
"path": "./res/lang/ui/ui.tmLanguage.json"
},
{
"language": "qrc",
"scopeName": "source.qrc",
"path": "./res/lang/qrc/qrc.tmLanguage.json"
}
],
"configuration": {
Expand All @@ -269,25 +300,24 @@
"ms-vscode.cmake-tools"
],
"scripts": {
"vscode:prepublish": "npm run esbuild-base -- --minify",
"esbuild-base": "esbuild ./src/extension.ts --bundle --tsconfig=./tsconfig.json --outfile=out/extension.js --external:vscode --format=cjs --platform=node",
"compile": "tsc -p ./",
"watch": "tsc -watch -p ./",
"vscode:prepublish": "NODE_ENV=production node ./esbuild.mjs",
"compile": "node ./esbuild.mjs",
"watch": "node ./esbuild.mjs --watch",
"pretest": "npm run compile && npm run lint",
"lint": "npm run prettier && npx eslint . --fix",
"unitTests": "npm run pretest && node ./out/test/unit/runTest.js",
"integrationTests": "npm run pretest && node ./out/test/integration/runTest.js",
"allTests": "ts-node ./src/scripts/run_all_tests.ts",
"prettier": "prettier --write \"**/*.{js,ts,json}\"",
"prettier": "prettier --write \"**/*.{js,ts,json}\" --log-level silent",
"package": "npm ci && vsce package --out out"
},
"devDependencies": {
"@types/chai": "^4.3.10",
"@types/command-exists": "^1.2.3",
"@types/glob": "^8.1.0",
"@types/mocha": "^10.0.1",
"@types/node": "^20.2.5",
"@types/vscode": "^1.78.0",
"@types/command-exists": "^1.2.3",
"@typescript-eslint/eslint-plugin": "^6.7.3",
"@typescript-eslint/parser": "^6.7.3",
"@vscode/l10n-dev": "^0.0.30",
Expand All @@ -305,6 +335,7 @@
},
"dependencies": {
"@vscode/l10n": "^0.0.16",
"@vscode/webview-ui-toolkit": "^1.4.0",
"command-exists": "^1.2.3",
"ts-sinon": "^2.0.2",
"typescript": "^5.2.2"
Expand Down
Binary file added res/icons/qrc.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit 48f0c73

Please sign in to comment.