From 372458b2dd604198570c1cca3caf61ef8de5a7a9 Mon Sep 17 00:00:00 2001 From: czy Date: Tue, 24 Nov 2026 23:16:47 -0600 Subject: [PATCH 1/6] CI: check the README install lines with strict peer rules Adds scripts/check-install-lines.mjs and a CI job (install-lines) that packs the SDK and resolves the README's bare and Expo install lines in throwaway lockfile-only apps (react-native@latest; expo@latest with the versions expo install picks), failing on any ERESOLVE or invalid peer. Also runs weekly. This commit adds the guard only, so it fails on the current react-native-get-random-values peer range (^1.8.0; latest is 2.1.0). Co-Authored-By: Claude Opus --- .github/workflows/ci.yml | 19 +++++ scripts/check-install-lines.mjs | 147 ++++++++++++++++++++++++++++++++ 2 files changed, 166 insertions(+) create mode 100644 scripts/check-install-lines.mjs diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 4cc2948a..67f6e793 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -6,6 +6,10 @@ on: push: branches: [main] pull_request: + # Weekly, so a new major of a peer that the README installs unpinned fails + # here before a customer's install does. + schedule: + - cron: '17 13 * * 1' # A newer commit on the same PR cancels the older run; each push to main keeps # its own run. @@ -36,3 +40,18 @@ jobs: - run: npm test -- --ci # scripts/validate-ios.sh compiles the native module inside a local Expo # app; it stays a manual pre-release step. + + install-lines: + # The README install lines, resolved with npm's strict peer rules against + # today's published versions. `test` above installs with + # --legacy-peer-deps and so cannot see a peer conflict. Lockfile only: no + # node_modules, no app build. + runs-on: ubuntu-latest + timeout-minutes: 10 + steps: + - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + - uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7.1.0 + with: + node-version: 22 + - name: README install lines resolve without peer conflicts + run: node scripts/check-install-lines.mjs diff --git a/scripts/check-install-lines.mjs b/scripts/check-install-lines.mjs new file mode 100644 index 00000000..de6455e3 --- /dev/null +++ b/scripts/check-install-lines.mjs @@ -0,0 +1,147 @@ +#!/usr/bin/env node +// Checks that the two README install lines resolve with npm's strict peer +// rules (no --legacy-peer-deps), against today's published versions. +// +// - Bare: a throwaway app with react-native@latest, then the README's bare +// `npm install` line, with the packed SDK in place of @datalyr/react-native. +// - Expo: a throwaway app with expo@latest and the react / react-native it +// bundles, then the README's `npx expo install` line, each package at the +// version expo@latest's bundledNativeModules.json names (what +// `expo install` picks), or latest when it names none. +// +// Only a lockfile is written (--package-lock-only): nothing is downloaded +// beyond package metadata, and no React Native app is built. A peer conflict +// (ERESOLVE) makes npm exit non-zero, which fails this script. +// +// Usage: node scripts/check-install-lines.mjs +// INSTALL_CHECK_DIR sets the scratch directory (default: a new temp dir). + +import { execFileSync, spawnSync } from 'node:child_process'; +import { mkdtempSync, mkdirSync, readFileSync, writeFileSync } from 'node:fs'; +import { tmpdir } from 'node:os'; +import { join, resolve } from 'node:path'; + +const repoRoot = resolve(import.meta.dirname, '..'); +const readme = readFileSync(join(repoRoot, 'README.md'), 'utf8').split('\n'); + +const bareLine = readme.find((line) => line.startsWith('npm install @datalyr/react-native ')); +const expoLine = readme.find((line) => line.startsWith('npx expo install @datalyr/react-native ')); +if (!bareLine || !expoLine) { + console.error('README: could not find both install lines'); + process.exit(1); +} + +const base = process.env.INSTALL_CHECK_DIR + ? resolve(process.env.INSTALL_CHECK_DIR) + : mkdtempSync(join(tmpdir(), 'install-lines-')); +mkdirSync(base, { recursive: true }); + +function run(cmd, args, cwd) { + console.log(`$ (${cwd}) ${cmd} ${args.join(' ')}`); + return execFileSync(cmd, args, { cwd, stdio: ['ignore', 'pipe', 'inherit'], encoding: 'utf8' }); +} + +// npm either stops on a peer conflict (`npm error ERESOLVE`) or, when the +// conflicting package is named in the same command, installs it anyway with +// `npm warn ERESOLVE overriding peer dependency`. Both are a broken install +// for a customer, so both fail here. +function npmInstall(args, cwd) { + console.log(`$ (${cwd}) npm install ${args.join(' ')}`); + const res = spawnSync('npm', ['install', ...npmFlags, ...args], { cwd, encoding: 'utf8' }); + const lines = `${res.stdout}\n${res.stderr}`.split('\n').filter((l) => !/npm warn deprecated/.test(l)); + console.log(lines.join('\n').trim()); + if (res.status !== 0) throw new Error(`npm install exited ${res.status}`); + if (lines.some((l) => l.includes('ERESOLVE'))) throw new Error('npm reported ERESOLVE (peer conflict)'); +} + +// Every peer in the resulting lockfile must be satisfied. +function checkTree(cwd) { + console.log(`$ (${cwd}) npm ls --all --package-lock-only`); + const res = spawnSync('npm', ['ls', '--all', '--package-lock-only'], { cwd, encoding: 'utf8' }); + const bad = `${res.stdout}\n${res.stderr}`.split('\n').filter((l) => /invalid|ERR|missing/.test(l)); + if (res.status !== 0 || bad.length) { + console.log(bad.join('\n')); + throw new Error('npm ls found an invalid or missing dependency'); + } +} + +const npmFlags = ['--package-lock-only', '--no-audit', '--no-fund', '--ignore-scripts']; + +// Pack the SDK as a customer receives it. +const packDir = join(base, 'pack'); +mkdirSync(packDir, { recursive: true }); +const packed = JSON.parse(run('npm', ['pack', '--json', '--ignore-scripts', '--pack-destination', packDir], repoRoot)); +const tarball = join(packDir, packed[0].filename); + +// Package names after "@datalyr/react-native" in a README line, with any +// version spec the line gives ("name@^2" stays "name@^2"). +function packagesOf(line, prefix) { + return line + .slice(prefix.length) + .trim() + .split(/\s+/) + .filter((word) => word && !word.startsWith('-')); +} +const nameOf = (spec) => spec.replace(/(.)@[^/]*$/, '$1'); + +function newApp(name) { + const dir = join(base, name); + mkdirSync(dir, { recursive: true }); + writeFileSync(join(dir, 'package.json'), JSON.stringify({ name, version: '0.0.0', private: true }, null, 2)); + return dir; +} + +let failed = false; +function scenario(title, fn) { + console.log(`\n=== ${title} ===`); + try { + fn(); + console.log(`PASS: ${title}`); + } catch (err) { + failed = true; + console.error(`FAIL: ${title} (${err.message.split('\n')[0]})`); + } +} + +scenario('bare README line on react-native@latest', () => { + const dir = newApp('bare-app'); + npmInstall(['react-native@latest'], dir); + const specs = packagesOf(bareLine, 'npm install'); + const args = specs.map((spec) => (spec === '@datalyr/react-native' ? tarball : spec)); + npmInstall(args, dir); + checkTree(dir); +}); + +scenario('Expo README line on expo@latest (versions as expo install picks them)', () => { + const dir = newApp('expo-app'); + const expoVersion = run('npm', ['view', 'expo@latest', 'version'], dir).trim(); + const bundled = fetchBundled(expoVersion); + // `expo install` passes the bundled version, or the bare name when expo + // names none (npm then takes the latest). + const pin = (name) => (bundled[name] ? `${name}@${bundled[name]}` : name); + npmInstall([`expo@${expoVersion}`, pin('react'), pin('react-native')], dir); + const specs = packagesOf(expoLine, 'npx expo install'); + const args = specs.map((spec) => (spec === '@datalyr/react-native' ? tarball : pin(nameOf(spec)))); + console.log(`expo ${expoVersion} picks: ${args.filter((a) => a !== tarball).join(' ')}`); + npmInstall(args, dir); + checkTree(dir); +}); + +// expo's bundledNativeModules.json is a file in the package, not in its +// registry metadata: read that one file from a package CDN. +function fetchBundled(version) { + const urls = [ + `https://cdn.jsdelivr.net/npm/expo@${version}/bundledNativeModules.json`, + `https://unpkg.com/expo@${version}/bundledNativeModules.json`, + ]; + for (const url of urls) { + try { + return JSON.parse(execFileSync('curl', ['-fsSL', '--retry', '2', url], { encoding: 'utf8' })); + } catch { + console.log(`could not read ${url}`); + } + } + throw new Error(`could not read bundledNativeModules.json for expo@${version}`); +} + +process.exit(failed ? 1 : 0); From 3ffc4d6ebac6f9c8656d637aa25d5b47686b29ad Mon Sep 17 00:00:00 2001 From: czy Date: Tue, 24 Nov 2026 23:17:51 -0600 Subject: [PATCH 2/6] 1.9.0: accept react-native-get-random-values 2.x (peer ^1.8.0 || ^2.0.0) The README install lines take get-random-values unpinned, which is 2.1.0 today (Expo SDK 58 bundles no version for it either), so the ^1.8.0 peer range made both lines fail with ERESOLVE. 2.x's one breaking change is the switch to the New Architecture (React Native 0.81+, Expo SDK 54+); the SDK only imports it for its crypto.getRandomValues polyfill, unchanged in 2.x. 1.x stays accepted for apps on React Native below 0.81; the README says to pin @^1 there. A jest test pins the range; CHANGELOG updated. Co-Authored-By: Claude Opus --- CHANGELOG.md | 4 +++- README.md | 2 +- package.json | 2 +- tests/dependency-declarations.test.ts | 6 ++++++ 4 files changed, 11 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d1b11bb4..c054b739 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -41,12 +41,14 @@ Minor version. Read the install change below before upgrading. - When a flush stops on a temporary failure, the events it already delivered are removed from disk at once. ### Install change -- `@react-native-async-storage/async-storage` (1.17 or later, or 2.x) and `react-native-get-random-values` are now peer dependencies, not dependencies. Install them in your app: +- `@react-native-async-storage/async-storage` (1.17 or later, or 2.x) and `react-native-get-random-values` (1.8 or later, or 2.x) are now peer dependencies, not dependencies. Install them in your app: - Bare React Native: `npm install @datalyr/react-native expo-modules-core @react-native-async-storage/async-storage@^2 react-native-get-random-values` (pin `@^2`: an unpinned install takes 3.x, which is outside the peer range) - Expo: `npx expo install @datalyr/react-native expo-application expo-device expo-network @react-native-async-storage/async-storage react-native-get-random-values` Both are native modules. React Native CLI autolinking links only the packages listed in the app's own `package.json`, and Expo before SDK 54 does the same, so as nested dependencies they could load without their native code. An app that already lists both needs no change. AsyncStorage 3.x is not supported yet (it renames `multiRemove` to `removeMany`). + `react-native-get-random-values` 2.x needs React Native 0.81 or later (Expo SDK 54 or later). On an older React Native, install `react-native-get-random-values@^1`. The unpinned install line takes 2.x today; the peer range accepted only 1.x in the 1.9.0 release candidate, so the README lines failed with `ERESOLVE`. CI now resolves both README install lines with strict peer rules, on every pull request and weekly. + ## [1.8.0] - 2026-10-30 diff --git a/README.md b/README.md index c77b09e2..d17348ae 100644 --- a/README.md +++ b/README.md @@ -31,7 +31,7 @@ npx install-expo-modules@latest cd ios && pod install ``` -The SDK is built on Expo Modules. You must install `expo-modules-core` in a bare app too. AsyncStorage and `react-native-get-random-values` are native modules: React Native links only the packages your app lists, so install them in your app. +The SDK is built on Expo Modules. You must install `expo-modules-core` in a bare app too. AsyncStorage and `react-native-get-random-values` are native modules: React Native links only the packages your app lists, so install them in your app. On React Native older than 0.81, install `react-native-get-random-values@^1` (2.x needs React Native 0.81 or later). **Expo:** diff --git a/package.json b/package.json index 2b524ac2..2f3e9bc7 100644 --- a/package.json +++ b/package.json @@ -67,7 +67,7 @@ "react": ">=18.0.0", "react-native": ">=0.72.0", "react-native-device-info": ">=12.0.0", - "react-native-get-random-values": "^1.8.0" + "react-native-get-random-values": "^1.8.0 || ^2.0.0" }, "dependencies": { "uuid": "^11.1.1" diff --git a/tests/dependency-declarations.test.ts b/tests/dependency-declarations.test.ts index 04d57bce..112f3e82 100644 --- a/tests/dependency-declarations.test.ts +++ b/tests/dependency-declarations.test.ts @@ -93,6 +93,12 @@ describe('W6 — native modules the app must list itself', () => { expect(pkg.peerDependencies['@react-native-async-storage/async-storage']).toBe('^1.17.0 || ^2.0.0'); }); + test('get-random-values peer range is 1.8+ or 2.x (the unpinned README lines take 2.x)', () => { + // 2.x needs React Native 0.81+; the SDK only imports it for its + // crypto.getRandomValues polyfill, which 1.x and 2.x install the same way. + expect(pkg.peerDependencies['react-native-get-random-values']).toBe('^1.8.0 || ^2.0.0'); + }); + test.each(nativeModules)('the README install lines name %s', (name) => { const readme = readFileSync(join(repoRoot, 'README.md'), 'utf8'); const installLines = readme From 45473ff02355a326e2f5f28f200da94ef399aa01 Mon Sep 17 00:00:00 2001 From: czy Date: Tue, 24 Nov 2026 23:25:48 -0600 Subject: [PATCH 3/6] 1.9.0 review fixes: New Architecture note, peer floor 1.11, install-lines logs versions - README (bare and Expo) and CHANGELOG: get-random-values 2.x works only on React Native 0.81+ with the New Architecture on; otherwise install @^1. 2.1.0's iOS module has only getTurboModule (no RCT_EXPORT_MODULE) and its JS calls TurboModuleRegistry.getEnforcing, so with the New Architecture off it installs cleanly and then fails at start. - CHANGELOG: drop the mention of the unpublished release candidate. - Peer range ^1.11.0 || ^2.0.0 (1.11 is the first bridgeless-aware 1.x; the README lines and Expo SDK 52-58 all resolve 1.11.0 or 2.1.0). - install-lines: logs the resolved react-native / expo / peers per scenario, and also checks the README's @^1 advice on react-native ~0.80 and the Expo line on expo ^52. Co-Authored-By: Claude Opus --- CHANGELOG.md | 4 +- README.md | 6 +- package.json | 2 +- scripts/check-install-lines.mjs | 91 ++++++++++++++++++++------- tests/dependency-declarations.test.ts | 10 +-- 5 files changed, 82 insertions(+), 31 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index c054b739..31448923 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -41,13 +41,13 @@ Minor version. Read the install change below before upgrading. - When a flush stops on a temporary failure, the events it already delivered are removed from disk at once. ### Install change -- `@react-native-async-storage/async-storage` (1.17 or later, or 2.x) and `react-native-get-random-values` (1.8 or later, or 2.x) are now peer dependencies, not dependencies. Install them in your app: +- `@react-native-async-storage/async-storage` (1.17 or later, or 2.x) and `react-native-get-random-values` (1.11 or later, or 2.x) are now peer dependencies, not dependencies. Install them in your app: - Bare React Native: `npm install @datalyr/react-native expo-modules-core @react-native-async-storage/async-storage@^2 react-native-get-random-values` (pin `@^2`: an unpinned install takes 3.x, which is outside the peer range) - Expo: `npx expo install @datalyr/react-native expo-application expo-device expo-network @react-native-async-storage/async-storage react-native-get-random-values` Both are native modules. React Native CLI autolinking links only the packages listed in the app's own `package.json`, and Expo before SDK 54 does the same, so as nested dependencies they could load without their native code. An app that already lists both needs no change. AsyncStorage 3.x is not supported yet (it renames `multiRemove` to `removeMany`). - `react-native-get-random-values` 2.x needs React Native 0.81 or later (Expo SDK 54 or later). On an older React Native, install `react-native-get-random-values@^1`. The unpinned install line takes 2.x today; the peer range accepted only 1.x in the 1.9.0 release candidate, so the README lines failed with `ERESOLVE`. CI now resolves both README install lines with strict peer rules, on every pull request and weekly. + `react-native-get-random-values` 2.x works only on React Native 0.81 or later with the New Architecture on (Expo SDK 54 or later with it on). On an older React Native, or with the New Architecture off, install `react-native-get-random-values@^1`: 2.x installs there without a warning, but its iOS native module is registered only for the New Architecture, so the SDK fails at start and sends no events. `npx expo install` picks the version your Expo SDK expects. ## [1.8.0] - 2026-10-30 diff --git a/README.md b/README.md index d17348ae..723ffb7d 100644 --- a/README.md +++ b/README.md @@ -31,7 +31,9 @@ npx install-expo-modules@latest cd ios && pod install ``` -The SDK is built on Expo Modules. You must install `expo-modules-core` in a bare app too. AsyncStorage and `react-native-get-random-values` are native modules: React Native links only the packages your app lists, so install them in your app. On React Native older than 0.81, install `react-native-get-random-values@^1` (2.x needs React Native 0.81 or later). +The SDK is built on Expo Modules. You must install `expo-modules-core` in a bare app too. AsyncStorage and `react-native-get-random-values` are native modules: React Native links only the packages your app lists, so install them in your app. + +`react-native-get-random-values` 2.x works only on React Native 0.81 or later with the New Architecture on. On an older React Native, or with the New Architecture off, install `react-native-get-random-values@^1` instead. 2.x installs there without a warning, but its iOS native module is registered only for the New Architecture, so the SDK fails at start and sends no events. **Expo:** @@ -39,6 +41,8 @@ The SDK is built on Expo Modules. You must install `expo-modules-core` in a bare npx expo install @datalyr/react-native expo-application expo-device expo-network @react-native-async-storage/async-storage react-native-get-random-values ``` +`npx expo install` picks the `react-native-get-random-values` version your Expo SDK expects. If you add it another way, use 2.x only on Expo SDK 54 or later with the New Architecture on; otherwise install `react-native-get-random-values@^1`. + Add the config plugin to `app.json`: ```json diff --git a/package.json b/package.json index 2f3e9bc7..d128d23b 100644 --- a/package.json +++ b/package.json @@ -67,7 +67,7 @@ "react": ">=18.0.0", "react-native": ">=0.72.0", "react-native-device-info": ">=12.0.0", - "react-native-get-random-values": "^1.8.0 || ^2.0.0" + "react-native-get-random-values": "^1.11.0 || ^2.0.0" }, "dependencies": { "uuid": "^11.1.1" diff --git a/scripts/check-install-lines.mjs b/scripts/check-install-lines.mjs index de6455e3..d5094fb6 100644 --- a/scripts/check-install-lines.mjs +++ b/scripts/check-install-lines.mjs @@ -4,8 +4,10 @@ // // - Bare: a throwaway app with react-native@latest, then the README's bare // `npm install` line, with the packed SDK in place of @datalyr/react-native. -// - Expo: a throwaway app with expo@latest and the react / react-native it -// bundles, then the README's `npx expo install` line, each package at the +// - Bare, React Native below 0.81: the same line with the README's +// react-native-get-random-values@^1 advice, on react-native@~0.80.0. +// - Expo: throwaway apps with expo@latest and expo@^52 (the oldest the SDK +// supports) and the react / react-native each bundles, then the README's `npx expo install` line, each package at the // version expo@latest's bundledNativeModules.json names (what // `expo install` picks), or latest when it names none. // @@ -103,30 +105,73 @@ function scenario(title, fn) { } } -scenario('bare README line on react-native@latest', () => { - const dir = newApp('bare-app'); - npmInstall(['react-native@latest'], dir); - const specs = packagesOf(bareLine, 'npm install'); - const args = specs.map((spec) => (spec === '@datalyr/react-native' ? tarball : spec)); - npmInstall(args, dir); - checkTree(dir); -}); +// The versions the lockfile resolved, so the log shows what was checked. +function logResolved(dir) { + const lock = JSON.parse(readFileSync(join(dir, 'package-lock.json'), 'utf8')); + const names = [ + 'react-native', + 'expo', + 'expo-modules-core', + '@react-native-async-storage/async-storage', + 'react-native-get-random-values', + ]; + const found = names + .map((name) => [name, lock.packages[`node_modules/${name}`]?.version]) + .filter(([, version]) => version) + .map(([name, version]) => `${name}@${version}`); + console.log(`RESOLVED: ${found.join(' ')}`); +} + +function bareScenario(title, reactNative, replace = {}) { + scenario(title, () => { + const dir = newApp(`bare-${reactNative.replace(/[^\w.]/g, '_')}`); + npmInstall([`react-native@${reactNative}`], dir); + const specs = packagesOf(bareLine, 'npm install'); + const args = specs.map((spec) => + spec === '@datalyr/react-native' ? tarball : (replace[nameOf(spec)] ?? spec), + ); + npmInstall(args, dir); + checkTree(dir); + logResolved(dir); + }); +} + +bareScenario('bare README line on react-native@latest', 'latest'); -scenario('Expo README line on expo@latest (versions as expo install picks them)', () => { - const dir = newApp('expo-app'); - const expoVersion = run('npm', ['view', 'expo@latest', 'version'], dir).trim(); - const bundled = fetchBundled(expoVersion); - // `expo install` passes the bundled version, or the bare name when expo - // names none (npm then takes the latest). - const pin = (name) => (bundled[name] ? `${name}@${bundled[name]}` : name); - npmInstall([`expo@${expoVersion}`, pin('react'), pin('react-native')], dir); - const specs = packagesOf(expoLine, 'npx expo install'); - const args = specs.map((spec) => (spec === '@datalyr/react-native' ? tarball : pin(nameOf(spec)))); - console.log(`expo ${expoVersion} picks: ${args.filter((a) => a !== tarball).join(' ')}`); - npmInstall(args, dir); - checkTree(dir); +// The README's advice for React Native below 0.81 (or the New Architecture +// off): the same line with react-native-get-random-values@^1. +const pinOne = readme.join('\n').match(/`(react-native-get-random-values@\^1)`/); +if (!pinOne) { + console.error('README: could not find the react-native-get-random-values@^1 advice'); + process.exit(1); +} +bareScenario(`bare README line with ${pinOne[1]} on react-native@~0.80.0`, '~0.80.0', { + 'react-native-get-random-values': pinOne[1], }); +function expoScenario(range) { + scenario(`Expo README line on expo@${range} (versions as expo install picks them)`, () => { + const dir = newApp(`expo-${range.replace(/[^\w.]/g, '_')}`); + const versions = JSON.parse(run('npm', ['view', `expo@${range}`, 'version', '--json'], dir)); + const expoVersion = Array.isArray(versions) ? versions[versions.length - 1] : versions; + const bundled = fetchBundled(expoVersion); + // `expo install` passes the bundled version, or the bare name when expo + // names none (npm then takes the latest). + const pin = (name) => (bundled[name] ? `${name}@${bundled[name]}` : name); + npmInstall([`expo@${expoVersion}`, pin('react'), pin('react-native')], dir); + const specs = packagesOf(expoLine, 'npx expo install'); + const args = specs.map((spec) => (spec === '@datalyr/react-native' ? tarball : pin(nameOf(spec)))); + console.log(`expo ${expoVersion} picks: ${args.filter((a) => a !== tarball).join(' ')}`); + npmInstall(args, dir); + checkTree(dir); + logResolved(dir); + }); +} + +// The newest Expo SDK, and the oldest the SDK supports (expo >=52). +expoScenario('latest'); +expoScenario('^52.0.0'); + // expo's bundledNativeModules.json is a file in the package, not in its // registry metadata: read that one file from a package CDN. function fetchBundled(version) { diff --git a/tests/dependency-declarations.test.ts b/tests/dependency-declarations.test.ts index 112f3e82..bd1073b8 100644 --- a/tests/dependency-declarations.test.ts +++ b/tests/dependency-declarations.test.ts @@ -93,10 +93,12 @@ describe('W6 — native modules the app must list itself', () => { expect(pkg.peerDependencies['@react-native-async-storage/async-storage']).toBe('^1.17.0 || ^2.0.0'); }); - test('get-random-values peer range is 1.8+ or 2.x (the unpinned README lines take 2.x)', () => { - // 2.x needs React Native 0.81+; the SDK only imports it for its - // crypto.getRandomValues polyfill, which 1.x and 2.x install the same way. - expect(pkg.peerDependencies['react-native-get-random-values']).toBe('^1.8.0 || ^2.0.0'); + test('get-random-values peer range is 1.11+ or 2.x (the unpinned README lines take 2.x)', () => { + // 2.x needs React Native 0.81+ with the New Architecture; 1.11 is the first + // 1.x with bridgeless support, and Expo SDK 52-57 bundle ~1.11.0. The SDK + // only imports it for its crypto.getRandomValues polyfill, which 1.x and + // 2.x install the same way. + expect(pkg.peerDependencies['react-native-get-random-values']).toBe('^1.11.0 || ^2.0.0'); }); test.each(nativeModules)('the README install lines name %s', (name) => { From d55e41ecc795882592200e3c4c8ec8454b723b4e Mon Sep 17 00:00:00 2001 From: czy Date: Tue, 24 Nov 2026 23:27:06 -0600 Subject: [PATCH 4/6] install-lines: tidy the header comment Co-Authored-By: Claude Opus --- scripts/check-install-lines.mjs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/scripts/check-install-lines.mjs b/scripts/check-install-lines.mjs index d5094fb6..7bd660db 100644 --- a/scripts/check-install-lines.mjs +++ b/scripts/check-install-lines.mjs @@ -7,9 +7,10 @@ // - Bare, React Native below 0.81: the same line with the README's // react-native-get-random-values@^1 advice, on react-native@~0.80.0. // - Expo: throwaway apps with expo@latest and expo@^52 (the oldest the SDK -// supports) and the react / react-native each bundles, then the README's `npx expo install` line, each package at the -// version expo@latest's bundledNativeModules.json names (what -// `expo install` picks), or latest when it names none. +// supports) and the react / react-native each bundles, then the README's +// `npx expo install` line, each package at the version that expo's +// bundledNativeModules.json names (what `expo install` picks), or latest +// when it names none. // // Only a lockfile is written (--package-lock-only): nothing is downloaded // beyond package metadata, and no React Native app is built. A peer conflict From 87ef4c38437ea841495094928e92a27430084365 Mon Sep 17 00:00:00 2001 From: czy Date: Wed, 25 Nov 2026 00:03:31 -0600 Subject: [PATCH 5/6] 1.9.0: bare install via install-expo-modules then expo install; drop expo-router peer - README bare steps: npx install-expo-modules@latest first (adds the Expo SDK that matches the app's React Native), then npx expo install for the SDK, expo-modules-core, AsyncStorage and get-random-values (SDK-matched), then pod install. The old npm install line took expo-modules-core 58 on any React Native below 0.88, and pod install failed. - README/CHANGELOG: on Expo SDK 54, install-expo-modules does not add bindReactNativeFactory(factory) to AppDelegate.swift (the SDK 54 bare template has it; 55+ removed it); point to Expo's manual steps. - package.json: expo-router is no longer an optional peer. npm checks an uninstalled optional peer against its newest version, and expo-router 58's expo-constants peer made the bare SDK 54 install fail with ERESOLVE (found by the guard). The SDK requires it only inside useDatalyrScreenTracking. - install-lines: bare cases follow the new steps for Expo SDK latest/54/52 (expo for the app's React Native, then the expo install line), fail on a second expo-modules-core copy, and state what a lockfile cannot cover (pod install, native edits, Gradle, autolinking). Jest tests updated. Co-Authored-By: Claude Opus --- CHANGELOG.md | 8 +- README.md | 8 +- package.json | 4 - scripts/check-install-lines.mjs | 221 +++++++++++++++----------- tests/dependency-declarations.test.ts | 33 +++- 5 files changed, 161 insertions(+), 113 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 31448923..06fb4406 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -15,7 +15,7 @@ Minor version. Read the install change below before upgrading. ### Changed - `uuid` is now `^11.1.1` (was `^10.0.0`). This clears the one production advisory. The SDK only uses `v4()`; ids keep the same format. `@types/uuid` is gone, since uuid 11 ships its own types. -- The Expo modules the SDK loads are now declared as optional peer dependencies: `expo-application`, `expo-device`, `expo-network`, `expo-router`, `expo` and `@expo/config-plugins` (Expo SDK 52 or later, the same floor as `expo-modules-core`). Your package manager now warns about a version it cannot work with. Nothing is installed for you. The unused `expo-tracking-transparency` entry is removed. +- The Expo modules the SDK loads are now declared as optional peer dependencies: `expo-application`, `expo-device`, `expo-network`, `expo` and `@expo/config-plugins` (Expo SDK 52 or later, the same floor as `expo-modules-core`). Your package manager now warns about a version it cannot work with. Nothing is installed for you. The unused `expo-tracking-transparency` entry is removed. `expo-router` is not declared: npm checks an optional peer against its newest version even when it is not installed, and expo-router's own peers then conflict with an older Expo SDK (`ERESOLVE`). The SDK loads it only when you use the Expo Router screen-tracking hook. - `debug: true` now turns on the SDK's debug logs in a release build. Before, they printed only in a development build (`__DEV__`) and the option did nothing else. - SKAdNetwork and AdAttributionKit success messages, and failed Apple Search Ads, advertiser-info and Play Install Referrer lookups in the native bridge, now log only when debug logging is on (`__DEV__` or `debug: true`). Warnings for a missing native module and failed SKAdNetwork updates are unchanged. - iOS: `setPostbackEnvironment` no longer writes an `NSLog` line; the JS side logs the result when debug logging is on. @@ -42,12 +42,14 @@ Minor version. Read the install change below before upgrading. ### Install change - `@react-native-async-storage/async-storage` (1.17 or later, or 2.x) and `react-native-get-random-values` (1.11 or later, or 2.x) are now peer dependencies, not dependencies. Install them in your app: - - Bare React Native: `npm install @datalyr/react-native expo-modules-core @react-native-async-storage/async-storage@^2 react-native-get-random-values` (pin `@^2`: an unpinned install takes 3.x, which is outside the peer range) + - Bare React Native: `npx install-expo-modules@latest`, then `npx expo install @datalyr/react-native expo-modules-core @react-native-async-storage/async-storage react-native-get-random-values`, then `cd ios && pod install`. Run `install-expo-modules` first: it adds the Expo SDK that matches your React Native, and `npx expo install` then picks versions for it. A plain `npm install` takes the newest `expo-modules-core` (and AsyncStorage 3.x), which an older Expo SDK cannot use. - Expo: `npx expo install @datalyr/react-native expo-application expo-device expo-network @react-native-async-storage/async-storage react-native-get-random-values` Both are native modules. React Native CLI autolinking links only the packages listed in the app's own `package.json`, and Expo before SDK 54 does the same, so as nested dependencies they could load without their native code. An app that already lists both needs no change. AsyncStorage 3.x is not supported yet (it renames `multiRemove` to `removeMany`). - `react-native-get-random-values` 2.x works only on React Native 0.81 or later with the New Architecture on (Expo SDK 54 or later with it on). On an older React Native, or with the New Architecture off, install `react-native-get-random-values@^1`: 2.x installs there without a warning, but its iOS native module is registered only for the New Architecture, so the SDK fails at start and sends no events. `npx expo install` picks the version your Expo SDK expects. + `react-native-get-random-values` 2.x works only on React Native 0.81 or later with the New Architecture on (Expo SDK 54 or later with it on). On an older React Native, or with the New Architecture off, install `react-native-get-random-values@^1`: 2.x installs there without a warning, but its iOS native module is registered only for the New Architecture, so the SDK fails at start and sends no events. `npx expo install` picks the version your Expo SDK expects (1.11 for Expo SDK 52 to 57, 2.x for SDK 58). + + Bare apps on Expo SDK 54: `install-expo-modules` does not add `bindReactNativeFactory(factory)` to `AppDelegate.swift`, and the app crashes at start without it. Add it after `reactNativeFactory = factory` (Expo's manual installation steps show it). ## [1.8.0] - 2026-10-30 diff --git a/README.md b/README.md index 723ffb7d..56d6e042 100644 --- a/README.md +++ b/README.md @@ -26,14 +26,14 @@ Use the option that matches your app. **Bare React Native:** ```bash -npm install @datalyr/react-native expo-modules-core @react-native-async-storage/async-storage@^2 react-native-get-random-values npx install-expo-modules@latest +npx expo install @datalyr/react-native expo-modules-core @react-native-async-storage/async-storage react-native-get-random-values cd ios && pod install ``` -The SDK is built on Expo Modules. You must install `expo-modules-core` in a bare app too. AsyncStorage and `react-native-get-random-values` are native modules: React Native links only the packages your app lists, so install them in your app. +The SDK is built on Expo Modules. `install-expo-modules` adds the Expo SDK that matches your React Native version; run it first, so that `npx expo install` then picks versions for that Expo SDK. Do not use a plain `npm install` for these packages: it takes the newest `expo-modules-core`, which does not match an older Expo SDK, and `pod install` fails. AsyncStorage and `react-native-get-random-values` are native modules: React Native links only the packages your app lists, so install them in your app. -`react-native-get-random-values` 2.x works only on React Native 0.81 or later with the New Architecture on. On an older React Native, or with the New Architecture off, install `react-native-get-random-values@^1` instead. 2.x installs there without a warning, but its iOS native module is registered only for the New Architecture, so the SDK fails at start and sends no events. +On Expo SDK 54 (React Native 0.81), check that `AppDelegate.swift` calls `bindReactNativeFactory(factory)` after `reactNativeFactory = factory`. `install-expo-modules` does not add it, and without it the app crashes at start (`Missing factory in ExpoAppDelegate`). See Expo's [manual installation steps](https://docs.expo.dev/bare/installing-expo-modules/). **Expo:** @@ -41,7 +41,7 @@ The SDK is built on Expo Modules. You must install `expo-modules-core` in a bare npx expo install @datalyr/react-native expo-application expo-device expo-network @react-native-async-storage/async-storage react-native-get-random-values ``` -`npx expo install` picks the `react-native-get-random-values` version your Expo SDK expects. If you add it another way, use 2.x only on Expo SDK 54 or later with the New Architecture on; otherwise install `react-native-get-random-values@^1`. +`npx expo install` picks the versions your Expo SDK expects, in both options above. If you add `react-native-get-random-values` another way, use 2.x only on React Native 0.81 or later (Expo SDK 54 or later) with the New Architecture on; otherwise install `react-native-get-random-values@^1`. 2.x installs there without a warning, but its iOS native module is registered only for the New Architecture, so the SDK fails at start and sends no events. Add the config plugin to `app.json`: diff --git a/package.json b/package.json index d128d23b..978f05c0 100644 --- a/package.json +++ b/package.json @@ -63,7 +63,6 @@ "expo-device": ">=7.0.0", "expo-modules-core": ">=2.0.0", "expo-network": ">=7.0.0", - "expo-router": ">=4.0.0", "react": ">=18.0.0", "react-native": ">=0.72.0", "react-native-device-info": ">=12.0.0", @@ -135,9 +134,6 @@ }, "@react-native-community/netinfo": { "optional": true - }, - "expo-router": { - "optional": true } } } diff --git a/scripts/check-install-lines.mjs b/scripts/check-install-lines.mjs index 7bd660db..a52ba833 100644 --- a/scripts/check-install-lines.mjs +++ b/scripts/check-install-lines.mjs @@ -1,20 +1,28 @@ #!/usr/bin/env node -// Checks that the two README install lines resolve with npm's strict peer -// rules (no --legacy-peer-deps), against today's published versions. +// Checks that the README install steps resolve with npm's strict peer rules +// (no --legacy-peer-deps), against today's published versions, in throwaway +// lockfile-only apps. The packed SDK stands in for @datalyr/react-native. // -// - Bare: a throwaway app with react-native@latest, then the README's bare -// `npm install` line, with the packed SDK in place of @datalyr/react-native. -// - Bare, React Native below 0.81: the same line with the README's -// react-native-get-random-values@^1 advice, on react-native@~0.80.0. -// - Expo: throwaway apps with expo@latest and expo@^52 (the oldest the SDK -// supports) and the react / react-native each bundles, then the README's -// `npx expo install` line, each package at the version that expo's +// - Bare: an app with the react-native (and react) that an Expo SDK bundles; +// then that Expo SDK's `expo` package, which is what +// `npx install-expo-modules` adds for that React Native; then the README's +// bare `npx expo install` line, each package at the version that expo's // bundledNativeModules.json names (what `expo install` picks), or latest -// when it names none. +// when it names none. Run for the newest Expo SDK, SDK 54 (React Native +// 0.81) and SDK 52 (React Native 0.76, the oldest the SDK supports). +// - Expo: an app with that Expo SDK's expo, react and react-native, then the +// README's Expo line the same way. Newest SDK and SDK 52. +// - The README's react-native-get-random-values@^1 advice, on Expo SDK 54. // -// Only a lockfile is written (--package-lock-only): nothing is downloaded -// beyond package metadata, and no React Native app is built. A peer conflict -// (ERESOLVE) makes npm exit non-zero, which fails this script. +// Each case fails on ERESOLVE (error or "overriding peer dependency"), on an +// invalid or missing package in `npm ls`, or on a second copy of +// expo-modules-core (an app copy that does not match its Expo SDK; pod +// install then fails). It logs the resolved versions. +// +// Not covered (needs a real app build): what install-expo-modules writes into +// the native projects, CocoaPods resolution in `pod install`, Gradle, and +// autolinking. Only a lockfile is written: nothing beyond package metadata is +// downloaded and no app is built. // // Usage: node scripts/check-install-lines.mjs // INSTALL_CHECK_DIR sets the scratch directory (default: a new temp dir). @@ -27,10 +35,30 @@ import { join, resolve } from 'node:path'; const repoRoot = resolve(import.meta.dirname, '..'); const readme = readFileSync(join(repoRoot, 'README.md'), 'utf8').split('\n'); -const bareLine = readme.find((line) => line.startsWith('npm install @datalyr/react-native ')); -const expoLine = readme.find((line) => line.startsWith('npx expo install @datalyr/react-native ')); +const INSTALL = 'npx expo install'; +const bareStart = readme.indexOf('**Bare React Native:**'); +const expoStart = readme.indexOf('**Expo:**'); +if (bareStart < 0 || expoStart < bareStart) { + console.error('README: could not find the Bare React Native and Expo sections'); + process.exit(1); +} +const bareSection = readme.slice(bareStart, expoStart); +const expoSection = readme.slice(expoStart); +const isInstallLine = (line) => line.startsWith(`${INSTALL} @datalyr/react-native `); +const bareLine = bareSection.find(isInstallLine); +const expoLine = expoSection.find(isInstallLine); +const addExpoAt = bareSection.findIndex((line) => line.startsWith('npx install-expo-modules')); if (!bareLine || !expoLine) { - console.error('README: could not find both install lines'); + console.error(`README: could not find a "${INSTALL} @datalyr/react-native" line in both sections`); + process.exit(1); +} +if (addExpoAt < 0 || addExpoAt > bareSection.indexOf(bareLine)) { + console.error('README: the bare steps must run npx install-expo-modules before npx expo install'); + process.exit(1); +} +const pinOne = readme.join('\n').match(/`(react-native-get-random-values@\^1)`/); +if (!pinOne) { + console.error('README: could not find the react-native-get-random-values@^1 advice'); process.exit(1); } @@ -44,6 +72,8 @@ function run(cmd, args, cwd) { return execFileSync(cmd, args, { cwd, stdio: ['ignore', 'pipe', 'inherit'], encoding: 'utf8' }); } +const npmFlags = ['--package-lock-only', '--no-audit', '--no-fund', '--ignore-scripts']; + // npm either stops on a peer conflict (`npm error ERESOLVE`) or, when the // conflicting package is named in the same command, installs it anyway with // `npm warn ERESOLVE overriding peer dependency`. Both are a broken install @@ -57,7 +87,8 @@ function npmInstall(args, cwd) { if (lines.some((l) => l.includes('ERESOLVE'))) throw new Error('npm reported ERESOLVE (peer conflict)'); } -// Every peer in the resulting lockfile must be satisfied. +// Every dependency in the resulting lockfile must be valid, and there must be +// one expo-modules-core, the one the Expo SDK uses. function checkTree(cwd) { console.log(`$ (${cwd}) npm ls --all --package-lock-only`); const res = spawnSync('npm', ['ls', '--all', '--package-lock-only'], { cwd, encoding: 'utf8' }); @@ -66,9 +97,32 @@ function checkTree(cwd) { console.log(bad.join('\n')); throw new Error('npm ls found an invalid or missing dependency'); } + const lock = JSON.parse(readFileSync(join(cwd, 'package-lock.json'), 'utf8')); + const copies = Object.entries(lock.packages) + .filter(([path]) => path.endsWith('node_modules/expo-modules-core')) + .map(([path, meta]) => `${path}@${meta.version}`); + if (copies.length !== 1) { + console.log(copies.join('\n')); + throw new Error(`expected one expo-modules-core, found ${copies.length}`); + } } -const npmFlags = ['--package-lock-only', '--no-audit', '--no-fund', '--ignore-scripts']; +// The versions the lockfile resolved, so the log shows what was checked. +function logResolved(dir) { + const lock = JSON.parse(readFileSync(join(dir, 'package-lock.json'), 'utf8')); + const names = [ + 'react-native', + 'expo', + 'expo-modules-core', + '@react-native-async-storage/async-storage', + 'react-native-get-random-values', + ]; + const found = names + .map((name) => [name, lock.packages[`node_modules/${name}`]?.version]) + .filter(([, version]) => version) + .map(([name, version]) => `${name}@${version}`); + console.log(`RESOLVED: ${found.join(' ')}`); +} // Pack the SDK as a customer receives it. const packDir = join(base, 'pack'); @@ -76,21 +130,13 @@ mkdirSync(packDir, { recursive: true }); const packed = JSON.parse(run('npm', ['pack', '--json', '--ignore-scripts', '--pack-destination', packDir], repoRoot)); const tarball = join(packDir, packed[0].filename); -// Package names after "@datalyr/react-native" in a README line, with any -// version spec the line gives ("name@^2" stays "name@^2"). -function packagesOf(line, prefix) { - return line - .slice(prefix.length) - .trim() - .split(/\s+/) - .filter((word) => word && !word.startsWith('-')); -} +const packagesOf = (line) => line.slice(INSTALL.length).trim().split(/\s+/).filter((w) => w && !w.startsWith('-')); const nameOf = (spec) => spec.replace(/(.)@[^/]*$/, '$1'); function newApp(name) { - const dir = join(base, name); + const dir = join(base, name.replace(/[^\w.-]/g, '_')); mkdirSync(dir, { recursive: true }); - writeFileSync(join(dir, 'package.json'), JSON.stringify({ name, version: '0.0.0', private: true }, null, 2)); + writeFileSync(join(dir, 'package.json'), JSON.stringify({ name: 'app', version: '0.0.0', private: true }, null, 2)); return dir; } @@ -106,73 +152,6 @@ function scenario(title, fn) { } } -// The versions the lockfile resolved, so the log shows what was checked. -function logResolved(dir) { - const lock = JSON.parse(readFileSync(join(dir, 'package-lock.json'), 'utf8')); - const names = [ - 'react-native', - 'expo', - 'expo-modules-core', - '@react-native-async-storage/async-storage', - 'react-native-get-random-values', - ]; - const found = names - .map((name) => [name, lock.packages[`node_modules/${name}`]?.version]) - .filter(([, version]) => version) - .map(([name, version]) => `${name}@${version}`); - console.log(`RESOLVED: ${found.join(' ')}`); -} - -function bareScenario(title, reactNative, replace = {}) { - scenario(title, () => { - const dir = newApp(`bare-${reactNative.replace(/[^\w.]/g, '_')}`); - npmInstall([`react-native@${reactNative}`], dir); - const specs = packagesOf(bareLine, 'npm install'); - const args = specs.map((spec) => - spec === '@datalyr/react-native' ? tarball : (replace[nameOf(spec)] ?? spec), - ); - npmInstall(args, dir); - checkTree(dir); - logResolved(dir); - }); -} - -bareScenario('bare README line on react-native@latest', 'latest'); - -// The README's advice for React Native below 0.81 (or the New Architecture -// off): the same line with react-native-get-random-values@^1. -const pinOne = readme.join('\n').match(/`(react-native-get-random-values@\^1)`/); -if (!pinOne) { - console.error('README: could not find the react-native-get-random-values@^1 advice'); - process.exit(1); -} -bareScenario(`bare README line with ${pinOne[1]} on react-native@~0.80.0`, '~0.80.0', { - 'react-native-get-random-values': pinOne[1], -}); - -function expoScenario(range) { - scenario(`Expo README line on expo@${range} (versions as expo install picks them)`, () => { - const dir = newApp(`expo-${range.replace(/[^\w.]/g, '_')}`); - const versions = JSON.parse(run('npm', ['view', `expo@${range}`, 'version', '--json'], dir)); - const expoVersion = Array.isArray(versions) ? versions[versions.length - 1] : versions; - const bundled = fetchBundled(expoVersion); - // `expo install` passes the bundled version, or the bare name when expo - // names none (npm then takes the latest). - const pin = (name) => (bundled[name] ? `${name}@${bundled[name]}` : name); - npmInstall([`expo@${expoVersion}`, pin('react'), pin('react-native')], dir); - const specs = packagesOf(expoLine, 'npx expo install'); - const args = specs.map((spec) => (spec === '@datalyr/react-native' ? tarball : pin(nameOf(spec)))); - console.log(`expo ${expoVersion} picks: ${args.filter((a) => a !== tarball).join(' ')}`); - npmInstall(args, dir); - checkTree(dir); - logResolved(dir); - }); -} - -// The newest Expo SDK, and the oldest the SDK supports (expo >=52). -expoScenario('latest'); -expoScenario('^52.0.0'); - // expo's bundledNativeModules.json is a file in the package, not in its // registry metadata: read that one file from a package CDN. function fetchBundled(version) { @@ -190,4 +169,54 @@ function fetchBundled(version) { throw new Error(`could not read bundledNativeModules.json for expo@${version}`); } +function expoSdk(range, dir) { + const versions = JSON.parse(run('npm', ['view', `expo@${range}`, 'version', '--json'], dir)); + const version = Array.isArray(versions) ? versions[versions.length - 1] : versions; + const bundled = fetchBundled(version); + // `expo install` passes the bundled version, or the bare name when expo + // names none (npm then takes the latest). + const pin = (name) => (bundled[name] ? `${name}@${bundled[name]}` : name); + return { version, pin }; +} + +function installLine(line, dir, pin, replace = {}) { + const args = packagesOf(line).map((spec) => + spec === '@datalyr/react-native' ? tarball : (replace[nameOf(spec)] ?? pin(nameOf(spec))), + ); + console.log(`expo install picks: ${args.filter((a) => a !== tarball).join(' ')}`); + npmInstall(args, dir); + checkTree(dir); + logResolved(dir); +} + +function bareScenario(range) { + scenario(`bare README steps on the React Native of expo@${range}`, () => { + const dir = newApp(`bare-${range}`); + const { version, pin } = expoSdk(range, dir); + // The bare app as the customer has it. + npmInstall([pin('react-native'), pin('react')], dir); + // npx install-expo-modules: adds the expo package for that React Native. + npmInstall([`expo@${version}`], dir); + installLine(bareLine, dir, pin); + }); +} + +function expoScenario(range, replace = {}, label = '') { + scenario(`Expo README line on expo@${range}${label}`, () => { + const dir = newApp(`expo-${range}${label}`); + const { version, pin } = expoSdk(range, dir); + npmInstall([`expo@${version}`, pin('react'), pin('react-native')], dir); + installLine(expoLine, dir, pin, replace); + }); +} + +bareScenario('latest'); +bareScenario('^54.0.0'); +bareScenario('^52.0.0'); +expoScenario('latest'); +expoScenario('^52.0.0'); +// The README's advice for the New Architecture off (React Native 0.81 can +// still turn it off): the Expo line with react-native-get-random-values@^1. +expoScenario('^54.0.0', { 'react-native-get-random-values': pinOne[1] }, ` with ${pinOne[1]}`); + process.exit(failed ? 1 : 0); diff --git a/tests/dependency-declarations.test.ts b/tests/dependency-declarations.test.ts index bd1073b8..a48e2e8b 100644 --- a/tests/dependency-declarations.test.ts +++ b/tests/dependency-declarations.test.ts @@ -35,17 +35,26 @@ describe('W6 — uuid', () => { describe('W6 — optional Expo peers', () => { // src/utils-expo.ts imports these three statically (the Expo entry); - // src/expo.ts requires expo-router lazily; app.plugin.js requires - // expo/config-plugins, falling back to @expo/config-plugins. + // app.plugin.js requires expo/config-plugins, falling back to + // @expo/config-plugins. const expoPeers = [ 'expo-application', 'expo-device', 'expo-network', - 'expo-router', 'expo', '@expo/config-plugins', ]; + test('expo-router is not a peer (an optional peer still makes npm check the newest expo-router)', () => { + // npm resolves an optional peer that is not installed against its newest + // version: expo-router 58 wants expo-constants 58, and a bare app on Expo + // SDK 54 then fails `npx expo install @datalyr/react-native` with ERESOLVE. + // src/expo.ts requires expo-router only when the app calls + // useDatalyrScreenTracking, so only apps that have it load it. + expect(pkg.peerDependencies['expo-router']).toBeUndefined(); + expect(pkg.peerDependenciesMeta['expo-router']).toBeUndefined(); + }); + test.each(expoPeers)('%s is an optional peer dependency', (name) => { expect(typeof pkg.peerDependencies[name]).toBe('string'); expect(pkg.peerDependenciesMeta[name]).toEqual({ optional: true }); @@ -113,9 +122,21 @@ describe('W6 — native modules the app must list itself', () => { } }); - test('the bare install line pins AsyncStorage to 2.x (latest is 3.x, outside the peer range)', () => { + test('the bare steps add the matching Expo SDK first, then install with expo install (SDK-matched versions)', () => { + // A plain npm install takes the newest expo-modules-core (pod install then + // fails on an older Expo SDK) and AsyncStorage 3.x (outside the peer range). const readme = readFileSync(join(repoRoot, 'README.md'), 'utf8'); - const bare = readme.split('\n').find((line) => line.startsWith('npm install @datalyr/react-native')); - expect(bare?.split(' ')).toContain('@react-native-async-storage/async-storage@^2'); + const lines = readme.split('\n'); + const bareStart = lines.indexOf('**Bare React Native:**'); + const expoStart = lines.indexOf('**Expo:**'); + expect(bareStart).toBeGreaterThan(-1); + expect(expoStart).toBeGreaterThan(bareStart); + const bare = lines.slice(bareStart, expoStart); + const addExpo = bare.indexOf('npx install-expo-modules@latest'); + const install = bare.findIndex((line) => line.startsWith('npx expo install @datalyr/react-native ')); + expect(addExpo).toBeGreaterThan(-1); + expect(install).toBeGreaterThan(addExpo); + expect(bare[install].split(' ')).toContain('expo-modules-core'); + expect(lines.some((line) => /^(npm install|yarn add|pnpm add) .*@datalyr\/react-native/.test(line))).toBe(false); }); }); From f40568990f9d9914a5cd298bda8639f0d21e05a1 Mon Sep 17 00:00:00 2001 From: czy Date: Wed, 25 Nov 2026 00:10:38 -0600 Subject: [PATCH 6/6] README/CHANGELOG: AppDelegate note covers Expo SDK 53 and 54; exact 2.x install wording Expo's bare template calls bindReactNativeFactory for SDK 53 and 54 (not 52 or 55+), and expo 53/54's ExpoAppDelegate has the same fatalError. On React Native below 0.81 npm refuses get-random-values 2.x (ERESOLVE); only with the New Architecture off does 2.x install without a warning. Co-Authored-By: Claude Opus --- CHANGELOG.md | 4 ++-- README.md | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 06fb4406..531752f5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -47,9 +47,9 @@ Minor version. Read the install change below before upgrading. Both are native modules. React Native CLI autolinking links only the packages listed in the app's own `package.json`, and Expo before SDK 54 does the same, so as nested dependencies they could load without their native code. An app that already lists both needs no change. AsyncStorage 3.x is not supported yet (it renames `multiRemove` to `removeMany`). - `react-native-get-random-values` 2.x works only on React Native 0.81 or later with the New Architecture on (Expo SDK 54 or later with it on). On an older React Native, or with the New Architecture off, install `react-native-get-random-values@^1`: 2.x installs there without a warning, but its iOS native module is registered only for the New Architecture, so the SDK fails at start and sends no events. `npx expo install` picks the version your Expo SDK expects (1.11 for Expo SDK 52 to 57, 2.x for SDK 58). + `react-native-get-random-values` 2.x works only on React Native 0.81 or later with the New Architecture on (Expo SDK 54 or later with it on). On an older React Native, or with the New Architecture off, install `react-native-get-random-values@^1`. On React Native older than 0.81, npm refuses 2.x (`ERESOLVE`); with the New Architecture off, 2.x installs without a warning, but its iOS native module is registered only for the New Architecture, so the SDK fails at start and sends no events. `npx expo install` picks the version your Expo SDK expects (1.11 for Expo SDK 52 to 57, 2.x for SDK 58). - Bare apps on Expo SDK 54: `install-expo-modules` does not add `bindReactNativeFactory(factory)` to `AppDelegate.swift`, and the app crashes at start without it. Add it after `reactNativeFactory = factory` (Expo's manual installation steps show it). + Bare apps on Expo SDK 53 or 54 (React Native 0.78 to 0.81): `install-expo-modules` does not add `bindReactNativeFactory(factory)` to `AppDelegate.swift`, and the app crashes at start without it. Add it after `reactNativeFactory = factory` (Expo's manual installation steps show it). ## [1.8.0] - 2026-10-30 diff --git a/README.md b/README.md index 56d6e042..4cbd1bd9 100644 --- a/README.md +++ b/README.md @@ -33,7 +33,7 @@ cd ios && pod install The SDK is built on Expo Modules. `install-expo-modules` adds the Expo SDK that matches your React Native version; run it first, so that `npx expo install` then picks versions for that Expo SDK. Do not use a plain `npm install` for these packages: it takes the newest `expo-modules-core`, which does not match an older Expo SDK, and `pod install` fails. AsyncStorage and `react-native-get-random-values` are native modules: React Native links only the packages your app lists, so install them in your app. -On Expo SDK 54 (React Native 0.81), check that `AppDelegate.swift` calls `bindReactNativeFactory(factory)` after `reactNativeFactory = factory`. `install-expo-modules` does not add it, and without it the app crashes at start (`Missing factory in ExpoAppDelegate`). See Expo's [manual installation steps](https://docs.expo.dev/bare/installing-expo-modules/). +On Expo SDK 53 or 54 (React Native 0.78 to 0.81), check that `AppDelegate.swift` calls `bindReactNativeFactory(factory)` after `reactNativeFactory = factory`. `install-expo-modules` does not add it, and without it the app crashes at start (`Missing factory in ExpoAppDelegate`). See Expo's [manual installation steps](https://docs.expo.dev/bare/installing-expo-modules/). **Expo:** @@ -41,7 +41,7 @@ On Expo SDK 54 (React Native 0.81), check that `AppDelegate.swift` calls `bindRe npx expo install @datalyr/react-native expo-application expo-device expo-network @react-native-async-storage/async-storage react-native-get-random-values ``` -`npx expo install` picks the versions your Expo SDK expects, in both options above. If you add `react-native-get-random-values` another way, use 2.x only on React Native 0.81 or later (Expo SDK 54 or later) with the New Architecture on; otherwise install `react-native-get-random-values@^1`. 2.x installs there without a warning, but its iOS native module is registered only for the New Architecture, so the SDK fails at start and sends no events. +`npx expo install` picks the versions your Expo SDK expects, in both options above. If you add `react-native-get-random-values` another way, use 2.x only on React Native 0.81 or later (Expo SDK 54 or later) with the New Architecture on; otherwise install `react-native-get-random-values@^1`. On React Native older than 0.81, npm refuses 2.x (`ERESOLVE`). With the New Architecture off, 2.x installs without a warning, but its iOS native module is registered only for the New Architecture, so the SDK fails at start and sends no events. Add the config plugin to `app.json`: