@modern-js/prod-server 2.0.0-beta.2 → 2.0.0-beta.4

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 (130) hide show
  1. package/CHANGELOG.md +132 -0
  2. package/dist/js/modern/constants.js +32 -25
  3. package/dist/js/modern/index.js +11 -6
  4. package/dist/js/modern/libs/context/context.js +52 -84
  5. package/dist/js/modern/libs/context/index.js +5 -2
  6. package/dist/js/modern/libs/hook-api/index.js +42 -35
  7. package/dist/js/modern/libs/hook-api/route.js +6 -7
  8. package/dist/js/modern/libs/hook-api/template.js +20 -34
  9. package/dist/js/modern/libs/loadConfig.js +45 -24
  10. package/dist/js/modern/libs/metrics.js +3 -4
  11. package/dist/js/modern/libs/proxy.js +68 -37
  12. package/dist/js/modern/libs/render/cache/__tests__/cache.fun.test.js +112 -67
  13. package/dist/js/modern/libs/render/cache/__tests__/cache.test.js +246 -216
  14. package/dist/js/modern/libs/render/cache/__tests__/cacheable.js +43 -49
  15. package/dist/js/modern/libs/render/cache/__tests__/error-configuration.js +36 -34
  16. package/dist/js/modern/libs/render/cache/__tests__/matched-cache.js +83 -113
  17. package/dist/js/modern/libs/render/cache/index.js +88 -54
  18. package/dist/js/modern/libs/render/cache/page-caches/index.js +31 -8
  19. package/dist/js/modern/libs/render/cache/page-caches/lru.js +6 -6
  20. package/dist/js/modern/libs/render/cache/spr.js +133 -117
  21. package/dist/js/modern/libs/render/cache/type.js +0 -1
  22. package/dist/js/modern/libs/render/cache/util.js +71 -39
  23. package/dist/js/modern/libs/render/index.js +76 -56
  24. package/dist/js/modern/libs/render/measure.js +38 -27
  25. package/dist/js/modern/libs/render/reader.js +65 -62
  26. package/dist/js/modern/libs/render/ssr.js +50 -32
  27. package/dist/js/modern/libs/render/static.js +50 -33
  28. package/dist/js/modern/libs/render/type.js +9 -6
  29. package/dist/js/modern/libs/route/index.js +8 -15
  30. package/dist/js/modern/libs/route/matcher.js +20 -34
  31. package/dist/js/modern/libs/route/route.js +9 -18
  32. package/dist/js/modern/libs/serve-file.js +33 -20
  33. package/dist/js/modern/server/index.js +144 -145
  34. package/dist/js/modern/server/modern-server-split.js +46 -12
  35. package/dist/js/modern/server/modern-server.js +377 -419
  36. package/dist/js/modern/type.js +0 -1
  37. package/dist/js/modern/utils.js +62 -43
  38. package/dist/js/modern/worker-server.js +34 -14
  39. package/dist/js/node/constants.js +45 -30
  40. package/dist/js/node/index.js +31 -57
  41. package/dist/js/node/libs/context/context.js +79 -94
  42. package/dist/js/node/libs/context/index.js +23 -13
  43. package/dist/js/node/libs/hook-api/index.js +69 -48
  44. package/dist/js/node/libs/hook-api/route.js +22 -11
  45. package/dist/js/node/libs/hook-api/template.js +36 -39
  46. package/dist/js/node/libs/loadConfig.js +69 -35
  47. package/dist/js/node/libs/metrics.js +21 -9
  48. package/dist/js/node/libs/proxy.js +86 -44
  49. package/dist/js/node/libs/render/cache/__tests__/cache.fun.test.js +132 -70
  50. package/dist/js/node/libs/render/cache/__tests__/cache.test.js +268 -218
  51. package/dist/js/node/libs/render/cache/__tests__/cacheable.js +61 -55
  52. package/dist/js/node/libs/render/cache/__tests__/error-configuration.js +54 -40
  53. package/dist/js/node/libs/render/cache/__tests__/matched-cache.js +101 -119
  54. package/dist/js/node/libs/render/cache/index.js +110 -64
  55. package/dist/js/node/libs/render/cache/page-caches/index.js +50 -14
  56. package/dist/js/node/libs/render/cache/page-caches/lru.js +29 -12
  57. package/dist/js/node/libs/render/cache/spr.js +156 -129
  58. package/dist/js/node/libs/render/cache/type.js +0 -5
  59. package/dist/js/node/libs/render/cache/util.js +88 -45
  60. package/dist/js/node/libs/render/index.js +102 -67
  61. package/dist/js/node/libs/render/measure.js +55 -31
  62. package/dist/js/node/libs/render/reader.js +87 -70
  63. package/dist/js/node/libs/render/ssr.js +76 -47
  64. package/dist/js/node/libs/render/static.js +75 -40
  65. package/dist/js/node/libs/render/type.js +27 -12
  66. package/dist/js/node/libs/route/index.js +26 -26
  67. package/dist/js/node/libs/route/matcher.js +36 -41
  68. package/dist/js/node/libs/route/route.js +25 -22
  69. package/dist/js/node/libs/serve-file.js +61 -32
  70. package/dist/js/node/server/index.js +160 -160
  71. package/dist/js/node/server/modern-server-split.js +68 -22
  72. package/dist/js/node/server/modern-server.js +395 -443
  73. package/dist/js/node/type.js +0 -3
  74. package/dist/js/node/utils.js +74 -52
  75. package/dist/js/node/worker-server.js +53 -21
  76. package/dist/js/treeshaking/constants.js +26 -25
  77. package/dist/js/treeshaking/index.js +10 -10
  78. package/dist/js/treeshaking/libs/context/context.js +268 -237
  79. package/dist/js/treeshaking/libs/context/index.js +3 -3
  80. package/dist/js/treeshaking/libs/hook-api/index.js +265 -143
  81. package/dist/js/treeshaking/libs/hook-api/route.js +65 -30
  82. package/dist/js/treeshaking/libs/hook-api/template.js +121 -85
  83. package/dist/js/treeshaking/libs/loadConfig.js +80 -37
  84. package/dist/js/treeshaking/libs/metrics.js +4 -10
  85. package/dist/js/treeshaking/libs/proxy.js +240 -76
  86. package/dist/js/treeshaking/libs/render/cache/__tests__/cache.fun.test.js +288 -121
  87. package/dist/js/treeshaking/libs/render/cache/__tests__/cache.test.js +772 -455
  88. package/dist/js/treeshaking/libs/render/cache/__tests__/cacheable.js +65 -51
  89. package/dist/js/treeshaking/libs/render/cache/__tests__/error-configuration.js +45 -35
  90. package/dist/js/treeshaking/libs/render/cache/__tests__/matched-cache.js +144 -118
  91. package/dist/js/treeshaking/libs/render/cache/index.js +337 -175
  92. package/dist/js/treeshaking/libs/render/cache/page-caches/index.js +151 -27
  93. package/dist/js/treeshaking/libs/render/cache/page-caches/lru.js +80 -42
  94. package/dist/js/treeshaking/libs/render/cache/spr.js +470 -340
  95. package/dist/js/treeshaking/libs/render/cache/type.js +1 -1
  96. package/dist/js/treeshaking/libs/render/cache/util.js +271 -92
  97. package/dist/js/treeshaking/libs/render/index.js +228 -95
  98. package/dist/js/treeshaking/libs/render/measure.js +142 -57
  99. package/dist/js/treeshaking/libs/render/reader.js +325 -177
  100. package/dist/js/treeshaking/libs/render/ssr.js +220 -95
  101. package/dist/js/treeshaking/libs/render/static.js +210 -78
  102. package/dist/js/treeshaking/libs/render/type.js +7 -6
  103. package/dist/js/treeshaking/libs/route/index.js +125 -89
  104. package/dist/js/treeshaking/libs/route/matcher.js +132 -107
  105. package/dist/js/treeshaking/libs/route/route.js +40 -26
  106. package/dist/js/treeshaking/libs/serve-file.js +177 -68
  107. package/dist/js/treeshaking/server/index.js +468 -327
  108. package/dist/js/treeshaking/server/modern-server-split.js +352 -144
  109. package/dist/js/treeshaking/server/modern-server.js +1046 -911
  110. package/dist/js/treeshaking/type.js +1 -1
  111. package/dist/js/treeshaking/utils.js +138 -81
  112. package/dist/js/treeshaking/worker-server.js +176 -55
  113. package/dist/types/index.d.ts +2 -0
  114. package/dist/types/libs/context/context.d.ts +4 -1
  115. package/dist/types/libs/loadConfig.d.ts +1 -0
  116. package/dist/types/libs/render/cache/index.d.ts +2 -0
  117. package/dist/types/libs/render/cache/spr.d.ts +2 -0
  118. package/dist/types/libs/route/route.d.ts +0 -1
  119. package/dist/types/server/index.d.ts +3 -0
  120. package/dist/types/utils.d.ts +1 -1
  121. package/dist/types/worker-server.d.ts +1 -2
  122. package/package.json +7 -14
  123. package/dist/js/modern/libs/render/modern/browser-list.js +0 -7
  124. package/dist/js/modern/libs/render/modern/index.js +0 -37
  125. package/dist/js/node/libs/render/modern/browser-list.js +0 -14
  126. package/dist/js/node/libs/render/modern/index.js +0 -46
  127. package/dist/js/treeshaking/libs/render/modern/browser-list.js +0 -7
  128. package/dist/js/treeshaking/libs/render/modern/index.js +0 -39
  129. package/dist/types/libs/render/modern/browser-list.d.ts +0 -1
  130. package/dist/types/libs/render/modern/index.d.ts +0 -3
