mirror of
https://github.com/zhigang1992/react-native.git
synced 2026-02-02 09:08:58 +08:00
Updates from Fri 13 Mar
- [ReactNative] Oss ActionSheet | Tadeu Zagallo - [ReactNative] Fix ScrollView.scrollTo() | Christopher Chedeau - [catalyst|madman] fix location observer | Jiajie Zhu - [ReactNative] Remove keyboardDismissMode from static | Christopher Chedeau - [ReactNative] Fix RCTMapManager retaining cycle | Tadeu Zagallo - [ReactNative] Support loading sourcemaps from sourceMappingURL | Alex Kotliarskyi - [catalyst] set up directory specific rql transform | Bhuwan Khattar - [React Native] Add .done() to terminate promise chains | Ben Alpert - [React Native] add support for reading tracking bit | Owen Coutts
This commit is contained in:
@@ -2,23 +2,42 @@
|
||||
* Copyright 2004-present Facebook. All Rights Reserved.
|
||||
*
|
||||
* @providesModule loadSourceMap
|
||||
* @flow
|
||||
*/
|
||||
|
||||
'use strict';
|
||||
|
||||
var Promise = require('Promise');
|
||||
var RCTSourceCode = require('NativeModules').RCTSourceCode;
|
||||
var SourceMapConsumer = require('SourceMap').SourceMapConsumer;
|
||||
var SourceMapURL = require('./source-map-url');
|
||||
|
||||
var sourceMapInstance;
|
||||
var fetch = require('fetch');
|
||||
|
||||
function loadSourceMap() {
|
||||
if (sourceMapInstance !== undefined) {
|
||||
return sourceMapInstance;
|
||||
function loadSourceMap(): Promise {
|
||||
return fetchSourceMap()
|
||||
.then(map => new SourceMapConsumer(map));
|
||||
}
|
||||
|
||||
function fetchSourceMap(): Promise {
|
||||
if (global.RAW_SOURCE_MAP) {
|
||||
return Promise.resolve(global.RAW_SOURCE_MAP);
|
||||
}
|
||||
if (!global.RAW_SOURCE_MAP) {
|
||||
return null;
|
||||
|
||||
if (!RCTSourceCode) {
|
||||
return Promise.reject(new Error('RCTSourceCode module is not available'));
|
||||
}
|
||||
sourceMapInstance = new SourceMapConsumer(global.RAW_SOURCE_MAP);
|
||||
return sourceMapInstance;
|
||||
|
||||
return new Promise(RCTSourceCode.getScriptText)
|
||||
.then(extractSourceMapURL)
|
||||
.then(fetch)
|
||||
.then(response => response.text())
|
||||
}
|
||||
|
||||
function extractSourceMapURL({url, text}): string {
|
||||
var mapURL = SourceMapURL.getFrom(text);
|
||||
var baseURL = url.match(/(.+:\/\/.*?)\//)[1];
|
||||
return baseURL + mapURL;
|
||||
}
|
||||
|
||||
module.exports = loadSourceMap;
|
||||
|
||||
Reference in New Issue
Block a user