@flipt-io/flipt-client-js 0.2.0 → 0.4.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.
@@ -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
- const cachedTextEncoder = (typeof TextEncoder !== 'undefined' ? new TextEncoder('utf-8') : { encode: () => { throw Error('TextEncoder not available') } } );
15
+ let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
16
+
17
+ cachedTextDecoder.decode();
18
18
 
19
- const encodeString = (typeof cachedTextEncoder.encodeInto === 'function'
20
- ? function (arg, view) {
21
- return cachedTextEncoder.encodeInto(arg, view);
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));
22
29
  }
23
- : function (arg, view) {
24
- const buf = cachedTextEncoder.encode(arg);
25
- view.set(buf);
26
- return {
27
- read: arg.length,
28
- written: buf.length
30
+
31
+ function getStringFromWasm0(ptr, len) {
32
+ ptr = ptr >>> 0;
33
+ return decodeText(ptr, len);
34
+ }
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 = encodeString(arg, view);
80
+ const ret = cachedTextEncoder.encodeInto(arg, view);
62
81
 
63
82
  offset += ret.written;
64
83
  ptr = realloc(ptr, len, offset, 1) >>> 0;
@@ -77,29 +96,6 @@ function getDataViewMemory0() {
77
96
  return cachedDataViewMemory0;
78
97
  }
79
98
 
80
- function addToExternrefTable0(obj) {
81
- const idx = wasm.__externref_table_alloc();
82
- wasm.__wbindgen_export_4.set(idx, obj);
83
- return idx;
84
- }
85
-
86
- function handleError(f, args) {
87
- try {
88
- return f.apply(this, args);
89
- } catch (e) {
90
- const idx = addToExternrefTable0(e);
91
- wasm.__wbindgen_exn_store(idx);
92
- }
93
- }
94
-
95
- const cachedTextDecoder = (typeof TextDecoder !== 'undefined' ? new TextDecoder('utf-8', { ignoreBOM: true, fatal: true }) : { decode: () => { throw Error('TextDecoder not available') } } );
96
-
97
- if (typeof TextDecoder !== 'undefined') { cachedTextDecoder.decode(); }
98
- function getStringFromWasm0(ptr, len) {
99
- ptr = ptr >>> 0;
100
- return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
101
- }
102
-
103
99
  function isLikeNone(x) {
104
100
  return x === undefined || x === null;
105
101
  }
@@ -169,8 +165,28 @@ function debugString(val) {
169
165
  return className;
170
166
  }
171
167
 
168
+ function addToExternrefTable0(obj) {
169
+ const idx = wasm.__externref_table_alloc();
170
+ wasm.__wbindgen_externrefs.set(idx, obj);
171
+ return idx;
172
+ }
173
+
174
+ function handleError(f, args) {
175
+ try {
176
+ return f.apply(this, args);
177
+ } catch (e) {
178
+ const idx = addToExternrefTable0(e);
179
+ wasm.__wbindgen_exn_store(idx);
180
+ }
181
+ }
182
+
183
+ function getArrayU8FromWasm0(ptr, len) {
184
+ ptr = ptr >>> 0;
185
+ return getUint8ArrayMemory0().subarray(ptr / 1, ptr / 1 + len);
186
+ }
187
+
172
188
  function takeFromExternrefTable0(idx) {
173
- const value = wasm.__wbindgen_export_4.get(idx);
189
+ const value = wasm.__wbindgen_externrefs.get(idx);
174
190
  wasm.__externref_table_dealloc(idx);
175
191
  return value;
176
192
  }
@@ -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
- if (module.headers.get('Content-Type') != 'application/wasm') {
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_e83987f665cf5504 = 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,69 @@ 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.__wbg_buffer_609cc3eee51ed158 = function(arg0) {
302
- const ret = arg0.buffer;
326
+ imports.wbg.__wbg___wbindgen_boolean_get_6d5a1ee65bab5f68 = function(arg0) {
327
+ const v = arg0;
328
+ const ret = typeof(v) === 'boolean' ? v : undefined;
329
+ return isLikeNone(ret) ? 0xFFFFFF : ret ? 1 : 0;
330
+ };
331
+ imports.wbg.__wbg___wbindgen_debug_string_df47ffb5e35e6763 = function(arg0, arg1) {
332
+ const ret = debugString(arg1);
333
+ const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
334
+ const len1 = WASM_VECTOR_LEN;
335
+ getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
336
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
337
+ };
338
+ imports.wbg.__wbg___wbindgen_in_bb933bd9e1b3bc0f = function(arg0, arg1) {
339
+ const ret = arg0 in arg1;
340
+ return ret;
341
+ };
342
+ imports.wbg.__wbg___wbindgen_is_function_ee8a6c5833c90377 = function(arg0) {
343
+ const ret = typeof(arg0) === 'function';
303
344
  return ret;
304
345
  };
305
- imports.wbg.__wbg_call_672a4d21634d4a24 = function() { return handleError(function (arg0, arg1) {
346
+ imports.wbg.__wbg___wbindgen_is_object_c818261d21f283a4 = function(arg0) {
347
+ const val = arg0;
348
+ const ret = typeof(val) === 'object' && val !== null;
349
+ return ret;
350
+ };
351
+ imports.wbg.__wbg___wbindgen_is_string_fbb76cb2940daafd = function(arg0) {
352
+ const ret = typeof(arg0) === 'string';
353
+ return ret;
354
+ };
355
+ imports.wbg.__wbg___wbindgen_is_undefined_2d472862bd29a478 = function(arg0) {
356
+ const ret = arg0 === undefined;
357
+ return ret;
358
+ };
359
+ imports.wbg.__wbg___wbindgen_jsval_loose_eq_b664b38a2f582147 = function(arg0, arg1) {
360
+ const ret = arg0 == arg1;
361
+ return ret;
362
+ };
363
+ imports.wbg.__wbg___wbindgen_number_get_a20bf9b85341449d = function(arg0, arg1) {
364
+ const obj = arg1;
365
+ const ret = typeof(obj) === 'number' ? obj : undefined;
366
+ getDataViewMemory0().setFloat64(arg0 + 8 * 1, isLikeNone(ret) ? 0 : ret, true);
367
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, !isLikeNone(ret), true);
368
+ };
369
+ imports.wbg.__wbg___wbindgen_string_get_e4f06c90489ad01b = function(arg0, arg1) {
370
+ const obj = arg1;
371
+ const ret = typeof(obj) === 'string' ? obj : undefined;
372
+ var ptr1 = isLikeNone(ret) ? 0 : passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
373
+ var len1 = WASM_VECTOR_LEN;
374
+ getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
375
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
376
+ };
377
+ imports.wbg.__wbg___wbindgen_throw_b855445ff6a94295 = function(arg0, arg1) {
378
+ throw new Error(getStringFromWasm0(arg0, arg1));
379
+ };
380
+ imports.wbg.__wbg_call_e762c39fa8ea36bf = function() { return handleError(function (arg0, arg1) {
306
381
  const ret = arg0.call(arg1);
307
382
  return ret;
308
383
  }, arguments) };
309
- imports.wbg.__wbg_done_769e5ede4b31c67b = function(arg0) {
384
+ imports.wbg.__wbg_done_2042aa2670fb1db1 = function(arg0) {
310
385
  const ret = arg0.done;
311
386
  return ret;
312
387
  };
313
- imports.wbg.__wbg_entries_3265d4158b33e5dc = function(arg0) {
388
+ imports.wbg.__wbg_entries_e171b586f8f6bdbf = function(arg0) {
314
389
  const ret = Object.entries(arg0);
315
390
  return ret;
316
391
  };
@@ -325,23 +400,23 @@ function __wbg_get_imports() {
325
400
  wasm.__wbindgen_free(deferred0_0, deferred0_1, 1);
326
401
  }
327
402
  };
328
- imports.wbg.__wbg_getTime_46267b1c24877e30 = function(arg0) {
403
+ imports.wbg.__wbg_getTime_14776bfb48a1bff9 = function(arg0) {
329
404
  const ret = arg0.getTime();
330
405
  return ret;
331
406
  };
332
- imports.wbg.__wbg_get_67b2ba62fc30de12 = function() { return handleError(function (arg0, arg1) {
333
- const ret = Reflect.get(arg0, arg1);
334
- return ret;
335
- }, arguments) };
336
- imports.wbg.__wbg_get_b9b93047fe3cf45b = function(arg0, arg1) {
407
+ imports.wbg.__wbg_get_7bed016f185add81 = function(arg0, arg1) {
337
408
  const ret = arg0[arg1 >>> 0];
338
409
  return ret;
339
410
  };
340
- imports.wbg.__wbg_getwithrefkey_1dc361bd10053bfe = function(arg0, arg1) {
411
+ imports.wbg.__wbg_get_efcb449f58ec27c2 = function() { return handleError(function (arg0, arg1) {
412
+ const ret = Reflect.get(arg0, arg1);
413
+ return ret;
414
+ }, arguments) };
415
+ imports.wbg.__wbg_get_with_ref_key_1dc361bd10053bfe = function(arg0, arg1) {
341
416
  const ret = arg0[arg1];
342
417
  return ret;
343
418
  };
344
- imports.wbg.__wbg_instanceof_ArrayBuffer_e14585432e3737fc = function(arg0) {
419
+ imports.wbg.__wbg_instanceof_ArrayBuffer_70beb1189ca63b38 = function(arg0) {
345
420
  let result;
346
421
  try {
347
422
  result = arg0 instanceof ArrayBuffer;
@@ -351,7 +426,7 @@ function __wbg_get_imports() {
351
426
  const ret = result;
352
427
  return ret;
353
428
  };
354
- imports.wbg.__wbg_instanceof_Uint8Array_17156bcf118086a9 = function(arg0) {
429
+ imports.wbg.__wbg_instanceof_Uint8Array_20c8e73002f7af98 = function(arg0) {
355
430
  let result;
356
431
  try {
357
432
  result = arg0 instanceof Uint8Array;
@@ -361,54 +436,54 @@ function __wbg_get_imports() {
361
436
  const ret = result;
362
437
  return ret;
363
438
  };
364
- imports.wbg.__wbg_isArray_a1eab7e0d067391b = function(arg0) {
439
+ imports.wbg.__wbg_isArray_96e0af9891d0945d = function(arg0) {
365
440
  const ret = Array.isArray(arg0);
366
441
  return ret;
367
442
  };
368
- imports.wbg.__wbg_iterator_9a24c88df860dc65 = function() {
443
+ imports.wbg.__wbg_iterator_e5822695327a3c39 = function() {
369
444
  const ret = Symbol.iterator;
370
445
  return ret;
371
446
  };
372
- imports.wbg.__wbg_length_a446193dc22c12f8 = function(arg0) {
447
+ imports.wbg.__wbg_length_69bca3cb64fc8748 = function(arg0) {
373
448
  const ret = arg0.length;
374
449
  return ret;
375
450
  };
376
- imports.wbg.__wbg_length_e2d2a49132c1b256 = function(arg0) {
451
+ imports.wbg.__wbg_length_cdd215e10d9dd507 = function(arg0) {
377
452
  const ret = arg0.length;
378
453
  return ret;
379
454
  };
380
- imports.wbg.__wbg_new0_f788a2397c7ca929 = function() {
455
+ imports.wbg.__wbg_new_0_f9740686d739025c = function() {
381
456
  const ret = new Date();
382
457
  return ret;
383
458
  };
384
- imports.wbg.__wbg_new_405e22f390576ce2 = function() {
459
+ imports.wbg.__wbg_new_1acc0b6eea89d040 = function() {
385
460
  const ret = new Object();
386
461
  return ret;
387
462
  };
388
- imports.wbg.__wbg_new_78feb108b6472713 = function() {
389
- const ret = new Array();
463
+ imports.wbg.__wbg_new_5a79be3ab53b8aa5 = function(arg0) {
464
+ const ret = new Uint8Array(arg0);
390
465
  return ret;
391
466
  };
392
467
  imports.wbg.__wbg_new_8a6f238a6ece86ea = function() {
393
468
  const ret = new Error();
394
469
  return ret;
395
470
  };
396
- imports.wbg.__wbg_new_a12002a7f91c75be = function(arg0) {
397
- const ret = new Uint8Array(arg0);
471
+ imports.wbg.__wbg_new_e17d9f43105b08be = function() {
472
+ const ret = new Array();
398
473
  return ret;
399
474
  };
400
- imports.wbg.__wbg_newnoargs_105ed471475aaf50 = function(arg0, arg1) {
475
+ imports.wbg.__wbg_new_no_args_ee98eee5275000a4 = function(arg0, arg1) {
401
476
  const ret = new Function(getStringFromWasm0(arg0, arg1));
402
477
  return ret;
403
478
  };
404
- imports.wbg.__wbg_next_25feadfc0913fea9 = function(arg0) {
405
- const ret = arg0.next;
406
- return ret;
407
- };
408
- imports.wbg.__wbg_next_6574e1a8a62d1055 = function() { return handleError(function (arg0) {
479
+ imports.wbg.__wbg_next_020810e0ae8ebcb0 = function() { return handleError(function (arg0) {
409
480
  const ret = arg0.next();
410
481
  return ret;
411
482
  }, arguments) };
483
+ imports.wbg.__wbg_next_2c826fe5dfec6b6a = function(arg0) {
484
+ const ret = arg0.next;
485
+ return ret;
486
+ };
412
487
  imports.wbg.__wbg_now_2c95c9de01293173 = function(arg0) {
413
488
  const ret = arg0.now();
414
489
  return ret;
@@ -417,14 +492,14 @@ function __wbg_get_imports() {
417
492
  const ret = arg0.performance;
418
493
  return ret;
419
494
  };
420
- imports.wbg.__wbg_set_37837023f3d740e8 = function(arg0, arg1, arg2) {
421
- arg0[arg1 >>> 0] = arg2;
495
+ imports.wbg.__wbg_prototypesetcall_2a6620b6922694b2 = function(arg0, arg1, arg2) {
496
+ Uint8Array.prototype.set.call(getArrayU8FromWasm0(arg0, arg1), arg2);
422
497
  };
423
498
  imports.wbg.__wbg_set_3f1d0b984ed272ed = function(arg0, arg1, arg2) {
424
499
  arg0[arg1] = arg2;
425
500
  };
426
- imports.wbg.__wbg_set_65595bdd868b3009 = function(arg0, arg1, arg2) {
427
- arg0.set(arg1, arg2 >>> 0);
501
+ imports.wbg.__wbg_set_c213c871859d6500 = function(arg0, arg1, arg2) {
502
+ arg0[arg1 >>> 0] = arg2;
428
503
  };
429
504
  imports.wbg.__wbg_stack_0ed75d68575b0f3c = function(arg0, arg1) {
430
505
  const ret = arg1.stack;
@@ -433,48 +508,38 @@ function __wbg_get_imports() {
433
508
  getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
434
509
  getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
435
510
  };
436
- imports.wbg.__wbg_static_accessor_GLOBAL_88a902d13a557d07 = function() {
511
+ imports.wbg.__wbg_static_accessor_GLOBAL_89e1d9ac6a1b250e = function() {
437
512
  const ret = typeof global === 'undefined' ? null : global;
438
513
  return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
439
514
  };
440
- imports.wbg.__wbg_static_accessor_GLOBAL_THIS_56578be7e9f832b0 = function() {
515
+ imports.wbg.__wbg_static_accessor_GLOBAL_THIS_8b530f326a9e48ac = function() {
441
516
  const ret = typeof globalThis === 'undefined' ? null : globalThis;
442
517
  return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
443
518
  };
444
- imports.wbg.__wbg_static_accessor_SELF_37c5d418e4bf5819 = function() {
519
+ imports.wbg.__wbg_static_accessor_SELF_6fdf4b64710cc91b = function() {
445
520
  const ret = typeof self === 'undefined' ? null : self;
446
521
  return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
447
522
  };
448
- imports.wbg.__wbg_static_accessor_WINDOW_5de37043a91a9c40 = function() {
523
+ imports.wbg.__wbg_static_accessor_WINDOW_b45bfc5a37f6cfa2 = function() {
449
524
  const ret = typeof window === 'undefined' ? null : window;
450
525
  return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
451
526
  };
452
- imports.wbg.__wbg_value_cd1ffa7b1ab794f1 = function(arg0) {
527
+ imports.wbg.__wbg_value_692627309814bb8c = function(arg0) {
453
528
  const ret = arg0.value;
454
529
  return ret;
455
530
  };
456
- imports.wbg.__wbindgen_boolean_get = function(arg0) {
457
- const v = arg0;
458
- const ret = typeof(v) === 'boolean' ? (v ? 1 : 0) : 2;
459
- return ret;
460
- };
461
- imports.wbg.__wbindgen_debug_string = function(arg0, arg1) {
462
- const ret = debugString(arg1);
463
- const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
464
- const len1 = WASM_VECTOR_LEN;
465
- getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
466
- getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
467
- };
468
- imports.wbg.__wbindgen_error_new = function(arg0, arg1) {
469
- const ret = new Error(getStringFromWasm0(arg0, arg1));
531
+ imports.wbg.__wbindgen_cast_2241b6af4c4b2941 = function(arg0, arg1) {
532
+ // Cast intrinsic for `Ref(String) -> Externref`.
533
+ const ret = getStringFromWasm0(arg0, arg1);
470
534
  return ret;
471
535
  };
472
- imports.wbg.__wbindgen_in = function(arg0, arg1) {
473
- const ret = arg0 in arg1;
536
+ imports.wbg.__wbindgen_cast_d6cd19b81560fd6e = function(arg0) {
537
+ // Cast intrinsic for `F64 -> Externref`.
538
+ const ret = arg0;
474
539
  return ret;
475
540
  };
476
541
  imports.wbg.__wbindgen_init_externref_table = function() {
477
- const table = wasm.__wbindgen_export_4;
542
+ const table = wasm.__wbindgen_externrefs;
478
543
  const offset = table.grow(4);
479
544
  table.set(0, undefined);
480
545
  table.set(offset + 0, undefined);
@@ -482,56 +547,6 @@ function __wbg_get_imports() {
482
547
  table.set(offset + 2, true);
483
548
  table.set(offset + 3, false);
484
549
  };
485
- imports.wbg.__wbindgen_is_function = function(arg0) {
486
- const ret = typeof(arg0) === 'function';
487
- return ret;
488
- };
489
- imports.wbg.__wbindgen_is_object = function(arg0) {
490
- const val = arg0;
491
- const ret = typeof(val) === 'object' && val !== null;
492
- return ret;
493
- };
494
- imports.wbg.__wbindgen_is_string = function(arg0) {
495
- const ret = typeof(arg0) === 'string';
496
- return ret;
497
- };
498
- imports.wbg.__wbindgen_is_undefined = function(arg0) {
499
- const ret = arg0 === undefined;
500
- return ret;
501
- };
502
- imports.wbg.__wbindgen_jsval_loose_eq = function(arg0, arg1) {
503
- const ret = arg0 == arg1;
504
- return ret;
505
- };
506
- imports.wbg.__wbindgen_memory = function() {
507
- const ret = wasm.memory;
508
- return ret;
509
- };
510
- imports.wbg.__wbindgen_number_get = function(arg0, arg1) {
511
- const obj = arg1;
512
- const ret = typeof(obj) === 'number' ? obj : undefined;
513
- getDataViewMemory0().setFloat64(arg0 + 8 * 1, isLikeNone(ret) ? 0 : ret, true);
514
- getDataViewMemory0().setInt32(arg0 + 4 * 0, !isLikeNone(ret), true);
515
- };
516
- imports.wbg.__wbindgen_number_new = function(arg0) {
517
- const ret = arg0;
518
- return ret;
519
- };
520
- imports.wbg.__wbindgen_string_get = function(arg0, arg1) {
521
- const obj = arg1;
522
- const ret = typeof(obj) === 'string' ? obj : undefined;
523
- var ptr1 = isLikeNone(ret) ? 0 : passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
524
- var len1 = WASM_VECTOR_LEN;
525
- getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
526
- getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
527
- };
528
- imports.wbg.__wbindgen_string_new = function(arg0, arg1) {
529
- const ret = getStringFromWasm0(arg0, arg1);
530
- return ret;
531
- };
532
- imports.wbg.__wbindgen_throw = function(arg0, arg1) {
533
- throw new Error(getStringFromWasm0(arg0, arg1));
534
- };
535
550
 
536
551
  return imports;
537
552
  }
@@ -683,18 +698,26 @@ class BaseFliptClient {
683
698
  entityId,
684
699
  context
685
700
  };
686
- const result = this.engine.evaluate_variant(serialize(evaluationRequest));
687
- if (result === null) {
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
- return deserialize(variantResult.result);
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
- const result = this.engine.evaluate_boolean(serialize(evaluationRequest));
715
- if (result === null) {
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
- return deserialize(booleanResult.result);
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
- const flags = deserialize(listFlagsResult);
785
- if (flags.status === 'failure') {
786
- throw new Error(flags.errorMessage);
832
+ if (listFlagsResult.status === 'failure') {
833
+ throw new Error(listFlagsResult.errorMessage);
787
834
  }
788
- if (!flags.result) {
835
+ if (!listFlagsResult.result) {
789
836
  throw new Error('Failed to list flags');
790
837
  }
791
- return flags.result.map((deserialize));
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
  }