@descope/sdk-helpers 0.1.0

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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2023 Descope <help@descope.com>
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
File without changes
@@ -0,0 +1,2 @@
1
+ "use strict";var e=require("tslib");const t=(e,t)=>e.length===t.length&&e.every(((e,s)=>e===t[s]));var s,r,i,a;function l(e,t){const s=Object.getOwnPropertyNames(e),r=Object.getOwnPropertyNames(t);if(s.length!==r.length)return!1;for(let r=0;r<s.length;r+=1){const i=s[r],a=e[i],n=t[i];if(null===a||null===n){if(a!==n)return!1}else if("object"==typeof a&&"object"==typeof n){if(!l(a,n))return!1}else if(a!==n)return!1}return!0}s=new WeakMap,r=new WeakMap,i=new WeakMap,a=new WeakMap,exports.State=class{constructor(t={},{updateOnlyOnChange:n=!0}={}){s.set(this,void 0),r.set(this,{}),i.set(this,0),a.set(this,!1),this.update=t=>{const i="function"==typeof t?t(e.__classPrivateFieldGet(this,s,"f")):t,n=Object.assign(Object.assign({},e.__classPrivateFieldGet(this,s,"f")),i);if(!e.__classPrivateFieldGet(this,a,"f")||!l(e.__classPrivateFieldGet(this,s,"f"),n)){const t=e.__classPrivateFieldGet(this,s,"f");e.__classPrivateFieldSet(this,s,n,"f"),Object.freeze(e.__classPrivateFieldGet(this,s,"f")),setTimeout((()=>{Object.values(e.__classPrivateFieldGet(this,r,"f")).forEach((e=>e(n,t,((e,t)=>s=>e[s]!==t[s])(n,t))))}),0)}},e.__classPrivateFieldSet(this,s,t,"f"),e.__classPrivateFieldSet(this,a,n,"f")}get current(){return Object.assign({},e.__classPrivateFieldGet(this,s,"f"))}subscribe(t){return e.__classPrivateFieldSet(this,i,e.__classPrivateFieldGet(this,i,"f")+1,"f"),e.__classPrivateFieldGet(this,r,"f")[e.__classPrivateFieldGet(this,i,"f")]=t,e.__classPrivateFieldGet(this,i,"f").toString()}unsubscribe(t){const s=!!e.__classPrivateFieldGet(this,r,"f")[t];return s&&delete e.__classPrivateFieldGet(this,r,"f")[t],s}unsubscribeAll(){return e.__classPrivateFieldSet(this,r,{},"f"),!0}},exports.compareArrays=t,exports.compose=function(...e){return t=>e.reduce(((e,t)=>t(e)),t)},exports.createSingletonMixin=e=>{const t=Symbol((e=>{const t=e.toString();let s=0;for(let e=0;e<t.length;e++)s=(s<<5)-s+t.charCodeAt(e),s&=s;return s.toString(16)})(e));return s=>{if(s[t])return s;const r=e(s);return r[t]=!0,r}},exports.createTemplate=e=>{const t=document.createElement("template");return t.innerHTML=e,t},exports.debounce=(e,t=500)=>{let s;return function(...r){clearTimeout(s),s=setTimeout((()=>e.apply(this,r)),t)}},exports.isObjEmpty=e=>0===Object.keys(e).length&&e.constructor===Object,exports.kebabCase=e=>e.replace(/([a-z])([A-Z])/g,"$1-$2").replace(/[\s_.]+/g,"-").toLowerCase(),exports.pathJoin=(...e)=>e.join("/").replace(/\/+/g,"/"),exports.pluralize=e=>(t,...s)=>t.reduce(((t,r,i)=>{var a;return`${t}${r}${(null===(a=null==s?void 0:s[i])||void 0===a?void 0:a[e>1?1:0])||""}`}),""),exports.withMemCache=e=>{let s,r;return(...i)=>(s&&t(s,i)||(s=i,r=e(...i)),r)};
2
+ //# sourceMappingURL=index.cjs.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.cjs.js","sources":["../../src/dom.ts","../../src/generic.ts","../../src/state.ts","../../src/compose.ts","../../src/mixins.ts"],"sourcesContent":["export const createTemplate = (templateString: string) => {\n const template = document.createElement('template');\n template.innerHTML = templateString;\n\n return template;\n};\n","// preventing duplicate separators\nexport const pathJoin = (...paths: string[]) =>\n paths.join('/').replace(/\\/+/g, '/');\n\nexport const compareArrays = (array1: any[], array2: any[]) =>\n array1.length === array2.length &&\n array1.every((value: any, index: number) => value === array2[index]);\n\nexport const withMemCache = <I extends any[], O>(fn: (...args: I) => O) => {\n let prevArgs: any[];\n let cache: any;\n return (...args: I) => {\n if (prevArgs && compareArrays(prevArgs, args)) return cache as O;\n\n prevArgs = args;\n cache = fn(...args);\n\n return cache as O;\n };\n};\n\nexport const kebabCase = (str: string) =>\n str\n .replace(/([a-z])([A-Z])/g, '$1-$2')\n .replace(/[\\s_.]+/g, '-')\n .toLowerCase();\n\nexport const isObjEmpty = (obj: object) =>\n Object.keys(obj).length === 0 && obj.constructor === Object;\n\nexport const pluralize =\n (amount: number) =>\n (strings: TemplateStringsArray, ...expressions: (string | number)[][]) =>\n strings.reduce(\n (acc, str, idx) =>\n `${acc}${str}${expressions?.[idx]?.[amount > 1 ? 1 : 0] || ''}`,\n '',\n );\n\nexport const debounce = (fn: Function, ms = 500) => {\n let timeoutId: ReturnType<typeof setTimeout>;\n return function debounced(this: any, ...args: any[]) {\n clearTimeout(timeoutId);\n timeoutId = setTimeout(() => fn.apply(this, args), ms);\n };\n};\n","const createIsChanged =\n <T extends Record<string, any>>(state: T, prevState: T) =>\n (attrName: keyof T) =>\n state[attrName] !== prevState[attrName];\n\ntype StateObject = Record<string, any>;\n\ntype UpdateStateCb<T> = (state: T) => Partial<T>;\ntype Subscribers<T> = Record<string, SubscribeCb<T>>;\n\n// eslint-disable-next-line import/exports-last\nexport type SubscribeCb<T> = (\n state: T,\n prevState: T,\n isChanged: ReturnType<typeof createIsChanged>,\n) => void | Promise<void>;\n\nfunction compareObjects(\n objectA: Record<string, any>,\n objectB: Record<string, any>,\n) {\n const aProperties = Object.getOwnPropertyNames(objectA);\n const bProperties = Object.getOwnPropertyNames(objectB);\n\n if (aProperties.length !== bProperties.length) {\n return false;\n }\n\n for (let i = 0; i < aProperties.length; i += 1) {\n const propName = aProperties[i];\n\n const valA = objectA[propName];\n const valB = objectB[propName];\n if (valA === null || valB === null) {\n if (valA !== valB) {\n return false;\n }\n } else if (typeof valA === 'object' && typeof valB === 'object') {\n // compare nested objects\n if (!compareObjects(valA, valB)) {\n return false;\n }\n } else if (valA !== valB) {\n return false;\n }\n }\n\n return true;\n}\n\nexport type IsChanged<T> = Parameters<SubscribeCb<T>>[2];\n\nexport class State<T extends StateObject> {\n #state: T;\n\n #subscribers: Subscribers<T> = {};\n\n #token = 0;\n\n #updateOnlyOnChange = false;\n\n constructor(init: T = {} as T, { updateOnlyOnChange = true } = {}) {\n this.#state = init;\n this.#updateOnlyOnChange = updateOnlyOnChange;\n }\n\n get current() {\n return { ...this.#state };\n }\n\n update = (newState: Partial<T> | UpdateStateCb<T>) => {\n const internalNewState =\n typeof newState === 'function' ? newState(this.#state) : newState;\n\n const nextState = { ...this.#state, ...internalNewState };\n if (!this.#updateOnlyOnChange || !compareObjects(this.#state, nextState)) {\n const prevState = this.#state;\n this.#state = nextState;\n Object.freeze(this.#state);\n\n setTimeout(() => {\n Object.values(this.#subscribers).forEach((cb) =>\n cb(nextState, prevState, createIsChanged(nextState, prevState)),\n );\n }, 0);\n }\n };\n\n subscribe(cb: SubscribeCb<T>) {\n this.#token += 1;\n this.#subscribers[this.#token] = cb;\n\n return this.#token.toString();\n }\n\n unsubscribe(token: string) {\n const isFound = !!this.#subscribers[token];\n\n if (isFound) {\n delete this.#subscribers[token];\n }\n\n return isFound;\n }\n\n unsubscribeAll() {\n this.#subscribers = {};\n\n return true;\n }\n}\n","type Fn = (arg: any) => any;\n\nexport function compose<Input, A1>(\n fn1: (input: Input) => A1,\n): (input: Input) => A1;\n\nexport function compose<Input, A1, A2>(\n fn1: (input: Input) => A1,\n fn2: (input: A1) => A2,\n): (input: Input) => A2;\n\nexport function compose<Input, A1, A2, A3>(\n fn1: (input: Input) => A1,\n fn2: (input: A1) => A2,\n fn3: (input: A2) => A3,\n): (input: Input) => A3;\n\nexport function compose<Input, A1, A2, A3, A4>(\n fn1: (input: Input) => A1,\n fn2: (input: A1) => A2,\n fn3: (input: A2) => A3,\n fn4: (input: A3) => A4,\n): (input: Input) => A4;\n\nexport function compose<Input, A1, A2, A3, A4, A5>(\n fn1: (input: Input) => A1,\n fn2: (input: A1) => A2,\n fn3: (input: A2) => A3,\n fn4: (input: A3) => A4,\n fn5: (input: A4) => A5,\n): (input: Input) => A5;\n\nexport function compose<Input, A1, A2, A3, A4, A5, A6>(\n fn1: (input: Input) => A1,\n fn2: (input: A1) => A2,\n fn3: (input: A2) => A3,\n fn4: (input: A3) => A4,\n fn5: (input: A4) => A5,\n fn6: (input: A5) => A6,\n): (input: Input) => A6;\n\nexport function compose<Input, A1, A2, A3, A4, A5, A6, A7>(\n fn1: (input: Input) => A1,\n fn2: (input: A1) => A2,\n fn3: (input: A2) => A3,\n fn4: (input: A3) => A4,\n fn5: (input: A4) => A5,\n fn6: (input: A5) => A6,\n fn7: (input: A6) => A7,\n): (input: Input) => A7;\n\nexport function compose<Input, A1, A2, A3, A4, A5, A6, A7, A8>(\n fn1: (input: Input) => A1,\n fn2: (input: A1) => A2,\n fn3: (input: A2) => A3,\n fn4: (input: A3) => A4,\n fn5: (input: A4) => A5,\n fn6: (input: A5) => A6,\n fn7: (input: A6) => A7,\n fn8: (input: A7) => A8,\n): (input: Input) => A8;\n\nexport function compose<Input, A1, A2, A3, A4, A5, A6, A7, A8, A9>(\n fn1: (input: Input) => A1,\n fn2: (input: A1) => A2,\n fn3: (input: A2) => A3,\n fn4: (input: A3) => A4,\n fn5: (input: A4) => A5,\n fn6: (input: A5) => A6,\n fn7: (input: A6) => A7,\n fn8: (input: A7) => A8,\n fn9: (input: A8) => A9,\n): (input: Input) => A9;\n\nexport function compose<Input, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10>(\n fn1: (input: Input) => A1,\n fn2: (input: A1) => A2,\n fn3: (input: A2) => A3,\n fn4: (input: A3) => A4,\n fn5: (input: A4) => A5,\n fn6: (input: A5) => A6,\n fn7: (input: A6) => A7,\n fn8: (input: A7) => A8,\n fn9: (input: A8) => A9,\n fn10: (input: A9) => A10,\n): (input: Input) => A10;\n\nexport function compose<Input, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11>(\n fn1: (input: Input) => A1,\n fn2: (input: A1) => A2,\n fn3: (input: A2) => A3,\n fn4: (input: A3) => A4,\n fn5: (input: A4) => A5,\n fn6: (input: A5) => A6,\n fn7: (input: A6) => A7,\n fn8: (input: A7) => A8,\n fn9: (input: A8) => A9,\n fn10: (input: A9) => A10,\n fn11: (input: A10) => A11,\n): (input: Input) => A11;\n\nexport function compose<\n Input,\n A1,\n A2,\n A3,\n A4,\n A5,\n A6,\n A7,\n A8,\n A9,\n A10,\n A11,\n A12,\n>(\n fn1: (input: Input) => A1,\n fn2: (input: A1) => A2,\n fn3: (input: A2) => A3,\n fn4: (input: A3) => A4,\n fn5: (input: A4) => A5,\n fn6: (input: A5) => A6,\n fn7: (input: A6) => A7,\n fn8: (input: A7) => A8,\n fn9: (input: A8) => A9,\n fn10: (input: A9) => A10,\n fn11: (input: A10) => A11,\n fn12: (input: A11) => A12,\n): (input: Input) => A12;\n\n/**\n * Currently there is no way to create a compose function in Typescript without using overloading\n * This function currently support up to 10 wrappers\n * If needed you can add more by duplicating the type and add more parameters\n */\n\nexport function compose(...args: Fn[]) {\n return (data: any) => args.reduce((acc, elem) => elem(acc), data) as any;\n}\n","const getFunctionHash = (fn: Function) => {\n const functionSource = fn.toString();\n\n let hash = 0;\n\n // eslint-disable-next-line no-plusplus\n for (let i = 0; i < functionSource.length; i++) {\n const char = functionSource.charCodeAt(i);\n // eslint-disable-next-line no-bitwise\n hash = (hash << 5) - hash + char;\n // eslint-disable-next-line no-bitwise\n hash &= hash; // Convert to 32-bit integer\n }\n\n return hash.toString(16);\n};\n\ntype Mixin = (superclass: CustomElementConstructor) => CustomElementConstructor;\n\n// because a single mixin can be a dependency for many other mixins, a mixin can be loaded multiple times\n// some mixins should not be loaded multiple times, wrapping a mixin with this fn ensures it will load only once\nexport const createSingletonMixin = <T extends Mixin>(mixin: T): T => {\n const mixinNameSym = Symbol(getFunctionHash(mixin));\n\n const singletonMixin = (superclass: CustomElementConstructor) => {\n if (superclass[mixinNameSym]) {\n return superclass;\n }\n\n const cls = mixin(superclass);\n cls[mixinNameSym] = true;\n\n return cls;\n };\n\n return singletonMixin as T;\n};\n"],"names":["compareArrays","array1","array2","length","every","value","index","compareObjects","objectA","objectB","aProperties","Object","getOwnPropertyNames","bProperties","i","propName","valA","valB","constructor","init","updateOnlyOnChange","_State_state","set","this","_State_subscribers","_State_token","_State_updateOnlyOnChange","update","newState","internalNewState","__classPrivateFieldGet","nextState","prevState","__classPrivateFieldSet","freeze","setTimeout","values","forEach","cb","state","attrName","createIsChanged","current","assign","subscribe","toString","unsubscribe","token","isFound","unsubscribeAll","args","data","reduce","acc","elem","mixin","mixinNameSym","Symbol","fn","functionSource","hash","charCodeAt","getFunctionHash","superclass","cls","templateString","template","document","createElement","innerHTML","ms","timeoutId","clearTimeout","apply","obj","keys","str","replace","toLowerCase","paths","join","amount","strings","expressions","idx","_a","prevArgs","cache"],"mappings":"oCAAa,MCIAA,EAAgB,C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AQ,mBCmCO,CAACR,EAAcY,EAAK,OAC1C,IAAIC,EACJ,OAAO,YAAiCrB,GACtCsB,aAAaD,GACbA,EAAYpC,YAAW,IAAMuB,EAAGe,MAAMlD,KAAM2B,IAAOoB,EACrD,CAAC,qBAjBwBI,GACG,IAA5B/D,OAAOgE,KAAKD,GAAKvE,QAAgBuE,EAAIxD,cAAgBP,yBAP7BiE,GACxBA,EACGC,QAAQ,kBAAmB,SAC3BA,QAAQ,WAAY,KACpBC,+BAxBmB,IAAIC,IAC1BA,EAAMC,KAAK,KAAKH,QAAQ,OAAQ,uBA6B/BI,GACD,CAACC,KAAkCC,IACjCD,EAAQ9B,QACN,CAACC,EAAKuB,EAAKQ,KAAO,IAAAC,EAChB,MAAA,GAAGhC,IAAMuB,KAA2B,QAArBS,EAAAF,aAAW,EAAXA,EAAcC,UAAO,IAAAC,OAAA,EAAAA,EAAAJ,EAAS,EAAI,EAAI,KAAM,IAAI,GACjE,yBA5B2CvB,IAC/C,IAAI4B,EACAC,EACJ,MAAO,IAAIrC,KACLoC,GAAYtF,EAAcsF,EAAUpC,KAExCoC,EAAWpC,EACXqC,EAAQ7B,KAAMR,IAHwCqC,EAMvD"}
@@ -0,0 +1 @@
1
+ {"type":"commonjs"}
@@ -0,0 +1,44 @@
1
+ declare function compose<Input, A1>(fn1: (input: Input) => A1): (input: Input) => A1;
2
+ declare function compose<Input, A1, A2>(fn1: (input: Input) => A1, fn2: (input: A1) => A2): (input: Input) => A2;
3
+ declare function compose<Input, A1, A2, A3>(fn1: (input: Input) => A1, fn2: (input: A1) => A2, fn3: (input: A2) => A3): (input: Input) => A3;
4
+ declare function compose<Input, A1, A2, A3, A4>(fn1: (input: Input) => A1, fn2: (input: A1) => A2, fn3: (input: A2) => A3, fn4: (input: A3) => A4): (input: Input) => A4;
5
+ declare function compose<Input, A1, A2, A3, A4, A5>(fn1: (input: Input) => A1, fn2: (input: A1) => A2, fn3: (input: A2) => A3, fn4: (input: A3) => A4, fn5: (input: A4) => A5): (input: Input) => A5;
6
+ declare function compose<Input, A1, A2, A3, A4, A5, A6>(fn1: (input: Input) => A1, fn2: (input: A1) => A2, fn3: (input: A2) => A3, fn4: (input: A3) => A4, fn5: (input: A4) => A5, fn6: (input: A5) => A6): (input: Input) => A6;
7
+ declare function compose<Input, A1, A2, A3, A4, A5, A6, A7>(fn1: (input: Input) => A1, fn2: (input: A1) => A2, fn3: (input: A2) => A3, fn4: (input: A3) => A4, fn5: (input: A4) => A5, fn6: (input: A5) => A6, fn7: (input: A6) => A7): (input: Input) => A7;
8
+ declare function compose<Input, A1, A2, A3, A4, A5, A6, A7, A8>(fn1: (input: Input) => A1, fn2: (input: A1) => A2, fn3: (input: A2) => A3, fn4: (input: A3) => A4, fn5: (input: A4) => A5, fn6: (input: A5) => A6, fn7: (input: A6) => A7, fn8: (input: A7) => A8): (input: Input) => A8;
9
+ declare function compose<Input, A1, A2, A3, A4, A5, A6, A7, A8, A9>(fn1: (input: Input) => A1, fn2: (input: A1) => A2, fn3: (input: A2) => A3, fn4: (input: A3) => A4, fn5: (input: A4) => A5, fn6: (input: A5) => A6, fn7: (input: A6) => A7, fn8: (input: A7) => A8, fn9: (input: A8) => A9): (input: Input) => A9;
10
+ declare function compose<Input, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10>(fn1: (input: Input) => A1, fn2: (input: A1) => A2, fn3: (input: A2) => A3, fn4: (input: A3) => A4, fn5: (input: A4) => A5, fn6: (input: A5) => A6, fn7: (input: A6) => A7, fn8: (input: A7) => A8, fn9: (input: A8) => A9, fn10: (input: A9) => A10): (input: Input) => A10;
11
+ declare function compose<Input, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11>(fn1: (input: Input) => A1, fn2: (input: A1) => A2, fn3: (input: A2) => A3, fn4: (input: A3) => A4, fn5: (input: A4) => A5, fn6: (input: A5) => A6, fn7: (input: A6) => A7, fn8: (input: A7) => A8, fn9: (input: A8) => A9, fn10: (input: A9) => A10, fn11: (input: A10) => A11): (input: Input) => A11;
12
+ declare function compose<Input, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12>(fn1: (input: Input) => A1, fn2: (input: A1) => A2, fn3: (input: A2) => A3, fn4: (input: A3) => A4, fn5: (input: A4) => A5, fn6: (input: A5) => A6, fn7: (input: A6) => A7, fn8: (input: A7) => A8, fn9: (input: A8) => A9, fn10: (input: A9) => A10, fn11: (input: A10) => A11, fn12: (input: A11) => A12): (input: Input) => A12;
13
+
14
+ declare const createTemplate: (templateString: string) => HTMLTemplateElement;
15
+
16
+ declare const pathJoin: (...paths: string[]) => string;
17
+ declare const compareArrays: (array1: any[], array2: any[]) => boolean;
18
+ declare const withMemCache: <I extends any[], O>(fn: (...args: I) => O) => (...args: I) => O;
19
+ declare const kebabCase: (str: string) => string;
20
+ declare const isObjEmpty: (obj: object) => boolean;
21
+ declare const pluralize: (amount: number) => (strings: TemplateStringsArray, ...expressions: (string | number)[][]) => string;
22
+ declare const debounce: (fn: Function, ms?: number) => (this: any, ...args: any[]) => void;
23
+
24
+ type Mixin = (superclass: CustomElementConstructor) => CustomElementConstructor;
25
+ declare const createSingletonMixin: <T extends Mixin>(mixin: T) => T;
26
+
27
+ declare const createIsChanged: <T extends Record<string, any>>(state: T, prevState: T) => (attrName: keyof T) => boolean;
28
+ type StateObject = Record<string, any>;
29
+ type UpdateStateCb<T> = (state: T) => Partial<T>;
30
+ type SubscribeCb<T> = (state: T, prevState: T, isChanged: ReturnType<typeof createIsChanged>) => void | Promise<void>;
31
+ type IsChanged<T> = Parameters<SubscribeCb<T>>[2];
32
+ declare class State<T extends StateObject> {
33
+ #private;
34
+ constructor(init?: T, { updateOnlyOnChange }?: {
35
+ updateOnlyOnChange?: boolean;
36
+ });
37
+ get current(): T;
38
+ update: (newState: Partial<T> | UpdateStateCb<T>) => void;
39
+ subscribe(cb: SubscribeCb<T>): string;
40
+ unsubscribe(token: string): boolean;
41
+ unsubscribeAll(): boolean;
42
+ }
43
+
44
+ export { IsChanged, State, SubscribeCb, compareArrays, compose, createSingletonMixin, createTemplate, debounce, isObjEmpty, kebabCase, pathJoin, pluralize, withMemCache };
@@ -0,0 +1,2 @@
1
+ import{__classPrivateFieldGet as t,__classPrivateFieldSet as e}from"tslib";function n(...t){return e=>t.reduce(((t,e)=>e(t)),e)}const r=t=>{const e=document.createElement("template");return e.innerHTML=t,e},s=(...t)=>t.join("/").replace(/\/+/g,"/"),i=(t,e)=>t.length===e.length&&t.every(((t,n)=>t===e[n])),o=t=>{let e,n;return(...r)=>(e&&i(e,r)||(e=r,n=t(...r)),n)},c=t=>t.replace(/([a-z])([A-Z])/g,"$1-$2").replace(/[\s_.]+/g,"-").toLowerCase(),u=t=>0===Object.keys(t).length&&t.constructor===Object,f=t=>(e,...n)=>e.reduce(((e,r,s)=>{var i;return`${e}${r}${(null===(i=null==n?void 0:n[s])||void 0===i?void 0:i[t>1?1:0])||""}`}),""),l=(t,e=500)=>{let n;return function(...r){clearTimeout(n),n=setTimeout((()=>t.apply(this,r)),e)}},h=t=>{const e=Symbol((t=>{const e=t.toString();let n=0;for(let t=0;t<e.length;t++)n=(n<<5)-n+e.charCodeAt(t),n&=n;return n.toString(16)})(t));return n=>{if(n[e])return n;const r=t(n);return r[e]=!0,r}};var a,g,b,p;function O(t,e){const n=Object.getOwnPropertyNames(t),r=Object.getOwnPropertyNames(e);if(n.length!==r.length)return!1;for(let r=0;r<n.length;r+=1){const s=n[r],i=t[s],o=e[s];if(null===i||null===o){if(i!==o)return!1}else if("object"==typeof i&&"object"==typeof o){if(!O(i,o))return!1}else if(i!==o)return!1}return!0}class j{constructor(n={},{updateOnlyOnChange:r=!0}={}){a.set(this,void 0),g.set(this,{}),b.set(this,0),p.set(this,!1),this.update=n=>{const r="function"==typeof n?n(t(this,a,"f")):n,s=Object.assign(Object.assign({},t(this,a,"f")),r);if(!t(this,p,"f")||!O(t(this,a,"f"),s)){const n=t(this,a,"f");e(this,a,s,"f"),Object.freeze(t(this,a,"f")),setTimeout((()=>{Object.values(t(this,g,"f")).forEach((t=>t(s,n,((t,e)=>n=>t[n]!==e[n])(s,n))))}),0)}},e(this,a,n,"f"),e(this,p,r,"f")}get current(){return Object.assign({},t(this,a,"f"))}subscribe(n){return e(this,b,t(this,b,"f")+1,"f"),t(this,g,"f")[t(this,b,"f")]=n,t(this,b,"f").toString()}unsubscribe(e){const n=!!t(this,g,"f")[e];return n&&delete t(this,g,"f")[e],n}unsubscribeAll(){return e(this,g,{},"f"),!0}}a=new WeakMap,g=new WeakMap,b=new WeakMap,p=new WeakMap;export{j as State,i as compareArrays,n as compose,h as createSingletonMixin,r as createTemplate,l as debounce,u as isObjEmpty,c as kebabCase,s as pathJoin,f as pluralize,o as withMemCache};
2
+ //# sourceMappingURL=index.esm.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.esm.js","sources":["../src/compose.ts","../src/dom.ts","../src/generic.ts","../src/mixins.ts","../src/state.ts"],"sourcesContent":["type Fn = (arg: any) => any;\n\nexport function compose<Input, A1>(\n fn1: (input: Input) => A1,\n): (input: Input) => A1;\n\nexport function compose<Input, A1, A2>(\n fn1: (input: Input) => A1,\n fn2: (input: A1) => A2,\n): (input: Input) => A2;\n\nexport function compose<Input, A1, A2, A3>(\n fn1: (input: Input) => A1,\n fn2: (input: A1) => A2,\n fn3: (input: A2) => A3,\n): (input: Input) => A3;\n\nexport function compose<Input, A1, A2, A3, A4>(\n fn1: (input: Input) => A1,\n fn2: (input: A1) => A2,\n fn3: (input: A2) => A3,\n fn4: (input: A3) => A4,\n): (input: Input) => A4;\n\nexport function compose<Input, A1, A2, A3, A4, A5>(\n fn1: (input: Input) => A1,\n fn2: (input: A1) => A2,\n fn3: (input: A2) => A3,\n fn4: (input: A3) => A4,\n fn5: (input: A4) => A5,\n): (input: Input) => A5;\n\nexport function compose<Input, A1, A2, A3, A4, A5, A6>(\n fn1: (input: Input) => A1,\n fn2: (input: A1) => A2,\n fn3: (input: A2) => A3,\n fn4: (input: A3) => A4,\n fn5: (input: A4) => A5,\n fn6: (input: A5) => A6,\n): (input: Input) => A6;\n\nexport function compose<Input, A1, A2, A3, A4, A5, A6, A7>(\n fn1: (input: Input) => A1,\n fn2: (input: A1) => A2,\n fn3: (input: A2) => A3,\n fn4: (input: A3) => A4,\n fn5: (input: A4) => A5,\n fn6: (input: A5) => A6,\n fn7: (input: A6) => A7,\n): (input: Input) => A7;\n\nexport function compose<Input, A1, A2, A3, A4, A5, A6, A7, A8>(\n fn1: (input: Input) => A1,\n fn2: (input: A1) => A2,\n fn3: (input: A2) => A3,\n fn4: (input: A3) => A4,\n fn5: (input: A4) => A5,\n fn6: (input: A5) => A6,\n fn7: (input: A6) => A7,\n fn8: (input: A7) => A8,\n): (input: Input) => A8;\n\nexport function compose<Input, A1, A2, A3, A4, A5, A6, A7, A8, A9>(\n fn1: (input: Input) => A1,\n fn2: (input: A1) => A2,\n fn3: (input: A2) => A3,\n fn4: (input: A3) => A4,\n fn5: (input: A4) => A5,\n fn6: (input: A5) => A6,\n fn7: (input: A6) => A7,\n fn8: (input: A7) => A8,\n fn9: (input: A8) => A9,\n): (input: Input) => A9;\n\nexport function compose<Input, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10>(\n fn1: (input: Input) => A1,\n fn2: (input: A1) => A2,\n fn3: (input: A2) => A3,\n fn4: (input: A3) => A4,\n fn5: (input: A4) => A5,\n fn6: (input: A5) => A6,\n fn7: (input: A6) => A7,\n fn8: (input: A7) => A8,\n fn9: (input: A8) => A9,\n fn10: (input: A9) => A10,\n): (input: Input) => A10;\n\nexport function compose<Input, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11>(\n fn1: (input: Input) => A1,\n fn2: (input: A1) => A2,\n fn3: (input: A2) => A3,\n fn4: (input: A3) => A4,\n fn5: (input: A4) => A5,\n fn6: (input: A5) => A6,\n fn7: (input: A6) => A7,\n fn8: (input: A7) => A8,\n fn9: (input: A8) => A9,\n fn10: (input: A9) => A10,\n fn11: (input: A10) => A11,\n): (input: Input) => A11;\n\nexport function compose<\n Input,\n A1,\n A2,\n A3,\n A4,\n A5,\n A6,\n A7,\n A8,\n A9,\n A10,\n A11,\n A12,\n>(\n fn1: (input: Input) => A1,\n fn2: (input: A1) => A2,\n fn3: (input: A2) => A3,\n fn4: (input: A3) => A4,\n fn5: (input: A4) => A5,\n fn6: (input: A5) => A6,\n fn7: (input: A6) => A7,\n fn8: (input: A7) => A8,\n fn9: (input: A8) => A9,\n fn10: (input: A9) => A10,\n fn11: (input: A10) => A11,\n fn12: (input: A11) => A12,\n): (input: Input) => A12;\n\n/**\n * Currently there is no way to create a compose function in Typescript without using overloading\n * This function currently support up to 10 wrappers\n * If needed you can add more by duplicating the type and add more parameters\n */\n\nexport function compose(...args: Fn[]) {\n return (data: any) => args.reduce((acc, elem) => elem(acc), data) as any;\n}\n","export const createTemplate = (templateString: string) => {\n const template = document.createElement('template');\n template.innerHTML = templateString;\n\n return template;\n};\n","// preventing duplicate separators\nexport const pathJoin = (...paths: string[]) =>\n paths.join('/').replace(/\\/+/g, '/');\n\nexport const compareArrays = (array1: any[], array2: any[]) =>\n array1.length === array2.length &&\n array1.every((value: any, index: number) => value === array2[index]);\n\nexport const withMemCache = <I extends any[], O>(fn: (...args: I) => O) => {\n let prevArgs: any[];\n let cache: any;\n return (...args: I) => {\n if (prevArgs && compareArrays(prevArgs, args)) return cache as O;\n\n prevArgs = args;\n cache = fn(...args);\n\n return cache as O;\n };\n};\n\nexport const kebabCase = (str: string) =>\n str\n .replace(/([a-z])([A-Z])/g, '$1-$2')\n .replace(/[\\s_.]+/g, '-')\n .toLowerCase();\n\nexport const isObjEmpty = (obj: object) =>\n Object.keys(obj).length === 0 && obj.constructor === Object;\n\nexport const pluralize =\n (amount: number) =>\n (strings: TemplateStringsArray, ...expressions: (string | number)[][]) =>\n strings.reduce(\n (acc, str, idx) =>\n `${acc}${str}${expressions?.[idx]?.[amount > 1 ? 1 : 0] || ''}`,\n '',\n );\n\nexport const debounce = (fn: Function, ms = 500) => {\n let timeoutId: ReturnType<typeof setTimeout>;\n return function debounced(this: any, ...args: any[]) {\n clearTimeout(timeoutId);\n timeoutId = setTimeout(() => fn.apply(this, args), ms);\n };\n};\n","const getFunctionHash = (fn: Function) => {\n const functionSource = fn.toString();\n\n let hash = 0;\n\n // eslint-disable-next-line no-plusplus\n for (let i = 0; i < functionSource.length; i++) {\n const char = functionSource.charCodeAt(i);\n // eslint-disable-next-line no-bitwise\n hash = (hash << 5) - hash + char;\n // eslint-disable-next-line no-bitwise\n hash &= hash; // Convert to 32-bit integer\n }\n\n return hash.toString(16);\n};\n\ntype Mixin = (superclass: CustomElementConstructor) => CustomElementConstructor;\n\n// because a single mixin can be a dependency for many other mixins, a mixin can be loaded multiple times\n// some mixins should not be loaded multiple times, wrapping a mixin with this fn ensures it will load only once\nexport const createSingletonMixin = <T extends Mixin>(mixin: T): T => {\n const mixinNameSym = Symbol(getFunctionHash(mixin));\n\n const singletonMixin = (superclass: CustomElementConstructor) => {\n if (superclass[mixinNameSym]) {\n return superclass;\n }\n\n const cls = mixin(superclass);\n cls[mixinNameSym] = true;\n\n return cls;\n };\n\n return singletonMixin as T;\n};\n","const createIsChanged =\n <T extends Record<string, any>>(state: T, prevState: T) =>\n (attrName: keyof T) =>\n state[attrName] !== prevState[attrName];\n\ntype StateObject = Record<string, any>;\n\ntype UpdateStateCb<T> = (state: T) => Partial<T>;\ntype Subscribers<T> = Record<string, SubscribeCb<T>>;\n\n// eslint-disable-next-line import/exports-last\nexport type SubscribeCb<T> = (\n state: T,\n prevState: T,\n isChanged: ReturnType<typeof createIsChanged>,\n) => void | Promise<void>;\n\nfunction compareObjects(\n objectA: Record<string, any>,\n objectB: Record<string, any>,\n) {\n const aProperties = Object.getOwnPropertyNames(objectA);\n const bProperties = Object.getOwnPropertyNames(objectB);\n\n if (aProperties.length !== bProperties.length) {\n return false;\n }\n\n for (let i = 0; i < aProperties.length; i += 1) {\n const propName = aProperties[i];\n\n const valA = objectA[propName];\n const valB = objectB[propName];\n if (valA === null || valB === null) {\n if (valA !== valB) {\n return false;\n }\n } else if (typeof valA === 'object' && typeof valB === 'object') {\n // compare nested objects\n if (!compareObjects(valA, valB)) {\n return false;\n }\n } else if (valA !== valB) {\n return false;\n }\n }\n\n return true;\n}\n\nexport type IsChanged<T> = Parameters<SubscribeCb<T>>[2];\n\nexport class State<T extends StateObject> {\n #state: T;\n\n #subscribers: Subscribers<T> = {};\n\n #token = 0;\n\n #updateOnlyOnChange = false;\n\n constructor(init: T = {} as T, { updateOnlyOnChange = true } = {}) {\n this.#state = init;\n this.#updateOnlyOnChange = updateOnlyOnChange;\n }\n\n get current() {\n return { ...this.#state };\n }\n\n update = (newState: Partial<T> | UpdateStateCb<T>) => {\n const internalNewState =\n typeof newState === 'function' ? newState(this.#state) : newState;\n\n const nextState = { ...this.#state, ...internalNewState };\n if (!this.#updateOnlyOnChange || !compareObjects(this.#state, nextState)) {\n const prevState = this.#state;\n this.#state = nextState;\n Object.freeze(this.#state);\n\n setTimeout(() => {\n Object.values(this.#subscribers).forEach((cb) =>\n cb(nextState, prevState, createIsChanged(nextState, prevState)),\n );\n }, 0);\n }\n };\n\n subscribe(cb: SubscribeCb<T>) {\n this.#token += 1;\n this.#subscribers[this.#token] = cb;\n\n return this.#token.toString();\n }\n\n unsubscribe(token: string) {\n const isFound = !!this.#subscribers[token];\n\n if (isFound) {\n delete this.#subscribers[token];\n }\n\n return isFound;\n }\n\n unsubscribeAll() {\n this.#subscribers = {};\n\n return true;\n }\n}\n"],"names":["compose","args","data","reduce","acc","elem","createTemplate","templateString","template","document","createElement","innerHTML","pathJoin","paths","join","replace","compareArrays","array1","array2","length","every","value","index","withMemCache","fn","prevArgs","cache","kebabCase","str","toLowerCase","isObjEmpty","obj","Object","keys","constructor","pluralize","amount","strings","expressions","idx","_a","debounce","ms","timeoutId","clearTimeout","setTimeout","apply","this","createSingletonMixin","mixin","mixinNameSym","Symbol","functionSource","toString","hash","i","charCodeAt","getFunctionHash","superclass","cls","compareObjects","objectA","objectB","aProperties","getOwnPropertyNames","bProperties","propName","valA","valB","State","init","updateOnlyOnChange","_State_state","set","_State_subscribers","_State_token","_State_updateOnlyOnChange","update","newState","internalNewState","__classPrivateFieldGet","nextState","prevState","__classPrivateFieldSet","freeze","values","forEach","cb","state","attrName","createIsChanged","current","assign","subscribe","unsubscribe","token","isFound","unsubscribeAll"],"mappings":"2EAwIgB,SAAAA,KAAWC,GACzB,OAAQC,GAAcD,EAAKE,QAAO,CAACC,EAAKC,IAASA,EAAKD,IAAMF,EAC9D,CC1Ia,MAAAI,EAAkBC,IAC7B,MAAMC,EAAWC,SAASC,cAAc,YAGxC,OAFAF,EAASG,UAAYJ,EAEdC,CAAQ,ECHJI,EAAW,IAAIC,IAC1BA,EAAMC,KAAK,KAAKC,QAAQ,OAAQ,KAErBC,EAAgB,CAACC,EAAeC,IAC3CD,EAAOE,SAAWD,EAAOC,QACzBF,EAAOG,OAAM,CAACC,EAAYC,IAAkBD,IAAUH,EAAOI,KAElDC,EAAoCC,IAC/C,IAAIC,EACAC,EACJ,MAAO,IAAIzB,KACLwB,GAAYT,EAAcS,EAAUxB,KAExCwB,EAAWxB,EACXyB,EAAQF,KAAMvB,IAHwCyB,EAMvD,EAGUC,EAAaC,GACxBA,EACGb,QAAQ,kBAAmB,SAC3BA,QAAQ,WAAY,KACpBc,cAEQC,EAAcC,GACG,IAA5BC,OAAOC,KAAKF,GAAKZ,QAAgBY,EAAIG,cAAgBF,OAE1CG,EACVC,GACD,CAACC,KAAkCC,IACjCD,EAAQlC,QACN,CAACC,EAAKwB,EAAKW,KAAO,IAAAC,EAChB,MAAA,GAAGpC,IAAMwB,KAA2B,QAArBY,EAAAF,aAAW,EAAXA,EAAcC,UAAO,IAAAC,OAAA,EAAAA,EAAAJ,EAAS,EAAI,EAAI,KAAM,IAAI,GACjE,IAGOK,EAAW,CAACjB,EAAckB,EAAK,OAC1C,IAAIC,EACJ,OAAO,YAAiC1C,GACtC2C,aAAaD,GACbA,EAAYE,Y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G,iCAAiBD,EAAAjC,aAAgBgC,GACvC,IAAKC,EAAAjC,KAAI6B,EAAA,OAAyBhB,EAAeoB,EAAAjC,KAAIyB,EAAA,KAASS,GAAY,CACxE,MAAMC,EAAYF,EAAAjC,YAClBoC,EAAApC,KAAIyB,EAAUS,EAAS,KACvBjD,OAAOoD,OAAOJ,EAAAjC,KAAIyB,EAAA,MAElB3B,YAAW,KACTb,OAAOqD,OAAOL,EAAAjC,KAAI2B,EAAA,MAAeY,SAASC,GACxCA,EAAGN,EAAWC,EAjFtB,EAAgCM,EAAUN,IACzCO,GACCD,EAAMC,KAAcP,EAAUO,GA+ECC,CAAgBT,EAAWC,KACrD,GACA,EACJ,GAvBDC,EAAApC,KAAIyB,EAAUF,EAAI,KAClBa,EAAApC,KAAI6B,EAAuBL,EAAkB,IAC9C,CAEGoB,cACF,OAAY3D,OAAA4D,OAAA,GAAAZ,EAAAjC,KAAIyB,EAAA,KACjB,CAoBDqB,UAAUN,GAIR,OAHAJ,EAAepC,KAAA4B,EAAAK,EAAAjC,KAAA4B,EAAA,KAAA,OACfK,EAAAjC,YAAkBiC,EAAAjC,KAAW4B,EAAA,MAAIY,EAE1BP,EAAAjC,KAAI4B,EAAA,KAAQtB,UACpB,CAEDyC,YAAYC,GACV,MAAMC,IAAYhB,EAAAjC,KAAiB2B,EAAA,KAACqB,GAMpC,OAJIC,UACKhB,EAAAjC,KAAI2B,EAAA,KAAcqB,GAGpBC,CACR,CAEDC,iBAGE,OAFAd,EAAApC,KAAI2B,EAAgB,CAAE,EAAA,MAEf,CACR"}
package/package.json ADDED
@@ -0,0 +1,92 @@
1
+ {
2
+ "name": "@descope/sdk-helpers",
3
+ "version": "0.1.0",
4
+ "author": "Descope Team <info@descope.com>",
5
+ "homepage": "https://github.com/descope/sdk-helpers",
6
+ "bugs": {
7
+ "url": "https://github.com/descope/sdk-helpers/issues",
8
+ "email": "help@descope.com"
9
+ },
10
+ "main": "dist/cjs/index.cjs.js",
11
+ "module": "dist/index.esm.js",
12
+ "types": "dist/index.d.ts",
13
+ "exports": {
14
+ "require": {
15
+ "types": "./dist/index.d.ts",
16
+ "default": "./dist/cjs/index.cjs.js"
17
+ },
18
+ "import": {
19
+ "types": "./dist/index.d.ts",
20
+ "default": "./dist/index.esm.js"
21
+ }
22
+ },
23
+ "type": "module",
24
+ "description": "Descope JavaScript SDK helpers",
25
+ "license": "MIT",
26
+ "repository": {
27
+ "type": "git",
28
+ "url": "https://github.com/descope/sdk-helpers.git"
29
+ },
30
+ "files": [
31
+ "dist"
32
+ ],
33
+ "keywords": [
34
+ "descope",
35
+ "authentication"
36
+ ],
37
+ "devDependencies": {
38
+ "@rollup/plugin-commonjs": "24.1.0",
39
+ "@rollup/plugin-node-resolve": "^15.0.0",
40
+ "@rollup/plugin-replace": "^5.0.2",
41
+ "@rollup/plugin-terser": "^0.4.0",
42
+ "@rollup/plugin-typescript": "^11.0.0",
43
+ "@types/jest": "^29.0.0",
44
+ "@types/node": "20.11.20",
45
+ "@types/js-cookie": "^3.0.2",
46
+ "@types/lodash.get": "^4.4.7",
47
+ "@typescript-eslint/parser": "^7.0.0",
48
+ "eslint": "8.52.0",
49
+ "eslint-config-airbnb-typescript": "17.1.0",
50
+ "eslint-config-prettier": "9.1.0",
51
+ "eslint-config-standard": "17.1.0",
52
+ "eslint-import-resolver-typescript": "3.6.1",
53
+ "eslint-plugin-import": "2.28.1",
54
+ "eslint-plugin-jest": "27.4.2",
55
+ "eslint-plugin-jest-dom": "4.0.3",
56
+ "eslint-plugin-jest-formatting": "3.1.0",
57
+ "eslint-plugin-n": "15.7.0",
58
+ "eslint-plugin-no-only-tests": "3.1.0",
59
+ "eslint-plugin-prefer-arrow": "1.2.3",
60
+ "eslint-plugin-prettier": "4.2.1",
61
+ "eslint-plugin-promise": "6.1.1",
62
+ "http-server": "^14.0.0",
63
+ "jest": "^29.0.0",
64
+ "jest-environment-jsdom": "^29.0.0",
65
+ "lint-staged": "^15.0.0",
66
+ "prettier": "^3.0.0",
67
+ "pretty-quick": "^3.1.3",
68
+ "rimraf": "^5.0.0",
69
+ "rollup": "^3.0.0",
70
+ "rollup-plugin-auto-external": "^2.0.0",
71
+ "rollup-plugin-browsersync": "^1.3.3",
72
+ "rollup-plugin-delete": "^2.0.0",
73
+ "rollup-plugin-dts": "^5.1.1",
74
+ "rollup-plugin-esbuild": "^5.0.0",
75
+ "rollup-plugin-inject-process-env": "^1.3.1",
76
+ "rollup-plugin-livereload": "^2.0.5",
77
+ "ts-jest": "^29.0.0",
78
+ "ts-node": "10.9.2",
79
+ "typescript": "^4.5.3"
80
+ },
81
+ "dependencies": {
82
+ "tslib": "2.6.2"
83
+ },
84
+ "overrides": {
85
+ "terser": "^5.14.2"
86
+ },
87
+ "scripts": {
88
+ "build": "rimraf dist && rollup -c",
89
+ "test": "echo no tests yet",
90
+ "lint": "eslint '+(src|test|examples)/**/*.ts'"
91
+ }
92
+ }