Merge branch 'master' into firebase-build-command
This commit is contained in:
@@ -11,7 +11,7 @@
|
||||
|
||||
# Web (development)
|
||||
|
||||
npm run build:web
|
||||
npm run dev
|
||||
|
||||
# Mobile
|
||||
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
|
||||
- **File System**: Limited browser APIs
|
||||
|
||||
- **Build**: `npm run build:web` (development build)
|
||||
- **Build**: `npm run dev` (development server), `npm run build:web` (production build into `dist/`)
|
||||
|
||||
### Mobile (Capacitor)
|
||||
|
||||
@@ -59,7 +59,7 @@
|
||||
|
||||
# Web (development)
|
||||
|
||||
npm run build:web
|
||||
npm run dev
|
||||
|
||||
# Mobile
|
||||
|
||||
|
||||
@@ -63,7 +63,7 @@ follow proper review, testing, and documentation procedures.
|
||||
|
||||
- **CI/CD Pipeline**: GitHub Actions, build validation scripts
|
||||
|
||||
- **Service Worker Assembly**: `sw_scripts/`, `sw_combine.js`, WASM copy steps
|
||||
- **WASM Assembly**: WASM copy steps
|
||||
|
||||
## Change Authorization Requirements
|
||||
|
||||
|
||||
@@ -39,7 +39,7 @@
|
||||
|
||||
### Rollback Verification
|
||||
|
||||
- **Web**: `npm run build:web:dev` and `npm run build:web:prod`
|
||||
- **Web**: `npm run dev` and `npm run build:web:prod`
|
||||
|
||||
- **Mobile**: `npm run build:android:test` and `npm run build:ios:test`
|
||||
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
|
||||
### After Build System Change
|
||||
|
||||
- [ ] **Web Platform**: Does `npm run build:web:dev` work?
|
||||
- [ ] **Web Platform**: Does `npm run dev` work?
|
||||
|
||||
- [ ] **Mobile Platforms**: Do iOS/Android builds succeed?
|
||||
|
||||
@@ -33,9 +33,9 @@
|
||||
|
||||
### Web Platform
|
||||
|
||||
- **Development**: `npm run build:web:dev` - serve and load app
|
||||
- **Development**: `npm run dev` - serve and load app
|
||||
|
||||
- **Production**: `npm run build:web:prod` - verify SW and WASM present
|
||||
- **Production**: `npm run build:web:prod` - verify WASM present
|
||||
|
||||
### Mobile Platforms
|
||||
|
||||
@@ -98,13 +98,11 @@
|
||||
verify single-instance,
|
||||
icons, signing
|
||||
|
||||
### Service Worker / WASM
|
||||
### WASM
|
||||
|
||||
- **Trigger**: `sw_combine.js`, WASM copy path
|
||||
- **Trigger**: WASM copy path
|
||||
|
||||
- **Validation**: Verify combined SW exists and is injected; page loads offline;
|
||||
|
||||
WASM present
|
||||
- **Validation**: WASM present
|
||||
|
||||
### Docker
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@ VITE_LOG_LEVEL=info
|
||||
|
||||
# iOS doesn't like spaces in the app title.
|
||||
TIME_SAFARI_APP_TITLE="TimeSafari_Test"
|
||||
VITE_APP_SERVER=https://test.timesafari.app
|
||||
VITE_APP_SERVER=https://test.`
|
||||
# This is the claim ID for actions in the BVC project, with the JWT ID on this environment (not
|
||||
# This is the claim ID for actions in the BVC project, with the JWT ID on this environment (not production).
|
||||
|
||||
|
||||
@@ -5,8 +5,6 @@ dist-electon-build
|
||||
node_modules
|
||||
dist
|
||||
signature.bin
|
||||
# generated during `npm run build`
|
||||
sw_scripts-combined.js
|
||||
*.pem
|
||||
verified.txt
|
||||
myenv
|
||||
|
||||
+68
-228
@@ -9,9 +9,9 @@ This guide explains how to build TimeSafari for different platforms using the co
|
||||
```bash
|
||||
# 🖥️ Web Development
|
||||
npm install # setup -- and pkgx.dev `dev` command before this will set environment with npm, etc
|
||||
npm run build:web:serve -- --test # Start with test endorser server
|
||||
npm run dev # Start development server with hot reload with local endorser server
|
||||
npm run build:web:prod # Production build
|
||||
npm run build:web:serve:test # Test build served from dist/ (test endorser server)
|
||||
npm run build:web # Production build into dist/
|
||||
|
||||
# 📱 Mobile Development
|
||||
npm run build:ios # iOS build (opens Xcode)
|
||||
@@ -225,30 +225,35 @@ npm install
|
||||
|
||||
```bash
|
||||
# Local development
|
||||
npm run dev # Start development server with hot reload (shortcut for `build:web:dev`)
|
||||
npm run dev # Start development server with hot reload (writes nothing to dist/)
|
||||
|
||||
# Web builds
|
||||
npm run build:web # Development build (starts dev server with hot reload)
|
||||
# Web builds (each one writes dist/)
|
||||
npm run build:web # Production build (same as build:web:prod)
|
||||
npm run build:web:test # Test environment build (optimized for testing)
|
||||
npm run build:web:prod # Production build (optimized for production)
|
||||
npm run build:web:serve # Build and serve locally for production testing
|
||||
|
||||
# Build, then serve dist/ locally
|
||||
npm run build:web:serve # Production build, then serve
|
||||
npm run build:web:serve:test # Test build, then serve
|
||||
|
||||
# Docker builds
|
||||
npm run build:web:docker # Development build with Docker containerization
|
||||
npm run build:web:docker # Production build with Docker containerization
|
||||
npm run build:web:docker:test # Test build with Docker containerization
|
||||
npm run build:web:docker:prod # Production build with Docker containerization
|
||||
```
|
||||
|
||||
### Local Development
|
||||
|
||||
Start the development server using `npm run dev` (a shortcut for `npm run build:web:dev`) or `npm run build:web` (both start the development server with hot reload).
|
||||
Start the development server with hot reload using `npm run dev`. Open it at `http://localhost:8080/`, not at a wildcard address such as `http://[::]:8080/` or `http://0.0.0.0:8080/`: browsers only allow the cryptography the app needs on HTTPS, `localhost`, `127.0.0.1`, or `[::1]`, so any other plain-HTTP address shows a "Cannot Start Here" page.
|
||||
|
||||
### Web Build for Server
|
||||
|
||||
1. Run the production build using `npm run build:web:prod`
|
||||
1. Run the production build using `npm run build:web` (or `npm run build:web:test` for the test server)
|
||||
2. The built files will be in the `dist` directory
|
||||
3. To test the production build locally, use `npm run build:web:serve` (builds then serves)
|
||||
|
||||
`dist/` is shared with the Android, iOS, Electron, and Capacitor builds, which overwrite it with non-web output. Run the web build immediately before deploying, and confirm that the browser console reports `Loading TimeSafari for platform: web`.
|
||||
|
||||
**Why Use `serve`?**
|
||||
- **Production Testing**: Test your optimized production build locally before deployment
|
||||
- **SPA Routing Validation**: Verify deep linking and navigation work correctly (handles routes like `/discover`, `/account`)
|
||||
@@ -1603,8 +1608,7 @@ Use the commands above to check and fix code quality issues.
|
||||
|
||||
1. **Environment Setup**: Load platform-specific environment variables
|
||||
2. **Asset Building**: Vite builds optimized web assets
|
||||
3. **PWA Generation**: Service worker and manifest creation
|
||||
4. **Output**: Production-ready files in `dist/` directory
|
||||
3. **Output**: Production-ready files in `dist/` directory
|
||||
|
||||
### Electron Build Process
|
||||
|
||||
@@ -1856,38 +1860,21 @@ npm run build:android:assets
|
||||
|
||||
### Build Process Overview
|
||||
|
||||
TimeSafari's build system follows a multi-stage process that prepares assets,
|
||||
combines scripts, and generates platform-specific outputs.
|
||||
TimeSafari's build system follows a multi-stage process that prepares assets
|
||||
and generates platform-specific outputs.
|
||||
|
||||
#### Pre-Build Preparation
|
||||
|
||||
##### 1. Service Worker Script Preparation
|
||||
|
||||
```bash
|
||||
# Optional: Format third-party service worker scripts
|
||||
npx prettier --write ./sw_scripts/
|
||||
```
|
||||
|
||||
**What this does:**
|
||||
|
||||
- Formats cryptographic libraries (`nacl.js`, `noble-curves.js`,
|
||||
`noble-hashes.js`, etc.)
|
||||
- These scripts are automatically combined during the build process
|
||||
- Improves readability and makes version control diffs cleaner
|
||||
- **Note**: This is optional and only needed when updating third-party scripts
|
||||
|
||||
**2. Automatic Pre-Build Steps**
|
||||
The `prebuild` script automatically runs before any build:
|
||||
#### Pre-Build Script
|
||||
|
||||
```json
|
||||
"prebuild": "eslint --ext .js,.ts,.vue --ignore-path .gitignore src && node sw_combine.js && node scripts/copy-wasm.js"
|
||||
"prebuild": "eslint --ext .js,.ts,.vue --ignore-path .gitignore src && node scripts/copy-wasm.js"
|
||||
```
|
||||
|
||||
**What happens automatically:**
|
||||
npm runs `prebuild` only before a script named `build`. This project defines
|
||||
no `build` script, so none of the `build:*` commands trigger it.
|
||||
|
||||
- **ESLint**: Checks and fixes code formatting in `src/`
|
||||
- **Script Combination**: `sw_combine.js` combines all `sw_scripts/*.js` files
|
||||
into `sw_scripts-combined.js`
|
||||
**What it does when run:**
|
||||
|
||||
- **ESLint**: Checks code formatting in `src/`
|
||||
- **WASM Copy**: `copy-wasm.js` copies SQLite WASM files to `public/wasm/`
|
||||
|
||||
#### Build Process Architecture
|
||||
@@ -1895,11 +1882,10 @@ The `prebuild` script automatically runs before any build:
|
||||
**Web Build Process:**
|
||||
|
||||
```text
|
||||
1. Pre-Build: ESLint + Script Combination + WASM Copy
|
||||
2. Environment Setup: Load .env files, set NODE_ENV
|
||||
3. Vite Build: Bundle web assets with PWA support
|
||||
4. Service Worker: Inject combined scripts into PWA
|
||||
5. Output: Production-ready files in dist/
|
||||
1. Environment Setup: Load .env files, set NODE_ENV
|
||||
2. Type Check: tsc --noEmit (test and production modes)
|
||||
3. Vite Build: Bundle web assets
|
||||
4. Output: Production-ready files in dist/
|
||||
```
|
||||
|
||||
**Electron Build Process:**
|
||||
@@ -1922,34 +1908,6 @@ The `prebuild` script automatically runs before any build:
|
||||
5. Package Creation: APK/IPA generation
|
||||
```
|
||||
|
||||
#### Service Worker Architecture
|
||||
|
||||
**Script Organization:**
|
||||
|
||||
- `sw_scripts/` - Individual third-party scripts
|
||||
- `sw_combine.js` - Combines scripts into single file
|
||||
- `sw_scripts-combined.js` - Combined service worker (317KB, 10K+ lines)
|
||||
- `vite.config.utils.mts` - PWA configuration using combined script
|
||||
|
||||
**PWA Integration:**
|
||||
|
||||
```typescript
|
||||
// vite.config.utils.mts
|
||||
pwaConfig: {
|
||||
strategies: "injectManifest",
|
||||
filename: "sw_scripts-combined.js", // Uses our combined script
|
||||
// ... manifest configuration
|
||||
}
|
||||
```
|
||||
|
||||
**What Gets Combined:**
|
||||
|
||||
- `nacl.js` - NaCl cryptographic library
|
||||
- `noble-curves.js` - Elliptic curve cryptography (177KB)
|
||||
- `noble-hashes.js` - Cryptographic hash functions (91KB)
|
||||
- `safari-notifications.js` - Safari-specific notifications
|
||||
- `additional-scripts.js` - Additional service worker functionality
|
||||
|
||||
#### Process Environment Configuration
|
||||
|
||||
**Environment Files:**
|
||||
@@ -2002,10 +1960,13 @@ device)
|
||||
```folders
|
||||
dist/
|
||||
├── index.html # Main HTML file
|
||||
├── assets/ # Bundled JavaScript/CSS
|
||||
├── sw.js # Service worker (injected)
|
||||
├── manifest.webmanifest # PWA manifest
|
||||
└── wasm/ # SQLite WASM files
|
||||
├── assets/ # Bundled JavaScript, CSS, and SQLite WASM
|
||||
├── img/ # Static images (copied from public/)
|
||||
├── models/ # Static model files (copied from public/)
|
||||
├── favicon.ico
|
||||
├── manifest.webmanifest # Web app manifest, incl. share_target (copied from public/)
|
||||
├── robots.txt
|
||||
└── sw.js # Service worker for the Web Share Target (copied from public/)
|
||||
```
|
||||
|
||||
**Electron Build:**
|
||||
@@ -2027,17 +1988,14 @@ electron/
|
||||
**Manual Steps (Developer Responsibility):**
|
||||
|
||||
- Database migration testing
|
||||
- Service worker script formatting (optional)
|
||||
- Version updates and changelog
|
||||
- Environment-specific builds
|
||||
|
||||
**Automatic Steps (Build System):**
|
||||
|
||||
- Code linting and formatting
|
||||
- Script combination
|
||||
- Type checking (test and production builds)
|
||||
- Asset optimization
|
||||
- Package creation
|
||||
- Service worker injection
|
||||
|
||||
This architecture ensures consistent builds across all platforms while providing
|
||||
flexibility for platform-specific optimizations and manual quality assurance steps.
|
||||
@@ -2062,31 +2020,34 @@ environment setup, Vite build, and optional Docker containerization.
|
||||
|
||||
```bash
|
||||
# Direct script usage
|
||||
./scripts/build-web.sh # Development build
|
||||
./scripts/build-web.sh --dev # Development build (explicit)
|
||||
./scripts/build-web.sh # Production build into dist/
|
||||
./scripts/build-web.sh --prod # Production build (explicit)
|
||||
./scripts/build-web.sh --test # Test environment build
|
||||
./scripts/build-web.sh --prod # Production environment build
|
||||
./scripts/build-web.sh --docker # Build with Docker containerization
|
||||
./scripts/build-web.sh --dev # Start Vite dev server (no dist/)
|
||||
./scripts/build-web.sh --docker # Production build + Docker image
|
||||
./scripts/build-web.sh --docker:test # Test environment + Docker
|
||||
./scripts/build-web.sh --docker:prod # Production environment + Docker
|
||||
./scripts/build-web.sh --serve # Build and serve locally
|
||||
./scripts/build-web.sh --serve # Production build, then serve dist/
|
||||
./scripts/build-web.sh --help # Show help
|
||||
./scripts/build-web.sh --verbose # Enable verbose logging
|
||||
|
||||
# NPM Script Equivalents
|
||||
npm run build:web # Development build
|
||||
npm run dev # Vite dev server
|
||||
npm run build:web # Production build
|
||||
npm run build:web:test # Test environment build
|
||||
npm run build:web:prod # Production environment build
|
||||
npm run build:web:docker # Docker build
|
||||
npm run build:web:docker # Production Docker build
|
||||
npm run build:web:docker:test # Test Docker build
|
||||
npm run build:web:docker:prod # Production Docker build
|
||||
npm run build:web:serve # Production build, then serve
|
||||
npm run build:web:serve:test # Test build, then serve
|
||||
```
|
||||
|
||||
**Build Modes**:
|
||||
|
||||
- **Development**: Starts Vite dev server with hot reload (default)
|
||||
- **Production**: Optimized for production with full minification (default)
|
||||
- **Test**: Optimized for testing with minimal minification
|
||||
- **Production**: Optimized for production with full minification
|
||||
- **Development**: Starts Vite dev server with hot reload (`--dev` alone); with `--serve` or `--docker`, builds `dist/` in development mode
|
||||
|
||||
**Script Features**:
|
||||
|
||||
@@ -2439,9 +2400,7 @@ export async function createBuildConfig(platform: string): Promise<UserConfig> {
|
||||
const appConfig = await loadAppConfig();
|
||||
const isCapacitor = platform === "capacitor";
|
||||
const isElectron = platform === "electron";
|
||||
const isNative = isCapacitor || isElectron;
|
||||
|
||||
// Set platform - PWA is always enabled for web platforms
|
||||
process.env.VITE_PLATFORM = platform;
|
||||
|
||||
return {
|
||||
@@ -2457,7 +2416,6 @@ export async function createBuildConfig(platform: string): Promise<UserConfig> {
|
||||
assetsDir: 'assets',
|
||||
chunkSizeWarningLimit: 1000,
|
||||
rollupOptions: {
|
||||
external: isNative ? ['@capacitor/app'] : [],
|
||||
output: {
|
||||
format: 'esm',
|
||||
generatedCode: { preset: 'es2015' },
|
||||
@@ -2489,12 +2447,7 @@ export async function createBuildConfig(platform: string): Promise<UserConfig> {
|
||||
'@jlongster/sql.js',
|
||||
'absurd-sql',
|
||||
// ... additional dependencies
|
||||
],
|
||||
exclude: isNative ? [
|
||||
'register-service-worker',
|
||||
'workbox-window',
|
||||
// ... native exclusions
|
||||
] : []
|
||||
]
|
||||
}
|
||||
};
|
||||
}
|
||||
@@ -2517,98 +2470,23 @@ export async function createBuildConfig(platform: string): Promise<UserConfig> {
|
||||
|
||||
**File**: `vite.config.web.mts`
|
||||
**Author**: Matthew Raymer
|
||||
**Description**: Vite configuration for web platform with PWA support
|
||||
**Description**: Vite configuration for the web platform
|
||||
|
||||
**Purpose**: Configures Vite for web builds with environment-specific
|
||||
optimizations and PWA features.
|
||||
**Purpose**: Configures Vite for web builds by delegating to the common
|
||||
configuration with the `web` platform.
|
||||
|
||||
**Configuration Structure**:
|
||||
|
||||
```typescript
|
||||
export default defineConfig(async () => createBuildConfig('web'));
|
||||
```
|
||||
|
||||
**Key Features**:
|
||||
|
||||
- **Environment-Specific Configuration**: Different settings for dev/test/prod
|
||||
- **PWA Integration**: Progressive Web App support with service worker
|
||||
- **Build Optimization**: Manual chunk splitting for better caching
|
||||
- **Source Maps**: Environment-specific source map configuration
|
||||
- **Caching Strategies**: Production-specific API caching
|
||||
|
||||
**Environment Configurations**:
|
||||
|
||||
**Development Mode**:
|
||||
|
||||
```typescript
|
||||
{
|
||||
build: {
|
||||
minify: false,
|
||||
sourcemap: true,
|
||||
rollupOptions: { output: { manualChunks: undefined } }
|
||||
},
|
||||
define: {
|
||||
__DEV__: true,
|
||||
__TEST__: false,
|
||||
__PROD__: false
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
**Test Mode**:
|
||||
|
||||
```typescript
|
||||
{
|
||||
build: {
|
||||
minify: false,
|
||||
sourcemap: true,
|
||||
rollupOptions: { output: { manualChunks: undefined } }
|
||||
},
|
||||
define: {
|
||||
__DEV__: false,
|
||||
__TEST__: true,
|
||||
__PROD__: false
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
**Production Mode**:
|
||||
|
||||
```typescript
|
||||
{
|
||||
build: {
|
||||
minify: 'terser',
|
||||
sourcemap: false,
|
||||
rollupOptions: {
|
||||
output: {
|
||||
manualChunks: {
|
||||
vendor: ['vue', 'vue-router', 'pinia'],
|
||||
utils: ['luxon', 'ramda', 'zod'],
|
||||
crypto: ['@ethersproject/wallet', '@ethersproject/hdnode'],
|
||||
sql: ['@jlongster/sql.js', 'absurd-sql']
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
define: {
|
||||
__DEV__: false,
|
||||
__TEST__: false,
|
||||
__PROD__: true
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
**PWA Configuration**:
|
||||
|
||||
```typescript
|
||||
VitePWA({
|
||||
registerType: 'autoUpdate',
|
||||
manifest: appConfig.pwaConfig?.manifest,
|
||||
devOptions: { enabled: true, type: 'classic' },
|
||||
workbox: {
|
||||
cleanupOutdatedCaches: true,
|
||||
skipWaiting: true,
|
||||
clientsClaim: true,
|
||||
sourcemap: mode !== 'production',
|
||||
maximumFileSizeToCacheInBytes: 10 * 1024 * 1024,
|
||||
runtimeCaching: mode === 'production' ? [/* API caching */] : []
|
||||
}
|
||||
})
|
||||
```
|
||||
- **Minimal Configuration**: Inherits all settings from `vite.config.common.mts`
|
||||
- **Mode Selection**: `--mode test` or `--mode production` (passed by
|
||||
`scripts/build-web.sh`) selects the matching `.env.*` file
|
||||
- **Output**: Writes to `dist/`
|
||||
|
||||
### B.3 vite.config.electron.mts
|
||||
|
||||
@@ -2699,7 +2577,6 @@ export default defineConfig(async () => createBuildConfig('capacitor'));
|
||||
|
||||
- **Minimal Configuration**: Inherits all settings from common config
|
||||
- **Mobile Platform**: Automatically configures for mobile-specific settings
|
||||
- **PWA Disabled**: Progressive Web App features disabled for native apps
|
||||
- **Native Dependencies**: Handles Capacitor-specific dependencies
|
||||
|
||||
### B.5 vite.config.utils.mts
|
||||
@@ -2708,51 +2585,15 @@ export default defineConfig(async () => createBuildConfig('capacitor'));
|
||||
**Author**: Matthew Raymer
|
||||
**Description**: Utility functions for Vite configuration
|
||||
|
||||
**Purpose**: Provides shared configuration loading and PWA manifest generation.
|
||||
**Purpose**: Provides the shared alias configuration and strict ESBuild settings.
|
||||
|
||||
**Key Functions**:
|
||||
|
||||
**loadPackageJson()**: Loads and parses package.json for app configuration
|
||||
**loadAppConfig()**: Returns the alias configuration used by the common and
|
||||
optimized configs
|
||||
|
||||
**loadAppConfig()**: Loads complete application configuration including PWA settings
|
||||
|
||||
**PWA Configuration**:
|
||||
|
||||
```typescript
|
||||
interface PWAConfig {
|
||||
registerType: string;
|
||||
strategies: string;
|
||||
srcDir: string;
|
||||
filename: string;
|
||||
manifest: {
|
||||
name: string;
|
||||
short_name: string;
|
||||
theme_color: string;
|
||||
background_color: string;
|
||||
icons: ManifestIcon[];
|
||||
share_target: ShareTarget;
|
||||
};
|
||||
}
|
||||
```
|
||||
|
||||
**Manifest Icons**:
|
||||
|
||||
- Android Chrome 192x192 PNG
|
||||
- Android Chrome 512x512 PNG
|
||||
- Maskable icons for adaptive UI
|
||||
|
||||
**Share Target Configuration**:
|
||||
|
||||
```typescript
|
||||
share_target: {
|
||||
action: "/share-target",
|
||||
method: "POST",
|
||||
enctype: "multipart/form-data",
|
||||
params: {
|
||||
files: [{ name: "photo", accept: ["image/*"] }]
|
||||
}
|
||||
}
|
||||
```
|
||||
**getStrictESBuildConfig()**: Returns ESBuild settings that fail the build on
|
||||
syntax and duplicate-declaration errors
|
||||
|
||||
**Alias Configuration**:
|
||||
|
||||
@@ -2820,8 +2661,7 @@ All scripts use consistent error handling:
|
||||
|
||||
**Web Platform**:
|
||||
|
||||
- PWA features enabled
|
||||
- Service worker injection
|
||||
- Requires a secure context (HTTPS, `localhost`, `127.0.0.1`, or `[::1]`)
|
||||
- Browser-specific optimizations
|
||||
|
||||
**Electron Platform**:
|
||||
|
||||
@@ -6,6 +6,21 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
||||
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
||||
|
||||
|
||||
## [Unreleased]
|
||||
### Changed
|
||||
- `npm run build:web` builds production into `dist/` instead of starting the dev server.
|
||||
- `npm run build:web:serve` builds production (instead of development) before serving.
|
||||
- `npm run build:web:docker` builds production (instead of development) before creating the image.
|
||||
- `npm run build:native` builds with the Capacitor Vite config instead of a bare `vite build`.
|
||||
### Removed
|
||||
- `npm run build:web:dev` is removed; use `npm run dev` for the dev server.
|
||||
- Leftover service-worker build code (`sw_scripts/`, the unused PWA config, and the `register-service-worker` package) is removed.
|
||||
### Fixed
|
||||
- The daily starred-project check (Android and iOS) remembers the newest change it found, so it no longer reports the same changes again the next day.
|
||||
- Sharing a photo into the installed web app (Web Share Target) works again.
|
||||
- `npm run docker:up:test` and `npm run docker:up:prod` run, instead of failing on a missing `build:web:build` script.
|
||||
|
||||
|
||||
## [1.4.9] - 2026.10.11
|
||||
### Fixed
|
||||
- Startup DB error for new installations
|
||||
|
||||
+3
-3
@@ -21,13 +21,13 @@
|
||||
# Using npm scripts (recommended):
|
||||
# Production: npm run build:web:docker:prod
|
||||
# Test: npm run build:web:docker:test
|
||||
# Development: npm run build:web:docker
|
||||
# Development: ./scripts/build-web.sh --docker --dev
|
||||
#
|
||||
# Manual workflow:
|
||||
# 1. Build web assets: npm run build:web:build -- --mode production
|
||||
# 1. Build web assets: npm run build:web:prod
|
||||
# 2. Build Docker: docker build -t timesafari:latest .
|
||||
#
|
||||
# Note: For development, use npm run build:web directly (no Docker needed)
|
||||
# Note: For development, use npm run dev directly (no Docker needed)
|
||||
#
|
||||
# Build Arguments:
|
||||
# BUILD_MODE: development, test, or production (default: production)
|
||||
|
||||
@@ -311,23 +311,25 @@ public class TimeSafariNativeFetcher implements NativeNotificationContentFetcher
|
||||
return prefs.getString(KEY_LAST_ACKED_JWT_ID, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Store the newest JWT ID in the response (the highest ULID), so the next fetch
|
||||
* asks only for later changes. The server lists them newest first, so the last
|
||||
* item is the oldest.
|
||||
*/
|
||||
private void updateLastAckedJwtIdFromResponse(String responseBody) {
|
||||
try {
|
||||
JsonObject root = JsonParser.parseString(responseBody).getAsJsonObject();
|
||||
if (!root.has("data")) return;
|
||||
JsonArray dataArray = root.getAsJsonArray("data");
|
||||
if (dataArray == null || dataArray.size() == 0) return;
|
||||
JsonObject lastItem = dataArray.get(dataArray.size() - 1).getAsJsonObject();
|
||||
String jwtId = null;
|
||||
if (lastItem.has("jwtId")) {
|
||||
jwtId = lastItem.get("jwtId").getAsString();
|
||||
} else if (lastItem.has("plan")) {
|
||||
JsonObject plan = lastItem.getAsJsonObject("plan");
|
||||
if (plan.has("jwtId")) {
|
||||
jwtId = plan.get("jwtId").getAsString();
|
||||
for (int i = 0; i < dataArray.size(); i++) {
|
||||
String itemJwtId = extractJwtIdFromItem(dataArray.get(i).getAsJsonObject());
|
||||
if (itemJwtId != null && !itemJwtId.isEmpty() && (jwtId == null || itemJwtId.compareTo(jwtId) > 0)) {
|
||||
jwtId = itemJwtId;
|
||||
}
|
||||
}
|
||||
if (jwtId != null && !jwtId.isEmpty()) {
|
||||
if (jwtId != null) {
|
||||
prefs.edit().putString(KEY_LAST_ACKED_JWT_ID, jwtId).apply();
|
||||
}
|
||||
} catch (Exception e) {
|
||||
|
||||
@@ -0,0 +1,167 @@
|
||||
# Plan: Web Push on the Web Build
|
||||
|
||||
## Goal
|
||||
|
||||
A user of the web build (browser tab or installed web app) can turn on the
|
||||
Daily Reminder and New Activity notifications and receive them, matching what
|
||||
native builds deliver.
|
||||
|
||||
Requirements:
|
||||
|
||||
1. A `DIRECT_NOTIFICATION` push shows its message as sent.
|
||||
2. A `DAILY_CHECK` push shows the count of new activity for the active
|
||||
identity, using the same Endorser query the native fetcher uses.
|
||||
3. The service worker never holds a long-lived credential: it holds only
|
||||
day-scoped JWTs, the same pool native builds hand to their background
|
||||
fetcher.
|
||||
4. The Notifications section of the Account view works on the web build.
|
||||
|
||||
## Can FCM replace Web Push?
|
||||
|
||||
No. Firebase Cloud Messaging on the web (the `firebase/messaging` SDK) is a
|
||||
layer over the browser Push API: `getToken()` requires a registered service
|
||||
worker (`firebase-messaging-sw.js` by default), and that worker must display the
|
||||
notification, the same as a plain Web Push worker. FCM changes only the
|
||||
sending side — the push server would call the FCM HTTP v1 API instead of
|
||||
sending VAPID-signed Web Push requests — and it adds a Google dependency and
|
||||
Firebase config to the web build. It removes none of the work below.
|
||||
|
||||
## Current state
|
||||
|
||||
- `public/sw.js` is registered by `src/main.web.ts` on the web platform. It
|
||||
handles only the Web Share Target POST; it has no `push` or
|
||||
`notificationclick` handler.
|
||||
- The Notifications section of the Account view renders only on native
|
||||
(`v-if="isNativePlatform"`, `src/views/AccountViewView.vue:81`), and the
|
||||
"Notification Push Server" setting is hidden with `v-if="false"`
|
||||
(`src/views/AccountViewView.vue:719`). Web users cannot subscribe.
|
||||
- `src/components/PushNotificationPermission.vue` contains the web
|
||||
subscription flow:
|
||||
- GET `{pushUrl}/web-push/vapid` for the VAPID key (`:242`);
|
||||
- `pushManager.subscribe({ userVisibleOnly: true, ... })` (`:538`);
|
||||
- POST of the subscription to the relative URL `/web-push/subscribe`
|
||||
(`:583`), so the web host must proxy that path to the push server;
|
||||
- `askPermission()` sends the worker the placeholder secret
|
||||
`"temporary-secret"` via `SEND_LOCAL_DATA`, which nothing reads.
|
||||
- The push server sends a JSON payload whose `title` is `DAILY_CHECK` (run the
|
||||
new-activity check) or `DIRECT_NOTIFICATION` (show `message` as-is).
|
||||
- Account data lives in SQLite through absurd-sql, which a service worker
|
||||
cannot open. The worker therefore cannot decrypt the identity and sign its
|
||||
own JWTs.
|
||||
- Native builds solve the same problem with `mintBackgroundJwtTokenPool()`
|
||||
(`src/libs/crypto/backgroundJwtPool.ts`): 100 JWTs, each valid for one UTC
|
||||
day, stored at index `epochDay % 100`, handed to the background fetcher by
|
||||
`configureNativeFetcherIfReady()`
|
||||
(`src/services/notifications/nativeFetcherConfig.ts`). Passkey (`did:peer`)
|
||||
identities cannot mint the pool and raise
|
||||
`BackgroundJwtUnsupportedIdentityError`.
|
||||
|
||||
## Work
|
||||
|
||||
### 1. Service worker push handling (`public/sw.js`)
|
||||
|
||||
- `push`: parse the JSON payload.
|
||||
- `DIRECT_NOTIFICATION`: `showNotification("Direct Message", { body: message })`.
|
||||
- `DAILY_CHECK` (and any other title): take the token for today's slot from the
|
||||
pool, GET `{apiServer}/api/v2/report/claims` with it, count claims newer
|
||||
than the stored `lastNotifiedClaimId`, store the newest ID, and show "There
|
||||
is 1 new activity" / "There are N new activities".
|
||||
- `notificationclick`: close the notification, focus an open app window or open
|
||||
`/`.
|
||||
- Worker state (token pool, `apiServer`, `activeDid`, `lastNotifiedClaimId`)
|
||||
lives in the worker's own IndexedDB database, never in the app's SQLite
|
||||
database.
|
||||
|
||||
### 2. Hand the token pool to the worker
|
||||
|
||||
- On app start, identity change, and pool expiry, mint the pool with
|
||||
`mintBackgroundJwtTokenPool()` and `postMessage` it to the worker together
|
||||
with `apiServer` and `activeDid`. Reuse the trigger points in
|
||||
`src/services/notifications/notificationAuthLifecycle.ts`
|
||||
(`onNotificationAuthMayBeReady`).
|
||||
- Delete the `SEND_LOCAL_DATA` / placeholder-secret path in
|
||||
`PushNotificationPermission.vue`.
|
||||
- Passkey identities: do not offer New Activity notifications (the Daily
|
||||
Reminder needs no token).
|
||||
|
||||
### 3. Empty daily checks
|
||||
|
||||
Chrome requires every push received with `userVisibleOnly: true` to show a
|
||||
notification. A `DAILY_CHECK` that finds nothing new must show one anyway, or
|
||||
Chrome eventually shows its own "This site has been updated in the background"
|
||||
notice. Choose one (see Open questions):
|
||||
|
||||
- show a quiet "No new activity" notification and close it after a short delay;
|
||||
- have the push server skip pushes when there is nothing new, which requires
|
||||
the server to query Endorser on the user's behalf.
|
||||
|
||||
### 4. Re-enable the UI on the web build
|
||||
|
||||
- Render the Notifications section on web when `"PushManager" in window` and a
|
||||
service worker is registered, instead of only on native.
|
||||
- Restore the "Notification Push Server" setting for web.
|
||||
- iOS Safari delivers Web Push only to web apps added to the Home Screen
|
||||
(iOS 16.4+). `public/manifest.webmanifest` is linked from `index.html` and
|
||||
makes the app installable; the UI must explain the Home Screen requirement on
|
||||
iOS.
|
||||
|
||||
### 5. Hosting
|
||||
|
||||
- Confirm each web host (test, production, Docker `docker/*.conf`) proxies
|
||||
`/web-push/subscribe` to the push server, or change the client to POST to
|
||||
`{pushUrl}/web-push/subscribe`.
|
||||
- Serve `sw.js` with `Cache-Control: no-cache` so worker updates reach users
|
||||
promptly.
|
||||
|
||||
### 6. Tests
|
||||
|
||||
- Playwright: register the worker, then deliver pushes with the Chrome DevTools
|
||||
Protocol `ServiceWorker.deliverPushMessage` and assert on the shown
|
||||
notification (`registration.getNotifications()`), for both payload types.
|
||||
- Unit-test the claim-counting function, extracted so it runs outside the
|
||||
worker.
|
||||
|
||||
## Estimate
|
||||
|
||||
Two to four days of work, plus push-server and nginx checks (low confidence:
|
||||
the push server's current behavior and routing are not visible from this
|
||||
repository).
|
||||
|
||||
## Open questions
|
||||
|
||||
- Empty daily checks: silent-notification workaround, or server-side filtering?
|
||||
- Does the push server serve `/web-push/vapid` and accept
|
||||
`/web-push/subscribe`, and does it send `DAILY_CHECK` daily?
|
||||
- Should New Activity on web use the same Endorser query as the native fetcher
|
||||
(starred-plan changes) rather than `/api/v2/report/claims`, so both platforms
|
||||
report the same thing?
|
||||
|
||||
## Rejected
|
||||
|
||||
- **FCM for web:** still needs a service worker; adds a Google dependency to the
|
||||
web build and a server-side switch to the FCM API. See "Can FCM replace Web
|
||||
Push?".
|
||||
- **Reviving the old worker scripts (`sw_scripts/safari-notifications.js`):**
|
||||
they read the Dexie `TimeSafari` IndexedDB database, which no longer holds
|
||||
accounts, and decrypted the identity inside the worker using a secret passed
|
||||
from the page, shipping NaCl and noble crypto libraries into the worker. The
|
||||
day-scoped token pool needs neither.
|
||||
|
||||
## History
|
||||
|
||||
- 2025-02-18 (`2746b8fe`): the Vite config reorganization switched the web build
|
||||
to a Workbox-generated worker, so the custom push, notification-click, and
|
||||
share-target handlers stopped shipping.
|
||||
- 2025-07-18 (`8bc1c521`): VitePWA and the generated worker were removed; the
|
||||
web manifest stopped being generated and linked.
|
||||
- The leftover `sw_scripts/` files and PWA config were deleted, and
|
||||
`public/sw.js` was added for the Web Share Target only.
|
||||
|
||||
## Checklist
|
||||
|
||||
- [ ] Decide the empty-daily-check behavior
|
||||
- [ ] Confirm push-server endpoints and routing per environment
|
||||
- [ ] `push` and `notificationclick` handlers in `public/sw.js`
|
||||
- [ ] Token-pool handoff to the worker; remove the placeholder secret
|
||||
- [ ] Re-enable the web Notifications UI, with the iOS Home Screen note
|
||||
- [ ] Playwright push-delivery tests
|
||||
@@ -104,9 +104,7 @@ Build Scripts:
|
||||
├── scripts/** # All build and automation scripts
|
||||
├── electron/** # Electron build files
|
||||
├── android/** # Android build configuration
|
||||
├── ios/** # iOS build configuration
|
||||
├── sw_scripts/** # Service worker scripts
|
||||
└── sw_combine.js # Service worker combination
|
||||
└── ios/** # iOS build configuration
|
||||
|
||||
Deployment:
|
||||
├── Dockerfile # Docker configuration
|
||||
|
||||
@@ -175,7 +175,6 @@ export async function createBuildConfig(mode: string) {
|
||||
return defineConfig({
|
||||
define: {
|
||||
'process.env.VITE_PLATFORM': JSON.stringify(mode),
|
||||
// PWA is automatically enabled for web platforms via build configuration
|
||||
__IS_MOBILE__: JSON.stringify(isCapacitor),
|
||||
__USE_QR_READER__: JSON.stringify(!isCapacitor)
|
||||
},
|
||||
|
||||
+4
-5
@@ -5,10 +5,9 @@
|
||||
# IMPORTANT: Build web assets first using npm scripts before running docker-compose
|
||||
#
|
||||
# Usage:
|
||||
# Development: npm run build:web:build -- --mode development && docker-compose up dev
|
||||
# Test: npm run build:web:build -- --mode test && docker-compose up test
|
||||
# Production: npm run build:web:build -- --mode production && docker-compose up production
|
||||
# Custom: BUILD_MODE=test npm run build:web:build -- --mode test && docker-compose up custom
|
||||
# Test: npm run docker:up:test (runs npm run build:web:test && docker-compose up test)
|
||||
# Production: npm run docker:up:prod (runs npm run build:web:prod && docker-compose up production)
|
||||
# Custom: npm run build:web:test && BUILD_MODE=test docker-compose up custom
|
||||
#
|
||||
# Environment Variables:
|
||||
# BUILD_MODE: development, test, or production (default: production)
|
||||
@@ -16,7 +15,7 @@
|
||||
# PORT: port to expose (default: 80 for production, 8080 for test)
|
||||
# ENV_FILE: environment file to use (default: .env.production)
|
||||
#
|
||||
# Note: For development, use npm run build:web directly (no Docker needed)
|
||||
# Note: For development, use npm run dev directly (no Docker needed)
|
||||
|
||||
version: '3.8'
|
||||
|
||||
|
||||
+2
-5
@@ -103,7 +103,6 @@ The Dockerfile supports these build arguments:
|
||||
| `BUILD_MODE` | `production` | Build mode: development, staging, or production |
|
||||
| `NODE_ENV` | `production` | Node.js environment |
|
||||
| `VITE_PLATFORM` | `web` | Vite platform type |
|
||||
| PWA | `enabled` | Automatically enabled for web platforms |
|
||||
|
||||
### Environment Variables
|
||||
|
||||
@@ -114,7 +113,6 @@ Docker Compose supports these environment variables:
|
||||
| `BUILD_MODE` | `production` | Build mode |
|
||||
| `NODE_ENV` | `production` | Node environment |
|
||||
| `VITE_PLATFORM` | `web` | Vite platform |
|
||||
| PWA | `enabled` | Automatically enabled for web platforms |
|
||||
| `DEV_PORT` | `5173` | Development port |
|
||||
| `STAGING_PORT` | `8080` | Staging port |
|
||||
| `PROD_PORT` | `80` | Production port |
|
||||
@@ -219,13 +217,12 @@ BUILD_MODE=staging NODE_ENV=staging ./docker/run.sh custom
|
||||
docker build \
|
||||
--build-arg BUILD_MODE=staging \
|
||||
--build-arg NODE_ENV=staging \
|
||||
|
||||
-t timesafari:staging-no-pwa .
|
||||
-t timesafari:staging .
|
||||
|
||||
# Run with custom configuration
|
||||
docker run -d -p 9000:80 \
|
||||
-e VITE_APP_SERVER=https://test.example.com \
|
||||
timesafari:staging-no-pwa
|
||||
timesafari:staging
|
||||
```
|
||||
|
||||
### Docker Compose with Custom Variables
|
||||
|
||||
@@ -13,7 +13,6 @@
|
||||
# BUILD_MODE: development, staging, or production
|
||||
# NODE_ENV: node environment
|
||||
# VITE_PLATFORM: vite platform
|
||||
# PWA: automatically enabled for web platforms
|
||||
# PORT: port to expose
|
||||
# ENV_FILE: environment file to use
|
||||
|
||||
@@ -71,7 +70,6 @@ show_usage() {
|
||||
echo " BUILD_MODE: development, staging, or production"
|
||||
echo " NODE_ENV: node environment"
|
||||
echo " VITE_PLATFORM: vite platform"
|
||||
echo " PWA: automatically enabled for web platforms"
|
||||
echo " PORT: port to expose"
|
||||
echo " ENV_FILE: environment file to use"
|
||||
}
|
||||
@@ -86,7 +84,6 @@ show_build_args() {
|
||||
echo " BUILD_MODE: development"
|
||||
echo " NODE_ENV: development"
|
||||
echo " VITE_PLATFORM: web"
|
||||
echo " PWA: enabled (web platform)"
|
||||
echo " Target: development"
|
||||
echo " Port: 5173"
|
||||
;;
|
||||
@@ -94,7 +91,6 @@ show_build_args() {
|
||||
echo " BUILD_MODE: staging"
|
||||
echo " NODE_ENV: staging"
|
||||
echo " VITE_PLATFORM: web"
|
||||
echo " PWA: enabled (web platform)"
|
||||
echo " Target: staging"
|
||||
echo " Port: 80 (mapped to 8080)"
|
||||
;;
|
||||
@@ -102,7 +98,6 @@ show_build_args() {
|
||||
echo " BUILD_MODE: production"
|
||||
echo " NODE_ENV: production"
|
||||
echo " VITE_PLATFORM: web"
|
||||
echo " PWA: enabled (web platform)"
|
||||
echo " Target: production"
|
||||
echo " Port: 80"
|
||||
;;
|
||||
@@ -110,7 +105,6 @@ show_build_args() {
|
||||
echo " BUILD_MODE: \${BUILD_MODE:-production}"
|
||||
echo " NODE_ENV: \${NODE_ENV:-production}"
|
||||
echo " VITE_PLATFORM: \${VITE_PLATFORM:-web}"
|
||||
echo " PWA: enabled for web platforms"
|
||||
echo " Target: \${BUILD_TARGET:-production}"
|
||||
echo " Port: \${CUSTOM_PORT:-8080}:\${CUSTOM_INTERNAL_PORT:-80}"
|
||||
;;
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<link rel="icon" type="image/svg+xml" href="/favicon.ico" />
|
||||
<link rel="manifest" href="/manifest.webmanifest" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0, viewport-fit=cover, user-scalable=no, interactive-widget=overlays-content" />
|
||||
|
||||
<!-- CORS headers removed to allow images from any domain -->
|
||||
|
||||
@@ -144,20 +144,16 @@ final class TimeSafariNativeFetcher: NativeNotificationContentFetcher {
|
||||
return (s?.isEmpty == false) ? s : nil
|
||||
}
|
||||
|
||||
/// Store the newest JWT ID in the response (the highest ULID), so the next fetch
|
||||
/// asks only for later changes. The server lists them newest first, so the last
|
||||
/// item is the oldest.
|
||||
private func updateLastAckedJwtIdFromResponse(responseBody: String) {
|
||||
guard let data = responseBody.data(using: .utf8),
|
||||
let root = try? JSONSerialization.jsonObject(with: data) as? [String: Any],
|
||||
let dataArray = root["data"] as? [[String: Any]], !dataArray.isEmpty
|
||||
else { return }
|
||||
|
||||
let lastItem = dataArray[dataArray.count - 1]
|
||||
var jwtId: String?
|
||||
if let j = lastItem["jwtId"] as? String {
|
||||
jwtId = j
|
||||
} else if let plan = lastItem["plan"] as? [String: Any], let j = plan["jwtId"] as? String {
|
||||
jwtId = j
|
||||
}
|
||||
if let jwtId = jwtId, !jwtId.isEmpty {
|
||||
if let jwtId = dataArray.compactMap({ extractJwtIdFromItem($0) }).max() {
|
||||
UserDefaults.standard.set(jwtId, forKey: prefsLastAckedKey)
|
||||
}
|
||||
}
|
||||
|
||||
Generated
-5
@@ -87,7 +87,6 @@
|
||||
"ramda": "^0.29.1",
|
||||
"readable-stream": "^4.5.2",
|
||||
"reflect-metadata": "^0.1.14",
|
||||
"register-service-worker": "^1.7.2",
|
||||
"simple-vue-camera": "^1.1.3",
|
||||
"sqlite3": "^5.1.7",
|
||||
"stream-browserify": "^3.0.0",
|
||||
@@ -26317,10 +26316,6 @@
|
||||
"node": ">=4"
|
||||
}
|
||||
},
|
||||
"node_modules/register-service-worker": {
|
||||
"version": "1.7.2",
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/registry-auth-token": {
|
||||
"version": "3.3.2",
|
||||
"dev": true,
|
||||
|
||||
+5
-7
@@ -90,9 +90,8 @@
|
||||
"build:ios:test:custom": "./scripts/build-ios.sh --test --api-ip",
|
||||
"build:ios:test:run": "./scripts/build-ios.sh --test --auto-run",
|
||||
"build:ios:test:run:custom": "./scripts/build-ios.sh --test --api-ip --auto-run",
|
||||
"build:native": "vite build && npx cap sync && node scripts/restore-local-plugins.js && bash -c 'source scripts/common.sh && ensure_ios_capacitor_asset_directories' && npx capacitor-assets generate --assetPath resources",
|
||||
"build:native": "npm run build:capacitor:sync && bash -c 'source scripts/common.sh && ensure_ios_capacitor_asset_directories' && npx capacitor-assets generate --ios --android --assetPath resources",
|
||||
"build:web": "./scripts/build-web.sh",
|
||||
"build:web:dev": "./scripts/build-web.sh --dev",
|
||||
"build:web:docker": "./scripts/build-web.sh --docker",
|
||||
"build:web:docker:prod": "./scripts/build-web.sh --docker:prod",
|
||||
"build:web:docker:test": "./scripts/build-web.sh --docker:test",
|
||||
@@ -110,12 +109,12 @@
|
||||
"clean:electron": "./scripts/build-electron.sh --clean",
|
||||
"clean:ios": "rm -rf ios/App/build ios/App/Pods ios/App/output ios/App/App/public ios/DerivedData ios/capacitor-cordova-ios-plugins ios/App/App/capacitor.config.json ios/App/App/config.xml || true",
|
||||
"deps:update-daily-notification-plugin": "npm install @timesafari/daily-notification-plugin@git+https://gitea.anomalistdesign.com/trent_larson/daily-notification-plugin.git#master",
|
||||
"dev": "npm run build:web:dev",
|
||||
"dev": "./scripts/build-web.sh --dev",
|
||||
"docker:down": "docker-compose down",
|
||||
"docker:logs": "docker-compose logs -f",
|
||||
"docker:up": "docker-compose up",
|
||||
"docker:up:prod": "npm run build:web:build -- --mode production && docker-compose up production",
|
||||
"docker:up:test": "npm run build:web:build -- --mode test && docker-compose up test",
|
||||
"docker:up:prod": "npm run build:web:prod && docker-compose up production",
|
||||
"docker:up:test": "npm run build:web:test && docker-compose up test",
|
||||
"guard": "bash ./scripts/build-arch-guard.sh",
|
||||
"guard:setup": "npm run prepare && echo 'Build Architecture Guard is now active!'",
|
||||
"guard:test": "bash ./scripts/build-arch-guard.sh --staged",
|
||||
@@ -124,7 +123,7 @@
|
||||
"markdown:check": "markdownlint-cli2",
|
||||
"markdown:fix": "markdownlint-cli2 --fix",
|
||||
"markdown:setup": "./scripts/setup-markdown-hooks.sh",
|
||||
"prebuild": "eslint --ext .js,.ts,.vue --ignore-path .gitignore src && node sw_combine.js && node scripts/copy-wasm.js",
|
||||
"prebuild": "eslint --ext .js,.ts,.vue --ignore-path .gitignore src && node scripts/copy-wasm.js",
|
||||
"prepare": "husky",
|
||||
"test:all": "npm run lint && npm run type-check && npm run type-check:vue && npm run test:unit && npm run test:web && npm run test:mobile && echo '\n\n\nGotta add the performance tests'",
|
||||
"test:android": "node scripts/test-android.js",
|
||||
@@ -220,7 +219,6 @@
|
||||
"ramda": "^0.29.1",
|
||||
"readable-stream": "^4.5.2",
|
||||
"reflect-metadata": "^0.1.14",
|
||||
"register-service-worker": "^1.7.2",
|
||||
"simple-vue-camera": "^1.1.3",
|
||||
"sqlite3": "^5.1.7",
|
||||
"stream-browserify": "^3.0.0",
|
||||
|
||||
@@ -106,7 +106,7 @@ export default defineConfig({
|
||||
*/
|
||||
webServer: {
|
||||
command:
|
||||
"VITE_APP_SERVER=http://localhost:8080 VITE_DEFAULT_ENDORSER_API_SERVER=http://localhost:3000 VITE_DEFAULT_PARTNER_API_SERVER=http://localhost:3000 VITE_DEFAULT_IMAGE_API_SERVER=https://test-image-api.timesafari.app VITE_PASSKEYS_ENABLED=true npm run build:web -- --port=8080",
|
||||
"VITE_APP_SERVER=http://localhost:8080 VITE_DEFAULT_ENDORSER_API_SERVER=http://localhost:3000 VITE_DEFAULT_PARTNER_API_SERVER=http://localhost:3000 VITE_DEFAULT_IMAGE_API_SERVER=https://test-image-api.timesafari.app VITE_PASSKEYS_ENABLED=true npm run dev",
|
||||
url: "http://localhost:8080",
|
||||
reuseExistingServer: !process.env.CI,
|
||||
},
|
||||
|
||||
+36
-36
@@ -1,46 +1,46 @@
|
||||
{
|
||||
"name": "Giftopia",
|
||||
"short_name": "Giftopia",
|
||||
"start_url": "/",
|
||||
"scope": "/",
|
||||
"display": "standalone",
|
||||
"theme_color": "#4a90e2",
|
||||
"background_color": "#ffffff",
|
||||
"icons": [
|
||||
{
|
||||
"src": "../icons/icon-48.webp",
|
||||
"type": "image/png",
|
||||
"sizes": "48x48",
|
||||
"purpose": "any maskable"
|
||||
},
|
||||
{
|
||||
"src": "../icons/icon-72.webp",
|
||||
"type": "image/png",
|
||||
"sizes": "72x72",
|
||||
"purpose": "any maskable"
|
||||
},
|
||||
{
|
||||
"src": "../icons/icon-96.webp",
|
||||
"type": "image/png",
|
||||
"sizes": "96x96",
|
||||
"purpose": "any maskable"
|
||||
},
|
||||
{
|
||||
"src": "../icons/icon-128.webp",
|
||||
"type": "image/png",
|
||||
"sizes": "128x128",
|
||||
"purpose": "any maskable"
|
||||
},
|
||||
{
|
||||
"src": "../icons/icon-192.webp",
|
||||
"type": "image/png",
|
||||
"src": "/img/icons/android-chrome-192x192.png",
|
||||
"sizes": "192x192",
|
||||
"purpose": "any maskable"
|
||||
"type": "image/png"
|
||||
},
|
||||
{
|
||||
"src": "../icons/icon-256.webp",
|
||||
"type": "image/png",
|
||||
"sizes": "256x256",
|
||||
"purpose": "any maskable"
|
||||
},
|
||||
{
|
||||
"src": "../icons/icon-512.webp",
|
||||
"type": "image/png",
|
||||
"src": "/img/icons/android-chrome-512x512.png",
|
||||
"sizes": "512x512",
|
||||
"purpose": "any maskable"
|
||||
"type": "image/png"
|
||||
},
|
||||
{
|
||||
"src": "/img/icons/android-chrome-maskable-192x192.png",
|
||||
"sizes": "192x192",
|
||||
"type": "image/png",
|
||||
"purpose": "maskable"
|
||||
},
|
||||
{
|
||||
"src": "/img/icons/android-chrome-maskable-512x512.png",
|
||||
"sizes": "512x512",
|
||||
"type": "image/png",
|
||||
"purpose": "maskable"
|
||||
}
|
||||
],
|
||||
"share_target": {
|
||||
"action": "/share-target",
|
||||
"method": "POST",
|
||||
"enctype": "multipart/form-data",
|
||||
"params": {
|
||||
"files": [
|
||||
{
|
||||
"name": "photo",
|
||||
"accept": ["image/*"]
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,68 @@
|
||||
/* eslint-env serviceworker */
|
||||
/**
|
||||
* Service worker for the web build.
|
||||
*
|
||||
* Its only job is the Web Share Target: the manifest's share_target POSTs a
|
||||
* photo to /share-target, which no static server can accept. This worker
|
||||
* stashes the photo in Cache Storage and redirects to /shared-photo, where
|
||||
* src/libs/webShareTarget.ts picks it up. Every other request goes straight to
|
||||
* the network (no fetch handler response, no precaching).
|
||||
*
|
||||
* It also replaces the Workbox worker that older builds registered at this
|
||||
* same URL, and deletes that worker's precaches, which otherwise keep serving
|
||||
* a stale index.html that points at JavaScript files no longer deployed.
|
||||
*/
|
||||
|
||||
const SHARE_TARGET_CACHE = "share-target";
|
||||
// Keep in sync with src/libs/webShareTarget.ts
|
||||
const SHARED_PHOTO_KEY = "/share-target/photo";
|
||||
const FILE_NAME_HEADER = "X-File-Name";
|
||||
|
||||
self.addEventListener("install", () => {
|
||||
self.skipWaiting();
|
||||
});
|
||||
|
||||
self.addEventListener("activate", (event) => {
|
||||
event.waitUntil(
|
||||
(async () => {
|
||||
const names = await caches.keys();
|
||||
await Promise.all(
|
||||
names
|
||||
.filter((name) => name !== SHARE_TARGET_CACHE)
|
||||
.map((name) => caches.delete(name)),
|
||||
);
|
||||
await self.clients.claim();
|
||||
})(),
|
||||
);
|
||||
});
|
||||
|
||||
self.addEventListener("fetch", (event) => {
|
||||
const url = new URL(event.request.url);
|
||||
if (
|
||||
event.request.method !== "POST" ||
|
||||
url.origin !== self.location.origin ||
|
||||
url.pathname !== "/share-target"
|
||||
) {
|
||||
return;
|
||||
}
|
||||
|
||||
event.respondWith(
|
||||
(async () => {
|
||||
const formData = await event.request.formData();
|
||||
const photo = formData.get("photo");
|
||||
if (photo instanceof File) {
|
||||
const cache = await caches.open(SHARE_TARGET_CACHE);
|
||||
await cache.put(
|
||||
SHARED_PHOTO_KEY,
|
||||
new Response(photo, {
|
||||
headers: {
|
||||
"Content-Type": photo.type || "application/octet-stream",
|
||||
[FILE_NAME_HEADER]: encodeURIComponent(photo.name || ""),
|
||||
},
|
||||
}),
|
||||
);
|
||||
}
|
||||
return Response.redirect("/shared-photo?source=share-target", 303);
|
||||
})(),
|
||||
);
|
||||
});
|
||||
@@ -15,7 +15,7 @@
|
||||
|
||||
## Commands Run (paste exact logs/snips)
|
||||
|
||||
- [ ] Web: `npm run build:web` / `:prod`
|
||||
- [ ] Web: `npm run dev` / `npm run build:web`
|
||||
- [ ] Electron: `npm run build:electron:dev` / package step
|
||||
- [ ] Mobile: `npm run build:android:test` / iOS equivalent
|
||||
- [ ] Clean/auto-run impacted scripts
|
||||
|
||||
+4
-6
@@ -23,10 +23,10 @@ All scripts automatically handle environment variables for different build types
|
||||
|
||||
#### Build Types and Environment Variables
|
||||
|
||||
| Platform | Mode | PWA Enabled | Native Features | Build Script |
|
||||
|----------|------|-------------|-----------------|--------------|
|
||||
| `web` | web | true | false | `build-web.sh` |
|
||||
| `capacitor` | capacitor | false | true | `build-capacitor.sh` |
|
||||
| Platform | Mode | Native Features | Build Script |
|
||||
|----------|------|-----------------|--------------|
|
||||
| `web` | web | false | `build-web.sh` |
|
||||
| `capacitor` | capacitor | true | `build-capacitor.sh` |
|
||||
|
||||
#### Automatic Environment Setup
|
||||
|
||||
@@ -183,8 +183,6 @@ All scripts automatically configure the correct environment variables for their
|
||||
```bash
|
||||
# Capacitor builds automatically get:
|
||||
export VITE_PLATFORM=capacitor
|
||||
export VITE_PWA_ENABLED=false
|
||||
export VITE_DISABLE_PWA=true
|
||||
export DEBUG_MIGRATIONS=0
|
||||
export VITE_GIT_HASH=<git-hash>
|
||||
|
||||
|
||||
@@ -23,8 +23,6 @@ SENSITIVE=(
|
||||
"electron/**"
|
||||
"android/**"
|
||||
"ios/**"
|
||||
"sw_scripts/**"
|
||||
"sw_combine.js"
|
||||
"Dockerfile"
|
||||
"docker/**"
|
||||
"capacitor.config.ts"
|
||||
|
||||
+23
-16
@@ -5,25 +5,31 @@
|
||||
# This script handles the complete web build process including cleanup,
|
||||
# environment setup, Vite build, and optional Docker containerization.
|
||||
#
|
||||
# Every invocation except --dev writes dist/. --dev alone starts the Vite dev
|
||||
# server and writes nothing.
|
||||
#
|
||||
# Usage:
|
||||
# ./scripts/build-web.sh # Development build
|
||||
# ./scripts/build-web.sh --dev # Development build (explicit)
|
||||
# ./scripts/build-web.sh # Production build into dist/
|
||||
# ./scripts/build-web.sh --prod # Production build (explicit)
|
||||
# ./scripts/build-web.sh --test # Test environment build
|
||||
# ./scripts/build-web.sh --prod # Production environment build
|
||||
# ./scripts/build-web.sh --docker # Build with Docker containerization
|
||||
# ./scripts/build-web.sh --dev # Start Vite dev server (no dist/)
|
||||
# ./scripts/build-web.sh --docker # Production build + Docker image
|
||||
# ./scripts/build-web.sh --docker:test # Test environment + Docker
|
||||
# ./scripts/build-web.sh --docker:prod # Production environment + Docker
|
||||
# ./scripts/build-web.sh --serve # Build and serve locally
|
||||
# ./scripts/build-web.sh --serve # Production build, then serve dist/
|
||||
# ./scripts/build-web.sh --help # Show help
|
||||
# ./scripts/build-web.sh --verbose # Enable verbose logging
|
||||
#
|
||||
# NPM Script Equivalents:
|
||||
# npm run build:web # Development build
|
||||
# npm run dev # Vite dev server
|
||||
# npm run build:web # Production build
|
||||
# npm run build:web:test # Test environment build
|
||||
# npm run build:web:prod # Production environment build
|
||||
# npm run build:web:docker # Docker build
|
||||
# npm run build:web:docker # Production Docker build
|
||||
# npm run build:web:docker:test # Test Docker build
|
||||
# npm run build:web:docker:prod # Production Docker build
|
||||
# npm run build:web:serve # Production build, then serve
|
||||
# npm run build:web:serve:test # Test build, then serve
|
||||
#
|
||||
# Exit Codes:
|
||||
# 1 - Web cleanup failed
|
||||
@@ -40,7 +46,7 @@ set -e
|
||||
source "$(dirname "$0")/common.sh"
|
||||
|
||||
# Default values
|
||||
BUILD_MODE="development"
|
||||
BUILD_MODE="production"
|
||||
BUILD_ACTION="build"
|
||||
DOCKER_BUILD=false
|
||||
SERVE_BUILD=false
|
||||
@@ -51,9 +57,10 @@ show_usage() {
|
||||
Usage: $0 [OPTIONS]
|
||||
|
||||
OPTIONS:
|
||||
--dev, --development Build for development environment (default)
|
||||
--prod, --production Build for production environment (default)
|
||||
--test Build for test environment
|
||||
--prod, --production Build for production environment
|
||||
--dev, --development Start the Vite dev server (with --serve or
|
||||
--docker: build for development instead)
|
||||
--docker Build and create Docker container
|
||||
--docker:test Build for test environment and create Docker container
|
||||
--docker:prod Build for production environment and create Docker container
|
||||
@@ -63,18 +70,18 @@ OPTIONS:
|
||||
--env Show environment variables
|
||||
|
||||
EXAMPLES:
|
||||
$0 # Development build
|
||||
$0 # Production build
|
||||
$0 --test # Test environment build
|
||||
$0 --prod # Production environment build
|
||||
$0 --docker # Development + Docker
|
||||
$0 --dev # Development server
|
||||
$0 --docker # Production + Docker
|
||||
$0 --docker:test # Test + Docker
|
||||
$0 --docker:prod # Production + Docker
|
||||
$0 --serve # Build and serve
|
||||
$0 --serve # Production build, then serve
|
||||
|
||||
BUILD MODES:
|
||||
development: Starts Vite development server with hot reload (default)
|
||||
production: Optimized for production with full minification and optimization (default)
|
||||
test: Optimized for testing with minimal minification
|
||||
production: Optimized for production with full minification and optimization
|
||||
development: Starts Vite development server with hot reload
|
||||
|
||||
EOF
|
||||
}
|
||||
|
||||
@@ -161,4 +161,4 @@ echo "✅ Database clearing instructions completed!"
|
||||
echo ""
|
||||
echo "💡 Tip: After clearing the database, restart your development server:"
|
||||
echo " npm run build:electron:dev # For Electron"
|
||||
echo " npm run build:web:dev # For Web"
|
||||
echo " npm run dev # For Web"
|
||||
@@ -283,7 +283,6 @@ const runDeeplinkTests = async (log) => {
|
||||
const buildWebAssets = async (log) => {
|
||||
log('🌐 Building web assets...');
|
||||
execSync('rm -rf dist', { stdio: 'inherit' });
|
||||
execSync('npm run build:web', { stdio: 'inherit' });
|
||||
execSync('npm run build:capacitor', { stdio: 'inherit' });
|
||||
log('✅ Web assets built successfully');
|
||||
};
|
||||
|
||||
@@ -147,7 +147,6 @@ export default config;
|
||||
log('🔄 Building web assets before adding iOS platform...');
|
||||
try {
|
||||
execSync('rm -rf dist', { stdio: 'inherit' });
|
||||
execSync('npm run build:web', { stdio: 'inherit' });
|
||||
execSync('npm run build:capacitor', { stdio: 'inherit' });
|
||||
log('✅ Web assets built successfully');
|
||||
} catch (error) {
|
||||
@@ -416,7 +415,6 @@ const generateTestData = async (log) => {
|
||||
const buildWebAssets = async (log) => {
|
||||
log('🌐 Building web assets...');
|
||||
execSync('rm -rf dist', { stdio: 'inherit' });
|
||||
execSync('npm run build:web', { stdio: 'inherit' });
|
||||
execSync('npm run build:capacitor', { stdio: 'inherit' });
|
||||
log('✅ Web assets built successfully');
|
||||
};
|
||||
|
||||
@@ -298,7 +298,6 @@ export async function logToDb(
|
||||
}
|
||||
}
|
||||
|
||||
// similar method is in the sw_scripts/additional-scripts.js file
|
||||
export async function logConsoleAndDb(
|
||||
message: string,
|
||||
isError = false,
|
||||
|
||||
@@ -302,7 +302,6 @@ export async function logToDb(message: string): Promise<void> {
|
||||
await db.logs.update(todayKey, { message: fullMessage });
|
||||
}
|
||||
|
||||
// similar method is in the sw_scripts/additional-scripts.js file
|
||||
export async function logConsoleAndDb(
|
||||
message: string,
|
||||
isError = false,
|
||||
|
||||
@@ -19,15 +19,28 @@
|
||||
/**
|
||||
* Server-issued ULID on a stored JWT/plan record, used as alertSearch afterId /
|
||||
* beforeId. Not an authentication JWT and not a delegated notification JWT.
|
||||
* Superseded by AlertSearchCursor for "what changed since" queries.
|
||||
*/
|
||||
export type AlertSearchCursorUlid = string;
|
||||
|
||||
/**
|
||||
* Opaque cursor: a position between changes on one server. Responses return
|
||||
* `nextAfterCursor` and `nextBeforeCursor`; requests send them back as
|
||||
* `afterCursor` (changes after it, oldest first) or `beforeCursor` (changes
|
||||
* before it, newest first). Store it as text and never parse or compare it;
|
||||
* its format belongs to the server (see endorser-ch
|
||||
* CHANGE/PLAN-accurate-cursors.md).
|
||||
*/
|
||||
export type AlertSearchCursor = string;
|
||||
|
||||
/**
|
||||
* JWT row from endorser `jwtsWithDidAfterId` (no claim body).
|
||||
* Cursor field: `id`.
|
||||
*/
|
||||
export interface AlertSearchClaimRecord {
|
||||
id: AlertSearchCursorUlid;
|
||||
/** Server change sequence of this row; ascending within a cursor-path list. */
|
||||
changeSeq?: number;
|
||||
issuedAt: string;
|
||||
issuer: string;
|
||||
subject?: string;
|
||||
@@ -54,6 +67,8 @@ export interface AlertSearchJwtWithClaimRecord extends AlertSearchClaimRecord {
|
||||
export interface AlertSearchPlanRecord {
|
||||
handleId: string;
|
||||
jwtId: AlertSearchCursorUlid;
|
||||
/** Server change sequence of this row; ascending within a cursor-path list. */
|
||||
changeSeq?: number;
|
||||
issuerDid?: string;
|
||||
agentDid?: string;
|
||||
fulfillsLinkConfirmed?: boolean | number;
|
||||
@@ -77,6 +92,8 @@ export interface AlertSearchPlanRecord {
|
||||
*/
|
||||
export interface AlertSearchProfileRecord {
|
||||
rowId?: number;
|
||||
/** Server change sequence of this row; ascending within a cursor-path list. */
|
||||
changeSeq?: number;
|
||||
issuerDid: string;
|
||||
updatedAt?: string;
|
||||
description: string;
|
||||
@@ -94,18 +111,43 @@ export interface EndorserAlertSearchData {
|
||||
plansNearby: AlertSearchPlanRecord[];
|
||||
}
|
||||
|
||||
/**
|
||||
* A profile or plan close in meaning to the requester's profile, from partner
|
||||
* `profilesSimilar` / `plansSimilar` (best first; not paged).
|
||||
*/
|
||||
export interface AlertSearchSimilarProfile {
|
||||
similarity: number;
|
||||
profile: AlertSearchProfileRecord;
|
||||
}
|
||||
|
||||
export interface AlertSearchSimilarPlan {
|
||||
similarity: number;
|
||||
plan: AlertSearchPlanRecord;
|
||||
}
|
||||
|
||||
export interface PartnerAlertSearchData {
|
||||
profilesNearby: AlertSearchProfileRecord[];
|
||||
profilesSimilar?: AlertSearchSimilarProfile[];
|
||||
plansSimilar?: AlertSearchSimilarPlan[];
|
||||
}
|
||||
|
||||
/**
|
||||
* Endorser GET/POST /api/v2/report/alertSearch body.
|
||||
* Per-bucket SQL hitLimit is not currently copied onto this envelope.
|
||||
* Timeouts may set `userMessage` instead.
|
||||
* The cursors and `hasMore` are absent from servers that predate cursors.
|
||||
* Timeouts may set `userMessage`; the cursor then does not move.
|
||||
*/
|
||||
export interface EndorserAlertSearchResponse {
|
||||
data: EndorserAlertSearchData;
|
||||
userMessage?: string;
|
||||
/** Send as `afterCursor` to get what changed after this response. */
|
||||
nextAfterCursor?: AlertSearchCursor;
|
||||
/** Send as `beforeCursor` to scroll back past this response. */
|
||||
nextBeforeCursor?: AlertSearchCursor;
|
||||
/**
|
||||
* A list was cut at its limit: call again in the same direction, with
|
||||
* `afterCursor = nextAfterCursor` or `beforeCursor = nextBeforeCursor`.
|
||||
*/
|
||||
hasMore?: boolean;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -114,6 +156,15 @@ export interface EndorserAlertSearchResponse {
|
||||
export interface PartnerAlertSearchResponse {
|
||||
data: PartnerAlertSearchData;
|
||||
userMessage?: string;
|
||||
/** Send as `afterCursor` to get what changed after this response. */
|
||||
nextAfterCursor?: AlertSearchCursor;
|
||||
/** Send as `beforeCursor` to scroll back past this response. */
|
||||
nextBeforeCursor?: AlertSearchCursor;
|
||||
/**
|
||||
* A list was cut at its limit: call again in the same direction, with
|
||||
* `afterCursor = nextAfterCursor` or `beforeCursor = nextBeforeCursor`.
|
||||
*/
|
||||
hasMore?: boolean;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
+18
-8
@@ -14,18 +14,21 @@
|
||||
* notify-api's push or SMS `alert-authorization` route.
|
||||
* - Native background pool: `mintBackgroundJwtTokenPool` for daily-notification
|
||||
* plugin prefetch. Unrelated to alertSearch and to the delegated batch.
|
||||
* - alertSearch cursor ULID: server-issued record/JWT primary id (26-char
|
||||
* ULID). `afterId` means ids strictly greater than that ULID; `beforeId`
|
||||
* means strictly less. First daily run omits afterId. `beforeId` is for
|
||||
* pagination within a run. These are not auth JWTs and not signed tokens.
|
||||
* - alertSearch cursors: opaque server strings, positions between changes.
|
||||
* To get what changed: send the stored value as `afterCursor`, store each
|
||||
* response's `nextAfterCursor`, and while `hasMore` call again with
|
||||
* `afterCursor = nextAfterCursor`. Every page is complete up to it.
|
||||
* To scroll back, newest first: send `beforeCursor` (any cursor, eg. a
|
||||
* `nextAfterCursor`), then `beforeCursor = nextBeforeCursor` while `hasMore`.
|
||||
* A first run sends neither.
|
||||
* - alertSearch ULIDs (`afterId` / `beforeId`): the older bounds, ignored when
|
||||
* a cursor is sent. Not auth JWTs and not signed tokens.
|
||||
*
|
||||
* Truncation: each endorser bucket query uses a server hit-limit (typically
|
||||
* 50). That flag is not currently returned on the alertSearch JSON envelope.
|
||||
* Timeouts may add `userMessage`. A later caller must still paginate with
|
||||
* beforeId when a bucket may be incomplete.
|
||||
* See endorser-ch CHANGE/PLAN-accurate-cursors.md.
|
||||
*/
|
||||
|
||||
import type {
|
||||
AlertSearchCursor,
|
||||
AlertSearchCursorUlid,
|
||||
CombinedAlertSearchData,
|
||||
EndorserAlertSearchResponse,
|
||||
@@ -47,6 +50,10 @@ export interface AlertSearchLocationBBox {
|
||||
* GET is the planned daily method; the server also accepts POST.
|
||||
*/
|
||||
export interface AlertSearchRequestParams {
|
||||
/** Changes after this cursor, oldest first; the ID and date bounds are then ignored. */
|
||||
afterCursor?: AlertSearchCursor;
|
||||
/** Changes before this cursor (and after `afterCursor`, if given), newest first. */
|
||||
beforeCursor?: AlertSearchCursor;
|
||||
afterId?: AlertSearchCursorUlid;
|
||||
beforeId?: AlertSearchCursorUlid;
|
||||
afterDate?: string;
|
||||
@@ -59,9 +66,12 @@ export interface AlertSearchRequestParams {
|
||||
planHandleIds?: string[];
|
||||
planIds?: string[];
|
||||
handleIds?: string[];
|
||||
/** Partner only: bounding box for profilesSimilar / plansSimilar (everywhere without it). */
|
||||
similarLocation?: AlertSearchLocationBBox;
|
||||
}
|
||||
|
||||
export type {
|
||||
AlertSearchCursor,
|
||||
AlertSearchCursorUlid,
|
||||
CombinedAlertSearchData,
|
||||
EndorserAlertSearchResponse,
|
||||
|
||||
@@ -0,0 +1,52 @@
|
||||
/**
|
||||
* Web Share Target handoff (web build only).
|
||||
*
|
||||
* public/sw.js receives the POST from the manifest's share_target, stores the
|
||||
* photo in Cache Storage under these keys, and redirects to /shared-photo.
|
||||
* Keep the constants in sync with public/sw.js.
|
||||
*/
|
||||
|
||||
import { logger } from "../utils/logger";
|
||||
|
||||
const SHARE_TARGET_CACHE = "share-target";
|
||||
const SHARED_PHOTO_KEY = "/share-target/photo";
|
||||
const FILE_NAME_HEADER = "X-File-Name";
|
||||
|
||||
export interface WebSharedPhoto {
|
||||
blob: Blob;
|
||||
fileName: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* Registers public/sw.js, which handles the share target POST.
|
||||
*/
|
||||
export function registerWebShareTargetWorker(): void {
|
||||
if (!("serviceWorker" in navigator)) {
|
||||
return;
|
||||
}
|
||||
navigator.serviceWorker.register("/sw.js").catch((error) => {
|
||||
// Not fatal: only sharing into the app depends on the worker.
|
||||
logger.warn("[WebShareTarget] Service worker registration failed", error);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the photo stashed by the service worker and removes it, or null
|
||||
* when there is none (or Cache Storage is unavailable).
|
||||
*/
|
||||
export async function takeWebSharedPhoto(): Promise<WebSharedPhoto | null> {
|
||||
if (typeof caches === "undefined") {
|
||||
return null;
|
||||
}
|
||||
const cache = await caches.open(SHARE_TARGET_CACHE);
|
||||
const response = await cache.match(SHARED_PHOTO_KEY);
|
||||
if (!response) {
|
||||
return null;
|
||||
}
|
||||
const blob = await response.blob();
|
||||
const fileName = decodeURIComponent(
|
||||
response.headers.get(FILE_NAME_HEADER) || "",
|
||||
);
|
||||
await cache.delete(SHARED_PHOTO_KEY);
|
||||
return { blob, fileName };
|
||||
}
|
||||
+46
-9
@@ -1,20 +1,57 @@
|
||||
import { initializeApp } from "./main.common";
|
||||
import { logger } from "./utils/logger";
|
||||
import { registerWebShareTargetWorker } from "./libs/webShareTarget";
|
||||
|
||||
const platform = process.env.VITE_PLATFORM;
|
||||
|
||||
// PWA service worker is automatically registered by VitePWA plugin
|
||||
/**
|
||||
* Browsers withhold crypto.subtle outside secure contexts (HTTPS, localhost,
|
||||
* 127.0.0.1, [::1]), and identity creation cannot run without it. Addresses
|
||||
* like http://[::]:8000 or http://192.168.x.x would otherwise fail later with
|
||||
* a misleading "could not open its data" startup error. main.common is loaded
|
||||
* only after this check because importing the router starts navigation.
|
||||
*/
|
||||
function showInsecureContextError(): void {
|
||||
const container = document.getElementById("app");
|
||||
if (!container) {
|
||||
return;
|
||||
}
|
||||
container.innerHTML = `
|
||||
<section style="max-width: 40rem; margin: 3rem auto; padding: 0 1rem; font-family: sans-serif; line-height: 1.5;">
|
||||
<h1 style="font-size: 1.25rem; font-weight: 600;">Time Safari Cannot Start Here</h1>
|
||||
<p>This page must be opened over HTTPS or from <code>localhost</code>.</p>
|
||||
<p>The browser does not treat <code></code> as secure, so it disables the cryptography the app uses for identities.</p>
|
||||
<p>On a local server, use <code>http://localhost:PORT/</code> instead of <code>http://[::]:PORT/</code> or <code>http://0.0.0.0:PORT/</code>.</p>
|
||||
</section>`;
|
||||
const originCode = container.querySelectorAll("code")[1];
|
||||
if (originCode) {
|
||||
originCode.textContent = window.location.origin;
|
||||
}
|
||||
}
|
||||
|
||||
const app = initializeApp();
|
||||
if (!window.isSecureContext) {
|
||||
logger.error("[Web] Not a secure context; app will not start", {
|
||||
origin: window.location.origin,
|
||||
});
|
||||
showInsecureContextError();
|
||||
} else {
|
||||
import("./main.common").then(({ initializeApp }) => {
|
||||
const app = initializeApp();
|
||||
|
||||
// Note: Worker initialization is now handled by WebPlatformService
|
||||
// This ensures single-point database access and prevents double migrations
|
||||
if (platform === "web" || platform === "development") {
|
||||
// Note: Worker initialization is now handled by WebPlatformService
|
||||
// This ensures single-point database access and prevents double migrations
|
||||
if (platform === "web" || platform === "development") {
|
||||
logger.debug(
|
||||
"[Web] Database initialization will be handled by WebPlatformService",
|
||||
);
|
||||
} else {
|
||||
} else {
|
||||
logger.debug("[Web] SQL not initialized for platform", { platform });
|
||||
}
|
||||
}
|
||||
|
||||
app.mount("#app");
|
||||
app.mount("#app");
|
||||
|
||||
// Handles the manifest's share_target POST (see public/sw.js)
|
||||
if (platform === "web") {
|
||||
registerWebShareTargetWorker();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@@ -281,8 +281,6 @@ const routes: Array<RouteRecordRaw> = [
|
||||
component: () => import("../views/SharedPhotoView.vue"),
|
||||
},
|
||||
|
||||
// /share-target is also an endpoint in the service worker
|
||||
|
||||
{
|
||||
path: "/start",
|
||||
name: "start",
|
||||
|
||||
@@ -225,14 +225,4 @@ export interface PlatformService {
|
||||
* @throws if the backup copy fails (the original is never deleted without one)
|
||||
*/
|
||||
resetDatabase?(): Promise<string | undefined>;
|
||||
|
||||
// --- PWA/Web-only methods (optional, only implemented on web) ---
|
||||
/**
|
||||
* Registers the service worker for PWA support (web only)
|
||||
*/
|
||||
registerServiceWorker?(): void;
|
||||
|
||||
/**
|
||||
* Returns true if PWA is enabled (web only)
|
||||
*/
|
||||
}
|
||||
|
||||
@@ -1546,9 +1546,6 @@ export class CapacitorPlatformService
|
||||
return false;
|
||||
}
|
||||
|
||||
// --- PWA/Web-only methods (no-op for Capacitor) ---
|
||||
public registerServiceWorker(): void {}
|
||||
|
||||
// Database utility methods - inherited from BaseDatabaseService
|
||||
// generateInsertStatement, updateDefaultSettings, updateActiveDid,
|
||||
// getActiveIdentity, insertNewDidIntoSettings, updateDidSpecificSettings,
|
||||
|
||||
@@ -163,7 +163,4 @@ export class ElectronPlatformService extends CapacitorPlatformService {
|
||||
isWeb(): boolean {
|
||||
return false;
|
||||
}
|
||||
|
||||
// --- PWA/Web-only methods (no-op for Electron) ---
|
||||
public registerServiceWorker(): void {}
|
||||
}
|
||||
|
||||
@@ -136,6 +136,7 @@ import {
|
||||
} from "../constants/app";
|
||||
import { accessToken } from "../libs/crypto";
|
||||
import { base64ToBlob, SHARED_PHOTO_BASE64_KEY } from "../libs/util";
|
||||
import { takeWebSharedPhoto } from "../libs/webShareTarget";
|
||||
import { logger } from "../utils/logger";
|
||||
|
||||
import { PlatformServiceMixin } from "@/utils/PlatformServiceMixin";
|
||||
@@ -221,6 +222,17 @@ export default class SharedPhotoView extends Vue {
|
||||
const activeIdentity = await (this as any).$getActiveIdentity();
|
||||
this.activeDid = activeIdentity.activeDid;
|
||||
|
||||
// Web Share Target: public/sw.js stashes the photo in Cache Storage
|
||||
if (this.$route.query["source"] === "share-target") {
|
||||
const shared = await takeWebSharedPhoto();
|
||||
if (shared) {
|
||||
this.imageBlob = shared.blob;
|
||||
this.imageFileName = shared.fileName;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// Native share: main.capacitor.ts stores the photo in the temp table
|
||||
const temp = await this.$getTemp(SHARED_PHOTO_BASE64_KEY);
|
||||
const imageB64 = temp?.blobB64 as string;
|
||||
if (temp) {
|
||||
|
||||
@@ -1,55 +0,0 @@
|
||||
import * as path from "path";
|
||||
import { promises as fs } from "fs";
|
||||
import { fileURLToPath } from "url";
|
||||
|
||||
export async function loadAppConfig() {
|
||||
const packageJson = await loadPackageJson();
|
||||
const appName = process.env.TIME_SAFARI_APP_TITLE || packageJson.name;
|
||||
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
||||
|
||||
return {
|
||||
pwaConfig: {
|
||||
manifest: {
|
||||
name: appName,
|
||||
short_name: appName,
|
||||
icons: [
|
||||
{
|
||||
src: "./img/icons/android-chrome-192x192.png",
|
||||
sizes: "192x192",
|
||||
type: "image/png",
|
||||
},
|
||||
{
|
||||
src: "./img/icons/android-chrome-512x512.png",
|
||||
sizes: "512x512",
|
||||
type: "image/png",
|
||||
},
|
||||
{
|
||||
src: "./img/icons/android-chrome-maskable-192x192.png",
|
||||
sizes: "192x192",
|
||||
type: "image/png",
|
||||
purpose: "maskable",
|
||||
},
|
||||
{
|
||||
src: "./img/icons/android-chrome-maskable-512x512.png",
|
||||
sizes: "512x512",
|
||||
type: "image/png",
|
||||
purpose: "maskable",
|
||||
},
|
||||
],
|
||||
},
|
||||
},
|
||||
aliasConfig: {
|
||||
"@": path.resolve(path.dirname(__dirname), "src"),
|
||||
buffer: path.resolve(path.dirname(__dirname), "node_modules", "buffer"),
|
||||
"dexie-export-import/dist/import":
|
||||
"dexie-export-import/dist/import/index.js",
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
async function loadPackageJson() {
|
||||
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
||||
const packageJsonPath = path.resolve(path.dirname(__dirname), "package.json");
|
||||
const packageJsonData = await fs.readFile(packageJsonPath, "utf-8");
|
||||
return JSON.parse(packageJsonData);
|
||||
}
|
||||
-1051
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -24,7 +24,7 @@
|
||||
*
|
||||
* Related Files:
|
||||
* - Frontend invite handling: src/libs/endorserServer.ts
|
||||
* - JWT creation: sw_scripts/safari-notifications.js
|
||||
* - JWT creation: src/libs/crypto/vc/index.ts
|
||||
*
|
||||
* @see Documentation on invitation flows in usage-guide.md
|
||||
* @requires @playwright/test
|
||||
|
||||
@@ -58,7 +58,7 @@
|
||||
*
|
||||
* Related Files:
|
||||
* - Project utilities: ./testUtils
|
||||
* - JWT handling: sw_scripts/safari-notifications.js
|
||||
* - JWT handling: src/libs/crypto/vc/index.ts
|
||||
* - Project view: src/views/ProjectView.vue
|
||||
*
|
||||
* @see Documentation in usage-guide.md for project creation workflows
|
||||
|
||||
@@ -63,7 +63,7 @@
|
||||
*
|
||||
* Related Files:
|
||||
* - Gift recording view: src/views/RecordGiftView.vue
|
||||
* - JWT creation: sw_scripts/safari-notifications.js
|
||||
* - JWT creation: src/libs/crypto/vc/index.ts
|
||||
* - Endorser API: src/libs/endorserServer.ts
|
||||
*
|
||||
* @see Documentation in usage-guide.md for gift recording workflows
|
||||
|
||||
@@ -60,7 +60,7 @@
|
||||
*
|
||||
* Related Files:
|
||||
* - Gift recording view: src/views/RecordGiftView.vue
|
||||
* - JWT creation: sw_scripts/safari-notifications.js
|
||||
* - JWT creation: src/libs/crypto/vc/index.ts
|
||||
* - Endorser API: src/libs/endorserServer.ts
|
||||
* - Test utilities: ./testUtils.ts
|
||||
*
|
||||
|
||||
+1
-10
@@ -15,9 +15,7 @@ export async function createBuildConfig(platform: string): Promise<UserConfig> {
|
||||
const appConfig = await loadAppConfig();
|
||||
const isCapacitor = platform === "capacitor";
|
||||
const isElectron = platform === "electron";
|
||||
const isNative = isCapacitor || isElectron;
|
||||
|
||||
// Set platform - PWA is always enabled for web platforms
|
||||
process.env.VITE_PLATFORM = platform;
|
||||
|
||||
// Environment variables are loaded from .env files via dotenv.config() above
|
||||
@@ -74,7 +72,6 @@ export async function createBuildConfig(platform: string): Promise<UserConfig> {
|
||||
'process.env.NODE_ENV': JSON.stringify(process.env.NODE_ENV),
|
||||
'process.env.VITE_PLATFORM': JSON.stringify(platform),
|
||||
'process.env.VITE_LOG_LEVEL': JSON.stringify(process.env.VITE_LOG_LEVEL),
|
||||
// PWA is always enabled for web platforms
|
||||
__dirname: JSON.stringify(process.cwd()),
|
||||
__IS_MOBILE__: JSON.stringify(isCapacitor),
|
||||
__IS_ELECTRON__: JSON.stringify(isElectron),
|
||||
@@ -106,13 +103,7 @@ export async function createBuildConfig(platform: string): Promise<UserConfig> {
|
||||
'absurd-sql',
|
||||
'absurd-sql/dist/indexeddb-main-thread',
|
||||
'absurd-sql/dist/indexeddb-backend'
|
||||
],
|
||||
exclude: isNative ? [
|
||||
'register-service-worker',
|
||||
'workbox-window',
|
||||
'web-push',
|
||||
'serviceworker-webpack-plugin'
|
||||
] : []
|
||||
]
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@@ -20,7 +20,6 @@
|
||||
*
|
||||
* Environment Variables:
|
||||
* - VITE_PLATFORM: Set to "electron"
|
||||
* - PWA: Disabled for desktop (via build exclusion)
|
||||
*/
|
||||
|
||||
import { defineConfig } from "vite";
|
||||
|
||||
@@ -24,7 +24,6 @@ export async function createOptimizedBuildConfig(mode: string): Promise<UserConf
|
||||
const isElectron = mode === "electron";
|
||||
const isNative = isCapacitor || isElectron;
|
||||
|
||||
// Set platform - PWA is always enabled for web platforms
|
||||
process.env.VITE_PLATFORM = mode;
|
||||
|
||||
return {
|
||||
@@ -120,13 +119,7 @@ export async function createOptimizedBuildConfig(mode: string): Promise<UserConf
|
||||
'vue-router',
|
||||
'pinia',
|
||||
'vue-facing-decorator'
|
||||
],
|
||||
exclude: isNative ? [
|
||||
'register-service-worker',
|
||||
'workbox-window',
|
||||
'web-push',
|
||||
'serviceworker-webpack-plugin'
|
||||
] : []
|
||||
]
|
||||
},
|
||||
// Enhanced performance optimizations
|
||||
esbuild: {
|
||||
|
||||
@@ -1,110 +1,16 @@
|
||||
import * as path from "path";
|
||||
import { fileURLToPath } from 'url';
|
||||
import { promises as fs } from "fs";
|
||||
|
||||
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
||||
|
||||
async function loadPackageJson() {
|
||||
const packageJsonPath = path.join(__dirname, 'package.json');
|
||||
const packageJsonContent = await fs.readFile(packageJsonPath, 'utf-8');
|
||||
return JSON.parse(packageJsonContent);
|
||||
}
|
||||
|
||||
interface ManifestIcon {
|
||||
src: string;
|
||||
sizes: string;
|
||||
type: string;
|
||||
purpose?: string;
|
||||
}
|
||||
|
||||
interface ShareTarget {
|
||||
action: string;
|
||||
method: "POST";
|
||||
enctype: string;
|
||||
params: {
|
||||
files: Array<{
|
||||
name: string;
|
||||
accept: string[];
|
||||
}>;
|
||||
};
|
||||
}
|
||||
|
||||
interface PWAConfig {
|
||||
registerType: string;
|
||||
strategies: string;
|
||||
srcDir: string;
|
||||
filename: string;
|
||||
manifest: {
|
||||
name: string;
|
||||
short_name: string;
|
||||
theme_color: string;
|
||||
background_color: string;
|
||||
icons: ManifestIcon[];
|
||||
share_target: ShareTarget;
|
||||
};
|
||||
}
|
||||
|
||||
interface AppConfig {
|
||||
pwaConfig: PWAConfig;
|
||||
aliasConfig: {
|
||||
[key: string]: string;
|
||||
};
|
||||
}
|
||||
|
||||
export async function loadAppConfig(): Promise<AppConfig> {
|
||||
const packageJson = await loadPackageJson();
|
||||
const appName = process.env.TIME_SAFARI_APP_TITLE || packageJson.name;
|
||||
|
||||
return {
|
||||
pwaConfig: {
|
||||
registerType: "autoUpdate",
|
||||
strategies: "injectManifest",
|
||||
srcDir: ".",
|
||||
filename: "sw_scripts-combined.js",
|
||||
manifest: {
|
||||
name: appName,
|
||||
short_name: appName,
|
||||
theme_color: "#4a90e2",
|
||||
background_color: "#ffffff",
|
||||
icons: [
|
||||
{
|
||||
src: "./img/icons/android-chrome-192x192.png",
|
||||
sizes: "192x192",
|
||||
type: "image/png",
|
||||
},
|
||||
{
|
||||
src: "./img/icons/android-chrome-512x512.png",
|
||||
sizes: "512x512",
|
||||
type: "image/png",
|
||||
},
|
||||
{
|
||||
src: "./img/icons/android-chrome-maskable-192x192.png",
|
||||
sizes: "192x192",
|
||||
type: "image/png",
|
||||
purpose: "maskable",
|
||||
},
|
||||
{
|
||||
src: "./img/icons/android-chrome-maskable-512x512.png",
|
||||
sizes: "512x512",
|
||||
type: "image/png",
|
||||
purpose: "maskable",
|
||||
},
|
||||
],
|
||||
share_target: {
|
||||
action: "/share-target",
|
||||
method: "POST",
|
||||
enctype: "multipart/form-data",
|
||||
params: {
|
||||
files: [
|
||||
{
|
||||
name: "photo",
|
||||
accept: ["image/*"],
|
||||
},
|
||||
],
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
aliasConfig: {
|
||||
"@": path.resolve(__dirname, "src"),
|
||||
buffer: path.resolve(__dirname, "node_modules", "buffer"),
|
||||
|
||||
Reference in New Issue
Block a user