dsh-pwa-plugin
其他 活跃维护

dsh-pwa-plugin

RaulLazaro/dsh-pwa-plugin

轻量级PWA插件,可快速为Web应用添加离线访问、桌面端快捷安装能力,无需复杂配置即可让Web应用获得接近原生的使用体验。

1
Stars 标星
0
Forks 分支
1
Watchers 关注
0
Open Issues
JavaScript
主要语言
MIT
开源协议
50 KB
仓库大小
19 天前
最后推送
一键安装扩展 / 插件指令
dsh plugin --profile web add github:RaulLazaro/dsh-pwa-plugin
git clone https://github.com/RaulLazaro/dsh-pwa-plugin.git
git clone git@github.com:RaulLazaro/dsh-pwa-plugin.git
README.md main

DSH PWA Plugin

PWA plugin for DeepSeek Harness that adds offline support and install-as-app capability.

Features

  • Service Worker with smart caching strategy
  • PWA Manifest with icons and metadata
  • Automatic updates — silently activates new versions
  • Offline-first for static assets
  • Custom icons (gradient background with DSH branding)

Installation

1. Add as a dependency

In your DSH web profile's package.json:

{
  "dependencies": {
    "dsh-pwa-plugin": "file:~/workspace/dsh-pwa-plugin"
  }
}

2. Register the plugin

In your profile's cordis.patch.yml:

- insert:
    - id: dsh-pwa
      name: 'dsh-pwa-plugin'

3. Restart DSH

dsh web

Generate PNG Icons

The plugin ships with SVG icons. To generate PNG icons (required for some browsers):

cd dsh-pwa-plugin
npm install sharp --save-dev
node scripts/generate-icons.js

How It Works

  1. The host plugin serves /sw.js, /manifest.webmanifest, and icon files
  2. It injects a service worker registration script into the HTML
  3. The service worker caches static assets for offline use
  4. The manifest enables installing the app as a PWA
  5. Updates are detected automatically and silently activated

Caching Strategy

Resource Type Strategy Description
HTML Network-first Always tries to fetch the latest version
JS/CSS/Fonts/Images Cache-first Serves from cache if available
API calls Not cached Always goes to the network

Limitations

  • Requires HTTPS to work (except localhost)
  • Service worker cannot cache API calls
  • Updates require a page reload (automatic after detection)

Project Structure

dsh-pwa-plugin/
├── src/
│   ├── host/
│   │   └── index.js          # Host plugin (Node.js)
│   └── sw.js                 # Service Worker
├── public/
│   ├── manifest.webmanifest  # PWA Manifest
│   ├── favicon.svg           # Favicon
│   └── icons/                # App icons (SVG + PNG)
├── scripts/
│   ├── generate-icons.js     # Icon generator
│   ├── install.js            # Verification script
│   └── verify.js             # Verification
├── example/
│   ├── cordis.patch.yml      # Configuration example
│   └── package.json          # Profile example
├── cordis.patch.yml          # Plugin registration
├── LICENSE
└── package.json

License

MIT