stellar-drive 1.2.28 → 1.2.29

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -52,7 +52,7 @@ Building offline-first sync is notoriously difficult. stellar-drive handles the
52
52
  - **Diagnostics** -- Comprehensive runtime diagnostics covering sync, queue, realtime, conflicts, egress, and network state.
53
53
  - **Debug utilities** -- Opt-in debug logging and `window` debug utilities for browser console inspection during development.
54
54
  - **SvelteKit integration** (optional) -- Layout helpers, server handlers, email confirmation, service worker lifecycle, and auth hydration.
55
- - **PWA scaffolding CLI** -- `stellar-drive install pwa` generates a complete SvelteKit PWA project (34+ files) with an interactive walkthrough.
55
+ - **PWA scaffolding CLI** -- `stellar-drive install pwa` generates a fully wired SvelteKit PWA skeleton (51 files) with auth, PIN gate, device verification, profile page, demo mode, adaptive navbar, and PWA plumbing pre-connected.
56
56
 
57
57
  ### Use cases
58
58
 
@@ -402,31 +402,156 @@ See [API Reference -- Vite Plugin](./API_REFERENCE.md#vite-plugin-stellarpwa) fo
402
402
 
403
403
  ### Install PWA
404
404
 
405
- Scaffold a complete offline-first SvelteKit PWA project with an interactive walkthrough:
405
+ Scaffold a complete offline-first SvelteKit PWA skeleton with an interactive walkthrough:
406
406
 
407
407
  ```bash
408
408
  npx stellar-drive install pwa
409
409
  ```
410
410
 
411
- The wizard prompts for:
411
+ Run this in an empty directory. The wizard collects four inputs, installs dependencies, and writes 51 files — a fully wired skeleton that passes `npm run validate` and `npm run cleanup` out of the box.
412
+
413
+ #### Wizard prompts
412
414
 
413
415
  | Prompt | Required | Description |
414
416
  |--------|----------|-------------|
415
- | App Name | Yes | Full app name (e.g., "Stellar Planner") |
416
- | Short Name | Yes | Short name for PWA home screen (under 12 chars) |
417
- | Prefix | Yes | Lowercase key for localStorage, caches, SW, and Supabase table names (auto-suggested from name) |
418
- | Description | No | App description (default: "A self-hosted offline-first PWA") |
419
-
420
- Generates **34+ files** for a production-ready SvelteKit 2 + Svelte 5 project:
421
-
422
- - **Config files (8):** `vite.config.ts`, `tsconfig.json`, `svelte.config.js`, `eslint.config.js`, `.prettierrc`, `.prettierignore`, `knip.json`, `.gitignore`
423
- - **Documentation (3):** `README.md`, `ARCHITECTURE.md`, `FRAMEWORKS.md`
424
- - **Static assets (13):** `manifest.json`, `offline.html`, placeholder SVG icons, email template placeholders
425
- - **Database (1):** `supabase-schema.sql` with helper functions, example tables, and `trusted_devices` table
426
- - **Source files (2):** `src/app.html` (PWA-ready with iOS meta tags, SW registration), `src/app.d.ts`
427
- - **Route files (16):** Root layout, login, setup, profile, protected area, API endpoints, catch-all redirect
428
- - **Library (1):** `src/lib/types.ts` with re-exports and app-specific type stubs
429
- - **Git hooks (1):** `.husky/pre-commit` with lint + format + validate
417
+ | App Name | Yes | Full app name (e.g., "Stellar Planner"). Used in page titles, manifest, and email templates. |
418
+ | Short Name | Yes | Condensed name for the PWA home-screen icon (12 chars max). |
419
+ | Prefix | Yes | Lowercase key used for localStorage, caches, the service worker scope, and Supabase table prefixes. Auto-suggested from the app name. |
420
+ | Description | No | One-line description shown in the manifest (default: `"A self-hosted offline-first PWA"`). |
421
+
422
+ #### What gets generated 51 files
423
+
424
+ **Project config (10)**
425
+
426
+ | File | Purpose |
427
+ |------|---------|
428
+ | `package.json` | All deps and scripts pre-configured: `dev`, `build`, `validate`, `cleanup` |
429
+ | `vite.config.ts` | `stellarPWA` plugin wired with your prefix; schema generation enabled |
430
+ | `tsconfig.json` | Extends SvelteKit's generated config with strict mode |
431
+ | `svelte.config.js` | `adapter-auto` + `vitePreprocess` |
432
+ | `eslint.config.js` | TypeScript-aware ESLint with Svelte plugin |
433
+ | `.prettierrc` | Consistent formatting rules |
434
+ | `.prettierignore` | Ignores build artifacts and generated files |
435
+ | `knip.json` | Dead-code detection configured for SvelteKit |
436
+ | `.gitignore` | Node, SvelteKit, and environment file ignores |
437
+ | `.env.example` | Template for `PUBLIC_SUPABASE_URL` and `PUBLIC_SUPABASE_PUBLISHABLE_DEFAULT_KEY` |
438
+
439
+ **Documentation (3)**
440
+
441
+ | File | Purpose |
442
+ |------|---------|
443
+ | `README.md` | Project-level readme linking architecture and framework docs |
444
+ | `ARCHITECTURE.md` | Directory layout, data flow, and module responsibilities |
445
+ | `FRAMEWORKS.md` | Technology choices, rationale, and Svelte 5 rune patterns |
446
+
447
+ **Git hooks (1)**
448
+
449
+ | File | Purpose |
450
+ |------|---------|
451
+ | `.husky/pre-commit` | Runs `npm run cleanup && npm run validate && git add -u` before every commit |
452
+
453
+ **Static assets (12)**
454
+
455
+ | File | Purpose |
456
+ |------|---------|
457
+ | `static/manifest.json` | PWA manifest with all icon sizes and display settings |
458
+ | `static/offline.html` | Offline fallback shown by the service worker |
459
+ | `static/icons/app.svg` | Green primary app icon (letter placeholder) |
460
+ | `static/icons/app-dark.svg` | Dark variant for light-mode context |
461
+ | `static/icons/maskable.svg` | Maskable icon for Android home screens |
462
+ | `static/icons/favicon.svg` | Browser tab favicon |
463
+ | `static/icons/monochrome.svg` | Monochrome icon for notification badges |
464
+ | `static/icons/splash.svg` | Splash screen icon |
465
+ | `static/icons/apple-touch.svg` | iOS Add-to-Home-Screen icon |
466
+ | `static/signup-email.html` | Signup confirmation email template |
467
+ | `static/change-email.html` | Email change confirmation template |
468
+ | `static/device-verification-email.html` | Device trust OTP email template |
469
+
470
+ **App core (2)**
471
+
472
+ | File | Purpose |
473
+ |------|---------|
474
+ | `src/app.html` | PWA shell: iOS meta tags, theme color, service-worker registration script |
475
+ | `src/app.d.ts` | SvelteKit ambient types (`App.Locals`, `App.PageData`) |
476
+
477
+ **Routes (16)**
478
+
479
+ | Route | File(s) | What it does |
480
+ |-------|---------|-------------|
481
+ | Root layout | `+layout.ts`, `+layout.svelte` | Engine bootstrap, auth resolution, adaptive navbar (top on desktop / bottom on mobile), sync status, offline toast, demo banner, PWA update prompt |
482
+ | Home | `+page.svelte` | Protected placeholder — add your app content here |
483
+ | Error | `+error.svelte` | SvelteKit error page with retry and home link |
484
+ | Login | `login/+page.svelte` | PIN-based login, device linking, device verification email flow, BroadcastChannel handshake, persistent lockout countdown |
485
+ | Email confirm | `confirm/+page.svelte` | Verifies Supabase email OTP, broadcasts `AUTH_CONFIRMED` to the login tab, then closes or redirects |
486
+ | Setup (initial) | `setup/+page.ts`, `setup/+page.svelte` | Multi-step wizard: Supabase credentials → validate → deploy schema → create account. Guarded by `resolveSetupAccess()` — only accessible before a user account exists. |
487
+ | Reconfigure | `setup/Reconfigure.svelte` | Single-page re-setup form for changing credentials after initial setup. Accessible from the profile settings. |
488
+ | Profile | `profile/+page.svelte` | Full settings hub: display name, email change (with re-verification), PIN/code change, trusted devices list with revocation, debug mode toggle, diagnostics dashboard (sync, realtime, queue, egress, errors), reset database |
489
+ | Demo | `demo/+page.svelte` | Toggle demo mode on/off with explanation and confirmation; triggers full page reload |
490
+ | Privacy policy | `policy/+page.svelte` | Static placeholder — replace with your actual policy |
491
+ | Config API | `api/config/+server.ts` | Returns `PUBLIC_SUPABASE_URL` and `PUBLIC_SUPABASE_PUBLISHABLE_DEFAULT_KEY` to the client |
492
+ | Setup deploy | `api/setup/deploy/+server.ts` | Writes `.env` during initial setup, creates Supabase auth user + pushes schema SQL |
493
+ | Setup validate | `api/setup/validate/+server.ts` | Validates Supabase credentials without writing anything |
494
+ | Catch-all | `[...catchall]/+page.server.ts` | 302 redirect to `/` for unknown URLs |
495
+
496
+ **Library (7)**
497
+
498
+ | File | Purpose |
499
+ |------|---------|
500
+ | `src/lib/routes.ts` | `ROUTES` constants for all app paths — single source of truth |
501
+ | `src/lib/schema.ts` | Example schema with two tables (`items`, `settings`); replace with your domain schema |
502
+ | `src/lib/types.generated.ts` | Placeholder for Vite-plugin-generated TypeScript interfaces |
503
+ | `src/lib/types.ts` | App-specific type stubs and re-exports |
504
+ | `src/lib/components/UpdatePrompt.svelte` | PWA update prompt that appears when a new service worker is waiting |
505
+ | `src/lib/demo/mockData.ts` | Mock data seeded into the demo database on each page load |
506
+ | `src/lib/demo/config.ts` | Demo configuration wired into `initEngine()` |
507
+
508
+ #### What's pre-wired
509
+
510
+ The skeleton is not just file stubs — the entire auth and engine lifecycle is already connected:
511
+
512
+ - **Engine bootstrap** — `initEngine()` in `+layout.ts` with your prefix, name, and demo config; `initConfig()` pulls Supabase credentials from `/api/config` at runtime
513
+ - **Auth resolution** — `resolveRootLayout()` in the layout load determines `authMode` (`'none'` | `'offline'` | `'demo'`) and redirects unauthenticated users to login
514
+ - **Single-user PIN gate** — login page handles first-time setup detection, `unlockSingleUser`, `setupSingleUser` inside the login flow, device linking, and persistent lockout
515
+ - **Device verification** — email OTP flow fully wired through login → confirm → BroadcastChannel → login tab reaction
516
+ - **Setup wizard** — multi-step Supabase credential entry, live validation, schema deploy, and user account creation; guarded so it only appears before initial setup
517
+ - **Profile page** — change name, email (with re-verification cooldown and resend), PIN, revoke trusted devices, toggle debug mode, full diagnostics panel, and reset database
518
+ - **Demo mode** — sandboxed IndexedDB, zero Supabase calls, mock profile, seeded data; toggle from `/demo` or profile settings
519
+ - **Adaptive navbar** — top bar on ≥768px, fixed bottom bar on mobile; active state driven by SvelteKit's `page` store; Dynamic Island safe area padding
520
+ - **PWA plumbing** — service worker via `stellarPWA` Vite plugin, Web App Manifest, offline fallback, `UpdatePrompt` for background updates, iOS splash/touch icons
521
+ - **Email templates** — Supabase-compatible HTML templates for signup, email change, and device verification; drop-in replacements for the default Supabase emails
522
+
523
+ #### Design theme
524
+
525
+ The skeleton uses a minimal green theme derived from the email templates:
526
+
527
+ | Token | Value | Use |
528
+ |-------|-------|-----|
529
+ | Primary | `#6B9E6B` | Buttons, active nav, focus rings, borders |
530
+ | Card background | `#0f0f1e` | Modal and card surfaces |
531
+ | Page background | `#111116` | App background |
532
+ | Card border | `#3d5a3d` | Card outlines |
533
+ | Text | `#f0f0ff` | Primary text |
534
+ | Text secondary | `#c8c8e0` | Descriptions, labels |
535
+ | Text muted | `#7878a0` | Hints, timestamps |
536
+
537
+ All colors are CSS custom properties — override `:root` in your app's global CSS to adopt any theme.
538
+
539
+ #### Building on the skeleton
540
+
541
+ After scaffolding, the typical customisation path is:
542
+
543
+ 1. **Define your schema** — edit `src/lib/schema.ts` to replace the example tables with your domain entities; the Vite plugin auto-generates TypeScript interfaces and pushes Supabase migrations on `npm run dev`
544
+ 2. **Add app pages** — create new routes under `src/routes/`; import stores and CRUD helpers from `stellar-drive`
545
+ 3. **Wire stores** — in `+page.svelte`, create collection/detail stores with `createCollectionStore` / `createDetailStore` and refresh them with `onSyncComplete`
546
+ 4. **Customise the navbar** — the root layout's navbar lists only the home and profile links; add your app's sections to the `navItems` array in `+layout.svelte`
547
+ 5. **Replace placeholder content** — swap the privacy policy text, update icon SVGs with your actual branding, and fill in the demo mock data with representative records
548
+ 6. **Set environment variables** — copy `.env.example` to `.env` and add your Supabase project URL and publishable key; run the setup wizard on first launch to push the schema
549
+
550
+ #### Prerequisites
551
+
552
+ - Node.js ≥ 18
553
+ - A [Supabase](https://supabase.com) project (free tier is sufficient)
554
+ - `PUBLIC_SUPABASE_URL` and `PUBLIC_SUPABASE_PUBLISHABLE_DEFAULT_KEY` from the Supabase dashboard (Settings → API)
430
555
 
431
556
  ---
432
557
 
@@ -450,7 +575,8 @@ Import only what you need:
450
575
  | `stellar-drive/config` | Runtime config management (`initConfig`, `getConfig`, `setConfig`, `getDexieTableFor`) |
451
576
  | `stellar-drive/vite` | Vite plugin (`stellarPWA`) for service worker builds, asset manifests, and schema auto-generation |
452
577
  | `stellar-drive/kit` | SvelteKit helpers: server route factories, layout loaders, email confirmation, SW lifecycle, auth hydration |
453
- | `stellar-drive/components/*` | Svelte components: `SyncStatus`, `DeferredChangesBanner`, `DemoBanner`, `DemoBlockedMessage` |
578
+ | `stellar-drive/toast` | Toast notifications: `addToast`, `dismissToast`, `toastStore`, `ToastVariant` type |
579
+ | `stellar-drive/components/*` | Svelte components: `SyncStatus`, `DeferredChangesBanner`, `DemoBanner`, `DemoBlockedMessage`, `OfflineToast`, `GlobalToast` |
454
580
 
455
581
  ### Key categories at a glance
456
582
 
@@ -1 +1 @@
1
- {"version":3,"file":"install-pwa.d.ts","sourceRoot":"","sources":["../../src/bin/install-pwa.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AAggNH;;;;;;;;;;;;;;GAcG;AACH,wBAAsB,GAAG,IAAI,OAAO,CAAC,IAAI,CAAC,CA4KzC"}
1
+ {"version":3,"file":"install-pwa.d.ts","sourceRoot":"","sources":["../../src/bin/install-pwa.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AAixRH;;;;;;;;;;;;;;GAcG;AACH,wBAAsB,GAAG,IAAI,OAAO,CAAC,IAAI,CAAC,CAgLzC"}