@splitsoftware/splitio 10.16.0 → 10.16.1-rc.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.
Files changed (46) hide show
  1. package/CHANGES.txt +5 -0
  2. package/README.md +2 -1
  3. package/es/engine/engine/murmur3/murmur3_128.js +1 -1
  4. package/es/engine/engine/murmur3/murmur3_128_x86.js +2 -3
  5. package/es/engine/matchers/index.js +20 -37
  6. package/es/engine/matchers/types.js +19 -72
  7. package/es/engine/transforms/matcherGroup.js +2 -2
  8. package/es/engine/transforms/matchers.js +2 -2
  9. package/es/engine/value/sanitize.js +12 -14
  10. package/es/impressions/hasher/hashImpression128.js +1 -1
  11. package/es/impressions/observer/observer.js +0 -1
  12. package/es/producer/updater/SplitChangesFromObject.js +3 -2
  13. package/es/sync/PushManager/index.js +3 -11
  14. package/es/utils/logger/LoggerFactory.js +23 -16
  15. package/es/utils/settings/index.js +1 -1
  16. package/es/utils/settings/storage/browser.js +19 -4
  17. package/lib/engine/engine/murmur3/murmur3_128.js +1 -1
  18. package/lib/engine/engine/murmur3/murmur3_128_x86.js +2 -3
  19. package/lib/engine/matchers/index.js +21 -39
  20. package/lib/engine/matchers/types.js +23 -77
  21. package/lib/engine/transforms/matcherGroup.js +3 -3
  22. package/lib/engine/transforms/matchers.js +22 -22
  23. package/lib/engine/value/sanitize.js +11 -13
  24. package/lib/impressions/hasher/hashImpression128.js +2 -2
  25. package/lib/impressions/observer/observer.js +0 -1
  26. package/lib/producer/updater/SplitChangesFromObject.js +4 -2
  27. package/lib/sync/PushManager/index.js +3 -11
  28. package/lib/utils/logger/LoggerFactory.js +23 -17
  29. package/lib/utils/settings/index.js +1 -1
  30. package/lib/utils/settings/storage/browser.js +18 -3
  31. package/package.json +13 -11
  32. package/src/engine/engine/murmur3/murmur3_128.js +1 -1
  33. package/src/engine/engine/murmur3/murmur3_128_x86.js +2 -3
  34. package/src/engine/matchers/index.js +22 -36
  35. package/src/engine/matchers/types.js +20 -55
  36. package/src/engine/transforms/matcherGroup.js +2 -5
  37. package/src/engine/transforms/matchers.js +2 -6
  38. package/src/engine/value/sanitize.js +12 -17
  39. package/src/impressions/hasher/hashImpression128.js +1 -1
  40. package/src/impressions/observer/observer.js +0 -2
  41. package/src/producer/updater/SplitChangesFromObject.js +2 -2
  42. package/src/sync/PushManager/index.js +3 -10
  43. package/src/sync/constants.js +1 -1
  44. package/src/utils/logger/LoggerFactory.js +25 -16
  45. package/src/utils/settings/index.js +1 -1
  46. package/src/utils/settings/storage/browser.js +18 -3
package/CHANGES.txt CHANGED
@@ -1,3 +1,8 @@
1
+ 10.16.1 (October 25, 2021)
2
+ - Updated some internal modules to optimize the time efficiency of split evaluations (i.e., `getTreatment(s)` method calls)
3
+ - Updated some dependencies for vulnerability fixes.
4
+ - Bugfixing - Fixed localhost mode with localStorage, to use a mock in memory instead of localStorage API directly but keep emitting emit SDK_READY_FROM_CACHE event.
5
+
1
6
  10.16.0 (September 28, 2021)
