@splitsoftware/splitio-commons 0.1.1-canary.6 → 0.1.1-rc.18

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 (269) hide show
  1. package/cjs/evaluator/matchers/matcherTypes.js +4 -4
  2. package/cjs/evaluator/matchersTransform/index.js +11 -11
  3. package/cjs/evaluator/value/sanitize.js +6 -6
  4. package/cjs/listeners/browser.js +5 -2
  5. package/cjs/listeners/node.js +9 -2
  6. package/cjs/logger/constants.js +3 -1
  7. package/cjs/logger/messages/error.js +3 -2
  8. package/cjs/logger/messages/info.js +2 -2
  9. package/cjs/logger/messages/warn.js +2 -1
  10. package/cjs/readiness/readinessManager.js +10 -7
  11. package/cjs/sdkFactory/index.js +1 -1
  12. package/cjs/services/splitApi.js +9 -1
  13. package/cjs/services/splitHttpClient.js +5 -4
  14. package/cjs/storages/AbstractSplitsCacheSync.js +1 -1
  15. package/cjs/storages/inLocalStorage/index.js +5 -2
  16. package/cjs/storages/inMemory/InMemoryStorage.js +2 -0
  17. package/cjs/storages/inMemory/InMemoryStorageCS.js +2 -0
  18. package/cjs/storages/inRedis/SplitsCacheInRedis.js +6 -2
  19. package/cjs/storages/inRedis/index.js +5 -2
  20. package/cjs/storages/pluggable/SplitsCachePluggable.js +6 -2
  21. package/cjs/storages/pluggable/inMemoryWrapper.js +6 -7
  22. package/cjs/storages/pluggable/index.js +5 -2
  23. package/cjs/storages/pluggable/wrapperAdapter.js +0 -1
  24. package/cjs/sync/offline/splitsParser/splitsParserFromFile.js +92 -89
  25. package/cjs/sync/offline/splitsParser/splitsParserFromSettings.js +45 -42
  26. package/cjs/sync/offline/syncTasks/fromObjectSyncTask.js +14 -4
  27. package/cjs/sync/polling/fetchers/segmentChangesFetcher.js +0 -8
  28. package/cjs/sync/polling/updaters/mySegmentsUpdater.js +30 -10
  29. package/cjs/sync/polling/updaters/segmentChangesUpdater.js +2 -4
  30. package/cjs/sync/streaming/SSEClient/index.js +38 -20
  31. package/cjs/sync/streaming/SSEHandler/NotificationKeeper.js +7 -0
  32. package/cjs/sync/streaming/SSEHandler/NotificationParser.js +4 -1
  33. package/cjs/sync/streaming/SSEHandler/index.js +8 -9
  34. package/cjs/sync/streaming/SSEHandler/types.js +14 -0
  35. package/cjs/sync/streaming/UpdateWorkers/MySegmentsUpdateWorker.js +5 -5
  36. package/cjs/sync/streaming/UpdateWorkers/SegmentsUpdateWorker.js +2 -1
  37. package/cjs/sync/streaming/UpdateWorkers/SplitsUpdateWorker.js +5 -3
  38. package/cjs/sync/streaming/constants.js +3 -1
  39. package/cjs/sync/streaming/mySegmentsV2utils.js +75 -0
  40. package/cjs/sync/streaming/pushManager.js +148 -40
  41. package/cjs/sync/submitters/metricsSyncTask.js +1 -1
  42. package/cjs/sync/submitters/submitterSyncTask.js +2 -2
  43. package/cjs/sync/syncManagerFromFile.js +15 -0
  44. package/cjs/sync/syncManagerFromObject.js +14 -0
  45. package/cjs/sync/syncManagerOffline.js +3 -3
  46. package/cjs/sync/syncManagerOnline.js +18 -5
  47. package/cjs/sync/syncTask.js +1 -1
  48. package/cjs/trackers/impressionObserver/ImpressionObserver.js +0 -2
  49. package/cjs/trackers/impressionObserver/buildKey.js +3 -9
  50. package/cjs/trackers/impressionObserver/impressionObserverCS.js +2 -2
  51. package/cjs/trackers/impressionObserver/impressionObserverSS.js +3 -3
  52. package/cjs/utils/constants/index.js +4 -1
  53. package/cjs/utils/decompress/index.js +427 -0
  54. package/cjs/utils/murmur3/{commons.js → common.js} +2 -6
  55. package/cjs/utils/murmur3/murmur3.js +11 -12
  56. package/cjs/utils/murmur3/murmur3_128.js +7 -142
  57. package/cjs/utils/murmur3/murmur3_128_x86.js +154 -0
  58. package/cjs/utils/murmur3/murmur3_64.js +36 -0
  59. package/cjs/utils/murmur3/utfx.js +100 -106
  60. package/cjs/utils/promise/wrapper.js +14 -11
  61. package/cjs/utils/settingsValidation/index.js +5 -2
  62. package/cjs/utils/settingsValidation/localhost/index.js +20 -0
  63. package/cjs/utils/settingsValidation/splitFilters.js +0 -1
  64. package/cjs/utils/settingsValidation/storage/storageCS.js +18 -8
  65. package/cjs/utils/settingsValidation/url.js +1 -1
  66. package/esm/evaluator/matchers/matcherTypes.js +2 -2
  67. package/esm/evaluator/matchersTransform/index.js +12 -12
  68. package/esm/evaluator/value/sanitize.js +7 -7
  69. package/esm/listeners/browser.js +5 -2
  70. package/esm/listeners/node.js +9 -2
  71. package/esm/logger/constants.js +2 -0
  72. package/esm/logger/messages/error.js +3 -2
  73. package/esm/logger/messages/info.js +2 -2
  74. package/esm/logger/messages/warn.js +2 -1
  75. package/esm/readiness/readinessManager.js +10 -7
  76. package/esm/sdkFactory/index.js +1 -1
  77. package/esm/services/splitApi.js +9 -1
  78. package/esm/services/splitHttpClient.js +5 -4
  79. package/esm/storages/AbstractSplitsCacheSync.js +1 -1
  80. package/esm/storages/inLocalStorage/index.js +5 -2
  81. package/esm/storages/inMemory/InMemoryStorage.js +2 -0
  82. package/esm/storages/inMemory/InMemoryStorageCS.js +2 -0
  83. package/esm/storages/inRedis/SplitsCacheInRedis.js +6 -2
  84. package/esm/storages/inRedis/index.js +5 -2
  85. package/esm/storages/pluggable/SplitsCachePluggable.js +6 -2
  86. package/esm/storages/pluggable/inMemoryWrapper.js +6 -7
  87. package/esm/storages/pluggable/index.js +5 -2
  88. package/esm/storages/pluggable/wrapperAdapter.js +0 -1
  89. package/esm/sync/offline/splitsParser/splitsParserFromFile.js +90 -88
  90. package/esm/sync/offline/splitsParser/splitsParserFromSettings.js +43 -41
  91. package/esm/sync/offline/syncTasks/fromObjectSyncTask.js +15 -5
  92. package/esm/sync/polling/fetchers/segmentChangesFetcher.js +0 -8
  93. package/esm/sync/polling/updaters/mySegmentsUpdater.js +30 -10
  94. package/esm/sync/polling/updaters/segmentChangesUpdater.js +2 -4
  95. package/esm/sync/streaming/SSEClient/index.js +38 -20
  96. package/esm/sync/streaming/SSEHandler/NotificationKeeper.js +7 -0
  97. package/esm/sync/streaming/SSEHandler/NotificationParser.js +4 -1
  98. package/esm/sync/streaming/SSEHandler/index.js +9 -10
  99. package/esm/sync/streaming/SSEHandler/types.js +13 -1
  100. package/esm/sync/streaming/UpdateWorkers/MySegmentsUpdateWorker.js +5 -5
  101. package/esm/sync/streaming/UpdateWorkers/SegmentsUpdateWorker.js +2 -1
  102. package/esm/sync/streaming/UpdateWorkers/SplitsUpdateWorker.js +5 -3
  103. package/esm/sync/streaming/constants.js +2 -0
  104. package/esm/sync/streaming/mySegmentsV2utils.js +69 -0
  105. package/esm/sync/streaming/pushManager.js +150 -42
  106. package/esm/sync/submitters/metricsSyncTask.js +1 -1
  107. package/esm/sync/submitters/submitterSyncTask.js +2 -2
  108. package/esm/sync/syncManagerFromFile.js +11 -0
  109. package/esm/sync/syncManagerFromObject.js +10 -0
  110. package/esm/sync/syncManagerOffline.js +3 -3
  111. package/esm/sync/syncManagerOnline.js +18 -5
  112. package/esm/sync/syncTask.js +1 -1
  113. package/esm/trackers/impressionObserver/ImpressionObserver.js +0 -2
  114. package/esm/trackers/impressionObserver/buildKey.js +2 -9
  115. package/esm/trackers/impressionObserver/impressionObserverCS.js +2 -2
  116. package/esm/trackers/impressionObserver/impressionObserverSS.js +3 -3
  117. package/esm/utils/constants/index.js +3 -0
  118. package/esm/utils/decompress/index.js +424 -0
  119. package/esm/utils/murmur3/{commons.js → common.js} +1 -4
  120. package/esm/utils/murmur3/murmur3.js +1 -2
  121. package/esm/utils/murmur3/murmur3_128.js +7 -142
  122. package/esm/utils/murmur3/murmur3_128_x86.js +150 -0
  123. package/esm/utils/murmur3/murmur3_64.js +32 -0
  124. package/esm/utils/murmur3/utfx.js +96 -106
  125. package/esm/utils/promise/wrapper.js +14 -11
  126. package/esm/utils/settingsValidation/index.js +5 -2
  127. package/esm/utils/settingsValidation/localhost/index.js +16 -0
  128. package/esm/utils/settingsValidation/splitFilters.js +0 -1
  129. package/esm/utils/settingsValidation/storage/storageCS.js +16 -7
  130. package/esm/utils/settingsValidation/url.js +1 -1
  131. package/package.json +5 -5
  132. package/src/evaluator/matchers/matcherTypes.ts +2 -2
  133. package/src/evaluator/matchersTransform/index.ts +12 -12
  134. package/src/evaluator/value/sanitize.ts +7 -7
  135. package/src/listeners/browser.ts +5 -2
  136. package/src/listeners/node.ts +14 -2
  137. package/src/logger/constants.ts +2 -0
  138. package/src/logger/messages/error.ts +3 -2
  139. package/src/logger/messages/info.ts +2 -2
  140. package/src/logger/messages/warn.ts +3 -1
  141. package/src/readiness/readinessManager.ts +9 -7
  142. package/src/sdkFactory/index.ts +1 -1
  143. package/src/sdkFactory/types.ts +4 -5
  144. package/src/services/splitApi.ts +12 -3
  145. package/src/services/splitHttpClient.ts +6 -5
  146. package/src/services/types.ts +7 -3
  147. package/src/storages/AbstractSplitsCacheSync.ts +1 -1
  148. package/src/storages/inLocalStorage/index.ts +8 -4
  149. package/src/storages/inMemory/InMemoryStorage.ts +3 -0
  150. package/src/storages/inMemory/InMemoryStorageCS.ts +3 -0
  151. package/src/storages/inRedis/SplitsCacheInRedis.ts +3 -1
  152. package/src/storages/inRedis/index.ts +8 -4
  153. package/src/storages/pluggable/SegmentsCachePluggable.ts +1 -1
  154. package/src/storages/pluggable/SplitsCachePluggable.ts +3 -1
  155. package/src/storages/pluggable/inMemoryWrapper.ts +6 -7
  156. package/src/storages/pluggable/index.ts +8 -4
  157. package/src/storages/pluggable/wrapperAdapter.ts +0 -1
  158. package/src/storages/types.ts +18 -15
  159. package/src/sync/offline/splitsParser/splitsParserFromFile.ts +110 -105
  160. package/src/sync/offline/splitsParser/splitsParserFromSettings.ts +45 -41
  161. package/src/sync/offline/syncTasks/fromObjectSyncTask.ts +15 -5
  162. package/src/sync/polling/fetchers/segmentChangesFetcher.ts +0 -7
  163. package/src/sync/polling/types.ts +2 -1
  164. package/src/sync/polling/updaters/mySegmentsUpdater.ts +28 -10
  165. package/src/sync/polling/updaters/segmentChangesUpdater.ts +2 -3
  166. package/src/sync/streaming/AuthClient/types.ts +3 -0
  167. package/src/sync/streaming/SSEClient/index.ts +43 -23
  168. package/src/sync/streaming/SSEClient/types.ts +0 -1
  169. package/src/sync/streaming/SSEHandler/NotificationKeeper.ts +8 -0
  170. package/src/sync/streaming/SSEHandler/NotificationParser.ts +4 -2
  171. package/src/sync/streaming/SSEHandler/index.ts +11 -20
  172. package/src/sync/streaming/SSEHandler/types.ts +37 -3
  173. package/src/sync/streaming/UpdateWorkers/MySegmentsUpdateWorker.ts +7 -6
  174. package/src/sync/streaming/UpdateWorkers/SegmentsUpdateWorker.ts +2 -1
  175. package/src/sync/streaming/UpdateWorkers/SplitsUpdateWorker.ts +4 -3
  176. package/src/sync/streaming/UpdateWorkers/types.ts +1 -1
  177. package/src/sync/streaming/constants.ts +2 -0
  178. package/src/sync/streaming/mySegmentsV2utils.ts +77 -0
  179. package/src/sync/streaming/pushManager.ts +145 -42
  180. package/src/sync/streaming/types.ts +14 -22
  181. package/src/sync/submitters/metricsSyncTask.ts +1 -1
  182. package/src/sync/submitters/submitterSyncTask.ts +2 -1
  183. package/src/sync/syncManagerFromFile.ts +13 -0
  184. package/src/sync/syncManagerFromObject.ts +12 -0
  185. package/src/sync/syncManagerOffline.ts +3 -3
  186. package/src/sync/syncManagerOnline.ts +19 -5
  187. package/src/sync/syncTask.ts +1 -1
  188. package/src/sync/types.ts +3 -1
  189. package/src/trackers/impressionObserver/ImpressionObserver.ts +4 -6
  190. package/src/trackers/impressionObserver/buildKey.ts +2 -16
  191. package/src/trackers/impressionObserver/impressionObserverCS.ts +2 -2
  192. package/src/trackers/impressionObserver/impressionObserverSS.ts +3 -3
  193. package/src/types.ts +16 -2
  194. package/src/utils/constants/index.ts +6 -1
  195. package/src/utils/decompress/index.ts +429 -0
  196. package/src/utils/lang/index.ts +1 -1
  197. package/src/utils/murmur3/{commons.ts → common.ts} +1 -5
  198. package/src/utils/murmur3/murmur3.ts +5 -5
  199. package/src/utils/murmur3/murmur3_128.ts +7 -180
  200. package/src/utils/murmur3/murmur3_128_x86.ts +188 -0
  201. package/src/utils/murmur3/murmur3_64.ts +36 -0
  202. package/src/utils/murmur3/utfx.ts +92 -110
  203. package/src/utils/promise/wrapper.ts +12 -9
  204. package/src/utils/settingsValidation/index.ts +8 -4
  205. package/src/utils/settingsValidation/localhost/index.ts +19 -0
  206. package/src/utils/settingsValidation/splitFilters.ts +0 -1
  207. package/src/utils/settingsValidation/storage/storageCS.ts +21 -8
  208. package/src/utils/settingsValidation/types.ts +2 -11
  209. package/src/utils/settingsValidation/url.ts +1 -1
  210. package/types/evaluator/matchers/matcherTypes.d.ts +2 -2
  211. package/types/listeners/browser.d.ts +3 -3
  212. package/types/listeners/node.d.ts +3 -2
  213. package/types/logger/constants.d.ts +2 -0
  214. package/types/sdkFactory/types.d.ts +4 -5
  215. package/types/services/types.d.ts +4 -0
  216. package/types/storages/inLocalStorage/index.d.ts +2 -2
  217. package/types/storages/inMemory/InMemoryStorage.d.ts +3 -0
  218. package/types/storages/inMemory/InMemoryStorageCS.d.ts +3 -0
  219. package/types/storages/inRedis/index.d.ts +2 -2
  220. package/types/storages/pluggable/index.d.ts +2 -2
  221. package/types/storages/types.d.ts +15 -15
  222. package/types/sync/offline/splitsParser/splitsParserFromFile.d.ts +2 -7
  223. package/types/sync/offline/splitsParser/splitsParserFromSettings.d.ts +1 -5
  224. package/types/sync/polling/types.d.ts +2 -1
  225. package/types/sync/streaming/AuthClient/indexV1.d.ts +12 -0
  226. package/types/sync/streaming/AuthClient/indexV2.d.ts +8 -0
  227. package/types/sync/streaming/AuthClient/types.d.ts +2 -0
  228. package/types/sync/streaming/SSEClient/index.d.ts +9 -12
  229. package/types/sync/streaming/SSEClient/types.d.ts +0 -1
  230. package/types/sync/streaming/SSEHandler/NotificationParser.d.ts +3 -2
  231. package/types/sync/streaming/SSEHandler/types.d.ts +30 -2
  232. package/types/sync/streaming/UpdateWorkers/MySegmentsUpdateWorker.d.ts +4 -3
  233. package/types/sync/streaming/UpdateWorkers/SegmentsUpdateWorker.d.ts +2 -1
  234. package/types/sync/streaming/UpdateWorkers/SplitsUpdateWorker.d.ts +3 -2
  235. package/types/sync/streaming/UpdateWorkers/types.d.ts +1 -1
  236. package/types/sync/streaming/constants.d.ts +3 -1
  237. package/types/sync/streaming/mySegmentsV2utils.d.ts +27 -0
  238. package/types/sync/streaming/pushManagerNoUsers.d.ts +13 -0
  239. package/types/sync/streaming/types.d.ts +9 -5
  240. package/types/sync/submitters/submitterSyncTask.d.ts +1 -1
  241. package/types/sync/syncManagerFromFile.d.ts +2 -0
  242. package/types/sync/syncManagerFromObject.d.ts +2 -0
  243. package/types/sync/syncManagerOffline.d.ts +1 -1
  244. package/types/sync/syncTask.d.ts +1 -1
  245. package/types/sync/types.d.ts +2 -0
  246. package/types/trackers/impressionObserver/ImpressionObserver.d.ts +2 -2
  247. package/types/trackers/impressionObserver/buildKey.d.ts +1 -1
  248. package/types/trackers/impressionObserver/impressionObserverCS.d.ts +2 -2
  249. package/types/trackers/impressionObserver/impressionObserverSS.d.ts +2 -2
  250. package/types/types.d.ts +16 -2
  251. package/types/utils/constants/index.d.ts +5 -1
  252. package/types/utils/decompress/index.d.ts +16 -0
  253. package/types/utils/lang/index.d.ts +1 -1
  254. package/types/utils/murmur3/common.d.ts +12 -0
  255. package/types/utils/murmur3/murmur3.d.ts +2 -2
  256. package/types/utils/murmur3/murmur3_128.d.ts +5 -0
  257. package/types/utils/murmur3/murmur3_128_x86.d.ts +7 -0
  258. package/types/utils/murmur3/murmur3_64.d.ts +10 -0
  259. package/types/utils/murmur3/utfx.d.ts +24 -6
  260. package/types/utils/settingsValidation/index.d.ts +3 -2
  261. package/types/utils/settingsValidation/localhost/index.d.ts +9 -0
  262. package/types/utils/settingsValidation/storage/storageCS.d.ts +7 -1
  263. package/types/utils/settingsValidation/types.d.ts +2 -10
  264. package/cjs/sync/streaming/pushManagerCS.js +0 -178
  265. package/cjs/sync/streaming/pushManagerSS.js +0 -128
  266. package/esm/sync/streaming/pushManagerCS.js +0 -174
  267. package/esm/sync/streaming/pushManagerSS.js +0 -124
  268. package/src/sync/streaming/pushManagerCS.ts +0 -237
  269. package/src/sync/streaming/pushManagerSS.ts +0 -177
