hexo-component-inferno 3.1.2 → 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.
Files changed (144) hide show
  1. package/asset/js/algolia.js +51 -10
  2. package/asset/js/google_cse.js +50 -7
  3. package/asset/js/insight.js +48 -7
  4. package/lib/hexo/filter/locals.js +2 -2
  5. package/lib/schema/comment/valine.json +2 -2
  6. package/lib/schema/plugin/matomo.json +25 -0
  7. package/lib/schema/plugin/umami.json +25 -0
  8. package/lib/schema/search/algolia.json +4 -0
  9. package/lib/util/script.js +65 -0
  10. package/lib/view/comment/changyan.js +5 -5
  11. package/lib/view/comment/disqus.js +1 -1
  12. package/lib/view/comment/disqusjs.js +6 -5
  13. package/lib/view/comment/facebook.js +1 -1
  14. package/lib/view/comment/giscus.js +1 -1
  15. package/lib/view/comment/gitalk.js +6 -5
  16. package/lib/view/comment/gitment.js +6 -5
  17. package/lib/view/comment/isso.js +7 -3
  18. package/lib/view/comment/livere.js +1 -1
  19. package/lib/view/comment/twikoo.js +3 -4
  20. package/lib/view/comment/utterances.js +1 -1
  21. package/lib/view/comment/valine.js +3 -6
  22. package/lib/view/comment/waline.js +8 -7
  23. package/lib/view/common/article_media.js +2 -2
  24. package/lib/view/donate/afdian.js +1 -1
  25. package/lib/view/donate/alipay.js +1 -1
  26. package/lib/view/donate/buymeacoffee.js +1 -1
  27. package/lib/view/donate/patreon.js +1 -1
  28. package/lib/view/donate/paypal.js +1 -1
  29. package/lib/view/donate/wechat.js +1 -1
  30. package/lib/view/misc/article_licensing.js +1 -1
  31. package/lib/view/misc/meta.js +1 -1
  32. package/lib/view/misc/open_graph.js +1 -1
  33. package/lib/view/misc/paginator.js +9 -5
  34. package/lib/view/misc/structured_data.js +1 -1
  35. package/lib/view/misc/web_app.js +2 -2
  36. package/lib/view/plugin/baidu_analytics.js +1 -1
  37. package/lib/view/plugin/bing_webmaster.js +1 -1
  38. package/lib/view/plugin/busuanzi.js +1 -1
  39. package/lib/view/plugin/cnzz.js +1 -1
  40. package/lib/view/plugin/cookie_consent.js +1 -1
  41. package/lib/view/plugin/gallery.js +2 -2
  42. package/lib/view/plugin/google_analytics.js +1 -1
  43. package/lib/view/plugin/hotjar.js +1 -1
  44. package/lib/view/plugin/katex.js +1 -1
  45. package/lib/view/plugin/mathjax.js +1 -1
  46. package/lib/view/plugin/matomo.js +89 -0
  47. package/lib/view/plugin/outdated_browser.js +1 -1
  48. package/lib/view/plugin/progressbar.js +1 -1
  49. package/lib/view/plugin/statcounter.js +1 -1
  50. package/lib/view/plugin/twitter_conversion_tracking.js +1 -1
  51. package/lib/view/plugin/umami.js +88 -0
  52. package/lib/view/search/algolia.js +11 -5
  53. package/lib/view/search/baidu.js +5 -3
  54. package/lib/view/search/google_cse.js +4 -2
  55. package/lib/view/search/insight.js +1 -1
  56. package/lib/view/share/addthis.js +1 -1
  57. package/lib/view/share/addtoany.js +1 -1
  58. package/lib/view/share/bdshare.js +1 -1
  59. package/lib/view/share/sharejs.js +1 -1
  60. package/lib/view/share/sharethis.js +1 -1
  61. package/lib/view/widget/adsense.js +1 -1
  62. package/lib/view/widget/archives.js +23 -5
  63. package/lib/view/widget/categories.js +1 -1
  64. package/lib/view/widget/followit.js +1 -1
  65. package/lib/view/widget/links.js +1 -1
  66. package/lib/view/widget/recent_posts.js +1 -1
  67. package/lib/view/widget/subscribe_email.js +1 -1
  68. package/lib/view/widget/tags.js +1 -1
  69. package/lib/view/widget/toc.js +1 -1
  70. package/package.json +10 -5
  71. package/lib/core/migrate.test.js +0 -48
  72. package/lib/core/schema.test.js +0 -520
  73. package/lib/core/view.test.js +0 -41
  74. package/lib/hexo/filter/locals.test.js +0 -118
  75. package/lib/hexo/generator/assets.test.js +0 -32
  76. package/lib/hexo/generator/categories.test.js +0 -41
  77. package/lib/hexo/generator/category.test.js +0 -84
  78. package/lib/hexo/generator/insight.test.js +0 -95
  79. package/lib/hexo/generator/manifest.test.js +0 -52
  80. package/lib/hexo/generator/tags.test.js +0 -41
  81. package/lib/hexo/helper/cdn.test.js +0 -128
  82. package/lib/hexo/helper/page.test.js +0 -62
  83. package/lib/hexo/tag/message.test.js +0 -72
  84. package/lib/hexo/tag/tabs.test.js +0 -98
  85. package/lib/schema/schema/comment/changyan.json +0 -21
  86. package/lib/schema/schema/comment/disqus.json +0 -17
  87. package/lib/schema/schema/comment/disqusjs.json +0 -53
  88. package/lib/schema/schema/comment/facebook.json +0 -13
  89. package/lib/schema/schema/comment/giscus.json +0 -105
  90. package/lib/schema/schema/comment/gitalk.json +0 -81
  91. package/lib/schema/schema/comment/gitment.json +0 -47
  92. package/lib/schema/schema/comment/isso.json +0 -17
  93. package/lib/schema/schema/comment/livere.json +0 -17
  94. package/lib/schema/schema/comment/twikoo.json +0 -28
  95. package/lib/schema/schema/comment/utterances.json +0 -59
  96. package/lib/schema/schema/comment/valine.json +0 -105
  97. package/lib/schema/schema/comment/waline.json +0 -176
  98. package/lib/schema/schema/donate/afdian.json +0 -17
  99. package/lib/schema/schema/donate/alipay.json +0 -17
  100. package/lib/schema/schema/donate/buymeacoffee.json +0 -17
  101. package/lib/schema/schema/donate/patreon.json +0 -17
  102. package/lib/schema/schema/donate/paypal.json +0 -22
  103. package/lib/schema/schema/donate/wechat.json +0 -17
  104. package/lib/schema/schema/misc/manifest.json +0 -66
  105. package/lib/schema/schema/misc/meta.json +0 -11
  106. package/lib/schema/schema/misc/open_graph.json +0 -78
  107. package/lib/schema/schema/misc/poly_links.json +0 -35
  108. package/lib/schema/schema/misc/structured_data.json +0 -47
  109. package/lib/schema/schema/plugin/baidu_analytics.json +0 -14
  110. package/lib/schema/schema/plugin/bing_webmaster.json +0 -14
  111. package/lib/schema/schema/plugin/busuanzi.json +0 -7
  112. package/lib/schema/schema/plugin/cnzz.json +0 -19
  113. package/lib/schema/schema/plugin/cookie_consent.json +0 -38
  114. package/lib/schema/schema/plugin/gallery.json +0 -7
  115. package/lib/schema/schema/plugin/google_analytics.json +0 -14
  116. package/lib/schema/schema/plugin/hotjar.json +0 -14
  117. package/lib/schema/schema/plugin/katex.json +0 -7
  118. package/lib/schema/schema/plugin/mathjax.json +0 -7
  119. package/lib/schema/schema/plugin/outdated_browser.json +0 -7
  120. package/lib/schema/schema/plugin/progressbar.json +0 -7
  121. package/lib/schema/schema/plugin/statcounter.json +0 -19
  122. package/lib/schema/schema/plugin/twitter_conversion_tracking.json +0 -14
  123. package/lib/schema/schema/search/algolia.json +0 -13
  124. package/lib/schema/schema/search/baidu.json +0 -13
  125. package/lib/schema/schema/search/google_cse.json +0 -17
  126. package/lib/schema/schema/search/insight.json +0 -19
  127. package/lib/schema/schema/share/addthis.json +0 -17
  128. package/lib/schema/schema/share/addtoany.json +0 -13
  129. package/lib/schema/schema/share/bdshare.json +0 -13
  130. package/lib/schema/schema/share/sharejs.json +0 -13
  131. package/lib/schema/schema/share/sharethis.json +0 -17
  132. package/lib/schema/schema/widget/adsense.json +0 -21
  133. package/lib/schema/schema/widget/archives.json +0 -13
  134. package/lib/schema/schema/widget/categories.json +0 -13
  135. package/lib/schema/schema/widget/followit.json +0 -26
  136. package/lib/schema/schema/widget/links.json +0 -47
  137. package/lib/schema/schema/widget/recent_posts.json +0 -13
  138. package/lib/schema/schema/widget/subscribe_email.json +0 -22
  139. package/lib/schema/schema/widget/tags.json +0 -30
  140. package/lib/schema/schema/widget/toc.json +0 -31
  141. package/lib/util/cache.test.js +0 -24
  142. package/lib/util/classname.test.js +0 -13
  143. package/lib/util/yaml.test.js +0 -18
  144. package/lib/view/widget/toc.test.js +0 -30
@@ -6,7 +6,7 @@ function _classCallCheck(a, n) { if (!(a instanceof n)) throw new TypeError("Can
6
6
  function _defineProperties(e, r) { for (var t = 0; t < r.length; t++) { var o = r[t]; o.enumerable = o.enumerable || !1, o.configurable = !0, "value" in o && (o.writable = !0), Object.defineProperty(e, _toPropertyKey(o.key), o); } }
7
7
  function _createClass(e, r, t) { return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, "prototype", { writable: !1 }), e; }
8
8
  function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
9
- function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
9
+ function _toPrimitive(t, e) { if ("object" != _typeof(t) || !t) return t; var r; if ("undefined" != typeof Symbol && void 0 !== (r = t[Symbol.toPrimitive])) { var i = r.call(t, e || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === e ? String : Number)(t); }
10
10
  function _callSuper(t, o, e) { return o = _getPrototypeOf(o), _possibleConstructorReturn(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], _getPrototypeOf(t).constructor) : o.apply(t, e)); }
11
11
  function _possibleConstructorReturn(t, e) { if (e && ("object" == _typeof(e) || "function" == typeof e)) return e; if (void 0 !== e) throw new TypeError("Derived constructors may only return object or undefined"); return _assertThisInitialized(t); }
12
12
  function _assertThisInitialized(e) { if (void 0 === e) throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); return e; }
@@ -6,7 +6,7 @@ function _classCallCheck(a, n) { if (!(a instanceof n)) throw new TypeError("Can
6
6
  function _defineProperties(e, r) { for (var t = 0; t < r.length; t++) { var o = r[t]; o.enumerable = o.enumerable || !1, o.configurable = !0, "value" in o && (o.writable = !0), Object.defineProperty(e, _toPropertyKey(o.key), o); } }
7
7
  function _createClass(e, r, t) { return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, "prototype", { writable: !1 }), e; }
8
8
  function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
9
- function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
9
+ function _toPrimitive(t, e) { if ("object" != _typeof(t) || !t) return t; var r; if ("undefined" != typeof Symbol && void 0 !== (r = t[Symbol.toPrimitive])) { var i = r.call(t, e || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === e ? String : Number)(t); }
10
10
  function _callSuper(t, o, e) { return o = _getPrototypeOf(o), _possibleConstructorReturn(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], _getPrototypeOf(t).constructor) : o.apply(t, e)); }
11
11
  function _possibleConstructorReturn(t, e) { if (e && ("object" == _typeof(e) || "function" == typeof e)) return e; if (void 0 !== e) throw new TypeError("Derived constructors may only return object or undefined"); return _assertThisInitialized(t); }
12
12
  function _assertThisInitialized(e) { if (void 0 === e) throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); return e; }
@@ -6,7 +6,7 @@ function _classCallCheck(a, n) { if (!(a instanceof n)) throw new TypeError("Can
6
6
  function _defineProperties(e, r) { for (var t = 0; t < r.length; t++) { var o = r[t]; o.enumerable = o.enumerable || !1, o.configurable = !0, "value" in o && (o.writable = !0), Object.defineProperty(e, _toPropertyKey(o.key), o); } }
7
7
  function _createClass(e, r, t) { return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, "prototype", { writable: !1 }), e; }
8
8
  function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
9
- function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
9
+ function _toPrimitive(t, e) { if ("object" != _typeof(t) || !t) return t; var r; if ("undefined" != typeof Symbol && void 0 !== (r = t[Symbol.toPrimitive])) { var i = r.call(t, e || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === e ? String : Number)(t); }
10
10
  function _callSuper(t, o, e) { return o = _getPrototypeOf(o), _possibleConstructorReturn(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], _getPrototypeOf(t).constructor) : o.apply(t, e)); }
11
11
  function _possibleConstructorReturn(t, e) { if (e && ("object" == _typeof(e) || "function" == typeof e)) return e; if (void 0 !== e) throw new TypeError("Derived constructors may only return object or undefined"); return _assertThisInitialized(t); }
12
12
  function _assertThisInitialized(e) { if (void 0 === e) throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); return e; }
@@ -6,7 +6,7 @@ function _classCallCheck(a, n) { if (!(a instanceof n)) throw new TypeError("Can
6
6
  function _defineProperties(e, r) { for (var t = 0; t < r.length; t++) { var o = r[t]; o.enumerable = o.enumerable || !1, o.configurable = !0, "value" in o && (o.writable = !0), Object.defineProperty(e, _toPropertyKey(o.key), o); } }
7
7
  function _createClass(e, r, t) { return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, "prototype", { writable: !1 }), e; }
8
8
  function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
9
- function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
9
+ function _toPrimitive(t, e) { if ("object" != _typeof(t) || !t) return t; var r; if ("undefined" != typeof Symbol && void 0 !== (r = t[Symbol.toPrimitive])) { var i = r.call(t, e || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === e ? String : Number)(t); }
10
10
  function _callSuper(t, o, e) { return o = _getPrototypeOf(o), _possibleConstructorReturn(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], _getPrototypeOf(t).constructor) : o.apply(t, e)); }
