@capgo/capacitor-webview-crash 8.0.1 → 8.0.3

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 (3) hide show
  1. package/Package.swift +2 -2
  2. package/README.md +29 -70
  3. package/package.json +3 -3
package/Package.swift CHANGED
@@ -2,11 +2,11 @@
2
2
  import PackageDescription
3
3
 
4
4
  let package = Package(
5
- name: "CapgoCapacitorWebViewCrash",
5
+ name: "CapgoCapacitorWebviewCrash",
6
6
  platforms: [.iOS(.v15)],
7
7
  products: [
8
8
  .library(
9
- name: "CapgoCapacitorWebViewCrash",
9
+ name: "CapgoCapacitorWebviewCrash",
10
10
  targets: ["WebViewCrashPlugin"])
11
11
  ],
12
12
  dependencies: [
package/README.md CHANGED
@@ -3,7 +3,7 @@
3
3
  <a href="https://capgo.app/">
4
4
  <img
5
5
  src="https://raw.githubusercontent.com/Cap-go/capgo/main/assets/capgo_banner.png"
6
- alt="Capgo - Instant updates for capacitor"
6
+ alt="Capgo - Instant updates for Capacitor"
7
7
  />
8
8
  </a>
9
9
 
@@ -13,54 +13,25 @@
13
13
  </h2>
14
14
  <h2>
15
15
  <a href="https://capgo.app/consulting/?ref=plugin_webview_crash">
16
- {' '}
17
16
  Missing a feature? We’ll build the plugin for you 💪
18
17
  </a>
19
18
  </h2>
20
19
  </div>
21
20
 
22
- ## Snapshot
21
+ Detect a recovered Capacitor WebView crash and give the next JavaScript runtime the native crash marker it needs to recover application state.
23
22
 
24
- - **Plugin name:** `WebView Crash`
25
- - **One-line value:** `Detect a crashed Capacitor WebView and tell the next JavaScript runtime what happened.`
26
- - **Maintainer:** `Capgo`
27
- - **Status:** `alpha`
28
-
29
- ## Pre-Release Checklist
30
-
31
- - [x] Replace all template placeholders in this README.
32
- - [x] Replace the Capgo CTA tracking slug.
33
- - [x] Replace the template keywords in `package.json`.
34
- - [x] Remove the bootstrap-only init script from the generated plugin copy.
35
- - [x] Update `src/definitions.ts` with the real public API and JSDoc.
36
- - [ ] Set GitHub repo description to start with `Capacitor plugin for ...`.
37
- - [ ] Set GitHub repo homepage to `https://capgo.app/docs/plugins/webview-crash/`.
38
- - [ ] Open the docs/website PR for the Capgo site.
39
- - [ ] Run `bun run verify` on a machine with full iOS toolchain support before publishing.
40
-
41
- ## Problem & Scope
42
-
43
- ### Why this plugin exists
44
-
45
- A WebView renderer crash kills the current JavaScript context. After the app recovers, the next JS runtime has no built-in signal that the previous WebView died and some in-memory state may have been lost. This plugin stores that crash marker natively and exposes it to the recovered runtime.
46
-
47
- ### What it does
23
+ ## What It Does
48
24
 
49
25
  - Stores a native crash marker when Android reports `onRenderProcessGone`.
50
- - Hooks the iOS WebView termination callback and preserves equivalent crash metadata.
51
- - Exposes that marker through an event, a polling method, and a simulation helper for testing.
26
+ - Hooks the iOS WebView termination callback and persists equivalent crash metadata.
27
+ - Exposes the marker through an event, a polling method, and a simulation helper for testing recovery flows.
28
+ - Ships a web implementation that simulates the same recovery flow with local storage.
52
29
 
53
- ### What it does not do
30
+ ## What It Does Not Do
54
31
 
55
32
  - Prevent the underlying WebView crash from happening.
56
33
  - Restore lost in-memory JavaScript state automatically.
57
34
 
58
- ## Capgo Links
59
-
60
- - **Plugin docs URL:** `https://capgo.app/docs/plugins/webview-crash/`
61
- - **Plugin tutorial URL:** `Pending publication`
62
- - **Website/docs repo:** `https://github.com/Cap-go/website`
63
-
64
35
  ## Compatibility
65
36
 
66
37
  | Plugin version | Capacitor compatibility | Maintained |
@@ -74,18 +45,14 @@ Policy:
74
45
  - New plugins start at version `8.0.0` (Capacitor 8 baseline).
75
46
  - Backward compatibility for older Capacitor majors is supported on demand.
76
47
 
77
- ## Template Base
78
-
79
- This repository was initialized from `Cap-go/capacitor-plugin-template` and then rewritten with the real WebView crash recovery API and native implementations.
80
-
81
48
  ## Install
82
49
 
83
50
  ```bash
84
- bun add @capgo/capacitor-webview-crash
85
- bunx cap sync
51
+ npm install @capgo/capacitor-webview-crash
52
+ npx cap sync
86
53
  ```
87
54
 
88
- ## Minimal Usage
55
+ ## Usage
89
56
 
90
57
  ```typescript
91
58
  import { WebViewCrash } from '@capgo/capacitor-webview-crash';
@@ -101,27 +68,31 @@ if (pending.value) {
101
68
  }
102
69
  ```
103
70
 
104
- ## Integration Notes
71
+ Use `simulateCrashRecovery()` in development or automated tests to exercise your recovery UI without forcing a real native WebView crash.
72
+
73
+ ## Platform Notes
105
74
 
106
75
  - **iOS:** Uses method swizzling on Capacitor's `WebViewDelegationHandler` to persist crash metadata before Capacitor reloads the WebView. No extra permissions are required.
107
76
  - **Android:** Registers a Capacitor `WebViewListener` and persists crash metadata from `onRenderProcessGone`. No extra permissions are required.
108
77
  - **Web:** There is no real browser crash detection. The web implementation only simulates the recovery flow with local storage.
109
78
 
110
- ## Example App
79
+ ## Documentation
111
80
 
112
- The `example-app/` folder is linked via `file:..` and shows the pending marker, recovery event, and simulation button for local validation.
81
+ - [Plugin docs](https://capgo.app/docs/plugins/webview-crash/)
82
+ - [Getting started guide](https://capgo.app/docs/plugins/webview-crash/getting-started/)
83
+ - [Example app](./example-app)
113
84
 
114
85
  ## API
115
86
 
116
87
  <docgen-index>
117
88
 
118
- * [`getPendingCrashInfo()`](#getpendingcrashinfo)
119
- * [`clearPendingCrashInfo()`](#clearpendingcrashinfo)
120
- * [`simulateCrashRecovery()`](#simulatecrashrecovery)
121
- * [`addListener('webViewRestoredAfterCrash', ...)`](#addlistenerwebviewrestoredaftercrash-)
122
- * [`removeAllListeners()`](#removealllisteners)
123
- * [Interfaces](#interfaces)
124
- * [Type Aliases](#type-aliases)
89
+ - [`getPendingCrashInfo()`](#getpendingcrashinfo)
90
+ - [`clearPendingCrashInfo()`](#clearpendingcrashinfo)
91
+ - [`simulateCrashRecovery()`](#simulatecrashrecovery)
92
+ - [`addListener('webViewRestoredAfterCrash', ...)`](#addlistenerwebviewrestoredaftercrash-)
93
+ - [`removeAllListeners()`](#removealllisteners)
94
+ - [Interfaces](#interfaces)
95
+ - [Type Aliases](#type-aliases)
125
96
 
126
97
  </docgen-index>
127
98
 
@@ -140,8 +111,7 @@ Returns the pending native crash marker, if one exists.
140
111
 
141
112
  **Returns:** <code>Promise&lt;<a href="#pendingcrashinforesult">PendingCrashInfoResult</a>&gt;</code>
142
113
 
143
- --------------------
144
-
114
+ ---
145
115
 
146
116
  ### clearPendingCrashInfo()
147
117
 
@@ -151,8 +121,7 @@ clearPendingCrashInfo() => Promise<void>
151
121
 
152
122
  Clears the stored crash marker after the app has handled recovery.
153
123
 
154
- --------------------
155
-
124
+ ---
156
125
 
157
126
  ### simulateCrashRecovery()
158
127
 
@@ -164,8 +133,7 @@ Creates a fake crash marker so recovery flows can be tested locally.
164
133
 
165
134
  **Returns:** <code>Promise&lt;<a href="#pendingcrashinforesult">PendingCrashInfoResult</a>&gt;</code>
166
135
 
167
- --------------------
168
-
136
+ ---
169
137
 
170
138
  ### addListener('webViewRestoredAfterCrash', ...)
171
139
 
@@ -182,8 +150,7 @@ Fires after a new JavaScript runtime attaches a listener and a crash marker is s
182
150
 
183
151
  **Returns:** <code>Promise&lt;<a href="#pluginlistenerhandle">PluginListenerHandle</a>&gt;</code>
184
152
 
185
- --------------------
186
-
153
+ ---
187
154
 
188
155
  ### removeAllListeners()
189
156
 
@@ -193,12 +160,10 @@ removeAllListeners() => Promise<void>
193
160
 
194
161
  Removes all plugin listeners.
195
162
 
196
- --------------------
197
-
163
+ ---
198
164
 
199
165
  ### Interfaces
200
166
 
201
-
202
167
  #### PendingCrashInfoResult
203
168
 
204
169
  Pending crash marker returned to JavaScript.
@@ -207,7 +172,6 @@ Pending crash marker returned to JavaScript.
207
172
  | ----------- | --------------------------------------------------------------------- | ----------------------------------------------------------- |
208
173
  | **`value`** | <code><a href="#webviewcrashinfo">WebViewCrashInfo</a> \| null</code> | Stored crash metadata, or `null` when no marker is pending. |
209
174
 
210
-
211
175
  #### WebViewCrashInfo
212
176
 
213
177
  Metadata captured natively after the previous WebView process died.
@@ -223,31 +187,26 @@ Metadata captured natively after the previous WebView process died.
223
187
  | **`rendererPriorityAtExit`** | <code>number</code> | Android-only renderer priority reported at exit. |
224
188
  | **`appState`** | <code><a href="#webviewcrashappstate">WebViewCrashAppState</a></code> | iOS-only application state captured when the crash marker was written. |
225
189
 
226
-
227
190
  #### PluginListenerHandle
228
191
 
229
192
  | Prop | Type |
230
193
  | ------------ | ----------------------------------------- |
231
194
  | **`remove`** | <code>() =&gt; Promise&lt;void&gt;</code> |
232
195
 
233
-
234
196
  ### Type Aliases
235
197
 
236
-
237
198
  #### WebViewCrashPlatform
238
199
 
239
200
  Platform that produced the stored crash marker.
240
201
 
241
202
  <code>'android' | 'ios' | 'web'</code>
242
203
 
243
-
244
204
  #### WebViewCrashReason
245
205
 
246
206
  Native reason reported for the previous WebView failure.
247
207
 
248
208
  <code>'renderProcessGone' | 'webContentProcessDidTerminate' | 'simulated'</code>
249
209
 
250
-
251
210
  #### WebViewCrashAppState
252
211
 
253
212
  Best-effort application state captured on iOS when the WebView process died.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@capgo/capacitor-webview-crash",
3
- "version": "8.0.1",
3
+ "version": "8.0.3",
4
4
  "description": "Capacitor plugin for detecting WebView crash recovery and informing the next JS runtime.",
5
5
  "main": "dist/plugin.cjs.js",
6
6
  "module": "dist/esm/index.js",
@@ -36,7 +36,7 @@
36
36
  ],
37
37
  "scripts": {
38
38
  "verify": "bun run verify:ios && bun run verify:android && bun run verify:web",
39
- "verify:ios": "xcodebuild -scheme CapgoCapacitorWebViewCrash -destination generic/platform=iOS",
39
+ "verify:ios": "xcodebuild -scheme CapgoCapacitorWebviewCrash -destination generic/platform=iOS",
40
40
  "verify:android": "cd android && ./gradlew clean build test && cd ..",
41
41
  "verify:web": "bun run build && bun test",
42
42
  "test": "bun test",
@@ -45,7 +45,7 @@
45
45
  "eslint": "eslint . --ext .ts",
46
46
  "prettier": "prettier-pretty-check \"**/*.{css,html,ts,js,java,json,md}\" --plugin=prettier-plugin-java",
47
47
  "swiftlint": "node-swiftlint",
48
- "docgen": "docgen --api WebViewCrashPlugin --output-readme README.md --output-json dist/docs.json",
48
+ "docgen": "docgen --api WebViewCrashPlugin --output-readme README.md --output-json dist/docs.json && prettier --write README.md",
49
49
  "build": "bun run clean && bun run docgen && tsc && rollup -c rollup.config.mjs",
50
50
  "clean": "rimraf ./dist",
51
51
  "watch": "tsc --watch",