@@ -1,94 +1,130 @@
1
- import _createForOfIteratorHelper from "@babel/runtime/helpers/esm/createForOfIteratorHelper";
2
- import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
3
- import _createClass from "@babel/runtime/helpers/esm/createClass";
4
- import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
5
- import { RouteMatcher } from "./matcher";
6
- export var RouteMatchManager = /*#__PURE__*/function () {
7
- function RouteMatchManager() {
8
- _classCallCheck(this, RouteMatchManager);
9
- _defineProperty(this, "matchers", void 0);
10
- _defineProperty(this, "specs", []);
11
- this.matchers = [];
12
- }
13
-
14
- // get all routes matches pathname
15
- _createClass(RouteMatchManager, [{
16
- key: "filter",
17
- value: function filter(pathname) {
18
- return this.matchers.reduce(function (matches, matcher) {
19
- if (matcher.matchUrlPath(pathname)) {
20
- matches.push(matcher);
21
- }
22
- return matches;
23
- }, []);
24
- }
25
-
26
- // get best match from a set of matches
27
- }, {
28
- key: "best",
29
- value: function best(pathname, matches) {
30
- var best;
31
- var matchedLen = 0;
32
- var _iterator = _createForOfIteratorHelper(matches),
33
- _step;
34
- try {
35
- for (_iterator.s(); !(_step = _iterator.n()).done;) {
36
- var match = _step.value;
37
- var len = match.matchLength(pathname);
38
- if (len === null) {
39
- continue;
40
- }
41
- if (len > matchedLen) {
42
- best = match;
43
- matchedLen = len;
44
- }
45
- }
46
- } catch (err) {
47
- _iterator.e(err);
48
- } finally {
49
- _iterator.f();
50
- }
51
- return best;
1
+ function _classCallCheck(instance, Constructor) {
2
+ if (!(instance instanceof Constructor)) {
3
+ throw new TypeError("Cannot call a class as a function");
52
4
  }
53
-
54
- // reset routes matcher
55
- }, {
56
- key: "reset",
57
- value: function reset(specs) {
58
- this.specs = specs;
59
- var matchers = specs.reduce(function (ms, spec) {
60
- ms.push(new RouteMatcher(spec));
61
- return ms;
62
- }, []);
63
- this.matchers = matchers;
5
+ }
6
+ function _defineProperties(target, props) {
7
+ for(var i = 0; i < props.length; i++){
8
+ var descriptor = props[i];
9
+ descriptor.enumerable = descriptor.enumerable || false;
10
+ descriptor.configurable = true;
11
+ if ("value" in descriptor) descriptor.writable = true;
12
+ Object.defineProperty(target, descriptor.key, descriptor);
64
13
  }
65
-
66
- // get best match from all matcher in manager
67
- }, {
68
- key: "match",
69
- value: function match(pathname) {
70
- var matches = this.filter(pathname);
71
- var best = this.best(pathname, matches);
72
- return best;
14
+ }
15
+ function _createClass(Constructor, protoProps, staticProps) {
16
+ if (protoProps) _defineProperties(Constructor.prototype, protoProps);
17
+ if (staticProps) _defineProperties(Constructor, staticProps);
18
+ return Constructor;
19
+ }
20
+ function _defineProperty(obj, key, value) {
21
+ if (key in obj) {
22
+ Object.defineProperty(obj, key, {
23
+ value: value,
24
+ enumerable: true,
25
+ configurable: true,
26
+ writable: true
27
+ });
28
+ } else {
29
+ obj[key] = value;
73
30
  }
74
- }, {
75
- key: "matchEntry",
76
- value: function matchEntry(entryname) {
77
- return this.matchers.find(function (matcher) {
78
- return matcher.matchEntry(entryname);
79
- });
80
- }
81
- }, {
82
- key: "getBundles",
83
- value: function getBundles() {
84
- var bundles = this.specs.filter(function (route) {
85
- return route.isSSR;
86
- }).map(function (route) {
87
- return route.bundle;
88
- });
89
- return bundles;
31
+ return obj;
32
+ }
33
+ import { RouteMatcher } from "./matcher";
34
+ var RouteMatchManager = /*#__PURE__*/ function() {
35
+ "use strict";
36
+ function RouteMatchManager() {
37
+ _classCallCheck(this, RouteMatchManager);
38
+ _defineProperty(this, "matchers", void 0);
39
+ _defineProperty(this, "specs", []);
40
+ this.matchers = [];
90
41
  }
91
- }]);
92
- return RouteMatchManager;
42
+ _createClass(RouteMatchManager, [
43
+ {
44
+ key: "filter",
45
+ value: function filter(pathname) {
46
+ return this.matchers.reduce(function(matches, matcher) {
47
+ if (matcher.matchUrlPath(pathname)) {
48
+ matches.push(matcher);
49
+ }
50
+ return matches;
51
+ }, []);
52
+ }
53
+ },
54
+ {
55
+ key: "best",
56
+ value: function best(pathname, matches) {
57
+ var best;
58
+ var matchedLen = 0;
59
+ var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
60
+ try {
61
+ for(var _iterator = matches[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
62
+ var match = _step.value;
63
+ var len = match.matchLength(pathname);
64
+ if (len === null) {
65
+ continue;
66
+ }
67
+ if (len > matchedLen) {
68
+ best = match;
69
+ matchedLen = len;
70
+ }
71
+ }
72
+ } catch (err) {
73
+ _didIteratorError = true;
74
+ _iteratorError = err;
75
+ } finally{
76
+ try {
77
+ if (!_iteratorNormalCompletion && _iterator.return != null) {
78
+ _iterator.return();
79
+ }
80
+ } finally{
81
+ if (_didIteratorError) {
82
+ throw _iteratorError;
83
+ }
84
+ }
85
+ }
86
+ return best;
87
+ }
88
+ },
89
+ {
90
+ key: "reset",
91
+ value: function reset(specs) {
92
+ this.specs = specs;
93
+ var matchers = specs.reduce(function(ms, spec) {
94
+ ms.push(new RouteMatcher(spec));
95
+ return ms;
96
+ }, []);
97
+ this.matchers = matchers;
98
+ }
99
+ },
100
+ {
101
+ key: "match",
102
+ value: function match(pathname) {
103
+ var matches = this.filter(pathname);
104
+ var best = this.best(pathname, matches);
105
+ return best;
106
+ }
107
+ },
108
+ {
109
+ key: "matchEntry",
110
+ value: function matchEntry(entryname) {
111
+ return this.matchers.find(function(matcher) {
112
+ return matcher.matchEntry(entryname);
113
+ });
114
+ }
115
+ },
116
+ {
117
+ key: "getBundles",
118
+ value: function getBundles() {
119
+ var bundles = this.specs.filter(function(route) {
120
+ return route.isSSR;
121
+ }).map(function(route) {
122
+ return route.bundle;
123
+ });
124
+ return bundles;
125
+ }
126
+ }
127
+ ]);
128
+ return RouteMatchManager;
93
129
  }();
94
- export { RouteMatcher };
130
+ export { RouteMatchManager, RouteMatcher };
@@ -1,113 +1,138 @@
1
- import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
2
- import _createClass from "@babel/runtime/helpers/esm/createClass";
3
- import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
4
- import { match, pathToRegexp, compile } from 'path-to-regexp';
1
+ function _classCallCheck(instance, Constructor) {
2
+ if (!(instance instanceof Constructor)) {
3
+ throw new TypeError("Cannot call a class as a function");
4
+ }
5
+ }
6
+ function _defineProperties(target, props) {
7
+ for(var i = 0; i < props.length; i++){
8
+ var descriptor = props[i];
9
+ descriptor.enumerable = descriptor.enumerable || false;
10
+ descriptor.configurable = true;
11
+ if ("value" in descriptor) descriptor.writable = true;
12
+ Object.defineProperty(target, descriptor.key, descriptor);
13
+ }
14
+ }
15
+ function _createClass(Constructor, protoProps, staticProps) {
16
+ if (protoProps) _defineProperties(Constructor.prototype, protoProps);
17
+ if (staticProps) _defineProperties(Constructor, staticProps);
18
+ return Constructor;
19
+ }
20
+ function _defineProperty(obj, key, value) {
21
+ if (key in obj) {
22
+ Object.defineProperty(obj, key, {
23
+ value: value,
24
+ enumerable: true,
25
+ configurable: true,
26
+ writable: true
27
+ });
28
+ } else {
29
+ obj[key] = value;
30
+ }
31
+ return obj;
32
+ }
33
+ import { match, pathToRegexp, compile } from "path-to-regexp";
5
34
  import { ModernRoute } from "./route";
6
-
7
- // avoid import @modern-js/utils
8
- var removeTailSlash = function removeTailSlash(s) {
9
- return s.replace(/\/+$/, '');
35
+ var removeTailSlash = function(s) {
36
+ return s.replace(/\/+$/, "");
10
37
  };
11
- var toPath = function toPath(reg, params) {
12
- var fn = compile(reg, {
13
- encode: encodeURIComponent
14
- });
15
- return fn(params);
38
+ var toPath = function(reg, params) {
39
+ var fn = compile(reg, {
40
+ encode: encodeURIComponent
41
+ });
42
+ return fn(params);
16
43
  };
17
-
18
- // eslint-disable-next-line no-useless-escape
19
44
  var regCharsDetector = /[^a-zA-Z\-_0-9\/\.]/;
20
- export var RouteMatcher = /*#__PURE__*/function () {
21
- function RouteMatcher(spec) {
22
- _classCallCheck(this, RouteMatcher);
23
- _defineProperty(this, "spec", void 0);
24
- _defineProperty(this, "urlPath", '');
25
- _defineProperty(this, "urlMatcher", void 0);
26
- _defineProperty(this, "urlReg", void 0);
27
- this.spec = spec;
28
- this.setupUrlPath();
29
- }
30
-
31
- // generate modern route object
32
- _createClass(RouteMatcher, [{
33
- key: "generate",
34
- value: function generate(url) {
35
- var route = new ModernRoute(this.spec);
36
- if (this.urlPath) {
37
- var params = this.parseURLParams(url);
38
- route.urlPath = toPath(route.urlPath, params);
39
- route.params = params;
40
- }
41
- return route;
42
- }
43
- }, {
44
- key: "parseURLParams",
45
- value: function parseURLParams(pathname) {
46
- if (!this.urlMatcher) {
47
- return {};
48
- } else {
49
- var matchResult = this.urlMatcher(pathname);
50
- return matchResult.params;
51
- }
52
- }
53
-
54
- // get match url length
55
- }, {
56
- key: "matchLength",
57
- value: function matchLength(pathname) {
58
- if (!this.urlReg) {
59
- return this.urlPath.length;
60
- } else {
61
- var _result$;
62
- var result = this.urlReg.exec(pathname);
63
- return (result === null || result === void 0 ? void 0 : (_result$ = result[0]) === null || _result$ === void 0 ? void 0 : _result$.length) || null;
64
- }
45
+ var RouteMatcher = /*#__PURE__*/ function() {
46
+ "use strict";
47
+ function RouteMatcher(spec) {
48
+ _classCallCheck(this, RouteMatcher);
49
+ _defineProperty(this, "spec", void 0);
50
+ _defineProperty(this, "urlPath", "");
51
+ _defineProperty(this, "urlMatcher", void 0);
52
+ _defineProperty(this, "urlReg", void 0);
53
+ this.spec = spec;
54
+ this.setupUrlPath();
65
55
  }
66
-
67
- // if match url path
68
- }, {
69
- key: "matchUrlPath",
70
- value: function matchUrlPath(requestUrl) {
71
- var urlWithoutSlash = requestUrl.endsWith('/') && requestUrl !== '/' ? requestUrl.slice(0, -1) : requestUrl;
72
- if (urlWithoutSlash.endsWith('.html')) {
73
- urlWithoutSlash = urlWithoutSlash.slice(0, -5);
74
- }
75
- if (this.urlMatcher) {
76
- return Boolean(this.urlMatcher(urlWithoutSlash));
77
- } else {
78
- if (urlWithoutSlash.startsWith(this.urlPath)) {
79
- // avoid /abcd match /a
80
- if (this.urlPath !== '/' && urlWithoutSlash.length > this.urlPath.length && !urlWithoutSlash.startsWith("".concat(this.urlPath, "/"))) {
81
- return false;
82
- }
83
- return true;
56
+ _createClass(RouteMatcher, [
57
+ {
58
+ key: "generate",
59
+ value: function generate(url) {
60
+ var route = new ModernRoute(this.spec);
61
+ if (this.urlPath) {
62
+ var params = this.parseURLParams(url);
63
+ route.urlPath = toPath(route.urlPath, params);
64
+ route.params = params;
65
+ }
66
+ return route;
67
+ }
68
+ },
69
+ {
70
+ key: "parseURLParams",
71
+ value: function parseURLParams(pathname) {
72
+ if (!this.urlMatcher) {
73
+ return {};
74
+ } else {
75
+ var matchResult = this.urlMatcher(pathname);
76
+ return matchResult.params;
77
+ }
78
+ }
79
+ },
80
+ {
81
+ key: "matchLength",
82
+ value: function matchLength(pathname) {
83
+ if (!this.urlReg) {
84
+ return this.urlPath.length;
85
+ } else {
86
+ var ref;
87
+ var result = this.urlReg.exec(pathname);
88
+ return (result === null || result === void 0 ? void 0 : (ref = result[0]) === null || ref === void 0 ? void 0 : ref.length) || null;
89
+ }
90
+ }
91
+ },
92
+ {
93
+ key: "matchUrlPath",
94
+ value: function matchUrlPath(requestUrl) {
95
+ var urlWithoutSlash = requestUrl.endsWith("/") && requestUrl !== "/" ? requestUrl.slice(0, -1) : requestUrl;
96
+ if (urlWithoutSlash.endsWith(".html")) {
97
+ urlWithoutSlash = urlWithoutSlash.slice(0, -5);
98
+ }
99
+ if (this.urlMatcher) {
100
+ return Boolean(this.urlMatcher(urlWithoutSlash));
101
+ } else {
102
+ if (urlWithoutSlash.startsWith(this.urlPath)) {
103
+ if (this.urlPath !== "/" && urlWithoutSlash.length > this.urlPath.length && !urlWithoutSlash.startsWith("".concat(this.urlPath, "/"))) {
104
+ return false;
105
+ }
106
+ return true;
107
+ }
108
+ return false;
109
+ }
110
+ }
111
+ },
112
+ {
113
+ key: "matchEntry",
114
+ value: function matchEntry(entryName) {
115
+ return this.spec.entryName === entryName;
116
+ }
117
+ },
118
+ {
119
+ key: "setupUrlPath",
120
+ value: function setupUrlPath() {
121
+ var urlPath = this.spec.urlPath;
122
+ this.urlPath = urlPath === "/" ? urlPath : removeTailSlash(urlPath);
123
+ var useReg = regCharsDetector.test(urlPath);
124
+ if (useReg) {
125
+ this.urlMatcher = match(urlPath, {
126
+ end: false,
127
+ decode: decodeURIComponent
128
+ });
129
+ this.urlReg = pathToRegexp(urlPath, [], {
130
+ end: false
131
+ });
132
+ }
133
+ }
84
134
  }
85
- return false;
86
- }
87
- }
88
- }, {
89
- key: "matchEntry",
90
- value: function matchEntry(entryName) {
91
- return this.spec.entryName === entryName;
92
- }
93
-
94
- // compiler urlPath to regexp if necessary
95
- }, {
96
- key: "setupUrlPath",
97
- value: function setupUrlPath() {
98
- var urlPath = this.spec.urlPath;
99
- this.urlPath = urlPath === '/' ? urlPath : removeTailSlash(urlPath);
100
- var useReg = regCharsDetector.test(urlPath);
101
- if (useReg) {
102
- this.urlMatcher = match(urlPath, {
103
- end: false,
104
- decode: decodeURIComponent
105
- });
106
- this.urlReg = pathToRegexp(urlPath, [], {
107
- end: false
108
- });
109
- }
110
- }
111
- }]);
112
- return RouteMatcher;
113
- }();
135
+ ]);
136
+ return RouteMatcher;
137
+ }();
138
+ export { RouteMatcher };
@@ -1,26 +1,40 @@
1
- import _createClass from "@babel/runtime/helpers/esm/createClass";
2
- import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
3
- import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
4
- export var ModernRoute = /*#__PURE__*/_createClass(function ModernRoute(routeSpec) {
5
- var _routeSpec$enableMode;
6
- _classCallCheck(this, ModernRoute);
7
- _defineProperty(this, "entryName", void 0);
8
- _defineProperty(this, "urlPath", void 0);
9
- _defineProperty(this, "entryPath", void 0);
10
- _defineProperty(this, "bundle", void 0);
11
- _defineProperty(this, "isApi", void 0);
12
- _defineProperty(this, "isSSR", void 0);
13
- _defineProperty(this, "isSPA", void 0);
14
- _defineProperty(this, "enableModernMode", void 0);
15
- _defineProperty(this, "params", {});
16
- _defineProperty(this, "responseHeaders", void 0);
17
- this.entryName = routeSpec.entryName || '';
18
- this.urlPath = routeSpec.urlPath;
19
- this.entryPath = routeSpec.entryPath || '';
20
- this.isSSR = routeSpec.isSSR || false;
21
- this.isSPA = routeSpec.isSPA || false;
22
- this.isApi = routeSpec.isApi || false;
23
- this.bundle = routeSpec.bundle || '';
24
- this.enableModernMode = (_routeSpec$enableMode = routeSpec.enableModernMode) !== null && _routeSpec$enableMode !== void 0 ? _routeSpec$enableMode : false;
25
- this.responseHeaders = routeSpec.responseHeaders;
26
- });
1
+ function _classCallCheck(instance, Constructor) {
2
+ if (!(instance instanceof Constructor)) {
3
+ throw new TypeError("Cannot call a class as a function");
4
+ }
5
+ }
6
+ function _defineProperty(obj, key, value) {
7
+ if (key in obj) {
8
+ Object.defineProperty(obj, key, {
9
+ value: value,
10
+ enumerable: true,
11
+ configurable: true,
12
+ writable: true
13
+ });
14
+ } else {
15
+ obj[key] = value;
16
+ }
17
+ return obj;
18
+ }
19
+ var ModernRoute = function ModernRoute(routeSpec) {
20
+ "use strict";
21
+ _classCallCheck(this, ModernRoute);
22
+ _defineProperty(this, "entryName", void 0);
23
+ _defineProperty(this, "urlPath", void 0);
24
+ _defineProperty(this, "entryPath", void 0);
25
+ _defineProperty(this, "bundle", void 0);
26
+ _defineProperty(this, "isApi", void 0);
27
+ _defineProperty(this, "isSSR", void 0);
28
+ _defineProperty(this, "isSPA", void 0);
29
+ _defineProperty(this, "params", {});
30
+ _defineProperty(this, "responseHeaders", void 0);
31
+ this.entryName = routeSpec.entryName || "";
32
+ this.urlPath = routeSpec.urlPath;
33
+ this.entryPath = routeSpec.entryPath || "";
34
+ this.isSSR = routeSpec.isSSR || false;
35
+ this.isSPA = routeSpec.isSPA || false;
36
+ this.isApi = routeSpec.isApi || false;
37
+ this.bundle = routeSpec.bundle || "";
38
+ this.responseHeaders = routeSpec.responseHeaders;
39
+ };
40
+ export { ModernRoute };