@kwiz/common 1.0.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.
Files changed (310) hide show
  1. package/LICENSE +21 -0
  2. package/dist/_dependencies.d.ts +1 -0
  3. package/dist/_dependencies.js +8 -0
  4. package/dist/_dependencies.js.map +1 -0
  5. package/dist/helpers/Guid.d.ts +119 -0
  6. package/dist/helpers/Guid.js +183 -0
  7. package/dist/helpers/Guid.js.map +1 -0
  8. package/dist/helpers/_dependencies.d.ts +2 -0
  9. package/dist/helpers/_dependencies.js +21 -0
  10. package/dist/helpers/_dependencies.js.map +1 -0
  11. package/dist/helpers/base64.d.ts +8 -0
  12. package/dist/helpers/base64.js +178 -0
  13. package/dist/helpers/base64.js.map +1 -0
  14. package/dist/helpers/browser.d.ts +144 -0
  15. package/dist/helpers/browser.js +1200 -0
  16. package/dist/helpers/browser.js.map +1 -0
  17. package/dist/helpers/browserinfo.d.ts +23 -0
  18. package/dist/helpers/browserinfo.js +215 -0
  19. package/dist/helpers/browserinfo.js.map +1 -0
  20. package/dist/helpers/collections.base.d.ts +128 -0
  21. package/dist/helpers/collections.base.js +430 -0
  22. package/dist/helpers/collections.base.js.map +1 -0
  23. package/dist/helpers/collections.d.ts +18 -0
  24. package/dist/helpers/collections.js +99 -0
  25. package/dist/helpers/collections.js.map +1 -0
  26. package/dist/helpers/color.d.ts +11 -0
  27. package/dist/helpers/color.js +57 -0
  28. package/dist/helpers/color.js.map +1 -0
  29. package/dist/helpers/cookies.d.ts +6 -0
  30. package/dist/helpers/cookies.js +56 -0
  31. package/dist/helpers/cookies.js.map +1 -0
  32. package/dist/helpers/date.d.ts +43 -0
  33. package/dist/helpers/date.js +158 -0
  34. package/dist/helpers/date.js.map +1 -0
  35. package/dist/helpers/debug.d.ts +33 -0
  36. package/dist/helpers/debug.js +177 -0
  37. package/dist/helpers/debug.js.map +1 -0
  38. package/dist/helpers/emails.d.ts +2 -0
  39. package/dist/helpers/emails.js +10 -0
  40. package/dist/helpers/emails.js.map +1 -0
  41. package/dist/helpers/eval.d.ts +1 -0
  42. package/dist/helpers/eval.js +10 -0
  43. package/dist/helpers/eval.js.map +1 -0
  44. package/dist/helpers/file.d.ts +11 -0
  45. package/dist/helpers/file.js +55 -0
  46. package/dist/helpers/file.js.map +1 -0
  47. package/dist/helpers/flatted.d.ts +20 -0
  48. package/dist/helpers/flatted.js +135 -0
  49. package/dist/helpers/flatted.js.map +1 -0
  50. package/dist/helpers/functions.d.ts +4 -0
  51. package/dist/helpers/functions.js +17 -0
  52. package/dist/helpers/functions.js.map +1 -0
  53. package/dist/helpers/graph/calendar.types.d.ts +3 -0
  54. package/dist/helpers/graph/calendar.types.js +15 -0
  55. package/dist/helpers/graph/calendar.types.js.map +1 -0
  56. package/dist/helpers/http.d.ts +25 -0
  57. package/dist/helpers/http.js +70 -0
  58. package/dist/helpers/http.js.map +1 -0
  59. package/dist/helpers/images.d.ts +16 -0
  60. package/dist/helpers/images.js +21 -0
  61. package/dist/helpers/images.js.map +1 -0
  62. package/dist/helpers/index.d.ts +29 -0
  63. package/dist/helpers/index.js +46 -0
  64. package/dist/helpers/index.js.map +1 -0
  65. package/dist/helpers/json.d.ts +3 -0
  66. package/dist/helpers/json.js +44 -0
  67. package/dist/helpers/json.js.map +1 -0
  68. package/dist/helpers/md5.d.ts +5 -0
  69. package/dist/helpers/md5.js +172 -0
  70. package/dist/helpers/md5.js.map +1 -0
  71. package/dist/helpers/objects.d.ts +49 -0
  72. package/dist/helpers/objects.js +271 -0
  73. package/dist/helpers/objects.js.map +1 -0
  74. package/dist/helpers/promises.d.ts +14 -0
  75. package/dist/helpers/promises.js +112 -0
  76. package/dist/helpers/promises.js.map +1 -0
  77. package/dist/helpers/random.d.ts +2 -0
  78. package/dist/helpers/random.js +32 -0
  79. package/dist/helpers/random.js.map +1 -0
  80. package/dist/helpers/scheduler/scheduler.d.ts +39 -0
  81. package/dist/helpers/scheduler/scheduler.js +109 -0
  82. package/dist/helpers/scheduler/scheduler.js.map +1 -0
  83. package/dist/helpers/sharepoint.d.ts +112 -0
  84. package/dist/helpers/sharepoint.js +629 -0
  85. package/dist/helpers/sharepoint.js.map +1 -0
  86. package/dist/helpers/strings.d.ts +56 -0
  87. package/dist/helpers/strings.js +282 -0
  88. package/dist/helpers/strings.js.map +1 -0
  89. package/dist/helpers/typecheckers.d.ts +56 -0
  90. package/dist/helpers/typecheckers.js +274 -0
  91. package/dist/helpers/typecheckers.js.map +1 -0
  92. package/dist/helpers/url.d.ts +46 -0
  93. package/dist/helpers/url.js +199 -0
  94. package/dist/helpers/url.js.map +1 -0
  95. package/dist/helpers/urlhelper.d.ts +16 -0
  96. package/dist/helpers/urlhelper.js +96 -0
  97. package/dist/helpers/urlhelper.js.map +1 -0
  98. package/dist/index.d.ts +15 -0
  99. package/dist/index.js +37 -0
  100. package/dist/index.js.map +1 -0
  101. package/dist/types/common.types.d.ts +19 -0
  102. package/dist/types/common.types.js +4 -0
  103. package/dist/types/common.types.js.map +1 -0
  104. package/dist/types/flatted.types.d.ts +49 -0
  105. package/dist/types/flatted.types.js +3 -0
  106. package/dist/types/flatted.types.js.map +1 -0
  107. package/dist/types/globals.types.d.ts +6 -0
  108. package/dist/types/globals.types.js +3 -0
  109. package/dist/types/globals.types.js.map +1 -0
  110. package/dist/types/graph/calendar.types.d.ts +79 -0
  111. package/dist/types/graph/calendar.types.js +3 -0
  112. package/dist/types/graph/calendar.types.js.map +1 -0
  113. package/dist/types/graph/index.d.ts +1 -0
  114. package/dist/types/graph/index.js +18 -0
  115. package/dist/types/graph/index.js.map +1 -0
  116. package/dist/types/index.d.ts +11 -0
  117. package/dist/types/index.js +28 -0
  118. package/dist/types/index.js.map +1 -0
  119. package/dist/types/knownscript.types.d.ts +22 -0
  120. package/dist/types/knownscript.types.js +3 -0
  121. package/dist/types/knownscript.types.js.map +1 -0
  122. package/dist/types/libs/datajs.types.d.ts +29 -0
  123. package/dist/types/libs/datajs.types.js +3 -0
  124. package/dist/types/libs/datajs.types.js.map +1 -0
  125. package/dist/types/libs/ics.types.d.ts +29 -0
  126. package/dist/types/libs/ics.types.js +3 -0
  127. package/dist/types/libs/ics.types.js.map +1 -0
  128. package/dist/types/libs/index.d.ts +3 -0
  129. package/dist/types/libs/index.js +20 -0
  130. package/dist/types/libs/index.js.map +1 -0
  131. package/dist/types/libs/msal.types.d.ts +33 -0
  132. package/dist/types/libs/msal.types.js +63 -0
  133. package/dist/types/libs/msal.types.js.map +1 -0
  134. package/dist/types/locales.d.ts +122 -0
  135. package/dist/types/locales.js +1 -0
  136. package/dist/types/locales.js.map +1 -0
  137. package/dist/types/localstoragecache.types.d.ts +8 -0
  138. package/dist/types/localstoragecache.types.js +3 -0
  139. package/dist/types/localstoragecache.types.js.map +1 -0
  140. package/dist/types/moment.d.ts +6 -0
  141. package/dist/types/moment.js +1 -0
  142. package/dist/types/moment.js.map +1 -0
  143. package/dist/types/regex.types.d.ts +14 -0
  144. package/dist/types/regex.types.js +3 -0
  145. package/dist/types/regex.types.js.map +1 -0
  146. package/dist/types/rest.types.d.ts +81 -0
  147. package/dist/types/rest.types.js +24 -0
  148. package/dist/types/rest.types.js.map +1 -0
  149. package/dist/types/sharepoint.types.d.ts +1432 -0
  150. package/dist/types/sharepoint.types.js +629 -0
  151. package/dist/types/sharepoint.types.js.map +1 -0
  152. package/dist/types/sharepoint.utils.types.d.ts +246 -0
  153. package/dist/types/sharepoint.utils.types.js +26 -0
  154. package/dist/types/sharepoint.utils.types.js.map +1 -0
  155. package/dist/utils/_dependencies.d.ts +3 -0
  156. package/dist/utils/_dependencies.js +24 -0
  157. package/dist/utils/_dependencies.js.map +1 -0
  158. package/dist/utils/base64.d.ts +2 -0
  159. package/dist/utils/base64.js +41 -0
  160. package/dist/utils/base64.js.map +1 -0
  161. package/dist/utils/consolelogger.d.ts +73 -0
  162. package/dist/utils/consolelogger.js +281 -0
  163. package/dist/utils/consolelogger.js.map +1 -0
  164. package/dist/utils/date.d.ts +10 -0
  165. package/dist/utils/date.js +30 -0
  166. package/dist/utils/date.js.map +1 -0
  167. package/dist/utils/emails.d.ts +2 -0
  168. package/dist/utils/emails.js +24 -0
  169. package/dist/utils/emails.js.map +1 -0
  170. package/dist/utils/index.d.ts +13 -0
  171. package/dist/utils/index.js +31 -0
  172. package/dist/utils/index.js.map +1 -0
  173. package/dist/utils/knownscript.d.ts +99 -0
  174. package/dist/utils/knownscript.js +261 -0
  175. package/dist/utils/knownscript.js.map +1 -0
  176. package/dist/utils/localstoragecache.d.ts +19 -0
  177. package/dist/utils/localstoragecache.js +372 -0
  178. package/dist/utils/localstoragecache.js.map +1 -0
  179. package/dist/utils/rest.d.ts +17 -0
  180. package/dist/utils/rest.js +402 -0
  181. package/dist/utils/rest.js.map +1 -0
  182. package/dist/utils/script.d.ts +33 -0
  183. package/dist/utils/script.js +169 -0
  184. package/dist/utils/script.js.map +1 -0
  185. package/dist/utils/sharepoint.rest/common.d.ts +32 -0
  186. package/dist/utils/sharepoint.rest/common.js +146 -0
  187. package/dist/utils/sharepoint.rest/common.js.map +1 -0
  188. package/dist/utils/sharepoint.rest/date.d.ts +2 -0
  189. package/dist/utils/sharepoint.rest/date.js +57 -0
  190. package/dist/utils/sharepoint.rest/date.js.map +1 -0
  191. package/dist/utils/sharepoint.rest/file.folder.d.ts +58 -0
  192. package/dist/utils/sharepoint.rest/file.folder.js +305 -0
  193. package/dist/utils/sharepoint.rest/file.folder.js.map +1 -0
  194. package/dist/utils/sharepoint.rest/index.d.ts +11 -0
  195. package/dist/utils/sharepoint.rest/index.js +28 -0
  196. package/dist/utils/sharepoint.rest/index.js.map +1 -0
  197. package/dist/utils/sharepoint.rest/item.d.ts +81 -0
  198. package/dist/utils/sharepoint.rest/item.js +444 -0
  199. package/dist/utils/sharepoint.rest/item.js.map +1 -0
  200. package/dist/utils/sharepoint.rest/list.d.ts +228 -0
  201. package/dist/utils/sharepoint.rest/list.js +868 -0
  202. package/dist/utils/sharepoint.rest/list.js.map +1 -0
  203. package/dist/utils/sharepoint.rest/listutils/GetListItemsByCaml.d.ts +19 -0
  204. package/dist/utils/sharepoint.rest/listutils/GetListItemsByCaml.js +629 -0
  205. package/dist/utils/sharepoint.rest/listutils/GetListItemsByCaml.js.map +1 -0
  206. package/dist/utils/sharepoint.rest/listutils/GetListItemsById.d.ts +14 -0
  207. package/dist/utils/sharepoint.rest/listutils/GetListItemsById.js +222 -0
  208. package/dist/utils/sharepoint.rest/listutils/GetListItemsById.js.map +1 -0
  209. package/dist/utils/sharepoint.rest/listutils/common.d.ts +3 -0
  210. package/dist/utils/sharepoint.rest/listutils/common.js +198 -0
  211. package/dist/utils/sharepoint.rest/listutils/common.js.map +1 -0
  212. package/dist/utils/sharepoint.rest/user-search.d.ts +76 -0
  213. package/dist/utils/sharepoint.rest/user-search.js +239 -0
  214. package/dist/utils/sharepoint.rest/user-search.js.map +1 -0
  215. package/dist/utils/sharepoint.rest/user.d.ts +71 -0
  216. package/dist/utils/sharepoint.rest/user.js +404 -0
  217. package/dist/utils/sharepoint.rest/user.js.map +1 -0
  218. package/dist/utils/sharepoint.rest/web.d.ts +107 -0
  219. package/dist/utils/sharepoint.rest/web.js +929 -0
  220. package/dist/utils/sharepoint.rest/web.js.map +1 -0
  221. package/dist/utils/sod.d.ts +29 -0
  222. package/dist/utils/sod.js +177 -0
  223. package/dist/utils/sod.js.map +1 -0
  224. package/package.json +60 -0
  225. package/readme.md +13 -0
  226. package/src/_dependencies.ts +2 -0
  227. package/src/helpers/Guid.ts +182 -0
  228. package/src/helpers/_dependencies.ts +3 -0
  229. package/src/helpers/base64.ts +174 -0
  230. package/src/helpers/browser.test.js +9 -0
  231. package/src/helpers/browser.ts +1299 -0
  232. package/src/helpers/browserinfo.ts +293 -0
  233. package/src/helpers/collections.base.test.js +26 -0
  234. package/src/helpers/collections.base.ts +439 -0
  235. package/src/helpers/collections.ts +108 -0
  236. package/src/helpers/color.ts +55 -0
  237. package/src/helpers/cookies.ts +55 -0
  238. package/src/helpers/date.test.js +97 -0
  239. package/src/helpers/date.ts +163 -0
  240. package/src/helpers/debug.ts +187 -0
  241. package/src/helpers/emails.ts +7 -0
  242. package/src/helpers/eval.ts +5 -0
  243. package/src/helpers/file.test.js +51 -0
  244. package/src/helpers/file.ts +59 -0
  245. package/src/helpers/flatted.ts +150 -0
  246. package/src/helpers/functions.ts +17 -0
  247. package/src/helpers/graph/calendar.types.ts +11 -0
  248. package/src/helpers/http.ts +70 -0
  249. package/src/helpers/images.ts +23 -0
  250. package/src/helpers/index.ts +29 -0
  251. package/src/helpers/json.ts +39 -0
  252. package/src/helpers/md5.ts +190 -0
  253. package/src/helpers/objects.test.js +27 -0
  254. package/src/helpers/objects.ts +256 -0
  255. package/src/helpers/promises.test.js +18 -0
  256. package/src/helpers/promises.ts +102 -0
  257. package/src/helpers/random.ts +27 -0
  258. package/src/helpers/scheduler/scheduler.test.js +104 -0
  259. package/src/helpers/scheduler/scheduler.ts +132 -0
  260. package/src/helpers/sharepoint.ts +681 -0
  261. package/src/helpers/strings.test.js +43 -0
  262. package/src/helpers/strings.ts +288 -0
  263. package/src/helpers/typecheckers.test.js +35 -0
  264. package/src/helpers/typecheckers.ts +263 -0
  265. package/src/helpers/url.test.js +18 -0
  266. package/src/helpers/url.ts +202 -0
  267. package/src/helpers/urlhelper.ts +104 -0
  268. package/src/index.ts +24 -0
  269. package/src/types/common.types.ts +16 -0
  270. package/src/types/flatted.types.ts +60 -0
  271. package/src/types/globals.types.ts +7 -0
  272. package/src/types/graph/calendar.types.ts +81 -0
  273. package/src/types/graph/index.ts +1 -0
  274. package/src/types/index.ts +12 -0
  275. package/src/types/knownscript.types.ts +19 -0
  276. package/src/types/libs/datajs.types.ts +29 -0
  277. package/src/types/libs/ics.types.ts +31 -0
  278. package/src/types/libs/index.ts +4 -0
  279. package/src/types/libs/msal.types.ts +79 -0
  280. package/src/types/locales.ts +125 -0
  281. package/src/types/localstoragecache.types.ts +9 -0
  282. package/src/types/moment.ts +7 -0
  283. package/src/types/regex.types.ts +17 -0
  284. package/src/types/rest.types.ts +94 -0
  285. package/src/types/sharepoint.types.ts +1413 -0
  286. package/src/types/sharepoint.utils.types.ts +246 -0
  287. package/src/utils/_dependencies.ts +4 -0
  288. package/src/utils/base64.ts +27 -0
  289. package/src/utils/consolelogger.ts +315 -0
  290. package/src/utils/date.ts +36 -0
  291. package/src/utils/emails.ts +25 -0
  292. package/src/utils/index.ts +13 -0
  293. package/src/utils/knownscript.ts +280 -0
  294. package/src/utils/localstoragecache.ts +419 -0
  295. package/src/utils/rest.ts +465 -0
  296. package/src/utils/script.ts +168 -0
  297. package/src/utils/sharepoint.rest/common.ts +149 -0
  298. package/src/utils/sharepoint.rest/date.ts +61 -0
  299. package/src/utils/sharepoint.rest/file.folder.ts +368 -0
  300. package/src/utils/sharepoint.rest/index.ts +11 -0
  301. package/src/utils/sharepoint.rest/item.ts +456 -0
  302. package/src/utils/sharepoint.rest/list.ts +1144 -0
  303. package/src/utils/sharepoint.rest/listutils/GetListItemsByCaml.ts +750 -0
  304. package/src/utils/sharepoint.rest/listutils/GetListItemsById.ts +265 -0
  305. package/src/utils/sharepoint.rest/listutils/common.ts +202 -0
  306. package/src/utils/sharepoint.rest/user-search.ts +254 -0
  307. package/src/utils/sharepoint.rest/user.ts +447 -0
  308. package/src/utils/sharepoint.rest/web.ts +1031 -0
  309. package/src/utils/sod.ts +193 -0
  310. package/tsconfig.json +21 -0
