jekyll-pwa-plugin 1.0.0 → 1.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/jekyll-pwa-plugin.rb +21 -5
- metadata +2 -3
- data/lib/vendor/broadcast-channel-polyfill.js +0 -77
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 70e5249c3b1e463e40abab6f044cfc3018df4d4d
|
4
|
+
data.tar.gz: bdb56904bbb94b5e5c4f9473a0b70cf10437b8f1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 81368c454131a3a673ff6cb86dbe41ca22896a8dbbdce035fa3f1fab7f2dfccf68e922f893c6350709f85a324bc28595ca9c970ae322685a3717e1ed0f2b2850
|
7
|
+
data.tar.gz: 9ea6b296cd510a5fb46926c82d67f8a9495ab2927b3ce682dfde5c3483e6e1f637df13058e5eb815b8c0387304492526036086f447e2fca8d139d9d7da4ab39a
|
data/lib/jekyll-pwa-plugin.rb
CHANGED
@@ -11,8 +11,26 @@ class SWHelper
|
|
11
11
|
# add build version in url params
|
12
12
|
sw_register_file.puts(
|
13
13
|
<<-SCRIPT
|
14
|
-
|
15
|
-
|
14
|
+
if ('serviceWorker' in navigator) {
|
15
|
+
navigator.serviceWorker.register('/#{@sw_filename}?v=#{@site.time.to_i.to_s}').then(function(reg) {
|
16
|
+
reg.onupdatefound = function() {
|
17
|
+
var installingWorker = reg.installing;
|
18
|
+
installingWorker.onstatechange = function() {
|
19
|
+
switch (installingWorker.state) {
|
20
|
+
case 'installed':
|
21
|
+
if (navigator.serviceWorker.controller) {
|
22
|
+
var event = document.createEvent('Event');
|
23
|
+
event.initEvent('sw.update', true, true);
|
24
|
+
window.dispatchEvent(event);
|
25
|
+
}
|
26
|
+
break;
|
27
|
+
}
|
28
|
+
};
|
29
|
+
};
|
30
|
+
}).catch(function(e) {
|
31
|
+
console.error('Error during service worker registration:', e);
|
32
|
+
});
|
33
|
+
}
|
16
34
|
SCRIPT
|
17
35
|
)
|
18
36
|
sw_register_file.close
|
@@ -76,7 +94,6 @@ class SWHelper
|
|
76
94
|
|
77
95
|
def write_sw()
|
78
96
|
cache_name = @config['cache_name'] || 'workbox'
|
79
|
-
precache_channel_name = @config['precache_channel_name'] || 'sw-precache'
|
80
97
|
runtime_cache = @config['runtime_cache'] || []
|
81
98
|
dest_js_directory = @config['dest_js_directory'] || 'js'
|
82
99
|
|
@@ -121,8 +138,7 @@ class SWHelper
|
|
121
138
|
cacheId: '#{cache_name}',
|
122
139
|
ignoreUrlParametersMatching: [/^utm_/],
|
123
140
|
skipWaiting: true,
|
124
|
-
clientsClaim: true
|
125
|
-
precacheChannelName: '#{precache_channel_name}'
|
141
|
+
clientsClaim: true
|
126
142
|
});
|
127
143
|
workboxSW.precache([#{precache_list_str}]);
|
128
144
|
#{runtime_cache_str}
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: jekyll-pwa-plugin
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Pan Yuqi
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-
|
11
|
+
date: 2017-12-16 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: This plugin provides PWA support for Jekyll. Generate a service worker
|
14
14
|
and provides precache with Google Workbox.
|
@@ -18,7 +18,6 @@ extensions: []
|
|
18
18
|
extra_rdoc_files: []
|
19
19
|
files:
|
20
20
|
- lib/jekyll-pwa-plugin.rb
|
21
|
-
- lib/vendor/broadcast-channel-polyfill.js
|
22
21
|
- lib/vendor/workbox-sw.prod.v2.1.1.js
|
23
22
|
homepage: https://github.com/lavas-project/jekyll-pwa
|
24
23
|
licenses:
|
@@ -1,77 +0,0 @@
|
|
1
|
-
(function(global) {
|
2
|
-
var channels = [];
|
3
|
-
|
4
|
-
function BroadcastChannel(channel) {
|
5
|
-
var $this = this;
|
6
|
-
channel = String(channel);
|
7
|
-
|
8
|
-
var id = '$BroadcastChannel$' + channel + '$';
|
9
|
-
|
10
|
-
channels[id] = channels[id] || [];
|
11
|
-
channels[id].push(this);
|
12
|
-
|
13
|
-
this._name = channel;
|
14
|
-
this._id = id;
|
15
|
-
this._closed = false;
|
16
|
-
this._mc = new MessageChannel();
|
17
|
-
this._mc.port1.start();
|
18
|
-
this._mc.port2.start();
|
19
|
-
|
20
|
-
global.addEventListener('storage', function(e) {
|
21
|
-
if (e.storageArea !== global.localStorage) return;
|
22
|
-
if (e.newValue === null) return;
|
23
|
-
if (e.key.substring(0, id.length) !== id) return;
|
24
|
-
var data = JSON.parse(e.newValue);
|
25
|
-
$this._mc.port2.postMessage(data);
|
26
|
-
});
|
27
|
-
}
|
28
|
-
|
29
|
-
BroadcastChannel.prototype = {
|
30
|
-
// BroadcastChannel API
|
31
|
-
get name() { return this._name; },
|
32
|
-
postMessage: function(message) {
|
33
|
-
var $this = this;
|
34
|
-
if (this._closed) {
|
35
|
-
var e = new Error();
|
36
|
-
e.name = 'InvalidStateError';
|
37
|
-
throw e;
|
38
|
-
}
|
39
|
-
var value = JSON.stringify(message);
|
40
|
-
|
41
|
-
// Broadcast to other contexts via storage events...
|
42
|
-
var key = this._id + String(Date.now()) + '$' + String(Math.random());
|
43
|
-
global.localStorage.setItem(key, value);
|
44
|
-
setTimeout(function() { global.localStorage.removeItem(key); }, 500);
|
45
|
-
|
46
|
-
// Broadcast to current context via ports
|
47
|
-
channels[this._id].forEach(function(bc) {
|
48
|
-
if (bc === $this) return;
|
49
|
-
bc._mc.port2.postMessage(JSON.parse(value));
|
50
|
-
});
|
51
|
-
},
|
52
|
-
close: function() {
|
53
|
-
if (this._closed) return;
|
54
|
-
this._closed = true;
|
55
|
-
this._mc.port1.close();
|
56
|
-
this._mc.port2.close();
|
57
|
-
|
58
|
-
var index = channels[this._id].indexOf(this);
|
59
|
-
channels[this._id].splice(index, 1);
|
60
|
-
},
|
61
|
-
|
62
|
-
// EventTarget API
|
63
|
-
get onmessage() { return this._mc.port1.onmessage; },
|
64
|
-
set onmessage(value) { this._mc.port1.onmessage = value; },
|
65
|
-
addEventListener: function(type, listener /*, useCapture*/) {
|
66
|
-
return this._mc.port1.addEventListener.apply(this._mc.port1, arguments);
|
67
|
-
},
|
68
|
-
removeEventListener: function(type, listener /*, useCapture*/) {
|
69
|
-
return this._mc.port1.removeEventListener.apply(this._mc.port1, arguments);
|
70
|
-
},
|
71
|
-
dispatchEvent: function(event) {
|
72
|
-
return this._mc.port1.dispatchEvent.apply(this._mc.port1, arguments);
|
73
|
-
}
|
74
|
-
};
|
75
|
-
|
76
|
-
global.BroadcastChannel = global.BroadcastChannel || BroadcastChannel;
|
77
|
-
}(self));
|