uicore-ts 1.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (128) hide show
  1. package/.idea/misc.xml +6 -0
  2. package/.idea/modules.xml +8 -0
  3. package/.idea/uicore.iml +9 -0
  4. package/.idea/vcs.xml +6 -0
  5. package/LICENSE +21 -0
  6. package/README.md +5 -0
  7. package/compiledScripts/UIActionIndicator.d.ts +12 -0
  8. package/compiledScripts/UIActionIndicator.js +54 -0
  9. package/compiledScripts/UIActionIndicator.js.map +1 -0
  10. package/compiledScripts/UIBaseButton.d.ts +52 -0
  11. package/compiledScripts/UIBaseButton.js +268 -0
  12. package/compiledScripts/UIBaseButton.js.map +1 -0
  13. package/compiledScripts/UIButton.d.ts +54 -0
  14. package/compiledScripts/UIButton.js +247 -0
  15. package/compiledScripts/UIButton.js.map +1 -0
  16. package/compiledScripts/UIColor.d.ts +41 -0
  17. package/compiledScripts/UIColor.js +286 -0
  18. package/compiledScripts/UIColor.js.map +1 -0
  19. package/compiledScripts/UICore.d.ts +27 -0
  20. package/compiledScripts/UICore.js +105 -0
  21. package/compiledScripts/UICore.js.map +1 -0
  22. package/compiledScripts/UICoreExtensions.d.ts +60 -0
  23. package/compiledScripts/UICoreExtensions.js +527 -0
  24. package/compiledScripts/UICoreExtensions.js.map +1 -0
  25. package/compiledScripts/UIDateTimeInput.d.ts +40 -0
  26. package/compiledScripts/UIDateTimeInput.js +38 -0
  27. package/compiledScripts/UIDateTimeInput.js.map +1 -0
  28. package/compiledScripts/UIDialogView.d.ts +23 -0
  29. package/compiledScripts/UIDialogView.js +118 -0
  30. package/compiledScripts/UIDialogView.js.map +1 -0
  31. package/compiledScripts/UIImageView.d.ts +36 -0
  32. package/compiledScripts/UIImageView.js +170 -0
  33. package/compiledScripts/UIImageView.js.map +1 -0
  34. package/compiledScripts/UIKeyValueStringFilter.d.ts +21 -0
  35. package/compiledScripts/UIKeyValueStringFilter.js +98 -0
  36. package/compiledScripts/UIKeyValueStringFilter.js.map +1 -0
  37. package/compiledScripts/UIKeyValueStringSorter.d.ts +38 -0
  38. package/compiledScripts/UIKeyValueStringSorter.js +117 -0
  39. package/compiledScripts/UIKeyValueStringSorter.js.map +1 -0
  40. package/compiledScripts/UILayoutGrid.d.ts +8 -0
  41. package/compiledScripts/UILayoutGrid.js +22 -0
  42. package/compiledScripts/UILayoutGrid.js.map +1 -0
  43. package/compiledScripts/UILink.d.ts +25 -0
  44. package/compiledScripts/UILink.js +81 -0
  45. package/compiledScripts/UILink.js.map +1 -0
  46. package/compiledScripts/UILinkButton.d.ts +18 -0
  47. package/compiledScripts/UILinkButton.js +60 -0
  48. package/compiledScripts/UILinkButton.js.map +1 -0
  49. package/compiledScripts/UINativeScrollView.d.ts +20 -0
  50. package/compiledScripts/UINativeScrollView.js +121 -0
  51. package/compiledScripts/UINativeScrollView.js.map +1 -0
  52. package/compiledScripts/UIObject.d.ts +69 -0
  53. package/compiledScripts/UIObject.js +442 -0
  54. package/compiledScripts/UIObject.js.map +1 -0
  55. package/compiledScripts/UIPoint.d.ts +18 -0
  56. package/compiledScripts/UIPoint.js +68 -0
  57. package/compiledScripts/UIPoint.js.map +1 -0
  58. package/compiledScripts/UIRectangle.d.ts +61 -0
  59. package/compiledScripts/UIRectangle.js +421 -0
  60. package/compiledScripts/UIRectangle.js.map +1 -0
  61. package/compiledScripts/UIRoute.d.ts +39 -0
  62. package/compiledScripts/UIRoute.js +202 -0
  63. package/compiledScripts/UIRoute.js.map +1 -0
  64. package/compiledScripts/UIScrollView.d.ts +19 -0
  65. package/compiledScripts/UIScrollView.js +121 -0
  66. package/compiledScripts/UIScrollView.js.map +1 -0
  67. package/compiledScripts/UISlideScrollerView.d.ts +40 -0
  68. package/compiledScripts/UISlideScrollerView.js +242 -0
  69. package/compiledScripts/UISlideScrollerView.js.map +1 -0
  70. package/compiledScripts/UIStringFilter.d.ts +26 -0
  71. package/compiledScripts/UIStringFilter.js +107 -0
  72. package/compiledScripts/UIStringFilter.js.map +1 -0
  73. package/compiledScripts/UITableView.d.ts +61 -0
  74. package/compiledScripts/UITableView.js +383 -0
  75. package/compiledScripts/UITableView.js.map +1 -0
  76. package/compiledScripts/UITextArea.d.ts +7 -0
  77. package/compiledScripts/UITextArea.js +27 -0
  78. package/compiledScripts/UITextArea.js.map +1 -0
  79. package/compiledScripts/UITextField.d.ts +44 -0
  80. package/compiledScripts/UITextField.js +83 -0
  81. package/compiledScripts/UITextField.js.map +1 -0
  82. package/compiledScripts/UITextView.d.ts +89 -0
  83. package/compiledScripts/UITextView.js +237 -0
  84. package/compiledScripts/UITextView.js.map +1 -0
  85. package/compiledScripts/UITimer.d.ts +13 -0
  86. package/compiledScripts/UITimer.js +45 -0
  87. package/compiledScripts/UITimer.js.map +1 -0
  88. package/compiledScripts/UIView.d.ts +330 -0
  89. package/compiledScripts/UIView.js +1533 -0
  90. package/compiledScripts/UIView.js.map +1 -0
  91. package/compiledScripts/UIViewController.d.ts +38 -0
  92. package/compiledScripts/UIViewController.js +153 -0
  93. package/compiledScripts/UIViewController.js.map +1 -0
  94. package/compiledScripts/index.d.ts +29 -0
  95. package/compiledScripts/index.js +46 -0
  96. package/compiledScripts/index.js.map +1 -0
  97. package/package.json +36 -0
  98. package/scripts/UIActionIndicator.ts +139 -0
  99. package/scripts/UIBaseButton.ts +563 -0
  100. package/scripts/UIButton.ts +552 -0
  101. package/scripts/UIColor.ts +427 -0
  102. package/scripts/UICore.ts +223 -0
  103. package/scripts/UICoreExtensions.ts +949 -0
  104. package/scripts/UIDateTimeInput.ts +109 -0
  105. package/scripts/UIDialogView.ts +297 -0
  106. package/scripts/UIImageView.ts +366 -0
  107. package/scripts/UIKeyValueStringFilter.ts +260 -0
  108. package/scripts/UIKeyValueStringSorter.ts +337 -0
  109. package/scripts/UILayoutGrid.ts +83 -0
  110. package/scripts/UILink.ts +292 -0
  111. package/scripts/UILinkButton.ts +238 -0
  112. package/scripts/UINativeScrollView.ts +254 -0
  113. package/scripts/UIObject.ts +827 -0
  114. package/scripts/UIPoint.ts +123 -0
  115. package/scripts/UIRectangle.ts +730 -0
  116. package/scripts/UIRoute.ts +391 -0
  117. package/scripts/UIScrollView.ts +290 -0
  118. package/scripts/UISlideScrollerView.ts +530 -0
  119. package/scripts/UIStringFilter.ts +293 -0
  120. package/scripts/UITableView.ts +790 -0
  121. package/scripts/UITextArea.ts +91 -0
  122. package/scripts/UITextField.ts +218 -0
  123. package/scripts/UITextView.ts +561 -0
  124. package/scripts/UITimer.ts +107 -0
  125. package/scripts/UIView.ts +2789 -0
  126. package/scripts/UIViewController.ts +304 -0
  127. package/scripts/index.ts +36 -0
  128. package/tsconfig.json +59 -0