2
7
  - Updated localhost mode to emit SDK_READY_FROM_CACHE event in Browser when using localStorage (issue https://github.com/splitio/react-client/issues/34).
3
8
  - Updated streaming logic to use the newest version of our streaming service, including:
package/README.md CHANGED
@@ -68,11 +68,12 @@ Split has built and maintains SDKs for:
68
68
  * iOS [Github](https://github.com/splitio/ios-client) [Docs](https://help.split.io/hc/en-us/articles/360020401491-iOS-SDK)
69
69
  * Java [Github](https://github.com/splitio/java-client) [Docs](https://help.split.io/hc/en-us/articles/360020405151-Java-SDK)
70
70
  * Javascript [Github](https://github.com/splitio/javascript-client) [Docs](https://help.split.io/hc/en-us/articles/360020448791-JavaScript-SDK)
71
+ * Javascript for Browser [Github](https://github.com/splitio/javascript-browser-client) [Docs](https://help.split.io/hc/en-us/articles/360058730852-Browser-SDK)
71
72
  * Node [Github](https://github.com/splitio/javascript-client) [Docs](https://help.split.io/hc/en-us/articles/360020564931-Node-js-SDK)
72
- * Javascript for Browser [Github](https://github.com/splitio/javascript-browser-client) [Docs](https://help.split.io/hc/en-us/articles/360058730852)
73
73
  * PHP [Github](https://github.com/splitio/php-client) [Docs](https://help.split.io/hc/en-us/articles/360020350372-PHP-SDK)
74
74
  * Python [Github](https://github.com/splitio/python-client) [Docs](https://help.split.io/hc/en-us/articles/360020359652-Python-SDK)
75
75
  * React [Github](https://github.com/splitio/react-client) [Docs](https://help.split.io/hc/en-us/articles/360038825091-React-SDK)
76
+ * React Native [Github](https://github.com/splitio/react-native-client) [Docs](https://help.split.io/hc/en-us/articles/4406066357901-React-Native-SDK)
76
77
  * Redux [Github](https://github.com/splitio/redux-client) [Docs](https://help.split.io/hc/en-us/articles/360038851551-Redux-SDK)
77
78
  * Ruby [Github](https://github.com/splitio/ruby-client) [Docs](https://help.split.io/hc/en-us/articles/360020673251-Ruby-SDK)
78
79
 
@@ -234,7 +234,7 @@ function hash128x64(key
234
234
  }
235
235
  /**
236
236
  * x64 version of Murmur3 for 128bits.
237
- * Used in hashImpression128.
237
+ *
238
238
  * @param {string} str
239
239
  */
240
240
 
@@ -166,10 +166,9 @@ function hash128x86(key
166
166
  }
167
167
  /**
168
168
  * x86 version of Murmur3 for 128bits.
169
- * @param {string} str
169
+ * Used by hashImpression128 because in JS it is more efficient than the x64 version, no matter the underlying OS/CPU arch.
170
170
  *
171
- * @TODO Test and use in hashImpression128 instead of the x64 version,
172
- * because it is more time efficient in JS, no matter the underlying CPU arch.
171
+ * @param {string} str
173
172
  */
174
173
 
175
174
 
@@ -13,7 +13,6 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
13
  See the License for the specific language governing permissions and
14
14
  limitations under the License.
15
15
  **/
16
- import { types } from './types';
17
16
  import allMatcher from './all';
18
17
  import segmentMatcher from './segment';
19
18
  import whitelistMatcher from './whitelist';
@@ -31,6 +30,25 @@ import containsStrMatcher from './cont_str';
31
30
  import dependencyMatcher from './dependency';
32
31
  import booleanMatcher from './boolean';
33
32
  import stringMatcher from './string';
33
+ var matchers = [undefined, // UNDEFINED: 0,
34
+ allMatcher, // ALL_KEYS: 1,
35
+ segmentMatcher, // IN_SEGMENT: 2,
36
+ whitelistMatcher, // WHITELIST: 3,
37
+ eqMatcher, // EQUAL_TO: 4,
38
+ gteMatcher, // GREATER_THAN_OR_EQUAL_TO: 5,
39
+ lteMatcher, // LESS_THAN_OR_EQUAL_TO: 6,
40
+ betweenMatcher, // BETWEEN: 7,
41
+ equalToSetMatcher, // EQUAL_TO_SET: 8,
42
+ containsAnySetMatcher, // CONTAINS_ANY_OF_SET: 9,
43
+ containsAllSetMatcher, // CONTAINS_ALL_OF_SET: 10,
44
+ partOfSetMatcher, // PART_OF_SET: 11,
45
+ ewMatcher, // ENDS_WITH: 12,
46
+ swMatcher, // STARTS_WITH: 13,
47
+ containsStrMatcher, // CONTAINS_STRING: 14,
48
+ dependencyMatcher, // IN_SPLIT_TREATMENT: 15,
49
+ booleanMatcher, // EQUAL_TO_BOOLEAN: 16,
50
+ stringMatcher // MATCHES_STRING: 17
51
+ ];
34
52
  /**
35
53
  * Matcher factory.
36
54
  */
@@ -39,42 +57,7 @@ function MatcherFactory(matcherDto, storage) {
39
57
  var type = matcherDto.type,
40
58
  value = matcherDto.value;
41
59
  var matcherFn;
42
-
43
- if (type === types.ALL) {
44
- matcherFn = allMatcher(value);
45
- } else if (type === types.SEGMENT) {
46
- matcherFn = segmentMatcher(value, storage);
47
- } else if (type === types.WHITELIST) {
48
- matcherFn = whitelistMatcher(value);
49
- } else if (type === types.EQUAL_TO) {
50
- matcherFn = eqMatcher(value);
51
- } else if (type === types.GREATER_THAN_OR_EQUAL_TO) {
52
- matcherFn = gteMatcher(value);
53
- } else if (type === types.LESS_THAN_OR_EQUAL_TO) {
54
- matcherFn = lteMatcher(value);
55
- } else if (type === types.BETWEEN) {
56
- matcherFn = betweenMatcher(value);
57
- } else if (type === types.EQUAL_TO_SET) {
58
- matcherFn = equalToSetMatcher(value);
59
- } else if (type === types.CONTAINS_ANY_OF_SET) {
60
- matcherFn = containsAnySetMatcher(value);
61
- } else if (type === types.CONTAINS_ALL_OF_SET) {
62
- matcherFn = containsAllSetMatcher(value);
63
- } else if (type === types.PART_OF_SET) {
64
- matcherFn = partOfSetMatcher(value);
65
- } else if (type === types.STARTS_WITH) {
66
- matcherFn = swMatcher(value);
67
- } else if (type === types.ENDS_WITH) {
68
- matcherFn = ewMatcher(value);
69
- } else if (type === types.CONTAINS_STRING) {
70
- matcherFn = containsStrMatcher(value);
71
- } else if (type === types.IN_SPLIT_TREATMENT) {
72
- matcherFn = dependencyMatcher(value, storage);
73
- } else if (type === types.EQUAL_TO_BOOLEAN) {
74
- matcherFn = booleanMatcher(value);
75
- } else if (type === types.MATCHES_STRING) {
76
- matcherFn = stringMatcher(value);
77
- }
60
+ if (matchers[type]) matcherFn = matchers[type](value, storage); // There is no index-out-of-bound exception in JavaScript
78
61
 
79
62
  return matcherFn;
80
63
  }
@@ -14,27 +14,27 @@ See the License for the specific language governing permissions and
14
14
  limitations under the License.
15
15
  **/
16
16
  // @WARNING Symbol is not correctly working in PhantomJS
17
- export var types = {
18
- ALL: 1,
19
- SEGMENT: 2,
17
+ export var matcherTypes = {
18
+ UNDEFINED: 0,
19
+ ALL_KEYS: 1,
20
+ IN_SEGMENT: 2,
20
21
  WHITELIST: 3,
21
22
  EQUAL_TO: 4,
22
23
  GREATER_THAN_OR_EQUAL_TO: 5,
23
24
  LESS_THAN_OR_EQUAL_TO: 6,
24
25
  BETWEEN: 7,
25
- UNDEFINED: 8,
26
- EQUAL_TO_SET: 9,
27
- CONTAINS_ANY_OF_SET: 10,
28
- CONTAINS_ALL_OF_SET: 11,
29
- PART_OF_SET: 12,
30
- ENDS_WITH: 13,
31
- STARTS_WITH: 14,
32
- CONTAINS_STRING: 15,
33
- IN_SPLIT_TREATMENT: 16,
34
- EQUAL_TO_BOOLEAN: 17,
35
- MATCHES_STRING: 18
26
+ EQUAL_TO_SET: 8,
27
+ CONTAINS_ANY_OF_SET: 9,
28
+ CONTAINS_ALL_OF_SET: 10,
29
+ PART_OF_SET: 11,
30
+ ENDS_WITH: 12,
31
+ STARTS_WITH: 13,
32
+ CONTAINS_STRING: 14,
33
+ IN_SPLIT_TREATMENT: 15,
34
+ EQUAL_TO_BOOLEAN: 16,
35
+ MATCHES_STRING: 17
36
36
  };
37
- export var dataTypes = {
37
+ export var matcherDataTypes = {
38
38
  BOOLEAN: 'BOOLEAN',
39
39
  STRING: 'STRING',
40
40
  NUMBER: 'NUMBER',
@@ -42,60 +42,7 @@ export var dataTypes = {
42
42
  DATETIME: 'DATETIME',
43
43
  NOT_SPECIFIED: 'NOT_SPECIFIED'
44
44
  };
45
- export var mapper = function mapper(matcherType) {
46
- switch (matcherType) {
47
- case 'ALL_KEYS':
48
- return types.ALL;
49
-
50
- case 'IN_SEGMENT':
51
- return types.SEGMENT;
52
-
53
- case 'WHITELIST':
54
- return types.WHITELIST;
55
-
56
- case 'EQUAL_TO':
57
- return types.EQUAL_TO;
58
-
59
- case 'GREATER_THAN_OR_EQUAL_TO':
60
- return types.GREATER_THAN_OR_EQUAL_TO;
61
-
62
- case 'LESS_THAN_OR_EQUAL_TO':
63
- return types.LESS_THAN_OR_EQUAL_TO;
64
-
65
- case 'BETWEEN':
66
- return types.BETWEEN;
67
-
68
- case 'EQUAL_TO_SET':
69
- return types.EQUAL_TO_SET;
70
-
71
- case 'CONTAINS_ANY_OF_SET':
72
- return types.CONTAINS_ANY_OF_SET;
73
-
74
- case 'CONTAINS_ALL_OF_SET':
75
- return types.CONTAINS_ALL_OF_SET;
76
-
77
- case 'PART_OF_SET':
78
- return types.PART_OF_SET;
79
-
80
- case 'ENDS_WITH':
81
- return types.ENDS_WITH;
82
-
83
- case 'STARTS_WITH':
84
- return types.STARTS_WITH;
85
-
86
- case 'CONTAINS_STRING':
87
- return types.CONTAINS_STRING;
88
-
89
- case 'IN_SPLIT_TREATMENT':
90
- return types.IN_SPLIT_TREATMENT;
91
-
92
- case 'EQUAL_TO_BOOLEAN':
93
- return types.EQUAL_TO_BOOLEAN;
94
-
95
- case 'MATCHES_STRING':
96
- return types.MATCHES_STRING;
97
-
98
- default:
99
- return types.UNDEFINED;
100
- }
101
- };
45
+ export function matcherTypesMapper(matcherType) {
46
+ var type = matcherTypes[matcherType];
47
+ if (type) return type;else return matcherTypes.UNDEFINED;
48
+ }
@@ -13,7 +13,7 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
13
  See the License for the specific language governing permissions and
14
14
  limitations under the License.
15
15
  **/
16
- import { types as matcherTypes, mapper as matcherTypesMapper } from '../matchers/types';
16
+ import { matcherTypes, matcherTypesMapper } from '../matchers/types';
17
17
  import segmentTransform from './segment';
18
18
  import whitelistTransform from './whitelist';
19
19
  /**
@@ -28,7 +28,7 @@ function transform(matcherGroup) {
28
28
  var type = matcherTypesMapper(matcherType);
29
29
  var value = undefined;
30
30
 
31
- if (type === matcherTypes.SEGMENT) {
31
+ if (type === matcherTypes.IN_SEGMENT) {
32
32
  value = segmentTransform(segmentObject);
33
33
  } else if (type === matcherTypes.WHITELIST) {
34
34
  value = whitelistTransform(whitelistObject);
@@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
14
14
  limitations under the License.
15
15
  **/
16
16
  import { findIndex } from '../../utils/lang';
17
- import { types as matcherTypes, mapper as matcherTypesMapper, dataTypes as matcherDataTypes } from '../matchers/types';
17
+ import { matcherTypes, matcherTypesMapper, matcherDataTypes } from '../matchers/types';
18
18
  import segmentTransform from './segment';
19
19
  import whitelistTransform from './whitelist';
20
20
  import setTransform from './set';
@@ -39,7 +39,7 @@ function transform(matchers) {
39
39
  var dataType = matcherDataTypes.STRING;
40
40
  var value = undefined;
41
41
 
42
- if (type === matcherTypes.SEGMENT) {
42
+ if (type === matcherTypes.IN_SEGMENT) {
43
43
  value = segmentTransform(segmentObject);
44
44
  } else if (type === matcherTypes.WHITELIST) {
45
45
  value = whitelistTransform(whitelistObject);
@@ -17,9 +17,7 @@ import logFactory from '../../utils/logger';
17
17
  var log = logFactory('splitio-engine:sanitize');
18
18
  import { isObject, uniq, toString, toNumber } from '../../utils/lang';
19
19
  import { zeroSinceHH, zeroSinceSS } from '../convertions';
20
- import { types as matcherTypes, dataTypes as matcherDataTypes } from '../matchers/types';
21
- var MATCHERS = matcherTypes;
22
- var DATA_TYPES = matcherDataTypes;
20
+ import { matcherTypes, matcherDataTypes } from '../matchers/types';
23
21
 
24
22
  function sanitizeNumber(val) {
25
23
  var num = toNumber(val);
@@ -70,15 +68,15 @@ function dependencyProcessor(sanitizedValue, attributes) {
70
68
 
71
69
  function getProcessingFunction(matcherTypeID, dataType) {
72
70
  switch (matcherTypeID) {
73
- case MATCHERS.EQUAL_TO:
71
+ case matcherTypes.EQUAL_TO:
74
72
  return dataType === 'DATETIME' ? zeroSinceHH : undefined;
75
73
 
76
- case MATCHERS.GREATER_THAN_OR_EQUAL_TO:
77
- case MATCHERS.LESS_THAN_OR_EQUAL_TO:
78
- case MATCHERS.BETWEEN:
74
+ case matcherTypes.GREATER_THAN_OR_EQUAL_TO:
75
+ case matcherTypes.LESS_THAN_OR_EQUAL_TO:
76
+ case matcherTypes.BETWEEN:
79
77
  return dataType === 'DATETIME' ? zeroSinceSS : undefined;
80
78
 
81
- case MATCHERS.IN_SPLIT_TREATMENT:
79
+ case matcherTypes.IN_SPLIT_TREATMENT:
82
80
  return dependencyProcessor;
83
81
 
84
82
  default:
@@ -91,24 +89,24 @@ function sanitizeValue(matcherTypeID, value, dataType, attributes) {
91
89
  var sanitizedValue;
92
90
 
93
91
  switch (dataType) {
94
- case DATA_TYPES.NUMBER:
95
- case DATA_TYPES.DATETIME:
92
+ case matcherDataTypes.NUMBER:
93
+ case matcherDataTypes.DATETIME:
96
94
  sanitizedValue = sanitizeNumber(value);
97
95
  break;
98
96
 
99
- case DATA_TYPES.STRING:
97
+ case matcherDataTypes.STRING:
100
98
  sanitizedValue = sanitizeString(value);
101
99
  break;
102
100
 
103
- case DATA_TYPES.SET:
101
+ case matcherDataTypes.SET:
104
102
  sanitizedValue = sanitizeArray(value);
105
103
  break;
106
104
 
107
- case DATA_TYPES.BOOLEAN:
105
+ case matcherDataTypes.BOOLEAN:
108
106
  sanitizedValue = sanitizeBoolean(value);
109
107
  break;
110
108
 
111
- case DATA_TYPES.NOT_SPECIFIED:
109
+ case matcherDataTypes.NOT_SPECIFIED:
112
110
  sanitizedValue = value;
113
111
  break;
114
112
 
@@ -1,4 +1,4 @@
1
- import { hash128 } from '../../engine/engine/murmur3/murmur3_128';
1
+ import { hash128 } from '../../engine/engine/murmur3/murmur3_128_x86';
2
2
  import { buildKey } from './buildKey';
3
3
  export function hashImpression128(impression) {
4
4
  return hash128(buildKey(impression));
@@ -9,7 +9,6 @@ var ImpressionObserver = /*#__PURE__*/function () {
9
9
  var _proto = ImpressionObserver.prototype;
10
10
 
11
11
  _proto.testAndSet = function testAndSet(impression) {
12
- if (!impression) return null;
13
12
  var hash = this.hasher(impression);
14
13
  var previous = this.cache.get(hash);
15
14
  this.cache.set(hash, impression.time);
@@ -13,6 +13,7 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
13
  See the License for the specific language governing permissions and
14
14
  limitations under the License.
15
15
  **/
16
+ import { STORAGE_LOCALSTORAGE } from '../../utils/constants';
16
17
  import { forOwn } from '../../utils/lang';
17
18
  import logFactory from '../../utils/logger';
18
19
  var log = logFactory('splitio-producer:offline');
@@ -52,13 +53,13 @@ function FromObjectUpdaterFactory(Fetcher, context) {
52
53
  })]);
53
54
  });
54
55
  return Promise.all([storage.splits.flush(), // required to sync removed splits from mock
55
- storage.splits.setChangeNumber(Date.now()), storage.splits.addSplits(splits)]).then(function () {
56
+ storage.splits.addSplits(splits)]).then(function () {
56
57
  readiness.splits.emit(readiness.splits.SDK_SPLITS_ARRIVED);
57
58
 
58
59
  if (startingUp) {
59
60
  startingUp = false; // Emits SDK_READY_FROM_CACHE
60
61
 
61
- if (storage.splits.checkCache()) readiness.splits.emit(readiness.splits.SDK_SPLITS_CACHE_LOADED); // Only emits SDK_SEGMENTS_ARRIVED the first time for SDK_READY
62
+ if (settings.storage.__originalType === STORAGE_LOCALSTORAGE) readiness.splits.emit(readiness.splits.SDK_SPLITS_CACHE_LOADED); // Only emits SDK_SEGMENTS_ARRIVED the first time for SDK_READY
62
63
 
63
64
  readiness.segments.emit(readiness.segments.SDK_SEGMENTS_ARRIVED);
64
65
  }
@@ -232,21 +232,13 @@ export default function PushManagerFactory(context, clientContexts
232
232
  forOwn(clients, function (_ref3) {
233
233
  var hash64 = _ref3.hash64,
234
234
  worker = _ref3.worker;
235
+ var add = added.has(hash64.dec) ? true : removed.has(hash64.dec) ? false : undefined;
235
236
 
236
- if (added.has(hash64.dec)) {
237
+ if (add !== undefined) {
237
238
  worker.put(parsedData.changeNumber, {
238
239
  name: parsedData.segmentName,
239
- add: true
240
+ add: add
240
241
  });
241
- return;
242
- }
243
-
244
- if (removed.has(hash64.dec)) {
245
- worker.put(parsedData.changeNumber, {
246
- name: parsedData.segmentName,
247
- add: false
248
- });
249
- return;
250
242
  }
251
243
  });
252
244
  return;
@@ -8,11 +8,22 @@ export var LogLevels = {
8
8
  'WARN': 'WARN',
9
9
  'ERROR': 'ERROR',
10
10
  'NONE': 'NONE'
11
+ };
12
+ var LogLevelIndexes = {
13
+ DEBUG: 1,
14
+ INFO: 2,
15
+ WARN: 3,
16
+ ERROR: 4,
17
+ NONE: 5
11
18
  }; // DEBUG is the default. The log level is not specific to an SDK instance.
12
19
 
13
- var GlobalLogLevel = LogLevels.DEBUG;
20
+ var GlobalLogLevel = LogLevelIndexes.DEBUG;
21
+ /**
22
+ * @param {'DEBUG'|'INFO'|'WARN'|'ERROR'|'NONE'} level
23
+ */
24
+
14
25
  export var setLogLevel = function setLogLevel(level) {
15
- GlobalLogLevel = level;
26
+ GlobalLogLevel = LogLevelIndexes[level];
16
27
  };
17
28
  var defaultOptions = {
18
29
  showLevel: true,
@@ -27,19 +38,19 @@ export var Logger = /*#__PURE__*/function () {
27
38
  var _proto = Logger.prototype;
28
39
 
29
40
  _proto.debug = function debug(msg) {
30
- if (this._shouldLog(LogLevels.DEBUG)) this._log(LogLevels.DEBUG, msg);
41
+ if (this._shouldLog(LogLevelIndexes.DEBUG)) this._log(LogLevels.DEBUG, msg);
31
42
  };
32
43
 
33
44
  _proto.info = function info(msg) {
34
- if (this._shouldLog(LogLevels.INFO)) this._log(LogLevels.INFO, msg);
45
+ if (this._shouldLog(LogLevelIndexes.INFO)) this._log(LogLevels.INFO, msg);
35
46
  };
36
47
 
37
48
  _proto.warn = function warn(msg) {
38
- if (this._shouldLog(LogLevels.WARN)) this._log(LogLevels.WARN, msg);
49
+ if (this._shouldLog(LogLevelIndexes.WARN)) this._log(LogLevels.WARN, msg);
39
50
  };
40
51
 
41
52
  _proto.error = function error(msg) {
42
- if (this.options.displayAllErrors || this._shouldLog(LogLevels.ERROR)) this._log(LogLevels.ERROR, msg);
53
+ if (this.options.displayAllErrors || this._shouldLog(LogLevelIndexes.ERROR)) this._log(LogLevels.ERROR, msg);
43
54
  };
44
55
 
45
56
  _proto._log = function _log(level, text) {
@@ -61,18 +72,14 @@ export var Logger = /*#__PURE__*/function () {
61
72
  }
62
73
 
63
74
  return result += text;
64
- };
75
+ }
76
+ /**
77
+ * @param {number} level
78
+ */
79
+ ;
65
80
 
66
81
  _proto._shouldLog = function _shouldLog(level) {
67
- var logLevel = GlobalLogLevel;
68
- var levels = Object.keys(LogLevels).map(function (f) {
69
- return LogLevels[f];
70
- });
71
- var index = levels.indexOf(level); // What's the index of what it's trying to check if it should log
72
-
73
- var levelIdx = levels.indexOf(logLevel); // What's the current log level index.
74
-
75
- return index >= levelIdx;
82
+ return level >= GlobalLogLevel;
76
83
  };
77
84
 
78
85
  return Logger;
@@ -25,7 +25,7 @@ import validateSplitFilters from '../inputValidation/splitFilters';
25
25
  import { API } from '../../utils/logger';
26
26
  import { STANDALONE_MODE, STORAGE_MEMORY, CONSUMER_MODE, OPTIMIZED } from '../../utils/constants';
27
27
  import validImpressionsMode from './impressionsMode';
28
- var version = '10.16.0';
28
+ var version = '10.16.1-rc.0';
29
29
  var eventsEndpointMatcher = /^\/(testImpressions|metrics|events)/;
30
30
  var authEndpointMatcher = /^\/v2\/auth/;
31
31
  var streamingEndpointMatcher = /^\/(sse|event-stream)/;
@@ -16,33 +16,48 @@ limitations under the License.
16
16
  import logFactory from '../../../utils/logger';
17
17
  var log = logFactory('splitio-settings');
18
18
  import isLocalStorageAvailable from '../../../utils/localstorage/isAvailable';
19
- import { STORAGE_MEMORY, STORAGE_LOCALSTORAGE } from '../../../utils/constants';
19
+ import { LOCALHOST_MODE, STORAGE_MEMORY, STORAGE_LOCALSTORAGE } from '../../../utils/constants';
20
20
 
21
21
  var ParseStorageSettings = function ParseStorageSettings(settings) {
22
- var _settings$storage = settings.storage,
22
+ var mode = settings.mode,
23
+ _settings$storage = settings.storage,
23
24
  _settings$storage$typ = _settings$storage.type,
24
25
  type = _settings$storage$typ === void 0 ? STORAGE_MEMORY : _settings$storage$typ,
25
26
  _settings$storage$opt = _settings$storage.options,
26
27
  options = _settings$storage$opt === void 0 ? {} : _settings$storage$opt,
27
28
  prefix = _settings$storage.prefix;
28
29
 
30
+ var __originalType;
31
+
29
32
  if (prefix) {
30
33
  prefix += '.SPLITIO';
31
34
  } else {
32
35
  prefix = 'SPLITIO';
36
+ }
37
+
38
+ var fallbackToMemory = function fallbackToMemory() {
39
+ __originalType = type;
40
+ type = STORAGE_MEMORY;
41
+ }; // In localhost mode, fallback to Memory storage and track original
42
+ // type to emit SDK_READY_FROM_CACHE if corresponds
43
+
44
+
45
+ if (mode === LOCALHOST_MODE && type === STORAGE_LOCALSTORAGE) {
46
+ fallbackToMemory();
33
47
  } // If an invalid storage type is provided OR we want to use LOCALSTORAGE and
34
48
  // it's not available, fallback into MEMORY
35
49
 
36
50
 
37
51
  if (type !== STORAGE_MEMORY && type !== STORAGE_LOCALSTORAGE || type === STORAGE_LOCALSTORAGE && !isLocalStorageAvailable()) {
38
- type = STORAGE_MEMORY;
52
+ fallbackToMemory();
39
53
  log.warn('Invalid or unavailable storage. Fallbacking into MEMORY storage');
40
54
  }
41
55
 
42
56
  return {
43
57
  type: type,
44
58
  options: options,
45
- prefix: prefix
59
+ prefix: prefix,
60
+ __originalType: __originalType
46
61
  };
47
62
  };
48
63
 
@@ -240,7 +240,7 @@ function hash128x64(key
240
240
  }
241
241
  /**
242
242
  * x64 version of Murmur3 for 128bits.
243
- * Used in hashImpression128.
243
+ *
244
244
  * @param {string} str
245
245
  */
246
246
 
@@ -172,10 +172,9 @@ function hash128x86(key
172
172
  }
173
173
  /**
174
174
  * x86 version of Murmur3 for 128bits.
175
- * @param {string} str
175
+ * Used by hashImpression128 because in JS it is more efficient than the x64 version, no matter the underlying OS/CPU arch.
176
176
  *
177
- * @TODO Test and use in hashImpression128 instead of the x64 version,
178
- * because it is more time efficient in JS, no matter the underlying CPU arch.
177
+ * @param {string} str
179
178
  */
180
179
 
181
180
 
@@ -5,8 +5,6 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
5
5
  exports.__esModule = true;
6
6
  exports.default = void 0;
7
7
 
8
- var _types = require("./types");
9
-
10
8
  var _all = _interopRequireDefault(require("./all"));
11
9
 
12
10
  var _segment = _interopRequireDefault(require("./segment"));
@@ -56,50 +54,34 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
56
54
  See the License for the specific language governing permissions and
57
55
  limitations under the License.
58
56
  **/
59
-
57
+ var matchers = [undefined, // UNDEFINED: 0,
58
+ _all.default, // ALL_KEYS: 1,
59
+ _segment.default, // IN_SEGMENT: 2,
60
+ _whitelist.default, // WHITELIST: 3,
61
+ _eq.default, // EQUAL_TO: 4,
62
+ _gte.default, // GREATER_THAN_OR_EQUAL_TO: 5,
63
+ _lte.default, // LESS_THAN_OR_EQUAL_TO: 6,
64
+ _between.default, // BETWEEN: 7,
65
+ _eq_set.default, // EQUAL_TO_SET: 8,
66
+ _cont_any.default, // CONTAINS_ANY_OF_SET: 9,
67
+ _cont_all.default, // CONTAINS_ALL_OF_SET: 10,
68
+ _part_of.default, // PART_OF_SET: 11,
69
+ _ew.default, // ENDS_WITH: 12,
70
+ _sw.default, // STARTS_WITH: 13,
71
+ _cont_str.default, // CONTAINS_STRING: 14,
72
+ _dependency.default, // IN_SPLIT_TREATMENT: 15,
73
+ _boolean.default, // EQUAL_TO_BOOLEAN: 16,
74
+ _string.default // MATCHES_STRING: 17
75
+ ];
60
76
  /**
61
77
  * Matcher factory.
62
78
  */
79
+
63
80
  function MatcherFactory(matcherDto, storage) {
64
81
  var type = matcherDto.type,
65
82
  value = matcherDto.value;
66
83
  var matcherFn;
67
-
68
- if (type === _types.types.ALL) {
69
- matcherFn = (0, _all.default)(value);
70
- } else if (type === _types.types.SEGMENT) {
71
- matcherFn = (0, _segment.default)(value, storage);
72
- } else if (type === _types.types.WHITELIST) {
73
- matcherFn = (0, _whitelist.default)(value);
74
- } else if (type === _types.types.EQUAL_TO) {
75
- matcherFn = (0, _eq.default)(value);
76
- } else if (type === _types.types.GREATER_THAN_OR_EQUAL_TO) {
77
- matcherFn = (0, _gte.default)(value);
78
- } else if (type === _types.types.LESS_THAN_OR_EQUAL_TO) {
79
- matcherFn = (0, _lte.default)(value);
80
- } else if (type === _types.types.BETWEEN) {
81
- matcherFn = (0, _between.default)(value);
82
- } else if (type === _types.types.EQUAL_TO_SET) {
83
- matcherFn = (0, _eq_set.default)(value);
84
- } else if (type === _types.types.CONTAINS_ANY_OF_SET) {
85
- matcherFn = (0, _cont_any.default)(value);
86
- } else if (type === _types.types.CONTAINS_ALL_OF_SET) {
87
- matcherFn = (0, _cont_all.default)(value);
88
- } else if (type === _types.types.PART_OF_SET) {
89
- matcherFn = (0, _part_of.default)(value);
90
- } else if (type === _types.types.STARTS_WITH) {
91
- matcherFn = (0, _sw.default)(value);
92
- } else if (type === _types.types.ENDS_WITH) {
93
- matcherFn = (0, _ew.default)(value);
94
- } else if (type === _types.types.CONTAINS_STRING) {
95
- matcherFn = (0, _cont_str.default)(value);
96
- } else if (type === _types.types.IN_SPLIT_TREATMENT) {
97
- matcherFn = (0, _dependency.default)(value, storage);
98
- } else if (type === _types.types.EQUAL_TO_BOOLEAN) {
99
- matcherFn = (0, _boolean.default)(value);
100
- } else if (type === _types.types.MATCHES_STRING) {
101
- matcherFn = (0, _string.default)(value);
102
- }
84
+ if (matchers[type]) matcherFn = matchers[type](value, storage); // There is no index-out-of-bound exception in JavaScript
103
85
 
104
86
  return matcherFn;
105
87
  }