@@ -0,0 +1,280 @@
1
+ import { ICS, IDataJs, IKnownScript, IMSAL, assign, isNullOrUndefined, ksGlobal } from "./_dependencies";
2
+ import script from "./script";
3
+
4
+ /** /products/common/scripts/ */
5
+ export const commonScriptsPrefix = "/products/common/scripts/";
6
+ /** /products/modern/scripts/ */
7
+ export const modernScriptsPrefix = "/products/modern/scripts/";
8
+
9
+ export class KnownScriptLoader<TypeOfGlobal> implements IKnownScript {
10
+ public url: string;
11
+ public dependencies?: IKnownScript[];
12
+ public global: ksGlobal;
13
+ public sodName?: string;
14
+ public css?: string[];
15
+ public rtlCss?: string[];
16
+ public forceMin?: boolean;
17
+
18
+ public _hash?: string;
19
+
20
+ private _globalInstance?: TypeOfGlobal;
21
+ public get globalInstance() { return this._globalInstance; }
22
+
23
+ public constructor(definition: IKnownScript) {
24
+ assign(this, definition);
25
+ }
26
+ public async load(): Promise<TypeOfGlobal> {
27
+ if (isNullOrUndefined(this.globalInstance))
28
+ this._globalInstance = await script.Instance.loadKnownScript(this) as TypeOfGlobal;
29
+ return this.globalInstance;
30
+ }
31
+ public loadSync(): TypeOfGlobal {
32
+ if (isNullOrUndefined(this.globalInstance))
33
+ this._globalInstance = script.Instance.loadKnownScript_Sync(this) as TypeOfGlobal;
34
+ return this.globalInstance;
35
+ }
36
+ }
37
+
38
+ /** loads into $kw */
39
+ export var jQueryKnownScript = new KnownScriptLoader<any>({
40
+ url: commonScriptsPrefix + "jquery-1.8.2.min.js",
41
+ global: "$kw",
42
+ sodName: "kwizcom.common.jquery-1.8.2.js"
43
+ });
44
+
45
+ /** loads into moment */
46
+ export var MomentJSKnownScript = new KnownScriptLoader<typeof momentJS>({
47
+ url: "/libs/moment/moment.min.js",
48
+ global: "moment"
49
+ });
50
+
51
+ /** loads into moment.tz */
52
+ export var MomentTimezoneJSKnownScript = new KnownScriptLoader<typeof monentJSTimeZone>({
53
+ url: "/libs/moment/moment-timezone.min.js",
54
+ global: "moment.tz",
55
+ dependencies: [MomentJSKnownScript]
56
+ });
57
+ /** loads into kLocales or kwizcom.kLocales */
58
+ export var LocaleKnownScript = new KnownScriptLoader<IKLocales>({
59
+ url: commonScriptsPrefix + "locale.min.js",
60
+ global: "kwizcom.kLocales",
61
+ sodName: "kwizcom.common.locale.js",
62
+ dependencies: [MomentTimezoneJSKnownScript]
63
+ });
64
+ /** Loads jQuery and Select2 with the CSS file for Select2 */
65
+ export var Select2KnownScript = new KnownScriptLoader<any>({
66
+ url: commonScriptsPrefix + "select2.min.js",
67
+ global: "Select2.class",
68
+ sodName: "kwizcom.common.select2.js",
69
+ css: ["/products/common/css/select2.min.css"],
70
+ dependencies: [jQueryKnownScript]
71
+ });
72
+ /** Loads fabric and its CSS */
73
+ export var FabricKnownScript = new KnownScriptLoader<any>({
74
+ url: "/libs/office-ui-fabric-js/1.4.0/js/fabric.min.js?prefix=kw",
75
+ global: "kwfabric",
76
+ //Issue 6494 rename fabric.css since SP modern page will remove any css that ends with fabric.css or fabric.min.css
77
+ css: ["/libs/office-ui-fabric-js/1.4.0/css/fabric.kwizcom.min.css?prefix=kw",
78
+ "/libs/office-ui-fabric-js/1.4.0/css/fabric.kwizcom.components.min.css?prefix=kw"],
79
+ rtlCss: ["/libs/office-ui-fabric-js/1.4.0/css/fabric.kwizcom.rtl.min.css?prefix=kw",
80
+ "/libs/office-ui-fabric-js/1.4.0/css/fabric.kwizcom.components.rtl.min.css?prefix=kw"]
81
+ });
82
+ /** loads into kwizcom.aplfe.api */
83
+ export var APLFEApiKnownScript = new KnownScriptLoader<any>({
84
+ url: "/products/aplfe/scripts/kwizcom.aplfe.api.min.js",
85
+ global: "kwizcom.aplfe.api",
86
+ sodName: "kwizcom.aplfe.api.js"
87
+ });
88
+
89
+ /** loads into KWizComRepeatingRowsControlBuilder */
90
+ export var RRWControlBuilderKnownScript = new KnownScriptLoader<any>({
91
+ url: "/products/aprrw/scripts/controlbuilder.min.js",
92
+ global: "KWizComRepeatingRowsControlBuilder",
93
+ dependencies: [jQueryKnownScript]
94
+ });
95
+
96
+ /** loads into kwOfficeUiFabricReact */
97
+ export var OfficeUiFabricReactKnownScript = new KnownScriptLoader<any>({
98
+ url: "/libs/office-ui-fabric-react/office-ui-fabric-react.js",
99
+ global: "kwizcom.OfficeUiFabricReact"
100
+ });
101
+
102
+ /** loads into $kw.ui */
103
+ export var jQueryUIKnownScript = new KnownScriptLoader<any>({
104
+ url: commonScriptsPrefix + "jquery-ui-1.9.2.custom.min.js",
105
+ global: "$kw.ui",
106
+ sodName: "kwizcom.common.jquery-ui-1.9.2.custom.js",
107
+ dependencies: [jQueryKnownScript],
108
+ css: ["/products/common/css/jquery-ui.min.css"]
109
+ });
110
+ /** loads into $kw.ui.touchLoded */
111
+ export var jQueryTouchPunchKnownScript = new KnownScriptLoader<any>({
112
+ url: commonScriptsPrefix + "jquery.ui.touch-punch.min.js",
113
+ global: "$kw.ui.touchLoded",
114
+ dependencies: [jQueryUIKnownScript]
115
+ });
116
+ /** loads into $kw.fn.camera */
117
+ export var CameraKnownScript = new KnownScriptLoader<any>({
118
+ url: "/libs/camera/js/camera.min.js",
119
+ global: "$kw.fn.camera",
120
+ dependencies: [jQueryUIKnownScript],
121
+ css: ["/libs/camera/css/camera.min.css"]
122
+ });
123
+ /** loads into flatpickr */
124
+ export var FlatPickerKnownScript = new KnownScriptLoader<any>({
125
+ url: "/libs/flatpickr/flatpickr.min.js",
126
+ global: "flatpickr",
127
+ css: ["/libs/flatpickr/flatpickr.min.css"]
128
+ });
129
+ /** loads into noUiSlider */
130
+ export var NoUiSliderKnownScript = new KnownScriptLoader<any>({
131
+ url: "/libs/nouislider/nouislider.min.js",
132
+ global: "noUiSlider",
133
+ css: ["/libs/nouislider/nouislider.min.css"]
134
+ });
135
+ /** loads into blueimp */
136
+ export var BlueImpGalleryKnownScript = new KnownScriptLoader<any>({
137
+ url: "/libs/blueimp-gallery/js/blueimp-gallery.min.js",
138
+ global: "blueimp",
139
+ css: ["/libs/blueimp-gallery/css/blueimp-gallery.min.css"]
140
+ });
141
+ /** loads into dhx */
142
+ export var dhxDiagramKnownScript = new KnownScriptLoader<any>({
143
+ url: "/libs/dhtmlx/diagram.min.js",
144
+ global: "dhx",
145
+ css: ["/libs/dhtmlx/diagram.min.css"]
146
+ });
147
+ /** loads into dragscroll */
148
+ export var dragScrollKnownScript = new KnownScriptLoader<any>({
149
+ url: "/libs/dragscroll/dragscroll.min.js",
150
+ global: "dragscroll"
151
+ });
152
+ /** loads into getOrgChart */
153
+ export var getOrgChartKnownScript = new KnownScriptLoader<any>({
154
+ url: "/libs/getorgchart/getorgchart.min.js",
155
+ global: "getOrgChart",
156
+ css: ["/libs/getorgchart/getorgchart.min.css"]
157
+ });
158
+ /** loads into OrgChart */
159
+ export var OrgChartJsKnownScript = new KnownScriptLoader<any>({
160
+ url: "/libs/orgchartjs/orgchart.min.js",
161
+ global: "OrgChart"
162
+ });
163
+ /** loads into photopile */
164
+ export var PhotopileKnownScript = new KnownScriptLoader<any>({
165
+ url: "/libs/photopile/js/photopile.min.js",
166
+ global: "photopile",
167
+ dependencies: [jQueryTouchPunchKnownScript],
168
+ css: ["/libs/photopile/css/photopile.min.css"]
169
+ });
170
+
171
+ /** loads into $kw.fn.fullCalendar */
172
+ export var fullCalendarKnownScript = new KnownScriptLoader<any>({
173
+ url: "/libs/fullcalendar/fullcalendar.min.js",
174
+ global: "$kw.fn.fullCalendar",
175
+ dependencies: [jQueryKnownScript, MomentTimezoneJSKnownScript],
176
+ css: ["/libs/fullcalendar/fullcalendar.min.css"]
177
+ });
178
+
179
+ /** loads into spEventsParser */
180
+ export var SpEventsParserKnownScript = new KnownScriptLoader<{
181
+ parseEvent(item: any, startDate: Date, endDate: Date): any[];
182
+ }>({
183
+ url: commonScriptsPrefix + "sp-events-parser/sp-events-parser.min.js",
184
+ global: "spEventsParser"
185
+ });
186
+
187
+ /** loads into kwizcom.controls.Conditions */
188
+ export var ConditionsKnownScript = new KnownScriptLoader<any>({
189
+ url: commonScriptsPrefix + "controls/conditions.min.js",
190
+ global: "kwizcom.controls.Conditions",
191
+ dependencies: [LocaleKnownScript]
192
+ });
193
+ /** loads into KWizComCountdownControlBuilder */
194
+ export var CountdownControlBuilderKnownScript = new KnownScriptLoader<any>({
195
+ url: "/products/apcnt/scripts/controlbuilder.min.js",
196
+ global: "KWizComCountdownControlBuilder",
197
+ dependencies: [LocaleKnownScript]
198
+ });
199
+ /** loads into SP.UI.ModalDialog.showErrorDialog */
200
+ export var OnPremPolyfillKnownScript = new KnownScriptLoader<any>({
201
+ url: commonScriptsPrefix + "onprem.polyfill.min.js",
202
+ sodName: "kwizcom.common.onprem.polyfill.js",
203
+ global: "SP.UI.ModalDialog.showErrorDialog"
204
+ });
205
+ /** loads into kwizcom.datajs */
206
+ export var DataJSKnownScript = new KnownScriptLoader<IDataJs>({
207
+ url: "/libs/datajs/datajs.min.js",
208
+ global: "kwizcom.OData"
209
+ });
210
+ /** loads into tinymce */
211
+ export var TinyMCEKnownScript = new KnownScriptLoader<any>({
212
+ url: "/libs/tinymce/tinymce.min.js",
213
+ forceMin: true,
214
+ global: "tinymce"
215
+ });
216
+ /** loads into kwizcom.monaco */
217
+ export var monacoKnownScript = new KnownScriptLoader<any>({
218
+ url: "/libs/monaco/monaco.js",
219
+ global: "kwizcom.monaco"
220
+ });
221
+ /** loads into kwizcom.ModernUILibrary.FormPage */
222
+ export var ModernUIListFormKnownScript = new KnownScriptLoader<any>({
223
+ url: modernScriptsPrefix + "forms/formpage.min.js",
224
+ global: "kwizcom.ModernUILibrary.FormPage",
225
+ //dependencies: [OfficeUiFabricReact]
226
+ });
227
+ /** loads into jsonPath */
228
+ export var jsonPathKnownScript = new KnownScriptLoader<any>({
229
+ url: commonScriptsPrefix + "JSONPath.min.js",
230
+ global: "jsonPath"
231
+ });
232
+
233
+ /** loads into _global_kwizcom_appas_modern_core */
234
+ export var PasteModernCoreKnownScript = new KnownScriptLoader<any>({
235
+ url: "/products/appas/scripts/kwizcom.pasteplus.modern.core.min.js",
236
+ global: "$_global_kwizcom_appas_modern_core",
237
+ //dependencies: [OfficeUiFabricReact]
238
+ });
239
+ /** loads into kwizcom.libs.msal */
240
+ export var msalKnownScript = new KnownScriptLoader<IMSAL>({
241
+ url: commonScriptsPrefix + "msal/msal.min.js",
242
+ global: "kwizcom.libs.msal"
243
+ });
244
+ /** loads into kwizcom.libs.ics */
245
+ export var icsKnownScript = new KnownScriptLoader<ICS>({
246
+ url: "/libs/ics/ics.min.js",
247
+ global: "kwizcom.libs.ics"
248
+ });
249
+
250
+ var _jQueryTmplKnownScript = new KnownScriptLoader<any>({
251
+ url: "/libs/jquery/js/jquery.tmpl.min.js",
252
+ global: "$kw.fn.tmpl", forceMin: true,
253
+ dependencies: [jQueryKnownScript]
254
+ });
255
+ var _jQueryEasingKnownScript = new KnownScriptLoader<any>({
256
+ url: "/libs/jquery/js/jquery.easing.1.3.js",
257
+ global: "$kw.easing",
258
+ dependencies: [jQueryKnownScript]
259
+ });
260
+ var _jQueryElastislideKnownScript = new KnownScriptLoader<any>({
261
+ url: "/libs/jquery/js/jquery.elastislide.js",
262
+ global: "$kw.fn.elastislide",
263
+ css: ["/libs/jquery/css/elastislide.css"],
264
+ dependencies: [jQueryKnownScript]
265
+ });
266
+ /** Responsive Image Gallery */
267
+ export var rigKnownScript = new KnownScriptLoader<(containerSelector: string, options?: {
268
+ mode?: "carousel" | "fullview";
269
+ anim?: boolean;
270
+ template?: string;
271
+ /** allow html in image description */
272
+ allowHTML?: boolean;
273
+ hideViewModes?: boolean;
274
+
275
+ }) => { addItems: (elm) => void; }>({
276
+ url: "/libs/rig/js/gallery.js",
277
+ global: "kwizcom.libs.rig",
278
+ css: ["/libs/rig/css/style.css"],
279
+ dependencies: [jQueryKnownScript, _jQueryTmplKnownScript, _jQueryEasingKnownScript, _jQueryElastislideKnownScript]
280
+ });
@@ -0,0 +1,419 @@
1
+ import { $w, BuildNumber, ILocalStorageCacheLifetime, flatted, getGlobal, isDate, isDebug, isNullOrEmptyString, isNullOrUndefined, isNumber, jsonParse, sizeOf } from "./_dependencies";
2
+ import { ConsoleLogger } from "./consolelogger";
3
+
4
+ /**key with prefix, value is a date string */
5
+ interface IExpirationsDictionary {
6
+ [keyWithPRefix: string]: string;
7
+ build: string;
8
+ }
9
+
10
+ let logger = ConsoleLogger.get("localstoragecache");
11
+
12
+ export const keyPrefix = "kw$_";
13
+ export const LOCAL_STORAGE_PREFIX = "kwizcom-localstorage-cache";
14
+ export const LOCAL_STORGAGE_EXPIRATIONS_KEY = LOCAL_STORAGE_PREFIX + "-expirations";
15
+ export const DEFAULT_EXPIRATION = 20 * 60 * 1000; // 20 minutes;
16
+ /** key (no prefix) is kept in lower case. not case sensitive */
17
+ var _cache = getGlobal<{
18
+ purgeCalled: boolean;
19
+ expirations: IExpirationsDictionary;
20
+ [keyNoPrefixToLower: string]: any;
21
+ }>("common_utils_localstoragecache_module_cache");
22
+ var _supportsLocalStorage: boolean = null;
23
+
24
+ function _parseExpiration(exp: number | ILocalStorageCacheLifetime | Date): Date {
25
+ var expirationDate: Date;
26
+
27
+ if (isNumber(exp) && exp > 0) {
28
+ expirationDate = new Date();
29
+ expirationDate.setMilliseconds(expirationDate.getMilliseconds() + exp);
30
+ } else if (exp instanceof Date) {
31
+ expirationDate = exp;
32
+ } else if (exp) {
33
+ var tempexp = exp as ILocalStorageCacheLifetime;
34
+ var seconds = typeof (tempexp.seconds) === "number" ? tempexp.seconds : undefined;
35
+ var minutes = typeof (tempexp.minutes) === "number" ? tempexp.minutes : undefined;
36
+ var hours = typeof (tempexp.hours) === "number" ? tempexp.hours : undefined;
37
+ var days = typeof (tempexp.days) === "number" ? tempexp.days : undefined;
38
+ var months = typeof (tempexp.months) === "number" ? tempexp.months : undefined;
39
+ var years = typeof (tempexp.years) === "number" ? tempexp.years : undefined;
40
+
41
+ if (seconds || minutes || hours || days || months || years) {
42
+ expirationDate = new Date();
43
+
44
+ if (seconds) {
45
+ expirationDate.setMilliseconds(expirationDate.getMilliseconds() + (seconds * 1000));
46
+ }
47
+
48
+ if (minutes) {
49
+ expirationDate.setMilliseconds(expirationDate.getMilliseconds() + (minutes * 60 * 1000));
50
+ }
51
+
52
+ if (hours) {
53
+ expirationDate.setMilliseconds(expirationDate.getMilliseconds() + (hours * 60 * 60 * 1000));
54
+ }
55
+
56
+ if (days) {
57
+ expirationDate.setMilliseconds(expirationDate.getMilliseconds() + (days * 24 * 60 * 60 * 1000));
58
+ }
59
+
60
+ if (months) {
61
+ expirationDate.setMonth(expirationDate.getMonth() + months);
62
+ }
63
+
64
+ if (years) {
65
+ expirationDate.setFullYear(expirationDate.getFullYear() + years);
66
+ }
67
+ }
68
+ }
69
+
70
+ if (!expirationDate) {
71
+ expirationDate = new Date();
72
+ expirationDate.setMilliseconds(expirationDate.getMilliseconds() + DEFAULT_EXPIRATION);
73
+ }
74
+
75
+ return expirationDate;
76
+ }
77
+
78
+ function _getCacheExpirations(): IExpirationsDictionary {
79
+ if (isNullOrUndefined(_cache.expirations)) {
80
+ _cache.expirations = jsonParse<IExpirationsDictionary>(_getItem(LOCAL_STORGAGE_EXPIRATIONS_KEY));
81
+
82
+ //ISSUE: 1525 - expire the cache if it was built with a different version number so that the cache
83
+ //is compatible with the current build
84
+ if (!isNullOrUndefined(_cache.expirations) && _cache.expirations.build !== BuildNumber.toString()) {
85
+ logger.log(`Purging cache because of build number change`)
86
+ purgeCache(true);
87
+ _cache.expirations = null;
88
+ }
89
+
90
+ if (isNullOrUndefined(_cache.expirations)) {
91
+ _cache.expirations = {
92
+ build: BuildNumber.toString()
93
+ };
94
+ }
95
+ }
96
+
97
+ return _cache.expirations;
98
+ }
99
+
100
+ function _saveCacheExpirations() {
101
+ if (!isNullOrUndefined(_cache.expirations) && sizeOf(_cache.expirations) > 0) {
102
+ _setItem(LOCAL_STORGAGE_EXPIRATIONS_KEY, JSON.stringify(_cache.expirations));
103
+ }
104
+ else {
105
+ _removeItem(LOCAL_STORGAGE_EXPIRATIONS_KEY);
106
+ }
107
+ }
108
+ function _setCacheExpiration(keyWithPrefix: string, expireDate: Date) {
109
+ var expirations = _getCacheExpirations();
110
+ expirations[keyWithPrefix] = expireDate.toString();
111
+ _saveCacheExpirations();
112
+ }
113
+
114
+ function _isKeyExpired(keyWithPrefix: string) {
115
+ var expirations = _getCacheExpirations();
116
+ if (expirations && expirations[keyWithPrefix]) {
117
+ var now = new Date();
118
+ var eDate = new Date(expirations[keyWithPrefix]);
119
+ if (now > eDate) {
120
+ try {
121
+ delete expirations[keyWithPrefix];
122
+ } catch (ex) {
123
+ expirations[keyWithPrefix] = undefined; // undefined variables are removed when passed to JSON.stringify
124
+ }
125
+
126
+ _saveCacheExpirations();
127
+ //has a date, it is expired.
128
+ return true;
129
+ }
130
+ //has a date, it is not expired yet.
131
+ return false;
132
+ }
133
+ //has no date or not in expirations at all - say it is expired...
134
+ return true;
135
+ }
136
+
137
+ function _getItem(key: string) {
138
+ try {
139
+ return localStorage.getItem(key);
140
+ } catch {
141
+ }
142
+ return null;
143
+ }
144
+
145
+ function _setItem(key: string, value: string) {
146
+ try {
147
+ localStorage.setItem(key, value);
148
+ return true;
149
+ } catch {
150
+ }
151
+ return false;
152
+ }
153
+
154
+ function _removeItem(key: string) {
155
+ try {
156
+ localStorage.removeItem(key);
157
+ return true;
158
+ } catch {
159
+ }
160
+ return false;
161
+ }
162
+
163
+ /**Get the size (KB) of all entries in local storage. Only returns the size for entries with kwizcom key prefix. */
164
+ function _getStoredSize() {
165
+ let keys = getCacheKeys();
166
+ let total = 0;
167
+ let length = 0;
168
+ let useBlob = 'Blob' in $w;
169
+
170
+ keys.forEach((key) => {
171
+ let v = _getItem(key);
172
+ if (!isNullOrEmptyString(v)) {
173
+ if (useBlob) {
174
+ length = (new Blob([v + key])).size;
175
+ } else {
176
+ length = ((v.length + key.length) * 2);
177
+ }
178
+ }
179
+ total += length;
180
+ });
181
+
182
+ return Number((total / 1024).toFixed(2));
183
+ }
184
+
185
+ export function isLocalStorageSupported() {
186
+ if (_supportsLocalStorage !== null) {
187
+ return _supportsLocalStorage;
188
+ }
189
+
190
+ var result;
191
+ try {
192
+ _setItem(LOCAL_STORAGE_PREFIX, LOCAL_STORAGE_PREFIX);
193
+ result = _getItem(LOCAL_STORAGE_PREFIX) === LOCAL_STORAGE_PREFIX;
194
+ _removeItem(LOCAL_STORAGE_PREFIX);
195
+ _supportsLocalStorage = result;
196
+ } catch (ex) {
197
+ _supportsLocalStorage = false;
198
+ }
199
+
200
+ return _supportsLocalStorage;
201
+ }
202
+
203
+ //#region exported methods
204
+ export function getCacheItem<T>(key: string, options?: {
205
+ /** Flatted allows serizlising circular dependency objects */
206
+ useFlatted?: boolean;
207
+ }): T {
208
+ key = key.toLowerCase();
209
+ let keyWithPrefix = keyPrefix + key;
210
+
211
+ if (typeof (_cache[key]) !== "undefined"
212
+ && _cache[key] !== null) {
213
+ return _cache[key] as T;
214
+ }
215
+
216
+ if (isLocalStorageSupported()) {
217
+ var value: string = _getItem(keyWithPrefix);
218
+ if (isNullOrUndefined(value)) {
219
+ return null;
220
+ }
221
+
222
+ let isExpired = _isKeyExpired(keyWithPrefix);
223
+
224
+ if (!isExpired) {
225
+ let valueAsT: T = options && options.useFlatted ? flatted.parse(value) as T : jsonParse<T>(value);
226
+ if (valueAsT !== null) {
227
+ _cache[key] = valueAsT;
228
+ return valueAsT;
229
+ } else {
230
+ _cache[key] = value;
231
+ return value as any as T;
232
+ }
233
+ }
234
+ //else remove it from cache
235
+ removeCacheItem(key);
236
+ }
237
+
238
+ return null;
239
+ }
240
+
241
+ export function setCacheItem(key: string, value: any, expiration: number | ILocalStorageCacheLifetime | Date, options?: {
242
+ /** Flatted allows serizlising circular dependency objects */
243
+ useFlatted?: boolean;
244
+ }): void {
245
+ if (isLocalStorageSupported()) {
246
+ key = key.toLowerCase();
247
+ removeCacheItem(key);
248
+
249
+ var val = null;
250
+ try {
251
+ if (options && options.useFlatted)
252
+ val = flatted.stringify(value);
253
+ else
254
+ val = JSON.stringify(value);
255
+ } catch (ex) {
256
+ logger.debug(`Object cannot be stored in local storage: ${ex && ex.message || ex} ${key}`);
257
+ return;//this put [object] in cache for me if object can't be stringified!
258
+ }
259
+
260
+ let keyWithPrefix = keyPrefix + key;
261
+
262
+ var expireDate = _parseExpiration(expiration);
263
+
264
+ let saved = _setItem(keyWithPrefix, val);
265
+ if (saved) {
266
+ _setCacheExpiration(keyWithPrefix, expireDate);
267
+ }
268
+
269
+ _cache[key] = value;
270
+ }
271
+ }
272
+
273
+ export function removeCacheItem(key: string) {
274
+ key = key.toLowerCase();
275
+ delete _cache[key];
276
+ let keyWithPrefix = keyPrefix + key;
277
+
278
+ if (isLocalStorageSupported()) {
279
+ _removeItem(key);//in case we have an old one
280
+ _removeItem(keyWithPrefix);
281
+ }
282
+ }
283
+
284
+ export function removeCacheItems(keys: string[]) {
285
+ keys.forEach((key) => {
286
+ removeCacheItem(key);
287
+ });
288
+ }
289
+
290
+ export function getCacheKeys() {
291
+ let keys: string[] = [];
292
+
293
+ if (isLocalStorageSupported()) {
294
+ keys = Object.keys(localStorage).filter((key) => {
295
+ return key.startsWith(keyPrefix);
296
+ }).map((key) => {
297
+ return key.substring(keyPrefix.length);
298
+ });
299
+ }
300
+
301
+ return keys;
302
+ }
303
+
304
+ /** remove expired cache keys created by this utility.
305
+ * to remove all keys (non-expired too) send removeAll=true
306
+ */
307
+ function purgeCache(removeAll?: boolean) {
308
+ if (!isLocalStorageSupported()) return;
309
+
310
+ var cacheExpirationsKeys = [
311
+ LOCAL_STORGAGE_EXPIRATIONS_KEY,
312
+ "kwizcom-aplfe-caching-expirations", // old clean up
313
+ "localStorageExpirations" // old clean up
314
+ ];
315
+
316
+ let now = new Date();
317
+
318
+ let nonExpiredKeys: string[] = [];
319
+
320
+ //get all expiration keys (key/expiration date/time)
321
+ for (let j = 0; j < cacheExpirationsKeys.length; j++) {
322
+ try {
323
+ let expirations = null;
324
+ let cacheExpirationsKey = cacheExpirationsKeys[j];
325
+
326
+ let removeAllForKey = removeAll || cacheExpirationsKey !== LOCAL_STORGAGE_EXPIRATIONS_KEY;
327
+
328
+ if (cacheExpirationsKey === "localStorageExpirations") {
329
+ //old format - load expirations from this one as well
330
+ expirations = _getItem(cacheExpirationsKey); // "key1^11/18/2011 5pm|key2^3/10/2012 3pm"
331
+ if (expirations) {
332
+ let arr = expirations.split("|"); // ["key1^11/18/2011 5pm","key2^3/10/2012 3pm"]
333
+ for (let i = 0; i < arr.length; i++) {
334
+ try {
335
+ let key_expiration_format = arr[i]; // "key1^11/18/2011 5pm"
336
+ let key = key_expiration_format.split("^")[0];
337
+ //old keys - remove all, all the time
338
+ _removeItem(key);//remove key from cache
339
+ } catch (e) { }
340
+ }
341
+ }
342
+ } else {
343
+ //new format
344
+ expirations = cacheExpirationsKey === LOCAL_STORGAGE_EXPIRATIONS_KEY ? _getCacheExpirations() : jsonParse(_getItem(cacheExpirationsKey));
345
+ if (expirations) {
346
+ let expirationKeys = Object.keys(expirations);
347
+ logger.group(() => {
348
+ expirationKeys.forEach(keyWithPrefix => {
349
+ try {
350
+ let shouldRemoveKey = removeAllForKey || !keyWithPrefix.startsWith(keyPrefix);
351
+ if (!shouldRemoveKey) {
352
+ //check specific key expiration
353
+ let expirationDate = new Date(expirations[keyWithPrefix]);
354
+ if (!isDate(expirationDate) || expirationDate < now) {
355
+ shouldRemoveKey = true;
356
+ delete expirations[keyWithPrefix];
357
+ logger.info(`purging key ${keyWithPrefix}`);
358
+ }
359
+ else {
360
+ nonExpiredKeys.push(keyWithPrefix);
361
+ }
362
+ }
363
+ if (shouldRemoveKey) _removeItem(keyWithPrefix);
364
+ } catch (e) {
365
+ logger.warn(`failed to remove key ${keyWithPrefix}`);
366
+ }
367
+ });
368
+ }, "Checking expired items", true);
369
+ }
370
+ }
371
+
372
+ if (cacheExpirationsKey === LOCAL_STORGAGE_EXPIRATIONS_KEY)
373
+ _saveCacheExpirations();
374
+ else//older keys - just remove them.
375
+ _removeItem(cacheExpirationsKey);
376
+ } catch (e) {
377
+ logger.warn(`something went terribly wrong ${e}`);
378
+ }
379
+ }
380
+
381
+ logger.group(() => {
382
+ logger.table(nonExpiredKeys);
383
+ //cleanup orphans
384
+ //loop on all keys
385
+ //if stats with: jsr_, kwfs| or keyPrefix - and not in nonExpiredKeys, it is an orphan. Remove it.
386
+ let localStorageKeys = Object.keys(localStorage);
387
+ for (let keyIdx = 0; keyIdx < localStorageKeys.length; keyIdx++) {
388
+ let key = localStorageKeys[keyIdx];
389
+ if (key.startsWith("jsr_") || key.startsWith("kwfs|")) {
390
+ logger.log(`removing old key ${key}`);
391
+ _removeItem(key);//old key
392
+ }
393
+ else if (key.startsWith(keyPrefix) && !nonExpiredKeys.includes(key))//orphan!
394
+ {
395
+ logger.log(`removing orphan key ${key}`);
396
+ _removeItem(key);
397
+ }
398
+ }
399
+ }, "Expired keys", true);
400
+ }
401
+
402
+ /** cleanup - remove all local storage keys created by this utility */
403
+ export function clearCache(): void {
404
+ return purgeCache(true);
405
+ }
406
+
407
+ if (!_cache.purgeCalled) {
408
+ //issue 7081 - purge all orphans/expired items
409
+ _cache.purgeCalled = true;
410
+ //clear expired cache items.
411
+ $w.setTimeout(() => {
412
+ purgeCache();
413
+ if (isDebug()) {
414
+ let size = _getStoredSize();
415
+ logger.debug(`Size of items in local storage: ${size}KB`);
416
+ }
417
+ }, 3000);
418
+ }
419
+ //#endregion