@xyd-js/host 0.0.0-build
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/CHANGELOG.md +24 -0
- package/LICENSE +21 -0
- package/app/debug-null.tsx +3 -0
- package/app/docPaths.ts +69 -0
- package/app/entry.client.tsx +58 -0
- package/app/entry.server.tsx +68 -0
- package/app/pathRoutes.ts +86 -0
- package/app/public.ts +43 -0
- package/app/raw.ts +31 -0
- package/app/robots.ts +18 -0
- package/app/root.tsx +579 -0
- package/app/routes.ts +35 -0
- package/app/scripts/abtesting.ts +279 -0
- package/app/scripts/bannerHeight.ts +14 -0
- package/app/scripts/colorSchemeScript.ts +21 -0
- package/app/scripts/growthbook.js +3574 -0
- package/app/scripts/launchdarkly.js +2 -0
- package/app/scripts/openfeature.growthbook.js +692 -0
- package/app/scripts/openfeature.js +1715 -0
- package/app/scripts/openfeature.launchdarkly.js +877 -0
- package/app/scripts/testFeatureFlag.ts +39 -0
- package/app/sitemap.ts +40 -0
- package/app/types/raw.d.ts +4 -0
- package/auto-imports.d.ts +10 -0
- package/package.json +41 -0
- package/plugins/README.md +1 -0
- package/postcss.config.cjs +5 -0
- package/react-router.config.ts +94 -0
- package/src/auto-imports.d.ts +29 -0
- package/tsconfig.json +28 -0
- package/types.d.ts +8 -0
- package/vite.config.ts +8 -0
|
@@ -0,0 +1,877 @@
|
|
|
1
|
+
var LaunchDarklyProvider = (function (exports, webSdk, launchdarklyJsClientSdk) {
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
|
|
5
|
+
|
|
6
|
+
function getDefaultExportFromCjs (x) {
|
|
7
|
+
return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
var lodash_isempty = {exports: {}};
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* lodash (Custom Build) <https://lodash.com/>
|
|
14
|
+
* Build: `lodash modularize exports="npm" -o ./`
|
|
15
|
+
* Copyright jQuery Foundation and other contributors <https://jquery.org/>
|
|
16
|
+
* Released under MIT license <https://lodash.com/license>
|
|
17
|
+
* Based on Underscore.js 1.8.3 <http://underscorejs.org/LICENSE>
|
|
18
|
+
* Copyright Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
|
|
19
|
+
*/
|
|
20
|
+
lodash_isempty.exports;
|
|
21
|
+
|
|
22
|
+
var hasRequiredLodash_isempty;
|
|
23
|
+
|
|
24
|
+
function requireLodash_isempty () {
|
|
25
|
+
if (hasRequiredLodash_isempty) return lodash_isempty.exports;
|
|
26
|
+
hasRequiredLodash_isempty = 1;
|
|
27
|
+
(function (module, exports) {
|
|
28
|
+
/** Used as references for various `Number` constants. */
|
|
29
|
+
var MAX_SAFE_INTEGER = 9007199254740991;
|
|
30
|
+
|
|
31
|
+
/** `Object#toString` result references. */
|
|
32
|
+
var argsTag = '[object Arguments]',
|
|
33
|
+
funcTag = '[object Function]',
|
|
34
|
+
genTag = '[object GeneratorFunction]',
|
|
35
|
+
mapTag = '[object Map]',
|
|
36
|
+
objectTag = '[object Object]',
|
|
37
|
+
promiseTag = '[object Promise]',
|
|
38
|
+
setTag = '[object Set]',
|
|
39
|
+
weakMapTag = '[object WeakMap]';
|
|
40
|
+
|
|
41
|
+
var dataViewTag = '[object DataView]';
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* Used to match `RegExp`
|
|
45
|
+
* [syntax characters](http://ecma-international.org/ecma-262/7.0/#sec-patterns).
|
|
46
|
+
*/
|
|
47
|
+
var reRegExpChar = /[\\^$.*+?()[\]{}|]/g;
|
|
48
|
+
|
|
49
|
+
/** Used to detect host constructors (Safari). */
|
|
50
|
+
var reIsHostCtor = /^\[object .+?Constructor\]$/;
|
|
51
|
+
|
|
52
|
+
/** Detect free variable `global` from Node.js. */
|
|
53
|
+
var freeGlobal = typeof commonjsGlobal == 'object' && commonjsGlobal && commonjsGlobal.Object === Object && commonjsGlobal;
|
|
54
|
+
|
|
55
|
+
/** Detect free variable `self`. */
|
|
56
|
+
var freeSelf = typeof self == 'object' && self && self.Object === Object && self;
|
|
57
|
+
|
|
58
|
+
/** Used as a reference to the global object. */
|
|
59
|
+
var root = freeGlobal || freeSelf || Function('return this')();
|
|
60
|
+
|
|
61
|
+
/** Detect free variable `exports`. */
|
|
62
|
+
var freeExports = exports && !exports.nodeType && exports;
|
|
63
|
+
|
|
64
|
+
/** Detect free variable `module`. */
|
|
65
|
+
var freeModule = freeExports && 'object' == 'object' && module && !module.nodeType && module;
|
|
66
|
+
|
|
67
|
+
/** Detect the popular CommonJS extension `module.exports`. */
|
|
68
|
+
var moduleExports = freeModule && freeModule.exports === freeExports;
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* Gets the value at `key` of `object`.
|
|
72
|
+
*
|
|
73
|
+
* @private
|
|
74
|
+
* @param {Object} [object] The object to query.
|
|
75
|
+
* @param {string} key The key of the property to get.
|
|
76
|
+
* @returns {*} Returns the property value.
|
|
77
|
+
*/
|
|
78
|
+
function getValue(object, key) {
|
|
79
|
+
return object == null ? undefined : object[key];
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
* Checks if `value` is a host object in IE < 9.
|
|
84
|
+
*
|
|
85
|
+
* @private
|
|
86
|
+
* @param {*} value The value to check.
|
|
87
|
+
* @returns {boolean} Returns `true` if `value` is a host object, else `false`.
|
|
88
|
+
*/
|
|
89
|
+
function isHostObject(value) {
|
|
90
|
+
// Many host objects are `Object` objects that can coerce to strings
|
|
91
|
+
// despite having improperly defined `toString` methods.
|
|
92
|
+
var result = false;
|
|
93
|
+
if (value != null && typeof value.toString != 'function') {
|
|
94
|
+
try {
|
|
95
|
+
result = !!(value + '');
|
|
96
|
+
} catch (e) {}
|
|
97
|
+
}
|
|
98
|
+
return result;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
/**
|
|
102
|
+
* Creates a unary function that invokes `func` with its argument transformed.
|
|
103
|
+
*
|
|
104
|
+
* @private
|
|
105
|
+
* @param {Function} func The function to wrap.
|
|
106
|
+
* @param {Function} transform The argument transform.
|
|
107
|
+
* @returns {Function} Returns the new function.
|
|
108
|
+
*/
|
|
109
|
+
function overArg(func, transform) {
|
|
110
|
+
return function(arg) {
|
|
111
|
+
return func(transform(arg));
|
|
112
|
+
};
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
/** Used for built-in method references. */
|
|
116
|
+
var funcProto = Function.prototype,
|
|
117
|
+
objectProto = Object.prototype;
|
|
118
|
+
|
|
119
|
+
/** Used to detect overreaching core-js shims. */
|
|
120
|
+
var coreJsData = root['__core-js_shared__'];
|
|
121
|
+
|
|
122
|
+
/** Used to detect methods masquerading as native. */
|
|
123
|
+
var maskSrcKey = (function() {
|
|
124
|
+
var uid = /[^.]+$/.exec(coreJsData && coreJsData.keys && coreJsData.keys.IE_PROTO || '');
|
|
125
|
+
return uid ? ('Symbol(src)_1.' + uid) : '';
|
|
126
|
+
}());
|
|
127
|
+
|
|
128
|
+
/** Used to resolve the decompiled source of functions. */
|
|
129
|
+
var funcToString = funcProto.toString;
|
|
130
|
+
|
|
131
|
+
/** Used to check objects for own properties. */
|
|
132
|
+
var hasOwnProperty = objectProto.hasOwnProperty;
|
|
133
|
+
|
|
134
|
+
/**
|
|
135
|
+
* Used to resolve the
|
|
136
|
+
* [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring)
|
|
137
|
+
* of values.
|
|
138
|
+
*/
|
|
139
|
+
var objectToString = objectProto.toString;
|
|
140
|
+
|
|
141
|
+
/** Used to detect if a method is native. */
|
|
142
|
+
var reIsNative = RegExp('^' +
|
|
143
|
+
funcToString.call(hasOwnProperty).replace(reRegExpChar, '\\$&')
|
|
144
|
+
.replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g, '$1.*?') + '$'
|
|
145
|
+
);
|
|
146
|
+
|
|
147
|
+
/** Built-in value references. */
|
|
148
|
+
var Buffer = moduleExports ? root.Buffer : undefined,
|
|
149
|
+
propertyIsEnumerable = objectProto.propertyIsEnumerable;
|
|
150
|
+
|
|
151
|
+
/* Built-in method references for those with the same name as other `lodash` methods. */
|
|
152
|
+
var nativeIsBuffer = Buffer ? Buffer.isBuffer : undefined,
|
|
153
|
+
nativeKeys = overArg(Object.keys, Object);
|
|
154
|
+
|
|
155
|
+
/* Built-in method references that are verified to be native. */
|
|
156
|
+
var DataView = getNative(root, 'DataView'),
|
|
157
|
+
Map = getNative(root, 'Map'),
|
|
158
|
+
Promise = getNative(root, 'Promise'),
|
|
159
|
+
Set = getNative(root, 'Set'),
|
|
160
|
+
WeakMap = getNative(root, 'WeakMap');
|
|
161
|
+
|
|
162
|
+
/** Detect if properties shadowing those on `Object.prototype` are non-enumerable. */
|
|
163
|
+
var nonEnumShadows = !propertyIsEnumerable.call({ 'valueOf': 1 }, 'valueOf');
|
|
164
|
+
|
|
165
|
+
/** Used to detect maps, sets, and weakmaps. */
|
|
166
|
+
var dataViewCtorString = toSource(DataView),
|
|
167
|
+
mapCtorString = toSource(Map),
|
|
168
|
+
promiseCtorString = toSource(Promise),
|
|
169
|
+
setCtorString = toSource(Set),
|
|
170
|
+
weakMapCtorString = toSource(WeakMap);
|
|
171
|
+
|
|
172
|
+
/**
|
|
173
|
+
* The base implementation of `getTag`.
|
|
174
|
+
*
|
|
175
|
+
* @private
|
|
176
|
+
* @param {*} value The value to query.
|
|
177
|
+
* @returns {string} Returns the `toStringTag`.
|
|
178
|
+
*/
|
|
179
|
+
function baseGetTag(value) {
|
|
180
|
+
return objectToString.call(value);
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
/**
|
|
184
|
+
* The base implementation of `_.isNative` without bad shim checks.
|
|
185
|
+
*
|
|
186
|
+
* @private
|
|
187
|
+
* @param {*} value The value to check.
|
|
188
|
+
* @returns {boolean} Returns `true` if `value` is a native function,
|
|
189
|
+
* else `false`.
|
|
190
|
+
*/
|
|
191
|
+
function baseIsNative(value) {
|
|
192
|
+
if (!isObject(value) || isMasked(value)) {
|
|
193
|
+
return false;
|
|
194
|
+
}
|
|
195
|
+
var pattern = (isFunction(value) || isHostObject(value)) ? reIsNative : reIsHostCtor;
|
|
196
|
+
return pattern.test(toSource(value));
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
/**
|
|
200
|
+
* Gets the native function at `key` of `object`.
|
|
201
|
+
*
|
|
202
|
+
* @private
|
|
203
|
+
* @param {Object} object The object to query.
|
|
204
|
+
* @param {string} key The key of the method to get.
|
|
205
|
+
* @returns {*} Returns the function if it's native, else `undefined`.
|
|
206
|
+
*/
|
|
207
|
+
function getNative(object, key) {
|
|
208
|
+
var value = getValue(object, key);
|
|
209
|
+
return baseIsNative(value) ? value : undefined;
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
/**
|
|
213
|
+
* Gets the `toStringTag` of `value`.
|
|
214
|
+
*
|
|
215
|
+
* @private
|
|
216
|
+
* @param {*} value The value to query.
|
|
217
|
+
* @returns {string} Returns the `toStringTag`.
|
|
218
|
+
*/
|
|
219
|
+
var getTag = baseGetTag;
|
|
220
|
+
|
|
221
|
+
// Fallback for data views, maps, sets, and weak maps in IE 11,
|
|
222
|
+
// for data views in Edge < 14, and promises in Node.js.
|
|
223
|
+
if ((DataView && getTag(new DataView(new ArrayBuffer(1))) != dataViewTag) ||
|
|
224
|
+
(Map && getTag(new Map) != mapTag) ||
|
|
225
|
+
(Promise && getTag(Promise.resolve()) != promiseTag) ||
|
|
226
|
+
(Set && getTag(new Set) != setTag) ||
|
|
227
|
+
(WeakMap && getTag(new WeakMap) != weakMapTag)) {
|
|
228
|
+
getTag = function(value) {
|
|
229
|
+
var result = objectToString.call(value),
|
|
230
|
+
Ctor = result == objectTag ? value.constructor : undefined,
|
|
231
|
+
ctorString = Ctor ? toSource(Ctor) : undefined;
|
|
232
|
+
|
|
233
|
+
if (ctorString) {
|
|
234
|
+
switch (ctorString) {
|
|
235
|
+
case dataViewCtorString: return dataViewTag;
|
|
236
|
+
case mapCtorString: return mapTag;
|
|
237
|
+
case promiseCtorString: return promiseTag;
|
|
238
|
+
case setCtorString: return setTag;
|
|
239
|
+
case weakMapCtorString: return weakMapTag;
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
return result;
|
|
243
|
+
};
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
/**
|
|
247
|
+
* Checks if `func` has its source masked.
|
|
248
|
+
*
|
|
249
|
+
* @private
|
|
250
|
+
* @param {Function} func The function to check.
|
|
251
|
+
* @returns {boolean} Returns `true` if `func` is masked, else `false`.
|
|
252
|
+
*/
|
|
253
|
+
function isMasked(func) {
|
|
254
|
+
return !!maskSrcKey && (maskSrcKey in func);
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
/**
|
|
258
|
+
* Checks if `value` is likely a prototype object.
|
|
259
|
+
*
|
|
260
|
+
* @private
|
|
261
|
+
* @param {*} value The value to check.
|
|
262
|
+
* @returns {boolean} Returns `true` if `value` is a prototype, else `false`.
|
|
263
|
+
*/
|
|
264
|
+
function isPrototype(value) {
|
|
265
|
+
var Ctor = value && value.constructor,
|
|
266
|
+
proto = (typeof Ctor == 'function' && Ctor.prototype) || objectProto;
|
|
267
|
+
|
|
268
|
+
return value === proto;
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
/**
|
|
272
|
+
* Converts `func` to its source code.
|
|
273
|
+
*
|
|
274
|
+
* @private
|
|
275
|
+
* @param {Function} func The function to process.
|
|
276
|
+
* @returns {string} Returns the source code.
|
|
277
|
+
*/
|
|
278
|
+
function toSource(func) {
|
|
279
|
+
if (func != null) {
|
|
280
|
+
try {
|
|
281
|
+
return funcToString.call(func);
|
|
282
|
+
} catch (e) {}
|
|
283
|
+
try {
|
|
284
|
+
return (func + '');
|
|
285
|
+
} catch (e) {}
|
|
286
|
+
}
|
|
287
|
+
return '';
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
/**
|
|
291
|
+
* Checks if `value` is likely an `arguments` object.
|
|
292
|
+
*
|
|
293
|
+
* @static
|
|
294
|
+
* @memberOf _
|
|
295
|
+
* @since 0.1.0
|
|
296
|
+
* @category Lang
|
|
297
|
+
* @param {*} value The value to check.
|
|
298
|
+
* @returns {boolean} Returns `true` if `value` is an `arguments` object,
|
|
299
|
+
* else `false`.
|
|
300
|
+
* @example
|
|
301
|
+
*
|
|
302
|
+
* _.isArguments(function() { return arguments; }());
|
|
303
|
+
* // => true
|
|
304
|
+
*
|
|
305
|
+
* _.isArguments([1, 2, 3]);
|
|
306
|
+
* // => false
|
|
307
|
+
*/
|
|
308
|
+
function isArguments(value) {
|
|
309
|
+
// Safari 8.1 makes `arguments.callee` enumerable in strict mode.
|
|
310
|
+
return isArrayLikeObject(value) && hasOwnProperty.call(value, 'callee') &&
|
|
311
|
+
(!propertyIsEnumerable.call(value, 'callee') || objectToString.call(value) == argsTag);
|
|
312
|
+
}
|
|
313
|
+
|
|
314
|
+
/**
|
|
315
|
+
* Checks if `value` is classified as an `Array` object.
|
|
316
|
+
*
|
|
317
|
+
* @static
|
|
318
|
+
* @memberOf _
|
|
319
|
+
* @since 0.1.0
|
|
320
|
+
* @category Lang
|
|
321
|
+
* @param {*} value The value to check.
|
|
322
|
+
* @returns {boolean} Returns `true` if `value` is an array, else `false`.
|
|
323
|
+
* @example
|
|
324
|
+
*
|
|
325
|
+
* _.isArray([1, 2, 3]);
|
|
326
|
+
* // => true
|
|
327
|
+
*
|
|
328
|
+
* _.isArray(document.body.children);
|
|
329
|
+
* // => false
|
|
330
|
+
*
|
|
331
|
+
* _.isArray('abc');
|
|
332
|
+
* // => false
|
|
333
|
+
*
|
|
334
|
+
* _.isArray(_.noop);
|
|
335
|
+
* // => false
|
|
336
|
+
*/
|
|
337
|
+
var isArray = Array.isArray;
|
|
338
|
+
|
|
339
|
+
/**
|
|
340
|
+
* Checks if `value` is array-like. A value is considered array-like if it's
|
|
341
|
+
* not a function and has a `value.length` that's an integer greater than or
|
|
342
|
+
* equal to `0` and less than or equal to `Number.MAX_SAFE_INTEGER`.
|
|
343
|
+
*
|
|
344
|
+
* @static
|
|
345
|
+
* @memberOf _
|
|
346
|
+
* @since 4.0.0
|
|
347
|
+
* @category Lang
|
|
348
|
+
* @param {*} value The value to check.
|
|
349
|
+
* @returns {boolean} Returns `true` if `value` is array-like, else `false`.
|
|
350
|
+
* @example
|
|
351
|
+
*
|
|
352
|
+
* _.isArrayLike([1, 2, 3]);
|
|
353
|
+
* // => true
|
|
354
|
+
*
|
|
355
|
+
* _.isArrayLike(document.body.children);
|
|
356
|
+
* // => true
|
|
357
|
+
*
|
|
358
|
+
* _.isArrayLike('abc');
|
|
359
|
+
* // => true
|
|
360
|
+
*
|
|
361
|
+
* _.isArrayLike(_.noop);
|
|
362
|
+
* // => false
|
|
363
|
+
*/
|
|
364
|
+
function isArrayLike(value) {
|
|
365
|
+
return value != null && isLength(value.length) && !isFunction(value);
|
|
366
|
+
}
|
|
367
|
+
|
|
368
|
+
/**
|
|
369
|
+
* This method is like `_.isArrayLike` except that it also checks if `value`
|
|
370
|
+
* is an object.
|
|
371
|
+
*
|
|
372
|
+
* @static
|
|
373
|
+
* @memberOf _
|
|
374
|
+
* @since 4.0.0
|
|
375
|
+
* @category Lang
|
|
376
|
+
* @param {*} value The value to check.
|
|
377
|
+
* @returns {boolean} Returns `true` if `value` is an array-like object,
|
|
378
|
+
* else `false`.
|
|
379
|
+
* @example
|
|
380
|
+
*
|
|
381
|
+
* _.isArrayLikeObject([1, 2, 3]);
|
|
382
|
+
* // => true
|
|
383
|
+
*
|
|
384
|
+
* _.isArrayLikeObject(document.body.children);
|
|
385
|
+
* // => true
|
|
386
|
+
*
|
|
387
|
+
* _.isArrayLikeObject('abc');
|
|
388
|
+
* // => false
|
|
389
|
+
*
|
|
390
|
+
* _.isArrayLikeObject(_.noop);
|
|
391
|
+
* // => false
|
|
392
|
+
*/
|
|
393
|
+
function isArrayLikeObject(value) {
|
|
394
|
+
return isObjectLike(value) && isArrayLike(value);
|
|
395
|
+
}
|
|
396
|
+
|
|
397
|
+
/**
|
|
398
|
+
* Checks if `value` is a buffer.
|
|
399
|
+
*
|
|
400
|
+
* @static
|
|
401
|
+
* @memberOf _
|
|
402
|
+
* @since 4.3.0
|
|
403
|
+
* @category Lang
|
|
404
|
+
* @param {*} value The value to check.
|
|
405
|
+
* @returns {boolean} Returns `true` if `value` is a buffer, else `false`.
|
|
406
|
+
* @example
|
|
407
|
+
*
|
|
408
|
+
* _.isBuffer(new Buffer(2));
|
|
409
|
+
* // => true
|
|
410
|
+
*
|
|
411
|
+
* _.isBuffer(new Uint8Array(2));
|
|
412
|
+
* // => false
|
|
413
|
+
*/
|
|
414
|
+
var isBuffer = nativeIsBuffer || stubFalse;
|
|
415
|
+
|
|
416
|
+
/**
|
|
417
|
+
* Checks if `value` is an empty object, collection, map, or set.
|
|
418
|
+
*
|
|
419
|
+
* Objects are considered empty if they have no own enumerable string keyed
|
|
420
|
+
* properties.
|
|
421
|
+
*
|
|
422
|
+
* Array-like values such as `arguments` objects, arrays, buffers, strings, or
|
|
423
|
+
* jQuery-like collections are considered empty if they have a `length` of `0`.
|
|
424
|
+
* Similarly, maps and sets are considered empty if they have a `size` of `0`.
|
|
425
|
+
*
|
|
426
|
+
* @static
|
|
427
|
+
* @memberOf _
|
|
428
|
+
* @since 0.1.0
|
|
429
|
+
* @category Lang
|
|
430
|
+
* @param {*} value The value to check.
|
|
431
|
+
* @returns {boolean} Returns `true` if `value` is empty, else `false`.
|
|
432
|
+
* @example
|
|
433
|
+
*
|
|
434
|
+
* _.isEmpty(null);
|
|
435
|
+
* // => true
|
|
436
|
+
*
|
|
437
|
+
* _.isEmpty(true);
|
|
438
|
+
* // => true
|
|
439
|
+
*
|
|
440
|
+
* _.isEmpty(1);
|
|
441
|
+
* // => true
|
|
442
|
+
*
|
|
443
|
+
* _.isEmpty([1, 2, 3]);
|
|
444
|
+
* // => false
|
|
445
|
+
*
|
|
446
|
+
* _.isEmpty({ 'a': 1 });
|
|
447
|
+
* // => false
|
|
448
|
+
*/
|
|
449
|
+
function isEmpty(value) {
|
|
450
|
+
if (isArrayLike(value) &&
|
|
451
|
+
(isArray(value) || typeof value == 'string' ||
|
|
452
|
+
typeof value.splice == 'function' || isBuffer(value) || isArguments(value))) {
|
|
453
|
+
return !value.length;
|
|
454
|
+
}
|
|
455
|
+
var tag = getTag(value);
|
|
456
|
+
if (tag == mapTag || tag == setTag) {
|
|
457
|
+
return !value.size;
|
|
458
|
+
}
|
|
459
|
+
if (nonEnumShadows || isPrototype(value)) {
|
|
460
|
+
return !nativeKeys(value).length;
|
|
461
|
+
}
|
|
462
|
+
for (var key in value) {
|
|
463
|
+
if (hasOwnProperty.call(value, key)) {
|
|
464
|
+
return false;
|
|
465
|
+
}
|
|
466
|
+
}
|
|
467
|
+
return true;
|
|
468
|
+
}
|
|
469
|
+
|
|
470
|
+
/**
|
|
471
|
+
* Checks if `value` is classified as a `Function` object.
|
|
472
|
+
*
|
|
473
|
+
* @static
|
|
474
|
+
* @memberOf _
|
|
475
|
+
* @since 0.1.0
|
|
476
|
+
* @category Lang
|
|
477
|
+
* @param {*} value The value to check.
|
|
478
|
+
* @returns {boolean} Returns `true` if `value` is a function, else `false`.
|
|
479
|
+
* @example
|
|
480
|
+
*
|
|
481
|
+
* _.isFunction(_);
|
|
482
|
+
* // => true
|
|
483
|
+
*
|
|
484
|
+
* _.isFunction(/abc/);
|
|
485
|
+
* // => false
|
|
486
|
+
*/
|
|
487
|
+
function isFunction(value) {
|
|
488
|
+
// The use of `Object#toString` avoids issues with the `typeof` operator
|
|
489
|
+
// in Safari 8-9 which returns 'object' for typed array and other constructors.
|
|
490
|
+
var tag = isObject(value) ? objectToString.call(value) : '';
|
|
491
|
+
return tag == funcTag || tag == genTag;
|
|
492
|
+
}
|
|
493
|
+
|
|
494
|
+
/**
|
|
495
|
+
* Checks if `value` is a valid array-like length.
|
|
496
|
+
*
|
|
497
|
+
* **Note:** This method is loosely based on
|
|
498
|
+
* [`ToLength`](http://ecma-international.org/ecma-262/7.0/#sec-tolength).
|
|
499
|
+
*
|
|
500
|
+
* @static
|
|
501
|
+
* @memberOf _
|
|
502
|
+
* @since 4.0.0
|
|
503
|
+
* @category Lang
|
|
504
|
+
* @param {*} value The value to check.
|
|
505
|
+
* @returns {boolean} Returns `true` if `value` is a valid length, else `false`.
|
|
506
|
+
* @example
|
|
507
|
+
*
|
|
508
|
+
* _.isLength(3);
|
|
509
|
+
* // => true
|
|
510
|
+
*
|
|
511
|
+
* _.isLength(Number.MIN_VALUE);
|
|
512
|
+
* // => false
|
|
513
|
+
*
|
|
514
|
+
* _.isLength(Infinity);
|
|
515
|
+
* // => false
|
|
516
|
+
*
|
|
517
|
+
* _.isLength('3');
|
|
518
|
+
* // => false
|
|
519
|
+
*/
|
|
520
|
+
function isLength(value) {
|
|
521
|
+
return typeof value == 'number' &&
|
|
522
|
+
value > -1 && value % 1 == 0 && value <= MAX_SAFE_INTEGER;
|
|
523
|
+
}
|
|
524
|
+
|
|
525
|
+
/**
|
|
526
|
+
* Checks if `value` is the
|
|
527
|
+
* [language type](http://www.ecma-international.org/ecma-262/7.0/#sec-ecmascript-language-types)
|
|
528
|
+
* of `Object`. (e.g. arrays, functions, objects, regexes, `new Number(0)`, and `new String('')`)
|
|
529
|
+
*
|
|
530
|
+
* @static
|
|
531
|
+
* @memberOf _
|
|
532
|
+
* @since 0.1.0
|
|
533
|
+
* @category Lang
|
|
534
|
+
* @param {*} value The value to check.
|
|
535
|
+
* @returns {boolean} Returns `true` if `value` is an object, else `false`.
|
|
536
|
+
* @example
|
|
537
|
+
*
|
|
538
|
+
* _.isObject({});
|
|
539
|
+
* // => true
|
|
540
|
+
*
|
|
541
|
+
* _.isObject([1, 2, 3]);
|
|
542
|
+
* // => true
|
|
543
|
+
*
|
|
544
|
+
* _.isObject(_.noop);
|
|
545
|
+
* // => true
|
|
546
|
+
*
|
|
547
|
+
* _.isObject(null);
|
|
548
|
+
* // => false
|
|
549
|
+
*/
|
|
550
|
+
function isObject(value) {
|
|
551
|
+
var type = typeof value;
|
|
552
|
+
return !!value && (type == 'object' || type == 'function');
|
|
553
|
+
}
|
|
554
|
+
|
|
555
|
+
/**
|
|
556
|
+
* Checks if `value` is object-like. A value is object-like if it's not `null`
|
|
557
|
+
* and has a `typeof` result of "object".
|
|
558
|
+
*
|
|
559
|
+
* @static
|
|
560
|
+
* @memberOf _
|
|
561
|
+
* @since 4.0.0
|
|
562
|
+
* @category Lang
|
|
563
|
+
* @param {*} value The value to check.
|
|
564
|
+
* @returns {boolean} Returns `true` if `value` is object-like, else `false`.
|
|
565
|
+
* @example
|
|
566
|
+
*
|
|
567
|
+
* _.isObjectLike({});
|
|
568
|
+
* // => true
|
|
569
|
+
*
|
|
570
|
+
* _.isObjectLike([1, 2, 3]);
|
|
571
|
+
* // => true
|
|
572
|
+
*
|
|
573
|
+
* _.isObjectLike(_.noop);
|
|
574
|
+
* // => false
|
|
575
|
+
*
|
|
576
|
+
* _.isObjectLike(null);
|
|
577
|
+
* // => false
|
|
578
|
+
*/
|
|
579
|
+
function isObjectLike(value) {
|
|
580
|
+
return !!value && typeof value == 'object';
|
|
581
|
+
}
|
|
582
|
+
|
|
583
|
+
/**
|
|
584
|
+
* This method returns `false`.
|
|
585
|
+
*
|
|
586
|
+
* @static
|
|
587
|
+
* @memberOf _
|
|
588
|
+
* @since 4.13.0
|
|
589
|
+
* @category Util
|
|
590
|
+
* @returns {boolean} Returns `false`.
|
|
591
|
+
* @example
|
|
592
|
+
*
|
|
593
|
+
* _.times(2, _.stubFalse);
|
|
594
|
+
* // => [false, false]
|
|
595
|
+
*/
|
|
596
|
+
function stubFalse() {
|
|
597
|
+
return false;
|
|
598
|
+
}
|
|
599
|
+
|
|
600
|
+
module.exports = isEmpty;
|
|
601
|
+
} (lodash_isempty, lodash_isempty.exports));
|
|
602
|
+
return lodash_isempty.exports;
|
|
603
|
+
}
|
|
604
|
+
|
|
605
|
+
var lodash_isemptyExports = requireLodash_isempty();
|
|
606
|
+
var isEmpty = /*@__PURE__*/getDefaultExportFromCjs(lodash_isemptyExports);
|
|
607
|
+
|
|
608
|
+
var __defProp$1 = Object.defineProperty;
|
|
609
|
+
var __getOwnPropSymbols$1 = Object.getOwnPropertySymbols;
|
|
610
|
+
var __hasOwnProp$1 = Object.prototype.hasOwnProperty;
|
|
611
|
+
var __propIsEnum$1 = Object.prototype.propertyIsEnumerable;
|
|
612
|
+
var __defNormalProp$1 = (obj, key, value) => key in obj ? __defProp$1(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
613
|
+
var __spreadValues$1 = (a, b) => {
|
|
614
|
+
for (var prop in b || (b = {}))
|
|
615
|
+
if (__hasOwnProp$1.call(b, prop))
|
|
616
|
+
__defNormalProp$1(a, prop, b[prop]);
|
|
617
|
+
if (__getOwnPropSymbols$1)
|
|
618
|
+
for (var prop of __getOwnPropSymbols$1(b)) {
|
|
619
|
+
if (__propIsEnum$1.call(b, prop))
|
|
620
|
+
__defNormalProp$1(a, prop, b[prop]);
|
|
621
|
+
}
|
|
622
|
+
return a;
|
|
623
|
+
};
|
|
624
|
+
const LDContextBuiltIns = {
|
|
625
|
+
name: "string",
|
|
626
|
+
anonymous: "boolean"
|
|
627
|
+
};
|
|
628
|
+
function convertAttributes(logger, key, value, object, visited) {
|
|
629
|
+
if (visited.includes(value)) {
|
|
630
|
+
logger.error(
|
|
631
|
+
"Detected a cycle within the evaluation context. The affected part of the context will not be included in evaluation."
|
|
632
|
+
);
|
|
633
|
+
return;
|
|
634
|
+
}
|
|
635
|
+
if (value instanceof Date) {
|
|
636
|
+
object[key] = value.toISOString();
|
|
637
|
+
} else if (typeof value === "object" && !Array.isArray(value)) {
|
|
638
|
+
object[key] = {};
|
|
639
|
+
Object.entries(value).forEach(([objectKey, objectValue]) => {
|
|
640
|
+
convertAttributes(logger, objectKey, objectValue, object[key], [...visited, value]);
|
|
641
|
+
});
|
|
642
|
+
} else {
|
|
643
|
+
object[key] = value;
|
|
644
|
+
}
|
|
645
|
+
}
|
|
646
|
+
function translateContextCommon(logger, inCommon, inTargetingKey) {
|
|
647
|
+
const keyAttr = inCommon["key"];
|
|
648
|
+
const finalKey = inTargetingKey != null ? inTargetingKey : keyAttr;
|
|
649
|
+
if (keyAttr != null && inTargetingKey != null) {
|
|
650
|
+
logger.warn(
|
|
651
|
+
"The EvaluationContext contained both a 'targetingKey' and a 'key' attribute. The 'key' attribute will be discarded."
|
|
652
|
+
);
|
|
653
|
+
}
|
|
654
|
+
if (finalKey == null) {
|
|
655
|
+
logger.error(
|
|
656
|
+
"The EvaluationContext must contain either a 'targetingKey' or a 'key' and the type must be a string."
|
|
657
|
+
);
|
|
658
|
+
}
|
|
659
|
+
const convertedContext = { key: finalKey };
|
|
660
|
+
Object.entries(inCommon).forEach(([key, value]) => {
|
|
661
|
+
if (key === "targetingKey" || key === "key") {
|
|
662
|
+
return;
|
|
663
|
+
}
|
|
664
|
+
if (key === "privateAttributes") {
|
|
665
|
+
convertedContext._meta = {
|
|
666
|
+
privateAttributes: value
|
|
667
|
+
};
|
|
668
|
+
} else if (key in LDContextBuiltIns) {
|
|
669
|
+
const typedKey = key;
|
|
670
|
+
if (typeof value === LDContextBuiltIns[typedKey]) {
|
|
671
|
+
convertedContext[key] = value;
|
|
672
|
+
} else {
|
|
673
|
+
logger.error(`The attribute '${key}' must be of type ${LDContextBuiltIns[typedKey]}`);
|
|
674
|
+
}
|
|
675
|
+
} else {
|
|
676
|
+
convertAttributes(logger, key, value, convertedContext, [inCommon]);
|
|
677
|
+
}
|
|
678
|
+
});
|
|
679
|
+
return convertedContext;
|
|
680
|
+
}
|
|
681
|
+
function translateContext(logger, evalContext) {
|
|
682
|
+
let finalKind = "user";
|
|
683
|
+
if (evalContext["kind"] === "multi") {
|
|
684
|
+
return Object.entries(evalContext).reduce((acc, [key, value]) => {
|
|
685
|
+
if (key === "kind") {
|
|
686
|
+
acc.kind = value;
|
|
687
|
+
} else if (typeof value === "object" && !Array.isArray(value)) {
|
|
688
|
+
const valueRecord = value;
|
|
689
|
+
acc[key] = translateContextCommon(logger, valueRecord, valueRecord["targetingKey"]);
|
|
690
|
+
} else {
|
|
691
|
+
logger.error("Top level attributes in a multi-kind context should be Structure types.");
|
|
692
|
+
}
|
|
693
|
+
return acc;
|
|
694
|
+
}, {});
|
|
695
|
+
}
|
|
696
|
+
if (evalContext["kind"] !== void 0 && typeof evalContext["kind"] === "string") {
|
|
697
|
+
finalKind = evalContext["kind"];
|
|
698
|
+
} else if (evalContext["kind"] !== void 0 && typeof evalContext["kind"] !== "string") {
|
|
699
|
+
logger.warn("Specified 'kind' of context was not a string.");
|
|
700
|
+
}
|
|
701
|
+
return __spreadValues$1({
|
|
702
|
+
kind: finalKind
|
|
703
|
+
}, translateContextCommon(logger, evalContext, evalContext.targetingKey));
|
|
704
|
+
}
|
|
705
|
+
|
|
706
|
+
function translateErrorKind(errorKind) {
|
|
707
|
+
switch (errorKind) {
|
|
708
|
+
case "CLIENT_NOT_READY":
|
|
709
|
+
return webSdk.ErrorCode.PROVIDER_NOT_READY;
|
|
710
|
+
case "MALFORMED_FLAG":
|
|
711
|
+
return webSdk.ErrorCode.PARSE_ERROR;
|
|
712
|
+
case "FLAG_NOT_FOUND":
|
|
713
|
+
return webSdk.ErrorCode.FLAG_NOT_FOUND;
|
|
714
|
+
case "USER_NOT_SPECIFIED":
|
|
715
|
+
return webSdk.ErrorCode.TARGETING_KEY_MISSING;
|
|
716
|
+
// General errors.
|
|
717
|
+
default:
|
|
718
|
+
return webSdk.ErrorCode.GENERAL;
|
|
719
|
+
}
|
|
720
|
+
}
|
|
721
|
+
function translateResult(result) {
|
|
722
|
+
var _a, _b, _c;
|
|
723
|
+
const resolution = {
|
|
724
|
+
value: result.value,
|
|
725
|
+
variant: (_a = result.variationIndex) == null ? void 0 : _a.toString(),
|
|
726
|
+
reason: (_b = result.reason) == null ? void 0 : _b.kind
|
|
727
|
+
};
|
|
728
|
+
if (((_c = result.reason) == null ? void 0 : _c.kind) === "ERROR") {
|
|
729
|
+
resolution.errorCode = translateErrorKind(result.reason.errorKind);
|
|
730
|
+
}
|
|
731
|
+
return resolution;
|
|
732
|
+
}
|
|
733
|
+
|
|
734
|
+
var __defProp = Object.defineProperty;
|
|
735
|
+
var __defProps = Object.defineProperties;
|
|
736
|
+
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
737
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
738
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
739
|
+
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
740
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
741
|
+
var __spreadValues = (a, b) => {
|
|
742
|
+
for (var prop in b || (b = {}))
|
|
743
|
+
if (__hasOwnProp.call(b, prop))
|
|
744
|
+
__defNormalProp(a, prop, b[prop]);
|
|
745
|
+
if (__getOwnPropSymbols)
|
|
746
|
+
for (var prop of __getOwnPropSymbols(b)) {
|
|
747
|
+
if (__propIsEnum.call(b, prop))
|
|
748
|
+
__defNormalProp(a, prop, b[prop]);
|
|
749
|
+
}
|
|
750
|
+
return a;
|
|
751
|
+
};
|
|
752
|
+
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
753
|
+
var __objRest = (source, exclude) => {
|
|
754
|
+
var target = {};
|
|
755
|
+
for (var prop in source)
|
|
756
|
+
if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
|
|
757
|
+
target[prop] = source[prop];
|
|
758
|
+
if (source != null && __getOwnPropSymbols)
|
|
759
|
+
for (var prop of __getOwnPropSymbols(source)) {
|
|
760
|
+
if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
|
|
761
|
+
target[prop] = source[prop];
|
|
762
|
+
}
|
|
763
|
+
return target;
|
|
764
|
+
};
|
|
765
|
+
function wrongTypeResult(value) {
|
|
766
|
+
return {
|
|
767
|
+
value,
|
|
768
|
+
reason: webSdk.StandardResolutionReasons.ERROR,
|
|
769
|
+
errorCode: webSdk.ErrorCode.TYPE_MISMATCH
|
|
770
|
+
};
|
|
771
|
+
}
|
|
772
|
+
class LaunchDarklyClientProvider {
|
|
773
|
+
constructor(envKey, _a) {
|
|
774
|
+
this.envKey = envKey;
|
|
775
|
+
this.metadata = {
|
|
776
|
+
name: "launchdarkly-client-provider"
|
|
777
|
+
};
|
|
778
|
+
this.events = new webSdk.OpenFeatureEventEmitter();
|
|
779
|
+
/*
|
|
780
|
+
* implement status field/accessor
|
|
781
|
+
* https://openfeature.dev/specification/sections/providers#requirement-242
|
|
782
|
+
* */
|
|
783
|
+
this._status = webSdk.ProviderStatus.NOT_READY;
|
|
784
|
+
var _b = _a, { logger, initializationTimeout } = _b, ldOptions = __objRest(_b, ["logger", "initializationTimeout"]);
|
|
785
|
+
if (logger) {
|
|
786
|
+
this.logger = logger;
|
|
787
|
+
} else {
|
|
788
|
+
this.logger = launchdarklyJsClientSdk.basicLogger({ level: "info" });
|
|
789
|
+
}
|
|
790
|
+
this.initializationTimeout = initializationTimeout;
|
|
791
|
+
this.ldOptions = __spreadProps(__spreadValues({}, ldOptions), { logger: this.logger });
|
|
792
|
+
}
|
|
793
|
+
set status(status) {
|
|
794
|
+
this._status = status;
|
|
795
|
+
}
|
|
796
|
+
get status() {
|
|
797
|
+
return this._status;
|
|
798
|
+
}
|
|
799
|
+
get client() {
|
|
800
|
+
if (!this._client) {
|
|
801
|
+
throw new webSdk.GeneralError("Provider is not initialized");
|
|
802
|
+
}
|
|
803
|
+
return this._client;
|
|
804
|
+
}
|
|
805
|
+
async initialize(context) {
|
|
806
|
+
var _a;
|
|
807
|
+
const _context = isEmpty(context) ? { anonymous: true } : this.translateContext(context);
|
|
808
|
+
this._client = launchdarklyJsClientSdk.initialize(this.envKey, _context, this.ldOptions);
|
|
809
|
+
if ((_a = this.ldOptions) == null ? void 0 : _a.streaming) {
|
|
810
|
+
this.setListeners();
|
|
811
|
+
}
|
|
812
|
+
try {
|
|
813
|
+
await this._client.waitForInitialization(this.initializationTimeout);
|
|
814
|
+
this.status = webSdk.ProviderStatus.READY;
|
|
815
|
+
} catch (e) {
|
|
816
|
+
this.status = webSdk.ProviderStatus.ERROR;
|
|
817
|
+
}
|
|
818
|
+
}
|
|
819
|
+
onClose() {
|
|
820
|
+
return this.client.close();
|
|
821
|
+
}
|
|
822
|
+
/** set listeners to LD client and event the correspodent event in the Provider
|
|
823
|
+
* necessary for LD streaming changes
|
|
824
|
+
* */
|
|
825
|
+
setListeners() {
|
|
826
|
+
this.client.on("change", (changeset) => {
|
|
827
|
+
this.events.emit(webSdk.ProviderEvents.ConfigurationChanged, {
|
|
828
|
+
flagsChanged: Object.keys(changeset)
|
|
829
|
+
});
|
|
830
|
+
});
|
|
831
|
+
}
|
|
832
|
+
async onContextChange(oldContext, newContext) {
|
|
833
|
+
await this.client.identify(this.translateContext(newContext));
|
|
834
|
+
}
|
|
835
|
+
resolveBooleanEvaluation(flagKey, defaultValue) {
|
|
836
|
+
const res = this.client.variationDetail(flagKey, defaultValue);
|
|
837
|
+
if (typeof res.value === "boolean") {
|
|
838
|
+
return translateResult(res);
|
|
839
|
+
}
|
|
840
|
+
return wrongTypeResult(defaultValue);
|
|
841
|
+
}
|
|
842
|
+
resolveNumberEvaluation(flagKey, defaultValue) {
|
|
843
|
+
const res = this.client.variationDetail(flagKey, defaultValue);
|
|
844
|
+
if (typeof res.value === "number") {
|
|
845
|
+
return translateResult(res);
|
|
846
|
+
}
|
|
847
|
+
return wrongTypeResult(defaultValue);
|
|
848
|
+
}
|
|
849
|
+
resolveObjectEvaluation(flagKey, defaultValue) {
|
|
850
|
+
const res = this.client.variationDetail(flagKey, defaultValue);
|
|
851
|
+
if (typeof res.value === "object") {
|
|
852
|
+
return translateResult(res);
|
|
853
|
+
}
|
|
854
|
+
return wrongTypeResult(defaultValue);
|
|
855
|
+
}
|
|
856
|
+
resolveStringEvaluation(flagKey, defaultValue) {
|
|
857
|
+
const res = this.client.variationDetail(flagKey, defaultValue);
|
|
858
|
+
if (typeof res.value === "string") {
|
|
859
|
+
return translateResult(res);
|
|
860
|
+
}
|
|
861
|
+
return wrongTypeResult(defaultValue);
|
|
862
|
+
}
|
|
863
|
+
track(trackingEventName, _context, _c) {
|
|
864
|
+
var _d = _c, { value } = _d, details = __objRest(_d, ["value"]);
|
|
865
|
+
this.client.track(trackingEventName, details, value);
|
|
866
|
+
}
|
|
867
|
+
translateContext(context) {
|
|
868
|
+
return translateContext(this.logger, context);
|
|
869
|
+
}
|
|
870
|
+
}
|
|
871
|
+
|
|
872
|
+
exports.LaunchDarklyClientProvider = LaunchDarklyClientProvider;
|
|
873
|
+
|
|
874
|
+
return exports;
|
|
875
|
+
|
|
876
|
+
})({}, OpenFeature, LDClient);
|
|
877
|
+
//# sourceMappingURL=index.js.map
|