hexo-theme-shokax 0.3.1 → 0.3.3

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/.eslintrc.cjs CHANGED
@@ -9,11 +9,13 @@ module.exports = {
9
9
  extends: [
10
10
  'standard',
11
11
  'plugin:@typescript-eslint/recommended',
12
- 'plugin:vue/vue3-recommended'
12
+ 'plugin:vue/vue3-recommended',
13
+ 'plugin:chai-friendly/recommended'
13
14
  ],
14
15
  plugins: [
15
16
  '@typescript-eslint',
16
- 'vue'
17
+ 'vue',
18
+ 'chai-friendly'
17
19
  ],
18
20
  parserOptions: {
19
21
  ecmaVersion: 12
@@ -25,6 +27,6 @@ module.exports = {
25
27
  '@typescript-eslint/ban-ts-comment': 'off',
26
28
  '@typescript-eslint/no-var-requires': 'off',
27
29
  '@typescript-eslint/no-unused-vars': 'off',
28
- 'prefer-const': 'warn'
30
+ 'prefer-const': 'off'
29
31
  }
30
32
  }
package/_config.yml CHANGED
@@ -358,18 +358,18 @@ advVendors:
358
358
  js:
359
359
  pace:
360
360
  src: bytedance:pace/1.0.2/pace.min.js
361
- pjax:
362
- src: npm:theme-shokax-pjax@latest/pjax.shokax.min.js
361
+ # pjax:
362
+ # src: npm:theme-shokax-pjax@latest/pjax.shokax.min.js
363
363
  fetch:
364
364
  src: npm:whatwg-fetch@3.4.0/dist/fetch.umd.js
365
- anime:
366
- src: npm:theme-shokax-anime@latest/anime.shokax.min.js
365
+ # anime:
366
+ # src: npm:theme-shokax-anime@latest/anime.shokax.min.js
367
367
  algolia:
368
368
  src: bytedance:algoliasearch/4.12.1/algoliasearch-lite.umd.min.js
369
369
  instantsearch:
370
370
  src: bytedance:instantsearch.js/4.39.0/instantsearch.production.min.js
371
- lazyload:
372
- src: bytedance:lozad.js/1.16.0/lozad.min.js
371
+ # lazyload:
372
+ # src: bytedance:lozad.js/1.16.0/lozad.min.js
373
373
  quicklink:
374
374
  src: bytedance:quicklink/2.2.0/quicklink.umd.min.js
375
375
  fancybox:
@@ -388,11 +388,11 @@ advVendors:
388
388
  vendorsList:
389
389
  js:
390
390
  - pace
391
- - pjax
392
- - anime
391
+ # - pjax
392
+ # - anime
393
393
  - algolia
394
394
  - instantsearch
395
- - lazyload
395
+ # - lazyload
396
396
  - quicklink
397
397
  - fancybox
398
398
  - copy_tex
@@ -405,12 +405,12 @@ vendors:
405
405
 
406
406
  js:
407
407
  pace: npm/pace-js@1.0.2/pace.min.js # ok
408
- pjax: npm/theme-shokax-pjax@latest/pjax.shokax.min.js # ok
408
+ # pjax: npm/theme-shokax-pjax@latest/pjax.shokax.min.js # ok
409
409
  fetch: npm/whatwg-fetch@3.4.0/dist/fetch.umd.min.js # ok
410
- anime: npm/theme-shokax-anime@latest/anime.shokax.min.js
410
+ # anime: npm/theme-shokax-anime@latest/anime.shokax.min.js
411
411
  algolia: npm/algoliasearch@4/dist/algoliasearch-lite.umd.js # ok
412
412
  instantsearch: npm/instantsearch.js@4/dist/instantsearch.production.min.js # ok
413
- lazyload: npm/lozad@1/dist/lozad.min.js # ok
413
+ # lazyload: npm/lozad@1/dist/lozad.min.js # ok
414
414
  quicklink: npm/quicklink@2/dist/quicklink.umd.js # ok
415
415
  fancybox: combine/npm/jquery@3.5.1/dist/jquery.min.js,npm/@fancyapps/fancybox@3.5.7/dist/jquery.fancybox.min.js,npm/justifiedGallery@3.8.1/dist/js/jquery.justifiedGallery.min.js # notok
416
416
  valine: gh/amehime/MiniValine@4.2.2-beta10/dist/MiniValine.min.js # TODO 弃用
@@ -26,7 +26,7 @@ mixin WRender(item)
26
26
  ul(class="leancloud-recent-comment" id="new-comment")
27
27
  if tk || waline
28
28
  li(v-for="com in coms" class="item")
29
- a(v-bind:href="com.href" data-pjax-state="data-pjax-state")
29
+ a(v-bind:href="root + com.href" data-pjax-state="data-pjax-state")
30
30
  span(class="breadcrumb") {{com.nick}} @ {{com.time}}
31
31
  span {{com.text}}
32
32
  br
package/package.json CHANGED
@@ -1,26 +1,30 @@
1
1
  {
2
2
  "name": "hexo-theme-shokax",
3
- "version": "0.3.1",
3
+ "version": "0.3.3",
4
4
  "description": "a hexo theme based on shoka",
5
5
  "main": "index.js",
6
6
  "repository": "https://github.com/theme-shoka-x/hexo-theme-shokaX",
7
7
  "author": "zkz098",
8
8
  "license": "AGPL-3.0-or-later",
9
9
  "scripts": {
10
- "test": "tsc",
10
+ "test": "mocha test --coverage",
11
11
  "build": "pnpm install && tsc"
12
12
  },
13
13
  "devDependencies": {
14
+ "@types/chai": "^4.3.5",
14
15
  "@types/fancybox": "^3.5.3",
15
16
  "@types/hexo": "^3.8.8",
16
17
  "@types/jquery": "^3.5.16",
17
18
  "@types/js-yaml": "^4.0.5",
18
19
  "@types/lozad": "^1.16.1",
20
+ "@types/mocha": "^10.0.1",
19
21
  "@types/node": "^20.4.4",
20
22
  "@typescript-eslint/eslint-plugin": "^6.2.0",
21
23
  "@typescript-eslint/parser": "^6.2.0",
24
+ "chai": "^4.3.7",
22
25
  "eslint": "^8.45.0",
23
26
  "eslint-config-standard": "*",
27
+ "eslint-plugin-chai-friendly": "^0.7.2",
24
28
  "eslint-plugin-import": "^2.27.5",
25
29
  "eslint-plugin-n": "^16.0.1",
26
30
  "eslint-plugin-promise": "^6.1.1",
@@ -28,16 +32,20 @@
28
32
  "hexo-fs": "^4.1.1",
29
33
  "hexo-util": "^3.1.0",
30
34
  "instantsearch.js": "^4.56.7",
31
- "theme-shokax-anime": "^0.0.4",
32
- "theme-shokax-pjax": "^0.0.2",
35
+ "mocha": "^10.2.0",
33
36
  "typescript": "^5.1.6",
34
- "vue": "^3.3.4"
37
+ "vue": "^3.3.4",
38
+ "jsdom": "^22.1.0"
35
39
  },
36
40
  "dependencies": {
37
- "js-yaml": "^4.1.0"
41
+ "esbuild": "^0.18.17",
42
+ "js-yaml": "^4.1.0",
43
+ "lozad": "^1.16.0",
44
+ "theme-shokax-anime": "^0.0.4",
45
+ "theme-shokax-pjax": "^0.0.2"
46
+ },
47
+ "engines": {
48
+ "node": ">=18.0.0"
38
49
  },
39
- "engines": {
40
- "node": ">=18.0.0"
41
- },
42
- "engineStrict": true
50
+ "engineStrict": true
43
51
  }
@@ -5,21 +5,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  const package_json_1 = __importDefault(require("../../package.json"));
7
7
  const fs = require("hexo-fs");
8
- const node_path_1 = __importDefault(require("node:path"));
9
- function findJsFile(path) {
10
- let result = [];
11
- fs.readdirSync(path).forEach((item) => {
12
- if (!item.endsWith('js')) {
13
- result = result.concat(findJsFile(node_path_1.default.join(path, item)));
14
- }
15
- else {
16
- if (item.indexOf('player') === -1 && item.indexOf('fireworks') === -1) {
17
- result.push(node_path_1.default.join(path, item));
18
- }
19
- }
20
- });
21
- return result;
22
- }
8
+ const esbuild = require("esbuild");
23
9
  hexo.extend.generator.register('script', function (locals) {
24
10
  const config = hexo.config;
25
11
  const theme = hexo.theme.config;
@@ -58,6 +44,7 @@ hexo.extend.generator.register('script', function (locals) {
58
44
  },
59
45
  playerAPI: theme.playerAPI,
60
46
  disableVL: theme.disableVL,
47
+ noPlayer: theme.experiments?.noPlayer,
61
48
  audio: undefined,
62
49
  fireworks: undefined
63
50
  };
@@ -72,41 +59,26 @@ hexo.extend.generator.register('script', function (locals) {
72
59
  if (theme?.audio) {
73
60
  siteConfig.audio = theme.audio;
74
61
  }
75
- let text = '';
76
- let path;
77
- if (fs.existsSync('themes/shokaX/source/js/_app/library/dom.js')) {
78
- path = 'themes/shokaX/source/js/_app';
62
+ let text;
63
+ let enterPoint;
64
+ if (fs.existsSync('themes/shokaX/source/js/_app/pjax/siteInit.js')) {
65
+ enterPoint = 'themes/shokaX/source/js/_app/pjax/siteInit.js';
79
66
  }
80
67
  else {
81
- path = 'node_modules/hexo-theme-shokax/source/js/_app';
68
+ enterPoint = 'node_modules/hexo-theme-shokax/source/js/_app/pjax/siteInit.js';
82
69
  }
83
- let files = findJsFile(node_path_1.default.join(path, 'library'));
84
- files = files.concat(findJsFile(node_path_1.default.join(path, 'globals')));
85
- files = files.concat(findJsFile(node_path_1.default.join(path, 'page')));
86
- files = files.concat(findJsFile(node_path_1.default.join(path, 'pjax')));
87
- files = files.concat(findJsFile(node_path_1.default.join(path, 'components')));
88
- files.forEach(function (item) {
89
- text += fs.readFileSync(item).toString();
70
+ text = 'const CONFIG = ' + JSON.stringify(siteConfig) + ';';
71
+ esbuild.buildSync({
72
+ entryPoints: [enterPoint],
73
+ bundle: true,
74
+ outfile: 'shokax_temp.js',
75
+ platform: 'browser',
76
+ target: ['es2021'],
77
+ minify: true
90
78
  });
91
- if (!theme.experiments?.noPlayer) {
92
- if (fs.existsSync('themes/shokaX/source/js/_app/player.js')) {
93
- text += fs.readFileSync('themes/shokaX/source/js/_app/player.js').toString();
94
- }
95
- else {
96
- text += fs.readFileSync('node_modules/hexo-theme-shokax/source/js/_app/player.js').toString();
97
- }
98
- }
99
- if (theme.fireworks && theme.fireworks.enable) {
100
- if (fs.existsSync('themes/shokaX/source/js/_app/fireworks.js')) {
101
- text += fs.readFileSync('themes/shokaX/source/js/_app/fireworks.js').toString();
102
- }
103
- else {
104
- text += fs.readFileSync('node_modules/hexo-theme-shokax/source/js/_app/fireworks.js').toString();
105
- }
106
- siteConfig.fireworks = theme.fireworks.color || ['rgba(255,182,185,.9)', 'rgba(250,227,217,.9)', 'rgba(187,222,214,.9)', 'rgba(138,198,209,.9)'];
107
- }
108
- text = 'const CONFIG = ' + JSON.stringify(siteConfig) + ';' + text;
79
+ text += fs.readFileSync('shokax_temp.js');
109
80
  const result = hexo.render.renderSync({ text, engine: 'js' });
81
+ fs.unlinkSync('shokax_temp.js');
110
82
  return {
111
83
  path: theme.js + '/app.js',
112
84
  data: function () {
@@ -6,6 +6,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
6
6
  const package_json_1 = __importDefault(require("../../package.json"));
7
7
  const hexo_util_1 = require("hexo-util");
8
8
  hexo.extend.helper.register('_new_comments', function (mode) {
9
+ const root = this.config.url.replace(/^(https?:\/\/)?[^\/]*/, '');
9
10
  if (mode === 'twikoo') {
10
11
  return `<script data-pjax type="module">
11
12
  let comments = []
@@ -29,7 +30,8 @@ hexo.extend.helper.register('_new_comments', function (mode) {
29
30
  Vue.createApp({
30
31
  data() {
31
32
  return {
32
- coms: comments
33
+ coms: comments,
34
+ root: '${root}'
33
35
  }
34
36
  }
35
37
  }).mount('#new-comment')
@@ -61,7 +63,8 @@ hexo.extend.helper.register('_new_comments', function (mode) {
61
63
  Vue.createApp({
62
64
  data() {
63
65
  return {
64
- coms: items
66
+ coms: items,
67
+ root: '${root}'
65
68
  }
66
69
  }
67
70
  }).mount('#new-comment')
@@ -1,44 +1,52 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.menuActive = exports.goToCommentHandle = exports.goToBottomHandle = exports.backToTopHandle = exports.sidebarTOC = exports.sideBarTab = exports.sideBarToggleHandle = void 0;
4
+ const globalVars_1 = require("../globals/globalVars");
5
+ const tools_1 = require("../globals/tools");
6
+ const anime_1 = require("../library/anime");
7
+ const dom_1 = require("../library/dom");
1
8
  const sideBarToggleHandle = (event, force) => {
2
- if (sideBar.hasClass('on')) {
3
- sideBar.removeClass('on');
4
- menuToggle.removeClass('close');
9
+ if (globalVars_1.sideBar.hasClass('on')) {
10
+ globalVars_1.sideBar.removeClass('on');
11
+ globalVars_1.menuToggle.removeClass('close');
5
12
  if (force) {
6
- sideBar.style = '';
13
+ globalVars_1.sideBar.style = '';
7
14
  }
8
15
  else {
9
- transition(sideBar, 'slideRightOut');
16
+ (0, anime_1.transition)(globalVars_1.sideBar, 'slideRightOut');
10
17
  }
11
18
  }
12
19
  else {
13
20
  if (force) {
14
- sideBar.style = '';
21
+ globalVars_1.sideBar.style = '';
15
22
  }
16
23
  else {
17
- transition(sideBar, 'slideRightIn', () => {
18
- sideBar.addClass('on');
19
- menuToggle.addClass('close');
24
+ (0, anime_1.transition)(globalVars_1.sideBar, 'slideRightIn', () => {
25
+ globalVars_1.sideBar.addClass('on');
26
+ globalVars_1.menuToggle.addClass('close');
20
27
  });
21
28
  }
22
29
  }
23
30
  };
31
+ exports.sideBarToggleHandle = sideBarToggleHandle;
24
32
  const sideBarTab = () => {
25
- const sideBarInner = sideBar.child('.inner');
26
- if (sideBar.child('.tab')) {
27
- sideBarInner.removeChild(sideBar.child('.tab'));
33
+ const sideBarInner = globalVars_1.sideBar.child('.inner');
34
+ if (globalVars_1.sideBar.child('.tab')) {
35
+ sideBarInner.removeChild(globalVars_1.sideBar.child('.tab'));
28
36
  }
29
37
  const list = document.createElement('ul');
30
38
  let active = 'active';
31
39
  list.className = 'tab';
32
40
  ['contents', 'related', 'overview'].forEach((item) => {
33
- const element = sideBar.child('.panel.' + item);
41
+ const element = globalVars_1.sideBar.child('.panel.' + item);
34
42
  if (element.innerHTML.trim().length < 1) {
35
43
  if (item === 'contents') {
36
- showContents.display('none');
44
+ globalVars_1.showContents.display('none');
37
45
  }
38
46
  return;
39
47
  }
40
48
  if (item === 'contents') {
41
- showContents.display('');
49
+ globalVars_1.showContents.display('');
42
50
  }
43
51
  const tab = document.createElement('li');
44
52
  const span = document.createElement('span');
@@ -57,13 +65,13 @@ const sideBarTab = () => {
57
65
  const target = event.currentTarget;
58
66
  if (target.hasClass('active'))
59
67
  return;
60
- sideBar.find('.tab .item').forEach((element) => {
68
+ globalVars_1.sideBar.find('.tab .item').forEach((element) => {
61
69
  element.removeClass('active');
62
70
  });
63
- sideBar.find('.panel').forEach((element) => {
71
+ globalVars_1.sideBar.find('.panel').forEach((element) => {
64
72
  element.removeClass('active');
65
73
  });
66
- sideBar.child('.panel.' + target.className.replace(' item', '')).addClass('active');
74
+ globalVars_1.sideBar.child('.panel.' + target.className.replace(' item', '')).addClass('active');
67
75
  target.addClass('active');
68
76
  });
69
77
  list.appendChild(tab);
@@ -71,12 +79,13 @@ const sideBarTab = () => {
71
79
  });
72
80
  if (list.childNodes.length > 1) {
73
81
  sideBarInner.insertBefore(list, sideBarInner.childNodes[0]);
74
- sideBar.child('.panels').style.paddingTop = '';
82
+ globalVars_1.sideBar.child('.panels').style.paddingTop = '';
75
83
  }
76
84
  else {
77
- sideBar.child('.panels').style.paddingTop = '.625rem';
85
+ globalVars_1.sideBar.child('.panels').style.paddingTop = '.625rem';
78
86
  }
79
87
  };
88
+ exports.sideBarTab = sideBarTab;
80
89
  const sidebarTOC = () => {
81
90
  const activateNavByIndex = (index) => {
82
91
  const target = navItems[index];
@@ -85,7 +94,7 @@ const sidebarTOC = () => {
85
94
  if (target.hasClass('current')) {
86
95
  return;
87
96
  }
88
- $dom.each('.toc .active', (element) => {
97
+ dom_1.$dom.each('.toc .active', (element) => {
89
98
  element && element.removeClass('active current');
90
99
  });
91
100
  sections.forEach((element) => {
@@ -97,18 +106,18 @@ const sidebarTOC = () => {
97
106
  while (!parent.matches('.contents')) {
98
107
  if (parent.matches('li')) {
99
108
  parent.addClass('active');
100
- const t = $dom(parent.child('a.toc-link').attr('href'));
109
+ const t = (0, dom_1.$dom)(parent.child('a.toc-link').attr('href'));
101
110
  if (t) {
102
111
  t.addClass('active');
103
112
  }
104
113
  }
105
114
  parent = parent.parentNode;
106
115
  }
107
- if (getComputedStyle(sideBar).display !== 'none' && tocElement.hasClass('active')) {
108
- pageScroll(tocElement, target.offsetTop - (tocElement.offsetHeight / 4));
116
+ if (getComputedStyle(globalVars_1.sideBar).display !== 'none' && tocElement.hasClass('active')) {
117
+ (0, anime_1.pageScroll)(tocElement, target.offsetTop - (tocElement.offsetHeight / 4));
109
118
  }
110
119
  };
111
- const navItems = $dom.all('.contents li');
120
+ const navItems = dom_1.$dom.all('.contents li');
112
121
  if (navItems.length < 1) {
113
122
  return;
114
123
  }
@@ -116,15 +125,15 @@ const sidebarTOC = () => {
116
125
  let activeLock = null;
117
126
  sections = sections.map((element, index) => {
118
127
  const link = element.child('a.toc-link');
119
- const anchor = $dom(decodeURI(link.attr('href')));
128
+ const anchor = (0, dom_1.$dom)(decodeURI(link.attr('href')));
120
129
  if (!anchor)
121
130
  return null;
122
131
  const alink = anchor.child('a.anchor');
123
132
  const anchorScroll = (event) => {
124
133
  event.preventDefault();
125
- const target = $dom(decodeURI(event.currentTarget.attr('href')));
134
+ const target = (0, dom_1.$dom)(decodeURI(event.currentTarget.attr('href')));
126
135
  activeLock = index;
127
- pageScroll(target, null, () => {
136
+ (0, anime_1.pageScroll)(target, null, () => {
128
137
  activateNavByIndex(index);
129
138
  activeLock = null;
130
139
  });
@@ -132,11 +141,11 @@ const sidebarTOC = () => {
132
141
  link.addEventListener('click', anchorScroll);
133
142
  alink && alink.addEventListener('click', (event) => {
134
143
  anchorScroll(event);
135
- clipBoard(CONFIG.hostname + '/' + LOCAL.path + event.currentTarget.attr('href'));
144
+ (0, tools_1.clipBoard)(CONFIG.hostname + '/' + LOCAL.path + event.currentTarget.attr('href'));
136
145
  });
137
146
  return anchor;
138
147
  });
139
- const tocElement = sideBar.child('.contents.panel');
148
+ const tocElement = globalVars_1.sideBar.child('.contents.panel');
140
149
  const findIndex = (entries) => {
141
150
  let index = 0;
142
151
  let entry = entries[index];
@@ -156,7 +165,7 @@ const sidebarTOC = () => {
156
165
  };
157
166
  const createIntersectionObserver = () => {
158
167
  const observer = new IntersectionObserver((entries) => {
159
- const index = findIndex(entries) + (diffY < 0 ? 1 : 0);
168
+ const index = findIndex(entries) + (globalVars_1.diffY < 0 ? 1 : 0);
160
169
  if (activeLock === null) {
161
170
  activateNavByIndex(index);
162
171
  }
@@ -169,17 +178,21 @@ const sidebarTOC = () => {
169
178
  };
170
179
  createIntersectionObserver();
171
180
  };
181
+ exports.sidebarTOC = sidebarTOC;
172
182
  const backToTopHandle = () => {
173
- pageScroll(0);
183
+ (0, anime_1.pageScroll)(0);
174
184
  };
185
+ exports.backToTopHandle = backToTopHandle;
175
186
  const goToBottomHandle = () => {
176
- pageScroll(parseInt(String(Container.changeOrGetHeight())));
187
+ (0, anime_1.pageScroll)(parseInt(String(globalVars_1.Container.changeOrGetHeight())));
177
188
  };
189
+ exports.goToBottomHandle = goToBottomHandle;
178
190
  const goToCommentHandle = () => {
179
- pageScroll($dom('#comments'));
191
+ (0, anime_1.pageScroll)((0, dom_1.$dom)('#comments'));
180
192
  };
193
+ exports.goToCommentHandle = goToCommentHandle;
181
194
  const menuActive = () => {
182
- $dom.each('.menu .item:not(.title)', (element) => {
195
+ dom_1.$dom.each('.menu .item:not(.title)', (element) => {
183
196
  const target = element.child('a[href]');
184
197
  const parentItem = element.parentNode.parentNode;
185
198
  if (!target)
@@ -196,3 +209,4 @@ const menuActive = () => {
196
209
  }
197
210
  });
198
211
  };
212
+ exports.menuActive = menuActive;
@@ -1,3 +1,10 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.initFireworks = void 0;
7
+ const theme_shokax_anime_1 = __importDefault(require("theme-shokax-anime"));
1
8
  const canvasEl = document.createElement('canvas');
2
9
  canvasEl.style.cssText = 'position:fixed;top:0;left:0;pointer-events:none;z-index:9999999';
3
10
  document.body.appendChild(canvasEl);
@@ -19,9 +26,9 @@ function updateCoords(e) {
19
26
  pointerY = e.clientY || (e.touches && e.touches[0].clientY);
20
27
  }
21
28
  function setParticuleDirection(p) {
22
- const angle = anime.random(0, 360) * Math.PI / 180;
23
- const value = anime.random(50, 180);
24
- const radius = [-1, 1][anime.random(0, 1)] * value;
29
+ const angle = theme_shokax_anime_1.default.random(0, 360) * Math.PI / 180;
30
+ const value = theme_shokax_anime_1.default.random(50, 180);
31
+ const radius = [-1, 1][theme_shokax_anime_1.default.random(0, 1)] * value;
25
32
  return {
26
33
  x: p.x + radius * Math.cos(angle),
27
34
  y: p.y + radius * Math.sin(angle)
@@ -41,8 +48,8 @@ function createParticule(x, y) {
41
48
  ctx.fill();
42
49
  }
43
50
  };
44
- p.color = colors[anime.random(0, colors.length - 1)];
45
- p.radius = anime.random(16, 32);
51
+ p.color = colors[theme_shokax_anime_1.default.random(0, colors.length - 1)];
52
+ p.radius = theme_shokax_anime_1.default.random(16, 32);
46
53
  p.endPos = setParticuleDirection(p);
47
54
  return p;
48
55
  }
@@ -78,9 +85,9 @@ function animateParticules(x, y) {
78
85
  for (let i = 0; i < numberOfParticules; i++) {
79
86
  particules.push(createParticule(x, y));
80
87
  }
81
- anime().timeline().add({
88
+ (0, theme_shokax_anime_1.default)().timeline().add({
82
89
  targets: particules,
83
- duration: anime.random(1200, 1800),
90
+ duration: theme_shokax_anime_1.default.random(1200, 1800),
84
91
  easing: 'easeOutExpo',
85
92
  update: renderParticule,
86
93
  x: p => p.endPos.x,
@@ -88,19 +95,19 @@ function animateParticules(x, y) {
88
95
  radius: 0.1
89
96
  }).add({
90
97
  targets: circle,
91
- duration: anime.random(1200, 1800),
98
+ duration: theme_shokax_anime_1.default.random(1200, 1800),
92
99
  easing: 'easeOutExpo',
93
100
  update: renderParticule,
94
- radius: anime.random(80, 160),
101
+ radius: theme_shokax_anime_1.default.random(80, 160),
95
102
  lineWidth: 0,
96
103
  alpha: {
97
104
  value: 0,
98
105
  easing: 'linear',
99
- duration: anime.random(600, 800)
106
+ duration: theme_shokax_anime_1.default.random(600, 800)
100
107
  }
101
108
  }).play();
102
109
  }
103
- const render = anime({
110
+ const render = (0, theme_shokax_anime_1.default)({
104
111
  duration: Infinity,
105
112
  update() {
106
113
  ctx.clearRect(0, 0, canvasEl.width, canvasEl.height);
@@ -116,13 +123,19 @@ const hasAncestor = (node, name) => {
116
123
  } while ((node = node.parentNode) !== null);
117
124
  return false;
118
125
  };
119
- document.addEventListener(tap, (e) => {
120
- if (hasAncestor(e.target, 'a')) {
126
+ function initFireworks() {
127
+ if (typeof CONFIG.fireworks === 'undefined') {
121
128
  return;
122
129
  }
123
- render.play();
124
- updateCoords(e);
125
- animateParticules(pointerX, pointerY);
126
- }, false);
127
- setCanvasSize();
128
- window.addEventListener('resize', setCanvasSize, false);
130
+ document.addEventListener(tap, (e) => {
131
+ if (hasAncestor(e.target, 'a')) {
132
+ return;
133
+ }
134
+ render.play();
135
+ updateCoords(e);
136
+ animateParticules(pointerX, pointerY);
137
+ }, false);
138
+ setCanvasSize();
139
+ window.addEventListener('resize', setCanvasSize, false);
140
+ }
141
+ exports.initFireworks = initFireworks;