@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.
- package/README.md +69 -0
- package/dist/browser/index.cjs +207 -159
- package/dist/browser/index.mjs +207 -159
- package/dist/flipt_engine_wasm_js_bg.wasm +0 -0
- package/dist/node/index.cjs +207 -159
- package/dist/node/index.mjs +207 -159
- package/dist/slim/index.cjs +206 -158
- package/dist/slim/index.mjs +206 -158
- package/dist/types/core/base.d.ts +2 -1
- package/dist/types/core/types.d.ts +27 -0
- package/dist/types/index.d.ts +2 -0
- package/dist/types/types.d.ts +10 -0
- package/package.json +11 -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
15
|
|
|
16
|
-
const
|
|
17
|
-
|
|
18
|
-
|
|
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));
|
|
19
26
|
}
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
return
|
|
24
|
-
|
|
25
|
-
|
|
27
|
+
|
|
28
|
+
function getStringFromWasm0(ptr, len) {
|
|
29
|
+
ptr = ptr >>> 0;
|
|
30
|
+
return decodeText(ptr, len);
|
|
31
|
+
}
|
|
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;
|
|
@@ -74,29 +93,6 @@ function getDataViewMemory0() {
|
|
|
74
93
|
return cachedDataViewMemory0;
|
|
75
94
|
}
|
|
76
95
|
|
|
77
|
-
function addToExternrefTable0(obj) {
|
|
78
|
-
const idx = wasm.__externref_table_alloc();
|
|
79
|
-
wasm.__wbindgen_export_4.set(idx, obj);
|
|
80
|
-
return idx;
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
function handleError(f, args) {
|
|
84
|
-
try {
|
|
85
|
-
return f.apply(this, args);
|
|
86
|
-
} catch (e) {
|
|
87
|
-
const idx = addToExternrefTable0(e);
|
|
88
|
-
wasm.__wbindgen_exn_store(idx);
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
const cachedTextDecoder = (typeof TextDecoder !== 'undefined' ? new TextDecoder('utf-8', { ignoreBOM: true, fatal: true }) : { decode: () => { throw Error('TextDecoder not available') } } );
|
|
93
|
-
|
|
94
|
-
if (typeof TextDecoder !== 'undefined') { cachedTextDecoder.decode(); }
|
|
95
|
-
function getStringFromWasm0(ptr, len) {
|
|
96
|
-
ptr = ptr >>> 0;
|
|
97
|
-
return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
|
|
98
|
-
}
|
|
99
|
-
|
|
100
96
|
function isLikeNone(x) {
|
|
101
97
|
return x === undefined || x === null;
|
|
102
98
|
}
|
|
@@ -166,8 +162,28 @@ function debugString(val) {
|
|
|
166
162
|
return className;
|
|
167
163
|
}
|
|
168
164
|
|
|
165
|
+
function addToExternrefTable0(obj) {
|
|
166
|
+
const idx = wasm.__externref_table_alloc();
|
|
167
|
+
wasm.__wbindgen_externrefs.set(idx, obj);
|
|
168
|
+
return idx;
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
function handleError(f, args) {
|
|
172
|
+
try {
|
|
173
|
+
return f.apply(this, args);
|
|
174
|
+
} catch (e) {
|
|
175
|
+
const idx = addToExternrefTable0(e);
|
|
176
|
+
wasm.__wbindgen_exn_store(idx);
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
function getArrayU8FromWasm0(ptr, len) {
|
|
181
|
+
ptr = ptr >>> 0;
|
|
182
|
+
return getUint8ArrayMemory0().subarray(ptr / 1, ptr / 1 + len);
|
|
183
|
+
}
|
|
184
|
+
|
|
169
185
|
function takeFromExternrefTable0(idx) {
|
|
170
|
-
const value = wasm.
|
|
186
|
+
const value = wasm.__wbindgen_externrefs.get(idx);
|
|
171
187
|
wasm.__externref_table_dealloc(idx);
|
|
172
188
|
return value;
|
|
173
189
|
}
|
|
@@ -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_e83987f665cf5504 = 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,69 @@ 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
|
|
323
|
+
imports.wbg.__wbg___wbindgen_boolean_get_6d5a1ee65bab5f68 = function(arg0) {
|
|
324
|
+
const v = arg0;
|
|
325
|
+
const ret = typeof(v) === 'boolean' ? v : undefined;
|
|
326
|
+
return isLikeNone(ret) ? 0xFFFFFF : ret ? 1 : 0;
|
|
327
|
+
};
|
|
328
|
+
imports.wbg.__wbg___wbindgen_debug_string_df47ffb5e35e6763 = function(arg0, arg1) {
|
|
329
|
+
const ret = debugString(arg1);
|
|
330
|
+
const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
331
|
+
const len1 = WASM_VECTOR_LEN;
|
|
332
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
|
|
333
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
|
|
334
|
+
};
|
|
335
|
+
imports.wbg.__wbg___wbindgen_in_bb933bd9e1b3bc0f = function(arg0, arg1) {
|
|
336
|
+
const ret = arg0 in arg1;
|
|
337
|
+
return ret;
|
|
338
|
+
};
|
|
339
|
+
imports.wbg.__wbg___wbindgen_is_function_ee8a6c5833c90377 = function(arg0) {
|
|
340
|
+
const ret = typeof(arg0) === 'function';
|
|
300
341
|
return ret;
|
|
301
342
|
};
|
|
302
|
-
imports.wbg.
|
|
343
|
+
imports.wbg.__wbg___wbindgen_is_object_c818261d21f283a4 = function(arg0) {
|
|
344
|
+
const val = arg0;
|
|
345
|
+
const ret = typeof(val) === 'object' && val !== null;
|
|
346
|
+
return ret;
|
|
347
|
+
};
|
|
348
|
+
imports.wbg.__wbg___wbindgen_is_string_fbb76cb2940daafd = function(arg0) {
|
|
349
|
+
const ret = typeof(arg0) === 'string';
|
|
350
|
+
return ret;
|
|
351
|
+
};
|
|
352
|
+
imports.wbg.__wbg___wbindgen_is_undefined_2d472862bd29a478 = function(arg0) {
|
|
353
|
+
const ret = arg0 === undefined;
|
|
354
|
+
return ret;
|
|
355
|
+
};
|
|
356
|
+
imports.wbg.__wbg___wbindgen_jsval_loose_eq_b664b38a2f582147 = function(arg0, arg1) {
|
|
357
|
+
const ret = arg0 == arg1;
|
|
358
|
+
return ret;
|
|
359
|
+
};
|
|
360
|
+
imports.wbg.__wbg___wbindgen_number_get_a20bf9b85341449d = function(arg0, arg1) {
|
|
361
|
+
const obj = arg1;
|
|
362
|
+
const ret = typeof(obj) === 'number' ? obj : undefined;
|
|
363
|
+
getDataViewMemory0().setFloat64(arg0 + 8 * 1, isLikeNone(ret) ? 0 : ret, true);
|
|
364
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 0, !isLikeNone(ret), true);
|
|
365
|
+
};
|
|
366
|
+
imports.wbg.__wbg___wbindgen_string_get_e4f06c90489ad01b = function(arg0, arg1) {
|
|
367
|
+
const obj = arg1;
|
|
368
|
+
const ret = typeof(obj) === 'string' ? obj : undefined;
|
|
369
|
+
var ptr1 = isLikeNone(ret) ? 0 : passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
370
|
+
var len1 = WASM_VECTOR_LEN;
|
|
371
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
|
|
372
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
|
|
373
|
+
};
|
|
374
|
+
imports.wbg.__wbg___wbindgen_throw_b855445ff6a94295 = function(arg0, arg1) {
|
|
375
|
+
throw new Error(getStringFromWasm0(arg0, arg1));
|
|
376
|
+
};
|
|
377
|
+
imports.wbg.__wbg_call_e762c39fa8ea36bf = function() { return handleError(function (arg0, arg1) {
|
|
303
378
|
const ret = arg0.call(arg1);
|
|
304
379
|
return ret;
|
|
305
380
|
}, arguments) };
|
|
306
|
-
imports.wbg.
|
|
381
|
+
imports.wbg.__wbg_done_2042aa2670fb1db1 = function(arg0) {
|
|
307
382
|
const ret = arg0.done;
|
|
308
383
|
return ret;
|
|
309
384
|
};
|
|
310
|
-
imports.wbg.
|
|
385
|
+
imports.wbg.__wbg_entries_e171b586f8f6bdbf = function(arg0) {
|
|
311
386
|
const ret = Object.entries(arg0);
|
|
312
387
|
return ret;
|
|
313
388
|
};
|
|
@@ -322,23 +397,23 @@ function __wbg_get_imports() {
|
|
|
322
397
|
wasm.__wbindgen_free(deferred0_0, deferred0_1, 1);
|
|
323
398
|
}
|
|
324
399
|
};
|
|
325
|
-
imports.wbg.
|
|
400
|
+
imports.wbg.__wbg_getTime_14776bfb48a1bff9 = function(arg0) {
|
|
326
401
|
const ret = arg0.getTime();
|
|
327
402
|
return ret;
|
|
328
403
|
};
|
|
329
|
-
imports.wbg.
|
|
330
|
-
const ret = Reflect.get(arg0, arg1);
|
|
331
|
-
return ret;
|
|
332
|
-
}, arguments) };
|
|
333
|
-
imports.wbg.__wbg_get_b9b93047fe3cf45b = function(arg0, arg1) {
|
|
404
|
+
imports.wbg.__wbg_get_7bed016f185add81 = function(arg0, arg1) {
|
|
334
405
|
const ret = arg0[arg1 >>> 0];
|
|
335
406
|
return ret;
|
|
336
407
|
};
|
|
337
|
-
imports.wbg.
|
|
408
|
+
imports.wbg.__wbg_get_efcb449f58ec27c2 = function() { return handleError(function (arg0, arg1) {
|
|
409
|
+
const ret = Reflect.get(arg0, arg1);
|
|
410
|
+
return ret;
|
|
411
|
+
}, arguments) };
|
|
412
|
+
imports.wbg.__wbg_get_with_ref_key_1dc361bd10053bfe = function(arg0, arg1) {
|
|
338
413
|
const ret = arg0[arg1];
|
|
339
414
|
return ret;
|
|
340
415
|
};
|
|
341
|
-
imports.wbg.
|
|
416
|
+
imports.wbg.__wbg_instanceof_ArrayBuffer_70beb1189ca63b38 = function(arg0) {
|
|
342
417
|
let result;
|
|
343
418
|
try {
|
|
344
419
|
result = arg0 instanceof ArrayBuffer;
|
|
@@ -348,7 +423,7 @@ function __wbg_get_imports() {
|
|
|
348
423
|
const ret = result;
|
|
349
424
|
return ret;
|
|
350
425
|
};
|
|
351
|
-
imports.wbg.
|
|
426
|
+
imports.wbg.__wbg_instanceof_Uint8Array_20c8e73002f7af98 = function(arg0) {
|
|
352
427
|
let result;
|
|
353
428
|
try {
|
|
354
429
|
result = arg0 instanceof Uint8Array;
|
|
@@ -358,54 +433,54 @@ function __wbg_get_imports() {
|
|
|
358
433
|
const ret = result;
|
|
359
434
|
return ret;
|
|
360
435
|
};
|
|
361
|
-
imports.wbg.
|
|
436
|
+
imports.wbg.__wbg_isArray_96e0af9891d0945d = function(arg0) {
|
|
362
437
|
const ret = Array.isArray(arg0);
|
|
363
438
|
return ret;
|
|
364
439
|
};
|
|
365
|
-
imports.wbg.
|
|
440
|
+
imports.wbg.__wbg_iterator_e5822695327a3c39 = function() {
|
|
366
441
|
const ret = Symbol.iterator;
|
|
367
442
|
return ret;
|
|
368
443
|
};
|
|
369
|
-
imports.wbg.
|
|
444
|
+
imports.wbg.__wbg_length_69bca3cb64fc8748 = function(arg0) {
|
|
370
445
|
const ret = arg0.length;
|
|
371
446
|
return ret;
|
|
372
447
|
};
|
|
373
|
-
imports.wbg.
|
|
448
|
+
imports.wbg.__wbg_length_cdd215e10d9dd507 = function(arg0) {
|
|
374
449
|
const ret = arg0.length;
|
|
375
450
|
return ret;
|
|
376
451
|
};
|
|
377
|
-
imports.wbg.
|
|
452
|
+
imports.wbg.__wbg_new_0_f9740686d739025c = function() {
|
|
378
453
|
const ret = new Date();
|
|
379
454
|
return ret;
|
|
380
455
|
};
|
|
381
|
-
imports.wbg.
|
|
456
|
+
imports.wbg.__wbg_new_1acc0b6eea89d040 = function() {
|
|
382
457
|
const ret = new Object();
|
|
383
458
|
return ret;
|
|
384
459
|
};
|
|
385
|
-
imports.wbg.
|
|
386
|
-
const ret = new
|
|
460
|
+
imports.wbg.__wbg_new_5a79be3ab53b8aa5 = function(arg0) {
|
|
461
|
+
const ret = new Uint8Array(arg0);
|
|
387
462
|
return ret;
|
|
388
463
|
};
|
|
389
464
|
imports.wbg.__wbg_new_8a6f238a6ece86ea = function() {
|
|
390
465
|
const ret = new Error();
|
|
391
466
|
return ret;
|
|
392
467
|
};
|
|
393
|
-
imports.wbg.
|
|
394
|
-
const ret = new
|
|
468
|
+
imports.wbg.__wbg_new_e17d9f43105b08be = function() {
|
|
469
|
+
const ret = new Array();
|
|
395
470
|
return ret;
|
|
396
471
|
};
|
|
397
|
-
imports.wbg.
|
|
472
|
+
imports.wbg.__wbg_new_no_args_ee98eee5275000a4 = function(arg0, arg1) {
|
|
398
473
|
const ret = new Function(getStringFromWasm0(arg0, arg1));
|
|
399
474
|
return ret;
|
|
400
475
|
};
|
|
401
|
-
imports.wbg.
|
|
402
|
-
const ret = arg0.next;
|
|
403
|
-
return ret;
|
|
404
|
-
};
|
|
405
|
-
imports.wbg.__wbg_next_6574e1a8a62d1055 = function() { return handleError(function (arg0) {
|
|
476
|
+
imports.wbg.__wbg_next_020810e0ae8ebcb0 = function() { return handleError(function (arg0) {
|
|
406
477
|
const ret = arg0.next();
|
|
407
478
|
return ret;
|
|
408
479
|
}, arguments) };
|
|
480
|
+
imports.wbg.__wbg_next_2c826fe5dfec6b6a = function(arg0) {
|
|
481
|
+
const ret = arg0.next;
|
|
482
|
+
return ret;
|
|
483
|
+
};
|
|
409
484
|
imports.wbg.__wbg_now_2c95c9de01293173 = function(arg0) {
|
|
410
485
|
const ret = arg0.now();
|
|
411
486
|
return ret;
|
|
@@ -414,14 +489,14 @@ function __wbg_get_imports() {
|
|
|
414
489
|
const ret = arg0.performance;
|
|
415
490
|
return ret;
|
|
416
491
|
};
|
|
417
|
-
imports.wbg.
|
|
418
|
-
arg0
|
|
492
|
+
imports.wbg.__wbg_prototypesetcall_2a6620b6922694b2 = function(arg0, arg1, arg2) {
|
|
493
|
+
Uint8Array.prototype.set.call(getArrayU8FromWasm0(arg0, arg1), arg2);
|
|
419
494
|
};
|
|
420
495
|
imports.wbg.__wbg_set_3f1d0b984ed272ed = function(arg0, arg1, arg2) {
|
|
421
496
|
arg0[arg1] = arg2;
|
|
422
497
|
};
|
|
423
|
-
imports.wbg.
|
|
424
|
-
arg0
|
|
498
|
+
imports.wbg.__wbg_set_c213c871859d6500 = function(arg0, arg1, arg2) {
|
|
499
|
+
arg0[arg1 >>> 0] = arg2;
|
|
425
500
|
};
|
|
426
501
|
imports.wbg.__wbg_stack_0ed75d68575b0f3c = function(arg0, arg1) {
|
|
427
502
|
const ret = arg1.stack;
|
|
@@ -430,48 +505,38 @@ function __wbg_get_imports() {
|
|
|
430
505
|
getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
|
|
431
506
|
getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
|
|
432
507
|
};
|
|
433
|
-
imports.wbg.
|
|
508
|
+
imports.wbg.__wbg_static_accessor_GLOBAL_89e1d9ac6a1b250e = function() {
|
|
434
509
|
const ret = typeof global === 'undefined' ? null : global;
|
|
435
510
|
return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
|
|
436
511
|
};
|
|
437
|
-
imports.wbg.
|
|
512
|
+
imports.wbg.__wbg_static_accessor_GLOBAL_THIS_8b530f326a9e48ac = function() {
|
|
438
513
|
const ret = typeof globalThis === 'undefined' ? null : globalThis;
|
|
439
514
|
return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
|
|
440
515
|
};
|
|
441
|
-
imports.wbg.
|
|
516
|
+
imports.wbg.__wbg_static_accessor_SELF_6fdf4b64710cc91b = function() {
|
|
442
517
|
const ret = typeof self === 'undefined' ? null : self;
|
|
443
518
|
return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
|
|
444
519
|
};
|
|
445
|
-
imports.wbg.
|
|
520
|
+
imports.wbg.__wbg_static_accessor_WINDOW_b45bfc5a37f6cfa2 = function() {
|
|
446
521
|
const ret = typeof window === 'undefined' ? null : window;
|
|
447
522
|
return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
|
|
448
523
|
};
|
|
449
|
-
imports.wbg.
|
|
524
|
+
imports.wbg.__wbg_value_692627309814bb8c = function(arg0) {
|
|
450
525
|
const ret = arg0.value;
|
|
451
526
|
return ret;
|
|
452
527
|
};
|
|
453
|
-
imports.wbg.
|
|
454
|
-
|
|
455
|
-
const ret =
|
|
456
|
-
return ret;
|
|
457
|
-
};
|
|
458
|
-
imports.wbg.__wbindgen_debug_string = function(arg0, arg1) {
|
|
459
|
-
const ret = debugString(arg1);
|
|
460
|
-
const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
461
|
-
const len1 = WASM_VECTOR_LEN;
|
|
462
|
-
getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
|
|
463
|
-
getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
|
|
464
|
-
};
|
|
465
|
-
imports.wbg.__wbindgen_error_new = function(arg0, arg1) {
|
|
466
|
-
const ret = new Error(getStringFromWasm0(arg0, arg1));
|
|
528
|
+
imports.wbg.__wbindgen_cast_2241b6af4c4b2941 = function(arg0, arg1) {
|
|
529
|
+
// Cast intrinsic for `Ref(String) -> Externref`.
|
|
530
|
+
const ret = getStringFromWasm0(arg0, arg1);
|
|
467
531
|
return ret;
|
|
468
532
|
};
|
|
469
|
-
imports.wbg.
|
|
470
|
-
|
|
533
|
+
imports.wbg.__wbindgen_cast_d6cd19b81560fd6e = function(arg0) {
|
|
534
|
+
// Cast intrinsic for `F64 -> Externref`.
|
|
535
|
+
const ret = arg0;
|
|
471
536
|
return ret;
|
|
472
537
|
};
|
|
473
538
|
imports.wbg.__wbindgen_init_externref_table = function() {
|
|
474
|
-
const table = wasm.
|
|
539
|
+
const table = wasm.__wbindgen_externrefs;
|
|
475
540
|
const offset = table.grow(4);
|
|
476
541
|
table.set(0, undefined);
|
|
477
542
|
table.set(offset + 0, undefined);
|
|
@@ -479,56 +544,6 @@ function __wbg_get_imports() {
|
|
|
479
544
|
table.set(offset + 2, true);
|
|
480
545
|
table.set(offset + 3, false);
|
|
481
546
|
};
|
|
482
|
-
imports.wbg.__wbindgen_is_function = function(arg0) {
|
|
483
|
-
const ret = typeof(arg0) === 'function';
|
|
484
|
-
return ret;
|
|
485
|
-
};
|
|
486
|
-
imports.wbg.__wbindgen_is_object = function(arg0) {
|
|
487
|
-
const val = arg0;
|
|
488
|
-
const ret = typeof(val) === 'object' && val !== null;
|
|
489
|
-
return ret;
|
|
490
|
-
};
|
|
491
|
-
imports.wbg.__wbindgen_is_string = function(arg0) {
|
|
492
|
-
const ret = typeof(arg0) === 'string';
|
|
493
|
-
return ret;
|
|
494
|
-
};
|
|
495
|
-
imports.wbg.__wbindgen_is_undefined = function(arg0) {
|
|
496
|
-
const ret = arg0 === undefined;
|
|
497
|
-
return ret;
|
|
498
|
-
};
|
|
499
|
-
imports.wbg.__wbindgen_jsval_loose_eq = function(arg0, arg1) {
|
|
500
|
-
const ret = arg0 == arg1;
|
|
501
|
-
return ret;
|
|
502
|
-
};
|
|
503
|
-
imports.wbg.__wbindgen_memory = function() {
|
|
504
|
-
const ret = wasm.memory;
|
|
505
|
-
return ret;
|
|
506
|
-
};
|
|
507
|
-
imports.wbg.__wbindgen_number_get = function(arg0, arg1) {
|
|
508
|
-
const obj = arg1;
|
|
509
|
-
const ret = typeof(obj) === 'number' ? obj : undefined;
|
|
510
|
-
getDataViewMemory0().setFloat64(arg0 + 8 * 1, isLikeNone(ret) ? 0 : ret, true);
|
|
511
|
-
getDataViewMemory0().setInt32(arg0 + 4 * 0, !isLikeNone(ret), true);
|
|
512
|
-
};
|
|
513
|
-
imports.wbg.__wbindgen_number_new = function(arg0) {
|
|
514
|
-
const ret = arg0;
|
|
515
|
-
return ret;
|
|
516
|
-
};
|
|
517
|
-
imports.wbg.__wbindgen_string_get = function(arg0, arg1) {
|
|
518
|
-
const obj = arg1;
|
|
519
|
-
const ret = typeof(obj) === 'string' ? obj : undefined;
|
|
520
|
-
var ptr1 = isLikeNone(ret) ? 0 : passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
521
|
-
var len1 = WASM_VECTOR_LEN;
|
|
522
|
-
getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
|
|
523
|
-
getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
|
|
524
|
-
};
|
|
525
|
-
imports.wbg.__wbindgen_string_new = function(arg0, arg1) {
|
|
526
|
-
const ret = getStringFromWasm0(arg0, arg1);
|
|
527
|
-
return ret;
|
|
528
|
-
};
|
|
529
|
-
imports.wbg.__wbindgen_throw = function(arg0, arg1) {
|
|
530
|
-
throw new Error(getStringFromWasm0(arg0, arg1));
|
|
531
|
-
};
|
|
532
547
|
|
|
533
548
|
return imports;
|
|
534
549
|
}
|
|
@@ -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/dist/types/index.d.ts
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
export * from './core/types';
|
|
2
|
+
export type { Flag, ClientOptions, EvaluationRequest, VariantEvaluationResponse, BooleanEvaluationResponse, BatchEvaluationResponse, ErrorEvaluationResponse, EvaluationResponse, VariantResult, BooleanResult, BatchResult, ListFlagsResult, Result, ClientTokenAuthentication, JWTAuthentication, AuthenticationStrategy, IFetcher, IFetcherOptions, Hook, Response } from './core/types';
|
|
3
|
+
export { ErrorStrategy, ClientOptionsFactory } from './core/types';
|
|
2
4
|
export { BaseFliptClient } from './core/base';
|
|
3
5
|
import { FliptClient as NodeImpl } from './node';
|
|
4
6
|
import { FliptClient as BrowserImpl } from './browser';
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Re-export all types for users who prefer explicit type imports.
|
|
3
|
+
*
|
|
4
|
+
* @example
|
|
5
|
+
* ```typescript
|
|
6
|
+
* import type { Flag, ClientOptions } from '@flipt-io/flipt-client-js/types';
|
|
7
|
+
* ```
|
|
8
|
+
*/
|
|
9
|
+
export type { Flag, ClientOptions, EvaluationRequest, VariantEvaluationResponse, BooleanEvaluationResponse, BatchEvaluationResponse, ErrorEvaluationResponse, EvaluationResponse, VariantResult, BooleanResult, BatchResult, ListFlagsResult, Result, Response, ClientTokenAuthentication, JWTAuthentication, AuthenticationStrategy, IFetcher, IFetcherOptions, Hook } from './core/types';
|
|
10
|
+
export { ErrorStrategy, ClientOptionsFactory } from './core/types';
|