package/src/types.ts CHANGED
@@ -1,8 +1,10 @@
1
+ import { ISplitFiltersValidation } from './dtos/types';
1
2
  import { IIntegration, IIntegrationFactoryParams } from './integrations/types';
2
3
  import { ILogger } from './logger/types';
3
4
  /* eslint-disable no-use-before-define */
4
5
 
5
- import { IStorageFactoryParams, IStorageSyncCS, IStorageSync, IStorageAsync } from './storages/types';
6
+ import { IStorageFactoryParams, IStorageSyncCS, IStorageSync, IStorageAsync, IStorageSyncFactory } from './storages/types';
7
+ import { ISyncManagerFactoryParams, ISyncManagerCS } from './sync/types';
6
8
 
7
9
  /**
8
10
  * EventEmitter interface with the minimal methods used by the SDK
@@ -55,6 +57,8 @@ export type SDKMode = 'standalone' | 'consumer' | 'localhost';
55
57
  * Settings interface. This is a representation of the settings the SDK expose, that's why
56
58
  * most of it's props are readonly. Only features should be rewritten when localhost mode is active.
57
59
  * @interface ISettings
60
+ *
61
+ * NOTE: same ISettings interface from public type declarations extended with private properties.
58
62
  */
59
63
  export interface ISettings {
60
64
  readonly core: {
@@ -81,7 +85,7 @@ export interface ISettings {
81
85
  retriesOnFailureBeforeReady: number,
82
86
  eventsFirstPushWindow: number
83
87
  },
84
- readonly storage: (params: IStorageFactoryParams) => IStorageSyncCS,
88
+ readonly storage: IStorageSyncFactory,
85
89
  readonly integrations?: Array<(params: IIntegrationFactoryParams) => IIntegration | void>,
86
90
  readonly urls: {
87
91
  events: string,
@@ -96,12 +100,15 @@ export interface ISettings {
96
100
  readonly sync: {
97
101
  splitFilters: SplitIO.SplitFilter[],
98
102
  impressionsMode: SplitIO.ImpressionsMode,
103
+ __splitFiltersValidation: ISplitFiltersValidation,
104
+ localhostMode: SplitIO.LocalhostFactory
99
105
  },
100
106
  readonly runtime: {
101
107
  ip: string | false
102
108
  hostname: string | false
103
109
  },
104
110
  readonly log: ILogger
111
+ readonly impressionListener?: unknown
105
112
  }
106
113
  /**
107
114
  * Log levels.
@@ -576,6 +583,13 @@ export namespace SplitIO {
576
583
  * @typedef {Promise<SplitNames>} SplitNamesAsync
577
584
  */
578
585
  export type SplitNamesAsync = Promise<SplitNames>;
586
+ /**
587
+ * Localhost mode factory.
588
+ */
589
+ export type LocalhostFactory = {
590
+ type?: 'localhost'
591
+ (params: ISyncManagerFactoryParams): ISyncManagerCS
592
+ }
579
593
  /**
580
594
  * Impression listener interface. This is the interface that needs to be implemented
581
595
  * by the element you provide to the SDK as impression listener.
@@ -1,3 +1,5 @@
1
+ import { StorageType } from '../../storages/types';
2
+
1
3
  // Special treatments
2
4
  export const CONTROL = 'control';
3
5
  export const CONTROL_WITH_CONFIG = {
@@ -24,4 +26,7 @@ export const PRODUCER_MODE = 'producer';
24
26
  export const CONSUMER_MODE = 'consumer';
25
27
 
26
28
  // Storage types
27
- export const STORAGE_MEMORY = 'MEMORY';
29
+ export const STORAGE_MEMORY: StorageType = 'MEMORY';
30
+ export const STORAGE_LOCALSTORAGE: StorageType = 'LOCALSTORAGE';
31
+ export const STORAGE_REDIS: StorageType = 'REDIS';
32
+ export const STORAGE_CUSTOM: StorageType = 'CUSTOM';
@@ -0,0 +1,429 @@
1
+ /*
2
+ Trimmed version of "fflate" library (https://www.npmjs.com/package/fflate/v/0.7.1)
3
+ used for GZIP/Zlib decompression in JavaScript, with the minimal modules used by the SDK.
4
+
5
+ MIT License
6
+
7
+ Copyright (c) 2020 Arjun Barrett
8
+
9
+ Permission is hereby granted, free of charge, to any person obtaining a copy
10
+ of this software and associated documentation files (the "Software"), to deal
11
+ in the Software without restriction, including without limitation the rights
12
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13
+ copies of the Software, and to permit persons to whom the Software is
14
+ furnished to do so, subject to the following conditions:
15
+
16
+ The above copyright notice and this permission notice shall be included in all
17
+ copies or substantial portions of the Software.
18
+
19
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
25
+ SOFTWARE.
26
+ */
27
+ /* eslint-disable */
28
+ // @ts-nocheck
29
+
30
+ export const algorithms = (function iifeDecompress() {
31
+
32
+ // Handle runtimes without typed arrays
33
+ if ([typeof Uint8Array, typeof Uint16Array, typeof Uint32Array].some(v => v != 'function')) {
34
+ return 'global Uint8Array object is not available for gzip/zlib decompression';
35
+ }
36
+
37
+ // DEFLATE is a complex format; to read this code, you should probably check the RFC first:
38
+
39
+ // aliases for shorter compressed code (most minifers don't do this)
40
+ var u8 = Uint8Array, u16 = Uint16Array, u32 = Uint32Array;
41
+ // fixed length extra bits
42
+ var fleb = new u8([0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 0, /* unused */ 0, 0, /* impossible */ 0]);
43
+ // fixed distance extra bits
44
+ // see fleb note
45
+ var fdeb = new u8([0, 0, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, /* unused */ 0, 0]);
46
+ // code length index map
47
+ var clim = new u8([16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15]);
48
+ // get base, reverse index map from extra bits
49
+ var freb = function (eb, start) {
50
+ var b = new u16(31);
51
+ for (var i = 0; i < 31; ++i) {
52
+ b[i] = start += 1 << eb[i - 1];
53
+ }
54
+ // numbers here are at max 18 bits
55
+ var r = new u32(b[30]);
56
+ for (var i = 1; i < 30; ++i) {
57
+ for (var j = b[i]; j < b[i + 1]; ++j) {
58
+ r[j] = ((j - b[i]) << 5) | i;
59
+ }
60
+ }
61
+ return [b, r];
62
+ };
63
+ var _a = freb(fleb, 2), fl = _a[0], revfl = _a[1];
64
+ // we can ignore the fact that the other numbers are wrong; they never happen anyway
65
+ fl[28] = 258, revfl[258] = 28;
66
+ var _b = freb(fdeb, 0), fd = _b[0];
67
+ // map of value to reverse (assuming 16 bits)
68
+ var rev = new u16(32768);
69
+ for (var i = 0; i < 32768; ++i) {
70
+ // reverse table algorithm from SO
71
+ var x = ((i & 0xAAAA) >>> 1) | ((i & 0x5555) << 1);
72
+ x = ((x & 0xCCCC) >>> 2) | ((x & 0x3333) << 2);
73
+ x = ((x & 0xF0F0) >>> 4) | ((x & 0x0F0F) << 4);
74
+ rev[i] = (((x & 0xFF00) >>> 8) | ((x & 0x00FF) << 8)) >>> 1;
75
+ }
76
+ // create huffman tree from u8 "map": index -> code length for code index
77
+ // mb (max bits) must be at most 15
78
+ // TODO: optimize/split up?
79
+ var hMap = (function (cd, mb, r) {
80
+ var s = cd.length;
81
+ // index
82
+ var i = 0;
83
+ // u16 "map": index -> # of codes with bit length = index
84
+ var l = new u16(mb);
85
+ // length of cd must be 288 (total # of codes)
86
+ for (; i < s; ++i)
87
+ ++l[cd[i] - 1];
88
+ // u16 "map": index -> minimum code for bit length = index
89
+ var le = new u16(mb);
90
+ for (i = 0; i < mb; ++i) {
91
+ le[i] = (le[i - 1] + l[i - 1]) << 1;
92
+ }
93
+ var co;
94
+ if (r) {
95
+ // u16 "map": index -> number of actual bits, symbol for code
96
+ co = new u16(1 << mb);
97
+ // bits to remove for reverser
98
+ var rvb = 15 - mb;
99
+ for (i = 0; i < s; ++i) {
100
+ // ignore 0 lengths
101
+ if (cd[i]) {
102
+ // num encoding both symbol and bits read
103
+ var sv = (i << 4) | cd[i];
104
+ // free bits
105
+ var r_1 = mb - cd[i];
106
+ // start value
107
+ var v = le[cd[i] - 1]++ << r_1;
108
+ // m is end value
109
+ for (var m = v | ((1 << r_1) - 1); v <= m; ++v) {
110
+ // every 16 bit value starting with the code yields the same result
111
+ co[rev[v] >>> rvb] = sv;
112
+ }
113
+ }
114
+ }
115
+ }
116
+ else {
117
+ co = new u16(s);
118
+ for (i = 0; i < s; ++i) {
119
+ if (cd[i]) {
120
+ co[i] = rev[le[cd[i] - 1]++] >>> (15 - cd[i]);
121
+ }
122
+ }
123
+ }
124
+ return co;
125
+ });
126
+ // fixed length tree
127
+ var flt = new u8(288);
128
+ for (var i = 0; i < 144; ++i)
129
+ flt[i] = 8;
130
+ for (var i = 144; i < 256; ++i)
131
+ flt[i] = 9;
132
+ for (var i = 256; i < 280; ++i)
133
+ flt[i] = 7;
134
+ for (var i = 280; i < 288; ++i)
135
+ flt[i] = 8;
136
+ // fixed distance tree
137
+ var fdt = new u8(32);
138
+ for (var i = 0; i < 32; ++i)
139
+ fdt[i] = 5;
140
+ // fixed length map
141
+ var flrm = /*#__PURE__*/ hMap(flt, 9, 1);
142
+ // fixed distance map
143
+ var fdrm = /*#__PURE__*/ hMap(fdt, 5, 1);
144
+ // find max of array
145
+ var max = function (a) {
146
+ var m = a[0];
147
+ for (var i = 1; i < a.length; ++i) {
148
+ if (a[i] > m)
149
+ m = a[i];
150
+ }
151
+ return m;
152
+ };
153
+ // read d, starting at bit p and mask with m
154
+ var bits = function (d, p, m) {
155
+ var o = (p / 8) | 0;
156
+ return ((d[o] | (d[o + 1] << 8)) >> (p & 7)) & m;
157
+ };
158
+ // read d, starting at bit p continuing for at least 16 bits
159
+ var bits16 = function (d, p) {
160
+ var o = (p / 8) | 0;
161
+ return ((d[o] | (d[o + 1] << 8) | (d[o + 2] << 16)) >> (p & 7));
162
+ };
163
+ // get end of byte
164
+ var shft = function (p) { return ((p + 7) / 8) | 0; };
165
+ // typed array slice - allows garbage collector to free original reference,
166
+ // while being more compatible than .slice
167
+ var slc = function (v, s, e) {
168
+ if (s == null || s < 0)
169
+ s = 0;
170
+ if (e == null || e > v.length)
171
+ e = v.length;
172
+ // can't use .constructor in case user-supplied
173
+ var n = new (v instanceof u16 ? u16 : v instanceof u32 ? u32 : u8)(e - s);
174
+ n.set(v.subarray(s, e));
175
+ return n;
176
+ };
177
+ // error codes
178
+ var ec = [
179
+ 'unexpected EOF',
180
+ 'invalid block type',
181
+ 'invalid length/literal',
182
+ 'invalid distance',
183
+ 'stream finished',
184
+ 'no stream handler',
185
+ ,
186
+ 'no callback',
187
+ 'invalid UTF-8 data',
188
+ 'extra field too long',
189
+ 'date not in range 1980-2099',
190
+ 'filename too long',
191
+ 'stream finishing',
192
+ 'invalid zip data'
193
+ // determined by unknown compression method
194
+ ];
195
+ var err = function (ind, msg, nt) {
196
+ var e = new Error(msg || ec[ind]);
197
+ e.code = ind;
198
+ if (Error.captureStackTrace)
199
+ Error.captureStackTrace(e, err);
200
+ if (!nt)
201
+ throw e;
202
+ return e;
203
+ };
204
+ // expands raw DEFLATE data
205
+ var inflt = function (dat, buf, st) {
206
+ // source length
207
+ var sl = dat.length;
208
+ if (!sl || (st && st.f && !st.l))
209
+ return buf || new u8(0);
210
+ // have to estimate size
211
+ var noBuf = !buf || st;
212
+ // no state
213
+ var noSt = !st || st.i;
214
+ if (!st)
215
+ st = {};
216
+ // Assumes roughly 33% compression ratio average
217
+ if (!buf)
218
+ buf = new u8(sl * 3);
219
+ // ensure buffer can fit at least l elements
220
+ var cbuf = function (l) {
221
+ var bl = buf.length;
222
+ // need to increase size to fit
223
+ if (l > bl) {
224
+ // Double or set to necessary, whichever is greater
225
+ var nbuf = new u8(Math.max(bl * 2, l));
226
+ nbuf.set(buf);
227
+ buf = nbuf;
228
+ }
229
+ };
230
+ // last chunk bitpos bytes
231
+ var final = st.f || 0, pos = st.p || 0, bt = st.b || 0, lm = st.l, dm = st.d, lbt = st.m, dbt = st.n;
232
+ // total bits
233
+ var tbts = sl * 8;
234
+ do {
235
+ if (!lm) {
236
+ // BFINAL - this is only 1 when last chunk is next
237
+ final = bits(dat, pos, 1);
238
+ // type: 0 = no compression, 1 = fixed huffman, 2 = dynamic huffman
239
+ var type = bits(dat, pos + 1, 3);
240
+ pos += 3;
241
+ if (!type) {
242
+ // go to end of byte boundary
243
+ var s = shft(pos) + 4, l = dat[s - 4] | (dat[s - 3] << 8), t = s + l;
244
+ if (t > sl) {
245
+ if (noSt)
246
+ err(0);
247
+ break;
248
+ }
249
+ // ensure size
250
+ if (noBuf)
251
+ cbuf(bt + l);
252
+ // Copy over uncompressed data
253
+ buf.set(dat.subarray(s, t), bt);
254
+ // Get new bitpos, update byte count
255
+ st.b = bt += l, st.p = pos = t * 8, st.f = final;
256
+ continue;
257
+ }
258
+ else if (type == 1)
259
+ lm = flrm, dm = fdrm, lbt = 9, dbt = 5;
260
+ else if (type == 2) {
261
+ // literal lengths
262
+ var hLit = bits(dat, pos, 31) + 257, hcLen = bits(dat, pos + 10, 15) + 4;
263
+ var tl = hLit + bits(dat, pos + 5, 31) + 1;
264
+ pos += 14;
265
+ // length+distance tree
266
+ var ldt = new u8(tl);
267
+ // code length tree
268
+ var clt = new u8(19);
269
+ for (var i = 0; i < hcLen; ++i) {
270
+ // use index map to get real code
271
+ clt[clim[i]] = bits(dat, pos + i * 3, 7);
272
+ }
273
+ pos += hcLen * 3;
274
+ // code lengths bits
275
+ var clb = max(clt), clbmsk = (1 << clb) - 1;
276
+ // code lengths map
277
+ var clm = hMap(clt, clb, 1);
278
+ for (var i = 0; i < tl;) {
279
+ var r = clm[bits(dat, pos, clbmsk)];
280
+ // bits read
281
+ pos += r & 15;
282
+ // symbol
283
+ var s = r >>> 4;
284
+ // code length to copy
285
+ if (s < 16) {
286
+ ldt[i++] = s;
287
+ }
288
+ else {
289
+ // copy count
290
+ var c = 0, n = 0;
291
+ if (s == 16)
292
+ n = 3 + bits(dat, pos, 3), pos += 2, c = ldt[i - 1];
293
+ else if (s == 17)
294
+ n = 3 + bits(dat, pos, 7), pos += 3;
295
+ else if (s == 18)
296
+ n = 11 + bits(dat, pos, 127), pos += 7;
297
+ while (n--)
298
+ ldt[i++] = c;
299
+ }
300
+ }
301
+ // length tree distance tree
302
+ var lt = ldt.subarray(0, hLit), dt = ldt.subarray(hLit);
303
+ // max length bits
304
+ lbt = max(lt);
305
+ // max dist bits
306
+ dbt = max(dt);
307
+ lm = hMap(lt, lbt, 1);
308
+ dm = hMap(dt, dbt, 1);
309
+ }
310
+ else
311
+ err(1);
312
+ if (pos > tbts) {
313
+ if (noSt)
314
+ err(0);
315
+ break;
316
+ }
317
+ }
318
+ // Make sure the buffer can hold this + the largest possible addition
319
+ // Maximum chunk size (practically, theoretically infinite) is 2^17;
320
+ if (noBuf)
321
+ cbuf(bt + 131072);
322
+ var lms = (1 << lbt) - 1, dms = (1 << dbt) - 1;
323
+ var lpos = pos;
324
+ for (; ; lpos = pos) {
325
+ // bits read, code
326
+ var c = lm[bits16(dat, pos) & lms], sym = c >>> 4;
327
+ pos += c & 15;
328
+ if (pos > tbts) {
329
+ if (noSt)
330
+ err(0);
331
+ break;
332
+ }
333
+ if (!c)
334
+ err(2);
335
+ if (sym < 256)
336
+ buf[bt++] = sym;
337
+ else if (sym == 256) {
338
+ lpos = pos, lm = null;
339
+ break;
340
+ }
341
+ else {
342
+ var add = sym - 254;
343
+ // no extra bits needed if less
344
+ if (sym > 264) {
345
+ // index
346
+ var i = sym - 257, b = fleb[i];
347
+ add = bits(dat, pos, (1 << b) - 1) + fl[i];
348
+ pos += b;
349
+ }
350
+ // dist
351
+ var d = dm[bits16(dat, pos) & dms], dsym = d >>> 4;
352
+ if (!d)
353
+ err(3);
354
+ pos += d & 15;
355
+ var dt = fd[dsym];
356
+ if (dsym > 3) {
357
+ var b = fdeb[dsym];
358
+ dt += bits16(dat, pos) & ((1 << b) - 1), pos += b;
359
+ }
360
+ if (pos > tbts) {
361
+ if (noSt)
362
+ err(0);
363
+ break;
364
+ }
365
+ if (noBuf)
366
+ cbuf(bt + 131072);
367
+ var end = bt + add;
368
+ for (; bt < end; bt += 4) {
369
+ buf[bt] = buf[bt - dt];
370
+ buf[bt + 1] = buf[bt + 1 - dt];
371
+ buf[bt + 2] = buf[bt + 2 - dt];
372
+ buf[bt + 3] = buf[bt + 3 - dt];
373
+ }
374
+ bt = end;
375
+ }
376
+ }
377
+ st.l = lm, st.p = lpos, st.b = bt, st.f = final;
378
+ if (lm)
379
+ final = 1, st.m = lbt, st.d = dm, st.n = dbt;
380
+ } while (!final);
381
+ return bt == buf.length ? buf : slc(buf, 0, bt);
382
+ };
383
+ // gzip footer: -8 to -4 = CRC, -4 to -0 is length
384
+ // gzip start
385
+ var gzs = function (d) {
386
+ if (d[0] != 31 || d[1] != 139 || d[2] != 8)
387
+ err(6, 'invalid gzip data');
388
+ var flg = d[3];
389
+ var st = 10;
390
+ if (flg & 4)
391
+ st += d[10] | (d[11] << 8) + 2;
392
+ for (var zs = (flg >> 3 & 1) + (flg >> 4 & 1); zs > 0; zs -= !d[st++])
393
+ ;
394
+ return st + (flg & 2);
395
+ };
396
+ // gzip length
397
+ var gzl = function (d) {
398
+ var l = d.length;
399
+ return ((d[l - 4] | d[l - 3] << 8 | d[l - 2] << 16) | (d[l - 1] << 24)) >>> 0;
400
+ };
401
+ // zlib valid
402
+ var zlv = function (d) {
403
+ if ((d[0] & 15) != 8 || (d[0] >>> 4) > 7 || ((d[0] << 8 | d[1]) % 31))
404
+ err(6, 'invalid zlib data');
405
+ if (d[1] & 32)
406
+ err(6, 'invalid zlib data: preset dictionaries not supported');
407
+ };
408
+
409
+ return {
410
+ /**
411
+ * Expands GZIP data
412
+ * @param data The data to decompress
413
+ * @param out Where to write the data. GZIP already encodes the output size, so providing this doesn't save memory.
414
+ * @returns The decompressed version of the data
415
+ */
416
+ gunzipSync(data: Uint8Array, out?: Uint8Array): Uint8Array {
417
+ return inflt(data.subarray(gzs(data), -8), out || new u8(gzl(data)));
418
+ },
419
+ /**
420
+ * Expands Zlib data
421
+ * @param data The data to decompress
422
+ * @param out Where to write the data. Saves memory if you know the decompressed size and provide an output buffer of that length.
423
+ * @returns The decompressed version of the data
424
+ */
425
+ unzlibSync(data: Uint8Array, out?: Uint8Array): Uint8Array {
426
+ return inflt((zlv(data), data.subarray(2, -4)), out);
427
+ }
428
+ }
429
+ })();
@@ -89,7 +89,7 @@ export function get(obj: any, prop: any, val: any): any {
89
89
  /**
90
90
  * Parses an array into a map of different arrays, grouping by the specified prop value.
91
91
  */
92
- export function groupBy(source: any, prop: string): Record<string, any[]> {
92
+ export function groupBy<T extends Record<string, any> >(source: T[], prop: string): Record<string, T[]> {
93
93
  const map: Record<string, any[]> = {};
94
94
 
95
95
  if (Array.isArray(source) && isString(prop)) {
@@ -1,8 +1,4 @@
1
- import utfx from './utfx';
2
-
3
- const stringSource = utfx.stringSource;
4
- const stringDestination = utfx.stringDestination;
5
- const encodeUTF16toUTF8 = utfx.encodeUTF16toUTF8;
1
+ import { stringSource, stringDestination, encodeUTF16toUTF8 } from './utfx';
6
2
 
7
3
  export function UTF16ToUTF8(key: string) {
8
4
  let sd;
@@ -1,5 +1,5 @@
1
1
  /* eslint-disable no-fallthrough */
2
- import { UTF16ToUTF8, x86Fmix, x86Multiply, x86Rotl } from './commons';
2
+ import { UTF16ToUTF8, x86Fmix, x86Multiply, x86Rotl } from './common';
3
3
 
4
4
  /*
5
5
  * +----------------------------------------------------------------------------------+
@@ -65,11 +65,11 @@ function hash32(key?: string, seed?: number) {
65
65
  return h1 >>> 0;
66
66
  }
67
67
 
68
- export function hash(str?: string, seed?: number): number {
69
- // @ts-ignore
70
- return hash32(UTF16ToUTF8(str), seed >>> 0);
68
+ export function hash(str: string, seed?: number): number {
69
+
70
+ return hash32(UTF16ToUTF8(str), seed as number >>> 0);
71
71
  }
72
72
 
73
- export function bucket(str?: string, seed?: number): number {
73
+ export function bucket(str: string, seed?: number): number {
74
74
  return Math.abs(hash(str, seed) % 100) + 1;
75
75
  }