@hot-updater/core 0.29.1 → 0.29.2
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/index.cjs +135 -19
- package/dist/index.d.cts +226 -5
- package/dist/index.d.mts +226 -5
- package/dist/index.mjs +121 -4
- package/package.json +1 -22
- package/dist/_virtual/_rolldown/runtime.cjs +0 -23
- package/dist/hotUpdateDirUtil.cjs +0 -26
- package/dist/hotUpdateDirUtil.d.cts +0 -25
- package/dist/hotUpdateDirUtil.d.mts +0 -25
- package/dist/hotUpdateDirUtil.mjs +0 -23
- package/dist/react-native.cjs +0 -18
- package/dist/react-native.d.cts +0 -4
- package/dist/react-native.d.mts +0 -4
- package/dist/react-native.mjs +0 -3
- package/dist/rollout.cjs +0 -132
- package/dist/rollout.d.cts +0 -17
- package/dist/rollout.d.mts +0 -17
- package/dist/rollout.mjs +0 -118
- package/dist/types.cjs +0 -0
- package/dist/types.d.cts +0 -207
- package/dist/types.d.mts +0 -207
- package/dist/types.mjs +0 -1
- package/dist/uuid.cjs +0 -5
- package/dist/uuid.d.cts +0 -4
- package/dist/uuid.d.mts +0 -4
- package/dist/uuid.mjs +0 -4
package/dist/index.mjs
CHANGED
|
@@ -1,4 +1,121 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
//#region src/rollout.ts
|
|
2
|
+
const NUMERIC_COHORT_SIZE = 1e3;
|
|
3
|
+
const DEFAULT_ROLLOUT_COHORT_COUNT = NUMERIC_COHORT_SIZE;
|
|
4
|
+
const MAX_COHORT_LENGTH = 64;
|
|
5
|
+
const INVALID_COHORT_ERROR_MESSAGE = `Invalid cohort. Use 1-1000 or a lowercase slug without spaces, up to 64 characters.`;
|
|
6
|
+
const CUSTOM_COHORT_PATTERN = /^[a-z0-9-]+$/;
|
|
7
|
+
function parseNumericCohortValue(cohort) {
|
|
8
|
+
if (!/^\d+$/.test(cohort)) return null;
|
|
9
|
+
const parsed = Number.parseInt(cohort, 10);
|
|
10
|
+
if (Number.isNaN(parsed) || parsed < 1 || parsed > 1e3) return null;
|
|
11
|
+
return parsed;
|
|
12
|
+
}
|
|
13
|
+
function positiveMod(value, modulus) {
|
|
14
|
+
return (value % modulus + modulus) % modulus;
|
|
15
|
+
}
|
|
16
|
+
function hashString(value) {
|
|
17
|
+
let hash = 0;
|
|
18
|
+
for (let i = 0; i < value.length; i++) {
|
|
19
|
+
const char = value.charCodeAt(i);
|
|
20
|
+
hash = (hash << 5) - hash + char;
|
|
21
|
+
hash |= 0;
|
|
22
|
+
}
|
|
23
|
+
return hash;
|
|
24
|
+
}
|
|
25
|
+
function gcd(a, b) {
|
|
26
|
+
let x = Math.abs(a);
|
|
27
|
+
let y = Math.abs(b);
|
|
28
|
+
while (y !== 0) {
|
|
29
|
+
const next = x % y;
|
|
30
|
+
x = y;
|
|
31
|
+
y = next;
|
|
32
|
+
}
|
|
33
|
+
return x;
|
|
34
|
+
}
|
|
35
|
+
function modularInverse(value, modulus) {
|
|
36
|
+
let t = 0;
|
|
37
|
+
let newT = 1;
|
|
38
|
+
let r = modulus;
|
|
39
|
+
let newR = positiveMod(value, modulus);
|
|
40
|
+
while (newR !== 0) {
|
|
41
|
+
const quotient = Math.floor(r / newR);
|
|
42
|
+
[t, newT] = [newT, t - quotient * newT];
|
|
43
|
+
[r, newR] = [newR, r - quotient * newR];
|
|
44
|
+
}
|
|
45
|
+
if (r > 1) throw new Error(`No modular inverse for ${value} mod ${modulus}`);
|
|
46
|
+
return positiveMod(t, modulus);
|
|
47
|
+
}
|
|
48
|
+
function getRolloutShuffleParameters(bundleId) {
|
|
49
|
+
let multiplier = positiveMod(hashString(`${bundleId}:multiplier`), 997);
|
|
50
|
+
if (multiplier === 0) multiplier = 1;
|
|
51
|
+
while (gcd(multiplier, NUMERIC_COHORT_SIZE) !== 1) {
|
|
52
|
+
multiplier = positiveMod(multiplier + 1, NUMERIC_COHORT_SIZE);
|
|
53
|
+
if (multiplier === 0) multiplier = 1;
|
|
54
|
+
}
|
|
55
|
+
const offset = positiveMod(hashString(`${bundleId}:offset`), NUMERIC_COHORT_SIZE);
|
|
56
|
+
return {
|
|
57
|
+
multiplier,
|
|
58
|
+
offset,
|
|
59
|
+
inverseMultiplier: modularInverse(multiplier, NUMERIC_COHORT_SIZE)
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
function normalizeRolloutCohortCount(rolloutCohortCount) {
|
|
63
|
+
if (rolloutCohortCount === null || rolloutCohortCount === void 0) return DEFAULT_ROLLOUT_COHORT_COUNT;
|
|
64
|
+
if (rolloutCohortCount <= 0) return 0;
|
|
65
|
+
if (rolloutCohortCount >= 1e3) return NUMERIC_COHORT_SIZE;
|
|
66
|
+
return Math.floor(rolloutCohortCount);
|
|
67
|
+
}
|
|
68
|
+
function normalizeCohortValue(cohort) {
|
|
69
|
+
const normalized = cohort.trim().toLowerCase();
|
|
70
|
+
const numericCohort = parseNumericCohortValue(normalized);
|
|
71
|
+
if (numericCohort !== null) return String(numericCohort);
|
|
72
|
+
return normalized;
|
|
73
|
+
}
|
|
74
|
+
function getNumericCohortValue(cohort) {
|
|
75
|
+
return parseNumericCohortValue(normalizeCohortValue(cohort));
|
|
76
|
+
}
|
|
77
|
+
function isNumericCohort(cohort) {
|
|
78
|
+
return getNumericCohortValue(cohort) !== null;
|
|
79
|
+
}
|
|
80
|
+
function isCustomCohort(cohort) {
|
|
81
|
+
const normalized = normalizeCohortValue(cohort);
|
|
82
|
+
return normalized.length > 0 && normalized.length <= 64 && !/^\d+$/.test(normalized) && CUSTOM_COHORT_PATTERN.test(normalized);
|
|
83
|
+
}
|
|
84
|
+
function isValidCohort(cohort) {
|
|
85
|
+
const normalized = normalizeCohortValue(cohort);
|
|
86
|
+
return isNumericCohort(normalized) || isCustomCohort(normalized);
|
|
87
|
+
}
|
|
88
|
+
function getDefaultNumericCohort(identifier) {
|
|
89
|
+
const cohortValue = positiveMod(hashString(identifier), NUMERIC_COHORT_SIZE) + 1;
|
|
90
|
+
return String(cohortValue);
|
|
91
|
+
}
|
|
92
|
+
function getNumericCohortRolloutPosition(bundleId, cohortValue) {
|
|
93
|
+
if (cohortValue < 1 || cohortValue > 1e3) throw new Error(`Invalid numeric cohort: ${cohortValue}`);
|
|
94
|
+
const { offset, inverseMultiplier } = getRolloutShuffleParameters(bundleId);
|
|
95
|
+
return positiveMod(inverseMultiplier * (cohortValue - 1 - offset), NUMERIC_COHORT_SIZE);
|
|
96
|
+
}
|
|
97
|
+
function getRolledOutNumericCohorts(bundleId, rolloutCohortCount) {
|
|
98
|
+
const normalizedRolloutCount = normalizeRolloutCohortCount(rolloutCohortCount);
|
|
99
|
+
if (normalizedRolloutCount <= 0) return [];
|
|
100
|
+
return Array.from({ length: NUMERIC_COHORT_SIZE }, (_, index) => index + 1).filter((cohortValue) => {
|
|
101
|
+
if (normalizedRolloutCount >= 1e3) return true;
|
|
102
|
+
return getNumericCohortRolloutPosition(bundleId, cohortValue) < normalizedRolloutCount;
|
|
103
|
+
});
|
|
104
|
+
}
|
|
105
|
+
function isCohortEligibleForUpdate(bundleId, cohort, rolloutCohortCount, targetCohorts) {
|
|
106
|
+
const normalizedCohort = cohort === null || cohort === void 0 ? void 0 : normalizeCohortValue(cohort);
|
|
107
|
+
const normalizedTargetCohorts = targetCohorts?.map((targetCohort) => normalizeCohortValue(targetCohort)) ?? [];
|
|
108
|
+
if (normalizedTargetCohorts.length > 0) return normalizedCohort !== void 0 && normalizedTargetCohorts.includes(normalizedCohort);
|
|
109
|
+
const normalizedRolloutCount = normalizeRolloutCohortCount(rolloutCohortCount);
|
|
110
|
+
if (normalizedRolloutCount <= 0) return false;
|
|
111
|
+
if (normalizedCohort === void 0) return normalizedRolloutCount >= NUMERIC_COHORT_SIZE;
|
|
112
|
+
const numericCohort = getNumericCohortValue(normalizedCohort);
|
|
113
|
+
if (numericCohort === null) return false;
|
|
114
|
+
if (normalizedRolloutCount >= 1e3) return true;
|
|
115
|
+
return getNumericCohortRolloutPosition(bundleId, numericCohort) < normalizedRolloutCount;
|
|
116
|
+
}
|
|
117
|
+
//#endregion
|
|
118
|
+
//#region src/uuid.ts
|
|
119
|
+
const NIL_UUID = "00000000-0000-0000-0000-000000000000";
|
|
120
|
+
//#endregion
|
|
121
|
+
export { DEFAULT_ROLLOUT_COHORT_COUNT, INVALID_COHORT_ERROR_MESSAGE, MAX_COHORT_LENGTH, NIL_UUID, NUMERIC_COHORT_SIZE, getDefaultNumericCohort, getNumericCohortRolloutPosition, getNumericCohortValue, getRolledOutNumericCohorts, isCohortEligibleForUpdate, isCustomCohort, isNumericCohort, isValidCohort, normalizeCohortValue, normalizeRolloutCohortCount };
|
package/package.json
CHANGED
|
@@ -1,38 +1,17 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hot-updater/core",
|
|
3
|
-
"version": "0.29.
|
|
3
|
+
"version": "0.29.2",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "React Native OTA solution for self-hosted",
|
|
6
6
|
"sideEffects": false,
|
|
7
7
|
"main": "./dist/index.cjs",
|
|
8
8
|
"module": "./dist/index.mjs",
|
|
9
|
-
"react-native": "./dist/react-native.mjs",
|
|
10
9
|
"types": "./dist/index.d.cts",
|
|
11
10
|
"exports": {
|
|
12
11
|
".": {
|
|
13
12
|
"import": "./dist/index.mjs",
|
|
14
13
|
"require": "./dist/index.cjs"
|
|
15
14
|
},
|
|
16
|
-
"./hotUpdateDirUtil": {
|
|
17
|
-
"import": "./dist/hotUpdateDirUtil.mjs",
|
|
18
|
-
"require": "./dist/hotUpdateDirUtil.cjs"
|
|
19
|
-
},
|
|
20
|
-
"./react-native": {
|
|
21
|
-
"import": "./dist/react-native.mjs",
|
|
22
|
-
"require": "./dist/react-native.cjs"
|
|
23
|
-
},
|
|
24
|
-
"./rollout": {
|
|
25
|
-
"import": "./dist/rollout.mjs",
|
|
26
|
-
"require": "./dist/rollout.cjs"
|
|
27
|
-
},
|
|
28
|
-
"./types": {
|
|
29
|
-
"import": "./dist/types.mjs",
|
|
30
|
-
"require": "./dist/types.cjs"
|
|
31
|
-
},
|
|
32
|
-
"./uuid": {
|
|
33
|
-
"import": "./dist/uuid.mjs",
|
|
34
|
-
"require": "./dist/uuid.cjs"
|
|
35
|
-
},
|
|
36
15
|
"./package.json": "./package.json"
|
|
37
16
|
},
|
|
38
17
|
"files": [
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
//#region \0rolldown/runtime.js
|
|
2
|
-
var __create = Object.create;
|
|
3
|
-
var __defProp = Object.defineProperty;
|
|
4
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
-
var __copyProps = (to, from, except, desc) => {
|
|
9
|
-
if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
|
|
10
|
-
key = keys[i];
|
|
11
|
-
if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
12
|
-
get: ((k) => from[k]).bind(null, key),
|
|
13
|
-
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
14
|
-
});
|
|
15
|
-
}
|
|
16
|
-
return to;
|
|
17
|
-
};
|
|
18
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
|
|
19
|
-
value: mod,
|
|
20
|
-
enumerable: true
|
|
21
|
-
}) : target, mod));
|
|
22
|
-
//#endregion
|
|
23
|
-
exports.__toESM = __toESM;
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
-
const require_runtime = require("./_virtual/_rolldown/runtime.cjs");
|
|
3
|
-
let node_path = require("node:path");
|
|
4
|
-
node_path = require_runtime.__toESM(node_path);
|
|
5
|
-
//#region src/hotUpdateDirUtil.ts
|
|
6
|
-
const HOT_UPDATE_DIR_NAME = ".hot-updater";
|
|
7
|
-
const HOT_UPDATE_OUTPUT_DIR_NAME = "output";
|
|
8
|
-
const HOT_UPDATE_LOG_DIR_NAME = "log";
|
|
9
|
-
const HotUpdateDirUtil = {
|
|
10
|
-
dirName: HOT_UPDATE_DIR_NAME,
|
|
11
|
-
outputDirName: HOT_UPDATE_OUTPUT_DIR_NAME,
|
|
12
|
-
logDirName: HOT_UPDATE_LOG_DIR_NAME,
|
|
13
|
-
outputGitignorePath: `${HOT_UPDATE_DIR_NAME}/${HOT_UPDATE_OUTPUT_DIR_NAME}`,
|
|
14
|
-
logGitignorePath: `${HOT_UPDATE_DIR_NAME}/${HOT_UPDATE_LOG_DIR_NAME}`,
|
|
15
|
-
getDirPath: ({ cwd }) => {
|
|
16
|
-
return node_path.default.join(cwd, HOT_UPDATE_DIR_NAME);
|
|
17
|
-
},
|
|
18
|
-
getDefaultOutputPath: ({ cwd }) => {
|
|
19
|
-
return node_path.default.join(cwd, HOT_UPDATE_DIR_NAME, HOT_UPDATE_OUTPUT_DIR_NAME);
|
|
20
|
-
},
|
|
21
|
-
getLogDirPath: ({ cwd }) => {
|
|
22
|
-
return node_path.default.join(cwd, HOT_UPDATE_DIR_NAME, HOT_UPDATE_LOG_DIR_NAME);
|
|
23
|
-
}
|
|
24
|
-
};
|
|
25
|
-
//#endregion
|
|
26
|
-
exports.HotUpdateDirUtil = HotUpdateDirUtil;
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
//#region src/hotUpdateDirUtil.d.ts
|
|
2
|
-
declare const HotUpdateDirUtil: {
|
|
3
|
-
readonly dirName: ".hot-updater";
|
|
4
|
-
readonly outputDirName: "output";
|
|
5
|
-
readonly logDirName: "log";
|
|
6
|
-
readonly outputGitignorePath: ".hot-updater/output";
|
|
7
|
-
readonly logGitignorePath: ".hot-updater/log";
|
|
8
|
-
readonly getDirPath: ({
|
|
9
|
-
cwd
|
|
10
|
-
}: {
|
|
11
|
-
cwd: string;
|
|
12
|
-
}) => string;
|
|
13
|
-
readonly getDefaultOutputPath: ({
|
|
14
|
-
cwd
|
|
15
|
-
}: {
|
|
16
|
-
cwd: string;
|
|
17
|
-
}) => string;
|
|
18
|
-
readonly getLogDirPath: ({
|
|
19
|
-
cwd
|
|
20
|
-
}: {
|
|
21
|
-
cwd: string;
|
|
22
|
-
}) => string;
|
|
23
|
-
};
|
|
24
|
-
//#endregion
|
|
25
|
-
export { HotUpdateDirUtil };
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
//#region src/hotUpdateDirUtil.d.ts
|
|
2
|
-
declare const HotUpdateDirUtil: {
|
|
3
|
-
readonly dirName: ".hot-updater";
|
|
4
|
-
readonly outputDirName: "output";
|
|
5
|
-
readonly logDirName: "log";
|
|
6
|
-
readonly outputGitignorePath: ".hot-updater/output";
|
|
7
|
-
readonly logGitignorePath: ".hot-updater/log";
|
|
8
|
-
readonly getDirPath: ({
|
|
9
|
-
cwd
|
|
10
|
-
}: {
|
|
11
|
-
cwd: string;
|
|
12
|
-
}) => string;
|
|
13
|
-
readonly getDefaultOutputPath: ({
|
|
14
|
-
cwd
|
|
15
|
-
}: {
|
|
16
|
-
cwd: string;
|
|
17
|
-
}) => string;
|
|
18
|
-
readonly getLogDirPath: ({
|
|
19
|
-
cwd
|
|
20
|
-
}: {
|
|
21
|
-
cwd: string;
|
|
22
|
-
}) => string;
|
|
23
|
-
};
|
|
24
|
-
//#endregion
|
|
25
|
-
export { HotUpdateDirUtil };
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import path from "node:path";
|
|
2
|
-
//#region src/hotUpdateDirUtil.ts
|
|
3
|
-
const HOT_UPDATE_DIR_NAME = ".hot-updater";
|
|
4
|
-
const HOT_UPDATE_OUTPUT_DIR_NAME = "output";
|
|
5
|
-
const HOT_UPDATE_LOG_DIR_NAME = "log";
|
|
6
|
-
const HotUpdateDirUtil = {
|
|
7
|
-
dirName: HOT_UPDATE_DIR_NAME,
|
|
8
|
-
outputDirName: HOT_UPDATE_OUTPUT_DIR_NAME,
|
|
9
|
-
logDirName: HOT_UPDATE_LOG_DIR_NAME,
|
|
10
|
-
outputGitignorePath: `${HOT_UPDATE_DIR_NAME}/${HOT_UPDATE_OUTPUT_DIR_NAME}`,
|
|
11
|
-
logGitignorePath: `${HOT_UPDATE_DIR_NAME}/${HOT_UPDATE_LOG_DIR_NAME}`,
|
|
12
|
-
getDirPath: ({ cwd }) => {
|
|
13
|
-
return path.join(cwd, HOT_UPDATE_DIR_NAME);
|
|
14
|
-
},
|
|
15
|
-
getDefaultOutputPath: ({ cwd }) => {
|
|
16
|
-
return path.join(cwd, HOT_UPDATE_DIR_NAME, HOT_UPDATE_OUTPUT_DIR_NAME);
|
|
17
|
-
},
|
|
18
|
-
getLogDirPath: ({ cwd }) => {
|
|
19
|
-
return path.join(cwd, HOT_UPDATE_DIR_NAME, HOT_UPDATE_LOG_DIR_NAME);
|
|
20
|
-
}
|
|
21
|
-
};
|
|
22
|
-
//#endregion
|
|
23
|
-
export { HotUpdateDirUtil };
|
package/dist/react-native.cjs
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
-
const require_rollout = require("./rollout.cjs");
|
|
3
|
-
const require_uuid = require("./uuid.cjs");
|
|
4
|
-
exports.DEFAULT_ROLLOUT_COHORT_COUNT = require_rollout.DEFAULT_ROLLOUT_COHORT_COUNT;
|
|
5
|
-
exports.INVALID_COHORT_ERROR_MESSAGE = require_rollout.INVALID_COHORT_ERROR_MESSAGE;
|
|
6
|
-
exports.MAX_COHORT_LENGTH = require_rollout.MAX_COHORT_LENGTH;
|
|
7
|
-
exports.NIL_UUID = require_uuid.NIL_UUID;
|
|
8
|
-
exports.NUMERIC_COHORT_SIZE = require_rollout.NUMERIC_COHORT_SIZE;
|
|
9
|
-
exports.getDefaultNumericCohort = require_rollout.getDefaultNumericCohort;
|
|
10
|
-
exports.getNumericCohortRolloutPosition = require_rollout.getNumericCohortRolloutPosition;
|
|
11
|
-
exports.getNumericCohortValue = require_rollout.getNumericCohortValue;
|
|
12
|
-
exports.getRolledOutNumericCohorts = require_rollout.getRolledOutNumericCohorts;
|
|
13
|
-
exports.isCohortEligibleForUpdate = require_rollout.isCohortEligibleForUpdate;
|
|
14
|
-
exports.isCustomCohort = require_rollout.isCustomCohort;
|
|
15
|
-
exports.isNumericCohort = require_rollout.isNumericCohort;
|
|
16
|
-
exports.isValidCohort = require_rollout.isValidCohort;
|
|
17
|
-
exports.normalizeCohortValue = require_rollout.normalizeCohortValue;
|
|
18
|
-
exports.normalizeRolloutCohortCount = require_rollout.normalizeRolloutCohortCount;
|
package/dist/react-native.d.cts
DELETED
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
import { DEFAULT_ROLLOUT_COHORT_COUNT, INVALID_COHORT_ERROR_MESSAGE, MAX_COHORT_LENGTH, NUMERIC_COHORT_SIZE, getDefaultNumericCohort, getNumericCohortRolloutPosition, getNumericCohortValue, getRolledOutNumericCohorts, isCohortEligibleForUpdate, isCustomCohort, isNumericCohort, isValidCohort, normalizeCohortValue, normalizeRolloutCohortCount } from "./rollout.cjs";
|
|
2
|
-
import { AppUpdateInfo, AppVersionGetBundlesArgs, Bundle, BundleMetadata, FingerprintGetBundlesArgs, GetBundlesArgs, Platform, SnakeCaseBundle, UpdateBundleParams, UpdateInfo, UpdateStatus, UpdateStrategy } from "./types.cjs";
|
|
3
|
-
import { NIL_UUID } from "./uuid.cjs";
|
|
4
|
-
export { AppUpdateInfo, AppVersionGetBundlesArgs, Bundle, BundleMetadata, DEFAULT_ROLLOUT_COHORT_COUNT, FingerprintGetBundlesArgs, GetBundlesArgs, INVALID_COHORT_ERROR_MESSAGE, MAX_COHORT_LENGTH, NIL_UUID, NUMERIC_COHORT_SIZE, Platform, SnakeCaseBundle, UpdateBundleParams, UpdateInfo, UpdateStatus, UpdateStrategy, getDefaultNumericCohort, getNumericCohortRolloutPosition, getNumericCohortValue, getRolledOutNumericCohorts, isCohortEligibleForUpdate, isCustomCohort, isNumericCohort, isValidCohort, normalizeCohortValue, normalizeRolloutCohortCount };
|
package/dist/react-native.d.mts
DELETED
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
import { DEFAULT_ROLLOUT_COHORT_COUNT, INVALID_COHORT_ERROR_MESSAGE, MAX_COHORT_LENGTH, NUMERIC_COHORT_SIZE, getDefaultNumericCohort, getNumericCohortRolloutPosition, getNumericCohortValue, getRolledOutNumericCohorts, isCohortEligibleForUpdate, isCustomCohort, isNumericCohort, isValidCohort, normalizeCohortValue, normalizeRolloutCohortCount } from "./rollout.mjs";
|
|
2
|
-
import { AppUpdateInfo, AppVersionGetBundlesArgs, Bundle, BundleMetadata, FingerprintGetBundlesArgs, GetBundlesArgs, Platform, SnakeCaseBundle, UpdateBundleParams, UpdateInfo, UpdateStatus, UpdateStrategy } from "./types.mjs";
|
|
3
|
-
import { NIL_UUID } from "./uuid.mjs";
|
|
4
|
-
export { AppUpdateInfo, AppVersionGetBundlesArgs, Bundle, BundleMetadata, DEFAULT_ROLLOUT_COHORT_COUNT, FingerprintGetBundlesArgs, GetBundlesArgs, INVALID_COHORT_ERROR_MESSAGE, MAX_COHORT_LENGTH, NIL_UUID, NUMERIC_COHORT_SIZE, Platform, SnakeCaseBundle, UpdateBundleParams, UpdateInfo, UpdateStatus, UpdateStrategy, getDefaultNumericCohort, getNumericCohortRolloutPosition, getNumericCohortValue, getRolledOutNumericCohorts, isCohortEligibleForUpdate, isCustomCohort, isNumericCohort, isValidCohort, normalizeCohortValue, normalizeRolloutCohortCount };
|
package/dist/react-native.mjs
DELETED
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
import { DEFAULT_ROLLOUT_COHORT_COUNT, INVALID_COHORT_ERROR_MESSAGE, MAX_COHORT_LENGTH, NUMERIC_COHORT_SIZE, getDefaultNumericCohort, getNumericCohortRolloutPosition, getNumericCohortValue, getRolledOutNumericCohorts, isCohortEligibleForUpdate, isCustomCohort, isNumericCohort, isValidCohort, normalizeCohortValue, normalizeRolloutCohortCount } from "./rollout.mjs";
|
|
2
|
-
import { NIL_UUID } from "./uuid.mjs";
|
|
3
|
-
export { DEFAULT_ROLLOUT_COHORT_COUNT, INVALID_COHORT_ERROR_MESSAGE, MAX_COHORT_LENGTH, NIL_UUID, NUMERIC_COHORT_SIZE, getDefaultNumericCohort, getNumericCohortRolloutPosition, getNumericCohortValue, getRolledOutNumericCohorts, isCohortEligibleForUpdate, isCustomCohort, isNumericCohort, isValidCohort, normalizeCohortValue, normalizeRolloutCohortCount };
|
package/dist/rollout.cjs
DELETED
|
@@ -1,132 +0,0 @@
|
|
|
1
|
-
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
-
//#region src/rollout.ts
|
|
3
|
-
const NUMERIC_COHORT_SIZE = 1e3;
|
|
4
|
-
const DEFAULT_ROLLOUT_COHORT_COUNT = NUMERIC_COHORT_SIZE;
|
|
5
|
-
const MAX_COHORT_LENGTH = 64;
|
|
6
|
-
const INVALID_COHORT_ERROR_MESSAGE = `Invalid cohort. Use 1-1000 or a lowercase slug without spaces, up to 64 characters.`;
|
|
7
|
-
const CUSTOM_COHORT_PATTERN = /^[a-z0-9-]+$/;
|
|
8
|
-
function parseNumericCohortValue(cohort) {
|
|
9
|
-
if (!/^\d+$/.test(cohort)) return null;
|
|
10
|
-
const parsed = Number.parseInt(cohort, 10);
|
|
11
|
-
if (Number.isNaN(parsed) || parsed < 1 || parsed > 1e3) return null;
|
|
12
|
-
return parsed;
|
|
13
|
-
}
|
|
14
|
-
function positiveMod(value, modulus) {
|
|
15
|
-
return (value % modulus + modulus) % modulus;
|
|
16
|
-
}
|
|
17
|
-
function hashString(value) {
|
|
18
|
-
let hash = 0;
|
|
19
|
-
for (let i = 0; i < value.length; i++) {
|
|
20
|
-
const char = value.charCodeAt(i);
|
|
21
|
-
hash = (hash << 5) - hash + char;
|
|
22
|
-
hash |= 0;
|
|
23
|
-
}
|
|
24
|
-
return hash;
|
|
25
|
-
}
|
|
26
|
-
function gcd(a, b) {
|
|
27
|
-
let x = Math.abs(a);
|
|
28
|
-
let y = Math.abs(b);
|
|
29
|
-
while (y !== 0) {
|
|
30
|
-
const next = x % y;
|
|
31
|
-
x = y;
|
|
32
|
-
y = next;
|
|
33
|
-
}
|
|
34
|
-
return x;
|
|
35
|
-
}
|
|
36
|
-
function modularInverse(value, modulus) {
|
|
37
|
-
let t = 0;
|
|
38
|
-
let newT = 1;
|
|
39
|
-
let r = modulus;
|
|
40
|
-
let newR = positiveMod(value, modulus);
|
|
41
|
-
while (newR !== 0) {
|
|
42
|
-
const quotient = Math.floor(r / newR);
|
|
43
|
-
[t, newT] = [newT, t - quotient * newT];
|
|
44
|
-
[r, newR] = [newR, r - quotient * newR];
|
|
45
|
-
}
|
|
46
|
-
if (r > 1) throw new Error(`No modular inverse for ${value} mod ${modulus}`);
|
|
47
|
-
return positiveMod(t, modulus);
|
|
48
|
-
}
|
|
49
|
-
function getRolloutShuffleParameters(bundleId) {
|
|
50
|
-
let multiplier = positiveMod(hashString(`${bundleId}:multiplier`), 997);
|
|
51
|
-
if (multiplier === 0) multiplier = 1;
|
|
52
|
-
while (gcd(multiplier, NUMERIC_COHORT_SIZE) !== 1) {
|
|
53
|
-
multiplier = positiveMod(multiplier + 1, NUMERIC_COHORT_SIZE);
|
|
54
|
-
if (multiplier === 0) multiplier = 1;
|
|
55
|
-
}
|
|
56
|
-
const offset = positiveMod(hashString(`${bundleId}:offset`), NUMERIC_COHORT_SIZE);
|
|
57
|
-
return {
|
|
58
|
-
multiplier,
|
|
59
|
-
offset,
|
|
60
|
-
inverseMultiplier: modularInverse(multiplier, NUMERIC_COHORT_SIZE)
|
|
61
|
-
};
|
|
62
|
-
}
|
|
63
|
-
function normalizeRolloutCohortCount(rolloutCohortCount) {
|
|
64
|
-
if (rolloutCohortCount === null || rolloutCohortCount === void 0) return DEFAULT_ROLLOUT_COHORT_COUNT;
|
|
65
|
-
if (rolloutCohortCount <= 0) return 0;
|
|
66
|
-
if (rolloutCohortCount >= 1e3) return NUMERIC_COHORT_SIZE;
|
|
67
|
-
return Math.floor(rolloutCohortCount);
|
|
68
|
-
}
|
|
69
|
-
function normalizeCohortValue(cohort) {
|
|
70
|
-
const normalized = cohort.trim().toLowerCase();
|
|
71
|
-
const numericCohort = parseNumericCohortValue(normalized);
|
|
72
|
-
if (numericCohort !== null) return String(numericCohort);
|
|
73
|
-
return normalized;
|
|
74
|
-
}
|
|
75
|
-
function getNumericCohortValue(cohort) {
|
|
76
|
-
return parseNumericCohortValue(normalizeCohortValue(cohort));
|
|
77
|
-
}
|
|
78
|
-
function isNumericCohort(cohort) {
|
|
79
|
-
return getNumericCohortValue(cohort) !== null;
|
|
80
|
-
}
|
|
81
|
-
function isCustomCohort(cohort) {
|
|
82
|
-
const normalized = normalizeCohortValue(cohort);
|
|
83
|
-
return normalized.length > 0 && normalized.length <= 64 && !/^\d+$/.test(normalized) && CUSTOM_COHORT_PATTERN.test(normalized);
|
|
84
|
-
}
|
|
85
|
-
function isValidCohort(cohort) {
|
|
86
|
-
const normalized = normalizeCohortValue(cohort);
|
|
87
|
-
return isNumericCohort(normalized) || isCustomCohort(normalized);
|
|
88
|
-
}
|
|
89
|
-
function getDefaultNumericCohort(identifier) {
|
|
90
|
-
const cohortValue = positiveMod(hashString(identifier), NUMERIC_COHORT_SIZE) + 1;
|
|
91
|
-
return String(cohortValue);
|
|
92
|
-
}
|
|
93
|
-
function getNumericCohortRolloutPosition(bundleId, cohortValue) {
|
|
94
|
-
if (cohortValue < 1 || cohortValue > 1e3) throw new Error(`Invalid numeric cohort: ${cohortValue}`);
|
|
95
|
-
const { offset, inverseMultiplier } = getRolloutShuffleParameters(bundleId);
|
|
96
|
-
return positiveMod(inverseMultiplier * (cohortValue - 1 - offset), NUMERIC_COHORT_SIZE);
|
|
97
|
-
}
|
|
98
|
-
function getRolledOutNumericCohorts(bundleId, rolloutCohortCount) {
|
|
99
|
-
const normalizedRolloutCount = normalizeRolloutCohortCount(rolloutCohortCount);
|
|
100
|
-
if (normalizedRolloutCount <= 0) return [];
|
|
101
|
-
return Array.from({ length: NUMERIC_COHORT_SIZE }, (_, index) => index + 1).filter((cohortValue) => {
|
|
102
|
-
if (normalizedRolloutCount >= 1e3) return true;
|
|
103
|
-
return getNumericCohortRolloutPosition(bundleId, cohortValue) < normalizedRolloutCount;
|
|
104
|
-
});
|
|
105
|
-
}
|
|
106
|
-
function isCohortEligibleForUpdate(bundleId, cohort, rolloutCohortCount, targetCohorts) {
|
|
107
|
-
const normalizedCohort = cohort === null || cohort === void 0 ? void 0 : normalizeCohortValue(cohort);
|
|
108
|
-
const normalizedTargetCohorts = targetCohorts?.map((targetCohort) => normalizeCohortValue(targetCohort)) ?? [];
|
|
109
|
-
if (normalizedTargetCohorts.length > 0) return normalizedCohort !== void 0 && normalizedTargetCohorts.includes(normalizedCohort);
|
|
110
|
-
const normalizedRolloutCount = normalizeRolloutCohortCount(rolloutCohortCount);
|
|
111
|
-
if (normalizedRolloutCount <= 0) return false;
|
|
112
|
-
if (normalizedCohort === void 0) return normalizedRolloutCount >= NUMERIC_COHORT_SIZE;
|
|
113
|
-
const numericCohort = getNumericCohortValue(normalizedCohort);
|
|
114
|
-
if (numericCohort === null) return false;
|
|
115
|
-
if (normalizedRolloutCount >= 1e3) return true;
|
|
116
|
-
return getNumericCohortRolloutPosition(bundleId, numericCohort) < normalizedRolloutCount;
|
|
117
|
-
}
|
|
118
|
-
//#endregion
|
|
119
|
-
exports.DEFAULT_ROLLOUT_COHORT_COUNT = DEFAULT_ROLLOUT_COHORT_COUNT;
|
|
120
|
-
exports.INVALID_COHORT_ERROR_MESSAGE = INVALID_COHORT_ERROR_MESSAGE;
|
|
121
|
-
exports.MAX_COHORT_LENGTH = MAX_COHORT_LENGTH;
|
|
122
|
-
exports.NUMERIC_COHORT_SIZE = NUMERIC_COHORT_SIZE;
|
|
123
|
-
exports.getDefaultNumericCohort = getDefaultNumericCohort;
|
|
124
|
-
exports.getNumericCohortRolloutPosition = getNumericCohortRolloutPosition;
|
|
125
|
-
exports.getNumericCohortValue = getNumericCohortValue;
|
|
126
|
-
exports.getRolledOutNumericCohorts = getRolledOutNumericCohorts;
|
|
127
|
-
exports.isCohortEligibleForUpdate = isCohortEligibleForUpdate;
|
|
128
|
-
exports.isCustomCohort = isCustomCohort;
|
|
129
|
-
exports.isNumericCohort = isNumericCohort;
|
|
130
|
-
exports.isValidCohort = isValidCohort;
|
|
131
|
-
exports.normalizeCohortValue = normalizeCohortValue;
|
|
132
|
-
exports.normalizeRolloutCohortCount = normalizeRolloutCohortCount;
|
package/dist/rollout.d.cts
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
//#region src/rollout.d.ts
|
|
2
|
-
declare const NUMERIC_COHORT_SIZE = 1000;
|
|
3
|
-
declare const DEFAULT_ROLLOUT_COHORT_COUNT = 1000;
|
|
4
|
-
declare const MAX_COHORT_LENGTH = 64;
|
|
5
|
-
declare const INVALID_COHORT_ERROR_MESSAGE = "Invalid cohort. Use 1-1000 or a lowercase slug without spaces, up to 64 characters.";
|
|
6
|
-
declare function normalizeRolloutCohortCount(rolloutCohortCount: number | null | undefined): number;
|
|
7
|
-
declare function normalizeCohortValue(cohort: string): string;
|
|
8
|
-
declare function getNumericCohortValue(cohort: string): number | null;
|
|
9
|
-
declare function isNumericCohort(cohort: string): boolean;
|
|
10
|
-
declare function isCustomCohort(cohort: string): boolean;
|
|
11
|
-
declare function isValidCohort(cohort: string): boolean;
|
|
12
|
-
declare function getDefaultNumericCohort(identifier: string): string;
|
|
13
|
-
declare function getNumericCohortRolloutPosition(bundleId: string, cohortValue: number): number;
|
|
14
|
-
declare function getRolledOutNumericCohorts(bundleId: string, rolloutCohortCount: number | null | undefined): number[];
|
|
15
|
-
declare function isCohortEligibleForUpdate(bundleId: string, cohort: string | null | undefined, rolloutCohortCount: number | null | undefined, targetCohorts: readonly string[] | null | undefined): boolean;
|
|
16
|
-
//#endregion
|
|
17
|
-
export { DEFAULT_ROLLOUT_COHORT_COUNT, INVALID_COHORT_ERROR_MESSAGE, MAX_COHORT_LENGTH, NUMERIC_COHORT_SIZE, getDefaultNumericCohort, getNumericCohortRolloutPosition, getNumericCohortValue, getRolledOutNumericCohorts, isCohortEligibleForUpdate, isCustomCohort, isNumericCohort, isValidCohort, normalizeCohortValue, normalizeRolloutCohortCount };
|
package/dist/rollout.d.mts
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
//#region src/rollout.d.ts
|
|
2
|
-
declare const NUMERIC_COHORT_SIZE = 1000;
|
|
3
|
-
declare const DEFAULT_ROLLOUT_COHORT_COUNT = 1000;
|
|
4
|
-
declare const MAX_COHORT_LENGTH = 64;
|
|
5
|
-
declare const INVALID_COHORT_ERROR_MESSAGE = "Invalid cohort. Use 1-1000 or a lowercase slug without spaces, up to 64 characters.";
|
|
6
|
-
declare function normalizeRolloutCohortCount(rolloutCohortCount: number | null | undefined): number;
|
|
7
|
-
declare function normalizeCohortValue(cohort: string): string;
|
|
8
|
-
declare function getNumericCohortValue(cohort: string): number | null;
|
|
9
|
-
declare function isNumericCohort(cohort: string): boolean;
|
|
10
|
-
declare function isCustomCohort(cohort: string): boolean;
|
|
11
|
-
declare function isValidCohort(cohort: string): boolean;
|
|
12
|
-
declare function getDefaultNumericCohort(identifier: string): string;
|
|
13
|
-
declare function getNumericCohortRolloutPosition(bundleId: string, cohortValue: number): number;
|
|
14
|
-
declare function getRolledOutNumericCohorts(bundleId: string, rolloutCohortCount: number | null | undefined): number[];
|
|
15
|
-
declare function isCohortEligibleForUpdate(bundleId: string, cohort: string | null | undefined, rolloutCohortCount: number | null | undefined, targetCohorts: readonly string[] | null | undefined): boolean;
|
|
16
|
-
//#endregion
|
|
17
|
-
export { DEFAULT_ROLLOUT_COHORT_COUNT, INVALID_COHORT_ERROR_MESSAGE, MAX_COHORT_LENGTH, NUMERIC_COHORT_SIZE, getDefaultNumericCohort, getNumericCohortRolloutPosition, getNumericCohortValue, getRolledOutNumericCohorts, isCohortEligibleForUpdate, isCustomCohort, isNumericCohort, isValidCohort, normalizeCohortValue, normalizeRolloutCohortCount };
|
package/dist/rollout.mjs
DELETED
|
@@ -1,118 +0,0 @@
|
|
|
1
|
-
//#region src/rollout.ts
|
|
2
|
-
const NUMERIC_COHORT_SIZE = 1e3;
|
|
3
|
-
const DEFAULT_ROLLOUT_COHORT_COUNT = NUMERIC_COHORT_SIZE;
|
|
4
|
-
const MAX_COHORT_LENGTH = 64;
|
|
5
|
-
const INVALID_COHORT_ERROR_MESSAGE = `Invalid cohort. Use 1-1000 or a lowercase slug without spaces, up to 64 characters.`;
|
|
6
|
-
const CUSTOM_COHORT_PATTERN = /^[a-z0-9-]+$/;
|
|
7
|
-
function parseNumericCohortValue(cohort) {
|
|
8
|
-
if (!/^\d+$/.test(cohort)) return null;
|
|
9
|
-
const parsed = Number.parseInt(cohort, 10);
|
|
10
|
-
if (Number.isNaN(parsed) || parsed < 1 || parsed > 1e3) return null;
|
|
11
|
-
return parsed;
|
|
12
|
-
}
|
|
13
|
-
function positiveMod(value, modulus) {
|
|
14
|
-
return (value % modulus + modulus) % modulus;
|
|
15
|
-
}
|
|
16
|
-
function hashString(value) {
|
|
17
|
-
let hash = 0;
|
|
18
|
-
for (let i = 0; i < value.length; i++) {
|
|
19
|
-
const char = value.charCodeAt(i);
|
|
20
|
-
hash = (hash << 5) - hash + char;
|
|
21
|
-
hash |= 0;
|
|
22
|
-
}
|
|
23
|
-
return hash;
|
|
24
|
-
}
|
|
25
|
-
function gcd(a, b) {
|
|
26
|
-
let x = Math.abs(a);
|
|
27
|
-
let y = Math.abs(b);
|
|
28
|
-
while (y !== 0) {
|
|
29
|
-
const next = x % y;
|
|
30
|
-
x = y;
|
|
31
|
-
y = next;
|
|
32
|
-
}
|
|
33
|
-
return x;
|
|
34
|
-
}
|
|
35
|
-
function modularInverse(value, modulus) {
|
|
36
|
-
let t = 0;
|
|
37
|
-
let newT = 1;
|
|
38
|
-
let r = modulus;
|
|
39
|
-
let newR = positiveMod(value, modulus);
|
|
40
|
-
while (newR !== 0) {
|
|
41
|
-
const quotient = Math.floor(r / newR);
|
|
42
|
-
[t, newT] = [newT, t - quotient * newT];
|
|
43
|
-
[r, newR] = [newR, r - quotient * newR];
|
|
44
|
-
}
|
|
45
|
-
if (r > 1) throw new Error(`No modular inverse for ${value} mod ${modulus}`);
|
|
46
|
-
return positiveMod(t, modulus);
|
|
47
|
-
}
|
|
48
|
-
function getRolloutShuffleParameters(bundleId) {
|
|
49
|
-
let multiplier = positiveMod(hashString(`${bundleId}:multiplier`), 997);
|
|
50
|
-
if (multiplier === 0) multiplier = 1;
|
|
51
|
-
while (gcd(multiplier, NUMERIC_COHORT_SIZE) !== 1) {
|
|
52
|
-
multiplier = positiveMod(multiplier + 1, NUMERIC_COHORT_SIZE);
|
|
53
|
-
if (multiplier === 0) multiplier = 1;
|
|
54
|
-
}
|
|
55
|
-
const offset = positiveMod(hashString(`${bundleId}:offset`), NUMERIC_COHORT_SIZE);
|
|
56
|
-
return {
|
|
57
|
-
multiplier,
|
|
58
|
-
offset,
|
|
59
|
-
inverseMultiplier: modularInverse(multiplier, NUMERIC_COHORT_SIZE)
|
|
60
|
-
};
|
|
61
|
-
}
|
|
62
|
-
function normalizeRolloutCohortCount(rolloutCohortCount) {
|
|
63
|
-
if (rolloutCohortCount === null || rolloutCohortCount === void 0) return DEFAULT_ROLLOUT_COHORT_COUNT;
|
|
64
|
-
if (rolloutCohortCount <= 0) return 0;
|
|
65
|
-
if (rolloutCohortCount >= 1e3) return NUMERIC_COHORT_SIZE;
|
|
66
|
-
return Math.floor(rolloutCohortCount);
|
|
67
|
-
}
|
|
68
|
-
function normalizeCohortValue(cohort) {
|
|
69
|
-
const normalized = cohort.trim().toLowerCase();
|
|
70
|
-
const numericCohort = parseNumericCohortValue(normalized);
|
|
71
|
-
if (numericCohort !== null) return String(numericCohort);
|
|
72
|
-
return normalized;
|
|
73
|
-
}
|
|
74
|
-
function getNumericCohortValue(cohort) {
|
|
75
|
-
return parseNumericCohortValue(normalizeCohortValue(cohort));
|
|
76
|
-
}
|
|
77
|
-
function isNumericCohort(cohort) {
|
|
78
|
-
return getNumericCohortValue(cohort) !== null;
|
|
79
|
-
}
|
|
80
|
-
function isCustomCohort(cohort) {
|
|
81
|
-
const normalized = normalizeCohortValue(cohort);
|
|
82
|
-
return normalized.length > 0 && normalized.length <= 64 && !/^\d+$/.test(normalized) && CUSTOM_COHORT_PATTERN.test(normalized);
|
|
83
|
-
}
|
|
84
|
-
function isValidCohort(cohort) {
|
|
85
|
-
const normalized = normalizeCohortValue(cohort);
|
|
86
|
-
return isNumericCohort(normalized) || isCustomCohort(normalized);
|
|
87
|
-
}
|
|
88
|
-
function getDefaultNumericCohort(identifier) {
|
|
89
|
-
const cohortValue = positiveMod(hashString(identifier), NUMERIC_COHORT_SIZE) + 1;
|
|
90
|
-
return String(cohortValue);
|
|
91
|
-
}
|
|
92
|
-
function getNumericCohortRolloutPosition(bundleId, cohortValue) {
|
|
93
|
-
if (cohortValue < 1 || cohortValue > 1e3) throw new Error(`Invalid numeric cohort: ${cohortValue}`);
|
|
94
|
-
const { offset, inverseMultiplier } = getRolloutShuffleParameters(bundleId);
|
|
95
|
-
return positiveMod(inverseMultiplier * (cohortValue - 1 - offset), NUMERIC_COHORT_SIZE);
|
|
96
|
-
}
|
|
97
|
-
function getRolledOutNumericCohorts(bundleId, rolloutCohortCount) {
|
|
98
|
-
const normalizedRolloutCount = normalizeRolloutCohortCount(rolloutCohortCount);
|
|
99
|
-
if (normalizedRolloutCount <= 0) return [];
|
|
100
|
-
return Array.from({ length: NUMERIC_COHORT_SIZE }, (_, index) => index + 1).filter((cohortValue) => {
|
|
101
|
-
if (normalizedRolloutCount >= 1e3) return true;
|
|
102
|
-
return getNumericCohortRolloutPosition(bundleId, cohortValue) < normalizedRolloutCount;
|
|
103
|
-
});
|
|
104
|
-
}
|
|
105
|
-
function isCohortEligibleForUpdate(bundleId, cohort, rolloutCohortCount, targetCohorts) {
|
|
106
|
-
const normalizedCohort = cohort === null || cohort === void 0 ? void 0 : normalizeCohortValue(cohort);
|
|
107
|
-
const normalizedTargetCohorts = targetCohorts?.map((targetCohort) => normalizeCohortValue(targetCohort)) ?? [];
|
|
108
|
-
if (normalizedTargetCohorts.length > 0) return normalizedCohort !== void 0 && normalizedTargetCohorts.includes(normalizedCohort);
|
|
109
|
-
const normalizedRolloutCount = normalizeRolloutCohortCount(rolloutCohortCount);
|
|
110
|
-
if (normalizedRolloutCount <= 0) return false;
|
|
111
|
-
if (normalizedCohort === void 0) return normalizedRolloutCount >= NUMERIC_COHORT_SIZE;
|
|
112
|
-
const numericCohort = getNumericCohortValue(normalizedCohort);
|
|
113
|
-
if (numericCohort === null) return false;
|
|
114
|
-
if (normalizedRolloutCount >= 1e3) return true;
|
|
115
|
-
return getNumericCohortRolloutPosition(bundleId, numericCohort) < normalizedRolloutCount;
|
|
116
|
-
}
|
|
117
|
-
//#endregion
|
|
118
|
-
export { DEFAULT_ROLLOUT_COHORT_COUNT, INVALID_COHORT_ERROR_MESSAGE, MAX_COHORT_LENGTH, NUMERIC_COHORT_SIZE, getDefaultNumericCohort, getNumericCohortRolloutPosition, getNumericCohortValue, getRolledOutNumericCohorts, isCohortEligibleForUpdate, isCustomCohort, isNumericCohort, isValidCohort, normalizeCohortValue, normalizeRolloutCohortCount };
|
package/dist/types.cjs
DELETED
|
File without changes
|