@oxy.so/app-preset 5.3.0 → 6.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/NOTICE CHANGED
@@ -17,7 +17,7 @@ everyone, including paying commercial licensees, and cannot be waived.
17
17
  ----------------------------------------------------------------------------
18
18
 
19
19
  metro/static-hydration/renderer.js adapts the static renderer from
20
- @expo/router-server 58.0.14–58.0.16, Copyright © 2026 650 Industries, under
20
+ @expo/router-server 58.0.14–58.0.16 and 58.0.18–58.0.21, Copyright © 2026 650 Industries, under
21
21
  the MIT license included at metro/static-hydration/EXPO-LICENSE.
22
22
  Other dependencies are resolved and installed by the package manager and
23
23
  remain governed by their own licenses.
package/README.md CHANGED
@@ -33,7 +33,8 @@ module.exports = createOxyMetroConfig(__dirname, {
33
33
  });
34
34
  ```
35
35
 
36
- Expo Router's renderer in `@expo/router-server` 58.0.14–58.0.16 renders the app
36
+ Expo Router's renderer in `@expo/router-server` 58.0.14–58.0.16 and 58.0.18–58.0.21
37
+ (Expo 58.0.23, expo-router 58.0.30) renders the app
37
38
  inside `+html`, but the browser hydrates only `#root`. Document siblings then
