@flipt-io/flipt-client-js 0.1.0 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -0
- package/dist/browser/index.cjs +156 -108
- package/dist/browser/index.mjs +156 -108
- package/dist/flipt_engine_wasm_js_bg.wasm +0 -0
- package/dist/node/index.cjs +156 -108
- package/dist/node/index.mjs +156 -108
- package/dist/slim/index.cjs +155 -107
- package/dist/slim/index.mjs +155 -107
- package/dist/types/core/base.d.ts +4 -3
- package/dist/types/core/types.d.ts +28 -1
- package/package.json +4 -4
package/dist/slim/index.cjs
CHANGED
|
@@ -3,8 +3,6 @@
|
|
|
3
3
|
var _documentCurrentScript = typeof document !== 'undefined' ? document.currentScript : null;
|
|
4
4
|
let wasm;
|
|
5
5
|
|
|
6
|
-
let WASM_VECTOR_LEN = 0;
|
|
7
|
-
|
|
8
6
|
let cachedUint8ArrayMemory0 = null;
|
|
9
7
|
|
|
10
8
|
function getUint8ArrayMemory0() {
|
|
@@ -14,20 +12,41 @@ function getUint8ArrayMemory0() {
|
|
|
14
12
|
return cachedUint8ArrayMemory0;
|
|
15
13
|
}
|
|
16
14
|
|
|
17
|
-
|
|
15
|
+
let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
|
|
16
|
+
|
|
17
|
+
cachedTextDecoder.decode();
|
|
18
|
+
|
|
19
|
+
const MAX_SAFARI_DECODE_BYTES = 2146435072;
|
|
20
|
+
let numBytesDecoded = 0;
|
|
21
|
+
function decodeText(ptr, len) {
|
|
22
|
+
numBytesDecoded += len;
|
|
23
|
+
if (numBytesDecoded >= MAX_SAFARI_DECODE_BYTES) {
|
|
24
|
+
cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
|
|
25
|
+
cachedTextDecoder.decode();
|
|
26
|
+
numBytesDecoded = len;
|
|
27
|
+
}
|
|
28
|
+
return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
|
|
29
|
+
}
|
|
18
30
|
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
return
|
|
31
|
+
function getStringFromWasm0(ptr, len) {
|
|
32
|
+
ptr = ptr >>> 0;
|
|
33
|
+
return decodeText(ptr, len);
|
|
22
34
|
}
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
35
|
+
|
|
36
|
+
let WASM_VECTOR_LEN = 0;
|
|
37
|
+
|
|
38
|
+
const cachedTextEncoder = new TextEncoder();
|
|
39
|
+
|
|
40
|
+
if (!('encodeInto' in cachedTextEncoder)) {
|
|
41
|
+
cachedTextEncoder.encodeInto = function (arg, view) {
|
|
42
|
+
const buf = cachedTextEncoder.encode(arg);
|
|
43
|
+
view.set(buf);
|
|
44
|
+
return {
|
|
45
|
+
read: arg.length,
|
|
46
|
+
written: buf.length
|
|
47
|
+
};
|
|
29
48
|
};
|
|
30
|
-
}
|
|
49
|
+
}
|
|
31
50
|
|
|
32
51
|
function passStringToWasm0(arg, malloc, realloc) {
|
|
33
52
|
|
|
@@ -58,7 +77,7 @@ function passStringToWasm0(arg, malloc, realloc) {
|
|
|
58
77
|
}
|
|
59
78
|
ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0;
|
|
60
79
|
const view = getUint8ArrayMemory0().subarray(ptr + offset, ptr + len);
|
|
61
|
-
const ret =
|
|
80
|
+
const ret = cachedTextEncoder.encodeInto(arg, view);
|
|
62
81
|
|
|
63
82
|
offset += ret.written;
|
|
64
83
|
ptr = realloc(ptr, len, offset, 1) >>> 0;
|
|
@@ -92,12 +111,9 @@ function handleError(f, args) {
|
|
|
92
111
|
}
|
|
93
112
|
}
|
|
94
113
|
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
if (typeof TextDecoder !== 'undefined') { cachedTextDecoder.decode(); }
|
|
98
|
-
function getStringFromWasm0(ptr, len) {
|
|
114
|
+
function getArrayU8FromWasm0(ptr, len) {
|
|
99
115
|
ptr = ptr >>> 0;
|
|
100
|
-
return
|
|
116
|
+
return getUint8ArrayMemory0().subarray(ptr / 1, ptr / 1 + len);
|
|
101
117
|
}
|
|
102
118
|
|
|
103
119
|
function isLikeNone(x) {
|
|
@@ -256,6 +272,9 @@ class Engine {
|
|
|
256
272
|
return takeFromExternrefTable0(ret[0]);
|
|
257
273
|
}
|
|
258
274
|
}
|
|
275
|
+
if (Symbol.dispose) Engine.prototype[Symbol.dispose] = Engine.prototype.free;
|
|
276
|
+
|
|
277
|
+
const EXPECTED_RESPONSE_TYPES = new Set(['basic', 'cors', 'default']);
|
|
259
278
|
|
|
260
279
|
async function __wbg_load(module, imports) {
|
|
261
280
|
if (typeof Response === 'function' && module instanceof Response) {
|
|
@@ -264,7 +283,9 @@ async function __wbg_load(module, imports) {
|
|
|
264
283
|
return await WebAssembly.instantiateStreaming(module, imports);
|
|
265
284
|
|
|
266
285
|
} catch (e) {
|
|
267
|
-
|
|
286
|
+
const validResponse = module.ok && EXPECTED_RESPONSE_TYPES.has(module.type);
|
|
287
|
+
|
|
288
|
+
if (validResponse && module.headers.get('Content-Type') !== 'application/wasm') {
|
|
268
289
|
console.warn("`WebAssembly.instantiateStreaming` failed because your server does not serve Wasm with `application/wasm` MIME type. Falling back to `WebAssembly.instantiate` which is slower. Original error:\n", e);
|
|
269
290
|
|
|
270
291
|
} else {
|
|
@@ -291,6 +312,10 @@ async function __wbg_load(module, imports) {
|
|
|
291
312
|
function __wbg_get_imports() {
|
|
292
313
|
const imports = {};
|
|
293
314
|
imports.wbg = {};
|
|
315
|
+
imports.wbg.__wbg_Error_e17e777aac105295 = function(arg0, arg1) {
|
|
316
|
+
const ret = Error(getStringFromWasm0(arg0, arg1));
|
|
317
|
+
return ret;
|
|
318
|
+
};
|
|
294
319
|
imports.wbg.__wbg_String_8f0eb39a4a4c2f66 = function(arg0, arg1) {
|
|
295
320
|
const ret = String(arg1);
|
|
296
321
|
const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
@@ -298,19 +323,15 @@ function __wbg_get_imports() {
|
|
|
298
323
|
getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
|
|
299
324
|
getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
|
|
300
325
|
};
|
|
301
|
-
imports.wbg.
|
|
302
|
-
const ret = arg0.buffer;
|
|
303
|
-
return ret;
|
|
304
|
-
};
|
|
305
|
-
imports.wbg.__wbg_call_672a4d21634d4a24 = function() { return handleError(function (arg0, arg1) {
|
|
326
|
+
imports.wbg.__wbg_call_13410aac570ffff7 = function() { return handleError(function (arg0, arg1) {
|
|
306
327
|
const ret = arg0.call(arg1);
|
|
307
328
|
return ret;
|
|
308
329
|
}, arguments) };
|
|
309
|
-
imports.wbg.
|
|
330
|
+
imports.wbg.__wbg_done_75ed0ee6dd243d9d = function(arg0) {
|
|
310
331
|
const ret = arg0.done;
|
|
311
332
|
return ret;
|
|
312
333
|
};
|
|
313
|
-
imports.wbg.
|
|
334
|
+
imports.wbg.__wbg_entries_2be2f15bd5554996 = function(arg0) {
|
|
314
335
|
const ret = Object.entries(arg0);
|
|
315
336
|
return ret;
|
|
316
337
|
};
|
|
@@ -325,23 +346,23 @@ function __wbg_get_imports() {
|
|
|
325
346
|
wasm.__wbindgen_free(deferred0_0, deferred0_1, 1);
|
|
326
347
|
}
|
|
327
348
|
};
|
|
328
|
-
imports.wbg.
|
|
349
|
+
imports.wbg.__wbg_getTime_6bb3f64e0f18f817 = function(arg0) {
|
|
329
350
|
const ret = arg0.getTime();
|
|
330
351
|
return ret;
|
|
331
352
|
};
|
|
332
|
-
imports.wbg.
|
|
333
|
-
const ret = Reflect.get(arg0, arg1);
|
|
334
|
-
return ret;
|
|
335
|
-
}, arguments) };
|
|
336
|
-
imports.wbg.__wbg_get_b9b93047fe3cf45b = function(arg0, arg1) {
|
|
353
|
+
imports.wbg.__wbg_get_0da715ceaecea5c8 = function(arg0, arg1) {
|
|
337
354
|
const ret = arg0[arg1 >>> 0];
|
|
338
355
|
return ret;
|
|
339
356
|
};
|
|
357
|
+
imports.wbg.__wbg_get_458e874b43b18b25 = function() { return handleError(function (arg0, arg1) {
|
|
358
|
+
const ret = Reflect.get(arg0, arg1);
|
|
359
|
+
return ret;
|
|
360
|
+
}, arguments) };
|
|
340
361
|
imports.wbg.__wbg_getwithrefkey_1dc361bd10053bfe = function(arg0, arg1) {
|
|
341
362
|
const ret = arg0[arg1];
|
|
342
363
|
return ret;
|
|
343
364
|
};
|
|
344
|
-
imports.wbg.
|
|
365
|
+
imports.wbg.__wbg_instanceof_ArrayBuffer_67f3012529f6a2dd = function(arg0) {
|
|
345
366
|
let result;
|
|
346
367
|
try {
|
|
347
368
|
result = arg0 instanceof ArrayBuffer;
|
|
@@ -351,7 +372,7 @@ function __wbg_get_imports() {
|
|
|
351
372
|
const ret = result;
|
|
352
373
|
return ret;
|
|
353
374
|
};
|
|
354
|
-
imports.wbg.
|
|
375
|
+
imports.wbg.__wbg_instanceof_Uint8Array_9a8378d955933db7 = function(arg0) {
|
|
355
376
|
let result;
|
|
356
377
|
try {
|
|
357
378
|
result = arg0 instanceof Uint8Array;
|
|
@@ -361,51 +382,51 @@ function __wbg_get_imports() {
|
|
|
361
382
|
const ret = result;
|
|
362
383
|
return ret;
|
|
363
384
|
};
|
|
364
|
-
imports.wbg.
|
|
385
|
+
imports.wbg.__wbg_isArray_030cce220591fb41 = function(arg0) {
|
|
365
386
|
const ret = Array.isArray(arg0);
|
|
366
387
|
return ret;
|
|
367
388
|
};
|
|
368
|
-
imports.wbg.
|
|
389
|
+
imports.wbg.__wbg_iterator_f370b34483c71a1c = function() {
|
|
369
390
|
const ret = Symbol.iterator;
|
|
370
391
|
return ret;
|
|
371
392
|
};
|
|
372
|
-
imports.wbg.
|
|
393
|
+
imports.wbg.__wbg_length_186546c51cd61acd = function(arg0) {
|
|
373
394
|
const ret = arg0.length;
|
|
374
395
|
return ret;
|
|
375
396
|
};
|
|
376
|
-
imports.wbg.
|
|
397
|
+
imports.wbg.__wbg_length_6bb7e81f9d7713e4 = function(arg0) {
|
|
377
398
|
const ret = arg0.length;
|
|
378
399
|
return ret;
|
|
379
400
|
};
|
|
380
|
-
imports.wbg.
|
|
401
|
+
imports.wbg.__wbg_new0_b0a0a38c201e6df5 = function() {
|
|
381
402
|
const ret = new Date();
|
|
382
403
|
return ret;
|
|
383
404
|
};
|
|
384
|
-
imports.wbg.
|
|
405
|
+
imports.wbg.__wbg_new_19c25a3f2fa63a02 = function() {
|
|
385
406
|
const ret = new Object();
|
|
386
407
|
return ret;
|
|
387
408
|
};
|
|
388
|
-
imports.wbg.
|
|
409
|
+
imports.wbg.__wbg_new_1f3a344cf3123716 = function() {
|
|
389
410
|
const ret = new Array();
|
|
390
411
|
return ret;
|
|
391
412
|
};
|
|
392
|
-
imports.wbg.
|
|
393
|
-
const ret = new
|
|
413
|
+
imports.wbg.__wbg_new_638ebfaedbf32a5e = function(arg0) {
|
|
414
|
+
const ret = new Uint8Array(arg0);
|
|
394
415
|
return ret;
|
|
395
416
|
};
|
|
396
|
-
imports.wbg.
|
|
397
|
-
const ret = new
|
|
417
|
+
imports.wbg.__wbg_new_8a6f238a6ece86ea = function() {
|
|
418
|
+
const ret = new Error();
|
|
398
419
|
return ret;
|
|
399
420
|
};
|
|
400
|
-
imports.wbg.
|
|
421
|
+
imports.wbg.__wbg_newnoargs_254190557c45b4ec = function(arg0, arg1) {
|
|
401
422
|
const ret = new Function(getStringFromWasm0(arg0, arg1));
|
|
402
423
|
return ret;
|
|
403
424
|
};
|
|
404
|
-
imports.wbg.
|
|
425
|
+
imports.wbg.__wbg_next_5b3530e612fde77d = function(arg0) {
|
|
405
426
|
const ret = arg0.next;
|
|
406
427
|
return ret;
|
|
407
428
|
};
|
|
408
|
-
imports.wbg.
|
|
429
|
+
imports.wbg.__wbg_next_692e82279131b03c = function() { return handleError(function (arg0) {
|
|
409
430
|
const ret = arg0.next();
|
|
410
431
|
return ret;
|
|
411
432
|
}, arguments) };
|
|
@@ -417,14 +438,14 @@ function __wbg_get_imports() {
|
|
|
417
438
|
const ret = arg0.performance;
|
|
418
439
|
return ret;
|
|
419
440
|
};
|
|
420
|
-
imports.wbg.
|
|
421
|
-
arg0
|
|
441
|
+
imports.wbg.__wbg_prototypesetcall_3d4a26c1ed734349 = function(arg0, arg1, arg2) {
|
|
442
|
+
Uint8Array.prototype.set.call(getArrayU8FromWasm0(arg0, arg1), arg2);
|
|
422
443
|
};
|
|
423
444
|
imports.wbg.__wbg_set_3f1d0b984ed272ed = function(arg0, arg1, arg2) {
|
|
424
445
|
arg0[arg1] = arg2;
|
|
425
446
|
};
|
|
426
|
-
imports.wbg.
|
|
427
|
-
arg0
|
|
447
|
+
imports.wbg.__wbg_set_90f6c0f7bd8c0415 = function(arg0, arg1, arg2) {
|
|
448
|
+
arg0[arg1 >>> 0] = arg2;
|
|
428
449
|
};
|
|
429
450
|
imports.wbg.__wbg_stack_0ed75d68575b0f3c = function(arg0, arg1) {
|
|
430
451
|
const ret = arg1.stack;
|
|
@@ -433,91 +454,70 @@ function __wbg_get_imports() {
|
|
|
433
454
|
getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
|
|
434
455
|
getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
|
|
435
456
|
};
|
|
436
|
-
imports.wbg.
|
|
457
|
+
imports.wbg.__wbg_static_accessor_GLOBAL_8921f820c2ce3f12 = function() {
|
|
437
458
|
const ret = typeof global === 'undefined' ? null : global;
|
|
438
459
|
return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
|
|
439
460
|
};
|
|
440
|
-
imports.wbg.
|
|
461
|
+
imports.wbg.__wbg_static_accessor_GLOBAL_THIS_f0a4409105898184 = function() {
|
|
441
462
|
const ret = typeof globalThis === 'undefined' ? null : globalThis;
|
|
442
463
|
return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
|
|
443
464
|
};
|
|
444
|
-
imports.wbg.
|
|
465
|
+
imports.wbg.__wbg_static_accessor_SELF_995b214ae681ff99 = function() {
|
|
445
466
|
const ret = typeof self === 'undefined' ? null : self;
|
|
446
467
|
return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
|
|
447
468
|
};
|
|
448
|
-
imports.wbg.
|
|
469
|
+
imports.wbg.__wbg_static_accessor_WINDOW_cde3890479c675ea = function() {
|
|
449
470
|
const ret = typeof window === 'undefined' ? null : window;
|
|
450
471
|
return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
|
|
451
472
|
};
|
|
452
|
-
imports.wbg.
|
|
473
|
+
imports.wbg.__wbg_value_dd9372230531eade = function(arg0) {
|
|
453
474
|
const ret = arg0.value;
|
|
454
475
|
return ret;
|
|
455
476
|
};
|
|
456
|
-
imports.wbg.
|
|
477
|
+
imports.wbg.__wbg_wbindgenbooleanget_3fe6f642c7d97746 = function(arg0) {
|
|
457
478
|
const v = arg0;
|
|
458
|
-
const ret = typeof(v) === 'boolean' ?
|
|
459
|
-
return ret;
|
|
479
|
+
const ret = typeof(v) === 'boolean' ? v : undefined;
|
|
480
|
+
return isLikeNone(ret) ? 0xFFFFFF : ret ? 1 : 0;
|
|
460
481
|
};
|
|
461
|
-
imports.wbg.
|
|
482
|
+
imports.wbg.__wbg_wbindgendebugstring_99ef257a3ddda34d = function(arg0, arg1) {
|
|
462
483
|
const ret = debugString(arg1);
|
|
463
484
|
const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
464
485
|
const len1 = WASM_VECTOR_LEN;
|
|
465
486
|
getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
|
|
466
487
|
getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
|
|
467
488
|
};
|
|
468
|
-
imports.wbg.
|
|
469
|
-
const ret = new Error(getStringFromWasm0(arg0, arg1));
|
|
470
|
-
return ret;
|
|
471
|
-
};
|
|
472
|
-
imports.wbg.__wbindgen_in = function(arg0, arg1) {
|
|
489
|
+
imports.wbg.__wbg_wbindgenin_d7a1ee10933d2d55 = function(arg0, arg1) {
|
|
473
490
|
const ret = arg0 in arg1;
|
|
474
491
|
return ret;
|
|
475
492
|
};
|
|
476
|
-
imports.wbg.
|
|
477
|
-
const table = wasm.__wbindgen_export_4;
|
|
478
|
-
const offset = table.grow(4);
|
|
479
|
-
table.set(0, undefined);
|
|
480
|
-
table.set(offset + 0, undefined);
|
|
481
|
-
table.set(offset + 1, null);
|
|
482
|
-
table.set(offset + 2, true);
|
|
483
|
-
table.set(offset + 3, false);
|
|
484
|
-
};
|
|
485
|
-
imports.wbg.__wbindgen_is_function = function(arg0) {
|
|
493
|
+
imports.wbg.__wbg_wbindgenisfunction_8cee7dce3725ae74 = function(arg0) {
|
|
486
494
|
const ret = typeof(arg0) === 'function';
|
|
487
495
|
return ret;
|
|
488
496
|
};
|
|
489
|
-
imports.wbg.
|
|
497
|
+
imports.wbg.__wbg_wbindgenisobject_307a53c6bd97fbf8 = function(arg0) {
|
|
490
498
|
const val = arg0;
|
|
491
499
|
const ret = typeof(val) === 'object' && val !== null;
|
|
492
500
|
return ret;
|
|
493
501
|
};
|
|
494
|
-
imports.wbg.
|
|
502
|
+
imports.wbg.__wbg_wbindgenisstring_d4fa939789f003b0 = function(arg0) {
|
|
495
503
|
const ret = typeof(arg0) === 'string';
|
|
496
504
|
return ret;
|
|
497
505
|
};
|
|
498
|
-
imports.wbg.
|
|
506
|
+
imports.wbg.__wbg_wbindgenisundefined_c4b71d073b92f3c5 = function(arg0) {
|
|
499
507
|
const ret = arg0 === undefined;
|
|
500
508
|
return ret;
|
|
501
509
|
};
|
|
502
|
-
imports.wbg.
|
|
510
|
+
imports.wbg.__wbg_wbindgenjsvallooseeq_9bec8c9be826bed1 = function(arg0, arg1) {
|
|
503
511
|
const ret = arg0 == arg1;
|
|
504
512
|
return ret;
|
|
505
513
|
};
|
|
506
|
-
imports.wbg.
|
|
507
|
-
const ret = wasm.memory;
|
|
508
|
-
return ret;
|
|
509
|
-
};
|
|
510
|
-
imports.wbg.__wbindgen_number_get = function(arg0, arg1) {
|
|
514
|
+
imports.wbg.__wbg_wbindgennumberget_f74b4c7525ac05cb = function(arg0, arg1) {
|
|
511
515
|
const obj = arg1;
|
|
512
516
|
const ret = typeof(obj) === 'number' ? obj : undefined;
|
|
513
517
|
getDataViewMemory0().setFloat64(arg0 + 8 * 1, isLikeNone(ret) ? 0 : ret, true);
|
|
514
518
|
getDataViewMemory0().setInt32(arg0 + 4 * 0, !isLikeNone(ret), true);
|
|
515
519
|
};
|
|
516
|
-
imports.wbg.
|
|
517
|
-
const ret = arg0;
|
|
518
|
-
return ret;
|
|
519
|
-
};
|
|
520
|
-
imports.wbg.__wbindgen_string_get = function(arg0, arg1) {
|
|
520
|
+
imports.wbg.__wbg_wbindgenstringget_0f16a6ddddef376f = function(arg0, arg1) {
|
|
521
521
|
const obj = arg1;
|
|
522
522
|
const ret = typeof(obj) === 'string' ? obj : undefined;
|
|
523
523
|
var ptr1 = isLikeNone(ret) ? 0 : passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
@@ -525,12 +525,27 @@ function __wbg_get_imports() {
|
|
|
525
525
|
getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
|
|
526
526
|
getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
|
|
527
527
|
};
|
|
528
|
-
imports.wbg.
|
|
528
|
+
imports.wbg.__wbg_wbindgenthrow_451ec1a8469d7eb6 = function(arg0, arg1) {
|
|
529
|
+
throw new Error(getStringFromWasm0(arg0, arg1));
|
|
530
|
+
};
|
|
531
|
+
imports.wbg.__wbindgen_cast_2241b6af4c4b2941 = function(arg0, arg1) {
|
|
532
|
+
// Cast intrinsic for `Ref(String) -> Externref`.
|
|
529
533
|
const ret = getStringFromWasm0(arg0, arg1);
|
|
530
534
|
return ret;
|
|
531
535
|
};
|
|
532
|
-
imports.wbg.
|
|
533
|
-
|
|
536
|
+
imports.wbg.__wbindgen_cast_d6cd19b81560fd6e = function(arg0) {
|
|
537
|
+
// Cast intrinsic for `F64 -> Externref`.
|
|
538
|
+
const ret = arg0;
|
|
539
|
+
return ret;
|
|
540
|
+
};
|
|
541
|
+
imports.wbg.__wbindgen_init_externref_table = function() {
|
|
542
|
+
const table = wasm.__wbindgen_export_4;
|
|
543
|
+
const offset = table.grow(4);
|
|
544
|
+
table.set(0, undefined);
|
|
545
|
+
table.set(offset + 0, undefined);
|
|
546
|
+
table.set(offset + 1, null);
|
|
547
|
+
table.set(offset + 2, true);
|
|
548
|
+
table.set(offset + 3, false);
|
|
534
549
|
};
|
|
535
550
|
|
|
536
551
|
return imports;
|
|
@@ -683,18 +698,26 @@ class BaseFliptClient {
|
|
|
683
698
|
entityId,
|
|
684
699
|
context
|
|
685
700
|
};
|
|
686
|
-
|
|
687
|
-
|
|
701
|
+
this.hook?.before({ flagKey });
|
|
702
|
+
const variantResult = this.engine.evaluate_variant(serialize(evaluationRequest));
|
|
703
|
+
if (variantResult === null) {
|
|
688
704
|
throw new Error('Failed to evaluate variant');
|
|
689
705
|
}
|
|
690
|
-
const variantResult = deserialize(result);
|
|
691
706
|
if (variantResult.status === 'failure') {
|
|
692
707
|
throw new Error(variantResult.errorMessage);
|
|
693
708
|
}
|
|
694
709
|
if (!variantResult.result) {
|
|
695
710
|
throw new Error('Failed to evaluate variant');
|
|
696
711
|
}
|
|
697
|
-
|
|
712
|
+
const result = deserialize(variantResult.result);
|
|
713
|
+
this.hook?.after({
|
|
714
|
+
flagKey,
|
|
715
|
+
flagType: 'variant',
|
|
716
|
+
value: result.variantKey,
|
|
717
|
+
reason: result.reason,
|
|
718
|
+
segmentKeys: result.segmentKeys
|
|
719
|
+
});
|
|
720
|
+
return result;
|
|
698
721
|
}
|
|
699
722
|
/**
|
|
700
723
|
* Evaluate a boolean flag
|
|
@@ -711,23 +734,34 @@ class BaseFliptClient {
|
|
|
711
734
|
entityId,
|
|
712
735
|
context
|
|
713
736
|
};
|
|
714
|
-
|
|
715
|
-
|
|
737
|
+
this.hook?.before({ flagKey });
|
|
738
|
+
const booleanResult = this.engine.evaluate_boolean(serialize(evaluationRequest));
|
|
739
|
+
if (booleanResult === null) {
|
|
716
740
|
throw new Error('Failed to evaluate boolean');
|
|
717
741
|
}
|
|
718
|
-
const booleanResult = deserialize(result);
|
|
719
742
|
if (booleanResult.status === 'failure') {
|
|
720
743
|
throw new Error(booleanResult.errorMessage);
|
|
721
744
|
}
|
|
722
745
|
if (!booleanResult.result) {
|
|
723
746
|
throw new Error('Failed to evaluate boolean');
|
|
724
747
|
}
|
|
725
|
-
|
|
748
|
+
const result = deserialize(booleanResult.result);
|
|
749
|
+
this.hook?.after({
|
|
750
|
+
flagKey,
|
|
751
|
+
flagType: 'boolean',
|
|
752
|
+
value: result.enabled.toString(),
|
|
753
|
+
reason: result.reason,
|
|
754
|
+
segmentKeys: result.segmentKeys
|
|
755
|
+
});
|
|
756
|
+
return result;
|
|
726
757
|
}
|
|
727
758
|
/**
|
|
728
759
|
* Evaluate a batch of flag requests
|
|
729
760
|
*/
|
|
730
761
|
evaluateBatch(requests) {
|
|
762
|
+
if (this.hook) {
|
|
763
|
+
requests.forEach((req) => this.hook?.before({ flagKey: req.flagKey }));
|
|
764
|
+
}
|
|
731
765
|
const serializedRequests = requests.map(serialize);
|
|
732
766
|
const batchResult = this.engine.evaluate_batch(serializedRequests);
|
|
733
767
|
if (batchResult === null) {
|
|
@@ -745,6 +779,13 @@ class BaseFliptClient {
|
|
|
745
779
|
const booleanResponse = deserialize(
|
|
746
780
|
// @ts-ignore
|
|
747
781
|
response.boolean_evaluation_response);
|
|
782
|
+
this.hook?.after({
|
|
783
|
+
flagKey: booleanResponse.flagKey,
|
|
784
|
+
flagType: 'boolean',
|
|
785
|
+
value: booleanResponse.enabled.toString(),
|
|
786
|
+
reason: booleanResponse.reason,
|
|
787
|
+
segmentKeys: booleanResponse.segmentKeys
|
|
788
|
+
});
|
|
748
789
|
return {
|
|
749
790
|
booleanEvaluationResponse: booleanResponse,
|
|
750
791
|
type: 'BOOLEAN_EVALUATION_RESPONSE_TYPE'
|
|
@@ -754,6 +795,13 @@ class BaseFliptClient {
|
|
|
754
795
|
const variantResponse = deserialize(
|
|
755
796
|
// @ts-ignore
|
|
756
797
|
response.variant_evaluation_response);
|
|
798
|
+
this.hook?.after({
|
|
799
|
+
flagKey: variantResponse.flagKey,
|
|
800
|
+
flagType: 'variant',
|
|
801
|
+
value: variantResponse.variantKey,
|
|
802
|
+
reason: variantResponse.reason,
|
|
803
|
+
segmentKeys: variantResponse.segmentKeys
|
|
804
|
+
});
|
|
757
805
|
return {
|
|
758
806
|
variantEvaluationResponse: variantResponse,
|
|
759
807
|
type: 'VARIANT_EVALUATION_RESPONSE_TYPE'
|
|
@@ -781,14 +829,13 @@ class BaseFliptClient {
|
|
|
781
829
|
if (listFlagsResult === null) {
|
|
782
830
|
throw new Error('Failed to list flags');
|
|
783
831
|
}
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
throw new Error(flags.errorMessage);
|
|
832
|
+
if (listFlagsResult.status === 'failure') {
|
|
833
|
+
throw new Error(listFlagsResult.errorMessage);
|
|
787
834
|
}
|
|
788
|
-
if (!
|
|
835
|
+
if (!listFlagsResult.result) {
|
|
789
836
|
throw new Error('Failed to list flags');
|
|
790
837
|
}
|
|
791
|
-
return
|
|
838
|
+
return listFlagsResult.result.map((deserialize));
|
|
792
839
|
}
|
|
793
840
|
}
|
|
794
841
|
|
|
@@ -858,6 +905,7 @@ class FliptClient extends BaseFliptClient {
|
|
|
858
905
|
const client = new FliptClient(engine, fetcher);
|
|
859
906
|
client.storeEtag(resp);
|
|
860
907
|
client.errorStrategy = options.errorStrategy;
|
|
908
|
+
client.hook = options.hook;
|
|
861
909
|
return client;
|
|
862
910
|
}
|
|
863
911
|
}
|