@e1011/es-kit 1.0.96 → 1.0.100
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/dist/lib/cjs/src/core/utils/appState/store/store.vanillajs.js +1 -1
- package/dist/lib/cjs/src/core/utils/appState/store/store.vanillajs.js.map +1 -1
- package/dist/lib/cjs/src/core/utils/appState/store/useStore.react.js +1 -1
- package/dist/lib/cjs/src/core/utils/appState/store/useStore.react.js.map +1 -1
- package/dist/lib/esm/src/core/utils/appState/store/store.vanillajs.js +1 -1
- package/dist/lib/esm/src/core/utils/appState/store/store.vanillajs.js.map +1 -1
- package/dist/lib/esm/src/core/utils/appState/store/useStore.react.js +1 -1
- package/dist/lib/esm/src/core/utils/appState/store/useStore.react.js.map +1 -1
- package/dist/lib/src/core/ui/utils/styling.spec.js +24 -0
- package/dist/lib/src/core/ui/utils/styling.spec.js.map +1 -0
- package/dist/lib/src/core/utils/appState/store/store.vanillajs.js +5 -1
- package/dist/lib/src/core/utils/appState/store/store.vanillajs.js.map +1 -1
- package/dist/lib/src/core/utils/appState/store/store.vanillajs.spec.js +152 -0
- package/dist/lib/src/core/utils/appState/store/store.vanillajs.spec.js.map +1 -0
- package/dist/lib/src/core/utils/appState/store/store.vanillajs.templates.js +24 -0
- package/dist/lib/src/core/utils/appState/store/store.vanillajs.templates.js.map +1 -0
- package/dist/lib/src/core/utils/appState/store/store.vanillajs.templates.spec.js +36 -0
- package/dist/lib/src/core/utils/appState/store/store.vanillajs.templates.spec.js.map +1 -0
- package/dist/lib/src/core/utils/appState/store/useStore.react.js +1 -1
- package/dist/lib/src/core/utils/appState/store/useStore.react.js.map +1 -1
- package/dist/lib/src/core/utils/date.spec.js +97 -0
- package/dist/lib/src/core/utils/date.spec.js.map +1 -0
- package/dist/lib/src/core/utils/decorators/convert.spec.js +22 -0
- package/dist/lib/src/core/utils/decorators/convert.spec.js.map +1 -0
- package/dist/lib/src/core/utils/helpers/birthnumberCZSKvalidator.spec.js +53 -0
- package/dist/lib/src/core/utils/helpers/birthnumberCZSKvalidator.spec.js.map +1 -0
- package/dist/lib/src/core/utils/helpers/emailMatcher.spec.js +36 -0
- package/dist/lib/src/core/utils/helpers/emailMatcher.spec.js.map +1 -0
- package/dist/lib/src/core/utils/helpers/file.spec.js +23 -0
- package/dist/lib/src/core/utils/helpers/file.spec.js.map +1 -0
- package/dist/lib/src/core/utils/helpers/fileValidator.spec.js +103 -0
- package/dist/lib/src/core/utils/helpers/fileValidator.spec.js.map +1 -0
- package/dist/lib/src/core/utils/helpers/objectOperations.spec.js +75 -0
- package/dist/lib/src/core/utils/helpers/objectOperations.spec.js.map +1 -0
- package/dist/lib/src/core/utils/helpers/other.spec.js +49 -0
- package/dist/lib/src/core/utils/helpers/other.spec.js.map +1 -0
- package/dist/lib/src/core/utils/helpers/textValueOperations.spec.js +70 -0
- package/dist/lib/src/core/utils/helpers/textValueOperations.spec.js.map +1 -0
- package/dist/lib/src/core/utils/helpers/valueOperations.spec.js +18 -0
- package/dist/lib/src/core/utils/helpers/valueOperations.spec.js.map +1 -0
- package/dist/lib/src/core/utils/logger.spec.js +32 -0
- package/dist/lib/src/core/utils/logger.spec.js.map +1 -0
- package/dist/lib/src/core/utils/webComponents/webComponents.utils.spec.js +42 -0
- package/dist/lib/src/core/utils/webComponents/webComponents.utils.spec.js.map +1 -0
- package/dist/lib/tsconfig.tsbuildinfo +1 -1
- package/dist/types/src/core/ui/utils/styling.spec.d.ts +2 -0
- package/dist/types/src/core/ui/utils/styling.spec.d.ts.map +1 -0
- package/dist/types/src/core/utils/appState/store/store.vanillajs.d.ts +5 -4
- package/dist/types/src/core/utils/appState/store/store.vanillajs.d.ts.map +1 -1
- package/dist/types/src/core/utils/appState/store/store.vanillajs.spec.d.ts +2 -0
- package/dist/types/src/core/utils/appState/store/store.vanillajs.spec.d.ts.map +1 -0
- package/dist/types/src/core/utils/appState/store/store.vanillajs.templates.d.ts +15 -0
- package/dist/types/src/core/utils/appState/store/store.vanillajs.templates.d.ts.map +1 -0
- package/dist/types/src/core/utils/appState/store/store.vanillajs.templates.spec.d.ts +2 -0
- package/dist/types/src/core/utils/appState/store/store.vanillajs.templates.spec.d.ts.map +1 -0
- package/dist/types/src/core/utils/appState/store/useStore.react.d.ts +4 -4
- package/dist/types/src/core/utils/appState/store/useStore.react.d.ts.map +1 -1
- package/dist/types/src/core/utils/date.spec.d.ts +2 -0
- package/dist/types/src/core/utils/date.spec.d.ts.map +1 -0
- package/dist/types/src/core/utils/decorators/convert.spec.d.ts +2 -0
- package/dist/types/src/core/utils/decorators/convert.spec.d.ts.map +1 -0
- package/dist/types/src/core/utils/helpers/birthnumberCZSKvalidator.spec.d.ts +2 -0
- package/dist/types/src/core/utils/helpers/birthnumberCZSKvalidator.spec.d.ts.map +1 -0
- package/dist/types/src/core/utils/helpers/emailMatcher.spec.d.ts +2 -0
- package/dist/types/src/core/utils/helpers/emailMatcher.spec.d.ts.map +1 -0
- package/dist/types/src/core/utils/helpers/file.spec.d.ts +2 -0
- package/dist/types/src/core/utils/helpers/file.spec.d.ts.map +1 -0
- package/dist/types/src/core/utils/helpers/fileValidator.spec.d.ts +2 -0
- package/dist/types/src/core/utils/helpers/fileValidator.spec.d.ts.map +1 -0
- package/dist/types/src/core/utils/helpers/objectOperations.spec.d.ts +2 -0
- package/dist/types/src/core/utils/helpers/objectOperations.spec.d.ts.map +1 -0
- package/dist/types/src/core/utils/helpers/other.spec.d.ts +2 -0
- package/dist/types/src/core/utils/helpers/other.spec.d.ts.map +1 -0
- package/dist/types/src/core/utils/helpers/textValueOperations.spec.d.ts +2 -0
- package/dist/types/src/core/utils/helpers/textValueOperations.spec.d.ts.map +1 -0
- package/dist/types/src/core/utils/helpers/valueOperations.spec.d.ts +2 -0
- package/dist/types/src/core/utils/helpers/valueOperations.spec.d.ts.map +1 -0
- package/dist/types/src/core/utils/logger.spec.d.ts +21 -0
- package/dist/types/src/core/utils/logger.spec.d.ts.map +1 -0
- package/dist/types/src/core/utils/webComponents/webComponents.utils.spec.d.ts +5 -0
- package/dist/types/src/core/utils/webComponents/webComponents.utils.spec.d.ts.map +1 -0
- package/dist/utils/esm/src/core/utils/appState/store/store.vanillajs.js +1 -1
- package/dist/utils/esm/src/core/utils/appState/store/store.vanillajs.js.map +1 -1
- package/dist/utils/esm/src/core/utils/appState/store/useStore.react.js +1 -1
- package/dist/utils/esm/src/core/utils/appState/store/useStore.react.js.map +1 -1
- package/dist/utils/src/core/utils/appState/store/store.vanillajs.js +1 -1
- package/dist/utils/src/core/utils/appState/store/store.vanillajs.js.map +1 -1
- package/dist/utils/src/core/utils/appState/store/useStore.react.js +1 -1
- package/dist/utils/src/core/utils/appState/store/useStore.react.js.map +1 -1
- package/package.json +1 -1
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../../../../_virtual/_rollupPluginBabelHelpers.js");require("../../../../../node_modules/core-js/modules/es.array.iterator.js"),require("../../../../../node_modules/core-js/modules/es.object.to-string.js"),require("../../../../../node_modules/core-js/modules/es.set.constructor.js"),require("../../../../../node_modules/core-js/modules/es.string.iterator.js"),require("../../../../../node_modules/core-js/modules/web.dom-collections.iterator.js"),require("../../../../../node_modules/core-js/modules/es.object.entries.js"),require("../../../../../node_modules/core-js/modules/es.array.reduce.js"),require("../../../../../node_modules/core-js/modules/es.array.concat.js");exports.createStore=function(r,t){var o,n=r,s=new Set,u=function(){return n},a=function(){var r=e.asyncToGenerator(e.regeneratorRuntime().mark((function r(t){var o,u,a,c,i;return e.regeneratorRuntime().wrap((function(r){for(;;)switch(r.prev=r.next){case 0:n=t,o=e.createForOfIteratorHelper(s),r.prev=2,o.s();case 4:if((u=o.n()).done){r.next=14;break}if(a=u.value,c=null==a?void 0:a.selector,i=c?c(n):n,void 0!==a.previousValue&&a.previousValue===i){r.next=12;break}return a.previousValue=i,r.next=12,a(i);case 12:r.next=4;break;case 14:r.next=19;break;case 16:r.prev=16,r.t0=r.catch(2),o.e(r.t0);case 19:return r.prev=19,o.f(),r.finish(19);case 22:case"end":return r.stop()}}),r,null,[[2,16,19,22]])})));return function(e){return r.apply(this,arguments)}}(),c={getState:u,setState:a,subscribe:function(e){return s.add(e),function(){return s.delete(e)}}},i=t?null===(o=Object.entries(t))||void 0===o?void 0:o.reduce((function(r,t){var o=e.slicedToArray(t,2),n=o[0],s=o[1];return e.objectSpread2(e.objectSpread2({},r),{},e.defineProperty({},n,e.asyncToGenerator(e.regeneratorRuntime().mark((function r(){var t,o,n,c=arguments;return e.regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:for(t=c.length,o=new Array(t),n=0;n<t;n++)o[n]=c[n];return e.abrupt("return",s.apply(void 0,[u,a].concat(o)));case 2:case"end":return e.stop()}}),r)})))))}),{}):null
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../../../../_virtual/_rollupPluginBabelHelpers.js");require("../../../../../node_modules/core-js/modules/es.array.iterator.js"),require("../../../../../node_modules/core-js/modules/es.object.to-string.js"),require("../../../../../node_modules/core-js/modules/es.set.constructor.js"),require("../../../../../node_modules/core-js/modules/es.string.iterator.js"),require("../../../../../node_modules/core-js/modules/web.dom-collections.iterator.js"),require("../../../../../node_modules/core-js/modules/es.object.entries.js"),require("../../../../../node_modules/core-js/modules/es.array.reduce.js"),require("../../../../../node_modules/core-js/modules/es.array.concat.js");exports.createStore=function(r,t){var o,n=r,s=new Set,u=function(){return n},a=function(){var r=e.asyncToGenerator(e.regeneratorRuntime().mark((function r(t){var o,u,a,c,i;return e.regeneratorRuntime().wrap((function(r){for(;;)switch(r.prev=r.next){case 0:n=t,o=e.createForOfIteratorHelper(s),r.prev=2,o.s();case 4:if((u=o.n()).done){r.next=14;break}if(a=u.value,c=null==a?void 0:a.selector,i=c?c(n):n,void 0!==a.previousValue&&a.previousValue===i){r.next=12;break}return a.previousValue=i,r.next=12,a(i);case 12:r.next=4;break;case 14:r.next=19;break;case 16:r.prev=16,r.t0=r.catch(2),o.e(r.t0);case 19:return r.prev=19,o.f(),r.finish(19);case 22:return r.abrupt("return",n);case 23:case"end":return r.stop()}}),r,null,[[2,16,19,22]])})));return function(e){return r.apply(this,arguments)}}(),c={getState:u,setState:a,subscribe:function(e){return s.add(e),function(){return s.delete(e)}}},i=t?null===(o=Object.entries(t))||void 0===o?void 0:o.reduce((function(r,t){var o=e.slicedToArray(t,2),n=o[0],s=o[1];return e.objectSpread2(e.objectSpread2({},r),{},e.defineProperty({},n,e.asyncToGenerator(e.regeneratorRuntime().mark((function r(){var t,o,n,c=arguments;return e.regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:for(t=c.length,o=new Array(t),n=0;n<t;n++)o[n]=c[n];return e.abrupt("return",s.apply(void 0,[u,a].concat(o)));case 2:case"end":return e.stop()}}),r)})))))}),{}):null,d=e.objectSpread2(e.objectSpread2({},c),i?{actions:e.objectSpread2({},i)}:{});return d};
|
|
2
2
|
//# sourceMappingURL=store.vanillajs.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"store.vanillajs.js","sources":["../../../../../../../../src/core/utils/appState/store/store.vanillajs.ts"],"sourcesContent":["\n// TinyStore, inspired by https://github.com/jherr/syncexternalstore/blob/main/csr/src/store.js\nexport type ListenerCallBack<T> = (state: Partial<T>) => void\n\nexport type Selector<T> = (state: Partial<T>) => Partial<T>;\n\nexport type Listener<T> = {\n selector?: Selector<T>\n previousValue?: Partial<T>\n} & ListenerCallBack<T>\n\nexport type Store<T> = {\n getState: () => Partial<T>\n setState: (state: Partial<T>) =>
|
|
1
|
+
{"version":3,"file":"store.vanillajs.js","sources":["../../../../../../../../src/core/utils/appState/store/store.vanillajs.ts"],"sourcesContent":["\n// TinyStore, inspired by https://github.com/jherr/syncexternalstore/blob/main/csr/src/store.js\nexport type ListenerCallBack<T> = (state: Partial<T>) => void\n\nexport type Selector<T> = (state: Partial<T>) => Partial<T>;\n\nexport type Listener<T> = {\n selector?: Selector<T>\n previousValue?: Partial<T>\n} & ListenerCallBack<T>\n\nexport type Store<T> = {\n getState: () => Partial<T>\n setState: (state: Partial<T>) => Promise<Partial<T>>\n subscribe: (listener: Listener<T>) => () => void\n}\n// & { actions?: { [actionName: string]: ActionHandlerCaller } }\n\nexport type StoreWithActions<T> = Store<T> & { actions: { [actionName: string]: ActionHandlerCaller } }\n\n\nexport type ActionHandler<T> = (\n getState: Store<T>['getState'],\n setState: Store<T>['setState'],\n ...rest: unknown[]\n) => void | Partial<T> | Promise<void | Partial<T>>\n\n\nexport type ActionHandlerCaller = (...args: unknown[]) => void\n\n\nexport const createStore = <T>(\n initialState: Partial<T>,\n actions?: Record<string, ActionHandler<T>>,\n): Store<T> | StoreWithActions<T> => {\n let currentState: Partial<T> = initialState\n const listeners = new Set<Listener<T>>()\n\n const getState = () => currentState\n\n // TODO debounce, batch? what is the meaningful time between setState ofr UI to be rendered and registerd by User?\n const setState = async (newState: Partial<T>) => {\n currentState = newState\n\n // eslint-disable-next-line no-restricted-syntax\n for (const listener of listeners) {\n // has Listener selector?\n const selector: Selector<T> | undefined = listener?.selector\n\n // TODO compare selected value to the previous values of that listener/selector pair\n // if listener.previousValue === selector(currentState) no call\n // else listener.previousValue = selector(currentState) and call\n // l1 cache, weak references?\n const newValue: Partial<T> = selector ? selector(currentState) : currentState\n\n // TODO plugin equality\n if (listener.previousValue === undefined || listener.previousValue !== newValue) {\n listener.previousValue = newValue\n // eslint-disable-next-line no-await-in-loop\n await listener(newValue)\n }\n }\n return currentState\n }\n\n const storeBaseicApi: Store<T> = {\n getState,\n setState,\n subscribe: (listener: Listener<T>) => {\n listeners.add(listener)\n return () => listeners.delete(listener)\n },\n }\n\n\n const resolvedActions: Record<string, ActionHandlerCaller> | null | undefined\n = actions ? Object.entries(actions)?.reduce(\n (\n aggregator: Record<string, ActionHandlerCaller>,\n [actionName, actionHandler]: [string, ActionHandler<T>],\n ) => ({\n ...aggregator,\n [actionName]: async(...rest: unknown[]) => actionHandler(getState, setState, ...rest),\n }),\n {},\n ) : null\n\n const storeCombinedWithActions = {\n ...storeBaseicApi,\n ...(resolvedActions ? { actions: { ...resolvedActions } } : {}),\n }\n\n return resolvedActions\n ? storeCombinedWithActions as StoreWithActions<T>\n : storeCombinedWithActions as Store<T>\n}\n"],"names":["initialState","actions","_Object$entries","currentState","listeners","Set","getState","setState","_ref","_asyncToGenerator","_regeneratorRuntime","regeneratorRuntime","mark","_callee","newState","_iterator","_step","_listener","selector","newValue","wrap","_context","prev","next","_createForOfIteratorHelper","s","n","done","listener","value","undefined","previousValue","t0","e","f","finish","abrupt","stop","_x","apply","this","arguments","storeBaseicApi","subscribe","add","delete","resolvedActions","Object","entries","reduce","aggregator","_ref2","_ref3","_slicedToArray","actionName","actionHandler","_objectSpread","objectSpread2","_defineProperty","_callee2","_len","rest","_key","_args2","_context2","length","Array","concat","storeCombinedWithActions"],"mappings":"ywBA+B2B,SACzBA,EACAC,GACmC,IAAAC,EAC/BC,EAA2BH,EACzBI,EAAY,IAAIC,IAEhBC,EAAW,WAAH,OAASH,CAAY,EAG7BI,EAAQ,WAAA,IAAAC,EAAAC,EAAAA,iBAAAC,EAAAC,qBAAAC,MAAG,SAAAC,EAAOC,GAAoB,IAAAC,EAAAC,EAAAC,EAAAC,EAAAC,EAAA,OAAAT,EAAAC,qBAAAS,MAAA,SAAAC,GAAA,cAAAA,EAAAC,KAAAD,EAAAE,MAAA,KAAA,EAC1CpB,EAAeW,EAEfC,EAAAS,EAAAA,0BACuBpB,GAASiB,EAAAC,KAAA,EAAAP,EAAAU,IAAA,KAAA,EAAA,IAAAT,EAAAD,EAAAW,KAAAC,KAAA,CAAAN,EAAAE,KAAA,GAAA,KAAA,CAU9B,GAVSK,EAAQZ,EAAAa,MAEXX,EAAoCU,eAAAA,EAAUV,SAM9CC,EAAuBD,EAAWA,EAASf,GAAgBA,OAGlC2B,IAA3BF,EAASG,eAA+BH,EAASG,gBAAkBZ,EAAQ,CAAAE,EAAA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N,GAAAE,EAAA,EAAAA,EAAAF,EAAAE,IAAJD,EAAIC,GAAAC,EAAAD,GAAA,OAAAE,EAAA5B,OAAA,SAAgBmB,EAAahB,WAACjC,EAAAA,CAAAA,EAAUC,GAAQ4D,OAAKN,KAAK,KAAA,EAAA,IAAA,MAAA,OAAAG,EAAA3B,OAAA,GAAAsB,EAAA,MAAA,GAEvF,CAAA,GACE,KAEAS,EAAwBZ,EAAAA,cAAAA,EAAAA,cACzBd,CAAAA,EAAAA,GACCI,EAAkB,CAAE7C,QAAOuD,EAAAA,cAAA,CAAA,EAAOV,IAAsB,CAAE,GAGhE,OACIsB,CAEN"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var t=require("react"),e=function(e){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:function(t){return t};return[t.useSyncExternalStore(e.subscribe,(function(){return r(e.getState())})),e.setState,e.actions]};exports.useStore=e,exports.useStoreApi=function(t){return[e(t,arguments.length>1&&void 0!==arguments[1]?arguments[1]:function(t){return t}),t.getState,t.setState,
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var t=require("react"),e=function(e){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:function(t){return t};return[t.useSyncExternalStore(e.subscribe,(function(){return r(e.getState())})),e.setState,e.actions]};exports.useStore=e,exports.useStoreApi=function(t){return[e(t,arguments.length>1&&void 0!==arguments[1]?arguments[1]:function(t){return t}),t.getState,t.setState,t.actions]};
|
|
2
2
|
//# sourceMappingURL=useStore.react.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useStore.react.js","sources":["../../../../../../../../src/core/utils/appState/store/useStore.react.ts"],"sourcesContent":["import { useSyncExternalStore } from 'react'\n\nimport type { Store, Selector } from './store.vanillajs'\n\n\nexport type useStoreType<T> = [\n Partial<T>,\n Store<T>['setState'],\n
|
|
1
|
+
{"version":3,"file":"useStore.react.js","sources":["../../../../../../../../src/core/utils/appState/store/useStore.react.ts"],"sourcesContent":["import { useSyncExternalStore } from 'react'\n\nimport type { Store, StoreWithActions, Selector } from './store.vanillajs'\n\n\nexport type useStoreType<T> = [\n Partial<T>,\n Store<T>['setState'],\n StoreWithActions<T>['actions'],\n]\n\n\nexport const useStore = <T>(\n store: Store<T> | StoreWithActions<T>,\n selector: Selector<T> = (state: Partial<T>) => state,\n // TODO pass selector\n // useSyncExternalStore((...args) => {\n // args[0].selector?? store.subscribe(...args) }, () => selector(store.getState()));\n): useStoreType<T> => [\n useSyncExternalStore(store.subscribe, () => selector(store.getState())),\n store.setState,\n (store as StoreWithActions<T>).actions,\n ]\n\n\nexport type useStoreApiType<T> = [\n ReturnType<typeof useStore>,\n Store<T>['getState'],\n Store<T>['setState'],\n StoreWithActions<T>['actions'],\n]\n\n\nexport const useStoreApi = <T>(\n store: Store<T>,\n selector: Selector<T> = (state: Partial<T>) => state,\n): useStoreApiType<T> => ([\n useStore(store, selector),\n store.getState,\n store.setState,\n (store as StoreWithActions<T>).actions,\n ])\n"],"names":["useStore","store","selector","arguments","length","undefined","state","useSyncExternalStore","subscribe","getState","setState","actions"],"mappings":"2FAYaA,EAAW,SACtBC,GAAqC,IACrCC,EAAqBC,UAAAC,OAAA,QAAAC,IAAAF,UAAA,GAAAA,UAAA,GAAG,SAACG,GAAiB,OAAKA,CAAK,EAAA,MAIhC,CAClBC,EAAoBA,qBAACN,EAAMO,WAAW,WAAA,OAAMN,EAASD,EAAMQ,WAAY,IACvER,EAAMS,SACLT,EAA8BU,QAChC,yCAWwB,SACzBV,GACoD,MAC5B,CACtBD,EAASC,EAFUE,UAAAC,OAAA,QAAAC,IAAAF,UAAA,GAAAA,UAAA,GAAG,SAACG,GAAiB,OAAKA,CAAK,GAGlDL,EAAMQ,SACNR,EAAMS,SACLT,EAA8BU,QAChC"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{slicedToArray as e,objectSpread2 as r,defineProperty as
|
|
1
|
+
import{slicedToArray as e,objectSpread2 as r,defineProperty as t,asyncToGenerator as o,regeneratorRuntime as s,createForOfIteratorHelper as n}from"../../../../../_virtual/_rollupPluginBabelHelpers.js";import"../../../../../node_modules/core-js/modules/es.array.iterator.js";import"../../../../../node_modules/core-js/modules/es.object.to-string.js";import"../../../../../node_modules/core-js/modules/es.set.constructor.js";import"../../../../../node_modules/core-js/modules/es.string.iterator.js";import"../../../../../node_modules/core-js/modules/web.dom-collections.iterator.js";import"../../../../../node_modules/core-js/modules/es.object.entries.js";import"../../../../../node_modules/core-js/modules/es.array.reduce.js";import"../../../../../node_modules/core-js/modules/es.array.concat.js";var a=function(a,u){var c,i=a,l=new Set,d=function(){return i},p=function(){var e=o(s().mark((function e(r){var t,o,a,u,c;return s().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:i=r,t=n(l),e.prev=2,t.s();case 4:if((o=t.n()).done){e.next=14;break}if(a=o.value,u=null==a?void 0:a.selector,c=u?u(i):i,void 0!==a.previousValue&&a.previousValue===c){e.next=12;break}return a.previousValue=c,e.next=12,a(c);case 12:e.next=4;break;case 14:e.next=19;break;case 16:e.prev=16,e.t0=e.catch(2),t.e(e.t0);case 19:return e.prev=19,t.f(),e.finish(19);case 22:return e.abrupt("return",i);case 23:case"end":return e.stop()}}),e,null,[[2,16,19,22]])})));return function(r){return e.apply(this,arguments)}}(),m={getState:d,setState:p,subscribe:function(e){return l.add(e),function(){return l.delete(e)}}},f=u?null===(c=Object.entries(u))||void 0===c?void 0:c.reduce((function(n,a){var u=e(a,2),c=u[0],i=u[1];return r(r({},n),{},t({},c,o(s().mark((function e(){var r,t,o,n=arguments;return s().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:for(r=n.length,t=new Array(r),o=0;o<r;o++)t[o]=n[o];return e.abrupt("return",i.apply(void 0,[d,p].concat(t)));case 2:case"end":return e.stop()}}),e)})))))}),{}):null,j=r(r({},m),f?{actions:r({},f)}:{});return j};export{a as createStore};
|
|
2
2
|
//# sourceMappingURL=store.vanillajs.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"store.vanillajs.js","sources":["../../../../../../../../src/core/utils/appState/store/store.vanillajs.ts"],"sourcesContent":["\n// TinyStore, inspired by https://github.com/jherr/syncexternalstore/blob/main/csr/src/store.js\nexport type ListenerCallBack<T> = (state: Partial<T>) => void\n\nexport type Selector<T> = (state: Partial<T>) => Partial<T>;\n\nexport type Listener<T> = {\n selector?: Selector<T>\n previousValue?: Partial<T>\n} & ListenerCallBack<T>\n\nexport type Store<T> = {\n getState: () => Partial<T>\n setState: (state: Partial<T>) =>
|
|
1
|
+
{"version":3,"file":"store.vanillajs.js","sources":["../../../../../../../../src/core/utils/appState/store/store.vanillajs.ts"],"sourcesContent":["\n// TinyStore, inspired by https://github.com/jherr/syncexternalstore/blob/main/csr/src/store.js\nexport type ListenerCallBack<T> = (state: Partial<T>) => void\n\nexport type Selector<T> = (state: Partial<T>) => Partial<T>;\n\nexport type Listener<T> = {\n selector?: Selector<T>\n previousValue?: Partial<T>\n} & ListenerCallBack<T>\n\nexport type Store<T> = {\n getState: () => Partial<T>\n setState: (state: Partial<T>) => Promise<Partial<T>>\n subscribe: (listener: Listener<T>) => () => void\n}\n// & { actions?: { [actionName: string]: ActionHandlerCaller } }\n\nexport type StoreWithActions<T> = Store<T> & { actions: { [actionName: string]: ActionHandlerCaller } }\n\n\nexport type ActionHandler<T> = (\n getState: Store<T>['getState'],\n setState: Store<T>['setState'],\n ...rest: unknown[]\n) => void | Partial<T> | Promise<void | Partial<T>>\n\n\nexport type ActionHandlerCaller = (...args: unknown[]) => void\n\n\nexport const createStore = <T>(\n initialState: Partial<T>,\n actions?: Record<string, ActionHandler<T>>,\n): Store<T> | StoreWithActions<T> => {\n let currentState: Partial<T> = initialState\n const listeners = new Set<Listener<T>>()\n\n const getState = () => currentState\n\n // TODO debounce, batch? what is the meaningful time between setState ofr UI to be rendered and registerd by User?\n const setState = async (newState: Partial<T>) => {\n currentState = newState\n\n // eslint-disable-next-line no-restricted-syntax\n for (const listener of listeners) {\n // has Listener selector?\n const selector: Selector<T> | undefined = listener?.selector\n\n // TODO compare selected value to the previous values of that listener/selector pair\n // if listener.previousValue === selector(currentState) no call\n // else listener.previousValue = selector(currentState) and call\n // l1 cache, weak references?\n const newValue: Partial<T> = selector ? selector(currentState) : currentState\n\n // TODO plugin equality\n if (listener.previousValue === undefined || listener.previousValue !== newValue) {\n listener.previousValue = newValue\n // eslint-disable-next-line no-await-in-loop\n await listener(newValue)\n }\n }\n return currentState\n }\n\n const storeBaseicApi: Store<T> = {\n getState,\n setState,\n subscribe: (listener: Listener<T>) => {\n listeners.add(listener)\n return () => listeners.delete(listener)\n },\n }\n\n\n const resolvedActions: Record<string, ActionHandlerCaller> | null | undefined\n = actions ? Object.entries(actions)?.reduce(\n (\n aggregator: Record<string, ActionHandlerCaller>,\n [actionName, actionHandler]: [string, ActionHandler<T>],\n ) => ({\n ...aggregator,\n [actionName]: async(...rest: unknown[]) => actionHandler(getState, setState, ...rest),\n }),\n {},\n ) : null\n\n const storeCombinedWithActions = {\n ...storeBaseicApi,\n ...(resolvedActions ? { actions: { ...resolvedActions } } : {}),\n }\n\n return resolvedActions\n ? storeCombinedWithActions as StoreWithActions<T>\n : storeCombinedWithActions as Store<T>\n}\n"],"names":["createStore","initialState","actions","_Object$entries","currentState","listeners","Set","getState","setState","_ref","_asyncToGenerator","_regeneratorRuntime","mark","_callee","newState","_iterator","_step","_listener","selector","newValue","wrap","_context","prev","next","_createForOfIteratorHelper","s","n","done","listener","value","undefined","previousValue","t0","e","f","finish","abrupt","stop","_x","apply","this","arguments","storeBaseicApi","subscribe","add","delete","resolvedActions","Object","entries","reduce","aggregator","_ref2","_ref3","_slicedToArray","actionName","actionHandler","_objectSpread","_defineProperty","_callee2","_len","rest","_key","_args2","_context2","length","Array","concat","storeCombinedWithActions"],"mappings":"4xBA+BO,IAAMA,EAAc,SACzBC,EACAC,GACmC,IAAAC,EAC/BC,EAA2B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B,GACP,WAAA,OAAMvB,EAAUwC,OAAOjB,EAAS,CACzC,GAIIkB,EACF5C,EAAiCC,QAA1BA,EAAG4C,OAAOC,QAAQ9C,cAAQC,SAAvBA,EAAyB8C,QACnC,SACEC,EAA+CC,GAAA,IAAAC,EAAAC,EAAAF,EAAA,GAC9CG,EAAUF,EAAA,GAAEG,EAAaH,EAAA,GAAA,OAAAI,EAAAA,EAEvBN,CAAAA,EAAAA,MAAUO,EAAA,CAAA,EACZH,EAAU5C,EAAAC,IAAAC,MAAG,SAAA8C,IAAA,IAAAC,EAAAC,EAAAC,EAAAC,EAAArB,UAAA,OAAA9B,IAAAS,MAAA,SAAA2C,GAAA,cAAAA,EAAAzC,KAAAyC,EAAAxC,MAAA,KAAA,EAAA,IAAAoC,EAAAG,EAAAE,OAASJ,EAAIK,IAAAA,MAAAN,GAAAE,EAAA,EAAAA,EAAAF,EAAAE,IAAJD,EAAIC,GAAAC,EAAAD,GAAA,OAAAE,EAAA3B,OAAA,SAAgBmB,EAAahB,WAAChC,EAAAA,CAAAA,EAAUC,GAAQ0D,OAAKN,KAAK,KAAA,EAAA,IAAA,MAAA,OAAAG,EAAA1B,OAAA,GAAAqB,EAAA,MAAA,GAEvF,CAAA,GACE,KAEAS,EAAwBX,EAAAA,EACzBd,CAAAA,EAAAA,GACCI,EAAkB,CAAE5C,QAAOsD,EAAA,CAAA,EAAOV,IAAsB,CAAE,GAGhE,OACIqB,CAEN"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{useSyncExternalStore as t}from"react";var n=function(n){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:function(t){return t};return[t(n.subscribe,(function(){return e(n.getState())})),n.setState,n.actions]},e=function(t){return[n(t,arguments.length>1&&void 0!==arguments[1]?arguments[1]:function(t){return t}),t.getState,t.setState,
|
|
1
|
+
import{useSyncExternalStore as t}from"react";var n=function(n){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:function(t){return t};return[t(n.subscribe,(function(){return e(n.getState())})),n.setState,n.actions]},e=function(t){return[n(t,arguments.length>1&&void 0!==arguments[1]?arguments[1]:function(t){return t}),t.getState,t.setState,t.actions]};export{n as useStore,e as useStoreApi};
|
|
2
2
|
//# sourceMappingURL=useStore.react.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useStore.react.js","sources":["../../../../../../../../src/core/utils/appState/store/useStore.react.ts"],"sourcesContent":["import { useSyncExternalStore } from 'react'\n\nimport type { Store, Selector } from './store.vanillajs'\n\n\nexport type useStoreType<T> = [\n Partial<T>,\n Store<T>['setState'],\n
|
|
1
|
+
{"version":3,"file":"useStore.react.js","sources":["../../../../../../../../src/core/utils/appState/store/useStore.react.ts"],"sourcesContent":["import { useSyncExternalStore } from 'react'\n\nimport type { Store, StoreWithActions, Selector } from './store.vanillajs'\n\n\nexport type useStoreType<T> = [\n Partial<T>,\n Store<T>['setState'],\n StoreWithActions<T>['actions'],\n]\n\n\nexport const useStore = <T>(\n store: Store<T> | StoreWithActions<T>,\n selector: Selector<T> = (state: Partial<T>) => state,\n // TODO pass selector\n // useSyncExternalStore((...args) => {\n // args[0].selector?? store.subscribe(...args) }, () => selector(store.getState()));\n): useStoreType<T> => [\n useSyncExternalStore(store.subscribe, () => selector(store.getState())),\n store.setState,\n (store as StoreWithActions<T>).actions,\n ]\n\n\nexport type useStoreApiType<T> = [\n ReturnType<typeof useStore>,\n Store<T>['getState'],\n Store<T>['setState'],\n StoreWithActions<T>['actions'],\n]\n\n\nexport const useStoreApi = <T>(\n store: Store<T>,\n selector: Selector<T> = (state: Partial<T>) => state,\n): useStoreApiType<T> => ([\n useStore(store, selector),\n store.getState,\n store.setState,\n (store as StoreWithActions<T>).actions,\n ])\n"],"names":["useStore","store","selector","arguments","length","undefined","state","useSyncExternalStore","subscribe","getState","setState","actions","useStoreApi"],"mappings":"iDAYaA,EAAW,SACtBC,GAAqC,IACrCC,EAAqBC,UAAAC,OAAA,QAAAC,IAAAF,UAAA,GAAAA,UAAA,GAAG,SAACG,GAAiB,OAAKA,CAAK,EAAA,MAIhC,CAClBC,EAAqBN,EAAMO,WAAW,WAAA,OAAMN,EAASD,EAAMQ,WAAY,IACvER,EAAMS,SACLT,EAA8BU,QAChC,EAWUC,EAAc,SACzBX,GACoD,MAC5B,CACtBD,EAASC,EAFUE,UAAAC,OAAA,QAAAC,IAAAF,UAAA,GAAAA,UAAA,GAAG,SAACG,GAAiB,OAAKA,CAAK,GAGlDL,EAAMQ,SACNR,EAAMS,SACLT,EAA8BU,QAChC"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { delay } from '../../utils/helpers';
|
|
2
|
+
import { pxToRem, defaultFontSize, convertHex, convertRGB } from './style';
|
|
3
|
+
describe('styling utils', () => {
|
|
4
|
+
it(`pxToRem to convert pixels to rem (${defaultFontSize})`, async () => {
|
|
5
|
+
expect.assertions(1);
|
|
6
|
+
await delay(1000);
|
|
7
|
+
expect(pxToRem(200)).toEqual(200 / defaultFontSize);
|
|
8
|
+
});
|
|
9
|
+
it('should convert hex to rgb', () => {
|
|
10
|
+
const hex = convertHex('#FFFFFF', 0.5);
|
|
11
|
+
expect(hex).toEqual('#FFFFFF80'.toLowerCase());
|
|
12
|
+
const hex2 = convertHex('#FFFFFF', 100);
|
|
13
|
+
expect(hex2).toEqual('#FFFFFFFF'.toLowerCase());
|
|
14
|
+
const hex3 = convertHex('#FFFFFF', 100, true);
|
|
15
|
+
expect(hex3).toEqual('rgba(255,255,255,1)'.toLowerCase());
|
|
16
|
+
});
|
|
17
|
+
it('should convert rgb to hex', () => {
|
|
18
|
+
const hex = convertRGB(255, 255, 255, 0.5);
|
|
19
|
+
expect(hex).toEqual('#FFFFFF80'.toLowerCase());
|
|
20
|
+
const hex2 = convertRGB(255, 255, 255, 1);
|
|
21
|
+
expect(hex2).toEqual('#FFFFFFFF'.toLowerCase());
|
|
22
|
+
});
|
|
23
|
+
});
|
|
24
|
+
//# sourceMappingURL=styling.spec.js.map
|
|
@@ -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,CAAA;QAE1C,MAAM,CAAC,GAAG,CAAC,CAAC,OAAO,CAAC,WAAW,CAAC,WAAW,EAAE,CAAC,CAAA;QAE9C,MAAM,IAAI,GAAG,UAAU,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,CAAC,CAAC,CAAA;QAEzC,MAAM,CAAC,IAAI,CAAC,CAAC,OAAO,CAAC,WAAW,CAAC,WAAW,EAAE,CAAC,CAAA;IACjD,CAAC,CAAC,CAAA;AACJ,CAAC,CAAC,CAAA"}
|
|
@@ -2,6 +2,7 @@ export const createStore = (initialState, actions) => {
|
|
|
2
2
|
let currentState = initialState;
|
|
3
3
|
const listeners = new Set();
|
|
4
4
|
const getState = () => currentState;
|
|
5
|
+
// TODO debounce, batch? what is the meaningful time between setState ofr UI to be rendered and registerd by User?
|
|
5
6
|
const setState = async (newState) => {
|
|
6
7
|
currentState = newState;
|
|
7
8
|
// eslint-disable-next-line no-restricted-syntax
|
|
@@ -20,6 +21,7 @@ export const createStore = (initialState, actions) => {
|
|
|
20
21
|
await listener(newValue);
|
|
21
22
|
}
|
|
22
23
|
}
|
|
24
|
+
return currentState;
|
|
23
25
|
};
|
|
24
26
|
const storeBaseicApi = {
|
|
25
27
|
getState,
|
|
@@ -37,6 +39,8 @@ export const createStore = (initialState, actions) => {
|
|
|
37
39
|
...storeBaseicApi,
|
|
38
40
|
...(resolvedActions ? { actions: { ...resolvedActions } } : {}),
|
|
39
41
|
};
|
|
40
|
-
return
|
|
42
|
+
return resolvedActions
|
|
43
|
+
? storeCombinedWithActions
|
|
44
|
+
: storeCombinedWithActions;
|
|
41
45
|
};
|
|
42
46
|
//# sourceMappingURL=store.vanillajs.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"store.vanillajs.js","sourceRoot":"","sources":["../../../../../../../src/core/utils/appState/store/store.vanillajs.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"store.vanillajs.js","sourceRoot":"","sources":["../../../../../../../src/core/ut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AC,EAAE,MAAM,CACzC,CACE,UAA+C,EAC/C,CAAC,UAAU,EAAE,aAAa,CAA6B,EACvD,EAAE,CAAC,CAAC;QACJ,GAAG,UAAU;QACb,CAAC,UAAU,CAAC,EAAE,KAAK,EAAC,GAAG,IAAe,EAAE,EAAE,CAAC,aAAa,CAAC,QAAQ,EAAE,QAAQ,EAAE,GAAG,IAAI,CAAC;KACtF,CAAC,EACF,EAAE,CACH,CAAC,CAAC,CAAC,IAAI,CAAA;IAEV,MAAM,wBAAwB,GAAG;QAC/B,GAAG,cAAc;QACjB,GAAG,CAAC,eAAe,CAAC,CAAC,CAAC,EAAE,OAAO,EAAE,EAAE,GAAG,eAAe,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;KAChE,CAAA;IAED,OAAO,eAAe;QACpB,CAAC,CAAC,wBAA+C;QACjD,CAAC,CAAC,wBAAoC,CAAA;AAC1C,CAAC,CAAA"}
|
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
import { delay } from '../../helpers/other';
|
|
2
|
+
import { createStore } from './store.vanillajs';
|
|
3
|
+
describe('Simple Tiny Store', () => {
|
|
4
|
+
let initialState;
|
|
5
|
+
beforeEach(() => {
|
|
6
|
+
initialState = {
|
|
7
|
+
data: [1, 2, 3],
|
|
8
|
+
date: new Date(),
|
|
9
|
+
messages: [
|
|
10
|
+
'message 1',
|
|
11
|
+
'message 2',
|
|
12
|
+
'message 3',
|
|
13
|
+
],
|
|
14
|
+
};
|
|
15
|
+
});
|
|
16
|
+
it('should have state', () => {
|
|
17
|
+
const store = createStore(initialState);
|
|
18
|
+
console.log('store', store);
|
|
19
|
+
console.log('store.getState()', store.getState());
|
|
20
|
+
expect(store).toBeDefined();
|
|
21
|
+
expect(store.getState()).toEqual(initialState);
|
|
22
|
+
});
|
|
23
|
+
it('should call subscribers', () => {
|
|
24
|
+
const store = createStore(initialState);
|
|
25
|
+
console.log('store', store);
|
|
26
|
+
// const subscriber = (state: Partial<CommentsState>) => console.log('state subscriber, state:', state);
|
|
27
|
+
const subscriber = jest.fn((state) => console.log('state subscriber, state:', state));
|
|
28
|
+
const unsubscribe = store.subscribe(subscriber);
|
|
29
|
+
store.setState({
|
|
30
|
+
...initialState,
|
|
31
|
+
messages: ['Only one message'],
|
|
32
|
+
});
|
|
33
|
+
expect(subscriber).toHaveBeenCalled();
|
|
34
|
+
expect(subscriber).toHaveBeenCalledTimes(1);
|
|
35
|
+
unsubscribe();
|
|
36
|
+
store.setState({
|
|
37
|
+
...initialState,
|
|
38
|
+
messages: ['Only one message after unsibscribed'],
|
|
39
|
+
});
|
|
40
|
+
expect(subscriber).toHaveBeenCalledTimes(1);
|
|
41
|
+
});
|
|
42
|
+
it('should call and await async subscribers', async () => {
|
|
43
|
+
expect.assertions(3);
|
|
44
|
+
const store = createStore(initialState);
|
|
45
|
+
console.log('store', store);
|
|
46
|
+
const subscriberCallback = async (state) => {
|
|
47
|
+
await delay(1000);
|
|
48
|
+
console.log('awaited state subscriber, state:', state);
|
|
49
|
+
};
|
|
50
|
+
const subscriber = jest.fn(subscriberCallback);
|
|
51
|
+
const unsubscribe = store.subscribe(subscriber);
|
|
52
|
+
await store.setState({
|
|
53
|
+
...initialState,
|
|
54
|
+
messages: ['Only one message'],
|
|
55
|
+
});
|
|
56
|
+
expect(subscriber).toHaveBeenCalled();
|
|
57
|
+
expect(subscriber).toHaveBeenCalledTimes(1);
|
|
58
|
+
unsubscribe();
|
|
59
|
+
store.setState({
|
|
60
|
+
...initialState,
|
|
61
|
+
messages: ['Only one message after unsibscribed'],
|
|
62
|
+
});
|
|
63
|
+
expect(subscriber).toHaveBeenCalledTimes(1);
|
|
64
|
+
});
|
|
65
|
+
it('should call subscribers with selected part of state', () => {
|
|
66
|
+
const store = createStore(initialState);
|
|
67
|
+
console.log('store', store);
|
|
68
|
+
const subscriberCallback = (state) => console.log('state subscriber, state:', state);
|
|
69
|
+
// normall use outside of test, mocking
|
|
70
|
+
// subscriberCallback.selector = ((state: Partial<CommentsState>) => ({ messages: state.messages }));
|
|
71
|
+
const subscriber = jest.fn(subscriberCallback);
|
|
72
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
73
|
+
// @ts-ignore
|
|
74
|
+
subscriber.selector = ((state) => ({ messages: state.messages }));
|
|
75
|
+
const unsubscribe = store.subscribe(subscriber);
|
|
76
|
+
store.setState({
|
|
77
|
+
...initialState,
|
|
78
|
+
messages: ['Only one message'],
|
|
79
|
+
});
|
|
80
|
+
expect(subscriber).toHaveBeenCalled();
|
|
81
|
+
expect(subscriber).toHaveBeenCalledWith({ messages: ['Only one message'] });
|
|
82
|
+
unsubscribe();
|
|
83
|
+
store.setState({
|
|
84
|
+
...initialState,
|
|
85
|
+
messages: ['Only one message after unsibscribed'],
|
|
86
|
+
});
|
|
87
|
+
expect(subscriber).toHaveBeenCalledTimes(1);
|
|
88
|
+
});
|
|
89
|
+
it('actions for fast state handling, and should call subscribers', async () => {
|
|
90
|
+
const store = createStore(initialState, {
|
|
91
|
+
addPriority: async (getState, setState) => {
|
|
92
|
+
await delay(300);
|
|
93
|
+
setState({
|
|
94
|
+
...getState(),
|
|
95
|
+
priority: 3,
|
|
96
|
+
});
|
|
97
|
+
},
|
|
98
|
+
});
|
|
99
|
+
console.log('store', store);
|
|
100
|
+
// const subscriber = (state: Partial<CommentsState>) => console.log('state subscriber, state:', state);
|
|
101
|
+
const subscriber = jest.fn((state) => console.log('state subscriber, state:', state));
|
|
102
|
+
const unsubscribe = store.subscribe(subscriber);
|
|
103
|
+
store.setState({
|
|
104
|
+
...initialState,
|
|
105
|
+
messages: ['Only one message'],
|
|
106
|
+
});
|
|
107
|
+
// async function needs to be awaited or expect in queued micro task
|
|
108
|
+
await store.actions?.addPriority?.();
|
|
109
|
+
// store.actions?.addPriority?.()
|
|
110
|
+
queueMicrotask(() => {
|
|
111
|
+
expect(subscriber).toHaveBeenCalled();
|
|
112
|
+
expect(subscriber).toHaveBeenCalledTimes(2);
|
|
113
|
+
unsubscribe();
|
|
114
|
+
store.setState({
|
|
115
|
+
...initialState,
|
|
116
|
+
messages: ['Only one message after unsibscribed'],
|
|
117
|
+
});
|
|
118
|
+
expect(subscriber).toHaveBeenCalledTimes(2);
|
|
119
|
+
});
|
|
120
|
+
});
|
|
121
|
+
it('subscriber called only for value different then previous call of setState:listener', async () => {
|
|
122
|
+
expect.assertions(2);
|
|
123
|
+
const store = createStore(initialState, {
|
|
124
|
+
addPriority: async (getState, setState, ...args) => {
|
|
125
|
+
await delay(250);
|
|
126
|
+
setState({
|
|
127
|
+
...getState(),
|
|
128
|
+
priority: args[0],
|
|
129
|
+
});
|
|
130
|
+
},
|
|
131
|
+
});
|
|
132
|
+
console.log('store', store);
|
|
133
|
+
const subscriber = jest.fn((state) => console.log('state subscriber, state:', state));
|
|
134
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
135
|
+
// @ts-ignore
|
|
136
|
+
subscriber.selector = (state) => state?.priority;
|
|
137
|
+
store.subscribe(subscriber);
|
|
138
|
+
// async function needs to be awaited or expect in queued micro task
|
|
139
|
+
await store.actions?.addPriority?.(3);
|
|
140
|
+
await store.actions?.addPriority?.(3);
|
|
141
|
+
await store.actions?.addPriority?.(4);
|
|
142
|
+
await store.actions?.addPriority?.(4);
|
|
143
|
+
await store.actions?.addPriority?.(5);
|
|
144
|
+
await store.actions?.addPriority?.(5);
|
|
145
|
+
await store.actions?.addPriority?.(4);
|
|
146
|
+
queueMicrotask(() => {
|
|
147
|
+
expect(subscriber).toHaveBeenCalled();
|
|
148
|
+
expect(subscriber).toHaveBeenCalledTimes(4);
|
|
149
|
+
});
|
|
150
|
+
});
|
|
151
|
+
});
|
|
152
|
+
//# sourceMappingURL=store.vanillajs.spec.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"store.vanillajs.spec.js","sourceRoot":"","sources":["../../../../../../../src/core/utils/appState/store/store.vanillajs.spec.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAA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E,CAAC,CAAC,CAAC,CAAA;QACrC,MAAM,KAAK,CAAC,OAAO,EAAE,WAAW,EAAE,CAAC,CAAC,CAAC,CAAA;QAErC,cAAc,CAAC,GAAG,EAAE;YAClB,MAAM,CAAC,UAAU,CAAC,CAAC,gBAAgB,EAAE,CAAA;YACrC,MAAM,CAAC,UAAU,CAAC,CAAC,qBAAqB,CAAC,CAAC,CAAC,CAAA;QAC7C,CAAC,CAAC,CAAA;IACJ,CAAC,CAAC,CAAA;AACJ,CAAC,CAAC,CAAA"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { createStore } from './store.vanillajs';
|
|
2
|
+
export const createDataStore = (dataId) => {
|
|
3
|
+
const actions = {
|
|
4
|
+
load: async (getState, setState, dataPromise) => {
|
|
5
|
+
const re = {};
|
|
6
|
+
setState({ isLoading: true });
|
|
7
|
+
try {
|
|
8
|
+
const response = await dataPromise;
|
|
9
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
10
|
+
// @ts-ignore
|
|
11
|
+
re.data = response?.data || response;
|
|
12
|
+
}
|
|
13
|
+
catch (error) {
|
|
14
|
+
re.error = error;
|
|
15
|
+
}
|
|
16
|
+
return setState({ ...re, isLoading: false });
|
|
17
|
+
},
|
|
18
|
+
};
|
|
19
|
+
return (createStore({
|
|
20
|
+
dataId,
|
|
21
|
+
isLoading: false,
|
|
22
|
+
}, actions));
|
|
23
|
+
};
|
|
24
|
+
//# sourceMappingURL=store.vanillajs.templates.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"store.vanillajs.templates.js","sourceRoot":"","sources":["../../../../../../../src/core/utils/appState/store/store.vanillajs.templates.ts"],"names":[],"mappings":"AAAA,OAAO,EAA2B,WAAW,EAAE,MAAM,mBAAmB,CAAA;AAwBxE,MAAM,CAAC,MAAM,eAAe,GAAG,CAAI,MAAc,EACT,EAAE;IACxC,MAAM,OAAO,GAAsB;QACjC,IAAI,EAAE,KAAK,EACT,QAAyC,EACzC,QAAyC,EACzC,WAAuC,EACvC,EAAE;YACF,MAAM,EAAE,GAA0B,EAAE,CAAA;YAEpC,QAAQ,CAAC,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAA;YAE7B,IAAI;gBACF,MAAM,QAAQ,GAAY,MAAM,WAAW,CAAA;gBAE3C,6DAA6D;gBAC7D,aAAa;gBACb,EAAE,CAAC,IAAI,GAAG,QAAQ,EAAE,IAAI,IAAI,QAAQ,CAAA;aACrC;YAAC,OAAO,KAAK,EAAE;gBACd,EAAE,CAAC,KAAK,GAAG,KAAK,CAAA;aACjB;YACD,OAAO,QAAQ,CAAC,EAAE,GAAG,EAAE,EAAE,SAAS,EAAE,KAAK,EAAE,CAAC,CAAA;QAC9C,CAAC;KACF,CAAA;IAED,OAAO,CAAC,WAAW,CAAe;QAChC,MAAM;QACN,SAAS,EAAE,KAAK;KACjB,EAAE,OAAO,CAAC,CAC4B,CAAA;AACzC,CAAC,CAAA"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
// import { delay } from '../../helpers/other'
|
|
2
|
+
import { delay } from '../../helpers/other';
|
|
3
|
+
import { createDataStore } from './store.vanillajs.templates';
|
|
4
|
+
describe('Simple Tiny Store', () => {
|
|
5
|
+
it('should have state', () => {
|
|
6
|
+
const store = createDataStore('postsData1');
|
|
7
|
+
console.log('store', store);
|
|
8
|
+
console.log('store.getState()', store.getState());
|
|
9
|
+
const Listener = (state) => console.log('PostData1 store listener', state);
|
|
10
|
+
store.subscribe(Listener);
|
|
11
|
+
expect(store).toBeDefined();
|
|
12
|
+
expect(store.getState().dataId).toEqual('postsData1');
|
|
13
|
+
expect(store.getState().isLoading).toEqual(false);
|
|
14
|
+
});
|
|
15
|
+
it('should load data into state', async () => {
|
|
16
|
+
const store = createDataStore('postsData1');
|
|
17
|
+
console.log('store', store);
|
|
18
|
+
console.log('store.getState()', store.getState());
|
|
19
|
+
const Listener = (state) => console.log('PostData1 store listener', state);
|
|
20
|
+
store.subscribe(Listener);
|
|
21
|
+
expect(store).toBeDefined();
|
|
22
|
+
expect(store.getState().dataId).toEqual('postsData1');
|
|
23
|
+
expect(store.getState().isLoading).toEqual(false);
|
|
24
|
+
const loadPromise = store.actions.load((async () => {
|
|
25
|
+
await delay(1000);
|
|
26
|
+
return fetch('https://jsonplaceholder.typicode.com/posts').then((res) => res.json());
|
|
27
|
+
})());
|
|
28
|
+
expect(store.getState().isLoading).toEqual(true);
|
|
29
|
+
const what = await loadPromise;
|
|
30
|
+
console.log('what ', what);
|
|
31
|
+
const data = store.getState().data;
|
|
32
|
+
expect(data).toBeDefined();
|
|
33
|
+
expect(data?.[0]?.body).toBeDefined();
|
|
34
|
+
});
|
|
35
|
+
});
|
|
36
|
+
//# sourceMappingURL=store.vanillajs.templates.spec.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"store.vanillajs.templates.spec.js","sourceRoot":"","sources":["../../../../../../../src/core/utils/appState/store/store.vanillajs.templates.spec.ts"],"names":[],"mappings":"AAAA,8CAA8C;AAE9C,OAAO,EAAE,KAAK,EAAE,MAAM,qBAAqB,CAAA;AAG3C,OAAO,EAAa,eAAe,EAAE,MAAM,6BAA6B,CAAA;AAaxE,QAAQ,CAAC,mBAAmB,EAAE,GAAG,EAAE;IACjC,EAAE,CAAC,mBAAmB,EAAE,GAAG,EAAE;QAC3B,MAAM,KAAK,GAAG,eAAe,CAAY,YAAY,CAAC,CAAA;QAEtD,OAAO,CAAC,GAAG,CAAC,OAAO,EAAE,KAAK,CAAC,CAAA;QAC3B,OAAO,CAAC,GAAG,CAAC,kBAAkB,EAAE,KAAK,CAAC,QAAQ,EAAE,CAAC,CAAA;QAEjD,MAAM,QAAQ,GACV,CAAC,KAA8B,EAAE,EAAE,CAAC,OAAO,CAAC,GAAG,CAAC,0BAA0B,EAAE,KAAK,CAAC,CAAA;QAEtF,KAAK,CAAC,SAAS,CAAC,QAAQ,CAAC,CAAA;QAEzB,MAAM,CAAC,KAAK,C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AAQ,EAAE,CAAC,SAAS,CAAC,CAAC,OAAO,CAAC,IAAI,CAAC,CAAA;QAEhD,MAAM,IAAI,GAAG,MAAM,WAAW,CAAA;QAE9B,OAAO,CAAC,GAAG,CAAC,OAAO,EAAE,IAAI,CAAC,CAAA;QAG1B,MAAM,IAAI,GAAG,KAAK,CAAC,QAAQ,EAAE,CAAC,IAAc,CAAA;QAE5C,MAAM,CAAC,IAAI,CAAC,CAAC,WAAW,EAAE,CAAA;QAC1B,MAAM,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,EAAE,IAAI,CAAC,CAAC,WAAW,EAAE,CAAA;IACvC,CAAC,CAAC,CAAA;AACJ,CAAC,CAAC,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useStore.react.js","sourceRoot":"","sources":["../../../../../../../src/core/utils/appState/store/useStore.react.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,OAAO,CAAA;AAY5C,MAAM,CAAC,MAAM,QAAQ,GAAG,CACtB,
|
|
1
|
+
{"version":3,"file":"useStore.react.js","sourceRoot":"","sources":["../../../../../../../src/core/utils/appState/store/useStore.react.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,OAAO,CAAA;AAY5C,MAAM,CAAC,MAAM,QAAQ,GAAG,CACtB,KAAqC,EACrC,WAAwB,CAAC,KAAiB,EAAE,EAAE,CAAC,KAAK,EAInC,EAAE,CAAC;IAClB,oBAAoB,CAAC,KAAK,CAAC,SAAS,EAAE,GAAG,EAAE,CAAC,QAAQ,CAAC,KAAK,CAAC,QAAQ,EAAE,CAAC,CAAC;IACvE,KAAK,CAAC,QAAQ;IACb,KAA6B,CAAC,OAAO;CACvC,CAAA;AAWH,MAAM,CAAC,MAAM,WAAW,GAAG,CACzB,KAAe,EACf,WAAwB,CAAC,KAAiB,EAAE,EAAE,CAAC,KAAK,EAChC,EAAE,CAAC,CAAC;IACtB,QAAQ,CAAC,KAAK,EAAE,QAAQ,CAAC;IACzB,KAAK,CAAC,QAAQ;IACd,KAAK,CAAC,QAAQ;IACb,KAA6B,CAAC,OAAO;CACvC,CAAC,CAAA"}
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
import dayjs from 'dayjs';
|
|
2
|
+
import { getDateTime, getTimeFromNow, getTimeTo, dateRangeFormat } from './date';
|
|
3
|
+
describe('getDateTime', () => {
|
|
4
|
+
it('should format date/time', () => {
|
|
5
|
+
let dateString;
|
|
6
|
+
dateString = getDateTime({ value: '01/20/2019', valueFormat: 'MM/DD/YYYY', formatString: 'DD/MM/YYYY' });
|
|
7
|
+
console.log(dateString);
|
|
8
|
+
expect(dateString).toEqual('20/01/2019');
|
|
9
|
+
dateString = getDateTime({ value: '20/20/2019', valueFormat: 'DD.MM.YYYY', formatString: 'DD.MM.YYYY' });
|
|
10
|
+
console.log(dateString);
|
|
11
|
+
expect(dateString).toEqual('20.08.2020');
|
|
12
|
+
dateString = getDateTime({ value: '12:12 12/05/1988', valueFormat: 'hh:mm DD.MM.YYYY', formatString: 'DD.MM.YYYY' });
|
|
13
|
+
console.log(dateString);
|
|
14
|
+
expect(dateString).toEqual('12.05.1988');
|
|
15
|
+
dateString = getDateTime({
|
|
16
|
+
value: '12:12 12/05/1988', valueFormat: 'hh:mm DD.MM.YYYY', formatString: 'hh-mm DD/MM/YYYY'
|
|
17
|
+
});
|
|
18
|
+
console.log(dateString);
|
|
19
|
+
expect(dateString).toEqual('12-12 12/05/1988');
|
|
20
|
+
const today = new Date();
|
|
21
|
+
dateString = getDateTime({ value: today, formatString: 'HH-mm DD.MM.YYYY' });
|
|
22
|
+
console.log('dateString', dateString);
|
|
23
|
+
const hours = String(today.getHours()).padStart(2, '0');
|
|
24
|
+
const minutes = String(today.getMinutes()).padStart(2, '0');
|
|
25
|
+
const date = String(today.getDate()).padStart(2, '0');
|
|
26
|
+
const month = String(today.getMonth() + 1).padStart(2, '0');
|
|
27
|
+
const year = today.getFullYear();
|
|
28
|
+
const expectedFormattedDate = `${hours}-${minutes} ${date}.${month}.${year}`;
|
|
29
|
+
console.log('expectedFormattedDate');
|
|
30
|
+
console.log(expectedFormattedDate);
|
|
31
|
+
expect(dateString).toEqual(expectedFormattedDate);
|
|
32
|
+
});
|
|
33
|
+
it('should format date/time from now', () => {
|
|
34
|
+
let dateString = getTimeFromNow(new Date(Date.now() - 60 * 1000), { language: 'cz' });
|
|
35
|
+
console.log(dateString);
|
|
36
|
+
expect(dateString).toEqual('nyní');
|
|
37
|
+
dateString = getTimeFromNow(new Date(Date.now() - 60 * 60 * 1000), { language: 'cz' });
|
|
38
|
+
console.log(dateString);
|
|
39
|
+
expect(dateString).toEqual('1 hodinu');
|
|
40
|
+
dateString = getTimeFromNow(new Date(Date.now() - 12 * 60 * 60 * 1000), { language: 'cz' });
|
|
41
|
+
console.log(dateString);
|
|
42
|
+
expect(dateString).toEqual('12 hodiny');
|
|
43
|
+
dateString = getTimeFromNow(new Date(Date.now() - 24 * 60 * 60 * 1000), { language: 'cz' });
|
|
44
|
+
console.log(dateString);
|
|
45
|
+
expect(dateString).toEqual('den');
|
|
46
|
+
dateString = getTimeFromNow(new Date(Date.now() - 2 * 24 * 60 * 60 * 1000), { language: 'cz' });
|
|
47
|
+
console.log(dateString);
|
|
48
|
+
expect(dateString).toEqual('2 dny');
|
|
49
|
+
});
|
|
50
|
+
it('should format date/time to now', () => {
|
|
51
|
+
let dateString;
|
|
52
|
+
dateString = getTimeTo(new Date(Date.now() + 60 * 1000), { language: 'cz' });
|
|
53
|
+
console.log(dateString);
|
|
54
|
+
expect(dateString).toEqual('nyní');
|
|
55
|
+
dateString = getTimeTo(new Date(Date.now() + 60 * 60 * 1000), { showPreffix: true, language: 'cz' });
|
|
56
|
+
console.log(dateString);
|
|
57
|
+
expect(dateString).toEqual('za 1 hodinu');
|
|
58
|
+
dateString = getTimeTo(new Date(Date.now() + 12 * 60 * 60 * 1000), { showPreffix: true, language: 'cz' });
|
|
59
|
+
console.log(dateString);
|
|
60
|
+
expect(dateString).toEqual('za 12 hodiny');
|
|
61
|
+
dateString = getTimeTo(new Date(Date.now() + 24 * 60 * 60 * 1000), { showPreffix: true, language: 'cz' });
|
|
62
|
+
console.log(dateString);
|
|
63
|
+
expect(dateString).toEqual('za den');
|
|
64
|
+
dateString = getTimeTo(new Date(Date.now() + 2 * 24 * 60 * 60 * 1000), { showPreffix: true, language: 'cz' });
|
|
65
|
+
console.log(dateString);
|
|
66
|
+
expect(dateString).toEqual('za 2 dny');
|
|
67
|
+
let when = dayjs('1:36', 'HH:mm').add(1, 'day').toDate();
|
|
68
|
+
dateString = getTimeTo(when);
|
|
69
|
+
let dateString2 = getTimeTo('1:36', { valueFormat: 'HH:mm', shouldAddDay: true });
|
|
70
|
+
console.log('when', when);
|
|
71
|
+
console.log('dateString', dateString);
|
|
72
|
+
console.log('dateString2', dateString2);
|
|
73
|
+
expect(dateString).toEqual(dateString2);
|
|
74
|
+
when = dayjs('14:36', 'HH:mm').add(1, 'day').toDate();
|
|
75
|
+
dateString = getTimeTo(when);
|
|
76
|
+
dateString2 = getTimeTo('14:36', { valueFormat: 'HH:mm', shouldAddDay: true });
|
|
77
|
+
console.log('when', when);
|
|
78
|
+
console.log('dateString', dateString);
|
|
79
|
+
console.log('dateString2', dateString2);
|
|
80
|
+
expect(dateString).toEqual(dateString2);
|
|
81
|
+
});
|
|
82
|
+
});
|
|
83
|
+
describe('formatting date range', () => {
|
|
84
|
+
it('should format date range', () => {
|
|
85
|
+
const dateFrom = new Date(2014, 10, 26);
|
|
86
|
+
const dateTo = new Date(2014, 10, 28);
|
|
87
|
+
const dateRangeFormatted = dateRangeFormat(dateFrom, dateTo, 'D', 'D MMM YYYY');
|
|
88
|
+
expect(dateRangeFormatted).toEqual('26 - 28 Nov 2014');
|
|
89
|
+
});
|
|
90
|
+
it('should format date range', () => {
|
|
91
|
+
const dateFrom = new Date(2014, 10, 26);
|
|
92
|
+
const dateTo = new Date(2018, 10, 28);
|
|
93
|
+
const dateRangeFormatted = dateRangeFormat(dateFrom, dateTo, 'D', 'D MMM YYYY');
|
|
94
|
+
expect(dateRangeFormatted).toEqual('26 Nov 2014 - 28 Nov 2018');
|
|
95
|
+
});
|
|
96
|
+
});
|
|
97
|
+
//# sourceMappingURL=date.spec.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"date.spec.js","sourceRoot":"","sources":["../../../../../src/core/utils/date.spec.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAA;AAEzB,OAAO,EAAE,WAAW,EAAE,cAAc,EAAE,SAAS,EAAE,eAAe,EAAE,MAAM,QAAQ,CAAA;AAEhF,QAAQ,CAAC,aAAa,EAAE,GAAG,EAAE;IAC3B,EAAE,CAAC,yBAAyB,EAAE,GAAG,EAAE;QACjC,IAAI,UAAU,CAAA;QAEd,UAAU,GAAG,WAAW,CAAC,EAAE,KAAK,EAAE,YAAY,EAAE,WAAW,EAAE,YAAY,EAAE,YAAY,EAAE,YAAY,EAAE,CAAC,CAAA;QACxG,OAAO,CAAC,GAAG,CAAC,UAAU,CAAC,CAAA;QACvB,MAAM,CAAC,UAAU,CAAC,CAAC,OAAO,CAAC,YAAY,CAAC,CAAA;QAExC,UAAU,GAAG,WAAW,CAAC,EAAE,KAAK,EAAE,YAAY,EAAE,WAAW,EAAE,YAAY,EAAE,YAAY,EAAE,YAAY,EAAE,CAAC,CAAA;QACxG,OAAO,CAAC,GAAG,CAAC,UAAU,CAAC,CAAA;QACvB,MAAM,CAAC,UAAU,CAAC,CAAC,OAAO,CAAC,YAAY,CAAC,CAAA;QAExC,UAAU,GAAG,WAAW,CAAC,EAAE,KAAK,EAAE,kBAAkB,EAAE,WAAW,EAAE,kBAAkB,EAAE,YAAY,EAAE,YAAY,EAAE,CAAC,CAAA;QACpH,OAAO,CAAC,GAAG,CAAC,UAAU,CAAC,CAAA;QACvB,MAAM,CAAC,UAAU,CAAC,CAAC,OAAO,CAAC,YAA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AE,EAAE,CAAC,CAAA;QAErC,MAAM,kBAAkB,GAAG,eAAe,CAAC,QAAQ,EAAE,MAAM,EAAE,GAAG,EAAE,YAAY,CAAC,CAAA;QAE/E,MAAM,CAAC,kBAAkB,CAAC,CAAC,OAAO,CAAC,2BAA2B,CAAC,CAAA;IACjE,CAAC,CAAC,CAAA;AACJ,CAAC,CAAC,CAAA"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { delay } from '../helpers';
|
|
2
|
+
import { Model } from './convert';
|
|
3
|
+
describe('timing decorator', () => {
|
|
4
|
+
const model = new Model();
|
|
5
|
+
it('timing decorator basic', async () => {
|
|
6
|
+
expect.assertions(1);
|
|
7
|
+
await delay(1000);
|
|
8
|
+
const validation = model.validate({ name: 'dataToValidate' });
|
|
9
|
+
console.log('validation');
|
|
10
|
+
console.log(validation);
|
|
11
|
+
expect(validation).toBeFalsy();
|
|
12
|
+
});
|
|
13
|
+
it('timing decorator basic2', async () => {
|
|
14
|
+
expect.assertions(1);
|
|
15
|
+
await delay(1000);
|
|
16
|
+
const msgResult = model.message('Jest spies tests');
|
|
17
|
+
console.log('msgResult');
|
|
18
|
+
console.log(msgResult);
|
|
19
|
+
expect(msgResult).toEqual('Jest spies tests');
|
|
20
|
+
});
|
|
21
|
+
});
|
|
22
|
+
//# sourceMappingURL=convert.spec.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"convert.spec.js","sourceRoot":"","sources":["../../../../../../src/core/utils/decorators/convert.spec.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAA;AAElC,OAAO,EAAE,KAAK,EAAE,MAAM,WAAW,CAAA;AAEjC,QAAQ,CAAC,kBAAkB,EAAE,GAAG,EAAE;IAChC,MAAM,KAAK,GAAG,IAAI,KAAK,EAAE,CAAA;IAEzB,EAAE,CAAC,wBAAwB,EAAE,KAAK,IAAI,EAAE;QACtC,MAAM,CAAC,UAAU,CAAC,CAAC,CAAC,CAAA;QACpB,MAAM,KAAK,CAAC,IAAI,CAAC,CAAA;QACjB,MAAM,UAAU,GAAG,KAAK,CAAC,QAAQ,CAAC,EAAE,IAAI,EAAE,gBAAgB,EAAE,CAAC,CAAA;QAE7D,OAAO,CAAC,GAAG,CAAC,YAAY,CAAC,CAAA;QACzB,OAAO,CAAC,GAAG,CAAC,UAAU,CAAC,CAAA;QACvB,MAAM,CAAC,UAAU,CAAC,CAAC,SAAS,EAAE,CAAA;IAChC,CAAC,CAAC,CAAA;IAEF,EAAE,CAAC,yBAAyB,EAAE,KAAK,IAAI,EAAE;QACvC,MAAM,CAAC,UAAU,CAAC,CAAC,CAAC,CAAA;QACpB,MAAM,KAAK,CAAC,IAAI,CAAC,CAAA;QACjB,MAAM,SAAS,GAAG,KAAK,CAAC,OAAO,CAAC,kBAAkB,CAAC,CAAA;QAEnD,OAAO,CAAC,GAAG,CAAC,WAAW,CAAC,CAAA;QACxB,OAAO,CAAC,GAAG,CAAC,SAAS,CAAC,CAAA;QACtB,MAAM,CAAC,SAAS,CAAC,CAAC,OAAO,CAAC,kBAAkB,CAAC,CAAA;IAC/C,CAAC,CAAC,CAAA;AACJ,CAAC,CAAC,CAAA"}
|