@vercel/flags-core 1.6.0 → 1.7.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +16 -0
- package/dist/{chunk-FBTDSIHP.js → chunk-PLRBLION.js} +50 -34
- package/dist/chunk-PLRBLION.js.map +1 -0
- package/dist/{chunk-L653ZWQA.js → chunk-RH2MIZYW.js} +50 -34
- package/dist/chunk-RH2MIZYW.js.map +1 -0
- package/dist/{chunk-HTK4XPSW.cjs → chunk-Y7HU5ZNT.cjs} +50 -34
- package/dist/chunk-Y7HU5ZNT.cjs.map +1 -0
- package/dist/{chunk-VT24U6D2.cjs → chunk-Z7PTTGMK.cjs} +50 -34
- package/dist/chunk-Z7PTTGMK.cjs.map +1 -0
- package/dist/index.default.cjs +2 -2
- package/dist/index.default.js +1 -1
- package/dist/index.next-js.cjs +2 -2
- package/dist/index.next-js.js +1 -1
- package/dist/openfeature.default.cjs +2 -2
- package/dist/openfeature.default.js +1 -1
- package/dist/openfeature.next-js.cjs +2 -2
- package/dist/openfeature.next-js.js +1 -1
- package/package.json +5 -5
- package/dist/chunk-FBTDSIHP.js.map +0 -1
- package/dist/chunk-HTK4XPSW.cjs.map +0 -1
- package/dist/chunk-L653ZWQA.js.map +0 -1
- package/dist/chunk-VT24U6D2.cjs.map +0 -1
|
@@ -32,21 +32,30 @@ var Packed;
|
|
|
32
32
|
|
|
33
33
|
// src/evaluate.ts
|
|
34
34
|
var MAX_REGEX_INPUT_LENGTH = 1e4;
|
|
35
|
-
var
|
|
36
|
-
var
|
|
35
|
+
var HASH_SPACE = 2 ** 32;
|
|
36
|
+
var PROMILLE_SCALE = 1e5;
|
|
37
|
+
function boundaryFor(numerator, denominator) {
|
|
38
|
+
return Math.floor(numerator / denominator * HASH_SPACE);
|
|
39
|
+
}
|
|
40
|
+
var splitBoundariesCache = /* @__PURE__ */ new WeakMap();
|
|
37
41
|
var compiledRegexCache = /* @__PURE__ */ new WeakMap();
|
|
38
|
-
function
|
|
39
|
-
const cached =
|
|
42
|
+
function getSplitBoundaries(outcome) {
|
|
43
|
+
const cached = splitBoundariesCache.get(outcome);
|
|
40
44
|
if (cached) return cached;
|
|
41
45
|
const total = sum(outcome.weights);
|
|
42
|
-
const
|
|
43
|
-
|
|
44
|
-
|
|
46
|
+
const boundaries = [];
|
|
47
|
+
let cumulative = 0;
|
|
48
|
+
for (const weight of outcome.weights) {
|
|
49
|
+
cumulative += weight;
|
|
50
|
+
boundaries.push(boundaryFor(cumulative, total));
|
|
51
|
+
}
|
|
52
|
+
splitBoundariesCache.set(outcome, boundaries);
|
|
53
|
+
return boundaries;
|
|
45
54
|
}
|
|
46
55
|
function getCompiledRegex(rhs) {
|
|
47
56
|
const cached = compiledRegexCache.get(rhs);
|
|
48
57
|
if (cached) return cached;
|
|
49
|
-
const compiled = new RegExp(rhs.pattern, rhs.flags);
|
|
58
|
+
const compiled = new RegExp(rhs.pattern, rhs.flags.replace(/[gy]/, ""));
|
|
50
59
|
compiledRegexCache.set(rhs, compiled);
|
|
51
60
|
return compiled;
|
|
52
61
|
}
|
|
@@ -276,11 +285,10 @@ function handleSegmentOutcome(params, outcome) {
|
|
|
276
285
|
case "split": {
|
|
277
286
|
const lhs = access(outcome.base, params);
|
|
278
287
|
if (typeof lhs !== "string") return false;
|
|
279
|
-
const maxValue = 1e5;
|
|
280
288
|
if (outcome.passPromille <= 0) return false;
|
|
281
|
-
if (outcome.passPromille >=
|
|
282
|
-
const
|
|
283
|
-
return
|
|
289
|
+
if (outcome.passPromille >= PROMILLE_SCALE) return true;
|
|
290
|
+
const bucket = hashInput(lhs, params.definition.seed);
|
|
291
|
+
return bucket < boundaryFor(outcome.passPromille, PROMILLE_SCALE);
|
|
284
292
|
}
|
|
285
293
|
default: {
|
|
286
294
|
const { type } = outcome;
|
|
@@ -325,12 +333,18 @@ function handleOutcome(params, outcome) {
|
|
|
325
333
|
outcomeType: "split" /* SPLIT */
|
|
326
334
|
};
|
|
327
335
|
}
|
|
328
|
-
const
|
|
329
|
-
const
|
|
330
|
-
|
|
331
|
-
|
|
336
|
+
const bucket = hashInput(lhs, params.definition.seed);
|
|
337
|
+
const boundaries = getSplitBoundaries(outcome);
|
|
338
|
+
for (let index = 0; index < boundaries.length; index++) {
|
|
339
|
+
if (bucket < boundaries[index]) {
|
|
340
|
+
return {
|
|
341
|
+
...getVariant(params.definition, index),
|
|
342
|
+
outcomeType: "split" /* SPLIT */
|
|
343
|
+
};
|
|
344
|
+
}
|
|
345
|
+
}
|
|
332
346
|
return {
|
|
333
|
-
...
|
|
347
|
+
...defaultOutcome,
|
|
334
348
|
outcomeType: "split" /* SPLIT */
|
|
335
349
|
};
|
|
336
350
|
}
|
|
@@ -366,7 +380,7 @@ function handleOutcome(params, outcome) {
|
|
|
366
380
|
break;
|
|
367
381
|
}
|
|
368
382
|
}
|
|
369
|
-
if (exhausted) currentPromille =
|
|
383
|
+
if (exhausted) currentPromille = PROMILLE_SCALE;
|
|
370
384
|
if (currentPromille <= 0) {
|
|
371
385
|
return {
|
|
372
386
|
...rollFromVariant,
|
|
@@ -377,17 +391,26 @@ function handleOutcome(params, outcome) {
|
|
|
377
391
|
params.definition,
|
|
378
392
|
outcome.rollToVariant
|
|
379
393
|
);
|
|
380
|
-
if (currentPromille >=
|
|
394
|
+
if (currentPromille >= PROMILLE_SCALE) {
|
|
381
395
|
return {
|
|
382
396
|
...rollToVariant,
|
|
383
397
|
outcomeType: "rollout" /* ROLLOUT */
|
|
384
398
|
};
|
|
385
399
|
}
|
|
386
|
-
const
|
|
387
|
-
|
|
388
|
-
|
|
400
|
+
const bucket = hashInput(lhs, params.definition.seed);
|
|
401
|
+
if (outcome.rollToVariant < outcome.rollFromVariant) {
|
|
402
|
+
const rollToBoundary = boundaryFor(currentPromille, PROMILLE_SCALE);
|
|
403
|
+
return {
|
|
404
|
+
...bucket < rollToBoundary ? rollToVariant : rollFromVariant,
|
|
405
|
+
outcomeType: "rollout" /* ROLLOUT */
|
|
406
|
+
};
|
|
407
|
+
}
|
|
408
|
+
const rollFromBoundary = boundaryFor(
|
|
409
|
+
PROMILLE_SCALE - currentPromille,
|
|
410
|
+
PROMILLE_SCALE
|
|
411
|
+
);
|
|
389
412
|
return {
|
|
390
|
-
...
|
|
413
|
+
...bucket < rollFromBoundary ? rollFromVariant : rollToVariant,
|
|
391
414
|
outcomeType: "rollout" /* ROLLOUT */
|
|
392
415
|
};
|
|
393
416
|
}
|
|
@@ -468,18 +491,9 @@ function bulkEvaluate(flags, shared) {
|
|
|
468
491
|
}
|
|
469
492
|
return results;
|
|
470
493
|
}
|
|
471
|
-
function findWeightedIndex(weights, value, maxValue) {
|
|
472
|
-
if (value < 0 || value >= maxValue) return -1;
|
|
473
|
-
let sum2 = 0;
|
|
474
|
-
for (let i = 0; i < weights.length; i++) {
|
|
475
|
-
sum2 += weights[i];
|
|
476
|
-
if (value < sum2) return i;
|
|
477
|
-
}
|
|
478
|
-
return -1;
|
|
479
|
-
}
|
|
480
494
|
|
|
481
495
|
// package.json
|
|
482
|
-
var version = "1.
|
|
496
|
+
var version = "1.7.1";
|
|
483
497
|
|
|
484
498
|
// src/lib/report-value.ts
|
|
485
499
|
function internalReportValue(key, value, data) {
|
|
@@ -956,6 +970,7 @@ var Scheduler = class {
|
|
|
956
970
|
constructor(onFlush) {
|
|
957
971
|
this.onFlush = onFlush;
|
|
958
972
|
}
|
|
973
|
+
onFlush;
|
|
959
974
|
resolveWait = null;
|
|
960
975
|
pending = null;
|
|
961
976
|
idleTimeout = null;
|
|
@@ -1207,6 +1222,7 @@ var BundledSource = class {
|
|
|
1207
1222
|
constructor(options) {
|
|
1208
1223
|
this.options = options;
|
|
1209
1224
|
}
|
|
1225
|
+
options;
|
|
1210
1226
|
promise;
|
|
1211
1227
|
/**
|
|
1212
1228
|
* Load bundled definitions.
|
|
@@ -2490,4 +2506,4 @@ export {
|
|
|
2490
2506
|
resetDefaultFlagsClient,
|
|
2491
2507
|
createClient
|
|
2492
2508
|
};
|
|
2493
|
-
//# sourceMappingURL=chunk-
|
|
2509
|
+
//# sourceMappingURL=chunk-RH2MIZYW.js.map
|