-
Notifications
You must be signed in to change notification settings - Fork 5
refactor: update capacitor page layout and logic for better readability and maintainability #42
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
472fea4
refactor: update capacitor page layout and logic for better readabili…
damiant 9a3dbf0
feat: implement reactive form for URL input and update browser support
damiant 88e18ee
fix: correct duplicate word in privacy policy regarding cookie usage
damiant 6c64370
chore: update iOS deployment target to 16.0 and upgrade Capacitor dep…
damiant d061557
chore: add Node.js setup step to Android build workflow
damiant 3f064aa
chore: update compileSdkVersion to 36 in variables.gradle
damiant b4a4f41
chore: update iOS deployment target from 16.0 to 26.0
damiant 4e75231
chore: update dependencies and increase iOS deployment target
damiant 27971ac
chore: update iOS deployment target from 16.0 to 26.0
damiant e74ab1c
chore: update iOS deployment target from 16.0 to 26.0
damiant a51ceff
chore: update macOS version from 15 to 26 in CI workflow
damiant ed7b076
chore: update Xcode version from 16.4 to 26.2.0 in CI workflow
damiant 06e7181
chore: update Xcode version from 16.4 to 26.2 in CI workflow
damiant File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| last 2 major versions | ||
| not dead | ||
| Safari >=16.1 | ||
| iOS >=16.1 | ||
| Chrome >=107 | ||
| ChromeAndroid >=60 | ||
| Firefox >=106 | ||
| Edge >=107 |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,125 @@ | ||
| # WebNative App - AI Agent Instructions | ||
|
|
||
| ## Project Overview | ||
| WebNative is a cross-platform web browser application (iOS/Android via Capacitor) built with Angular 21 and Ionic 8. It enables viewing websites, scanning QR codes, and discovering local services. Deployed to App/Play Stores and https://webnative.app. | ||
|
|
||
| ## Architecture Essentials | ||
|
|
||
| ### Tech Stack | ||
| - **Framework**: Angular 21 with Ionic 8 (standalone components) | ||
| - **Mobile**: Capacitor 7+ (replaces Cordova) for iOS/Android | ||
| - **Build**: Angular CLI with bun package manager | ||
| - **Testing**: Vitest with jsdom environment | ||
| - **Styling**: SCSS with Ionic theme variables | ||
|
|
||
| ### Core Services Pattern | ||
| All services use Angular's `@Injectable({ providedIn: 'root' })` for tree-shakeable singletons: | ||
| - **HistoryService**: Manages URL history/shortcuts via Capacitor Preferences | ||
| - **ScanService**: QR/barcode scanning via Capacitor plugin | ||
| - **SettingsService**: UI presentation (ActionSheets) for settings/actions | ||
| - **UrlService**: Deep linking and URL navigation handling | ||
| - **UIService**: Toast/dialog notifications | ||
| - **UtilService**: Utility functions (strings, random IDs) | ||
|
|
||
| ### Key Patterns | ||
| 1. **Dependency Injection**: Use `inject()` helper in constructors, not constructor params (modern Angular pattern) | ||
| 2. **Service Communication**: Direct service injection; use RxJS Observables when state changes propagate | ||
| 3. **Cordova Plugin Access**: Wrapped in `cordova-plugins.ts` with typed interfaces (avoid direct window access) | ||
| 4. **Capacitor vs Cordova**: Prefer Capacitor APIs; some plugins still use Cordova bridges (Http, BarcodeScanner) | ||
|
|
||
| ## Build & Development Commands | ||
|
|
||
| ```bash | ||
| bun install # Install dependencies | ||
| npm start # Local dev server (ng serve) | ||
| npm run build # Production build → www/browser/ | ||
| npm run test:unit # Run Vitest in watch mode | ||
| npm run test:unit:run # Run tests once (CI) | ||
| npm run lint # ESLint check | ||
| npm run lint-fix # Auto-fix ESLint & Prettier | ||
| npm run deploy # Build + deploy to Netlify | ||
| npm run packages # Generate plugin list for README | ||
| npm run capacitor:sync:after # Post-sync patches for Capacitor bridge issues | ||
| ``` | ||
|
|
||
| **Critical**: After `capacitor sync`, run `npm run capacitor:sync:after` to apply custom patches to CAPLog.swift and Logger.java (see `patch/` directory). | ||
|
|
||
| ## Routing & Navigation | ||
|
|
||
| Routes use standalone component lazy-loading in [src/app/app-routes.ts](../src/app/app-routes.ts): | ||
| - `/home` → HomePage (main UI) | ||
| - `/privacy` → PrivacyPage (legal) | ||
| - `/capacitor` → CapacitorPage (dev/fallback for first-time users) | ||
| - Deep links via `App.addListener('appUrlOpen')` → `UrlService.deepLink()` | ||
|
|
||
| ## Native Features Integration | ||
|
|
||
| ### Capacitor Plugins Used | ||
| - **Filesystem**: File I/O for shortcuts/icons | ||
| - **Preferences**: Local storage (replaces localStorage for plugins) | ||
| - **Browser**: Open URLs in system browser | ||
| - **App**: Version info, deep links | ||
| - **StatusBar/Keyboard**: UI chrome control | ||
| - **Barcode Scanner**: QR code scanning (via Cordova bridge) | ||
| - **Screen Orientation**: Lock to portrait/landscape | ||
|
|
||
| ### Discovery Service | ||
| Local device discovery via `IonicDiscover` (custom Cordova plugin) finds mDNS services. [src/app/discovery.ts](../src/app/discovery.ts) defines Service interface with name, hostname, address, port fields. | ||
|
|
||
| ## File Organization | ||
|
|
||
| ``` | ||
| src/app/ | ||
| ├── [service-name].service.ts # Shared services | ||
| ├── [service-name].service.spec.ts # Unit tests | ||
| ├── home/ # Main page (lazy-loaded) | ||
| ├── slides/ # Tutorial components | ||
| ├── shortcut/ # Shortcut UI component | ||
| ├── capacitor/ # Dev/fallback page | ||
| ├── privacy/ # Legal page | ||
| └── cordova-plugins.ts # Plugin type definitions | ||
| ``` | ||
damiant marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| ## Testing & Linting | ||
|
|
||
| - **Unit Tests**: Vitest with jsdom, included in `src/**/*.spec.ts` | ||
| - **Config**: [vitest.config.ts](../vitest.config.ts) with path alias `@/` → `src/` | ||
| - **Linting**: @ionic/eslint-config with Prettier auto-formatting | ||
| - **Run Tests**: `npm run test:unit:ui` for interactive testing dashboard | ||
|
|
||
| ## Capacitor Configuration | ||
|
|
||
| [capacitor.config.ts](../capacitor.config.ts) key settings: | ||
| - **webDir**: `www/browser` (production build output) | ||
| - **allowNavigation**: `['*']` (allow all URLs in web view) | ||
| - **cleartext**: `true` (allows HTTP on Android) | ||
| - **errorPath**: `error.html` (fallback for missing pages) | ||
| - **CapacitorHttp**: Disabled (uses Cordova advanced-http plugin instead) | ||
|
|
||
| ## Common Workflows | ||
|
|
||
| ### Adding a New Service | ||
| 1. Create `src/app/[name].service.ts` with `@Injectable({ providedIn: 'root' })` | ||
| 2. Inject via `inject()` in components | ||
| 3. Add unit test `[name].service.spec.ts` | ||
| 4. Export from service barrel or import directly | ||
|
|
||
| ### Modifying Capacitor Bridge | ||
| - Edit `patch/CAPLog.swift` or `patch/Logger.java` | ||
| - Run `npm run capacitor:sync:after` after `capacitor sync` | ||
| - Never commit node_modules changes directly | ||
|
|
||
| ### Building for Mobile | ||
| ```bash | ||
| bun install && npm run build # Web build | ||
| npx capacitor sync # Sync to iOS/Android | ||
| npm run capacitor:sync:after # Apply patches | ||
| # Then use Xcode/Android Studio to build signed releases | ||
| ``` | ||
|
|
||
| ## Important Notes | ||
| - **Strict TypeScript**: `strict: true` in tsconfig.json; no implicit any | ||
| - **Angular Version**: Latest (21+) with latest Ionic standalone API | ||
| - **No jQuery/Legacy Cordova**: Use Capacitor, not legacy Cordova patterns | ||
| - **Tree Shaking**: Ensure all services use `providedIn: 'root'` for optimization | ||
| - **iOS/Android Keys**: Stored in `keys/AndroidKeys`; iOS signing via Xcode | ||
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
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
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
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
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
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.