How hwangjungeon/pwa-install works
Project type and purpose
• This is a front-end library published to npm (“@khmyznikov/pwa-install”) that delivers a reusable Web Component for installing Progressive Web Apps (PWAs) across platforms. It offers a customizable dialog/gallery, localization support, and builds multiple bundle formats (ES modules, UMD, React).
File structure
• Top-level:
• src/ – TypeScript source organized into subpackages:
– index.ts (entry-point Web Component)
– fallback/ (React fallback component)
– gallery/ (gallery UI)
– localization/ (runtime locale selection + locale data)
– templates/ (device-specific templates & styles)
– types/ (global/type declarations)
– utils.ts (shared helpers)
• i18n/ + lit-localize.json – raw XLF translation files & config
• webpack/ – multiple configs (common, dev, prod, module, react, UMD, service-worker stub)
• custom-elements-*.mjs/json – manifest generation for custom elements
• dist/ – build outputs:
– es/ (ESM bundles & maps)
– umd/ (UMD bundles & maps)
– pwa-install.bundle.js (standalone bundle)
– pwa-install.react.js (React wrapper)
– types/ (declaration files)
• docs/ – static demo site & service worker, preview assets
• package.json, tsconfig.json, .gitignore, CI configs, etc.
Key insights from the README
• Core feature: <pwa-install> custom element with attributes, events, methods
• Extensibility: “manual” display, externalPromptEvent for async mode
• Localization: auto language switching, XLF sources in i18n/
• Build targets: modern ESM, UMD for CDN, React polyfill wrapper
• Demo site at khmyznikov.com/pwa-install
Essential details
• Src subfolder as its own component
• Webpack configs as stages (dev vs. prod vs. UMD vs. React)
• Custom-elements-manifest step for automated metadata
• Localization workflow: XLF → compiled locale TS → runtime locale lookup
• Style pipelines (SCSS templates → CSS in bundles)