mirror of
https://github.com/status-im/react-native.git
synced 2025-01-11 01:56:26 +00:00
d5e9e55fa3
Summary: This PR removes the need for having the `providesModule` tags in all the modules in the repository. It configures Flow, Jest and Metro to get the module names from the filenames (`Libraries/Animated/src/nodes/AnimatedInterpolation.js` => `AnimatedInterpolation`) * Checked the Flow configuration by running flow on the project root (no errors): ``` yarn flow ``` * Checked the Jest configuration by running the tests with a clean cache: ``` yarn jest --clearCache && yarn test ``` * Checked the Metro configuration by starting the server with a clean cache and requesting some bundles: ``` yarn run start --reset-cache curl 'localhost:8081/IntegrationTests/AccessibilityManagerTest.bundle?platform=android' curl 'localhost:8081/Libraries/Alert/Alert.bundle?platform=ios' ``` [INTERNAL] [FEATURE] [All] - Removed providesModule from all modules and configured tools. Closes https://github.com/facebook/react-native/pull/18995 Reviewed By: mjesun Differential Revision: D7729509 Pulled By: rubennorte fbshipit-source-id: 892f760a05ce1fddb088ff0cd2e97e521fb8e825
70 lines
1.7 KiB
JavaScript
70 lines
1.7 KiB
JavaScript
/**
|
|
* Copyright (c) 2013-present, Facebook, Inc.
|
|
*
|
|
* This source code is licensed under the MIT license found in the
|
|
* LICENSE file in the root directory of this source tree.
|
|
*
|
|
* @format
|
|
* @flow
|
|
*/
|
|
|
|
'use strict';
|
|
|
|
const Blob = require('Blob');
|
|
|
|
const {BlobModule} = require('NativeModules');
|
|
|
|
let BLOB_URL_PREFIX = null;
|
|
|
|
if (BlobModule && typeof BlobModule.BLOB_URI_SCHEME === 'string') {
|
|
BLOB_URL_PREFIX = BlobModule.BLOB_URI_SCHEME + ':';
|
|
if (typeof BlobModule.BLOB_URI_HOST === 'string') {
|
|
BLOB_URL_PREFIX += `//${BlobModule.BLOB_URI_HOST}/`;
|
|
}
|
|
}
|
|
|
|
/**
|
|
* To allow Blobs be accessed via `content://` URIs,
|
|
* you need to register `BlobProvider` as a ContentProvider in your app's `AndroidManifest.xml`:
|
|
*
|
|
* ```xml
|
|
* <manifest>
|
|
* <application>
|
|
* <provider
|
|
* android:name="com.facebook.react.modules.blob.BlobProvider"
|
|
* android:authorities="@string/blob_provider_authority"
|
|
* android:exported="false"
|
|
* />
|
|
* </application>
|
|
* </manifest>
|
|
* ```
|
|
* And then define the `blob_provider_authority` string in `res/values/strings.xml`.
|
|
* Use a dotted name that's entirely unique to your app:
|
|
*
|
|
* ```xml
|
|
* <resources>
|
|
* <string name="blob_provider_authority">your.app.package.blobs</string>
|
|
* </resources>
|
|
* ```
|
|
*/
|
|
class URL {
|
|
constructor() {
|
|
throw new Error('Creating URL objects is not supported yet.');
|
|
}
|
|
|
|
static createObjectURL(blob: Blob) {
|
|
if (BLOB_URL_PREFIX === null) {
|
|
throw new Error('Cannot create URL for blob!');
|
|
}
|
|
return `${BLOB_URL_PREFIX}${blob.data.blobId}?offset=${
|
|
blob.data.offset
|
|
}&size=${blob.size}`;
|
|
}
|
|
|
|
static revokeObjectURL(url: string) {
|
|
// Do nothing.
|
|
}
|
|
}
|
|
|
|
module.exports = URL;
|