Browse Source

migrating

Daniel Zlotin 7 years ago
parent
commit
a8d4aee11d

+ 0
- 1
lib/src/Navigation.js View File

11
 
11
 
12
 import { Element } from './adapters/Element';
12
 import { Element } from './adapters/Element';
13
 
13
 
14
-/** @constructor */
15
 class Navigation {
14
 class Navigation {
16
   constructor() {
15
   constructor() {
17
     this.store = new Store();
16
     this.store = new Store();

+ 0
- 1
lib/src/adapters/NativeCommandsSender.mock.js View File

1
-module.exports = jest.genMockFromModule('./NativeCommandsSender');

+ 1
- 0
lib/src/adapters/NativeCommandsSender.mock.ts View File

1
+export const { NativeCommandsSender } = jest.genMockFromModule('./NativeCommandsSender');

lib/src/adapters/NativeCommandsSender.js → lib/src/adapters/NativeCommandsSender.ts View File

1
-const { NativeModules } = require('react-native');
1
+import { NativeModules } from 'react-native';
2
+
3
+export class NativeCommandsSender {
4
+  private nativeCommandsModule: any;
2
 
5
 
3
-class NativeCommandsSender {
4
   constructor() {
6
   constructor() {
5
     this.nativeCommandsModule = NativeModules.RNNBridgeModule;
7
     this.nativeCommandsModule = NativeModules.RNNBridgeModule;
6
   }
8
   }
7
 
9
 
8
-  setRoot(layoutTree) {
10
+  setRoot(layoutTree: object) {
9
     return this.nativeCommandsModule.setRoot(layoutTree);
11
     return this.nativeCommandsModule.setRoot(layoutTree);
10
   }
12
   }
11
 
13
 
12
-  setDefaultOptions(options) {
14
+  setDefaultOptions(options: object) {
13
     this.nativeCommandsModule.setDefaultOptions(options);
15
     this.nativeCommandsModule.setDefaultOptions(options);
14
   }
16
   }
15
 
17
 
16
-  setOptions(componentId, options) {
18
+  setOptions(componentId: string, options: object) {
17
     this.nativeCommandsModule.setOptions(componentId, options);
19
     this.nativeCommandsModule.setOptions(componentId, options);
18
   }
20
   }
19
 
21
 
20
-  async push(onComponentId, layout) {
22
+  async push(onComponentId: string, layout: object) {
21
     const pushedComponentId = await this.nativeCommandsModule.push(onComponentId, layout);
23
     const pushedComponentId = await this.nativeCommandsModule.push(onComponentId, layout);
22
     return pushedComponentId;
24
     return pushedComponentId;
23
   }
25
   }
24
 
26
 
25
-  pop(componentId, options) {
27
+  pop(componentId: string, options: object) {
26
     return this.nativeCommandsModule.pop(componentId, options);
28
     return this.nativeCommandsModule.pop(componentId, options);
27
   }
29
   }
28
 
30
 
29
-  popTo(componentId) {
31
+  popTo(componentId: string) {
30
     return this.nativeCommandsModule.popTo(componentId);
32
     return this.nativeCommandsModule.popTo(componentId);
31
   }
33
   }
32
 
34
 
33
-  popToRoot(componentId) {
35
+  popToRoot(componentId: string) {
34
     return this.nativeCommandsModule.popToRoot(componentId);
36
     return this.nativeCommandsModule.popToRoot(componentId);
35
   }
37
   }
36
 
38
 
37
-  async showModal(layout) {
39
+  async showModal(layout: object) {
38
     const completed = await this.nativeCommandsModule.showModal(layout);
40
     const completed = await this.nativeCommandsModule.showModal(layout);
39
     return completed;
41
     return completed;
40
   }
42
   }
41
 
43
 
42
-  dismissModal(componentId) {
44
+  dismissModal(componentId: string) {
43
     return this.nativeCommandsModule.dismissModal(componentId);
45
     return this.nativeCommandsModule.dismissModal(componentId);
44
   }
46
   }
45
 
47
 
47
     return this.nativeCommandsModule.dismissAllModals();
49
     return this.nativeCommandsModule.dismissAllModals();
48
   }
50
   }
49
 
51
 
50
-  showOverlay(type, options) {
52
+  showOverlay(type: any, options: object) {
51
     return this.nativeCommandsModule.showOverlay(type, options);
53
     return this.nativeCommandsModule.showOverlay(type, options);
52
   }
54
   }
53
 
55
 
56
     return Promise.resolve(true);
58
     return Promise.resolve(true);
57
   }
59
   }
58
 }
60
 }
59
-
60
-module.exports = NativeCommandsSender;

+ 0
- 1
lib/src/adapters/NativeEventsReceiver.mock.js View File

1
-module.exports = jest.genMockFromModule('./NativeEventsReceiver');

+ 1
- 0
lib/src/adapters/NativeEventsReceiver.mock.ts View File

1
+export const { NativeEventsReceiver } = jest.genMockFromModule('./NativeEventsReceiver');

lib/src/adapters/NativeEventsReceiver.js → lib/src/adapters/NativeEventsReceiver.ts View File

