@capgo/capacitor-patch 8.1.0 → 8.2.1

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.
Files changed (34) hide show
  1. package/README.md +195 -11
  2. package/package.json +1 -1
  3. package/patches/catalog.json +657 -9
  4. package/patches/upstream-pr-6991-android-native-bridge.patch +15 -0
  5. package/patches/upstream-pr-6991-ios-native-bridge.patch +15 -0
  6. package/patches/upstream-pr-7301-core.patch +38 -0
  7. package/patches/upstream-pr-7419-ios.patch +13 -0
  8. package/patches/upstream-pr-7420-ios.patch +13 -0
  9. package/patches/upstream-pr-7446-android.patch +14 -0
  10. package/patches/upstream-pr-7490-android.patch +13 -0
  11. package/patches/upstream-pr-7490-ios.patch +13 -0
  12. package/patches/upstream-pr-7535-android.patch +13 -0
  13. package/patches/upstream-pr-7599-ios.patch +86 -0
  14. package/patches/upstream-pr-7732-android-native-bridge.patch +12 -0
  15. package/patches/upstream-pr-7732-ios-native-bridge.patch +12 -0
  16. package/patches/upstream-pr-7781-android.patch +24 -0
  17. package/patches/upstream-pr-7803-android.patch +13 -0
  18. package/patches/upstream-pr-7831-ios.patch +13 -0
  19. package/patches/upstream-pr-7987-android.patch +42 -0
  20. package/patches/upstream-pr-8087-android.patch +64 -0
  21. package/patches/upstream-pr-8188-cli.patch +18 -0
  22. package/patches/upstream-pr-8190-android.patch +13 -0
  23. package/patches/upstream-pr-8249-ios.patch +32 -0
  24. package/patches/upstream-pr-8252-cli.patch +31 -0
  25. package/patches/upstream-pr-8271-core.patch +30 -0
  26. package/patches/upstream-pr-8275-android.patch +158 -0
  27. package/patches/upstream-pr-8304-ios.patch +36 -0
  28. package/patches/upstream-pr-8418-android.patch +82 -0
  29. package/patches/upstream-pr-8424-android.patch +55 -0
  30. package/patches/upstream-pr-8429-android.patch +19 -0
  31. package/patches/upstream-pr-8454-android.patch +207 -0
  32. package/patches/upstream-pr-8458-cli.patch +14 -0
  33. package/scripts/capacitor-patch/runner.mjs +38 -4
  34. package/patches/capacitor-cli-spm-ios-minor-platform.patch +0 -40
package/README.md CHANGED
@@ -33,9 +33,13 @@ npm install @capgo/capacitor-patch
33
33
  npx cap sync
34
34
  ```
35
35
 
36
- ## Enable Recommended Patches
36
+ ## Enable Patches
37
37
 
38
- `@capgo/capacitor-patch` is a no-op by default. Enable Capgo-recommended patches in your Capacitor config:
38
+ `@capgo/capacitor-patch` is a no-op by default. List the bundled fixes, then opt in to the patch IDs your app needs:
39
+
40
+ ```bash
41
+ npx capgo-capacitor-patch list --all
42
+ ```
39
43
 
40
44
  ```ts
41
45
  import type { CapacitorConfig } from '@capacitor/cli';
@@ -46,7 +50,8 @@ const config: CapacitorConfig = {
46
50
  webDir: 'dist',
47
51
  plugins: {
48
52
  CapacitorPatch: {
49
- recommended: true,
53
+ patches: ['upstream-pr-8418-android'],
54
+ strict: true,
50
55
  },
51
56
  },
52
57
  };
@@ -62,6 +67,8 @@ npx cap sync
62
67
 
63
68
  Package patches run before `sync` and `update`. Native project patches run after `sync` and `update`.
64
69
 
70
+ `recommended: true` is also supported for fixes Capgo marks as recommended in the catalog.
71
+
65
72
  ## Configuration
66
73
 
