@bleedingdev/modern-js-sandpack-react 3.2.0-ultramodern.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/CHANGELOG.md +89 -0
- package/LICENSE +21 -0
- package/README.md +26 -0
- package/dist/cjs/index.js +94 -0
- package/dist/cjs/templates/common.js +39 -0
- package/dist/cjs/templates/index.js +55 -0
- package/dist/cjs/templates/mwa.js +58 -0
- package/dist/esm/index.mjs +60 -0
- package/dist/esm/rslib-runtime.mjs +18 -0
- package/dist/esm/templates/common.mjs +5 -0
- package/dist/esm/templates/index.mjs +12 -0
- package/dist/esm/templates/mwa.mjs +24 -0
- package/dist/esm-node/index.mjs +61 -0
- package/dist/esm-node/rslib-runtime.mjs +19 -0
- package/dist/esm-node/templates/common.mjs +6 -0
- package/dist/esm-node/templates/index.mjs +13 -0
- package/dist/esm-node/templates/mwa.mjs +25 -0
- package/dist/types/index.d.ts +12 -0
- package/dist/types/templates/common.d.ts +4 -0
- package/dist/types/templates/index.d.ts +3 -0
- package/dist/types/templates/mwa.d.ts +23 -0
- package/package.json +63 -0
- package/rslib.config.mts +4 -0
- package/rstest.config.mts +5 -0
- package/scripts/codesandbox/.codesandbox/environment.json +3 -0
- package/scripts/codesandbox/.codesandbox/tasks.json +19 -0
- package/scripts/template.mts +105 -0
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
# @modern-js/sandpack-react
|
|
2
|
+
|
|
3
|
+
## 3.2.0
|
|
4
|
+
|
|
5
|
+
## 3.1.5
|
|
6
|
+
|
|
7
|
+
## 3.1.4
|
|
8
|
+
|
|
9
|
+
## 3.1.3
|
|
10
|
+
|
|
11
|
+
## 3.1.2
|
|
12
|
+
|
|
13
|
+
## 3.1.1
|
|
14
|
+
|
|
15
|
+
## 3.1.0
|
|
16
|
+
|
|
17
|
+
## 3.0.5
|
|
18
|
+
|
|
19
|
+
## 3.0.4
|
|
20
|
+
|
|
21
|
+
## 3.0.3
|
|
22
|
+
|
|
23
|
+
## 3.0.2
|
|
24
|
+
|
|
25
|
+
## 3.0.1
|
|
26
|
+
|
|
27
|
+
## 3.0.0
|
|
28
|
+
|
|
29
|
+
## 3.0.0-alpha.2
|
|
30
|
+
|
|
31
|
+
## 3.0.0-alpha.1
|
|
32
|
+
|
|
33
|
+
## 3.0.0-alpha.0
|
|
34
|
+
|
|
35
|
+
## 2.68.1
|
|
36
|
+
|
|
37
|
+
## 2.68.0
|
|
38
|
+
|
|
39
|
+
## 2.67.11
|
|
40
|
+
|
|
41
|
+
## 2.67.10
|
|
42
|
+
|
|
43
|
+
## 2.67.9
|
|
44
|
+
|
|
45
|
+
## 2.67.8
|
|
46
|
+
|
|
47
|
+
## 2.67.7
|
|
48
|
+
|
|
49
|
+
## 2.67.6
|
|
50
|
+
|
|
51
|
+
## 2.67.5
|
|
52
|
+
|
|
53
|
+
## 2.67.4
|
|
54
|
+
|
|
55
|
+
## 2.67.3
|
|
56
|
+
|
|
57
|
+
## 2.67.2
|
|
58
|
+
|
|
59
|
+
## 2.67.1
|
|
60
|
+
|
|
61
|
+
## 2.67.0
|
|
62
|
+
|
|
63
|
+
## 2.66.0
|
|
64
|
+
|
|
65
|
+
## 2.65.5
|
|
66
|
+
|
|
67
|
+
## 2.65.4
|
|
68
|
+
|
|
69
|
+
## 2.65.3
|
|
70
|
+
|
|
71
|
+
## 2.65.2
|
|
72
|
+
|
|
73
|
+
## 2.65.1
|
|
74
|
+
|
|
75
|
+
## 2.65.0
|
|
76
|
+
|
|
77
|
+
## 2.64.3
|
|
78
|
+
|
|
79
|
+
## 2.64.2
|
|
80
|
+
|
|
81
|
+
## 2.64.1
|
|
82
|
+
|
|
83
|
+
## 2.64.0
|
|
84
|
+
|
|
85
|
+
## 2.63.7
|
|
86
|
+
|
|
87
|
+
## 2.63.6
|
|
88
|
+
|
|
89
|
+
## 2.63.5
|
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,94 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __webpack_require__ = {};
|
|
3
|
+
(()=>{
|
|
4
|
+
__webpack_require__.d = (exports1, definition)=>{
|
|
5
|
+
for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: definition[key]
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
})();
|
|
11
|
+
(()=>{
|
|
12
|
+
__webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
|
|
13
|
+
})();
|
|
14
|
+
(()=>{
|
|
15
|
+
__webpack_require__.r = (exports1)=>{
|
|
16
|
+
if ("u" > typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
|
|
17
|
+
value: 'Module'
|
|
18
|
+
});
|
|
19
|
+
Object.defineProperty(exports1, '__esModule', {
|
|
20
|
+
value: true
|
|
21
|
+
});
|
|
22
|
+
};
|
|
23
|
+
})();
|
|
24
|
+
var __webpack_exports__ = {};
|
|
25
|
+
__webpack_require__.r(__webpack_exports__);
|
|
26
|
+
__webpack_require__.d(__webpack_exports__, {
|
|
27
|
+
default: ()=>ModernSandpack
|
|
28
|
+
});
|
|
29
|
+
const jsx_runtime_namespaceObject = require("react/jsx-runtime");
|
|
30
|
+
const sandpack_react_namespaceObject = require("@codesandbox/sandpack-react");
|
|
31
|
+
const index_js_namespaceObject = require("./templates/index.js");
|
|
32
|
+
function fileterFiles(files, removeFiles) {
|
|
33
|
+
if (0 === removeFiles.length) return files;
|
|
34
|
+
const result = {};
|
|
35
|
+
Object.keys(files).forEach((filename)=>{
|
|
36
|
+
if (!removeFiles.includes(filename)) result[filename] = files[filename];
|
|
37
|
+
});
|
|
38
|
+
return result;
|
|
39
|
+
}
|
|
40
|
+
function ModernSandpack(props) {
|
|
41
|
+
const { template, customSetup = {}, files: customFiles = {}, removeFiles = [], options = {}, initialCollapsedFolder = [], activeFile = 'src/routes/page.tsx', theme = 'light' } = props;
|
|
42
|
+
const initFiles = index_js_namespaceObject.ModernTemplates[template];
|
|
43
|
+
const files = {
|
|
44
|
+
...fileterFiles(initFiles, removeFiles),
|
|
45
|
+
...fileterFiles(customFiles, removeFiles)
|
|
46
|
+
};
|
|
47
|
+
return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(sandpack_react_namespaceObject.SandpackProvider, {
|
|
48
|
+
theme: theme,
|
|
49
|
+
customSetup: {
|
|
50
|
+
environment: 'node',
|
|
51
|
+
...customSetup
|
|
52
|
+
},
|
|
53
|
+
files: files,
|
|
54
|
+
options: {
|
|
55
|
+
activeFile,
|
|
56
|
+
visibleFiles: Object.keys(customFiles).filter((file)=>!removeFiles.includes(file)),
|
|
57
|
+
...options
|
|
58
|
+
},
|
|
59
|
+
children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)(sandpack_react_namespaceObject.SandpackLayout, {
|
|
60
|
+
children: [
|
|
61
|
+
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(sandpack_react_namespaceObject.SandpackFileExplorer, {
|
|
62
|
+
autoHiddenFiles: true,
|
|
63
|
+
initialCollapsedFolder: [
|
|
64
|
+
'/.husky/',
|
|
65
|
+
'/.vscode/',
|
|
66
|
+
'/.codesandbox/',
|
|
67
|
+
...initialCollapsedFolder
|
|
68
|
+
]
|
|
69
|
+
}),
|
|
70
|
+
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(sandpack_react_namespaceObject.SandpackCodeEditor, {
|
|
71
|
+
showLineNumbers: true,
|
|
72
|
+
showInlineErrors: true,
|
|
73
|
+
readOnly: true,
|
|
74
|
+
showTabs: false
|
|
75
|
+
}),
|
|
76
|
+
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("div", {
|
|
77
|
+
style: {
|
|
78
|
+
position: 'absolute',
|
|
79
|
+
right: '5px',
|
|
80
|
+
bottom: '5px'
|
|
81
|
+
},
|
|
82
|
+
children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(sandpack_react_namespaceObject.OpenInCodeSandboxButton, {})
|
|
83
|
+
})
|
|
84
|
+
]
|
|
85
|
+
})
|
|
86
|
+
});
|
|
87
|
+
}
|
|
88
|
+
exports["default"] = __webpack_exports__["default"];
|
|
89
|
+
for(var __rspack_i in __webpack_exports__)if (-1 === [
|
|
90
|
+
"default"
|
|
91
|
+
].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
|
|
92
|
+
Object.defineProperty(exports, '__esModule', {
|
|
93
|
+
value: true
|
|
94
|
+
});
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __webpack_require__ = {};
|
|
3
|
+
(()=>{
|
|
4
|
+
__webpack_require__.d = (exports1, definition)=>{
|
|
5
|
+
for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: definition[key]
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
})();
|
|
11
|
+
(()=>{
|
|
12
|
+
__webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
|
|
13
|
+
})();
|
|
14
|
+
(()=>{
|
|
15
|
+
__webpack_require__.r = (exports1)=>{
|
|
16
|
+
if ("u" > typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
|
|
17
|
+
value: 'Module'
|
|
18
|
+
});
|
|
19
|
+
Object.defineProperty(exports1, '__esModule', {
|
|
20
|
+
value: true
|
|
21
|
+
});
|
|
22
|
+
};
|
|
23
|
+
})();
|
|
24
|
+
var __webpack_exports__ = {};
|
|
25
|
+
__webpack_require__.r(__webpack_exports__);
|
|
26
|
+
__webpack_require__.d(__webpack_exports__, {
|
|
27
|
+
commonFiles: ()=>commonFiles
|
|
28
|
+
});
|
|
29
|
+
const commonFiles = {
|
|
30
|
+
".codesandbox/environment.json": "{\n \"nodeVersion\": 18\n}\n",
|
|
31
|
+
".codesandbox/tasks.json": "{\n \"$schema\": \"https://codesandbox.io/schemas/tasks.json\",\n \"setupTasks\": [\n {\n \"name\": \"Installing Dependencies\",\n \"command\": \"pnpm install\"\n }\n ],\n \"tasks\": {\n \"start\": {\n \"name\": \"Application\",\n \"command\": \"pnpm run start\",\n \"runAtStart\": true,\n \"restartOn\": {\n \"files\": [\"pnpm-lock.yaml\"]\n }\n }\n }\n}\n"
|
|
32
|
+
};
|
|
33
|
+
exports.commonFiles = __webpack_exports__.commonFiles;
|
|
34
|
+
for(var __rspack_i in __webpack_exports__)if (-1 === [
|
|
35
|
+
"commonFiles"
|
|
36
|
+
].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
|
|
37
|
+
Object.defineProperty(exports, '__esModule', {
|
|
38
|
+
value: true
|
|
39
|
+
});
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __webpack_modules__ = {
|
|
3
|
+
"./mwa" (module) {
|
|
4
|
+
module.exports = require("./mwa.js");
|
|
5
|
+
}
|
|
6
|
+
};
|
|
7
|
+
var __webpack_module_cache__ = {};
|
|
8
|
+
function __webpack_require__(moduleId) {
|
|
9
|
+
var cachedModule = __webpack_module_cache__[moduleId];
|
|
10
|
+
if (void 0 !== cachedModule) return cachedModule.exports;
|
|
11
|
+
var module = __webpack_module_cache__[moduleId] = {
|
|
12
|
+
exports: {}
|
|
13
|
+
};
|
|
14
|
+
__webpack_modules__[moduleId](module, module.exports, __webpack_require__);
|
|
15
|
+
return module.exports;
|
|
16
|
+
}
|
|
17
|
+
(()=>{
|
|
18
|
+
__webpack_require__.d = (exports1, definition)=>{
|
|
19
|
+
for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
|
|
20
|
+
enumerable: true,
|
|
21
|
+
get: definition[key]
|
|
22
|
+
});
|
|
23
|
+
};
|
|
24
|
+
})();
|
|
25
|
+
(()=>{
|
|
26
|
+
__webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
|
|
27
|
+
})();
|
|
28
|
+
(()=>{
|
|
29
|
+
__webpack_require__.r = (exports1)=>{
|
|
30
|
+
if ("u" > typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
|
|
31
|
+
value: 'Module'
|
|
32
|
+
});
|
|
33
|
+
Object.defineProperty(exports1, '__esModule', {
|
|
34
|
+
value: true
|
|
35
|
+
});
|
|
36
|
+
};
|
|
37
|
+
})();
|
|
38
|
+
var __webpack_exports__ = {};
|
|
39
|
+
(()=>{
|
|
40
|
+
__webpack_require__.r(__webpack_exports__);
|
|
41
|
+
__webpack_require__.d(__webpack_exports__, {
|
|
42
|
+
ModernTemplates: ()=>ModernTemplates
|
|
43
|
+
});
|
|
44
|
+
const { MWAFiles } = __webpack_require__("./mwa");
|
|
45
|
+
const ModernTemplates = {
|
|
46
|
+
'web-app': MWAFiles
|
|
47
|
+
};
|
|
48
|
+
})();
|
|
49
|
+
exports.ModernTemplates = __webpack_exports__.ModernTemplates;
|
|
50
|
+
for(var __rspack_i in __webpack_exports__)if (-1 === [
|
|
51
|
+
"ModernTemplates"
|
|
52
|
+
].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
|
|
53
|
+
Object.defineProperty(exports, '__esModule', {
|
|
54
|
+
value: true
|
|
55
|
+
});
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __webpack_require__ = {};
|
|
3
|
+
(()=>{
|
|
4
|
+
__webpack_require__.d = (exports1, definition)=>{
|
|
5
|
+
for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: definition[key]
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
})();
|
|
11
|
+
(()=>{
|
|
12
|
+
__webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
|
|
13
|
+
})();
|
|
14
|
+
(()=>{
|
|
15
|
+
__webpack_require__.r = (exports1)=>{
|
|
16
|
+
if ("u" > typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
|
|
17
|
+
value: 'Module'
|
|
18
|
+
});
|
|
19
|
+
Object.defineProperty(exports1, '__esModule', {
|
|
20
|
+
value: true
|
|
21
|
+
});
|
|
22
|
+
};
|
|
23
|
+
})();
|
|
24
|
+
var __webpack_exports__ = {};
|
|
25
|
+
__webpack_require__.r(__webpack_exports__);
|
|
26
|
+
__webpack_require__.d(__webpack_exports__, {
|
|
27
|
+
MWAFiles: ()=>MWAFiles
|
|
28
|
+
});
|
|
29
|
+
const external_common_js_namespaceObject = require("./common.js");
|
|
30
|
+
const MWAFiles = {
|
|
31
|
+
...external_common_js_namespaceObject.commonFiles,
|
|
32
|
+
".browserslistrc": "chrome >= 87\nedge >= 88\nfirefox >= 78\nsafari >= 14\n",
|
|
33
|
+
".gitignore": ".DS_Store\n\n.pnp\n.pnp.js\n.env.local\n.env.*.local\n.history\n*.log*\n\nnode_modules/\n.yarn-integrity\n.pnpm-store/\n*.tsbuildinfo\n.changeset/pre.json\n\ndist/\ncoverage/\nrelease/\noutput/\noutput_resource/\nlog/\n\n.vscode/**/*\n!.vscode/settings.json\n!.vscode/extensions.json\n.idea/\n\n**/*/typings/auto-generated\n\nmodern.config.local.*\n",
|
|
34
|
+
".npmrc": "strict-peer-dependencies=false\n",
|
|
35
|
+
"biome.json": '{\n "root": false,\n "$schema": "https://biomejs.dev/schemas/2.4.13/schema.json",\n "vcs": {\n "enabled": true,\n "defaultBranch": "main",\n "clientKind": "git",\n "useIgnoreFile": true\n },\n "formatter": {\n "enabled": true,\n "indentStyle": "space"\n },\n "javascript": {\n "formatter": {\n "quoteStyle": "single",\n "arrowParentheses": "asNeeded",\n "jsxQuoteStyle": "double",\n "lineWidth": 80\n }\n },\n "linter": {\n "enabled": true,\n "rules": {\n "recommended": true,\n "suspicious": {\n "noDuplicateFontNames": "off"\n }\n }\n },\n "assist": { "actions": { "source": { "organizeImports": "on" } } },\n "files": {\n "ignoreUnknown": true,\n "includes": [\n "**",\n "!**/.vscode/**/*",\n "!**/node_modules/**/*",\n "!**/dist/**/*"\n ]\n }\n}\n',
|
|
36
|
+
"modern.config.ts": "import { appTools, defineConfig, presetUltramodern } from '@modern-js/app-tools';\nimport path from 'node:path';\n\nconst appId = process.env.MODERN_BASELINE_APP_ID || path.basename(process.cwd());\nconst enableModuleFederationSSR =\n process.env.MODERN_BASELINE_ENABLE_MF_SSR !== 'false';\nconst enableBffRequestId =\n process.env.MODERN_BASELINE_ENABLE_BFF_REQUEST_ID !== 'false';\nconst enableTelemetryExporters =\n process.env.MODERN_BASELINE_ENABLE_TELEMETRY_EXPORTERS !== 'false';\nconst telemetryFailLoudStartup =\n process.env.MODERN_TELEMETRY_FAIL_LOUD_STARTUP !== 'false';\n\n// https://modernjs.dev/en/configure/app/usage\nexport default defineConfig(\n presetUltramodern(\n {\n plugins: [\n appTools(),\n ],\n },\n {\n appId,\n enableBffRequestId,\n enableModuleFederationSSR,\n enableTelemetryExporters,\n telemetryFailLoudStartup,\n otlpEndpoint: process.env.MODERN_TELEMETRY_OTLP_ENDPOINT,\n victoriaMetricsEndpoint: process.env.MODERN_TELEMETRY_VICTORIA_ENDPOINT,\n },\n ),\n);\n",
|
|
37
|
+
"package.json": '{\n "name": "modern-app",\n "version": "0.1.0",\n "scripts": {\n "reset": "npx rimraf node_modules ./**/node_modules",\n "dev": "modern dev",\n "build": "modern build",\n "serve": "modern serve",\n "ultramodern:check": "node ./scripts/validate-ultramodern.mjs",\n "lint": "biome check",\n "prepare": "simple-git-hooks"\n },\n "engines": {\n "node": ">=20"\n },\n "lint-staged": {\n "*.{js,ts,cjs,mjs,d.cts,d.mts,jsx,tsx,json,jsonc}": [\n "biome check --files-ignore-unknown=true"\n ]\n },\n "simple-git-hooks": {\n "pre-commit": "npx lint-staged"\n },\n "dependencies": {\n "@modern-js/runtime": "3.2.0",\n "react": "^19.2.3",\n "react-dom": "^19.2.0"\n },\n "devDependencies": {\n "@modern-js/app-tools": "3.2.0",\n "@modern-js/tsconfig": "3.2.0",\n "@biomejs/biome": "1.9.4",\n "@typescript/native-preview": "7.0.0-dev.20260516.1",\n "@types/node": "^20",\n "@types/react": "^19.1.8",\n "@types/react-dom": "^19.1.6",\n "lint-staged": "~15.4.0",\n "simple-git-hooks": "^2.11.1",\n "rimraf": "^6.0.1"\n }\n}\n',
|
|
38
|
+
"postcss.config.mjs": "",
|
|
39
|
+
"tailwind.config.ts": "",
|
|
40
|
+
"tsconfig.json": "{\n \"extends\": \"@modern-js/tsconfig/base\",\n \"compilerOptions\": {\n \"declaration\": false,\n \"jsx\": \"preserve\",\n \"baseUrl\": \"./\",\n \"paths\": {\n \"@/*\": [\"./src/*\"],\n \"@api/*\": [\"./api/*\"],\n \"@shared/*\": [\"./shared/*\"]\n },\n \"rootDir\": \"./src\"\n },\n \"include\": [\"src\", \"api\", \"shared\", \"config\", \"modern.config.ts\"],\n \"exclude\": [\"**/node_modules\"]\n}\n",
|
|
41
|
+
"scripts/validate-ultramodern.mjs": "import fs from 'node:fs';\nimport path from 'node:path';\n\nconst configPath = path.resolve(process.cwd(), 'modern.config.ts');\nconst templateManifestPath = path.resolve(\n process.cwd(),\n '.modernjs/mv-template-manifest.json',\n);\n\nif (!fs.existsSync(configPath)) {\n console.error('modern.config.ts not found');\n process.exit(1);\n}\n\nconst content = fs.readFileSync(configPath, 'utf8');\nconst requiredTokens = [\n 'presetUltramodern(',\n 'appTools()',\n 'enableModuleFederationSSR',\n 'enableBffRequestId',\n 'enableTelemetryExporters',\n];\nconst missing = requiredTokens.filter(token => !content.includes(token));\n\nif (missing.length > 0) {\n console.error(\n `Ultramodern contract check failed. Missing tokens: ${missing.join(', ')}`,\n );\n process.exit(1);\n}\n\nif (!fs.existsSync(templateManifestPath)) {\n console.error('.modernjs/mv-template-manifest.json not found');\n process.exit(1);\n}\n\nconst templateManifest = JSON.parse(\n fs.readFileSync(templateManifestPath, 'utf8'),\n);\nconst requiredDeniedPaths = [\n '.git/**',\n '.github/**',\n '.npmrc',\n '.yarnrc',\n '.env',\n '.env.*',\n 'node_modules/**',\n 'dist/**',\n];\nconst requiredPostMaterialization = [\n 'ultramodern-contract-check',\n 'dependency-install-with-lifecycle-deny',\n 'template-manifest-retained',\n];\nconst manifestErrors = [];\n\nif (templateManifest.schemaVersion !== 1) {\n manifestErrors.push('schemaVersion');\n}\n\nif (templateManifest.source?.type !== 'builtin') {\n manifestErrors.push('source.type');\n}\n\nif (\n !Array.isArray(templateManifest.integrity?.checksums) ||\n !templateManifest.integrity.checksums.some(\n checksum =>\n checksum.algorithm === 'sha256' &&\n checksum.scope === 'source-tree' &&\n /^[0-9a-f]{64}$/.test(checksum.value),\n )\n) {\n manifestErrors.push('integrity.checksums[source-tree]');\n}\n\nfor (const deniedPath of requiredDeniedPaths) {\n if (!templateManifest.materialization?.deniedPaths?.includes(deniedPath)) {\n manifestErrors.push(`materialization.deniedPaths:${deniedPath}`);\n }\n}\n\nif (templateManifest.lifecyclePolicy?.denyByDefault !== true) {\n manifestErrors.push('lifecyclePolicy.denyByDefault');\n}\n\nfor (const token of requiredPostMaterialization) {\n if (!templateManifest.validation?.postMaterializationValidation?.includes(token)) {\n manifestErrors.push(`validation.postMaterializationValidation:${token}`);\n }\n}\n\nif (manifestErrors.length > 0) {\n console.error(\n `Ultramodern template manifest check failed. Invalid fields: ${manifestErrors.join(\n ', ',\n )}`,\n );\n process.exit(1);\n}\n\nconsole.log('Ultramodern contract check passed.');\n",
|
|
42
|
+
"api/effect/index.ts": "",
|
|
43
|
+
"api/lambda/hello.ts": "",
|
|
44
|
+
"src/modern.runtime.ts": "import { defineRuntimeConfig } from '@modern-js/runtime';\n\nexport default defineRuntimeConfig({\n});\n",
|
|
45
|
+
"src/modern-app-env.d.ts": "/// <reference types='@modern-js/app-tools/types' />\n",
|
|
46
|
+
"src/routes/index.css": "html,\nbody {\n padding: 0;\n margin: 0;\n font-family: PingFang SC, Hiragino Sans GB, Microsoft YaHei, Arial, sans-serif;\n background: linear-gradient(to bottom, transparent, #fff) #eceeef;\n}\n\np {\n margin: 0;\n}\n\n* {\n -webkit-font-smoothing: antialiased;\n -moz-osx-font-smoothing: grayscale;\n box-sizing: border-box;\n}\n\n.container-box {\n min-height: 100vh;\n max-width: 100%;\n display: flex;\n flex-direction: column;\n justify-content: center;\n align-items: center;\n padding-top: 10px;\n}\n\nmain {\n flex: 1;\n display: flex;\n flex-direction: column;\n justify-content: center;\n align-items: center;\n}\n\n.title {\n display: flex;\n margin: 4rem 0 4rem;\n align-items: center;\n font-size: 4rem;\n font-weight: 600;\n}\n\n.logo {\n width: 6rem;\n margin: 7px 0 0 1rem;\n}\n\n.name {\n color: #4ecaff;\n}\n\n.description {\n text-align: center;\n line-height: 1.5;\n font-size: 1.3rem;\n color: #1b3a42;\n margin-bottom: 5rem;\n}\n\n.code {\n background: #fafafa;\n border-radius: 12px;\n padding: 0.6rem 0.9rem;\n font-size: 1.05rem;\n font-family:\n Menlo, Monaco, Lucida Console, Liberation Mono, DejaVu Sans Mono,\n Bitstream Vera Sans Mono, Courier New, monospace;\n}\n\n.container-box .grid {\n display: flex;\n align-items: center;\n justify-content: center;\n width: 1100px;\n margin-top: 3rem;\n}\n\n.card {\n padding: 1.5rem;\n display: flex;\n flex-direction: column;\n justify-content: center;\n height: 100px;\n color: inherit;\n text-decoration: none;\n transition: 0.15s ease;\n width: 45%;\n}\n\n.card:hover,\n.card:focus {\n transform: scale(1.05);\n}\n\n.card h2 {\n display: flex;\n align-items: center;\n font-size: 1.5rem;\n margin: 0;\n padding: 0;\n}\n\n.card p {\n opacity: 0.6;\n font-size: 0.9rem;\n line-height: 1.5;\n margin-top: 1rem;\n}\n\n.arrow-right {\n width: 1.3rem;\n margin-left: 0.5rem;\n margin-top: 3px;\n}\n",
|
|
47
|
+
"src/routes/layout.tsx": "import { Outlet } from '@modern-js/runtime/';\n\nexport default function Layout() {\n return (\n <div>\n <Outlet />\n </div>\n );\n}\n",
|
|
48
|
+
"src/routes/page.tsx": 'import { Helmet } from \'@modern-js/runtime/head\';\nimport \'./index.css\';\n\nconst Index = () => {\n\n return (\n <div className="container-box">\n <Helmet>\n <link\n rel="icon"\n type="image/x-icon"\n href="https://lf3-static.bytednsdoc.com/obj/eden-cn/uhbfnupenuhf/favicon.ico"\n />\n </Helmet>\n <main>\n <div className="title">\n Modern.js\n <img\n className="logo"\n src="https://lf3-static.bytednsdoc.com/obj/eden-cn/zq-uylkvT/ljhwZthlaukjlkulzlp/modern-js-logo.svg"\n alt="Modern.js Logo"\n />\n <p className="name">presetUltramodern</p>\n </div>\n <p className="description">\n This starter ships the public <code className="code">presetUltramodern(...)</code> profile. Start in\n <code className="code">modern.config.ts</code>, keep\n <code className="code">pnpm run ultramodern:check</code> green, and\n tune the generated preset only where your app needs a softer lane.\n </p>\n <div className="grid">\n <a\n href="https://modernjs.dev/en/guides/get-started/ultramodern.html"\n target="_blank"\n rel="noopener noreferrer"\n className="card"\n >\n <h2>\n presetUltramodern Guide\n <img\n className="arrow-right"\n src="https://lf3-static.bytednsdoc.com/obj/eden-cn/zq-uylkvT/ljhwZthlaukjlkulzlp/arrow-right.svg"\n alt="Guide"\n />\n </h2>\n <p>Review the MV-first, TanStack-ready, Effect-ready public preset.</p>\n </a>\n <a\n href="https://modernjs.dev/en/configure/app/usage.html"\n target="_blank"\n className="card"\n rel="noreferrer"\n >\n <h2>\n Configure presetUltramodern\n <img\n className="arrow-right"\n src="https://lf3-static.bytednsdoc.com/obj/eden-cn/zq-uylkvT/ljhwZthlaukjlkulzlp/arrow-right.svg"\n alt="Tutorials"\n />\n </h2>\n <p>Tune the generated defaults in <code className="code">modern.config.ts</code>.</p>\n </a>\n <a\n href="https://github.com/web-infra-dev/modern.js/blob/main/packages/toolkit/create/template/.github/workflows/ultramodern-gates.yml.handlebars"\n target="_blank"\n className="card"\n rel="noreferrer"\n >\n <h2>\n Ultramodern Gates\n <img\n className="arrow-right"\n src="https://lf3-static.bytednsdoc.com/obj/eden-cn/zq-uylkvT/ljhwZthlaukjlkulzlp/arrow-right.svg"\n alt="Config"\n />\n </h2>\n <p>The starter includes a PR workflow for <code className="code">ultramodern:check</code> and build.</p>\n </a>\n <a\n href="https://modernjs.dev/en/configure/app/bff/effect.html"\n target="_blank"\n rel="noopener noreferrer"\n className="card"\n >\n <h2>\n BFF + Effect\n <img\n className="arrow-right"\n src="https://lf3-static.bytednsdoc.com/obj/eden-cn/zq-uylkvT/ljhwZthlaukjlkulzlp/arrow-right.svg"\n alt="Github"\n />\n </h2>\n <p>Keep Effect as the preferred BFF lane while Hono stays an explicit fallback.</p>\n </a>\n </div>\n </main>\n </div>\n );\n};\n\nexport default Index;\n',
|
|
49
|
+
".github/workflows/ultramodern-gates.yml": "name: Ultramodern Gates\n\non:\n push:\n pull_request:\n\njobs:\n ultramodern-gates:\n runs-on: ubuntu-latest\n steps:\n - name: Checkout\n uses: actions/checkout@v4\n\n - name: Setup pnpm\n uses: pnpm/action-setup@v4\n\n - name: Setup Node.js\n uses: actions/setup-node@v4\n with:\n node-version: 20\n cache: pnpm\n\n - name: Install Dependencies\n run: pnpm install\n\n - name: Validate Ultramodern Contract\n run: pnpm run ultramodern:check\n\n - name: Build\n run: pnpm run build\n",
|
|
50
|
+
"shared/effect/api.ts": ""
|
|
51
|
+
};
|
|
52
|
+
exports.MWAFiles = __webpack_exports__.MWAFiles;
|
|
53
|
+
for(var __rspack_i in __webpack_exports__)if (-1 === [
|
|
54
|
+
"MWAFiles"
|
|
55
|
+
].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
|
|
56
|
+
Object.defineProperty(exports, '__esModule', {
|
|
57
|
+
value: true
|
|
58
|
+
});
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { OpenInCodeSandboxButton, SandpackCodeEditor, SandpackFileExplorer, SandpackLayout, SandpackProvider } from "@codesandbox/sandpack-react";
|
|
3
|
+
import { ModernTemplates } from "./templates/index.mjs";
|
|
4
|
+
function fileterFiles(files, removeFiles) {
|
|
5
|
+
if (0 === removeFiles.length) return files;
|
|
6
|
+
const result = {};
|
|
7
|
+
Object.keys(files).forEach((filename)=>{
|
|
8
|
+
if (!removeFiles.includes(filename)) result[filename] = files[filename];
|
|
9
|
+
});
|
|
10
|
+
return result;
|
|
11
|
+
}
|
|
12
|
+
function ModernSandpack(props) {
|
|
13
|
+
const { template, customSetup = {}, files: customFiles = {}, removeFiles = [], options = {}, initialCollapsedFolder = [], activeFile = 'src/routes/page.tsx', theme = 'light' } = props;
|
|
14
|
+
const initFiles = ModernTemplates[template];
|
|
15
|
+
const files = {
|
|
16
|
+
...fileterFiles(initFiles, removeFiles),
|
|
17
|
+
...fileterFiles(customFiles, removeFiles)
|
|
18
|
+
};
|
|
19
|
+
return /*#__PURE__*/ jsx(SandpackProvider, {
|
|
20
|
+
theme: theme,
|
|
21
|
+
customSetup: {
|
|
22
|
+
environment: 'node',
|
|
23
|
+
...customSetup
|
|
24
|
+
},
|
|
25
|
+
files: files,
|
|
26
|
+
options: {
|
|
27
|
+
activeFile,
|
|
28
|
+
visibleFiles: Object.keys(customFiles).filter((file)=>!removeFiles.includes(file)),
|
|
29
|
+
...options
|
|
30
|
+
},
|
|
31
|
+
children: /*#__PURE__*/ jsxs(SandpackLayout, {
|
|
32
|
+
children: [
|
|
33
|
+
/*#__PURE__*/ jsx(SandpackFileExplorer, {
|
|
34
|
+
autoHiddenFiles: true,
|
|
35
|
+
initialCollapsedFolder: [
|
|
36
|
+
'/.husky/',
|
|
37
|
+
'/.vscode/',
|
|
38
|
+
'/.codesandbox/',
|
|
39
|
+
...initialCollapsedFolder
|
|
40
|
+
]
|
|
41
|
+
}),
|
|
42
|
+
/*#__PURE__*/ jsx(SandpackCodeEditor, {
|
|
43
|
+
showLineNumbers: true,
|
|
44
|
+
showInlineErrors: true,
|
|
45
|
+
readOnly: true,
|
|
46
|
+
showTabs: false
|
|
47
|
+
}),
|
|
48
|
+
/*#__PURE__*/ jsx("div", {
|
|
49
|
+
style: {
|
|
50
|
+
position: 'absolute',
|
|
51
|
+
right: '5px',
|
|
52
|
+
bottom: '5px'
|
|
53
|
+
},
|
|
54
|
+
children: /*#__PURE__*/ jsx(OpenInCodeSandboxButton, {})
|
|
55
|
+
})
|
|
56
|
+
]
|
|
57
|
+
})
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
export default ModernSandpack;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
var __webpack_modules__ = {};
|
|
2
|
+
var __webpack_module_cache__ = {};
|
|
3
|
+
function __webpack_require__(moduleId) {
|
|
4
|
+
var cachedModule = __webpack_module_cache__[moduleId];
|
|
5
|
+
if (void 0 !== cachedModule) return cachedModule.exports;
|
|
6
|
+
var module = __webpack_module_cache__[moduleId] = {
|
|
7
|
+
exports: {}
|
|
8
|
+
};
|
|
9
|
+
__webpack_modules__[moduleId](module, module.exports, __webpack_require__);
|
|
10
|
+
return module.exports;
|
|
11
|
+
}
|
|
12
|
+
__webpack_require__.m = __webpack_modules__;
|
|
13
|
+
(()=>{
|
|
14
|
+
__webpack_require__.add = function(modules) {
|
|
15
|
+
Object.assign(__webpack_require__.m, modules);
|
|
16
|
+
};
|
|
17
|
+
})();
|
|
18
|
+
export { __webpack_require__ };
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
const commonFiles = {
|
|
2
|
+
".codesandbox/environment.json": "{\n \"nodeVersion\": 18\n}\n",
|
|
3
|
+
".codesandbox/tasks.json": "{\n \"$schema\": \"https://codesandbox.io/schemas/tasks.json\",\n \"setupTasks\": [\n {\n \"name\": \"Installing Dependencies\",\n \"command\": \"pnpm install\"\n }\n ],\n \"tasks\": {\n \"start\": {\n \"name\": \"Application\",\n \"command\": \"pnpm run start\",\n \"runAtStart\": true,\n \"restartOn\": {\n \"files\": [\"pnpm-lock.yaml\"]\n }\n }\n }\n}\n"
|
|
4
|
+
};
|
|
5
|
+
export { commonFiles };
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { __webpack_require__ } from "../rslib-runtime.mjs";
|
|
2
|
+
import * as __rspack_external__mwa_mjs_5d9bbc8d from "./mwa.mjs";
|
|
3
|
+
__webpack_require__.add({
|
|
4
|
+
"./mwa" (module) {
|
|
5
|
+
module.exports = __rspack_external__mwa_mjs_5d9bbc8d;
|
|
6
|
+
}
|
|
7
|
+
});
|
|
8
|
+
const { MWAFiles: MWAFiles } = __webpack_require__("./mwa");
|
|
9
|
+
const ModernTemplates = {
|
|
10
|
+
'web-app': MWAFiles
|
|
11
|
+
};
|
|
12
|
+
export { ModernTemplates };
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { commonFiles } from "./common.mjs";
|
|
2
|
+
const MWAFiles = {
|
|
3
|
+
...commonFiles,
|
|
4
|
+
".browserslistrc": "chrome >= 87\nedge >= 88\nfirefox >= 78\nsafari >= 14\n",
|
|
5
|
+
".gitignore": ".DS_Store\n\n.pnp\n.pnp.js\n.env.local\n.env.*.local\n.history\n*.log*\n\nnode_modules/\n.yarn-integrity\n.pnpm-store/\n*.tsbuildinfo\n.changeset/pre.json\n\ndist/\ncoverage/\nrelease/\noutput/\noutput_resource/\nlog/\n\n.vscode/**/*\n!.vscode/settings.json\n!.vscode/extensions.json\n.idea/\n\n**/*/typings/auto-generated\n\nmodern.config.local.*\n",
|
|
6
|
+
".npmrc": "strict-peer-dependencies=false\n",
|
|
7
|
+
"biome.json": '{\n "root": false,\n "$schema": "https://biomejs.dev/schemas/2.4.13/schema.json",\n "vcs": {\n "enabled": true,\n "defaultBranch": "main",\n "clientKind": "git",\n "useIgnoreFile": true\n },\n "formatter": {\n "enabled": true,\n "indentStyle": "space"\n },\n "javascript": {\n "formatter": {\n "quoteStyle": "single",\n "arrowParentheses": "asNeeded",\n "jsxQuoteStyle": "double",\n "lineWidth": 80\n }\n },\n "linter": {\n "enabled": true,\n "rules": {\n "recommended": true,\n "suspicious": {\n "noDuplicateFontNames": "off"\n }\n }\n },\n "assist": { "actions": { "source": { "organizeImports": "on" } } },\n "files": {\n "ignoreUnknown": true,\n "includes": [\n "**",\n "!**/.vscode/**/*",\n "!**/node_modules/**/*",\n "!**/dist/**/*"\n ]\n }\n}\n',
|
|
8
|
+
"modern.config.ts": "import { appTools, defineConfig, presetUltramodern } from '@modern-js/app-tools';\nimport path from 'node:path';\n\nconst appId = process.env.MODERN_BASELINE_APP_ID || path.basename(process.cwd());\nconst enableModuleFederationSSR =\n process.env.MODERN_BASELINE_ENABLE_MF_SSR !== 'false';\nconst enableBffRequestId =\n process.env.MODERN_BASELINE_ENABLE_BFF_REQUEST_ID !== 'false';\nconst enableTelemetryExporters =\n process.env.MODERN_BASELINE_ENABLE_TELEMETRY_EXPORTERS !== 'false';\nconst telemetryFailLoudStartup =\n process.env.MODERN_TELEMETRY_FAIL_LOUD_STARTUP !== 'false';\n\n// https://modernjs.dev/en/configure/app/usage\nexport default defineConfig(\n presetUltramodern(\n {\n plugins: [\n appTools(),\n ],\n },\n {\n appId,\n enableBffRequestId,\n enableModuleFederationSSR,\n enableTelemetryExporters,\n telemetryFailLoudStartup,\n otlpEndpoint: process.env.MODERN_TELEMETRY_OTLP_ENDPOINT,\n victoriaMetricsEndpoint: process.env.MODERN_TELEMETRY_VICTORIA_ENDPOINT,\n },\n ),\n);\n",
|
|
9
|
+
"package.json": '{\n "name": "modern-app",\n "version": "0.1.0",\n "scripts": {\n "reset": "npx rimraf node_modules ./**/node_modules",\n "dev": "modern dev",\n "build": "modern build",\n "serve": "modern serve",\n "ultramodern:check": "node ./scripts/validate-ultramodern.mjs",\n "lint": "biome check",\n "prepare": "simple-git-hooks"\n },\n "engines": {\n "node": ">=20"\n },\n "lint-staged": {\n "*.{js,ts,cjs,mjs,d.cts,d.mts,jsx,tsx,json,jsonc}": [\n "biome check --files-ignore-unknown=true"\n ]\n },\n "simple-git-hooks": {\n "pre-commit": "npx lint-staged"\n },\n "dependencies": {\n "@modern-js/runtime": "3.2.0",\n "react": "^19.2.3",\n "react-dom": "^19.2.0"\n },\n "devDependencies": {\n "@modern-js/app-tools": "3.2.0",\n "@modern-js/tsconfig": "3.2.0",\n "@biomejs/biome": "1.9.4",\n "@typescript/native-preview": "7.0.0-dev.20260516.1",\n "@types/node": "^20",\n "@types/react": "^19.1.8",\n "@types/react-dom": "^19.1.6",\n "lint-staged": "~15.4.0",\n "simple-git-hooks": "^2.11.1",\n "rimraf": "^6.0.1"\n }\n}\n',
|
|
10
|
+
"postcss.config.mjs": "",
|
|
11
|
+
"tailwind.config.ts": "",
|
|
12
|
+
"tsconfig.json": "{\n \"extends\": \"@modern-js/tsconfig/base\",\n \"compilerOptions\": {\n \"declaration\": false,\n \"jsx\": \"preserve\",\n \"baseUrl\": \"./\",\n \"paths\": {\n \"@/*\": [\"./src/*\"],\n \"@api/*\": [\"./api/*\"],\n \"@shared/*\": [\"./shared/*\"]\n },\n \"rootDir\": \"./src\"\n },\n \"include\": [\"src\", \"api\", \"shared\", \"config\", \"modern.config.ts\"],\n \"exclude\": [\"**/node_modules\"]\n}\n",
|
|
13
|
+
"scripts/validate-ultramodern.mjs": "import fs from 'node:fs';\nimport path from 'node:path';\n\nconst configPath = path.resolve(process.cwd(), 'modern.config.ts');\nconst templateManifestPath = path.resolve(\n process.cwd(),\n '.modernjs/mv-template-manifest.json',\n);\n\nif (!fs.existsSync(configPath)) {\n console.error('modern.config.ts not found');\n process.exit(1);\n}\n\nconst content = fs.readFileSync(configPath, 'utf8');\nconst requiredTokens = [\n 'presetUltramodern(',\n 'appTools()',\n 'enableModuleFederationSSR',\n 'enableBffRequestId',\n 'enableTelemetryExporters',\n];\nconst missing = requiredTokens.filter(token => !content.includes(token));\n\nif (missing.length > 0) {\n console.error(\n `Ultramodern contract check failed. Missing tokens: ${missing.join(', ')}`,\n );\n process.exit(1);\n}\n\nif (!fs.existsSync(templateManifestPath)) {\n console.error('.modernjs/mv-template-manifest.json not found');\n process.exit(1);\n}\n\nconst templateManifest = JSON.parse(\n fs.readFileSync(templateManifestPath, 'utf8'),\n);\nconst requiredDeniedPaths = [\n '.git/**',\n '.github/**',\n '.npmrc',\n '.yarnrc',\n '.env',\n '.env.*',\n 'node_modules/**',\n 'dist/**',\n];\nconst requiredPostMaterialization = [\n 'ultramodern-contract-check',\n 'dependency-install-with-lifecycle-deny',\n 'template-manifest-retained',\n];\nconst manifestErrors = [];\n\nif (templateManifest.schemaVersion !== 1) {\n manifestErrors.push('schemaVersion');\n}\n\nif (templateManifest.source?.type !== 'builtin') {\n manifestErrors.push('source.type');\n}\n\nif (\n !Array.isArray(templateManifest.integrity?.checksums) ||\n !templateManifest.integrity.checksums.some(\n checksum =>\n checksum.algorithm === 'sha256' &&\n checksum.scope === 'source-tree' &&\n /^[0-9a-f]{64}$/.test(checksum.value),\n )\n) {\n manifestErrors.push('integrity.checksums[source-tree]');\n}\n\nfor (const deniedPath of requiredDeniedPaths) {\n if (!templateManifest.materialization?.deniedPaths?.includes(deniedPath)) {\n manifestErrors.push(`materialization.deniedPaths:${deniedPath}`);\n }\n}\n\nif (templateManifest.lifecyclePolicy?.denyByDefault !== true) {\n manifestErrors.push('lifecyclePolicy.denyByDefault');\n}\n\nfor (const token of requiredPostMaterialization) {\n if (!templateManifest.validation?.postMaterializationValidation?.includes(token)) {\n manifestErrors.push(`validation.postMaterializationValidation:${token}`);\n }\n}\n\nif (manifestErrors.length > 0) {\n console.error(\n `Ultramodern template manifest check failed. Invalid fields: ${manifestErrors.join(\n ', ',\n )}`,\n );\n process.exit(1);\n}\n\nconsole.log('Ultramodern contract check passed.');\n",
|
|
14
|
+
"api/effect/index.ts": "",
|
|
15
|
+
"api/lambda/hello.ts": "",
|
|
16
|
+
"src/modern.runtime.ts": "import { defineRuntimeConfig } from '@modern-js/runtime';\n\nexport default defineRuntimeConfig({\n});\n",
|
|
17
|
+
"src/modern-app-env.d.ts": "/// <reference types='@modern-js/app-tools/types' />\n",
|
|
18
|
+
"src/routes/index.css": "html,\nbody {\n padding: 0;\n margin: 0;\n font-family: PingFang SC, Hiragino Sans GB, Microsoft YaHei, Arial, sans-serif;\n background: linear-gradient(to bottom, transparent, #fff) #eceeef;\n}\n\np {\n margin: 0;\n}\n\n* {\n -webkit-font-smoothing: antialiased;\n -moz-osx-font-smoothing: grayscale;\n box-sizing: border-box;\n}\n\n.container-box {\n min-height: 100vh;\n max-width: 100%;\n display: flex;\n flex-direction: column;\n justify-content: center;\n align-items: center;\n padding-top: 10px;\n}\n\nmain {\n flex: 1;\n display: flex;\n flex-direction: column;\n justify-content: center;\n align-items: center;\n}\n\n.title {\n display: flex;\n margin: 4rem 0 4rem;\n align-items: center;\n font-size: 4rem;\n font-weight: 600;\n}\n\n.logo {\n width: 6rem;\n margin: 7px 0 0 1rem;\n}\n\n.name {\n color: #4ecaff;\n}\n\n.description {\n text-align: center;\n line-height: 1.5;\n font-size: 1.3rem;\n color: #1b3a42;\n margin-bottom: 5rem;\n}\n\n.code {\n background: #fafafa;\n border-radius: 12px;\n padding: 0.6rem 0.9rem;\n font-size: 1.05rem;\n font-family:\n Menlo, Monaco, Lucida Console, Liberation Mono, DejaVu Sans Mono,\n Bitstream Vera Sans Mono, Courier New, monospace;\n}\n\n.container-box .grid {\n display: flex;\n align-items: center;\n justify-content: center;\n width: 1100px;\n margin-top: 3rem;\n}\n\n.card {\n padding: 1.5rem;\n display: flex;\n flex-direction: column;\n justify-content: center;\n height: 100px;\n color: inherit;\n text-decoration: none;\n transition: 0.15s ease;\n width: 45%;\n}\n\n.card:hover,\n.card:focus {\n transform: scale(1.05);\n}\n\n.card h2 {\n display: flex;\n align-items: center;\n font-size: 1.5rem;\n margin: 0;\n padding: 0;\n}\n\n.card p {\n opacity: 0.6;\n font-size: 0.9rem;\n line-height: 1.5;\n margin-top: 1rem;\n}\n\n.arrow-right {\n width: 1.3rem;\n margin-left: 0.5rem;\n margin-top: 3px;\n}\n",
|
|
19
|
+
"src/routes/layout.tsx": "import { Outlet } from '@modern-js/runtime/';\n\nexport default function Layout() {\n return (\n <div>\n <Outlet />\n </div>\n );\n}\n",
|
|
20
|
+
"src/routes/page.tsx": 'import { Helmet } from \'@modern-js/runtime/head\';\nimport \'./index.css\';\n\nconst Index = () => {\n\n return (\n <div className="container-box">\n <Helmet>\n <link\n rel="icon"\n type="image/x-icon"\n href="https://lf3-static.bytednsdoc.com/obj/eden-cn/uhbfnupenuhf/favicon.ico"\n />\n </Helmet>\n <main>\n <div className="title">\n Modern.js\n <img\n className="logo"\n src="https://lf3-static.bytednsdoc.com/obj/eden-cn/zq-uylkvT/ljhwZthlaukjlkulzlp/modern-js-logo.svg"\n alt="Modern.js Logo"\n />\n <p className="name">presetUltramodern</p>\n </div>\n <p className="description">\n This starter ships the public <code className="code">presetUltramodern(...)</code> profile. Start in\n <code className="code">modern.config.ts</code>, keep\n <code className="code">pnpm run ultramodern:check</code> green, and\n tune the generated preset only where your app needs a softer lane.\n </p>\n <div className="grid">\n <a\n href="https://modernjs.dev/en/guides/get-started/ultramodern.html"\n target="_blank"\n rel="noopener noreferrer"\n className="card"\n >\n <h2>\n presetUltramodern Guide\n <img\n className="arrow-right"\n src="https://lf3-static.bytednsdoc.com/obj/eden-cn/zq-uylkvT/ljhwZthlaukjlkulzlp/arrow-right.svg"\n alt="Guide"\n />\n </h2>\n <p>Review the MV-first, TanStack-ready, Effect-ready public preset.</p>\n </a>\n <a\n href="https://modernjs.dev/en/configure/app/usage.html"\n target="_blank"\n className="card"\n rel="noreferrer"\n >\n <h2>\n Configure presetUltramodern\n <img\n className="arrow-right"\n src="https://lf3-static.bytednsdoc.com/obj/eden-cn/zq-uylkvT/ljhwZthlaukjlkulzlp/arrow-right.svg"\n alt="Tutorials"\n />\n </h2>\n <p>Tune the generated defaults in <code className="code">modern.config.ts</code>.</p>\n </a>\n <a\n href="https://github.com/web-infra-dev/modern.js/blob/main/packages/toolkit/create/template/.github/workflows/ultramodern-gates.yml.handlebars"\n target="_blank"\n className="card"\n rel="noreferrer"\n >\n <h2>\n Ultramodern Gates\n <img\n className="arrow-right"\n src="https://lf3-static.bytednsdoc.com/obj/eden-cn/zq-uylkvT/ljhwZthlaukjlkulzlp/arrow-right.svg"\n alt="Config"\n />\n </h2>\n <p>The starter includes a PR workflow for <code className="code">ultramodern:check</code> and build.</p>\n </a>\n <a\n href="https://modernjs.dev/en/configure/app/bff/effect.html"\n target="_blank"\n rel="noopener noreferrer"\n className="card"\n >\n <h2>\n BFF + Effect\n <img\n className="arrow-right"\n src="https://lf3-static.bytednsdoc.com/obj/eden-cn/zq-uylkvT/ljhwZthlaukjlkulzlp/arrow-right.svg"\n alt="Github"\n />\n </h2>\n <p>Keep Effect as the preferred BFF lane while Hono stays an explicit fallback.</p>\n </a>\n </div>\n </main>\n </div>\n );\n};\n\nexport default Index;\n',
|
|
21
|
+
".github/workflows/ultramodern-gates.yml": "name: Ultramodern Gates\n\non:\n push:\n pull_request:\n\njobs:\n ultramodern-gates:\n runs-on: ubuntu-latest\n steps:\n - name: Checkout\n uses: actions/checkout@v4\n\n - name: Setup pnpm\n uses: pnpm/action-setup@v4\n\n - name: Setup Node.js\n uses: actions/setup-node@v4\n with:\n node-version: 20\n cache: pnpm\n\n - name: Install Dependencies\n run: pnpm install\n\n - name: Validate Ultramodern Contract\n run: pnpm run ultramodern:check\n\n - name: Build\n run: pnpm run build\n",
|
|
22
|
+
"shared/effect/api.ts": ""
|
|
23
|
+
};
|
|
24
|
+
export { MWAFiles };
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import "node:module";
|
|
2
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { OpenInCodeSandboxButton, SandpackCodeEditor, SandpackFileExplorer, SandpackLayout, SandpackProvider } from "@codesandbox/sandpack-react";
|
|
4
|
+
import { ModernTemplates } from "./templates/index.mjs";
|
|
5
|
+
function fileterFiles(files, removeFiles) {
|
|
6
|
+
if (0 === removeFiles.length) return files;
|
|
7
|
+
const result = {};
|
|
8
|
+
Object.keys(files).forEach((filename)=>{
|
|
9
|
+
if (!removeFiles.includes(filename)) result[filename] = files[filename];
|
|
10
|
+
});
|
|
11
|
+
return result;
|
|
12
|
+
}
|
|
13
|
+
function ModernSandpack(props) {
|
|
14
|
+
const { template, customSetup = {}, files: customFiles = {}, removeFiles = [], options = {}, initialCollapsedFolder = [], activeFile = 'src/routes/page.tsx', theme = 'light' } = props;
|
|
15
|
+
const initFiles = ModernTemplates[template];
|
|
16
|
+
const files = {
|
|
17
|
+
...fileterFiles(initFiles, removeFiles),
|
|
18
|
+
...fileterFiles(customFiles, removeFiles)
|
|
19
|
+
};
|
|
20
|
+
return /*#__PURE__*/ jsx(SandpackProvider, {
|
|
21
|
+
theme: theme,
|
|
22
|
+
customSetup: {
|
|
23
|
+
environment: 'node',
|
|
24
|
+
...customSetup
|
|
25
|
+
},
|
|
26
|
+
files: files,
|
|
27
|
+
options: {
|
|
28
|
+
activeFile,
|
|
29
|
+
visibleFiles: Object.keys(customFiles).filter((file)=>!removeFiles.includes(file)),
|
|
30
|
+
...options
|
|
31
|
+
},
|
|
32
|
+
children: /*#__PURE__*/ jsxs(SandpackLayout, {
|
|
33
|
+
children: [
|
|
34
|
+
/*#__PURE__*/ jsx(SandpackFileExplorer, {
|
|
35
|
+
autoHiddenFiles: true,
|
|
36
|
+
initialCollapsedFolder: [
|
|
37
|
+
'/.husky/',
|
|
38
|
+
'/.vscode/',
|
|
39
|
+
'/.codesandbox/',
|
|
40
|
+
...initialCollapsedFolder
|
|
41
|
+
]
|
|
42
|
+
}),
|
|
43
|
+
/*#__PURE__*/ jsx(SandpackCodeEditor, {
|
|
44
|
+
showLineNumbers: true,
|
|
45
|
+
showInlineErrors: true,
|
|
46
|
+
readOnly: true,
|
|
47
|
+
showTabs: false
|
|
48
|
+
}),
|
|
49
|
+
/*#__PURE__*/ jsx("div", {
|
|
50
|
+
style: {
|
|
51
|
+
position: 'absolute',
|
|
52
|
+
right: '5px',
|
|
53
|
+
bottom: '5px'
|
|
54
|
+
},
|
|
55
|
+
children: /*#__PURE__*/ jsx(OpenInCodeSandboxButton, {})
|
|
56
|
+
})
|
|
57
|
+
]
|
|
58
|
+
})
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
export default ModernSandpack;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import "node:module";
|
|
2
|
+
var __webpack_modules__ = {};
|
|
3
|
+
var __webpack_module_cache__ = {};
|
|
4
|
+
function __webpack_require__(moduleId) {
|
|
5
|
+
var cachedModule = __webpack_module_cache__[moduleId];
|
|
6
|
+
if (void 0 !== cachedModule) return cachedModule.exports;
|
|
7
|
+
var module = __webpack_module_cache__[moduleId] = {
|
|
8
|
+
exports: {}
|
|
9
|
+
};
|
|
10
|
+
__webpack_modules__[moduleId](module, module.exports, __webpack_require__);
|
|
11
|
+
return module.exports;
|
|
12
|
+
}
|
|
13
|
+
__webpack_require__.m = __webpack_modules__;
|
|
14
|
+
(()=>{
|
|
15
|
+
__webpack_require__.add = function(modules) {
|
|
16
|
+
Object.assign(__webpack_require__.m, modules);
|
|
17
|
+
};
|
|
18
|
+
})();
|
|
19
|
+
export { __webpack_require__ };
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import "node:module";
|
|
2
|
+
const commonFiles = {
|
|
3
|
+
".codesandbox/environment.json": "{\n \"nodeVersion\": 18\n}\n",
|
|
4
|
+
".codesandbox/tasks.json": "{\n \"$schema\": \"https://codesandbox.io/schemas/tasks.json\",\n \"setupTasks\": [\n {\n \"name\": \"Installing Dependencies\",\n \"command\": \"pnpm install\"\n }\n ],\n \"tasks\": {\n \"start\": {\n \"name\": \"Application\",\n \"command\": \"pnpm run start\",\n \"runAtStart\": true,\n \"restartOn\": {\n \"files\": [\"pnpm-lock.yaml\"]\n }\n }\n }\n}\n"
|
|
5
|
+
};
|
|
6
|
+
export { commonFiles };
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import "node:module";
|
|
2
|
+
import { __webpack_require__ } from "../rslib-runtime.mjs";
|
|
3
|
+
import * as __rspack_external__mwa_mjs_5d9bbc8d from "./mwa.mjs";
|
|
4
|
+
__webpack_require__.add({
|
|
5
|
+
"./mwa" (module) {
|
|
6
|
+
module.exports = __rspack_external__mwa_mjs_5d9bbc8d;
|
|
7
|
+
}
|
|
8
|
+
});
|
|
9
|
+
const { MWAFiles: MWAFiles } = __webpack_require__("./mwa");
|
|
10
|
+
const ModernTemplates = {
|
|
11
|
+
'web-app': MWAFiles
|
|
12
|
+
};
|
|
13
|
+
export { ModernTemplates };
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import "node:module";
|
|
2
|
+
import { commonFiles } from "./common.mjs";
|
|
3
|
+
const MWAFiles = {
|
|
4
|
+
...commonFiles,
|
|
5
|
+
".browserslistrc": "chrome >= 87\nedge >= 88\nfirefox >= 78\nsafari >= 14\n",
|
|
6
|
+
".gitignore": ".DS_Store\n\n.pnp\n.pnp.js\n.env.local\n.env.*.local\n.history\n*.log*\n\nnode_modules/\n.yarn-integrity\n.pnpm-store/\n*.tsbuildinfo\n.changeset/pre.json\n\ndist/\ncoverage/\nrelease/\noutput/\noutput_resource/\nlog/\n\n.vscode/**/*\n!.vscode/settings.json\n!.vscode/extensions.json\n.idea/\n\n**/*/typings/auto-generated\n\nmodern.config.local.*\n",
|
|
7
|
+
".npmrc": "strict-peer-dependencies=false\n",
|
|
8
|
+
"biome.json": '{\n "root": false,\n "$schema": "https://biomejs.dev/schemas/2.4.13/schema.json",\n "vcs": {\n "enabled": true,\n "defaultBranch": "main",\n "clientKind": "git",\n "useIgnoreFile": true\n },\n "formatter": {\n "enabled": true,\n "indentStyle": "space"\n },\n "javascript": {\n "formatter": {\n "quoteStyle": "single",\n "arrowParentheses": "asNeeded",\n "jsxQuoteStyle": "double",\n "lineWidth": 80\n }\n },\n "linter": {\n "enabled": true,\n "rules": {\n "recommended": true,\n "suspicious": {\n "noDuplicateFontNames": "off"\n }\n }\n },\n "assist": { "actions": { "source": { "organizeImports": "on" } } },\n "files": {\n "ignoreUnknown": true,\n "includes": [\n "**",\n "!**/.vscode/**/*",\n "!**/node_modules/**/*",\n "!**/dist/**/*"\n ]\n }\n}\n',
|
|
9
|
+
"modern.config.ts": "import { appTools, defineConfig, presetUltramodern } from '@modern-js/app-tools';\nimport path from 'node:path';\n\nconst appId = process.env.MODERN_BASELINE_APP_ID || path.basename(process.cwd());\nconst enableModuleFederationSSR =\n process.env.MODERN_BASELINE_ENABLE_MF_SSR !== 'false';\nconst enableBffRequestId =\n process.env.MODERN_BASELINE_ENABLE_BFF_REQUEST_ID !== 'false';\nconst enableTelemetryExporters =\n process.env.MODERN_BASELINE_ENABLE_TELEMETRY_EXPORTERS !== 'false';\nconst telemetryFailLoudStartup =\n process.env.MODERN_TELEMETRY_FAIL_LOUD_STARTUP !== 'false';\n\n// https://modernjs.dev/en/configure/app/usage\nexport default defineConfig(\n presetUltramodern(\n {\n plugins: [\n appTools(),\n ],\n },\n {\n appId,\n enableBffRequestId,\n enableModuleFederationSSR,\n enableTelemetryExporters,\n telemetryFailLoudStartup,\n otlpEndpoint: process.env.MODERN_TELEMETRY_OTLP_ENDPOINT,\n victoriaMetricsEndpoint: process.env.MODERN_TELEMETRY_VICTORIA_ENDPOINT,\n },\n ),\n);\n",
|
|
10
|
+
"package.json": '{\n "name": "modern-app",\n "version": "0.1.0",\n "scripts": {\n "reset": "npx rimraf node_modules ./**/node_modules",\n "dev": "modern dev",\n "build": "modern build",\n "serve": "modern serve",\n "ultramodern:check": "node ./scripts/validate-ultramodern.mjs",\n "lint": "biome check",\n "prepare": "simple-git-hooks"\n },\n "engines": {\n "node": ">=20"\n },\n "lint-staged": {\n "*.{js,ts,cjs,mjs,d.cts,d.mts,jsx,tsx,json,jsonc}": [\n "biome check --files-ignore-unknown=true"\n ]\n },\n "simple-git-hooks": {\n "pre-commit": "npx lint-staged"\n },\n "dependencies": {\n "@modern-js/runtime": "3.2.0",\n "react": "^19.2.3",\n "react-dom": "^19.2.0"\n },\n "devDependencies": {\n "@modern-js/app-tools": "3.2.0",\n "@modern-js/tsconfig": "3.2.0",\n "@biomejs/biome": "1.9.4",\n "@typescript/native-preview": "7.0.0-dev.20260516.1",\n "@types/node": "^20",\n "@types/react": "^19.1.8",\n "@types/react-dom": "^19.1.6",\n "lint-staged": "~15.4.0",\n "simple-git-hooks": "^2.11.1",\n "rimraf": "^6.0.1"\n }\n}\n',
|
|
11
|
+
"postcss.config.mjs": "",
|
|
12
|
+
"tailwind.config.ts": "",
|
|
13
|
+
"tsconfig.json": "{\n \"extends\": \"@modern-js/tsconfig/base\",\n \"compilerOptions\": {\n \"declaration\": false,\n \"jsx\": \"preserve\",\n \"baseUrl\": \"./\",\n \"paths\": {\n \"@/*\": [\"./src/*\"],\n \"@api/*\": [\"./api/*\"],\n \"@shared/*\": [\"./shared/*\"]\n },\n \"rootDir\": \"./src\"\n },\n \"include\": [\"src\", \"api\", \"shared\", \"config\", \"modern.config.ts\"],\n \"exclude\": [\"**/node_modules\"]\n}\n",
|
|
14
|
+
"scripts/validate-ultramodern.mjs": "import fs from 'node:fs';\nimport path from 'node:path';\n\nconst configPath = path.resolve(process.cwd(), 'modern.config.ts');\nconst templateManifestPath = path.resolve(\n process.cwd(),\n '.modernjs/mv-template-manifest.json',\n);\n\nif (!fs.existsSync(configPath)) {\n console.error('modern.config.ts not found');\n process.exit(1);\n}\n\nconst content = fs.readFileSync(configPath, 'utf8');\nconst requiredTokens = [\n 'presetUltramodern(',\n 'appTools()',\n 'enableModuleFederationSSR',\n 'enableBffRequestId',\n 'enableTelemetryExporters',\n];\nconst missing = requiredTokens.filter(token => !content.includes(token));\n\nif (missing.length > 0) {\n console.error(\n `Ultramodern contract check failed. Missing tokens: ${missing.join(', ')}`,\n );\n process.exit(1);\n}\n\nif (!fs.existsSync(templateManifestPath)) {\n console.error('.modernjs/mv-template-manifest.json not found');\n process.exit(1);\n}\n\nconst templateManifest = JSON.parse(\n fs.readFileSync(templateManifestPath, 'utf8'),\n);\nconst requiredDeniedPaths = [\n '.git/**',\n '.github/**',\n '.npmrc',\n '.yarnrc',\n '.env',\n '.env.*',\n 'node_modules/**',\n 'dist/**',\n];\nconst requiredPostMaterialization = [\n 'ultramodern-contract-check',\n 'dependency-install-with-lifecycle-deny',\n 'template-manifest-retained',\n];\nconst manifestErrors = [];\n\nif (templateManifest.schemaVersion !== 1) {\n manifestErrors.push('schemaVersion');\n}\n\nif (templateManifest.source?.type !== 'builtin') {\n manifestErrors.push('source.type');\n}\n\nif (\n !Array.isArray(templateManifest.integrity?.checksums) ||\n !templateManifest.integrity.checksums.some(\n checksum =>\n checksum.algorithm === 'sha256' &&\n checksum.scope === 'source-tree' &&\n /^[0-9a-f]{64}$/.test(checksum.value),\n )\n) {\n manifestErrors.push('integrity.checksums[source-tree]');\n}\n\nfor (const deniedPath of requiredDeniedPaths) {\n if (!templateManifest.materialization?.deniedPaths?.includes(deniedPath)) {\n manifestErrors.push(`materialization.deniedPaths:${deniedPath}`);\n }\n}\n\nif (templateManifest.lifecyclePolicy?.denyByDefault !== true) {\n manifestErrors.push('lifecyclePolicy.denyByDefault');\n}\n\nfor (const token of requiredPostMaterialization) {\n if (!templateManifest.validation?.postMaterializationValidation?.includes(token)) {\n manifestErrors.push(`validation.postMaterializationValidation:${token}`);\n }\n}\n\nif (manifestErrors.length > 0) {\n console.error(\n `Ultramodern template manifest check failed. Invalid fields: ${manifestErrors.join(\n ', ',\n )}`,\n );\n process.exit(1);\n}\n\nconsole.log('Ultramodern contract check passed.');\n",
|
|
15
|
+
"api/effect/index.ts": "",
|
|
16
|
+
"api/lambda/hello.ts": "",
|
|
17
|
+
"src/modern.runtime.ts": "import { defineRuntimeConfig } from '@modern-js/runtime';\n\nexport default defineRuntimeConfig({\n});\n",
|
|
18
|
+
"src/modern-app-env.d.ts": "/// <reference types='@modern-js/app-tools/types' />\n",
|
|
19
|
+
"src/routes/index.css": "html,\nbody {\n padding: 0;\n margin: 0;\n font-family: PingFang SC, Hiragino Sans GB, Microsoft YaHei, Arial, sans-serif;\n background: linear-gradient(to bottom, transparent, #fff) #eceeef;\n}\n\np {\n margin: 0;\n}\n\n* {\n -webkit-font-smoothing: antialiased;\n -moz-osx-font-smoothing: grayscale;\n box-sizing: border-box;\n}\n\n.container-box {\n min-height: 100vh;\n max-width: 100%;\n display: flex;\n flex-direction: column;\n justify-content: center;\n align-items: center;\n padding-top: 10px;\n}\n\nmain {\n flex: 1;\n display: flex;\n flex-direction: column;\n justify-content: center;\n align-items: center;\n}\n\n.title {\n display: flex;\n margin: 4rem 0 4rem;\n align-items: center;\n font-size: 4rem;\n font-weight: 600;\n}\n\n.logo {\n width: 6rem;\n margin: 7px 0 0 1rem;\n}\n\n.name {\n color: #4ecaff;\n}\n\n.description {\n text-align: center;\n line-height: 1.5;\n font-size: 1.3rem;\n color: #1b3a42;\n margin-bottom: 5rem;\n}\n\n.code {\n background: #fafafa;\n border-radius: 12px;\n padding: 0.6rem 0.9rem;\n font-size: 1.05rem;\n font-family:\n Menlo, Monaco, Lucida Console, Liberation Mono, DejaVu Sans Mono,\n Bitstream Vera Sans Mono, Courier New, monospace;\n}\n\n.container-box .grid {\n display: flex;\n align-items: center;\n justify-content: center;\n width: 1100px;\n margin-top: 3rem;\n}\n\n.card {\n padding: 1.5rem;\n display: flex;\n flex-direction: column;\n justify-content: center;\n height: 100px;\n color: inherit;\n text-decoration: none;\n transition: 0.15s ease;\n width: 45%;\n}\n\n.card:hover,\n.card:focus {\n transform: scale(1.05);\n}\n\n.card h2 {\n display: flex;\n align-items: center;\n font-size: 1.5rem;\n margin: 0;\n padding: 0;\n}\n\n.card p {\n opacity: 0.6;\n font-size: 0.9rem;\n line-height: 1.5;\n margin-top: 1rem;\n}\n\n.arrow-right {\n width: 1.3rem;\n margin-left: 0.5rem;\n margin-top: 3px;\n}\n",
|
|
20
|
+
"src/routes/layout.tsx": "import { Outlet } from '@modern-js/runtime/';\n\nexport default function Layout() {\n return (\n <div>\n <Outlet />\n </div>\n );\n}\n",
|
|
21
|
+
"src/routes/page.tsx": 'import { Helmet } from \'@modern-js/runtime/head\';\nimport \'./index.css\';\n\nconst Index = () => {\n\n return (\n <div className="container-box">\n <Helmet>\n <link\n rel="icon"\n type="image/x-icon"\n href="https://lf3-static.bytednsdoc.com/obj/eden-cn/uhbfnupenuhf/favicon.ico"\n />\n </Helmet>\n <main>\n <div className="title">\n Modern.js\n <img\n className="logo"\n src="https://lf3-static.bytednsdoc.com/obj/eden-cn/zq-uylkvT/ljhwZthlaukjlkulzlp/modern-js-logo.svg"\n alt="Modern.js Logo"\n />\n <p className="name">presetUltramodern</p>\n </div>\n <p className="description">\n This starter ships the public <code className="code">presetUltramodern(...)</code> profile. Start in\n <code className="code">modern.config.ts</code>, keep\n <code className="code">pnpm run ultramodern:check</code> green, and\n tune the generated preset only where your app needs a softer lane.\n </p>\n <div className="grid">\n <a\n href="https://modernjs.dev/en/guides/get-started/ultramodern.html"\n target="_blank"\n rel="noopener noreferrer"\n className="card"\n >\n <h2>\n presetUltramodern Guide\n <img\n className="arrow-right"\n src="https://lf3-static.bytednsdoc.com/obj/eden-cn/zq-uylkvT/ljhwZthlaukjlkulzlp/arrow-right.svg"\n alt="Guide"\n />\n </h2>\n <p>Review the MV-first, TanStack-ready, Effect-ready public preset.</p>\n </a>\n <a\n href="https://modernjs.dev/en/configure/app/usage.html"\n target="_blank"\n className="card"\n rel="noreferrer"\n >\n <h2>\n Configure presetUltramodern\n <img\n className="arrow-right"\n src="https://lf3-static.bytednsdoc.com/obj/eden-cn/zq-uylkvT/ljhwZthlaukjlkulzlp/arrow-right.svg"\n alt="Tutorials"\n />\n </h2>\n <p>Tune the generated defaults in <code className="code">modern.config.ts</code>.</p>\n </a>\n <a\n href="https://github.com/web-infra-dev/modern.js/blob/main/packages/toolkit/create/template/.github/workflows/ultramodern-gates.yml.handlebars"\n target="_blank"\n className="card"\n rel="noreferrer"\n >\n <h2>\n Ultramodern Gates\n <img\n className="arrow-right"\n src="https://lf3-static.bytednsdoc.com/obj/eden-cn/zq-uylkvT/ljhwZthlaukjlkulzlp/arrow-right.svg"\n alt="Config"\n />\n </h2>\n <p>The starter includes a PR workflow for <code className="code">ultramodern:check</code> and build.</p>\n </a>\n <a\n href="https://modernjs.dev/en/configure/app/bff/effect.html"\n target="_blank"\n rel="noopener noreferrer"\n className="card"\n >\n <h2>\n BFF + Effect\n <img\n className="arrow-right"\n src="https://lf3-static.bytednsdoc.com/obj/eden-cn/zq-uylkvT/ljhwZthlaukjlkulzlp/arrow-right.svg"\n alt="Github"\n />\n </h2>\n <p>Keep Effect as the preferred BFF lane while Hono stays an explicit fallback.</p>\n </a>\n </div>\n </main>\n </div>\n );\n};\n\nexport default Index;\n',
|
|
22
|
+
".github/workflows/ultramodern-gates.yml": "name: Ultramodern Gates\n\non:\n push:\n pull_request:\n\njobs:\n ultramodern-gates:\n runs-on: ubuntu-latest\n steps:\n - name: Checkout\n uses: actions/checkout@v4\n\n - name: Setup pnpm\n uses: pnpm/action-setup@v4\n\n - name: Setup Node.js\n uses: actions/setup-node@v4\n with:\n node-version: 20\n cache: pnpm\n\n - name: Install Dependencies\n run: pnpm install\n\n - name: Validate Ultramodern Contract\n run: pnpm run ultramodern:check\n\n - name: Build\n run: pnpm run build\n",
|
|
23
|
+
"shared/effect/api.ts": ""
|
|
24
|
+
};
|
|
25
|
+
export { MWAFiles };
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { type SandpackFiles, type SandpackSetup, type SandpackThemeProp } from '@codesandbox/sandpack-react';
|
|
2
|
+
export type ModernSandpackProps = {
|
|
3
|
+
template: 'web-app';
|
|
4
|
+
customSetup?: SandpackSetup;
|
|
5
|
+
files?: SandpackFiles;
|
|
6
|
+
removeFiles?: string[];
|
|
7
|
+
options?: Record<string, any>;
|
|
8
|
+
initialCollapsedFolder?: string[];
|
|
9
|
+
theme?: SandpackThemeProp;
|
|
10
|
+
activeFile?: string;
|
|
11
|
+
};
|
|
12
|
+
export default function ModernSandpack(props: ModernSandpackProps): import("react").JSX.Element;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
export declare const MWAFiles: {
|
|
2
|
+
".codesandbox/environment.json": string;
|
|
3
|
+
".codesandbox/tasks.json": string;
|
|
4
|
+
".browserslistrc": string;
|
|
5
|
+
".gitignore": string;
|
|
6
|
+
".npmrc": string;
|
|
7
|
+
"biome.json": string;
|
|
8
|
+
"modern.config.ts": string;
|
|
9
|
+
"package.json": string;
|
|
10
|
+
"postcss.config.mjs": string;
|
|
11
|
+
"tailwind.config.ts": string;
|
|
12
|
+
"tsconfig.json": string;
|
|
13
|
+
"scripts/validate-ultramodern.mjs": string;
|
|
14
|
+
"api/effect/index.ts": string;
|
|
15
|
+
"api/lambda/hello.ts": string;
|
|
16
|
+
"src/modern.runtime.ts": string;
|
|
17
|
+
"src/modern-app-env.d.ts": string;
|
|
18
|
+
"src/routes/index.css": string;
|
|
19
|
+
"src/routes/layout.tsx": string;
|
|
20
|
+
"src/routes/page.tsx": string;
|
|
21
|
+
".github/workflows/ultramodern-gates.yml": string;
|
|
22
|
+
"shared/effect/api.ts": string;
|
|
23
|
+
};
|
package/package.json
ADDED
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@bleedingdev/modern-js-sandpack-react",
|
|
3
|
+
"description": "A Progressive React Framework for modern web development.",
|
|
4
|
+
"homepage": "https://github.com/BleedingDev/ultramodern.js#readme",
|
|
5
|
+
"bugs": {
|
|
6
|
+
"url": "https://github.com/BleedingDev/ultramodern.js/issues"
|
|
7
|
+
},
|
|
8
|
+
"repository": {
|
|
9
|
+
"type": "git",
|
|
10
|
+
"url": "git+https://github.com/BleedingDev/ultramodern.js.git",
|
|
11
|
+
"directory": "packages/generator/sandpack-react"
|
|
12
|
+
},
|
|
13
|
+
"license": "MIT",
|
|
14
|
+
"keywords": [
|
|
15
|
+
"react",
|
|
16
|
+
"framework",
|
|
17
|
+
"modern",
|
|
18
|
+
"modern.js"
|
|
19
|
+
],
|
|
20
|
+
"version": "3.2.0-ultramodern.0",
|
|
21
|
+
"types": "./dist/types/index.d.ts",
|
|
22
|
+
"main": "./dist/cjs/index.js",
|
|
23
|
+
"module": "./dist/esm/index.mjs",
|
|
24
|
+
"exports": {
|
|
25
|
+
".": {
|
|
26
|
+
"types": "./dist/types/index.d.ts",
|
|
27
|
+
"default": "./dist/esm/index.mjs"
|
|
28
|
+
}
|
|
29
|
+
},
|
|
30
|
+
"typesVersions": {
|
|
31
|
+
"*": {
|
|
32
|
+
".": [
|
|
33
|
+
"./dist/types/index.d.ts"
|
|
34
|
+
]
|
|
35
|
+
}
|
|
36
|
+
},
|
|
37
|
+
"dependencies": {
|
|
38
|
+
"@codesandbox/sandpack-react": "^2.20.0",
|
|
39
|
+
"@swc/helpers": "^0.5.21",
|
|
40
|
+
"react": "^19.2.6",
|
|
41
|
+
"react-dom": "^19.2.6"
|
|
42
|
+
},
|
|
43
|
+
"devDependencies": {
|
|
44
|
+
"@rslib/core": "0.21.5",
|
|
45
|
+
"@types/node": "^25.8.0",
|
|
46
|
+
"@types/react": "^19.2.14",
|
|
47
|
+
"@types/react-dom": "^19.2.3",
|
|
48
|
+
"@types/recursive-readdir": "^2.2.4",
|
|
49
|
+
"@typescript/native-preview": "7.0.0-dev.20260516.1",
|
|
50
|
+
"recursive-readdir": "^2.2.3",
|
|
51
|
+
"@modern-js/create": "npm:@bleedingdev/modern-js-create@3.2.0-ultramodern.0"
|
|
52
|
+
},
|
|
53
|
+
"sideEffects": false,
|
|
54
|
+
"publishConfig": {
|
|
55
|
+
"registry": "https://registry.npmjs.org/",
|
|
56
|
+
"access": "public"
|
|
57
|
+
},
|
|
58
|
+
"scripts": {
|
|
59
|
+
"build": "node --disable-warning=ExperimentalWarning --experimental-strip-types scripts/template.mts && rslib build && pnpm -w tsgo:dts \"$PWD\"",
|
|
60
|
+
"dev": "rslib build --watch",
|
|
61
|
+
"test": "rstest --passWithNoTests"
|
|
62
|
+
}
|
|
63
|
+
}
|
package/rslib.config.mts
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://codesandbox.io/schemas/tasks.json",
|
|
3
|
+
"setupTasks": [
|
|
4
|
+
{
|
|
5
|
+
"name": "Installing Dependencies",
|
|
6
|
+
"command": "pnpm install"
|
|
7
|
+
}
|
|
8
|
+
],
|
|
9
|
+
"tasks": {
|
|
10
|
+
"start": {
|
|
11
|
+
"name": "Application",
|
|
12
|
+
"command": "pnpm run start",
|
|
13
|
+
"runAtStart": true,
|
|
14
|
+
"restartOn": {
|
|
15
|
+
"files": ["pnpm-lock.yaml"]
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
}
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
import { renderString } from '@modern-js/codesmith-api-handlebars';
|
|
2
|
+
import { fs } from '@modern-js/codesmith-utils/fs-extra';
|
|
3
|
+
import { createRequire } from 'module';
|
|
4
|
+
import path from 'path';
|
|
5
|
+
import recursive from 'recursive-readdir';
|
|
6
|
+
|
|
7
|
+
const require = createRequire(import.meta.url);
|
|
8
|
+
|
|
9
|
+
const IgnoreFiles = [
|
|
10
|
+
'.nvmrc',
|
|
11
|
+
'.vscode/extensions.json',
|
|
12
|
+
'.vscode/settings.json',
|
|
13
|
+
'.husky/pre-commit',
|
|
14
|
+
'README.md',
|
|
15
|
+
];
|
|
16
|
+
|
|
17
|
+
export async function handleTemplate(
|
|
18
|
+
templatePath: string,
|
|
19
|
+
data: Record<string, any> = {},
|
|
20
|
+
{ fileExtra, routerPrefix }: { fileExtra: string; routerPrefix: string } = {
|
|
21
|
+
fileExtra: '',
|
|
22
|
+
routerPrefix: '',
|
|
23
|
+
},
|
|
24
|
+
) {
|
|
25
|
+
const files: Record<string, string> = {};
|
|
26
|
+
const templateFiles = await recursive(templatePath);
|
|
27
|
+
templateFiles.forEach(filePath => {
|
|
28
|
+
const file = filePath.replace(`${templatePath}/`, '');
|
|
29
|
+
if (IgnoreFiles.includes(file)) {
|
|
30
|
+
return;
|
|
31
|
+
}
|
|
32
|
+
if (fs.statSync(filePath).isFile()) {
|
|
33
|
+
if (file.endsWith('.handlebars')) {
|
|
34
|
+
files[
|
|
35
|
+
`${routerPrefix}${file
|
|
36
|
+
.replace('.handlebars', fileExtra)
|
|
37
|
+
.replace('npmrc', '.npmrc')}`.replace('language', 'ts')
|
|
38
|
+
] = `${renderString(fs.readFileSync(filePath, 'utf-8'), data)}`;
|
|
39
|
+
} else {
|
|
40
|
+
files[`${routerPrefix}${file}`] = `${fs.readFileSync(
|
|
41
|
+
filePath,
|
|
42
|
+
'utf-8',
|
|
43
|
+
)}`;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
});
|
|
47
|
+
return files;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
async function handleCodesandboxTemplate() {
|
|
51
|
+
const templateDir = path.join(import.meta.dirname, 'codesandbox');
|
|
52
|
+
const files: Record<string, string> = {
|
|
53
|
+
...(await handleTemplate(templateDir)),
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
return files;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
async function handleCreateTemplate() {
|
|
60
|
+
const createPackageMainPath = require.resolve('@modern-js/create');
|
|
61
|
+
const createPackagePath = path.dirname(path.dirname(createPackageMainPath));
|
|
62
|
+
const createPackageJsonPath = path.join(createPackagePath, 'package.json');
|
|
63
|
+
|
|
64
|
+
const templateDir = path.join(createPackagePath, 'template');
|
|
65
|
+
|
|
66
|
+
const createPackageJson = JSON.parse(
|
|
67
|
+
fs.readFileSync(createPackageJsonPath, 'utf-8'),
|
|
68
|
+
);
|
|
69
|
+
const version = createPackageJson.version || '3.0.0';
|
|
70
|
+
|
|
71
|
+
const files = await handleTemplate(templateDir, {
|
|
72
|
+
packageName: 'modern-app',
|
|
73
|
+
version,
|
|
74
|
+
});
|
|
75
|
+
|
|
76
|
+
return files;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
async function main() {
|
|
80
|
+
const codesandboxFiles = await handleCodesandboxTemplate();
|
|
81
|
+
const createFiles = await handleCreateTemplate();
|
|
82
|
+
const srcTemplatesDir = path.join(import.meta.dirname, '..', 'src/templates');
|
|
83
|
+
const commonFiles = { ...codesandboxFiles };
|
|
84
|
+
fs.writeFileSync(
|
|
85
|
+
path.join(srcTemplatesDir, 'common.ts'),
|
|
86
|
+
`export const commonFiles = ${JSON.stringify(commonFiles, null, 2)};`,
|
|
87
|
+
'utf-8',
|
|
88
|
+
);
|
|
89
|
+
const mwaFiles = createFiles;
|
|
90
|
+
fs.writeFileSync(
|
|
91
|
+
path.join(srcTemplatesDir, 'mwa.ts'),
|
|
92
|
+
`import { commonFiles } from './common';
|
|
93
|
+
|
|
94
|
+
export const MWAFiles = {
|
|
95
|
+
...commonFiles,
|
|
96
|
+
...${JSON.stringify(mwaFiles, null, 2)}
|
|
97
|
+
};`,
|
|
98
|
+
'utf-8',
|
|
99
|
+
);
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
main().catch(e => {
|
|
103
|
+
console.error(e);
|
|
104
|
+
process.exit(1);
|
|
105
|
+
});
|