1
-const { NativeModules, NativeEventEmitter } = require('react-native');
1
+import { NativeModules, NativeEventEmitter } from 'react-native';
2
+
3
+export class NativeEventsReceiver {
4
+  private emitter: NativeEventEmitter;
2
 
5
 
3
-class NativeEventsReceiver {
4
   constructor() {
6
   constructor() {
5
     this.emitter = new NativeEventEmitter(NativeModules.RNNEventEmitter);
7
     this.emitter = new NativeEventEmitter(NativeModules.RNNEventEmitter);
6
   }
8
   }
7
 
9
 
8
-  registerComponentDidAppear(callback) {
10
+  registerComponentDidAppear(callback: any) {
9
     this.emitter.addListener('RNN.componentDidAppear', callback);
11
     this.emitter.addListener('RNN.componentDidAppear', callback);
10
   }
12
   }
11
 
13
 
12
-  registerComponentDidDisappear(callback) {
14
+  registerComponentDidDisappear(callback: any) {
13
     this.emitter.addListener('RNN.componentDidDisappear', callback);
15
     this.emitter.addListener('RNN.componentDidDisappear', callback);
14
   }
16
   }
15
 
17
 
16
-  registerAppLaunched(callback) {
18
+  registerAppLaunched(callback: any) {
17
     this.emitter.addListener('RNN.appLaunched', callback);
19
     this.emitter.addListener('RNN.appLaunched', callback);
18
   }
20
   }
19
 
21
 
20
-  registerNavigationButtonPressed(callback) {
22
+  registerNavigationButtonPressed(callback: any) {
21
     this.emitter.addListener('RNN.navigationButtonPressed', callback);
23
     this.emitter.addListener('RNN.navigationButtonPressed', callback);
22
   }
24
   }
23
 }
25
 }
24
-
25
-module.exports = NativeEventsReceiver;

+ 0
- 9
lib/src/adapters/UniqueIdProvider.js View File

1
-const _ = require('lodash');
2
-
3
-class UniqueIdProvider {
4
-  generate(prefix) {
5
-    return _.uniqueId(prefix);
6
-  }
7
-}
8
-
9
-module.exports = UniqueIdProvider;

+ 0
- 7
lib/src/adapters/UniqueIdProvider.mock.js View File

1
-class UniqueIdProvider {
2
-  generate(prefix) {
3
-    return `${prefix}+UNIQUE_ID`;
4
-  }
5
-}
6
-
7
-module.exports = UniqueIdProvider;

+ 5
- 0
lib/src/adapters/UniqueIdProvider.mock.ts View File

1
+export class UniqueIdProvider {
2
+  generate(prefix: string): string {
3
+    return `${prefix}+UNIQUE_ID`;
4
+  }
5
+}

+ 7
- 0
lib/src/adapters/UniqueIdProvider.ts View File

1
+import * as _ from 'lodash';
2
+
3
+export class UniqueIdProvider {
4
+  generate(prefix: string): string {
5
+    return _.uniqueId(prefix);
6
+  }
7
+}

+ 2
- 2
lib/src/commands/Commands.test.js View File

1
 const LayoutTreeParser = require('./LayoutTreeParser');
1
 const LayoutTreeParser = require('./LayoutTreeParser');
2
 const LayoutTreeCrawler = require('./LayoutTreeCrawler');
2
 const LayoutTreeCrawler = require('./LayoutTreeCrawler');
3
 const Store = require('../components/Store');
3
 const Store = require('../components/Store');
4
-const UniqueIdProvider = require('../adapters/UniqueIdProvider.mock');
5
-const NativeCommandsSender = require('../adapters/NativeCommandsSender.mock');
4
+const { UniqueIdProvider } = require('../adapters/UniqueIdProvider.mock');
5
+const { NativeCommandsSender } = require('../adapters/NativeCommandsSender.mock');
6
 const Commands = require('./Commands');
6
 const Commands = require('./Commands');
7
 
7
 
