@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.
- package/cjs/evaluator/matchers/matcherTypes.js +4 -4
- package/cjs/evaluator/matchersTransform/index.js +11 -11
- package/cjs/evaluator/value/sanitize.js +6 -6
- package/cjs/listeners/browser.js +5 -2
- package/cjs/listeners/node.js +9 -2
- package/cjs/logger/constants.js +3 -1
- package/cjs/logger/messages/error.js +3 -2
- package/cjs/logger/messages/info.js +2 -2
- package/cjs/logger/messages/warn.js +2 -1
- package/cjs/readiness/readinessManager.js +10 -7
- package/cjs/sdkFactory/index.js +1 -1
- package/cjs/services/splitApi.js +9 -1
- package/cjs/services/splitHttpClient.js +5 -4
- package/cjs/storages/AbstractSplitsCacheSync.js +1 -1
- package/cjs/storages/inLocalStorage/index.js +5 -2
- package/cjs/storages/inMemory/InMemoryStorage.js +2 -0
- package/cjs/storages/inMemory/InMemoryStorageCS.js +2 -0
- package/cjs/storages/inRedis/SplitsCacheInRedis.js +6 -2
- package/cjs/storages/inRedis/index.js +5 -2
- package/cjs/storages/pluggable/SplitsCachePluggable.js +6 -2
- package/cjs/storages/pluggable/inMemoryWrapper.js +6 -7
- package/cjs/storages/pluggable/index.js +5 -2
- package/cjs/storages/pluggable/wrapperAdapter.js +0 -1
- package/cjs/sync/offline/splitsParser/splitsParserFromFile.js +92 -89
- package/cjs/sync/offline/splitsParser/splitsParserFromSettings.js +45 -42
- package/cjs/sync/offline/syncTasks/fromObjectSyncTask.js +14 -4
- package/cjs/sync/polling/fetchers/segmentChangesFetcher.js +0 -8
- package/cjs/sync/polling/updaters/mySegmentsUpdater.js +30 -10
- package/cjs/sync/polling/updaters/segmentChangesUpdater.js +2 -4
- package/cjs/sync/streaming/SSEClient/index.js +38 -20
- package/cjs/sync/streaming/SSEHandler/NotificationKeeper.js +7 -0
- package/cjs/sync/streaming/SSEHandler/NotificationParser.js +4 -1
- package/cjs/sync/streaming/SSEHandler/index.js +8 -9
- package/cjs/sync/streaming/SSEHandler/types.js +14 -0
- package/cjs/sync/streaming/UpdateWorkers/MySegmentsUpdateWorker.js +5 -5
- package/cjs/sync/streaming/UpdateWorkers/SegmentsUpdateWorker.js +2 -1
- package/cjs/sync/streaming/UpdateWorkers/SplitsUpdateWorker.js +5 -3
- package/cjs/sync/streaming/constants.js +3 -1
- package/cjs/sync/streaming/mySegmentsV2utils.js +75 -0
- package/cjs/sync/streaming/pushManager.js +148 -40
- package/cjs/sync/submitters/metricsSyncTask.js +1 -1
- package/cjs/sync/submitters/submitterSyncTask.js +2 -2
- package/cjs/sync/syncManagerFromFile.js +15 -0
- package/cjs/sync/syncManagerFromObject.js +14 -0
- package/cjs/sync/syncManagerOffline.js +3 -3
- package/cjs/sync/syncManagerOnline.js +18 -5
- package/cjs/sync/syncTask.js +1 -1
- package/cjs/trackers/impressionObserver/ImpressionObserver.js +0 -2
- package/cjs/trackers/impressionObserver/buildKey.js +3 -9
- package/cjs/trackers/impressionObserver/impressionObserverCS.js +2 -2
- package/cjs/trackers/impressionObserver/impressionObserverSS.js +3 -3
- package/cjs/utils/constants/index.js +4 -1
- package/cjs/utils/decompress/index.js +427 -0
- package/cjs/utils/murmur3/{commons.js → common.js} +2 -6
- package/cjs/utils/murmur3/murmur3.js +11 -12
- package/cjs/utils/murmur3/murmur3_128.js +7 -142
- package/cjs/utils/murmur3/murmur3_128_x86.js +154 -0
- package/cjs/utils/murmur3/murmur3_64.js +36 -0
- package/cjs/utils/murmur3/utfx.js +100 -106
- package/cjs/utils/promise/wrapper.js +14 -11
- package/cjs/utils/settingsValidation/index.js +5 -2
- package/cjs/utils/settingsValidation/localhost/index.js +20 -0
- package/cjs/utils/settingsValidation/splitFilters.js +0 -1
- package/cjs/utils/settingsValidation/storage/storageCS.js +18 -8
- package/cjs/utils/settingsValidation/url.js +1 -1
- package/esm/evaluator/matchers/matcherTypes.js +2 -2
- package/esm/evaluator/matchersTransform/index.js +12 -12
- package/esm/evaluator/value/sanitize.js +7 -7
- package/esm/listeners/browser.js +5 -2
- package/esm/listeners/node.js +9 -2
- package/esm/logger/constants.js +2 -0
- package/esm/logger/messages/error.js +3 -2
- package/esm/logger/messages/info.js +2 -2
- package/esm/logger/messages/warn.js +2 -1
- package/esm/readiness/readinessManager.js +10 -7
- package/esm/sdkFactory/index.js +1 -1
- package/esm/services/splitApi.js +9 -1
- package/esm/services/splitHttpClient.js +5 -4
- package/esm/storages/AbstractSplitsCacheSync.js +1 -1
- package/esm/storages/inLocalStorage/index.js +5 -2
- package/esm/storages/inMemory/InMemoryStorage.js +2 -0
- package/esm/storages/inMemory/InMemoryStorageCS.js +2 -0
- package/esm/storages/inRedis/SplitsCacheInRedis.js +6 -2
- package/esm/storages/inRedis/index.js +5 -2
- package/esm/storages/pluggable/SplitsCachePluggable.js +6 -2
- package/esm/storages/pluggable/inMemoryWrapper.js +6 -7
- package/esm/storages/pluggable/index.js +5 -2
- package/esm/storages/pluggable/wrapperAdapter.js +0 -1
- package/esm/sync/offline/splitsParser/splitsParserFromFile.js +90 -88
- package/esm/sync/offline/splitsParser/splitsParserFromSettings.js +43 -41
- package/esm/sync/offline/syncTasks/fromObjectSyncTask.js +15 -5
- package/esm/sync/polling/fetchers/segmentChangesFetcher.js +0 -8
- package/esm/sync/polling/updaters/mySegmentsUpdater.js +30 -10
- package/esm/sync/polling/updaters/segmentChangesUpdater.js +2 -4
- package/esm/sync/streaming/SSEClient/index.js +38 -20
- package/esm/sync/streaming/SSEHandler/NotificationKeeper.js +7 -0
- package/esm/sync/streaming/SSEHandler/NotificationParser.js +4 -1
- package/esm/sync/streaming/SSEHandler/index.js +9 -10
- package/esm/sync/streaming/SSEHandler/types.js +13 -1
- package/esm/sync/streaming/UpdateWorkers/MySegmentsUpdateWorker.js +5 -5
- package/esm/sync/streaming/UpdateWorkers/SegmentsUpdateWorker.js +2 -1
- package/esm/sync/streaming/UpdateWorkers/SplitsUpdateWorker.js +5 -3
- package/esm/sync/streaming/constants.js +2 -0
- package/esm/sync/streaming/mySegmentsV2utils.js +69 -0
- package/esm/sync/streaming/pushManager.js +150 -42
- package/esm/sync/submitters/metricsSyncTask.js +1 -1
- package/esm/sync/submitters/submitterSyncTask.js +2 -2
- package/esm/sync/syncManagerFromFile.js +11 -0
- package/esm/sync/syncManagerFromObject.js +10 -0
- package/esm/sync/syncManagerOffline.js +3 -3
- package/esm/sync/syncManagerOnline.js +18 -5
- package/esm/sync/syncTask.js +1 -1
- package/esm/trackers/impressionObserver/ImpressionObserver.js +0 -2
- package/esm/trackers/impressionObserver/buildKey.js +2 -9
- package/esm/trackers/impressionObserver/impressionObserverCS.js +2 -2
- package/esm/trackers/impressionObserver/impressionObserverSS.js +3 -3
- package/esm/utils/constants/index.js +3 -0
- package/esm/utils/decompress/index.js +424 -0
- package/esm/utils/murmur3/{commons.js → common.js} +1 -4
- package/esm/utils/murmur3/murmur3.js +1 -2
- package/esm/utils/murmur3/murmur3_128.js +7 -142
- package/esm/utils/murmur3/murmur3_128_x86.js +150 -0
- package/esm/utils/murmur3/murmur3_64.js +32 -0
- package/esm/utils/murmur3/utfx.js +96 -106
- package/esm/utils/promise/wrapper.js +14 -11
- package/esm/utils/settingsValidation/index.js +5 -2
- package/esm/utils/settingsValidation/localhost/index.js +16 -0
- package/esm/utils/settingsValidation/splitFilters.js +0 -1
- package/esm/utils/settingsValidation/storage/storageCS.js +16 -7
- package/esm/utils/settingsValidation/url.js +1 -1
- package/package.json +5 -5
- package/src/evaluator/matchers/matcherTypes.ts +2 -2
- package/src/evaluator/matchersTransform/index.ts +12 -12
- package/src/evaluator/value/sanitize.ts +7 -7
- package/src/listeners/browser.ts +5 -2
- package/src/listeners/node.ts +14 -2
- package/src/logger/constants.ts +2 -0
- package/src/logger/messages/error.ts +3 -2
- package/src/logger/messages/info.ts +2 -2
- package/src/logger/messages/warn.ts +3 -1
- package/src/readiness/readinessManager.ts +9 -7
- package/src/sdkFactory/index.ts +1 -1
- package/src/sdkFactory/types.ts +4 -5
- package/src/services/splitApi.ts +12 -3
- package/src/services/splitHttpClient.ts +6 -5
- package/src/services/types.ts +7 -3
- package/src/storages/AbstractSplitsCacheSync.ts +1 -1
- package/src/storages/inLocalStorage/index.ts +8 -4
- package/src/storages/inMemory/InMemoryStorage.ts +3 -0
- package/src/storages/inMemory/InMemoryStorageCS.ts +3 -0
- package/src/storages/inRedis/SplitsCacheInRedis.ts +3 -1
- package/src/storages/inRedis/index.ts +8 -4
- package/src/storages/pluggable/SegmentsCachePluggable.ts +1 -1
- package/src/storages/pluggable/SplitsCachePluggable.ts +3 -1
- package/src/storages/pluggable/inMemoryWrapper.ts +6 -7
- package/src/storages/pluggable/index.ts +8 -4
- package/src/storages/pluggable/wrapperAdapter.ts +0 -1
- package/src/storages/types.ts +18 -15
- package/src/sync/offline/splitsParser/splitsParserFromFile.ts +110 -105
- package/src/sync/offline/splitsParser/splitsParserFromSettings.ts +45 -41
- package/src/sync/offline/syncTasks/fromObjectSyncTask.ts +15 -5
- package/src/sync/polling/fetchers/segmentChangesFetcher.ts +0 -7
- package/src/sync/polling/types.ts +2 -1
- package/src/sync/polling/updaters/mySegmentsUpdater.ts +28 -10
- package/src/sync/polling/updaters/segmentChangesUpdater.ts +2 -3
- package/src/sync/streaming/AuthClient/types.ts +3 -0
- package/src/sync/streaming/SSEClient/index.ts +43 -23
- package/src/sync/streaming/SSEClient/types.ts +0 -1
- package/src/sync/streaming/SSEHandler/NotificationKeeper.ts +8 -0
- package/src/sync/streaming/SSEHandler/NotificationParser.ts +4 -2
- package/src/sync/streaming/SSEHandler/index.ts +11 -20
- package/src/sync/streaming/SSEHandler/types.ts +37 -3
- package/src/sync/streaming/UpdateWorkers/MySegmentsUpdateWorker.ts +7 -6
- package/src/sync/streaming/UpdateWorkers/SegmentsUpdateWorker.ts +2 -1
- package/src/sync/streaming/UpdateWorkers/SplitsUpdateWorker.ts +4 -3
- package/src/sync/streaming/UpdateWorkers/types.ts +1 -1
- package/src/sync/streaming/constants.ts +2 -0
- package/src/sync/streaming/mySegmentsV2utils.ts +77 -0
- package/src/sync/streaming/pushManager.ts +145 -42
- package/src/sync/streaming/types.ts +14 -22
- package/src/sync/submitters/metricsSyncTask.ts +1 -1
- package/src/sync/submitters/submitterSyncTask.ts +2 -1
- package/src/sync/syncManagerFromFile.ts +13 -0
- package/src/sync/syncManagerFromObject.ts +12 -0
- package/src/sync/syncManagerOffline.ts +3 -3
- package/src/sync/syncManagerOnline.ts +19 -5
- package/src/sync/syncTask.ts +1 -1
- package/src/sync/types.ts +3 -1
- package/src/trackers/impressionObserver/ImpressionObserver.ts +4 -6
- package/src/trackers/impressionObserver/buildKey.ts +2 -16
- package/src/trackers/impressionObserver/impressionObserverCS.ts +2 -2
- package/src/trackers/impressionObserver/impressionObserverSS.ts +3 -3
- package/src/types.ts +16 -2
- package/src/utils/constants/index.ts +6 -1
- package/src/utils/decompress/index.ts +429 -0
- package/src/utils/lang/index.ts +1 -1
- package/src/utils/murmur3/{commons.ts → common.ts} +1 -5
- package/src/utils/murmur3/murmur3.ts +5 -5
- package/src/utils/murmur3/murmur3_128.ts +7 -180
- package/src/utils/murmur3/murmur3_128_x86.ts +188 -0
- package/src/utils/murmur3/murmur3_64.ts +36 -0
- package/src/utils/murmur3/utfx.ts +92 -110
- package/src/utils/promise/wrapper.ts +12 -9
- package/src/utils/settingsValidation/index.ts +8 -4
- package/src/utils/settingsValidation/localhost/index.ts +19 -0
- package/src/utils/settingsValidation/splitFilters.ts +0 -1
- package/src/utils/settingsValidation/storage/storageCS.ts +21 -8
- package/src/utils/settingsValidation/types.ts +2 -11
- package/src/utils/settingsValidation/url.ts +1 -1
- package/types/evaluator/matchers/matcherTypes.d.ts +2 -2
- package/types/listeners/browser.d.ts +3 -3
- package/types/listeners/node.d.ts +3 -2
- package/types/logger/constants.d.ts +2 -0
- package/types/sdkFactory/types.d.ts +4 -5
- package/types/services/types.d.ts +4 -0
- package/types/storages/inLocalStorage/index.d.ts +2 -2
- package/types/storages/inMemory/InMemoryStorage.d.ts +3 -0
- package/types/storages/inMemory/InMemoryStorageCS.d.ts +3 -0
- package/types/storages/inRedis/index.d.ts +2 -2
- package/types/storages/pluggable/index.d.ts +2 -2
- package/types/storages/types.d.ts +15 -15
- package/types/sync/offline/splitsParser/splitsParserFromFile.d.ts +2 -7
- package/types/sync/offline/splitsParser/splitsParserFromSettings.d.ts +1 -5
- package/types/sync/polling/types.d.ts +2 -1
- package/types/sync/streaming/AuthClient/indexV1.d.ts +12 -0
- package/types/sync/streaming/AuthClient/indexV2.d.ts +8 -0
- package/types/sync/streaming/AuthClient/types.d.ts +2 -0
- package/types/sync/streaming/SSEClient/index.d.ts +9 -12
- package/types/sync/streaming/SSEClient/types.d.ts +0 -1
- package/types/sync/streaming/SSEHandler/NotificationParser.d.ts +3 -2
- package/types/sync/streaming/SSEHandler/types.d.ts +30 -2
- package/types/sync/streaming/UpdateWorkers/MySegmentsUpdateWorker.d.ts +4 -3
- package/types/sync/streaming/UpdateWorkers/SegmentsUpdateWorker.d.ts +2 -1
- package/types/sync/streaming/UpdateWorkers/SplitsUpdateWorker.d.ts +3 -2
- package/types/sync/streaming/UpdateWorkers/types.d.ts +1 -1
- package/types/sync/streaming/constants.d.ts +3 -1
- package/types/sync/streaming/mySegmentsV2utils.d.ts +27 -0
- package/types/sync/streaming/pushManagerNoUsers.d.ts +13 -0
- package/types/sync/streaming/types.d.ts +9 -5
- package/types/sync/submitters/submitterSyncTask.d.ts +1 -1
- package/types/sync/syncManagerFromFile.d.ts +2 -0
- package/types/sync/syncManagerFromObject.d.ts +2 -0
- package/types/sync/syncManagerOffline.d.ts +1 -1
- package/types/sync/syncTask.d.ts +1 -1
- package/types/sync/types.d.ts +2 -0
- package/types/trackers/impressionObserver/ImpressionObserver.d.ts +2 -2
- package/types/trackers/impressionObserver/buildKey.d.ts +1 -1
- package/types/trackers/impressionObserver/impressionObserverCS.d.ts +2 -2
- package/types/trackers/impressionObserver/impressionObserverSS.d.ts +2 -2
- package/types/types.d.ts +16 -2
- package/types/utils/constants/index.d.ts +5 -1
- package/types/utils/decompress/index.d.ts +16 -0
- package/types/utils/lang/index.d.ts +1 -1
- package/types/utils/murmur3/common.d.ts +12 -0
- package/types/utils/murmur3/murmur3.d.ts +2 -2
- package/types/utils/murmur3/murmur3_128.d.ts +5 -0
- package/types/utils/murmur3/murmur3_128_x86.d.ts +7 -0
- package/types/utils/murmur3/murmur3_64.d.ts +10 -0
- package/types/utils/murmur3/utfx.d.ts +24 -6
- package/types/utils/settingsValidation/index.d.ts +3 -2
- package/types/utils/settingsValidation/localhost/index.d.ts +9 -0
- package/types/utils/settingsValidation/storage/storageCS.d.ts +7 -1
- package/types/utils/settingsValidation/types.d.ts +2 -10
- package/cjs/sync/streaming/pushManagerCS.js +0 -178
- package/cjs/sync/streaming/pushManagerSS.js +0 -128
- package/esm/sync/streaming/pushManagerCS.js +0 -174
- package/esm/sync/streaming/pushManagerSS.js +0 -124
- package/src/sync/streaming/pushManagerCS.ts +0 -237
- package/src/sync/streaming/pushManagerSS.ts +0 -177
|
@@ -2,11 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.hash128 = void 0;
|
|
4
4
|
/* eslint-disable no-fallthrough */
|
|
5
|
-
var
|
|
6
|
-
var X64 = 'x64';
|
|
7
|
-
var X86 = 'x86';
|
|
8
|
-
var X64_ARCHS = ['arm64', 'ppc64', 'x64', 's390x', 'mipsel'];
|
|
9
|
-
var isX64 = getArchType() === X64;
|
|
5
|
+
var common_1 = require("./common");
|
|
10
6
|
/*
|
|
11
7
|
* +----------------------------------------------------------------------------------+
|
|
12
8
|
* | murmurHash3.js v3.0.0 (http://github.com/karanlyons/murmurHash3.js) |
|
|
@@ -125,135 +121,6 @@ function _x64Fmix(h) {
|
|
|
125
121
|
}
|
|
126
122
|
// PUBLIC FUNCTIONS
|
|
127
123
|
// ----------------
|
|
128
|
-
function hash128x86(key, seed) {
|
|
129
|
-
//
|
|
130
|
-
// Given a string and an optional seed as an int, returns a 128 bit
|
|
131
|
-
// hash using the x86 flavor of MurmurHash3, as an unsigned hex.
|
|
132
|
-
//
|
|
133
|
-
key = key || '';
|
|
134
|
-
seed = seed || 0;
|
|
135
|
-
var remainder = key.length % 16;
|
|
136
|
-
var bytes = key.length - remainder;
|
|
137
|
-
var h1 = seed;
|
|
138
|
-
var h2 = seed;
|
|
139
|
-
var h3 = seed;
|
|
140
|
-
var h4 = seed;
|
|
141
|
-
var k1 = 0;
|
|
142
|
-
var k2 = 0;
|
|
143
|
-
var k3 = 0;
|
|
144
|
-
var k4 = 0;
|
|
145
|
-
var c1 = 0x239b961b;
|
|
146
|
-
var c2 = 0xab0e9789;
|
|
147
|
-
var c3 = 0x38b34ae5;
|
|
148
|
-
var c4 = 0xa1e38b93;
|
|
149
|
-
for (var i = 0; i < bytes; i = i + 16) {
|
|
150
|
-
k1 = ((key.charCodeAt(i) & 0xff)) | ((key.charCodeAt(i + 1) & 0xff) << 8) | ((key.charCodeAt(i + 2) & 0xff) << 16) | ((key.charCodeAt(i + 3) & 0xff) << 24);
|
|
151
|
-
k2 = ((key.charCodeAt(i + 4) & 0xff)) | ((key.charCodeAt(i + 5) & 0xff) << 8) | ((key.charCodeAt(i + 6) & 0xff) << 16) | ((key.charCodeAt(i + 7) & 0xff) << 24);
|
|
152
|
-
k3 = ((key.charCodeAt(i + 8) & 0xff)) | ((key.charCodeAt(i + 9) & 0xff) << 8) | ((key.charCodeAt(i + 10) & 0xff) << 16) | ((key.charCodeAt(i + 11) & 0xff) << 24);
|
|
153
|
-
k4 = ((key.charCodeAt(i + 12) & 0xff)) | ((key.charCodeAt(i + 13) & 0xff) << 8) | ((key.charCodeAt(i + 14) & 0xff) << 16) | ((key.charCodeAt(i + 15) & 0xff) << 24);
|
|
154
|
-
k1 = commons_1.x86Multiply(k1, c1);
|
|
155
|
-
k1 = commons_1.x86Rotl(k1, 15);
|
|
156
|
-
k1 = commons_1.x86Multiply(k1, c2);
|
|
157
|
-
h1 ^= k1;
|
|
158
|
-
h1 = commons_1.x86Rotl(h1, 19);
|
|
159
|
-
h1 += h2;
|
|
160
|
-
h1 = commons_1.x86Multiply(h1, 5) + 0x561ccd1b;
|
|
161
|
-
k2 = commons_1.x86Multiply(k2, c2);
|
|
162
|
-
k2 = commons_1.x86Rotl(k2, 16);
|
|
163
|
-
k2 = commons_1.x86Multiply(k2, c3);
|
|
164
|
-
h2 ^= k2;
|
|
165
|
-
h2 = commons_1.x86Rotl(h2, 17);
|
|
166
|
-
h2 += h3;
|
|
167
|
-
h2 = commons_1.x86Multiply(h2, 5) + 0x0bcaa747;
|
|
168
|
-
k3 = commons_1.x86Multiply(k3, c3);
|
|
169
|
-
k3 = commons_1.x86Rotl(k3, 17);
|
|
170
|
-
k3 = commons_1.x86Multiply(k3, c4);
|
|
171
|
-
h3 ^= k3;
|
|
172
|
-
h3 = commons_1.x86Rotl(h3, 15);
|
|
173
|
-
h3 += h4;
|
|
174
|
-
h3 = commons_1.x86Multiply(h3, 5) + 0x96cd1c35;
|
|
175
|
-
k4 = commons_1.x86Multiply(k4, c4);
|
|
176
|
-
k4 = commons_1.x86Rotl(k4, 18);
|
|
177
|
-
k4 = commons_1.x86Multiply(k4, c1);
|
|
178
|
-
h4 ^= k4;
|
|
179
|
-
h4 = commons_1.x86Rotl(h4, 13);
|
|
180
|
-
h4 += h1;
|
|
181
|
-
h4 = commons_1.x86Multiply(h4, 5) + 0x32ac3b17;
|
|
182
|
-
}
|
|
183
|
-
k1 = 0;
|
|
184
|
-
k2 = 0;
|
|
185
|
-
k3 = 0;
|
|
186
|
-
k4 = 0;
|
|
187
|
-
switch (remainder) {
|
|
188
|
-
case 15:
|
|
189
|
-
k4 ^= key.charCodeAt(i + 14) << 16;
|
|
190
|
-
case 14:
|
|
191
|
-
k4 ^= key.charCodeAt(i + 13) << 8;
|
|
192
|
-
case 13:
|
|
193
|
-
k4 ^= key.charCodeAt(i + 12);
|
|
194
|
-
k4 = commons_1.x86Multiply(k4, c4);
|
|
195
|
-
k4 = commons_1.x86Rotl(k4, 18);
|
|
196
|
-
k4 = commons_1.x86Multiply(k4, c1);
|
|
197
|
-
h4 ^= k4;
|
|
198
|
-
case 12:
|
|
199
|
-
k3 ^= key.charCodeAt(i + 11) << 24;
|
|
200
|
-
case 11:
|
|
201
|
-
k3 ^= key.charCodeAt(i + 10) << 16;
|
|
202
|
-
case 10:
|
|
203
|
-
k3 ^= key.charCodeAt(i + 9) << 8;
|
|
204
|
-
case 9:
|
|
205
|
-
k3 ^= key.charCodeAt(i + 8);
|
|
206
|
-
k3 = commons_1.x86Multiply(k3, c3);
|
|
207
|
-
k3 = commons_1.x86Rotl(k3, 17);
|
|
208
|
-
k3 = commons_1.x86Multiply(k3, c4);
|
|
209
|
-
h3 ^= k3;
|
|
210
|
-
case 8:
|
|
211
|
-
k2 ^= key.charCodeAt(i + 7) << 24;
|
|
212
|
-
case 7:
|
|
213
|
-
k2 ^= key.charCodeAt(i + 6) << 16;
|
|
214
|
-
case 6:
|
|
215
|
-
k2 ^= key.charCodeAt(i + 5) << 8;
|
|
216
|
-
case 5:
|
|
217
|
-
k2 ^= key.charCodeAt(i + 4);
|
|
218
|
-
k2 = commons_1.x86Multiply(k2, c2);
|
|
219
|
-
k2 = commons_1.x86Rotl(k2, 16);
|
|
220
|
-
k2 = commons_1.x86Multiply(k2, c3);
|
|
221
|
-
h2 ^= k2;
|
|
222
|
-
case 4:
|
|
223
|
-
k1 ^= key.charCodeAt(i + 3) << 24;
|
|
224
|
-
case 3:
|
|
225
|
-
k1 ^= key.charCodeAt(i + 2) << 16;
|
|
226
|
-
case 2:
|
|
227
|
-
k1 ^= key.charCodeAt(i + 1) << 8;
|
|
228
|
-
case 1:
|
|
229
|
-
k1 ^= key.charCodeAt(i);
|
|
230
|
-
k1 = commons_1.x86Multiply(k1, c1);
|
|
231
|
-
k1 = commons_1.x86Rotl(k1, 15);
|
|
232
|
-
k1 = commons_1.x86Multiply(k1, c2);
|
|
233
|
-
h1 ^= k1;
|
|
234
|
-
}
|
|
235
|
-
h1 ^= key.length;
|
|
236
|
-
h2 ^= key.length;
|
|
237
|
-
h3 ^= key.length;
|
|
238
|
-
h4 ^= key.length;
|
|
239
|
-
h1 += h2;
|
|
240
|
-
h1 += h3;
|
|
241
|
-
h1 += h4;
|
|
242
|
-
h2 += h1;
|
|
243
|
-
h3 += h1;
|
|
244
|
-
h4 += h1;
|
|
245
|
-
h1 = commons_1.x86Fmix(h1);
|
|
246
|
-
h2 = commons_1.x86Fmix(h2);
|
|
247
|
-
h3 = commons_1.x86Fmix(h3);
|
|
248
|
-
h4 = commons_1.x86Fmix(h4);
|
|
249
|
-
h1 += h2;
|
|
250
|
-
h1 += h3;
|
|
251
|
-
h1 += h4;
|
|
252
|
-
h2 += h1;
|
|
253
|
-
h3 += h1;
|
|
254
|
-
h4 += h1;
|
|
255
|
-
return ('00000000' + (h1 >>> 0).toString(16)).slice(-8) + ('00000000' + (h2 >>> 0).toString(16)).slice(-8) + ('00000000' + (h3 >>> 0).toString(16)).slice(-8) + ('00000000' + (h4 >>> 0).toString(16)).slice(-8);
|
|
256
|
-
}
|
|
257
124
|
function hash128x64(key, seed) {
|
|
258
125
|
//
|
|
259
126
|
// Given a string and an optional seed as an int, returns a 128 bit
|
|
@@ -341,14 +208,12 @@ function hash128x64(key, seed) {
|
|
|
341
208
|
h2 = _x64Add(h2, h1);
|
|
342
209
|
return ('00000000' + (h1[0] >>> 0).toString(16)).slice(-8) + ('00000000' + (h1[1] >>> 0).toString(16)).slice(-8) + ('00000000' + (h2[0] >>> 0).toString(16)).slice(-8) + ('00000000' + (h2[1] >>> 0).toString(16)).slice(-8);
|
|
343
210
|
}
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
return (X64_ARCHS.indexOf(arch) > -1) ? X64 : X86;
|
|
350
|
-
}
|
|
211
|
+
/**
|
|
212
|
+
* x64 version of Murmur3 for 128bits.
|
|
213
|
+
*
|
|
214
|
+
* @param {string} str
|
|
215
|
+
*/
|
|
351
216
|
function hash128(str, seed) {
|
|
352
|
-
return
|
|
217
|
+
return hash128x64(common_1.UTF16ToUTF8(str), seed >>> 0);
|
|
353
218
|
}
|
|
354
219
|
exports.hash128 = hash128;
|
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.hash128 = void 0;
|
|
4
|
+
/* eslint-disable no-fallthrough */
|
|
5
|
+
var common_1 = require("./common");
|
|
6
|
+
/*!
|
|
7
|
+
* +----------------------------------------------------------------------------------+
|
|
8
|
+
* | murmurHash3.js v3.0.0 (http://github.com/karanlyons/murmurHash3.js) |
|
|
9
|
+
* | A TypeScript/JavaScript implementation of MurmurHash3's hashing algorithms. |
|
|
10
|
+
* |----------------------------------------------------------------------------------|
|
|
11
|
+
* | Copyright (c) 2012-2020 Karan Lyons. Freely distributable under the MIT license. |
|
|
12
|
+
* +----------------------------------------------------------------------------------+
|
|
13
|
+
*/
|
|
14
|
+
// PUBLIC FUNCTIONS
|
|
15
|
+
// ----------------
|
|
16
|
+
function hash128x86(key, seed) {
|
|
17
|
+
//
|
|
18
|
+
// Given a string and an optional seed as an int, returns a 128 bit
|
|
19
|
+
// hash using the x86 flavor of MurmurHash3, as an unsigned hex.
|
|
20
|
+
//
|
|
21
|
+
key = key || '';
|
|
22
|
+
seed = seed || 0;
|
|
23
|
+
var remainder = key.length % 16;
|
|
24
|
+
var bytes = key.length - remainder;
|
|
25
|
+
var h1 = seed;
|
|
26
|
+
var h2 = seed;
|
|
27
|
+
var h3 = seed;
|
|
28
|
+
var h4 = seed;
|
|
29
|
+
var k1 = 0;
|
|
30
|
+
var k2 = 0;
|
|
31
|
+
var k3 = 0;
|
|
32
|
+
var k4 = 0;
|
|
33
|
+
var c1 = 0x239b961b;
|
|
34
|
+
var c2 = 0xab0e9789;
|
|
35
|
+
var c3 = 0x38b34ae5;
|
|
36
|
+
var c4 = 0xa1e38b93;
|
|
37
|
+
for (var i = 0; i < bytes; i = i + 16) {
|
|
38
|
+
k1 = ((key.charCodeAt(i) & 0xff)) | ((key.charCodeAt(i + 1) & 0xff) << 8) | ((key.charCodeAt(i + 2) & 0xff) << 16) | ((key.charCodeAt(i + 3) & 0xff) << 24);
|
|
39
|
+
k2 = ((key.charCodeAt(i + 4) & 0xff)) | ((key.charCodeAt(i + 5) & 0xff) << 8) | ((key.charCodeAt(i + 6) & 0xff) << 16) | ((key.charCodeAt(i + 7) & 0xff) << 24);
|
|
40
|
+
k3 = ((key.charCodeAt(i + 8) & 0xff)) | ((key.charCodeAt(i + 9) & 0xff) << 8) | ((key.charCodeAt(i + 10) & 0xff) << 16) | ((key.charCodeAt(i + 11) & 0xff) << 24);
|
|
41
|
+
k4 = ((key.charCodeAt(i + 12) & 0xff)) | ((key.charCodeAt(i + 13) & 0xff) << 8) | ((key.charCodeAt(i + 14) & 0xff) << 16) | ((key.charCodeAt(i + 15) & 0xff) << 24);
|
|
42
|
+
k1 = common_1.x86Multiply(k1, c1);
|
|
43
|
+
k1 = common_1.x86Rotl(k1, 15);
|
|
44
|
+
k1 = common_1.x86Multiply(k1, c2);
|
|
45
|
+
h1 ^= k1;
|
|
46
|
+
h1 = common_1.x86Rotl(h1, 19);
|
|
47
|
+
h1 += h2;
|
|
48
|
+
h1 = common_1.x86Multiply(h1, 5) + 0x561ccd1b;
|
|
49
|
+
k2 = common_1.x86Multiply(k2, c2);
|
|
50
|
+
k2 = common_1.x86Rotl(k2, 16);
|
|
51
|
+
k2 = common_1.x86Multiply(k2, c3);
|
|
52
|
+
h2 ^= k2;
|
|
53
|
+
h2 = common_1.x86Rotl(h2, 17);
|
|
54
|
+
h2 += h3;
|
|
55
|
+
h2 = common_1.x86Multiply(h2, 5) + 0x0bcaa747;
|
|
56
|
+
k3 = common_1.x86Multiply(k3, c3);
|
|
57
|
+
k3 = common_1.x86Rotl(k3, 17);
|
|
58
|
+
k3 = common_1.x86Multiply(k3, c4);
|
|
59
|
+
h3 ^= k3;
|
|
60
|
+
h3 = common_1.x86Rotl(h3, 15);
|
|
61
|
+
h3 += h4;
|
|
62
|
+
h3 = common_1.x86Multiply(h3, 5) + 0x96cd1c35;
|
|
63
|
+
k4 = common_1.x86Multiply(k4, c4);
|
|
64
|
+
k4 = common_1.x86Rotl(k4, 18);
|
|
65
|
+
k4 = common_1.x86Multiply(k4, c1);
|
|
66
|
+
h4 ^= k4;
|
|
67
|
+
h4 = common_1.x86Rotl(h4, 13);
|
|
68
|
+
h4 += h1;
|
|
69
|
+
h4 = common_1.x86Multiply(h4, 5) + 0x32ac3b17;
|
|
70
|
+
}
|
|
71
|
+
k1 = 0;
|
|
72
|
+
k2 = 0;
|
|
73
|
+
k3 = 0;
|
|
74
|
+
k4 = 0;
|
|
75
|
+
switch (remainder) {
|
|
76
|
+
case 15:
|
|
77
|
+
k4 ^= key.charCodeAt(i + 14) << 16;
|
|
78
|
+
case 14:
|
|
79
|
+
k4 ^= key.charCodeAt(i + 13) << 8;
|
|
80
|
+
case 13:
|
|
81
|
+
k4 ^= key.charCodeAt(i + 12);
|
|
82
|
+
k4 = common_1.x86Multiply(k4, c4);
|
|
83
|
+
k4 = common_1.x86Rotl(k4, 18);
|
|
84
|
+
k4 = common_1.x86Multiply(k4, c1);
|
|
85
|
+
h4 ^= k4;
|
|
86
|
+
case 12:
|
|
87
|
+
k3 ^= key.charCodeAt(i + 11) << 24;
|
|
88
|
+
case 11:
|
|
89
|
+
k3 ^= key.charCodeAt(i + 10) << 16;
|
|
90
|
+
case 10:
|
|
91
|
+
k3 ^= key.charCodeAt(i + 9) << 8;
|
|
92
|
+
case 9:
|
|
93
|
+
k3 ^= key.charCodeAt(i + 8);
|
|
94
|
+
k3 = common_1.x86Multiply(k3, c3);
|
|
95
|
+
k3 = common_1.x86Rotl(k3, 17);
|
|
96
|
+
k3 = common_1.x86Multiply(k3, c4);
|
|
97
|
+
h3 ^= k3;
|
|
98
|
+
case 8:
|
|
99
|
+
k2 ^= key.charCodeAt(i + 7) << 24;
|
|
100
|
+
case 7:
|
|
101
|
+
k2 ^= key.charCodeAt(i + 6) << 16;
|
|
102
|
+
case 6:
|
|
103
|
+
k2 ^= key.charCodeAt(i + 5) << 8;
|
|
104
|
+
case 5:
|
|
105
|
+
k2 ^= key.charCodeAt(i + 4);
|
|
106
|
+
k2 = common_1.x86Multiply(k2, c2);
|
|
107
|
+
k2 = common_1.x86Rotl(k2, 16);
|
|
108
|
+
k2 = common_1.x86Multiply(k2, c3);
|
|
109
|
+
h2 ^= k2;
|
|
110
|
+
case 4:
|
|
111
|
+
k1 ^= key.charCodeAt(i + 3) << 24;
|
|
112
|
+
case 3:
|
|
113
|
+
k1 ^= key.charCodeAt(i + 2) << 16;
|
|
114
|
+
case 2:
|
|
115
|
+
k1 ^= key.charCodeAt(i + 1) << 8;
|
|
116
|
+
case 1:
|
|
117
|
+
k1 ^= key.charCodeAt(i);
|
|
118
|
+
k1 = common_1.x86Multiply(k1, c1);
|
|
119
|
+
k1 = common_1.x86Rotl(k1, 15);
|
|
120
|
+
k1 = common_1.x86Multiply(k1, c2);
|
|
121
|
+
h1 ^= k1;
|
|
122
|
+
}
|
|
123
|
+
h1 ^= key.length;
|
|
124
|
+
h2 ^= key.length;
|
|
125
|
+
h3 ^= key.length;
|
|
126
|
+
h4 ^= key.length;
|
|
127
|
+
h1 += h2;
|
|
128
|
+
h1 += h3;
|
|
129
|
+
h1 += h4;
|
|
130
|
+
h2 += h1;
|
|
131
|
+
h3 += h1;
|
|
132
|
+
h4 += h1;
|
|
133
|
+
h1 = common_1.x86Fmix(h1);
|
|
134
|
+
h2 = common_1.x86Fmix(h2);
|
|
135
|
+
h3 = common_1.x86Fmix(h3);
|
|
136
|
+
h4 = common_1.x86Fmix(h4);
|
|
137
|
+
h1 += h2;
|
|
138
|
+
h1 += h3;
|
|
139
|
+
h1 += h4;
|
|
140
|
+
h2 += h1;
|
|
141
|
+
h3 += h1;
|
|
142
|
+
h4 += h1;
|
|
143
|
+
return ('00000000' + (h1 >>> 0).toString(16)).slice(-8) + ('00000000' + (h2 >>> 0).toString(16)).slice(-8) + ('00000000' + (h3 >>> 0).toString(16)).slice(-8) + ('00000000' + (h4 >>> 0).toString(16)).slice(-8);
|
|
144
|
+
}
|
|
145
|
+
/**
|
|
146
|
+
* x86 version of Murmur3 for 128bits.
|
|
147
|
+
* Used by hashImpression128 because in JS it is more efficient than the x64 version, no matter the underlying OS/CPU arch.
|
|
148
|
+
*
|
|
149
|
+
* @param {string} str
|
|
150
|
+
*/
|
|
151
|
+
function hash128(str, seed) {
|
|
152
|
+
return hash128x86(common_1.UTF16ToUTF8(str), seed >>> 0);
|
|
153
|
+
}
|
|
154
|
+
exports.hash128 = hash128;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.hash64 = void 0;
|
|
4
|
+
var murmur3_128_1 = require("./murmur3_128");
|
|
5
|
+
/**
|
|
6
|
+
* Use instead of parseInt, to not lose precision when converting big integers (greater than 2^53 - 1)
|
|
7
|
+
*/
|
|
8
|
+
function hex2dec(s) {
|
|
9
|
+
var i, j, digits = [0], carry;
|
|
10
|
+
for (i = 0; i < s.length; i += 1) {
|
|
11
|
+
carry = parseInt(s.charAt(i), 16);
|
|
12
|
+
for (j = digits.length - 1; j >= 0; j -= 1) {
|
|
13
|
+
digits[j] = digits[j] * 16 + carry;
|
|
14
|
+
carry = digits[j] / 10 | 0;
|
|
15
|
+
digits[j] %= 10;
|
|
16
|
+
}
|
|
17
|
+
while (carry > 0) {
|
|
18
|
+
digits.unshift(carry % 10);
|
|
19
|
+
carry = carry / 10 | 0;
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
return digits.join('');
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Gets the higher 64 bits of the x64 version of Murmur3 for 128bits, as decimal and hexadecimal number strings.
|
|
26
|
+
* Used for MySegments channel V2 notifications.
|
|
27
|
+
* @param {string} str
|
|
28
|
+
*/
|
|
29
|
+
function hash64(str) {
|
|
30
|
+
var hex = murmur3_128_1.hash128(str).slice(0, 16);
|
|
31
|
+
return {
|
|
32
|
+
hex: hex,
|
|
33
|
+
dec: hex2dec(hex) // KeyList notification
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
exports.hash64 = hash64;
|
|
@@ -8,114 +8,108 @@
|
|
|
8
8
|
see: https://github.com/dcodeIO/utfx for details
|
|
9
9
|
*/
|
|
10
10
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
11
|
-
exports.
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
if (
|
|
29
|
-
cp
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
break;
|
|
56
|
-
if (c1 >= 0xD800 && c1 <= 0xDFFF) {
|
|
57
|
-
if ((c2 = src()) !== null) {
|
|
58
|
-
if (c2 >= 0xDC00 && c2 <= 0xDFFF) {
|
|
59
|
-
dst((c1 - 0xD800) * 0x400 + c2 - 0xDC00 + 0x10000);
|
|
60
|
-
c2 = null;
|
|
61
|
-
continue;
|
|
62
|
-
}
|
|
11
|
+
exports.stringDestination = exports.stringSource = exports.encodeUTF16toUTF8 = void 0;
|
|
12
|
+
/**
|
|
13
|
+
* Encodes UTF8 code points to UTF8 bytes.
|
|
14
|
+
* @param {(!function():number|null) | number} src Code points source, either as a function returning the next code point
|
|
15
|
+
* respectively `null` if there are no more code points left or a single numeric code point.
|
|
16
|
+
* @param {!function(number)} dst Bytes destination as a function successively called with the next byte
|
|
17
|
+
* @expose
|
|
18
|
+
*/
|
|
19
|
+
function encodeUTF8(src, dst) {
|
|
20
|
+
var cp = null;
|
|
21
|
+
if (typeof src === 'number')
|
|
22
|
+
cp = src, src = function () { return null; };
|
|
23
|
+
while (cp !== null || (cp = src()) !== null) {
|
|
24
|
+
if (cp < 0x80)
|
|
25
|
+
dst(cp & 0x7F);
|
|
26
|
+
else if (cp < 0x800)
|
|
27
|
+
dst(((cp >> 6) & 0x1F) | 0xC0), dst((cp & 0x3F) | 0x80);
|
|
28
|
+
else if (cp < 0x10000)
|
|
29
|
+
dst(((cp >> 12) & 0x0F) | 0xE0), dst(((cp >> 6) & 0x3F) | 0x80), dst((cp & 0x3F) | 0x80);
|
|
30
|
+
else
|
|
31
|
+
dst(((cp >> 18) & 0x07) | 0xF0), dst(((cp >> 12) & 0x3F) | 0x80), dst(((cp >> 6) & 0x3F) | 0x80), dst((cp & 0x3F) | 0x80);
|
|
32
|
+
cp = null;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Converts UTF16 characters to UTF8 code points.
|
|
37
|
+
* @param {!function():number|null} src Characters source as a function returning the next char code respectively
|
|
38
|
+
* `null` if there are no more characters left.
|
|
39
|
+
* @param {!function(number)} dst Code points destination as a function successively called with each converted code
|
|
40
|
+
* point.
|
|
41
|
+
* @expose
|
|
42
|
+
*/
|
|
43
|
+
function UTF16toUTF8(src, dst) {
|
|
44
|
+
var c1, c2 = null;
|
|
45
|
+
// eslint-disable-next-line no-constant-condition
|
|
46
|
+
while (true) {
|
|
47
|
+
if ((c1 = c2 !== null ? c2 : src()) === null)
|
|
48
|
+
break;
|
|
49
|
+
if (c1 >= 0xD800 && c1 <= 0xDFFF) {
|
|
50
|
+
if ((c2 = src()) !== null) {
|
|
51
|
+
if (c2 >= 0xDC00 && c2 <= 0xDFFF) {
|
|
52
|
+
dst((c1 - 0xD800) * 0x400 + c2 - 0xDC00 + 0x10000);
|
|
53
|
+
c2 = null;
|
|
54
|
+
continue;
|
|
63
55
|
}
|
|
64
56
|
}
|
|
65
|
-
dst(c1);
|
|
66
57
|
}
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
58
|
+
dst(c1);
|
|
59
|
+
}
|
|
60
|
+
if (c2 !== null)
|
|
61
|
+
dst(c2);
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Converts and encodes UTF16 characters to UTF8 bytes.
|
|
65
|
+
* @param {!function():number|null} src Characters source as a function returning the next char code respectively `null`
|
|
66
|
+
* if there are no more characters left.
|
|
67
|
+
* @param {!function(number)} dst Bytes destination as a function successively called with the next byte.
|
|
68
|
+
* @expose
|
|
69
|
+
*/
|
|
70
|
+
function encodeUTF16toUTF8(src, dst) {
|
|
71
|
+
UTF16toUTF8(src, function (cp) {
|
|
72
|
+
encodeUTF8(cp, dst);
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
exports.encodeUTF16toUTF8 = encodeUTF16toUTF8;
|
|
76
|
+
/**
|
|
77
|
+
* String.fromCharCode reference for compile time renaming.
|
|
78
|
+
* @type {!function(...[number]):string}
|
|
79
|
+
* @inner
|
|
80
|
+
*/
|
|
81
|
+
var stringFromCharCode = String.fromCharCode;
|
|
82
|
+
/**
|
|
83
|
+
* Creates a source function for a string.
|
|
84
|
+
* @param {string} s String to read from
|
|
85
|
+
* @returns {!function():number|null} Source function returning the next char code respectively `null` if there are
|
|
86
|
+
* no more characters left.
|
|
87
|
+
* @throws {TypeError} If the argument is invalid
|
|
88
|
+
* @expose
|
|
89
|
+
*/
|
|
90
|
+
function stringSource(s) {
|
|
91
|
+
if (typeof s !== 'string')
|
|
92
|
+
throw TypeError('Illegal argument: ' + (typeof s));
|
|
93
|
+
var i = 0;
|
|
94
|
+
return function () {
|
|
95
|
+
return i >= s.length ? null : s.charCodeAt(i++);
|
|
103
96
|
};
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
97
|
+
}
|
|
98
|
+
exports.stringSource = stringSource;
|
|
99
|
+
/**
|
|
100
|
+
* Creates a destination function for a string.
|
|
101
|
+
* @returns {function(number=):undefined|string} Destination function successively called with the next char code.
|
|
102
|
+
* Returns the final string when called without arguments.
|
|
103
|
+
* @expose
|
|
104
|
+
*/
|
|
105
|
+
function stringDestination() {
|
|
106
|
+
var cs = [], ps = [];
|
|
107
|
+
return function () {
|
|
108
|
+
if (arguments.length === 0)
|
|
109
|
+
return ps.join('') + stringFromCharCode.apply(String, cs);
|
|
110
|
+
if (cs.length + arguments.length > 1024)
|
|
111
|
+
ps.push(stringFromCharCode.apply(String, cs)), cs.length = 0; // @ts-ignore
|
|
112
|
+
Array.prototype.push.apply(cs, arguments);
|
|
119
113
|
};
|
|
120
|
-
|
|
121
|
-
|
|
114
|
+
}
|
|
115
|
+
exports.stringDestination = stringDestination;
|
|
@@ -33,18 +33,21 @@ function promiseWrapper(customPromise, defaultOnRejected) {
|
|
|
33
33
|
});
|
|
34
34
|
});
|
|
35
35
|
var originalThen = newPromise.then;
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
36
|
+
// Using `defineProperty` in case Promise.prototype.then property is not writable
|
|
37
|
+
Object.defineProperty(newPromise, 'then', {
|
|
38
|
+
value: function (onfulfilled, onrejected) {
|
|
39
|
+
var result = originalThen.call(newPromise, onfulfilled, onrejected);
|
|
40
|
+
if (typeof onfulfilled === 'function')
|
|
41
|
+
hasOnFulfilled = true;
|
|
42
|
+
if (typeof onrejected === 'function') {
|
|
43
|
+
hasOnRejected = true;
|
|
44
|
+
return result;
|
|
45
|
+
}
|
|
46
|
+
else {
|
|
47
|
+
return chain(result);
|
|
48
|
+
}
|
|
46
49
|
}
|
|
47
|
-
};
|
|
50
|
+
});
|
|
48
51
|
return newPromise;
|
|
49
52
|
}
|
|
50
53
|
var result = chain(customPromise);
|
|
@@ -65,7 +65,8 @@ var base = {
|
|
|
65
65
|
sync: {
|
|
66
66
|
splitFilters: undefined,
|
|
67
67
|
// impressions collection mode
|
|
68
|
-
impressionsMode: constants_1.OPTIMIZED
|
|
68
|
+
impressionsMode: constants_1.OPTIMIZED,
|
|
69
|
+
localhostMode: undefined
|
|
69
70
|
},
|
|
70
71
|
runtime: {
|
|
71
72
|
ip: false,
|
|
@@ -85,7 +86,7 @@ function fromSecondsToMillis(n) {
|
|
|
85
86
|
* @param validationParams defaults and fields validators used to validate and creates a settings object from a given config
|
|
86
87
|
*/
|
|
87
88
|
function settingsValidation(config, validationParams) {
|
|
88
|
-
var defaults = validationParams.defaults, runtime = validationParams.runtime, storage = validationParams.storage, integrations = validationParams.integrations, logger = validationParams.logger;
|
|
89
|
+
var defaults = validationParams.defaults, runtime = validationParams.runtime, storage = validationParams.storage, integrations = validationParams.integrations, logger = validationParams.logger, localhost = validationParams.localhost;
|
|
89
90
|
// creates a settings object merging base, defaults and config objects.
|
|
90
91
|
var withDefaults = lang_1.merge({}, base, defaults, config);
|
|
91
92
|
// ensure a valid logger.
|
|
@@ -123,6 +124,8 @@ function settingsValidation(config, validationParams) {
|
|
|
123
124
|
// @ts-ignore, modify readonly prop
|
|
124
125
|
if (integrations)
|
|
125
126
|
withDefaults.integrations = integrations(withDefaults);
|
|
127
|
+
if (localhost)
|
|
128
|
+
withDefaults.sync.localhostMode = localhost(withDefaults);
|
|
126
129
|
// validate push options
|
|
127
130
|
if (withDefaults.streamingEnabled !== false) { // @ts-ignore, modify readonly prop
|
|
128
131
|
withDefaults.streamingEnabled = true;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.validateLocalhost = void 0;
|
|
4
|
+
var constants_1 = require("../../../logger/constants");
|
|
5
|
+
var constants_2 = require("../../constants");
|
|
6
|
+
/**
|
|
7
|
+
* This function validates `settings.storage` object
|
|
8
|
+
*
|
|
9
|
+
* @param {any} settings config object provided by the user to initialize the sdk
|
|
10
|
+
*
|
|
11
|
+
* @returns {Object} valid storage factory. It might be the default `InMemoryStorageCSFactory` if the provided storage is invalid.
|
|
12
|
+
*/
|
|
13
|
+
function validateLocalhost(settings) {
|
|
14
|
+
var localhostMode = settings.sync.localhostMode;
|
|
15
|
+
if (settings.mode === constants_2.LOCALHOST_MODE && (typeof localhostMode !== 'function' || localhostMode.type !== constants_2.LOCALHOST_MODE)) {
|
|
16
|
+
settings.log.error(constants_1.ERROR_LOCALHOST_MODULE_REQUIRED);
|
|
17
|
+
}
|
|
18
|
+
return localhostMode;
|
|
19
|
+
}
|
|
20
|
+
exports.validateLocalhost = validateLocalhost;
|