11
11
  function _possibleConstructorReturn(t, e) { if (e && ("object" == _typeof(e) || "function" == typeof e)) return e; if (void 0 !== e) throw new TypeError("Derived constructors may only return object or undefined"); return _assertThisInitialized(t); }
12
12
  function _assertThisInitialized(e) { if (void 0 === e) throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); return e; }
@@ -0,0 +1,88 @@
1
+ "use strict";
2
+
3
+ function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
4
+ var _inferno = require("inferno");
5
+ function _classCallCheck(a, n) { if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function"); }
6
+ function _defineProperties(e, r) { for (var t = 0; t < r.length; t++) { var o = r[t]; o.enumerable = o.enumerable || !1, o.configurable = !0, "value" in o && (o.writable = !0), Object.defineProperty(e, _toPropertyKey(o.key), o); } }
7
+ function _createClass(e, r, t) { return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, "prototype", { writable: !1 }), e; }
8
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
9
+ function _toPrimitive(t, e) { if ("object" != _typeof(t) || !t) return t; var r; if ("undefined" != typeof Symbol && void 0 !== (r = t[Symbol.toPrimitive])) { var i = r.call(t, e || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === e ? String : Number)(t); }
10
+ function _callSuper(t, o, e) { return o = _getPrototypeOf(o), _possibleConstructorReturn(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], _getPrototypeOf(t).constructor) : o.apply(t, e)); }
11
+ function _possibleConstructorReturn(t, e) { if (e && ("object" == _typeof(e) || "function" == typeof e)) return e; if (void 0 !== e) throw new TypeError("Derived constructors may only return object or undefined"); return _assertThisInitialized(t); }
12
+ function _assertThisInitialized(e) { if (void 0 === e) throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); return e; }
13
+ function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
14
+ function _getPrototypeOf(t) { return _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function (t) { return t.__proto__ || Object.getPrototypeOf(t); }, _getPrototypeOf(t); }
15
+ function _inherits(t, e) { if ("function" != typeof e && null !== e) throw new TypeError("Super expression must either be null or a function"); t.prototype = Object.create(e && e.prototype, { constructor: { value: t, writable: !0, configurable: !0 } }), Object.defineProperty(t, "prototype", { writable: !1 }), e && _setPrototypeOf(t, e); }
16
+ function _setPrototypeOf(t, e) { return _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function (t, e) { return t.__proto__ = e, t; }, _setPrototypeOf(t, e); }
17
+ /**
18
+ * Umami analytics plugin JSX component.
19
+ * @module view/plugin/umami
20
+ */
21
+ var _require = require('inferno'),
22
+ Component = _require.Component;
23
+ var _require2 = require('../../util/cache'),
24
+ cacheComponent = _require2.cacheComponent;
25
+
26
+ /**
27
+ * Umami analytics plugin JSX component.
28
+ * <p>
29
+ * Umami also tracks the pages that are switched to with the History API, such as by PJAX.
30
+ *
31
+ * @see https://umami.is/docs/tracker-configuration
32
+ * @example
33
+ * <Umami
34
+ * websiteId="******"
35
+ * scriptUrl="https://cloud.umami.is/script.js"
36
+ * domains="example.com,www.example.com" />
37
+ */
38
+ var Umami = /*#__PURE__*/function (_Component) {
39
+ function Umami() {
40
+ _classCallCheck(this, Umami);
41
+ return _callSuper(this, Umami, arguments);
42
+ }
43
+ _inherits(Umami, _Component);
44
+ return _createClass(Umami, [{
45
+ key: "render",
46
+ value: function render() {
47
+ var _this$props = this.props,
48
+ websiteId = _this$props.websiteId,
49
+ scriptUrl = _this$props.scriptUrl,
50
+ domains = _this$props.domains;
51
+ return (0, _inferno.createVNode)(1, "script", null, null, 1, {
52
+ "src": scriptUrl,
53
+ "data-website-id": websiteId,
54
+ "data-domains": domains,
55
+ "defer": true
56
+ });
57
+ }
58
+ }]);
59
+ }(Component);
60
+ /**
61
+ * Cacheable Umami analytics plugin JSX component.
62
+ * <p>
63
+ * This class is supposed to be used in combination with the <code>locals</code> hexo filter
64
+ * ({@link module:hexo/filter/locals}).
65
+ *
66
+ * @see module:util/cache.cacheComponent
67
+ * @example
68
+ * <Umami.Cacheable
69
+ * head={true}
70
+ * plugin={{
71
+ * website_id: '******',
72
+ * script_url: 'https://cloud.umami.is/script.js',
73
+ * domains: 'example.com,www.example.com'
74
+ * }} />
75
+ */
76
+ Umami.Cacheable = cacheComponent(Umami, 'plugin.umami', function (props) {
77
+ var head = props.head,
78
+ plugin = props.plugin;
79
+ if (!head || !plugin.website_id) {
80
+ return null;
81
+ }
82
+ return {
83
+ websiteId: plugin.website_id,
84
+ scriptUrl: plugin.script_url || 'https://cloud.umami.is/script.js',
85
+ domains: plugin.domains
86
+ };
87
+ });
88
+ module.exports = Umami;
@@ -6,7 +6,7 @@ function _classCallCheck(a, n) { if (!(a instanceof n)) throw new TypeError("Can
6
6
  function _defineProperties(e, r) { for (var t = 0; t < r.length; t++) { var o = r[t]; o.enumerable = o.enumerable || !1, o.configurable = !0, "value" in o && (o.writable = !0), Object.defineProperty(e, _toPropertyKey(o.key), o); } }
7
7
  function _createClass(e, r, t) { return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, "prototype", { writable: !1 }), e; }
8
8
  function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
9
- function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
9
+ function _toPrimitive(t, e) { if ("object" != _typeof(t) || !t) return t; var r; if ("undefined" != typeof Symbol && void 0 !== (r = t[Symbol.toPrimitive])) { var i = r.call(t, e || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === e ? String : Number)(t); }
10
10
  function _callSuper(t, o, e) { return o = _getPrototypeOf(o), _possibleConstructorReturn(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], _getPrototypeOf(t).constructor) : o.apply(t, e)); }
11
11
  function _possibleConstructorReturn(t, e) { if (e && ("object" == _typeof(e) || "function" == typeof e)) return e; if (void 0 !== e) throw new TypeError("Derived constructors may only return object or undefined"); return _assertThisInitialized(t); }
12
12
  function _assertThisInitialized(e) { if (void 0 === e) throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); return e; }
