@statsig/client-core 0.0.1-beta.3 → 0.0.1-beta.31
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/README.md +1 -1
- package/package.json +1 -1
- package/src/$_StatsigGlobal.d.ts +8 -1
- package/src/$_StatsigGlobal.js +22 -12
- package/src/ClientInterfaces.d.ts +47 -14
- package/src/DataAdapterCore.d.ts +32 -0
- package/src/DataAdapterCore.js +167 -0
- package/src/Diagnostics.js +24 -26
- package/src/DownloadConfigSpecsResponse.d.ts +41 -0
- package/src/ErrorBoundary.d.ts +1 -0
- package/src/ErrorBoundary.js +41 -86
- package/src/EvaluationOptions.d.ts +20 -0
- package/src/EvaluationOptions.js +2 -0
- package/src/EvaluationTypes.d.ts +39 -0
- package/src/EvaluationTypes.js +2 -0
- package/src/EventLogger.d.ts +21 -8
- package/src/EventLogger.js +206 -228
- package/src/Hashing.d.ts +2 -1
- package/src/Hashing.js +25 -6
- package/src/InitializeResponse.d.ts +18 -0
- package/src/InitializeResponse.js +2 -0
- package/src/Log.js +15 -34
- package/src/Monitoring.d.ts +1 -2
- package/src/Monitoring.js +68 -27
- package/src/NetworkCore.d.ts +17 -6
- package/src/NetworkCore.js +128 -166
- package/src/NetworkDefaults.d.ts +5 -0
- package/src/NetworkDefaults.js +8 -0
- package/src/NetworkParams.d.ts +9 -0
- package/src/NetworkParams.js +13 -0
- package/src/OverrideAdapter.d.ts +9 -0
- package/src/OverrideAdapter.js +2 -0
- package/src/SDKType.d.ts +8 -0
- package/src/SDKType.js +19 -0
- package/src/SafeJs.d.ts +4 -0
- package/src/SafeJs.js +27 -0
- package/src/SessionID.d.ts +10 -1
- package/src/SessionID.js +86 -6
- package/src/StableID.js +24 -53
- package/src/StatsigClientBase.d.ts +57 -28
- package/src/StatsigClientBase.js +114 -238
- package/src/StatsigClientEventEmitter.d.ts +65 -28
- package/src/StatsigDataAdapter.d.ts +89 -0
- package/src/StatsigDataAdapter.js +4 -0
- package/src/StatsigEvent.d.ts +10 -19
- package/src/StatsigEvent.js +50 -41
- package/src/StatsigMetadata.d.ts +1 -1
- package/src/StatsigMetadata.js +7 -18
- package/src/StatsigOptionsCommon.d.ts +68 -17
- package/src/StatsigTypeFactories.d.ts +6 -0
- package/src/StatsigTypeFactories.js +50 -0
- package/src/StatsigTypes.d.ts +29 -18
- package/src/StatsigTypes.js +0 -29
- package/src/StatsigUser.d.ts +2 -5
- package/src/StatsigUser.js +10 -18
- package/src/StorageProvider.d.ts +12 -7
- package/src/StorageProvider.js +58 -67
- package/src/TypedJsonParse.d.ts +8 -0
- package/src/TypedJsonParse.js +27 -0
- package/src/UUID.js +9 -5
- package/src/UrlOverrides.d.ts +1 -0
- package/src/UrlOverrides.js +15 -0
- package/src/UtitlityTypes.d.ts +3 -0
- package/src/UtitlityTypes.js +2 -0
- package/src/VisibilityObserving.d.ts +8 -0
- package/src/VisibilityObserving.js +30 -0
- package/src/index.d.ts +21 -4
- package/src/index.js +31 -17
- package/src/StatsigDataProvider.d.ts +0 -9
- package/src/VisibilityChangeObserver.d.ts +0 -13
- package/src/VisibilityChangeObserver.js +0 -48
- package/src/__tests__/MockLocalStorage.d.ts +0 -9
- package/src/__tests__/MockLocalStorage.js +0 -37
- /package/src/{StatsigDataProvider.js → DownloadConfigSpecsResponse.js} +0 -0
package/src/StorageProvider.js
CHANGED
|
@@ -8,103 +8,94 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
8
8
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
9
|
});
|
|
10
10
|
};
|
|
11
|
-
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
12
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
13
|
-
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
14
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
15
|
-
function step(op) {
|
|
16
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
17
|
-
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
18
|
-
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
19
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
20
|
-
switch (op[0]) {
|
|
21
|
-
case 0: case 1: t = op; break;
|
|
22
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
23
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
24
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
25
|
-
default:
|
|
26
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
27
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
28
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
29
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
30
|
-
if (t[2]) _.ops.pop();
|
|
31
|
-
_.trys.pop(); continue;
|
|
32
|
-
}
|
|
33
|
-
op = body.call(thisArg, _);
|
|
34
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
35
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
36
|
-
}
|
|
37
|
-
};
|
|
38
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
-
exports.
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
12
|
+
exports._setObjectInStorage = exports._getObjectFromStorage = exports.Storage = void 0;
|
|
13
|
+
const Log_1 = require("./Log");
|
|
14
|
+
const inMemoryStore = {};
|
|
15
|
+
const _inMemoryProvider = {
|
|
16
|
+
_getProviderName: () => 'InMemory',
|
|
17
|
+
_getItemSync(key) {
|
|
18
|
+
var _a;
|
|
19
|
+
return (_a = inMemoryStore[key]) !== null && _a !== void 0 ? _a : null;
|
|
20
|
+
},
|
|
21
|
+
_getItem(key) {
|
|
44
22
|
var _a;
|
|
45
23
|
return Promise.resolve((_a = inMemoryStore[key]) !== null && _a !== void 0 ? _a : null);
|
|
46
24
|
},
|
|
47
|
-
|
|
25
|
+
_setItem(key, value) {
|
|
48
26
|
inMemoryStore[key] = value;
|
|
49
27
|
return Promise.resolve();
|
|
50
28
|
},
|
|
51
|
-
|
|
29
|
+
_removeItem(key) {
|
|
52
30
|
delete inMemoryStore[key];
|
|
53
31
|
return Promise.resolve();
|
|
54
32
|
},
|
|
33
|
+
_getAllKeys() {
|
|
34
|
+
return Promise.resolve(Object.keys(inMemoryStore));
|
|
35
|
+
},
|
|
55
36
|
};
|
|
37
|
+
let _localStorageProvider = null;
|
|
56
38
|
try {
|
|
57
39
|
if (typeof window !== 'undefined' && 'localStorage' in window) {
|
|
58
|
-
|
|
59
|
-
|
|
40
|
+
_localStorageProvider = {
|
|
41
|
+
_getProviderName: () => 'LocalStorage',
|
|
42
|
+
_getItemSync(key) {
|
|
43
|
+
return localStorage.getItem(key);
|
|
44
|
+
},
|
|
45
|
+
_getItem(key) {
|
|
60
46
|
return Promise.resolve(localStorage.getItem(key));
|
|
61
47
|
},
|
|
62
|
-
|
|
48
|
+
_setItem(key, value) {
|
|
63
49
|
localStorage.setItem(key, value);
|
|
64
50
|
return Promise.resolve();
|
|
65
51
|
},
|
|
66
|
-
|
|
52
|
+
_removeItem(key) {
|
|
67
53
|
localStorage.removeItem(key);
|
|
68
54
|
return Promise.resolve();
|
|
69
55
|
},
|
|
56
|
+
_getAllKeys() {
|
|
57
|
+
const keys = Object.keys(localStorage);
|
|
58
|
+
return Promise.resolve(keys);
|
|
59
|
+
},
|
|
70
60
|
};
|
|
71
61
|
}
|
|
72
62
|
}
|
|
73
63
|
catch (error) {
|
|
74
|
-
Log_1.Log.warn('Failed to
|
|
64
|
+
Log_1.Log.warn('Failed to setup localStorageProvider.');
|
|
75
65
|
}
|
|
66
|
+
let _main = _localStorageProvider !== null && _localStorageProvider !== void 0 ? _localStorageProvider : _inMemoryProvider;
|
|
67
|
+
let _current = _main;
|
|
76
68
|
exports.Storage = {
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
69
|
+
_getProviderName: () => _current._getProviderName(),
|
|
70
|
+
_getItem: (key) => _current._getItem(key),
|
|
71
|
+
_setItem: (key, value) => _current._setItem(key, value),
|
|
72
|
+
_removeItem: (key) => _current._removeItem(key),
|
|
73
|
+
_getAllKeys: () => _current._getAllKeys(),
|
|
74
|
+
_getItemSync: (key) => { var _a, _b; return (_b = (_a = _current._getItemSync) === null || _a === void 0 ? void 0 : _a.call(_current, key)) !== null && _b !== void 0 ? _b : null; },
|
|
75
|
+
// StorageProviderManagment
|
|
76
|
+
_setProvider: (newProvider) => {
|
|
77
|
+
_main = newProvider;
|
|
78
|
+
_current = newProvider;
|
|
79
|
+
},
|
|
80
|
+
_setDisabled: (isDisabled) => {
|
|
81
|
+
if (isDisabled) {
|
|
82
|
+
_current = _inMemoryProvider;
|
|
83
|
+
}
|
|
84
|
+
else {
|
|
85
|
+
_current = _main;
|
|
86
|
+
}
|
|
82
87
|
},
|
|
83
88
|
};
|
|
84
|
-
function
|
|
85
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
86
|
-
|
|
87
|
-
return
|
|
88
|
-
switch (_a.label) {
|
|
89
|
-
case 0: return [4 /*yield*/, provider.getItem(key)];
|
|
90
|
-
case 1:
|
|
91
|
-
value = _a.sent();
|
|
92
|
-
return [2 /*return*/, JSON.parse(value !== null && value !== void 0 ? value : 'null')];
|
|
93
|
-
}
|
|
94
|
-
});
|
|
89
|
+
function _getObjectFromStorage(key) {
|
|
90
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
91
|
+
const value = yield _current._getItem(key);
|
|
92
|
+
return JSON.parse(value !== null && value !== void 0 ? value : 'null');
|
|
95
93
|
});
|
|
96
94
|
}
|
|
97
|
-
exports.
|
|
98
|
-
function
|
|
99
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
100
|
-
|
|
101
|
-
switch (_a.label) {
|
|
102
|
-
case 0: return [4 /*yield*/, provider.setItem(key, JSON.stringify(obj))];
|
|
103
|
-
case 1:
|
|
104
|
-
_a.sent();
|
|
105
|
-
return [2 /*return*/];
|
|
106
|
-
}
|
|
107
|
-
});
|
|
95
|
+
exports._getObjectFromStorage = _getObjectFromStorage;
|
|
96
|
+
function _setObjectInStorage(key, obj) {
|
|
97
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
98
|
+
yield _current._setItem(key, JSON.stringify(obj));
|
|
108
99
|
});
|
|
109
100
|
}
|
|
110
|
-
exports.
|
|
101
|
+
exports._setObjectInStorage = _setObjectInStorage;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
*
|
|
3
|
+
* @param {string} data The values to parse into T
|
|
4
|
+
* @param {string} guard A field that must exists on the parsed object for the parse to be valid
|
|
5
|
+
* @param {string} error An error to print via Log.error() when parsing fails
|
|
6
|
+
* @returns {T | null} The parse object T or null if it failed
|
|
7
|
+
*/
|
|
8
|
+
export declare function typedJsonParse<T>(data: string, guard: string, error: string): T | null;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.typedJsonParse = void 0;
|
|
4
|
+
const Log_1 = require("./Log");
|
|
5
|
+
/**
|
|
6
|
+
*
|
|
7
|
+
* @param {string} data The values to parse into T
|
|
8
|
+
* @param {string} guard A field that must exists on the parsed object for the parse to be valid
|
|
9
|
+
* @param {string} error An error to print via Log.error() when parsing fails
|
|
10
|
+
* @returns {T | null} The parse object T or null if it failed
|
|
11
|
+
*/
|
|
12
|
+
function typedJsonParse(data, guard, error) {
|
|
13
|
+
try {
|
|
14
|
+
const result = JSON.parse(data);
|
|
15
|
+
if (typeof result === 'object' &&
|
|
16
|
+
guard in result) {
|
|
17
|
+
return result;
|
|
18
|
+
}
|
|
19
|
+
return result;
|
|
20
|
+
}
|
|
21
|
+
catch (_a) {
|
|
22
|
+
// noop
|
|
23
|
+
}
|
|
24
|
+
Log_1.Log.error(error);
|
|
25
|
+
return null;
|
|
26
|
+
}
|
|
27
|
+
exports.typedJsonParse = typedJsonParse;
|
package/src/UUID.js
CHANGED
|
@@ -2,14 +2,18 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.getUUID = void 0;
|
|
4
4
|
function getUUID() {
|
|
5
|
-
|
|
6
|
-
|
|
5
|
+
if (typeof crypto !== 'undefined' &&
|
|
6
|
+
typeof crypto.randomUUID === 'function') {
|
|
7
|
+
return crypto.randomUUID();
|
|
8
|
+
}
|
|
9
|
+
let d = new Date().getTime();
|
|
10
|
+
let d2 = (typeof performance !== 'undefined' &&
|
|
7
11
|
performance.now &&
|
|
8
12
|
performance.now() * 1000) ||
|
|
9
13
|
0;
|
|
10
|
-
|
|
11
|
-
return
|
|
12
|
-
|
|
14
|
+
const y = '89ab'[Math.floor(Math.random() * 4)];
|
|
15
|
+
return `xxxxxxxx-xxxx-4xxx-${y}xxx-xxxxxxxxxxxx`.replace(/[xy]/g, (c) => {
|
|
16
|
+
let r = Math.random() * 16;
|
|
13
17
|
if (d > 0) {
|
|
14
18
|
r = (d + r) % 16 | 0;
|
|
15
19
|
d = Math.floor(d / 16);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function _getOverridableUrl(overrideUrl: string | undefined, overrideApi: string | undefined, defaultEndpoint: string, defaultApi: string): string;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports._getOverridableUrl = void 0;
|
|
4
|
+
function _getOverridableUrl(overrideUrl, overrideApi, defaultEndpoint, defaultApi) {
|
|
5
|
+
if (overrideUrl) {
|
|
6
|
+
return overrideUrl;
|
|
7
|
+
}
|
|
8
|
+
else if (overrideApi) {
|
|
9
|
+
return `${overrideApi}${defaultEndpoint}`;
|
|
10
|
+
}
|
|
11
|
+
else {
|
|
12
|
+
return `${defaultApi}${defaultEndpoint}`;
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
exports._getOverridableUrl = _getOverridableUrl;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
declare const FOREGROUND = "foreground";
|
|
2
|
+
declare const BACKGROUND = "background";
|
|
3
|
+
export type Visibility = typeof FOREGROUND | typeof BACKGROUND;
|
|
4
|
+
type VisibilityChangedCallback = (visibility: Visibility) => void;
|
|
5
|
+
export declare const _isCurrentlyVisible: () => boolean;
|
|
6
|
+
export declare const _subscribeToVisiblityChanged: (listener: VisibilityChangedCallback) => void;
|
|
7
|
+
export declare const _notifyVisibilityChanged: (visibility: Visibility) => void;
|
|
8
|
+
export {};
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports._notifyVisibilityChanged = exports._subscribeToVisiblityChanged = exports._isCurrentlyVisible = void 0;
|
|
4
|
+
const SafeJs_1 = require("./SafeJs");
|
|
5
|
+
const FOREGROUND = 'foreground';
|
|
6
|
+
const BACKGROUND = 'background';
|
|
7
|
+
const LISTENERS = [];
|
|
8
|
+
let current = FOREGROUND;
|
|
9
|
+
const _isCurrentlyVisible = () => {
|
|
10
|
+
return current === FOREGROUND;
|
|
11
|
+
};
|
|
12
|
+
exports._isCurrentlyVisible = _isCurrentlyVisible;
|
|
13
|
+
const _subscribeToVisiblityChanged = (listener) => {
|
|
14
|
+
LISTENERS.unshift(listener);
|
|
15
|
+
};
|
|
16
|
+
exports._subscribeToVisiblityChanged = _subscribeToVisiblityChanged;
|
|
17
|
+
const _notifyVisibilityChanged = (visibility) => {
|
|
18
|
+
if (visibility === current) {
|
|
19
|
+
return;
|
|
20
|
+
}
|
|
21
|
+
current = visibility;
|
|
22
|
+
LISTENERS.forEach((l) => l(visibility));
|
|
23
|
+
};
|
|
24
|
+
exports._notifyVisibilityChanged = _notifyVisibilityChanged;
|
|
25
|
+
(0, SafeJs_1._addWindowEventListenerSafe)('focus', () => (0, exports._notifyVisibilityChanged)(FOREGROUND));
|
|
26
|
+
(0, SafeJs_1._addWindowEventListenerSafe)('blur', () => (0, exports._notifyVisibilityChanged)(BACKGROUND));
|
|
27
|
+
(0, SafeJs_1._addWindowEventListenerSafe)('beforeunload', () => (0, exports._notifyVisibilityChanged)(BACKGROUND));
|
|
28
|
+
(0, SafeJs_1._addDocumentEventListenerSafe)('visibilitychange', () => {
|
|
29
|
+
(0, exports._notifyVisibilityChanged)(document.visibilityState === 'visible' ? FOREGROUND : BACKGROUND);
|
|
30
|
+
});
|
package/src/index.d.ts
CHANGED
|
@@ -1,23 +1,40 @@
|
|
|
1
1
|
/** Statsig Global should go first */
|
|
2
2
|
import './$_StatsigGlobal';
|
|
3
3
|
import { EventLogger } from './EventLogger';
|
|
4
|
+
import { Log } from './Log';
|
|
5
|
+
import { Storage } from './StorageProvider';
|
|
4
6
|
export * from './$_StatsigGlobal';
|
|
5
7
|
export * from './ClientInterfaces';
|
|
8
|
+
export * from './DataAdapterCore';
|
|
9
|
+
export * from './DownloadConfigSpecsResponse';
|
|
6
10
|
export * from './ErrorBoundary';
|
|
11
|
+
export * from './EvaluationOptions';
|
|
12
|
+
export * from './EvaluationTypes';
|
|
7
13
|
export * from './Hashing';
|
|
8
|
-
export * from './
|
|
14
|
+
export * from './InitializeResponse';
|
|
9
15
|
export * from './Log';
|
|
10
16
|
export * from './Monitoring';
|
|
17
|
+
export * from './NetworkParams';
|
|
11
18
|
export * from './NetworkCore';
|
|
19
|
+
export * from './NetworkDefaults';
|
|
20
|
+
export * from './OverrideAdapter';
|
|
21
|
+
export * from './SafeJs';
|
|
22
|
+
export * from './SDKType';
|
|
23
|
+
export * from './SessionID';
|
|
12
24
|
export * from './StableID';
|
|
13
25
|
export * from './StatsigClientBase';
|
|
14
26
|
export * from './StatsigClientEventEmitter';
|
|
15
|
-
export * from './
|
|
27
|
+
export * from './StatsigDataAdapter';
|
|
16
28
|
export * from './StatsigEvent';
|
|
17
29
|
export * from './StatsigMetadata';
|
|
18
30
|
export * from './StatsigOptionsCommon';
|
|
31
|
+
export * from './StatsigTypeFactories';
|
|
19
32
|
export * from './StatsigTypes';
|
|
20
33
|
export * from './StatsigUser';
|
|
34
|
+
export * from './StorageProvider';
|
|
35
|
+
export * from './TypedJsonParse';
|
|
36
|
+
export * from './UrlOverrides';
|
|
37
|
+
export * from './UtitlityTypes';
|
|
21
38
|
export * from './UUID';
|
|
22
|
-
export * from './
|
|
23
|
-
export { EventLogger };
|
|
39
|
+
export * from './VisibilityObserving';
|
|
40
|
+
export { EventLogger, Storage, Log };
|
package/src/index.js
CHANGED
|
@@ -1,15 +1,4 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __assign = (this && this.__assign) || function () {
|
|
3
|
-
__assign = Object.assign || function(t) {
|
|
4
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
5
|
-
s = arguments[i];
|
|
6
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
7
|
-
t[p] = s[p];
|
|
8
|
-
}
|
|
9
|
-
return t;
|
|
10
|
-
};
|
|
11
|
-
return __assign.apply(this, arguments);
|
|
12
|
-
};
|
|
13
2
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
14
3
|
if (k2 === undefined) k2 = k;
|
|
15
4
|
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
@@ -25,28 +14,53 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
25
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
26
15
|
};
|
|
27
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
28
|
-
exports.EventLogger = void 0;
|
|
17
|
+
exports.Log = exports.Storage = exports.EventLogger = void 0;
|
|
29
18
|
/** Statsig Global should go first */
|
|
30
19
|
require("./$_StatsigGlobal");
|
|
31
|
-
|
|
20
|
+
const EventLogger_1 = require("./EventLogger");
|
|
32
21
|
Object.defineProperty(exports, "EventLogger", { enumerable: true, get: function () { return EventLogger_1.EventLogger; } });
|
|
22
|
+
const Log_1 = require("./Log");
|
|
23
|
+
Object.defineProperty(exports, "Log", { enumerable: true, get: function () { return Log_1.Log; } });
|
|
24
|
+
const StatsigMetadata_1 = require("./StatsigMetadata");
|
|
25
|
+
const StorageProvider_1 = require("./StorageProvider");
|
|
26
|
+
Object.defineProperty(exports, "Storage", { enumerable: true, get: function () { return StorageProvider_1.Storage; } });
|
|
27
|
+
const UUID_1 = require("./UUID");
|
|
33
28
|
__exportStar(require("./$_StatsigGlobal"), exports);
|
|
34
29
|
__exportStar(require("./ClientInterfaces"), exports);
|
|
30
|
+
__exportStar(require("./DataAdapterCore"), exports);
|
|
31
|
+
__exportStar(require("./DownloadConfigSpecsResponse"), exports);
|
|
35
32
|
__exportStar(require("./ErrorBoundary"), exports);
|
|
33
|
+
__exportStar(require("./EvaluationOptions"), exports);
|
|
34
|
+
__exportStar(require("./EvaluationTypes"), exports);
|
|
36
35
|
__exportStar(require("./Hashing"), exports);
|
|
37
|
-
__exportStar(require("./
|
|
36
|
+
__exportStar(require("./InitializeResponse"), exports);
|
|
38
37
|
__exportStar(require("./Log"), exports);
|
|
39
38
|
__exportStar(require("./Monitoring"), exports);
|
|
39
|
+
__exportStar(require("./NetworkParams"), exports);
|
|
40
40
|
__exportStar(require("./NetworkCore"), exports);
|
|
41
|
+
__exportStar(require("./NetworkDefaults"), exports);
|
|
42
|
+
__exportStar(require("./OverrideAdapter"), exports);
|
|
43
|
+
__exportStar(require("./SafeJs"), exports);
|
|
44
|
+
__exportStar(require("./SDKType"), exports);
|
|
45
|
+
__exportStar(require("./SessionID"), exports);
|
|
41
46
|
__exportStar(require("./StableID"), exports);
|
|
42
47
|
__exportStar(require("./StatsigClientBase"), exports);
|
|
43
48
|
__exportStar(require("./StatsigClientEventEmitter"), exports);
|
|
44
|
-
__exportStar(require("./
|
|
49
|
+
__exportStar(require("./StatsigDataAdapter"), exports);
|
|
45
50
|
__exportStar(require("./StatsigEvent"), exports);
|
|
46
51
|
__exportStar(require("./StatsigMetadata"), exports);
|
|
47
52
|
__exportStar(require("./StatsigOptionsCommon"), exports);
|
|
53
|
+
__exportStar(require("./StatsigTypeFactories"), exports);
|
|
48
54
|
__exportStar(require("./StatsigTypes"), exports);
|
|
49
55
|
__exportStar(require("./StatsigUser"), exports);
|
|
56
|
+
__exportStar(require("./StorageProvider"), exports);
|
|
57
|
+
__exportStar(require("./TypedJsonParse"), exports);
|
|
58
|
+
__exportStar(require("./UrlOverrides"), exports);
|
|
59
|
+
__exportStar(require("./UtitlityTypes"), exports);
|
|
50
60
|
__exportStar(require("./UUID"), exports);
|
|
51
|
-
__exportStar(require("./
|
|
52
|
-
__STATSIG__ =
|
|
61
|
+
__exportStar(require("./VisibilityObserving"), exports);
|
|
62
|
+
__STATSIG__ = Object.assign(Object.assign({}, (__STATSIG__ !== null && __STATSIG__ !== void 0 ? __STATSIG__ : {})), { EventLogger: EventLogger_1.EventLogger,
|
|
63
|
+
Log: Log_1.Log,
|
|
64
|
+
getUUID: UUID_1.getUUID,
|
|
65
|
+
Storage: StorageProvider_1.Storage,
|
|
66
|
+
SDK_VERSION: StatsigMetadata_1.SDK_VERSION });
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { StatsigUser } from './StatsigUser';
|
|
2
|
-
export type DataSource = 'Uninitialized' | 'Loading' | 'NoValues' | 'Cache' | 'Network' | 'Bootstrap' | 'Prefetch';
|
|
3
|
-
export type StatsigDataProvider = {
|
|
4
|
-
readonly getData?: (sdkKey: string, user?: StatsigUser) => string | null;
|
|
5
|
-
readonly getDataAsync?: (sdkKey: string, user?: StatsigUser) => Promise<string | null>;
|
|
6
|
-
readonly getDataPostInit?: (sdkKey: string, currentData: string | null, user?: StatsigUser) => Promise<string | null>;
|
|
7
|
-
readonly setDataPostInit?: (sdkKey: string, data: string, user?: StatsigUser) => Promise<void>;
|
|
8
|
-
readonly source: DataSource;
|
|
9
|
-
};
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
export type Visibility = 'foreground' | 'background';
|
|
2
|
-
type VisibilityChangeListener = {
|
|
3
|
-
onVisibilityChanged: (visibility: Visibility) => void;
|
|
4
|
-
};
|
|
5
|
-
export declare class VisibilityChangeObserver {
|
|
6
|
-
private static _listeners;
|
|
7
|
-
private static _current;
|
|
8
|
-
static isCurrentlyVisible(): boolean;
|
|
9
|
-
static add(listener: VisibilityChangeListener): void;
|
|
10
|
-
static remove(listener: VisibilityChangeListener): void;
|
|
11
|
-
static notify(visibility: Visibility): void;
|
|
12
|
-
}
|
|
13
|
-
export {};
|
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.VisibilityChangeObserver = void 0;
|
|
4
|
-
var VisibilityChangeObserver = /** @class */ (function () {
|
|
5
|
-
function VisibilityChangeObserver() {
|
|
6
|
-
}
|
|
7
|
-
VisibilityChangeObserver.isCurrentlyVisible = function () {
|
|
8
|
-
return this._current === 'foreground';
|
|
9
|
-
};
|
|
10
|
-
VisibilityChangeObserver.add = function (listener) {
|
|
11
|
-
this._listeners.push(listener);
|
|
12
|
-
};
|
|
13
|
-
VisibilityChangeObserver.remove = function (listener) {
|
|
14
|
-
var index = this._listeners.indexOf(listener);
|
|
15
|
-
if (index !== -1) {
|
|
16
|
-
this._listeners.splice(index, 1);
|
|
17
|
-
}
|
|
18
|
-
};
|
|
19
|
-
VisibilityChangeObserver.notify = function (visibility) {
|
|
20
|
-
if (visibility === this._current) {
|
|
21
|
-
return;
|
|
22
|
-
}
|
|
23
|
-
this._current = visibility;
|
|
24
|
-
this._listeners.forEach(function (l) { return l.onVisibilityChanged(visibility); });
|
|
25
|
-
};
|
|
26
|
-
VisibilityChangeObserver._listeners = [];
|
|
27
|
-
VisibilityChangeObserver._current = 'foreground';
|
|
28
|
-
return VisibilityChangeObserver;
|
|
29
|
-
}());
|
|
30
|
-
exports.VisibilityChangeObserver = VisibilityChangeObserver;
|
|
31
|
-
if (typeof window !== 'undefined' &&
|
|
32
|
-
typeof window.addEventListener === 'function') {
|
|
33
|
-
window.addEventListener('focus', function () {
|
|
34
|
-
return VisibilityChangeObserver.notify('foreground');
|
|
35
|
-
});
|
|
36
|
-
window.addEventListener('blur', function () {
|
|
37
|
-
return VisibilityChangeObserver.notify('background');
|
|
38
|
-
});
|
|
39
|
-
window.addEventListener('beforeunload', function () {
|
|
40
|
-
return VisibilityChangeObserver.notify('background');
|
|
41
|
-
});
|
|
42
|
-
}
|
|
43
|
-
if (typeof document !== 'undefined' &&
|
|
44
|
-
typeof document.addEventListener === 'function') {
|
|
45
|
-
document.addEventListener('visibilitychange', function () {
|
|
46
|
-
VisibilityChangeObserver.notify(document.visibilityState === 'visible' ? 'foreground' : 'background');
|
|
47
|
-
});
|
|
48
|
-
}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
export declare class MockLocalStorage {
|
|
2
|
-
data: Record<string, string>;
|
|
3
|
-
static enabledMockStorage(): MockLocalStorage;
|
|
4
|
-
static disableMockStorage(): void;
|
|
5
|
-
clear(): void;
|
|
6
|
-
getItem(key: string): string | null;
|
|
7
|
-
setItem(key: string, value: string): void;
|
|
8
|
-
removeItem(key: string): void;
|
|
9
|
-
}
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.MockLocalStorage = void 0;
|
|
4
|
-
var actualLocalStorage = window.localStorage;
|
|
5
|
-
// todo: move to test-helpers (break circular dep)
|
|
6
|
-
var MockLocalStorage = /** @class */ (function () {
|
|
7
|
-
function MockLocalStorage() {
|
|
8
|
-
this.data = {};
|
|
9
|
-
}
|
|
10
|
-
MockLocalStorage.enabledMockStorage = function () {
|
|
11
|
-
var value = new MockLocalStorage();
|
|
12
|
-
Object.defineProperty(window, 'localStorage', {
|
|
13
|
-
value: value,
|
|
14
|
-
});
|
|
15
|
-
return value;
|
|
16
|
-
};
|
|
17
|
-
MockLocalStorage.disableMockStorage = function () {
|
|
18
|
-
Object.defineProperty(window, 'localStorage', {
|
|
19
|
-
value: actualLocalStorage,
|
|
20
|
-
});
|
|
21
|
-
};
|
|
22
|
-
// LocalStorage Functions
|
|
23
|
-
MockLocalStorage.prototype.clear = function () {
|
|
24
|
-
this.data = {};
|
|
25
|
-
};
|
|
26
|
-
MockLocalStorage.prototype.getItem = function (key) {
|
|
27
|
-
return this.data[key] ? this.data[key] : null;
|
|
28
|
-
};
|
|
29
|
-
MockLocalStorage.prototype.setItem = function (key, value) {
|
|
30
|
-
this.data[key] = String(value);
|
|
31
|
-
};
|
|
32
|
-
MockLocalStorage.prototype.removeItem = function (key) {
|
|
33
|
-
delete this.data[key];
|
|
34
|
-
};
|
|
35
|
-
return MockLocalStorage;
|
|
36
|
-
}());
|
|
37
|
-
exports.MockLocalStorage = MockLocalStorage;
|
|
File without changes
|