@modern-js/plugin-ssg 2.14.0 → 2.16.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.
@@ -1,83 +1,82 @@
1
- function _defineProperty(obj, key, value) {
2
- if (key in obj) {
3
- Object.defineProperty(obj, key, {
4
- value: value,
5
- enumerable: true,
6
- configurable: true,
7
- writable: true
8
- });
9
- } else {
10
- obj[key] = value;
11
- }
12
- return obj;
1
+ function _define_property(obj, key, value) {
2
+ if (key in obj) {
3
+ Object.defineProperty(obj, key, {
4
+ value,
5
+ enumerable: true,
6
+ configurable: true,
7
+ writable: true
8
+ });
9
+ } else {
10
+ obj[key] = value;
11
+ }
12
+ return obj;
13
13
  }
14
- function _objectSpread(target) {
15
- for(var i = 1; i < arguments.length; i++){
16
- var source = arguments[i] != null ? arguments[i] : {};
17
- var ownKeys = Object.keys(source);
18
- if (typeof Object.getOwnPropertySymbols === "function") {
19
- ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function(sym) {
20
- return Object.getOwnPropertyDescriptor(source, sym).enumerable;
21
- }));
22
- }
23
- ownKeys.forEach(function(key) {
24
- _defineProperty(target, key, source[key]);
25
- });
14
+ function _object_spread(target) {
15
+ for (var i = 1; i < arguments.length; i++) {
16
+ var source = arguments[i] != null ? arguments[i] : {};
17
+ var ownKeys2 = Object.keys(source);
18
+ if (typeof Object.getOwnPropertySymbols === "function") {
19
+ ownKeys2 = ownKeys2.concat(Object.getOwnPropertySymbols(source).filter(function(sym) {
20
+ return Object.getOwnPropertyDescriptor(source, sym).enumerable;
21
+ }));
26
22
  }
27
- return target;
23
+ ownKeys2.forEach(function(key) {
24
+ _define_property(target, key, source[key]);
25
+ });
26
+ }
27
+ return target;
28
28
  }
29
29
  function ownKeys(object, enumerableOnly) {
30
- var keys = Object.keys(object);
31
- if (Object.getOwnPropertySymbols) {
32
- var symbols = Object.getOwnPropertySymbols(object);
33
- if (enumerableOnly) {
34
- symbols = symbols.filter(function(sym) {
35
- return Object.getOwnPropertyDescriptor(object, sym).enumerable;
36
- });
37
- }
38
- keys.push.apply(keys, symbols);
30
+ var keys = Object.keys(object);
31
+ if (Object.getOwnPropertySymbols) {
32
+ var symbols = Object.getOwnPropertySymbols(object);
33
+ if (enumerableOnly) {
34
+ symbols = symbols.filter(function(sym) {
35
+ return Object.getOwnPropertyDescriptor(object, sym).enumerable;
36
+ });
39
37
  }
40
- return keys;
38
+ keys.push.apply(keys, symbols);
39
+ }
40
+ return keys;
41
41
  }
42
- function _objectSpreadProps(target, source) {
43
- source = source != null ? source : {};
44
- if (Object.getOwnPropertyDescriptors) {
45
- Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
46
- } else {
47
- ownKeys(Object(source)).forEach(function(key) {
48
- Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
49
- });
50
- }
51
- return target;
42
+ function _object_spread_props(target, source) {
43
+ source = source != null ? source : {};
44
+ if (Object.getOwnPropertyDescriptors) {
45
+ Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
46
+ } else {
47
+ ownKeys(Object(source)).forEach(function(key) {
48
+ Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
49
+ });
50
+ }
51
+ return target;
52
52
  }
53
53
  import path from "path";
54
54
  import normalize from "normalize-path";
55
- function makeRender(ssgRoutes, render, port) {
56
- return ssgRoutes.map(function(ssgRoute) {
57
- return render({
58
- url: ssgRoute.urlPath,
59
- headers: _objectSpread({
60
- host: "localhost:".concat(port)
61
- }, ssgRoute.headers),
62
- connection: {}
63
- });
55
+ export function makeRender(ssgRoutes, render, port) {
56
+ return ssgRoutes.map(function(ssgRoute) {
57
+ return render({
58
+ url: ssgRoute.urlPath,
59
+ headers: _object_spread({
60
+ host: "localhost:".concat(port)
61
+ }, ssgRoute.headers),
62
+ connection: {}
64
63
  });
64
+ });
65
65
  }
66
- function makeRoute(baseRoute, route) {
67
- var headers = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : {};
68
- var urlPath = baseRoute.urlPath, entryPath = baseRoute.entryPath;
69
- if (typeof route === "string") {
70
- return _objectSpreadProps(_objectSpread({}, baseRoute), {
71
- urlPath: normalize("".concat(urlPath).concat(route)) || "/",
72
- headers: headers,
73
- output: path.join(entryPath, "..".concat(route === "/" ? "" : route))
74
- });
75
- } else {
76
- return _objectSpreadProps(_objectSpread({}, baseRoute), {
77
- urlPath: normalize("".concat(urlPath).concat(route.url)) || "/",
78
- headers: _objectSpread({}, headers, route.headers),
79
- output: route.output ? path.normalize(route.output) : path.join(entryPath, "..".concat(route.url === "/" ? "" : route.url))
80
- });
81
- }
66
+ export function makeRoute(baseRoute, route) {
67
+ var headers = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : {};
68
+ var urlPath = baseRoute.urlPath, entryPath = baseRoute.entryPath;
69
+ if (typeof route === "string") {
70
+ return _object_spread_props(_object_spread({}, baseRoute), {
71
+ urlPath: normalize("".concat(urlPath).concat(route)) || "/",
72
+ headers,
73
+ output: path.join(entryPath, "..".concat(route === "/" ? "" : route))
74
+ });
75
+ } else {
76
+ return _object_spread_props(_object_spread({}, baseRoute), {
77
+ urlPath: normalize("".concat(urlPath).concat(route.url)) || "/",
78
+ headers: _object_spread({}, headers, route.headers),
79
+ output: route.output ? path.normalize(route.output) : path.join(entryPath, "..".concat(route.url === "/" ? "" : route.url))
80
+ });
81
+ }
82
82
  }
83
- export { makeRender, makeRoute };
@@ -1,13 +1,12 @@
1
1
  import path from "path";
2
2
  import { fs } from "@modern-js/utils";
3
- function writeHtmlFile(htmlAry, ssgRoutes, baseDir) {
4
- htmlAry.forEach(function(html, index) {
5
- var ssgRoute = ssgRoutes[index];
6
- var filepath = path.join(baseDir, ssgRoute.output);
7
- if (!fs.existsSync(path.dirname(filepath))) {
8
- fs.ensureDirSync(path.dirname(filepath));
9
- }
10
- fs.writeFileSync(filepath, html);
11
- });
3
+ export function writeHtmlFile(htmlAry, ssgRoutes, baseDir) {
4
+ htmlAry.forEach(function(html, index) {
5
+ var ssgRoute = ssgRoutes[index];
6
+ var filepath = path.join(baseDir, ssgRoute.output);
7
+ if (!fs.existsSync(path.dirname(filepath))) {
8
+ fs.ensureDirSync(path.dirname(filepath));
9
+ }
10
+ fs.writeFileSync(filepath, html);
11
+ });
12
12
  }
13
- export { writeHtmlFile };
@@ -1,115 +1,128 @@
1
- function _arrayLikeToArray(arr, len) {
2
- if (len == null || len > arr.length) len = arr.length;
3
- for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
4
- return arr2;
1
+ function _array_like_to_array(arr, len) {
2
+ if (len == null || len > arr.length)
3
+ len = arr.length;
4
+ for (var i = 0, arr2 = new Array(len); i < len; i++)
5
+ arr2[i] = arr[i];
6
+ return arr2;
5
7
  }
6
- function _arrayWithoutHoles(arr) {
7
- if (Array.isArray(arr)) return _arrayLikeToArray(arr);
8
+ function _array_without_holes(arr) {
9
+ if (Array.isArray(arr))
10
+ return _array_like_to_array(arr);
8
11
  }
9
- function _defineProperty(obj, key, value) {
10
- if (key in obj) {
11
- Object.defineProperty(obj, key, {
12
- value: value,
13
- enumerable: true,
14
- configurable: true,
15
- writable: true
16
- });
17
- } else {
18
- obj[key] = value;
19
- }
20
- return obj;
12
+ function _define_property(obj, key, value) {
13
+ if (key in obj) {
14
+ Object.defineProperty(obj, key, {
15
+ value,
16
+ enumerable: true,
17
+ configurable: true,
18
+ writable: true
19
+ });
20
+ } else {
21
+ obj[key] = value;
22
+ }
23
+ return obj;
21
24
  }
22
- function _iterableToArray(iter) {
23
- if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
25
+ function _iterable_to_array(iter) {
26
+ if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null)
27
+ return Array.from(iter);
24
28
  }
25
- function _nonIterableSpread() {
26
- throw new TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
29
+ function _non_iterable_spread() {
30
+ throw new TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
27
31
  }
28
- function _objectSpread(target) {
29
- for(var i = 1; i < arguments.length; i++){
30
- var source = arguments[i] != null ? arguments[i] : {};
31
- var ownKeys = Object.keys(source);
32
- if (typeof Object.getOwnPropertySymbols === "function") {
33
- ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function(sym) {
34
- return Object.getOwnPropertyDescriptor(source, sym).enumerable;
35
- }));
36
- }
37
- ownKeys.forEach(function(key) {
38
- _defineProperty(target, key, source[key]);
39
- });
32
+ function _object_spread(target) {
33
+ for (var i = 1; i < arguments.length; i++) {
34
+ var source = arguments[i] != null ? arguments[i] : {};
35
+ var ownKeys = Object.keys(source);
36
+ if (typeof Object.getOwnPropertySymbols === "function") {
37
+ ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function(sym) {
38
+ return Object.getOwnPropertyDescriptor(source, sym).enumerable;
39
+ }));
40
40
  }
41
- return target;
41
+ ownKeys.forEach(function(key) {
42
+ _define_property(target, key, source[key]);
43
+ });
44
+ }
45
+ return target;
42
46
  }
43
- function _objectWithoutProperties(source, excluded) {
44
- if (source == null) return {};
45
- var target = _objectWithoutPropertiesLoose(source, excluded);
46
- var key, i;
47
- if (Object.getOwnPropertySymbols) {
48
- var sourceSymbolKeys = Object.getOwnPropertySymbols(source);
49
- for(i = 0; i < sourceSymbolKeys.length; i++){
50
- key = sourceSymbolKeys[i];
51
- if (excluded.indexOf(key) >= 0) continue;
52
- if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue;
53
- target[key] = source[key];
54
- }
47
+ function _object_without_properties(source, excluded) {
48
+ if (source == null)
49
+ return {};
50
+ var target = _object_without_properties_loose(source, excluded);
51
+ var key, i;
52
+ if (Object.getOwnPropertySymbols) {
53
+ var sourceSymbolKeys = Object.getOwnPropertySymbols(source);
54
+ for (i = 0; i < sourceSymbolKeys.length; i++) {
55
+ key = sourceSymbolKeys[i];
56
+ if (excluded.indexOf(key) >= 0)
57
+ continue;
58
+ if (!Object.prototype.propertyIsEnumerable.call(source, key))
59
+ continue;
60
+ target[key] = source[key];
55
61
  }
56
- return target;
62
+ }
63
+ return target;
57
64
  }
58
- function _objectWithoutPropertiesLoose(source, excluded) {
59
- if (source == null) return {};
60
- var target = {};
61
- var sourceKeys = Object.keys(source);
62
- var key, i;
63
- for(i = 0; i < sourceKeys.length; i++){
64
- key = sourceKeys[i];
65
- if (excluded.indexOf(key) >= 0) continue;
66
- target[key] = source[key];
67
- }
68
- return target;
65
+ function _object_without_properties_loose(source, excluded) {
66
+ if (source == null)
67
+ return {};
68
+ var target = {};
69
+ var sourceKeys = Object.keys(source);
70
+ var key, i;
71
+ for (i = 0; i < sourceKeys.length; i++) {
72
+ key = sourceKeys[i];
73
+ if (excluded.indexOf(key) >= 0)
74
+ continue;
75
+ target[key] = source[key];
76
+ }
77
+ return target;
69
78
  }
70
- function _toConsumableArray(arr) {
71
- return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread();
79
+ function _to_consumable_array(arr) {
80
+ return _array_without_holes(arr) || _iterable_to_array(arr) || _unsupported_iterable_to_array(arr) || _non_iterable_spread();
72
81
  }
73
- function _unsupportedIterableToArray(o, minLen) {
74
- if (!o) return;
75
- if (typeof o === "string") return _arrayLikeToArray(o, minLen);
76
- var n = Object.prototype.toString.call(o).slice(8, -1);
77
- if (n === "Object" && o.constructor) n = o.constructor.name;
78
- if (n === "Map" || n === "Set") return Array.from(n);
79
- if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
82
+ function _unsupported_iterable_to_array(o, minLen) {
83
+ if (!o)
84
+ return;
85
+ if (typeof o === "string")
86
+ return _array_like_to_array(o, minLen);
87
+ var n = Object.prototype.toString.call(o).slice(8, -1);
88
+ if (n === "Object" && o.constructor)
89
+ n = o.constructor.name;
90
+ if (n === "Map" || n === "Set")
91
+ return Array.from(n);
92
+ if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))
93
+ return _array_like_to_array(o, minLen);
80
94
  }
81
95
  import normalize from "normalize-path";
82
- function exist(route, pageRoutes) {
83
- return pageRoutes.slice().findIndex(function(pageRoute) {
84
- var urlEqual = normalize(pageRoute.urlPath) === normalize(route.urlPath);
85
- var entryEqual = pageRoute.entryName === route.entryName;
86
- if (urlEqual && entryEqual) {
87
- return true;
88
- }
89
- return false;
90
- });
96
+ export function exist(route, pageRoutes) {
97
+ return pageRoutes.slice().findIndex(function(pageRoute) {
98
+ var urlEqual = normalize(pageRoute.urlPath) === normalize(route.urlPath);
99
+ var entryEqual = pageRoute.entryName === route.entryName;
100
+ if (urlEqual && entryEqual) {
101
+ return true;
102
+ }
103
+ return false;
104
+ });
91
105
  }
92
- function replaceRoute(ssgRoutes, pageRoutes) {
93
- var _pageRoutes;
94
- var cleanSsgRoutes = ssgRoutes.map(function(ssgRoute) {
95
- var output = ssgRoute.output, headers = ssgRoute.headers, cleanSsgRoute = _objectWithoutProperties(ssgRoute, [
96
- "output",
97
- "headers"
98
- ]);
99
- return Object.assign(cleanSsgRoute, output ? {
100
- entryPath: output
101
- } : {});
102
- });
103
- var freshRoutes = [];
104
- cleanSsgRoutes.forEach(function(ssgRoute) {
105
- var index = exist(ssgRoute, pageRoutes);
106
- if (index < 0) {
107
- freshRoutes.push(_objectSpread({}, ssgRoute));
108
- } else {
109
- pageRoutes[index].entryPath = ssgRoute.entryPath;
110
- }
111
- });
112
- (_pageRoutes = pageRoutes).push.apply(_pageRoutes, _toConsumableArray(freshRoutes));
113
- return pageRoutes;
106
+ export function replaceRoute(ssgRoutes, pageRoutes) {
107
+ var _pageRoutes;
108
+ var cleanSsgRoutes = ssgRoutes.map(function(ssgRoute) {
109
+ var output = ssgRoute.output, headers = ssgRoute.headers, cleanSsgRoute = _object_without_properties(ssgRoute, [
110
+ "output",
111
+ "headers"
112
+ ]);
113
+ return Object.assign(cleanSsgRoute, output ? {
114
+ entryPath: output
115
+ } : {});
116
+ });
117
+ var freshRoutes = [];
118
+ cleanSsgRoutes.forEach(function(ssgRoute) {
119
+ var index = exist(ssgRoute, pageRoutes);
120
+ if (index < 0) {
121
+ freshRoutes.push(_object_spread({}, ssgRoute));
122
+ } else {
123
+ pageRoutes[index].entryPath = ssgRoute.entryPath;
124
+ }
125
+ });
126
+ (_pageRoutes = pageRoutes).push.apply(_pageRoutes, _to_consumable_array(freshRoutes));
127
+ return pageRoutes;
114
128
  }
115
- export { exist, replaceRoute };