@oxy.so/app-preset 4.0.0 → 5.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/README.md +83 -18
- package/metro/index.js +76 -3
- package/metro/react-native.js +44 -0
- package/package.json +9 -7
- package/plugin/requireFromProject.js +14 -6
- package/plugin/withOxyAndroidRelease.js +15 -122
- package/plugin/withOxyAppPreset.js +18 -3
- package/plugin/withOxyR8Optimize.js +40 -0
package/README.md
CHANGED
|
@@ -14,8 +14,7 @@ and JSON.
|
|
|
14
14
|
|
|
15
15
|
| Piece | Import | Replaces |
|
|
16
16
|
| --- | --- | --- |
|
|
17
|
-
| Config plugin | `['@oxy.so/app-preset', {}]` | iOS keychain entitlement + `expo-build-properties` + `@oxy.so/services/plugins/withOxySharedPermissions` |
|
|
18
|
-
| Android release build | `@oxy.so/app-preset/plugin/withOxyAndroidRelease` | R8 `-optimize` ProGuard file + shared-keystore release signing (opt-in, see below) |
|
|
17
|
+
| Config plugin | `['@oxy.so/app-preset', {}]` | iOS keychain entitlement + `expo-build-properties` + `@oxy.so/services/plugins/withOxySharedPermissions` (which signs every release with the ecosystem key, see below) + the R8 `-optimize` ProGuard file |
|
|
19
18
|
| Android WebP resources | `@oxy.so/app-preset/plugin/withOxyAndroidWebp` | re-encoding generated mipmaps/splash bitmaps to real lossless WebP (opt-in, needs `sharp`) |
|
|
20
19
|
| Oxy Updates (OTA) | `@oxy.so/app-preset/plugin/withOxyUpdates` | the `expo-updates` manifest URL, release channel, `runtimeVersion` policy and the shared code-signing certificate (opt-in, see below) |
|
|
21
20
|
| Metro | `@oxy.so/app-preset/metro` | monorepo watch folders, block list, symlink + package-exports resolution, web-font/wasm asset exts, release minifier, NativeWind wrapper |
|
|
@@ -120,17 +119,61 @@ react-native's `Image` renders nothing for it, with no error. The keys exist fro
|
|
|
120
119
|
`expo-build-properties` 58 (Expo SDK 58); older versions ignore them silently.
|
|
121
120
|
|
|
122
121
|
The `sharedUserId` and `sharedIdentityReader` options were removed in 3.0.0 and
|
|
123
|
-
throw if passed. `@oxy.so/services`
|
|
122
|
+
throw if passed. `@oxy.so/services` 13.4.0+ is a required peer (the preset refuses an older one: it would declare the permissions without release signing).
|
|
124
123
|
|
|
125
124
|
`webgpu: true` (opt-in, 3.2.0+) also applies `react-native-webgpu`'s config
|
|
126
125
|
plugin, for an app that draws with WebGPU on native. Install
|
|
127
126
|
`react-native-webgpu` in the app first; the option throws without it.
|
|
128
127
|
|
|
129
|
-
#### Android release
|
|
128
|
+
#### Android release signing (always on, fails closed)
|
|
129
|
+
|
|
130
|
+
Every Oxy Android release is signed with the ONE ecosystem key (certificate
|
|
131
|
+
SHA-256 `b8ab3746466ce4569d7a6a0ffa1eed91bc375174d503613987ca09cb33d6a58d`,
|
|
132
|
+
alias `oxy`). It is not a preset plugin: `@oxy.so/services/plugins/withOxySharedPermissions`
|
|
133
|
+
applies `withOxyReleaseSigning` (services 13.4.0+), because the signature
|
|
134
|
+
permissions it declares are what make the certificate load-bearing. A release
|
|
135
|
+
signed with anything else takes ownership of `so.oxy.permission.IDENTITY` /
|
|
136
|
+
`DEVICE_SESSION`, after which every correctly signed Oxy app fails to install
|
|
137
|
+
(`INSTALL_FAILED_DUPLICATE_PERMISSION`), and Commons refuses it. So every app
|
|
138
|
+
that declares the permissions, through the preset or directly, gets the rule;
|
|
139
|
+
**list no signing plugin**.
|
|
140
|
+
|
|
141
|
+
The keystore comes from Gradle properties (`~/.gradle/gradle.properties`, `-P`,
|
|
142
|
+
or `ORG_GRADLE_PROJECT_<name>` environment variables), never from the repo:
|
|
143
|
+
|
|
144
|
+
```properties
|
|
145
|
+
OXY_UPLOAD_STORE_FILE=~/.config/oxy/oxy-ecosystem-release.keystore
|
|
146
|
+
OXY_UPLOAD_STORE_PASSWORD_FILE=~/.config/oxy/oxy-ecosystem-release-keystore.pass
|
|
147
|
+
OXY_UPLOAD_KEY_ALIAS=oxy
|
|
148
|
+
```
|
|
149
|
+
|
|
150
|
+
`OXY_UPLOAD_STORE_PASSWORD` takes the password itself instead of a file;
|
|
151
|
+
`OXY_UPLOAD_KEY_PASSWORD` (or `_FILE`) is needed only when the key's password
|
|
152
|
+
differs from the store's. `~/` is expanded, a password file is trimmed.
|
|
153
|
+
|
|
154
|
+
Release always uses `signingConfigs.release`; nothing falls back to the debug
|
|
155
|
+
key. A task, `oxyVerifyReleaseSigning`, runs before every release variant
|
|
156
|
+
(`pre…ReleaseBuild`, `validateSigning…Release`, so `assembleRelease`,
|
|
157
|
+
`bundleRelease`, `expo run:android --variant release` and EAS's release
|
|
158
|
+
builds) and fails the build, saying how to provide the key, unless the release
|
|
159
|
+
buildType's EFFECTIVE signing config opens and its certificate is the ecosystem
|
|
160
|
+
one. It checks the outcome, not the properties, so it also refuses EAS-managed
|
|
161
|
+
or per-app keys and a wrong alias. Debug builds never run it. There is no
|
|
162
|
+
opt-out for release.
|
|
163
|
+
|
|
164
|
+
Debug builds keep Expo's debug key unless `OXY_UPLOAD_SIGN_DEBUG=true` is set:
|
|
165
|
+
then debug is signed with the same key and checked by the same task, so a dev
|
|
166
|
+
client can be installed next to real Oxy apps and be granted the permissions
|
|
167
|
+
(this replaces Willo's `withOxyDebugSigning`, which prebuild now refuses). An app
|
|
168
|
+
that declares no Oxy permission (Authenticator) lists
|
|
169
|
+
`@oxy.so/services/plugins/withOxyReleaseSigning` directly for the same release
|
|
170
|
+
signing.
|
|
171
|
+
|
|
172
|
+
`withOxyAndroidRelease` was removed in 5.0.0; listing it throws and says to delete it.
|
|
173
|
+
|
|
174
|
+
#### Android WebP resources (opt-in)
|
|
130
175
|
|
|
131
|
-
|
|
132
|
-
signing config and the other needs `sharp` installed, so both are registered
|
|
133
|
-
explicitly by apps that ship to Play.
|
|
176
|
+
`withOxyAndroidWebp` needs `sharp` installed, so it is registered explicitly:
|
|
134
177
|
|
|
135
178
|
```js
|
|
136
179
|
plugins: [
|
|
@@ -138,17 +181,9 @@ plugins: [
|
|
|
138
181
|
// order, and this has to run after every image generator (splash included).
|
|
139
182
|
'@oxy.so/app-preset/plugin/withOxyAndroidWebp',
|
|
140
183
|
// …app-specific plugins…
|
|
141
|
-
'@oxy.so/app-preset/plugin/withOxyAndroidRelease',
|
|
142
184
|
]
|
|
143
185
|
```
|
|
144
186
|
|
|
145
|
-
`withOxyAndroidRelease` reads the release keystore from four Gradle properties
|
|
146
|
-
(`OXY_UPLOAD_STORE_FILE`, `OXY_UPLOAD_STORE_PASSWORD`, `OXY_UPLOAD_KEY_ALIAS`,
|
|
147
|
-
`OXY_UPLOAD_KEY_PASSWORD`) in `~/.gradle/gradle.properties` or CI secrets — never
|
|
148
|
-
from the repo. When they are absent the release buildType falls back to the debug
|
|
149
|
-
keystore, so **always verify the artefact's certificate** (`keytool -printcert
|
|
150
|
-
-jarfile <aab>`, `apksigner verify --print-certs <apk>`) instead of assuming.
|
|
151
|
-
|
|
152
187
|
`withOxyAndroidWebp` requires `sharp` as a devDependency of the app.
|
|
153
188
|
|
|
154
189
|
#### Oxy Updates (OTA) (opt-in)
|
|
@@ -232,6 +267,37 @@ paths are escaped and block only their descendants. `extraNodeModules`,
|
|
|
232
267
|
`extraWatchFolders`, `extraAssetExts`, and `extraSourceExts` extend the shared
|
|
233
268
|
defaults without replacing them.
|
|
234
269
|
|
|
270
|
+
#### `react-native` on native: the complete NativeWind shim (4.1.0+)
|
|
271
|
+
|
|
272
|
+
On native, NativeWind's resolver sends every `import … from 'react-native'`
|
|
273
|
+
outside React Native itself to `react-native-css/components`, a shim that
|
|
274
|
+
re-exports a FIXED list of React Native's API. A name React Native adds and the
|
|
275
|
+
list lacks reads as `undefined`: React Native 0.88 added `AssetRegistry`, Expo
|
|
276
|
+
SDK 58's `expo-asset` imports it from `'react-native'`, every `useFonts` failed
|
|
277
|
+
(`Cannot read property 'getAssetByID' of undefined`), Bloom's font loader never
|
|
278
|
+
rendered its children, and Android release builds showed a blank screen with no
|
|
279
|
+
visible error (upstream: nativewind/react-native-css#506, #504).
|
|
280
|
+
|
|
281
|
+
`createOxyMetroConfig` returns `metro/react-native.js` wherever NativeWind
|
|
282
|
+
resolved `react-native` to that shim: the shim's own properties, copied as they
|
|
283
|
+
are (so `className` behaves exactly as NativeWind makes it), plus every other
|
|
284
|
+
name of React Native's index, forwarded to React Native. Only a request for
|
|
285
|
+
exactly `react-native` that NativeWind resolved to the shim is touched; web,
|
|
286
|
+
deep `react-native/…` imports and every other module resolve as before. No
|
|
287
|
+
`node_modules` patch is needed, and a name React Native adds later is covered
|
|
288
|
+
without one. An app that wraps the returned `resolveRequest` in its own (Allo's
|
|
289
|
+
`@hpke` and harness aliases) sits above this one, which is fine as long as it
|
|
290
|
+
hands `react-native` and `react-native-css/components` down unchanged.
|
|
291
|
+
|
|
292
|
+
An app that still composes `withNativeWind` itself gets the same fix by
|
|
293
|
+
wrapping its finished config, LAST (over worklets' Bundle Mode too):
|
|
294
|
+
|
|
295
|
+
```js
|
|
296
|
+
const { withCompleteReactNative } = require('@oxy.so/app-preset/metro');
|
|
297
|
+
|
|
298
|
+
module.exports = withCompleteReactNative(withNativeWind(config, options), __dirname);
|
|
299
|
+
```
|
|
300
|
+
|
|
235
301
|
### 3. Babel (`babel.config.js`)
|
|
236
302
|
|
|
237
303
|
```js
|
|
@@ -305,6 +371,5 @@ Requires **Expo SDK 56+**; validated against **Expo SDK 58 / React Native 0.88**
|
|
|
305
371
|
(the current Oxy ecosystem target) with a clean `expo prebuild` of `test-app-expo`,
|
|
306
372
|
`accounts` and `commons` (Android and iOS). SDK 58's Android template already
|
|
307
373
|
uses `proguard-android-optimize.txt` and turns R8 on through `gradle.properties`
|
|
308
|
-
(`android.enableMinifyInReleaseBuilds`), so
|
|
309
|
-
only
|
|
310
|
-
`-optimize` ProGuard file.
|
|
374
|
+
(`android.enableMinifyInReleaseBuilds`), so the preset's `-optimize` ProGuard
|
|
375
|
+
swap only changes anything on SDK 56/57.
|
package/metro/index.js
CHANGED
|
@@ -271,6 +271,74 @@ function createOxyMetroConfig(projectRoot, options = {}) {
|
|
|
271
271
|
});
|
|
272
272
|
}
|
|
273
273
|
|
|
274
|
+
const COMPLETE_REACT_NATIVE = path.join(__dirname, 'react-native.js');
|
|
275
|
+
/** Both spellings: Metro reports real paths, and the preset may sit behind a symlink. */
|
|
276
|
+
const COMPLETE_REACT_NATIVE_PATHS = new Set([
|
|
277
|
+
COMPLETE_REACT_NATIVE,
|
|
278
|
+
fs.realpathSync(COMPLETE_REACT_NATIVE),
|
|
279
|
+
]);
|
|
280
|
+
/** `react-native-css/components`' entry, by any of the conditions Metro may pick. */
|
|
281
|
+
const CSS_COMPONENTS_ENTRY =
|
|
282
|
+
/[/\\]react-native-css[/\\](?:dist[/\\](?:commonjs|module)[/\\]components[/\\]index\.cjs|src[/\\]components[/\\]index\.cts)$/;
|
|
283
|
+
|
|
284
|
+
/**
|
|
285
|
+
* Wraps a NativeWind Metro config so that wherever NativeWind sends
|
|
286
|
+
* `react-native` to `react-native-css/components`, the import gets
|
|
287
|
+
* `./react-native.js` instead: that shim with every name of React Native's
|
|
288
|
+
* index it lacks (React Native 0.88's `AssetRegistry`, which `expo-asset`
|
|
289
|
+
* reads) forwarded to React Native. Every name the shim defines keeps its own
|
|
290
|
+
* getter, so `className` behaves exactly as NativeWind makes it.
|
|
291
|
+
*
|
|
292
|
+
* Narrow on purpose: only a request for exactly `react-native` that NativeWind
|
|
293
|
+
* resolved to the shim's entry is touched. Web (NativeWind leaves
|
|
294
|
+
* `react-native-web` imports alone at this level), deep `react-native/…`
|
|
295
|
+
* imports and every other module resolve as before.
|
|
296
|
+
*
|
|
297
|
+
* Apply it LAST, over every other resolver (NativeWind's, worklets' Bundle
|
|
298
|
+
* Mode, an app's own): it has to see the final resolution, and the completed
|
|
299
|
+
* module's own two imports must reach no redirect beneath it. They go straight
|
|
300
|
+
* to Metro's resolver (NativeWind's redirect would point the module at itself,
|
|
301
|
+
* worklets' at a module that requires it back) and resolve from the project,
|
|
302
|
+
* which sees both packages under any linker; the preset depends on neither.
|
|
303
|
+
*
|
|
304
|
+
* @param {import('metro-config').MetroConfig} config The finished config, NativeWind applied.
|
|
305
|
+
* @param {string} [projectRoot=config.projectRoot] The app package.
|
|
306
|
+
* @returns {import('metro-config').MetroConfig} `config`, its resolver wrapped.
|
|
307
|
+
*/
|
|
308
|
+
function withCompleteReactNative(config, projectRoot = config.projectRoot) {
|
|
309
|
+
const parentResolveRequest = config.resolver.resolveRequest;
|
|
310
|
+
const projectOrigin = path.join(projectRoot, 'package.json');
|
|
311
|
+
|
|
312
|
+
config.resolver.resolveRequest = (context, moduleName, platform) => {
|
|
313
|
+
if (
|
|
314
|
+
COMPLETE_REACT_NATIVE_PATHS.has(context.originModulePath) &&
|
|
315
|
+
(moduleName === 'react-native' || moduleName === 'react-native-css/components')
|
|
316
|
+
) {
|
|
317
|
+
return context.resolveRequest(
|
|
318
|
+
{ ...context, originModulePath: projectOrigin },
|
|
319
|
+
moduleName,
|
|
320
|
+
platform,
|
|
321
|
+
);
|
|
322
|
+
}
|
|
323
|
+
|
|
324
|
+
const resolution = (parentResolveRequest ?? context.resolveRequest)(
|
|
325
|
+
context,
|
|
326
|
+
moduleName,
|
|
327
|
+
platform,
|
|
328
|
+
);
|
|
329
|
+
if (
|
|
330
|
+
moduleName === 'react-native' &&
|
|
331
|
+
resolution?.type === 'sourceFile' &&
|
|
332
|
+
CSS_COMPONENTS_ENTRY.test(resolution.filePath)
|
|
333
|
+
) {
|
|
334
|
+
return { type: 'sourceFile', filePath: COMPLETE_REACT_NATIVE };
|
|
335
|
+
}
|
|
336
|
+
return resolution;
|
|
337
|
+
};
|
|
338
|
+
|
|
339
|
+
return config;
|
|
340
|
+
}
|
|
341
|
+
|
|
274
342
|
/**
|
|
275
343
|
* Wraps a NativeWind Metro config with the Bloom single-instance rewrite and the
|
|
276
344
|
* web `ws` shim. In hoisted monorepos the same Bloom version is duplicated under
|
|
@@ -300,8 +368,9 @@ function withBloomSingleInstance(nativeWindConfig, projectRoot) {
|
|
|
300
368
|
|
|
301
369
|
/**
|
|
302
370
|
* Wraps the finished config for react-native-worklets' Bundle Mode. Applied
|
|
303
|
-
*
|
|
304
|
-
*
|
|
371
|
+
* after Bloom's and NativeWind's resolvers, so worklets' resolver sees every
|
|
372
|
+
* request before them and hands the rest down; only
|
|
373
|
+
* {@link withCompleteReactNative} sits above it.
|
|
305
374
|
*/
|
|
306
375
|
function withWorkletsBundleMode(config, projectRoot) {
|
|
307
376
|
let bundleMode;
|
|
@@ -321,11 +390,15 @@ function createOxyMetroConfigWithBloom(projectRoot, options = {}) {
|
|
|
321
390
|
const nativeWindConfig = createOxyMetroConfig(projectRoot, options);
|
|
322
391
|
let config = withBloomSingleInstance(nativeWindConfig, projectRoot);
|
|
323
392
|
if (staticHydrationBoundary) config = withStaticHydrationBoundary(config, projectRoot);
|
|
324
|
-
|
|
393
|
+
if (workletsBundleMode) config = withWorkletsBundleMode(config, projectRoot);
|
|
394
|
+
// Outermost, so it sees the final resolution and its own module's imports
|
|
395
|
+
// reach no redirect beneath it.
|
|
396
|
+
return withCompleteReactNative(config, projectRoot);
|
|
325
397
|
}
|
|
326
398
|
|
|
327
399
|
module.exports = {
|
|
328
400
|
createOxyMetroConfig: createOxyMetroConfigWithBloom,
|
|
329
401
|
findWorkspaceRoot,
|
|
330
402
|
withBloomSingleInstance,
|
|
403
|
+
withCompleteReactNative,
|
|
331
404
|
};
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* What `import … from 'react-native'` resolves to on native under the preset,
|
|
3
|
+
* wherever NativeWind would have sent it to `react-native-css/components`.
|
|
4
|
+
*
|
|
5
|
+
* NativeWind's resolver (`globalClassNamePolyfill`) redirects every
|
|
6
|
+
* `react-native` import outside React Native itself to that shim, which
|
|
7
|
+
* re-exports a FIXED list of React Native's API: the components it wraps for
|
|
8
|
+
* `className`, and a getter per remaining name. A name React Native adds and the
|
|
9
|
+
* list lacks reads as `undefined`. React Native 0.88 added `AssetRegistry`;
|
|
10
|
+
* Expo SDK 58's `expo-asset` imports it from 'react-native', so every
|
|
11
|
+
* `useFonts` failed (`Cannot read property 'getAssetByID' of undefined`) and a
|
|
12
|
+
* release build sat on a blank screen with no visible error.
|
|
13
|
+
*
|
|
14
|
+
* This module is that shim plus every name of React Native's runtime index it
|
|
15
|
+
* does not define. The shim's own properties are copied as they are (the same
|
|
16
|
+
* getters), so every component NativeWind wraps, and every name it lists,
|
|
17
|
+
* behaves exactly as before; a missing name forwards to React Native's.
|
|
18
|
+
* Nothing is read until it is used: React Native's index is an object of
|
|
19
|
+
* getters, and only property NAMES are enumerated here.
|
|
20
|
+
*
|
|
21
|
+
* `withCompleteReactNative` (`./index.js`) routes both requires below past
|
|
22
|
+
* NativeWind: the first to the real shim, the second to the real React Native.
|
|
23
|
+
*/
|
|
24
|
+
const css = require('react-native-css/components');
|
|
25
|
+
const reactNative = require('react-native');
|
|
26
|
+
|
|
27
|
+
const completed = {};
|
|
28
|
+
|
|
29
|
+
for (const key of Object.getOwnPropertyNames(css)) {
|
|
30
|
+
Object.defineProperty(completed, key, Object.getOwnPropertyDescriptor(css, key));
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
for (const key of Object.getOwnPropertyNames(reactNative)) {
|
|
34
|
+
if (Object.hasOwn(completed, key)) continue;
|
|
35
|
+
Object.defineProperty(completed, key, {
|
|
36
|
+
configurable: true,
|
|
37
|
+
enumerable: Object.getOwnPropertyDescriptor(reactNative, key).enumerable,
|
|
38
|
+
get() {
|
|
39
|
+
return reactNative[key];
|
|
40
|
+
},
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
module.exports = completed;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@oxy.so/app-preset",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "5.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": {
|
|
@@ -62,10 +62,10 @@
|
|
|
62
62
|
"scripts": {
|
|
63
63
|
"test": "node --test __tests__/*.test.js"
|
|
64
64
|
},
|
|
65
|
-
"//peerDependencies": "THE TWO @oxy.so PEERS ARE DELIBERATE. This package couples to them by FILE PATH, not by API: `css/base.css` imports `@oxy.so/bloom/design-tokens/theme.css`, and `plugin/withOxyAppPreset.js` requires `@oxy.so/services/plugins/withOxySharedPermissions` (services
|
|
65
|
+
"//peerDependencies": "THE TWO @oxy.so PEERS ARE DELIBERATE. This package couples to them by FILE PATH, not by API: `css/base.css` imports `@oxy.so/bloom/design-tokens/theme.css`, and `plugin/withOxyAppPreset.js` requires `@oxy.so/services/plugins/withOxySharedPermissions` together with the `withOxyReleaseSigning` it applies (services 13.4.0+, the first release whose permissions plugin signs and checks the release; the floor is that release). Both peers retain a measured floor and are deliberately OPEN-ENDED above it: Oxy apps always run the latest Bloom and Services, so a new release of either must never need a preset release first. A release that breaks this package's file-path coupling is caught by its own tests and the apps' CI, not by a cap. Never replace either constraint with `*`.",
|
|
66
66
|
"peerDependencies": {
|
|
67
67
|
"@oxy.so/bloom": "^2.0.0 || ^3.0.0 || ^4.2.0 || ^5.1.0 || >=6.0.0",
|
|
68
|
-
"@oxy.so/services": ">=
|
|
68
|
+
"@oxy.so/services": ">=13.4.0",
|
|
69
69
|
"babel-preset-expo": "*",
|
|
70
70
|
"eslint": ">=9.0.0",
|
|
71
71
|
"eslint-config-expo": "*",
|
|
@@ -84,14 +84,16 @@
|
|
|
84
84
|
"react-dom": ">=19.0.0 <20.0.0"
|
|
85
85
|
},
|
|
86
86
|
"devDependencies": {
|
|
87
|
-
"expo": "~58.0.
|
|
88
|
-
"nativewind": "5.0.0-
|
|
87
|
+
"expo": "~58.0.19",
|
|
88
|
+
"nativewind": "5.0.0-rc.0",
|
|
89
89
|
"tailwindcss": "4.3.3",
|
|
90
90
|
"react": "19.3.0",
|
|
91
91
|
"react-dom": "19.3.0",
|
|
92
92
|
"jsdom": "^29.1.1",
|
|
93
|
-
"expo-router": "~58.0.
|
|
94
|
-
"@expo/router-server": "58.0.14"
|
|
93
|
+
"expo-router": "~58.0.26",
|
|
94
|
+
"@expo/router-server": "58.0.14",
|
|
95
|
+
"react-native": "0.88.0",
|
|
96
|
+
"react-native-css": "3.1.0-rc.0"
|
|
95
97
|
},
|
|
96
98
|
"peerDependenciesMeta": {
|
|
97
99
|
"@oxy.so/bloom": {
|
|
@@ -12,16 +12,24 @@
|
|
|
12
12
|
* @param {string | undefined} projectRoot The app's directory.
|
|
13
13
|
*/
|
|
14
14
|
function requireFromProject(specifier, projectRoot) {
|
|
15
|
+
return require(resolveFromProject(specifier, projectRoot));
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* The file `requireFromProject` would load, resolved the same way.
|
|
20
|
+
*
|
|
21
|
+
* @param {string} specifier
|
|
22
|
+
* @param {string | undefined} projectRoot
|
|
23
|
+
*/
|
|
24
|
+
function resolveFromProject(specifier, projectRoot) {
|
|
15
25
|
if (projectRoot) {
|
|
16
|
-
let resolved;
|
|
17
26
|
try {
|
|
18
|
-
|
|
27
|
+
return require.resolve(specifier, { paths: [projectRoot] });
|
|
19
28
|
} catch {
|
|
20
|
-
|
|
29
|
+
// Fall through to the preset's own resolution.
|
|
21
30
|
}
|
|
22
|
-
if (resolved) return require(resolved);
|
|
23
31
|
}
|
|
24
|
-
return require(specifier);
|
|
32
|
+
return require.resolve(specifier);
|
|
25
33
|
}
|
|
26
34
|
|
|
27
35
|
/**
|
|
@@ -34,4 +42,4 @@ function projectRootOf(config) {
|
|
|
34
42
|
return config?._internal?.projectRoot ?? process.cwd();
|
|
35
43
|
}
|
|
36
44
|
|
|
37
|
-
module.exports = { requireFromProject, projectRootOf };
|
|
45
|
+
module.exports = { requireFromProject, resolveFromProject, projectRootOf };
|
|
@@ -1,127 +1,20 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* Removed in `@oxy.so/app-preset` 5.0.0. It stays only to fail with the fix
|
|
3
|
+
* instead of an unresolvable module path; it does nothing else.
|
|
3
4
|
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
* `
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
* `android/` is gitignored and regenerated by `expo prebuild`, so these edits
|
|
11
|
-
* have to live in a plugin or they are lost on the next prebuild.
|
|
12
|
-
*
|
|
13
|
-
* 1. R8 optimization passes
|
|
14
|
-
* Expo generates `getDefaultProguardFile("proguard-android.txt")`, whose
|
|
15
|
-
* only meaningful line is `-dontoptimize`. Swapping to the `-optimize`
|
|
16
|
-
* variant drops that and adds `-allowaccessmodification`, which is what lets
|
|
17
|
-
* R8 inline and merge classes. Worth a few MB of dex on a typical Oxy app.
|
|
18
|
-
* Expo SDK 58's template already generates the `-optimize` file, so on SDK
|
|
19
|
-
* 58 this step is a no-op and only the signing config below changes.
|
|
20
|
-
*
|
|
21
|
-
* 2. Release signing
|
|
22
|
-
* Expo generates `signingConfig signingConfigs.debug` for release, and Play
|
|
23
|
-
* rejects a debug-signed AAB. The real credentials are read from Gradle
|
|
24
|
-
* properties (set in the developer's `~/.gradle/gradle.properties` or CI
|
|
25
|
-
* secrets) so nothing secret ever lands in the repo. When those properties
|
|
26
|
-
* are absent the build falls back to the debug keystore, so a contributor
|
|
27
|
-
* without the keystore can still build — which is exactly why the shipped
|
|
28
|
-
* artefact's certificate must ALWAYS be verified (`keytool -printcert
|
|
29
|
-
* -jarfile <aab>` / `apksigner verify --print-certs <apk>`) rather than
|
|
30
|
-
* assumed.
|
|
31
|
-
*
|
|
32
|
-
* The certificate MUST be the shared Oxy ecosystem one: Oxy apps share the
|
|
33
|
-
* identity and the device session through `signature`-level permissions
|
|
34
|
-
* (`withOxySharedPermissions`) and providers that check the caller's
|
|
35
|
-
* certificate. An app-specific key is refused by Commons, and its duplicate
|
|
36
|
-
* permission declaration makes Android refuse to install it next to its
|
|
37
|
-
* siblings (INSTALL_FAILED_DUPLICATE_PERMISSION).
|
|
38
|
-
*
|
|
39
|
-
* @param {import('expo/config').ExpoConfig} config
|
|
5
|
+
* Release signing moved to `@oxy.so/services/plugins/withOxySharedPermissions`
|
|
6
|
+
* (services 13.4.0), which every Oxy Android app already applies (directly or
|
|
7
|
+
* through `['@oxy.so/app-preset', {}]`): an app cannot declare the Oxy signature
|
|
8
|
+
* permissions without its release being signed with, and checked against, the
|
|
9
|
+
* ecosystem certificate. The R8 `-optimize` swap moved into
|
|
10
|
+
* `['@oxy.so/app-preset', {}]`.
|
|
40
11
|
*/
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
const KEY_PASSWORD = 'OXY_UPLOAD_KEY_PASSWORD';
|
|
49
|
-
|
|
50
|
-
const DEFAULT_PROGUARD = 'getDefaultProguardFile("proguard-android.txt")';
|
|
51
|
-
const OPTIMIZED_PROGUARD = 'getDefaultProguardFile("proguard-android-optimize.txt")';
|
|
52
|
-
|
|
53
|
-
const DEBUG_SIGNING_CONFIG = 'signingConfig signingConfigs.debug';
|
|
54
|
-
const CONDITIONAL_SIGNING_CONFIG = `signingConfig project.hasProperty('${STORE_FILE}') ? signingConfigs.release : signingConfigs.debug`;
|
|
55
|
-
|
|
56
|
-
const RELEASE_SIGNING_CONFIG = ` release {
|
|
57
|
-
// Populated only when the Oxy release keystore properties are
|
|
58
|
-
// available; otherwise this config stays empty and the release
|
|
59
|
-
// buildType falls back to signingConfigs.debug below.
|
|
60
|
-
if (project.hasProperty('${STORE_FILE}')) {
|
|
61
|
-
storeFile file(project.property('${STORE_FILE}'))
|
|
62
|
-
storePassword project.property('${STORE_PASSWORD}')
|
|
63
|
-
keyAlias project.property('${KEY_ALIAS}')
|
|
64
|
-
keyPassword project.property('${KEY_PASSWORD}')
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
`;
|
|
68
|
-
|
|
69
|
-
function useOptimizedProguardFile(contents) {
|
|
70
|
-
if (contents.includes(OPTIMIZED_PROGUARD)) return contents;
|
|
71
|
-
if (!contents.includes(DEFAULT_PROGUARD)) {
|
|
72
|
-
throw new Error(
|
|
73
|
-
`[withOxyAndroidRelease] Could not find ${DEFAULT_PROGUARD} in app/build.gradle. ` +
|
|
74
|
-
'The Expo template changed — update this plugin instead of editing android/ by hand.',
|
|
75
|
-
);
|
|
76
|
-
}
|
|
77
|
-
return contents.replace(DEFAULT_PROGUARD, OPTIMIZED_PROGUARD);
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
function addReleaseSigningConfig(contents) {
|
|
81
|
-
if (contents.includes(CONDITIONAL_SIGNING_CONFIG)) return contents;
|
|
82
|
-
|
|
83
|
-
// Declare signingConfigs.release immediately after the generated debug entry.
|
|
84
|
-
const debugSigningBlock = /(signingConfigs\s*\{\s*\n\s*debug\s*\{[\s\S]*?\n\s{8}\}\n)/;
|
|
85
|
-
if (!debugSigningBlock.test(contents)) {
|
|
86
|
-
throw new Error(
|
|
87
|
-
'[withOxyAndroidRelease] Could not find the generated signingConfigs.debug block in ' +
|
|
88
|
-
'app/build.gradle. The Expo template changed — update this plugin.',
|
|
89
|
-
);
|
|
90
|
-
}
|
|
91
|
-
const next = contents.replace(debugSigningBlock, `$1${RELEASE_SIGNING_CONFIG}`);
|
|
92
|
-
|
|
93
|
-
// Point the release buildType at it. The debug buildType also contains
|
|
94
|
-
// `signingConfig signingConfigs.debug`, so only replace the occurrence that
|
|
95
|
-
// follows the `release {` marker.
|
|
96
|
-
const releaseBuildType = next.indexOf('release {', next.indexOf('buildTypes'));
|
|
97
|
-
if (releaseBuildType === -1) {
|
|
98
|
-
throw new Error(
|
|
99
|
-
'[withOxyAndroidRelease] Could not find the release buildType in app/build.gradle.',
|
|
100
|
-
);
|
|
101
|
-
}
|
|
102
|
-
const target = next.indexOf(DEBUG_SIGNING_CONFIG, releaseBuildType);
|
|
103
|
-
if (target === -1) {
|
|
104
|
-
throw new Error(
|
|
105
|
-
'[withOxyAndroidRelease] Could not find the release buildType signingConfig line.',
|
|
106
|
-
);
|
|
107
|
-
}
|
|
108
|
-
return (
|
|
109
|
-
next.slice(0, target) +
|
|
110
|
-
CONDITIONAL_SIGNING_CONFIG +
|
|
111
|
-
next.slice(target + DEBUG_SIGNING_CONFIG.length)
|
|
12
|
+
module.exports = function withOxyAndroidRelease() {
|
|
13
|
+
throw new Error(
|
|
14
|
+
'[@oxy.so/app-preset] plugin/withOxyAndroidRelease was removed in 5.0.0. Delete it from the ' +
|
|
15
|
+
'app config: release signing is applied by @oxy.so/services/plugins/withOxySharedPermissions ' +
|
|
16
|
+
"(@oxy.so/services 13.4.0 or later, also applied by ['@oxy.so/app-preset', {}]), and it now " +
|
|
17
|
+
'FAILS a release build that is not signed with the Oxy ecosystem key. The R8 -optimize ' +
|
|
18
|
+
"ProGuard swap is applied by ['@oxy.so/app-preset', {}].",
|
|
112
19
|
);
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
module.exports = function withOxyAndroidRelease(config) {
|
|
116
|
-
return withAppBuildGradle(config, (config) => {
|
|
117
|
-
if (config.modResults.language !== 'groovy') {
|
|
118
|
-
throw new Error(
|
|
119
|
-
`[withOxyAndroidRelease] Expected a Groovy app/build.gradle, got ${config.modResults.language}.`,
|
|
120
|
-
);
|
|
121
|
-
}
|
|
122
|
-
config.modResults.contents = addReleaseSigningConfig(
|
|
123
|
-
useOptimizedProguardFile(config.modResults.contents),
|
|
124
|
-
);
|
|
125
|
-
return config;
|
|
126
|
-
});
|
|
127
20
|
};
|
|
@@ -30,6 +30,12 @@
|
|
|
30
30
|
* options throw, so an app config that still passes them fails loudly instead
|
|
31
31
|
* of silently doing something else.
|
|
32
32
|
*
|
|
33
|
+
* `withOxySharedPermissions` also signs every release build with the ONE Oxy
|
|
34
|
+
* ecosystem key (the `OXY_UPLOAD_*` Gradle properties) and fails a release that
|
|
35
|
+
* does not carry its certificate; an app lists no signing plugin of its own.
|
|
36
|
+
* `withOxyR8Optimize` (always applied) swaps in R8's `-optimize` ProGuard file on
|
|
37
|
+
* Expo SDK 56/57 and is a no-op on 58.
|
|
38
|
+
*
|
|
33
39
|
* @param {import('expo/config').ExpoConfig} config
|
|
34
40
|
* @param {object} [options]
|
|
35
41
|
* @param {string|false} [options.keychainGroup='group.so.oxy.shared']
|
|
@@ -48,7 +54,9 @@
|
|
|
48
54
|
*/
|
|
49
55
|
const withOxyKeychain = require('./withOxyKeychain');
|
|
50
56
|
const withOxyBuildProperties = require('./withOxyBuildProperties');
|
|
51
|
-
const
|
|
57
|
+
const withOxyR8Optimize = require('./withOxyR8Optimize');
|
|
58
|
+
const { dirname, join } = require('node:path');
|
|
59
|
+
const { projectRootOf, requireFromProject, resolveFromProject } = require('./requireFromProject');
|
|
52
60
|
|
|
53
61
|
const REMOVED_OPTIONS = {
|
|
54
62
|
sharedUserId:
|
|
@@ -94,15 +102,22 @@ module.exports = function withOxyAppPreset(config, options = {}) {
|
|
|
94
102
|
next = withOxyBuildProperties(next, { ios, android });
|
|
95
103
|
}
|
|
96
104
|
|
|
105
|
+
next = withOxyR8Optimize(next);
|
|
106
|
+
|
|
97
107
|
let withOxySharedPermissions;
|
|
98
108
|
try {
|
|
99
|
-
|
|
109
|
+
const permissionsPlugin = resolveFromProject(
|
|
100
110
|
'@oxy.so/services/plugins/withOxySharedPermissions',
|
|
101
111
|
projectRootOf(config),
|
|
102
112
|
);
|
|
113
|
+
// A Services older than 13.4.0 declares the permissions WITHOUT release
|
|
114
|
+
// signing, and Expo's template then signs release with the debug key: refuse
|
|
115
|
+
// it. Its sibling, because withOxySharedPermissions loads that very file.
|
|
116
|
+
require.resolve(join(dirname(permissionsPlugin), 'withOxyReleaseSigning'));
|
|
117
|
+
withOxySharedPermissions = require(permissionsPlugin);
|
|
103
118
|
} catch (error) {
|
|
104
119
|
throw new Error(
|
|
105
|
-
"[@oxy.so/app-preset] needs '@oxy.so/services'
|
|
120
|
+
"[@oxy.so/app-preset] needs '@oxy.so/services' 13.4.0 or later (for plugins/withOxySharedPermissions and withOxyReleaseSigning). " +
|
|
106
121
|
`Install it in the app. (${error instanceof Error ? error.message : String(error)})`,
|
|
107
122
|
);
|
|
108
123
|
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Expo Config Plugin: withOxyR8Optimize (applied by `['@oxy.so/app-preset', {}]`).
|
|
3
|
+
*
|
|
4
|
+
* Expo SDK 56/57 generate `getDefaultProguardFile("proguard-android.txt")` for
|
|
5
|
+
* the release buildType, whose only meaningful line is `-dontoptimize`. The
|
|
6
|
+
* `-optimize` variant drops it and adds `-allowaccessmodification`, which is what
|
|
7
|
+
* lets R8 inline and merge classes (measured on Mention: dex 22,814,960 →
|
|
8
|
+
* 15,290,636 bytes uncompressed, -33%, 4 dex files → 2). SDK 58's template
|
|
9
|
+
* already generates the `-optimize` file, so there this is a no-op.
|
|
10
|
+
*
|
|
11
|
+
* Release signing is not here: `@oxy.so/services/plugins/withOxySharedPermissions`
|
|
12
|
+
* (which the preset applies) owns it, because the signature permissions it
|
|
13
|
+
* declares are what make the certificate load-bearing.
|
|
14
|
+
*/
|
|
15
|
+
const { withAppBuildGradle } = require('expo/config-plugins');
|
|
16
|
+
|
|
17
|
+
const DEFAULT_PROGUARD = 'getDefaultProguardFile("proguard-android.txt")';
|
|
18
|
+
const OPTIMIZED_PROGUARD = 'getDefaultProguardFile("proguard-android-optimize.txt")';
|
|
19
|
+
|
|
20
|
+
/** @param {string} contents */
|
|
21
|
+
function optimizeProguardFile(contents) {
|
|
22
|
+
if (contents.includes(OPTIMIZED_PROGUARD)) return contents;
|
|
23
|
+
if (!contents.includes(DEFAULT_PROGUARD)) {
|
|
24
|
+
throw new Error(
|
|
25
|
+
`[@oxy.so/app-preset withOxyR8Optimize] Could not find ${DEFAULT_PROGUARD} in app/build.gradle. ` +
|
|
26
|
+
'The Expo template changed: update this plugin instead of editing android/ by hand.',
|
|
27
|
+
);
|
|
28
|
+
}
|
|
29
|
+
return contents.replace(DEFAULT_PROGUARD, OPTIMIZED_PROGUARD);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
module.exports = function withOxyR8Optimize(config) {
|
|
33
|
+
return withAppBuildGradle(config, (modConfig) => {
|
|
34
|
+
if (modConfig.modResults.language === 'groovy') {
|
|
35
|
+
modConfig.modResults.contents = optimizeProguardFile(modConfig.modResults.contents);
|
|
36
|
+
}
|
|
37
|
+
return modConfig;
|
|
38
|
+
});
|
|
39
|
+
};
|
|
40
|
+
module.exports.optimizeProguardFile = optimizeProguardFile;
|