8000 GitHub - tinijs/pwa: The PWA module for TiniJS apps.
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content
This repository was archived by the owner on Apr 11, 2024. It is now read-only.

tinijs/pwa

Repository files navigation

TiniJS PWA

Important

This previously experiment is wrapped up, moving forward the development will happen at https://github.com/tinijs/tinijs/tree/main/packages/pwa.

If you want to use the experimental version still, please use the version 0.16.0.

The PWA module for TiniJS apps.

It uses workbox-window under the hood.

Install

To manually install the module: npm i @tinijs/pwa@0.16.0

It is recommended to download the Skeleton for a ready-to-use structured project.

Or, install and setup a complete PWA app via the @tinijs/cli CLI tool:

  • Install the CLI: npm i @tinijs/cli@0.16.0
  • Add PWA capability: npx tini pwa init

For more, please visit: https://tinijs.dev

Usage

  • Expose an API endpoint-ish in sw.js
addEventListener('message', event => {
  if (event.data.type === 'endpoint-1') {
    event.ports[0].postMessage({ data: 'a payload' });
  }
});
  • Communicate with the Service Worker
import {UseWorkbox, Workbox} from '@tinijs/pwa';

@Page({
  name: 'app-page-home',
})
export class AppPageHome extends TiniComponent {
  @UseWorkbox() workbox!: Workbox;

  onReady() {
    this.workbox
      .messageSW({type: 'endpoint-1'})
      .then(value => {
        // do something with the value returned from the SW
      });
  }
}

API

// TODO

Developement

  • Create a home for TiniJS: mkdir TiniJS && cd TiniJS
  • Fork the repo
  • Install dependencies: cd pwa && npm i
  • Make changes & preview locally: npm run build && npm pack
  • Push changes & create a PR 👌

License

@tinijs/pwa is released under the MIT license.

About

The PWA module for TiniJS apps.

Resources

License

Stars

Watchers

Forks

Packages

No packages published
0