@aramiworks/app-updates 0.0.0 → 0.1.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.
@@ -1,40 +0,0 @@
1
- import { type FirebaseRelease, type NativeDistribution, type PlayUpdateInfo } from './native';
2
- import { type AppStoreOptions } from './sources/appStore';
3
- import type { StoreUpdate } from './types';
4
- /** Budget for one store lookup before it resolves `{ kind: 'error' }` (8 seconds). */
5
- export declare const STORE_CHECK_TIMEOUT_MS = 8000;
6
- export interface StoreCheckEnv {
7
- platform: 'ios' | 'android' | 'web';
8
- channel: string | null;
9
- installed: string | null;
10
- bundleId: string | null;
11
- country: string | null;
12
- distribution: NativeDistribution;
13
- }
14
- export interface StoreCheckDeps {
15
- checkAppStore: (opts: AppStoreOptions) => Promise<{
16
- version: string;
17
- url: string;
18
- } | null>;
19
- getPlayUpdateInfo: () => Promise<PlayUpdateInfo>;
20
- isFirebaseAvailable: () => boolean;
21
- isTesterSignedIn: () => Promise<boolean>;
22
- checkFirebaseRelease: () => Promise<FirebaseRelease | null>;
23
- }
24
- /**
25
- * `update`: a newer version exists. `none`: the source answered definitively that nothing
26
- * newer exists. `error`: unknown (throw, timeout, missing input, or Firebase can't be verified).
27
- */
28
- export type StoreCheckResult = {
29
- kind: 'update';
30
- update: StoreUpdate;
31
- } | {
32
- kind: 'none';
33
- } | {
34
- kind: 'error';
35
- };
36
- /**
37
- * Checks the store this build ships through for a newer major.minor.
38
- * Never throws: errors and an 8 s timeout resolve `{ kind: 'error' }`.
39
- */
40
- export declare function checkStoreUpdate(env: StoreCheckEnv, deps?: Partial<StoreCheckDeps>): Promise<StoreCheckResult>;
@@ -1,112 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.STORE_CHECK_TIMEOUT_MS = void 0;
4
- exports.checkStoreUpdate = checkStoreUpdate;
5
- const native_1 = require("./native");
6
- const appStore_1 = require("./sources/appStore");
7
- const version_1 = require("./version");
8
- /** Budget for one store lookup before it resolves `{ kind: 'error' }` (8 seconds). */
9
- exports.STORE_CHECK_TIMEOUT_MS = 8_000;
10
- const REAL_DEPS = {
11
- checkAppStore: appStore_1.checkAppStore,
12
- getPlayUpdateInfo: native_1.getPlayUpdateInfo,
13
- isFirebaseAvailable: native_1.isFirebaseAvailable,
14
- isTesterSignedIn: native_1.isTesterSignedIn,
15
- checkFirebaseRelease: native_1.checkFirebaseRelease,
16
- };
17
- const NONE = { kind: 'none' };
18
- const ERROR = { kind: 'error' };
19
- /** A definitive candidate, a definitive "nothing" (null) or an unknown (ERROR). */
20
- async function findCandidate(env, deps, signal) {
21
- // Android develop builds are the firebase flavor; iOS reports distribution "none",
22
- // so develop is the only iOS Firebase signal. Never call Firebase in the play flavor.
23
- const isFirebase = env.channel === 'develop' || (env.platform === 'android' && env.distribution === 'firebase');
24
- if (isFirebase) {
25
- // Signed out, or no Firebase at all: we can't verify, so it is unknown, not "nothing".
26
- if (!deps.isFirebaseAvailable())
27
- return ERROR;
28
- if (!(await deps.isTesterSignedIn()))
29
- return ERROR;
30
- const release = await deps.checkFirebaseRelease();
31
- if (!release)
32
- return null;
33
- const version = (0, version_1.parseMajorMinor)(release.displayVersion);
34
- return version ? { version, source: 'firebase', url: null } : ERROR;
35
- }
36
- if (env.platform === 'ios') {
37
- if (!env.bundleId)
38
- return ERROR;
39
- const listing = await deps.checkAppStore({
40
- bundleId: env.bundleId,
41
- country: env.country,
42
- signal,
43
- });
44
- if (!listing)
45
- return null;
46
- const version = (0, version_1.parseMajorMinor)(listing.version);
47
- return version ? { version, source: 'app-store', url: listing.url } : ERROR;
48
- }
49
- if (env.platform === 'android') {
50
- if (!env.bundleId)
51
- return ERROR;
52
- const info = await deps.getPlayUpdateInfo();
53
- if (!info.updateAvailable)
54
- return null;
55
- const code = info.availableVersionCode;
56
- if (!Number.isInteger(code) || code < 0)
57
- return ERROR;
58
- const { major, minor } = (0, version_1.decodeVersionCode)(code);
59
- return {
60
- version: { major, minor },
61
- source: 'play',
62
- url: `https://play.google.com/store/apps/details?id=${encodeURIComponent(env.bundleId)}`,
63
- };
64
- }
65
- return null;
66
- }
67
- /**
68
- * Checks the store this build ships through for a newer major.minor.
69
- * Never throws: errors and an 8 s timeout resolve `{ kind: 'error' }`.
70
- */
71
- async function checkStoreUpdate(env, deps) {
72
- try {
73
- if (env.platform === 'web')
74
- return NONE;
75
- const installed = (0, version_1.parseMajorMinor)(env.installed);
76
- if (!installed)
77
- return ERROR;
78
- const controller = new AbortController();
79
- let timer;
80
- const timeout = new Promise((resolve) => {
81
- timer = setTimeout(() => {
82
- controller.abort();
83
- resolve(ERROR);
84
- }, exports.STORE_CHECK_TIMEOUT_MS);
85
- });
86
- try {
87
- const candidate = await Promise.race([
88
- findCandidate(env, { ...REAL_DEPS, ...deps }, controller.signal),
89
- timeout,
90
- ]);
91
- if (candidate && 'kind' in candidate)
92
- return ERROR;
93
- if (!candidate || !(0, version_1.isNewerMajorMinor)(installed, candidate.version))
94
- return NONE;
95
- return {
96
- kind: 'update',
97
- update: {
98
- installed: (0, version_1.formatMajorMinor)(installed),
99
- available: (0, version_1.formatMajorMinor)(candidate.version),
100
- source: candidate.source,
101
- url: candidate.url,
102
- },
103
- };
104
- }
105
- finally {
106
- clearTimeout(timer);
107
- }
108
- }
109
- catch {
110
- return ERROR;
111
- }
112
- }
package/build/tester.d.ts DELETED
@@ -1,22 +0,0 @@
1
- import type { KeyValueStore } from './cache';
2
- import type { StoreCheckEnv } from './storeCheck';
3
- export declare const TESTER_DISMISSED_KEY = "aramiworks.app-updates.tester-dismissed-at";
4
- export declare const TESTER_DISMISS_MS: number;
5
- export interface TesterState {
6
- /** null when unknown or not applicable. */
7
- signedIn: boolean | null;
8
- promptVisible: boolean;
9
- signIn: () => Promise<void>;
10
- dismissPrompt: () => void;
11
- }
12
- export declare const INERT_TESTER: TesterState;
13
- /** The Firebase tester prompt only applies to Firebase-distributed builds. */
14
- export declare function isFirebaseBuild(env: StoreCheckEnv): boolean;
15
- interface TesterDeps {
16
- store: KeyValueStore;
17
- now: () => number;
18
- isTesterSignedIn: () => Promise<boolean>;
19
- signInTester: () => Promise<void>;
20
- }
21
- export declare function useTester(applicable: boolean, deps: TesterDeps, recheckStore: () => void, isMounted: () => boolean): TesterState;
22
- export {};
package/build/tester.js DELETED
@@ -1,78 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.INERT_TESTER = exports.TESTER_DISMISS_MS = exports.TESTER_DISMISSED_KEY = void 0;
4
- exports.isFirebaseBuild = isFirebaseBuild;
5
- exports.useTester = useTester;
6
- const react_1 = require("react");
7
- exports.TESTER_DISMISSED_KEY = 'aramiworks.app-updates.tester-dismissed-at';
8
- exports.TESTER_DISMISS_MS = 7 * 24 * 60 * 60 * 1000;
9
- exports.INERT_TESTER = {
10
- signedIn: null,
11
- promptVisible: false,
12
- signIn: async () => { },
13
- dismissPrompt: () => { },
14
- };
15
- /** The Firebase tester prompt only applies to Firebase-distributed builds. */
16
- function isFirebaseBuild(env) {
17
- if (env.platform === 'android') {
18
- return env.distribution === 'firebase' || env.channel === 'develop';
19
- }
20
- return env.platform === 'ios' && env.channel === 'develop';
21
- }
22
- /**
23
- * Dismissal counts while it is under 7 days old. Future or non-numeric timestamps
24
- * count as expired. Expiry is judged when the hook loads (next launch), not live.
25
- */
26
- async function loadDismissed(store, now) {
27
- try {
28
- const at = Number(await store.getItem(exports.TESTER_DISMISSED_KEY));
29
- return Number.isFinite(at) && at > 0 && now - at >= 0 && now - at < exports.TESTER_DISMISS_MS;
30
- }
31
- catch {
32
- return false;
33
- }
34
- }
35
- function useTester(applicable, deps, recheckStore, isMounted) {
36
- const [signedIn, setSignedIn] = (0, react_1.useState)(null);
37
- const [dismissed, setDismissed] = (0, react_1.useState)(null);
38
- const { store, now, isTesterSignedIn, signInTester } = deps;
39
- const querySignedIn = (0, react_1.useCallback)(async () => {
40
- try {
41
- return await isTesterSignedIn();
42
- }
43
- catch {
44
- return null;
45
- }
46
- }, [isTesterSignedIn]);
47
- (0, react_1.useEffect)(() => {
48
- if (!applicable)
49
- return;
50
- querySignedIn().then((v) => {
51
- if (isMounted())
52
- setSignedIn(v);
53
- });
54
- loadDismissed(store, now()).then((d) => {
55
- if (isMounted())
56
- setDismissed(d);
57
- });
58
- }, [applicable, querySignedIn, store, now, isMounted]);
59
- const signIn = (0, react_1.useCallback)(async () => {
60
- await signInTester();
61
- const v = await querySignedIn();
62
- if (isMounted())
63
- setSignedIn(v);
64
- recheckStore();
65
- }, [signInTester, querySignedIn, isMounted, recheckStore]);
66
- const dismissPrompt = (0, react_1.useCallback)(() => {
67
- setDismissed(true);
68
- store.setItem(exports.TESTER_DISMISSED_KEY, String(now())).catch(() => { });
69
- }, [store, now]);
70
- if (!applicable)
71
- return exports.INERT_TESTER;
72
- return {
73
- signedIn,
74
- promptVisible: signedIn === false && dismissed === false,
75
- signIn,
76
- dismissPrompt,
77
- };
78
- }
@@ -1,3 +0,0 @@
1
- /** Minimum gap between foreground store/OTA checks (15 minutes). */
2
- export declare const CHECK_INTERVAL_MS: number;
3
- export declare function shouldCheck(lastAt: number | null, now: number): boolean;
package/build/throttle.js DELETED
@@ -1,11 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.CHECK_INTERVAL_MS = void 0;
4
- exports.shouldCheck = shouldCheck;
5
- /** Minimum gap between foreground store/OTA checks (15 minutes). */
6
- exports.CHECK_INTERVAL_MS = 15 * 60 * 1000;
7
- function shouldCheck(lastAt, now) {
8
- if (lastAt === null || !Number.isFinite(lastAt) || lastAt > now)
9
- return true;
10
- return now - lastAt >= exports.CHECK_INTERVAL_MS;
11
- }
package/build/types.d.ts DELETED
@@ -1,7 +0,0 @@
1
- export type Distribution = 'app-store' | 'play' | 'firebase';
2
- export interface StoreUpdate {
3
- installed: string;
4
- available: string;
5
- source: Distribution;
6
- url: string | null;
7
- }
package/build/types.js DELETED
@@ -1,2 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,3 +0,0 @@
1
- import type { AppUpdateState, UseAppUpdateOptions } from './useAppUpdateCore';
2
- export type { AppUpdateState, UseAppUpdateOptions } from './useAppUpdateCore';
3
- export declare function useAppUpdate(options?: UseAppUpdateOptions): AppUpdateState;
@@ -1,7 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.useAppUpdate = useAppUpdate;
4
- const useAppUpdateCore_1 = require("./useAppUpdateCore");
5
- function useAppUpdate(options = {}) {
6
- return (0, useAppUpdateCore_1.useAppUpdateWithDeps)(options, {});
7
- }
@@ -1,43 +0,0 @@
1
- import { readVerified, writeVerified, type KeyValueStore } from './cache';
2
- import { checkWarmOta, runColdStartOta } from './ota';
3
- import { checkStoreUpdate, type StoreCheckEnv } from './storeCheck';
4
- import { type TesterState } from './tester';
5
- import type { StoreUpdate } from './types';
6
- export interface UseAppUpdateOptions {
7
- /** false → inert state with no side effects (e.g. dev clients). Default true. */
8
- enabled?: boolean;
9
- }
10
- export interface AppUpdateState {
11
- /** true while the cold-start OTA runs; render NoticeTemplate "Updating…". */
12
- coldStartUpdating: boolean;
13
- /** Non-null → render the blocking NoticeTemplate; wins over everything else. */
14
- storeUpdate: StoreUpdate | null;
15
- openStore: () => Promise<void>;
16
- /** A warm OTA is downloaded; render the persistent Snackbar. */
17
- otaReady: boolean;
18
- restart: () => Promise<void>;
19
- dismissOta: () => void;
20
- /** Firebase builds only: inert (signedIn null, no prompt) elsewhere. */
21
- tester: TesterState;
22
- }
23
- /**
24
- * Every collaborator the hook uses. Tests pass a partial mock as the hook's second
25
- * parameter, so they need no global module mocks. Apps never pass it.
26
- */
27
- export interface AppUpdateDeps {
28
- getEnv: () => StoreCheckEnv;
29
- checkStoreUpdate: typeof checkStoreUpdate;
30
- runColdStartOta: typeof runColdStartOta;
31
- checkWarmOta: typeof checkWarmOta;
32
- readVerified: typeof readVerified;
33
- writeVerified: typeof writeVerified;
34
- isFirebaseAvailable: () => boolean;
35
- isTesterSignedIn: () => Promise<boolean>;
36
- signInTester: () => Promise<void>;
37
- openStore: (update: StoreUpdate) => Promise<void>;
38
- reload: () => Promise<void>;
39
- now: () => number;
40
- store: KeyValueStore;
41
- }
42
- /** Hook body with injectable collaborators. Internal: tests import it; the public hook wraps it. */
43
- export declare function useAppUpdateWithDeps(options: UseAppUpdateOptions, deps: Partial<AppUpdateDeps>): AppUpdateState;
@@ -1,209 +0,0 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || (function () {
19
- var ownKeys = function(o) {
20
- ownKeys = Object.getOwnPropertyNames || function (o) {
21
- var ar = [];
22
- for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
- return ar;
24
- };
25
- return ownKeys(o);
26
- };
27
- return function (mod) {
28
- if (mod && mod.__esModule) return mod;
29
- var result = {};
30
- if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
- __setModuleDefault(result, mod);
32
- return result;
33
- };
34
- })();
35
- Object.defineProperty(exports, "__esModule", { value: true });
36
- exports.useAppUpdateWithDeps = useAppUpdateWithDeps;
37
- const Updates = __importStar(require("expo-updates"));
38
- const react_1 = require("react");
39
- const react_native_1 = require("react-native");
40
- const cache_1 = require("./cache");
41
- const env_1 = require("./env");
42
- const native_1 = require("./native");
43
- const openStore_1 = require("./openStore");
44
- const ota_1 = require("./ota");
45
- const storeCheck_1 = require("./storeCheck");
46
- const tester_1 = require("./tester");
47
- const throttle_1 = require("./throttle");
48
- const DEFAULT_DEPS = {
49
- getEnv: env_1.getEnv,
50
- checkStoreUpdate: storeCheck_1.checkStoreUpdate,
51
- runColdStartOta: ota_1.runColdStartOta,
52
- checkWarmOta: ota_1.checkWarmOta,
53
- readVerified: cache_1.readVerified,
54
- writeVerified: cache_1.writeVerified,
55
- isFirebaseAvailable: native_1.isFirebaseAvailable,
56
- isTesterSignedIn: native_1.isTesterSignedIn,
57
- signInTester: native_1.signInTester,
58
- openStore: (update) => (0, openStore_1.openStore)(update),
59
- reload: () => Updates.reloadAsync(),
60
- now: Date.now,
61
- store: cache_1.secureStore,
62
- };
63
- const INERT = {
64
- coldStartUpdating: false,
65
- storeUpdate: null,
66
- openStore: async () => { },
67
- otaReady: false,
68
- restart: async () => { },
69
- dismissOta: () => { },
70
- tester: tester_1.INERT_TESTER,
71
- };
72
- const NULL_OTA_ID = '\0no-update-id';
73
- /** Hook body with injectable collaborators. Internal: tests import it; the public hook wraps it. */
74
- function useAppUpdateWithDeps(options, deps) {
75
- const d = { ...DEFAULT_DEPS };
76
- for (const key of Object.keys(deps)) {
77
- if (deps[key] !== undefined)
78
- d[key] = deps[key];
79
- }
80
- const depsRef = (0, react_1.useRef)(d);
81
- (0, react_1.useEffect)(() => {
82
- depsRef.current = d;
83
- });
84
- // The environment is read once per mount. `enabled` is honoured at mount; flipping it
85
- // from false to true later does not start checks until the component remounts.
86
- const [env] = (0, react_1.useState)(() => options.enabled !== false ? d.getEnv() : null);
87
- const active = env !== null && env.platform !== 'web';
88
- const mounted = (0, react_1.useRef)(true);
89
- const started = (0, react_1.useRef)(false);
90
- const lastCheckAt = (0, react_1.useRef)(null);
91
- const dismissedOta = (0, react_1.useRef)(new Set());
92
- const [coldStartUpdating, setColdStartUpdating] = (0, react_1.useState)(active);
93
- const [storeUpdate, setStoreUpdate] = (0, react_1.useState)(null);
94
- const [otaKey, setOtaKey] = (0, react_1.useState)(null);
95
- const isMounted = (0, react_1.useCallback)(() => mounted.current, []);
96
- (0, react_1.useEffect)(() => {
97
- mounted.current = true;
98
- return () => {
99
- mounted.current = false;
100
- };
101
- }, []);
102
- const runStoreCheck = (0, react_1.useCallback)(async () => {
103
- if (!env)
104
- return;
105
- const { checkStoreUpdate: check, writeVerified: write, store, now } = depsRef.current;
106
- try {
107
- const result = await check(env);
108
- if (result.kind === 'update') {
109
- await write(store, result.update, now());
110
- if (mounted.current)
111
- setStoreUpdate(result.update);
112
- }
113
- else if (result.kind === 'none') {
114
- // The source said definitively nothing newer exists: lift the gate.
115
- await (0, cache_1.clearVerified)(store);
116
- if (mounted.current)
117
- setStoreUpdate(null);
118
- }
119
- // 'error': keep the current state and cache (fail open without unblocking).
120
- }
121
- catch {
122
- // checkStoreUpdate never throws; stay fail-open if a fake does
123
- }
124
- }, [env]);
125
- const runWarmCheck = (0, react_1.useCallback)(async () => {
126
- try {
127
- const r = await depsRef.current.checkWarmOta();
128
- if (!r.ready || !mounted.current)
129
- return;
130
- const key = r.updateId ?? NULL_OTA_ID;
131
- if (!dismissedOta.current.has(key))
132
- setOtaKey(key);
133
- }
134
- catch {
135
- // checkWarmOta never throws
136
- }
137
- }, []);
138
- const recheckStore = (0, react_1.useCallback)(() => {
139
- lastCheckAt.current = depsRef.current.now();
140
- runStoreCheck();
141
- }, [runStoreCheck]);
142
- (0, react_1.useEffect)(() => {
143
- if (!active || !env)
144
- return;
145
- const { readVerified: readCache, runColdStartOta: coldStart, store, now } = depsRef.current;
146
- // One-shot mount work runs once per hook instance, even if StrictMode re-runs the effect.
147
- if (!started.current) {
148
- started.current = true;
149
- lastCheckAt.current = now();
150
- if (env.installed) {
151
- readCache(store, env.installed, now()).then((cached) => {
152
- if (cached && mounted.current)
153
- setStoreUpdate((prev) => prev ?? cached);
154
- });
155
- }
156
- runStoreCheck();
157
- coldStart()
158
- .then((result) => {
159
- if (result !== 'reloading' && mounted.current)
160
- setColdStartUpdating(false);
161
- })
162
- .catch(() => {
163
- if (mounted.current)
164
- setColdStartUpdating(false);
165
- });
166
- }
167
- const sub = react_native_1.AppState.addEventListener('change', (state) => {
168
- if (state !== 'active')
169
- return;
170
- const at = depsRef.current.now();
171
- if (!(0, throttle_1.shouldCheck)(lastCheckAt.current, at))
172
- return;
173
- lastCheckAt.current = at;
174
- runStoreCheck();
175
- runWarmCheck();
176
- });
177
- return () => sub.remove();
178
- }, [active, env, runStoreCheck, runWarmCheck]);
179
- const blocked = storeUpdate !== null;
180
- const isAndroid = env?.platform === 'android';
181
- (0, react_1.useEffect)(() => {
182
- if (!blocked || !isAndroid)
183
- return;
184
- const sub = react_native_1.BackHandler.addEventListener('hardwareBackPress', () => true);
185
- return () => sub.remove();
186
- }, [blocked, isAndroid]);
187
- const tester = (0, tester_1.useTester)(active && env !== null && (0, tester_1.isFirebaseBuild)(env) && d.isFirebaseAvailable(), d, recheckStore, isMounted);
188
- const openStore = (0, react_1.useCallback)(async () => {
189
- if (storeUpdate)
190
- await depsRef.current.openStore(storeUpdate);
191
- }, [storeUpdate]);
192
- const restart = (0, react_1.useCallback)(() => depsRef.current.reload(), []);
193
- const dismissOta = (0, react_1.useCallback)(() => {
194
- if (otaKey !== null)
195
- dismissedOta.current.add(otaKey);
196
- setOtaKey(null);
197
- }, [otaKey]);
198
- if (!active)
199
- return INERT;
200
- return {
201
- coldStartUpdating,
202
- storeUpdate,
203
- openStore,
204
- otaReady: otaKey !== null && storeUpdate === null,
205
- restart,
206
- dismissOta,
207
- tester,
208
- };
209
- }
@@ -1,13 +0,0 @@
1
- export type MajorMinor = {
2
- major: number;
3
- minor: number;
4
- };
5
- /** Reads the leading `v?<int>.<int>` of a version string; anything else yields null. */
6
- export declare function parseMajorMinor(v: string | null | undefined): MajorMinor | null;
7
- /** True when the candidate's major.minor is strictly greater than the installed one. */
8
- export declare function isNewerMajorMinor(installed: MajorMinor, candidate: MajorMinor): boolean;
9
- /** Android versionCode is `major * 1_000_000 + minor * 1_000 + build`. */
10
- export declare function decodeVersionCode(code: number): MajorMinor & {
11
- build: number;
12
- };
13
- export declare function formatMajorMinor(v: MajorMinor): string;
package/build/version.js DELETED
@@ -1,32 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.parseMajorMinor = parseMajorMinor;
4
- exports.isNewerMajorMinor = isNewerMajorMinor;
5
- exports.decodeVersionCode = decodeVersionCode;
6
- exports.formatMajorMinor = formatMajorMinor;
7
- const LEADING_MAJOR_MINOR = /^v?(\d+)\.(\d+)/;
8
- /** Reads the leading `v?<int>.<int>` of a version string; anything else yields null. */
9
- function parseMajorMinor(v) {
10
- if (!v)
11
- return null;
12
- const match = LEADING_MAJOR_MINOR.exec(v);
13
- if (!match)
14
- return null;
15
- return { major: Number(match[1]), minor: Number(match[2]) };
16
- }
17
- /** True when the candidate's major.minor is strictly greater than the installed one. */
18
- function isNewerMajorMinor(installed, candidate) {
19
- if (candidate.major !== installed.major)
20
- return candidate.major > installed.major;
21
- return candidate.minor > installed.minor;
22
- }
23
- /** Android versionCode is `major * 1_000_000 + minor * 1_000 + build`. */
24
- function decodeVersionCode(code) {
25
- const major = Math.floor(code / 1_000_000);
26
- const minor = Math.floor((code % 1_000_000) / 1_000);
27
- const build = code % 1_000;
28
- return { major, minor, build };
29
- }
30
- function formatMajorMinor(v) {
31
- return `${v.major}.${v.minor}`;
32
- }
@@ -1,16 +0,0 @@
1
- /**
2
- * Pure string transforms over the app-level `android/app/build.gradle` (Groovy).
3
- * Kept free of Expo imports so they are trivially testable.
4
- */
5
- export declare const MARKER = "// @aramiworks/app-updates";
6
- export declare const DISTRIBUTION_DIMENSION = "distribution";
7
- export declare const DISTRIBUTION_RESOURCE = "app_updates_distribution";
8
- export declare function addDistributionFlavors(appBuildGradle: string): string;
9
- export declare function addFirebaseDependency(appBuildGradle: string, version: string): string;
10
- export declare const DEBUGGABLE_VARIANTS: readonly ["playDebug", "firebaseDebug"];
11
- /**
12
- * With flavors the RN Gradle plugin's debug variants are `playDebug` / `firebaseDebug`;
13
- * its default `debuggableVariants = ["debug"]` matches none of them (exact variant name,
14
- * case-insensitive), so debug builds would bundle JS instead of loading from Metro.
15
- */
16
- export declare function setDebuggableVariants(appBuildGradle: string): string;