Revert D15495065: Add method to get a segment path without injecting it in the VM
Differential Revision: D15495065 Original commit changeset: 6537100d8b6d fbshipit-source-id: fee8319eaa5461f11ee4ea8d3b9d25e211beb2a8
This commit is contained in:
Родитель
171cc0edb7
Коммит
99bb710617
|
@ -18,11 +18,6 @@ export interface Spec extends TurboModule {
|
|||
options: Object, // flowlint-line unclear-type: off
|
||||
callback: (error: ?Object) => void, // flowlint-line unclear-type: off
|
||||
) => void;
|
||||
+getSegment?: (
|
||||
segmentId: number,
|
||||
options: Object, // flowlint-line unclear-type: off
|
||||
callback: (error: ?Object, path: ?string) => void, // flowlint-line unclear-type: off
|
||||
) => void;
|
||||
}
|
||||
|
||||
export default TurboModuleRegistry.getEnforcing<Spec>('SegmentFetcher');
|
||||
|
|
|
@ -9,20 +9,13 @@
|
|||
*/
|
||||
'use strict';
|
||||
|
||||
export type FetchSegmentFunction = typeof __fetchSegment;
|
||||
export type GetSegmentFunction = typeof __getSegment;
|
||||
|
||||
/**
|
||||
* Set up SegmentFetcher.
|
||||
* You can use this module directly, or just require InitializeCore.
|
||||
*/
|
||||
|
||||
function __fetchSegment(
|
||||
global.__fetchSegment = function(
|
||||
segmentId: number,
|
||||
options: {|
|
||||
+otaBuildNumber: ?string,
|
||||
+requestedModuleName?: ?string,
|
||||
|},
|
||||
options: {|+otaBuildNumber: ?string|},
|
||||
callback: (?Error) => void,
|
||||
) {
|
||||
const SegmentFetcher = require('./SegmentFetcher/NativeSegmentFetcher')
|
||||
|
@ -40,38 +33,4 @@ function __fetchSegment(
|
|||
callback(null);
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
global.__fetchSegment = __fetchSegment;
|
||||
|
||||
function __getSegment(
|
||||
segmentId: number,
|
||||
options: {|
|
||||
+otaBuildNumber: ?string,
|
||||
+requestedModuleName?: ?string,
|
||||
|},
|
||||
callback: (?Error, ?string) => void,
|
||||
) {
|
||||
const SegmentFetcher = require('./SegmentFetcher/NativeSegmentFetcher')
|
||||
.default;
|
||||
|
||||
if (!SegmentFetcher.getSegment) {
|
||||
throw new Error('SegmentFetcher.getSegment must be defined');
|
||||
}
|
||||
|
||||
SegmentFetcher.getSegment(
|
||||
segmentId,
|
||||
options,
|
||||
(errorObject: ?{message: string, code: string}, path: ?string) => {
|
||||
if (errorObject) {
|
||||
const error = new Error(errorObject.message);
|
||||
(error: any).code = errorObject.code; // flowlint-line unclear-type: off
|
||||
callback(error);
|
||||
}
|
||||
|
||||
callback(null, path);
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
global.__getSegment = __getSegment;
|
||||
};
|
||||
|
|
Загрузка…
Ссылка в новой задаче