@modern-js/plugin-router-v7 0.0.0-next-20250507161323
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/LICENSE +21 -0
- package/README.md +26 -0
- package/dist/cjs/cli/index.js +72 -0
- package/dist/cjs/runtime/index.js +53 -0
- package/dist/esm/cli/index.js +40 -0
- package/dist/esm/runtime/index.js +25 -0
- package/dist/esm-node/cli/index.js +38 -0
- package/dist/esm-node/runtime/index.js +25 -0
- package/dist/types/cli/index.d.ts +3 -0
- package/dist/types/runtime/index.d.ts +4 -0
- package/package.json +90 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2021-present Modern.js
|
|
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.
|
package/README.md
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
<p align="center">
|
|
2
|
+
<a href="https://modernjs.dev" target="blank"><img src="https://lf3-static.bytednsdoc.com/obj/eden-cn/ylaelkeh7nuhfnuhf/modernjs-cover.png" width="300" alt="Modern.js Logo" /></a>
|
|
3
|
+
</p>
|
|
4
|
+
|
|
5
|
+
<h1 align="center">Modern.js</h1>
|
|
6
|
+
|
|
7
|
+
<p align="center">
|
|
8
|
+
A Progressive React Framework for modern web development.
|
|
9
|
+
</p>
|
|
10
|
+
|
|
11
|
+
## Getting Started
|
|
12
|
+
|
|
13
|
+
Please follow [Quick Start](https://modernjs.dev/en/guides/get-started/quick-start) to get started with Modern.js.
|
|
14
|
+
|
|
15
|
+
## Documentation
|
|
16
|
+
|
|
17
|
+
- [English Documentation](https://modernjs.dev/en/)
|
|
18
|
+
- [中文文档](https://modernjs.dev)
|
|
19
|
+
|
|
20
|
+
## Contributing
|
|
21
|
+
|
|
22
|
+
Please read the [Contributing Guide](https://github.com/web-infra-dev/modern.js/blob/main/CONTRIBUTING.md).
|
|
23
|
+
|
|
24
|
+
## License
|
|
25
|
+
|
|
26
|
+
Modern.js is [MIT licensed](https://github.com/web-infra-dev/modern.js/blob/main/LICENSE).
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
"use strict";
|
|
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 __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
+
var cli_exports = {};
|
|
30
|
+
__export(cli_exports, {
|
|
31
|
+
default: () => cli_default,
|
|
32
|
+
routerPlugin: () => routerPlugin
|
|
33
|
+
});
|
|
34
|
+
module.exports = __toCommonJS(cli_exports);
|
|
35
|
+
var import_utils = require("@modern-js/utils");
|
|
36
|
+
const routerPlugin = () => ({
|
|
37
|
+
name: "@modern-js/plugin-router-v7",
|
|
38
|
+
required: [
|
|
39
|
+
"@modern-js/runtime"
|
|
40
|
+
],
|
|
41
|
+
setup: (api) => {
|
|
42
|
+
api.config(() => {
|
|
43
|
+
var _config_source;
|
|
44
|
+
const config = api.getNormalizedConfig();
|
|
45
|
+
const alias = config === null || config === void 0 ? void 0 : (_config_source = config.source) === null || _config_source === void 0 ? void 0 : _config_source.alias;
|
|
46
|
+
if (typeof alias !== "undefined") {
|
|
47
|
+
Object.keys(alias).forEach((key) => {
|
|
48
|
+
if (key.includes("react-router")) {
|
|
49
|
+
return import_utils.logger.error(`Checked for possible configuration of react-router alias, using react-router-v7 may fail, please remove the alias first`);
|
|
50
|
+
}
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
return {
|
|
54
|
+
source: {
|
|
55
|
+
alias: {
|
|
56
|
+
"react-router-dom$": require.resolve("../runtime").replace(/\/cjs\//, "/esm/"),
|
|
57
|
+
"@remix-run/router": require.resolve("../runtime").replace(/\/cjs\//, "/esm/"),
|
|
58
|
+
"react-router-dom/server": require.resolve("../runtime").replace(/\/cjs\//, "/esm/")
|
|
59
|
+
},
|
|
60
|
+
globalVars: {
|
|
61
|
+
"process.env._MODERN_ROUTER_VERSION": "v7"
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
};
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
});
|
|
68
|
+
var cli_default = routerPlugin;
|
|
69
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
70
|
+
0 && (module.exports = {
|
|
71
|
+
routerPlugin
|
|
72
|
+
});
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
"use strict";
|
|
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 __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
|
19
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
20
|
+
var runtime_exports = {};
|
|
21
|
+
__export(runtime_exports, {
|
|
22
|
+
AbortedDeferredError: () => import_browser.AbortedDeferredError,
|
|
23
|
+
defer: () => defer,
|
|
24
|
+
json: () => json
|
|
25
|
+
});
|
|
26
|
+
module.exports = __toCommonJS(runtime_exports);
|
|
27
|
+
__reExport(runtime_exports, require("react-router"), module.exports);
|
|
28
|
+
var import_browser = require("@modern-js/runtime-utils/browser");
|
|
29
|
+
const json = (data, init) => {
|
|
30
|
+
console.warn("json is deprecated, Please use Response.json instead.");
|
|
31
|
+
const responseInit = init ? typeof init === "number" ? {
|
|
32
|
+
status: init
|
|
33
|
+
} : init : void 0;
|
|
34
|
+
return new Response(JSON.stringify(data), responseInit);
|
|
35
|
+
};
|
|
36
|
+
const defer = (data, init) => {
|
|
37
|
+
console.warn("defer is deprecated, you don't need to use it anymore.");
|
|
38
|
+
if (typeof init === "undefined") {
|
|
39
|
+
return data;
|
|
40
|
+
} else {
|
|
41
|
+
const responseInit = init ? typeof init === "number" ? {
|
|
42
|
+
status: init
|
|
43
|
+
} : init : void 0;
|
|
44
|
+
return new Response(JSON.stringify(data), responseInit);
|
|
45
|
+
}
|
|
46
|
+
};
|
|
47
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
48
|
+
0 && (module.exports = {
|
|
49
|
+
AbortedDeferredError,
|
|
50
|
+
defer,
|
|
51
|
+
json,
|
|
52
|
+
...require("react-router")
|
|
53
|
+
});
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { logger } from "@modern-js/utils";
|
|
2
|
+
var routerPlugin = function() {
|
|
3
|
+
return {
|
|
4
|
+
name: "@modern-js/plugin-router-v7",
|
|
5
|
+
required: [
|
|
6
|
+
"@modern-js/runtime"
|
|
7
|
+
],
|
|
8
|
+
setup: function(api) {
|
|
9
|
+
api.config(function() {
|
|
10
|
+
var _config_source;
|
|
11
|
+
var config = api.getNormalizedConfig();
|
|
12
|
+
var alias = config === null || config === void 0 ? void 0 : (_config_source = config.source) === null || _config_source === void 0 ? void 0 : _config_source.alias;
|
|
13
|
+
if (typeof alias !== "undefined") {
|
|
14
|
+
Object.keys(alias).forEach(function(key) {
|
|
15
|
+
if (key.includes("react-router")) {
|
|
16
|
+
return logger.error("Checked for possible configuration of react-router alias, using react-router-v7 may fail, please remove the alias first");
|
|
17
|
+
}
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
return {
|
|
21
|
+
source: {
|
|
22
|
+
alias: {
|
|
23
|
+
"react-router-dom$": require.resolve("../runtime").replace(/\/cjs\//, "/esm/"),
|
|
24
|
+
"@remix-run/router": require.resolve("../runtime").replace(/\/cjs\//, "/esm/"),
|
|
25
|
+
"react-router-dom/server": require.resolve("../runtime").replace(/\/cjs\//, "/esm/")
|
|
26
|
+
},
|
|
27
|
+
globalVars: {
|
|
28
|
+
"process.env._MODERN_ROUTER_VERSION": "v7"
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
};
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
};
|
|
35
|
+
};
|
|
36
|
+
var cli_default = routerPlugin;
|
|
37
|
+
export {
|
|
38
|
+
cli_default as default,
|
|
39
|
+
routerPlugin
|
|
40
|
+
};
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
export * from "react-router";
|
|
2
|
+
import { AbortedDeferredError } from "@modern-js/runtime-utils/browser";
|
|
3
|
+
var json = function(data, init) {
|
|
4
|
+
console.warn("json is deprecated, Please use Response.json instead.");
|
|
5
|
+
var responseInit = init ? typeof init === "number" ? {
|
|
6
|
+
status: init
|
|
7
|
+
} : init : void 0;
|
|
8
|
+
return new Response(JSON.stringify(data), responseInit);
|
|
9
|
+
};
|
|
10
|
+
var defer = function(data, init) {
|
|
11
|
+
console.warn("defer is deprecated, you don't need to use it anymore.");
|
|
12
|
+
if (typeof init === "undefined") {
|
|
13
|
+
return data;
|
|
14
|
+
} else {
|
|
15
|
+
var responseInit = init ? typeof init === "number" ? {
|
|
16
|
+
status: init
|
|
17
|
+
} : init : void 0;
|
|
18
|
+
return new Response(JSON.stringify(data), responseInit);
|
|
19
|
+
}
|
|
20
|
+
};
|
|
21
|
+
export {
|
|
22
|
+
AbortedDeferredError,
|
|
23
|
+
defer,
|
|
24
|
+
json
|
|
25
|
+
};
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { logger } from "@modern-js/utils";
|
|
2
|
+
const routerPlugin = () => ({
|
|
3
|
+
name: "@modern-js/plugin-router-v7",
|
|
4
|
+
required: [
|
|
5
|
+
"@modern-js/runtime"
|
|
6
|
+
],
|
|
7
|
+
setup: (api) => {
|
|
8
|
+
api.config(() => {
|
|
9
|
+
var _config_source;
|
|
10
|
+
const config = api.getNormalizedConfig();
|
|
11
|
+
const alias = config === null || config === void 0 ? void 0 : (_config_source = config.source) === null || _config_source === void 0 ? void 0 : _config_source.alias;
|
|
12
|
+
if (typeof alias !== "undefined") {
|
|
13
|
+
Object.keys(alias).forEach((key) => {
|
|
14
|
+
if (key.includes("react-router")) {
|
|
15
|
+
return logger.error(`Checked for possible configuration of react-router alias, using react-router-v7 may fail, please remove the alias first`);
|
|
16
|
+
}
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
return {
|
|
20
|
+
source: {
|
|
21
|
+
alias: {
|
|
22
|
+
"react-router-dom$": require.resolve("../runtime").replace(/\/cjs\//, "/esm/"),
|
|
23
|
+
"@remix-run/router": require.resolve("../runtime").replace(/\/cjs\//, "/esm/"),
|
|
24
|
+
"react-router-dom/server": require.resolve("../runtime").replace(/\/cjs\//, "/esm/")
|
|
25
|
+
},
|
|
26
|
+
globalVars: {
|
|
27
|
+
"process.env._MODERN_ROUTER_VERSION": "v7"
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
};
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
});
|
|
34
|
+
var cli_default = routerPlugin;
|
|
35
|
+
export {
|
|
36
|
+
cli_default as default,
|
|
37
|
+
routerPlugin
|
|
38
|
+
};
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
export * from "react-router";
|
|
2
|
+
import { AbortedDeferredError } from "@modern-js/runtime-utils/browser";
|
|
3
|
+
const json = (data, init) => {
|
|
4
|
+
console.warn("json is deprecated, Please use Response.json instead.");
|
|
5
|
+
const responseInit = init ? typeof init === "number" ? {
|
|
6
|
+
status: init
|
|
7
|
+
} : init : void 0;
|
|
8
|
+
return new Response(JSON.stringify(data), responseInit);
|
|
9
|
+
};
|
|
10
|
+
const defer = (data, init) => {
|
|
11
|
+
console.warn("defer is deprecated, you don't need to use it anymore.");
|
|
12
|
+
if (typeof init === "undefined") {
|
|
13
|
+
return data;
|
|
14
|
+
} else {
|
|
15
|
+
const responseInit = init ? typeof init === "number" ? {
|
|
16
|
+
status: init
|
|
17
|
+
} : init : void 0;
|
|
18
|
+
return new Response(JSON.stringify(data), responseInit);
|
|
19
|
+
}
|
|
20
|
+
};
|
|
21
|
+
export {
|
|
22
|
+
AbortedDeferredError,
|
|
23
|
+
defer,
|
|
24
|
+
json
|
|
25
|
+
};
|
package/package.json
ADDED
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@modern-js/plugin-router-v7",
|
|
3
|
+
"description": "A Progressive React Framework for modern web development.",
|
|
4
|
+
"homepage": "https://modernjs.dev",
|
|
5
|
+
"bugs": "https://github.com/web-infra-dev/modern.js/issues",
|
|
6
|
+
"repository": {
|
|
7
|
+
"type": "git",
|
|
8
|
+
"url": "https://github.com/web-infra-dev/modern.js",
|
|
9
|
+
"directory": "packages/runtime/plugin-router-v5"
|
|
10
|
+
},
|
|
11
|
+
"license": "MIT",
|
|
12
|
+
"keywords": [
|
|
13
|
+
"react",
|
|
14
|
+
"framework",
|
|
15
|
+
"modern",
|
|
16
|
+
"modern.js"
|
|
17
|
+
],
|
|
18
|
+
"version": "0.0.0-next-20250507161323",
|
|
19
|
+
"jsnext:source": "./src/index.ts",
|
|
20
|
+
"types": "./dist/types/cli/index.d.ts",
|
|
21
|
+
"main": "./dist/cjs/cli/index.js",
|
|
22
|
+
"module": "./dist/esm/index.js",
|
|
23
|
+
"exports": {
|
|
24
|
+
".": {
|
|
25
|
+
"types": "./dist/types/cli/index.d.ts",
|
|
26
|
+
"jsnext:source": "./src/cli/index.ts",
|
|
27
|
+
"default": "./dist/cjs/cli/index.js"
|
|
28
|
+
},
|
|
29
|
+
"./runtime": {
|
|
30
|
+
"types": "./dist/types/runtime/index.d.ts",
|
|
31
|
+
"jsnext:source": "./src/runtime/index.ts",
|
|
32
|
+
"default": "./dist/esm/runtime/index.js"
|
|
33
|
+
},
|
|
34
|
+
"./cli": {
|
|
35
|
+
"types": "./dist/types/cli/index.d.ts",
|
|
36
|
+
"jsnext:source": "./src/cli/index.ts",
|
|
37
|
+
"default": "./dist/cjs/cli/index.js"
|
|
38
|
+
}
|
|
39
|
+
},
|
|
40
|
+
"typesVersions": {
|
|
41
|
+
"*": {
|
|
42
|
+
".": [
|
|
43
|
+
"./dist/types/cli/index.d.ts"
|
|
44
|
+
],
|
|
45
|
+
"cli": [
|
|
46
|
+
"./dist/types/cli/index.d.ts"
|
|
47
|
+
],
|
|
48
|
+
"runtime": [
|
|
49
|
+
"./dist/types/runtime/index.d.ts"
|
|
50
|
+
]
|
|
51
|
+
}
|
|
52
|
+
},
|
|
53
|
+
"dependencies": {
|
|
54
|
+
"@swc/helpers": "0.5.13",
|
|
55
|
+
"react-router": "^7.5.0",
|
|
56
|
+
"@modern-js/runtime-utils": "0.0.0-next-20250507161323",
|
|
57
|
+
"@modern-js/utils": "0.0.0-next-20250507161323"
|
|
58
|
+
},
|
|
59
|
+
"peerDependencies": {
|
|
60
|
+
"react": ">=17",
|
|
61
|
+
"react-dom": ">=17",
|
|
62
|
+
"@modern-js/runtime": "0.0.0-next-20250507161323"
|
|
63
|
+
},
|
|
64
|
+
"devDependencies": {
|
|
65
|
+
"@testing-library/react": "^13.4.0",
|
|
66
|
+
"@types/jest": "^29",
|
|
67
|
+
"@types/node": "^14",
|
|
68
|
+
"jest": "^29",
|
|
69
|
+
"react": "^18.3.1",
|
|
70
|
+
"react-dom": "^18.3.1",
|
|
71
|
+
"ts-jest": "^29.1.0",
|
|
72
|
+
"typescript": "^5",
|
|
73
|
+
"@modern-js/app-tools": "0.0.0-next-20250507161323",
|
|
74
|
+
"@modern-js/core": "0.0.0-next-20250507161323",
|
|
75
|
+
"@modern-js/runtime": "0.0.0-next-20250507161323",
|
|
76
|
+
"@scripts/build": "0.0.0-next-20250507161323",
|
|
77
|
+
"@scripts/jest-config": "0.0.0-next-20250507161323"
|
|
78
|
+
},
|
|
79
|
+
"sideEffects": false,
|
|
80
|
+
"publishConfig": {
|
|
81
|
+
"registry": "https://registry.npmjs.org/",
|
|
82
|
+
"access": "public"
|
|
83
|
+
},
|
|
84
|
+
"scripts": {
|
|
85
|
+
"dev": "modern-lib build --watch",
|
|
86
|
+
"new": "modern-lib new",
|
|
87
|
+
"build": "modern-lib build",
|
|
88
|
+
"test": "jest --passWithNoTests"
|
|
89
|
+
}
|
|
90
|
+
}
|