managarten/packages/shared-pwa/src/index.ts
Till JS 8a991f7c39 feat(articles): M7 share-target + bookmarklet — save from anywhere
@mana/shared-pwa gains PWAShareTarget + PWAShareTargetParams types
plus ManifestConfig.share_target pass-through. createPWAConfig now
accepts an optional `shareTarget` and threads it into the generated
manifest. Other apps keep working unchanged — the field is omitted
unless set.

Web app wiring:
 - vite.config.ts passes shareTarget: { action: '/articles/add',
   method: 'GET', params: { title, text, url } } so the installed PWA
   shows up as a destination in the Android / Chromium share sheet.
 - AddUrlForm reads ?url / ?text / ?title in onMount; falls back to
   the first URL-shaped token in ?text because some senders (Chrome
   Android, WhatsApp) put the shared link there instead of ?url. When
   a URL is pre-filled the Readability preview auto-triggers, so the
   user just hits "In Leseliste speichern" to confirm.
 - New /articles/settings route hosts the bookmarklet (drag-to-
   bookmarks-bar button + copy-to-clipboard + expandable snippet
   viewer) and a short Share-Target explainer with an iOS-Safari
   caveat. Linked from the ListView via a new gear button next to
   "+ Neu speichern".

Bookmarklet form (origin-prefixed so it works across tenants):
  javascript:void(window.open('${origin}/articles/add?url='+…))

Not in scope (plan marked optional): _pendingUrls offline queue.
Share without internet shows the existing error + retry state today;
can slot in as M7b if users hit it.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-04-21 19:03:33 +02:00

55 lines
1.2 KiB
TypeScript

/**
* @mana/shared-pwa
*
* Unified PWA configuration for all Mana SvelteKit apps.
* Provides factory functions, presets, and defaults for consistent PWA setup.
*
* @example
* ```ts
* import { createPWAConfig } from '@mana/shared-pwa';
* import { SvelteKitPWA } from '@vite-pwa/sveltekit';
*
* export default defineConfig({
* plugins: [
* sveltekit(),
* SvelteKitPWA(createPWAConfig({
* name: 'My App',
* shortName: 'MyApp',
* description: 'My awesome app',
* themeColor: '#3b82f6',
* })),
* ],
* });
* ```
*/
// Main factory functions
export { createPWAConfig, createOfflineFirstPWAConfig } from './config.js';
// Presets and cache strategies
export { getPresetRuntimeCaching, cacheStrategies } from './presets.js';
// Default values
export {
DEFAULT_BACKGROUND_COLOR,
DEFAULT_CATEGORIES,
DEFAULT_INCLUDE_ASSETS,
DEFAULT_GLOB_PATTERNS,
DEFAULT_GLOB_IGNORES,
DEFAULT_NAVIGATE_FALLBACK_DENYLIST,
DEFAULT_ICONS,
APPLE_TOUCH_ICON,
} from './defaults.js';
// Types
export type {
PWAConfigOptions,
PWAConfig,
PWAShortcut,
PWAShareTarget,
PWAShareTargetParams,
WorkboxPreset,
ManifestConfig,
ManifestIcon,
WorkboxConfig,
} from './types.js';