@vercel/routing-utils 2.2.1 → 3.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/append.js +62 -41
- package/dist/index.js +339 -282
- package/dist/merge.js +106 -88
- package/dist/schemas.d.ts +7 -0
- package/dist/schemas.js +315 -275
- package/dist/superstatic.js +312 -300
- package/dist/types.d.ts +1 -0
- package/dist/types.js +15 -1
- package/package.json +9 -8
package/dist/append.js
CHANGED
|
@@ -1,45 +1,66 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
Object.defineProperty
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var append_exports = {};
|
|
20
|
+
__export(append_exports, {
|
|
21
|
+
appendRoutesToPhase: () => appendRoutesToPhase
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(append_exports);
|
|
24
|
+
var import_index = require("./index");
|
|
25
|
+
function appendRoutesToPhase({
|
|
26
|
+
routes: prevRoutes,
|
|
27
|
+
newRoutes,
|
|
28
|
+
phase
|
|
29
|
+
}) {
|
|
30
|
+
const routes = prevRoutes ? [...prevRoutes] : [];
|
|
31
|
+
if (newRoutes === null || newRoutes.length === 0) {
|
|
32
|
+
return routes;
|
|
33
|
+
}
|
|
34
|
+
let isInPhase = false;
|
|
35
|
+
let insertIndex = -1;
|
|
36
|
+
routes.forEach((r, i) => {
|
|
37
|
+
if ((0, import_index.isHandler)(r)) {
|
|
38
|
+
if (r.handle === phase) {
|
|
39
|
+
isInPhase = true;
|
|
40
|
+
} else if (isInPhase) {
|
|
41
|
+
insertIndex = i;
|
|
42
|
+
isInPhase = false;
|
|
43
|
+
}
|
|
38
44
|
}
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
45
|
+
});
|
|
46
|
+
if (isInPhase) {
|
|
47
|
+
routes.push(...newRoutes);
|
|
48
|
+
} else if (phase === null) {
|
|
49
|
+
const lastPhase = routes.findIndex((r) => (0, import_index.isHandler)(r) && r.handle);
|
|
50
|
+
if (lastPhase === -1) {
|
|
51
|
+
routes.push(...newRoutes);
|
|
52
|
+
} else {
|
|
53
|
+
routes.splice(lastPhase, 0, ...newRoutes);
|
|
42
54
|
}
|
|
43
|
-
|
|
55
|
+
} else if (insertIndex > -1) {
|
|
56
|
+
routes.splice(insertIndex, 0, ...newRoutes);
|
|
57
|
+
} else {
|
|
58
|
+
routes.push({ handle: phase });
|
|
59
|
+
routes.push(...newRoutes);
|
|
60
|
+
}
|
|
61
|
+
return routes;
|
|
44
62
|
}
|
|
45
|
-
|
|
63
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
64
|
+
0 && (module.exports = {
|
|
65
|
+
appendRoutesToPhase
|
|
66
|
+
});
|