mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-07 17:23:56 -05:00
Merge VS Code 1.31.1 (#4283)
This commit is contained in:
@@ -660,6 +660,7 @@ var AMDLoader;
|
||||
this._env = env;
|
||||
this._didInitialize = false;
|
||||
this._didPatchNodeRequire = false;
|
||||
this._hasCreateCachedData = false;
|
||||
}
|
||||
NodeScriptLoader.prototype._init = function (nodeRequire) {
|
||||
if (this._didInitialize) {
|
||||
@@ -671,6 +672,8 @@ var AMDLoader;
|
||||
this._vm = nodeRequire('vm');
|
||||
this._path = nodeRequire('path');
|
||||
this._crypto = nodeRequire('crypto');
|
||||
// check for `createCachedData`-api
|
||||
this._hasCreateCachedData = typeof (new this._vm.Script('').createCachedData) === 'function';
|
||||
};
|
||||
// patch require-function of nodejs such that we can manually create a script
|
||||
// from cached data. this is done by overriding the `Module._compile` function
|
||||
@@ -711,7 +714,7 @@ var AMDLoader;
|
||||
options.cachedData = that._fs.readFileSync(cachedDataPath);
|
||||
}
|
||||
catch (e) {
|
||||
options.produceCachedData = true;
|
||||
options.produceCachedData = !that._hasCreateCachedData;
|
||||
}
|
||||
var script = new that._vm.Script(wrapper, options);
|
||||
var compileWrapper = script.runInThisContext(options);
|
||||
@@ -719,7 +722,7 @@ var AMDLoader;
|
||||
var require = makeRequireFunction(this);
|
||||
var args = [this.exports, require, this, filename, dirname, process, _commonjsGlobal, Buffer];
|
||||
var result = compileWrapper.apply(this.exports, args);
|
||||
that._processCachedData(moduleManager, script, cachedDataPath);
|
||||
that._processCachedData(moduleManager, script, wrapper, cachedDataPath, !options.cachedData);
|
||||
return result;
|
||||
};
|
||||
};
|
||||
@@ -778,15 +781,15 @@ var AMDLoader;
|
||||
}
|
||||
else {
|
||||
var cachedDataPath_1 = _this._getCachedDataPath(opts.nodeCachedData.seed, opts.nodeCachedData.path, scriptSrc);
|
||||
_this._fs.readFile(cachedDataPath_1, function (err, cachedData) {
|
||||
_this._fs.readFile(cachedDataPath_1, function (_err, cachedData) {
|
||||
// create script options
|
||||
var options = {
|
||||
filename: vmScriptSrc,
|
||||
produceCachedData: typeof cachedData === 'undefined',
|
||||
produceCachedData: !_this._hasCreateCachedData && typeof cachedData === 'undefined',
|
||||
cachedData: cachedData
|
||||
};
|
||||
var script = _this._loadAndEvalScript(moduleManager, scriptSrc, vmScriptSrc, contents, options, recorder, callback, errorback);
|
||||
_this._processCachedData(moduleManager, script, cachedDataPath_1);
|
||||
_this._processCachedData(moduleManager, script, contents, cachedDataPath_1, !options.cachedData);
|
||||
});
|
||||
}
|
||||
});
|
||||
@@ -820,7 +823,7 @@ var AMDLoader;
|
||||
var basename = this._path.basename(filename).replace(/\.js$/, '');
|
||||
return this._path.join(basedir, basename + "-" + hash + ".code");
|
||||
};
|
||||
NodeScriptLoader.prototype._processCachedData = function (moduleManager, script, cachedDataPath) {
|
||||
NodeScriptLoader.prototype._processCachedData = function (moduleManager, script, contents, cachedDataPath, createCachedData) {
|
||||
var _this = this;
|
||||
if (script.cachedDataRejected) {
|
||||
// data rejected => delete cache file
|
||||
@@ -838,13 +841,12 @@ var AMDLoader;
|
||||
});
|
||||
}
|
||||
});
|
||||
}, moduleManager.getConfig().getOptionsLiteral().nodeCachedData.writeDelay);
|
||||
}, moduleManager.getConfig().getOptionsLiteral().nodeCachedData.writeDelay / 2);
|
||||
}
|
||||
else if (script.cachedDataProduced) {
|
||||
// data produced => tell outside world
|
||||
moduleManager.getConfig().getOptionsLiteral().nodeCachedData.onData(undefined, {
|
||||
path: cachedDataPath,
|
||||
length: script.cachedData.length
|
||||
path: cachedDataPath
|
||||
});
|
||||
// data produced => write cache file
|
||||
NodeScriptLoader._runSoon(function () {
|
||||
@@ -859,6 +861,27 @@ var AMDLoader;
|
||||
});
|
||||
}, moduleManager.getConfig().getOptionsLiteral().nodeCachedData.writeDelay);
|
||||
}
|
||||
else if (this._hasCreateCachedData && createCachedData) {
|
||||
// NEW world
|
||||
// data produced => tell outside world
|
||||
moduleManager.getConfig().getOptionsLiteral().nodeCachedData.onData(undefined, {
|
||||
path: cachedDataPath
|
||||
});
|
||||
// soon'ish create and save cached data
|
||||
NodeScriptLoader._runSoon(function () {
|
||||
var data = script.createCachedData(contents);
|
||||
_this._fs.writeFile(cachedDataPath, data, function (err) {
|
||||
if (!err) {
|
||||
return;
|
||||
}
|
||||
moduleManager.getConfig().getOptionsLiteral().nodeCachedData.onData({
|
||||
errorCode: 'writeFile',
|
||||
path: cachedDataPath,
|
||||
detail: err
|
||||
});
|
||||
});
|
||||
}, moduleManager.getConfig().getOptionsLiteral().nodeCachedData.writeDelay);
|
||||
}
|
||||
};
|
||||
NodeScriptLoader._runSoon = function (callback, minTimeout) {
|
||||
var timeout = minTimeout + Math.ceil(Math.random() * minTimeout);
|
||||
|
||||
Reference in New Issue
Block a user