@zajno/common 1.6.2 → 2.0.0-beta.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.
- package/.eslintrc.js +1 -1
- package/README.md +6 -1
- package/coverage/clover.xml +342 -1064
- package/coverage/coverage-final.json +30 -44
- package/coverage/lcov-report/__tests__/helpers/expect.ts.html +94 -0
- package/coverage/lcov-report/__tests__/helpers/index.html +131 -0
- package/coverage/lcov-report/__tests__/helpers/main.ts.html +121 -0
- package/coverage/lcov-report/async/arrays.ts.html +199 -0
- package/coverage/lcov-report/async/index.html +36 -21
- package/coverage/lcov-report/async/timeout.ts.html +124 -22
- package/coverage/lcov-report/dates/calc.ts.html +301 -0
- package/coverage/lcov-report/dates/convert.ts.html +658 -0
- package/coverage/lcov-report/dates/datex.ts.html +211 -0
- package/coverage/lcov-report/dates/format.ts.html +403 -0
- package/coverage/lcov-report/dates/index.html +251 -0
- package/coverage/lcov-report/dates/index.ts.html +112 -0
- package/coverage/lcov-report/dates/parse.ts.html +157 -0
- package/coverage/lcov-report/dates/period.ts.html +154 -0
- package/coverage/lcov-report/dates/shift.ts.html +355 -0
- package/coverage/lcov-report/dates/types.ts.html +181 -0
- package/coverage/lcov-report/dates/yearDate.ts.html +193 -0
- package/coverage/lcov-report/fields/index.html +116 -0
- package/coverage/lcov-report/fields/update.ts.html +457 -0
- package/coverage/lcov-report/functions/disposer.ts.html +376 -0
- package/coverage/lcov-report/functions/index.html +116 -0
- package/coverage/lcov-report/functions/safeCall.ts.html +103 -0
- package/coverage/lcov-report/index.html +119 -74
- package/coverage/lcov-report/lazy/index.html +131 -0
- package/coverage/lcov-report/lazy/light.ts.html +172 -0
- package/coverage/lcov-report/lazy/promise.ts.html +241 -0
- package/coverage/lcov-report/lazy/singleton.ts.html +181 -0
- package/coverage/lcov-report/logger/batch.ts.html +112 -0
- package/coverage/lcov-report/logger/console.ts.html +241 -0
- package/coverage/lcov-report/logger/index.html +80 -20
- package/coverage/lcov-report/logger/index.ts.html +48 -48
- package/coverage/lcov-report/logger/named.ts.html +226 -0
- package/coverage/lcov-report/logger/proxy.ts.html +172 -0
- package/coverage/lcov-report/math/arrays.ts.html +907 -0
- package/coverage/lcov-report/math/calc.ts.html +292 -0
- package/coverage/lcov-report/math/distribution.ts.html +145 -0
- package/coverage/lcov-report/math/index.html +161 -0
- package/coverage/lcov-report/math/index.ts.html +166 -0
- package/coverage/lcov-report/observing/event.ts.html +358 -0
- package/coverage/lcov-report/observing/index.html +116 -0
- package/coverage/lcov-report/observing/transition.ts.html +634 -0
- package/coverage/lcov-report/src/__tests__/helpers/expect.ts.html +1 -1
- package/coverage/lcov-report/src/__tests__/helpers/index.html +1 -1
- package/coverage/lcov-report/src/__tests__/helpers/main.ts.html +1 -1
- package/coverage/lcov-report/src/async/arrays.ts.html +1 -1
- package/coverage/lcov-report/src/async/index.html +21 -36
- package/coverage/lcov-report/src/async/timeout.ts.html +59 -59
- package/coverage/lcov-report/src/cache.ts.html +97 -97
- package/coverage/lcov-report/src/dates/calc.ts.html +1 -1
- package/coverage/lcov-report/src/dates/convert.ts.html +1 -1
- package/coverage/lcov-report/src/dates/datex.ts.html +1 -1
- package/coverage/lcov-report/src/dates/format.ts.html +1 -1
- package/coverage/lcov-report/src/dates/index.html +1 -1
- package/coverage/lcov-report/src/dates/index.ts.html +1 -1
- package/coverage/lcov-report/src/dates/parse.ts.html +1 -1
- package/coverage/lcov-report/src/dates/period.ts.html +1 -1
- package/coverage/lcov-report/src/dates/shift.ts.html +1 -1
- package/coverage/lcov-report/src/dates/types.ts.html +1 -1
- package/coverage/lcov-report/src/dates/yearDate.ts.html +1 -1
- package/coverage/lcov-report/src/disposer.ts.html +1 -1
- package/coverage/lcov-report/src/enumHelper.ts.html +1 -1
- package/coverage/lcov-report/src/event.ts.html +1 -1
- package/coverage/lcov-report/src/fields/index.html +1 -1
- package/coverage/lcov-report/src/fields/update.ts.html +1 -1
- package/coverage/lcov-report/src/functions.ts.html +1 -1
- package/coverage/lcov-report/src/index.html +20 -155
- package/coverage/lcov-report/src/lazy/index.html +1 -1
- package/coverage/lcov-report/src/lazy/light.ts.html +1 -1
- package/coverage/lcov-report/src/lazy/observable.ts.html +1 -1
- package/coverage/lcov-report/src/lazy/promise.ts.html +1 -1
- package/coverage/lcov-report/src/lazy/singleton.ts.html +1 -1
- package/coverage/lcov-report/src/logger/batch.ts.html +1 -1
- package/coverage/lcov-report/src/logger/console.ts.html +1 -1
- package/coverage/lcov-report/src/logger/index.html +1 -1
- package/coverage/lcov-report/src/logger/index.ts.html +1 -1
- package/coverage/lcov-report/src/logger/named.ts.html +1 -1
- package/coverage/lcov-report/src/logger/proxy.ts.html +1 -1
- package/coverage/lcov-report/src/math/arrays.ts.html +316 -277
- package/coverage/lcov-report/src/math/calc.ts.html +1 -1
- package/coverage/lcov-report/src/math/distribution.ts.html +1 -1
- package/coverage/lcov-report/src/math/index.html +21 -66
- package/coverage/lcov-report/src/math/index.ts.html +1 -1
- package/coverage/lcov-report/src/observersMap.ts.html +1 -1
- package/coverage/lcov-report/src/observingCache.ts.html +1 -1
- package/coverage/lcov-report/src/queue/index.html +1 -1
- package/coverage/lcov-report/src/queue/parallel.ts.html +1 -1
- package/coverage/lcov-report/src/tempoCache.ts.html +1 -1
- package/coverage/lcov-report/src/transitionObserver.ts.html +1 -1
- package/coverage/lcov-report/src/types/comparator.ts.html +103 -0
- package/coverage/lcov-report/src/types/getter.ts.html +127 -0
- package/coverage/lcov-report/src/types/index.html +146 -0
- package/coverage/lcov-report/src/types/index.ts.html +112 -0
- package/coverage/lcov-report/src/validation/ValidationErrors.ts.html +1 -1
- package/coverage/lcov-report/src/validation/creditCard.ts.html +1 -1
- package/coverage/lcov-report/src/validation/helpers.ts.html +1 -1
- package/coverage/lcov-report/src/validation/index.html +1 -1
- package/coverage/lcov-report/src/validation/index.ts.html +1 -1
- package/coverage/lcov-report/src/validation/types.ts.html +1 -1
- package/coverage/lcov-report/src/validation/validators.ts.html +1 -1
- package/coverage/lcov-report/src/validation/wrappers.ts.html +1 -1
- package/coverage/lcov-report/src/viewModels/CommonModel.ts.html +1 -1
- package/coverage/lcov-report/src/viewModels/FlagModel.ts.html +1 -1
- package/coverage/lcov-report/src/viewModels/LoadingModel.ts.html +5 -2
- package/coverage/lcov-report/src/viewModels/MultiSelectModel.ts.html +1 -1
- package/coverage/lcov-report/src/viewModels/NumberModel.ts.html +1 -1
- package/coverage/lcov-report/src/viewModels/SelectModel.ts.html +1 -1
- package/coverage/lcov-report/src/viewModels/TextModel.ts.html +1 -1
- package/coverage/lcov-report/src/viewModels/Validatable.ts.html +1 -1
- package/coverage/lcov-report/src/viewModels/index.html +10 -130
- package/coverage/lcov-report/src/viewModels/wrappers.ts.html +1 -1
- package/coverage/lcov-report/structures/helpers/enum.ts.html +454 -0
- package/coverage/lcov-report/structures/helpers/index.html +116 -0
- package/coverage/lcov-report/structures/index.html +116 -0
- package/coverage/lcov-report/structures/promiseCache.ts.html +628 -0
- package/coverage/lcov-report/structures/queue/index.html +116 -0
- package/coverage/lcov-report/structures/queue/parallel.ts.html +511 -0
- package/coverage/lcov-report/structures/subscribersMap.ts.html +400 -0
- package/coverage/lcov-report/structures/subscribersPromiseCache.ts.html +562 -0
- package/coverage/lcov-report/structures/tempoCache.ts.html +139 -0
- package/coverage/lcov-report/types/comparator.ts.html +103 -0
- package/coverage/lcov-report/types/getter.ts.html +127 -0
- package/coverage/lcov-report/types/index.html +146 -0
- package/coverage/lcov-report/types/index.ts.html +112 -0
- package/coverage/lcov-report/validation/ValidationErrors.ts.html +163 -0
- package/coverage/lcov-report/validation/creditCard.ts.html +160 -0
- package/coverage/lcov-report/validation/helpers.ts.html +226 -0
- package/coverage/lcov-report/validation/index.html +107 -12
- package/coverage/lcov-report/validation/index.ts.html +13 -8
- package/coverage/lcov-report/validation/types.ts.html +139 -0
- package/coverage/lcov-report/validation/validators.ts.html +250 -0
- package/coverage/lcov-report/validation/wrappers.ts.html +163 -0
- package/coverage/lcov-report/viewModels/LoadingModel.ts.html +15 -7
- package/coverage/lcov-report/viewModels/index.html +19 -59
- package/coverage/lcov.info +745 -2263
- package/lib/fields/update.js +3 -3
- package/lib/fields/update.js.map +1 -1
- package/lib/{assert.d.ts → functions/assert.d.ts} +1 -1
- package/lib/functions/assert.d.ts.map +1 -0
- package/lib/{assert.js → functions/assert.js} +2 -2
- package/lib/functions/assert.js.map +1 -0
- package/lib/{disposer.d.ts → functions/disposer.d.ts} +0 -0
- package/lib/functions/disposer.d.ts.map +1 -0
- package/lib/{disposer.js → functions/disposer.js} +1 -1
- package/lib/functions/disposer.js.map +1 -0
- package/lib/functions/safeCall.d.ts +2 -0
- package/lib/functions/safeCall.d.ts.map +1 -0
- package/lib/{functions.js → functions/safeCall.js} +1 -1
- package/lib/functions/safeCall.js.map +1 -0
- package/lib/{throttle.d.ts → functions/throttle.d.ts} +0 -0
- package/lib/functions/throttle.d.ts.map +1 -0
- package/lib/{throttle.js → functions/throttle.js} +1 -1
- package/lib/functions/throttle.js.map +1 -0
- package/lib/lazy/light.d.ts +1 -1
- package/lib/lazy/light.d.ts.map +1 -1
- package/lib/lazy/promise.d.ts +1 -1
- package/lib/lazy/promise.d.ts.map +1 -1
- package/lib/lazy/singleton.d.ts +1 -1
- package/lib/lazy/singleton.d.ts.map +1 -1
- package/lib/math/arrays.d.ts +1 -0
- package/lib/math/arrays.d.ts.map +1 -1
- package/lib/math/arrays.js +13 -1
- package/lib/math/arrays.js.map +1 -1
- package/lib/{event.d.ts → observing/event.d.ts} +2 -3
- package/lib/observing/event.d.ts.map +1 -0
- package/lib/{event.js → observing/event.js} +2 -3
- package/lib/{event.js.map → observing/event.js.map} +1 -1
- package/lib/{throttledEvent.d.ts → observing/throttledEvent.d.ts} +0 -0
- package/lib/observing/throttledEvent.d.ts.map +1 -0
- package/lib/{throttledEvent.js → observing/throttledEvent.js} +1 -1
- package/lib/observing/throttledEvent.js.map +1 -0
- package/lib/{timer.d.ts → observing/timer.d.ts} +1 -1
- package/lib/observing/timer.d.ts.map +1 -0
- package/lib/{timer.js → observing/timer.js} +0 -0
- package/lib/observing/timer.js.map +1 -0
- package/lib/{services/storage → storage}/index.d.ts +1 -1
- package/lib/storage/index.d.ts.map +1 -0
- package/lib/{services/storage → storage}/index.js +0 -0
- package/lib/storage/index.js.map +1 -0
- package/lib/{services/storage → storage}/web/localStorage.d.ts +1 -1
- package/lib/storage/web/localStorage.d.ts.map +1 -0
- package/lib/{services/storage → storage}/web/localStorage.js +0 -0
- package/lib/storage/web/localStorage.js.map +1 -0
- package/lib/{services/storage → storage}/web/sessionStorage.d.ts +1 -1
- package/lib/storage/web/sessionStorage.d.ts.map +1 -0
- package/lib/{services/storage → storage}/web/sessionStorage.js +0 -0
- package/lib/storage/web/sessionStorage.js.map +1 -0
- package/lib/{services/storage → storage}/web/webStorage.d.ts +1 -1
- package/lib/storage/web/webStorage.d.ts.map +1 -0
- package/lib/{services/storage → storage}/web/webStorage.js +0 -0
- package/lib/storage/web/webStorage.js.map +1 -0
- package/lib/{enumHelper.d.ts → structures/helpers/enum.d.ts} +1 -1
- package/lib/structures/helpers/enum.d.ts.map +1 -0
- package/lib/{enumHelper.js → structures/helpers/enum.js} +1 -1
- package/lib/structures/helpers/enum.js.map +1 -0
- package/lib/{nameHelper.d.ts → structures/helpers/name.d.ts} +5 -5
- package/lib/structures/helpers/name.d.ts.map +1 -0
- package/lib/{nameHelper.js → structures/helpers/name.js} +7 -6
- package/lib/structures/helpers/name.js.map +1 -0
- package/lib/structures/linkedList.d.ts +39 -0
- package/lib/structures/linkedList.d.ts.map +1 -0
- package/lib/structures/linkedList.js +82 -0
- package/lib/structures/linkedList.js.map +1 -0
- package/lib/{pool.d.ts → structures/pool.d.ts} +1 -1
- package/lib/structures/pool.d.ts.map +1 -0
- package/lib/{pool.js → structures/pool.js} +2 -2
- package/lib/structures/pool.js.map +1 -0
- package/lib/{queue → structures/queue}/parallel.d.ts +3 -3
- package/lib/structures/queue/parallel.d.ts.map +1 -0
- package/lib/{queue → structures/queue}/parallel.js +2 -2
- package/lib/structures/queue/parallel.js.map +1 -0
- package/lib/{tempoCache.d.ts → structures/tempoCache.d.ts} +0 -0
- package/lib/structures/tempoCache.d.ts.map +1 -0
- package/lib/{tempoCache.js → structures/tempoCache.js} +0 -0
- package/lib/structures/tempoCache.js.map +1 -0
- package/lib/types/comparator.d.ts +5 -0
- package/lib/types/comparator.d.ts.map +1 -0
- package/lib/types/comparator.js +8 -0
- package/lib/types/comparator.js.map +1 -0
- package/lib/types/deep.d.ts +9 -0
- package/lib/types/deep.d.ts.map +1 -0
- package/lib/{deepPartial.js → types/deep.js} +1 -1
- package/lib/types/deep.js.map +1 -0
- package/lib/types/functions.d.ts +7 -0
- package/lib/types/functions.d.ts.map +1 -0
- package/lib/{services/localization/abstractions.js → types/functions.js} +1 -1
- package/lib/types/functions.js.map +1 -0
- package/lib/types/getter.d.ts +5 -0
- package/lib/types/getter.d.ts.map +1 -0
- package/lib/{types.js → types/getter.js} +2 -6
- package/lib/types/getter.js.map +1 -0
- package/lib/{ident.d.ts → types/ident.d.ts} +0 -0
- package/lib/types/ident.d.ts.map +1 -0
- package/lib/{ident.js → types/ident.js} +0 -0
- package/lib/types/ident.js.map +1 -0
- package/lib/types/index.d.ts +8 -0
- package/lib/types/index.d.ts.map +1 -0
- package/lib/types/index.js +7 -0
- package/lib/types/index.js.map +1 -0
- package/lib/validation/ValidationErrors.d.ts +1 -1
- package/lib/validation/ValidationErrors.d.ts.map +1 -1
- package/lib/validation/ValidationErrors.js +2 -2
- package/lib/validation/ValidationErrors.js.map +1 -1
- package/lib/{emails.d.ts → validation/emails.d.ts} +0 -0
- package/lib/validation/emails.d.ts.map +1 -0
- package/lib/{emails.js → validation/emails.js} +0 -0
- package/lib/validation/emails.js.map +1 -0
- package/lib/web/breakpoints/index.d.ts +3 -0
- package/lib/web/breakpoints/index.d.ts.map +1 -0
- package/lib/web/breakpoints/index.js +6 -0
- package/lib/web/breakpoints/index.js.map +1 -0
- package/lib/web/breakpoints/manager.d.ts +17 -0
- package/lib/web/breakpoints/manager.d.ts.map +1 -0
- package/lib/web/breakpoints/manager.js +56 -0
- package/lib/web/breakpoints/manager.js.map +1 -0
- package/lib/web/breakpoints/rem.d.ts +3 -0
- package/lib/web/breakpoints/rem.d.ts.map +1 -0
- package/lib/web/breakpoints/rem.js +22 -0
- package/lib/web/breakpoints/rem.js.map +1 -0
- package/lib/web/breakpoints/types.d.ts +22 -0
- package/lib/web/breakpoints/types.d.ts.map +1 -0
- package/lib/{viewModels → web/breakpoints}/types.js +0 -0
- package/lib/{viewModels → web/breakpoints}/types.js.map +1 -1
- package/package.json +16 -16
- package/src/.DS_Store +0 -0
- package/src/async/__tests__/timeout.test.ts +1 -1
- package/src/fields/update.ts +1 -1
- package/src/{assert.ts → functions/assert.ts} +2 -2
- package/src/{disposer.ts → functions/disposer.ts} +1 -1
- package/src/functions/safeCall.ts +6 -0
- package/src/{throttle.ts → functions/throttle.ts} +1 -1
- package/src/lazy/__tests__/lazy.test.ts +1 -48
- package/src/lazy/light.ts +1 -1
- package/src/lazy/promise.ts +1 -1
- package/src/lazy/singleton.ts +1 -1
- package/src/math/arrays.ts +13 -0
- package/src/{event.ts → observing/event.ts} +3 -4
- package/src/{throttledEvent.ts → observing/throttledEvent.ts} +1 -1
- package/src/{timer.ts → observing/timer.ts} +1 -1
- package/src/{services/storage → storage}/index.ts +1 -1
- package/src/{services/storage → storage}/web/localStorage.ts +1 -1
- package/src/{services/storage → storage}/web/sessionStorage.ts +1 -1
- package/src/{services/storage → storage}/web/webStorage.ts +1 -1
- package/src/{__tests__ → structures/__tests__}/enumHelper.test.ts +1 -1
- package/src/{__tests__ → structures/__tests__}/tempoCache.test.ts +1 -1
- package/src/{enumHelper.ts → structures/helpers/enum.ts} +0 -0
- package/src/{nameHelper.ts → structures/helpers/name.ts} +4 -4
- package/src/structures/linkedList.ts +129 -0
- package/src/{pool.ts → structures/pool.ts} +2 -2
- package/src/{queue → structures/queue}/__tests__/parallel.test.ts +2 -2
- package/src/{queue → structures/queue}/parallel.ts +2 -2
- package/src/{tempoCache.ts → structures/tempoCache.ts} +0 -0
- package/src/types/comparator.ts +6 -0
- package/src/types/deep.ts +18 -0
- package/src/types/functions.ts +8 -0
- package/src/types/getter.ts +14 -0
- package/src/{ident.ts → types/ident.ts} +0 -0
- package/src/types/index.ts +9 -0
- package/src/validation/ValidationErrors.ts +1 -1
- package/src/{emails.ts → validation/emails.ts} +0 -0
- package/src/web/breakpoints/index.ts +3 -0
- package/src/web/breakpoints/manager.ts +65 -0
- package/src/web/breakpoints/rem.ts +24 -0
- package/src/web/breakpoints/types.ts +26 -0
- package/tsconfig.build.json +10 -0
- package/tsconfig.json +0 -1
- package/yarn.lock +467 -370
- package/lib/assert.d.ts.map +0 -1
- package/lib/assert.js.map +0 -1
- package/lib/cache.d.ts +0 -36
- package/lib/cache.d.ts.map +0 -1
- package/lib/cache.js +0 -165
- package/lib/cache.js.map +0 -1
- package/lib/deepPartial.d.ts +0 -4
- package/lib/deepPartial.d.ts.map +0 -1
- package/lib/deepPartial.js.map +0 -1
- package/lib/disposer.d.ts.map +0 -1
- package/lib/disposer.js.map +0 -1
- package/lib/emails.d.ts.map +0 -1
- package/lib/emails.js.map +0 -1
- package/lib/enumHelper.d.ts.map +0 -1
- package/lib/enumHelper.js.map +0 -1
- package/lib/event.d.ts.map +0 -1
- package/lib/functions.d.ts +0 -9
- package/lib/functions.d.ts.map +0 -1
- package/lib/functions.js.map +0 -1
- package/lib/ident.d.ts.map +0 -1
- package/lib/ident.js.map +0 -1
- package/lib/lazy/index.d.ts +0 -10
- package/lib/lazy/index.d.ts.map +0 -1
- package/lib/lazy/index.js +0 -23
- package/lib/lazy/index.js.map +0 -1
- package/lib/lazy/observable.d.ts +0 -9
- package/lib/lazy/observable.d.ts.map +0 -1
- package/lib/lazy/observable.js +0 -31
- package/lib/lazy/observable.js.map +0 -1
- package/lib/lazy.light.d.ts +0 -2
- package/lib/lazy.light.d.ts.map +0 -1
- package/lib/lazy.light.js +0 -8
- package/lib/lazy.light.js.map +0 -1
- package/lib/nameHelper.d.ts.map +0 -1
- package/lib/nameHelper.js.map +0 -1
- package/lib/observersMap.d.ts +0 -22
- package/lib/observersMap.d.ts.map +0 -1
- package/lib/observersMap.js +0 -93
- package/lib/observersMap.js.map +0 -1
- package/lib/observingCache.d.ts +0 -32
- package/lib/observingCache.d.ts.map +0 -1
- package/lib/observingCache.js +0 -128
- package/lib/observingCache.js.map +0 -1
- package/lib/pool.d.ts.map +0 -1
- package/lib/pool.js.map +0 -1
- package/lib/queue/parallel.d.ts.map +0 -1
- package/lib/queue/parallel.js.map +0 -1
- package/lib/services/localization/LocalaziedValidationErrors.d.ts +0 -9
- package/lib/services/localization/LocalaziedValidationErrors.d.ts.map +0 -1
- package/lib/services/localization/LocalaziedValidationErrors.js +0 -27
- package/lib/services/localization/LocalaziedValidationErrors.js.map +0 -1
- package/lib/services/localization/LocalizationManager.d.ts +0 -18
- package/lib/services/localization/LocalizationManager.d.ts.map +0 -1
- package/lib/services/localization/LocalizationManager.js +0 -58
- package/lib/services/localization/LocalizationManager.js.map +0 -1
- package/lib/services/localization/abstractions.d.ts +0 -12
- package/lib/services/localization/abstractions.d.ts.map +0 -1
- package/lib/services/localization/abstractions.js.map +0 -1
- package/lib/services/localization/defaultShape.d.ts +0 -26
- package/lib/services/localization/defaultShape.d.ts.map +0 -1
- package/lib/services/localization/defaultShape.js +0 -28
- package/lib/services/localization/defaultShape.js.map +0 -1
- package/lib/services/localization/index.d.ts +0 -5
- package/lib/services/localization/index.d.ts.map +0 -1
- package/lib/services/localization/index.js +0 -10
- package/lib/services/localization/index.js.map +0 -1
- package/lib/services/storage/index.d.ts.map +0 -1
- package/lib/services/storage/index.js.map +0 -1
- package/lib/services/storage/web/localStorage.d.ts.map +0 -1
- package/lib/services/storage/web/localStorage.js.map +0 -1
- package/lib/services/storage/web/sessionStorage.d.ts.map +0 -1
- package/lib/services/storage/web/sessionStorage.js.map +0 -1
- package/lib/services/storage/web/webStorage.d.ts.map +0 -1
- package/lib/services/storage/web/webStorage.js.map +0 -1
- package/lib/tempoCache.d.ts.map +0 -1
- package/lib/tempoCache.js.map +0 -1
- package/lib/throttle.d.ts.map +0 -1
- package/lib/throttle.js.map +0 -1
- package/lib/throttledEvent.d.ts.map +0 -1
- package/lib/throttledEvent.js.map +0 -1
- package/lib/timeHelper.d.ts +0 -7
- package/lib/timeHelper.d.ts.map +0 -1
- package/lib/timeHelper.js +0 -37
- package/lib/timeHelper.js.map +0 -1
- package/lib/timer.d.ts.map +0 -1
- package/lib/timer.js.map +0 -1
- package/lib/transitionObserver.d.ts +0 -36
- package/lib/transitionObserver.d.ts.map +0 -1
- package/lib/transitionObserver.js +0 -153
- package/lib/transitionObserver.js.map +0 -1
- package/lib/types.d.ts +0 -17
- package/lib/types.d.ts.map +0 -1
- package/lib/types.js.map +0 -1
- package/lib/unsubscriber.d.ts +0 -2
- package/lib/unsubscriber.d.ts.map +0 -1
- package/lib/unsubscriber.js +0 -12
- package/lib/unsubscriber.js.map +0 -1
- package/lib/validation/ValidationErrorsLocalization.d.ts +0 -27
- package/lib/validation/ValidationErrorsLocalization.d.ts.map +0 -1
- package/lib/validation/ValidationErrorsLocalization.js +0 -26
- package/lib/validation/ValidationErrorsLocalization.js.map +0 -1
- package/lib/viewModels/CommonModel.d.ts +0 -13
- package/lib/viewModels/CommonModel.d.ts.map +0 -1
- package/lib/viewModels/CommonModel.js +0 -38
- package/lib/viewModels/CommonModel.js.map +0 -1
- package/lib/viewModels/FlagModel.d.ts +0 -22
- package/lib/viewModels/FlagModel.d.ts.map +0 -1
- package/lib/viewModels/FlagModel.js +0 -52
- package/lib/viewModels/FlagModel.js.map +0 -1
- package/lib/viewModels/InitializableModel.d.ts +0 -6
- package/lib/viewModels/InitializableModel.d.ts.map +0 -1
- package/lib/viewModels/InitializableModel.js +0 -23
- package/lib/viewModels/InitializableModel.js.map +0 -1
- package/lib/viewModels/LoadingModel.d.ts +0 -17
- package/lib/viewModels/LoadingModel.d.ts.map +0 -1
- package/lib/viewModels/LoadingModel.js +0 -42
- package/lib/viewModels/LoadingModel.js.map +0 -1
- package/lib/viewModels/MultiSelectModel.d.ts +0 -47
- package/lib/viewModels/MultiSelectModel.d.ts.map +0 -1
- package/lib/viewModels/MultiSelectModel.js +0 -144
- package/lib/viewModels/MultiSelectModel.js.map +0 -1
- package/lib/viewModels/NumberModel.d.ts +0 -19
- package/lib/viewModels/NumberModel.d.ts.map +0 -1
- package/lib/viewModels/NumberModel.js +0 -38
- package/lib/viewModels/NumberModel.js.map +0 -1
- package/lib/viewModels/PromptModal.d.ts +0 -31
- package/lib/viewModels/PromptModal.d.ts.map +0 -1
- package/lib/viewModels/PromptModal.js +0 -57
- package/lib/viewModels/PromptModal.js.map +0 -1
- package/lib/viewModels/SelectModel.d.ts +0 -35
- package/lib/viewModels/SelectModel.d.ts.map +0 -1
- package/lib/viewModels/SelectModel.js +0 -118
- package/lib/viewModels/SelectModel.js.map +0 -1
- package/lib/viewModels/TextModel.d.ts +0 -41
- package/lib/viewModels/TextModel.d.ts.map +0 -1
- package/lib/viewModels/TextModel.js +0 -98
- package/lib/viewModels/TextModel.js.map +0 -1
- package/lib/viewModels/Validatable.d.ts +0 -26
- package/lib/viewModels/Validatable.d.ts.map +0 -1
- package/lib/viewModels/Validatable.js +0 -81
- package/lib/viewModels/Validatable.js.map +0 -1
- package/lib/viewModels/ValueModel.d.ts +0 -12
- package/lib/viewModels/ValueModel.d.ts.map +0 -1
- package/lib/viewModels/ValueModel.js +0 -29
- package/lib/viewModels/ValueModel.js.map +0 -1
- package/lib/viewModels/ValuesCollector.d.ts +0 -26
- package/lib/viewModels/ValuesCollector.d.ts.map +0 -1
- package/lib/viewModels/ValuesCollector.js +0 -51
- package/lib/viewModels/ValuesCollector.js.map +0 -1
- package/lib/viewModels/index.d.ts +0 -12
- package/lib/viewModels/index.d.ts.map +0 -1
- package/lib/viewModels/index.js +0 -15
- package/lib/viewModels/index.js.map +0 -1
- package/lib/viewModels/types.d.ts +0 -19
- package/lib/viewModels/types.d.ts.map +0 -1
- package/lib/viewModels/wrappers.d.ts +0 -12
- package/lib/viewModels/wrappers.d.ts.map +0 -1
- package/lib/viewModels/wrappers.js +0 -43
- package/lib/viewModels/wrappers.js.map +0 -1
- package/src/__tests__/observingCache.test.ts +0 -127
- package/src/__tests__/transitionObserver.test.ts +0 -219
- package/src/cache.ts +0 -181
- package/src/deepPartial.ts +0 -4
- package/src/functions.ts +0 -14
- package/src/lazy/index.ts +0 -33
- package/src/lazy/observable.ts +0 -37
- package/src/lazy.light.ts +0 -8
- package/src/observersMap.ts +0 -105
- package/src/observingCache.ts +0 -160
- package/src/services/localization/LocalaziedValidationErrors.ts +0 -18
- package/src/services/localization/LocalizationManager.ts +0 -53
- package/src/services/localization/abstractions.ts +0 -16
- package/src/services/localization/defaultShape.ts +0 -26
- package/src/services/localization/index.ts +0 -6
- package/src/timeHelper.ts +0 -39
- package/src/transitionObserver.ts +0 -183
- package/src/types.ts +0 -30
- package/src/unsubscriber.ts +0 -14
- package/src/validation/ValidationErrorsLocalization.ts +0 -27
- package/src/viewModels/CommonModel.ts +0 -45
- package/src/viewModels/FlagModel.ts +0 -70
- package/src/viewModels/InitializableModel.ts +0 -17
- package/src/viewModels/LoadingModel.ts +0 -52
- package/src/viewModels/MultiSelectModel.ts +0 -178
- package/src/viewModels/NumberModel.ts +0 -50
- package/src/viewModels/PromptModal.ts +0 -65
- package/src/viewModels/SelectModel.ts +0 -152
- package/src/viewModels/TextModel.ts +0 -127
- package/src/viewModels/Validatable.ts +0 -102
- package/src/viewModels/ValueModel.ts +0 -34
- package/src/viewModels/ValuesCollector.ts +0 -81
- package/src/viewModels/__tests__/common.test.ts +0 -107
- package/src/viewModels/__tests__/multiSelect.test.ts +0 -138
- package/src/viewModels/__tests__/select.test.ts +0 -71
- package/src/viewModels/__tests__/wrappers.test.ts +0 -79
- package/src/viewModels/index.ts +0 -15
- package/src/viewModels/types.ts +0 -23
- package/src/viewModels/wrappers.ts +0 -49
- package/tsconfig.eslint.json +0 -9
package/src/observingCache.ts
DELETED
|
@@ -1,160 +0,0 @@
|
|
|
1
|
-
import { action } from 'mobx';
|
|
2
|
-
import { Disposable } from './disposer';
|
|
3
|
-
import { PromiseCache, DeferredGetter } from './cache';
|
|
4
|
-
import { ObserversMap } from './observersMap';
|
|
5
|
-
import { Fields } from './fields';
|
|
6
|
-
import logger from './logger';
|
|
7
|
-
|
|
8
|
-
export type Unsub = () => void;
|
|
9
|
-
export type Fetcher<T> = (key: string, cb: (val: T) => Promise<void> | void) => Unsub | Promise<Unsub>;
|
|
10
|
-
|
|
11
|
-
type ObserveStrategy = boolean | 'short' | number;
|
|
12
|
-
|
|
13
|
-
export interface IObservingCache<T> {
|
|
14
|
-
get(key: string): DeferredGetter<T>;
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
export class ObservingCache<T> extends Disposable implements IObservingCache<T> {
|
|
18
|
-
|
|
19
|
-
private readonly _cache: PromiseCache<T>;
|
|
20
|
-
private readonly _observers: ObserversMap;
|
|
21
|
-
|
|
22
|
-
private _observeStrategy: ObserveStrategy = null;
|
|
23
|
-
private readonly _observeStrategyOverrides: Record<string, ObserveStrategy> = { };
|
|
24
|
-
|
|
25
|
-
private _updater: Fields.Updater<T> = null;
|
|
26
|
-
|
|
27
|
-
constructor(readonly fetcher: Fetcher<T>) {
|
|
28
|
-
super();
|
|
29
|
-
|
|
30
|
-
this._cache = new PromiseCache(this._fetch);
|
|
31
|
-
this._observers = new ObserversMap(this._subscribe);
|
|
32
|
-
|
|
33
|
-
this.disposer.add(this._observers);
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
public get loadingCount() { return this._cache.busyCount; }
|
|
37
|
-
public get observersCount() { return this._observers.count; }
|
|
38
|
-
|
|
39
|
-
useObservingStrategy(observe: ObserveStrategy) {
|
|
40
|
-
this._observeStrategy = observe;
|
|
41
|
-
if (!this._observeStrategy) {
|
|
42
|
-
this._observers.clear();
|
|
43
|
-
} else {
|
|
44
|
-
const currentKeys = this._cache.keys();
|
|
45
|
-
const timeout = getObserveTimeout(this._observeStrategy);
|
|
46
|
-
currentKeys.forEach(key => this._observers.enable(key, true, timeout));
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
return this;
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
useUpdater(updater: Fields.Updater<T>) {
|
|
53
|
-
this._updater = updater;
|
|
54
|
-
this._cache.useObserveItems(updater != null);
|
|
55
|
-
return this;
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
getIsCached(key: string) {
|
|
59
|
-
return this._cache.hasKey(key);
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
getCurent(key: string) {
|
|
63
|
-
return this._cache.getCurrent(key, false);
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
get(key: string, overrideStrategy?: ObserveStrategy, observingStartedPromise?: (p: Promise<void>) => void): DeferredGetter<T> {
|
|
67
|
-
if (overrideStrategy !== undefined) {
|
|
68
|
-
this._observeStrategyOverrides[key] = overrideStrategy;
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
const strategy = firstDefined(this._observeStrategyOverrides[key], this._observeStrategy);
|
|
72
|
-
|
|
73
|
-
if (strategy && !this._observers.getIsObserving(key)) {
|
|
74
|
-
// ensure observe
|
|
75
|
-
if (this._cache.hasKey(key)) {
|
|
76
|
-
// the request has been initiated already
|
|
77
|
-
const timeout = getObserveTimeout(strategy);
|
|
78
|
-
const promise = this._observers.enable(key, true, timeout);
|
|
79
|
-
if (observingStartedPromise) {
|
|
80
|
-
observingStartedPromise(promise);
|
|
81
|
-
}
|
|
82
|
-
promise.catch(err => logger.error('[ObservingCache] Error on starting observe', key, strategy, err));
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
return this._cache.getDeferred(key);
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
populate = (key: string, item: T) => {
|
|
90
|
-
this._updateItem(key, item);
|
|
91
|
-
};
|
|
92
|
-
|
|
93
|
-
invalidate = (key: string) => {
|
|
94
|
-
this._observers.enable(key, false);
|
|
95
|
-
this._cache.invalidate(key);
|
|
96
|
-
};
|
|
97
|
-
|
|
98
|
-
private _fetch = async (key: string): Promise<T> => {
|
|
99
|
-
let firstLoad = true;
|
|
100
|
-
|
|
101
|
-
return new Promise<T>((resolve) => {
|
|
102
|
-
Promise.resolve<Unsub>(
|
|
103
|
-
this.fetcher(key, item => {
|
|
104
|
-
if (firstLoad) {
|
|
105
|
-
resolve(item);
|
|
106
|
-
firstLoad = false;
|
|
107
|
-
} else {
|
|
108
|
-
this._updateItem(key, item);
|
|
109
|
-
}
|
|
110
|
-
})
|
|
111
|
-
).then(unsub => {
|
|
112
|
-
const strategy = firstDefined(this._observeStrategyOverrides[key], this._observeStrategy);
|
|
113
|
-
if (!strategy) {
|
|
114
|
-
// immediate unsub in case no observing strategy has been set
|
|
115
|
-
unsub();
|
|
116
|
-
} else {
|
|
117
|
-
const timeout = getObserveTimeout(strategy);
|
|
118
|
-
this._observers.enable(key, true, timeout, [unsub]);
|
|
119
|
-
}
|
|
120
|
-
});
|
|
121
|
-
});
|
|
122
|
-
};
|
|
123
|
-
|
|
124
|
-
private _subscribe = (key: string) => {
|
|
125
|
-
return Promise.all([
|
|
126
|
-
this.fetcher(key, item => this._updateItem(key, item)),
|
|
127
|
-
]);
|
|
128
|
-
};
|
|
129
|
-
|
|
130
|
-
private _updateItem = action((key: string, item: T) => {
|
|
131
|
-
if (this._updater != null && item != null) {
|
|
132
|
-
const current = this._cache.getCurrent(key, false);
|
|
133
|
-
if (current != null) {
|
|
134
|
-
const result = this._updater(current, item);
|
|
135
|
-
// re-set existing item but with updated contents
|
|
136
|
-
this._cache.updateValueDirectly(key, result);
|
|
137
|
-
return;
|
|
138
|
-
}
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
this._cache.updateValueDirectly(key, item);
|
|
142
|
-
});
|
|
143
|
-
}
|
|
144
|
-
|
|
145
|
-
function getObserveTimeout(s: ObserveStrategy) {
|
|
146
|
-
if (!s) {
|
|
147
|
-
return undefined;
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
return typeof s === 'number'
|
|
151
|
-
? s
|
|
152
|
-
: (s === 'short'
|
|
153
|
-
? 5 * 60 * 1000
|
|
154
|
-
: null
|
|
155
|
-
);
|
|
156
|
-
}
|
|
157
|
-
|
|
158
|
-
function firstDefined<T>(...values: (T | undefined)[]) {
|
|
159
|
-
return values.find(v => v !== undefined);
|
|
160
|
-
}
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import { action, observable } from 'mobx';
|
|
2
|
-
import { IErrorsLocalization, ILocalizationDependency, ValidationErrorsFactory, ValidationErrorsStrings } from './abstractions';
|
|
3
|
-
|
|
4
|
-
export class LocalaziedValidationErrors<TStrings extends { }, TErrors extends string | number>
|
|
5
|
-
implements IErrorsLocalization<TErrors>, ILocalizationDependency<TStrings> {
|
|
6
|
-
|
|
7
|
-
@observable.ref
|
|
8
|
-
private _strings: ValidationErrorsStrings<TErrors> = null;
|
|
9
|
-
|
|
10
|
-
constructor(private readonly factory: ValidationErrorsFactory<TStrings, TErrors>) { }
|
|
11
|
-
|
|
12
|
-
public get Errors(): Partial<Record<TErrors, string>> { return this._strings; }
|
|
13
|
-
|
|
14
|
-
@action
|
|
15
|
-
public updateLocale(strings: TStrings): void {
|
|
16
|
-
this._strings = this.factory(strings);
|
|
17
|
-
}
|
|
18
|
-
}
|
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
import { observable, makeObservable, action } from 'mobx';
|
|
2
|
-
import { ILocalization, ILocalizationDependency } from './abstractions';
|
|
3
|
-
|
|
4
|
-
export class LocalizationManager<TLocaleType extends string, TStrings extends { }> implements ILocalization<TStrings> {
|
|
5
|
-
@observable
|
|
6
|
-
private _currentLocale: TLocaleType = null;
|
|
7
|
-
|
|
8
|
-
@observable.ref
|
|
9
|
-
private _currentStrings: TStrings = null;
|
|
10
|
-
|
|
11
|
-
private readonly _defaultStrings: TStrings = null;
|
|
12
|
-
private readonly _dependants: ILocalizationDependency<TStrings, TLocaleType>[] = [];
|
|
13
|
-
|
|
14
|
-
constructor(
|
|
15
|
-
private readonly _dataSource: { [locale: string]: TStrings },
|
|
16
|
-
initialLocale: TLocaleType,
|
|
17
|
-
defaultLocale: TLocaleType = null,
|
|
18
|
-
) {
|
|
19
|
-
makeObservable(this);
|
|
20
|
-
this._defaultStrings = this.getStrings(defaultLocale || initialLocale);
|
|
21
|
-
this.useLocale(initialLocale);
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
public get Locale() { return this._currentLocale; }
|
|
25
|
-
public get Current() { return this._currentStrings; }
|
|
26
|
-
|
|
27
|
-
@action
|
|
28
|
-
public useLocale(locale: TLocaleType) {
|
|
29
|
-
this._currentLocale = locale;
|
|
30
|
-
this._currentStrings = this.getStrings(this._currentLocale) || this._defaultStrings;
|
|
31
|
-
this.updateDependencies();
|
|
32
|
-
return this;
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
public useDependency(dep: ILocalizationDependency<TStrings, TLocaleType>, remove = false) {
|
|
36
|
-
const i = this._dependants.indexOf(dep);
|
|
37
|
-
if (i < 0 && !remove) {
|
|
38
|
-
this._dependants.push(dep);
|
|
39
|
-
this.updateDependencies();
|
|
40
|
-
} else if (i >= 0 && remove) {
|
|
41
|
-
this._dependants.splice(i, 1);
|
|
42
|
-
}
|
|
43
|
-
return this;
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
private updateDependencies() {
|
|
47
|
-
this._dependants.forEach(d => d.updateLocale(this._currentStrings, this._currentLocale));
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
private getStrings(locale: string): TStrings {
|
|
51
|
-
return this._dataSource[locale];
|
|
52
|
-
}
|
|
53
|
-
}
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
export interface ILocalization<TStrings extends { }> {
|
|
3
|
-
readonly Current: Readonly<TStrings>;
|
|
4
|
-
}
|
|
5
|
-
|
|
6
|
-
export interface IErrorsLocalization<TErrors extends string | number> {
|
|
7
|
-
readonly Errors: ValidationErrorsStrings<TErrors>
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
export interface ILocalizationDependency<TStrings extends { }, TLocale extends string = any> {
|
|
11
|
-
updateLocale(strings: TStrings, locale?: TLocale): void;
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
export type ValidationErrorsStrings<T extends string | number> = Partial<Record<T, string>>;
|
|
15
|
-
|
|
16
|
-
export type ValidationErrorsFactory<TStrings extends { }, TErrors extends string | number> = (strings: TStrings) => ValidationErrorsStrings<TErrors>;
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
export const Strings = {
|
|
2
|
-
Ok: 'OK',
|
|
3
|
-
Cancel: 'Cancel',
|
|
4
|
-
Submit: 'Submit',
|
|
5
|
-
ForgotPassword: 'Forgot password?',
|
|
6
|
-
Validation: {
|
|
7
|
-
Empty: 'Value should be not empty',
|
|
8
|
-
Name: 'Invalid name format',
|
|
9
|
-
Email: 'Incorrect email',
|
|
10
|
-
Password: 'Must include at least 8 characters',
|
|
11
|
-
EnglishOnly: 'Only English letters supported',
|
|
12
|
-
Phone: 'Invalid phone number format: only digits allowed',
|
|
13
|
-
CreditCard: 'Invalid credit card number format',
|
|
14
|
-
CreditCardExpiryDate: 'Invalid expiry date format',
|
|
15
|
-
CreditCardCvv: 'Invalid CVV format',
|
|
16
|
-
PasswordsShouldMatch: 'Passwords should match',
|
|
17
|
-
FirstName: 'First name is required',
|
|
18
|
-
LastName: 'Last name is required',
|
|
19
|
-
OnlyDigit: 'Only digits are valid',
|
|
20
|
-
Website: 'Incorrect website',
|
|
21
|
-
Linkedin: 'Incorrect Linkedin link',
|
|
22
|
-
},
|
|
23
|
-
UnknownServerError: 'Something went wrong and we were not able to process your request. Please contact the administrator.',
|
|
24
|
-
};
|
|
25
|
-
|
|
26
|
-
export type StringsShape = typeof Strings;
|
package/src/timeHelper.ts
DELETED
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
// eslint-disable-next-line no-console
|
|
3
|
-
console.warn('"timeHelper" module is deprecated. Please use "dates" one.');
|
|
4
|
-
|
|
5
|
-
/** @deprecated */
|
|
6
|
-
export function formatMS(ms: number): string {
|
|
7
|
-
if (!ms && ms !== 0) {
|
|
8
|
-
return '';
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
const sec = Math.floor((ms / 1000) % 60);
|
|
12
|
-
const min = Math.floor((ms / (1000 * 60)) % 60);
|
|
13
|
-
const hours = Math.floor((ms / (1000 * 60 * 60)) % 60);
|
|
14
|
-
|
|
15
|
-
return `${hours ? hours + ':' : ''}${min < 10 ? '0' + min : min}:${sec < 10 ? '0' + sec : sec}`;
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
/** @deprecated */
|
|
19
|
-
export function formatTime(n: number): string {
|
|
20
|
-
if (n < 10) {
|
|
21
|
-
return '0' + n;
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
return n.toString();
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
/** @deprecated */
|
|
28
|
-
export function secToFormattedMin(totalSec: number): string {
|
|
29
|
-
const sec = Math.round(totalSec) % 60;
|
|
30
|
-
const min = Math.floor((totalSec + 1) / 60);
|
|
31
|
-
let res = `${formatTime(min)}`;
|
|
32
|
-
|
|
33
|
-
if (sec) {
|
|
34
|
-
res += ':';
|
|
35
|
-
res += formatTime(Math.floor(sec));
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
return res;
|
|
39
|
-
}
|
|
@@ -1,183 +0,0 @@
|
|
|
1
|
-
import { reaction } from 'mobx';
|
|
2
|
-
import { IEvent, Event } from './event';
|
|
3
|
-
import { ILogger, createLogger } from './logger';
|
|
4
|
-
import { IDisposable } from './disposer';
|
|
5
|
-
|
|
6
|
-
export class TransitionObserver<T> implements IDisposable {
|
|
7
|
-
|
|
8
|
-
private readonly _event = new Event<T>();
|
|
9
|
-
private _getter: () => T = null;
|
|
10
|
-
|
|
11
|
-
private _disposer: () => void;
|
|
12
|
-
private _prev: T = undefined;
|
|
13
|
-
|
|
14
|
-
private _from: T = undefined;
|
|
15
|
-
private _to: T = undefined;
|
|
16
|
-
|
|
17
|
-
private _cb: (v: T) => any;
|
|
18
|
-
private _fireOnce = false;
|
|
19
|
-
|
|
20
|
-
private _promise: Promise<T> = null;
|
|
21
|
-
private _promiseReject: (err?: any) => any = null;
|
|
22
|
-
|
|
23
|
-
private logger: ILogger = createLogger('', false);
|
|
24
|
-
|
|
25
|
-
constructor(getter?: () => T) {
|
|
26
|
-
if (getter) {
|
|
27
|
-
this.observe(getter);
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
public get event(): IEvent<T> { return this._event; }
|
|
32
|
-
public get currentValue() { return this._prev; }
|
|
33
|
-
|
|
34
|
-
public get isObserving() { return this._disposer != null; }
|
|
35
|
-
private get isPromising() { return this._promiseReject != null; }
|
|
36
|
-
|
|
37
|
-
observe(getter: () => T) {
|
|
38
|
-
this.dispose();
|
|
39
|
-
this._getter = getter;
|
|
40
|
-
this._prev = this._getter();
|
|
41
|
-
this._disposer = reaction(this._getter, this._checkValue);
|
|
42
|
-
return this;
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
from(from: T) {
|
|
46
|
-
this._from = from;
|
|
47
|
-
return this;
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
to(to: T) {
|
|
51
|
-
this._to = to;
|
|
52
|
-
return this;
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
cb(cb: (v: T) => any) {
|
|
56
|
-
if (this.isPromising) {
|
|
57
|
-
throw new Error('Cannot set callback when promise is running');
|
|
58
|
-
}
|
|
59
|
-
this._cb = cb;
|
|
60
|
-
return this;
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
forceCall() {
|
|
64
|
-
if (this._cb) {
|
|
65
|
-
this._cb(this._prev);
|
|
66
|
-
}
|
|
67
|
-
return this;
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
fireOnce(enable = true) {
|
|
71
|
-
this._fireOnce = enable;
|
|
72
|
-
return this;
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
forceCheck() {
|
|
76
|
-
return this._checkValue(this._getter());
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
andForceCheck() {
|
|
80
|
-
this.forceCheck();
|
|
81
|
-
return this;
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
getPromise(timeout: number = null) {
|
|
85
|
-
if (!this._promise) {
|
|
86
|
-
if (!this.isObserving) {
|
|
87
|
-
return Promise.reject(new Error('Cannot get promise for disposed TransitionObserver'));
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
this._promise = new Promise<T>((resolve, reject) => {
|
|
91
|
-
this._promiseReject = reject;
|
|
92
|
-
|
|
93
|
-
let timeoutHandle: any = null;
|
|
94
|
-
if (timeout) {
|
|
95
|
-
timeoutHandle = setTimeout(() => {
|
|
96
|
-
this._finishPromise(this._promiseReject, new Error(`TransitionObserver Aborted – timed out after ${timeout}ms`));
|
|
97
|
-
}, timeout);
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
this._cb = (v => {
|
|
101
|
-
clearTimeout(timeoutHandle);
|
|
102
|
-
this._finishPromise(resolve, v);
|
|
103
|
-
});
|
|
104
|
-
this.forceCheck();
|
|
105
|
-
});
|
|
106
|
-
this.logger.log('started a new promise...');
|
|
107
|
-
}
|
|
108
|
-
return this._promise;
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
reverse() {
|
|
112
|
-
return new TransitionObserver<T>(this._getter)
|
|
113
|
-
.from(this._to)
|
|
114
|
-
.to(this._from);
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
enableLogging(name: string) {
|
|
118
|
-
this.logger = createLogger(name, name ? undefined : false);
|
|
119
|
-
return this;
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
dispose = () => {
|
|
123
|
-
this.logger.log(' disposing... ');
|
|
124
|
-
if (this._disposer) {
|
|
125
|
-
this._disposer();
|
|
126
|
-
this._disposer = null;
|
|
127
|
-
}
|
|
128
|
-
if (this.isPromising) {
|
|
129
|
-
this._finishPromise(this._promiseReject, new Error('TransitionObserver Aborted'));
|
|
130
|
-
}
|
|
131
|
-
};
|
|
132
|
-
|
|
133
|
-
private _checkValue = (v: T) => {
|
|
134
|
-
let trigger = false;
|
|
135
|
-
|
|
136
|
-
if (this._from !== undefined && this._to !== undefined) {
|
|
137
|
-
// both 'from' and 'two' should be matched
|
|
138
|
-
trigger = this._prev === this._from && v === this._to;
|
|
139
|
-
} else if (this._from !== undefined || this._to !== undefined) {
|
|
140
|
-
// at least one match – 'from' or 'to'
|
|
141
|
-
trigger = (this._from !== undefined && this._from === this._prev)
|
|
142
|
-
|| (this._to !== undefined && this._to === v);
|
|
143
|
-
} else {
|
|
144
|
-
// if both 'from' and 'to' are undefined – trigger for any change
|
|
145
|
-
// this._from === undefined && this._to === undefined;
|
|
146
|
-
trigger = true;
|
|
147
|
-
}
|
|
148
|
-
|
|
149
|
-
this.logger.log('Checked value:', v, ' ==> will trigger:', trigger);
|
|
150
|
-
|
|
151
|
-
this._prev = v;
|
|
152
|
-
|
|
153
|
-
if (trigger) {
|
|
154
|
-
this._event.trigger(v);
|
|
155
|
-
|
|
156
|
-
if (this._cb) {
|
|
157
|
-
this._cb(v);
|
|
158
|
-
}
|
|
159
|
-
|
|
160
|
-
if (this._fireOnce) {
|
|
161
|
-
this.dispose();
|
|
162
|
-
}
|
|
163
|
-
}
|
|
164
|
-
|
|
165
|
-
return trigger;
|
|
166
|
-
};
|
|
167
|
-
|
|
168
|
-
private _finishPromise<T>(cb: (a?: T) => any, arg?: T) {
|
|
169
|
-
this._promise = null;
|
|
170
|
-
this._promiseReject = null;
|
|
171
|
-
this._cb = null;
|
|
172
|
-
if (cb) {
|
|
173
|
-
cb(arg);
|
|
174
|
-
}
|
|
175
|
-
}
|
|
176
|
-
}
|
|
177
|
-
|
|
178
|
-
export function waitFor<T>(current: () => T, toBe: T) {
|
|
179
|
-
return new TransitionObserver(current)
|
|
180
|
-
.to(toBe)
|
|
181
|
-
.fireOnce()
|
|
182
|
-
.getPromise();
|
|
183
|
-
}
|
package/src/types.ts
DELETED
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
export { DeepPartial } from './deepPartial';
|
|
2
|
-
|
|
3
|
-
export type DeepReadonly<T> = {
|
|
4
|
-
readonly [P in keyof T]: DeepReadonly<T[P]>;
|
|
5
|
-
};
|
|
6
|
-
|
|
7
|
-
export type Getter<T> = (() => T) | T | null;
|
|
8
|
-
|
|
9
|
-
export namespace Getter {
|
|
10
|
-
export function getValue<T>(getter: Getter<T>): T {
|
|
11
|
-
if (getter == null) {
|
|
12
|
-
return undefined;
|
|
13
|
-
}
|
|
14
|
-
if (typeof getter === 'function') {
|
|
15
|
-
return (getter as () => T)();
|
|
16
|
-
}
|
|
17
|
-
return getter;
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
export type Predicate<T> = (value: T) => boolean;
|
|
22
|
-
export type Comparator<T, C = boolean> = (v1: T, v2: T) => C;
|
|
23
|
-
|
|
24
|
-
export namespace Comparator {
|
|
25
|
-
export const Default: Comparator<any> = (a, b) => a === b;
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
export type TypedKeys<T extends Object, K> = {
|
|
29
|
-
[P in keyof T]: T[P] extends K ? P : never
|
|
30
|
-
}[keyof T];
|
package/src/unsubscriber.ts
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
// DEPRECATED MODULE. Delete in future versions
|
|
3
|
-
|
|
4
|
-
import logger from './logger';
|
|
5
|
-
|
|
6
|
-
export {
|
|
7
|
-
IDisposable,
|
|
8
|
-
DisposeFunction as Disposer,
|
|
9
|
-
combineDisposers,
|
|
10
|
-
Disposer as Unsubscriber,
|
|
11
|
-
Disposable,
|
|
12
|
-
} from './disposer';
|
|
13
|
-
|
|
14
|
-
logger.warn('@zajno/common: importing module "unsusbcriber" is deprecated; please change your import to "disposer" module.');
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import { ValidationErrorsStrings } from '../services/localization';
|
|
2
|
-
import { StringsShape } from '../services/localization/defaultShape';
|
|
3
|
-
import { LocalaziedValidationErrors } from '../services/localization/LocalaziedValidationErrors';
|
|
4
|
-
import { ValidationErrors } from './ValidationErrors';
|
|
5
|
-
|
|
6
|
-
function locationFactory(strings: StringsShape): ValidationErrorsStrings<ValidationErrors> {
|
|
7
|
-
return {
|
|
8
|
-
[ValidationErrors.None]: '',
|
|
9
|
-
[ValidationErrors.ShouldBeNonEmpty]: strings.Validation.Empty,
|
|
10
|
-
[ValidationErrors.InvalidNameFormat]: strings.Validation.Name,
|
|
11
|
-
[ValidationErrors.InvalidEmailFormat]: strings.Validation.Email,
|
|
12
|
-
[ValidationErrors.InvalidPasswordFormat]: strings.Validation.Password,
|
|
13
|
-
[ValidationErrors.OnlyEnglishLetters]: strings.Validation.EnglishOnly,
|
|
14
|
-
[ValidationErrors.InvalidPhoneFormat]: strings.Validation.Phone,
|
|
15
|
-
[ValidationErrors.InvalidCreditCardFormat]: strings.Validation.CreditCard,
|
|
16
|
-
[ValidationErrors.InvalidCreditCardExpiryDateFormat]: strings.Validation.CreditCardExpiryDate,
|
|
17
|
-
[ValidationErrors.InvalidCreditCardCvvFormat]: strings.Validation.CreditCardCvv,
|
|
18
|
-
|
|
19
|
-
[ValidationErrors.FirstName]: strings.Validation.FirstName,
|
|
20
|
-
[ValidationErrors.LastName]: strings.Validation.LastName,
|
|
21
|
-
[ValidationErrors.OnlyDigit]: strings.Validation.OnlyDigit,
|
|
22
|
-
[ValidationErrors.Website]: strings.Validation.Website,
|
|
23
|
-
[ValidationErrors.Linkedin]: strings.Validation.Linkedin,
|
|
24
|
-
};
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
export const ValidationErrorsLocalized = new LocalaziedValidationErrors<StringsShape, ValidationErrors>(locationFactory);
|
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
import { action, makeObservable, observable } from 'mobx';
|
|
2
|
-
import { Getter } from '../types';
|
|
3
|
-
import { ValidatableModel } from './Validatable';
|
|
4
|
-
|
|
5
|
-
export class CommonModel<T = any> extends ValidatableModel<T> {
|
|
6
|
-
|
|
7
|
-
// observable[.ref]
|
|
8
|
-
private _value: T;
|
|
9
|
-
|
|
10
|
-
private _defaultValue: Getter<T> = null;
|
|
11
|
-
|
|
12
|
-
constructor(v: Getter<T> = null, useRefObservable = true) {
|
|
13
|
-
super();
|
|
14
|
-
this._value = Getter.getValue(v) || null;
|
|
15
|
-
this._defaultValue = v;
|
|
16
|
-
|
|
17
|
-
makeObservable<CommonModel<T>, '_value'>(this, {
|
|
18
|
-
_value: useRefObservable ? observable.ref : observable,
|
|
19
|
-
setValue: action,
|
|
20
|
-
});
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
protected get valueToValidate(): Readonly<T> {
|
|
24
|
-
return this._value;
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
public get value() { return this._value; }
|
|
28
|
-
public set value(v: T) {
|
|
29
|
-
this.setValue(v);
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
// action
|
|
33
|
-
public readonly setValue = (value: T) => {
|
|
34
|
-
this._value = value;
|
|
35
|
-
|
|
36
|
-
if (this._validateOnChange) {
|
|
37
|
-
this.validate();
|
|
38
|
-
}
|
|
39
|
-
};
|
|
40
|
-
|
|
41
|
-
reset = () => {
|
|
42
|
-
this._value = Getter.getValue(this._defaultValue);
|
|
43
|
-
super.reset();
|
|
44
|
-
};
|
|
45
|
-
}
|