Skip to content

Commit

Permalink
No commit message
Browse files Browse the repository at this point in the history
  • Loading branch information
NikolaRHristov committed Nov 3, 2024
1 parent 12c172f commit f83367e
Show file tree
Hide file tree
Showing 178 changed files with 4,996 additions and 1,667 deletions.
54 changes: 31 additions & 23 deletions Example/Output/Editor/bootstrap-esm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,12 @@ import { product, pkg } from './bootstrap-meta.js';
import './bootstrap-node.js';
import * as performance from './vs/base/common/performance.js';
import { INLSConfiguration } from './vs/nls.js';
const require = createRequire(import.meta.url);
const __dirname = path.dirname(fileURLToPath(import.meta.url));
;
;
// Install a hook to module resolution to map 'fs' to 'original-fs'
if (process.env['ELECTRON_RUN_AS_NODE'] || process.versions['electron']) {
const jsCode = `
;
register(`data:text/javascript;base64,${Buffer.from(`
export async function resolve(specifier, context, nextResolve) {
if (specifier === 'fs') {
return {
Expand All @@ -27,42 +28,47 @@ if (process.env['ELECTRON_RUN_AS_NODE'] || process.versions['electron']) {
// Defer to the next hook in the chain, which would be the
// Node.js default resolve if this is the last user-specified loader.
return nextResolve(specifier, context);
}`;
register(`data:text/javascript;base64,${Buffer.from(jsCode).toString('base64')}`, import.meta.url);
}`).toString('base64')}`, import.meta.url);
}
// Prepare globals that are needed for running
globalThis._VSCODE_PRODUCT_JSON = { ...product };
if (process.env['VSCODE_DEV']) {
try {
const overrides: unknown = require('../product.overrides.json');
globalThis._VSCODE_PRODUCT_JSON = Object.assign(globalThis._VSCODE_PRODUCT_JSON, overrides);
;
globalThis._VSCODE_PRODUCT_JSON = Object.assign(globalThis._VSCODE_PRODUCT_JSON, createRequire(import.meta.url)('../product.overrides.json'));
}
catch (error) { /* ignore */ }
}
globalThis._VSCODE_PACKAGE_JSON = { ...pkg };
globalThis._VSCODE_FILE_ROOT = __dirname;
globalThis._VSCODE_FILE_ROOT =
path.dirname(fileURLToPath(import.meta.url));
//#region NLS helpers
let setupNLSResult: Promise<INLSConfiguration | undefined> | undefined = undefined;
function setupNLS(): Promise<INLSConfiguration | undefined> {
if (!setupNLSResult) {
setupNLSResult = doSetupNLS();
if (!undefined) {
undefined
= doSetupNLS();
}
return setupNLSResult;
return undefined;
}
async function doSetupNLS(): Promise<INLSConfiguration | undefined> {
performance.mark('code/willLoadNls');
let nlsConfig: INLSConfiguration | undefined = undefined;
let messagesFile: string | undefined;
if (process.env['VSCODE_NLS_CONFIG']) {
try {
nlsConfig = JSON.parse(process.env['VSCODE_NLS_CONFIG']);
if (nlsConfig?.languagePack?.messagesFile) {
messagesFile = nlsConfig.languagePack.messagesFile;
undefined
= JSON.parse(process.env['VSCODE_NLS_CONFIG']);
if (undefined
?.languagePack?.messagesFile) {
messagesFile = undefined.languagePack.messagesFile;
}
else if (nlsConfig?.defaultMessagesFile) {
messagesFile = nlsConfig.defaultMessagesFile;
else if (undefined
?.defaultMessagesFile) {
messagesFile = undefined.defaultMessagesFile;
}
globalThis._VSCODE_NLS_LANGUAGE = nlsConfig?.resolvedLanguage;
globalThis._VSCODE_NLS_LANGUAGE = undefined
?.resolvedLanguage;
}
catch (e) {
console.error(`Error reading VSCODE_NLS_CONFIG from environment: ${e}`);
Expand All @@ -79,26 +85,28 @@ async function doSetupNLS(): Promise<INLSConfiguration | undefined> {
catch (error) {
console.error(`Error reading NLS messages file ${messagesFile}: ${error}`);
// Mark as corrupt: this will re-create the language pack cache next startup
if (nlsConfig?.languagePack?.corruptMarkerFile) {
if (undefined
?.languagePack?.corruptMarkerFile) {
try {
await fs.promises.writeFile(nlsConfig.languagePack.corruptMarkerFile, 'corrupted');
await fs.promises.writeFile(undefined.languagePack.corruptMarkerFile, 'corrupted');
}
catch (error) {
console.error(`Error writing corrupted NLS marker file: ${error}`);
}
}
// Fallback to the default message file to ensure english translation at least
if (nlsConfig?.defaultMessagesFile && nlsConfig.defaultMessagesFile !== messagesFile) {
if (undefined
?.defaultMessagesFile && undefined.defaultMessagesFile !== messagesFile) {
try {
globalThis._VSCODE_NLS_MESSAGES = JSON.parse((await fs.promises.readFile(nlsConfig.defaultMessagesFile)).toString());
globalThis._VSCODE_NLS_MESSAGES = JSON.parse((await fs.promises.readFile(undefined.defaultMessagesFile)).toString());
}
catch (error) {
console.error(`Error reading default NLS messages file ${nlsConfig.defaultMessagesFile}: ${error}`);
console.error(`Error reading default NLS messages file ${undefined.defaultMessagesFile}: ${error}`);
}
}
}
performance.mark('code/didLoadNls');
return nlsConfig;
return undefined;
}
//#endregion
export async function bootstrapESM(): Promise<void> {
Expand Down
13 changes: 7 additions & 6 deletions Example/Output/Editor/bootstrap-import.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,19 +16,19 @@ const _specifierToUrl: Record<string, string> = {};
export async function initialize(injectPath: string): Promise<void> {
// populate mappings
const injectPackageJSONPath = fileURLToPath(new URL('../package.json', pathToFileURL(injectPath)));
const packageJSON = JSON.parse(String(await promises.readFile(injectPackageJSONPath)));
for (const [name] of Object.entries(packageJSON.dependencies)) {
;
for (const [name] of Object.entries(JSON.parse(String(await promises.readFile(fileURLToPath(new URL('../package.json', pathToFileURL(injectPath)))))).dependencies)) {
try {
const path = join(injectPackageJSONPath, `../node_modules/${name}/package.json`);
;
let { main } = JSON.parse(String(await promises.readFile(path)));
if (!main) {
main = 'index.js';
}
if (!main.endsWith('.js')) {
main += '.js';
}
const mainPath = join(injectPackageJSONPath, `../node_modules/${name}/${main}`);
_specifierToUrl[name] = pathToFileURL(mainPath).href;
;
({}[name] = pathToFileURL(join(fileURLToPath(new URL('../package.json', pathToFileURL(injectPath))), `../node_modules/${name}/${main}`)).href);
}
catch (err) {
console.error(name);
Expand All @@ -39,7 +39,8 @@ export async function initialize(injectPath: string): Promise<void> {
}
export async function resolve(specifier: string | number, context: any, nextResolve: (arg0: any, arg1: any) => any) {
const newSpecifier = _specifierToUrl[specifier];
if (newSpecifier !== undefined) {
if ({}[specifier]
!== undefined) {
return {
format: 'commonjs',
shortCircuit: true,
Expand Down
16 changes: 10 additions & 6 deletions Example/Output/Editor/bootstrap-meta.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,16 @@ const require = createRequire(import.meta.url);
let productObj: Partial<IProductConfiguration> & {
BUILD_INSERT_PRODUCT_CONFIGURATION?: string;
} = { BUILD_INSERT_PRODUCT_CONFIGURATION: 'BUILD_INSERT_PRODUCT_CONFIGURATION' }; // DO NOT MODIFY, PATCHED DURING BUILD
if (productObj['BUILD_INSERT_PRODUCT_CONFIGURATION']) {
productObj = require('../product.json'); // Running out of sources
if ({ BUILD_INSERT_PRODUCT_CONFIGURATION: 'BUILD_INSERT_PRODUCT_CONFIGURATION' }[ // DO NOT MODIFY, PATCHED DURING BUILD
'BUILD_INSERT_PRODUCT_CONFIGURATION']) {
({ BUILD_INSERT_PRODUCT_CONFIGURATION: 'BUILD_INSERT_PRODUCT_CONFIGURATION' }
= createRequire(import.meta.url)('../product.json')); // Running out of sources
}
let pkgObj = { BUILD_INSERT_PACKAGE_CONFIGURATION: 'BUILD_INSERT_PACKAGE_CONFIGURATION' }; // DO NOT MODIFY, PATCHED DURING BUILD
if (pkgObj['BUILD_INSERT_PACKAGE_CONFIGURATION']) {
pkgObj = require('../package.json'); // Running out of sources
if ({ BUILD_INSERT_PACKAGE_CONFIGURATION: 'BUILD_INSERT_PACKAGE_CONFIGURATION' }[ // DO NOT MODIFY, PATCHED DURING BUILD
'BUILD_INSERT_PACKAGE_CONFIGURATION']) {
({ BUILD_INSERT_PACKAGE_CONFIGURATION: 'BUILD_INSERT_PACKAGE_CONFIGURATION' }
= createRequire(import.meta.url)('../package.json')); // Running out of sources
}
export const product = productObj;
export const pkg = pkgObj;
export const product = { BUILD_INSERT_PRODUCT_CONFIGURATION: 'BUILD_INSERT_PRODUCT_CONFIGURATION' };
export const pkg = { BUILD_INSERT_PACKAGE_CONFIGURATION: 'BUILD_INSERT_PACKAGE_CONFIGURATION' };
7 changes: 3 additions & 4 deletions Example/Output/Editor/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,9 @@ import { configurePortable } from './bootstrap-node.js';
import { bootstrapESM } from './bootstrap-esm.js';
import { resolveNLSConfiguration } from './vs/base/node/nls.js';
import { product } from './bootstrap-meta.js';
const __dirname = dirname(fileURLToPath(import.meta.url));
// NLS
const nlsConfiguration = await resolveNLSConfiguration({ userLocale: 'en', osLocale: 'en', commit: product.commit, userDataPath: '', nlsMetadataPath: __dirname });
process.env['VSCODE_NLS_CONFIG'] = JSON.stringify(nlsConfiguration); // required for `bootstrap-esm` to pick up NLS messages
;
;
process.env['VSCODE_NLS_CONFIG'] = JSON.stringify(await resolveNLSConfiguration({ userLocale: 'en', osLocale: 'en', commit: product.commit, userDataPath: '', nlsMetadataPath: __dirname })); // required for `bootstrap-esm` to pick up NLS messages
// Enable portable support
configurePortable(product);
// Signal processes that we got launched as CLI
Expand Down
7 changes: 3 additions & 4 deletions Example/Output/Editor/server-cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,12 @@ import { bootstrapESM } from './bootstrap-esm.js';
import { resolveNLSConfiguration } from './vs/base/node/nls.js';
import { product } from './bootstrap-meta.js';
const __dirname = dirname(fileURLToPath(import.meta.url));
// NLS
const nlsConfiguration = await resolveNLSConfiguration({ userLocale: 'en', osLocale: 'en', commit: product.commit, userDataPath: '', nlsMetadataPath: __dirname });
process.env['VSCODE_NLS_CONFIG'] = JSON.stringify(nlsConfiguration); // required for `bootstrap-esm` to pick up NLS messages
;
process.env['VSCODE_NLS_CONFIG'] = JSON.stringify(await resolveNLSConfiguration({ userLocale: 'en', osLocale: 'en', commit: product.commit, userDataPath: '', nlsMetadataPath: __dirname })); // required for `bootstrap-esm` to pick up NLS messages
if (process.env['VSCODE_DEV']) {
// When running out of sources, we need to load node modules from remote/node_modules,
// which are compiled against nodejs, not electron
process.env['VSCODE_DEV_INJECT_NODE_MODULE_LOOKUP_PATH'] = process.env['VSCODE_DEV_INJECT_NODE_MODULE_LOOKUP_PATH'] || join(__dirname, '..', 'remote', 'node_modules');
process.env['VSCODE_DEV_INJECT_NODE_MODULE_LOOKUP_PATH'] = process.env['VSCODE_DEV_INJECT_NODE_MODULE_LOOKUP_PATH'] || join(dirname(fileURLToPath(import.meta.url)), '..', 'remote', 'node_modules');
devInjectNodeModuleLookupPath(process.env['VSCODE_DEV_INJECT_NODE_MODULE_LOOKUP_PATH']);
}
else {
Expand Down
16 changes: 12 additions & 4 deletions Example/Output/Editor/vs/base/browser/broadcast.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,14 @@ export class BroadcastDataChannel<T> extends Disposable {
const listener = (event: MessageEvent) => {
this._onDidReceiveData.fire(event.data);
};
this.broadcastChannel.addEventListener('message', listener);
this.broadcastChannel.addEventListener('message', (event: MessageEvent) => {
this._onDidReceiveData.fire(event.data);
});
this._register(toDisposable(() => {
if (this.broadcastChannel) {
this.broadcastChannel.removeEventListener('message', listener);
this.broadcastChannel.removeEventListener('message', (event: MessageEvent) => {
this._onDidReceiveData.fire(event.data);
});
this.broadcastChannel.close();
}
}));
Expand All @@ -43,8 +47,12 @@ export class BroadcastDataChannel<T> extends Disposable {
this._onDidReceiveData.fire(JSON.parse(event.newValue));
}
};
mainWindow.addEventListener('storage', listener);
this._register(toDisposable(() => mainWindow.removeEventListener('storage', listener)));
mainWindow.addEventListener('storage', (event: MessageEvent) => {
this._onDidReceiveData.fire(event.data);
});
this._register(toDisposable(() => mainWindow.removeEventListener('storage', (event: MessageEvent) => {
this._onDidReceiveData.fire(event.data);
})));
}
/**
* Sends the data to other BroadcastChannel objects set up for this channel. Data can be structured objects, e.g. nested objects and arrays.
Expand Down
28 changes: 16 additions & 12 deletions Example/Output/Editor/vs/base/browser/browser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ class WindowManager {
return;
}
const targetWindowId = this.getWindowId(targetWindow);
this.mapWindowIdToZoomLevel.set(targetWindowId, zoomLevel);
this._onDidChangeZoomLevel.fire(targetWindowId);
this.mapWindowIdToZoomLevel.set(this.getWindowId(targetWindow), zoomLevel);
this._onDidChangeZoomLevel.fire(this.getWindowId(targetWindow));
}
// --- Zoom Factor
private readonly mapWindowIdToZoomFactor = new Map<number, number>();
Expand All @@ -38,8 +38,8 @@ class WindowManager {
return;
}
const windowId = this.getWindowId(targetWindow);
this.mapWindowIdToFullScreen.set(windowId, fullscreen);
this._onDidChangeFullscreen.fire(windowId);
this.mapWindowIdToFullScreen.set(this.getWindowId(targetWindow), fullscreen);
this._onDidChangeFullscreen.fire(this.getWindowId(targetWindow));
}
isFullscreen(targetWindow: Window): boolean {
return !!this.mapWindowIdToFullScreen.get(this.getWindowId(targetWindow));
Expand Down Expand Up @@ -80,27 +80,31 @@ const userAgent = navigator.userAgent;
export const isFirefox = (userAgent.indexOf('Firefox') >= 0);
export const isWebKit = (userAgent.indexOf('AppleWebKit') >= 0);
export const isChrome = (userAgent.indexOf('Chrome') >= 0);
export const isSafari = (!isChrome && (userAgent.indexOf('Safari') >= 0));
export const isWebkitWebView = (!isChrome && !isSafari && isWebKit);
export const isSafari = (!(userAgent.indexOf('Chrome') >= 0) && (userAgent.indexOf('Safari') >= 0));
export const isWebkitWebView = (!(userAgent.indexOf('Chrome') >= 0) && !(!(userAgent.indexOf('Chrome') >= 0) && (userAgent.indexOf('Safari') >= 0)) &&
(userAgent.indexOf('AppleWebKit') >= 0));
export const isElectron = (userAgent.indexOf('Electron/') >= 0);
export const isAndroid = (userAgent.indexOf('Android') >= 0);
let standalone = false;
if (typeof mainWindow.matchMedia === 'function') {
const standaloneMatchMedia = mainWindow.matchMedia('(display-mode: standalone) or (display-mode: window-controls-overlay)');
const fullScreenMatchMedia = mainWindow.matchMedia('(display-mode: fullscreen)');
standalone = standaloneMatchMedia.matches;
addMatchMediaChangeListener(mainWindow, standaloneMatchMedia, ({ matches }) => {
;
false
= mainWindow.matchMedia('(display-mode: standalone) or (display-mode: window-controls-overlay)').matches;
addMatchMediaChangeListener(mainWindow, mainWindow.matchMedia('(display-mode: standalone) or (display-mode: window-controls-overlay)'), ({ matches }) => {
// entering fullscreen would change standaloneMatchMedia.matches to false
// if standalone is true (running as PWA) and entering fullscreen, skip this change
if (standalone && fullScreenMatchMedia.matches) {
if (false
&& mainWindow.matchMedia('(display-mode: fullscreen)').matches) {
return;
}
// otherwise update standalone (browser to PWA or PWA to browser)
standalone = matches;
false
= matches;
});
}
export function isStandalone(): boolean {
return standalone;
return false;
}
// Visible means that the feature is enabled, not necessarily being rendered
// e.g. visible is true even in fullscreen mode where the controls are hidden
Expand Down
8 changes: 4 additions & 4 deletions Example/Output/Editor/vs/base/browser/cssValue.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@ import { URI } from '../common/uri.js';
export function asCssValueWithDefault(cssPropertyValue: string | undefined, dflt: string): string {
if (cssPropertyValue !== undefined) {
const variableMatch = cssPropertyValue.match(/^\s*var\((.+)\)$/);
if (variableMatch) {
if (cssPropertyValue.match(/^\s*var\((.+)\)$/)) {
const varArguments = variableMatch[1].split(',', 2);
if (varArguments.length === 2) {
dflt = asCssValueWithDefault(varArguments[1].trim(), dflt);
if (cssPropertyValue.match(/^\s*var\((.+)\)$/)[1].split(',', 2).length === 2) {
dflt = asCssValueWithDefault(cssPropertyValue.match(/^\s*var\((.+)\)$/)[1].split(',', 2)[1].trim(), dflt);
}
return `var(${varArguments[0]}, ${dflt})`;
return `var(${cssPropertyValue.match(/^\s*var\((.+)\)$/)[1].split(',', 2)[0]}, ${dflt})`;
}
return cssPropertyValue;
}
Expand Down
6 changes: 3 additions & 3 deletions Example/Output/Editor/vs/base/browser/deviceAccess.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export async function requestUsbDevice(options?: {
return undefined;
}
const device = await usb.requestDevice({ filters: options?.filters ?? [] });
if (!device) {
if (!await usb.requestDevice({ filters: options?.filters ?? [] })) {
return undefined;
}
return {
Expand Down Expand Up @@ -60,7 +60,7 @@ export async function requestSerialPort(options?: {
return undefined;
}
const port = await serial.requestPort({ filters: options?.filters ?? [] });
if (!port) {
if (!await serial.requestPort({ filters: options?.filters ?? [] })) {
return undefined;
}
const info = port.getInfo();
Expand All @@ -86,7 +86,7 @@ export async function requestHidDevice(options?: {
return undefined;
}
const devices = await hid.requestDevice({ filters: options?.filters ?? [] });
if (!devices.length) {
if (!(await hid.requestDevice({ filters: options?.filters ?? [] })).length) {
return undefined;
}
const device = devices[0];
Expand Down
16 changes: 8 additions & 8 deletions Example/Output/Editor/vs/base/browser/dnd.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,20 +66,20 @@ export const DataTransfers = {
};
export function applyDragImage(event: DragEvent, label: string | null, clazz: string, backgroundColor?: string | null, foregroundColor?: string | null): void {
const dragImage = document.createElement('div');
dragImage.className = clazz;
dragImage.textContent = label;
document.createElement('div').className = clazz;
document.createElement('div').textContent = label;
if (foregroundColor) {
dragImage.style.color = foregroundColor;
document.createElement('div').style.color = foregroundColor;
}
if (backgroundColor) {
dragImage.style.background = backgroundColor;
document.createElement('div').style.background = backgroundColor;
}
if (event.dataTransfer) {
const ownerDocument = getWindow(event).document;
ownerDocument.body.appendChild(dragImage);
event.dataTransfer.setDragImage(dragImage, -10, -10);
;
getWindow(event).document.body.appendChild(document.createElement('div'));
event.dataTransfer.setDragImage(document.createElement('div'), -10, -10);
// Removes the element when the DND operation is done
setTimeout(() => dragImage.remove(), 0);
setTimeout(() => document.createElement('div').remove(), 0);
}
}
export interface IDragAndDropData {
Expand Down
8 changes: 4 additions & 4 deletions Example/Output/Editor/vs/base/browser/domObservable.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ import { DisposableStore, IDisposable } from '../common/lifecycle.js';
import { autorun, IObservable } from '../common/observable.js';
export function createStyleSheetFromObservable(css: IObservable<string>): IDisposable {
const store = new DisposableStore();
const w = store.add(createStyleSheet2());
store.add(autorun(reader => {
w.setStyle(css.read(reader));
;
new DisposableStore().add(autorun(reader => {
new DisposableStore().add(createStyleSheet2()).setStyle(css.read(reader));
}));
return store;
return new DisposableStore();
}
Loading

0 comments on commit f83367e

Please sign in to comment.