@@ -0,0 +1,827 @@
1
+ import { UICoreExtensionValueObject } from "./UICoreExtensions"
2
+ import { UITimer } from "./UITimer"
3
+
4
+
5
+
6
+
7
+
8
+ export function NilFunction() {
9
+ return nil
10
+ }
11
+
12
+
13
+
14
+ export var nil: any = new Proxy(Object.assign(NilFunction, { "class": nil, "className": "Nil" }), {
15
+
16
+ get(target, name) {
17
+
18
+ if (name == Symbol.toPrimitive) {
19
+
20
+ return function (hint) {
21
+ if (hint == "number") {
22
+ return 0
23
+ }
24
+ if (hint == "string") {
25
+ return ""
26
+ }
27
+ return false
28
+ }
29
+
30
+ }
31
+
32
+ if (name == "toString") {
33
+
34
+ return function toString() {
35
+ return ""
36
+ }
37
+
38
+ }
39
+
40
+ return NilFunction()
41
+ },
42
+
43
+ set(target, name, value) {
44
+ return NilFunction()
45
+ }
46
+
47
+ })
48
+
49
+
50
+
51
+
52
+
53
+ export function wrapInNil<T>(object?: T): T {
54
+
55
+
56
+ let result = FIRST_OR_NIL(object)
57
+
58
+ if (object instanceof Object && !(object instanceof Function)) {
59
+
60
+ result = new Proxy(object as Object & T, {
61
+
62
+ get(target, name) {
63
+
64
+ if (name == "wrapped_nil_target") {
65
+
66
+ return target
67
+
68
+ }
69
+
70
+
71
+ const value = Reflect.get(target, name)
72
+
73
+ if (typeof value === "object") {
74
+
75
+ return wrapInNil(value)
76
+
77
+ }
78
+
79
+ if (IS_NOT_LIKE_NULL(value)) {
80
+
81
+ return value
82
+
83
+ }
84
+
85
+ return nil
86
+
87
+ },
88
+
89
+ set(target, name, value) {
90
+
91
+ if (IS(target)) {
92
+
93
+ target[name] = value
94
+
95
+ }
96
+
97
+ return YES
98
+
99
+ }
100
+
101
+ })
102
+
103
+ }
104
+
105
+ return result
106
+
107
+ }
108
+
109
+
110
+ export const YES = true
111
+ export const NO = false
112
+
113
+ export function IS(object) {
114
+
115
+ if (object && object !== nil) {
116
+
117
+ return YES
118
+
119
+ }
120
+
121
+ return NO
122
+
123
+ //return (object != nil && object);
124
+
125
+ }
126
+
127
+ export function IS_NOT(object) {
128
+
129
+ return !IS(object)
130
+
131
+ }
132
+
133
+ export function IS_DEFINED(object) {
134
+
135
+ if (object != undefined) {
136
+
137
+ return YES
138
+
139
+ }
140
+
141
+ return NO
142
+
143
+ }
144
+
145
+ export function IS_UNDEFINED(object) {
146
+
147
+ return !IS_DEFINED(object)
148
+
149
+ }
150
+
151
+ export function IS_NIL(object) {
152
+
153
+ if (object === nil) {
154
+
155
+ return YES
156
+
157
+ }
158
+
159
+ return NO
160
+
161
+ }
162
+
163
+ export function IS_NOT_NIL(object) {
164
+
165
+ return !IS_NIL(object)
166
+
167
+ }
168
+
169
+
170
+ export function IS_LIKE_NULL(object) {
171
+
172
+ return (IS_UNDEFINED(object) || IS_NIL(object) || object == null)
173
+
174
+ }
175
+
176
+ export function IS_NOT_LIKE_NULL(object) {
177
+
178
+ return !IS_LIKE_NULL(object)
179
+
180
+ }
181
+
182
+
183
+ export function IS_AN_EMAIL_ADDRESS(email: string) {
184
+ const re = /\S+@\S+\.\S+/
185
+ return re.test(email)
186
+ }
187
+
188
+
189
+ export function FIRST_OR_NIL<T>(...objects: T[]): T {
190
+
191
+ const result = objects.find(function (object, index, array) {
192
+
193
+ return IS(object)
194
+
195
+ })
196
+
197
+ return result || nil
198
+
199
+ }
200
+
201
+ export function FIRST<T>(...objects: T[]): T {
202
+
203
+ const result = objects.find(function (object, index, array) {
204
+
205
+ return IS(object)
206
+
207
+ })
208
+
209
+ return result || IF(IS_DEFINED(objects.lastElement))(RETURNER(objects.lastElement))()
210
+
211
+ }
212
+
213
+
214
+ export function MAKE_ID(randomPartLength = 15) {
215
+
216
+ let result = ""
217
+ const characters = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"
218
+
219
+ for (let i = 0; i < randomPartLength; i++) {
220
+
221
+ result = result + characters.charAt(Math.floor(Math.random() * characters.length))
222
+
223
+ }
224
+
225
+ result = result + Date.now()
226
+
227
+ return result
228
+
229
+ }
230
+
231
+
232
+ export function RETURNER<T>(value?: T) {
233
+
234
+ return function (...objects: any[]) {
235
+
236
+ return value
237
+
238
+ }
239
+
240
+ }
241
+
242
+
243
+
244
+
245
+
246
+ export type UIIFBlockReceiver<T> = (functionToCall: () => any) => UIIFEvaluator<T>;
247
+
248
+ export type UIIFEvaluatorBase<T> = () => T;
249
+
250
+
251
+ export interface UIIFEvaluator<T> extends UIIFEvaluatorBase<T> {
252
+
253
+ ELSE_IF: (otherValue: any) => UIIFBlockReceiver<T>;
254
+ ELSE: (functionToCall: () => any) => T;
255
+
256
+ }
257
+
258
+
259
+ export function IF<T = any>(value: any): UIIFBlockReceiver<T> {
260
+
261
+ let thenFunction = nil
262
+ let elseFunction = nil
263
+
264
+ const result: any = function (functionToCall: () => T) {
265
+ thenFunction = functionToCall
266
+ return result.evaluateConditions
267
+ }
268
+
269
+
270
+ result.evaluateConditions = function () {
271
+ if (IS(value)) {
272
+ return thenFunction()
273
+ }
274
+ return elseFunction()
275
+ }
276
+
277
+
278
+ result.evaluateConditions.ELSE_IF = function (otherValue: any) {
279
+
280
+ const functionResult = IF(otherValue) as (UIIFBlockReceiver<T> & { evaluateConditions: UIIFEvaluator<T> })
281
+ elseFunction = functionResult.evaluateConditions
282
+
283
+ const functionResultEvaluateConditionsFunction: any = function () {
284
+ return result.evaluateConditions()
285
+ }
286
+ functionResultEvaluateConditionsFunction.ELSE_IF = functionResult.evaluateConditions.ELSE_IF
287
+ functionResultEvaluateConditionsFunction.ELSE = functionResult.evaluateConditions.ELSE
288
+
289
+ functionResult.evaluateConditions = functionResultEvaluateConditionsFunction
290
+
291
+ return functionResult
292
+
293
+ }
294
+
295
+
296
+ result.evaluateConditions.ELSE = function (functionToCall: () => T) {
297
+ elseFunction = functionToCall
298
+ return result.evaluateConditions()
299
+ }
300
+
301
+
302
+ return result
303
+ }
304
+
305
+
306
+
307
+
308
+
309
+ export class UIFunctionCall<T extends (...args: any) => any> {
310
+
311
+ isAUIFunctionCallObject = YES
312
+ parameters: Parameters<T>[]
313
+
314
+ constructor(...parameters: Parameters<T>) {
315
+
316
+ this.parameters = parameters
317
+
318
+ }
319
+
320
+ callFunction(functionToCall: T) {
321
+
322
+ const parameters = this.parameters
323
+ functionToCall(...parameters)
324
+
325
+ }
326
+
327
+
328
+ }
329
+
330
+
331
+ export function CALL<T extends (...args: any) => any>(...objects: Parameters<T>) {
332
+
333
+ const result = new UIFunctionCall<T>(...objects)
334
+ return result
335
+
336
+ }
337
+
338
+
339
+ export class UIFunctionExtender<T extends (...args: any) => any> {
340
+
341
+ isAUIFunctionExtenderObject = YES
342
+ extendingFunction: T
343
+
344
+ constructor(extendingFunction: T) {
345
+
346
+ this.extendingFunction = extendingFunction
347
+
348
+ }
349
+
350
+ extendedFunction(functionToExtend: T) {
351
+
352
+ const extendingFunction = this.extendingFunction
353
+
354
+ function extendedFunction(...objects: any[]) {
355
+
356
+ const boundFunctionToExtend = functionToExtend.bind(this)
357
+ boundFunctionToExtend(...objects)
358
+
359
+ const boundExtendingFunction = extendingFunction.bind(this)
360
+ boundExtendingFunction(...objects)
361
+
362
+ }
363
+
364
+ return extendedFunction
365
+
366
+ }
367
+
368
+
369
+ }
370
+
371
+
372
+ export function EXTEND<T extends (...args: any) => any>(extendingFunction: T) {
373
+
374
+ const result = new UIFunctionExtender(extendingFunction)
375
+ return result
376
+
377
+ }
378
+
379
+
380
+ export class UILazyPropertyValue<T> {
381
+
382
+ isAUILazyPropertyValueObject = YES
383
+ initFunction: () => T
384
+
385
+ constructor(initFunction: () => T) {
386
+
387
+ this.initFunction = initFunction
388
+
389
+ }
390
+
391
+ setLazyPropertyValue(key: string, target: object) {
392
+
393
+ let isValueInitialized = NO
394
+
395
+ // property value
396
+ let _value = nil
397
+
398
+ const initValue = () => {
399
+
400
+ _value = this.initFunction()
401
+ isValueInitialized = YES
402
+ this.initFunction = nil
403
+
404
+ }
405
+
406
+ if (delete target[key]) {
407
+
408
+ // Create new property with getter and setter
409
+ Object.defineProperty(target, key, {
410
+ get: function () {
411
+
412
+ if (IS_NOT(isValueInitialized)) {
413
+
414
+ initValue()
415
+
416
+ }
417
+
418
+ return _value
419
+
420
+ },
421
+ set: function (newValue) {
422
+
423
+ _value = newValue
424
+
425
+ },
426
+ enumerable: true,
427
+ configurable: true
428
+ })
429
+
430
+ }
431
+
432
+ }
433
+
434
+
435
+ }
436
+
437
+
438
+ export function LAZY_VALUE<T>(initFunction: () => T) {
439
+
440
+ const result = new UILazyPropertyValue(initFunction)
441
+
442
+ return result
443
+
444
+ }
445
+
446
+
447
+ export type UIInitializerObject<T> = {
448
+
449
+ [P in keyof T]?:
450
+ //T[P] extends (infer U)[] ? UIInitializerObject<U>[] :
451
+ T[P] extends (...args: any) => any ? UIFunctionCall<T[P]> | UIFunctionExtender<T[P]> | T[P] :
452
+ T[P] extends object ? UIInitializerObject<T[P]> | UILazyPropertyValue<T[P]> :
453
+ T[P];
454
+
455
+ }
456
+
457
+
458
+
459
+
460
+
461
+ // @ts-ignore
462
+ if (!window.AutoLayout) {
463
+
464
+ // @ts-ignore
465
+ window.AutoLayout = nil
466
+
467
+ }
468
+
469
+
470
+ export class UIObject {
471
+
472
+ _class: any
473
+
474
+ constructor() {
475
+
476
+ this._class = UIObject
477
+ this.superclass = nil.class
478
+
479
+
480
+ }
481
+
482
+ public get class(): any {
483
+ return (this.constructor as any)
484
+ }
485
+
486
+
487
+ public get superclass(): any {
488
+
489
+ return (this.constructor as any).superclass
490
+
491
+ }
492
+
493
+ public set superclass(superclass: any) {
494
+ (this.constructor as any).superclass = superclass
495
+ }
496
+
497
+
498
+
499
+
500
+
501
+ public static wrapObject<T>(object: T): UIObject & T {
502
+
503
+ if (IS_NOT(object)) {
504
+ return nil
505
+ }
506
+
507
+ if (object instanceof UIObject) {
508
+ return object
509
+ }
510
+
511
+ const result = Object.assign(new UIObject(), object)
512
+
513
+ return result
514
+
515
+ }
516
+
517
+
518
+ isKindOfClass(classObject) {
519
+ if (this.isMemberOfClass(classObject)) {
520
+ return YES
521
+ }
522
+ for (let superclassObject = this.superclass; IS(superclassObject); superclassObject = superclassObject.superclass) {
523
+ if (superclassObject == classObject) {
524
+ return YES
525
+ }
526
+ }
527
+ return NO
528
+ }
529
+
530
+
531
+ isMemberOfClass(classObject: any) {
532
+ return (this.class == classObject)
533
+ }
534
+
535
+
536
+
537
+ valueForKey(key: string) {
538
+ return this[key]
539
+ }
540
+
541
+ valueForKeyPath(keyPath: string): any {
542
+ return UIObject.valueForKeyPath(keyPath, this)
543
+ }
544
+
545
+ static valueForKeyPath(keyPath: string, object: any): any {
546
+
547
+ if (IS_NOT(keyPath)) {
548
+
549
+ return object
550
+
551
+ }
552
+
553
+ const keys = keyPath.split(".")
554
+ let currentObject = object
555
+
556
+ for (let i = 0; i < keys.length; i++) {
557
+
558
+ const key = keys[i]
559
+
560
+ if (key.substring(0, 2) == "[]") {
561
+
562
+ // This next object will be an array and the rest of the keys need to be run for each of the elements
563
+
564
+ currentObject = currentObject[key.substring(2)]
565
+
566
+ // CurrentObject is now an array
567
+
568
+ const remainingKeyPath = keys.slice(i + 1).join(".")
569
+
570
+ const currentArray = currentObject as unknown as any[]
571
+
572
+ currentObject = currentArray.map(function (subObject, index, array) {
573
+
574
+ const result = UIObject.valueForKeyPath(remainingKeyPath, subObject)
575
+
576
+ return result
577
+
578
+ })
579
+
580
+ break
581
+
582
+ }
583
+
584
+ currentObject = currentObject[key]
585
+ if (IS_NOT(currentObject)) {
586
+ currentObject = nil
587
+ }
588
+
589
+ }
590
+
591
+ return currentObject
592
+
593
+ }
594
+
595
+ setValueForKeyPath(keyPath: string, value: any, createPath = YES) {
596
+
597
+ return UIObject.setValueForKeyPath(keyPath, value, this, createPath)
598
+
599
+ }
600
+
601
+ static setValueForKeyPath(keyPath: string, value: any, currentObject: any, createPath) {
602
+
603
+ const keys = keyPath.split(".")
604
+ let didSetValue = NO
605
+
606
+ keys.forEach(function (key, index, array) {
607
+ if (index == array.length - 1 && IS_NOT_LIKE_NULL(currentObject)) {
608
+ currentObject[key] = value
609
+ didSetValue = YES
610
+ return
611
+ }
612
+ else if (IS_NOT(currentObject)) {
613
+ return
614
+ }
615
+
616
+ const currentObjectValue = currentObject[key]
617
+ if (IS_LIKE_NULL(currentObjectValue) && createPath) {
618
+ currentObject[key] = {}
619
+ }
620
+ currentObject = currentObject[key]
621
+ })
622
+
623
+ return didSetValue
624
+
625
+ }
626
+
627
+
628
+
629
+
630
+
631
+ configureWithObject(object: UIInitializerObject<this>): this {
632
+
633
+ return UIObject.configureWithObject(this, object)
634
+
635
+ }
636
+
637
+ configuredWithObject(object: UIInitializerObject<this>): this {
638
+
639
+ return UIObject.configureWithObject(this, object)
640
+
641
+ }
642
+
643
+
644
+ static configureWithObject<T extends object>(configurationTarget: T, object: UIInitializerObject<T>) {
645
+
646
+ const isAnObject = (item: any) => (item && typeof item === "object" && !Array.isArray(item) &&
647
+ !(item instanceof UICoreExtensionValueObject))
648
+
649
+ function isAClass(funcOrClass) {
650
+
651
+ const isFunction = functionToCheck => (functionToCheck && {}.toString.call(functionToCheck) ===
652
+ "[object Function]")
653
+
654
+ const propertyNames = Object.getOwnPropertyNames(funcOrClass)
655
+
656
+ return (isFunction(funcOrClass) && !propertyNames.includes("arguments") &&
657
+ propertyNames.includes("prototype"))
658
+
659
+ }
660
+
661
+ let keyPathsAndValues = []
662
+
663
+ function prepareKeyPathsAndValues(target: object, source: object, keyPath = "") {
664
+
665
+ if ((isAnObject(target) || isAClass(target)) && isAnObject(source)) {
666
+
667
+ source.forEach((sourceValue, key) => {
668
+
669
+ const valueKeyPath = keyPath + "." + key
670
+
671
+ function addValueAndKeyPath(sourceValue) {
672
+ keyPathsAndValues.push({
673
+ value: sourceValue,
674
+ keyPath: valueKeyPath.replace(".", "")
675
+ })
676
+ }
677
+
678
+ if (isAnObject(sourceValue) || isAClass(sourceValue)) {
679
+ if (!(key in target) || target[key] instanceof Function) {
680
+ addValueAndKeyPath(sourceValue)
681
+ }
682
+ else {
683
+ prepareKeyPathsAndValues(target[key], sourceValue, valueKeyPath)
684
+ }
685
+ }
686
+ else if (sourceValue instanceof UICoreExtensionValueObject) {
687
+ addValueAndKeyPath(sourceValue.value)
688
+ }
689
+ else {
690
+ addValueAndKeyPath(sourceValue)
691
+ }
692
+
693
+ })
694
+
695
+ }
696
+
697
+ }
698
+
699
+ prepareKeyPathsAndValues(configurationTarget, object)
700
+
701
+ // Sort based on key paths
702
+ keyPathsAndValues = keyPathsAndValues.sort((a, b) => {
703
+
704
+ const firstKeyPath = (a.keyPath as string).split(".").length
705
+ const secondKeyPath = (b.keyPath as string).split(".").length
706
+
707
+ if (firstKeyPath < secondKeyPath) {
708
+ return -1
709
+ }
710
+ if (firstKeyPath > secondKeyPath) {
711
+ return 1
712
+ }
713
+ return 0
714
+
715
+ })
716
+
717
+ keyPathsAndValues.forEach((valueAndKeyPath) => {
718
+
719
+ const keyPath: string = valueAndKeyPath.keyPath
720
+ let value = valueAndKeyPath.value
721
+
722
+ const getTargetFunction = (bindThis = NO) => {
723
+
724
+ let result = (UIObject.valueForKeyPath(keyPath, configurationTarget) as Function)
725
+
726
+ if (bindThis) {
727
+
728
+ const indexOfDot = keyPath.lastIndexOf(".")
729
+ const thisObject = UIObject.valueForKeyPath(keyPath.substring(0, indexOfDot), configurationTarget)
730
+ result = result.bind(thisObject)
731
+
732
+ }
733
+
734
+ return result
735
+
736
+ }
737
+
738
+ if (value instanceof UILazyPropertyValue) {
739
+
740
+ const indexOfDot = keyPath.lastIndexOf(".")
741
+ const thisObject = UIObject.valueForKeyPath(keyPath.substring(0, indexOfDot), configurationTarget)
742
+ const key = keyPath.substring(indexOfDot + 1)
743
+
744
+ value.setLazyPropertyValue(key, thisObject)
745
+
746
+ return
747
+
748
+ }
749
+
750
+ if (value instanceof UIFunctionCall) {
751
+
752
+ value.callFunction(getTargetFunction(YES))
753
+
754
+ return
755
+
756
+ }
757
+
758
+ if (value instanceof UIFunctionExtender) {
759
+
760
+ value = value.extendedFunction(getTargetFunction())
761
+
762
+ }
763
+
764
+ UIObject.setValueForKeyPath(keyPath, value, configurationTarget, YES)
765
+
766
+ })
767
+
768
+
769
+ return configurationTarget
770
+
771
+ }
772
+
773
+
774
+
775
+
776
+
777
+ performFunctionWithSelf(functionToPerform: (self: this) => any) {
778
+
779
+ return functionToPerform(this)
780
+
781
+ }
782
+
783
+ performFunctionWithDelay(delay: number, functionToCall: Function) {
784
+
785
+
786
+
787
+ new UITimer(delay, NO, functionToCall)
788
+
789
+
790
+
791
+ }
792
+
793
+
794
+
795
+
796
+
797
+ }
798
+
799
+
800
+
801
+
802
+
803
+
804
+
805
+
806
+
807
+
808
+
809
+
810
+
811
+
812
+
813
+
814
+
815
+
816
+
817
+
818
+
819
+
820
+
821
+
822
+
823
+
824
+
825
+
826
+
827
+