@e1011/es-kit 1.1.48 → 1.1.50
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/hooks/esm/index.css +159 -159
- package/dist/hooks/index.css +159 -159
- package/dist/lib/cjs/src/core/utils/appState/peregrineMQ/index.js.map +1 -1
- package/dist/lib/cjs/src/core/utils/appState/peregrineMQ/peregrineMQ.js +1 -1
- package/dist/lib/cjs/src/core/utils/appState/peregrineMQ/peregrineMQ.js.map +1 -1
- package/dist/lib/cjs/src/core/utils/appState/peregrineMQ/peregrineMQ.types.js +2 -0
- package/dist/lib/cjs/src/core/utils/appState/peregrineMQ/peregrineMQ.types.js.map +1 -0
- package/dist/lib/cjs/src/core/utils/appState/peregrineMQ/usePeregrineMQ.react.js.map +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/store.vanillajs.templates.js.map +1 -1
- package/dist/lib/cjs/src/index.js +1 -1
- package/dist/lib/esm/src/core/utils/appState/peregrineMQ/index.js.map +1 -1
- package/dist/lib/esm/src/core/utils/appState/peregrineMQ/peregrineMQ.js +1 -1
- package/dist/lib/esm/src/core/utils/appState/peregrineMQ/peregrineMQ.js.map +1 -1
- package/dist/lib/esm/src/core/utils/appState/peregrineMQ/peregrineMQ.types.js +2 -0
- package/dist/lib/esm/src/core/utils/appState/peregrineMQ/peregrineMQ.types.js.map +1 -0
- package/dist/lib/esm/src/core/utils/appState/peregrineMQ/usePeregrineMQ.react.js.map +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/store.vanillajs.templates.js.map +1 -1
- package/dist/lib/esm/src/index.js +1 -1
- package/dist/lib/tsconfig.tsbuildinfo +1 -1
- package/dist/types/src/core/utils/appState/peregrineMQ/index.d.ts +1 -1
- package/dist/types/src/core/utils/appState/peregrineMQ/index.d.ts.map +1 -1
- package/dist/types/src/core/utils/appState/peregrineMQ/peregrineMQ.d.ts +2 -2
- package/dist/types/src/core/utils/appState/peregrineMQ/peregrineMQ.d.ts.map +1 -1
- package/dist/types/src/core/utils/appState/peregrineMQ/peregrineMQ.types.d.ts +5 -1
- package/dist/types/src/core/utils/appState/peregrineMQ/peregrineMQ.types.d.ts.map +1 -1
- package/dist/types/src/core/utils/appState/peregrineMQ/usePeregrineMQ.react.d.ts +2 -2
- package/dist/types/src/core/utils/appState/peregrineMQ/usePeregrineMQ.react.d.ts.map +1 -1
- package/dist/types/src/core/utils/appState/store/store.vanillajs.d.ts.map +1 -1
- package/dist/types/src/ts-playground.d.ts +1 -0
- package/dist/types/src/ts-playground.d.ts.map +1 -0
- package/dist/utils/esm/index.css +159 -159
- package/dist/utils/esm/src/core/utils/appState/peregrineMQ/index.js.map +1 -1
- package/dist/utils/esm/src/core/utils/appState/peregrineMQ/peregrineMQ.js +1 -1
- package/dist/utils/esm/src/core/utils/appState/peregrineMQ/peregrineMQ.js.map +1 -1
- package/dist/utils/esm/src/core/utils/appState/peregrineMQ/peregrineMQ.types.js +2 -0
- package/dist/utils/esm/src/core/utils/appState/peregrineMQ/peregrineMQ.types.js.map +1 -0
- package/dist/utils/esm/src/core/utils/appState/peregrineMQ/usePeregrineMQ.react.js.map +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/store.vanillajs.templates.js.map +1 -1
- package/dist/utils/esm/src/core/utils/index.js +1 -1
- package/dist/utils/index.css +159 -159
- package/dist/utils/src/core/utils/appState/peregrineMQ/index.js.map +1 -1
- package/dist/utils/src/core/utils/appState/peregrineMQ/peregrineMQ.js +1 -1
- package/dist/utils/src/core/utils/appState/peregrineMQ/peregrineMQ.js.map +1 -1
- package/dist/utils/src/core/utils/appState/peregrineMQ/peregrineMQ.types.js +2 -0
- package/dist/utils/src/core/utils/appState/peregrineMQ/peregrineMQ.types.js.map +1 -0
- package/dist/utils/src/core/utils/appState/peregrineMQ/usePeregrineMQ.react.js.map +1 -1
- package/dist/utils/src/core/utils/appState/store/store.vanillajs.js.map +1 -1
- package/dist/utils/src/core/utils/appState/store/store.vanillajs.templates.js.map +1 -1
- package/dist/utils/src/core/utils/index.js +1 -1
- package/package.json +1 -1
|
@@ -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\n\nimport { isFunctionAsync } from '../../helpers'\n\n/**\n * Represents the callback function for a store listener.\n */\nexport type ListenerCallBack<T> = (state: Partial<T>) => void\n\n/**\n * Represents a selector function that transforms the store state.\n */\n// export type Selector<T> = (state: Partial<T>) => Partial<T>;\nexport type SelectedValueType<T> = Partial<T> | Partial<keyof T>\n| string | number | boolean | undefined | string[] | number[] | boolean[] | undefined[];\nexport type Selector<T> = (state: Partial<T>) => SelectedValueType<T>;\n\n\n/**\n * Represents a listener for the store.\n */\nexport type Listener<T> = {\n selector?: Selector<T>\n previousValue?: SelectedValueType<T>\n} & ListenerCallBack<T>\n\n/**\n * Represents a store.\n */\nexport type Store<T> = {\n /**\n * Get the current state of the store.\n * @returns The current state of the store.\n */\n getState: () => Partial<T>\n /**\n * Set the state of the store.\n * @param state - The new state to set.\n * @returns A promise that resolves to the new state.\n */\n setState: (state: Partial<T>) => Promise<Partial<T>>\n /**\n * Subscribe a listener to the store.\n * @param listener - The listener function to be subscribed.\n * @param selector - Optional selector function to transform the store state.\n * @returns A function to unsubscribe the listener.\n */\n subscribe: (listener: Listener<T>, selector?: Selector<T>) => () => void\n /**\n * Unubscribe a listener from the store.\n * @param listener - The listener function to be unsubscribed.\n */\n unsubscribe: (listener: Listener<T>) => void\n}\n// & { actions?: { [actionName: string]: ActionHandlerCaller } }\n\n// TODO infer actionNames from createStore arguments\n/**\n * Represents a store with additional actions.\n */\nexport type StoreWithActions<T> = Store<T> & { actions: { [actionName: string]: ActionHandlerCaller<T> } }\n\n// export type PendingAction<A> = `${A}Pending`\n// export type ErrorAction<A> = `${A}Error`\n// export type ActionName<A> = `${A}`\n\n// export type ActionsReturnType<A, TActionHandler> = Record<ActionName<A>, TActionHandler>\n\n// export type ActionsStateReturnType<A>\n// = Partial<Record<PendingAction<A>, boolean>> & Partial<Record<ErrorAction<A>, boolean>>\n\n\n// function invert<T, ActionName extends string>(\n// arr: ActionName[], state: Partial<T>, actionHandler: ActionHandlerCaller<T>,\n// ): Partial<T> & ActionsStateReturnType<ActionName> {\n// arr.forEach((x) => {\n// state[`${x}Error`] = true\n// state[`${x}Pending`] = true\n// })\n\n// return state as (Partial<T> & ActionsStateReturnType<ActionName>)\n// }\n\n// function invert2<T, A extends string>(\n// arr: A[], actions: ActionsReturnType<A>, actionHandler: ActionHandlerCaller<T>,\n// ): ActionsReturnType<A, ActionHandlerCaller<T>> {\n// arr.forEach((x) => {\n// actions[`${x}`] = actionHandler\n// })\n\n// return actions as ActionsReturnType<A>\n// }\n\n// function invert3<T, A extends string>(\n// arr: A[], actions: ActionsReturnType<A>, state: Partial<T>, actionHandler: ActionHandlerCaller<T>,\n// ): [Partial<T> & ActionsStateReturnType<A>, ActionsReturnType<A, ActionHandlerCaller<T>>] {\n// arr.forEach((x) => {\n// state[`${x}Error`] = actionHandler\n// state[`${x}Pending`] = actionHandler\n// actions[`${x}`] = actionHandler\n// })\n\n// return [state, actions] as [Partial<T> & ActionsStateReturnType<A>, ActionsReturnType<A, ActionHandlerCaller<T>>]\n// }\n\n// const example = invert(['foo', 'bar', 'baz'], {}, () => {})\n// const example2 = invert2(['foo', 'bar', 'baz'], {}, () => {})\n// const example3 = invert3(['foo', 'bar', 'baz'], {}, () => {})\n\n\n\n/**\n * Represents an action handler function.\n */\nexport type ActionHandler<T> = (\n getState: Store<T>['getState'], // Function to get the current state of the store\n setState: Store<T>['setState'], // Function to set the state of the store\n ...rest: unknown[]\n) => void | Partial<T> | Promise<void | Partial<T>>\n\n/**\n * Represents an reducer function.\n */\nexport type Reducer<T> = (\n state: Partial<T>,\n action: string,\n ...rest: unknown[]\n) => Partial<T>\n\n\n/**\n * Represents a function that calls an action handler.\n */\nexport type ActionHandlerCaller<T> = (...args: unknown[]) => void | Partial<T> | Promise<void | Partial<T>>\n\n\ntype Actions<T> = { [key: string]: ActionHandler<T>}\n/**\n * Creates a new store.\n * @param initialState - The initial state of the store.\n * @param actions - Optional actions for the store.\n * @returns The created store.\n */\nexport const createStore = <T>(\n initialState: Partial<T>,\n actions?: Actions<T>,\n reducer?: Reducer<T>,\n): Store<T> | StoreWithActions<T> => {\n let currentState: Partial<T> = initialState\n const listeners = new Set<Listener<T>>()\n\n /**\n * Gets the current state of the store.\n * @returns The current state of the store.\n */\n const getState = (): Partial<T> => currentState\n\n // TODO debounce, batch? what is the meaningful time between setState ofr UI to be rendered and registerd by User?\n /**\n * Sets the state of the store.\n * @param newState - The new state to set.\n * @returns A promise that resolves to the new state.\n */\n const setState = async (newState: Partial<T>): Promise<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: SelectedValueType<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 as Partial<T>)\n }\n }\n return currentState\n }\n\n /**\n * Represents the basic API of the store.\n */\n const storeBaseicApi: Store<T> = {\n /**\n * Get the current state of the store.\n * @returns The current state of the store.\n */\n getState,\n /**\n * Set the state of the store.\n * @param state - The new state to set.\n * @returns A promise that resolves to the new state.\n */\n setState,\n /**\n * Subscribe a listener to the store.\n * @param listener - The listener function to be subscribed.\n * @returns A function to unsubscribe the listener.\n */\n subscribe: (listener: Listener<T>, selector?: Selector<T>) => {\n if (selector && listener.selector && listener.selector !== selector) {\n throw new Error('Error, mismatch selector, listener.selector !== selector.')\n }\n if (selector && !listener.selector) {\n // eslint-disable-next-line no-param-reassign\n listener.selector = selector\n }\n\n if (listener.selector) {\n // setting the previousValue for the next cache/equality check\n // eslint-disable-next-line no-param-reassign\n listener.previousValue = listener.selector(getState())\n }\n\n listeners.add(listener)\n return () => listeners.delete(listener)\n },\n /**\n * Unsubscribe a listener from the store.\n * @param listener - The listener function to be unsubscribed.\n */\n unsubscribe: (listener: Listener<T>) => {\n listeners.delete(listener)\n },\n }\n\n /**\n * Resolves the actions and creates action handlers.\n */\n const resolvedActions: Actions<T> | null | undefined\n = actions ? Object.entries(actions)?.reduce(\n (\n aggregator: Record<string, ActionHandlerCaller<T>>,\n [actionName, actionHandler]: [string, ActionHandler<T>],\n ) => {\n // eslint-disable-next-line no-param-reassign\n aggregator[actionName] = async(...rest: unknown[]): Promise<void | Partial<T>> => {\n // TODO try to not call subscriber too many times becuase of Error and Pending values\n const isAsync = isFunctionAsync(actionHandler as () => unknown)\n\n if (isAsync) {\n setState({\n ...getState(),\n [`${actionName}Error`]: null,\n [`${actionName}Pending`]: true,\n })\n }\n\n try {\n const resultOfAction = await actionHandler(getState, setState, ...rest)\n\n // TODO try to mutate state only once with the results, that means pass custom setState to action,\n // so that it would matk pending and error already inside action\n if (reducer) {\n setState(reducer(getState(), actionName, ...rest))\n }\n\n if (isAsync) {\n setState({ ...getState(), [`${actionName}Pending`]: false })\n }\n\n return resultOfAction\n } catch (error) {\n if (isAsync) {\n setState({\n ...getState(),\n [`${actionName}Pending`]: false,\n [`${actionName}Error`]: error,\n })\n }\n throw error\n }\n }\n\n return aggregator\n },\n {},\n ) : null\n\n /**\n * Represents the store combined with actions.\n */\n const storeCombinedWithActions = {\n ...storeBaseicApi,\n ...(resolvedActions ? { actions: { ...resolvedActions } } : {}),\n }\n\n return resolvedActions\n ? storeCombinedWithActions as StoreWithActions<T>\n // ? storeCombinedWithActions as StoreWithActions<T> & ActionsStateReturnType<A>\n : storeCombinedWithActions as Store<T>\n}\n"],"names":["createStore","initialState","actions","reducer","currentState","listeners","Set","getState","setState","_ref","_asyncToGenerator","newState","listener","selector","newValue","undefined","previousValue","_x","apply","this","arguments","storeBaseicApi","subscribe","Error","add","delete","unsubscribe","resolvedActions","Object","entries","reduce","aggregator","_ref2","actionName","actionHandler","isAsync","isFunctionAsync","_len","length","rest","Array","_key","resultOfAction","error","storeCombinedWithActions"],"mappings":"iJAgJO,MAAMA,EAAcA,CACzBC,EACAC,EACAC,KAEA,IAAIC,EAA2BH,EAC/B,MAAMI,EAAY,IAAIC,IAMhBC,EAAWA,IAAkBH,EAQ7BI,EAAQ,WAAA,IAAAC,EAAAC,GAAG,UAAOC,GACtBP,EAAeO,EAGf,IAAK,MAAMC,KAAYP,EAAW,CAEhC,MAAMQ,EAAoCD,GAAUC,SAM9CC,EAAiCD,EAAWA,EAAST,GAAgBA,OAG5CW,IAA3BH,EAASI,eAA+BJ,EAASI,gBAAkBF,IACrEF,EAASI,cAAgBF,QAEnBF,EAASE,GAEnB,CACA,OAAOV,KACR,OAtBKI,SAAQS,GAAA,OAAAR,EAAAS,MAAAC,KAAAC,UAAA,EAAA,GA2BRC,EAA2B,CAK/Bd,WAMAC,WAMAc,UAAWA,CAACV,EAAuBC,KACjC,GAAIA,GAAYD,EAASC,UAAYD,EAASC,WAAaA,EACzD,MAAM,IAAIU,MAAM,6DAclB,OAZIV,IAAaD,EAASC,WAExBD,EAASC,SAAWA,GAGlBD,EAASC,WAGXD,EAASI,cAAgBJ,EAASC,SAASN,MAG7CF,EAAUmB,IAAIZ,GACP,IAAMP,EAAUoB,OAAOb,EAAS,EAMzCc,YAAcd,IACZP,EAAUoB,OAAOb,EAAS,GAOxBe,EACFzB,EAAU0B,OAAOC,QAAQ3B,IAAU4B,QACnC,CACEC,EAAkDC,KAE/C,IADFC,EAAYC,GAA0CF,EAyCvD,OAtCAD,EAAWE,GAAWvB,GAAG,YAEvB,MAAMyB,EAAUC,EAAgBF,GAE5BC,GACF3B,EAAS,IACJD,IACH,CAAC,GAAG0B,UAAoB,KACxB,CAAC,GAAGA,aAAsB,IAI9B,IAAI,IAAA,IAAAI,EAAAjB,UAAAkB,OAZ4BC,EAAIC,IAAAA,MAAAH,GAAAI,EAAA,EAAAA,EAAAJ,EAAAI,IAAJF,EAAIE,GAAArB,UAAAqB,GAalC,MAAMC,QAAuBR,EAAc3B,EAAUC,KAAa+B,GAYlE,OARIpC,GACFK,EAASL,EAAQI,IAAY0B,KAAeM,IAG1CJ,GACF3B,EAAS,IAAKD,IAAY,CAAC,GAAG0B,aAAsB,IAG/CS,CACR,CAAC,MAAOC,GAQP,MAPIR,GACF3B,EAAS,IACJD,IACH,CAAC,GAAG0B,aAAsB,EAC1B,CAAC,GAAGA,UAAoBU,IAGtBA,CACR,KAGKZ,CAAU,GAEnB,CAAA,GACE,KAKAa,EAA2B,IAC5BvB,KACCM,EAAkB,CAAEzB,QAAS,IAAKyB,IAAsB,IAG9D,OACIiB,CAEoC"}
|
|
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\n\nimport { isFunctionAsync } from '../../helpers'\n\n/**\n * Represents the callback function for a store listener.\n */\nexport type ListenerCallBack<T> = (state: Partial<T>) => void\n\n/**\n * Represents a selector function that transforms the store state.\n */\n// export type Selector<T> = (state: Partial<T>) => Partial<T>;\nexport type SelectedValueType<T> = Partial<T> | Partial<keyof T>\n| string | number | boolean | undefined | string[] | number[] | boolean[] | undefined[];\nexport type Selector<T> = (state: Partial<T>) => SelectedValueType<T>;\n\n\n/**\n * Represents a listener for the store.\n */\nexport type Listener<T> = {\n selector?: Selector<T>\n previousValue?: SelectedValueType<T>\n} & ListenerCallBack<T>\n\n/**\n * Represents a store.\n */\nexport type Store<T> = {\n /**\n * Get the current state of the store.\n * @returns The current state of the store.\n */\n getState: () => Partial<T>\n /**\n * Set the state of the store.\n * @param state - The new state to set.\n * @returns A promise that resolves to the new state.\n */\n setState: (state: Partial<T>) => Promise<Partial<T>>\n /**\n * Subscribe a listener to the store.\n * @param listener - The listener function to be subscribed.\n * @param selector - Optional selector function to transform the store state.\n * @returns A function to unsubscribe the listener.\n */\n subscribe: (listener: Listener<T>, selector?: Selector<T>) => () => void\n /**\n * Unubscribe a listener from the store.\n * @param listener - The listener function to be unsubscribed.\n */\n unsubscribe: (listener: Listener<T>) => void\n}\n// & { actions?: { [actionName: string]: ActionHandlerCaller } }\n\n// TODO infer actionNames from createStore arguments\n/**\n * Represents a store with additional actions.\n */\nexport type StoreWithActions<T> = Store<T> & { actions: { [actionName: string]: ActionHandlerCaller<T> } }\n\n\n\n\n/**\n * Represents an action handler function.\n */\nexport type ActionHandler<T> = (\n getState: Store<T>['getState'], // Function to get the current state of the store\n setState: Store<T>['setState'], // Function to set the state of the store\n ...rest: unknown[]\n) => void | Partial<T> | Promise<void | Partial<T>>\n\n/**\n * Represents an reducer function.\n */\nexport type Reducer<T> = (\n state: Partial<T>,\n action: string,\n ...rest: unknown[]\n) => Partial<T>\n\n\n/**\n * Represents a function that calls an action handler.\n */\nexport type ActionHandlerCaller<T> = (...args: unknown[]) => void | Partial<T> | Promise<void | Partial<T>>\n\n\ntype Actions<T> = { [key: string]: ActionHandler<T>}\n/**\n * Creates a new store.\n * @param initialState - The initial state of the store.\n * @param actions - Optional actions for the store.\n * @returns The created store.\n */\nexport const createStore = <T>(\n initialState: Partial<T>,\n actions?: Actions<T>,\n reducer?: Reducer<T>,\n): Store<T> | StoreWithActions<T> => {\n let currentState: Partial<T> = initialState\n const listeners = new Set<Listener<T>>()\n\n /**\n * Gets the current state of the store.\n * @returns The current state of the store.\n */\n const getState = (): Partial<T> => currentState\n\n // TODO debounce, batch? what is the meaningful time between setState ofr UI to be rendered and registerd by User?\n /**\n * Sets the state of the store.\n * @param newState - The new state to set.\n * @returns A promise that resolves to the new state.\n */\n const setState = async (newState: Partial<T>): Promise<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: SelectedValueType<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 as Partial<T>)\n }\n }\n return currentState\n }\n\n /**\n * Represents the basic API of the store.\n */\n const storeBaseicApi: Store<T> = {\n /**\n * Get the current state of the store.\n * @returns The current state of the store.\n */\n getState,\n /**\n * Set the state of the store.\n * @param state - The new state to set.\n * @returns A promise that resolves to the new state.\n */\n setState,\n /**\n * Subscribe a listener to the store.\n * @param listener - The listener function to be subscribed.\n * @returns A function to unsubscribe the listener.\n */\n subscribe: (listener: Listener<T>, selector?: Selector<T>) => {\n if (selector && listener.selector && listener.selector !== selector) {\n throw new Error('Error, mismatch selector, listener.selector !== selector.')\n }\n if (selector && !listener.selector) {\n // eslint-disable-next-line no-param-reassign\n listener.selector = selector\n }\n\n if (listener.selector) {\n // setting the previousValue for the next cache/equality check\n // eslint-disable-next-line no-param-reassign\n listener.previousValue = listener.selector(getState())\n }\n\n listeners.add(listener)\n return () => listeners.delete(listener)\n },\n /**\n * Unsubscribe a listener from the store.\n * @param listener - The listener function to be unsubscribed.\n */\n unsubscribe: (listener: Listener<T>) => {\n listeners.delete(listener)\n },\n }\n\n /**\n * Resolves the actions and creates action handlers.\n */\n const resolvedActions: Actions<T> | null | undefined\n = actions ? Object.entries(actions)?.reduce(\n (\n aggregator: Record<string, ActionHandlerCaller<T>>,\n [actionName, actionHandler]: [string, ActionHandler<T>],\n ) => {\n // eslint-disable-next-line no-param-reassign\n aggregator[actionName] = async(...rest: unknown[]): Promise<void | Partial<T>> => {\n // TODO try to not call subscriber too many times becuase of Error and Pending values\n const isAsync = isFunctionAsync(actionHandler as () => unknown)\n\n if (isAsync) {\n setState({\n ...getState(),\n [`${actionName}Error`]: null,\n [`${actionName}Pending`]: true,\n })\n }\n\n try {\n const resultOfAction = await actionHandler(getState, setState, ...rest)\n\n // TODO try to mutate state only once with the results, that means pass custom setState to action,\n // so that it would matk pending and error already inside action\n if (reducer) {\n setState(reducer(getState(), actionName, ...rest))\n }\n\n if (isAsync) {\n setState({ ...getState(), [`${actionName}Pending`]: false })\n }\n\n return resultOfAction\n } catch (error) {\n if (isAsync) {\n setState({\n ...getState(),\n [`${actionName}Pending`]: false,\n [`${actionName}Error`]: error,\n })\n }\n throw error\n }\n }\n\n return aggregator\n },\n {},\n ) : null\n\n /**\n * Represents the store combined with actions.\n */\n const storeCombinedWithActions = {\n ...storeBaseicApi,\n ...(resolvedActions ? { actions: { ...resolvedActions } } : {}),\n }\n\n return resolvedActions\n ? storeCombinedWithActions as StoreWithActions<T>\n // ? storeCombinedWithActions as StoreWithActions<T> & ActionsStateReturnType<A>\n : storeCombinedWithActions as Store<T>\n}\n"],"names":["createStore","initialState","actions","reducer","currentState","listeners","Set","getState","setState","_ref","_asyncToGenerator","newState","listener","selector","newValue","undefined","previousValue","_x","apply","this","arguments","storeBaseicApi","subscribe","Error","add","delete","unsubscribe","resolvedActions","Object","entries","reduce","aggregator","_ref2","actionName","actionHandler","isAsync","isFunctionAsync","_len","length","rest","Array","_key","resultOfAction","error","storeCombinedWithActions"],"mappings":"iJAkGO,MAAMA,EAAcA,CACzBC,EACAC,EACAC,KAEA,IAAIC,EAA2BH,EAC/B,MAAMI,EAAY,IAAIC,IAMhBC,EAAWA,IAAkBH,EAQ7BI,EAAQ,WAAA,IAAAC,EAAAC,GAAG,U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,CAAC,GAAG0B,aAAsB,EAC1B,CAAC,GAAGA,UAAoBU,IAGtBA,CACR,KAGKZ,CAAU,GAEnB,CAAA,GACE,KAKAa,EAA2B,IAC5BvB,KACCM,EAAkB,CAAEzB,QAAS,IAAKyB,IAAsB,IAG9D,OACIiB,CAEoC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"store.vanillajs.templates.js","sources":["../../../../../../../../src/core/utils/appState/store/store.vanillajs.templates.ts"],"sourcesContent":["import { ActionHandler, Reducer, Store, StoreWithActions, createStore } from './store.vanillajs'\n\n\ntype DefaultES = { [key: string]: any }\n\n\nexport type DataState<T, ES = DefaultES> = {\n dataId: string\n isLoading: boolean\n error?: unknown\n data?: T\n} & ES\n\n\ntype Load<T, ES = DefaultES> = (\n getState: Store<DataState<T, ES>>['getState'],\n setState: Store<DataState<T, ES>>['setState'],\n dataPromise: unknown | Promise<unknown>,\n) => Promise<Partial<DataState<T, ES>>>\n\n\ntype LoadHandler<T, ES = DefaultES> = (\n dataPromise: unknown | Promise<unknown>,\n) => Promise<Partial<DataState<T, ES>>>\n\n/**\n * Creates a data store with actions.\n * @param dataId - The ID of the data.\n * @param actions - Optional actions for the data store.\n * @returns The created data store with actions.\n */\nexport const createDataStore\n= <T, ES = DefaultES>(\n dataId: string,\n initialState?: Partial<ES>,\n actions?: Record<string, ActionHandler<DataState<T, ES>>>,\n reducer?: Reducer<DataState<T, ES>>,\n): StoreWithActions<DataState<T, ES>>\n& { actions: { load: LoadHandler<T, ES> } } => {\n const loadActions: { load: Load<T, ES> } = {\n ...actions,\n /**\n * Loads data into the data store.\n * @param getState - Function to get the current state of the data store.\n * @param setState - Function to set the state of the data store.\n * @param dataPromise - The data promise to be loaded.\n * @returns A promise that resolves to the updated state of the data store.\n */\n load: async (\n getState: Store<DataState<T, ES>>['getState'],\n setState: Store<DataState<T, ES>>['setState'],\n dataPromise: unknown | Promise<unknown>,\n ) => {\n const dataState: Partial<DataState<T, ES>> = getState()\n\n setState({ ...dataState, isLoading: true })\n\n try {\n const response: unknown = await dataPromise\n\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore\n dataState.data = response?.data || response\n } catch (error: unknown) {\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore\n dataState.error = error\n }\n return setState({ ...dataState, isLoading: false })\n },\n }\n\n return (createStore<DataState<T, ES>>({\n ...initialState,\n dataId,\n isLoading: false,\n } as Partial<DataState<T, ES>>, loadActions, reducer)) as StoreWithActions<DataState<T, ES>>\n & { actions: { load: LoadHandler<T, ES> } }\n}\n"],"names":["createDataStore","dataId","initialState","actions","reducer","loadActions","load","_ref","_asyncToGenerator","getState","setState","dataPromise","dataState","isLoading","response","data","error","_x","_x2","_x3","apply","this","arguments","createStore"],"mappings":"2IA+BO,MAAMA,EACXA,CACAC,EACAC,EACAC,EACAC,KAGA,MAAMC,EAAqC,IACtCF,EAQHG,MAAIC,EAAAC,GAAE,UACJC,EACAC,EACAC,GAEA,MAAMC,EAAuCH,IAE7CC,EAAS,IAAKE,EAAWC,WAAW,IAEpC,IACE,MAAMC,QAA0BH,EAIhCC,EAAUG,KAAOD,GAAUC,MAAQD,CACpC,CAAC,MAAOE,GAGPJ,EAAUI,MAAQA,CACpB,CACA,OAAON,EAAS,IAAKE,EAAWC,WAAW,OAC5C,
|
|
1
|
+
{"version":3,"file":"store.vanillajs.templates.js","sources":["../../../../../../../../src/core/utils/appState/store/store.vanillajs.templates.ts"],"sourcesContent":["import { ActionHandler, Reducer, Store, StoreWithActions, createStore } from './store.vanillajs'\n\n\ntype DefaultES = { [key: string]: any }\n\n\nexport type DataState<T, ES = DefaultES> = {\n dataId: string\n isLoading: boolean\n error?: unknown\n data?: T\n} & ES\n\n\ntype Load<T, ES = DefaultES> = (\n getState: Store<DataState<T, ES>>['getState'],\n setState: Store<DataState<T, ES>>['setState'],\n dataPromise: unknown | Promise<unknown>,\n) => Promise<Partial<DataState<T, ES>>>\n\n\ntype LoadHandler<T, ES = DefaultES> = (\n dataPromise: unknown | Promise<unknown>,\n) => Promise<Partial<DataState<T, ES>>>\n\n/**\n * Creates a data store with actions.\n * @param dataId - The ID of the data.\n * @param actions - Optional actions for the data store.\n * @returns The created data store with actions.\n */\nexport const createDataStore\n= <T, ES = DefaultES>(\n dataId: string,\n initialState?: Partial<ES>,\n actions?: Record<string, ActionHandler<DataState<T, ES>>>,\n reducer?: Reducer<DataState<T, ES>>,\n): StoreWithActions<DataState<T, ES>>\n& { actions: { load: LoadHandler<T, ES> } } => {\n const loadActions: { load: Load<T, ES> } = {\n ...actions,\n /**\n * Loads data into the data store.\n * @param getState - Function to get the current state of the data store.\n * @param setState - Function to set the state of the data store.\n * @param dataPromise - The data promise to be loaded.\n * @returns A promise that resolves to the updated state of the data store.\n */\n load: async (\n getState: Store<DataState<T, ES>>['getState'],\n setState: Store<DataState<T, ES>>['setState'],\n dataPromise: unknown | Promise<unknown>,\n ) => {\n const dataState: Partial<DataState<T, ES>> = getState()\n\n setState({ ...dataState, isLoading: true })\n\n try {\n const response: unknown = await dataPromise\n\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore\n dataState.data = response?.data || response\n } catch (error: unknown) {\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore\n dataState.error = error\n }\n return setState({ ...dataState, isLoading: false })\n },\n }\n\n return (createStore<DataState<T, ES>>({\n ...initialState,\n dataId,\n isLoading: false,\n } as Partial<DataState<T, ES>>, loadActions, reducer)) as StoreWithActions<DataState<T, ES>>\n & { actions: { load: LoadHandler<T, ES> } }\n}\n"],"names":["createDataStore","dataId","initialState","actions","reducer","loadActions","load","_ref","_asyncToGenerator","getState","setState","dataPromise","dataState","isLoading","response","data","error","_x","_x2","_x3","apply","this","arguments","createStore"],"mappings":"2IA+BO,MAAMA,EACXA,CACAC,EACAC,EACAC,EACAC,KAGA,MAAMC,EAAqC,IACtCF,EAQHG,MAAIC,EAAAC,GAAE,UACJC,EACAC,EACAC,GAEA,MAAMC,EAAuCH,IAE7CC,EAAS,IAAKE,EAAWC,WAAW,IAEpC,IACE,MAAMC,QAA0BH,EAIhCC,EAAUG,KAAOD,GAAUC,MAAQD,CACpC,CAAC,MAAOE,GAGPJ,EAAUI,MAAQA,CACpB,CACA,OAAON,EAAS,IAAKE,EAAWC,WAAW,OAC5C,SArBGI,EAAAC,EAAAC,GAAA,OAAAZ,EAAAa,MAAAC,KAAAC,UAAA,IAAA,IAAAf,EAwBN,OAAQgB,EAA8B,IACjCrB,EACHD,SACAY,WAAW,GACmBR,EAAaD,EAAQ"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export{keyExtractor,keyExtractorFunction}from"./keyExtractor.js";export{dateRangeFormat,getDateTime,getTimeFromNow,getTimeFromNowOriginal,getTimeTo}from"./date.js";export{peregrineMQInstance}from"./appState/peregrineMQ/index.js";export{isBirthNumberValid}from"./helpers/birthnumber.validator.js";export{getMatch,isValidFormat,isValidModulo11,parse,regex}from"./helpers/birthnumberCZSKvalidator.js";export{parseCSVdata,validateCSVFile,validateCSVlines,validateJSONFile,validateLineCellTrimmed,validateLineNumColumns,validateSDFFile}from"./helpers/fileValidator.js";export{DATE_FORMAT,DATE_TIME_FORMAT,formatDate,formatDateTime,formatDateToTimestamp,getDate}from"./helpers/date.js";export{getDeviceId}from"./helpers/deviceInfo.js";export{emailMatch,emailMatcher,regexBuilder}from"./helpers/emailMatcher.js";export{cleanCsvLines,formatFilePath}from"./helpers/file.js";export{arrayToObjectTree,chunkArray,duplicatesInArray,formatJsonString,formatObj,formatObj2}from"./helpers/objectOperations.js";export{AsyncFunctionTemplate,debounce,delay,isFunctionAsync,memoize,memoizeComplex,memoizer,nestedTernary}from"./helpers/other.js";export{escapeRegExp,fileNameExt,findStringInText,normalizeString,removeWhitespaces,sanitizeId,sanitizePathId,toLowerCase,toUpperCase,truncateText}from"./helpers/textValueOperations.js";export{Operation,decrementValue,incerementValue,numberDefined,numberOperation,restrictNumberInLimits,setValue}from"./helpers/valueOperations.js";export{cancelableSetInterval,cancelableSetTimeout}from"./helpers/cancelableDelayedFunction.js";export{anchorClick,classNames,generateId,mapSerReplacer,noop,parseProps}from"./helpers/ui.js";export{composeId,defaultSanitizeConfig,sanitizeHtml}from"./helpers/text.js";export{ced,createResolveAttribute,customElementDefine,resolveAttributes}from"./webComponents/webComponent.utils.js";export{createStore}from"./appState/store/store.vanillajs.js";export{createDataStore}from"./appState/store/store.vanillajs.templates.js";export{useStore,useStoreApi}from"./appState/store/useStore.react.js";export{PeregrineMQ,PeregrineMQClearError}from"./appState/peregrineMQ/peregrineMQ.js";export{usePeregrineMQ}from"./appState/peregrineMQ/usePeregrineMQ.react.js";export{TinyStateMachine,TinyStateMachineEvent,TinyStateMachineEventType,TinyStateMachineState,createStates,stateIterator}from"./appState/stateMachine/tiny-state-machine.base.js";
|
|
1
|
+
export{keyExtractor,keyExtractorFunction}from"./keyExtractor.js";export{dateRangeFormat,getDateTime,getTimeFromNow,getTimeFromNowOriginal,getTimeTo}from"./date.js";export{peregrineMQInstance}from"./appState/peregrineMQ/index.js";export{isBirthNumberValid}from"./helpers/birthnumber.validator.js";export{getMatch,isValidFormat,isValidModulo11,parse,regex}from"./helpers/birthnumberCZSKvalidator.js";export{parseCSVdata,validateCSVFile,validateCSVlines,validateJSONFile,validateLineCellTrimmed,validateLineNumColumns,validateSDFFile}from"./helpers/fileValidator.js";export{DATE_FORMAT,DATE_TIME_FORMAT,formatDate,formatDateTime,formatDateToTimestamp,getDate}from"./helpers/date.js";export{getDeviceId}from"./helpers/deviceInfo.js";export{emailMatch,emailMatcher,regexBuilder}from"./helpers/emailMatcher.js";export{cleanCsvLines,formatFilePath}from"./helpers/file.js";export{arrayToObjectTree,chunkArray,duplicatesInArray,formatJsonString,formatObj,formatObj2}from"./helpers/objectOperations.js";export{AsyncFunctionTemplate,debounce,delay,isFunctionAsync,memoize,memoizeComplex,memoizer,nestedTernary}from"./helpers/other.js";export{escapeRegExp,fileNameExt,findStringInText,normalizeString,removeWhitespaces,sanitizeId,sanitizePathId,toLowerCase,toUpperCase,truncateText}from"./helpers/textValueOperations.js";export{Operation,decrementValue,incerementValue,numberDefined,numberOperation,restrictNumberInLimits,setValue}from"./helpers/valueOperations.js";export{cancelableSetInterval,cancelableSetTimeout}from"./helpers/cancelableDelayedFunction.js";export{anchorClick,classNames,generateId,mapSerReplacer,noop,parseProps}from"./helpers/ui.js";export{composeId,defaultSanitizeConfig,sanitizeHtml}from"./helpers/text.js";export{ced,createResolveAttribute,customElementDefine,resolveAttributes}from"./webComponents/webComponent.utils.js";export{createStore}from"./appState/store/store.vanillajs.js";export{createDataStore}from"./appState/store/store.vanillajs.templates.js";export{useStore,useStoreApi}from"./appState/store/useStore.react.js";export{PeregrineMQ,PeregrineMQClearError}from"./appState/peregrineMQ/peregrineMQ.js";export{NON_EXISTENT_CHANNEL}from"./appState/peregrineMQ/peregrineMQ.types.js";export{usePeregrineMQ}from"./appState/peregrineMQ/usePeregrineMQ.react.js";export{TinyStateMachine,TinyStateMachineEvent,TinyStateMachineEventType,TinyStateMachineState,createStates,stateIterator}from"./appState/stateMachine/tiny-state-machine.base.js";
|
|
2
2
|
//# sourceMappingURL=index.js.map
|
package/dist/utils/index.css
CHANGED
|
@@ -1,3 +1,12 @@
|
|
|
1
|
+
.errorBoundary-module_errorBoundary__gk9ps {
|
|
2
|
+
background: #EFEFEF;
|
|
3
|
+
width: 100%;
|
|
4
|
+
height: 100%;
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
.errorBoundary-module_StyledIcon__IYHiU {
|
|
8
|
+
margin-right: 10px;
|
|
9
|
+
}
|
|
1
10
|
.icon-module_icon-base-parent__nOMvW {
|
|
2
11
|
line-height: 1px !important;
|
|
3
12
|
}
|
|
@@ -61,6 +70,25 @@
|
|
|
61
70
|
max-width: var(--prop-value);
|
|
62
71
|
opacity: 1;
|
|
63
72
|
}
|
|
73
|
+
.divider-module_divider-line__6CesR {
|
|
74
|
+
position: relative;
|
|
75
|
+
display: block;
|
|
76
|
+
transition: opacity, width, height 250ms ease-in-out;
|
|
77
|
+
background-color: var(--color);
|
|
78
|
+
opacity: var(--opacity);
|
|
79
|
+
}
|
|
80
|
+
.divider-module_divider-line__6CesR.divider-module_vertical__qSVWD {
|
|
81
|
+
height: var(--length);
|
|
82
|
+
left: var(--left);
|
|
83
|
+
width: var(--width);
|
|
84
|
+
margin: var(--margin);
|
|
85
|
+
}
|
|
86
|
+
.divider-module_divider-line__6CesR.divider-module_horizontal__Gz-Oj {
|
|
87
|
+
width: var(--length);
|
|
88
|
+
left: var(--left);
|
|
89
|
+
height: var(--height);
|
|
90
|
+
margin: var(--margin);
|
|
91
|
+
}
|
|
64
92
|
.field-module_field__UfKm3 {
|
|
65
93
|
opacity: 1;
|
|
66
94
|
pointer-events: auto;
|
|
@@ -135,34 +163,6 @@
|
|
|
135
163
|
.field-module_field__UfKm3 label {
|
|
136
164
|
text-align: left;
|
|
137
165
|
}
|
|
138
|
-
.errorBoundary-module_errorBoundary__gk9ps {
|
|
139
|
-
background: #EFEFEF;
|
|
140
|
-
width: 100%;
|
|
141
|
-
height: 100%;
|
|
142
|
-
}
|
|
143
|
-
|
|
144
|
-
.errorBoundary-module_StyledIcon__IYHiU {
|
|
145
|
-
margin-right: 10px;
|
|
146
|
-
}
|
|
147
|
-
.divider-module_divider-line__6CesR {
|
|
148
|
-
position: relative;
|
|
149
|
-
display: block;
|
|
150
|
-
transition: opacity, width, height 250ms ease-in-out;
|
|
151
|
-
background-color: var(--color);
|
|
152
|
-
opacity: var(--opacity);
|
|
153
|
-
}
|
|
154
|
-
.divider-module_divider-line__6CesR.divider-module_vertical__qSVWD {
|
|
155
|
-
height: var(--length);
|
|
156
|
-
left: var(--left);
|
|
157
|
-
width: var(--width);
|
|
158
|
-
margin: var(--margin);
|
|
159
|
-
}
|
|
160
|
-
.divider-module_divider-line__6CesR.divider-module_horizontal__Gz-Oj {
|
|
161
|
-
width: var(--length);
|
|
162
|
-
left: var(--left);
|
|
163
|
-
height: var(--height);
|
|
164
|
-
margin: var(--margin);
|
|
165
|
-
}
|
|
166
166
|
.layoutBox-module_layout-box__ZIID8 {
|
|
167
167
|
display: flex;
|
|
168
168
|
position: relative;
|
|
@@ -230,6 +230,11 @@
|
|
|
230
230
|
stroke-dashoffset: -124;
|
|
231
231
|
}
|
|
232
232
|
}
|
|
233
|
+
.textAndContent-module_textAndContent__X5P1n {
|
|
234
|
+
align-items: baseline;
|
|
235
|
+
flex-shrink: 1;
|
|
236
|
+
gap: 8px;
|
|
237
|
+
}
|
|
233
238
|
:root {
|
|
234
239
|
--divider-line: #4a4b4b;
|
|
235
240
|
}
|
|
@@ -296,10 +301,18 @@
|
|
|
296
301
|
pointer-events: none;
|
|
297
302
|
opacity: 0.6;
|
|
298
303
|
}
|
|
299
|
-
.
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
304
|
+
.flowLayout-module_flowLayout__VHpnY {
|
|
305
|
+
overflow: auto;
|
|
306
|
+
}
|
|
307
|
+
.flowLayout-module_flowLayout__VHpnY .flowLayout-module_beforeContent__rY-mW {
|
|
308
|
+
display: flex;
|
|
309
|
+
width: 100%;
|
|
310
|
+
min-width: 0;
|
|
311
|
+
}
|
|
312
|
+
.flowLayout-module_flowLayout__VHpnY .flowLayout-module_afterContent__Hlh8v {
|
|
313
|
+
display: flex;
|
|
314
|
+
width: 100%;
|
|
315
|
+
min-width: 0;
|
|
303
316
|
}
|
|
304
317
|
:root {
|
|
305
318
|
--divider-line: #4a4b4b;
|
|
@@ -415,133 +428,6 @@
|
|
|
415
428
|
.cui-theme-light .button-module_button__NDMQS {
|
|
416
429
|
color: #090A0A;
|
|
417
430
|
}
|
|
418
|
-
.flowLayout-module_flowLayout__VHpnY {
|
|
419
|
-
overflow: auto;
|
|
420
|
-
}
|
|
421
|
-
.flowLayout-module_flowLayout__VHpnY .flowLayout-module_beforeContent__rY-mW {
|
|
422
|
-
display: flex;
|
|
423
|
-
width: 100%;
|
|
424
|
-
min-width: 0;
|
|
425
|
-
}
|
|
426
|
-
.flowLayout-module_flowLayout__VHpnY .flowLayout-module_afterContent__Hlh8v {
|
|
427
|
-
display: flex;
|
|
428
|
-
width: 100%;
|
|
429
|
-
min-width: 0;
|
|
430
|
-
}
|
|
431
|
-
:root {
|
|
432
|
-
--divider-line: #4a4b4b;
|
|
433
|
-
}
|
|
434
|
-
|
|
435
|
-
.tooltip-module_overflow-hidden__YDzdx, .tooltip-module_text-truncate__CPvp3 {
|
|
436
|
-
overflow: hidden !important;
|
|
437
|
-
}
|
|
438
|
-
|
|
439
|
-
.tooltip-module_text-nowrap__g6kzP, .tooltip-module_text-truncate__CPvp3 {
|
|
440
|
-
white-space: nowrap !important;
|
|
441
|
-
}
|
|
442
|
-
|
|
443
|
-
.tooltip-module_text-ellipsis__AYivV, .tooltip-module_text-truncate__CPvp3 {
|
|
444
|
-
text-overflow: ellipsis !important;
|
|
445
|
-
}
|
|
446
|
-
|
|
447
|
-
.tooltip-module_popover-tooltip__sAhKa {
|
|
448
|
-
position: fixed;
|
|
449
|
-
z-index: 999;
|
|
450
|
-
will-change: opacity;
|
|
451
|
-
transition: opacity 450ms ease;
|
|
452
|
-
opacity: 0;
|
|
453
|
-
visibility: hidden;
|
|
454
|
-
border-radius: 4px;
|
|
455
|
-
background-color: #1B1D1D;
|
|
456
|
-
box-shadow: 0px 4px 4px 0px rgba(0, 0, 0, 0.16);
|
|
457
|
-
}
|
|
458
|
-
.tooltip-module_popover-tooltip__sAhKa span, .tooltip-module_popover-tooltip__sAhKa p, .tooltip-module_popover-tooltip__sAhKa h3 {
|
|
459
|
-
margin: 0;
|
|
460
|
-
padding: 0;
|
|
461
|
-
}
|
|
462
|
-
.tooltip-module_popover-tooltip__sAhKa p {
|
|
463
|
-
display: -webkit-box;
|
|
464
|
-
-webkit-line-clamp: 4; /* number of lines to show */
|
|
465
|
-
line-clamp: 4;
|
|
466
|
-
-webkit-box-orient: vertical;
|
|
467
|
-
margin: 0;
|
|
468
|
-
width: 100%;
|
|
469
|
-
white-space: normal;
|
|
470
|
-
overflow: auto;
|
|
471
|
-
}
|
|
472
|
-
.tooltip-module_popover-tooltip__sAhKa[data-show] {
|
|
473
|
-
opacity: 1;
|
|
474
|
-
visibility: visible;
|
|
475
|
-
}
|
|
476
|
-
.tooltip-module_popover-tooltip__sAhKa[data-show=false] {
|
|
477
|
-
opacity: 0;
|
|
478
|
-
visibility: hidden;
|
|
479
|
-
}
|
|
480
|
-
.tooltip-module_popover-tooltip__sAhKa[data-popper-placement^=top] .tooltip-module_arrow__pqqOi {
|
|
481
|
-
bottom: -16px;
|
|
482
|
-
}
|
|
483
|
-
.tooltip-module_popover-tooltip__sAhKa[data-popper-placement^=top] .tooltip-module_arrow__pqqOi .tooltip-module_arrow-inner__IqzxY {
|
|
484
|
-
transform: rotate(0deg);
|
|
485
|
-
}
|
|
486
|
-
.tooltip-module_popover-tooltip__sAhKa[data-popper-placement^=bottom] .tooltip-module_arrow__pqqOi {
|
|
487
|
-
top: -16px;
|
|
488
|
-
}
|
|
489
|
-
.tooltip-module_popover-tooltip__sAhKa[data-popper-placement^=bottom] .tooltip-module_arrow__pqqOi .tooltip-module_arrow-inner__IqzxY {
|
|
490
|
-
transform: rotate(180deg);
|
|
491
|
-
}
|
|
492
|
-
.tooltip-module_popover-tooltip__sAhKa[data-popper-placement^=left] .tooltip-module_arrow__pqqOi {
|
|
493
|
-
right: -16px;
|
|
494
|
-
}
|
|
495
|
-
.tooltip-module_popover-tooltip__sAhKa[data-popper-placement^=left] .tooltip-module_arrow__pqqOi .tooltip-module_arrow-inner__IqzxY {
|
|
496
|
-
transform: rotate(-90deg);
|
|
497
|
-
}
|
|
498
|
-
.tooltip-module_popover-tooltip__sAhKa[data-popper-placement^=right] .tooltip-module_arrow__pqqOi {
|
|
499
|
-
left: -16px;
|
|
500
|
-
}
|
|
501
|
-
.tooltip-module_popover-tooltip__sAhKa[data-popper-placement^=right] .tooltip-module_arrow__pqqOi .tooltip-module_arrow-inner__IqzxY {
|
|
502
|
-
transform: rotate(90deg);
|
|
503
|
-
}
|
|
504
|
-
.tooltip-module_popover-tooltip__sAhKa .tooltip-module_arrow__pqqOi {
|
|
505
|
-
position: absolute;
|
|
506
|
-
}
|
|
507
|
-
.tooltip-module_popover-tooltip__sAhKa .tooltip-module_arrow__pqqOi .tooltip-module_arrow-inner__IqzxY {
|
|
508
|
-
content: "";
|
|
509
|
-
border-width: 8px;
|
|
510
|
-
border-style: solid;
|
|
511
|
-
border-color: #1B1D1D transparent transparent transparent;
|
|
512
|
-
}
|
|
513
|
-
|
|
514
|
-
.tooltip-module_close-button__o8OBN {
|
|
515
|
-
cursor: pointer;
|
|
516
|
-
line-height: 1px;
|
|
517
|
-
background-color: rgba(255, 255, 255, 0);
|
|
518
|
-
}
|
|
519
|
-
.tooltip-module_close-button__o8OBN .icon-base {
|
|
520
|
-
background-color: #FDDA0D;
|
|
521
|
-
width: 9px !important;
|
|
522
|
-
height: 9px !important;
|
|
523
|
-
line-height: 1px !important;
|
|
524
|
-
}
|
|
525
|
-
.tooltip-module_close-button__o8OBN:hover .icon-base {
|
|
526
|
-
background-color: #FFEA00;
|
|
527
|
-
}
|
|
528
|
-
|
|
529
|
-
.cui-theme-dark .tooltip-module_popover-tooltip__sAhKa {
|
|
530
|
-
background-color: #1B1D1D;
|
|
531
|
-
color: #F4F4F4;
|
|
532
|
-
}
|
|
533
|
-
.cui-theme-dark .tooltip-module_popover-tooltip__sAhKa .tooltip-module_arrow-inner__IqzxY {
|
|
534
|
-
border-color: #1B1D1D transparent transparent transparent;
|
|
535
|
-
}
|
|
536
|
-
.cui-theme-light {
|
|
537
|
-
color: #1B1D1D;
|
|
538
|
-
}
|
|
539
|
-
.cui-theme-light .tooltip-module_popover-tooltip__sAhKa {
|
|
540
|
-
background-color: #515757;
|
|
541
|
-
}
|
|
542
|
-
.cui-theme-light .tooltip-module_popover-tooltip__sAhKa .tooltip-module_arrow-inner__IqzxY {
|
|
543
|
-
border-color: #515757 transparent transparent transparent;
|
|
544
|
-
}
|
|
545
431
|
:root {
|
|
546
432
|
--divider-line: #4a4b4b;
|
|
547
433
|
}
|
|
@@ -706,6 +592,120 @@
|
|
|
706
592
|
border-color: #FD8F3E;
|
|
707
593
|
color: #632E03;
|
|
708
594
|
}
|
|
595
|
+
:root {
|
|
596
|
+
--divider-line: #4a4b4b;
|
|
597
|
+
}
|
|
598
|
+
|
|
599
|
+
.tooltip-module_overflow-hidden__YDzdx, .tooltip-module_text-truncate__CPvp3 {
|
|
600
|
+
overflow: hidden !important;
|
|
601
|
+
}
|
|
602
|
+
|
|
603
|
+
.tooltip-module_text-nowrap__g6kzP, .tooltip-module_text-truncate__CPvp3 {
|
|
604
|
+
white-space: nowrap !important;
|
|
605
|
+
}
|
|
606
|
+
|
|
607
|
+
.tooltip-module_text-ellipsis__AYivV, .tooltip-module_text-truncate__CPvp3 {
|
|
608
|
+
text-overflow: ellipsis !important;
|
|
609
|
+
}
|
|
610
|
+
|
|
611
|
+
.tooltip-module_popover-tooltip__sAhKa {
|
|
612
|
+
position: fixed;
|
|
613
|
+
z-index: 999;
|
|
614
|
+
will-change: opacity;
|
|
615
|
+
transition: opacity 450ms ease;
|
|
616
|
+
opacity: 0;
|
|
617
|
+
visibility: hidden;
|
|
618
|
+
border-radius: 4px;
|
|
619
|
+
background-color: #1B1D1D;
|
|
620
|
+
box-shadow: 0px 4px 4px 0px rgba(0, 0, 0, 0.16);
|
|
621
|
+
}
|
|
622
|
+
.tooltip-module_popover-tooltip__sAhKa span, .tooltip-module_popover-tooltip__sAhKa p, .tooltip-module_popover-tooltip__sAhKa h3 {
|
|
623
|
+
margin: 0;
|
|
624
|
+
padding: 0;
|
|
625
|
+
}
|
|
626
|
+
.tooltip-module_popover-tooltip__sAhKa p {
|
|
627
|
+
display: -webkit-box;
|
|
628
|
+
-webkit-line-clamp: 4; /* number of lines to show */
|
|
629
|
+
line-clamp: 4;
|
|
630
|
+
-webkit-box-orient: vertical;
|
|
631
|
+
margin: 0;
|
|
632
|
+
width: 100%;
|
|
633
|
+
white-space: normal;
|
|
634
|
+
overflow: auto;
|
|
635
|
+
}
|
|
636
|
+
.tooltip-module_popover-tooltip__sAhKa[data-show] {
|
|
637
|
+
opacity: 1;
|
|
638
|
+
visibility: visible;
|
|
639
|
+
}
|
|
640
|
+
.tooltip-module_popover-tooltip__sAhKa[data-show=false] {
|
|
641
|
+
opacity: 0;
|
|
642
|
+
visibility: hidden;
|
|
643
|
+
}
|
|
644
|
+
.tooltip-module_popover-tooltip__sAhKa[data-popper-placement^=top] .tooltip-module_arrow__pqqOi {
|
|
645
|
+
bottom: -16px;
|
|
646
|
+
}
|
|
647
|
+
.tooltip-module_popover-tooltip__sAhKa[data-popper-placement^=top] .tooltip-module_arrow__pqqOi .tooltip-module_arrow-inner__IqzxY {
|
|
648
|
+
transform: rotate(0deg);
|
|
649
|
+
}
|
|
650
|
+
.tooltip-module_popover-tooltip__sAhKa[data-popper-placement^=bottom] .tooltip-module_arrow__pqqOi {
|
|
651
|
+
top: -16px;
|
|
652
|
+
}
|
|
653
|
+
.tooltip-module_popover-tooltip__sAhKa[data-popper-placement^=bottom] .tooltip-module_arrow__pqqOi .tooltip-module_arrow-inner__IqzxY {
|
|
654
|
+
transform: rotate(180deg);
|
|
655
|
+
}
|
|
656
|
+
.tooltip-module_popover-tooltip__sAhKa[data-popper-placement^=left] .tooltip-module_arrow__pqqOi {
|
|
657
|
+
right: -16px;
|
|
658
|
+
}
|
|
659
|
+
.tooltip-module_popover-tooltip__sAhKa[data-popper-placement^=left] .tooltip-module_arrow__pqqOi .tooltip-module_arrow-inner__IqzxY {
|
|
660
|
+
transform: rotate(-90deg);
|
|
661
|
+
}
|
|
662
|
+
.tooltip-module_popover-tooltip__sAhKa[data-popper-placement^=right] .tooltip-module_arrow__pqqOi {
|
|
663
|
+
left: -16px;
|
|
664
|
+
}
|
|
665
|
+
.tooltip-module_popover-tooltip__sAhKa[data-popper-placement^=right] .tooltip-module_arrow__pqqOi .tooltip-module_arrow-inner__IqzxY {
|
|
666
|
+
transform: rotate(90deg);
|
|
667
|
+
}
|
|
668
|
+
.tooltip-module_popover-tooltip__sAhKa .tooltip-module_arrow__pqqOi {
|
|
669
|
+
position: absolute;
|
|
670
|
+
}
|
|
671
|
+
.tooltip-module_popover-tooltip__sAhKa .tooltip-module_arrow__pqqOi .tooltip-module_arrow-inner__IqzxY {
|
|
672
|
+
content: "";
|
|
673
|
+
border-width: 8px;
|
|
674
|
+
border-style: solid;
|
|
675
|
+
border-color: #1B1D1D transparent transparent transparent;
|
|
676
|
+
}
|
|
677
|
+
|
|
678
|
+
.tooltip-module_close-button__o8OBN {
|
|
679
|
+
cursor: pointer;
|
|
680
|
+
line-height: 1px;
|
|
681
|
+
background-color: rgba(255, 255, 255, 0);
|
|
682
|
+
}
|
|
683
|
+
.tooltip-module_close-button__o8OBN .icon-base {
|
|
684
|
+
background-color: #FDDA0D;
|
|
685
|
+
width: 9px !important;
|
|
686
|
+
height: 9px !important;
|
|
687
|
+
line-height: 1px !important;
|
|
688
|
+
}
|
|
689
|
+
.tooltip-module_close-button__o8OBN:hover .icon-base {
|
|
690
|
+
background-color: #FFEA00;
|
|
691
|
+
}
|
|
692
|
+
|
|
693
|
+
.cui-theme-dark .tooltip-module_popover-tooltip__sAhKa {
|
|
694
|
+
background-color: #1B1D1D;
|
|
695
|
+
color: #F4F4F4;
|
|
696
|
+
}
|
|
697
|
+
.cui-theme-dark .tooltip-module_popover-tooltip__sAhKa .tooltip-module_arrow-inner__IqzxY {
|
|
698
|
+
border-color: #1B1D1D transparent transparent transparent;
|
|
699
|
+
}
|
|
700
|
+
.cui-theme-light {
|
|
701
|
+
color: #1B1D1D;
|
|
702
|
+
}
|
|
703
|
+
.cui-theme-light .tooltip-module_popover-tooltip__sAhKa {
|
|
704
|
+
background-color: #515757;
|
|
705
|
+
}
|
|
706
|
+
.cui-theme-light .tooltip-module_popover-tooltip__sAhKa .tooltip-module_arrow-inner__IqzxY {
|
|
707
|
+
border-color: #515757 transparent transparent transparent;
|
|
708
|
+
}
|
|
709
709
|
.popup-overlay-module_popup-modal-overlay__dlJqM {
|
|
710
710
|
z-index: 1;
|
|
711
711
|
position: fixed;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../../../../../../src/core/utils/appState/peregrineMQ/index.ts"],"sourcesContent":["import { PeregrineMQ } from './peregrineMQ'\n\nexport { PeregrineMQ, PeregrineMQClearError } from './peregrineMQ'\n\nexport const peregrineMQInstance = new PeregrineMQ()\n\nexport
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../../../../../../src/core/utils/appState/peregrineMQ/index.ts"],"sourcesContent":["import { PeregrineMQ } from './peregrineMQ'\n\nexport { PeregrineMQ, PeregrineMQClearError } from './peregrineMQ'\n\nexport const peregrineMQInstance = new PeregrineMQ()\n\nexport * from './peregrineMQ.types'\nexport * from './usePeregrineMQ.react'\n"],"names":["peregrineMQInstance","PeregrineMQ"],"mappings":"qDAIaA,EAAsB,IAAIC,EAAWA"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";var e=require("../../../../../node_modules/uuid/dist/esm-browser/v4.js");class
|
|
1
|
+
"use strict";var e=require("./peregrineMQ.types.js"),t=require("../../../../../node_modules/uuid/dist/esm-browser/v4.js");class s extends Error{constructor(){super("Clearing PeregrineMQ is not allowed. Please read the documentation for more information."),this.name="PeregrineMQClearError"}}exports.PeregrineMQ=class{constructor(n,r){this.id=void 0,this.config={allowAutoPrune:!1,pruneInterval:1e4,allowClear:!1},this.channels=new Map,this.listeners=new Map,this.addListener=(e,t)=>{const s=this.listeners.get(e),n=this.channels.get(t);n&&(s?s.push(n):this.listeners.set(e,[n]))},this.removeListener=e=>{const t=this.listeners.get(e);let s=!0;for(const n of t||[])if(s=!n.has(e),!s)break;s&&this.listeners.delete(e)},this.publishToChannel=(t,s,n)=>{const r=this.channels.get(t);if(!r)return e.NON_EXISTENT_CHANNEL;const i=r[Symbol.iterator]();let l=i.next().value;const h=[];for(;l;)h.push(l(t,n)),l=i.next().value;return 1===h?.length?h[0]:h},this.configure=e=>{this.config=e;const{allowAutoPrune:t,pruneInterval:s}=e;let n;t&&(n=setInterval((()=>{this.prune()}),s));const r=this;return{...t?{clearPruneInterval:()=>{clearInterval(n)},restartPruneInterval:()=>{clearInterval(n),n=setInterval((()=>{r.prune()}),s)}}:{}}},this.getChannels=()=>[...this.channels.keys()],this.prune=()=>{const e=this.channels[Symbol.iterator]();let t=e.next().value;const s=[];for(;t;)0===t[1]?.size&&(s.push(t[0]),this.channels.delete(t[0])),t=e.next().value;return s},this.removeChannel=e=>{const t=this.channels.get(e);if(t&&t.size>0){const e=[...t||[]];t.clear();let s=e.length;for(;s--;)this.removeListener(e[s])}return this.channels.delete(e)},this.publish=(e,t)=>{if(e.includes(".")){const s=e.split(".");let{length:n}=s,r=0;const i=[];for(;n--;){const e=this.publishToChannel(s.slice(0,r+1).join("."),n!==s.length-1,t);r+=1,i.push(e)}return i}return this.publishToChannel(e,!1,t)},this.subscribe=(e,t)=>{const s=this.channels.get(e);return s?s.add(t):this.channels.set(e,new Set([t])),this.addListener(t,e),()=>this.unsubscribe(t,{channel:e,prune:!0})},this.unsubscribe=(e,t)=>{const{channel:s,prune:n}=t||{};let r=!1;if(s){const t=this.channels.get(s);return r=!!t&&t.delete(e),n&&0===t?.size&&this.channels.delete(s),this.removeListener(e),r}const i=this.listeners.get(e)||[];for(const t of i)r=t.delete(e),n&&0===t.size&&this.prune();return this.listeners.delete(e),r},this.isSubscribed=(e,t)=>{if(t){const s=this.channels.get(t);return!!s&&s.has(e)}return this.listeners.has(e)},this.clear=()=>{if(!this.config.allowClear)throw new s;this.channels.clear(),this.listeners.clear()},this.getId=()=>this.id,this.id=n||t(),this.configure(r||{})}get length(){return[...this.channels.values()].reduce(((e,t)=>e+t.size),0)}},exports.PeregrineMQClearError=s;
|
|
2
2
|
//# sourceMappingURL=peregrineMQ.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"peregrineMQ.js","sources":["../../../../../../../src/core/utils/appState/peregrineMQ/peregrineMQ.ts"],"sourcesContent":["import { v4 as uuidv4 } from 'uuid'\n\nimport { Callback, Config, PeregrineMQApi, SubscribersSet, UnsubscribeOptions } from './peregrineMQ.types'\n\n\nexport class PeregrineMQClearError extends Error {\n constructor() {\n super('Clearing PeregrineMQ is not allowed. Please read the documentation for more information.')\n this.name = 'PeregrineMQClearError'\n }\n}\n\n/**\n * Represents a message queue with publish/subscribe functionality.\n */\nexport class PeregrineMQ implements PeregrineMQApi {\n private id: string\n\n private config: Config = {\n allowAutoPrune: false,\n pruneInterval: 10000,\n allowClear: false,\n }\n\n /**\n * The map of channels and their subscribers sets.\n */\n private channels: Map<string, SubscribersSet> = new Map()\n\n /**\n * The map of listeners and their subscribed channels.\n */\n private listeners: Map<Callback, SubscribersSet[]> = new Map()\n\n /**\n * Adds a callback as a listener to a channel.\n * @param callback The callback function to add as a listener.\n * @param channel The channel to add the listener to.\n */\n private addListener = (callback: Callback, channel: string): void => {\n const listener = this.listeners.get(callback)\n const subscribersSet = this.channels.get(channel)\n\n if (subscribersSet) {\n if (listener) {\n listener.push(subscribersSet)\n } else {\n this.listeners.set(callback, [subscribersSet])\n }\n }\n }\n\n /**\n * Removes the callback from the listeners collection if it is not subscribed to any channels.\n * @description Removes the callback only when it is not present in any other subscriberSet\n * (Ref to Map<string, SubscribersSet>).\n * @param callback The callback to remove from listeners.\n */\n private removeListener = (callback: Callback): void => {\n const channelSubscriberSets = this.listeners.get(callback)\n let isEmpty = true\n\n // eslint-disable-next-line no-restricted-syntax\n for (const channelSubscriberSet of channelSubscriberSets || []) {\n isEmpty = !channelSubscriberSet.has(callback)\n if (!isEmpty) {\n break\n }\n }\n\n if (isEmpty) {\n this.listeners.delete(callback)\n }\n }\n\n /**\n * Publishes data to a channel.\n * @param channel The channel to publish the data to.\n * @param isParent Indicates if the channel is a parent channel.\n * @param data The data to publish.\n * @returns A boolean indicating if the publication was successful.\n */\n private publishToChannel = (channel: string, isParent: boolean, data?: unknown): boolean => {\n const subscribersSet = this.channels.get(channel)\n\n if (!subscribersSet) {\n return isParent\n }\n\n const iterator = subscribersSet[Symbol.iterator]()\n let subscriberFunc = iterator.next().value\n\n // eslint-disable-next-line no-plusplus\n while (subscriberFunc) {\n subscriberFunc(channel, data)\n subscriberFunc = iterator.next().value\n }\n return true\n }\n\n /**\n * Creates a new instance of PeregrineMQ.\n * @param id Specific instance of PeregrineMQ identifier\n * @param config The configuration options for PeregrineMQ.\n */\n constructor(id?: string, config?: Config) {\n this.id = id || uuidv4()\n this.configure(config || {})\n }\n\n /**\n * Gets the total number of subscribers across all channels.\n */\n get length(): number {\n return [...this.channels.values()].reduce((acc, subscribersList) => acc + subscribersList.size, 0)\n }\n\n /**\n * Configures PeregrineMQ with the specified options.\n * @param config The configuration options for PeregrineMQ.\n * @returns An object containing the prune interval handler (if auto prune is enabled).\n */\n configure = (config: Config): {\n clearPruneInterval?: () => void\n restartPruneInterval?: () => void\n } => {\n this.config = config\n const { allowAutoPrune, pruneInterval } = config\n\n let pruneIntervalHandler: ReturnType<typeof setInterval>\n\n if (allowAutoPrune) {\n pruneIntervalHandler = setInterval(() => {\n this.prune()\n }, pruneInterval)\n }\n\n // eslint-disable-next-line @typescript-eslint/no-this-alias\n const instance: PeregrineMQ = this\n\n return {\n ...(allowAutoPrune\n ? {\n clearPruneInterval: (): void => {\n clearInterval(pruneIntervalHandler)\n },\n restartPruneInterval: (): void => {\n clearInterval(pruneIntervalHandler)\n pruneIntervalHandler = setInterval(() => {\n instance.prune()\n }, pruneInterval)\n },\n }\n : {}),\n }\n }\n\n /**\n * Gets an array of all channels.\n * @returns An array of channel names.\n */\n getChannels = (): string[] => [...this.channels.keys()]\n\n /**\n * Prunes the channels with no subscribers.\n * @returns An array of pruned channel names.\n */\n prune = (): string[] => {\n const iterator = this.channels[Symbol.iterator]()\n let subscribersSet = iterator.next().value\n const prunedChannels: string[] = []\n\n // eslint-disable-next-line no-plusplus\n while (subscribersSet) {\n if (subscribersSet[1]?.size === 0) {\n prunedChannels.push(subscribersSet[0])\n this.channels.delete(subscribersSet[0])\n }\n subscribersSet = iterator.next().value\n }\n\n return prunedChannels\n }\n\n /**\n * Removes a channel and its subscribers.\n * @param channel The channel to remove.\n * @returns A boolean indicating if the channel was successfully removed.\n */\n removeChannel = (channel: string): boolean => {\n const subscribersSet = this.channels.get(channel)\n\n if (subscribersSet && subscribersSet.size > 0) {\n const channelListeners = [...subscribersSet || []]\n\n subscribersSet.clear()\n\n let index = channelListeners.length\n\n // eslint-disable-next-line no-plusplus\n while (index--) {\n this.removeListener(channelListeners[index])\n }\n }\n\n return this.channels.delete(channel)\n }\n\n /**\n * Publishes data to a channel.\n * @param channel The channel to publish the data to.\n * @param data The data to publish.\n * @returns A boolean indicating if the publication was successful.\n */\n publish = <T>(channel: string, data?: T): boolean => {\n if (channel.includes('.')) {\n const nestedChannels = channel.split('.')\n\n let { length } = nestedChannels\n let failed = false\n\n // eslint-disable-next-line no-plusplus\n while (length--) {\n const result = this.publishToChannel(\n nestedChannels.slice(0, length + 1).join('.'),\n length !== nestedChannels.length - 1,\n data,\n )\n\n if (!result) {\n failed = true\n }\n }\n return !failed\n }\n\n return this.publishToChannel(channel, false, data)\n }\n\n /**\n * Subscribes a callback to a channel.\n * @param channel The channel to subscribe to.\n * @param callback The callback function to subscribe.\n * @returns A function to unsubscribe the callback.\n */\n subscribe = (channel: string, callback: Callback): () => boolean => {\n const subscribersList = this.channels.get(channel)\n\n if (subscribersList) {\n subscribersList.add(callback)\n } else {\n this.channels.set(channel, new Set([callback]))\n }\n\n this.addListener(callback, channel)\n\n return () => this.unsubscribe(callback, { channel, prune: true })\n }\n\n /**\n * Unsubscribes a callback from a channel or all channels.\n * @param callback The callback function to unsubscribe.\n * @param options Optional unsubscribe options.\n * @returns A boolean indicating if the callback was successfully unsubscribed.\n */\n unsubscribe = (callback: Callback, options?: UnsubscribeOptions): boolean => {\n const { channel, prune } = options || {}\n\n let unsubscribed = false\n\n if (channel) {\n const subscriberSet = this.channels.get(channel)\n\n unsubscribed = subscriberSet ? subscriberSet.delete(callback) : false\n if (prune && subscriberSet?.size === 0) {\n this.channels.delete(channel)\n }\n\n this.removeListener(callback)\n\n return unsubscribed\n }\n\n const subscriberSetArray = this.listeners.get(callback) || []\n\n // remove callback form listeners and all channels\n // TODO remove only if has\n // eslint-disable-next-line no-restricted-syntax\n for (const subscriberSet of subscriberSetArray) {\n unsubscribed = subscriberSet.delete(callback) as boolean\n\n if (prune && subscriberSet.size === 0) {\n this.prune()\n }\n }\n\n this.listeners.delete(callback)\n\n return unsubscribed\n }\n\n /**\n * Checks if a callback is subscribed to a specific channel or any channel.\n * @param callback The callback function to check.\n * @param channel Optional channel name to check subscription for.\n * @returns A boolean indicating if the callback is subscribed.\n */\n isSubscribed = (callback: Callback, channel?: string): boolean => {\n if (channel) {\n const subscribersList = this.channels.get(channel)\n\n return subscribersList ? subscribersList.has(callback) : false\n }\n\n return this.listeners.has(callback)\n }\n\n /**\n * Clears all channels and listeners.\n * @throws {Error} If clearing PeregrineMQ is not allowed.\n */\n clear = (): void => {\n if (this.config.allowClear) {\n this.channels.clear()\n this.listeners.clear()\n } else {\n throw new PeregrineMQClearError()\n }\n }\n\n /**\n * Returns the specific instance of PeregrineMQ.\n * @returns A string identifier of the specific instance of PeregrineMQ.\n */\n getId = (): string => this.id\n}\n"],"names":["PeregrineMQClearError","Error","constructor","super","this","name","id","config","allowAutoPrune","pruneInterval","allowClear","channels","Map","listeners","addListener","callback","channel","listener","get","subscribersSet","push","set","removeListener","channelSubscriberSets","isEmpty","channelSubscriberSet","has","delete","publishToChannel","isParent","data","iterator","Symbol","subscriberFunc","next","value","configure","pruneIntervalHandler","setInterval","prune","instance","clearPruneInterval","clearInterval","restartPruneInterval","getChannels","keys","prunedChannels","size","removeChannel","channelListeners","clear","index","length","publish","includes","nestedChannels","split","failed","slice","join","subscribe","subscribersList","add","Set","unsubscribe","options","unsubscribed","subscriberSet","subscriberSetArray","isSubscribed","getId","uuidv4","values","reduce","acc"],"mappings":"sFAKO,MAAMA,UAA8BC,MACzCC,WAAAA,GACEC,MAAM,4FACNC,KAAKC,KAAO,uBACd,sBAMK,MA0FLH,WAAAA,CAAYI,EAAaC,GAAiBH,KAzFlCE,QAAE,EAAAF,KAEFG,OAAiB,CACvBC,gBAAgB,EAChBC,cAAe,IACfC,YAAY,GAGdN,KAGQO,SAAwC,IAAIC,IAEpDR,KAGQS,UAA6C,IAAID,IAEzDR,KAKQU,YAAc,CAACC,EAAoBC,KACzC,MAAMC,EAAWb,KAAKS,UAAUK,IAAIH,GAC9BI,EAAiBf,KAAKO,SAASO,IAAIF,GAErCG,IACEF,EACFA,EAASG,KAAKD,GAEdf,KAAKS,UAAUQ,IAAIN,EAAU,CAACI,IAElC,EAGFf,KAMQkB,eAAkBP,IACxB,MAAMQ,EAAwBnB,KAAKS,UAAUK,IAAIH,GACjD,IAAIS,GAAU,EAGd,IAAK,MAAMC,KAAwBF,GAAyB,GAE1D,GADAC,GAAWC,EAAqBC,IAAIX,IAC/BS,EACH,MAIAA,GACFpB,KAAKS,UAAUc,OAAOZ,EACxB,EAGFX,KAOQwB,iBAAmB,CAACZ,EAAiBa,EAAmBC,KAC9D,MAAMX,EAAiBf,KAAKO,SAASO,IAAIF,GAEzC,IAAKG,EACH,OAAOU,EAGT,MAAME,EAAWZ,EAAea,OAAOD,YACvC,IAAIE,EAAiBF,EAASG,OAAOC,MAGrC,KAAOF,GACLA,EAAejB,EAASc,GACxBG,EAAiBF,EAASG,OAAOC,MAEnC,OAAO,CAAI,EAoBb/B,KAKAgC,UAAa7B,IAIXH,KAAKG,OAASA,EACd,MAAMC,eAAEA,EAAcC,cAAEA,GAAkBF,EAE1C,IAAI8B,EAEA7B,IACF6B,EAAuBC,aAAY,KACjClC,KAAKmC,OAAO,GACX9B,IAIL,MAAM+B,EAAwBpC,KAE9B,MAAO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IAAoBa,EAAMb,EAAgBd,MAAM,EAClG"}
|
|
1
|
+
{"version":3,"file":"peregrineMQ.js","sources":["../../../../../../../src/core/utils/appState/peregrineMQ/peregrineMQ.ts"],"sourcesContent":["import { v4 as uuidv4 } from 'uuid'\n\nimport {\n Callback, Config, PeregrineMQApi, PublishToChannelReturnType,\n PublishReturnType, SubscribersSet,\n UnsubscribeOptions, NON_EXISTENT_CHANNEL_TYPE,\n NON_EXISTENT_CHANNEL,\n} from './peregrineMQ.types'\n\n\nexport class PeregrineMQClearError extends Error {\n constructor() {\n super('Clearing PeregrineMQ is not allowed. Please read the documentation for more information.')\n this.name = 'PeregrineMQClearError'\n }\n}\n\n/**\n * Represents a message queue with publish/subscribe functionality.\n */\nexport class PeregrineMQ implements PeregrineMQApi {\n private id: string\n\n private config: Config = {\n allowAutoPrune: false,\n pruneInterval: 10000,\n allowClear: false,\n }\n\n /**\n * The map of channels and their subscribers sets.\n */\n private channels: Map<string, SubscribersSet> = new Map()\n\n /**\n * The map of listeners and their subscribed channels.\n */\n private listeners: Map<Callback, SubscribersSet[]> = new Map()\n\n /**\n * Adds a callback as a listener to a channel.\n * @param callback The callback function to add as a listener.\n * @param channel The channel to add the listener to.\n */\n private addListener = (callback: Callback, channel: string): void => {\n const listener = this.listeners.get(callback)\n const subscribersSet = this.channels.get(channel)\n\n if (subscribersSet) {\n if (listener) {\n listener.push(subscribersSet)\n } else {\n this.listeners.set(callback, [subscribersSet])\n }\n }\n }\n\n /**\n * Removes the callback from the listeners collection if it is not subscribed to any channels.\n * @description Removes the callback only when it is not present in any other subscriberSet\n * (Ref to Map<string, SubscribersSet>).\n * @param callback The callback to remove from listeners.\n */\n private removeListener = (callback: Callback): void => {\n const channelSubscriberSets = this.listeners.get(callback)\n let isEmpty = true\n\n // eslint-disable-next-line no-restricted-syntax\n for (const channelSubscriberSet of channelSubscriberSets || []) {\n isEmpty = !channelSubscriberSet.has(callback)\n if (!isEmpty) {\n break\n }\n }\n\n if (isEmpty) {\n this.listeners.delete(callback)\n }\n }\n\n /**\n * Publishes data to a channel.\n * @param channel The channel to publish the data to.\n * @param isParent Indicates if the channel is a parent channel.\n * @param data The data to publish.\n * @returns A boolean indicating if the publication was successful.\n */\n private publishToChannel = (\n channel: string, isParent: boolean, data?: unknown,\n ): PublishToChannelReturnType => {\n const subscribersSet = this.channels.get(channel)\n\n if (!subscribersSet) {\n return NON_EXISTENT_CHANNEL as NON_EXISTENT_CHANNEL_TYPE\n }\n\n const iterator = subscribersSet[Symbol.iterator]()\n let subscriberFunc = iterator.next().value\n\n const results = []\n\n // eslint-disable-next-line no-plusplus\n while (subscriberFunc) {\n // eslint-disable-next-line no-await-in-loop\n results.push(subscriberFunc(channel, data))\n subscriberFunc = iterator.next().value\n }\n return results?.length === 1 ? results[0] : results\n }\n\n /**\n * Creates a new instance of PeregrineMQ.\n * @param id Specific instance of PeregrineMQ identifier\n * @param config The configuration options for PeregrineMQ.\n */\n constructor(id?: string, config?: Config) {\n this.id = id || uuidv4()\n this.configure(config || {})\n }\n\n /**\n * Gets the total number of subscribers across all channels.\n */\n get length(): number {\n return [...this.channels.values()].reduce((acc, subscribersList) => acc + subscribersList.size, 0)\n }\n\n /**\n * Configures PeregrineMQ with the specified options.\n * @param config The configuration options for PeregrineMQ.\n * @returns An object containing the prune interval handler (if auto prune is enabled).\n */\n configure = (config: Config): {\n clearPruneInterval?: () => void\n restartPruneInterval?: () => void\n } => {\n this.config = config\n const { allowAutoPrune, pruneInterval } = config\n\n let pruneIntervalHandler: ReturnType<typeof setInterval>\n\n if (allowAutoPrune) {\n pruneIntervalHandler = setInterval(() => {\n this.prune()\n }, pruneInterval)\n }\n\n // eslint-disable-next-line @typescript-eslint/no-this-alias\n const instance: PeregrineMQ = this\n\n return {\n ...(allowAutoPrune\n ? {\n clearPruneInterval: (): void => {\n clearInterval(pruneIntervalHandler)\n },\n restartPruneInterval: (): void => {\n clearInterval(pruneIntervalHandler)\n pruneIntervalHandler = setInterval(() => {\n instance.prune()\n }, pruneInterval)\n },\n }\n : {}),\n }\n }\n\n /**\n * Gets an array of all channels.\n * @returns An array of channel names.\n */\n getChannels = (): string[] => [...this.channels.keys()]\n\n /**\n * Prunes the channels with no subscribers.\n * @returns An array of pruned channel names.\n */\n prune = (): string[] => {\n const iterator = this.channels[Symbol.iterator]()\n let subscribersSet = iterator.next().value\n const prunedChannels: string[] = []\n\n // eslint-disable-next-line no-plusplus\n while (subscribersSet) {\n if (subscribersSet[1]?.size === 0) {\n prunedChannels.push(subscribersSet[0])\n this.channels.delete(subscribersSet[0])\n }\n subscribersSet = iterator.next().value\n }\n\n return prunedChannels\n }\n\n /**\n * Removes a channel and its subscribers.\n * @param channel The channel to remove.\n * @returns A boolean indicating if the channel was successfully removed.\n */\n removeChannel = (channel: string): boolean => {\n const subscribersSet = this.channels.get(channel)\n\n if (subscribersSet && subscribersSet.size > 0) {\n const channelListeners = [...subscribersSet || []]\n\n subscribersSet.clear()\n\n let index = channelListeners.length\n\n // eslint-disable-next-line no-plusplus\n while (index--) {\n this.removeListener(channelListeners[index])\n }\n }\n\n return this.channels.delete(channel)\n }\n\n /**\n * Publishes data to a channel.\n * @param channel The channel to publish the data to.\n * @param data The data to publish.\n * @returns A boolean indicating if the publication was successful.\n */\n publish = <T>(channel: string, data?: T): PublishReturnType => {\n if (channel.includes('.')) {\n const nestedChannels = channel.split('.')\n\n let { length } = nestedChannels\n let it = 0\n const results = []\n\n // eslint-disable-next-line no-plusplus\n while (length--) {\n // eslint-disable-next-line no-await-in-loop\n const result = this.publishToChannel(\n nestedChannels.slice(0, it + 1).join('.'),\n length !== nestedChannels.length - 1,\n data,\n )\n\n it += 1\n results.push(result)\n }\n return results\n }\n\n return this.publishToChannel(channel, false, data)\n }\n\n /**\n * Subscribes a callback to a channel.\n * @param channel The channel to subscribe to.\n * @param callback The callback function to subscribe.\n * @returns A function to unsubscribe the callback.\n */\n subscribe = (channel: string, callback: Callback): () => boolean => {\n const subscribersList = this.channels.get(channel)\n\n if (subscribersList) {\n subscribersList.add(callback)\n } else {\n this.channels.set(channel, new Set([callback]))\n }\n\n this.addListener(callback, channel)\n\n return () => this.unsubscribe(callback, { channel, prune: true })\n }\n\n /**\n * Unsubscribes a callback from a channel or all channels.\n * @param callback The callback function to unsubscribe.\n * @param options Optional unsubscribe options.\n * @returns A boolean indicating if the callback was successfully unsubscribed.\n */\n unsubscribe = (callback: Callback, options?: UnsubscribeOptions): boolean => {\n const { channel, prune } = options || {}\n\n let unsubscribed = false\n\n if (channel) {\n const subscriberSet = this.channels.get(channel)\n\n unsubscribed = subscriberSet ? subscriberSet.delete(callback) : false\n if (prune && subscriberSet?.size === 0) {\n this.channels.delete(channel)\n }\n\n this.removeListener(callback)\n\n return unsubscribed\n }\n\n const subscriberSetArray = this.listeners.get(callback) || []\n\n // remove callback form listeners and all channels\n // TODO remove only if has\n // eslint-disable-next-line no-restricted-syntax\n for (const subscriberSet of subscriberSetArray) {\n unsubscribed = subscriberSet.delete(callback) as boolean\n\n if (prune && subscriberSet.size === 0) {\n this.prune()\n }\n }\n\n this.listeners.delete(callback)\n\n return unsubscribed\n }\n\n /**\n * Checks if a callback is subscribed to a specific channel or any channel.\n * @param callback The callback function to check.\n * @param channel Optional channel name to check subscription for.\n * @returns A boolean indicating if the callback is subscribed.\n */\n isSubscribed = (callback: Callback, channel?: string): boolean => {\n if (channel) {\n const subscribersList = this.channels.get(channel)\n\n return subscribersList ? subscribersList.has(callback) : false\n }\n\n return this.listeners.has(callback)\n }\n\n /**\n * Clears all channels and listeners.\n * @throws {Error} If clearing PeregrineMQ is not allowed.\n */\n clear = (): void => {\n if (this.config.allowClear) {\n this.channels.clear()\n this.listeners.clear()\n } else {\n throw new PeregrineMQClearError()\n }\n }\n\n /**\n * Returns the specific instance of PeregrineMQ.\n * @returns A string identifier of the specific instance of PeregrineMQ.\n */\n getId = (): string => this.id\n}\n"],"names":["PeregrineMQClearError","Error","constructor","super","this","name","id","config","allowAutoPrune","pruneInterval","allowClear","channels","Map","listeners","addListener","callback","channel","listener","get","subscribersSet","push","set","removeListener","channelSubscriberSets","isEmpty","channelSubscriberSet","has","delete","publishToChannel","isParent","data","NON_EXISTENT_CHANNEL","iterator","Symbol","subscriberFunc","next","value","results","length","configure","pruneIntervalHandler","setInterval","prune","instance","clearPruneInterval","clearInterval","restartPruneInterval","getChannels","keys","prunedChannels","size","removeChannel","channelListeners","clear","index","publish","includes","nestedChannels","split","it","result","slice","join","subscribe","subscribersList","add","Set","unsubscribe","options","unsubscribed","subscriberSet","subscriberSetArray","isSubscribed","getId","uuidv4","values","reduce","acc"],"mappings":"0HAUO,MAAMA,UAA8BC,MACzCC,WAAAA,GACEC,MAAM,4FACNC,KAAKC,KAAO,uBACd,sBAMK,MA+FLH,WAAAA,CAAYI,EAAaC,GAAiBH,KA9FlCE,QAAE,EAAAF,KAEFG,OAAiB,CACvBC,gBAAgB,EAChBC,cAAe,IACfC,YAAY,GAGdN,KAGQO,SAAwC,IAAIC,IAEpDR,KAGQS,UAA6C,IAAID,IAEzDR,KAKQU,YAAc,CAACC,EAAoBC,KACzC,MAAMC,EAAWb,KAAKS,UAAUK,IAAIH,GAC9BI,EAAiBf,KAAKO,SAASO,IAAIF,GAErCG,IACEF,EACFA,EAASG,KAAKD,GAEdf,KAAKS,UAAUQ,IAAIN,EAAU,CAACI,IAElC,EAGFf,KAMQkB,eAAkBP,IACxB,MAAMQ,EAAwBnB,KAAKS,UAAUK,IAAIH,GACjD,IAAIS,GAAU,EAGd,IAAK,MAAMC,KAAwBF,GAAyB,GAE1D,GADAC,GAAWC,EAAqBC,IAAIX,IAC/BS,EACH,MAIAA,GACFpB,KAAKS,UAAUc,OAAOZ,EACxB,EAGFX,KAOQwB,iBAAmB,CACzBZ,EAAiBa,EAAmBC,KAEpC,MAAMX,EAAiBf,KAAKO,SAASO,IAAIF,GAEzC,IAAKG,EACH,OAAOY,uBAGT,MAAMC,EAAWb,EAAec,OAAOD,YACvC,IAAIE,EAAiBF,EAASG,OAAOC,M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,SAASO,IAAIF,GAE1C,QAAOgD,GAAkBA,EAAgBtC,IAAIX,EAC/C,CAEA,OAAOX,KAAKS,UAAUa,IAAIX,EAAS,EAGrCX,KAIAiD,MAAQ,KACN,IAAIjD,KAAKG,OAAOG,WAId,MAAM,IAAIV,EAHVI,KAAKO,SAAS0C,QACdjD,KAAKS,UAAUwC,OAGjB,EAGFjD,KAIAqE,MAAQ,IAAcrE,KAAKE,GArOzBF,KAAKE,GAAKA,GAAMoE,IAChBtE,KAAKmC,UAAUhC,GAAU,CAAA,EAC3B,CAKA,UAAI+B,GACF,MAAO,IAAIlC,KAAKO,SAASgE,UAAUC,QAAO,CAACC,EAAKb,IAAoBa,EAAMb,EAAgBd,MAAM,EAClG"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"peregrineMQ.types.js","sources":["../../../../../../../src/core/utils/appState/peregrineMQ/peregrineMQ.types.ts"],"sourcesContent":["export type CallbackPayload = string | number | Record<any, any>;\nexport type Callback = (message: string, data?: CallbackPayload) => void;\n\nexport type SubscribersSet = Set<Callback>;\n\nexport interface Config {\n /**\n * If true, enables automatic removal of channels without subscribers.\n */\n allowAutoPrune?: boolean\n\n /**\n * The interval, in milliseconds, for checking channels with no subscribers.\n */\n pruneInterval?: number\n\n /**\n * If true, allows the use of the clear method to remove all channels and listeners.\n */\n allowClear?: boolean\n}\n\nexport interface UnsubscribeOptions {\n /**\n * The channel to unsubscribe from.\n */\n channel?: string\n\n /**\n * If true, removes the channel from the collection when the last subscriber is removed.\n */\n prune?: boolean\n}\n\nexport interface PeregrineMQApi {\n /**\n * Sets the configuration options for a PeregrineMQ instance.\n *\n * @param {Config} config - An object containing configuration options for the instance.\n * @return {void}\n */\n configure: (config: Config) => void\n\n /**\n * Retrieves a list of all channels and their subscribers.\n *\n * @return { string[] }\n */\n getChannels: () => string[]\n\n /**\n * Removes all channels that have no subscribers.\n *\n * @return {void}\n */\n prune: () => void\n\n /**\n * Removes a specified channel from the collection.\n *\n * @param {string} channel - The name of the channel to remove.\n * @return {boolean} - Returns true if the channel was successfully removed, otherwise false.\n */\n removeChannel: (channel: string) => boolean\n\n /**\n * Publishes a message to a specified channel, passing the data to its subscribers.\n *\n * @param {string} channel - The channel to publish the message to.\n * @param {unknown} [data] - The data to pass to subscribers.\n * @return {boolean} - Returns true if the message was successfully published, otherwise false.\n */\n publish: (channel: string, data?: unknown) => PublishReturnType\n\n /**\n * Subscribes a function to a specified channel.\n * The returned unsubscribe function is unique and should be stored for later use.\n *\n * @param {string} channel - The channel name to subscribe to.\n * @param {Callback} callback - The function to call when a new message is published.\n * @return {() => boolean} - The unsubscribe function.\n */\n subscribe: (channel: string, callback: Callback) => () => boolean\n\n /**\n * Unsubscribes a callback from a channel.\n * Returns true if the callback was successfully unsubscribed, otherwise false.\n *\n * @param {Callback} callback - The callback to unsubscribe.\n * @param {UnsubscribeOptions} [options] - Options for unsubscribing, including the channel.\n * @return {boolean} - Returns true if the callback was successfully unsubscribed, otherwise false.\n */\n unsubscribe: (callback: Callback, options?: UnsubscribeOptions) => boolean\n\n /**\n * Checks if a specified callback is subscribed to a specified channel (or any channel if not specified).\n *\n * @param {Callback} callback - The callback to check for subscription.\n * @param {string} [channel] - The channel to check for subscription. If not specified, all channels will be checked.\n * @return {boolean} - Returns true if the callback is subscribed, otherwise false.\n */\n isSubscribed: (callback: Callback, channel?: string) => boolean\n\n /**\n * Removes all channels and subscribers from the collection.\n *\n * @function\n * @alias clear\n */\n clear: () => void\n\n /**\n * Retrieves the identifier for the specific instance of PeregrineMQ.\n *\n * @return {string} - A string identifier for the specific instance.\n */\n getId: () => string\n}\nexport const NON_EXISTENT_CHANNEL = 'NON_EXISTENT_CHANNEL'\n\nexport type NON_EXISTENT_CHANNEL_TYPE = typeof NON_EXISTENT_CHANNEL\n\nexport type PublishToChannelReturnType = NON_EXISTENT_CHANNEL_TYPE\n | undefined | boolean | unknown | Array<undefined | boolean | unknown>\n\nexport type PublishReturnType = PublishToChannelReturnType | PublishToChannelReturnType[]\n"],"names":[],"mappings":"0CAsHoC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"usePeregrineMQ.react.js","sources":["../../../../../../../src/core/utils/appState/peregrineMQ/usePeregrineMQ.react.ts"],"sourcesContent":["import { useCallback, useEffect, useRef } from 'react'\n\nimport { PeregrineMQ } from './peregrineMQ'\nimport { Callback } from './peregrineMQ.types'\n\nexport type usePeregrineMQReturnType = [\n (() => boolean) | undefined,\n <T>(channel: string, data?: T) =>
|
|
1
|
+
{"version":3,"file":"usePeregrineMQ.react.js","sources":["../../../../../../../src/core/utils/appState/peregrineMQ/usePeregrineMQ.react.ts"],"sourcesContent":["import { useCallback, useEffect, useRef } from 'react'\n\nimport { PeregrineMQ } from './peregrineMQ'\nimport { Callback, PublishReturnType } from './peregrineMQ.types'\n\nexport type usePeregrineMQReturnType = [\n (() => boolean) | undefined,\n <T>(channel: string, data?: T) => PublishReturnType\n]\n\nexport const usePeregrineMQ = (\n peregrineInstance: PeregrineMQ, channel: string, callback: Callback,\n): usePeregrineMQReturnType => {\n const memCallback = useCallback(callback, [callback])\n\n const unsubscribeRef = useRef<ReturnType<typeof peregrineInstance.subscribe>>()\n\n useEffect(() => {\n unsubscribeRef.current = peregrineInstance.subscribe(channel, memCallback)\n\n return (): void => {\n unsubscribeRef?.current?.()\n }\n }, [memCallback, channel, peregrineInstance])\n\n return [unsubscribeRef.current, peregrineInstance.publish]\n}\n"],"names":["usePeregrineMQ","peregrineInstance","channel","callback","memCallback","useCallback","unsubscribeRef","useRef","useEffect","current","subscribe","publish"],"mappings":"2DAU8BA,CAC5BC,EAAgCC,EAAiBC,KAEjD,MAAMC,EAAcC,EAAWA,YAACF,EAAU,CAACA,IAErCG,EAAiBC,EAAAA,SAUvB,OARAC,EAAAA,WAAU,KACRF,EAAeG,QAAUR,EAAkBS,UAAUR,EAASE,GAEvD,KACLE,GAAgBG,WAAW,IAE5B,CAACL,EAAaF,EAASD,IAEnB,CAACK,EAAeG,QAASR,EAAkBU,QAAQ"}
|