38
39
  change React `useId` paths. An ID in text (for example Bloom's scoped stylesheet)
39
40
  causes React to replace the workspace during hydration.
@@ -171,6 +172,20 @@ signing.
171
172
 
172
173
  `withOxyAndroidRelease` was removed in 5.0.0; listing it throws and says to delete it.
173
174
 
175
+ #### Store build number (always on, 6.0.0+)
176
+
177
+ The preset derives Android `versionCode` and iOS `buildNumber` from the app's
178
+ `version`: `major * 1_000_000 + minor * 1_000 + patch` (1.2.3 → 1002003; minor
179
+ and patch ≤ 999). Every later version gets a strictly higher number, which is
180
+ what Google Play and the App Store require, and nobody keeps it by hand. An app
181
+ config that still sets `android.versionCode` or `ios.buildNumber` fails to
182
+ load: delete them. `version` must be `MAJOR.MINOR.PATCH`.
183
+
184
+ `version` is also the OTA boundary (`withOxyUpdates`, `appVersion` policy):
185
+ bump it for a native change and the next push to main releases a new binary
186
+ (oxy's `android-release.yml`, docs/engineering/build-and-deploy.md#native-android-releases);
187
+ a JS-only change keeps the version and ships as an OTA update.
188
+
174
189
  #### Android WebP resources (opt-in)
175
190
 
176
191
  `withOxyAndroidWebp` needs `sharp` installed, so it is registered explicitly:
@@ -236,8 +251,23 @@ accepts no publish, without its key. Development builds may explicitly pass
236
251
  `{ codeSigning: 'auto' }` to receive platform warnings, or
237
252
  `{ codeSigning: false }` to opt out of verification.
238
253
 
239
- Publishing is `oxy-ship` (`@oxy.so/ship`); see that package's README and its
240
- `templates/publish-update.yml` CI workflow.
254
+ Publishing is `oxy-ship` (`@oxy.so/ship`) from GitHub Actions, with **no stored
255
+ secret** (oxy ADR 0057, GitHub trusted publishing). Per app repository:
256
+
257
+ 1. Declare the repository as the app's trusted publisher: an Oxy app adds
258
+ `trustedPublishers: [otaPublisher('OxyHQ/<Repo>', '<numeric id>')]` to its
259
+ entry in oxy's `seedOxyApplicationsSpecs.ts` and runs the seed; a
260
+ third-party app registers it with
261
+ `POST https://api.oxy.so/applications/<appId>/trusted-publishers`.
262
+ 2. Add `@oxy.so/ship` as a devDependency.
263
+ 3. Copy `@oxy.so/ship/templates/publish-update.yml` to
264
+ `.github/workflows/publish-update.yml` and set `OXY_CLIENT_ID` in it to the
265
+ same public client id passed to `withOxyUpdates` above.
266
+
267
+ Every push to `main` then publishes to `production`; the job's GitHub OIDC
268
+ token (`permissions: id-token: write`) is exchanged for a five-minute
269
+ `updates:publish` token of that app only. Pull requests never publish. See the
270
+ `@oxy.so/ship` README for the exchange and the registration fields.
241
271
 
242
272
  ### 2. Metro (`metro.config.js`)
243
273
 
@@ -1,5 +1,5 @@
1
1
  /*
2
- * Adapted from @expo/router-server 58.0.14 / 58.0.16 renderStreamingContent.
2
+ * Adapted from @expo/router-server 58.0.14–58.0.16 and 58.0.18–58.0.21 renderStreamingContent.
3
3
  * Copyright © 2026 650 Industries. MIT license: ./EXPO-LICENSE.
4
4
  * Static output only. Keep Expo's live streaming renderer unchanged.
5
5
  */
@@ -9,11 +9,7 @@ const { ExpoRoot } = require('expo-router');
9
9
  const { ctx } = require('expo-router/_ctx');
10
10
  const Head = require('expo-router/head').default;
11
11
  const { ServerDocument } = require('expo-router/internal/server');
12
- const {
13
- InnerRoot,
14
- getRouteInfoForLocation,
15
- registerStaticRootComponent,
16
- } = require('expo-router/internal/static');
12
+ const routerStatic = require('expo-router/internal/static');
17
13
  const { normalizeCssAssets } = require('expo-server/private');
18
14
  const { getRootComponent } = require('@expo/router-server/build/static/getRootComponent');
19
15
  const assets = require('@expo/router-server/build/utils/react');
@@ -23,6 +19,32 @@ const { renderHydratableDocument } = require('./render-document');
23
19
 
24
20
  const h = React.createElement;
25
21
 
22
+ const { InnerRoot, registerStaticRootComponent } = routerStatic;
23
+
24
+ // The page's route and its loader key, as the installed Expo renderer derives
25
+ // them. Through router-server 58.0.16 (expo-router ≤ 58.0.25) the route comes
26
+ // from the location and the loader key appends `location.search`. From 58.0.18
27
+ // (expo-router 58.0.30 removed `getRouteInfoForLocation`) the CLI passes the
28
+ // route it matched and its params, and the loader key appends the route's own
29
+ // search params.
30
+ function routeInfo(location, options) {
31
+ if (typeof routerStatic.getRouteInfoForMatchedRoute === 'function') {
32
+ if (!options.route) {
33
+ throw new Error(
34
+ '[@oxy.so/app-preset] staticHydrationBoundary: Expo called the renderer without the matched route.',
35
+ );
36
+ }
37
+ const { pathname, params, searchParams } = routerStatic.getRouteInfoForMatchedRoute(
38
+ options.route,
39
+ options.params ?? {},
40
+ location,
41
+ );
42
+ const search = searchParams.toString();
43
+ return { route: { pathname, params }, search: search ? `?${search}` : '' };
44
+ }
45
+ return { route: routerStatic.getRouteInfoForLocation(ctx, location), search: location.search };
46
+ }
47
+
26
48
  function StaticApp({ headContext, loadedData, element }) {
27
49
  return h(Head.Provider, { context: headContext }, h(InnerRoot, { loadedData }, element));
28
50
  }
@@ -40,7 +62,7 @@ function getStreamingContent(location, options) {
40
62
  return fonts.withServerContext(async () => {
41
63
  const headContext = {};
42
64
  const Document = getRootComponent();
43
- const route = getRouteInfoForLocation(ctx, location);
65
+ const { route, search } = routeInfo(location, options);
44
66
  // No document wrapper here: this is exactly the boundary hydrated in #root.
45
67
  const { element, getStyleElement } = registerStaticRootComponent(ExpoRoot, {
46
68
  location,
@@ -48,7 +70,7 @@ function getStreamingContent(location, options) {
48
70
  });
49
71
  // Match Expo's per-page reset; React Navigation caches named contexts globally.
50
72
  globalThis.__react_navigation__elements_contexts = new Map();
51
- const loaderKey = options.loader ? options.loader.key + location.search : null;
73
+ const loaderKey = options.loader ? options.loader.key + search : null;
52
74
  const loadedData = loaderKey ? { [loaderKey]: options.loader.data ?? null } : null;
53
75
  const app = h(StaticAppRoot, { headContext, loadedData, element });
54
76
 
@@ -4,9 +4,11 @@ const { requireFromProject } = require('../../plugin/requireFromProject');
4
4
  /** Opt-in compatibility adapter for Expo's static document/app render boundary. */
5
5
  function withStaticHydrationBoundary(config, projectRoot) {
6
6
  const { version } = requireFromProject('@expo/router-server/package.json', projectRoot);
7
- if (!/^58\.0\.(14|15|16)$/.test(version)) {
7
+ // 58.0.17 stays out: its renderer is a halfway step (the matched route with
8
+ // the old loader key) that was not reviewed.
9
+ if (!/^58\.0\.(14|15|16|18|19|20|21)$/.test(version)) {
8
10
  throw new Error(
9
- `[@oxy.so/app-preset] staticHydrationBoundary supports @expo/router-server 58.0.14–58.0.16; found ${version}. Review the upstream renderer before extending this range.`,
11
+ `[@oxy.so/app-preset] staticHydrationBoundary supports @expo/router-server 58.0.14–58.0.16 and 58.0.18–58.0.21; found ${version}. Review the upstream renderer before extending this range.`,
10
12
  );
11
13
  }
12
14
  const adapter = path.join(__dirname, 'renderer.js');
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@oxy.so/app-preset",
3
- "version": "5.3.0",
3
+ "version": "6.0.0",
4
4
  "description": "The Oxy distro of Expo — centralized Expo config plugin, Metro/Babel/ESLint factories, Tailwind base CSS and TypeScript bases shared by every Oxy app (Mention, Homiio, Allo, accounts, …). A zero-build package: apps replace copy-pasted config with a single dependency bump.",
5
5
  "main": "./app.plugin.js",
6
6
  "publishConfig": {
@@ -33,6 +33,8 @@
33
33
  * `withOxySharedPermissions` also signs every release build with the ONE Oxy
34
34
  * ecosystem key (the `OXY_UPLOAD_*` Gradle properties) and fails a release that
35
35
  * does not carry its certificate; an app lists no signing plugin of its own.
36
+ * `withOxyReleaseVersion` (always applied) derives Android `versionCode` and iOS
37
+ * `buildNumber` from `version` (1.2.3 → 1002003); an app sets neither.
36
38
  * `withOxyR8Optimize` (always applied) swaps in R8's `-optimize` ProGuard file on
37
39
  * Expo SDK 56/57 and is a no-op on 58.
38
40
  *
@@ -55,6 +57,7 @@
55
57
  const withOxyKeychain = require('./withOxyKeychain');
56
58
  const withOxyBuildProperties = require('./withOxyBuildProperties');
57
59
  const withOxyR8Optimize = require('./withOxyR8Optimize');
60
+ const withOxyReleaseVersion = require('./withOxyReleaseVersion');
58
61
  const { dirname, join } = require('node:path');
59
62
  const { projectRootOf, requireFromProject, resolveFromProject } = require('./requireFromProject');
60
63
 
@@ -103,6 +106,7 @@ module.exports = function withOxyAppPreset(config, options = {}) {
103
106
  }
104
107
 
105
108
  next = withOxyR8Optimize(next);
109
+ next = withOxyReleaseVersion(next);
106
110
 
107
111
  let withOxySharedPermissions;
108
112
  try {
@@ -0,0 +1,72 @@
1
+ /**
2
+ * Expo Config Plugin: withOxyReleaseVersion (always applied by the preset)
3
+ *
4
+ * Derives the store build number from the app's `version`, so it is never kept
5
+ * by hand and never drifts: Android `versionCode` and iOS `buildNumber` are
6
+ *
7
+ * major * 1_000_000 + minor * 1_000 + patch (1.2.3 → 1002003)
8
+ *
9
+ * The app `version` is already the OTA compatibility boundary (`withOxyUpdates`
10
+ * uses the `appVersion` runtime policy): a new native binary is exactly a new
11
+ * version, and every new version gets a strictly higher build number, which is
12
+ * what Google Play and the App Store require. JS-only changes ship as OTA
13
+ * updates under the same version and never need a build number.
14
+ *
15
+ * Applied by the preset and by `withOxyUpdates` (the OTA boundary it rests on),
16
+ * so it is idempotent: a number equal to the derived one passes. An app that
17
+ * keeps any OTHER `android.versionCode` or `ios.buildNumber` fails: two sources
18
+ * for one number is how a release ends up rejected for reusing one.
19
+ */
20
+ const VERSION_PATTERN = /^(\d+)\.(\d+)\.(\d+)$/;
21
+ const MAX_MAJOR = 2099; // Play's versionCode ceiling is 2_100_000_000.
22
+
23
+ /**
24
+ * @param {string} version
25
+ * @returns {number}
26
+ */
27
+ function releaseBuildNumber(version) {
28
+ const match = VERSION_PATTERN.exec(String(version));
29
+ if (!match) {
30
+ throw new Error(
31
+ `[@oxy.so/app-preset] The app \`version\` must be MAJOR.MINOR.PATCH (got ${JSON.stringify(version)}): ` +
32
+ 'the store build number is derived from it.',
33
+ );
34
+ }
35
+ const [major, minor, patch] = match.slice(1).map(Number);
36
+ if (major > MAX_MAJOR || minor > 999 || patch > 999) {
37
+ throw new Error(
38
+ `[@oxy.so/app-preset] The app \`version\` ${version} is out of range: major ≤ ${MAX_MAJOR}, minor and patch ≤ 999.`,
39
+ );
40
+ }
41
+ return major * 1_000_000 + minor * 1_000 + patch;
42
+ }
43
+
44
+ /**
45
+ * @param {import('expo/config').ExpoConfig} config
46
+ */
47
+ function withOxyReleaseVersion(config) {
48
+ if (config.version === undefined) {
49
+ throw new Error('[@oxy.so/app-preset] The app config needs a `version` (MAJOR.MINOR.PATCH).');
50
+ }
51
+ const buildNumber = releaseBuildNumber(config.version);
52
+ const versionCode = config.android?.versionCode;
53
+ if (versionCode !== undefined && versionCode !== buildNumber) {
54
+ throw new Error(
55
+ `[@oxy.so/app-preset] Remove \`android.versionCode\` (${versionCode}): the preset derives it from \`version\` (${buildNumber}).`,
56
+ );
57
+ }
58
+ const iosBuildNumber = config.ios?.buildNumber;
59
+ if (iosBuildNumber !== undefined && iosBuildNumber !== String(buildNumber)) {
60
+ throw new Error(
61
+ `[@oxy.so/app-preset] Remove \`ios.buildNumber\` (${iosBuildNumber}): the preset derives it from \`version\` (${buildNumber}).`,
62
+ );
63
+ }
64
+ return {
65
+ ...config,
66
+ android: { ...config.android, versionCode: buildNumber },
67
+ ios: { ...config.ios, buildNumber: String(buildNumber) },
68
+ };
69
+ }
70
+
71
+ module.exports = withOxyReleaseVersion;
72
+ module.exports.releaseBuildNumber = releaseBuildNumber;
@@ -68,6 +68,7 @@
68
68
  const fs = require('fs');
69
69
  const path = require('path');
70
70
  const { WarningAggregator } = require('expo/config-plugins');
71
+ const withOxyReleaseVersion = require('./withOxyReleaseVersion');
71
72
 
72
73
  /** Origin of the Oxy Updates server. `updates.oxy.so` does not exist; oxy-api serves it. */
73
74
  const DEFAULT_API_ORIGIN = 'https://api.oxy.so';
@@ -180,5 +181,7 @@ module.exports = function withOxyUpdates(config, options = {}) {
180
181
  next.runtimeVersion = { policy: runtimeVersionPolicy };
181
182
  }
182
183
 
183
- return next;
184
+ // `version` is the OTA boundary, so it also numbers the store build: an
185
+ // OTA-enabled app that skips the preset's main plugin gets the same rule.
186
+ return withOxyReleaseVersion(next);
184
187
  };