@@ -56,6 +56,7 @@ var Algolia = /*#__PURE__*/function (_Component) {
56
56
  applicationId = _this$props.applicationId,
57
57
  apiKey = _this$props.apiKey,
58
58
  indexName = _this$props.indexName,
59
+ excerpt = _this$props.excerpt,
59
60
  jsUrl = _this$props.jsUrl,
60
61
  algoliaSearchUrl = _this$props.algoliaSearchUrl,
61
62
  instantSearchUrl = _this$props.instantSearchUrl;
@@ -65,17 +66,20 @@ var Algolia = /*#__PURE__*/function (_Component) {
65
66
  var config = {
66
67
  applicationId: applicationId,
67
68
  apiKey: apiKey,
68
- indexName: indexName
69
+ indexName: indexName,
70
+ excerpt: excerpt
69
71
  };
70
72
  var js = "document.addEventListener('DOMContentLoaded', function () {\n loadAlgolia(".concat(JSON.stringify(config), ", ").concat(JSON.stringify(translation), ");\n });");
71
- return (0, _inferno.createFragment)([(0, _inferno.createVNode)(1, "div", "searchbox", (0, _inferno.createVNode)(1, "div", "searchbox-container", [(0, _inferno.createVNode)(1, "div", "searchbox-header", [(0, _inferno.createVNode)(1, "div", "searchbox-input-container", null, 1, {
73
+ return (0, _inferno.createFragment)([(0, _inferno.createVNode)(1, "div", "searchbox", [(0, _inferno.createVNode)(1, "div", "searchbox-mask", null, 1, {
74
+ "style": "position:absolute;bottom:0px;left:0px;right:0px;top:0px;"
75
+ }), (0, _inferno.createVNode)(1, "div", "searchbox-container", [(0, _inferno.createVNode)(1, "div", "searchbox-header", [(0, _inferno.createVNode)(1, "div", "searchbox-input-container", null, 1, {
72
76
  "id": "algolia-input"
73
77
  }), (0, _inferno.createVNode)(1, "div", null, null, 1, {
74
78
  "id": "algolia-poweredby",
75
79
  "style": "display:flex;margin:0 .5em 0 1em;align-items:center;line-height:0"
76
80
  }), (0, _inferno.createVNode)(1, "a", "searchbox-close", "\xD7", 16, {
77
81
  "href": "javascript:;"
78
- })], 4), (0, _inferno.createVNode)(1, "div", "searchbox-body"), (0, _inferno.createVNode)(1, "div", "searchbox-footer")], 4), 2), (0, _inferno.createVNode)(1, "script", null, null, 1, {
82
+ })], 4), (0, _inferno.createVNode)(1, "div", "searchbox-body"), (0, _inferno.createVNode)(1, "div", "searchbox-footer")], 4)], 4), (0, _inferno.createVNode)(1, "script", null, null, 1, {
79
83
  "src": algoliaSearchUrl,
80
84
  "crossorigin": "anonymous",
81
85
  "defer": true
@@ -118,7 +122,8 @@ var Algolia = /*#__PURE__*/function (_Component) {
118
122
  */
119
123
  Algolia.Cacheable = cacheComponent(Algolia, 'search.algolia', function (props) {
120
124
  var config = props.config,
121
- helper = props.helper;
125
+ helper = props.helper,
126
+ search = props.search;
122
127
  var algolia = config.algolia;
123
128
  return {
124
129
  translation: {
@@ -130,6 +135,7 @@ Algolia.Cacheable = cacheComponent(Algolia, 'search.algolia', function (props) {
130
135
  applicationId: algolia ? algolia.applicationID : null,
131
136
  apiKey: algolia ? algolia.apiKey : null,
132
137
  indexName: algolia ? algolia.indexName : null,
138
+ excerpt: search.excerpt ? search.excerpt : 'excerpt',
133
139
  algoliaSearchUrl: helper.cdn('algoliasearch', '4.0.3', 'dist/algoliasearch-lite.umd.js'),
134
140
  instantSearchUrl: helper.cdn('instantsearch.js', '4.3.1', 'dist/instantsearch.production.min.js'),
135
141
  jsUrl: helper.url_for('/js/algolia.js')
@@ -6,7 +6,7 @@ function _classCallCheck(a, n) { if (!(a instanceof n)) throw new TypeError("Can
6
6
  function _defineProperties(e, r) { for (var t = 0; t < r.length; t++) { var o = r[t]; o.enumerable = o.enumerable || !1, o.configurable = !0, "value" in o && (o.writable = !0), Object.defineProperty(e, _toPropertyKey(o.key), o); } }
7
7
  function _createClass(e, r, t) { return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, "prototype", { writable: !1 }), e; }
8
8
  function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
9
- function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
9
+ function _toPrimitive(t, e) { if ("object" != _typeof(t) || !t) return t; var r; if ("undefined" != typeof Symbol && void 0 !== (r = t[Symbol.toPrimitive])) { var i = r.call(t, e || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === e ? String : Number)(t); }
10
10
  function _callSuper(t, o, e) { return o = _getPrototypeOf(o), _possibleConstructorReturn(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], _getPrototypeOf(t).constructor) : o.apply(t, e)); }
11
11
  function _possibleConstructorReturn(t, e) { if (e && ("object" == _typeof(e) || "function" == typeof e)) return e; if (void 0 !== e) throw new TypeError("Derived constructors may only return object or undefined"); return _assertThisInitialized(t); }
12
12
  function _assertThisInitialized(e) { if (void 0 === e) throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); return e; }
@@ -43,13 +43,15 @@ var Baidu = /*#__PURE__*/function (_Component) {
43
43
  hint = _this$props.hint;
44
44
  var siteUrl = url.replace(/http(s)*:\/\//, '');
45
45
  var js = "(function ($) {\n $('.searchbox-input-container').on('submit', function (e) {\n var keyword = $('.searchbox-input[name=\"wd\"]').val();\n window.location = 'https://www.baidu.com/s?wd=site:".concat(siteUrl, " ' + keyword;\n return false;\n });\n })(jQuery);\n (function (document, $) {\n $(document).on('click', '.navbar-main .search', function () {\n $('.searchbox').toggleClass('show');\n }).on('click', '.searchbox .searchbox-mask', function () {\n $('.searchbox').removeClass('show');\n }).on('click', '.searchbox-close', function () {\n $('.searchbox').removeClass('show');\n });\n })(document, jQuery);");
46
- return (0, _inferno.createFragment)([(0, _inferno.createVNode)(1, "div", "searchbox", (0, _inferno.createVNode)(1, "div", "searchbox-container", (0, _inferno.createVNode)(1, "div", "searchbox-header", [(0, _inferno.createVNode)(1, "form", "searchbox-input-container", (0, _inferno.createVNode)(64, "input", "searchbox-input", null, 1, {
46
+ return (0, _inferno.createFragment)([(0, _inferno.createVNode)(1, "div", "searchbox", [(0, _inferno.createVNode)(1, "div", "searchbox-mask", null, 1, {
47
+ "style": "position:absolute;bottom:0px;left:0px;right:0px;top:0px;"
48
+ }), (0, _inferno.createVNode)(1, "div", "searchbox-container", (0, _inferno.createVNode)(1, "div", "searchbox-header", [(0, _inferno.createVNode)(1, "form", "searchbox-input-container", (0, _inferno.createVNode)(64, "input", "searchbox-input", null, 1, {
47
49
  "name": "wd",
48
50
  "type": "text",
49
51
  "placeholder": hint
50
52
  }), 2), (0, _inferno.createVNode)(1, "a", "searchbox-close", "\xD7", 16, {
51
53
  "href": "javascript:;"
52
- })], 4), 2), 2), (0, _inferno.createVNode)(1, "script", null, null, 1, {
54
+ })], 4), 2)], 4), (0, _inferno.createVNode)(1, "script", null, null, 1, {
53
55
  "dangerouslySetInnerHTML": {
54
56
  __html: js
55
57
  }
@@ -6,7 +6,7 @@ function _classCallCheck(a, n) { if (!(a instanceof n)) throw new TypeError("Can
6
6
  function _defineProperties(e, r) { for (var t = 0; t < r.length; t++) { var o = r[t]; o.enumerable = o.enumerable || !1, o.configurable = !0, "value" in o && (o.writable = !0), Object.defineProperty(e, _toPropertyKey(o.key), o); } }
7
7
  function _createClass(e, r, t) { return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, "prototype", { writable: !1 }), e; }
8
8
  function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
9
- function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
9
+ function _toPrimitive(t, e) { if ("object" != _typeof(t) || !t) return t; var r; if ("undefined" != typeof Symbol && void 0 !== (r = t[Symbol.toPrimitive])) { var i = r.call(t, e || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === e ? String : Number)(t); }
10
10
  function _callSuper(t, o, e) { return o = _getPrototypeOf(o), _possibleConstructorReturn(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], _getPrototypeOf(t).constructor) : o.apply(t, e)); }
11
11
  function _possibleConstructorReturn(t, e) { if (e && ("object" == _typeof(e) || "function" == typeof e)) return e; if (void 0 !== e) throw new TypeError("Derived constructors may only return object or undefined"); return _assertThisInitialized(t); }
12
12
  function _assertThisInitialized(e) { if (void 0 === e) throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); return e; }
@@ -52,7 +52,9 @@ var GoogleCSE = /*#__PURE__*/function (_Component) {
52
52
  "dangerouslySetInnerHTML": {
53
53
  __html: css
54
54
  }
55
- }), (0, _inferno.createVNode)(1, "div", "searchbox", [(0, _inferno.createVNode)(1, "div", "searchbox-container", [(0, _inferno.createVNode)(1, "div", "searchbox-header", [(0, _inferno.createVNode)(1, "div", "searchbox-input-container", (0, _inferno.createVNode)(64, "input", "searchbox-input", null, 1, {
55
+ }), (0, _inferno.createVNode)(1, "div", "searchbox", [(0, _inferno.createVNode)(1, "div", "searchbox-mask", null, 1, {
56
+ "style": "position:absolute;bottom:0px;left:0px;right:0px;top:0px;"
57
+ }), (0, _inferno.createVNode)(1, "div", "searchbox-container", [(0, _inferno.createVNode)(1, "div", "searchbox-header", [(0, _inferno.createVNode)(1, "div", "searchbox-input-container", (0, _inferno.createVNode)(64, "input", "searchbox-input", null, 1, {
56
58
  "type": "text",
57
59
  "placeholder": hint
58
60
  }), 2), (0, _inferno.createVNode)(1, "a", "searchbox-close", "\xD7", 16, {
@@ -6,7 +6,7 @@ function _classCallCheck(a, n) { if (!(a instanceof n)) throw new TypeError("Can
6
6
  function _defineProperties(e, r) { for (var t = 0; t < r.length; t++) { var o = r[t]; o.enumerable = o.enumerable || !1, o.configurable = !0, "value" in o && (o.writable = !0), Object.defineProperty(e, _toPropertyKey(o.key), o); } }
7
7
  function _createClass(e, r, t) { return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, "prototype", { writable: !1 }), e; }
8
8
  function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
9
- function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
9
+ function _toPrimitive(t, e) { if ("object" != _typeof(t) || !t) return t; var r; if ("undefined" != typeof Symbol && void 0 !== (r = t[Symbol.toPrimitive])) { var i = r.call(t, e || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === e ? String : Number)(t); }
10
10
  function _callSuper(t, o, e) { return o = _getPrototypeOf(o), _possibleConstructorReturn(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], _getPrototypeOf(t).constructor) : o.apply(t, e)); }
11
11
  function _possibleConstructorReturn(t, e) { if (e && ("object" == _typeof(e) || "function" == typeof e)) return e; if (void 0 !== e) throw new TypeError("Derived constructors may only return object or undefined"); return _assertThisInitialized(t); }
12
12
  function _assertThisInitialized(e) { if (void 0 === e) throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); return e; }
@@ -6,7 +6,7 @@ function _classCallCheck(a, n) { if (!(a instanceof n)) throw new TypeError("Can
6
6
  function _defineProperties(e, r) { for (var t = 0; t < r.length; t++) { var o = r[t]; o.enumerable = o.enumerable || !1, o.configurable = !0, "value" in o && (o.writable = !0), Object.defineProperty(e, _toPropertyKey(o.key), o); } }
7
7
  function _createClass(e, r, t) { return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, "prototype", { writable: !1 }), e; }
8
8
  function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
9
- function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
9
+ function _toPrimitive(t, e) { if ("object" != _typeof(t) || !t) return t; var r; if ("undefined" != typeof Symbol && void 0 !== (r = t[Symbol.toPrimitive])) { var i = r.call(t, e || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === e ? String : Number)(t); }
10
10
  function _callSuper(t, o, e) { return o = _getPrototypeOf(o), _possibleConstructorReturn(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], _getPrototypeOf(t).constructor) : o.apply(t, e)); }
11
11
  function _possibleConstructorReturn(t, e) { if (e && ("object" == _typeof(e) || "function" == typeof e)) return e; if (void 0 !== e) throw new TypeError("Derived constructors may only return object or undefined"); return _assertThisInitialized(t); }
12
12
  function _assertThisInitialized(e) { if (void 0 === e) throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); return e; }
@@ -6,7 +6,7 @@ function _classCallCheck(a, n) { if (!(a instanceof n)) throw new TypeError("Can
6
6
  function _defineProperties(e, r) { for (var t = 0; t < r.length; t++) { var o = r[t]; o.enumerable = o.enumerable || !1, o.configurable = !0, "value" in o && (o.writable = !0), Object.defineProperty(e, _toPropertyKey(o.key), o); } }
7
7
  function _createClass(e, r, t) { return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, "prototype", { writable: !1 }), e; }
8
8
  function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
9
- function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
9
+ function _toPrimitive(t, e) { if ("object" != _typeof(t) || !t) return t; var r; if ("undefined" != typeof Symbol && void 0 !== (r = t[Symbol.toPrimitive])) { var i = r.call(t, e || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === e ? String : Number)(t); }
10
10
  function _callSuper(t, o, e) { return o = _getPrototypeOf(o), _possibleConstructorReturn(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], _getPrototypeOf(t).constructor) : o.apply(t, e)); }
11
11
  function _possibleConstructorReturn(t, e) { if (e && ("object" == _typeof(e) || "function" == typeof e)) return e; if (void 0 !== e) throw new TypeError("Derived constructors may only return object or undefined"); return _assertThisInitialized(t); }
12
12
  function _assertThisInitialized(e) { if (void 0 === e) throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); return e; }
@@ -6,7 +6,7 @@ function _classCallCheck(a, n) { if (!(a instanceof n)) throw new TypeError("Can
6
6
  function _defineProperties(e, r) { for (var t = 0; t < r.length; t++) { var o = r[t]; o.enumerable = o.enumerable || !1, o.configurable = !0, "value" in o && (o.writable = !0), Object.defineProperty(e, _toPropertyKey(o.key), o); } }
7
7
  function _createClass(e, r, t) { return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, "prototype", { writable: !1 }), e; }
8
8
  function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
9
- function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
9
+ function _toPrimitive(t, e) { if ("object" != _typeof(t) || !t) return t; var r; if ("undefined" != typeof Symbol && void 0 !== (r = t[Symbol.toPrimitive])) { var i = r.call(t, e || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === e ? String : Number)(t); }
10
10
  function _callSuper(t, o, e) { return o = _getPrototypeOf(o), _possibleConstructorReturn(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], _getPrototypeOf(t).constructor) : o.apply(t, e)); }
11
11
  function _possibleConstructorReturn(t, e) { if (e && ("object" == _typeof(e) || "function" == typeof e)) return e; if (void 0 !== e) throw new TypeError("Derived constructors may only return object or undefined"); return _assertThisInitialized(t); }
12
12
  function _assertThisInitialized(e) { if (void 0 === e) throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); return e; }
@@ -6,7 +6,7 @@ function _classCallCheck(a, n) { if (!(a instanceof n)) throw new TypeError("Can
6
6
  function _defineProperties(e, r) { for (var t = 0; t < r.length; t++) { var o = r[t]; o.enumerable = o.enumerable || !1, o.configurable = !0, "value" in o && (o.writable = !0), Object.defineProperty(e, _toPropertyKey(o.key), o); } }
7
7
  function _createClass(e, r, t) { return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, "prototype", { writable: !1 }), e; }
8
8
  function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
9
- function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
9
+ function _toPrimitive(t, e) { if ("object" != _typeof(t) || !t) return t; var r; if ("undefined" != typeof Symbol && void 0 !== (r = t[Symbol.toPrimitive])) { var i = r.call(t, e || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === e ? String : Number)(t); }
10
10
  function _callSuper(t, o, e) { return o = _getPrototypeOf(o), _possibleConstructorReturn(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], _getPrototypeOf(t).constructor) : o.apply(t, e)); }
11
11
  function _possibleConstructorReturn(t, e) { if (e && ("object" == _typeof(e) || "function" == typeof e)) return e; if (void 0 !== e) throw new TypeError("Derived constructors may only return object or undefined"); return _assertThisInitialized(t); }
12
12
  function _assertThisInitialized(e) { if (void 0 === e) throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); return e; }
@@ -6,7 +6,7 @@ function _classCallCheck(a, n) { if (!(a instanceof n)) throw new TypeError("Can
6
6
  function _defineProperties(e, r) { for (var t = 0; t < r.length; t++) { var o = r[t]; o.enumerable = o.enumerable || !1, o.configurable = !0, "value" in o && (o.writable = !0), Object.defineProperty(e, _toPropertyKey(o.key), o); } }
7
7
  function _createClass(e, r, t) { return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, "prototype", { writable: !1 }), e; }
8
8
  function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
9
- function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
9
+ function _toPrimitive(t, e) { if ("object" != _typeof(t) || !t) return t; var r; if ("undefined" != typeof Symbol && void 0 !== (r = t[Symbol.toPrimitive])) { var i = r.call(t, e || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === e ? String : Number)(t); }
10
10
  function _callSuper(t, o, e) { return o = _getPrototypeOf(o), _possibleConstructorReturn(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], _getPrototypeOf(t).constructor) : o.apply(t, e)); }
11
11
  function _possibleConstructorReturn(t, e) { if (e && ("object" == _typeof(e) || "function" == typeof e)) return e; if (void 0 !== e) throw new TypeError("Derived constructors may only return object or undefined"); return _assertThisInitialized(t); }
12
12
  function _assertThisInitialized(e) { if (void 0 === e) throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); return e; }
@@ -6,7 +6,7 @@ function _classCallCheck(a, n) { if (!(a instanceof n)) throw new TypeError("Can
6
6
  function _defineProperties(e, r) { for (var t = 0; t < r.length; t++) { var o = r[t]; o.enumerable = o.enumerable || !1, o.configurable = !0, "value" in o && (o.writable = !0), Object.defineProperty(e, _toPropertyKey(o.key), o); } }
7
7
  function _createClass(e, r, t) { return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, "prototype", { writable: !1 }), e; }
8
8
  function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
9
- function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
9
+ function _toPrimitive(t, e) { if ("object" != _typeof(t) || !t) return t; var r; if ("undefined" != typeof Symbol && void 0 !== (r = t[Symbol.toPrimitive])) { var i = r.call(t, e || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === e ? String : Number)(t); }
10
10
  function _callSuper(t, o, e) { return o = _getPrototypeOf(o), _possibleConstructorReturn(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], _getPrototypeOf(t).constructor) : o.apply(t, e)); }
11
11
  function _possibleConstructorReturn(t, e) { if (e && ("object" == _typeof(e) || "function" == typeof e)) return e; if (void 0 !== e) throw new TypeError("Derived constructors may only return object or undefined"); return _assertThisInitialized(t); }
12
12
  function _assertThisInitialized(e) { if (void 0 === e) throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); return e; }
@@ -6,7 +6,7 @@ function _classCallCheck(a, n) { if (!(a instanceof n)) throw new TypeError("Can
6
6
  function _defineProperties(e, r) { for (var t = 0; t < r.length; t++) { var o = r[t]; o.enumerable = o.enumerable || !1, o.configurable = !0, "value" in o && (o.writable = !0), Object.defineProperty(e, _toPropertyKey(o.key), o); } }
7
7
  function _createClass(e, r, t) { return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, "prototype", { writable: !1 }), e; }
8
8
  function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
9
- function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
9
+ function _toPrimitive(t, e) { if ("object" != _typeof(t) || !t) return t; var r; if ("undefined" != typeof Symbol && void 0 !== (r = t[Symbol.toPrimitive])) { var i = r.call(t, e || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === e ? String : Number)(t); }
10
10
  function _callSuper(t, o, e) { return o = _getPrototypeOf(o), _possibleConstructorReturn(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], _getPrototypeOf(t).constructor) : o.apply(t, e)); }
11
11
  function _possibleConstructorReturn(t, e) { if (e && ("object" == _typeof(e) || "function" == typeof e)) return e; if (void 0 !== e) throw new TypeError("Derived constructors may only return object or undefined"); return _assertThisInitialized(t); }
12
12
  function _assertThisInitialized(e) { if (void 0 === e) throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); return e; }
@@ -20,10 +20,28 @@ function _setPrototypeOf(t, e) { return _setPrototypeOf = Object.setPrototypeOf
20
20
  */
21
21
  var _require = require('inferno'),
22
22
  Component = _require.Component;
23
- var _require2 = require('hexo/dist/plugins/helper/date'),
24
- toMomentLocale = _require2.toMomentLocale;
25
- var _require3 = require('../../util/cache'),
26
- cacheComponent = _require3.cacheComponent;
23
+ var _require2 = require('../../util/cache'),
24
+ cacheComponent = _require2.cacheComponent;
25
+
26
+ /**
27
+ * Convert a Hexo language code into a Moment.js locale name.
28
+ * <p>
29
+ * Same as Hexo's internal <code>toMomentLocale</code>, copied here so that the component does not
30
+ * depend on Hexo's private modules.
31
+ *
32
+ * @param {string} lang Hexo language code, such as <code>zh-CN</code> or <code>en_US</code>.
33
+ * @returns {string|undefined} Moment.js locale name.
34
+ */
35
+ function toMomentLocale(lang) {
36
+ if (lang === undefined) {
37
+ return undefined;
38
+ }
39
+ // moment.locale('') and moment.locale(null) both equal moment.locale('en')
40
+ if (!lang || lang === 'en' || lang === 'default') {
41
+ return 'en';
42
+ }
43
+ return lang.toLowerCase().replace('_', '-');
44
+ }
27
45
 
28
46
  /**
29
47
  * Archives widget JSX component.
@@ -6,7 +6,7 @@ function _classCallCheck(a, n) { if (!(a instanceof n)) throw new TypeError("Can
6
6
  function _defineProperties(e, r) { for (var t = 0; t < r.length; t++) { var o = r[t]; o.enumerable = o.enumerable || !1, o.configurable = !0, "value" in o && (o.writable = !0), Object.defineProperty(e, _toPropertyKey(o.key), o); } }
7
7
  function _createClass(e, r, t) { return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, "prototype", { writable: !1 }), e; }
8
8
  function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
9
- function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
9
+ function _toPrimitive(t, e) { if ("object" != _typeof(t) || !t) return t; var r; if ("undefined" != typeof Symbol && void 0 !== (r = t[Symbol.toPrimitive])) { var i = r.call(t, e || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === e ? String : Number)(t); }
10
10
  function _callSuper(t, o, e) { return o = _getPrototypeOf(o), _possibleConstructorReturn(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], _getPrototypeOf(t).constructor) : o.apply(t, e)); }
11
11
  function _possibleConstructorReturn(t, e) { if (e && ("object" == _typeof(e) || "function" == typeof e)) return e; if (void 0 !== e) throw new TypeError("Derived constructors may only return object or undefined"); return _assertThisInitialized(t); }
12
12
  function _assertThisInitialized(e) { if (void 0 === e) throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); return e; }
@@ -6,7 +6,7 @@ function _classCallCheck(a, n) { if (!(a instanceof n)) throw new TypeError("Can
6
6
  function _defineProperties(e, r) { for (var t = 0; t < r.length; t++) { var o = r[t]; o.enumerable = o.enumerable || !1, o.configurable = !0, "value" in o && (o.writable = !0), Object.defineProperty(e, _toPropertyKey(o.key), o); } }
7
7
  function _createClass(e, r, t) { return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, "prototype", { writable: !1 }), e; }
8
8
  function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
9
- function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
9
+ function _toPrimitive(t, e) { if ("object" != _typeof(t) || !t) return t; var r; if ("undefined" != typeof Symbol && void 0 !== (r = t[Symbol.toPrimitive])) { var i = r.call(t, e || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === e ? String : Number)(t); }
10
10
  function _callSuper(t, o, e) { return o = _getPrototypeOf(o), _possibleConstructorReturn(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], _getPrototypeOf(t).constructor) : o.apply(t, e)); }
11
11
  function _possibleConstructorReturn(t, e) { if (e && ("object" == _typeof(e) || "function" == typeof e)) return e; if (void 0 !== e) throw new TypeError("Derived constructors may only return object or undefined"); return _assertThisInitialized(t); }
12
12
  function _assertThisInitialized(e) { if (void 0 === e) throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); return e; }
@@ -6,7 +6,7 @@ function _classCallCheck(a, n) { if (!(a instanceof n)) throw new TypeError("Can
6
6
  function _defineProperties(e, r) { for (var t = 0; t < r.length; t++) { var o = r[t]; o.enumerable = o.enumerable || !1, o.configurable = !0, "value" in o && (o.writable = !0), Object.defineProperty(e, _toPropertyKey(o.key), o); } }
7
7
  function _createClass(e, r, t) { return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, "prototype", { writable: !1 }), e; }
8
8
  function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
9
- function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
9
+ function _toPrimitive(t, e) { if ("object" != _typeof(t) || !t) return t; var r; if ("undefined" != typeof Symbol && void 0 !== (r = t[Symbol.toPrimitive])) { var i = r.call(t, e || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === e ? String : Number)(t); }
10
10
  function _callSuper(t, o, e) { return o = _getPrototypeOf(o), _possibleConstructorReturn(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], _getPrototypeOf(t).constructor) : o.apply(t, e)); }
11
11
  function _possibleConstructorReturn(t, e) { if (e && ("object" == _typeof(e) || "function" == typeof e)) return e; if (void 0 !== e) throw new TypeError("Derived constructors may only return object or undefined"); return _assertThisInitialized(t); }
12
12
  function _assertThisInitialized(e) { if (void 0 === e) throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); return e; }
@@ -6,7 +6,7 @@ function _classCallCheck(a, n) { if (!(a instanceof n)) throw new TypeError("Can
6
6
  function _defineProperties(e, r) { for (var t = 0; t < r.length; t++) { var o = r[t]; o.enumerable = o.enumerable || !1, o.configurable = !0, "value" in o && (o.writable = !0), Object.defineProperty(e, _toPropertyKey(o.key), o); } }
7
7
  function _createClass(e, r, t) { return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, "prototype", { writable: !1 }), e; }
8
8
  function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
9
- function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
9
+ function _toPrimitive(t, e) { if ("object" != _typeof(t) || !t) return t; var r; if ("undefined" != typeof Symbol && void 0 !== (r = t[Symbol.toPrimitive])) { var i = r.call(t, e || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === e ? String : Number)(t); }
10
10
  function _callSuper(t, o, e) { return o = _getPrototypeOf(o), _possibleConstructorReturn(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], _getPrototypeOf(t).constructor) : o.apply(t, e)); }
11
11
  function _possibleConstructorReturn(t, e) { if (e && ("object" == _typeof(e) || "function" == typeof e)) return e; if (void 0 !== e) throw new TypeError("Derived constructors may only return object or undefined"); return _assertThisInitialized(t); }
12
12
  function _assertThisInitialized(e) { if (void 0 === e) throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); return e; }
@@ -6,7 +6,7 @@ function _classCallCheck(a, n) { if (!(a instanceof n)) throw new TypeError("Can
6
6
  function _defineProperties(e, r) { for (var t = 0; t < r.length; t++) { var o = r[t]; o.enumerable = o.enumerable || !1, o.configurable = !0, "value" in o && (o.writable = !0), Object.defineProperty(e, _toPropertyKey(o.key), o); } }
7
7
  function _createClass(e, r, t) { return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, "prototype", { writable: !1 }), e; }
8
8
  function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
9
- function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
9
+ function _toPrimitive(t, e) { if ("object" != _typeof(t) || !t) return t; var r; if ("undefined" != typeof Symbol && void 0 !== (r = t[Symbol.toPrimitive])) { var i = r.call(t, e || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === e ? String : Number)(t); }
10
10
  function _callSuper(t, o, e) { return o = _getPrototypeOf(o), _possibleConstructorReturn(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], _getPrototypeOf(t).constructor) : o.apply(t, e)); }
11
11
  function _possibleConstructorReturn(t, e) { if (e && ("object" == _typeof(e) || "function" == typeof e)) return e; if (void 0 !== e) throw new TypeError("Derived constructors may only return object or undefined"); return _assertThisInitialized(t); }
12
12
  function _assertThisInitialized(e) { if (void 0 === e) throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); return e; }
@@ -6,7 +6,7 @@ function _classCallCheck(a, n) { if (!(a instanceof n)) throw new TypeError("Can
6
6
  function _defineProperties(e, r) { for (var t = 0; t < r.length; t++) { var o = r[t]; o.enumerable = o.enumerable || !1, o.configurable = !0, "value" in o && (o.writable = !0), Object.defineProperty(e, _toPropertyKey(o.key), o); } }
7
7
  function _createClass(e, r, t) { return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, "prototype", { writable: !1 }), e; }
8
8
  function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
9
- function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
9
+ function _toPrimitive(t, e) { if ("object" != _typeof(t) || !t) return t; var r; if ("undefined" != typeof Symbol && void 0 !== (r = t[Symbol.toPrimitive])) { var i = r.call(t, e || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === e ? String : Number)(t); }
10
10
  function _callSuper(t, o, e) { return o = _getPrototypeOf(o), _possibleConstructorReturn(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], _getPrototypeOf(t).constructor) : o.apply(t, e)); }
11
11
  function _possibleConstructorReturn(t, e) { if (e && ("object" == _typeof(e) || "function" == typeof e)) return e; if (void 0 !== e) throw new TypeError("Derived constructors may only return object or undefined"); return _assertThisInitialized(t); }
12
12
  function _assertThisInitialized(e) { if (void 0 === e) throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); return e; }
@@ -6,7 +6,7 @@ function _classCallCheck(a, n) { if (!(a instanceof n)) throw new TypeError("Can
6
6
  function _defineProperties(e, r) { for (var t = 0; t < r.length; t++) { var o = r[t]; o.enumerable = o.enumerable || !1, o.configurable = !0, "value" in o && (o.writable = !0), Object.defineProperty(e, _toPropertyKey(o.key), o); } }
7
7
  function _createClass(e, r, t) { return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, "prototype", { writable: !1 }), e; }
8
8
  function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
9
- function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
9
+ function _toPrimitive(t, e) { if ("object" != _typeof(t) || !t) return t; var r; if ("undefined" != typeof Symbol && void 0 !== (r = t[Symbol.toPrimitive])) { var i = r.call(t, e || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === e ? String : Number)(t); }
10
10
  function _callSuper(t, o, e) { return o = _getPrototypeOf(o), _possibleConstructorReturn(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], _getPrototypeOf(t).constructor) : o.apply(t, e)); }
11
11
  function _possibleConstructorReturn(t, e) { if (e && ("object" == _typeof(e) || "function" == typeof e)) return e; if (void 0 !== e) throw new TypeError("Derived constructors may only return object or undefined"); return _assertThisInitialized(t); }
12
12
  function _assertThisInitialized(e) { if (void 0 === e) throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); return e; }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "hexo-component-inferno",
3
- "version": "3.1.2",
3
+ "version": "4.0.0",
4
4
  "description": "A collection of Inferno.js layout components and utility scripts for Hexo",
5
5
  "main": "lib/index.js",
6
6
  "repository": "https://github.com/ppoffice/hexo-component-inferno",
@@ -17,7 +17,7 @@
17
17
  "format": "npm run _format -- --write",
18
18
  "format-check": "npm run _format -- --check",
19
19
  "docs": "jsdoc src/**/* -d doc -t node_modules/minami",
20
- "build": "babel src --out-dir lib && cp -r src/schema lib/schema",
20
+ "build": "babel src --out-dir lib && mkdir -p lib/schema && cp -r src/schema/. lib/schema",
21
21
  "clean": "rm -rf lib doc coverage",
22
22
  "prepare": "npm run build"
23
23
  },
@@ -26,6 +26,7 @@
26
26
  },
27
27
  "files": [
28
28
  "lib/",
29
+ "!lib/**/*.test.js",
29
30
  "asset/"
30
31
  ],
31
32
  "devDependencies": {
@@ -34,7 +35,7 @@
34
35
  "@babel/preset-env": "^7.23.9",
35
36
  "@types/hexo": "^3.8.12",
36
37
  "@types/hexo-util": "^0.6.8",
37
- "babel-plugin-inferno": "^6.7.1",
38
+ "babel-plugin-inferno": "~6.8.5",
38
39
  "cheerio": "1.0.0-rc.12",
39
40
  "deepmerge": "^4.3.1",
40
41
  "eslint": "^8.56.0",
@@ -43,6 +44,7 @@
43
44
  "eslint-plugin-jest": "^27.6.3",
44
45
  "eslint-plugin-json": "^3.1.0",
45
46
  "eslint-plugin-react": "^7.33.2",
47
+ "hexo": "^7.1.1",
46
48
  "hexo-renderer-marked": "^6.2.0",
47
49
  "html-minifier": "^4.0.0",
48
50
  "inferno-server": "^8.2.3",
@@ -52,11 +54,11 @@
52
54
  "jsdoc": "^4.0.2",
53
55
  "minami": "^1.2.3",
54
56
  "prettier": "^3.2.4",
55
- "taffydb": "^2.7.3"
57
+ "taffydb": "^2.7.3",
58
+ "typescript": "^5.9.3"
56
59
  },
57
60
  "dependencies": {
58
61
  "ajv": "^8.12.0",
59
- "hexo": "^7.1.1",
60
62
  "hexo-pagination": "^3.0.0",
61
63
  "hexo-util": "^3.2.0",
62
64
  "inferno": "^8.2.3",
@@ -64,5 +66,8 @@
64
66
  "js-yaml": "^4.1.0",
65
67
  "moment": "^2.30.1",
66
68
  "semver": "^7.5.4"
69
+ },
70
+ "peerDependencies": {
71
+ "hexo": "^7.1.1 || ^8.0.0"
67
72
  }
68
73
  }
@@ -1,48 +0,0 @@
1
- const {
2
- Migrator
3
- } = require('./migrate');
4
- const head = require('../../fixture/migration/head');
5
- test('Correctly load all migrations and read the latest version', () => {
6
- const migrator = new Migrator(head);
7
- expect(migrator.getLatestVersion()).toBe('3.0.0');
8
- expect(migrator.isOudated('1.0.0')).toBe(true);
9
- expect(migrator.isOudated('3.0.0')).toBe(false);
10
- });
11
- test('Do full upgrade correctly', () => {
12
- const migrator = new Migrator(head);
13
- const callback = jest.fn();
14
- const result = migrator.migrate({
15
- version: '1.0.0'
16
- }, null, callback);
17
- // callback has been invoked twice
18
- expect(callback.mock.calls.length).toBe(2);
19
- // first invocation received the correct version parameters
20
- expect(callback.mock.calls[0][0]).toBe('1.0.0');
21
- expect(callback.mock.calls[0][1]).toBe('2.0.0');
22
- // second invocation received the correct version parameters
23
- expect(callback.mock.calls[1][0]).toBe('2.0.0');
24
- expect(callback.mock.calls[1][1]).toBe('3.0.0');
25
- expect(result).toEqual({
26
- version: '3.0.0',
27
- scalar: 2,
28
- vector: [1, 2]
29
- });
30
- });
31
- test('Do partial upgrade correctly', () => {
32
- const migrator = new Migrator(head);
33
- const callback = jest.fn();
34
- const result = migrator.migrate({
35
- version: '1.0.0'
36
- }, '2.1.0', callback);
37
- // callback has been invoked twice
38
- expect(callback.mock.calls.length).toBe(1);
39
- // first invocation received the correct version parameters
40
- expect(callback.mock.calls[0][0]).toBe('1.0.0');
41
- expect(callback.mock.calls[0][1]).toBe('2.0.0');
42
- expect(result).toEqual({
43
- version: '2.0.0',
44
- scalar: 1,
45
- vector: [1],
46
- useless: true
47
- });
48
- });