hexo-offline 2.0.1 → 4.0.0

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.
package/README.md CHANGED
@@ -1,7 +1,7 @@
1
1
  # hexo-offline
2
2
 
3
3
  [![npm version](https://img.shields.io/npm/v/hexo-offline.svg?style=flat-square)](https://www.npmjs.com/package/hexo-offline)
4
- ![Build Status](https://img.shields.io/github/workflow/status/JLHwung/hexo-offline/CI.svg?style=flat-square)
4
+ ![Build Status](https://img.shields.io/github/actions/workflow/status/JLHwung/hexo-offline/ci.yml?branch=main&style=flat-square)
5
5
  [![Coverage Status](https://img.shields.io/coveralls/JLHwung/hexo-offline.svg?style=flat-square)](https://coveralls.io/github/JLHwung/hexo-offline)
6
6
 
7
7
  hexo-offline is intended to provide [offline experience](https://web.dev/progressive-web-apps/) for [hexo](https://hexo.io) built static website. It uses _ServiceWorker_ under the hood. Simply install this plugin to your website and it should be offline ready by caching most of static assets.
package/lib/index.js CHANGED
@@ -1,8 +1,7 @@
1
1
  "use strict";
2
2
 
3
3
  var _lib = _interopRequireDefault(require("./lib"));
4
-
5
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
6
-
4
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
7
5
  /* global hexo */
6
+
8
7
  hexo.extend.filter.register("before_exit", _lib.default);
@@ -4,5 +4,4 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.workerName = void 0;
7
- const workerName = "service-worker.js";
8
- exports.workerName = workerName;
7
+ const workerName = exports.workerName = "service-worker.js";
package/lib/lib/index.js CHANGED
@@ -4,13 +4,9 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.default = _default;
7
-
8
7
  var _runWorkboxBuild = _interopRequireDefault(require("./run-workbox-build"));
9
-
10
8
  var _injectSwRegister = _interopRequireDefault(require("./inject-sw-register"));
11
-
12
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
13
-
9
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
14
10
  async function _default() {
15
11
  await _runWorkboxBuild.default.call(this);
16
12
  return (0, _injectSwRegister.default)(this.public_dir);
@@ -4,42 +4,29 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.default = void 0;
7
-
8
7
  var _fs = _interopRequireDefault(require("fs"));
9
-
10
8
  var _path = _interopRequireDefault(require("path"));
11
-
12
- var _constants = require("./constants");
13
-
14
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
15
-
9
+ var _constants = require("./constants.js");
10
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
16
11
  const template = _fs.default.readFileSync(_path.default.join(__dirname, "./template.js"), "utf-8");
17
-
18
12
  const helperSWRegister = function () {
19
13
  const registerContent = template.replace("__workerName__", _constants.workerName);
20
14
  return `<script>${registerContent}</script>`;
21
15
  };
22
-
23
16
  const injectSWRegisterWithContent = script => publicDir => {
24
- const indexHTMLPath = _path.default.join(publicDir, "index.html"); // early return when no index.html presets in public directory
25
-
17
+ const indexHTMLPath = _path.default.join(publicDir, "index.html");
26
18
 
19
+ // early return when no index.html presets in public directory
27
20
  if (!_fs.default.existsSync(indexHTMLPath)) {
28
21
  return;
29
22
  }
23
+ const fileContent = _fs.default.readFileSync(indexHTMLPath, "utf-8");
30
24
 
31
- const fileContent = _fs.default.readFileSync(indexHTMLPath, "utf-8"); // early return if it has been injected before
32
-
33
-
25
+ // early return if it has been injected before
34
26
  if (fileContent.includes(`${script}</body></html>`)) {
35
27
  return;
36
28
  }
37
-
38
29
  const injectedContent = fileContent.replace(/<\/body>\s*<\/html>\s*$/, `${script}</body></html>`);
39
-
40
30
  _fs.default.writeFileSync(indexHTMLPath, injectedContent);
41
31
  };
42
-
43
- var _default = injectSWRegisterWithContent(helperSWRegister());
44
-
45
- exports.default = _default;
32
+ var _default = exports.default = injectSWRegisterWithContent(helperSWRegister());
@@ -4,17 +4,11 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.default = runWorkboxBuild;
7
-
8
7
  var _fs = _interopRequireDefault(require("fs"));
9
-
10
8
  var _path = _interopRequireDefault(require("path"));
11
-
12
9
  var _workboxBuild = require("workbox-build");
13
-
14
10
  var _constants = require("./constants");
15
-
16
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
17
-
11
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
18
12
  function generateSWPrecacheConfig({
19
13
  publicDir
20
14
  }, extraWorkboxBuildConfig) {
@@ -26,7 +20,6 @@ function generateSWPrecacheConfig({
26
20
  ...extraWorkboxBuildConfig
27
21
  };
28
22
  }
29
-
30
23
  function formatNumber(number) {
31
24
  try {
32
25
  return new Intl.NumberFormat().format(number);
@@ -34,7 +27,6 @@ function formatNumber(number) {
34
27
  return number;
35
28
  }
36
29
  }
37
-
38
30
  function printSWResult({
39
31
  count,
40
32
  size,
@@ -43,26 +35,22 @@ function printSWResult({
43
35
  for (const warning of warnings) {
44
36
  logger.warn(warnings);
45
37
  }
46
-
47
38
  logger.info(`Generated manifests for ${formatNumber(count)} files. Total size: ${formatNumber(size)} bytes.`);
48
39
  }
49
-
50
40
  async function runWorkboxBuild() {
51
41
  const {
52
42
  public_dir: publicDir,
53
43
  base_dir: baseDir,
54
44
  config,
55
45
  log: logger
56
- } = this; // early return when no index.html presets in public directory
46
+ } = this;
57
47
 
48
+ // early return when no index.html presets in public directory
58
49
  const indexHTMLPath = _path.default.join(publicDir, "index.html");
59
-
60
50
  if (!_fs.default.existsSync(indexHTMLPath)) {
61
51
  return Promise.resolve();
62
52
  }
63
-
64
53
  let offline;
65
-
66
54
  if ("offline" in config) {
67
55
  logger.warn(`
68
56
  Starting from hexo-offline v2 the 'offline' config in _config.yaml is
@@ -71,11 +59,9 @@ See https://github.com/JLHwung/hexo-offline#usage for more info.
71
59
  `);
72
60
  offline = config.offline;
73
61
  }
74
-
75
62
  try {
76
63
  offline = require(_path.default.resolve(baseDir, "hexo-offline.config.cjs"));
77
64
  } catch {}
78
-
79
65
  const SWPrecacheConfig = generateSWPrecacheConfig({
80
66
  publicDir
81
67
  }, offline);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "hexo-offline",
3
- "version": "2.0.1",
3
+ "version": "4.0.0",
4
4
  "description": "Out-of-the-box hexo offline experience",
5
5
  "main": "lib/index.js",
6
6
  "repository": "https://github.com/JLHwung/hexo-offline.git",
@@ -11,32 +11,29 @@
11
11
  "build:template": "babel src/lib/template.js --out-file lib/lib/template.js && terser lib/lib/template.js -o lib/lib/template.js",
12
12
  "build:lib": "babel src --out-dir lib",
13
13
  "build": "npm run build:lib && npm run build:template",
14
- "test": "jest",
15
- "spellcheck": "yaspeller-ci README.md",
14
+ "test": "node --test",
16
15
  "prepublishOnly": "npm run test && npm run clean && npm run build"
17
16
  },
18
17
  "dependencies": {
19
- "workbox-build": "^6.4.2"
18
+ "workbox-build": "^7.3.0"
20
19
  },
21
20
  "devDependencies": {
22
- "@babel/cli": "^7.8.0",
23
- "@babel/core": "^7.8.0",
24
- "@babel/preset-env": "^7.8.0",
25
- "husky": "^7.0.4",
26
- "jest": "^27.4.7",
27
- "lint-staged": "^12.1.5",
28
- "prettier": "^2.5.1",
29
- "rimraf": "^3.0.2",
30
- "terser": "^5.10.0",
31
- "yaspeller-ci": "^1.0.2"
21
+ "@babel/cli": "^7.24.0",
22
+ "@babel/core": "^7.24.0",
23
+ "@babel/preset-env": "^7.24.0",
24
+ "husky": "^9.1.5",
25
+ "lint-staged": "^16.0.0",
26
+ "prettier": "^3.3.3",
27
+ "terser": "^5.31.6"
32
28
  },
33
29
  "peerDependencies": {
34
- "hexo": "^5.0.0 || ^6.0.0"
30
+ "hexo": "^5.0.0 || ^6.0.0 || ^7.0.0 || ^8.0.0"
35
31
  },
36
32
  "engines": {
37
- "node": ">=12"
33
+ "node": ">=20"
38
34
  },
39
35
  "files": [
40
36
  "lib"
41
- ]
42
- }
37
+ ],
38
+ "packageManager": "yarn@4.11.0"
39
+ }
package/CHANGELOG.md DELETED
@@ -1,174 +0,0 @@
1
- #### 2.0.1 (2022-01-06)
2
-
3
- ##### Chores
4
-
5
- * support Hexo v6 (#143) (2ad4305)
6
- * update renovate config (3fe78f7f)
7
- * **deps:** update coverallsapp/github-action action to v1.1.3 (#144) (05269257)
8
-
9
- ## 2.0.0 (2021-03-12)
10
-
11
- ##### Breaking Changes
12
-
13
- - use workbox-build (#138) (8208bef7)
14
- - drop node < 10 support (4711dad5)
15
-
16
- #### 1.0.1 (2018-12-06)
17
-
18
- ##### Chores
19
-
20
- - **package:**
21
- - update yarn lockfiles (0225b25c)
22
- - update devDependencies (638f390a)
23
- - **deps:**
24
- - update babel monorepo to v7.2.0 (#57) (9d9babcd)
25
- - update dependency prettier to v1.15.3 (#56) (845477f6)
26
- - update dependency lint-staged to v8.1.0 (#54) (b0abea6f)
27
- - update dependency prettier to v1.15.2 (bf02d99e)
28
- - update dependency husky to v1.2.0 (0cf31bee)
29
- - update babel monorepo (d1c93593)
30
- - pin dependencies (#51) (b305ad1f)
31
-
32
- ##### Code Style Changes
33
-
34
- - format whole project (15deac7a)
35
-
36
- ## 1.0.0 (2018-06-09)
37
-
38
- ##### Chores
39
-
40
- - **package:**
41
- - drop node.js 4 support (66b55e0e)
42
- - update dependencies (4b983894)
43
- - **npmignore:** include lib only in package (9c6bcbd6)
44
-
45
- #### 0.2.3 (2018-03-15)
46
-
47
- ##### Chores
48
-
49
- - **package:**
50
- - update standard to version 11.0.1 (e68823a0)
51
- - use yaspeller-ci (159bacc4)
52
- - does not spellcheck CHANGELOG.md (017b5d40)
53
- - update lockfile (9599ee3f)
54
- - update tap to version 11.0.1 (7bb8fad0)
55
- - remove package-lock (d2fa713b)
56
- - update yarn lockfile (6164d774)
57
- - update lockfile (7dfc5419)
58
- - update yaspeller to version 4.0.0 (eb7b6a11)
59
- - upgrade dependencies to latest version (5f1bb1a0)
60
- - update nyc to version 11.0.2 (f075611c)
61
- - add package-lock (53d1f274)
62
- - upgrade dependencies (e1bc34b4)
63
- - update babel-preset-babili to version 0.1.1 (ccabd582)
64
- - update cross-env to version 5.0.0 (f7180935)
65
- - regenerate yarn lockfile (b97f7d6a)
66
- - update standard to version 10.0.0 (3c209f06)
67
- - **appveyor:**
68
- - use yarn cache in appveyor (f34bbd51)
69
- - use bundled npm version (8fd7e21d)
70
- - **travis:**
71
- - add greenkeeper lockfile (6bdc17b6)
72
- - use node as latest node.js build target (178aac46)
73
- - **yaspeller:** add vuejs to dictionary (46dce2db)
74
-
75
- ##### Documentation Changes
76
-
77
- - **README:** fix typo (ad34600c)
78
- - **readme:** add vuejs.org as demo site (7c89bf62)
79
-
80
- ##### Bug Fixes
81
-
82
- - **run-sw-precache:** remove hardcoded public directory (c178610e)
83
- - **inject-sw-register:** remove async attribute on script (9d735e04)
84
- - **appveyor:** use yarn as install process (e6526892)
85
-
86
- #### 0.2.2 (2017-3-31)
87
-
88
- ##### Chores
89
-
90
- - **yaspeller:** update dictionary (1793a9f5)
91
- - **package:**
92
- - upgrade sw-precache to version 5.1.0 (dc7feb09)
93
- - update babel-preset-env to version 1.3.2 (6f1b0f49)
94
- - update cross-env to version 4.0.0 (09b6024d)
95
- - update standard to version 9.0.0 (67a28e13)
96
- - re-generate yarn lockfile using default registry (4b9e5d55)
97
- - update cross-env to version 3.2.3 (c0e4b6ef)
98
- - update babel-preset-babili to version 0.0.12 (f172fa6e)
99
-
100
- #### 0.2.1 (2017-2-20)
101
-
102
- ##### Chores
103
-
104
- - **package:** update babel-plugin-istanbul to version 4.0.0 (87589b23)
105
-
106
- ##### Documentation Changes
107
-
108
- - **readme:** add CDN contents usage (4432e0b4)
109
-
110
- ##### Bug Fixes
111
-
112
- - **inject-sw-register:** early return when injected before (7d4b61fd)
113
-
114
- ##### Tests
115
-
116
- - **inject-sw-register:** add test case on duplicated injection (bfa88df9)
117
-
118
- ### 0.2.0 (2017-2-17)
119
-
120
- ##### Chores
121
-
122
- - **yaspeller:** add words to dictionary (316eac55)
123
- - **package:**
124
- - update babel-preset-babili to version 0.0.11 (333e85e1)
125
- - update tap to version 10.0.1 (672ecc66)
126
- - update babel-preset-babili to version 0.0.10 (6a082c0d)
127
-
128
- ##### Bug Fixes
129
-
130
- - **package:** update sw-precache to version 5.0.0 (6d5719a1)
131
-
132
- #### 0.1.3 (2017-1-17)
133
-
134
- ##### Chores
135
-
136
- - **yaspeller:** add words to dictionary (40775e56)
137
-
138
- #### 0.1.2 (2017-1-17)
139
-
140
- ##### Chores
141
-
142
- - **package:**
143
- - update sw-precache to version 4.3.0 (e95ac9b3)
144
- - remove unused babel-core (2ed41655)
145
- - remove unused babel-register (5a08426f)
146
-
147
- ##### Bug Fixes
148
-
149
- - **package:** change prepublish script to prepublishOnly (4470a438)
150
-
151
- ##### Tests
152
-
153
- - **yaspeller:** add yaspeller (31191a97)
154
-
155
- #### 0.1.1 (2017-1-15)
156
-
157
- ##### Chores
158
-
159
- - **package:**
160
- - update tap to version 9.0.3 (ed45acd4)
161
- - update tap to version 9.0.1 (b6a451bd)
162
-
163
- ##### Documentation Changes
164
-
165
- - **readme:** add more badges (b579c93e)
166
-
167
- ##### Other Changes
168
-
169
- - **package:** revise package description (9bce29c5)
170
-
171
- ##### Tests
172
-
173
- - **travis:** add fast_finish (78f14250)
174
- - **appveyor:** initial test configuration (59186cf8)