• Stars
    star
    183
  • Rank 210,154 (Top 5 %)
  • Language
    TypeScript
  • License
    MIT License
  • Created almost 3 years ago
  • Updated over 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

🚀 A progressive framework helps you to build PWA app easier !!!

Introduction

📖 🇨🇳 中文文档

📖 🇬🇧 Document for English

A framework dedicated to making it easier for you to build enterprise-grade PWA applications.

Features

  • 🧳 Out of the box
  • 🗽 Multi-dimensional plug-in system based on onion model, programming is more decoupled and free
  • 🚀 SW security registration and uninstallation
  • 🎡 Static resource caching
  • 🎢 Resource pre-cache
  • 🎠 Remote control
  • ⛲️ Data metrics collection

Motivation

Due to the complexity of Service Worker technology, we need to know a lot of related knowledge in the development of PWA applications.
Google Workbox provides a set of convenient APIs to simplify common SW operations such as SW registration and installation, resource caching, etc., but its positioning is: "Library".

When there are more and more SW program codes, it will cause the code to be bloated, the management is chaotic, and the reuse is difficult.
At the same time, some common PWA implementations, such as: remote control, process communication, data reporting, etc., hope to achieve on-demand pluggable reuse.
We need : "Framework".

Can we use Workbox as the underlying technology and build a higher-level abstraction framework on top of it to solve these problems?
So, I built a basic suite: GlacierJS.
It is based on a core "multi-dimensional onion plug-in system" and multiple plug-ins, allowing you to build an enterprise-level PWA application faster.

Glacier is a tribute to the former Lavas

Simplest example

In Main thread

<script src="//cdn.jsdelivr.net/npm/@glacierjs/core/dist/index.min.js" ></script>
<script src="//cdn.jsdelivr.net/npm/@glacierjs/window/dist/index.min.js"></script>

<script>
    const { GlacierWindow } = window['@glacierjs/window'];
    const glacier = new GlacierWindow('./service-worker.js');

    glacier.register().then((registration) => {
      console.log('Register service-worker succeed', registration);
    }).catch((error) => {
      console.error('Register service-worker failed', error);
    });
</script>

In ServiceWorker thread

importScripts("//cdn.jsdelivr.net/npm/@glacierjs/core/dist/index.js");
importScripts('//cdn.jsdelivr.net/npm/@glacierjs/sw/dist/index.js');

const { GlacierSW } = self['@glacierjs/sw'];
const glacierSW = new GlacierSW();
glacierSW.listen();

Design overview

Architecture

logo

It consists of several parts:

  • Core

    • @glacierjs/core: As the core of Glacier, it implements functions such as plug-in system, log system, etc.Generally, you will not use this module directly.
    • @glacierjs/sw: The code running in the SW process encapsulates the SW life cycle and provides a simple programming method.
    • @glacierjs/window: The code running in the main process, in addition to supporting plug-in programming, is also responsible for managing the registration and uninstallation of SW.
  • Plugins

    • @glacierjs/plugin-precache: Implement static resource pre-cache function.
    • @glacierjs/plugin-collector: Realize basic data reporting function.
    • @glacierjs/plugin-assets: Implement static resource caching.
    • @glacierjs/plugin-remote-controller: Implement remote control function.
  • Related

    • @glacierjs/cli: Supports rapid creation of applications and plugins.
    • @glacierjs/webpack-plugin: support building static resource manifests.

Multidimensional Onion Plugin System

GlacierJS encapsulates traditional ServiceWorker lifecycle hooks to support plug-in. The plug-in system implements an "onion" for each native lifecycle hook according to the onion model, so we call this system:

Multidimensional Onion Plugin System

GlacierJS 多维洋葱插件系统

After encapsulating the traditional life cycle, we provide a more elegant life cycle hook function for each plugin

GlacierJS 生命周期图示

Contribute

See How to contribute

Contact & Support

License

This project is licensed under the MIT license.

Copyright (c) JerryC Huang ([email protected])

More Repositories

1

Memeye

👀 The eye of memory. A lightweight memory monitor and dashboard for Node.js application on development.
JavaScript
348
star
2

understand-tcp-udp

📙 理解 TCP 和 UDP
292
star
3

unittest-demo

📘 Node.js单元测试实例
HTML
106
star
4

Tools

🛠 每个开发者都应该有一个自己的工具箱
78
star
5

wxapp-router

🛵 The router for Wechat Miniprogram
TypeScript
48
star
6

docsify-remote-markdown

Remote markdown plugin of docsify
JavaScript
26
star
7

module-seed

🌱 一套优雅的 Typescript Module 工作流
TypeScript
15
star
8

super-cache

💾 一个跨 JS 平台的缓存库,支持缓存逻辑代理,支持自定义数据存储
TypeScript
15
star
9

handlebarjs-guide

📗 Handlerbars不完全指南
8
star
10

use-npm-in-weapp

在微信小程序开发中使用 NPM 示例。
JavaScript
6
star
11

concurrent-merger

Concurrent function called merger
TypeScript
5
star
12

learn-music

📕 乐理学习笔记
CSS
4
star
13

method-fuse

避免函数过热调用
TypeScript
4
star
14

skipper-upyun

A simple skipper adapter for upyun
JavaScript
4
star
15

mini-logger

✏️ A mini logger with four level
TypeScript
4
star
16

sql-base

SQL基础笔记
GCC Machine Description
3
star
17

express-sso-auth

A express middleware that design and implementing strategy for Single Site-On authorization.
JavaScript
3
star
18

programming-knowledge

Programming knowledge summary for JC
2
star
19

dragDemo

演示原生Javascript实现的图标拖拽效果
2
star
20

BlueSun_V3

BlueSun 博客,第三版本,由 Hexo 驱动.
SCSS
1
star
21

mac-setup

💻 A Guide for Developer who new to MacOS
1
star
22

time-buried

Buried time point.
JavaScript
1
star
23

Front-end-Development-kit

本文总结一下本人所接触到的前端开发工具,只为梳理一下,各位看官轻拍。
1
star
24

sailsx

The scaffold extend by Sails
JavaScript
1
star
25

BlueSun

基于NodeJS实现的全静态化个人博客网站,目前很无耻的挂载在gitpages上。
JavaScript
1
star
26

socket-mvc

The socket mvc server framework
JavaScript
1
star
27

pwa-in-action

《PWA实战》系列
1
star
28

My2048

基于Jquery的 2048 demo版
JavaScript
1
star
29

passport-flyme

passport strategy for flyme.com
JavaScript
1
star