feat: native iPad wrapper — Capacitor iOS scaffold
Wrap the PWA in a thin native iOS shell (Capacitor 8):
- capacitor.config.json (webDir dist, appId uk.timevans.thedirector,
iOS safe-area contentInset + theme background).
- @capacitor/{core,cli,ios} as devDependencies (web app keeps zero
runtime deps); ios:add / ios:sync / ios:open / ios npm scripts.
- main.js skips service-worker registration under Capacitor
(window.Capacitor.isNativePlatform) — assets are already local.
- iOS <meta> hints in index.html; .gitignore for native build output.
- docs/native-ipad-wrapper.md: full Xcode + CocoaPods build guide,
incl. the keep-awake plugin note for the wake toggle in WKWebView.
The iOS project generation/build (npx cap add ios → Xcode) needs a Mac
with full Xcode + CocoaPods, which this env lacks; it is documented for
the user to run. tests/tools/capacitor-config.test.js guards the config.
211 tests pass; build clean.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 4.8
parent
028dcb5e4e
commit
e79f643409
@@ -0,0 +1,36 @@
|
||||
import { describe, it, expect } from 'vitest';
|
||||
import { readFileSync } from 'node:fs';
|
||||
|
||||
const cfg = JSON.parse(readFileSync('capacitor.config.json', 'utf8'));
|
||||
const pkg = JSON.parse(readFileSync('package.json', 'utf8'));
|
||||
|
||||
describe('Capacitor iOS wrapper', () => {
|
||||
it('has a reverse-DNS appId and an app name', () => {
|
||||
expect(cfg.appId).toMatch(/^[a-z]+(\.[a-z0-9]+)+$/);
|
||||
expect(cfg.appName).toBeTruthy();
|
||||
});
|
||||
|
||||
it('points webDir at the vite build output (dist)', () => {
|
||||
expect(cfg.webDir).toBe('dist');
|
||||
});
|
||||
|
||||
it('exposes the iOS build scripts', () => {
|
||||
for (const s of ['ios:add', 'ios:sync', 'ios:open']) {
|
||||
expect(pkg.scripts[s], s).toBeTruthy();
|
||||
}
|
||||
expect(pkg.scripts['ios:sync']).toContain('build'); // always sync fresh web assets
|
||||
});
|
||||
|
||||
it('declares the Capacitor toolchain as dev-only (web app keeps zero runtime deps)', () => {
|
||||
expect(pkg.dependencies ?? {}).toEqual({});
|
||||
for (const d of ['@capacitor/core', '@capacitor/cli', '@capacitor/ios']) {
|
||||
expect(pkg.devDependencies[d], d).toBeTruthy();
|
||||
}
|
||||
});
|
||||
|
||||
it('skips the service worker inside the native wrapper', () => {
|
||||
const main = readFileSync('src/main.js', 'utf8');
|
||||
expect(main).toContain('isNativePlatform');
|
||||
expect(main).toContain("register('/sw.js')"); // still registers for the browser PWA
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user