@modern-js/sandpack-react 2.69.4 → 3.0.0-alpha.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.
@@ -1,113 +0,0 @@
1
- import { _ as _object_spread } from "@swc/helpers/_/_object_spread";
2
- import { commonFiles } from "./common";
3
- var MWAFiles = _object_spread({}, commonFiles, {
4
- "README.md": "# Modern.js App\n\n## Setup\n\nInstall the dependencies:\n\n```bash\npnpm install\n```\n\n## Get Started\n\nStart the dev server:\n\n```bash\npnpm dev\n```\n\nEnable optional features or add a new entry:\n\n```bash\npnpm new\n```\n\nBuild the app for production:\n\n```bash\npnpm build\n```\n\nPreview the production build locally:\n\n```bash\npnpm serve\n```\n\nFor more information, see the [Modern.js documentation](https://modernjs.dev/en).\n",
5
- ".browserslistrc": "chrome >= 51\nedge >= 15\nfirefox >= 54\nsafari >= 10\nios_saf >= 10\n",
6
- "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 "start": "modern start",\n "serve": "modern serve",\n "new": "modern new",\n "lint": "biome check",\n "prepare": "simple-git-hooks",\n "upgrade": "modern upgrade"\n },\n "engines": {\n "node": ">=16.18.1"\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": "2.69.3",\n "react": "^18.3.1",\n "react-dom": "^18.3.1"\n },\n "devDependencies": {\n "@modern-js/app-tools": "2.69.3",\n "@modern-js/tsconfig": "2.69.3",\n "@biomejs/biome": "1.9.4",\n "typescript": "~5.7.3",\n "@types/jest": "~29.2.4",\n "@types/node": "~18.11.9",\n "@types/react": "^18.3.11",\n "@types/react-dom": "~18.3.1",\n "lint-staged": "~15.4.0",\n "simple-git-hooks": "^2.11.1",\n "rimraf": "^6.0.1"\n }\n}\n',
7
- "modern.config.ts": "import { appTools, defineConfig } from '@modern-js/app-tools';\n\n// https://modernjs.dev/en/configure/app/usage\nexport default defineConfig({\n runtime: {\n router: true,\n },\n plugins: [\n appTools({\n bundler: \n }),\n ],\n});\n",
8
- "tsconfig.json": '{\n "extends": "@modern-js/tsconfig/base",\n "compilerOptions": {\n "declaration": false,\n "jsx": "preserve",\n "baseUrl": "./",\n "paths": {\n "@/*": ["./src/*"],\n "@shared/*": ["./shared/*"]\n }\n },\n "include": ["src", "shared", "config", "modern.config.ts"],\n "exclude": ["**/node_modules"]\n}\n',
9
- "src/modern-app-env.d.ts": "/// <reference types='@modern-js/app-tools/types' />\n/// <reference types='@modern-js/runtime/types' />\n/// <reference types='@modern-js/runtime/types/router' />\n",
10
- "src/modern.runtime.ts": "import { defineRuntimeConfig } from '@modern-js/runtime';\n\nexport default defineRuntimeConfig({});\n",
11
- "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",
12
- "src/routes/layout.tsx": "import { Outlet } from '@modern-js/runtime/router';\n\nexport default function Layout() {\n return (\n <div>\n <Outlet />\n </div>\n );\n}\n",
13
- "src/routes/page.tsx": `import { Helmet } from '@modern-js/runtime/head';
14
- import './index.css';
15
-
16
- const Index = () => (
17
- <div className="container-box">
18
- <Helmet>
19
- <link
20
- rel="icon"
21
- type="image/x-icon"
22
- href="https://lf3-static.bytednsdoc.com/obj/eden-cn/uhbfnupenuhf/favicon.ico"
23
- />
24
- </Helmet>
25
- <main>
26
- <div className="title">
27
- Welcome to
28
- <img
29
- className="logo"
30
- src="https://lf3-static.bytednsdoc.com/obj/eden-cn/zq-uylkvT/ljhwZthlaukjlkulzlp/modern-js-logo.svg"
31
- alt="Modern.js Logo"
32
- />
33
- <p className="name">Modern.js</p>
34
- </div>
35
- <p className="description">
36
- Get started by editing <code className="code">src/routes/page.tsx</code>
37
- </p>
38
- <div className="grid">
39
- <a
40
- href="https://modernjs.dev/guides/get-started/introduction.html"
41
- target="_blank"
42
- rel="noopener noreferrer"
43
- className="card"
44
- >
45
- <h2>
46
- Guide
47
- <img
48
- className="arrow-right"
49
- src="https://lf3-static.bytednsdoc.com/obj/eden-cn/zq-uylkvT/ljhwZthlaukjlkulzlp/arrow-right.svg"
50
- alt="Guide"
51
- />
52
- </h2>
53
- <p>Follow the guides to use all features of Modern.js.</p>
54
- </a>
55
- <a
56
- href="https://modernjs.dev/tutorials/foundations/introduction.html"
57
- target="_blank"
58
- className="card"
59
- rel="noreferrer"
60
- >
61
- <h2>
62
- Tutorials
63
- <img
64
- className="arrow-right"
65
- src="https://lf3-static.bytednsdoc.com/obj/eden-cn/zq-uylkvT/ljhwZthlaukjlkulzlp/arrow-right.svg"
66
- alt="Tutorials"
67
- />
68
- </h2>
69
- <p>Learn to use Modern.js to create your first application.</p>
70
- </a>
71
- <a
72
- href="https://modernjs.dev/configure/app/usage.html"
73
- target="_blank"
74
- className="card"
75
- rel="noreferrer"
76
- >
77
- <h2>
78
- Config
79
- <img
80
- className="arrow-right"
81
- src="https://lf3-static.bytednsdoc.com/obj/eden-cn/zq-uylkvT/ljhwZthlaukjlkulzlp/arrow-right.svg"
82
- alt="Config"
83
- />
84
- </h2>
85
- <p>Find all configuration options provided by Modern.js.</p>
86
- </a>
87
- <a
88
- href="https://github.com/web-infra-dev/modern.js"
89
- target="_blank"
90
- rel="noopener noreferrer"
91
- className="card"
92
- >
93
- <h2>
94
- GitHub
95
- <img
96
- className="arrow-right"
97
- src="https://lf3-static.bytednsdoc.com/obj/eden-cn/zq-uylkvT/ljhwZthlaukjlkulzlp/arrow-right.svg"
98
- alt="Github"
99
- />
100
- </h2>
101
- <p>View the source code on GitHub; feel free to contribute.</p>
102
- </a>
103
- </div>
104
- </main>
105
- </div>
106
- );
107
-
108
- export default Index;
109
- `
110
- });
111
- export {
112
- MWAFiles
113
- };
@@ -1,66 +0,0 @@
1
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
- import { OpenInCodeSandboxButton, SandpackCodeEditor, SandpackFileExplorer, SandpackLayout, SandpackProvider } from "@codesandbox/sandpack-react";
3
- import { ModernTemplates } from "./templates";
4
- function fileterFiles(files, removeFiles) {
5
- if (removeFiles.length === 0) {
6
- return files;
7
- }
8
- const result = {};
9
- Object.keys(files).forEach((filename) => {
10
- if (!removeFiles.includes(filename)) {
11
- result[filename] = files[filename];
12
- }
13
- });
14
- return result;
15
- }
16
- function ModernSandpack(props) {
17
- const { template, customSetup = {}, files: customFiles = {}, removeFiles = [], options = {}, initialCollapsedFolder = [], activeFile = "src/routes/page.tsx", theme = "light" } = props;
18
- const initFiles = ModernTemplates[template];
19
- const files = {
20
- ...fileterFiles(initFiles, removeFiles),
21
- ...fileterFiles(customFiles, removeFiles)
22
- };
23
- return /* @__PURE__ */ _jsx(SandpackProvider, {
24
- theme,
25
- customSetup: {
26
- environment: "node",
27
- ...customSetup
28
- },
29
- files,
30
- options: {
31
- activeFile,
32
- visibleFiles: Object.keys(customFiles).filter((file) => !removeFiles.includes(file)),
33
- ...options
34
- },
35
- children: /* @__PURE__ */ _jsxs(SandpackLayout, {
36
- children: [
37
- /* @__PURE__ */ _jsx(SandpackFileExplorer, {
38
- autoHiddenFiles: true,
39
- initialCollapsedFolder: [
40
- "/.husky/",
41
- "/.vscode/",
42
- "/.codesandbox/",
43
- ...initialCollapsedFolder
44
- ]
45
- }),
46
- /* @__PURE__ */ _jsx(SandpackCodeEditor, {
47
- showLineNumbers: true,
48
- showInlineErrors: true,
49
- readOnly: true,
50
- showTabs: false
51
- }),
52
- /* @__PURE__ */ _jsx("div", {
53
- style: {
54
- position: "absolute",
55
- right: "5px",
56
- bottom: "5px"
57
- },
58
- children: /* @__PURE__ */ _jsx(OpenInCodeSandboxButton, {})
59
- })
60
- ]
61
- })
62
- });
63
- }
64
- export {
65
- ModernSandpack as default
66
- };
@@ -1,10 +0,0 @@
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
- ".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",
5
- "biome.json": '{\n "$schema": "https://biomejs.dev/schemas/1.9.4/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 "organizeImports": {\n "enabled": true\n },\n "files": {\n "ignoreUnknown": true,\n "ignore": [".vscode/**/*", "node_modules/**/*", "dist/**/*"]\n }\n}\n',
6
- ".npmrc": "strict-peer-dependencies=false\n"
7
- };
8
- export {
9
- commonFiles
10
- };
@@ -1,7 +0,0 @@
1
- const { MWAFiles } = require("./mwa");
2
- const ModernTemplates = {
3
- "web-app": MWAFiles
4
- };
5
- export {
6
- ModernTemplates
7
- };
@@ -1,115 +0,0 @@
1
- import { commonFiles } from "./common";
2
- const MWAFiles = {
3
- ...commonFiles,
4
- ...{
5
- "README.md": "# Modern.js App\n\n## Setup\n\nInstall the dependencies:\n\n```bash\npnpm install\n```\n\n## Get Started\n\nStart the dev server:\n\n```bash\npnpm dev\n```\n\nEnable optional features or add a new entry:\n\n```bash\npnpm new\n```\n\nBuild the app for production:\n\n```bash\npnpm build\n```\n\nPreview the production build locally:\n\n```bash\npnpm serve\n```\n\nFor more information, see the [Modern.js documentation](https://modernjs.dev/en).\n",
6
- ".browserslistrc": "chrome >= 51\nedge >= 15\nfirefox >= 54\nsafari >= 10\nios_saf >= 10\n",
7
- "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 "start": "modern start",\n "serve": "modern serve",\n "new": "modern new",\n "lint": "biome check",\n "prepare": "simple-git-hooks",\n "upgrade": "modern upgrade"\n },\n "engines": {\n "node": ">=16.18.1"\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": "2.69.3",\n "react": "^18.3.1",\n "react-dom": "^18.3.1"\n },\n "devDependencies": {\n "@modern-js/app-tools": "2.69.3",\n "@modern-js/tsconfig": "2.69.3",\n "@biomejs/biome": "1.9.4",\n "typescript": "~5.7.3",\n "@types/jest": "~29.2.4",\n "@types/node": "~18.11.9",\n "@types/react": "^18.3.11",\n "@types/react-dom": "~18.3.1",\n "lint-staged": "~15.4.0",\n "simple-git-hooks": "^2.11.1",\n "rimraf": "^6.0.1"\n }\n}\n',
8
- "modern.config.ts": "import { appTools, defineConfig } from '@modern-js/app-tools';\n\n// https://modernjs.dev/en/configure/app/usage\nexport default defineConfig({\n runtime: {\n router: true,\n },\n plugins: [\n appTools({\n bundler: \n }),\n ],\n});\n",
9
- "tsconfig.json": '{\n "extends": "@modern-js/tsconfig/base",\n "compilerOptions": {\n "declaration": false,\n "jsx": "preserve",\n "baseUrl": "./",\n "paths": {\n "@/*": ["./src/*"],\n "@shared/*": ["./shared/*"]\n }\n },\n "include": ["src", "shared", "config", "modern.config.ts"],\n "exclude": ["**/node_modules"]\n}\n',
10
- "src/modern-app-env.d.ts": "/// <reference types='@modern-js/app-tools/types' />\n/// <reference types='@modern-js/runtime/types' />\n/// <reference types='@modern-js/runtime/types/router' />\n",
11
- "src/modern.runtime.ts": "import { defineRuntimeConfig } from '@modern-js/runtime';\n\nexport default defineRuntimeConfig({});\n",
12
- "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",
13
- "src/routes/layout.tsx": "import { Outlet } from '@modern-js/runtime/router';\n\nexport default function Layout() {\n return (\n <div>\n <Outlet />\n </div>\n );\n}\n",
14
- "src/routes/page.tsx": `import { Helmet } from '@modern-js/runtime/head';
15
- import './index.css';
16
-
17
- const Index = () => (
18
- <div className="container-box">
19
- <Helmet>
20
- <link
21
- rel="icon"
22
- type="image/x-icon"
23
- href="https://lf3-static.bytednsdoc.com/obj/eden-cn/uhbfnupenuhf/favicon.ico"
24
- />
25
- </Helmet>
26
- <main>
27
- <div className="title">
28
- Welcome to
29
- <img
30
- className="logo"
31
- src="https://lf3-static.bytednsdoc.com/obj/eden-cn/zq-uylkvT/ljhwZthlaukjlkulzlp/modern-js-logo.svg"
32
- alt="Modern.js Logo"
33
- />
34
- <p className="name">Modern.js</p>
35
- </div>
36
- <p className="description">
37
- Get started by editing <code className="code">src/routes/page.tsx</code>
38
- </p>
39
- <div className="grid">
40
- <a
41
- href="https://modernjs.dev/guides/get-started/introduction.html"
42
- target="_blank"
43
- rel="noopener noreferrer"
44
- className="card"
45
- >
46
- <h2>
47
- Guide
48
- <img
49
- className="arrow-right"
50
- src="https://lf3-static.bytednsdoc.com/obj/eden-cn/zq-uylkvT/ljhwZthlaukjlkulzlp/arrow-right.svg"
51
- alt="Guide"
52
- />
53
- </h2>
54
- <p>Follow the guides to use all features of Modern.js.</p>
55
- </a>
56
- <a
57
- href="https://modernjs.dev/tutorials/foundations/introduction.html"
58
- target="_blank"
59
- className="card"
60
- rel="noreferrer"
61
- >
62
- <h2>
63
- Tutorials
64
- <img
65
- className="arrow-right"
66
- src="https://lf3-static.bytednsdoc.com/obj/eden-cn/zq-uylkvT/ljhwZthlaukjlkulzlp/arrow-right.svg"
67
- alt="Tutorials"
68
- />
69
- </h2>
70
- <p>Learn to use Modern.js to create your first application.</p>
71
- </a>
72
- <a
73
- href="https://modernjs.dev/configure/app/usage.html"
74
- target="_blank"
75
- className="card"
76
- rel="noreferrer"
77
- >
78
- <h2>
79
- Config
80
- <img
81
- className="arrow-right"
82
- src="https://lf3-static.bytednsdoc.com/obj/eden-cn/zq-uylkvT/ljhwZthlaukjlkulzlp/arrow-right.svg"
83
- alt="Config"
84
- />
85
- </h2>
86
- <p>Find all configuration options provided by Modern.js.</p>
87
- </a>
88
- <a
89
- href="https://github.com/web-infra-dev/modern.js"
90
- target="_blank"
91
- rel="noopener noreferrer"
92
- className="card"
93
- >
94
- <h2>
95
- GitHub
96
- <img
97
- className="arrow-right"
98
- src="https://lf3-static.bytednsdoc.com/obj/eden-cn/zq-uylkvT/ljhwZthlaukjlkulzlp/arrow-right.svg"
99
- alt="Github"
100
- />
101
- </h2>
102
- <p>View the source code on GitHub; feel free to contribute.</p>
103
- </a>
104
- </div>
105
- </main>
106
- </div>
107
- );
108
-
109
- export default Index;
110
- `
111
- }
112
- };
113
- export {
114
- MWAFiles
115
- };