@scbt-ecom/ui 0.127.0 → 0.127.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
var
|
|
1
|
+
var l=Object.defineProperty;var o=(a,t,e)=>t in a?l(a,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):a[t]=e;var s=(a,t,e)=>o(a,typeof t!="symbol"?t+"":t,e);import{localStorageActions as h}from"../localStorageActions.js";class _{constructor(){s(this,"_store",new Map)}clearItems(...t){for(const e of t)this._store.delete(e)}getItem(t){return this._store.get(t)??null}setItem(t,e){this._store.set(t,e)}}const i=class i{constructor(t){s(this,"_variables",[]);s(this,"_listeners",new Map);s(this,"_nextListenerId",0);s(this,"_storeContext");s(this,"get",t=>this._variables.find(e=>e._id===t));s(this,"append",t=>{this._variables.push(t),this.collect()});s(this,"clear",()=>{this._variables=[],this.collect()});s(this,"entriesOf",(...t)=>{const e=[];for(const r of this._variables)t.includes(r.key)&&e.push([r.key,r.value]);return e});s(this,"remove",t=>{this._variables=this._variables.filter(e=>e.key!==t),this.collect()});s(this,"replace",t=>(this._variables=t,this.collect()));s(this,"update",(t,e)=>{const r=this._variables.map(n=>n._id===t?e:n);return this.replace(r)});s(this,"observe",t=>{const e=Symbol(this._nextListenerId++);return this._listeners.set(e,t),()=>{this._listeners.delete(e)}});this._store=t,typeof window>"u"?this._storeContext=new _:this._storeContext=h,this._variables=this._storeContext.getItem(this._store)??[]}static unwrap(t){return t.replace(/\$\{|}/g,"")}static wrap(t){return this._VARIABLE_PATTERN.replace("variable",t)}static match(t){return t.match(this._VARIABLE_REGEX)}static getInstance(t){const e=i._instance.get(t);if(!e){const r=new i(t);return i._instance.set(t,r),r}return e}get variables(){return this._variables}collect(){return this._storeContext.setItem(this._store,this._variables),this._listeners.forEach(t=>t(this._variables)),this._variables}has(t){return this._variables.some(e=>e.key===t)}};s(i,"_VARIABLE_REGEX",/\$\{([^}]+)}/g),s(i,"_VARIABLE_PATTERN","${variable}"),s(i,"_instance",new Map);let c=i;export{c as VariableContextHolder};
|
|
2
2
|
//# sourceMappingURL=variableContextHolder.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"variableContextHolder.js","sources":["../../../../../lib/shared/utils/variableHolder/variableContextHolder.ts"],"sourcesContent":["import { localStorageActions } from '../localStorageActions'\n\nexport interface Variable<Key = string, Value = string> {\n _id: string\n key: Key\n value: Value\n createdAt: string\n updatedAt: string\n description: string\n}\n\nexport type VariableEntry<Key = string, Value = string> = [Key, Value]\n\nexport interface IVariableContextHolder<Key, Value> {\n variables: Variable<Key, Value>[]\n append: (variable: Variable<Key, Value>) => void\n remove: (key: Key) => void\n has: (key: Key) => boolean\n replace: (variables: Variable<Key, Value>[]) => void\n clear: () => void\n update: (id: string, variable: Variable<Key, Value>) => void\n entriesOf: (...keys: Key[]) => VariableEntry<Key, Value>[]\n observe: (listener: (variables: Variable<Key, Value>[]) => void) => () => void\n get: (key: Key) => Variable<Key, Value> | undefined\n}\n\n/**\n * Класс для управления переменными\n */\nexport class VariableContextHolder<Key extends string = string, Value = string> implements IVariableContextHolder<Key, Value> {\n private _variables: Variable<Key, Value>[] = []\n private _listeners = new Map<symbol, (variables: Variable<Key, Value>[]) => void>()\n private _nextListenerId: number = 0\n\n private static _VARIABLE_REGEX: RegExp = /\\$\\{([^}]+)}/g\n private static _VARIABLE_PATTERN: string = '${variable}'\n private static _instance = new Map<string, VariableContextHolder>()\n\n private constructor(private _store: string) {\n this.
|
|
1
|
+
{"version":3,"file":"variableContextHolder.js","sources":["../../../../../lib/shared/utils/variableHolder/variableContextHolder.ts"],"sourcesContent":["import { localStorageActions } from '../localStorageActions'\n\nexport interface Variable<Key = string, Value = string> {\n _id: string\n key: Key\n value: Value\n createdAt: string\n updatedAt: string\n description: string\n}\n\nexport type VariableEntry<Key = string, Value = string> = [Key, Value]\n\nexport interface IVariableContextHolder<Key, Value> {\n variables: Variable<Key, Value>[]\n append: (variable: Variable<Key, Value>) => void\n remove: (key: Key) => void\n has: (key: Key) => boolean\n replace: (variables: Variable<Key, Value>[]) => void\n clear: () => void\n update: (id: string, variable: Variable<Key, Value>) => void\n entriesOf: (...keys: Key[]) => VariableEntry<Key, Value>[]\n observe: (listener: (variables: Variable<Key, Value>[]) => void) => () => void\n get: (key: Key) => Variable<Key, Value> | undefined\n}\n\nexport interface VariableStore {\n setItem: <T>(key: string, value: T) => void\n getItem: <T>(key: string) => T | null\n clearItems: (...keys: string[]) => void\n}\n\nclass InMemoryVariableStore implements VariableStore {\n private _store = new Map<string, unknown>()\n\n constructor() {}\n\n clearItems(...keys: string[]): void {\n for (const key of keys) {\n this._store.delete(key)\n }\n }\n\n getItem<T>(key: string): T | null {\n return (this._store.get(key) as T) ?? null\n }\n\n setItem<T>(key: string, value: T): void {\n this._store.set(key, value)\n }\n}\n\n/**\n * Класс для управления переменными\n */\nexport class VariableContextHolder<Key extends string = string, Value = string> implements IVariableContextHolder<Key, Value> {\n private _variables: Variable<Key, Value>[] = []\n private _listeners = new Map<symbol, (variables: Variable<Key, Value>[]) => void>()\n private _nextListenerId: number = 0\n private _storeContext: VariableStore\n\n private static _VARIABLE_REGEX: RegExp = /\\$\\{([^}]+)}/g\n private static _VARIABLE_PATTERN: string = '${variable}'\n private static _instance = new Map<string, VariableContextHolder>()\n\n private constructor(private _store: string) {\n if (typeof window === 'undefined') {\n this._storeContext = new InMemoryVariableStore()\n } else {\n this._storeContext = localStorageActions\n }\n\n this._variables = this._storeContext.getItem<Variable<Key, Value>[]>(this._store) ?? []\n }\n\n static unwrap(variable: string): string {\n return variable.replace(/\\$\\{|}/g, '')\n }\n\n static wrap(variable: string): string {\n return this._VARIABLE_PATTERN.replace('variable', variable)\n }\n\n static match(pattern: string): string[] | null {\n return pattern.match(this._VARIABLE_REGEX) as string[] | null\n }\n\n // use only a singleton instance, do not create duplicated instances of each store key\n public static getInstance(store: string): VariableContextHolder {\n const instance = VariableContextHolder._instance.get(store)\n\n if (!instance) {\n const holder = new VariableContextHolder(store)\n VariableContextHolder._instance.set(store, holder)\n\n return holder\n }\n\n return instance\n }\n\n get variables() {\n return this._variables\n }\n\n private collect() {\n this._storeContext.setItem(this._store, this._variables)\n this._listeners.forEach((listener) => listener(this._variables))\n\n return this._variables\n }\n\n get = (id: string) => {\n return this._variables.find((variable) => variable._id === id)\n }\n\n append = (variable: Variable<Key, Value>) => {\n this._variables.push(variable)\n this.collect()\n }\n\n clear = () => {\n this._variables = []\n this.collect()\n }\n\n entriesOf = (...keys: Key[]): VariableEntry<Key, Value>[] => {\n const entries: VariableEntry<Key, Value>[] = []\n\n for (const variable of this._variables) {\n if (keys.includes(variable.key)) entries.push([variable.key, variable.value])\n }\n\n return entries\n }\n\n remove = (key: Key) => {\n this._variables = this._variables.filter((v) => v.key !== key)\n this.collect()\n }\n\n replace = (variables: Variable<Key, Value>[]): Variable<Key, Value>[] => {\n this._variables = variables\n\n return this.collect()\n }\n\n update = (id: string, variable: Variable<Key, Value>): Variable<Key, Value>[] => {\n const updated = this._variables.map((v) => (v._id === id ? variable : v))\n\n return this.replace(updated)\n }\n\n observe = (listener: (variables: Variable<Key, Value>[]) => void): (() => void) => {\n const listenerId = Symbol(this._nextListenerId++)\n this._listeners.set(listenerId, listener)\n\n return () => {\n this._listeners.delete(listenerId)\n }\n }\n\n has(key: Key): boolean {\n return this._variables.some((variable) => variable.key === key)\n }\n}\n"],"names":["InMemoryVariableStore","__publicField","keys","key","value","_VariableContextHolder","_store","id","variable","entries","v","variables","updated","listener","listenerId","localStorageActions","pattern","store","instance","holder","VariableContextHolder"],"mappings":"oOAgCA,MAAMA,CAA+C,CAGnD,aAAc,CAFNC,EAAA,kBAAa,IAEN,CAEf,cAAcC,EAAsB,CAClC,UAAWC,KAAOD,EAChB,KAAK,OAAO,OAAOC,CAAG,CAE1B,CAEA,QAAWA,EAAuB,CAChC,OAAQ,KAAK,OAAO,IAAIA,CAAG,GAAW,IACxC,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