Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
microsoft
GitHub Repository: microsoft/vscode
Path: blob/main/build/lib/snapshotLoader.js
3520 views
1
"use strict";
2
Object.defineProperty(exports, "__esModule", { value: true });
3
exports.snaps = void 0;
4
/*---------------------------------------------------------------------------------------------
5
* Copyright (c) Microsoft Corporation. All rights reserved.
6
* Licensed under the MIT License. See License.txt in the project root for license information.
7
*--------------------------------------------------------------------------------------------*/
8
var snaps;
9
(function (snaps) {
10
const fs = require('fs');
11
const path = require('path');
12
const os = require('os');
13
const cp = require('child_process');
14
const mksnapshot = path.join(__dirname, `../../node_modules/.bin/${process.platform === 'win32' ? 'mksnapshot.cmd' : 'mksnapshot'}`);
15
const product = require('../../product.json');
16
const arch = (process.argv.join('').match(/--arch=(.*)/) || [])[1];
17
//
18
let loaderFilepath;
19
let startupBlobFilepath;
20
switch (process.platform) {
21
case 'darwin':
22
loaderFilepath = `VSCode-darwin/${product.nameLong}.app/Contents/Resources/app/out/vs/loader.js`;
23
startupBlobFilepath = `VSCode-darwin/${product.nameLong}.app/Contents/Frameworks/Electron Framework.framework/Resources/snapshot_blob.bin`;
24
break;
25
case 'win32':
26
case 'linux':
27
loaderFilepath = `VSCode-${process.platform}-${arch}/resources/app/out/vs/loader.js`;
28
startupBlobFilepath = `VSCode-${process.platform}-${arch}/snapshot_blob.bin`;
29
break;
30
default:
31
throw new Error('Unknown platform');
32
}
33
loaderFilepath = path.join(__dirname, '../../../', loaderFilepath);
34
startupBlobFilepath = path.join(__dirname, '../../../', startupBlobFilepath);
35
snapshotLoader(loaderFilepath, startupBlobFilepath);
36
function snapshotLoader(loaderFilepath, startupBlobFilepath) {
37
const inputFile = fs.readFileSync(loaderFilepath);
38
const wrappedInputFile = `
39
var Monaco_Loader_Init;
40
(function() {
41
var doNotInitLoader = true;
42
${inputFile.toString()};
43
Monaco_Loader_Init = function() {
44
AMDLoader.init();
45
CSSLoaderPlugin.init();
46
NLSLoaderPlugin.init();
47
48
return { define, require };
49
}
50
})();
51
`;
52
const wrappedInputFilepath = path.join(os.tmpdir(), 'wrapped-loader.js');
53
console.log(wrappedInputFilepath);
54
fs.writeFileSync(wrappedInputFilepath, wrappedInputFile);
55
cp.execFileSync(mksnapshot, [wrappedInputFilepath, `--startup_blob`, startupBlobFilepath]);
56
}
57
})(snaps || (exports.snaps = snaps = {}));
58
//# sourceMappingURL=snapshotLoader.js.map
59