Browse Source

this doesnt quite work

Daniel Zlotin 7 years ago
parent
commit
5e00c1838d

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

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

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

@@ -1,14 +1,18 @@
1
-const _ = require('lodash');
2
-const OptionsProcessor = require('./OptionsProcessor');
1
+import * as _ from 'lodash';
2
+import { OptionsProcessor } from './OptionsProcessor';
3
+
4
+export class Commands {
5
+  private nativeCommandsSender: any;
6
+  private layoutTreeParser: any;
7
+  private layoutTreeCrawler: any;
3 8
 
4
-class Commands {
5 9
   constructor(nativeCommandsSender, layoutTreeParser, layoutTreeCrawler) {
6 10
     this.nativeCommandsSender = nativeCommandsSender;
7 11
     this.layoutTreeParser = layoutTreeParser;
8 12
     this.layoutTreeCrawler = layoutTreeCrawler;
9 13
   }
10 14
 
11
-  setRoot(simpleApi) {
15
+  setRoot(simpleApi: any) {
12 16
     const input = _.cloneDeep(simpleApi);
13 17
     const layout = this.layoutTreeParser.parse(input);
14 18
     this.layoutTreeCrawler.crawl(layout);
@@ -63,22 +67,20 @@ class Commands {
63 67
   }
64 68
 
65 69
   // showOverlay(type, options) {
66
-    // let promise;
67
-    // if (type === 'custom') {
68
-    //   const layout = this.layoutTreeParser.createDialogComponent({ name: options });
69
-    //   this.layoutTreeCrawler.crawl(layout);
70
-    //   promise = this.nativeCommandsSender.showOverlay(type, layout);
71
-    // } else {
72
-    //   const input = _.cloneDeep(options);
73
-    //   OptionsProcessor.processOptions(input);
74
-    //   promise = this.nativeCommandsSender.showOverlay(type, input);
75
-    // }
76
-    // return promise;
70
+  // let promise;
71
+  // if (type === 'custom') {
72
+  //   const layout = this.layoutTreeParser.createDialogComponent({ name: options });
73
+  //   this.layoutTreeCrawler.crawl(layout);
74
+  //   promise = this.nativeCommandsSender.showOverlay(type, layout);
75
+  // } else {
76
+  //   const input = _.cloneDeep(options);
77
+  //   OptionsProcessor.processOptions(input);
78
+  //   promise = this.nativeCommandsSender.showOverlay(type, input);
79
+  // }
80
+  // return promise;
77 81
   // }
78 82
 
79 83
   dismissOverlay() {
80 84
     return this.nativeCommandsSender.dismissOverlay();
81 85
   }
82 86
 }
83
-
84
-module.exports = Commands;

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

@@ -1,7 +1,8 @@
1
-const LayoutTypes = require('./LayoutTypes');
2
-const LayoutTreeCrawler = require('./LayoutTreeCrawler');
1
+import { LayoutType } from './values/LayoutType';
2
+import { LayoutTreeCrawler } from './LayoutTreeCrawler';
3
+import { UniqueIdProvider } from '../adapters/UniqueIdProvider.mock';
4
+import { LayoutNode } from './values/LayoutNode';
3 5
 const Store = require('../components/Store');
4
-const UniqueIdProvider = require('../adapters/UniqueIdProvider.mock');
5 6
 
6 7
 describe('LayoutTreeCrawler', () => {
7 8
   let uut;
@@ -13,34 +14,34 @@ describe('LayoutTreeCrawler', () => {
13 14
   });
14 15
 
15 16
   it('crawls a layout tree and adds unique id to each node', () => {
16
-    const node = { type: LayoutTypes.Stack, children: [{ type: LayoutTypes.BottomTabs }] };
17
+    const node: any = { type: LayoutType.Stack, children: [{ type: LayoutType.BottomTabs }] };
17 18
     uut.crawl(node);
18 19
     expect(node.id).toEqual('Stack+UNIQUE_ID');
19 20
     expect(node.children[0].id).toEqual('BottomTabs+UNIQUE_ID');
20 21
   });
21 22
 
22 23
   it('crawls a layout tree and ensures data exists', () => {
23
-    const node = { type: LayoutTypes.Stack, children: [{ type: LayoutTypes.BottomTabs }] };
24
+    const node: any = { type: LayoutType.Stack, children: [{ type: LayoutType.BottomTabs }] };
24 25
     uut.crawl(node);
25 26
     expect(node.data).toEqual({});
26 27
     expect(node.children[0].data).toEqual({});
27 28
   });
28 29
 
29 30
   it('crawls a layout tree and ensures children exists', () => {
30
-    const node = { type: LayoutTypes.Stack, children: [{ type: LayoutTypes.BottomTabs }] };
31
+    const node: any = { type: LayoutType.Stack, children: [{ type: LayoutType.BottomTabs }] };
31 32
     uut.crawl(node);
32 33
     expect(node.children[0].children).toEqual([]);
33 34
   });
34 35
 
35 36
   it('crawls a layout tree and asserts known layout type', () => {
36
-    const node = { type: LayoutTypes.Stack, children: [{ type: 'Bob' }] };
37
-    expect(() => uut.crawl(node)).toThrow(new Error('Unknown layout type Bob'));
37
+    const node = { type: LayoutType.Stack, children: [{ type: 'Bob' }] };
38
+    expect(() => uut.crawl(node)).toThrowError('Unknown layout type Bob');
38 39
   });
39 40
 
40 41
   it('saves passProps into store for Component nodes', () => {
41 42
     const node = {
42
-      type: LayoutTypes.BottomTabs, children: [
43
-        { type: LayoutTypes.Component, data: { name: 'the name', passProps: { myProp: 123 } } }]
43
+      type: LayoutType.BottomTabs, children: [
44
+        { type: LayoutType.Component, data: { name: 'the name', passProps: { myProp: 123 } } }]
44 45
     };
45 46
     expect(store.getPropsForComponentId('Component+UNIQUE_ID')).toEqual({});
46 47
     uut.crawl(node);
@@ -55,7 +56,7 @@ describe('LayoutTreeCrawler', () => {
55 56
       }
56 57
     };
57 58
 
58
-    const node = { type: LayoutTypes.Component, data: { name: 'theComponentName' } };
59
+    const node: any = { type: LayoutType.Component, data: { name: 'theComponentName' } };
59 60
     store.setOriginalComponentClassForName('theComponentName', MyComponent);
60 61
     uut.crawl(node);
61 62
     expect(node.data.options).toEqual(theStyle);
@@ -83,7 +84,7 @@ describe('LayoutTreeCrawler', () => {
83 84
       }
84 85
     };
85 86
 
86
-    const node = { type: LayoutTypes.Component, data: { name: 'theComponentName', options: passedOptions } };
87
+    const node = { type: LayoutType.Component, data: { name: 'theComponentName', options: passedOptions } };
87 88
     store.setOriginalComponentClassForName('theComponentName', MyComponent);
88 89
 
89 90
     uut.crawl(node);
@@ -106,21 +107,21 @@ describe('LayoutTreeCrawler', () => {
106 107
       }
107 108
     };
108 109
 
109
-    const node = { type: LayoutTypes.Component, data: { name: 'theComponentName' } };
110
+    const node: any = { type: LayoutType.Component, data: { name: 'theComponentName' } };
110 111
     store.setOriginalComponentClassForName('theComponentName', MyComponent);
111 112
     uut.crawl(node);
112 113
     expect(node.data.options).not.toBe(theStyle);
113 114
   });
114 115
 
115 116
   it('Components: must contain data name', () => {
116
-    const node = { type: LayoutTypes.Component, data: {} };
117
-    expect(() => uut.crawl(node)).toThrow(new Error('Missing component data.name'));
117
+    const node = { type: LayoutType.Component, data: {} };
118
+    expect(() => uut.crawl(node)).toThrowError('Missing component data.name');
118 119
   });
119 120
 
120 121
   it('Components: options default obj', () => {
121 122
     const MyComponent = class { };
122 123
 
123
-    const node = { type: LayoutTypes.Component, data: { name: 'theComponentName' } };
124
+    const node: any = { type: LayoutType.Component, data: { name: 'theComponentName' } };
124 125
     store.setOriginalComponentClassForName('theComponentName', MyComponent);
125 126
     uut.crawl(node);
126 127
     expect(node.data.options).toEqual({});
@@ -132,7 +133,7 @@ describe('LayoutTreeCrawler', () => {
132 133
 
133 134
     beforeEach(() => {
134 135
       options = {};
135
-      node = { type: LayoutTypes.Component, data: { name: 'theComponentName', options } };
136
+      node = { type: LayoutType.Component, data: { name: 'theComponentName', options } };
136 137
     });
137 138
 
138 139
     it('processes colors into numeric AARRGGBB', () => {

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

@@ -1,21 +1,33 @@
1
-import { LayoutTypes } from './LayoutTypes';
1
+import * as _ from 'lodash';
2
+import { OptionsProcessor } from './OptionsProcessor';
3
+import { LayoutType, isLayoutType } from './values/LayoutType';
4
+import { LayoutNode } from './values/LayoutNode';
2 5
 
3
-const _ = require('lodash');
4
-const OptionsProcessor = require('./OptionsProcessor');
6
+interface IdProvider {
7
+  generate: (str: string) => string;
8
+}
9
+
10
+interface Store {
11
+  setPropsForComponentId: (str: string, props: object) => void;
12
+  getOriginalComponentClassForName: (str: string) => any;
13
+}
5 14
 
6
-class LayoutTreeCrawler {
7
-  constructor(uniqueIdProvider, store) {
15
+export class LayoutTreeCrawler {
16
+  private uniqueIdProvider: IdProvider
17
+  private store: Store
18
+
19
+  constructor(uniqueIdProvider: IdProvider, store: Store) {
8 20
     this.uniqueIdProvider = uniqueIdProvider;
9 21
     this.store = store;
10 22
     this.crawl = this.crawl.bind(this);
11 23
   }
12 24
 
13
-  crawl(node) {
25
+  crawl(node: LayoutNode): void {
14 26
     this._assertKnownLayoutType(node.type);
15 27
     node.id = this.uniqueIdProvider.generate(node.type);
16 28
     node.data = node.data || {};
17 29
     node.children = node.children || [];
18
-    if (_.isEqual(node.type, LayoutTypes.Component)) {
30
+    if (node.type == LayoutType.Component) {
19 31
       this._handleComponent(node);
20 32
     }
21 33
     _.forEach(node.children, this.crawl);
@@ -40,7 +52,7 @@ class LayoutTreeCrawler {
40 52
   }
41 53
 
42 54
   _assertKnownLayoutType(type) {
43
-    if (!_.includes(LayoutTypes, type)) {
55
+    if (!isLayoutType(type)) {
44 56
       throw new Error(`Unknown layout type ${type}`);
45 57
     }
46 58
   }
@@ -51,5 +63,3 @@ class LayoutTreeCrawler {
51 63
     }
52 64
   }
53 65
 }
54
-
55
-module.exports = LayoutTreeCrawler;

+ 113
- 103
lib/src/commands/LayoutTreeParser.test.ts View File

@@ -11,7 +11,7 @@ describe('LayoutTreeParser', () => {
11 11
 
12 12
   describe('parses into { type, data, children }', () => {
13 13
     it('unknown type', () => {
14
-      expect(() => uut.parse({ wut: {} })).toThrow(new Error('unknown LayoutType "wut"'));
14
+      expect(() => uut.parse({ wut: {} })).toThrowError('unknown LayoutType "wut"');
15 15
     });
16 16
 
17 17
     it('single component', () => {
@@ -88,7 +88,7 @@ describe('LayoutTreeParser', () => {
88 88
     });
89 89
 
90 90
     it('side menu center is require', () => {
91
-      expect(() => uut.parse({ sideMenu: {} })).toThrow(new Error('sideMenu.center is required'));
91
+      expect(() => uut.parse({ sideMenu: {} })).toThrowError('sideMenu.center is required');
92 92
     });
93 93
 
94 94
     it('top tabs', () => {
@@ -127,120 +127,130 @@ describe('LayoutTreeParser', () => {
127 127
   });
128 128
 });
129 129
 
130
-const LayoutExamples = {
131
-  passProps: {
132
-    strProp: 'string prop',
133
-    numProp: 12345,
134
-    objProp: { inner: { foo: 'bar' } },
135
-    fnProp: () => 'Hello from a function'
136
-  },
137
-
138
-  options: {
139
-    topBar: {
140
-      title: 'Hello1'
141
-    }
142
-  },
130
+/* Layout Examples: */
143 131
 
144
-  singleComponent: {
145
-    component: {
146
-      name: 'MyReactComponent',
147
-      options: this.options,
148
-      passProps: this.passProps
149
-    }
150
-  },
151
-
152
-  stackWithTopBar: {
153
-    stack: {
154
-      children: [
155
-        {
156
-          component: {
157
-            name: 'MyReactComponent1'
158
-          }
159
-        },
160
-        {
161
-          component: {
162
-            name: 'MyReactComponent2',
163
-            options: this.options
164
-          }
132
+const passProps = {
133
+  strProp: 'string prop',
134
+  numProp: 12345,
135
+  objProp: { inner: { foo: 'bar' } },
136
+  fnProp: () => 'Hello from a function'
137
+};
138
+
139
+const options = {
140
+  topBar: {
141
+    title: 'Hello1'
142
+  }
143
+};
144
+
145
+const singleComponent = {
146
+  component: {
147
+    name: 'MyReactComponent',
148
+    options,
149
+    passProps
150
+  }
151
+};
152
+
153
+const stackWithTopBar = {
154
+  stack: {
155
+    children: [
156
+      {
157
+        component: {
158
+          name: 'MyReactComponent1'
165 159
         }
166
-      ],
167
-      options: this.options
168
-    }
169
-  },
160
+      },
161
+      {
162
+        component: {
163
+          name: 'MyReactComponent2',
164
+          options
165
+        }
166
+      }
167
+    ],
168
+    options
169
+  }
170
+};
170 171
 
172
+const bottomTabs = {
171 173
   bottomTabs: {
172
-    bottomTabs: {
173
-      children: [
174
-        { ...this.stackWithTopBar },
175
-        { ...this.stackWithTopBar },
176
-        {
177
-          component: {
178
-            name: 'MyReactComponent1'
179
-          }
174
+    children: [
175
+      stackWithTopBar,
176
+      stackWithTopBar,
177
+      {
178
+        component: {
179
+          name: 'MyReactComponent1'
180 180
         }
181
-      ]
182
-    }
183
-  },
181
+      }
182
+    ]
183
+  }
184
+};
184 185
 
186
+const sideMenu = {
185 187
   sideMenu: {
186
-    sideMenu: {
187
-      left: { ...this.singleComponent },
188
-      center: { ...this.stackWithTopBar },
189
-      right: { ...this.singleComponent }
190
-    }
191
-  },
188
+    left: singleComponent,
189
+    center: stackWithTopBar,
190
+    right: singleComponent
191
+  }
192
+};
192 193
 
194
+const topTabs = {
193 195
   topTabs: {
194
-    topTabs: {
195
-      children: [
196
-        { ...this.singleComponent },
197
-        { ...this.singleComponent },
198
-        { ...this.singleComponent },
199
-        { ...this.singleComponent },
200
-        { ...this.stackWithTopBar }
201
-      ],
202
-      options: this.options
203
-    }
204
-  },
205
-
206
-  complexLayout: {
207
-    sideMenu: {
208
-      left: { ...this.singleComponent },
209
-      center: {
210
-        bottomTabs: {
211
-          children: [
212
-            { ...this.stackWithTopBar },
213
-            { ...this.stackWithTopBar },
214
-            {
215
-              stack: {
216
-                children: [
217
-                  {
218
-                    topTabs: {
219
-                      children: [
220
-                        { ...this.stackWithTopBar },
221
-                        { ...this.stackWithTopBar },
222
-                        {
223
-                          topTabs: {
224
-                            options: this.options,
225
-                            children: [
226
-                              { ...this.singleComponent },
227
-                              { ...this.singleComponent },
228
-                              { ...this.singleComponent },
229
-                              { ...this.singleComponent },
230
-                              { ...this.stackWithTopBar }
231
-                            ]
232
-                          }
196
+    children: [
197
+      singleComponent,
198
+      singleComponent,
199
+      singleComponent,
200
+      singleComponent,
201
+      stackWithTopBar
202
+    ],
203
+    options
204
+  }
205
+};
206
+
207
+const complexLayout = {
208
+  sideMenu: {
209
+    left: singleComponent,
210
+    center: {
211
+      bottomTabs: {
212
+        children: [
213
+          stackWithTopBar,
214
+          stackWithTopBar,
215
+          {
216
+            stack: {
217
+              children: [
218
+                {
219
+                  topTabs: {
220
+                    children: [
221
+                      stackWithTopBar,
222
+                      stackWithTopBar,
223
+                      {
224
+                        topTabs: {
225
+                          options,
226
+                          children: [
227
+                            singleComponent,
228
+                            singleComponent,
229
+                            singleComponent,
230
+                            singleComponent,
231
+                            stackWithTopBar
232
+                          ]
233 233
                         }
234
-                      ]
235
-                    }
234
+                      }
235
+                    ]
236 236
                   }
237
-                ]
238
-              }
237
+                }
238
+              ]
239 239
             }
240
-          ]
241
-        }
240
+          }
241
+        ]
242 242
       }
243 243
     }
244 244
   }
245
-}
245
+};
246 246
 
247
+const LayoutExamples = {
248
+  passProps,
249
+  options,
250
+  singleComponent,
251
+  stackWithTopBar,
252
+  bottomTabs,
253
+  sideMenu,
254
+  topTabs,
255
+  complexLayout
256
+};

+ 8
- 10
lib/src/commands/LayoutTreeParser.ts View File

@@ -1,15 +1,13 @@
1 1
 import * as _ from 'lodash';
2 2
 import { LayoutType } from './values/LayoutType';
3
+import { LayoutNode } from './values/LayoutNode';
3 4
 
4 5
 export class LayoutTreeParser {
5 6
   constructor() {
6 7
     this.parse = this.parse.bind(this);
7 8
   }
8 9
 
9
-  /**
10
-   * @returns correct layout tree of nodes which are { type, data, children }
11
-   */
12
-  parse(api) {
10
+  parse(api: any): LayoutNode {
13 11
     if (api.topTabs) {
14 12
       return this._topTabs(api.topTabs);
15 13
     } else if (api.sideMenu) {
@@ -24,7 +22,7 @@ export class LayoutTreeParser {
24 22
     throw new Error(`unknown LayoutType "${_.keys(api)}"`);
25 23
   }
26 24
 
27
-  _topTabs(api) {
25
+  _topTabs(api): LayoutNode {
28 26
     return {
29 27
       type: LayoutType.TopTabs,
30 28
       data: { options: api.options },
@@ -32,7 +30,7 @@ export class LayoutTreeParser {
32 30
     };
33 31
   }
34 32
 
35
-  _sideMenu(api) {
33
+  _sideMenu(api): LayoutNode {
36 34
     return {
37 35
       type: LayoutType.SideMenuRoot,
38 36
       data: { options: api.options },
@@ -40,7 +38,7 @@ export class LayoutTreeParser {
40 38
     };
41 39
   }
42 40
 
43
-  _sideMenuChildren(api) {
41
+  _sideMenuChildren(api): Array<LayoutNode> {
44 42
     if (!api.center) {
45 43
       throw new Error(`sideMenu.center is required`);
46 44
     }
@@ -67,7 +65,7 @@ export class LayoutTreeParser {
67 65
     return children;
68 66
   }
69 67
 
70
-  _bottomTabs(api) {
68
+  _bottomTabs(api): LayoutNode {
71 69
     return {
72 70
       type: LayoutType.BottomTabs,
73 71
       data: { options: api.options },
@@ -75,7 +73,7 @@ export class LayoutTreeParser {
75 73
     };
76 74
   }
77 75
 
78
-  _stack(api) {
76
+  _stack(api): LayoutNode {
79 77
     return {
80 78
       type: LayoutType.Stack,
81 79
       data: { name: api.name, options: api.options },
@@ -83,7 +81,7 @@ export class LayoutTreeParser {
83 81
     };
84 82
   }
85 83
 
86
-  _component(api) {
84
+  _component(api): LayoutNode {
87 85
     return {
88 86
       type: LayoutType.Component,
89 87
       data: { name: api.name, options: api.options, passProps: api.passProps },

+ 1
- 1
lib/src/commands/values/LayoutNode.ts View File

@@ -1,7 +1,7 @@
1 1
 import { LayoutType } from "./LayoutType";
2 2
 
3 3
 export interface LayoutNode {
4
-  id: string;
4
+  id?: string;
5 5
   type: LayoutType;
6 6
   data: object;
7 7
   children: Array<LayoutNode>;

lib/src/components/ComponentRegistry.test.js → lib/src/components/ComponentRegistry.test.ts View File


lib/src/components/ComponentRegistry.js → lib/src/components/ComponentRegistry.ts View File


lib/src/components/ComponentWrapper.test.js → lib/src/components/ComponentWrapper.test.ts View File


lib/src/components/ComponentWrapper.js → lib/src/components/ComponentWrapper.ts View File

@@ -1,11 +1,9 @@
1
-const _ = require('lodash');
1
+import * as  _ from 'lodash';
2
+import * as React from 'react';
2 3
 
3
-const React = require('react');
4
-const { Component } = require('react');
5
-
6
-class ComponentWrapper {
7
-  static wrap(componentName, OriginalComponent, store) {
8
-    return class extends Component {
4
+export class ComponentWrapper {
5
+  static wrap(componentName: string, OriginalComponent: any, store: any) {
6
+    return class extends React.Component<any, any> {
9 7
       constructor(props) {
10 8
         super(props);
11 9
         this._saveComponentRef = this._saveComponentRef.bind(this);
@@ -61,15 +59,13 @@ class ComponentWrapper {
61 59
       render() {
62 60
         return (
63 61
           <OriginalComponent
64
-            ref={this._saveComponentRef}
65
-            {...this.state.allProps}
66
-            componentId={this.state.componentId}
67
-            key={this.state.componentId}
62
+            ref= { this._saveComponentRef }
63
+        {...this.state.allProps }
64
+        componentId = { this.state.componentId }
65
+        key = { this.state.componentId }
68 66
           />
69 67
         );
70 68
       }
71 69
     };
72 70
   }
73 71
 }
74
-
75
-module.exports = ComponentWrapper;

lib/src/components/Lifecycle.test.js → lib/src/components/Lifecycle.test.ts View File

@@ -1,5 +1,5 @@
1
-const Lifecycle = require('./Lifecycle');
2
-const Store = require('../components/Store');
1
+import { Lifecycle } from './Lifecycle';
2
+import { Store } from '../components/Store';
3 3
 
4 4
 describe('Lifecycle', () => {
5 5
   let store;

lib/src/components/Lifecycle.js → lib/src/components/Lifecycle.ts View File

@@ -1,4 +1,6 @@
1
-class Lifecycle {
1
+export class Lifecycle {
2
+  private store: any;
3
+
2 4
   constructor(store) {
3 5
     this.store = store;
4 6
     this.componentDidAppear = this.componentDidAppear.bind(this);
@@ -27,5 +29,3 @@ class Lifecycle {
27 29
     }
28 30
   }
29 31
 }
30
-
31
-module.exports = Lifecycle;

lib/src/components/Store.test.js → lib/src/components/Store.test.ts View File

@@ -1,4 +1,4 @@
1
-const Store = require('./Store');
1
+import { Store } from './Store';
2 2
 
3 3
 describe('Store', () => {
4 4
   let uut;

lib/src/components/Store.js → lib/src/components/Store.ts View File

@@ -1,6 +1,10 @@
1
-const _ = require('lodash');
1
+import * as _ from 'lodash';
2
+
3
+export class Store {
4
+  private propsByComponentId: {};
5
+  private componentsByName: {};
6
+  private refsById: {};
2 7
 
3
-class Store {
4 8
   constructor() {
5 9
     this.propsByComponentId = {};
6 10
     this.componentsByName = {};
@@ -36,5 +40,3 @@ class Store {
36 40
     _.unset(this.propsByComponentId, id);
37 41
   }
38 42
 }
39
-
40
-module.exports = Store;

+ 1
- 1
lib/src/events/PrivateEventsListener.test.ts View File

@@ -1,6 +1,6 @@
1 1
 import { PrivateEventsListener } from './PrivateEventsListener';
2 2
 import { NativeEventsReceiver } from '../adapters/NativeEventsReceiver.mock';
3
-import * as  Store from '../components/Store';
3
+import { Store } from '../components/Store';
4 4
 
5 5
 describe('PrivateEventsListener', () => {
6 6
   let uut: PrivateEventsListener;

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

@@ -1,5 +1,5 @@
1
-const PublicEventsRegistry = require('./PublicEventsRegistry');
2
-const NativeEventsReceiver = require('../adapters/NativeEventsReceiver.mock');
1
+import { PublicEventsRegistry } from './PublicEventsRegistry';
2
+import { NativeEventsReceiver } from '../adapters/NativeEventsReceiver.mock';
3 3
 
4 4
 describe('PublicEventsRegistry', () => {
5 5
   let uut;

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

@@ -1,4 +1,6 @@
1
-class PublicEventsRegistry {
1
+export class PublicEventsRegistry {
2
+  private nativeEventsReceiver: any;
3
+
2 4
   constructor(nativeEventsReceiver) {
3 5
     this.nativeEventsReceiver = nativeEventsReceiver;
4 6
   }
@@ -7,5 +9,3 @@ class PublicEventsRegistry {
7 9
     this.nativeEventsReceiver.registerAppLaunched(callback);
8 10
   }
9 11
 }
10
-
11
-module.exports = PublicEventsRegistry;