67
74
  ```ts
@@ -132,9 +139,186 @@ For generated native project files, use `"phase": "native"` and `"target": { "ty
132
139
 
133
140
  ### Built-in patches
134
141
 
135
- | ID | Source | Target | Description |
136
- | -------------------------------------- | ------------------------------------------------------------------ | ------------------- | --------------------------------------------------------------------------------------------------- |
137
- | `capacitor-cli-spm-ios-minor-platform` | [Capacitor+ #38](https://github.com/Cap-go/capacitor-plus/pull/38) | `@capacitor/cli` v8 | Keeps iOS SPM `Package.swift` generation from truncating deployment targets such as `15.5` to `15`. |
142
+ The bundled catalog tracks external fix PRs mirrored by Capacitor+ auto-sync branches named `sync/upstream-pr-*`. These entries are explicit opt-in patches by default, so apps can choose the fixes they need without receiving every pending upstream change automatically.
143
+
144
+ Run `capgo-capacitor-patch list --all` to see the shipped catalog. Each entry includes the original upstream Capacitor PR URL, the Capacitor+ sync branch, target package, supported version range, and patch file.
145
+
146
+ ## Future Automation
147
+
148
+ The long-term goal is to make this repository the fast path for Capacitor fixes that are waiting upstream.
149
+
150
+ For every external PR opened against `ionic-team/capacitor`, the automation should:
151
+
152
+ 1. Detect whether the PR is a fix that changes shipped Capacitor code.
153
+ 2. Wait until the upstream PR, or the matching Capacitor+ `sync/upstream-pr-*` branch, passes its test suite.
154
+ 3. Generate package-ready patch files in this repository.
155
+ 4. Open or update a pull request here with the new `patches/catalog.json` entries and patch files.
156
+ 5. Run this repository's tests against supported Capacitor versions.
157
+ 6. Comment on the original upstream PR with the quick-patch ID and install snippet once the patch package PR is ready.
158
+
159
+ The upstream PR comment should only be posted when the patch applies cleanly and this repository's checks pass. A good comment looks like:
160
+
161
+ ````md
162
+ This fix is available as a quick patch through `@capgo/capacitor-patch`.
163
+
164
+ Patch ID: `upstream-pr-8418-android`
165
+
166
+ ```ts
167
+ plugins: {
168
+ CapacitorPatch: {
169
+ patches: ['upstream-pr-8418-android'],
170
+ strict: true,
171
+ },
172
+ }
173
+ ```
174
+
175
+ Run `npx cap sync` after installing `@capgo/capacitor-patch`.
176
+ ````
177
+
178
+ When a fix is merged and released upstream, the catalog entry should either narrow its version range to the affected releases or be removed in the next major catalog cleanup.
179
+
180
+ ## Contributing Patches
181
+
182
+ Patch contributions should be small, traceable, and easy to remove once upstream ships the fix.
183
+
184
+ ### Good patch candidates
185
+
186
+ - Fixes from external Capacitor PRs that are not merged or not released yet.
187
+ - Fixes mirrored by Capacitor+ `sync/upstream-pr-*` branches.
188
+ - Small bug fixes for `@capacitor/core`, `@capacitor/android`, `@capacitor/ios`, `@capacitor/cli`, Capacitor plugins, or generated native project files.
189
+ - Changes that can be expressed as a unified diff and safely version-gated.
190
+
191
+ Avoid broad refactors, formatting-only changes, feature work, generated lockfile changes, test-only changes, and patches that require app-specific assumptions.
192
+
193
+ ### Patch file rules
194
+
195
+ Patch files live in `patches/` and must be unified diffs.
196
+
197
+ Use this naming pattern:
198
+
199
+ ```text
200
+ patches/upstream-pr-<number>-<target>.patch
201
+ ```
202
+
203
+ Examples:
204
+
205
+ ```text
206
+ patches/upstream-pr-8418-android.patch
207
+ patches/upstream-pr-8304-ios.patch
208
+ patches/upstream-pr-8271-core.patch
209
+ patches/upstream-pr-8458-cli.patch
210
+ ```
211
+
212
+ For package patches, paths are relative to the installed npm package root:
213
+
214
+ | Target package | Patch paths look like |
215
+ | -------------------- | --------------------------------------------------------------------------------------------------------------- |
216
+ | `@capacitor/android` | `capacitor/src/main/java/com/getcapacitor/Bridge.java` |
217
+ | `@capacitor/ios` | `Capacitor/Capacitor/Router.swift` |
218
+ | `@capacitor/core` | `dist/index.js`, `dist/index.cjs.js` |
219
+ | `@capacitor/cli` | `dist/ios/update.js`, `dist/tasks/update.js` |
220
+ | Native bridge assets | `capacitor/src/main/assets/native-bridge.js` on Android or `Capacitor/Capacitor/assets/native-bridge.js` on iOS |
221
+
222
+ For native project patches, use `"phase": "native"` and make paths relative to the app root, such as `android/app/build.gradle` or `ios/App/App/Info.plist`.
223
+
224
+ Capacitor packages usually ship compiled JavaScript, not TypeScript source. If the upstream fix touches CLI or core TypeScript files, patch the shipped `dist/` JavaScript files that users actually have in `node_modules`.
225
+
226
+ ### Catalog entry rules
227
+
228
+ Every patch needs an entry in `patches/catalog.json`.
229
+
230
+ Use stable IDs:
231
+
232
+ ```text
233
+ upstream-pr-<number>-android
234
+ upstream-pr-<number>-ios
235
+ upstream-pr-<number>-core
236
+ upstream-pr-<number>-cli
237
+ ```
238
+
239
+ Use separate entries when one upstream PR patches multiple packages. For example, a fix that changes both Android and iOS should create `upstream-pr-6991-android` and `upstream-pr-6991-ios`.
240
+
241
+ Recommended shape:
242
+
243
+ ```json
244
+ {
245
+ "id": "upstream-pr-8418-android",
246
+ "title": "fix(android): range request truncation (android)",
247
+ "recommended": false,
248
+ "phase": "package",
249
+ "target": {
250
+ "type": "package",
251
+ "packageName": "@capacitor/android",
252
+ "versionRange": ">=8.3.2 <9.0.0"
253
+ },
254
+ "source": {
255
+ "upstreamPullRequest": "https://github.com/ionic-team/capacitor/pull/8418",
256
+ "capacitorPlusBranch": "https://github.com/Cap-go/capacitor-plus/tree/sync/upstream-pr-8418",
257
+ "author": "upstream-author",
258
+ "authorAssociation": "external"
259
+ },
260
+ "upstream": {
261
+ "state": "open",
262
+ "mergedAt": null,
263
+ "status": "not-merged-as-of-2026-05-12"
264
+ },
265
+ "patchFile": "patches/upstream-pr-8418-android.patch"
266
+ }
267
+ ```
268
+
269
+ Set `recommended: false` by default. Only set `recommended: true` when Capgo is comfortable applying the fix automatically after a user opts into recommended patches.
270
+
271
+ Use `supersedes` when a newer patch includes or replaces an older overlapping patch:
272
+
273
+ ```json
274
+ {
275
+ "id": "upstream-pr-8429-android",
276
+ "supersedes": ["upstream-pr-7781-android"]
277
+ }
278
+ ```
279
+
280
+ ### Version ranges
281
+
282
+ Start with the narrowest range you have verified. Do not use `>=8.0.0 <9.0.0` unless the patch applies cleanly across the supported Capacitor 8 releases.
283
+
284
+ If a patch is already released upstream in later Capacitor versions, cap the upper bound:
285
+
286
+ ```json
287
+ "versionRange": ">=8.0.0 <8.3.1"
288
+ ```
289
+
290
+ Incompatible selected patches are skipped by default and fail when users set `strict: true`, so accurate version ranges are part of the user experience.
291
+
292
+ ### Local validation
293
+
294
+ Before opening a patch PR, run:
295
+
296
+ ```bash
297
+ npm run lint
298
+ npm run verify
299
+ npm pack --dry-run
300
+ ```
301
+
302
+ Then test the patch against a throwaway app with the target Capacitor version:
303
+
304
+ ```bash
305
+ npm init -y
306
+ npm install @capgo/capacitor-patch @capacitor/android@8.3.3 @capacitor/ios@8.3.3 @capacitor/core@8.3.3 @capacitor/cli@8.3.3
307
+ CAPACITOR_CONFIG='{"plugins":{"CapacitorPatch":{"patches":["upstream-pr-8418-android"],"strict":true}}}' npx capgo-capacitor-patch doctor --root . --phase package
308
+ ```
309
+
310
+ For an unpublished local branch, run the local binary from this repository and pass a config that selects the patch ID:
311
+
312
+ ```bash
313
+ CAPACITOR_CONFIG='{"plugins":{"CapacitorPatch":{"patches":["upstream-pr-8418-android"],"strict":true}}}' node /path/to/capacitor-patch/bin/capgo-capacitor-patch doctor --root . --phase package
314
+ ```
315
+
316
+ The patch is ready when:
317
+
318
+ - `doctor` says the patch would apply for supported versions.
319
+ - Running `apply` twice reports `already-applied` on the second run.
320
+ - Incompatible versions skip cleanly or fail only in `strict: true`.
321
+ - `npm pack --dry-run` includes the catalog entry and patch file.
138
322
 
139
323
  ## Compatibility
140
324
 
@@ -147,10 +331,10 @@ For generated native project files, use `"phase": "native"` and `"target": { "ty
147
331
  ## Development
148
332
 
149
333
  ```bash
150
- bun install
151
- bun run build
152
- bun run test
153
- bun run lint
334
+ npm install
335
+ npm run build
336
+ npm run test
337
+ npm run lint
154
338
  ```
155
339
 
156
- Use `bun run verify` before opening a pull request.
340
+ Use `npm run verify` before opening a pull request.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@capgo/capacitor-patch",
3
- "version": "8.1.0",
3
+ "version": "8.2.1",
4
4
  "description": "Capacitor plugin for applying vetted Capgo patches during cap sync and cap update.",
5
5
  "main": "dist/plugin.cjs.js",
6
6
  "module": "dist/esm/index.js",