diff --git a/Libraries/Blob/NativeBlobModule.js b/Libraries/Blob/NativeBlobModule.js index ab2572bd0ea..d58aeeab6eb 100644 --- a/Libraries/Blob/NativeBlobModule.js +++ b/Libraries/Blob/NativeBlobModule.js @@ -23,4 +23,38 @@ export interface Spec extends TurboModule { +release: (blobId: string) => void; } -export default (TurboModuleRegistry.get('BlobModule'): ?Spec); +const NativeModule = TurboModuleRegistry.get('BlobModule'); + +let constants = null; +let NativeBlobModule = null; + +if (NativeModule != null) { + NativeBlobModule = { + getConstants(): {|BLOB_URI_SCHEME: ?string, BLOB_URI_HOST: ?string|} { + if (constants == null) { + constants = NativeModule.getConstants(); + } + return constants; + }, + addNetworkingHandler(): void { + NativeModule.addNetworkingHandler(); + }, + addWebSocketHandler(id: number): void { + NativeModule.addWebSocketHandler(id); + }, + removeWebSocketHandler(id: number): void { + NativeModule.removeWebSocketHandler(id); + }, + sendOverSocket(blob: Object, socketID: number): void { + NativeModule.sendOverSocket(blob, socketID); + }, + createFromParts(parts: Array, withId: string): void { + NativeModule.createFromParts(parts, withId); + }, + release(blobId: string): void { + NativeModule.release(blobId); + }, + }; +} + +export default (NativeBlobModule: ?Spec); diff --git a/Libraries/NativeModules/specs/NativeSourceCode.js b/Libraries/NativeModules/specs/NativeSourceCode.js index 7bcd16bdf8e..903123c94da 100644 --- a/Libraries/NativeModules/specs/NativeSourceCode.js +++ b/Libraries/NativeModules/specs/NativeSourceCode.js @@ -19,4 +19,19 @@ export interface Spec extends TurboModule { |}; } -export default (TurboModuleRegistry.getEnforcing('SourceCode'): Spec); +const NativeModule = TurboModuleRegistry.getEnforcing('SourceCode'); +let constants = null; + +const NativeSourceCode = { + getConstants(): {| + scriptURL: string, + |} { + if (constants == null) { + constants = NativeModule.getConstants(); + } + + return constants; + }, +}; + +export default NativeSourceCode;