Remove dead SourceMap code

Summary:
In several pervious diffs we have moved symbolication of JS stack traces
to the packeger. This lets us save a bunch of memory (~80MB) and CPU on device,
reduces dependency on JS after exception occured.

This diff cleans up a bunch of code that was used to do symbolication on client side.

Reviewed By: javache

Differential Revision: D3348676

fbshipit-source-id: 88baa5c502836c9ca892896e1ee5d83db37486d3
This commit is contained in:
Alex Kotliarskyi
2016-06-01 13:50:36 -07:00
committed by Facebook Github Bot 2
parent 2ef533352f
commit 0d1d7ba2b7
4 changed files with 0 additions and 2112 deletions

File diff suppressed because it is too large Load Diff

View File

@@ -1,44 +0,0 @@
/**
* Copyright (c) 2015-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*
* @providesModule SourceMapsCache
*/
'use strict';
const getObjectValues = require('getObjectValues');
const SourceMapsUtils = require('SourceMapsUtils');
const sourceMapsCache = {};
const SourceMapsCache = {
mainSourceMapID: 'main',
fetch({text, url, fullSourceMappingURL}) {
const sourceMappingURL = fullSourceMappingURL
? fullSourceMappingURL
: SourceMapsUtils.extractSourceMapURL({text, url});
sourceMapsCache[sourceMappingURL] = SourceMapsUtils.fetchSourceMap(
sourceMappingURL
);
},
getSourceMaps() {
fetchMainSourceMap();
return Promise.all(getObjectValues(sourceMapsCache));
},
};
function fetchMainSourceMap() {
if (!sourceMapsCache[SourceMapsCache.mainSourceMapID]) {
sourceMapsCache[SourceMapsCache.mainSourceMapID] =
SourceMapsUtils.fetchMainSourceMap();
}
}
module.exports = SourceMapsCache;

View File

@@ -1,88 +0,0 @@
/**
* Copyright (c) 2015-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*
* @providesModule SourceMapsUtils
* @flow
*/
'use strict';
const Promise = require('Promise');
const NativeModules = require('NativeModules');
const SourceMapConsumer = require('SourceMap').SourceMapConsumer;
const SourceMapURL = require('./source-map-url');
const RCTSourceCode = NativeModules.SourceCode;
const RCTNetworking = NativeModules.Networking;
const SourceMapsUtils = {
fetchMainSourceMap(): Promise {
return SourceMapsUtils._getMainSourceMapURL().then(url =>
SourceMapsUtils.fetchSourceMap(url)
);
},
fetchSourceMap(sourceMappingURL: string): Promise {
return fetch(sourceMappingURL)
.then(response => response.text())
.then(map => new SourceMapConsumer(map));
},
extractSourceMapURL(data: ({url?:string, text?:string, fullSourceMappingURL?:string})): ?string {
const url = data.url;
const text = data.text;
const fullSourceMappingURL = data.fullSourceMappingURL;
if (fullSourceMappingURL) {
return fullSourceMappingURL;
}
const mapURL = SourceMapURL.getFrom(text);
if (!mapURL) {
return null;
}
if (!url) {
return null;
}
const baseURLs = url.match(/(.+:\/\/.*?)\//);
if (!baseURLs || baseURLs.length < 2) {
return null;
}
return baseURLs[1] + mapURL;
},
_getMainSourceMapURL(): Promise {
if (global.RAW_SOURCE_MAP) {
return Promise.resolve(global.RAW_SOURCE_MAP);
}
if (!RCTSourceCode) {
return Promise.reject(new Error('RCTSourceCode module is not available'));
}
if (!RCTNetworking) {
// Used internally by fetch
return Promise.reject(new Error('RCTNetworking module is not available'));
}
const scriptText = RCTSourceCode.getScriptText();
if (scriptText) {
return scriptText
.then(SourceMapsUtils.extractSourceMapURL)
.then((url) => {
if (url === null) {
return Promise.reject(new Error('No source map URL found. May be running from bundled file.'));
}
return Promise.resolve(url);
});
} else {
// Running in mock-config mode
return Promise.reject(new Error('Couldn\'t fetch script text'));
}
},
};
module.exports = SourceMapsUtils;