@flipt-io/flipt-client-js 0.2.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/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 +2 -1
- package/dist/types/core/types.d.ts +27 -0
- package/package.json +3 -3
package/dist/slim/index.mjs
CHANGED
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
let wasm;
|
|
2
2
|
|
|
3
|
-
let WASM_VECTOR_LEN = 0;
|
|
4
|
-
|
|
5
3
|
let cachedUint8ArrayMemory0 = null;
|
|
6
4
|
|
|
7
5
|
function getUint8ArrayMemory0() {
|
|
@@ -11,20 +9,41 @@ function getUint8ArrayMemory0() {
|
|
|
11
9
|
return cachedUint8ArrayMemory0;
|
|
12
10
|
}
|
|
13
11
|
|
|
14
|
-
|
|
12
|
+
let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
|
|
13
|
+
|
|
14
|
+
cachedTextDecoder.decode();
|
|
15
|
+
|
|
16
|
+
const MAX_SAFARI_DECODE_BYTES = 2146435072;
|
|
17
|
+
let numBytesDecoded = 0;
|
|
18
|
+
function decodeText(ptr, len) {
|
|
19
|
+
numBytesDecoded += len;
|
|
20
|
+
if (numBytesDecoded >= MAX_SAFARI_DECODE_BYTES) {
|
|
21
|
+
cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
|
|
22
|
+
cachedTextDecoder.decode();
|
|
23
|
+
numBytesDecoded = len;
|
|
24
|
+
}
|
|
25
|
+
return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
|
|
26
|
+
}
|
|
15
27
|
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
return
|
|
28
|
+
function getStringFromWasm0(ptr, len) {
|
|
29
|
+
ptr = ptr >>> 0;
|
|
30
|
+
return decodeText(ptr, len);
|
|
19
31
|
}
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
32
|
+
|
|
33
|
+
let WASM_VECTOR_LEN = 0;
|
|
34
|
+
|
|
35
|
+
const cachedTextEncoder = new TextEncoder();
|
|
36
|
+
|
|
37
|
+
if (!('encodeInto' in cachedTextEncoder)) {
|
|
38
|
+
cachedTextEncoder.encodeInto = function (arg, view) {
|
|
39
|
+
const buf = cachedTextEncoder.encode(arg);
|
|
40
|
+
view.set(buf);
|
|
41
|
+
return {
|
|
42
|
+
read: arg.length,
|
|
43
|
+
written: buf.length
|
|
44
|
+
};
|
|
26
45
|
};
|
|
27
|
-
}
|
|
46
|
+
}
|
|
28
47
|
|
|
29
48
|
function passStringToWasm0(arg, malloc, realloc) {
|
|
30
49
|
|
|
@@ -55,7 +74,7 @@ function passStringToWasm0(arg, malloc, realloc) {
|
|
|
55
74
|
}
|
|
56
75
|
ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0;
|
|
57
76
|
const view = getUint8ArrayMemory0().subarray(ptr + offset, ptr + len);
|
|
58
|
-
const ret =
|
|
77
|
+
const ret = cachedTextEncoder.encodeInto(arg, view);
|
|
59
78
|
|
|
60
79
|
offset += ret.written;
|
|
61
80
|
ptr = realloc(ptr, len, offset, 1) >>> 0;
|
|
@@ -89,12 +108,9 @@ function handleError(f, args) {
|
|
|
89
108
|
}
|
|
90
109
|
}
|
|
91
110
|
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
if (typeof TextDecoder !== 'undefined') { cachedTextDecoder.decode(); }
|
|
95
|
-
function getStringFromWasm0(ptr, len) {
|
|
111
|
+
function getArrayU8FromWasm0(ptr, len) {
|
|
96
112
|
ptr = ptr >>> 0;
|
|
97
|
-
return
|
|
113
|
+
return getUint8ArrayMemory0().subarray(ptr / 1, ptr / 1 + len);
|
|
98
114
|
}
|
|
99
115
|
|
|
100
116
|
function isLikeNone(x) {
|
|
@@ -253,6 +269,9 @@ class Engine {
|
|
|
253
269
|
return takeFromExternrefTable0(ret[0]);
|
|
254
270
|
}
|
|
255
271
|
}
|
|
272
|
+
if (Symbol.dispose) Engine.prototype[Symbol.dispose] = Engine.prototype.free;
|
|
273
|
+
|
|
274
|
+
const EXPECTED_RESPONSE_TYPES = new Set(['basic', 'cors', 'default']);
|
|
256
275
|
|
|
257
276
|
async function __wbg_load(module, imports) {
|
|
258
277
|
if (typeof Response === 'function' && module instanceof Response) {
|
|
@@ -261,7 +280,9 @@ async function __wbg_load(module, imports) {
|
|
|
261
280
|
return await WebAssembly.instantiateStreaming(module, imports);
|
|
262
281
|
|
|
263
282
|
} catch (e) {
|
|
264
|
-
|
|
283
|
+
const validResponse = module.ok && EXPECTED_RESPONSE_TYPES.has(module.type);
|
|
284
|
+
|
|
285
|
+
if (validResponse && module.headers.get('Content-Type') !== 'application/wasm') {
|
|
265
286
|
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);
|
|
266
287
|
|
|
267
288
|
} else {
|
|
@@ -288,6 +309,10 @@ async function __wbg_load(module, imports) {
|
|
|
288
309
|
function __wbg_get_imports() {
|
|
289
310
|
const imports = {};
|
|
290
311
|
imports.wbg = {};
|
|
312
|
+
imports.wbg.__wbg_Error_e17e777aac105295 = function(arg0, arg1) {
|
|
313
|
+
const ret = Error(getStringFromWasm0(arg0, arg1));
|
|
314
|
+
return ret;
|
|
315
|
+
};
|
|
291
316
|
imports.wbg.__wbg_String_8f0eb39a4a4c2f66 = function(arg0, arg1) {
|
|
292
317
|
const ret = String(arg1);
|
|
293
318
|
const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
@@ -295,19 +320,15 @@ function __wbg_get_imports() {
|
|
|
295
320
|
getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
|
|
296
321
|
getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
|
|
297
322
|
};
|
|
298
|
-
imports.wbg.
|
|
299
|
-
const ret = arg0.buffer;
|
|
300
|
-
return ret;
|
|
301
|
-
};
|
|
302
|
-
imports.wbg.__wbg_call_672a4d21634d4a24 = function() { return handleError(function (arg0, arg1) {
|
|
323
|
+
imports.wbg.__wbg_call_13410aac570ffff7 = function() { return handleError(function (arg0, arg1) {
|
|
303
324
|
const ret = arg0.call(arg1);
|
|
304
325
|
return ret;
|
|
305
326
|
}, arguments) };
|
|
306
|
-
imports.wbg.
|
|
327
|
+
imports.wbg.__wbg_done_75ed0ee6dd243d9d = function(arg0) {
|
|
307
328
|
const ret = arg0.done;
|
|
308
329
|
return ret;
|
|
309
330
|
};
|
|
310
|
-
imports.wbg.
|
|
331
|
+
imports.wbg.__wbg_entries_2be2f15bd5554996 = function(arg0) {
|
|
311
332
|
const ret = Object.entries(arg0);
|
|
312
333
|
return ret;
|
|
313
334
|
};
|
|
@@ -322,23 +343,23 @@ function __wbg_get_imports() {
|
|
|
322
343
|
wasm.__wbindgen_free(deferred0_0, deferred0_1, 1);
|
|
323
344
|
}
|
|
324
345
|
};
|
|
325
|
-
imports.wbg.
|
|
346
|
+
imports.wbg.__wbg_getTime_6bb3f64e0f18f817 = function(arg0) {
|
|
326
347
|
const ret = arg0.getTime();
|
|
327
348
|
return ret;
|
|
328
349
|
};
|
|
329
|
-
imports.wbg.
|
|
330
|
-
const ret = Reflect.get(arg0, arg1);
|
|
331
|
-
return ret;
|
|
332
|
-
}, arguments) };
|
|
333
|
-
imports.wbg.__wbg_get_b9b93047fe3cf45b = function(arg0, arg1) {
|
|
350
|
+
imports.wbg.__wbg_get_0da715ceaecea5c8 = function(arg0, arg1) {
|
|
334
351
|
const ret = arg0[arg1 >>> 0];
|
|
335
352
|
return ret;
|
|
336
353
|
};
|
|
354
|
+
imports.wbg.__wbg_get_458e874b43b18b25 = function() { return handleError(function (arg0, arg1) {
|
|
355
|
+
const ret = Reflect.get(arg0, arg1);
|
|
356
|
+
return ret;
|
|
357
|
+
}, arguments) };
|
|
337
358
|
imports.wbg.__wbg_getwithrefkey_1dc361bd10053bfe = function(arg0, arg1) {
|
|
338
359
|
const ret = arg0[arg1];
|
|
339
360
|
return ret;
|
|
340
361
|
};
|
|
341
|
-
imports.wbg.
|
|
362
|
+
imports.wbg.__wbg_instanceof_ArrayBuffer_67f3012529f6a2dd = function(arg0) {
|
|
342
363
|
let result;
|
|
343
364
|
try {
|
|
344
365
|
result = arg0 instanceof ArrayBuffer;
|
|
@@ -348,7 +369,7 @@ function __wbg_get_imports() {
|
|
|
348
369
|
const ret = result;
|
|
349
370
|
return ret;
|
|
350
371
|
};
|
|
351
|
-
imports.wbg.
|
|
372
|
+
imports.wbg.__wbg_instanceof_Uint8Array_9a8378d955933db7 = function(arg0) {
|
|
352
373
|
let result;
|
|
353
374
|
try {
|
|
354
375
|
result = arg0 instanceof Uint8Array;
|
|
@@ -358,51 +379,51 @@ function __wbg_get_imports() {
|
|
|
358
379
|
const ret = result;
|
|
359
380
|
return ret;
|
|
360
381
|
};
|
|
361
|
-
imports.wbg.
|
|
382
|
+
imports.wbg.__wbg_isArray_030cce220591fb41 = function(arg0) {
|
|
362
383
|
const ret = Array.isArray(arg0);
|
|
363
384
|
return ret;
|
|
364
385
|
};
|
|
365
|
-
imports.wbg.
|
|
386
|
+
imports.wbg.__wbg_iterator_f370b34483c71a1c = function() {
|
|
366
387
|
const ret = Symbol.iterator;
|
|
367
388
|
return ret;
|
|
368
389
|
};
|
|
369
|
-
imports.wbg.
|
|
390
|
+
imports.wbg.__wbg_length_186546c51cd61acd = function(arg0) {
|
|
370
391
|
const ret = arg0.length;
|
|
371
392
|
return ret;
|
|
372
393
|
};
|
|
373
|
-
imports.wbg.
|
|
394
|
+
imports.wbg.__wbg_length_6bb7e81f9d7713e4 = function(arg0) {
|
|
374
395
|
const ret = arg0.length;
|
|
375
396
|
return ret;
|
|
376
397
|
};
|
|
377
|
-
imports.wbg.
|
|
398
|
+
imports.wbg.__wbg_new0_b0a0a38c201e6df5 = function() {
|
|
378
399
|
const ret = new Date();
|
|
379
400
|
return ret;
|
|
380
401
|
};
|
|
381
|
-
imports.wbg.
|
|
402
|
+
imports.wbg.__wbg_new_19c25a3f2fa63a02 = function() {
|
|
382
403
|
const ret = new Object();
|
|
383
404
|
return ret;
|
|
384
405
|
};
|
|
385
|
-
imports.wbg.
|
|
406
|
+
imports.wbg.__wbg_new_1f3a344cf3123716 = function() {
|
|
386
407
|
const ret = new Array();
|
|
387
408
|
return ret;
|
|
388
409
|
};
|
|
389
|
-
imports.wbg.
|
|
390
|
-
const ret = new
|
|
410
|
+
imports.wbg.__wbg_new_638ebfaedbf32a5e = function(arg0) {
|
|
411
|
+
const ret = new Uint8Array(arg0);
|
|
391
412
|
return ret;
|
|
392
413
|
};
|
|
393
|
-
imports.wbg.
|
|
394
|
-
const ret = new
|
|
414
|
+
imports.wbg.__wbg_new_8a6f238a6ece86ea = function() {
|
|
415
|
+
const ret = new Error();
|
|
395
416
|
return ret;
|
|
396
417
|
};
|
|
397
|
-
imports.wbg.
|
|
418
|
+
imports.wbg.__wbg_newnoargs_254190557c45b4ec = function(arg0, arg1) {
|
|
398
419
|
const ret = new Function(getStringFromWasm0(arg0, arg1));
|
|
399
420
|
return ret;
|
|
400
421
|
};
|
|
401
|
-
imports.wbg.
|
|
422
|
+
imports.wbg.__wbg_next_5b3530e612fde77d = function(arg0) {
|
|
402
423
|
const ret = arg0.next;
|
|
403
424
|
return ret;
|
|
404
425
|
};
|
|
405
|
-
imports.wbg.
|
|
426
|
+
imports.wbg.__wbg_next_692e82279131b03c = function() { return handleError(function (arg0) {
|
|
406
427
|
const ret = arg0.next();
|
|
407
428
|
return ret;
|
|
408
429
|
}, arguments) };
|
|
@@ -414,14 +435,14 @@ function __wbg_get_imports() {
|
|
|
414
435
|
const ret = arg0.performance;
|
|
415
436
|
return ret;
|
|
416
437
|
};
|
|
417
|
-
imports.wbg.
|
|
418
|
-
arg0
|
|
438
|
+
imports.wbg.__wbg_prototypesetcall_3d4a26c1ed734349 = function(arg0, arg1, arg2) {
|
|
439
|
+
Uint8Array.prototype.set.call(getArrayU8FromWasm0(arg0, arg1), arg2);
|
|
419
440
|
};
|
|
420
441
|
imports.wbg.__wbg_set_3f1d0b984ed272ed = function(arg0, arg1, arg2) {
|
|
421
442
|
arg0[arg1] = arg2;
|
|
422
443
|
};
|
|
423
|
-
imports.wbg.
|
|
424
|
-
arg0
|
|
444
|
+
imports.wbg.__wbg_set_90f6c0f7bd8c0415 = function(arg0, arg1, arg2) {
|
|
445
|
+
arg0[arg1 >>> 0] = arg2;
|
|
425
446
|
};
|
|
426
447
|
imports.wbg.__wbg_stack_0ed75d68575b0f3c = function(arg0, arg1) {
|
|
427
448
|
const ret = arg1.stack;
|
|
@@ -430,91 +451,70 @@ function __wbg_get_imports() {
|
|
|
430
451
|
getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
|
|
431
452
|
getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
|
|
432
453
|
};
|
|
433
|
-
imports.wbg.
|
|
454
|
+
imports.wbg.__wbg_static_accessor_GLOBAL_8921f820c2ce3f12 = function() {
|
|
434
455
|
const ret = typeof global === 'undefined' ? null : global;
|
|
435
456
|
return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
|
|
436
457
|
};
|
|
437
|
-
imports.wbg.
|
|
458
|
+
imports.wbg.__wbg_static_accessor_GLOBAL_THIS_f0a4409105898184 = function() {
|
|
438
459
|
const ret = typeof globalThis === 'undefined' ? null : globalThis;
|
|
439
460
|
return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
|
|
440
461
|
};
|
|
441
|
-
imports.wbg.
|
|
462
|
+
imports.wbg.__wbg_static_accessor_SELF_995b214ae681ff99 = function() {
|
|
442
463
|
const ret = typeof self === 'undefined' ? null : self;
|
|
443
464
|
return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
|
|
444
465
|
};
|
|
445
|
-
imports.wbg.
|
|
466
|
+
imports.wbg.__wbg_static_accessor_WINDOW_cde3890479c675ea = function() {
|
|
446
467
|
const ret = typeof window === 'undefined' ? null : window;
|
|
447
468
|
return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
|
|
448
469
|
};
|
|
449
|
-
imports.wbg.
|
|
470
|
+
imports.wbg.__wbg_value_dd9372230531eade = function(arg0) {
|
|
450
471
|
const ret = arg0.value;
|
|
451
472
|
return ret;
|
|
452
473
|
};
|
|
453
|
-
imports.wbg.
|
|
474
|
+
imports.wbg.__wbg_wbindgenbooleanget_3fe6f642c7d97746 = function(arg0) {
|
|
454
475
|
const v = arg0;
|
|
455
|
-
const ret = typeof(v) === 'boolean' ?
|
|
456
|
-
return ret;
|
|
476
|
+
const ret = typeof(v) === 'boolean' ? v : undefined;
|
|
477
|
+
return isLikeNone(ret) ? 0xFFFFFF : ret ? 1 : 0;
|
|
457
478
|
};
|
|
458
|
-
imports.wbg.
|
|
479
|
+
imports.wbg.__wbg_wbindgendebugstring_99ef257a3ddda34d = function(arg0, arg1) {
|
|
459
480
|
const ret = debugString(arg1);
|
|
460
481
|
const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
461
482
|
const len1 = WASM_VECTOR_LEN;
|
|
462
483
|
getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
|
|
463
484
|
getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
|
|
464
485
|
};
|
|
465
|
-
imports.wbg.
|
|
466
|
-
const ret = new Error(getStringFromWasm0(arg0, arg1));
|
|
467
|
-
return ret;
|
|
468
|
-
};
|
|
469
|
-
imports.wbg.__wbindgen_in = function(arg0, arg1) {
|
|
486
|
+
imports.wbg.__wbg_wbindgenin_d7a1ee10933d2d55 = function(arg0, arg1) {
|
|
470
487
|
const ret = arg0 in arg1;
|
|
471
488
|
return ret;
|
|
472
489
|
};
|
|
473
|
-
imports.wbg.
|
|
474
|
-
const table = wasm.__wbindgen_export_4;
|
|
475
|
-
const offset = table.grow(4);
|
|
476
|
-
table.set(0, undefined);
|
|
477
|
-
table.set(offset + 0, undefined);
|
|
478
|
-
table.set(offset + 1, null);
|
|
479
|
-
table.set(offset + 2, true);
|
|
480
|
-
table.set(offset + 3, false);
|
|
481
|
-
};
|
|
482
|
-
imports.wbg.__wbindgen_is_function = function(arg0) {
|
|
490
|
+
imports.wbg.__wbg_wbindgenisfunction_8cee7dce3725ae74 = function(arg0) {
|
|
483
491
|
const ret = typeof(arg0) === 'function';
|
|
484
492
|
return ret;
|
|
485
493
|
};
|
|
486
|
-
imports.wbg.
|
|
494
|
+
imports.wbg.__wbg_wbindgenisobject_307a53c6bd97fbf8 = function(arg0) {
|
|
487
495
|
const val = arg0;
|
|
488
496
|
const ret = typeof(val) === 'object' && val !== null;
|
|
489
497
|
return ret;
|
|
490
498
|
};
|
|
491
|
-
imports.wbg.
|
|
499
|
+
imports.wbg.__wbg_wbindgenisstring_d4fa939789f003b0 = function(arg0) {
|
|
492
500
|
const ret = typeof(arg0) === 'string';
|
|
493
501
|
return ret;
|
|
494
502
|
};
|
|
495
|
-
imports.wbg.
|
|
503
|
+
imports.wbg.__wbg_wbindgenisundefined_c4b71d073b92f3c5 = function(arg0) {
|
|
496
504
|
const ret = arg0 === undefined;
|
|
497
505
|
return ret;
|
|
498
506
|
};
|
|
499
|
-
imports.wbg.
|
|
507
|
+
imports.wbg.__wbg_wbindgenjsvallooseeq_9bec8c9be826bed1 = function(arg0, arg1) {
|
|
500
508
|
const ret = arg0 == arg1;
|
|
501
509
|
return ret;
|
|
502
510
|
};
|
|
503
|
-
imports.wbg.
|
|
504
|
-
const ret = wasm.memory;
|
|
505
|
-
return ret;
|
|
506
|
-
};
|
|
507
|
-
imports.wbg.__wbindgen_number_get = function(arg0, arg1) {
|
|
511
|
+
imports.wbg.__wbg_wbindgennumberget_f74b4c7525ac05cb = function(arg0, arg1) {
|
|
508
512
|
const obj = arg1;
|
|
509
513
|
const ret = typeof(obj) === 'number' ? obj : undefined;
|
|
510
514
|
getDataViewMemory0().setFloat64(arg0 + 8 * 1, isLikeNone(ret) ? 0 : ret, true);
|
|
511
515
|
getDataViewMemory0().setInt32(arg0 + 4 * 0, !isLikeNone(ret), true);
|
|
512
516
|
};
|
|
513
|
-
imports.wbg.
|
|
514
|
-
const ret = arg0;
|
|
515
|
-
return ret;
|
|
516
|
-
};
|
|
517
|
-
imports.wbg.__wbindgen_string_get = function(arg0, arg1) {
|
|
517
|
+
imports.wbg.__wbg_wbindgenstringget_0f16a6ddddef376f = function(arg0, arg1) {
|
|
518
518
|
const obj = arg1;
|
|
519
519
|
const ret = typeof(obj) === 'string' ? obj : undefined;
|
|
520
520
|
var ptr1 = isLikeNone(ret) ? 0 : passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
@@ -522,12 +522,27 @@ function __wbg_get_imports() {
|
|
|
522
522
|
getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
|
|
523
523
|
getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
|
|
524
524
|
};
|
|
525
|
-
imports.wbg.
|
|
525
|
+
imports.wbg.__wbg_wbindgenthrow_451ec1a8469d7eb6 = function(arg0, arg1) {
|
|
526
|
+
throw new Error(getStringFromWasm0(arg0, arg1));
|
|
527
|
+
};
|
|
528
|
+
imports.wbg.__wbindgen_cast_2241b6af4c4b2941 = function(arg0, arg1) {
|
|
529
|
+
// Cast intrinsic for `Ref(String) -> Externref`.
|
|
526
530
|
const ret = getStringFromWasm0(arg0, arg1);
|
|
527
531
|
return ret;
|
|
528
532
|
};
|
|
529
|
-
imports.wbg.
|
|
530
|
-
|
|
533
|
+
imports.wbg.__wbindgen_cast_d6cd19b81560fd6e = function(arg0) {
|
|
534
|
+
// Cast intrinsic for `F64 -> Externref`.
|
|
535
|
+
const ret = arg0;
|
|
536
|
+
return ret;
|
|
537
|
+
};
|
|
538
|
+
imports.wbg.__wbindgen_init_externref_table = function() {
|
|
539
|
+
const table = wasm.__wbindgen_export_4;
|
|
540
|
+
const offset = table.grow(4);
|
|
541
|
+
table.set(0, undefined);
|
|
542
|
+
table.set(offset + 0, undefined);
|
|
543
|
+
table.set(offset + 1, null);
|
|
544
|
+
table.set(offset + 2, true);
|
|
545
|
+
table.set(offset + 3, false);
|
|
531
546
|
};
|
|
532
547
|
|
|
533
548
|
return imports;
|
|
@@ -680,18 +695,26 @@ class BaseFliptClient {
|
|
|
680
695
|
entityId,
|
|
681
696
|
context
|
|
682
697
|
};
|
|
683
|
-
|
|
684
|
-
|
|
698
|
+
this.hook?.before({ flagKey });
|
|
699
|
+
const variantResult = this.engine.evaluate_variant(serialize(evaluationRequest));
|
|
700
|
+
if (variantResult === null) {
|
|
685
701
|
throw new Error('Failed to evaluate variant');
|
|
686
702
|
}
|
|
687
|
-
const variantResult = deserialize(result);
|
|
688
703
|
if (variantResult.status === 'failure') {
|
|
689
704
|
throw new Error(variantResult.errorMessage);
|
|
690
705
|
}
|
|
691
706
|
if (!variantResult.result) {
|
|
692
707
|
throw new Error('Failed to evaluate variant');
|
|
693
708
|
}
|
|
694
|
-
|
|
709
|
+
const result = deserialize(variantResult.result);
|
|
710
|
+
this.hook?.after({
|
|
711
|
+
flagKey,
|
|
712
|
+
flagType: 'variant',
|
|
713
|
+
value: result.variantKey,
|
|
714
|
+
reason: result.reason,
|
|
715
|
+
segmentKeys: result.segmentKeys
|
|
716
|
+
});
|
|
717
|
+
return result;
|
|
695
718
|
}
|
|
696
719
|
/**
|
|
697
720
|
* Evaluate a boolean flag
|
|
@@ -708,23 +731,34 @@ class BaseFliptClient {
|
|
|
708
731
|
entityId,
|
|
709
732
|
context
|
|
710
733
|
};
|
|
711
|
-
|
|
712
|
-
|
|
734
|
+
this.hook?.before({ flagKey });
|
|
735
|
+
const booleanResult = this.engine.evaluate_boolean(serialize(evaluationRequest));
|
|
736
|
+
if (booleanResult === null) {
|
|
713
737
|
throw new Error('Failed to evaluate boolean');
|
|
714
738
|
}
|
|
715
|
-
const booleanResult = deserialize(result);
|
|
716
739
|
if (booleanResult.status === 'failure') {
|
|
717
740
|
throw new Error(booleanResult.errorMessage);
|
|
718
741
|
}
|
|
719
742
|
if (!booleanResult.result) {
|
|
720
743
|
throw new Error('Failed to evaluate boolean');
|
|
721
744
|
}
|
|
722
|
-
|
|
745
|
+
const result = deserialize(booleanResult.result);
|
|
746
|
+
this.hook?.after({
|
|
747
|
+
flagKey,
|
|
748
|
+
flagType: 'boolean',
|
|
749
|
+
value: result.enabled.toString(),
|
|
750
|
+
reason: result.reason,
|
|
751
|
+
segmentKeys: result.segmentKeys
|
|
752
|
+
});
|
|
753
|
+
return result;
|
|
723
754
|
}
|
|
724
755
|
/**
|
|
725
756
|
* Evaluate a batch of flag requests
|
|
726
757
|
*/
|
|
727
758
|
evaluateBatch(requests) {
|
|
759
|
+
if (this.hook) {
|
|
760
|
+
requests.forEach((req) => this.hook?.before({ flagKey: req.flagKey }));
|
|
761
|
+
}
|
|
728
762
|
const serializedRequests = requests.map(serialize);
|
|
729
763
|
const batchResult = this.engine.evaluate_batch(serializedRequests);
|
|
730
764
|
if (batchResult === null) {
|
|
@@ -742,6 +776,13 @@ class BaseFliptClient {
|
|
|
742
776
|
const booleanResponse = deserialize(
|
|
743
777
|
// @ts-ignore
|
|
744
778
|
response.boolean_evaluation_response);
|
|
779
|
+
this.hook?.after({
|
|
780
|
+
flagKey: booleanResponse.flagKey,
|
|
781
|
+
flagType: 'boolean',
|
|
782
|
+
value: booleanResponse.enabled.toString(),
|
|
783
|
+
reason: booleanResponse.reason,
|
|
784
|
+
segmentKeys: booleanResponse.segmentKeys
|
|
785
|
+
});
|
|
745
786
|
return {
|
|
746
787
|
booleanEvaluationResponse: booleanResponse,
|
|
747
788
|
type: 'BOOLEAN_EVALUATION_RESPONSE_TYPE'
|
|
@@ -751,6 +792,13 @@ class BaseFliptClient {
|
|
|
751
792
|
const variantResponse = deserialize(
|
|
752
793
|
// @ts-ignore
|
|
753
794
|
response.variant_evaluation_response);
|
|
795
|
+
this.hook?.after({
|
|
796
|
+
flagKey: variantResponse.flagKey,
|
|
797
|
+
flagType: 'variant',
|
|
798
|
+
value: variantResponse.variantKey,
|
|
799
|
+
reason: variantResponse.reason,
|
|
800
|
+
segmentKeys: variantResponse.segmentKeys
|
|
801
|
+
});
|
|
754
802
|
return {
|
|
755
803
|
variantEvaluationResponse: variantResponse,
|
|
756
804
|
type: 'VARIANT_EVALUATION_RESPONSE_TYPE'
|
|
@@ -778,14 +826,13 @@ class BaseFliptClient {
|
|
|
778
826
|
if (listFlagsResult === null) {
|
|
779
827
|
throw new Error('Failed to list flags');
|
|
780
828
|
}
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
throw new Error(flags.errorMessage);
|
|
829
|
+
if (listFlagsResult.status === 'failure') {
|
|
830
|
+
throw new Error(listFlagsResult.errorMessage);
|
|
784
831
|
}
|
|
785
|
-
if (!
|
|
832
|
+
if (!listFlagsResult.result) {
|
|
786
833
|
throw new Error('Failed to list flags');
|
|
787
834
|
}
|
|
788
|
-
return
|
|
835
|
+
return listFlagsResult.result.map((deserialize));
|
|
789
836
|
}
|
|
790
837
|
}
|
|
791
838
|
|
|
@@ -855,6 +902,7 @@ class FliptClient extends BaseFliptClient {
|
|
|
855
902
|
const client = new FliptClient(engine, fetcher);
|
|
856
903
|
client.storeEtag(resp);
|
|
857
904
|
client.errorStrategy = options.errorStrategy;
|
|
905
|
+
client.hook = options.hook;
|
|
858
906
|
return client;
|
|
859
907
|
}
|
|
860
908
|
}
|
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
import { BatchEvaluationResponse, BooleanEvaluationResponse, EvaluationRequest, Flag, IFetcher, VariantEvaluationResponse, ErrorStrategy, Response } from './types';
|
|
1
|
+
import { BatchEvaluationResponse, BooleanEvaluationResponse, EvaluationRequest, Flag, IFetcher, VariantEvaluationResponse, ErrorStrategy, Response, Hook } from './types';
|
|
2
2
|
export type FliptClient = BaseFliptClient;
|
|
3
3
|
export declare abstract class BaseFliptClient {
|
|
4
4
|
protected engine: any;
|
|
5
5
|
protected fetcher: IFetcher;
|
|
6
6
|
protected etag?: string;
|
|
7
7
|
protected errorStrategy?: ErrorStrategy;
|
|
8
|
+
protected hook?: Hook;
|
|
8
9
|
constructor(engine: any, fetcher: IFetcher);
|
|
9
10
|
/**
|
|
10
11
|
* Store etag from response for next requests
|
|
@@ -126,6 +126,10 @@ export interface ClientOptions {
|
|
|
126
126
|
* The strategy to use for errors during refresh snapshot calls. {@link ErrorStrategy}
|
|
127
127
|
*/
|
|
128
128
|
errorStrategy?: ErrorStrategy;
|
|
129
|
+
/**
|
|
130
|
+
* The hook to use for before and after evaluation calls.
|
|
131
|
+
*/
|
|
132
|
+
hook?: Hook;
|
|
129
133
|
}
|
|
130
134
|
/**
|
|
131
135
|
* Represents a request to evaluate a feature flag.
|
|
@@ -210,6 +214,8 @@ export interface BooleanEvaluationResponse {
|
|
|
210
214
|
requestDurationMillis: number;
|
|
211
215
|
/** Timestamp when the response was generated. */
|
|
212
216
|
timestamp: string;
|
|
217
|
+
/** Segments that impacted evaluation. */
|
|
218
|
+
segmentKeys: string[];
|
|
213
219
|
}
|
|
214
220
|
/**
|
|
215
221
|
* Represents the response returned when an error occurs during the evaluation of a feature flag.
|
|
@@ -266,3 +272,24 @@ export declare class ClientOptionsFactory {
|
|
|
266
272
|
*/
|
|
267
273
|
static default(): ClientOptions;
|
|
268
274
|
}
|
|
275
|
+
/**
|
|
276
|
+
* Hook interface for before and after evaluation calls.
|
|
277
|
+
*/
|
|
278
|
+
export interface Hook {
|
|
279
|
+
/**
|
|
280
|
+
* before is called before evaluation.
|
|
281
|
+
*/
|
|
282
|
+
before(data: {
|
|
283
|
+
flagKey: string;
|
|
284
|
+
}): void;
|
|
285
|
+
/**
|
|
286
|
+
* after is called after successful evaluation.
|
|
287
|
+
*/
|
|
288
|
+
after(data: {
|
|
289
|
+
flagKey: string;
|
|
290
|
+
flagType: string;
|
|
291
|
+
value: string;
|
|
292
|
+
reason: string;
|
|
293
|
+
segmentKeys: string[];
|
|
294
|
+
}): void;
|
|
295
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@flipt-io/flipt-client-js",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.0",
|
|
4
4
|
"description": "Flipt Client Evaluation SDK for Web and Node.js",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/node/index.cjs",
|
|
@@ -82,14 +82,14 @@
|
|
|
82
82
|
"@eslint/js": "^9.28.0",
|
|
83
83
|
"@rollup/plugin-typescript": "^12.1.0",
|
|
84
84
|
"@rollup/plugin-wasm": "^6.2.2",
|
|
85
|
-
"@types/jest": "^
|
|
85
|
+
"@types/jest": "^30.0.0",
|
|
86
86
|
"@types/node": "^24.0.3",
|
|
87
87
|
"@types/node-fetch": "^2.6.11",
|
|
88
88
|
"@typescript-eslint/eslint-plugin": "^8.33.1",
|
|
89
89
|
"@typescript-eslint/parser": "^8.33.1",
|
|
90
90
|
"eslint": "^9.28.0",
|
|
91
91
|
"globals": "^16.2.0",
|
|
92
|
-
"jest": "^
|
|
92
|
+
"jest": "^30.0.3",
|
|
93
93
|
"node-fetch": "^3.3.0",
|
|
94
94
|
"prettier": "^3.1.0",
|
|
95
95
|
"rimraf": "^6.0.1",
|