mirror of
https://github.com/status-im/react-native.git
synced 2025-01-10 01:25:39 +00:00
28aa691d13
- [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
44 lines
1.0 KiB
JavaScript
44 lines
1.0 KiB
JavaScript
/**
|
|
* 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 fetch = require('fetch');
|
|
|
|
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 (!RCTSourceCode) {
|
|
return Promise.reject(new Error('RCTSourceCode module is not available'));
|
|
}
|
|
|
|
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;
|