hexo-adsense 1.0.26 → 2.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/CHANGELOG.md +6 -0
- package/LICENSE +0 -0
- package/dist/index.cjs +757 -0
- package/dist/index.d.cts +2 -0
- package/dist/index.d.mts +2 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +740 -0
- package/dist/index.mjs +740 -0
- package/dist/source/adblock.css +2 -0
- package/{lib → dist}/source/adblock.js +0 -0
- package/{lib → dist}/source/article-ads.css +0 -0
- package/dist/source/article-ads.js +1 -0
- package/{lib/source/article-ads.js → dist/source/article-ads.old.js} +0 -0
- package/{lib → dist}/source/blogger-redirect.html +0 -0
- package/{lib → dist}/source/https.js +0 -0
- package/{lib → dist}/source/in_article_ads_test.html +0 -0
- package/package.json +122 -37
- package/{README.md → readme.md} +29 -11
- package/lib/index.d.ts +0 -1
- package/lib/index.js +0 -85
- package/lib/packages/hexo-cli-extras/lib/env.d.ts +0 -3
- package/lib/packages/hexo-cli-extras/lib/env.js +0 -49
- package/lib/packages/hexo-extend-injector2/index.d.ts +0 -2
- package/lib/packages/hexo-extend-injector2/index.js +0 -12
- package/lib/packages/hexo-extend-injector2/lib/bundle/css-bundle.d.ts +0 -2
- package/lib/packages/hexo-extend-injector2/lib/bundle/css-bundle.js +0 -64
- package/lib/packages/hexo-extend-injector2/lib/bundle/css-generator.d.ts +0 -2
- package/lib/packages/hexo-extend-injector2/lib/bundle/css-generator.js +0 -12
- package/lib/packages/hexo-extend-injector2/lib/bundle/handle-data-pre.d.ts +0 -2
- package/lib/packages/hexo-extend-injector2/lib/bundle/handle-data-pre.js +0 -28
- package/lib/packages/hexo-extend-injector2/lib/bundle/js-bundle.d.ts +0 -2
- package/lib/packages/hexo-extend-injector2/lib/bundle/js-bundle.js +0 -32
- package/lib/packages/hexo-extend-injector2/lib/bundle/js-generator.d.ts +0 -2
- package/lib/packages/hexo-extend-injector2/lib/bundle/js-generator.js +0 -8
- package/lib/packages/hexo-extend-injector2/lib/default-config.d.ts +0 -39
- package/lib/packages/hexo-extend-injector2/lib/default-config.js +0 -46
- package/lib/packages/hexo-extend-injector2/lib/filter.d.ts +0 -2
- package/lib/packages/hexo-extend-injector2/lib/filter.js +0 -22
- package/lib/packages/hexo-extend-injector2/lib/helper/injector.d.ts +0 -2
- package/lib/packages/hexo-extend-injector2/lib/helper/injector.js +0 -5
- package/lib/packages/hexo-extend-injector2/lib/helper/next-inject.d.ts +0 -2
- package/lib/packages/hexo-extend-injector2/lib/helper/next-inject.js +0 -12
- package/lib/packages/hexo-extend-injector2/lib/injector.d.ts +0 -29
- package/lib/packages/hexo-extend-injector2/lib/injector.js +0 -125
- package/lib/packages/hexo-extend-injector2/lib/load.d.ts +0 -3
- package/lib/packages/hexo-extend-injector2/lib/load.js +0 -37
- package/lib/packages/hexo-extend-injector2/lib/next-point.d.ts +0 -2
- package/lib/packages/hexo-extend-injector2/lib/next-point.js +0 -18
- package/lib/packages/hexo-extend-injector2/lib/next.d.ts +0 -2
- package/lib/packages/hexo-extend-injector2/lib/next.js +0 -99
- package/lib/packages/hexo-extend-injector2/lib/order.d.ts +0 -5
- package/lib/packages/hexo-extend-injector2/lib/order.js +0 -8
- package/lib/source/adblock.css +0 -2
- package/lib/src/article-ads.d.ts +0 -20
- package/lib/src/article-ads.js +0 -304
- package/lib/src/checkLocalHost.d.ts +0 -10
- package/lib/src/checkLocalHost.js +0 -37
- package/lib/src/config.d.ts +0 -13
- package/lib/src/config.js +0 -42
- package/lib/src/html-parser.d.ts +0 -9
- package/lib/src/html-parser.js +0 -26
- package/lib/src/log.d.ts +0 -1
- package/lib/src/log.js +0 -11
- package/lib/src/logger.d.ts +0 -3
- package/lib/src/logger.js +0 -25
- package/lib/src/md5.d.ts +0 -2
- package/lib/src/md5.js +0 -165
- package/lib/src/safestringify.d.ts +0 -2
- package/lib/src/safestringify.js +0 -125
- package/lib/src/utils.d.ts +0 -31
- package/lib/src/utils.js +0 -159
- package/lib/src/versionParser.d.ts +0 -27
- package/lib/src/versionParser.js +0 -40
- package/packages/hexo-cli-extras/.eslintrc +0 -13
- package/packages/hexo-cli-extras/LICENSE.md +0 -20
- package/packages/hexo-cli-extras/README.md +0 -146
- package/packages/hexo-cli-extras/docs/basic.gif +0 -0
- package/packages/hexo-cli-extras/docs/gui.gif +0 -0
- package/packages/hexo-cli-extras/docs/remove.png +0 -0
- package/packages/hexo-cli-extras/docs/rename.png +0 -0
- package/packages/hexo-cli-extras/index.js +0 -48
- package/packages/hexo-cli-extras/lib/edit.js +0 -209
- package/packages/hexo-cli-extras/lib/env.js +0 -52
- package/packages/hexo-cli-extras/lib/extensions.js +0 -23
- package/packages/hexo-cli-extras/lib/integrate.js +0 -87
- package/packages/hexo-cli-extras/lib/isolate.js +0 -179
- package/packages/hexo-cli-extras/lib/remove.js +0 -145
- package/packages/hexo-cli-extras/lib/rename.js +0 -171
- package/packages/hexo-cli-extras/package.json +0 -34
- package/packages/hexo-extend-injector2/.eslintrc +0 -4
- package/packages/hexo-extend-injector2/.github/workflows/linter.yml +0 -27
- package/packages/hexo-extend-injector2/.github/workflows/tester.yml +0 -24
- package/packages/hexo-extend-injector2/.vscode/settings.json +0 -10
- package/packages/hexo-extend-injector2/LICENSE +0 -165
- package/packages/hexo-extend-injector2/README-ZH.md +0 -189
- package/packages/hexo-extend-injector2/README.md +0 -191
- package/packages/hexo-extend-injector2/USAGE.md +0 -38
- package/packages/hexo-extend-injector2/index.js +0 -14
- package/packages/hexo-extend-injector2/lib/bundle/css-bundle.js +0 -79
- package/packages/hexo-extend-injector2/lib/bundle/css-generator.js +0 -13
- package/packages/hexo-extend-injector2/lib/bundle/handle-data-pre.js +0 -29
- package/packages/hexo-extend-injector2/lib/bundle/js-bundle.js +0 -42
- package/packages/hexo-extend-injector2/lib/bundle/js-generator.js +0 -10
- package/packages/hexo-extend-injector2/lib/default-config.js +0 -52
- package/packages/hexo-extend-injector2/lib/filter.js +0 -24
- package/packages/hexo-extend-injector2/lib/helper/injector.js +0 -6
- package/packages/hexo-extend-injector2/lib/helper/next-inject.js +0 -14
- package/packages/hexo-extend-injector2/lib/injector.js +0 -128
- package/packages/hexo-extend-injector2/lib/load.js +0 -45
- package/packages/hexo-extend-injector2/lib/next-point.js +0 -19
- package/packages/hexo-extend-injector2/lib/next.js +0 -87
- package/packages/hexo-extend-injector2/lib/order.js +0 -9
- package/packages/hexo-extend-injector2/package.json +0 -49
- package/packages/hexo-extend-injector2/renovate.json +0 -6
- package/packages/hexo-extend-injector2/test/.eslintrc +0 -3
- package/packages/hexo-extend-injector2/test/index.js +0 -18
- package/packages/hexo-extend-injector2/test/lib/bundle/bundle-css.js +0 -86
- package/packages/hexo-extend-injector2/test/lib/bundle/bundle-js.js +0 -36
- package/packages/hexo-extend-injector2/test/lib/bundle/test.css +0 -3
- package/packages/hexo-extend-injector2/test/lib/bundle/test.js +0 -5
- package/packages/hexo-extend-injector2/test/lib/helper/injector.js +0 -45
- package/packages/hexo-extend-injector2/test/lib/helper/next-inject.js +0 -69
- package/packages/hexo-extend-injector2/test/lib/hexo-compatible.js +0 -250
- package/packages/hexo-extend-injector2/test/lib/hexo-injector.js +0 -37
- package/packages/hexo-extend-injector2/test/lib/injector.js +0 -93
- package/packages/memoize/CHANGELOG.md +0 -82
- package/packages/memoize/CHANGES +0 -124
- package/packages/memoize/LICENSE +0 -15
- package/packages/memoize/README.md +0 -503
- package/packages/memoize/ext/async.js +0 -154
- package/packages/memoize/ext/dispose.js +0 -33
- package/packages/memoize/ext/max-age.js +0 -90
- package/packages/memoize/ext/max.js +0 -27
- package/packages/memoize/ext/promise.js +0 -147
- package/packages/memoize/ext/ref-counter.js +0 -48
- package/packages/memoize/index.js +0 -34
- package/packages/memoize/lib/configure-map.js +0 -182
- package/packages/memoize/lib/methods.js +0 -32
- package/packages/memoize/lib/registered-extensions.js +0 -1
- package/packages/memoize/lib/resolve-length.js +0 -15
- package/packages/memoize/lib/resolve-normalize.js +0 -17
- package/packages/memoize/lib/resolve-resolve.js +0 -21
- package/packages/memoize/lib/weak.js +0 -134
- package/packages/memoize/methods-plain.js +0 -3
- package/packages/memoize/methods.js +0 -3
- package/packages/memoize/normalizers/get-1.js +0 -29
- package/packages/memoize/normalizers/get-fixed.js +0 -71
- package/packages/memoize/normalizers/get-primitive-fixed.js +0 -16
- package/packages/memoize/normalizers/get.js +0 -90
- package/packages/memoize/normalizers/primitive.js +0 -9
- package/packages/memoize/package.json +0 -60
- package/packages/memoize/plain.js +0 -37
- package/packages/memoize/profile.js +0 -107
- package/packages/memoize/repository.md +0 -1
- package/packages/memoize/weak-plain.js +0 -3
- package/packages/memoize/weak.js +0 -3
- package/unused.md +0 -12
|
@@ -1,250 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
describe('hexo\'s injector compatible', () => {
|
|
4
|
-
const content = [
|
|
5
|
-
'<!DOCTYPE html>',
|
|
6
|
-
'<html lang="en">',
|
|
7
|
-
'<head id="head"><title>Test</title>',
|
|
8
|
-
'</head>',
|
|
9
|
-
'<body id="body">',
|
|
10
|
-
'<div></div>',
|
|
11
|
-
'<p></p>',
|
|
12
|
-
'</body>',
|
|
13
|
-
'</html>'
|
|
14
|
-
].join('');
|
|
15
|
-
|
|
16
|
-
const Injector = require('./hexo-injector');
|
|
17
|
-
|
|
18
|
-
it('register() - entry is required', () => {
|
|
19
|
-
const i = new Injector();
|
|
20
|
-
|
|
21
|
-
// no name
|
|
22
|
-
try {
|
|
23
|
-
i.register();
|
|
24
|
-
} catch (err) {
|
|
25
|
-
err.should.be
|
|
26
|
-
.instanceOf(TypeError)
|
|
27
|
-
.property('message', 'entry is required');
|
|
28
|
-
}
|
|
29
|
-
});
|
|
30
|
-
|
|
31
|
-
it('register() - string', () => {
|
|
32
|
-
const i = new Injector();
|
|
33
|
-
|
|
34
|
-
const str = '<link rel="stylesheet" href="DPlayer.min.css" />';
|
|
35
|
-
i.register('head_begin', str);
|
|
36
|
-
i.register('head_end', str, 'home');
|
|
37
|
-
|
|
38
|
-
i.get('head_begin').should.contains(str);
|
|
39
|
-
i.get('head_begin', 'default').should.contains(str);
|
|
40
|
-
i.get('head_end', 'home').should.contains(str);
|
|
41
|
-
});
|
|
42
|
-
|
|
43
|
-
it('register() - function', () => {
|
|
44
|
-
const i = new Injector();
|
|
45
|
-
|
|
46
|
-
const fn = () => '<link rel="stylesheet" href="DPlayer.min.css" />';
|
|
47
|
-
i.register('head_begin', fn);
|
|
48
|
-
|
|
49
|
-
i.get('head_begin').should.contains(fn());
|
|
50
|
-
});
|
|
51
|
-
|
|
52
|
-
it.skip('register() - fallback when entry not exists', () => {
|
|
53
|
-
const i = new Injector();
|
|
54
|
-
|
|
55
|
-
const str = '<link rel="stylesheet" href="DPlayer.min.css" />';
|
|
56
|
-
i.register('foo', str);
|
|
57
|
-
|
|
58
|
-
i.get('head_end').should.contains(str);
|
|
59
|
-
});
|
|
60
|
-
|
|
61
|
-
it.skip('list()', () => {
|
|
62
|
-
const i = new Injector();
|
|
63
|
-
|
|
64
|
-
i.register('body_begin', '<script src="DPlayer.min.js"></script>');
|
|
65
|
-
|
|
66
|
-
i.list().body_begin.default.should.be.instanceOf(Set);
|
|
67
|
-
[...i.list().body_begin.default].should.not.be.empty;
|
|
68
|
-
});
|
|
69
|
-
|
|
70
|
-
it('get()', () => {
|
|
71
|
-
const i = new Injector();
|
|
72
|
-
const str = '<script src="jquery.min.js"></script>';
|
|
73
|
-
|
|
74
|
-
i.register('body_begin', str);
|
|
75
|
-
i.register('body_end', str, 'home');
|
|
76
|
-
|
|
77
|
-
i.get('body_begin').should.be.instanceOf(Array);
|
|
78
|
-
i.get('body_begin').should.contains(str);
|
|
79
|
-
i.get('body_end', 'home').should.be.instanceOf(Array);
|
|
80
|
-
i.get('body_end', 'home').should.contains(str);
|
|
81
|
-
|
|
82
|
-
i.get('head_end').should.be.instanceOf(Array);
|
|
83
|
-
i.get('head_end').should.eql([]);
|
|
84
|
-
});
|
|
85
|
-
|
|
86
|
-
it('getText()', () => {
|
|
87
|
-
const i = new Injector();
|
|
88
|
-
const str = '<script src="jquery.min.js"></script>';
|
|
89
|
-
|
|
90
|
-
i.register('head_end', str);
|
|
91
|
-
i.register('body_end', str, 'home');
|
|
92
|
-
|
|
93
|
-
i.getText('body_end', 'home').should.eql(str);
|
|
94
|
-
i.getText('body_end').should.eql('');
|
|
95
|
-
});
|
|
96
|
-
|
|
97
|
-
it('getSize()', () => {
|
|
98
|
-
const i = new Injector();
|
|
99
|
-
const str = '<script src="jquery.min.js"></script>';
|
|
100
|
-
|
|
101
|
-
i.register('head_end', str);
|
|
102
|
-
i.register('body_end', str);
|
|
103
|
-
i.register('body_end', str, 'home');
|
|
104
|
-
|
|
105
|
-
i.getSize('head_begin').should.eql(0);
|
|
106
|
-
i.getSize('head_end').should.eql(1);
|
|
107
|
-
i.getSize('body_end').should.eql(2);
|
|
108
|
-
});
|
|
109
|
-
|
|
110
|
-
it.skip('exec() - default', () => {
|
|
111
|
-
const i = new Injector();
|
|
112
|
-
const result = i.exec(content);
|
|
113
|
-
result.should.contain('<head id="head"><title>Test</title></head>');
|
|
114
|
-
result.should.contain('<body id="body"><div></div><p></p></body>');
|
|
115
|
-
});
|
|
116
|
-
|
|
117
|
-
it.skip('exec() - default', () => {
|
|
118
|
-
const i = new Injector();
|
|
119
|
-
const result = i.exec(content);
|
|
120
|
-
result.should.contain('<head id="head"><title>Test</title></head>');
|
|
121
|
-
result.should.contain('<body id="body"><div></div><p></p></body>');
|
|
122
|
-
});
|
|
123
|
-
|
|
124
|
-
it.skip('exec() - insert code', () => {
|
|
125
|
-
const i = new Injector();
|
|
126
|
-
|
|
127
|
-
i.register('head_begin', '<!-- Powered by Hexo -->');
|
|
128
|
-
i.register('head_end', '<link href="prism.css" rel="stylesheet">');
|
|
129
|
-
i.register('head_end', '<link href="prism-linenumber.css" rel="stylesheet">');
|
|
130
|
-
i.register('body_begin', '<script>window.Prism = window.Prism || {}; window.Prism.manual = true;</script>');
|
|
131
|
-
i.register('body_end', '<script src="prism.js"></script>');
|
|
132
|
-
|
|
133
|
-
const result = i.exec(content);
|
|
134
|
-
|
|
135
|
-
result.should.contain('<head id="head"><!-- hexo injector head_begin start --><!-- Powered by Hexo --><!-- hexo injector head_begin end -->');
|
|
136
|
-
result.should.contain('<!-- hexo injector head_end start --><link href="prism.css" rel="stylesheet"><link href="prism-linenumber.css" rel="stylesheet"><!-- hexo injector head_end end --></head>');
|
|
137
|
-
result.should.contain('<body id="body"><!-- hexo injector body_begin start --><script>window.Prism = window.Prism || {}; window.Prism.manual = true;</script><!-- hexo injector body_begin end -->');
|
|
138
|
-
result.should.contain('<!-- hexo injector body_end start --><script src="prism.js"></script><!-- hexo injector body_end end --></body>');
|
|
139
|
-
});
|
|
140
|
-
|
|
141
|
-
it.skip('exec() - no duplicate insert', () => {
|
|
142
|
-
const content = [
|
|
143
|
-
'<!DOCTYPE html>',
|
|
144
|
-
'<html lang="en">',
|
|
145
|
-
'<head id="head"><!-- hexo injector head_begin start --><!-- hexo injector head_begin end -->',
|
|
146
|
-
'<title>Test</title>',
|
|
147
|
-
'<!-- hexo injector head_end start --><link href="prism.css" rel="stylesheet"></head>',
|
|
148
|
-
'<body id="body"><!-- hexo injector body_begin start --><!-- hexo injector body_begin end -->',
|
|
149
|
-
'<div></div>',
|
|
150
|
-
'<p></p>',
|
|
151
|
-
'<!-- hexo injector body_end start --><script src="prism.js"></script><!-- hexo injector body_end end --></body>',
|
|
152
|
-
'</html>'
|
|
153
|
-
].join('');
|
|
154
|
-
|
|
155
|
-
const i = new Injector();
|
|
156
|
-
|
|
157
|
-
i.register('head_begin', '<!-- Powered by Hexo -->');
|
|
158
|
-
i.register('head_end', '<link href="prism.css" rel="stylesheet">');
|
|
159
|
-
i.register('head_end', '<link href="prism-linenumber.css" rel="stylesheet">');
|
|
160
|
-
i.register('body_begin', '<script>window.Prism = window.Prism || {}; window.Prism.manual = true;</script>');
|
|
161
|
-
i.register('body_end', '<script src="prism.js"></script>');
|
|
162
|
-
|
|
163
|
-
const result = i.exec(content);
|
|
164
|
-
|
|
165
|
-
result.should.contain('<head id="head"><!-- hexo injector head_begin start --><!-- hexo injector head_begin end -->');
|
|
166
|
-
result.should.contain('<!-- hexo injector head_end start --><link href="prism.css" rel="stylesheet"></head>');
|
|
167
|
-
result.should.contain('<body id="body"><!-- hexo injector body_begin start --><!-- hexo injector body_begin end -->');
|
|
168
|
-
result.should.contain('<!-- hexo injector body_end start --><script src="prism.js"></script><!-- hexo injector body_end end --></body>');
|
|
169
|
-
});
|
|
170
|
-
|
|
171
|
-
it.skip('exec() - multi-line head & body', () => {
|
|
172
|
-
const content = [
|
|
173
|
-
'<!DOCTYPE html>',
|
|
174
|
-
'<html lang="en">',
|
|
175
|
-
'<head id="head"><title>Test</title>',
|
|
176
|
-
'</head>',
|
|
177
|
-
'<body id="body">',
|
|
178
|
-
'<div></div>',
|
|
179
|
-
'<p></p>',
|
|
180
|
-
'</body>',
|
|
181
|
-
'</html>'
|
|
182
|
-
].join('\n');
|
|
183
|
-
|
|
184
|
-
const i = new Injector();
|
|
185
|
-
|
|
186
|
-
i.register('head_begin', '<!-- Powered by Hexo -->');
|
|
187
|
-
i.register('head_end', '<link href="prism.css" rel="stylesheet">');
|
|
188
|
-
i.register('head_end', '<link href="prism-linenumber.css" rel="stylesheet">');
|
|
189
|
-
i.register('body_begin', '<script>window.Prism = window.Prism || {}; window.Prism.manual = true;</script>');
|
|
190
|
-
i.register('body_end', '<script src="prism.js"></script>');
|
|
191
|
-
|
|
192
|
-
const result = i.exec(content);
|
|
193
|
-
|
|
194
|
-
result.should.contain('<head id="head"><!-- hexo injector head_begin start --><!-- Powered by Hexo --><!-- hexo injector head_begin end -->');
|
|
195
|
-
result.should.contain('<!-- hexo injector head_end start --><link href="prism.css" rel="stylesheet"><link href="prism-linenumber.css" rel="stylesheet"><!-- hexo injector head_end end --></head>');
|
|
196
|
-
result.should.contain('<body id="body"><!-- hexo injector body_begin start --><script>window.Prism = window.Prism || {}; window.Prism.manual = true;</script><!-- hexo injector body_begin end -->');
|
|
197
|
-
result.should.contain('<!-- hexo injector body_end start --><script src="prism.js"></script><!-- hexo injector body_end end --></body>');
|
|
198
|
-
});
|
|
199
|
-
|
|
200
|
-
it.skip('exec() - inject on specific page', () => {
|
|
201
|
-
const content = [
|
|
202
|
-
'<!DOCTYPE html>',
|
|
203
|
-
'<html lang="en">',
|
|
204
|
-
'<head id="head"><title>Test</title>',
|
|
205
|
-
'</head>',
|
|
206
|
-
'<body id="body">',
|
|
207
|
-
'<div></div>',
|
|
208
|
-
'<p></p>',
|
|
209
|
-
'</body>',
|
|
210
|
-
'</html>'
|
|
211
|
-
].join('\n');
|
|
212
|
-
|
|
213
|
-
const i = new Injector();
|
|
214
|
-
|
|
215
|
-
i.register('head_begin', '<!-- head_begin_default -->');
|
|
216
|
-
i.register('head_begin', '<!-- head_begin_home -->', 'home');
|
|
217
|
-
i.register('head_begin', '<!-- head_begin_post -->', 'post');
|
|
218
|
-
i.register('head_begin', '<!-- head_begin_page -->', 'page');
|
|
219
|
-
i.register('head_begin', '<!-- head_begin_archive -->', 'archive');
|
|
220
|
-
i.register('head_begin', '<!-- head_begin_category -->', 'category');
|
|
221
|
-
i.register('head_begin', '<!-- head_begin_tag -->', 'tag');
|
|
222
|
-
|
|
223
|
-
const result1 = i.exec(content, { page: {} });
|
|
224
|
-
const result2 = i.exec(content, { page: { __index: true } });
|
|
225
|
-
const result3 = i.exec(content, { page: { __post: true } });
|
|
226
|
-
const result4 = i.exec(content, { page: { __page: true } });
|
|
227
|
-
const result5 = i.exec(content, { page: { archive: true } });
|
|
228
|
-
const result6 = i.exec(content, { page: { category: true } });
|
|
229
|
-
const result7 = i.exec(content, { page: { tag: true } });
|
|
230
|
-
|
|
231
|
-
// home
|
|
232
|
-
result1.should.not.contain('<!-- head_begin_home -->');
|
|
233
|
-
result2.should.contain('<!-- head_begin_home --><!-- head_begin_default -->');
|
|
234
|
-
// post
|
|
235
|
-
result1.should.not.contain('<!-- head_begin_post -->');
|
|
236
|
-
result3.should.contain('<!-- head_begin_post --><!-- head_begin_default -->');
|
|
237
|
-
// page
|
|
238
|
-
result1.should.not.contain('<!-- head_begin_page -->');
|
|
239
|
-
result4.should.contain('<!-- head_begin_page --><!-- head_begin_default -->');
|
|
240
|
-
// archive
|
|
241
|
-
result1.should.not.contain('<!-- head_begin_archive -->');
|
|
242
|
-
result5.should.contain('<!-- head_begin_archive --><!-- head_begin_default -->');
|
|
243
|
-
// category
|
|
244
|
-
result1.should.not.contain('<!-- head_begin_category -->');
|
|
245
|
-
result6.should.contain('<!-- head_begin_category --><!-- head_begin_default -->');
|
|
246
|
-
// tag
|
|
247
|
-
result1.should.not.contain('<!-- head_begin_tag -->');
|
|
248
|
-
result7.should.contain('<!-- head_begin_tag --><!-- head_begin_default -->');
|
|
249
|
-
});
|
|
250
|
-
});
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
const Hexo = require('hexo');
|
|
4
|
-
const hexo = new Hexo();
|
|
5
|
-
|
|
6
|
-
const getLocalsFromType = type => {
|
|
7
|
-
let options;
|
|
8
|
-
switch (type) {
|
|
9
|
-
case 'default': options = {context: {page: {}}}; break;
|
|
10
|
-
case 'home': options = {context: {page: {__index: true}}}; break;
|
|
11
|
-
case 'post': options = {context: {page: {__post: true}}}; break;
|
|
12
|
-
case 'page': options = {context: {page: {__page: true}}}; break;
|
|
13
|
-
case 'archive': options = {context: {page: {archive: true}}}; break;
|
|
14
|
-
case 'category': options = {context: {page: {category: true}}}; break;
|
|
15
|
-
case 'tag': options = {context: {page: {tag: true}}}; break;
|
|
16
|
-
default: options = {context: {page: {layout: type}}}; break;
|
|
17
|
-
}
|
|
18
|
-
return options;
|
|
19
|
-
};
|
|
20
|
-
|
|
21
|
-
const Injector2 = require('../../lib/injector');
|
|
22
|
-
class Injector extends Injector2 {
|
|
23
|
-
constructor() {
|
|
24
|
-
super(hexo);
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
get(entry, to = 'default') {
|
|
28
|
-
const options = getLocalsFromType(to);
|
|
29
|
-
return super.get(entry, options).rendered().map(item => item.value);
|
|
30
|
-
}
|
|
31
|
-
getText(entry, to = 'default') {
|
|
32
|
-
const options = getLocalsFromType(to);
|
|
33
|
-
return super.get(entry, options).text();
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
module.exports = Injector;
|
|
@@ -1,93 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
require('chai').should();
|
|
4
|
-
const Injector = require('../../lib/injector');
|
|
5
|
-
const Hexo = require('hexo');
|
|
6
|
-
const hexo = new Hexo();
|
|
7
|
-
|
|
8
|
-
describe('injector', () => {
|
|
9
|
-
|
|
10
|
-
it('basic', () => {
|
|
11
|
-
const injector = new Injector(hexo);
|
|
12
|
-
injector.register('body-end', 'a');
|
|
13
|
-
injector.register('body-end', 'b');
|
|
14
|
-
injector.get('body-end').list().should.have.lengthOf(2);
|
|
15
|
-
injector.get('body-end').text().should.eql('ab');
|
|
16
|
-
});
|
|
17
|
-
|
|
18
|
-
it('format key', () => {
|
|
19
|
-
const injector = new Injector(hexo);
|
|
20
|
-
const registerKey = 'o n_e-tW o';
|
|
21
|
-
injector.register(registerKey, 'a');
|
|
22
|
-
injector.formatKey(registerKey).should.eql('onetwo');
|
|
23
|
-
});
|
|
24
|
-
|
|
25
|
-
it('value is function, should render when call rendered', () => {
|
|
26
|
-
const injector = new Injector(hexo);
|
|
27
|
-
injector.register('one', () => 'a');
|
|
28
|
-
injector.get('one').rendered()[0].should.include({value: 'a'});
|
|
29
|
-
});
|
|
30
|
-
|
|
31
|
-
it('exec predicate', () => {
|
|
32
|
-
const injector = new Injector(hexo);
|
|
33
|
-
const homeEnv = {page: {__index: true}};
|
|
34
|
-
const postEnv = {page: {__post: true}};
|
|
35
|
-
const pageEnv = {page: {__page: true}};
|
|
36
|
-
injector.register('one', 'a', 'home');
|
|
37
|
-
injector.register('one', 'b', 'post');
|
|
38
|
-
injector.register('one', 'c', injector.is('post', 'page'));
|
|
39
|
-
injector.register('one', 'd', ctx => ctx.page.__index || ctx.page.__page);
|
|
40
|
-
injector.get('one', {context: homeEnv}).text().should.eql('ad');
|
|
41
|
-
injector.get('one', {context: postEnv}).text().should.eql('bc');
|
|
42
|
-
injector.get('one', {context: pageEnv}).text().should.eql('cd');
|
|
43
|
-
});
|
|
44
|
-
|
|
45
|
-
it('exec priority', () => {
|
|
46
|
-
const injector = new Injector(hexo);
|
|
47
|
-
injector.register('one', 'a', () => true, 2);
|
|
48
|
-
injector.register('one', 'b', () => true, 1);
|
|
49
|
-
injector.get('one').text().should.eql('ba');
|
|
50
|
-
});
|
|
51
|
-
|
|
52
|
-
it('should be clean when isRun is true', () => {
|
|
53
|
-
const injector = new Injector(hexo);
|
|
54
|
-
injector.register('one', 'a', () => true, 2, true);
|
|
55
|
-
injector.register('one', 'b', () => true, 1, false);
|
|
56
|
-
injector.clean();
|
|
57
|
-
injector.get('one').text().should.eql('b');
|
|
58
|
-
});
|
|
59
|
-
|
|
60
|
-
it('getSize()', () => {
|
|
61
|
-
const injector = new Injector(hexo);
|
|
62
|
-
injector.register('one', 'a', () => true, 2, true);
|
|
63
|
-
injector.register('one', 'b', () => true, 1, false);
|
|
64
|
-
injector.register('two', 'c', () => true, 1, true);
|
|
65
|
-
injector.register('three', 'c', () => true, 1, false);
|
|
66
|
-
injector.getSize('one').should.eql(2);
|
|
67
|
-
injector.getSize('two').should.eql(1);
|
|
68
|
-
injector.getSize('three').should.eql(1);
|
|
69
|
-
injector.getSize('four').should.eql(0);
|
|
70
|
-
injector.clean();
|
|
71
|
-
injector.getSize('one').should.eql(1);
|
|
72
|
-
injector.getSize('two').should.eql(0);
|
|
73
|
-
injector.getSize('three').should.eql(1);
|
|
74
|
-
injector.getSize('four').should.eql(0);
|
|
75
|
-
});
|
|
76
|
-
|
|
77
|
-
it('exec filter', () => {
|
|
78
|
-
const newHexo = new Hexo();
|
|
79
|
-
const injector = new Injector(newHexo);
|
|
80
|
-
newHexo.extend.filter.register('injector2:register', data => {
|
|
81
|
-
data.value += 'x';
|
|
82
|
-
});
|
|
83
|
-
newHexo.extend.filter.register('injector2:register-bodyend', data => {
|
|
84
|
-
data.value += 'bodyend';
|
|
85
|
-
});
|
|
86
|
-
injector.register('body-end', 'a');
|
|
87
|
-
injector.register('body-end', 'b');
|
|
88
|
-
injector.register('one', 'a', () => true, 2, true);
|
|
89
|
-
injector.get('bodyend').text().should.eql('axbodyendbxbodyend');
|
|
90
|
-
injector.get('one').text().should.eql('ax');
|
|
91
|
-
});
|
|
92
|
-
|
|
93
|
-
});
|
|
@@ -1,82 +0,0 @@
|
|
|
1
|
-
# Changelog
|
|
2
|
-
|
|
3
|
-
All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
|
|
4
|
-
|
|
5
|
-
### [0.4.15](https://github.com/medikoo/memoizee/compare/v0.4.14...v0.4.15) (2021-01-08)
|
|
6
|
-
|
|
7
|
-
_Maintainance update_
|
|
8
|
-
|
|
9
|
-
<a name="0.4.14"></a>
|
|
10
|
-
|
|
11
|
-
## [0.4.14](https://github.com/medikoo/memoizee/compare/v0.4.13...v0.4.14) (2018-08-13)
|
|
12
|
-
|
|
13
|
-
### Bug Fixes
|
|
14
|
-
|
|
15
|
-
- ensure to not force unhandled rejections ([9b416ea](https://github.com/medikoo/memoizee/commit/9b416ea))
|
|
16
|
-
|
|
17
|
-
<a name="0.4.13"></a>
|
|
18
|
-
|
|
19
|
-
## [0.4.13](https://github.com/medikoo/memoizee/compare/v0.4.12...v0.4.13) (2018-08-06)
|
|
20
|
-
|
|
21
|
-
### Features
|
|
22
|
-
|
|
23
|
-
- **promise:** support cancellation case ([b4b018d](https://github.com/medikoo/memoizee/commit/b4b018d)), closes [#97](https://github.com/medikoo/memoizee/issues/97)
|
|
24
|
-
|
|
25
|
-
<a name="0.4.12"></a>
|
|
26
|
-
|
|
27
|
-
## [0.4.12](https://github.com/medikoo/memoizee/compare/v0.4.11...v0.4.12) (2018-02-23)
|
|
28
|
-
|
|
29
|
-
### Bug Fixes
|
|
30
|
-
|
|
31
|
-
- **max-age:** unref timeouts to not block processes from exiting ([5bcc5a4](https://github.com/medikoo/memoizee/commit/5bcc5a4)), closes [#25](https://github.com/medikoo/memoizee/issues/25)
|
|
32
|
-
|
|
33
|
-
<a name="0.4.11"></a>
|
|
34
|
-
|
|
35
|
-
## [0.4.11](https://github.com/medikoo/memoizee/compare/v0.4.10...v0.4.11) (2017-09-11)
|
|
36
|
-
|
|
37
|
-
### Bug Fixes
|
|
38
|
-
|
|
39
|
-
- \_get and \_has internal args handling. ([7cb1c7a](https://github.com/medikoo/memoizee/commit/7cb1c7a)), closes [#88](https://github.com/medikoo/memoizee/issues/88)
|
|
40
|
-
|
|
41
|
-
<a name="0.4.10"></a>
|
|
42
|
-
|
|
43
|
-
## [0.4.10](https://github.com/medikoo/memoizee/compare/v0.4.9...v0.4.10) (2017-09-07)
|
|
44
|
-
|
|
45
|
-
### Bug Fixes
|
|
46
|
-
|
|
47
|
-
- remove then:finally mode as it can't work right ([5b79698](https://github.com/medikoo/memoizee/commit/5b79698))
|
|
48
|
-
|
|
49
|
-
<a name="0.4.9"></a>
|
|
50
|
-
|
|
51
|
-
## [0.4.9](https://github.com/medikoo/memoizee/compare/v0.4.8...v0.4.9) (2017-08-29)
|
|
52
|
-
|
|
53
|
-
<a name="0.4.8"></a>
|
|
54
|
-
|
|
55
|
-
## [0.4.8](https://github.com/medikoo/memoizee/compare/v0.4.7...v0.4.8) (2017-08-29)
|
|
56
|
-
|
|
57
|
-
<a name="0.4.7"></a>
|
|
58
|
-
|
|
59
|
-
## [0.4.7](https://github.com/medikoo/memoizee/compare/v0.4.6...v0.4.7) (2017-08-29)
|
|
60
|
-
|
|
61
|
-
### Features
|
|
62
|
-
|
|
63
|
-
- improve 'promise' mode handling ([759e315](https://github.com/medikoo/memoizee/commit/759e315))
|
|
64
|
-
- improve internal promise validation ([d23b94f](https://github.com/medikoo/memoizee/commit/d23b94f))
|
|
65
|
-
|
|
66
|
-
<a name="0.4.6"></a>
|
|
67
|
-
|
|
68
|
-
## [0.4.6](https://github.com/medikoo/memoizee/compare/v0.4.5...v0.4.6) (2017-08-24)
|
|
69
|
-
|
|
70
|
-
- `profileName` option for naming memoizee instances in profile output
|
|
71
|
-
|
|
72
|
-
<a name="0.4.5"></a>
|
|
73
|
-
|
|
74
|
-
## [0.4.5](https://github.com/medikoo/memoizee/compare/v0.4.4...v0.4.5) (2017-05-10)
|
|
75
|
-
|
|
76
|
-
### Bug Fixes
|
|
77
|
-
|
|
78
|
-
- resolution of extensions with weak handling ([f29a97b](https://github.com/medikoo/memoizee/commit/f29a97b)), closes [#79](https://github.com/medikoo/memoizee/issues/79)
|
|
79
|
-
|
|
80
|
-
## Old changelog
|
|
81
|
-
|
|
82
|
-
See `CHANGES`
|
package/packages/memoize/CHANGES
DELETED
|
@@ -1,124 +0,0 @@
|
|
|
1
|
-
-- For new changelog see CHANGELOG.md
|
|
2
|
-
|
|
3
|
-
v0.4.4 -- 2017.03.15
|
|
4
|
-
* Expose _get and _has methods. It provides temporary means for better cache inspection until
|
|
5
|
-
v1 is delivered
|
|
6
|
-
|
|
7
|
-
v0.4.3 -- 2017.02.20
|
|
8
|
-
* Fix normalization resolver, so it validates already normalized resolvers (reported at #70)
|
|
9
|
-
|
|
10
|
-
v0.4.2 -- 2017.02.17
|
|
11
|
-
* Guard proper promise resolution in promise mode
|
|
12
|
-
* Improve documentation
|
|
13
|
-
* Improve npm scripts configuration
|
|
14
|
-
* Improve CI configuration
|
|
15
|
-
|
|
16
|
-
v0.4.1 -- 2016.07.13
|
|
17
|
-
* Fix promise mode to not use `then` and `finally` pair. Thanks @Kovensky
|
|
18
|
-
* Add 'done' mode to 'promise' mode (so now callbacks can be registered through `done` but no
|
|
19
|
-
`finally` event if it's implemented)
|
|
20
|
-
|
|
21
|
-
v0.4.0 -- 2016.07.07
|
|
22
|
-
* Introduce 'promise' mode
|
|
23
|
-
* Change signature of internal events for 'async' case
|
|
24
|
-
* Document 'normalizer' option
|
|
25
|
-
|
|
26
|
-
v0.3.10 -- 2016.04.21
|
|
27
|
-
* Fix resolvers bug (#12)
|
|
28
|
-
* Fix arguments support for weak mode
|
|
29
|
-
* Update repository address after rename
|
|
30
|
-
|
|
31
|
-
v0.3.9 -- 2015.08.04
|
|
32
|
-
* Update dependencies
|
|
33
|
-
* Improve documentation
|
|
34
|
-
* FIx spelling of LICENSE
|
|
35
|
-
|
|
36
|
-
v0.3.8 -- 2014.10.08
|
|
37
|
-
* Introduce WeakMap based `weak` mode
|
|
38
|
-
|
|
39
|
-
v0.3.7 -- 2014.08.14
|
|
40
|
-
* Fix prefetch support for asynchronous functions (#19)
|
|
41
|
-
* Configure lint scripts
|
|
42
|
-
|
|
43
|
-
v0.3.6 -- 2014.07.28
|
|
44
|
-
* Fix race condition issue related to clear/delete calls and returning id's (#18)
|
|
45
|
-
* Fix maxAge major cache handling issue (on timeout instead of individual record whole cache was
|
|
46
|
-
cleared)
|
|
47
|
-
|
|
48
|
-
v0.3.5 -- 2014.07.07
|
|
49
|
-
* Fix internal id genaration, for primitive, length = 1 case.
|
|
50
|
-
Ids were not serialized to strings, and that caused issues with other
|
|
51
|
-
internal logiv, which e.g. treated `null` case specifically.
|
|
52
|
-
Fixes #15 (Thanks @isaacg for reporting)
|
|
53
|
-
|
|
54
|
-
v0.3.4 -- 2014.06.22
|
|
55
|
-
* Fix async handling in case of clear between two async calls
|
|
56
|
-
(assurance of unique cache ids solves that). Fixes #13
|
|
57
|
-
|
|
58
|
-
v0.3.3 -- 2014.05.12
|
|
59
|
-
* Fix profiler special property definition
|
|
60
|
-
|
|
61
|
-
v0.3.2 -- 2014.05.01
|
|
62
|
-
* Provide no-arguments memoization out of a box
|
|
63
|
-
(no need to provide normalizer to `memoizee/plain`)
|
|
64
|
-
|
|
65
|
-
v0.3.1 -- 2014.04.27
|
|
66
|
-
* Update package.json to use latest 'tad' engine (fixes tests evaluation)
|
|
67
|
-
|
|
68
|
-
v0.3.0 -- 2014.04.27
|
|
69
|
-
Major reorganization and partial refactoring
|
|
70
|
-
* Move out main modules from lib folder
|
|
71
|
-
* Introduce normalizer based memoization. Primitive and regular handlers were converted into
|
|
72
|
-
dedicated normalizers (located in lib/normalizers folder). Custom normalizers can be provided at
|
|
73
|
-
run time via `normalizer` option.
|
|
74
|
-
* Provide 'plain' module which does not import (require) any extensions or normalizers. Thanks to
|
|
75
|
-
that it's lighter for e.g. client-side bundle. Any extensions that are expected to be used should
|
|
76
|
-
be required upfront, normalizers should be provided via `normalizer` option.
|
|
77
|
-
* Rename `memoized.clear` into `memoized.delete`, and `memoized.clearAll` into `memoized.clear`
|
|
78
|
-
* Rename `memoized.clearRef` into `memoized.deleteRef` (applies to 'refCounter' option)
|
|
79
|
-
* Remove 'method' option. Instead 'methods' and 'methods-plan' modules are provided which generate
|
|
80
|
-
descriptors for lazy created memoized methods.
|
|
81
|
-
* 'profile' is no longer an extension. It's provided as dedicated module.
|
|
82
|
-
* Clean up logic for `async` handling
|
|
83
|
-
* Take out 'max' extension's LRU logic into external `lru-queue` package.
|
|
84
|
-
See https://github.com/medikoo/lru-queue
|
|
85
|
-
* Remove possibility to access original arguments when resolvers are used
|
|
86
|
-
* Assure expected length of memoized functions
|
|
87
|
-
* Remove Makefile (it's environment agnostic package)
|
|
88
|
-
|
|
89
|
-
v0.2.6 -- 2013.10.08
|
|
90
|
-
* Fix internal events propagation when handling async calls that
|
|
91
|
-
resolve with errors. `asyncpurge` was emitted for values that had no
|
|
92
|
-
`asyncinit` emitted. Issue #9
|
|
93
|
-
|
|
94
|
-
v0.2.5 -- 2013.06.21
|
|
95
|
-
* Fix primitive handling for dynamic arguments length
|
|
96
|
-
|
|
97
|
-
v0.2.4 -- 2013.03.23
|
|
98
|
-
* Throw on circular invocations, they cannot be memoized as intended.
|
|
99
|
-
|
|
100
|
-
v0.2.3 -- 2012.10.04
|
|
101
|
-
* Fixed serious bug related to not properly cleared cache when working in
|
|
102
|
-
regular mode
|
|
103
|
-
|
|
104
|
-
v0.2.2 -- 2012.10.03
|
|
105
|
-
* preFetch functionality for maxAge variant
|
|
106
|
-
* Prevent memoization of already memoized functions
|
|
107
|
-
|
|
108
|
-
v0.2.1 -- 2012.09.21
|
|
109
|
-
* Fix missing global reference in method option logic
|
|
110
|
-
* Fix variable visibility in async option logic
|
|
111
|
-
* Lint cleanup
|
|
112
|
-
|
|
113
|
-
v0.2.0 -- 2012.09.21
|
|
114
|
-
* Modularization and general algorithm cleanup
|
|
115
|
-
* Cache is limited (max option) using LRU instead of FIFO algorithm
|
|
116
|
-
* Improved async mode, and its handling by other options
|
|
117
|
-
|
|
118
|
-
v0.1.1 -- 2012.09.19
|
|
119
|
-
* Fix dispose invocations for no arguments call
|
|
120
|
-
* Small documentation improvements
|
|
121
|
-
|
|
122
|
-
v0.1.0 -- 2012.09.18
|
|
123
|
-
* Initial. Derived from es5-ext package and added `async`, `maxAge`,
|
|
124
|
-
`refCounter`, `max` and `dispose` options.
|
package/packages/memoize/LICENSE
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
ISC License
|
|
2
|
-
|
|
3
|
-
Copyright (c) 2012-2018, Mariusz Nowak, @medikoo, medikoo.com
|
|
4
|
-
|
|
5
|
-
Permission to use, copy, modify, and/or distribute this software for any
|
|
6
|
-
purpose with or without fee is hereby granted, provided that the above
|
|
7
|
-
copyright notice and this permission notice appear in all copies.
|
|
8
|
-
|
|
9
|
-
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|
10
|
-
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
|
11
|
-
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
12
|
-
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
|
13
|
-
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
|
|
14
|
-
OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
15
|
-
PERFORMANCE OF THIS SOFTWARE.
|