deploy: current vibn theia state
Made-with: Cursor
This commit is contained in:
64
packages/core/scripts/download-catalog.js
Normal file
64
packages/core/scripts/download-catalog.js
Normal file
@@ -0,0 +1,64 @@
|
||||
// *****************************************************************************
|
||||
// Copyright (C) 2024 STMicroelectronics and others.
|
||||
//
|
||||
// This program and the accompanying materials are made available under the
|
||||
// terms of the Eclipse Public License v. 2.0 which is available at
|
||||
// http://www.eclipse.org/legal/epl-2.0.
|
||||
//
|
||||
// This Source Code may also be made available under the following Secondary
|
||||
// Licenses when the conditions for such availability set forth in the Eclipse
|
||||
// Public License v. 2.0 are satisfied: GNU General Public License, version 2
|
||||
// with the GNU Classpath Exception which is available at
|
||||
// https://www.gnu.org/software/classpath/license.html.
|
||||
//
|
||||
// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
|
||||
// *****************************************************************************
|
||||
const path = require('path');
|
||||
const { Downloader } = require('nodejs-file-downloader');
|
||||
|
||||
const url = 'https://schemastore.org/api/json/catalog.json';
|
||||
|
||||
const targetDir = './lib/browser';
|
||||
const fileName = 'catalog.json';
|
||||
const targetFile = path.join(targetDir, fileName);
|
||||
|
||||
const downloader = new Downloader({
|
||||
url,
|
||||
directory: targetDir,
|
||||
fileName: 'catalog.json',
|
||||
timeout: 60000,
|
||||
proxy: process.env.http_proxy
|
||||
|| process.env.HTTP_PROXY
|
||||
|| process.env.https_proxy
|
||||
|| process.env.HTTPS_PROXY
|
||||
|| '',
|
||||
cloneFiles: false
|
||||
});
|
||||
|
||||
downloader.download().catch(error => {
|
||||
const errorMessage = `
|
||||
Failed to download ${fileName} from schemastore.org
|
||||
Error: ${error.message}
|
||||
|
||||
This is likely due to one of the following issues:
|
||||
1. Network connectivity issues
|
||||
2. Proxy configuration needed
|
||||
3. SSL certificate validation failure
|
||||
|
||||
Possible workarounds:
|
||||
|
||||
1. If behind a proxy, set proxy environment variables:
|
||||
export HTTPS_PROXY=http://your-proxy:port
|
||||
export HTTP_PROXY=http://your-proxy:port
|
||||
|
||||
2. If you have to use specific SSL certificates:
|
||||
export NODE_EXTRA_CA_CERTS=/path/to/certificate.crt
|
||||
|
||||
3. Download the file manually and place it at:
|
||||
${targetFile}
|
||||
Download from: ${url}
|
||||
Adapt core npm scripts to skip automatic download.
|
||||
`;
|
||||
console.error(errorMessage);
|
||||
process.exit(1);
|
||||
});
|
||||
91
packages/core/scripts/generate-layout.js
Normal file
91
packages/core/scripts/generate-layout.js
Normal file
@@ -0,0 +1,91 @@
|
||||
// *****************************************************************************
|
||||
// Copyright (C) 2019 TypeFox and others.
|
||||
//
|
||||
// This program and the accompanying materials are made available under the
|
||||
// terms of the Eclipse Public License v. 2.0 which is available at
|
||||
// http://www.eclipse.org/legal/epl-2.0.
|
||||
//
|
||||
// This Source Code may also be made available under the following Secondary
|
||||
// Licenses when the conditions for such availability set forth in the Eclipse
|
||||
// Public License v. 2.0 are satisfied: GNU General Public License, version 2
|
||||
// with the GNU Classpath Exception which is available at
|
||||
// https://www.gnu.org/software/classpath/license.html.
|
||||
//
|
||||
// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
|
||||
// *****************************************************************************
|
||||
|
||||
const parseArgs = require('minimist');
|
||||
const nativeKeymap = require('native-keymap');
|
||||
const fs = require('fs');
|
||||
const electron = require('electron');
|
||||
|
||||
/*
|
||||
* Generate keyboard layouts for using Theia as web application.
|
||||
*
|
||||
* Usage:
|
||||
* npm run generate-layout [--info] [--all] [--pretty] [--output file]
|
||||
*
|
||||
* --info Print the keyboard layout information; if omitted, the full
|
||||
* keyboard layout with info and mapping is printed.
|
||||
* --all Include all keys in the output, not only the relevant ones.
|
||||
* --pretty Pretty-print the JSON output.
|
||||
* --output file Write the output to the given file instead of stdout.
|
||||
*
|
||||
* Hint: keyboard layouts are stored in packages/core/src/common/keyboard/layouts
|
||||
* and have the following file name scheme:
|
||||
* <language>-<name>-<hardware>.json
|
||||
*
|
||||
* <language> A language subtag according to IETF BCP 47
|
||||
* <name> Display name of the keyboard layout (without dashes)
|
||||
* <hardware> `pc` or `mac`
|
||||
*/
|
||||
const args = parseArgs(process.argv);
|
||||
const printInfo = args['info'];
|
||||
const includeAll = args['all'];
|
||||
const prettyPrint = args['pretty'];
|
||||
const outFile = args['output'];
|
||||
|
||||
let output;
|
||||
if (printInfo) {
|
||||
output = nativeKeymap.getCurrentKeyboardLayout();
|
||||
} else {
|
||||
output = {
|
||||
info: nativeKeymap.getCurrentKeyboardLayout(),
|
||||
mapping: nativeKeymap.getKeyMap()
|
||||
};
|
||||
if (!includeAll) {
|
||||
// We store only key codes for the "writing system keys" as defined here:
|
||||
// https://w3c.github.io/uievents-code/#writing-system-keys
|
||||
const ACCEPTED_CODES = [
|
||||
'KeyA', 'KeyB', 'KeyC', 'KeyD', 'KeyE', 'KeyF', 'KeyG', 'KeyH', 'KeyI', 'KeyJ', 'KeyK', 'KeyL', 'KeyM',
|
||||
'KeyN', 'KeyO', 'KeyP', 'KeyQ', 'KeyR', 'KeyS', 'KeyT', 'KeyU', 'KeyV', 'KeyW', 'KeyX', 'KeyY', 'KeyZ',
|
||||
'Digit1', 'Digit2', 'Digit3', 'Digit4', 'Digit5', 'Digit6', 'Digit7', 'Digit8', 'Digit9', 'Digit0',
|
||||
'Minus', 'Equal', 'BracketLeft', 'BracketRight', 'Backslash', 'Semicolon', 'Quote', 'Backquote',
|
||||
'Comma', 'Period', 'Slash', 'IntlBackslash', 'IntlRo', 'IntlYen'
|
||||
];
|
||||
const ACCEPTED_VARIANTS = ['value', 'withShift', 'withAltGr', 'withShiftAltGr', 'vkey'];
|
||||
for (let code of Object.keys(output.mapping)) {
|
||||
if (ACCEPTED_CODES.indexOf(code) < 0) {
|
||||
delete output.mapping[code];
|
||||
} else {
|
||||
for (let variant of Object.keys(output.mapping[code])) {
|
||||
if (ACCEPTED_VARIANTS.indexOf(variant) < 0 || output.mapping[code][variant] === '') {
|
||||
delete output.mapping[code][variant];
|
||||
}
|
||||
}
|
||||
if (Object.keys(output.mapping[code]).length === 0) {
|
||||
delete output.mapping[code];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const stringOutput = JSON.stringify(output, undefined, prettyPrint ? 2 : undefined);
|
||||
if (outFile) {
|
||||
fs.writeFileSync(outFile, stringOutput);
|
||||
} else {
|
||||
console.log(stringOutput);
|
||||
}
|
||||
|
||||
electron.app.quit();
|
||||
Reference in New Issue
Block a user