8
 describe('Commands', () => {
8
 describe('Commands', () => {

+ 2
- 1
lib/src/commands/LayoutTreeCrawler.js View File

1
+import { LayoutTypes } from './LayoutTypes';
2
+
1
 const _ = require('lodash');
3
 const _ = require('lodash');
2
-const LayoutTypes = require('./LayoutTypes');
3
 const OptionsProcessor = require('./OptionsProcessor');
4
 const OptionsProcessor = require('./OptionsProcessor');
4
 
5
 
5
 class LayoutTreeCrawler {
6
 class LayoutTreeCrawler {

+ 2
- 1
lib/src/commands/LayoutTreeParser.js View File

1
+import { LayoutTypes } from './LayoutTypes';
2
+
1
 const _ = require('lodash');
3
 const _ = require('lodash');
2
-const LayoutTypes = require('./LayoutTypes');
3
 
4
 
4
 class LayoutTreeParser {
5
 class LayoutTreeParser {
5
   constructor() {
6
   constructor() {

+ 0
- 10
lib/src/commands/LayoutTypes.js View File

1
-module.exports = {
2
-  Component: 'Component',
3
-  Stack: 'Stack',
4
-  BottomTabs: 'BottomTabs',
5
-  SideMenuRoot: 'SideMenuRoot',
6
-  SideMenuCenter: 'SideMenuCenter',
7
-  SideMenuLeft: 'SideMenuLeft',
8
-  SideMenuRight: 'SideMenuRight',
9
-  TopTabs: 'TopTabs'
10
-};

+ 10
- 0
lib/src/commands/LayoutTypes.ts View File

1
+export const enum LayoutTypes {
2
+  Component = 'Component',
3
+  Stack = 'Stack',
4
+  BottomTabs = 'BottomTabs',
5
+  SideMenuRoot = 'SideMenuRoot',
6
+  SideMenuCenter = 'SideMenuCenter',
7
+  SideMenuLeft = 'SideMenuLeft',
8
+  SideMenuRight = 'SideMenuRight',
9
+  TopTabs = 'TopTabs'
10
+};

lib/src/commands/OptionsProcessor.test.js → lib/src/commands/OptionsProcessor.test.ts View File

1
-const OptionsProcessor = require('./OptionsProcessor');
1
+import { OptionsProcessor } from './OptionsProcessor';
2
 
2
 
3
 describe('navigation options', () => {
3
 describe('navigation options', () => {
4
-  let options;
4
+  let options: any;
5
 
5
 
6
   beforeEach(() => {
6
   beforeEach(() => {
7
     options = {};
7
     options = {};

lib/src/commands/OptionsProcessor.js → lib/src/commands/OptionsProcessor.ts View File

1
-const _ = require('lodash');
2
-const { processColor } = require('react-native');
3
-const resolveAssetSource = require('react-native/Libraries/Image/resolveAssetSource');
1
+import * as _ from 'lodash';
2
+import { processColor } from 'react-native';
3
+import * as resolveAssetSource from 'react-native/Libraries/Image/resolveAssetSource';
4
 
4
 
5
-class OptionsProcessor {
6
-  static processOptions(options) {
5
+export class OptionsProcessor {
6
+  static processOptions(options: any) {
7
     _.forEach(options, (value, key) => {
7
     _.forEach(options, (value, key) => {
8
       if (value) {
8
       if (value) {
9
         if (_.endsWith(key, 'Color')) {
9
         if (_.endsWith(key, 'Color')) {
19
     });
19
     });
20
   }
20
   }
21
 }
21
 }
22
-
23
-module.exports = OptionsProcessor;

lib/src/events/PrivateEventsListener.test.js → lib/src/events/PrivateEventsListener.test.ts View File

1
-const PrivateEventsListener = require('./PrivateEventsListener');
2
-const NativeEventsReceiver = require('../adapters/NativeEventsReceiver.mock');
3
-const Store = require('../components/Store');
1
+import { PrivateEventsListener } from './PrivateEventsListener';
2
+import { NativeEventsReceiver } from '../adapters/NativeEventsReceiver.mock';
3
+import * as  Store from '../components/Store';
4
 
4
 
5
 describe('PrivateEventsListener', () => {
5
 describe('PrivateEventsListener', () => {
6
-  let uut;
7
-  let nativeEventsReceiver;
8
-  let store;
6
+  let uut: PrivateEventsListener;
7
+  let nativeEventsReceiver: any;
8
+  let store: any;
9
 
9
 
10
   beforeEach(() => {
10
   beforeEach(() => {
11
     nativeEventsReceiver = new NativeEventsReceiver();
11
     nativeEventsReceiver = new NativeEventsReceiver();

lib/src/events/PrivateEventsListener.js → lib/src/events/PrivateEventsListener.ts View File

1
-const Lifecycle = require('../components/Lifecycle');
1
+import * as Lifecycle from '../components/Lifecycle';
2
 
2
 
3
-class PrivateEventsListener {
4
-  constructor(nativeEventsReceiver, store) {
3
+export class PrivateEventsListener {
4
+  private nativeEventsReceiver: any;
5
+  private lifecycle: any;
6
+
7
+  constructor(nativeEventsReceiver: any, store: any) {
5
     this.nativeEventsReceiver = nativeEventsReceiver;
8
     this.nativeEventsReceiver = nativeEventsReceiver;
6
     this.lifecycle = new Lifecycle(store);
9
     this.lifecycle = new Lifecycle(store);
7
   }
10
   }
12
     this.nativeEventsReceiver.registerNavigationButtonPressed(this.lifecycle.onNavigationButtonPressed);
15
     this.nativeEventsReceiver.registerNavigationButtonPressed(this.lifecycle.onNavigationButtonPressed);
13
   }
16
   }
14
 }
17
 }
15
-
16
-module.exports = PrivateEventsListener;

+ 1
- 0
lib/src/globals.d.ts View File

1
+declare module 'react-native/Libraries/Image/resolveAssetSource';

+ 0
- 1
tsconfig.json View File

1
 {
1
 {
2
-  "extends": "./tsconfig-strict",
3
   "compilerOptions": {
2
   "compilerOptions": {
4
     "outDir": "./lib/dist",
3
     "outDir": "./lib/dist",
5
     "allowJs": true,
4
     "allowJs": true,