Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
TODO: - [x] Update typescript - [x] Update eslint plugins - [x] Fix ts errors - [x] Fix eslint errors How was changed compilations output: <details> <summary>diff: lib/dist</summary> ```diff index bb7566a47..32be1e8d4 100644 --- a/lib/dist/Mock/Application.js +++ b/lib/dist/Mock/Application.js @@ -2,10 +2,10 @@ Object.defineProperty(exports, "__esModule", { value: true }); exports.Application = void 0; const tslib_1 = require("tslib"); -const React = tslib_1.__importStar(require("react")); +const React = (0, tslib_1.__importStar)(require("react")); const react_native_1 = require("react-native"); const connect_1 = require("./connect"); -exports.Application = connect_1.connect(class extends React.Component { +exports.Application = (0, connect_1.connect)(class extends React.Component { constructor(props) { super(props); props.entryPoint(); diff --git a/lib/dist/Mock/Components/BottomTabs.js b/lib/dist/Mock/Components/BottomTabs.js index 0eacd9f6a..ffd403db7 100644 --- a/lib/dist/Mock/Components/BottomTabs.js +++ b/lib/dist/Mock/Components/BottomTabs.js @@ -2,10 +2,10 @@ Object.defineProperty(exports, "__esModule", { value: true }); exports.BottomTabs = void 0; const tslib_1 = require("tslib"); -const react_1 = tslib_1.__importStar(require("react")); +const react_1 = (0, tslib_1.__importStar)(require("react")); const LayoutComponent_1 = require("./LayoutComponent"); const connect_1 = require("../connect"); -exports.BottomTabs = connect_1.connect(class extends react_1.Component { +exports.BottomTabs = (0, connect_1.connect)(class extends react_1.Component { render() { return this.props.layoutNode.children.map((child) => { return react_1.default.createElement(LayoutComponent_1.LayoutComponent, { key: child.nodeId, layoutNode: child }); diff --git a/lib/dist/Mock/Components/ComponentScreen.js b/lib/dist/Mock/Components/ComponentScreen.js index c23f91d91..d030db91a 100644 --- a/lib/dist/Mock/Components/ComponentScreen.js +++ b/lib/dist/Mock/Components/ComponentScreen.js @@ -2,14 +2,14 @@ Object.defineProperty(exports, "__esModule", { value: true }); exports.ComponentScreen = void 0; const tslib_1 = require("tslib"); -const react_1 = tslib_1.__importStar(require("react")); +const react_1 = (0, tslib_1.__importStar)(require("react")); const react_native_1 = require("react-native"); const __1 = require("../.."); const constants_1 = require("../constants"); const LayoutStore_1 = require("../Stores/LayoutStore"); const connect_1 = require("../connect"); const TopBar_1 = require("./TopBar"); -exports.ComponentScreen = connect_1.connect(class extends react_1.Component { +exports.ComponentScreen = (0, connect_1.connect)(class extends react_1.Component { constructor(props) { super(props); } diff --git a/lib/dist/Mock/Components/LayoutComponent.js b/lib/dist/Mock/Components/LayoutComponent.js index f29b2eb52..593382929 100644 --- a/lib/dist/Mock/Components/LayoutComponent.js +++ b/lib/dist/Mock/Components/LayoutComponent.js @@ -2,12 +2,12 @@ Object.defineProperty(exports, "__esModule", { value: true }); exports.LayoutComponent = void 0; const tslib_1 = require("tslib"); -const react_1 = tslib_1.__importStar(require("react")); +const react_1 = (0, tslib_1.__importStar)(require("react")); const react_native_1 = require("react-native"); const BottomTabs_1 = require("./BottomTabs"); const ComponentScreen_1 = require("./ComponentScreen"); const Stack_1 = require("./Stack"); -exports.LayoutComponent = class extends react_1.Component { +const LayoutComponent = class extends react_1.Component { render() { switch (this.props.layoutNode.type) { case 'BottomTabs': @@ -20,3 +20,4 @@ exports.LayoutComponent = class extends react_1.Component { return react_1.default.createElement(react_native_1.View, null); } }; +exports.LayoutComponent = LayoutComponent; diff --git a/lib/dist/Mock/Components/Modals.js b/lib/dist/Mock/Components/Modals.js index 8ac96a790..c6275458f 100644 --- a/lib/dist/Mock/Components/Modals.js +++ b/lib/dist/Mock/Components/Modals.js @@ -2,12 +2,12 @@ Object.defineProperty(exports, "__esModule", { value: true }); exports.Modals = void 0; const tslib_1 = require("tslib"); -const react_1 = tslib_1.__importStar(require("react")); +const react_1 = (0, tslib_1.__importStar)(require("react")); const react_native_1 = require("react-native"); const LayoutComponent_1 = require("./LayoutComponent"); const LayoutStore_1 = require("../Stores/LayoutStore"); const connect_1 = require("../connect"); -exports.Modals = connect_1.connect(class extends react_1.Component { +exports.Modals = (0, connect_1.connect)(class extends react_1.Component { render() { const children = LayoutStore_1.LayoutStore.getModals(); return (react_1.default.createElement(react_native_1.View, { testID: 'MODALS' }, children.map((child) => { diff --git a/lib/dist/Mock/Components/NavigationButton.js b/lib/dist/Mock/Components/NavigationButton.js index 2cb32877a..84ce46707 100644 --- a/lib/dist/Mock/Components/NavigationButton.js +++ b/lib/dist/Mock/Components/NavigationButton.js @@ -2,15 +2,12 @@ Object.defineProperty(exports, "__esModule", { value: true }); exports.NavigationButton = void 0; const tslib_1 = require("tslib"); -const react_1 = tslib_1.__importStar(require("react")); +const react_1 = (0, tslib_1.__importStar)(require("react")); const react_native_1 = require("react-native"); const __1 = require("../../"); const EventsStore_1 = require("../Stores/EventsStore"); -exports.NavigationButton = class extends react_1.Component { - constructor() { - super(...arguments); - this.ref = undefined; - } +const NavigationButton = class extends react_1.Component { + ref = undefined; render() { const { button, componentId } = this.props; if (button.component) @@ -38,7 +35,7 @@ exports.NavigationButton = class extends react_1.Component { componentId: componentId, }); }, testID: button.testID }, - react_1.default.createElement(Component, Object.assign({ key: buttonComponentId }, props, { componentId: buttonComponentId, ref: (ref) => (this.ref = ref) })))); + react_1.default.createElement(Component, { key: buttonComponentId, ...props, componentId: buttonComponentId, ref: (ref) => (this.ref = ref) }))); } invokeOnClick(stateNode) { if (stateNode.children) { @@ -53,3 +50,4 @@ exports.NavigationButton = class extends react_1.Component { } } }; +exports.NavigationButton = NavigationButton; diff --git a/lib/dist/Mock/Components/Overlays.js b/lib/dist/Mock/Components/Overlays.js index f20cb399c..f9d336bd9 100644 --- a/lib/dist/Mock/Components/Overlays.js +++ b/lib/dist/Mock/Components/Overlays.js @@ -2,13 +2,13 @@ Object.defineProperty(exports, "__esModule", { value: true }); exports.Overlays = void 0; const tslib_1 = require("tslib"); -const react_1 = tslib_1.__importStar(require("react")); +const react_1 = (0, tslib_1.__importStar)(require("react")); const react_native_1 = require("react-native"); const constants_1 = require("../constants"); const LayoutComponent_1 = require("./LayoutComponent"); const LayoutStore_1 = require("../Stores/LayoutStore"); const connect_1 = require("../connect"); -exports.Overlays = connect_1.connect(class extends react_1.Component { +exports.Overlays = (0, connect_1.connect)(class extends react_1.Component { render() { const children = LayoutStore_1.LayoutStore.getOverlays(); return (react_1.default.createElement(react_native_1.View, { testID: constants_1.VISIBLE_OVERLAY_TEST_ID }, children.map((child) => { diff --git a/lib/dist/Mock/Components/Stack.js b/lib/dist/Mock/Components/Stack.js index d2586c8b5..602089fc1 100644 --- a/lib/dist/Mock/Components/Stack.js +++ b/lib/dist/Mock/Components/Stack.js @@ -2,10 +2,10 @@ Object.defineProperty(exports, "__esModule", { value: true }); exports.Stack = void 0; const tslib_1 = require("tslib"); -const react_1 = tslib_1.__importStar(require("react")); +const react_1 = (0, tslib_1.__importStar)(require("react")); const LayoutComponent_1 = require("./LayoutComponent"); const connect_1 = require("../connect"); -exports.Stack = connect_1.connect(class extends react_1.Component { +exports.Stack = (0, connect_1.connect)(class extends react_1.Component { render() { const children = this.props.layoutNode.children; return children.map((child, i) => { diff --git a/lib/dist/Mock/Components/TopBar.js b/lib/dist/Mock/Components/TopBar.js index 9482bc4d4..2140a3f3d 100644 --- a/lib/dist/Mock/Components/TopBar.js +++ b/lib/dist/Mock/Components/TopBar.js @@ -2,14 +2,14 @@ Object.defineProperty(exports, "__esModule", { value: true }); exports.TopBar = void 0; const tslib_1 = require("tslib"); -const react_1 = tslib_1.__importStar(require("react")); +const react_1 = (0, tslib_1.__importStar)(require("react")); const react_native_1 = require("react-native"); const __1 = require("../.."); const LayoutStore_1 = require("../Stores/LayoutStore"); const NavigationButton_1 = require("./NavigationButton"); const EventsStore_1 = require("../Stores/EventsStore"); const DEFAULT_BACK_BUTTON_ID = 'RNN.back'; -exports.TopBar = class extends react_1.Component { +const TopBar = class extends react_1.Component { constructor(props) { super(props); } @@ -57,6 +57,7 @@ exports.TopBar = class extends react_1.Component { const Component = __1.Navigation.mock.store.getComponentClassForName(name)(); const props = __1.Navigation.mock.store.getPropsForId(id); return (react_1.default.createElement(react_native_1.View, { key: id, testID: testID }, - react_1.default.createElement(Component, Object.assign({}, props, { componentId: id })))); + react_1.default.createElement(Component, { ...props, componentId: id }))); } }; +exports.TopBar = TopBar; diff --git a/lib/dist/Mock/Layouts/BottomTabsNode.js b/lib/dist/Mock/Layouts/BottomTabsNode.js index 82625609f..97a97df43 100644 --- a/lib/dist/Mock/Layouts/BottomTabsNode.js +++ b/lib/dist/Mock/Layouts/BottomTabsNode.js @@ -1,13 +1,13 @@ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const tslib_1 = require("tslib"); -const lodash_1 = tslib_1.__importDefault(require("lodash")); +const lodash_1 = (0, tslib_1.__importDefault)(require("lodash")); const LayoutStore_1 = require("../Stores/LayoutStore"); -const ParentNode_1 = tslib_1.__importDefault(require("./ParentNode")); +const ParentNode_1 = (0, tslib_1.__importDefault)(require("./ParentNode")); class BottomTabsNode extends ParentNode_1.default { + selectedIndex = 0; constructor(layout, parentNode) { super(layout, 'BottomTabs', parentNode); - this.selectedIndex = 0; } mergeOptions(options) { super.mergeOptions(options); diff --git a/lib/dist/Mock/Layouts/ComponentNode.js b/lib/dist/Mock/Layouts/ComponentNode.js index 6ff44f821..50f3629ec 100644 --- a/lib/dist/Mock/Layouts/ComponentNode.js +++ b/lib/dist/Mock/Layouts/ComponentNode.js @@ -1,14 +1,14 @@ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const tslib_1 = require("tslib"); -const lodash_1 = tslib_1.__importDefault(require("lodash")); +const lodash_1 = (0, tslib_1.__importDefault)(require("lodash")); const EventsStore_1 = require("../Stores/EventsStore"); -const ParentNode_1 = tslib_1.__importDefault(require("./ParentNode")); +const ParentNode_1 = (0, tslib_1.__importDefault)(require("./ParentNode")); class ComponentNode extends ParentNode_1.default { + componentDidMountOnce = false; + componentDidAppearPending = false; constructor(layout, parentNode) { super(layout, 'Component', parentNode); - this.componentDidMountOnce = false; - this.componentDidAppearPending = false; } componentDidMount() { this.componentDidMountOnce = true; diff --git a/lib/dist/Mock/Layouts/LayoutNodeFactory.js b/lib/dist/Mock/Layouts/LayoutNodeFactory.js index 2a5d9fa1a..1ea4e18b9 100644 --- a/lib/dist/Mock/Layouts/LayoutNodeFactory.js +++ b/lib/dist/Mock/Layouts/LayoutNodeFactory.js @@ -1,9 +1,9 @@ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const tslib_1 = require("tslib"); -const BottomTabsNode_1 = tslib_1.__importDefault(require("./BottomTabsNode")); -const ComponentNode_1 = tslib_1.__importDefault(require("./ComponentNode")); -const StackNode_1 = tslib_1.__importDefault(require("./StackNode")); +const BottomTabsNode_1 = (0, tslib_1.__importDefault)(require("./BottomTabsNode")); +const ComponentNode_1 = (0, tslib_1.__importDefault)(require("./ComponentNode")); +const StackNode_1 = (0, tslib_1.__importDefault)(require("./StackNode")); class LayoutNodeFactory { static create(layout, parentNode) { switch (layout.type) { diff --git a/lib/dist/Mock/Layouts/Node.js b/lib/dist/Mock/Layouts/Node.js index f03599138..04bc68354 100644 --- a/lib/dist/Mock/Layouts/Node.js +++ b/lib/dist/Mock/Layouts/Node.js @@ -1,6 +1,11 @@ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); class Node { + nodeId; + data; + type; + // options: Options; + parentNode; constructor(layout, type, parentNode) { this.nodeId = layout.id; this.data = layout.data; diff --git a/lib/dist/Mock/Layouts/ParentNode.js b/lib/dist/Mock/Layouts/ParentNode.js index c446dcd8b..0ba4f703e 100644 --- a/lib/dist/Mock/Layouts/ParentNode.js +++ b/lib/dist/Mock/Layouts/ParentNode.js @@ -1,11 +1,12 @@ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const tslib_1 = require("tslib"); -const lodash_1 = tslib_1.__importDefault(require("lodash")); +const lodash_1 = (0, tslib_1.__importDefault)(require("lodash")); const LayoutStore_1 = require("../Stores/LayoutStore"); -const LayoutNodeFactory_1 = tslib_1.__importDefault(require("./LayoutNodeFactory")); -const Node_1 = tslib_1.__importDefault(require("./Node")); +const LayoutNodeFactory_1 = (0, tslib_1.__importDefault)(require("./LayoutNodeFactory")); +const Node_1 = (0, tslib_1.__importDefault)(require("./Node")); class ParentNode extends Node_1.default { + children; constructor(layout, type, parentNode) { super(layout, type, parentNode); this.children = layout.children.map((childLayout) => LayoutNodeFactory_1.default.create(childLayout, this)); diff --git a/lib/dist/Mock/Layouts/StackNode.js b/lib/dist/Mock/Layouts/StackNode.js index 2093e7b23..7d78383cf 100644 --- a/lib/dist/Mock/Layouts/StackNode.js +++ b/lib/dist/Mock/Layouts/StackNode.js @@ -1,7 +1,7 @@ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const tslib_1 = require("tslib"); -const ParentNode_1 = tslib_1.__importDefault(require("./ParentNode")); +const ParentNode_1 = (0, tslib_1.__importDefault)(require("./ParentNode")); class StackNode extends ParentNode_1.default { constructor(layout, parentNode) { super(layout, 'Stack', parentNode); diff --git a/lib/dist/Mock/Stores/LayoutStore.js b/lib/dist/Mock/Stores/LayoutStore.js index 1aa3bcde3..0bb08f41b 100644 --- a/lib/dist/Mock/Stores/LayoutStore.js +++ b/lib/dist/Mock/Stores/LayoutStore.js @@ -2,8 +2,8 @@ Object.defineProperty(exports, "__esModule", { value: true }); exports.LayoutStore = void 0; const tslib_1 = require("tslib"); -const lodash_1 = tslib_1.__importDefault(require("lodash")); -const LayoutNodeFactory_1 = tslib_1.__importDefault(require("../Layouts/LayoutNodeFactory")); +const lodash_1 = (0, tslib_1.__importDefault)(require("lodash")); +const LayoutNodeFactory_1 = (0, tslib_1.__importDefault)(require("../Layouts/LayoutNodeFactory")); const remx = require('remx'); const state = remx.state({ root: {}, diff --git a/lib/dist/Mock/connect.js b/lib/dist/Mock/connect.js index ca7b3b493..c9fa9cdfa 100644 --- a/lib/dist/Mock/connect.js +++ b/lib/dist/Mock/connect.js @@ -4,6 +4,6 @@ exports.connect = void 0; const remx_1 = require("remx"); function connect(component) { // @ts-ignore - return remx_1.connect()(component); + return (0, remx_1.connect)()(component); } exports.connect = connect; diff --git a/lib/dist/Mock/index.js b/lib/dist/Mock/index.js index 3720f4cf6..26e72e816 100644 --- a/lib/dist/Mock/index.js +++ b/lib/dist/Mock/index.js @@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true }); exports.mockNativeComponents = exports.ApplicationMock = void 0; const tslib_1 = require("tslib"); exports.ApplicationMock = require('./Application').Application; -tslib_1.__exportStar(require("./constants"), exports); +(0, tslib_1.__exportStar)(require("./constants"), exports); function mockNativeComponents() { const { NativeCommandsSender } = require('./mocks/NativeCommandsSender'); const { NativeEventsReceiver } = require('./mocks/NativeEventsReceiver'); diff --git a/lib/dist/Mock/mocks/NativeCommandsSender.js b/lib/dist/Mock/mocks/NativeCommandsSender.js index 145c82361..3d64226dd 100644 --- a/lib/dist/Mock/mocks/NativeCommandsSender.js +++ b/lib/dist/Mock/mocks/NativeCommandsSender.js @@ -3,9 +3,9 @@ Object.defineProperty(exports, "__esModule", { value: true }); exports.NativeCommandsSender = void 0; const tslib_1 = require("tslib"); const LayoutStore_1 = require("../Stores/LayoutStore"); -const LayoutNodeFactory_1 = tslib_1.__importDefault(require("../Layouts/LayoutNodeFactory")); +const LayoutNodeFactory_1 = (0, tslib_1.__importDefault)(require("../Layouts/LayoutNodeFactory")); const EventsStore_1 = require("../Stores/EventsStore"); -const lodash_1 = tslib_1.__importDefault(require("lodash")); +const lodash_1 = (0, tslib_1.__importDefault)(require("lodash")); class NativeCommandsSender { constructor() { } setRoot(_commandId, layout) { diff --git a/lib/dist/Mock/mocks/NativeEventsReceiver.js b/lib/dist/Mock/mocks/NativeEventsReceiver.js index dcb7de6d1..513cfd44a 100644 --- a/lib/dist/Mock/mocks/NativeEventsReceiver.js +++ b/lib/dist/Mock/mocks/NativeEventsReceiver.js @@ -2,7 +2,7 @@ Object.defineProperty(exports, "__esModule", { value: true }); exports.NativeEventsReceiver = void 0; const tslib_1 = require("tslib"); -const lodash_1 = tslib_1.__importDefault(require("lodash")); +const lodash_1 = (0, tslib_1.__importDefault)(require("lodash")); const EventsStore_1 = require("./../Stores/EventsStore"); class NativeEventsReceiver { registerAppLaunchedListener(callback) { diff --git a/lib/dist/Navigation.js b/lib/dist/Navigation.js index 200c8e56a..ceabecc4a 100644 --- a/lib/dist/Navigation.js +++ b/lib/dist/Navigation.js @@ -2,7 +2,7 @@ Object.defineProperty(exports, "__esModule", { value: true }); exports.NavigationRoot = void 0; const tslib_1 = require("tslib"); -const isArray_1 = tslib_1.__importDefault(require("lodash/isArray")); +const isArray_1 = (0, tslib_1.__importDefault)(require("lodash/isArray")); const UniqueIdProvider_1 = require("./adapters/UniqueIdProvider"); const Store_1 = require("./components/Store"); const OptionProcessorsStore_1 = require("./processors/OptionProcessorsStore"); @@ -24,11 +24,27 @@ const LayoutProcessor_1 = require("./processors/LayoutProcessor"); const LayoutProcessorsStore_1 = require("./processors/LayoutProcessorsStore"); const OptionsCrawler_1 = require("./commands/OptionsCrawler"); class NavigationRoot { + nativeCommandsSender; + nativeEventsReceiver; + appRegistryService; + TouchablePreview = TouchablePreview_1.TouchablePreview; + store; + optionProcessorsStore; + layoutProcessorsStore; + uniqueIdProvider; + componentRegistry; + layoutTreeParser; + layoutTreeCrawler; + commands; + eventsRegistry; + commandsObserver; + componentEventsObserver; + componentWrapper; + optionsCrawler; constructor(nativeCommandsSender, nativeEventsReceiver, appRegistryService) { this.nativeCommandsSender = nativeCommandsSender; this.nativeEventsReceiver = nativeEventsReceiver; this.appRegistryService = appRegistryService; - this.TouchablePreview = TouchablePreview_1.TouchablePreview; this.componentWrapper = new ComponentWrapper_1.ComponentWrapper(); this.store = new Store_1.Store(); this.optionProcessorsStore = new OptionProcessorsStore_1.OptionProcessorsStore(); @@ -147,7 +163,7 @@ class NavigationRoot { * Sets new root component to stack. */ setStackRoot(componentId, layout) { - const children = isArray_1.default(layout) ? layout : [layout]; + const children = (0, isArray_1.default)(layout) ? layout : [layout]; return this.commands.setStackRoot(componentId, children); } /** diff --git a/lib/dist/NavigationDelegate.js b/lib/dist/NavigationDelegate.js index 745e950d0..e4b83a973 100644 --- a/lib/dist/NavigationDelegate.js +++ b/lib/dist/NavigationDelegate.js @@ -6,6 +6,7 @@ const NativeCommandsSender_1 = require("./adapters/NativeCommandsSender"); const NativeEventsReceiver_1 = require("./adapters/NativeEventsReceiver"); const AppRegistryService_1 = require("./adapters/AppRegistryService"); class NavigationDelegate { + concreteNavigation; constructor() { this.concreteNavigation = this.createConcreteNavigation(new NativeCommandsSender_1.NativeCommandsSender(), new NativeEventsReceiver_1.NativeEventsReceiver(), new AppRegistryService_1.AppRegistryService()); } diff --git a/lib/dist/adapters/ColorService.d.ts b/lib/dist/adapters/ColorService.d.ts index ab3e0ca04..6af546721 100644 --- a/lib/dist/adapters/ColorService.d.ts +++ b/lib/dist/adapters/ColorService.d.ts @@ -1,3 +1,3 @@ export declare class ColorService { - toNativeColor(inputColor: string): number | typeof import("react-native").OpaqueColorValue | null | undefined; + toNativeColor(inputColor: string): import("react-native").ProcessedColorValue | null | undefined; } diff --git a/lib/dist/adapters/ColorService.js b/lib/dist/adapters/ColorService.js index b9ebf7fef..96fdc3fc8 100644 --- a/lib/dist/adapters/ColorService.js +++ b/lib/dist/adapters/ColorService.js @@ -4,7 +4,7 @@ exports.ColorService = void 0; const react_native_1 = require("react-native"); class ColorService { toNativeColor(inputColor) { - return react_native_1.processColor(inputColor); + return (0, react_native_1.processColor)(inputColor); } } exports.ColorService = ColorService; diff --git a/lib/dist/adapters/Constants.js b/lib/dist/adapters/Constants.js index dea12936d..114a4c85d 100644 --- a/lib/dist/adapters/Constants.js +++ b/lib/dist/adapters/Constants.js @@ -3,12 +3,6 @@ Object.defineProperty(exports, "__esModule", { value: true }); exports.Constants = void 0; const react_native_1 = require("react-native"); class Constants { - constructor(constants) { - this.statusBarHeight = constants.statusBarHeight; - this.topBarHeight = constants.topBarHeight; - this.backButtonId = constants.backButtonId; - this.bottomTabsHeight = constants.bottomTabsHeight; - } static async get() { const constants = await react_native_1.NativeModules.RNNBridgeModule.getNavigationConstants(); return new Constants(constants); @@ -16,5 +10,15 @@ class Constants { static getSync() { return new Constants(react_native_1.NativeModules.RNNBridgeModule.getNavigationConstantsSync()); } + statusBarHeight; + backButtonId; + topBarHeight; + bottomTabsHeight; + constructor(constants) { + this.statusBarHeight = constants.statusBarHeight; + this.topBarHeight = constants.topBarHeight; + this.backButtonId = constants.backButtonId; + this.bottomTabsHeight = constants.bottomTabsHeight; + } } exports.Constants = Constants; diff --git a/lib/dist/adapters/NativeCommandsSender.js b/lib/dist/adapters/NativeCommandsSender.js index c58050b0b..3ef9607dc 100644 --- a/lib/dist/adapters/NativeCommandsSender.js +++ b/lib/dist/adapters/NativeCommandsSender.js @@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true }); exports.NativeCommandsSender = void 0; const react_native_1 = require("react-native"); class NativeCommandsSender { + nativeCommandsModule; constructor() { this.nativeCommandsModule = react_native_1.NativeModules.RNNBridgeModule; } diff --git a/lib/dist/adapters/NativeEventsReceiver.js b/lib/dist/adapters/NativeEventsReceiver.js index af2d45e3e..f04bcb888 100644 --- a/lib/dist/adapters/NativeEventsReceiver.js +++ b/lib/dist/adapters/NativeEventsReceiver.js @@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true }); exports.NativeEventsReceiver = void 0; const react_native_1 = require("react-native"); class NativeEventsReceiver { + emitter; constructor() { // NOTE: This try catch is workaround for integration tests // TODO: mock NativeEventEmitter in integration tests rather done adding try catch in source code diff --git a/lib/dist/adapters/TouchablePreview.js b/lib/dist/adapters/TouchablePreview.js index 4eb1e86ba..4e792a6bc 100644 --- a/lib/dist/adapters/TouchablePreview.js +++ b/lib/dist/adapters/TouchablePreview.js @@ -2,61 +2,72 @@ Object.defineProperty(exports, "__esModule", { value: true }); exports.TouchablePreview = void 0; const tslib_1 = require("tslib"); -const React = tslib_1.__importStar(require("react")); -const PropTypes = tslib_1.__importStar(require("prop-types")); +const React = (0, tslib_1.__importStar)(require("react")); +const PropTypes = (0, tslib_1.__importStar)(require("prop-types")); const react_native_1 = require("react-native"); const PREVIEW_DELAY = 350; const PREVIEW_MIN_FORCE = 0.1; const PREVIEW_TIMEOUT = 1250; class TouchablePreview extends React.PureComponent { - constructor() { - super(...arguments); - this.touchStartedAt = 0; - this.onRef = React.createRef(); - this.onPress = () => { - const { onPress } = this.props; - if (typeof onPress !== 'function' || TouchablePreview.peeking) { + static propTypes = { + children: PropTypes.node, + touchableComponent: PropTypes.func, + onPress: PropTypes.func, + onPressIn: PropTypes.func, + onPeekIn: PropTypes.func, + onPeekOut: PropTypes.func, + label: PropTypes.string, + }; + static defaultProps = { + touchableComponent: react_native_1.TouchableWithoutFeedback, + }; + static peeking = false; + timeout; + touchStartedAt = 0; + onRef = React.createRef(); + onPress = () => { + const { onPress } = this.props; + if (typeof onPress !== 'function' || TouchablePreview.peeking) { + return; + } + return onPress(); + }; + onPressIn = () => { + if (react_native_1.Platform.OS === 'ios') { + const { onPressIn } = this.props; + if (!onPressIn) { return; } - return onPress(); - }; - this.onPressIn = () => { - if (react_native_1.Platform.OS === 'ios') { - const { onPressIn } = this.props; - if (!onPressIn) { - return; - } - const reactTag = react_native_1.findNodeHandle(this.onRef.current); - return onPressIn({ reactTag }); + const reactTag = (0, react_native_1.findNodeHandle)(this.onRef.current); + return onPressIn({ reactTag }); + } + // Other platforms don't support 3D Touch Preview API + return null; + }; + onTouchStart = (event) => { + // Store a timestamp of the initial touch start + this.touchStartedAt = event.nativeEvent.timestamp; + }; + onTouchMove = (event) => { + clearTimeout(this.timeout); + const { force, timestamp } = event.nativeEvent; + const diff = timestamp - this.touchStartedAt; + if (force > PREVIEW_MIN_FORCE && diff > PREVIEW_DELAY) { + TouchablePreview.peeking = true; + if (typeof this.props.onPeekIn === 'function') { + this.props.onPeekIn(); } - // Other platforms don't support 3D Touch Preview API - return null; - }; - this.onTouchStart = (event) => { - // Store a timestamp of the initial touch start - this.touchStartedAt = event.nativeEvent.timestamp; - }; - this.onTouchMove = (event) => { - clearTimeout(this.timeout); - const { force, timestamp } = event.nativeEvent; - const diff = timestamp - this.touchStartedAt; - if (force > PREVIEW_MIN_FORCE && diff > PREVIEW_DELAY) { - TouchablePreview.peeking = true; - if (typeof this.props.onPeekIn === 'function') { - this.props.onPeekIn(); - } - } - //@ts-ignore - this.timeout = setTimeout(this.onTouchEnd, PREVIEW_TIMEOUT); - }; - this.onTouchEnd = () => { - clearTimeout(this.timeout); - TouchablePreview.peeking = false; - if (typeof this.props.onPeekOut === 'function') { - this.props.onPeekOut(); - } - }; - } + } + //@ts-ignore + this.timeout = setTimeout(this.onTouchEnd, PREVIEW_TIMEOUT); + }; + onTouchEnd = () => { + clearTimeout(this.timeout); + TouchablePreview.peeking = false; + if (typeof this.props.onPeekOut === 'function') { + this.props.onPeekOut(); + } + }; render() { const { children, touchableComponent, ...props } = this.props; // Default to TouchableWithoutFeedback for iOS if set to TouchableNativeFeedback @@ -71,21 +82,8 @@ class TouchablePreview extends React.PureComponent { * Ignoring this for now so that it builds. */ // @ts-ignore - React.createElement(Touchable, Object.assign({}, props, { ref: this.onRef, onPress: this.onPress, onPressIn: this.onPressIn }), + React.createElement(Touchable, { ...props, ref: this.onRef, onPress: this.onPress, onPressIn: this.onPressIn }, React.createElement(react_native_1.View, { onTouchStart: this.onTouchStart, onTouchMove: this.onTouchMove, onTouchEnd: this.onTouchEnd }, children))); } } exports.TouchablePreview = TouchablePreview; -TouchablePreview.propTypes = { - children: PropTypes.node, - touchableComponent: PropTypes.func, - onPress: PropTypes.func, - onPressIn: PropTypes.func, - onPeekIn: PropTypes.func, - onPeekOut: PropTypes.func, - label: PropTypes.string, -}; -TouchablePreview.defaultProps = { - touchableComponent: react_native_1.TouchableWithoutFeedback, -}; -TouchablePreview.peeking = false; diff --git a/lib/dist/adapters/UniqueIdProvider.js b/lib/dist/adapters/UniqueIdProvider.js index f3b382a25..a1f75a00d 100644 --- a/lib/dist/adapters/UniqueIdProvider.js +++ b/lib/dist/adapters/UniqueIdProvider.js @@ -2,10 +2,10 @@ Object.defineProperty(exports, "__esModule", { value: true }); exports.UniqueIdProvider = void 0; const tslib_1 = require("tslib"); -const uniqueId_1 = tslib_1.__importDefault(require("lodash/uniqueId")); +const uniqueId_1 = (0, tslib_1.__importDefault)(require("lodash/uniqueId")); class UniqueIdProvider { generate(prefix) { - return uniqueId_1.default(prefix); + return (0, uniqueId_1.default)(prefix); } } exports.UniqueIdProvider = UniqueIdProvider; diff --git a/lib/dist/commands/Commands.js b/lib/dist/commands/Commands.js index c86ed714a..f13976c5a 100644 --- a/lib/dist/commands/Commands.js +++ b/lib/dist/commands/Commands.js @@ -2,11 +2,20 @@ Object.defineProperty(exports, "__esModule", { value: true }); exports.Commands = void 0; const tslib_1 = require("tslib"); -const cloneDeepWith_1 = tslib_1.__importDefault(require("lodash/cloneDeepWith")); -const cloneDeep_1 = tslib_1.__importDefault(require("lodash/cloneDeep")); -const map_1 = tslib_1.__importDefault(require("lodash/map")); +const cloneDeepWith_1 = (0, tslib_1.__importDefault)(require("lodash/cloneDeepWith")); +const cloneDeep_1 = (0, tslib_1.__importDefault)(require("lodash/cloneDeep")); +const map_1 = (0, tslib_1.__importDefault)(require("lodash/map")); const CommandName_1 = require("../interfaces/CommandName"); class Commands { + store; + nativeCommandsSender; + layoutTreeParser; + layoutTreeCrawler; + commandsObserver; + uniqueIdProvider; + optionsProcessor; + layoutProcessor; + optionsCrawler; constructor(store, nativeCommandsSender, layoutTreeParser, layoutTreeCrawler, commandsObserver, uniqueIdProvider, optionsProcessor, layoutProcessor, optionsCrawler) { this.store = store; this.nativeCommandsSender = nativeCommandsSender; @@ -23,12 +32,12 @@ class Commands { this.optionsCrawler.crawl(input.root); const processedRoot = this.layoutProcessor.process(input.root, CommandName_1.CommandName.SetRoot); const root = this.layoutTreeParser.parse(processedRoot); - const modals = map_1.default(input.modals, (modal) => { + const modals = (0, map_1.default)(input.modals, (modal) => { this.optionsCrawler.crawl(modal); const processedModal = this.layoutProcessor.process(modal, CommandName_1.CommandName.SetRoot); return this.layoutTreeParser.parse(processedModal); }); - const overlays = map_1.default(input.overlays, (overlay) => { + const overlays = (0, map_1.default)(input.overlays, (overlay) => { this.optionsCrawler.crawl(overlay); const processedOverlay = this.layoutProcessor.process(overlay, CommandName_1.CommandName.SetRoot); return this.layoutTreeParser.parse(processedOverlay); @@ -49,13 +58,13 @@ class Commands { return result; } setDefaultOptions(options) { - const input = cloneDeep_1.default(options); + const input = (0, cloneDeep_1.default)(options); this.optionsProcessor.processDefaultOptions(input, CommandName_1.CommandName.SetDefaultOptions); this.nativeCommandsSender.setDefaultOptions(input); this.commandsObserver.notify(CommandName_1.CommandName.SetDefaultOptions, { options }); } mergeOptions(componentId, options) { - const input = cloneDeep_1.default(options); + const input = (0, cloneDeep_1.default)(options); this.optionsProcessor.processOptions(input, CommandName_1.CommandName.MergeOptions); const component = this.store.getComponentInstance(componentId); if (component && !component.isMounted) @@ -124,7 +133,7 @@ class Commands { return result; } setStackRoot(componentId, children) { - const input = map_1.default(cloneLayout(children), (simpleApi) => { + const input = (0, map_1.default)(cloneLayout(children), (simpleApi) => { this.optionsCrawler.crawl(simpleApi); const layoutProcessed = this.layoutProcessor.process(simpleApi, CommandName_1.CommandName.SetStackRoot); const layout = this.layoutTreeParser.parse(layoutProcessed); @@ -174,7 +183,7 @@ class Commands { } exports.Commands = Commands; function cloneLayout(layout) { - return cloneDeepWith_1.default(layout, (value, key) => { + return (0, cloneDeepWith_1.default)(layout, (value, key) => { if (key === 'passProps' && typeof value === 'object' && value !== null) return { ...value }; }); diff --git a/lib/dist/commands/Commands.test.js b/lib/dist/commands/Commands.test.js index 7063480e9..574db36be 100644 --- a/lib/dist/commands/Commands.test.js +++ b/lib/dist/commands/Commands.test.js @@ -1,9 +1,9 @@ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const tslib_1 = require("tslib"); -const forEach_1 = tslib_1.__importDefault(require("lodash/forEach")); -const filter_1 = tslib_1.__importDefault(require("lodash/filter")); -const invoke_1 = tslib_1.__importDefault(require("lodash/invoke")); +const forEach_1 = (0, tslib_1.__importDefault)(require("lodash/forEach")); +const filter_1 = (0, tslib_1.__importDefault)(require("lodash/filter")); +const invoke_1 = (0, tslib_1.__importDefault)(require("lodash/invoke")); const ts_mockito_1 = require("ts-mockito"); const LayoutTreeParser_1 = require("./LayoutTreeParser"); const LayoutTreeCrawler_1 = require("./LayoutTreeCrawler"); @@ -17,7 +17,7 @@ const LayoutProcessor_1 = require("../processors/LayoutProcessor"); const LayoutProcessorsStore_1 = require("../processors/LayoutProcessorsStore"); const CommandName_1 = require("../interfaces/CommandName"); const OptionsCrawler_1 = require("./OptionsCrawler"); -const react_1 = tslib_1.__importDefault(require("react")); +const react_1 = (0, tslib_1.__importDefault)(require("react")); describe('Commands', () => { let uut; let mockedNativeCommandsSender; @@ -26,25 +26,25 @@ describe('Commands', () => { let mockedUniqueIdProvider; let layoutProcessor; beforeEach(() => { - mockedNativeCommandsSender = ts_mockito_1.mock(NativeCommandsSender_1.NativeCommandsSender); - mockedUniqueIdProvider = ts_mockito_1.mock(UniqueIdProvider_1.UniqueIdProvider); - ts_mockito_1.when(mockedUniqueIdProvider.generate(ts_mockito_1.anything())).thenCall((prefix) => `${prefix}+UNIQUE_ID`); - const uniqueIdProvider = ts_mockito_1.instance(mockedUniqueIdProvider); - mockedStore = ts_mockito_1.mock(Store_1.Store); + mockedNativeCommandsSender = (0, ts_mockito_1.mock)(NativeCommandsSender_1.NativeCommandsSender); + mockedUniqueIdProvider = (0, ts_mockito_1.mock)(UniqueIdProvider_1.UniqueIdProvider); + (0, ts_mockito_1.when)(mockedUniqueIdProvider.generate((0, ts_mockito_1.anything)())).thenCall((prefix) => `${prefix}+UNIQUE_ID`); + const uniqueIdProvider = (0, ts_mockito_1.instance)(mockedUniqueIdProvider); + mockedStore = (0, ts_mockito_1.mock)(Store_1.Store); commandsObserver = new CommandsObserver_1.CommandsObserver(uniqueIdProvider); const layoutProcessorsStore = new LayoutProcessorsStore_1.LayoutProcessorsStore(); - const mockedOptionsProcessor = ts_mockito_1.mock(OptionsProcessor_1.OptionsProcessor); - const optionsProcessor = ts_mockito_1.instance(mockedOptionsProcessor); + const mockedOptionsProcessor = (0, ts_mockito_1.mock)(OptionsProcessor_1.OptionsProcessor); + const optionsProcessor = (0, ts_mockito_1.instance)(mockedOptionsProcessor); layoutProcessor = new LayoutProcessor_1.LayoutProcessor(layoutProcessorsStore); jest.spyOn(layoutProcessor, 'process'); - uut = new Commands_1.Commands(ts_mockito_1.instance(mockedStore), ts_mockito_1.instance(mockedNativeCommandsSender), new LayoutTreeParser_1.LayoutTreeParser(uniqueIdProvider), new LayoutTreeCrawler_1.LayoutTreeCrawler(ts_mockito_1.instance(mockedStore), optionsProcessor), commandsObserver, uniqueIdProvider, optionsProcessor, layoutProcessor, new OptionsCrawler_1.OptionsCrawler(ts_mockito_1.instance(mockedStore), uniqueIdProvider)); + uut = new Commands_1.Commands((0, ts_mockito_1.instance)(mockedStore), (0, ts_mockito_1.instance)(mockedNativeCommandsSender), new LayoutTreeParser_1.LayoutTreeParser(uniqueIdProvider), new LayoutTreeCrawler_1.LayoutTreeCrawler((0, ts_mockito_1.instance)(mockedStore), optionsProcessor), commandsObserver, uniqueIdProvider, optionsProcessor, layoutProcessor, new OptionsCrawler_1.OptionsCrawler((0, ts_mockito_1.instance)(mockedStore), uniqueIdProvider)); }); describe('setRoot', () => { it('sends setRoot to native after parsing into a correct layout tree', () => { uut.setRoot({ root: { component: { name: 'com.example.MyScreen' } }, }); - ts_mockito_1.verify(mockedNativeCommandsSender.setRoot('setRoot+UNIQUE_ID', ts_mockito_1.deepEqual({ + (0, ts_mockito_1.verify)(mockedNativeCommandsSender.setRoot('setRoot+UNIQUE_ID', (0, ts_mockito_1.deepEqual)({ root: { type: 'Component', id: 'Component+UNIQUE_ID', @@ -56,7 +56,7 @@ describe('Commands', () => { }))).called(); }); it('returns a promise with the resolved layout', async () => { - ts_mockito_1.when(mockedNativeCommandsSender.setRoot(ts_mockito_1.anything(), ts_mockito_1.anything())).thenResolve('the resolved layout'); + (0, ts_mockito_1.when)(mockedNativeCommandsSender.setRoot((0, ts_mockito_1.anything)(), (0, ts_mockito_1.anything)())).thenResolve('the resolved layout'); const result = await uut.setRoot({ root: { component: { name: 'com.example.MyScreen' } } }); expect(result).toEqual('the resolved layout'); }); @@ -66,7 +66,7 @@ describe('Commands', () => { modals: [{ component: { name: 'com.example.MyModal' } }], overlays: [{ component: { name: 'com.example.MyOverlay' } }], }); - ts_mockito_1.verify(mockedNativeCommandsSender.setRoot('setRoot+UNIQUE_ID', ts_mockito_1.deepEqual({ + (0, ts_mockito_1.verify)(mockedNativeCommandsSender.setRoot('setRoot+UNIQUE_ID', (0, ts_mockito_1.deepEqual)({ root: { type: 'Component', id: 'Component+UNIQUE_ID', @@ -110,7 +110,7 @@ describe('Commands', () => { expect(layoutProcessor.process).toBeCalledWith({ component: { name: 'com.example.MyScreen', options: {}, id: 'Component+UNIQUE_ID' } }, CommandName_1.CommandName.SetRoot); }); it('pass component static options to layoutProcessor', () => { - ts_mockito_1.when(mockedStore.getComponentClassForName('com.example.MyScreen')).thenReturn(() => class extends react_1.default.Component { + (0, ts_mockito_1.when)(mockedStore.getComponentClassForName('com.example.MyScreen')).thenReturn(() => class extends react_1.default.Component { static options() { return { topBar: { @@ -133,18 +133,18 @@ describe('Commands', () => { it('retains passProps properties identity', () => { const obj = { some: 'content' }; uut.setRoot({ root: { component: { name: 'com.example.MyScreen', passProps: { obj } } } }); - const args = ts_mockito_1.capture(mockedStore.updateProps).last(); + const args = (0, ts_mockito_1.capture)(mockedStore.updateProps).last(); expect(args[1].obj).toBe(obj); }); }); describe('mergeOptions', () => { it('passes options for component', () => { uut.mergeOptions('theComponentId', { blurOnUnmount: true }); - ts_mockito_1.verify(mockedNativeCommandsSender.mergeOptions('theComponentId', ts_mockito_1.deepEqual({ blurOnUnmount: true }))).called(); + (0, ts_mockito_1.verify)(mockedNativeCommandsSender.mergeOptions('theComponentId', (0, ts_mockito_1.deepEqual)({ blurOnUnmount: true }))).called(); }); it('show warning when invoking before componentDidMount', () => { jest.spyOn(console, 'warn'); - ts_mockito_1.when(mockedStore.getComponentInstance('component1')).thenReturn({}); + (0, ts_mockito_1.when)(mockedStore.getComponentInstance('component1')).thenReturn({}); const componentId = 'component1'; uut.mergeOptions(componentId, { blurOnUnmount: true }); expect(console.warn).toBeCalledWith(`Navigation.mergeOptions was invoked on component with id: ${componentId} before it is mounted, this can cause UI issues and should be avoided.\n Use static options instead.`); @@ -152,7 +152,7 @@ describe('Commands', () => { it('should not show warning for mounted component', () => { jest.spyOn(console, 'warn'); const componentId = 'component1'; - ts_mockito_1.when(mockedStore.getComponentInstance('component1')).thenReturn({ + (0, ts_mockito_1.when)(mockedStore.getComponentInstance('component1')).thenReturn({ isMounted: true, }); uut.mergeOptions('component1', { blurOnUnmount: true }); @@ -161,7 +161,7 @@ describe('Commands', () => { it('should not show warning for component id that does not exist', () => { jest.spyOn(console, 'warn'); const componentId = 'component1'; - ts_mockito_1.when(mockedStore.getComponentInstance('stackId')).thenReturn(undefined); + (0, ts_mockito_1.when)(mockedStore.getComponentInstance('stackId')).thenReturn(undefined); uut.mergeOptions('stackId', { blurOnUnmount: true }); expect(console.warn).not.toBeCalledWith(`Navigation.mergeOptions was invoked on component with id: ${componentId} before it is mounted, this can cause UI issues and should be avoided.\n Use static options instead.`); }); @@ -169,11 +169,11 @@ describe('Commands', () => { describe('updateProps', () => { it('delegates to store', () => { uut.updateProps('theComponentId', { someProp: 'someValue' }); - ts_mockito_1.verify(mockedStore.updateProps('theComponentId', ts_mockito_1.deepEqual({ someProp: 'someValue' }))); + (0, ts_mockito_1.verify)(mockedStore.updateProps('theComponentId', (0, ts_mockito_1.deepEqual)({ someProp: 'someValue' }))); }); it('notifies commands observer', () => { uut.updateProps('theComponentId', { someProp: 'someValue' }); - ts_mockito_1.verify(commandsObserver.notify('updateProps', ts_mockito_1.deepEqual({ componentId: 'theComponentId', props: { someProp: 'someValue' } }))); + (0, ts_mockito_1.verify)(commandsObserver.notify('updateProps', (0, ts_mockito_1.deepEqual)({ componentId: 'theComponentId', props: { someProp: 'someValue' } }))); }); test('update props with callback', (done) => { function callback() { @@ -191,7 +191,7 @@ describe('Commands', () => { describe('showModal', () => { it('sends command to native after parsing into a correct layout tree', () => { uut.showModal({ component: { name: 'com.example.MyScreen' } }); - ts_mockito_1.verify(mockedNativeCommandsSender.showModal('showModal+UNIQUE_ID', ts_mockito_1.deepEqual({ + (0, ts_mockito_1.verify)(mockedNativeCommandsSender.showModal('showModal+UNIQUE_ID', (0, ts_mockito_1.deepEqual)({ type: 'Component', id: 'Component+UNIQUE_ID', data: { @@ -203,7 +203,7 @@ describe('Commands', () => { }))).called(); }); it('returns a promise with the resolved layout', async () => { - ts_mockito_1.when(mockedNativeCommandsSender.showModal(ts_mockito_1.anything(), ts_mockito_1.anything())).thenResolve('the resolved layout'); + (0, ts_mockito_1.when)(mockedNativeCommandsSender.showModal((0, ts_mockito_1.anything)(), (0, ts_mockito_1.anything)())).thenResolve('the resolved layout'); const result = await uut.showModal({ component: { name: 'com.example.MyScreen' } }); expect(result).toEqual('the resolved layout'); }); @@ -214,17 +214,17 @@ describe('Commands', () => { it('retains passProps properties identity', () => { const obj = { some: 'content' }; uut.showModal({ component: { name: 'com.example.MyScreen', passProps: { obj } } }); - const args = ts_mockito_1.capture(mockedStore.updateProps).last(); + const args = (0, ts_mockito_1.capture)(mockedStore.updateProps).last(); expect(args[1].obj).toBe(obj); }); }); describe('dismissModal', () => { it('sends command to native', () => { uut.dismissModal('myUniqueId', {}); - ts_mockito_1.verify(mockedNativeCommandsSender.dismissModal('dismissModal+UNIQUE_ID', 'myUniqueId', ts_mockito_1.deepEqual({}))).called(); + (0, ts_mockito_1.verify)(mockedNativeCommandsSender.dismissModal('dismissModal+UNIQUE_ID', 'myUniqueId', (0, ts_mockito_1.deepEqual)({}))).called(); }); it('returns a promise with the id', async () => { - ts_mockito_1.when(mockedNativeCommandsSender.dismissModal(ts_mockito_1.anyString(), ts_mockito_1.anything(), ts_mockito_1.anything())).thenResolve('the id'); + (0, ts_mockito_1.when)(mockedNativeCommandsSender.dismissModal((0, ts_mockito_1.anyString)(), (0, ts_mockito_1.anything)(), (0, ts_mockito_1.anything)())).thenResolve('the id'); const result = await uut.dismissModal('myUniqueId'); expect(result).toEqual('the id'); }); @@ -232,17 +232,17 @@ describe('Commands', () => { describe('dismissAllModals', () => { it('sends command to native', () => { uut.dismissAllModals({}); - ts_mockito_1.verify(mockedNativeCommandsSender.dismissAllModals('dismissAllModals+UNIQUE_ID', ts_mockito_1.deepEqual({}))).called(); + (0, ts_mockito_1.verify)(mockedNativeCommandsSender.dismissAllModals('dismissAllModals+UNIQUE_ID', (0, ts_mockito_1.deepEqual)({}))).called(); }); it('returns a promise with the id', async () => { - ts_mockito_1.when(mockedNativeCommandsSender.dismissAllModals(ts_mockito_1.anyString(), ts_mockito_1.anything())).thenResolve('the id'); + (0, ts_mockito_1.when)(mockedNativeCommandsSender.dismissAllModals((0, ts_mockito_1.anyString)(), (0, ts_mockito_1.anything)())).thenResolve('the id'); const result = await uut.dismissAllModals(); expect(result).toEqual('the id'); }); }); describe('push', () => { it('resolves with the parsed layout', async () => { - ts_mockito_1.when(mockedNativeCommandsSender.push(ts_mockito_1.anyString(), ts_mockito_1.anyString(), ts_mockito_1.anything())).thenResolve('the resolved layout'); + (0, ts_mockito_1.when)(mockedNativeCommandsSender.push((0, ts_mockito_1.anyString)(), (0, ts_mockito_1.anyString)(), (0, ts_mockito_1.anything)())).thenResolve('the resolved layout'); const result = await uut.push('theComponentId', { component: { name: 'com.example.MyScreen' }, }); @@ -250,7 +250,7 @@ describe('Commands', () => { }); it('parses into correct layout node and sends to native', () => { uut.push('theComponentId', { component: { name: 'com.example.MyScreen' } }); - ts_mockito_1.verify(mockedNativeCommandsSender.push('push+UNIQUE_ID', 'theComponentId', ts_mockito_1.deepEqual({ + (0, ts_mockito_1.verify)(mockedNativeCommandsSender.push('push+UNIQUE_ID', 'theComponentId', (0, ts_mockito_1.deepEqual)({ type: 'Component', id: 'Component+UNIQUE_ID', data: { @@ -270,22 +270,22 @@ describe('Commands', () => { uut.push('theComponentId', { component: { name: 'com.example.MyScreen', passProps: { obj } }, }); - const args = ts_mockito_1.capture(mockedStore.updateProps).last(); + const args = (0, ts_mockito_1.capture)(mockedStore.updateProps).last(); expect(args[1].obj).toBe(obj); }); }); describe('pop', () => { it('pops a component, passing componentId', () => { uut.pop('theComponentId', {}); - ts_mockito_1.verify(mockedNativeCommandsSender.pop('pop+UNIQUE_ID', 'theComponentId', ts_mockito_1.deepEqual({}))).called(); + (0, ts_mockito_1.verify)(mockedNativeCommandsSender.pop('pop+UNIQUE_ID', 'theComponentId', (0, ts_mockito_1.deepEqual)({}))).called(); }); it('pops a component, passing componentId and options', () => { const options = { popGesture: true }; uut.pop('theComponentId', options); - ts_mockito_1.verify(mockedNativeCommandsSender.pop('pop+UNIQUE_ID', 'theComponentId', options)).called(); + (0, ts_mockito_1.verify)(mockedNativeCommandsSender.pop('pop+UNIQUE_ID', 'theComponentId', options)).called(); }); it('pop returns a promise that resolves to componentId', async () => { - ts_mockito_1.when(mockedNativeCommandsSender.pop(ts_mockito_1.anyString(), ts_mockito_1.anyString(), ts_mockito_1.anything())).thenResolve('theComponentId'); + (0, ts_mockito_1.when)(mockedNativeCommandsSender.pop((0, ts_mockito_1.anyString)(), (0, ts_mockito_1.anyString)(), (0, ts_mockito_1.anything)())).thenResolve('theComponentId'); const result = await uut.pop('theComponentId', {}); expect(result).toEqual('theComponentId'); }); @@ -293,10 +293,10 @@ describe('Commands', () => { describe('popTo', () => { it('pops all components until the passed Id is top', () => { uut.popTo('theComponentId', {}); - ts_mockito_1.verify(mockedNativeCommandsSender.popTo('popTo+UNIQUE_ID', 'theComponentId', ts_mockito_1.deepEqual({}))).called(); + (0, ts_mockito_1.verify)(mockedNativeCommandsSender.popTo('popTo+UNIQUE_ID', 'theComponentId', (0, ts_mockito_1.deepEqual)({}))).called(); }); it('returns a promise that resolves to targetId', async () => { - ts_mockito_1.when(mockedNativeCommandsSender.popTo(ts_mockito_1.anyString(), ts_mockito_1.anyString(), ts_mockito_1.anything())).thenResolve('theComponentId'); + (0, ts_mockito_1.when)(mockedNativeCommandsSender.popTo((0, ts_mockito_1.anyString)(), (0, ts_mockito_1.anyString)(), (0, ts_mockito_1.anything)())).thenResolve('theComponentId'); const result = await uut.popTo('theComponentId'); expect(result).toEqual('theComponentId'); }); @@ -304,10 +304,10 @@ describe('Commands', () => { describe('popToRoot', () => { it('pops all components to root', () => { uut.popToRoot('theComponentId', {}); - ts_mockito_1.verify(mockedNativeCommandsSender.popToRoot('popToRoot+UNIQUE_ID', 'theComponentId', ts_mockito_1.deepEqual({}))).called(); + (0, ts_mockito_1.verify)(mockedNativeCommandsSender.popToRoot('popToRoot+UNIQUE_ID', 'theComponentId', (0, ts_mockito_1.deepEqual)({}))).called(); }); it('returns a promise that resolves to targetId', async () => { - ts_mockito_1.when(mockedNativeCommandsSender.popToRoot(ts_mockito_1.anyString(), ts_mockito_1.anyString(), ts_mockito_1.anything())).thenResolve('theComponentId'); + (0, ts_mockito_1.when)(mockedNativeCommandsSender.popToRoot((0, ts_mockito_1.anyString)(), (0, ts_mockito_1.anyString)(), (0, ts_mockito_1.anything)())).thenResolve('theComponentId'); const result = await uut.popToRoot('theComponentId'); expect(result).toEqual('theComponentId'); }); @@ -315,7 +315,7 @@ describe('Commands', () => { describe('setStackRoot', () => { it('parses into correct layout node and sends to native', () => { uut.setStackRoot('theComponentId', [{ component: { name: 'com.example.MyScreen' } }]); - ts_mockito_1.verify(mockedNativeCommandsSender.setStackRoot('setStackRoot+UNIQUE_ID', 'theComponentId', ts_mockito_1.deepEqual([ + (0, ts_mockito_1.verify)(mockedNativeCommandsSender.setStackRoot('setStackRoot+UNIQUE_ID', 'theComponentId', (0, ts_mockito_1.deepEqual)([ { type: 'Component', id: 'Component+UNIQUE_ID', @@ -337,14 +337,14 @@ describe('Commands', () => { uut.setStackRoot('theComponentId', [ { component: { name: 'com.example.MyScreen', passProps: { obj } } }, ]); - const args = ts_mockito_1.capture(mockedStore.updateProps).last(); + const args = (0, ts_mockito_1.capture)(mockedStore.updateProps).last(); expect(args[1].obj).toBe(obj); }); }); describe('showOverlay', () => { it('sends command to native after parsing into a correct layout tree', () => { uut.showOverlay({ component: { name: 'com.example.MyScreen' } }); - ts_mockito_1.verify(mockedNativeCommandsSender.showOverlay('showOverlay+UNIQUE_ID', ts_mockito_1.deepEqual({ + (0, ts_mockito_1.verify)(mockedNativeCommandsSender.showOverlay('showOverlay+UNIQUE_ID', (0, ts_mockito_1.deepEqual)({ type: 'Component', id: 'Component+UNIQUE_ID', data: { @@ -356,7 +356,7 @@ describe('Commands', () => { }))).called(); }); it('resolves with the component id', async () => { - ts_mockito_1.when(mockedNativeCommandsSender.showOverlay(ts_mockito_1.anyString(), ts_mockito_1.anything())).thenResolve('Component1'); + (0, ts_mockito_1.when)(mockedNativeCommandsSender.showOverlay((0, ts_mockito_1.anyString)(), (0, ts_mockito_1.anything)())).thenResolve('Component1'); const result = await uut.showOverlay({ component: { name: 'com.example.MyScreen' } }); expect(result).toEqual('Component1'); }); @@ -367,20 +367,20 @@ describe('Commands', () => { it('retains passProps properties identity', () => { const obj = { some: 'content' }; uut.showOverlay({ component: { name: 'com.example.MyScreen', passProps: { obj } } }); - const args = ts_mockito_1.capture(mockedStore.updateProps).last(); + const args = (0, ts_mockito_1.capture)(mockedStore.updateProps).last(); expect(args[1].obj).toBe(obj); }); }); describe('dismissOverlay', () => { it('check promise returns true', async () => { - ts_mockito_1.when(mockedNativeCommandsSender.dismissOverlay(ts_mockito_1.anyString(), ts_mockito_1.anyString())).thenResolve(true); + (0, ts_mockito_1.when)(mockedNativeCommandsSender.dismissOverlay((0, ts_mockito_1.anyString)(), (0, ts_mockito_1.anyString)())).thenResolve(true); const result = await uut.dismissOverlay('Component1'); - ts_mockito_1.verify(mockedNativeCommandsSender.dismissOverlay(ts_mockito_1.anyString(), ts_mockito_1.anyString())).called(); + (0, ts_mockito_1.verify)(mockedNativeCommandsSender.dismissOverlay((0, ts_mockito_1.anyString)(), (0, ts_mockito_1.anyString)())).called(); expect(result).toEqual(true); }); it('send command to native with componentId', () => { uut.dismissOverlay('Component1'); - ts_mockito_1.verify(mockedNativeCommandsSender.dismissOverlay('dismissOverlay+UNIQUE_ID', 'Component1')).called(); + (0, ts_mockito_1.verify)(mockedNativeCommandsSender.dismissOverlay('dismissOverlay+UNIQUE_ID', 'Component1')).called(); }); }); describe('notifies commandsObserver', () => { @@ -389,15 +389,15 @@ describe('Commands', () => { let mockedLayoutTreeCrawler; beforeEach(() => { cb = jest.fn(); - mockedLayoutTreeParser = ts_mockito_1.mock(LayoutTreeParser_1.LayoutTreeParser); - mockedLayoutTreeCrawler = ts_mockito_1.mock(LayoutTreeCrawler_1.LayoutTreeCrawler); + mockedLayoutTreeParser = (0, ts_mockito_1.mock)(LayoutTreeParser_1.LayoutTreeParser); + mockedLayoutTreeCrawler = (0, ts_mockito_1.mock)(LayoutTreeCrawler_1.LayoutTreeCrawler); commandsObserver.register(cb); - const mockedOptionsProcessor = ts_mockito_1.mock(OptionsProcessor_1.OptionsProcessor); - uut = new Commands_1.Commands(mockedStore, mockedNativeCommandsSender, ts_mockito_1.instance(mockedLayoutTreeParser), ts_mockito_1.instance(mockedLayoutTreeCrawler), commandsObserver, ts_mockito_1.instance(mockedUniqueIdProvider), ts_mockito_1.instance(mockedOptionsProcessor), new LayoutProcessor_1.LayoutProcessor(new LayoutProcessorsStore_1.LayoutProcessorsStore()), new OptionsCrawler_1.OptionsCrawler(ts_mockito_1.instance(mockedStore), mockedUniqueIdProvider)); + const mockedOptionsProcessor = (0, ts_mockito_1.mock)(OptionsProcessor_1.OptionsProcessor); + uut = new Commands_1.Commands(mockedStore, mockedNativeCommandsSender, (0, ts_mockito_1.instance)(mockedLayoutTreeParser), (0, ts_mockito_1.instance)(mockedLayoutTreeCrawler), commandsObserver, (0, ts_mockito_1.instance)(mockedUniqueIdProvider), (0, ts_mockito_1.instance)(mockedOptionsProcessor), new LayoutProcessor_1.LayoutProcessor(new LayoutProcessorsStore_1.LayoutProcessorsStore()), new OptionsCrawler_1.OptionsCrawler((0, ts_mockito_1.instance)(mockedStore), mockedUniqueIdProvider)); }); function getAllMethodsOfUut() { const uutFns = Object.getOwnPropertyNames(Commands_1.Commands.prototype); - const methods = filter_1.default(uutFns, (fn) => fn !== 'constructor'); + const methods = (0, filter_1.default)(uutFns, (fn) => fn !== 'constructor'); expect(methods.length).toBeGreaterThan(1); return methods; } @@ -445,11 +445,11 @@ describe('Commands', () => { dismissAllOverlays: { commandId: 'dismissAllOverlays+UNIQUE_ID' }, getLaunchArgs: { commandId: 'getLaunchArgs+UNIQUE_ID' }, }; - forEach_1.default(getAllMethodsOfUut(), (m) => { + (0, forEach_1.default)(getAllMethodsOfUut(), (m) => { it(`for ${m}`, () => { expect(argsForMethodName).toHaveProperty(m); expect(paramsForMethodName).toHaveProperty(m); - invoke_1.defaul…
- Loading branch information