feat: plugin lifecycle, watchdog opt-out, and splash screen#6
Open
robingenz wants to merge 8 commits into
Open
feat: plugin lifecycle, watchdog opt-out, and splash screen#6robingenz wants to merge 8 commits into
robingenz wants to merge 8 commits into
Conversation
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
There was a problem hiding this comment.
Pull request overview
Adds two new Electron runtime primitives intended to support OTA/live-update workflows: a per-activation “boot watchdog” opt-out for bundle activation, and an optional async plugin initialize() lifecycle hook awaited during PluginHost.start().
Changes:
- Extend
BundlesService.setActiveBundle()to accept{ bootWatchdog?: boolean }, allowing opt-out from pending-marker persistence and watchdog rollback behavior. - Add an optional plugin instance
initialize()hook that runs sequentially after plugin construction and before the platform finishes starting. - Add/extend Vitest coverage for both the watchdog opt-out behavior and the new lifecycle hook.
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| src/runtime/plugin-host.ts | Await optional plugin initialize() hook during startup. |
| src/runtime/plugin-host.spec.ts | Tests for sync/async initialize() behavior and failure handling. |
| src/runtime/index.ts | Re-export ElectronPluginLifecycle type. |
| src/runtime/bundles.ts | Add watchdog opt-out option to setActiveBundle() and adjust pending/watchdog behavior. |
| src/runtime/bundles.spec.ts | New test suite covering watchdog opt-out, restart behavior, and mixed sequences. |
| src/plugin/index.ts | Update BundlesService API docs/signature; introduce ElectronPluginLifecycle. |
| README.md | Document optional plugin initialize() lifecycle hook. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
…() lifecycle Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Platform primitives for the upcoming Electron implementation of
@capawesome/capacitor-live-update, plus a splash screen covering the plugin-load boot phase.setActiveBundle:setActiveBundle(dir, { bootWatchdog: false })repoints + reloads without arming the failed-boot watchdog and without persisting apendingmarker, so the startup pending-check never reverts an externally-managed bundle.notifyBootReady()becomes a no-op for such activations. Default remainstrue— non-breaking, no state-format change.ElectronPluginbase class +load()lifecycle (exported from./plugin): plugins extend the class (platform as devDependency + optional peerDependency, matching the Android/iOS mental model) and overrideload(), which is awaited sequentially after all plugins are constructed and before the first window load — async setup (e.g. repointing the active bundle) takes effect on first paint, and a throwingloadaborts boot loudly. Detection stays structural (noinstanceof), so zero-dependency marker-only plugins with a structuralload()keep working.loadis reserved and never bridged (boot error if listed inmethods); the earlier duck-typedinitializehook is gone andinitializeis an ordinary method name again.load()hooks run — the app previously showed nothing). Config:splashScreen: { enabled?, path?, width?, height?, backgroundColor?, minimumDurationMs? }. Default lookupassets/splash.html→assets/splash.png(the latter matches the community platform convention for zero-config migration;splashScreenImageName: 'x.gif'→path: 'assets/x.gif').pathaccepts HTML or an image (image is wrapped in a generated data-URI document). The splash window is fully outside the bridge: sandboxed, no preload, no custom scheme, navigation blocked. Closes after main-windowready-to-show(+ optional minimum duration) and on every boot-failure path. Includes a theme-aware scaffold template and a packaging fix:assets/**/*added to the electron-builderfiles(buildResources are otherwise excluded from packaged apps — the splash would have vanished in production builds).Tests
bundles.spec.ts: watchdog opt-out semantics, startup pending-check behavior, mixed activation sequences.plugin-host.spec.ts: base-class + marker-onlyload()coverage, reserved-name rejection, boot-failure on throwing hooks.splash.spec.ts: path resolution/fallback/enabled semantics, HTML-vs-image branching, wrapper generation, minimum-duration timing.Related PRs
🤖 Generated with Claude Code`
withversionimported fromelectron/package.json. Scaffold example +resolveJsonModule` included.Tests}