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 514651a commit bde7795
Show file tree
Hide file tree
Showing 6,658 changed files with 1,717,048 additions and 1,236,814 deletions.
The diff you're trying to view is too large. We only load the first 3000 changed files.
43 changes: 20 additions & 23 deletions Configuration.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,26 +2,23 @@
* @module Option
*
*/
export default (await import("./Target/Function/Merge.js")).default(
(await import("@playform/pipe/Target/Variable/Option.js")).default,
{
Action: {
Wrote: async (On) => {
try {
return (
await import("./Target/Function/Output.js")
).default(On.Buffer.toString());
} catch (_Error) {
console.log(_Error);
return On.Buffer;
}
},
Failed: async (Input, _Error) => {
console.log(_Error);
return "";
},
},
Path: new Map([["./Example/Input", "./Example/Output"]]),
File: "**/*.ts",
},
);
export default (await import("./Target/Function/Merge.js")).default((await import("@playform/pipe/Target/Variable/Option.js")).default, {
Action: {
Wrote: async (On) => {
try {
return (await import("./Target/Function/Output.js")).default(On.Buffer.toString());
}
catch (_Error) {
console.log(_Error);
return On.Buffer;
}
},
Failed: async (Input, _Error) => {
console.log(_Error);
return "";
},
},
Path: new Map([["./Example/Input", "./Example/Output"]]),
File: "**/*.ts",
Exclude: (File) => (File.indexOf(".d.ts") !== -1 ? true : false),
});
1 change: 1 addition & 0 deletions Configuration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,5 +27,6 @@ export default (await import("./Target/Function/Merge.js")).default(
},
Path: new Map([["./Example/Input", "./Example/Output"]]),
File: "**/*.ts",
Exclude: (File) => (File.indexOf(".d.ts") !== -1 ? true : false),
} satisfies Interface,
);
1 change: 0 additions & 1 deletion Example/Input/Editor/bootstrap-cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/

// Delete `VSCODE_CWD` very early. We have seen
// reports where `code .` would use the wrong
// current working directory due to our variable
Expand Down
178 changes: 66 additions & 112 deletions Example/Input/Editor/bootstrap-esm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,25 +2,19 @@
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/

import * as fs from "fs";
import { createRequire, register } from "node:module";
import * as path from "path";
import { fileURLToPath } from "url";

import { pkg, product } 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 = `
const jsCode = `
export async function resolve(specifier, context, nextResolve) {
if (specifier === 'fs') {
return {
Expand All @@ -34,123 +28,83 @@ if (process.env["ELECTRON_RUN_AS_NODE"] || process.versions["electron"]) {
// 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,
);
register(`data:text/javascript;base64,${Buffer.from(jsCode).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,
);
} catch (error) {
/* ignore */
}
try {
const overrides: unknown = require("../product.overrides.json");
globalThis._VSCODE_PRODUCT_JSON = Object.assign(globalThis._VSCODE_PRODUCT_JSON, overrides);
}
catch (error) {
/* ignore */
}
}
globalThis._VSCODE_PACKAGE_JSON = { ...pkg };
globalThis._VSCODE_FILE_ROOT = __dirname;

//#region NLS helpers

let setupNLSResult: Promise<INLSConfiguration | undefined> | undefined =
undefined;

let setupNLSResult: Promise<INLSConfiguration | undefined> | undefined = undefined;
function setupNLS(): Promise<INLSConfiguration | undefined> {
if (!setupNLSResult) {
setupNLSResult = doSetupNLS();
}

return setupNLSResult;
if (!setupNLSResult) {
setupNLSResult = doSetupNLS();
}
return setupNLSResult;
}

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;
} else if (nlsConfig?.defaultMessagesFile) {
messagesFile = nlsConfig.defaultMessagesFile;
}

globalThis._VSCODE_NLS_LANGUAGE = nlsConfig?.resolvedLanguage;
} catch (e) {
console.error(
`Error reading VSCODE_NLS_CONFIG from environment: ${e}`,
);
}
}

if (
process.env["VSCODE_DEV"] || // no NLS support in dev mode
!messagesFile // no NLS messages file
) {
return undefined;
}

try {
globalThis._VSCODE_NLS_MESSAGES = JSON.parse(
(await fs.promises.readFile(messagesFile)).toString(),
);
} 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) {
try {
await fs.promises.writeFile(
nlsConfig.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
) {
try {
globalThis._VSCODE_NLS_MESSAGES = JSON.parse(
(
await fs.promises.readFile(
nlsConfig.defaultMessagesFile,
)
).toString(),
);
} catch (error) {
console.error(
`Error reading default NLS messages file ${nlsConfig.defaultMessagesFile}: ${error}`,
);
}
}
}

performance.mark("code/didLoadNls");

return nlsConfig;
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;
}
else if (nlsConfig?.defaultMessagesFile) {
messagesFile = nlsConfig.defaultMessagesFile;
}
globalThis._VSCODE_NLS_LANGUAGE = nlsConfig?.resolvedLanguage;
}
catch (e) {
console.error(`Error reading VSCODE_NLS_CONFIG from environment: ${e}`);
}
}
if (process.env["VSCODE_DEV"] || // no NLS support in dev mode
!messagesFile // no NLS messages file
) {
return undefined;
}
try {
globalThis._VSCODE_NLS_MESSAGES = JSON.parse((await fs.promises.readFile(messagesFile)).toString());
}
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) {
try {
await fs.promises.writeFile(nlsConfig.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) {
try {
globalThis._VSCODE_NLS_MESSAGES = JSON.parse((await fs.promises.readFile(nlsConfig.defaultMessagesFile)).toString());
}
catch (error) {
console.error(`Error reading default NLS messages file ${nlsConfig.defaultMessagesFile}: ${error}`);
}
}
}
performance.mark("code/didLoadNls");
return nlsConfig;
}

//#endregion

export async function bootstrapESM(): Promise<void> {
// NLS
await setupNLS();
// NLS
await setupNLS();
}
Loading

0 comments on commit bde7795

Please sign in to comment.