@module-federation/nextjs-mf 8.8.56 → 8.8.58
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/LICENSE +21 -0
- package/dist/_virtual/_rolldown/runtime.js +29 -0
- package/dist/_virtual/_rolldown/runtime.mjs +8 -0
- package/dist/client/UrlNode.js +89 -147
- package/dist/client/UrlNode.js.map +1 -1
- package/dist/client/UrlNode.mjs +91 -0
- package/dist/client/UrlNode.mjs.map +1 -0
- package/dist/src/federation-noop.d.mts +1 -0
- package/dist/src/federation-noop.d.ts +1 -0
- package/dist/src/federation-noop.js +17 -0
- package/dist/src/federation-noop.js.map +1 -1
- package/dist/src/federation-noop.mjs +23 -0
- package/dist/src/federation-noop.mjs.map +1 -0
- package/dist/src/index.d.mts +2 -0
- package/dist/src/index.d.ts +2 -3
- package/dist/src/index.js +13 -11
- package/dist/src/index.js.map +1 -1
- package/dist/src/index.mjs +8 -0
- package/dist/src/index.mjs.map +1 -0
- package/dist/src/internal.js +140 -243
- package/dist/src/internal.js.map +1 -1
- package/dist/src/internal.mjs +152 -0
- package/dist/src/internal.mjs.map +1 -0
- package/dist/src/loaders/fixImageLoader.d.mts +27 -0
- package/dist/src/loaders/fixImageLoader.d.ts +8 -3
- package/dist/src/loaders/fixImageLoader.js +91 -103
- package/dist/src/loaders/fixImageLoader.js.map +1 -1
- package/dist/src/loaders/fixImageLoader.mjs +101 -0
- package/dist/src/loaders/fixImageLoader.mjs.map +1 -0
- package/dist/src/loaders/fixUrlLoader.d.mts +16 -0
- package/dist/src/loaders/fixUrlLoader.d.ts +5 -2
- package/dist/src/loaders/fixUrlLoader.js +17 -19
- package/dist/src/loaders/fixUrlLoader.js.map +1 -1
- package/dist/src/loaders/fixUrlLoader.mjs +19 -0
- package/dist/src/loaders/fixUrlLoader.mjs.map +1 -0
- package/dist/src/loaders/helpers.js +72 -124
- package/dist/src/loaders/helpers.js.map +1 -1
- package/dist/src/loaders/helpers.mjs +79 -0
- package/dist/src/loaders/helpers.mjs.map +1 -0
- package/dist/src/loaders/nextPageMapLoader.d.mts +29 -0
- package/dist/src/loaders/nextPageMapLoader.d.ts +10 -5
- package/dist/src/loaders/nextPageMapLoader.js +126 -144
- package/dist/src/loaders/nextPageMapLoader.js.map +1 -1
- package/dist/src/loaders/nextPageMapLoader.mjs +143 -0
- package/dist/src/loaders/nextPageMapLoader.mjs.map +1 -0
- package/dist/src/logger.js +7 -7
- package/dist/src/logger.js.map +1 -1
- package/dist/src/logger.mjs +8 -0
- package/dist/src/logger.mjs.map +1 -0
- package/dist/src/plugins/CopyFederationPlugin.js +64 -71
- package/dist/src/plugins/CopyFederationPlugin.js.map +1 -1
- package/dist/src/plugins/CopyFederationPlugin.mjs +65 -0
- package/dist/src/plugins/CopyFederationPlugin.mjs.map +1 -0
- package/dist/src/plugins/NextFederationPlugin/apply-client-plugins.js +36 -53
- package/dist/src/plugins/NextFederationPlugin/apply-client-plugins.js.map +1 -1
- package/dist/src/plugins/NextFederationPlugin/apply-client-plugins.mjs +40 -0
- package/dist/src/plugins/NextFederationPlugin/apply-client-plugins.mjs.map +1 -0
- package/dist/src/plugins/NextFederationPlugin/apply-server-plugins.js +103 -121
- package/dist/src/plugins/NextFederationPlugin/apply-server-plugins.js.map +1 -1
- package/dist/src/plugins/NextFederationPlugin/apply-server-plugins.mjs +111 -0
- package/dist/src/plugins/NextFederationPlugin/apply-server-plugins.mjs.map +1 -0
- package/dist/src/plugins/NextFederationPlugin/index.d.mts +31 -0
- package/dist/src/plugins/NextFederationPlugin/index.d.ts +27 -23
- package/dist/src/plugins/NextFederationPlugin/index.js +151 -181
- package/dist/src/plugins/NextFederationPlugin/index.js.map +1 -1
- package/dist/src/plugins/NextFederationPlugin/index.mjs +153 -0
- package/dist/src/plugins/NextFederationPlugin/index.mjs.map +1 -0
- package/dist/src/plugins/NextFederationPlugin/next-fragments.d.mts +18 -0
- package/dist/src/plugins/NextFederationPlugin/next-fragments.d.ts +16 -18
- package/dist/src/plugins/NextFederationPlugin/next-fragments.js +58 -93
- package/dist/src/plugins/NextFederationPlugin/next-fragments.js.map +1 -1
- package/dist/src/plugins/NextFederationPlugin/next-fragments.mjs +63 -0
- package/dist/src/plugins/NextFederationPlugin/next-fragments.mjs.map +1 -0
- package/dist/src/plugins/NextFederationPlugin/set-options.js +17 -19
- package/dist/src/plugins/NextFederationPlugin/set-options.js.map +1 -1
- package/dist/src/plugins/NextFederationPlugin/set-options.mjs +19 -0
- package/dist/src/plugins/NextFederationPlugin/set-options.mjs.map +1 -0
- package/dist/src/plugins/NextFederationPlugin/validate-options.js +30 -38
- package/dist/src/plugins/NextFederationPlugin/validate-options.js.map +1 -1
- package/dist/src/plugins/NextFederationPlugin/validate-options.mjs +35 -0
- package/dist/src/plugins/NextFederationPlugin/validate-options.mjs.map +1 -0
- package/dist/src/plugins/container/InvertedContainerPlugin.js +23 -25
- package/dist/src/plugins/container/InvertedContainerPlugin.js.map +1 -1
- package/dist/src/plugins/container/InvertedContainerPlugin.mjs +27 -0
- package/dist/src/plugins/container/InvertedContainerPlugin.mjs.map +1 -0
- package/dist/src/plugins/container/InvertedContainerRuntimeModule.js +55 -67
- package/dist/src/plugins/container/InvertedContainerRuntimeModule.js.map +1 -1
- package/dist/src/plugins/container/InvertedContainerRuntimeModule.mjs +57 -0
- package/dist/src/plugins/container/InvertedContainerRuntimeModule.mjs.map +1 -0
- package/dist/src/plugins/container/runtimePlugin.d.mts +7 -0
- package/dist/src/plugins/container/runtimePlugin.d.ts +6 -2
- package/dist/src/plugins/container/runtimePlugin.js +167 -0
- package/dist/src/plugins/container/runtimePlugin.js.map +1 -1
- package/dist/src/plugins/container/runtimePlugin.mjs +166 -0
- package/dist/src/plugins/container/runtimePlugin.mjs.map +1 -0
- package/dist/utils/flushedChunks.d.mts +29 -0
- package/dist/utils/flushedChunks.d.ts +12 -5
- package/dist/utils/flushedChunks.js +32 -72
- package/dist/utils/flushedChunks.js.map +1 -1
- package/dist/utils/flushedChunks.mjs +35 -0
- package/dist/utils/flushedChunks.mjs.map +1 -0
- package/dist/utils/index.d.mts +14 -0
- package/dist/utils/index.d.ts +8 -14
- package/dist/utils/index.js +27 -62
- package/dist/utils/index.js.map +1 -1
- package/dist/utils/index.mjs +22 -0
- package/dist/utils/index.mjs.map +1 -0
- package/package.json +34 -10
- package/dist/client/UrlNode.d.ts +0 -17
- package/dist/node.d.ts +0 -1
- package/dist/node.js +0 -18
- package/dist/node.js.map +0 -1
- package/dist/package.json +0 -80
- package/dist/src/federation-noop.cjs +0 -15
- package/dist/src/internal.d.ts +0 -50
- package/dist/src/loaders/helpers.d.ts +0 -17
- package/dist/src/logger.d.ts +0 -2
- package/dist/src/plugins/AddRuntimeRequirementToPromiseExternalPlugin.d.ts +0 -5
- package/dist/src/plugins/AddRuntimeRequirementToPromiseExternalPlugin.js +0 -19
- package/dist/src/plugins/AddRuntimeRequirementToPromiseExternalPlugin.js.map +0 -1
- package/dist/src/plugins/CopyFederationPlugin.d.ts +0 -20
- package/dist/src/plugins/NextFederationPlugin/apply-client-plugins.d.ts +0 -23
- package/dist/src/plugins/NextFederationPlugin/apply-server-plugins.d.ts +0 -36
- package/dist/src/plugins/NextFederationPlugin/regex-equal.d.ts +0 -14
- package/dist/src/plugins/NextFederationPlugin/regex-equal.js +0 -25
- package/dist/src/plugins/NextFederationPlugin/regex-equal.js.map +0 -1
- package/dist/src/plugins/NextFederationPlugin/remove-unnecessary-shared-keys.d.ts +0 -8
- package/dist/src/plugins/NextFederationPlugin/remove-unnecessary-shared-keys.js +0 -34
- package/dist/src/plugins/NextFederationPlugin/remove-unnecessary-shared-keys.js.map +0 -1
- package/dist/src/plugins/NextFederationPlugin/set-options.d.ts +0 -16
- package/dist/src/plugins/NextFederationPlugin/validate-options.d.ts +0 -25
- package/dist/src/plugins/container/InvertedContainerPlugin.d.ts +0 -5
- package/dist/src/plugins/container/InvertedContainerRuntimeModule.d.ts +0 -11
- package/dist/src/plugins/container/RemoveEagerModulesFromRuntimePlugin.d.ts +0 -39
- package/dist/src/plugins/container/RemoveEagerModulesFromRuntimePlugin.js +0 -78
- package/dist/src/plugins/container/RemoveEagerModulesFromRuntimePlugin.js.map +0 -1
- package/dist/src/plugins/container/runtimePlugin.cjs +0 -219
- package/dist/src/plugins/container/types.d.ts +0 -2
- package/dist/src/plugins/container/types.js +0 -3
- package/dist/src/plugins/container/types.js.map +0 -1
- package/dist/src/types.d.ts +0 -28
- package/dist/src/types.js +0 -3
- package/dist/src/types.js.map +0 -1
package/dist/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2023-present zhanghang(2heal1)
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
//#region \0rolldown/runtime.js
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __copyProps = (to, from, except, desc) => {
|
|
9
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
10
|
+
for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
|
|
11
|
+
key = keys[i];
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except) {
|
|
13
|
+
__defProp(to, key, {
|
|
14
|
+
get: ((k) => from[k]).bind(null, key),
|
|
15
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
return to;
|
|
21
|
+
};
|
|
22
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
|
|
23
|
+
value: mod,
|
|
24
|
+
enumerable: true
|
|
25
|
+
}) : target, mod));
|
|
26
|
+
|
|
27
|
+
//#endregion
|
|
28
|
+
|
|
29
|
+
exports.__toESM = __toESM;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { createRequire } from "node:module";
|
|
2
|
+
|
|
3
|
+
//#region \0rolldown/runtime.js
|
|
4
|
+
var __commonJSMin = (cb, mod) => () => (mod || cb((mod = { exports: {} }).exports, mod), mod.exports);
|
|
5
|
+
var __require = /* @__PURE__ */ createRequire(import.meta.url);
|
|
6
|
+
|
|
7
|
+
//#endregion
|
|
8
|
+
export { __commonJSMin, __require };
|
package/dist/client/UrlNode.js
CHANGED
|
@@ -1,150 +1,92 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
exports.UrlNode = void 0;
|
|
4
|
-
// TODO: fix the no-non-null assertion errors
|
|
5
|
-
/* eslint-disable @typescript-eslint/no-non-null-assertion */
|
|
1
|
+
|
|
2
|
+
//#region client/UrlNode.ts
|
|
6
3
|
/**
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
class UrlNode {
|
|
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
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
if (previousSlug !== null && previousSlug !== nextSlug) {
|
|
95
|
-
throw new Error(`You cannot use different slug names for the same dynamic path ('${previousSlug}' !== '${nextSlug}').`);
|
|
96
|
-
}
|
|
97
|
-
slugNames.forEach((slug) => {
|
|
98
|
-
if (slug === nextSlug) {
|
|
99
|
-
throw new Error(`You cannot have the same slug name "${nextSlug}" repeat within a single dynamic path`);
|
|
100
|
-
}
|
|
101
|
-
if (slug.replace(/\W/g, '') === nextSegment.replace(/\W/g, '')) {
|
|
102
|
-
throw new Error(`You cannot have the slug names "${slug}" and "${nextSlug}" differ only by non-word symbols within a single dynamic path`);
|
|
103
|
-
}
|
|
104
|
-
});
|
|
105
|
-
slugNames.push(nextSlug);
|
|
106
|
-
};
|
|
107
|
-
if (isCatchAll) {
|
|
108
|
-
if (isOptional) {
|
|
109
|
-
if (this.restSlugName != null) {
|
|
110
|
-
throw new Error(`You cannot use both an required and optional catch-all route at the same level ("[...${this.restSlugName}]" and "${urlPaths[0]}" ).`);
|
|
111
|
-
}
|
|
112
|
-
handleSlug(this.optionalRestSlugName, segmentName);
|
|
113
|
-
// slugName is kept as it can only be one particular slugName
|
|
114
|
-
this.optionalRestSlugName = segmentName;
|
|
115
|
-
// nextSegment is overwritten to [[...]] so that it can later be sorted specifically
|
|
116
|
-
nextSegment = '[[...]]';
|
|
117
|
-
}
|
|
118
|
-
else {
|
|
119
|
-
if (this.optionalRestSlugName != null) {
|
|
120
|
-
throw new Error(`You cannot use both an optional and required catch-all route at the same level ("[[...${this.optionalRestSlugName}]]" and "${urlPaths[0]}").`);
|
|
121
|
-
}
|
|
122
|
-
handleSlug(this.restSlugName, segmentName);
|
|
123
|
-
// slugName is kept as it can only be one particular slugName
|
|
124
|
-
this.restSlugName = segmentName;
|
|
125
|
-
// nextSegment is overwritten to [...] so that it can later be sorted specifically
|
|
126
|
-
nextSegment = '[...]';
|
|
127
|
-
}
|
|
128
|
-
}
|
|
129
|
-
else {
|
|
130
|
-
if (isOptional) {
|
|
131
|
-
throw new Error(`Optional route parameters are not yet supported ("${urlPaths[0]}").`);
|
|
132
|
-
}
|
|
133
|
-
handleSlug(this.slugName, segmentName);
|
|
134
|
-
// slugName is kept as it can only be one particular slugName
|
|
135
|
-
this.slugName = segmentName;
|
|
136
|
-
// nextSegment is overwritten to [] so that it can later be sorted specifically
|
|
137
|
-
nextSegment = '[]';
|
|
138
|
-
}
|
|
139
|
-
}
|
|
140
|
-
// If this UrlNode doesn't have the nextSegment yet we create a new child UrlNode
|
|
141
|
-
if (!this.children.has(nextSegment)) {
|
|
142
|
-
this.children.set(nextSegment, new UrlNode());
|
|
143
|
-
}
|
|
144
|
-
this.children
|
|
145
|
-
.get(nextSegment)
|
|
146
|
-
._insert(urlPaths.slice(1), slugNames, isCatchAll);
|
|
147
|
-
}
|
|
148
|
-
}
|
|
4
|
+
* This class provides a logic of sorting dynamic routes in NextJS.
|
|
5
|
+
*
|
|
6
|
+
* It was copied from
|
|
7
|
+
* @see https://github.com/vercel/next.js/blob/canary/packages/next/shared/lib/router/utils/sorted-routes.ts
|
|
8
|
+
*/
|
|
9
|
+
var UrlNode = class UrlNode {
|
|
10
|
+
constructor() {
|
|
11
|
+
this.placeholder = true;
|
|
12
|
+
this.children = /* @__PURE__ */ new Map();
|
|
13
|
+
this.slugName = null;
|
|
14
|
+
this.restSlugName = null;
|
|
15
|
+
this.optionalRestSlugName = null;
|
|
16
|
+
}
|
|
17
|
+
insert(urlPath) {
|
|
18
|
+
this._insert(urlPath.split("/").filter(Boolean), [], false);
|
|
19
|
+
}
|
|
20
|
+
smoosh() {
|
|
21
|
+
return this._smoosh();
|
|
22
|
+
}
|
|
23
|
+
_smoosh(prefix = "/") {
|
|
24
|
+
const childrenPaths = [...this.children.keys()].sort();
|
|
25
|
+
if (this.slugName !== null) childrenPaths.splice(childrenPaths.indexOf("[]"), 1);
|
|
26
|
+
if (this.restSlugName !== null) childrenPaths.splice(childrenPaths.indexOf("[...]"), 1);
|
|
27
|
+
if (this.optionalRestSlugName !== null) childrenPaths.splice(childrenPaths.indexOf("[[...]]"), 1);
|
|
28
|
+
const routes = childrenPaths.map((c) => this.children.get(c)._smoosh(`${prefix}${c}/`)).reduce((prev, curr) => [...prev, ...curr], []);
|
|
29
|
+
if (this.slugName !== null) routes.push(...this.children.get("[]")._smoosh(`${prefix}[${this.slugName}]/`));
|
|
30
|
+
if (!this.placeholder) {
|
|
31
|
+
const r = prefix === "/" ? "/" : prefix.slice(0, -1);
|
|
32
|
+
if (this.optionalRestSlugName != null) throw new Error(`You cannot define a route with the same specificity as a optional catch-all route ("${r}" and "${r}[[...${this.optionalRestSlugName}]]").`);
|
|
33
|
+
routes.unshift(r);
|
|
34
|
+
}
|
|
35
|
+
if (this.restSlugName !== null) routes.push(...this.children.get("[...]")._smoosh(`${prefix}[...${this.restSlugName}]/`));
|
|
36
|
+
if (this.optionalRestSlugName !== null) routes.push(...this.children.get("[[...]]")._smoosh(`${prefix}[[...${this.optionalRestSlugName}]]/`));
|
|
37
|
+
return routes;
|
|
38
|
+
}
|
|
39
|
+
_insert(urlPaths, slugNames, isCatchAll) {
|
|
40
|
+
if (urlPaths.length === 0) {
|
|
41
|
+
this.placeholder = false;
|
|
42
|
+
return;
|
|
43
|
+
}
|
|
44
|
+
if (isCatchAll) throw new Error(`Catch-all must be the last part of the URL.`);
|
|
45
|
+
let nextSegment = urlPaths[0];
|
|
46
|
+
if (nextSegment.startsWith("[") && nextSegment.endsWith("]")) {
|
|
47
|
+
let segmentName = nextSegment.slice(1, -1);
|
|
48
|
+
let isOptional = false;
|
|
49
|
+
if (segmentName.startsWith("[") && segmentName.endsWith("]")) {
|
|
50
|
+
segmentName = segmentName.slice(1, -1);
|
|
51
|
+
isOptional = true;
|
|
52
|
+
}
|
|
53
|
+
if (segmentName.startsWith("...")) {
|
|
54
|
+
segmentName = segmentName.substring(3);
|
|
55
|
+
isCatchAll = true;
|
|
56
|
+
}
|
|
57
|
+
if (segmentName.startsWith("[") || segmentName.endsWith("]")) throw new Error(`Segment names may not start or end with extra brackets ('${segmentName}').`);
|
|
58
|
+
if (segmentName.startsWith(".")) throw new Error(`Segment names may not start with erroneous periods ('${segmentName}').`);
|
|
59
|
+
const handleSlug = function handleSlug(previousSlug, nextSlug) {
|
|
60
|
+
if (previousSlug !== null && previousSlug !== nextSlug) throw new Error(`You cannot use different slug names for the same dynamic path ('${previousSlug}' !== '${nextSlug}').`);
|
|
61
|
+
slugNames.forEach((slug) => {
|
|
62
|
+
if (slug === nextSlug) throw new Error(`You cannot have the same slug name "${nextSlug}" repeat within a single dynamic path`);
|
|
63
|
+
if (slug.replace(/\W/g, "") === nextSegment.replace(/\W/g, "")) throw new Error(`You cannot have the slug names "${slug}" and "${nextSlug}" differ only by non-word symbols within a single dynamic path`);
|
|
64
|
+
});
|
|
65
|
+
slugNames.push(nextSlug);
|
|
66
|
+
};
|
|
67
|
+
if (isCatchAll) if (isOptional) {
|
|
68
|
+
if (this.restSlugName != null) throw new Error(`You cannot use both an required and optional catch-all route at the same level ("[...${this.restSlugName}]" and "${urlPaths[0]}" ).`);
|
|
69
|
+
handleSlug(this.optionalRestSlugName, segmentName);
|
|
70
|
+
this.optionalRestSlugName = segmentName;
|
|
71
|
+
nextSegment = "[[...]]";
|
|
72
|
+
} else {
|
|
73
|
+
if (this.optionalRestSlugName != null) throw new Error(`You cannot use both an optional and required catch-all route at the same level ("[[...${this.optionalRestSlugName}]]" and "${urlPaths[0]}").`);
|
|
74
|
+
handleSlug(this.restSlugName, segmentName);
|
|
75
|
+
this.restSlugName = segmentName;
|
|
76
|
+
nextSegment = "[...]";
|
|
77
|
+
}
|
|
78
|
+
else {
|
|
79
|
+
if (isOptional) throw new Error(`Optional route parameters are not yet supported ("${urlPaths[0]}").`);
|
|
80
|
+
handleSlug(this.slugName, segmentName);
|
|
81
|
+
this.slugName = segmentName;
|
|
82
|
+
nextSegment = "[]";
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
if (!this.children.has(nextSegment)) this.children.set(nextSegment, new UrlNode());
|
|
86
|
+
this.children.get(nextSegment)._insert(urlPaths.slice(1), slugNames, isCatchAll);
|
|
87
|
+
}
|
|
88
|
+
};
|
|
89
|
+
|
|
90
|
+
//#endregion
|
|
149
91
|
exports.UrlNode = UrlNode;
|
|
150
92
|
//# sourceMappingURL=UrlNode.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"UrlNode.js","
|
|
1
|
+
{"version":3,"file":"UrlNode.js","names":[],"sources":["../../client/UrlNode.ts"],"sourcesContent":["// TODO: fix the no-non-null assertion errors\n/* eslint-disable @typescript-eslint/no-non-null-assertion */\n/**\n * This class provides a logic of sorting dynamic routes in NextJS.\n *\n * It was copied from\n * @see https://github.com/vercel/next.js/blob/canary/packages/next/shared/lib/router/utils/sorted-routes.ts\n */\nexport class UrlNode {\n placeholder = true;\n children: Map<string, UrlNode> = new Map();\n slugName: string | null = null;\n restSlugName: string | null = null;\n optionalRestSlugName: string | null = null;\n\n insert(urlPath: string): void {\n this._insert(urlPath.split('/').filter(Boolean), [], false);\n }\n\n smoosh(): string[] {\n return this._smoosh();\n }\n\n private _smoosh(prefix = '/'): string[] {\n const childrenPaths = [...this.children.keys()].sort();\n if (this.slugName !== null) {\n childrenPaths.splice(childrenPaths.indexOf('[]'), 1);\n }\n if (this.restSlugName !== null) {\n childrenPaths.splice(childrenPaths.indexOf('[...]'), 1);\n }\n if (this.optionalRestSlugName !== null) {\n childrenPaths.splice(childrenPaths.indexOf('[[...]]'), 1);\n }\n\n const routes = childrenPaths\n .map((c) => this.children.get(c)!._smoosh(`${prefix}${c}/`))\n .reduce((prev, curr) => [...prev, ...curr], []);\n\n if (this.slugName !== null) {\n routes.push(\n ...this.children.get('[]')!._smoosh(`${prefix}[${this.slugName}]/`),\n );\n }\n\n if (!this.placeholder) {\n const r = prefix === '/' ? '/' : prefix.slice(0, -1);\n if (this.optionalRestSlugName != null) {\n throw new Error(\n `You cannot define a route with the same specificity as a optional catch-all route (\"${r}\" and \"${r}[[...${this.optionalRestSlugName}]]\").`,\n );\n }\n\n routes.unshift(r);\n }\n\n if (this.restSlugName !== null) {\n routes.push(\n ...this.children\n .get('[...]')!\n ._smoosh(`${prefix}[...${this.restSlugName}]/`),\n );\n }\n\n if (this.optionalRestSlugName !== null) {\n routes.push(\n ...this.children\n .get('[[...]]')!\n ._smoosh(`${prefix}[[...${this.optionalRestSlugName}]]/`),\n );\n }\n\n return routes;\n }\n\n private _insert(\n urlPaths: string[],\n slugNames: string[],\n isCatchAll: boolean,\n ): void {\n if (urlPaths.length === 0) {\n this.placeholder = false;\n return;\n }\n\n if (isCatchAll) {\n throw new Error(`Catch-all must be the last part of the URL.`);\n }\n\n // The next segment in the urlPaths list\n let nextSegment = urlPaths[0];\n\n // Check if the segment matches `[something]`\n if (nextSegment.startsWith('[') && nextSegment.endsWith(']')) {\n // Strip `[` and `]`, leaving only `something`\n let segmentName = nextSegment.slice(1, -1);\n\n let isOptional = false;\n if (segmentName.startsWith('[') && segmentName.endsWith(']')) {\n // Strip optional `[` and `]`, leaving only `something`\n segmentName = segmentName.slice(1, -1);\n isOptional = true;\n }\n\n if (segmentName.startsWith('...')) {\n // Strip `...`, leaving only `something`\n segmentName = segmentName.substring(3);\n isCatchAll = true;\n }\n\n if (segmentName.startsWith('[') || segmentName.endsWith(']')) {\n throw new Error(\n `Segment names may not start or end with extra brackets ('${segmentName}').`,\n );\n }\n\n if (segmentName.startsWith('.')) {\n throw new Error(\n `Segment names may not start with erroneous periods ('${segmentName}').`,\n );\n }\n\n const handleSlug = function handleSlug(\n previousSlug: string | null,\n nextSlug: string,\n ) {\n if (previousSlug !== null && previousSlug !== nextSlug) {\n throw new Error(\n `You cannot use different slug names for the same dynamic path ('${previousSlug}' !== '${nextSlug}').`,\n );\n }\n\n slugNames.forEach((slug) => {\n if (slug === nextSlug) {\n throw new Error(\n `You cannot have the same slug name \"${nextSlug}\" repeat within a single dynamic path`,\n );\n }\n\n if (slug.replace(/\\W/g, '') === nextSegment.replace(/\\W/g, '')) {\n throw new Error(\n `You cannot have the slug names \"${slug}\" and \"${nextSlug}\" differ only by non-word symbols within a single dynamic path`,\n );\n }\n });\n\n slugNames.push(nextSlug);\n };\n\n if (isCatchAll) {\n if (isOptional) {\n if (this.restSlugName != null) {\n throw new Error(\n `You cannot use both an required and optional catch-all route at the same level (\"[...${this.restSlugName}]\" and \"${urlPaths[0]}\" ).`,\n );\n }\n\n handleSlug(this.optionalRestSlugName, segmentName);\n // slugName is kept as it can only be one particular slugName\n this.optionalRestSlugName = segmentName;\n // nextSegment is overwritten to [[...]] so that it can later be sorted specifically\n nextSegment = '[[...]]';\n } else {\n if (this.optionalRestSlugName != null) {\n throw new Error(\n `You cannot use both an optional and required catch-all route at the same level (\"[[...${this.optionalRestSlugName}]]\" and \"${urlPaths[0]}\").`,\n );\n }\n\n handleSlug(this.restSlugName, segmentName);\n // slugName is kept as it can only be one particular slugName\n this.restSlugName = segmentName;\n // nextSegment is overwritten to [...] so that it can later be sorted specifically\n nextSegment = '[...]';\n }\n } else {\n if (isOptional) {\n throw new Error(\n `Optional route parameters are not yet supported (\"${urlPaths[0]}\").`,\n );\n }\n handleSlug(this.slugName, segmentName);\n // slugName is kept as it can only be one particular slugName\n this.slugName = segmentName;\n // nextSegment is overwritten to [] so that it can later be sorted specifically\n nextSegment = '[]';\n }\n }\n\n // If this UrlNode doesn't have the nextSegment yet we create a new child UrlNode\n if (!this.children.has(nextSegment)) {\n this.children.set(nextSegment, new UrlNode());\n }\n\n this.children\n .get(nextSegment)!\n ._insert(urlPaths.slice(1), slugNames, isCatchAll);\n }\n}\n"],"mappings":";;;;;;;;AAQA,IAAa,UAAb,MAAa,QAAQ;;qBACL;kCACmB,IAAI,KAAK;kBAChB;sBACI;8BACQ;;CAEtC,OAAO,SAAuB;AAC5B,OAAK,QAAQ,QAAQ,MAAM,IAAI,CAAC,OAA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,IAAI,MACR,yFAAyF,KAAK,qBAAqB,WAAW,SAAS,GAAG,KAC3I;AAGH,eAAW,KAAK,cAAc,YAAY;AAE1C,SAAK,eAAe;AAEpB,kBAAc;;QAEX;AACL,QAAI,WACF,OAAM,IAAI,MACR,qDAAqD,SAAS,GAAG,KAClE;AAEH,eAAW,KAAK,UAAU,YAAY;AAEtC,SAAK,WAAW;AAEhB,kBAAc;;;AAKlB,MAAI,CAAC,KAAK,SAAS,IAAI,YAAY,CACjC,MAAK,SAAS,IAAI,aAAa,IAAI,SAAS,CAAC;AAG/C,OAAK,SACF,IAAI,YAAY,CAChB,QAAQ,SAAS,MAAM,EAAE,EAAE,WAAW,WAAW"}
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
//#region client/UrlNode.ts
|
|
2
|
+
/**
|
|
3
|
+
* This class provides a logic of sorting dynamic routes in NextJS.
|
|
4
|
+
*
|
|
5
|
+
* It was copied from
|
|
6
|
+
* @see https://github.com/vercel/next.js/blob/canary/packages/next/shared/lib/router/utils/sorted-routes.ts
|
|
7
|
+
*/
|
|
8
|
+
var UrlNode = class UrlNode {
|
|
9
|
+
constructor() {
|
|
10
|
+
this.placeholder = true;
|
|
11
|
+
this.children = /* @__PURE__ */ new Map();
|
|
12
|
+
this.slugName = null;
|
|
13
|
+
this.restSlugName = null;
|
|
14
|
+
this.optionalRestSlugName = null;
|
|
15
|
+
}
|
|
16
|
+
insert(urlPath) {
|
|
17
|
+
this._insert(urlPath.split("/").filter(Boolean), [], false);
|
|
18
|
+
}
|
|
19
|
+
smoosh() {
|
|
20
|
+
return this._smoosh();
|
|
21
|
+
}
|
|
22
|
+
_smoosh(prefix = "/") {
|
|
23
|
+
const childrenPaths = [...this.children.keys()].sort();
|
|
24
|
+
if (this.slugName !== null) childrenPaths.splice(childrenPaths.indexOf("[]"), 1);
|
|
25
|
+
if (this.restSlugName !== null) childrenPaths.splice(childrenPaths.indexOf("[...]"), 1);
|
|
26
|
+
if (this.optionalRestSlugName !== null) childrenPaths.splice(childrenPaths.indexOf("[[...]]"), 1);
|
|
27
|
+
const routes = childrenPaths.map((c) => this.children.get(c)._smoosh(`${prefix}${c}/`)).reduce((prev, curr) => [...prev, ...curr], []);
|
|
28
|
+
if (this.slugName !== null) routes.push(...this.children.get("[]")._smoosh(`${prefix}[${this.slugName}]/`));
|
|
29
|
+
if (!this.placeholder) {
|
|
30
|
+
const r = prefix === "/" ? "/" : prefix.slice(0, -1);
|
|
31
|
+
if (this.optionalRestSlugName != null) throw new Error(`You cannot define a route with the same specificity as a optional catch-all route ("${r}" and "${r}[[...${this.optionalRestSlugName}]]").`);
|
|
32
|
+
routes.unshift(r);
|
|
33
|
+
}
|
|
34
|
+
if (this.restSlugName !== null) routes.push(...this.children.get("[...]")._smoosh(`${prefix}[...${this.restSlugName}]/`));
|
|
35
|
+
if (this.optionalRestSlugName !== null) routes.push(...this.children.get("[[...]]")._smoosh(`${prefix}[[...${this.optionalRestSlugName}]]/`));
|
|
36
|
+
return routes;
|
|
37
|
+
}
|
|
38
|
+
_insert(urlPaths, slugNames, isCatchAll) {
|
|
39
|
+
if (urlPaths.length === 0) {
|
|
40
|
+
this.placeholder = false;
|
|
41
|
+
return;
|
|
42
|
+
}
|
|
43
|
+
if (isCatchAll) throw new Error(`Catch-all must be the last part of the URL.`);
|
|
44
|
+
let nextSegment = urlPaths[0];
|
|
45
|
+
if (nextSegment.startsWith("[") && nextSegment.endsWith("]")) {
|
|
46
|
+
let segmentName = nextSegment.slice(1, -1);
|
|
47
|
+
let isOptional = false;
|
|
48
|
+
if (segmentName.startsWith("[") && segmentName.endsWith("]")) {
|
|
49
|
+
segmentName = segmentName.slice(1, -1);
|
|
50
|
+
isOptional = true;
|
|
51
|
+
}
|
|
52
|
+
if (segmentName.startsWith("...")) {
|
|
53
|
+
segmentName = segmentName.substring(3);
|
|
54
|
+
isCatchAll = true;
|
|
55
|
+
}
|
|
56
|
+
if (segmentName.startsWith("[") || segmentName.endsWith("]")) throw new Error(`Segment names may not start or end with extra brackets ('${segmentName}').`);
|
|
57
|
+
if (segmentName.startsWith(".")) throw new Error(`Segment names may not start with erroneous periods ('${segmentName}').`);
|
|
58
|
+
const handleSlug = function handleSlug(previousSlug, nextSlug) {
|
|
59
|
+
if (previousSlug !== null && previousSlug !== nextSlug) throw new Error(`You cannot use different slug names for the same dynamic path ('${previousSlug}' !== '${nextSlug}').`);
|
|
60
|
+
slugNames.forEach((slug) => {
|
|
61
|
+
if (slug === nextSlug) throw new Error(`You cannot have the same slug name "${nextSlug}" repeat within a single dynamic path`);
|
|
62
|
+
if (slug.replace(/\W/g, "") === nextSegment.replace(/\W/g, "")) throw new Error(`You cannot have the slug names "${slug}" and "${nextSlug}" differ only by non-word symbols within a single dynamic path`);
|
|
63
|
+
});
|
|
64
|
+
slugNames.push(nextSlug);
|
|
65
|
+
};
|
|
66
|
+
if (isCatchAll) if (isOptional) {
|
|
67
|
+
if (this.restSlugName != null) throw new Error(`You cannot use both an required and optional catch-all route at the same level ("[...${this.restSlugName}]" and "${urlPaths[0]}" ).`);
|
|
68
|
+
handleSlug(this.optionalRestSlugName, segmentName);
|
|
69
|
+
this.optionalRestSlugName = segmentName;
|
|
70
|
+
nextSegment = "[[...]]";
|
|
71
|
+
} else {
|
|
72
|
+
if (this.optionalRestSlugName != null) throw new Error(`You cannot use both an optional and required catch-all route at the same level ("[[...${this.optionalRestSlugName}]]" and "${urlPaths[0]}").`);
|
|
73
|
+
handleSlug(this.restSlugName, segmentName);
|
|
74
|
+
this.restSlugName = segmentName;
|
|
75
|
+
nextSegment = "[...]";
|
|
76
|
+
}
|
|
77
|
+
else {
|
|
78
|
+
if (isOptional) throw new Error(`Optional route parameters are not yet supported ("${urlPaths[0]}").`);
|
|
79
|
+
handleSlug(this.slugName, segmentName);
|
|
80
|
+
this.slugName = segmentName;
|
|
81
|
+
nextSegment = "[]";
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
if (!this.children.has(nextSegment)) this.children.set(nextSegment, new UrlNode());
|
|
85
|
+
this.children.get(nextSegment)._insert(urlPaths.slice(1), slugNames, isCatchAll);
|
|
86
|
+
}
|
|
87
|
+
};
|
|
88
|
+
|
|
89
|
+
//#endregion
|
|
90
|
+
export { UrlNode };
|
|
91
|
+
//# sourceMappingURL=UrlNode.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"UrlNode.mjs","names":[],"sources":["../../client/UrlNode.ts"],"sourcesContent":["// TODO: fix the no-non-null assertion errors\n/* eslint-disable @typescript-eslint/no-non-null-assertion */\n/**\n * This class provides a logic of sorting dynamic routes in NextJS.\n *\n * It was copied from\n * @see https://github.com/vercel/next.js/blob/canary/packages/next/shared/lib/router/utils/sorted-routes.ts\n */\nexport class UrlNode {\n placeholder = true;\n children: Map<string, UrlNode> = new Map();\n slugName: string | null = null;\n restSlugName: string | null = null;\n optionalRestSlugName: string | null = null;\n\n insert(urlPath: string): void {\n this._insert(urlPath.split('/').filter(Boolean), [], false);\n }\n\n smoosh(): string[] {\n return this._smoosh();\n }\n\n private _smoosh(prefix = '/'): string[] {\n const childrenPaths = [...this.children.keys()].sort();\n if (this.slugName !== null) {\n childrenPaths.splice(childrenPaths.indexOf('[]'), 1);\n }\n if (this.restSlugName !== null) {\n childrenPaths.splice(childrenPaths.indexOf('[...]'), 1);\n }\n if (this.optionalRestSlugName !== null) {\n childrenPaths.splice(childrenPaths.indexOf('[[...]]'), 1);\n }\n\n const routes = childrenPaths\n .map((c) => this.children.get(c)!._smoosh(`${prefix}${c}/`))\n .reduce((prev, curr) => [...prev, ...curr], []);\n\n if (this.slugName !== null) {\n routes.push(\n ...this.children.get('[]')!._smoosh(`${prefix}[${this.slugName}]/`),\n );\n }\n\n if (!this.placeholder) {\n const r = prefix === '/' ? '/' : prefix.slice(0, -1);\n if (this.optionalRestSlugName != null) {\n throw new Error(\n `You cannot define a route with the same specificity as a optional catch-all route (\"${r}\" and \"${r}[[...${this.optionalRestSlugName}]]\").`,\n );\n }\n\n routes.unshift(r);\n }\n\n if (this.restSlugName !== null) {\n routes.push(\n ...this.children\n .get('[...]')!\n ._smoosh(`${prefix}[...${this.restSlugName}]/`),\n );\n }\n\n if (this.optionalRestSlugName !== null) {\n routes.push(\n ...this.children\n .get('[[...]]')!\n ._smoosh(`${prefix}[[...${this.optionalRestSlugName}]]/`),\n );\n }\n\n return routes;\n }\n\n private _insert(\n urlPaths: string[],\n slugNames: string[],\n isCatchAll: boolean,\n ): void {\n if (urlPaths.length === 0) {\n this.placeholder = false;\n return;\n }\n\n if (isCatchAll) {\n throw new Error(`Catch-all must be the last part of the URL.`);\n }\n\n // The next segment in the urlPaths list\n let nextSegment = urlPaths[0];\n\n // Check if the segment matches `[something]`\n if (nextSegment.startsWith('[') && nextSegment.endsWith(']')) {\n // Strip `[` and `]`, leaving only `something`\n let segmentName = nextSegment.slice(1, -1);\n\n let isOptional = false;\n if (segmentName.startsWith('[') && segmentName.endsWith(']')) {\n // Strip optional `[` and `]`, leaving only `something`\n segmentName = segmentName.slice(1, -1);\n isOptional = true;\n }\n\n if (segmentName.startsWith('...')) {\n // Strip `...`, leaving only `something`\n segmentName = segmentName.substring(3);\n isCatchAll = true;\n }\n\n if (segmentName.startsWith('[') || segmentName.endsWith(']')) {\n throw new Error(\n `Segment names may not start or end with extra brackets ('${segmentName}').`,\n );\n }\n\n if (segmentName.startsWith('.')) {\n throw new Error(\n `Segment names may not start with erroneous periods ('${segmentName}').`,\n );\n }\n\n const handleSlug = function handleSlug(\n previousSlug: string | null,\n nextSlug: string,\n ) {\n if (previousSlug !== null && previousSlug !== nextSlug) {\n throw new Error(\n `You cannot use different slug names for the same dynamic path ('${previousSlug}' !== '${nextSlug}').`,\n );\n }\n\n slugNames.forEach((slug) => {\n if (slug === nextSlug) {\n throw new Error(\n `You cannot have the same slug name \"${nextSlug}\" repeat within a single dynamic path`,\n );\n }\n\n if (slug.replace(/\\W/g, '') === nextSegment.replace(/\\W/g, '')) {\n throw new Error(\n `You cannot have the slug names \"${slug}\" and \"${nextSlug}\" differ only by non-word symbols within a single dynamic path`,\n );\n }\n });\n\n slugNames.push(nextSlug);\n };\n\n if (isCatchAll) {\n if (isOptional) {\n if (this.restSlugName != null) {\n throw new Error(\n `You cannot use both an required and optional catch-all route at the same level (\"[...${this.restSlugName}]\" and \"${urlPaths[0]}\" ).`,\n );\n }\n\n handleSlug(this.optionalRestSlugName, segmentName);\n // slugName is kept as it can only be one particular slugName\n this.optionalRestSlugName = segmentName;\n // nextSegment is overwritten to [[...]] so that it can later be sorted specifically\n nextSegment = '[[...]]';\n } else {\n if (this.optionalRestSlugName != null) {\n throw new Error(\n `You cannot use both an optional and required catch-all route at the same level (\"[[...${this.optionalRestSlugName}]]\" and \"${urlPaths[0]}\").`,\n );\n }\n\n handleSlug(this.restSlugName, segmentName);\n // slugName is kept as it can only be one particular slugName\n this.restSlugName = segmentName;\n // nextSegment is overwritten to [...] so that it can later be sorted specifically\n nextSegment = '[...]';\n }\n } else {\n if (isOptional) {\n throw new Error(\n `Optional route parameters are not yet supported (\"${urlPaths[0]}\").`,\n );\n }\n handleSlug(this.slugName, segmentName);\n // slugName is kept as it can only be one particular slugName\n this.slugName = segmentName;\n // nextSegment is overwritten to [] so that it can later be sorted specifically\n nextSegment = '[]';\n }\n }\n\n // If this UrlNode doesn't have the nextSegment yet we create a new child UrlNode\n if (!this.children.has(nextSegment)) {\n this.children.set(nextSegment, new UrlNode());\n }\n\n this.children\n .get(nextSegment)!\n ._insert(urlPaths.slice(1), slugNames, isCatchAll);\n }\n}\n"],"mappings":";;;;;;;AAQA,IAAa,UAAb,MAAa,QAAQ;;qBACL;kCACmB,IAAI,KAAK;kBAChB;sBACI;8BACQ;;CAEtC,OAAO,SAAuB;AAC5B,OAAK,QAAQ,QAAQ,MAAM,IAAI,CAAC,OAAO,QAAQ,EAAE,EAAE,EAAE,MAAM;;CAG7D,SAAmB;AACjB,SAAO,KAAK,SAAS;;CAGvB,AAAQ,QAAQ,SAAS,KAAe;EACt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EpB,kBAAc;;QAEX;AACL,QAAI,WACF,OAAM,IAAI,MACR,qDAAqD,SAAS,GAAG,KAClE;AAEH,eAAW,KAAK,UAAU,YAAY;AAEtC,SAAK,WAAW;AAEhB,kBAAc;;;AAKlB,MAAI,CAAC,KAAK,SAAS,IAAI,YAAY,CACjC,MAAK,SAAS,IAAI,aAAa,IAAI,SAAS,CAAC;AAG/C,OAAK,SACF,IAAI,YAAY,CAChB,QAAQ,SAAS,MAAM,EAAE,EAAE,WAAW,WAAW"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { };
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
|
|
2
|
+
//#region src/federation-noop.ts
|
|
3
|
+
require("next/head");
|
|
4
|
+
require("next/router");
|
|
5
|
+
require("next/link");
|
|
6
|
+
require("next/script");
|
|
7
|
+
require("next/image");
|
|
8
|
+
require("next/dynamic");
|
|
9
|
+
require("next/error");
|
|
10
|
+
require("next/amp");
|
|
11
|
+
require("styled-jsx");
|
|
12
|
+
require("styled-jsx/style");
|
|
13
|
+
require("next/image");
|
|
14
|
+
require("react/jsx-runtime");
|
|
15
|
+
|
|
16
|
+
//#endregion
|
|
17
|
+
//# sourceMappingURL=federation-noop.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"federation-noop.js","
|
|
1
|
+
{"version":3,"file":"federation-noop.js","names":[],"sources":["../../src/federation-noop.ts"],"sourcesContent":["require('next/head');\nrequire('next/router');\nrequire('next/link');\nrequire('next/script');\nrequire('next/image');\nrequire('next/dynamic');\nrequire('next/error');\nrequire('next/amp');\nrequire('styled-jsx');\nrequire('styled-jsx/style');\nrequire('next/image');\n// require('react/jsx-dev-runtime');\nrequire('react/jsx-runtime');\n"],"mappings":";;AAAA,QAAQ,YAAY;AACpB,QAAQ,cAAc;AACtB,QAAQ,YAAY;AACpB,QAAQ,cAAc;AACtB,QAAQ,aAAa;AACrB,QAAQ,eAAe;AACvB,QAAQ,aAAa;AACrB,QAAQ,WAAW;AACnB,QAAQ,aAAa;AACrB,QAAQ,mBAAmB;AAC3B,QAAQ,aAAa;AAErB,QAAQ,oBAAoB"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { __commonJSMin, __require } from "../_virtual/_rolldown/runtime.mjs";
|
|
2
|
+
|
|
3
|
+
//#region src/federation-noop.ts
|
|
4
|
+
var require_federation_noop = /* @__PURE__ */ __commonJSMin((() => {
|
|
5
|
+
__require("next/head");
|
|
6
|
+
__require("next/router");
|
|
7
|
+
__require("next/link");
|
|
8
|
+
__require("next/script");
|
|
9
|
+
__require("next/image");
|
|
10
|
+
__require("next/dynamic");
|
|
11
|
+
__require("next/error");
|
|
12
|
+
__require("next/amp");
|
|
13
|
+
__require("styled-jsx");
|
|
14
|
+
__require("styled-jsx/style");
|
|
15
|
+
__require("next/image");
|
|
16
|
+
__require("react/jsx-runtime");
|
|
17
|
+
}));
|
|
18
|
+
|
|
19
|
+
//#endregion
|
|
20
|
+
export default require_federation_noop();
|
|
21
|
+
|
|
22
|
+
export { };
|
|
23
|
+
//# sourceMappingURL=federation-noop.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"federation-noop.mjs","names":[],"sources":["../../src/federation-noop.ts"],"sourcesContent":["require('next/head');\nrequire('next/router');\nrequire('next/link');\nrequire('next/script');\nrequire('next/image');\nrequire('next/dynamic');\nrequire('next/error');\nrequire('next/amp');\nrequire('styled-jsx');\nrequire('styled-jsx/style');\nrequire('next/image');\n// require('react/jsx-dev-runtime');\nrequire('react/jsx-runtime');\n"],"mappings":";;;;AAAA,WAAQ,YAAY;AACpB,WAAQ,cAAc;AACtB,WAAQ,YAAY;AACpB,WAAQ,cAAc;AACtB,WAAQ,aAAa;AACrB,WAAQ,eAAe;AACvB,WAAQ,aAAa;AACrB,WAAQ,WAAW;AACnB,WAAQ,aAAa;AACrB,WAAQ,mBAAmB;AAC3B,WAAQ,aAAa;AAErB,WAAQ,oBAAoB"}
|
package/dist/src/index.d.ts
CHANGED
|
@@ -1,3 +1,2 @@
|
|
|
1
|
-
import NextFederationPlugin from
|
|
2
|
-
export { NextFederationPlugin };
|
|
3
|
-
export default NextFederationPlugin;
|
|
1
|
+
import { NextFederationPlugin } from "./plugins/NextFederationPlugin/index.js";
|
|
2
|
+
export { NextFederationPlugin, NextFederationPlugin as default };
|
package/dist/src/index.js
CHANGED
|
@@ -1,12 +1,14 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
exports
|
|
7
|
-
|
|
8
|
-
exports.NextFederationPlugin =
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
1
|
+
Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: 'Module' } });
|
|
2
|
+
const require_index = require('./plugins/NextFederationPlugin/index.js');
|
|
3
|
+
|
|
4
|
+
//#region src/index.ts
|
|
5
|
+
var src_default = require_index.default;
|
|
6
|
+
if (typeof module !== "undefined" && typeof module.exports !== "undefined") {
|
|
7
|
+
module.exports = require_index.default;
|
|
8
|
+
module.exports.NextFederationPlugin = require_index.default;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
//#endregion
|
|
12
|
+
exports.NextFederationPlugin = require_index;
|
|
13
|
+
exports.default = src_default;
|
|
12
14
|
//# sourceMappingURL=index.js.map
|
package/dist/src/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","
|
|
1
|
+
{"version":3,"file":"index.js","names":["NextFederationPlugin"],"sources":["../../src/index.ts"],"sourcesContent":["import NextFederationPlugin from './plugins/NextFederationPlugin';\n\nexport { NextFederationPlugin };\nexport default NextFederationPlugin;\n\nif (\n process.env.IS_ESM_BUILD !== 'true' &&\n typeof module !== 'undefined' &&\n typeof module.exports !== 'undefined'\n) {\n module.exports = NextFederationPlugin;\n module.exports.NextFederationPlugin = NextFederationPlugin;\n}\n"],"mappings":";;;;AAGA,kBAAeA;AAEf,IAEE,OAAO,WAAW,eAClB,OAAO,OAAO,YAAY,aAC1B;AACA,QAAO,UAAUA;AACjB,QAAO,QAAQ,uBAAuBA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.mjs","names":[],"sources":["../../src/index.ts"],"sourcesContent":["import NextFederationPlugin from './plugins/NextFederationPlugin';\n\nexport { NextFederationPlugin };\nexport default NextFederationPlugin;\n\nif (\n process.env.IS_ESM_BUILD !== 'true' &&\n typeof module !== 'undefined' &&\n typeof module.exports !== 'undefined'\n) {\n module.exports = NextFederationPlugin;\n module.exports.NextFederationPlugin = NextFederationPlugin;\n}\n"],"mappings":";;;AAGA,kBAAe"}
|