create-mettle-app 1.1.0 → 1.2.1
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/index.js +3 -13
- package/package.json +1 -1
- package/template-mettle/index.html +12 -10
- package/template-mettle/package.json +4 -6
- package/{template-mettle-jsx → template-mettle}/src/components/list.jsx +2 -5
- package/template-mettle/src/main.jsx +18 -0
- package/{template-mettle-jsx → template-mettle}/src/template/home.jsx +2 -7
- package/template-mettle/vite.config.js +2 -10
- package/template-mettle-apps/index.html +12 -10
- package/template-mettle-apps/package.json +5 -7
- package/template-mettle-apps/src/main.jsx +8 -0
- package/template-mettle-apps/src/router/index.js +21 -21
- package/template-mettle-apps/src/template/about.jsx +20 -0
- package/template-mettle-apps/src/template/home.jsx +40 -0
- package/template-mettle-apps/vite.config.js +2 -10
- package/template-mettle-apps-ts/README.md +1 -0
- package/{template-mettle-tsx-apps → template-mettle-apps-ts}/package.json +4 -4
- package/template-mettle-apps-ts/src/main.tsx +8 -0
- package/{template-mettle-tsx-apps → template-mettle-apps-ts}/src/router/index.ts +4 -4
- package/template-mettle-apps-ts/src/template/about.tsx +20 -0
- package/template-mettle-apps-ts/src/template/home.tsx +40 -0
- package/template-mettle-ts/README.md +1 -0
- package/{template-mettle-tsx → template-mettle-ts}/package.json +3 -3
- package/{template-mettle-tsx → template-mettle-ts}/src/components/list.tsx +2 -6
- package/template-mettle-ts/src/main.tsx +18 -0
- package/{template-mettle-tsx → template-mettle-ts}/src/template/home.tsx +2 -8
- package/template-mettle/babel.config.cjs +0 -3
- package/template-mettle/src/components/list.js +0 -43
- package/template-mettle/src/main.js +0 -20
- package/template-mettle/src/template/home.js +0 -22
- package/template-mettle-apps/babel.config.cjs +0 -3
- package/template-mettle-apps/src/main.js +0 -12
- package/template-mettle-apps/src/template/about.js +0 -23
- package/template-mettle-apps/src/template/home.js +0 -42
- package/template-mettle-jsx/README.md +0 -1
- package/template-mettle-jsx/index.html +0 -15
- package/template-mettle-jsx/package.json +0 -17
- package/template-mettle-jsx/src/main.jsx +0 -21
- package/template-mettle-jsx/vite.config.js +0 -6
- package/template-mettle-jsx-apps/README.md +0 -1
- package/template-mettle-jsx-apps/index.html +0 -15
- package/template-mettle-jsx-apps/package.json +0 -18
- package/template-mettle-jsx-apps/src/main.jsx +0 -12
- package/template-mettle-jsx-apps/src/router/index.js +0 -21
- package/template-mettle-jsx-apps/src/template/about.jsx +0 -24
- package/template-mettle-jsx-apps/src/template/home.jsx +0 -44
- package/template-mettle-jsx-apps/vite.config.js +0 -6
- package/template-mettle-tsx/README.md +0 -1
- package/template-mettle-tsx/_gitignore +0 -25
- package/template-mettle-tsx/src/main.tsx +0 -21
- package/template-mettle-tsx/src/style/app.css +0 -14
- package/template-mettle-tsx/src/style/list.module.css +0 -27
- package/template-mettle-tsx-apps/README.md +0 -1
- package/template-mettle-tsx-apps/_gitignore +0 -25
- package/template-mettle-tsx-apps/src/main.tsx +0 -12
- package/template-mettle-tsx-apps/src/styles/app.css +0 -7
- package/template-mettle-tsx-apps/src/template/about.tsx +0 -24
- package/template-mettle-tsx-apps/src/template/home.tsx +0 -45
- /package/{template-mettle-jsx-apps → template-mettle-apps-ts}/_gitignore +0 -0
- /package/{template-mettle-tsx-apps → template-mettle-apps-ts}/index.html +0 -0
- /package/{template-mettle-jsx-apps → template-mettle-apps-ts}/src/styles/app.css +0 -0
- /package/{template-mettle-tsx-apps → template-mettle-apps-ts}/src/vite-env.d.ts +0 -0
- /package/{template-mettle-tsx-apps → template-mettle-apps-ts}/tsconfig.json +0 -0
- /package/{template-mettle-tsx-apps → template-mettle-apps-ts}/vite.config.ts +0 -0
- /package/{template-mettle-jsx → template-mettle-ts}/_gitignore +0 -0
- /package/{template-mettle-tsx → template-mettle-ts}/index.html +0 -0
- /package/{template-mettle-jsx → template-mettle-ts}/src/style/app.css +0 -0
- /package/{template-mettle-jsx → template-mettle-ts}/src/style/list.module.css +0 -0
- /package/{template-mettle-tsx → template-mettle-ts}/src/vite-env.d.ts +0 -0
- /package/{template-mettle-tsx → template-mettle-ts}/tsconfig.json +0 -0
- /package/{template-mettle-tsx → template-mettle-ts}/vite.config.ts +0 -0
package/index.js
CHANGED
|
@@ -16,30 +16,20 @@ const FRAMEWORKS = [
|
|
|
16
16
|
{
|
|
17
17
|
name: 'mettle',
|
|
18
18
|
display: 'JavaScript',
|
|
19
|
-
color: lightYellow,
|
|
20
|
-
},
|
|
21
|
-
{
|
|
22
|
-
name: 'mettle-apps',
|
|
23
|
-
display: 'JavaScript',
|
|
24
|
-
color: lightYellow,
|
|
25
|
-
},
|
|
26
|
-
{
|
|
27
|
-
name: 'mettle-jsx',
|
|
28
|
-
display: 'JavaScript',
|
|
29
19
|
color: cyan,
|
|
30
20
|
},
|
|
31
21
|
{
|
|
32
|
-
name: 'mettle-
|
|
22
|
+
name: 'mettle-apps',
|
|
33
23
|
display: 'JavaScript',
|
|
34
24
|
color: cyan,
|
|
35
25
|
},
|
|
36
26
|
{
|
|
37
|
-
name: 'mettle-
|
|
27
|
+
name: 'mettle-ts',
|
|
38
28
|
display: 'TypeScript',
|
|
39
29
|
color: blue,
|
|
40
30
|
},
|
|
41
31
|
{
|
|
42
|
-
name: 'mettle-
|
|
32
|
+
name: 'mettle-apps-ts',
|
|
43
33
|
display: 'TypeScript',
|
|
44
34
|
color: blue,
|
|
45
35
|
},
|
package/package.json
CHANGED
|
@@ -1,13 +1,15 @@
|
|
|
1
1
|
<!DOCTYPE html>
|
|
2
2
|
<html lang="en">
|
|
3
|
-
<head>
|
|
4
|
-
<meta charset="UTF-8" />
|
|
5
|
-
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
6
|
-
<title>create-mettle-app</title>
|
|
7
|
-
</head>
|
|
8
3
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
</
|
|
13
|
-
</
|
|
4
|
+
<head>
|
|
5
|
+
<meta charset="UTF-8" />
|
|
6
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
7
|
+
<title>create-mettle-app</title>
|
|
8
|
+
</head>
|
|
9
|
+
|
|
10
|
+
<body>
|
|
11
|
+
<div id="app"></div>
|
|
12
|
+
<script type="module" src="/src/main.jsx"></script>
|
|
13
|
+
</body>
|
|
14
|
+
|
|
15
|
+
</html>
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"name": "template
|
|
2
|
+
"name": "template",
|
|
3
3
|
"version": "0.0.0",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"scripts": {
|
|
@@ -8,12 +8,10 @@
|
|
|
8
8
|
"build": "vite build"
|
|
9
9
|
},
|
|
10
10
|
"devDependencies": {
|
|
11
|
-
"
|
|
12
|
-
"
|
|
13
|
-
"vite": "^4.0.0",
|
|
14
|
-
"vite-plugin-babel": "^1.1.3"
|
|
11
|
+
"vite": "^6.1.0",
|
|
12
|
+
"vite-plugin-mettle": "^1.0.0"
|
|
15
13
|
},
|
|
16
14
|
"dependencies": {
|
|
17
|
-
"mettle": "^
|
|
15
|
+
"mettle": "^1.1.0"
|
|
18
16
|
}
|
|
19
17
|
}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import { defineComponent } from 'mettle';
|
|
2
1
|
import style from '../style/list.module.css';
|
|
3
2
|
|
|
4
|
-
|
|
3
|
+
export default function List({ setData }) {
|
|
5
4
|
const listState = {
|
|
6
5
|
arr: [1, 2],
|
|
7
6
|
};
|
|
@@ -39,6 +38,4 @@ const List = defineComponent(({ setData }) => {
|
|
|
39
38
|
</ul>
|
|
40
39
|
</fragment>
|
|
41
40
|
);
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
export default List;
|
|
41
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { createApp } from 'mettle';
|
|
2
|
+
import Home from './template/home';
|
|
3
|
+
import List from './components/list';
|
|
4
|
+
import './style/app.css';
|
|
5
|
+
|
|
6
|
+
function App() {
|
|
7
|
+
return () => (
|
|
8
|
+
<div class='inner'>
|
|
9
|
+
<h1>Hello mettle.js</h1>
|
|
10
|
+
<div class='app-tool'>
|
|
11
|
+
<Home/>
|
|
12
|
+
<List/>
|
|
13
|
+
</div>
|
|
14
|
+
</div>
|
|
15
|
+
);
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
createApp(<App />, '#app');
|
|
@@ -1,6 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
const Home = defineComponent(({ setData }) => {
|
|
1
|
+
export default function Home({ setData }) {
|
|
4
2
|
let count = 0;
|
|
5
3
|
|
|
6
4
|
function add() {
|
|
@@ -8,7 +6,6 @@ const Home = defineComponent(({ setData }) => {
|
|
|
8
6
|
count++;
|
|
9
7
|
});
|
|
10
8
|
}
|
|
11
|
-
|
|
12
9
|
return () => (
|
|
13
10
|
<fragment>
|
|
14
11
|
<button onClick={add}>Add</button>
|
|
@@ -16,6 +13,4 @@ const Home = defineComponent(({ setData }) => {
|
|
|
16
13
|
<input value={count} />
|
|
17
14
|
</fragment>
|
|
18
15
|
);
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
export default Home;
|
|
16
|
+
}
|
|
@@ -1,14 +1,6 @@
|
|
|
1
1
|
import { defineConfig } from 'vite';
|
|
2
|
-
import
|
|
2
|
+
import mettle from 'vite-plugin-mettle';
|
|
3
3
|
|
|
4
4
|
export default defineConfig({
|
|
5
|
-
|
|
6
|
-
server: {
|
|
7
|
-
strictPort: true,
|
|
8
|
-
port: 3002,
|
|
9
|
-
},
|
|
10
|
-
plugins: [
|
|
11
|
-
// Babel will try to pick up Babel config files (.babelrc or .babelrc.json)
|
|
12
|
-
babel(),
|
|
13
|
-
],
|
|
5
|
+
plugins: [mettle()],
|
|
14
6
|
});
|
|
@@ -1,13 +1,15 @@
|
|
|
1
1
|
<!DOCTYPE html>
|
|
2
2
|
<html lang="en">
|
|
3
|
-
<head>
|
|
4
|
-
<meta charset="UTF-8" />
|
|
5
|
-
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
6
|
-
<title>create-mettle-app</title>
|
|
7
|
-
</head>
|
|
8
3
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
</
|
|
13
|
-
</
|
|
4
|
+
<head>
|
|
5
|
+
<meta charset="UTF-8" />
|
|
6
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
7
|
+
<title>create-mettle-app</title>
|
|
8
|
+
</head>
|
|
9
|
+
|
|
10
|
+
<body>
|
|
11
|
+
<div id="app"></div>
|
|
12
|
+
<script type="module" src="/src/main.jsx"></script>
|
|
13
|
+
</body>
|
|
14
|
+
|
|
15
|
+
</html>
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"name": "template
|
|
2
|
+
"name": "template",
|
|
3
3
|
"version": "0.0.0",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"scripts": {
|
|
@@ -8,13 +8,11 @@
|
|
|
8
8
|
"build": "vite build"
|
|
9
9
|
},
|
|
10
10
|
"devDependencies": {
|
|
11
|
-
"
|
|
12
|
-
"
|
|
13
|
-
"vite": "^4.0.0",
|
|
14
|
-
"vite-plugin-babel": "^1.1.3"
|
|
11
|
+
"vite": "^6.1.0",
|
|
12
|
+
"vite-plugin-mettle": "^1.0.0"
|
|
15
13
|
},
|
|
16
14
|
"dependencies": {
|
|
17
|
-
"mettle": "^
|
|
18
|
-
"mettle-router": "^0.
|
|
15
|
+
"mettle": "^1.1.0",
|
|
16
|
+
"mettle-router": "^0.6.0"
|
|
19
17
|
}
|
|
20
18
|
}
|
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
import { resetView } from 'mettle';
|
|
2
|
-
import { initRouter } from 'mettle-router';
|
|
3
|
-
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
|
|
7
|
-
const router = initRouter(
|
|
8
|
-
[
|
|
9
|
-
{
|
|
10
|
-
path: '/',
|
|
11
|
-
template:
|
|
12
|
-
},
|
|
13
|
-
{
|
|
14
|
-
path: '/about',
|
|
15
|
-
template:
|
|
16
|
-
},
|
|
17
|
-
],
|
|
18
|
-
resetView
|
|
19
|
-
);
|
|
20
|
-
|
|
21
|
-
export default router;
|
|
1
|
+
import { resetView } from 'mettle';
|
|
2
|
+
import { initRouter } from 'mettle-router';
|
|
3
|
+
|
|
4
|
+
import Home from '../template/home';
|
|
5
|
+
import About from '../template/about';
|
|
6
|
+
|
|
7
|
+
const router = initRouter(
|
|
8
|
+
[
|
|
9
|
+
{
|
|
10
|
+
path: '/',
|
|
11
|
+
template: Home,
|
|
12
|
+
},
|
|
13
|
+
{
|
|
14
|
+
path: '/about',
|
|
15
|
+
template: About,
|
|
16
|
+
},
|
|
17
|
+
],
|
|
18
|
+
resetView
|
|
19
|
+
);
|
|
20
|
+
|
|
21
|
+
export default router;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { linkTo, toParse } from 'mettle-router';
|
|
2
|
+
|
|
3
|
+
export default function About() {
|
|
4
|
+
function goHome() {
|
|
5
|
+
linkTo({
|
|
6
|
+
path: '/',
|
|
7
|
+
});
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
function getOption() {
|
|
11
|
+
console.log(toParse());
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
return () => (
|
|
15
|
+
<fragment>
|
|
16
|
+
<button onClick={goHome}>goHome</button>
|
|
17
|
+
<h1 onClick={getOption}>About</h1>
|
|
18
|
+
</fragment>
|
|
19
|
+
);
|
|
20
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { linkTo } from 'mettle-router';
|
|
2
|
+
|
|
3
|
+
export default function Home({ setData }) {
|
|
4
|
+
const state = {
|
|
5
|
+
msg: 'hello',
|
|
6
|
+
arr: [1, 2],
|
|
7
|
+
count: 3,
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
function goAbout() {
|
|
11
|
+
linkTo({
|
|
12
|
+
path: '/about',
|
|
13
|
+
query: {
|
|
14
|
+
id: 1,
|
|
15
|
+
name: 'maomin',
|
|
16
|
+
},
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
function useChange() {
|
|
21
|
+
setData(() => {
|
|
22
|
+
state.msg = 'world';
|
|
23
|
+
state.count++;
|
|
24
|
+
state.arr.unshift(state.count);
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
return () => (
|
|
29
|
+
<fragment>
|
|
30
|
+
<button onClick={goAbout}>goAbout</button>
|
|
31
|
+
<h1>Home</h1>
|
|
32
|
+
<p onClick={useChange}>{state.msg}</p>
|
|
33
|
+
<ul>
|
|
34
|
+
{state.arr.map((item) => (
|
|
35
|
+
<li key={item}>{item}</li>
|
|
36
|
+
))}
|
|
37
|
+
</ul>
|
|
38
|
+
</fragment>
|
|
39
|
+
);
|
|
40
|
+
}
|
|
@@ -1,14 +1,6 @@
|
|
|
1
1
|
import { defineConfig } from 'vite';
|
|
2
|
-
import
|
|
2
|
+
import mettle from 'vite-plugin-mettle';
|
|
3
3
|
|
|
4
4
|
export default defineConfig({
|
|
5
|
-
|
|
6
|
-
server: {
|
|
7
|
-
strictPort: true,
|
|
8
|
-
port: 3002,
|
|
9
|
-
},
|
|
10
|
-
plugins: [
|
|
11
|
-
// Babel will try to pick up Babel config files (.babelrc or .babelrc.json)
|
|
12
|
-
babel(),
|
|
13
|
-
],
|
|
5
|
+
plugins: [mettle()],
|
|
14
6
|
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
# template-mettle-apps-ts
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"name": "template
|
|
2
|
+
"name": "template",
|
|
3
3
|
"version": "0.0.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"scripts": {
|
|
@@ -10,10 +10,10 @@
|
|
|
10
10
|
"devDependencies": {
|
|
11
11
|
"typescript": "~5.7.2",
|
|
12
12
|
"vite": "^6.1.0",
|
|
13
|
-
"vite-plugin-mettle": "^0.0
|
|
13
|
+
"vite-plugin-mettle": "^1.0.0"
|
|
14
14
|
},
|
|
15
15
|
"dependencies": {
|
|
16
|
-
"mettle": "^
|
|
17
|
-
"mettle-router": "^0.
|
|
16
|
+
"mettle": "^1.1.0",
|
|
17
|
+
"mettle-router": "^0.6.0"
|
|
18
18
|
}
|
|
19
19
|
}
|
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
import { resetView } from 'mettle';
|
|
2
2
|
import { initRouter } from 'mettle-router';
|
|
3
3
|
|
|
4
|
-
import
|
|
5
|
-
import
|
|
4
|
+
import Home from '../template/home';
|
|
5
|
+
import About from '../template/about';
|
|
6
6
|
|
|
7
7
|
const router = initRouter(
|
|
8
8
|
[
|
|
9
9
|
{
|
|
10
10
|
path: '/',
|
|
11
|
-
template:
|
|
11
|
+
template: Home,
|
|
12
12
|
},
|
|
13
13
|
{
|
|
14
14
|
path: '/about',
|
|
15
|
-
template:
|
|
15
|
+
template: About,
|
|
16
16
|
},
|
|
17
17
|
],
|
|
18
18
|
resetView
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { linkTo, toParse } from 'mettle-router';
|
|
2
|
+
|
|
3
|
+
export default function About() {
|
|
4
|
+
function goHome() {
|
|
5
|
+
linkTo({
|
|
6
|
+
path: '/',
|
|
7
|
+
});
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
function getOption() {
|
|
11
|
+
console.log(toParse());
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
return () => (
|
|
15
|
+
<fragment>
|
|
16
|
+
<button onClick={goHome}>goHome</button>
|
|
17
|
+
<h1 onClick={getOption}>About</h1>
|
|
18
|
+
</fragment>
|
|
19
|
+
);
|
|
20
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { linkTo } from 'mettle-router';
|
|
2
|
+
|
|
3
|
+
export default function Home({ setData }:any) {
|
|
4
|
+
const state = {
|
|
5
|
+
msg: 'hello',
|
|
6
|
+
arr: [1, 2],
|
|
7
|
+
count: 3,
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
function goAbout() {
|
|
11
|
+
linkTo({
|
|
12
|
+
path: '/about',
|
|
13
|
+
query: {
|
|
14
|
+
id: 1,
|
|
15
|
+
name: 'maomin',
|
|
16
|
+
},
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
function useChange() {
|
|
21
|
+
setData(() => {
|
|
22
|
+
state.msg = 'world';
|
|
23
|
+
state.count++;
|
|
24
|
+
state.arr.unshift(state.count);
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
return () => (
|
|
29
|
+
<fragment>
|
|
30
|
+
<button onClick={goAbout}>goAbout</button>
|
|
31
|
+
<h1>Home</h1>
|
|
32
|
+
<p onClick={useChange}>{state.msg}</p>
|
|
33
|
+
<ul>
|
|
34
|
+
{state.arr.map((item) => (
|
|
35
|
+
<li key={item}>{item}</li>
|
|
36
|
+
))}
|
|
37
|
+
</ul>
|
|
38
|
+
</fragment>
|
|
39
|
+
);
|
|
40
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
# template-mettle-ts
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"name": "template
|
|
2
|
+
"name": "template",
|
|
3
3
|
"version": "0.0.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"scripts": {
|
|
@@ -10,9 +10,9 @@
|
|
|
10
10
|
"devDependencies": {
|
|
11
11
|
"typescript": "~5.7.2",
|
|
12
12
|
"vite": "^6.1.0",
|
|
13
|
-
"vite-plugin-mettle": "^0.0
|
|
13
|
+
"vite-plugin-mettle": "^1.0.0"
|
|
14
14
|
},
|
|
15
15
|
"dependencies": {
|
|
16
|
-
"mettle": "^
|
|
16
|
+
"mettle": "^1.1.0"
|
|
17
17
|
}
|
|
18
18
|
}
|
|
@@ -1,8 +1,6 @@
|
|
|
1
|
-
import { defineComponent } from 'mettle';
|
|
2
|
-
import type { OptionsProps } from 'mettle';
|
|
3
1
|
import style from '../style/list.module.css';
|
|
4
2
|
|
|
5
|
-
|
|
3
|
+
export default function List({ setData }:any) {
|
|
6
4
|
const listState = {
|
|
7
5
|
arr: [1, 2],
|
|
8
6
|
};
|
|
@@ -40,6 +38,4 @@ const List = defineComponent(({ setData }:OptionsProps) => {
|
|
|
40
38
|
</ul>
|
|
41
39
|
</fragment>
|
|
42
40
|
);
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
export default List;
|
|
41
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { createApp } from 'mettle';
|
|
2
|
+
import Home from './template/home';
|
|
3
|
+
import List from './components/list';
|
|
4
|
+
import './style/app.css';
|
|
5
|
+
|
|
6
|
+
function App() {
|
|
7
|
+
return () => (
|
|
8
|
+
<div class='inner'>
|
|
9
|
+
<h1>Hello mettle.js</h1>
|
|
10
|
+
<div class='app-tool'>
|
|
11
|
+
<Home/>
|
|
12
|
+
<List/>
|
|
13
|
+
</div>
|
|
14
|
+
</div>
|
|
15
|
+
);
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
createApp(<App />, '#app');
|
|
@@ -1,7 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
import type { OptionsProps } from 'mettle';
|
|
3
|
-
|
|
4
|
-
const Home = defineComponent(({ setData }:OptionsProps) => {
|
|
1
|
+
export default function Home({ setData }:any) {
|
|
5
2
|
let count = 0;
|
|
6
3
|
|
|
7
4
|
function add() {
|
|
@@ -9,7 +6,6 @@ const Home = defineComponent(({ setData }:OptionsProps) => {
|
|
|
9
6
|
count++;
|
|
10
7
|
});
|
|
11
8
|
}
|
|
12
|
-
|
|
13
9
|
return () => (
|
|
14
10
|
<fragment>
|
|
15
11
|
<button onClick={add}>Add</button>
|
|
@@ -17,6 +13,4 @@ const Home = defineComponent(({ setData }:OptionsProps) => {
|
|
|
17
13
|
<input value={count} />
|
|
18
14
|
</fragment>
|
|
19
15
|
);
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
export default Home;
|
|
16
|
+
}
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
import { defineComponent } from 'mettle';
|
|
2
|
-
import style from '../style/list.module.css';
|
|
3
|
-
|
|
4
|
-
const List = defineComponent(({ setData }) => {
|
|
5
|
-
const listState = {
|
|
6
|
-
arr: [1, 2],
|
|
7
|
-
};
|
|
8
|
-
let count = 3;
|
|
9
|
-
|
|
10
|
-
function usePush() {
|
|
11
|
-
setData(() => {
|
|
12
|
-
listState.arr.push(count++);
|
|
13
|
-
});
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
function useUnshift() {
|
|
17
|
-
setData(() => {
|
|
18
|
-
listState.arr.unshift(count++);
|
|
19
|
-
});
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
function useDel() {
|
|
23
|
-
setData(() => {
|
|
24
|
-
listState.arr.splice(1, 1);
|
|
25
|
-
});
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
return () =>
|
|
29
|
-
html`
|
|
30
|
-
<fragment>
|
|
31
|
-
<div class=${style.listInner}>
|
|
32
|
-
<button onClick=${useUnshift}>Unshift</button>
|
|
33
|
-
<button onClick=${usePush}>Push</button>
|
|
34
|
-
<button onClick=${useDel}>Del</button>
|
|
35
|
-
</div>
|
|
36
|
-
<ul class=${style.listInner}>
|
|
37
|
-
${listState.arr.map((item) => html`<li key=${item}>${item}</li>`)}
|
|
38
|
-
</ul>
|
|
39
|
-
</fragment>
|
|
40
|
-
`;
|
|
41
|
-
});
|
|
42
|
-
|
|
43
|
-
export default List;
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import { defineComponent } from 'mettle';
|
|
2
|
-
import Home from './template/home';
|
|
3
|
-
import List from './components/list';
|
|
4
|
-
import './style/app.css';
|
|
5
|
-
|
|
6
|
-
defineComponent(
|
|
7
|
-
{
|
|
8
|
-
mount: '#app',
|
|
9
|
-
},
|
|
10
|
-
() => {
|
|
11
|
-
return () =>
|
|
12
|
-
html`<div class="inner">
|
|
13
|
-
<h1>Hello mettle.js</h1>
|
|
14
|
-
<div class="app-tool">
|
|
15
|
-
<component $is=${Home} />
|
|
16
|
-
<component $is=${List} />
|
|
17
|
-
</div>
|
|
18
|
-
</div>`;
|
|
19
|
-
}
|
|
20
|
-
);
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import { defineComponent } from 'mettle';
|
|
2
|
-
|
|
3
|
-
const Home = defineComponent(({ setData }) => {
|
|
4
|
-
let count = 0;
|
|
5
|
-
|
|
6
|
-
function add() {
|
|
7
|
-
setData(() => {
|
|
8
|
-
count++;
|
|
9
|
-
});
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
return () =>
|
|
13
|
-
html`
|
|
14
|
-
<fragment>
|
|
15
|
-
<button onClick=${add}>Add</button>
|
|
16
|
-
<h1>${count}</h1>
|
|
17
|
-
<input value=${count} />
|
|
18
|
-
</fragment>
|
|
19
|
-
`;
|
|
20
|
-
});
|
|
21
|
-
|
|
22
|
-
export default Home;
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import { defineComponent } from 'mettle';
|
|
2
|
-
import { linkTo, toParse } from 'mettle-router';
|
|
3
|
-
|
|
4
|
-
const about = () =>
|
|
5
|
-
defineComponent(() => {
|
|
6
|
-
function goHome() {
|
|
7
|
-
linkTo({
|
|
8
|
-
path: '/',
|
|
9
|
-
});
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
function getOption() {
|
|
13
|
-
console.log(toParse());
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
return () => html`
|
|
17
|
-
<fragment>
|
|
18
|
-
<button onClick=${goHome}>goHome</button>
|
|
19
|
-
<h1 onClick=${getOption}>About</h1>
|
|
20
|
-
</fragment>
|
|
21
|
-
`;
|
|
22
|
-
});
|
|
23
|
-
export default about;
|
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
import { defineComponent } from 'mettle';
|
|
2
|
-
import { linkTo } from 'mettle-router';
|
|
3
|
-
|
|
4
|
-
const home = () =>
|
|
5
|
-
defineComponent(({ setData }) => {
|
|
6
|
-
const state = {
|
|
7
|
-
msg: 'hello',
|
|
8
|
-
arr: [1, 2],
|
|
9
|
-
count: 3,
|
|
10
|
-
};
|
|
11
|
-
|
|
12
|
-
function goAbout() {
|
|
13
|
-
linkTo({
|
|
14
|
-
path: '/about',
|
|
15
|
-
query: {
|
|
16
|
-
id: 1,
|
|
17
|
-
name: 'maomin',
|
|
18
|
-
},
|
|
19
|
-
});
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
function useChange() {
|
|
23
|
-
setData(() => {
|
|
24
|
-
state.msg = 'world';
|
|
25
|
-
state.count++;
|
|
26
|
-
state.arr.unshift(state.count);
|
|
27
|
-
});
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
return () => html`
|
|
31
|
-
<fragment>
|
|
32
|
-
<button onClick=${goAbout}>goAbout</button>
|
|
33
|
-
<h1>Home</h1>
|
|
34
|
-
<p onClick=${useChange}>${state.msg}</p>
|
|
35
|
-
<ul>
|
|
36
|
-
${state.arr.map((item) => html`<li key=${item}>${item}</li>`)}
|
|
37
|
-
</ul>
|
|
38
|
-
</fragment>
|
|
39
|
-
`;
|
|
40
|
-
});
|
|
41
|
-
|
|
42
|
-
export default home;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
# template-mettle-jsx
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
<!DOCTYPE html>
|
|
2
|
-
<html lang="en">
|
|
3
|
-
|
|
4
|
-
<head>
|
|
5
|
-
<meta charset="UTF-8" />
|
|
6
|
-
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
7
|
-
<title>create-mettle-app</title>
|
|
8
|
-
</head>
|
|
9
|
-
|
|
10
|
-
<body>
|
|
11
|
-
<div id="app"></div>
|
|
12
|
-
<script type="module" src="/src/main.jsx"></script>
|
|
13
|
-
</body>
|
|
14
|
-
|
|
15
|
-
</html>
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "template-mettle-jsx",
|
|
3
|
-
"version": "0.0.0",
|
|
4
|
-
"license": "MIT",
|
|
5
|
-
"scripts": {
|
|
6
|
-
"dev": "vite --open",
|
|
7
|
-
"serve": "vite preview",
|
|
8
|
-
"build": "vite build"
|
|
9
|
-
},
|
|
10
|
-
"devDependencies": {
|
|
11
|
-
"vite": "^6.1.0",
|
|
12
|
-
"vite-plugin-mettle": "^0.0.1"
|
|
13
|
-
},
|
|
14
|
-
"dependencies": {
|
|
15
|
-
"mettle": "^0.5.0"
|
|
16
|
-
}
|
|
17
|
-
}
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import { defineComponent } from 'mettle';
|
|
2
|
-
import Home from './template/home';
|
|
3
|
-
import List from './components/list';
|
|
4
|
-
import './style/app.css';
|
|
5
|
-
|
|
6
|
-
defineComponent(
|
|
7
|
-
{
|
|
8
|
-
mount: '#app',
|
|
9
|
-
},
|
|
10
|
-
() => {
|
|
11
|
-
return () => (
|
|
12
|
-
<div class='inner'>
|
|
13
|
-
<h1>Hello mettle.js</h1>
|
|
14
|
-
<div class='app-tool'>
|
|
15
|
-
<component $is={Home} />
|
|
16
|
-
<component $is={List} />
|
|
17
|
-
</div>
|
|
18
|
-
</div>
|
|
19
|
-
);
|
|
20
|
-
}
|
|
21
|
-
);
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
# template-mettle-jsx-apps
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
<!DOCTYPE html>
|
|
2
|
-
<html lang="en">
|
|
3
|
-
|
|
4
|
-
<head>
|
|
5
|
-
<meta charset="UTF-8" />
|
|
6
|
-
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
7
|
-
<title>create-mettle-app</title>
|
|
8
|
-
</head>
|
|
9
|
-
|
|
10
|
-
<body>
|
|
11
|
-
<div id="app"></div>
|
|
12
|
-
<script type="module" src="/src/main.jsx"></script>
|
|
13
|
-
</body>
|
|
14
|
-
|
|
15
|
-
</html>
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "template-mettle-jsx-apps",
|
|
3
|
-
"version": "0.0.0",
|
|
4
|
-
"license": "MIT",
|
|
5
|
-
"scripts": {
|
|
6
|
-
"dev": "vite --open",
|
|
7
|
-
"serve": "vite preview",
|
|
8
|
-
"build": "vite build"
|
|
9
|
-
},
|
|
10
|
-
"devDependencies": {
|
|
11
|
-
"vite": "^6.1.0",
|
|
12
|
-
"vite-plugin-mettle": "^0.0.1"
|
|
13
|
-
},
|
|
14
|
-
"dependencies": {
|
|
15
|
-
"mettle": "^0.5.0",
|
|
16
|
-
"mettle-router": "^0.2.0"
|
|
17
|
-
}
|
|
18
|
-
}
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import { resetView } from 'mettle';
|
|
2
|
-
import { initRouter } from 'mettle-router';
|
|
3
|
-
|
|
4
|
-
import home from '../template/home';
|
|
5
|
-
import about from '../template/about';
|
|
6
|
-
|
|
7
|
-
const router = initRouter(
|
|
8
|
-
[
|
|
9
|
-
{
|
|
10
|
-
path: '/',
|
|
11
|
-
template: home,
|
|
12
|
-
},
|
|
13
|
-
{
|
|
14
|
-
path: '/about',
|
|
15
|
-
template: about,
|
|
16
|
-
},
|
|
17
|
-
],
|
|
18
|
-
resetView
|
|
19
|
-
);
|
|
20
|
-
|
|
21
|
-
export default router;
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import { defineComponent } from 'mettle';
|
|
2
|
-
import { linkTo, toParse } from 'mettle-router';
|
|
3
|
-
|
|
4
|
-
const about = () =>
|
|
5
|
-
defineComponent(() => {
|
|
6
|
-
function goHome() {
|
|
7
|
-
linkTo({
|
|
8
|
-
path: '/',
|
|
9
|
-
});
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
function getOption() {
|
|
13
|
-
console.log(toParse());
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
return () => (
|
|
17
|
-
<fragment>
|
|
18
|
-
<button onClick={goHome}>goHome</button>
|
|
19
|
-
<h1 onClick={getOption}>About</h1>
|
|
20
|
-
</fragment>
|
|
21
|
-
);
|
|
22
|
-
});
|
|
23
|
-
|
|
24
|
-
export default about;
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
import { defineComponent } from 'mettle';
|
|
2
|
-
import { linkTo } from 'mettle-router';
|
|
3
|
-
|
|
4
|
-
const home = () =>
|
|
5
|
-
defineComponent(({ setData }) => {
|
|
6
|
-
const state = {
|
|
7
|
-
msg: 'hello',
|
|
8
|
-
arr: [1, 2],
|
|
9
|
-
count: 3,
|
|
10
|
-
};
|
|
11
|
-
|
|
12
|
-
function goAbout() {
|
|
13
|
-
linkTo({
|
|
14
|
-
path: '/about',
|
|
15
|
-
query: {
|
|
16
|
-
id: 1,
|
|
17
|
-
name: 'maomin',
|
|
18
|
-
},
|
|
19
|
-
});
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
function useChange() {
|
|
23
|
-
setData(() => {
|
|
24
|
-
state.msg = 'world';
|
|
25
|
-
state.count++;
|
|
26
|
-
state.arr.unshift(state.count);
|
|
27
|
-
});
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
return () => (
|
|
31
|
-
<fragment>
|
|
32
|
-
<button onClick={goAbout}>goAbout</button>
|
|
33
|
-
<h1>Home</h1>
|
|
34
|
-
<p onClick={useChange}>{state.msg}</p>
|
|
35
|
-
<ul>
|
|
36
|
-
{state.arr.map((item) => (
|
|
37
|
-
<li key={item}>{item}</li>
|
|
38
|
-
))}
|
|
39
|
-
</ul>
|
|
40
|
-
</fragment>
|
|
41
|
-
);
|
|
42
|
-
});
|
|
43
|
-
|
|
44
|
-
export default home;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
# template-mettle-tsx
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
.DS_Store
|
|
2
|
-
node_modules
|
|
3
|
-
/dist
|
|
4
|
-
/buildDir
|
|
5
|
-
.parcel-cache
|
|
6
|
-
|
|
7
|
-
# local env files
|
|
8
|
-
.env.local
|
|
9
|
-
.env.*.local
|
|
10
|
-
|
|
11
|
-
# Log files
|
|
12
|
-
npm-debug.log*
|
|
13
|
-
yarn-debug.log*
|
|
14
|
-
yarn-error.log*
|
|
15
|
-
pnpm-debug.log*
|
|
16
|
-
|
|
17
|
-
# Editor directories and files
|
|
18
|
-
.idea
|
|
19
|
-
.vscode
|
|
20
|
-
*.suo
|
|
21
|
-
*.ntvs*
|
|
22
|
-
*.njsproj
|
|
23
|
-
*.sln
|
|
24
|
-
*.sw?
|
|
25
|
-
yarn.lock
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import { defineComponent } from 'mettle';
|
|
2
|
-
import Home from './template/home';
|
|
3
|
-
import List from './components/list';
|
|
4
|
-
import './style/app.css';
|
|
5
|
-
|
|
6
|
-
defineComponent(
|
|
7
|
-
{
|
|
8
|
-
mount: '#app',
|
|
9
|
-
},
|
|
10
|
-
() => {
|
|
11
|
-
return () => (
|
|
12
|
-
<div class='inner'>
|
|
13
|
-
<h1>Hello mettle.js</h1>
|
|
14
|
-
<div class='app-tool'>
|
|
15
|
-
<component $is={Home} />
|
|
16
|
-
<component $is={List} />
|
|
17
|
-
</div>
|
|
18
|
-
</div>
|
|
19
|
-
);
|
|
20
|
-
}
|
|
21
|
-
);
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
.listInner{
|
|
2
|
-
padding: 0;
|
|
3
|
-
margin: 0;
|
|
4
|
-
width: 400px;
|
|
5
|
-
}
|
|
6
|
-
.listInner li {
|
|
7
|
-
list-style: none;
|
|
8
|
-
text-align: center;
|
|
9
|
-
font-weight: bold;
|
|
10
|
-
padding: 10px;
|
|
11
|
-
margin: 10px 0;
|
|
12
|
-
background-color: #6c2de4;
|
|
13
|
-
color: #fff;
|
|
14
|
-
border-radius: 20px;
|
|
15
|
-
animation: my1 1s ease-in;
|
|
16
|
-
}
|
|
17
|
-
.listInner button {
|
|
18
|
-
margin-top: 30px;
|
|
19
|
-
}
|
|
20
|
-
@keyframes my1 {
|
|
21
|
-
from {
|
|
22
|
-
opacity: 0.2;
|
|
23
|
-
}
|
|
24
|
-
to {
|
|
25
|
-
opacity: 1;
|
|
26
|
-
}
|
|
27
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
# template-mettle-tsx-apps
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
.DS_Store
|
|
2
|
-
node_modules
|
|
3
|
-
/dist
|
|
4
|
-
/buildDir
|
|
5
|
-
.parcel-cache
|
|
6
|
-
|
|
7
|
-
# local env files
|
|
8
|
-
.env.local
|
|
9
|
-
.env.*.local
|
|
10
|
-
|
|
11
|
-
# Log files
|
|
12
|
-
npm-debug.log*
|
|
13
|
-
yarn-debug.log*
|
|
14
|
-
yarn-error.log*
|
|
15
|
-
pnpm-debug.log*
|
|
16
|
-
|
|
17
|
-
# Editor directories and files
|
|
18
|
-
.idea
|
|
19
|
-
.vscode
|
|
20
|
-
*.suo
|
|
21
|
-
*.ntvs*
|
|
22
|
-
*.njsproj
|
|
23
|
-
*.sln
|
|
24
|
-
*.sw?
|
|
25
|
-
yarn.lock
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import { defineComponent } from 'mettle';
|
|
2
|
-
import { linkTo, toParse } from 'mettle-router';
|
|
3
|
-
|
|
4
|
-
const about = () =>
|
|
5
|
-
defineComponent(() => {
|
|
6
|
-
function goHome() {
|
|
7
|
-
linkTo({
|
|
8
|
-
path: '/',
|
|
9
|
-
});
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
function getOption() {
|
|
13
|
-
console.log(toParse());
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
return () => (
|
|
17
|
-
<fragment>
|
|
18
|
-
<button onClick={goHome}>goHome</button>
|
|
19
|
-
<h1 onClick={getOption}>About</h1>
|
|
20
|
-
</fragment>
|
|
21
|
-
);
|
|
22
|
-
});
|
|
23
|
-
|
|
24
|
-
export default about;
|
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
import { defineComponent } from 'mettle';
|
|
2
|
-
import { linkTo } from 'mettle-router';
|
|
3
|
-
import type { OptionsProps } from 'mettle';
|
|
4
|
-
|
|
5
|
-
const home = () =>
|
|
6
|
-
defineComponent(({ setData }:OptionsProps) => {
|
|
7
|
-
const state = {
|
|
8
|
-
msg: 'hello',
|
|
9
|
-
arr: [1, 2],
|
|
10
|
-
count: 3,
|
|
11
|
-
};
|
|
12
|
-
|
|
13
|
-
function goAbout() {
|
|
14
|
-
linkTo({
|
|
15
|
-
path: '/about',
|
|
16
|
-
query: {
|
|
17
|
-
id: 1,
|
|
18
|
-
name: 'maomin',
|
|
19
|
-
},
|
|
20
|
-
});
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
function useChange() {
|
|
24
|
-
setData(() => {
|
|
25
|
-
state.msg = 'world';
|
|
26
|
-
state.count++;
|
|
27
|
-
state.arr.unshift(state.count);
|
|
28
|
-
});
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
return () => (
|
|
32
|
-
<fragment>
|
|
33
|
-
<button onClick={goAbout}>goAbout</button>
|
|
34
|
-
<h1>Home</h1>
|
|
35
|
-
<p onClick={useChange}>{state.msg}</p>
|
|
36
|
-
<ul>
|
|
37
|
-
{state.arr.map((item) => (
|
|
38
|
-
<li key={item}>{item}</li>
|
|
39
|
-
))}
|
|
40
|
-
</ul>
|
|
41
|
-
</fragment>
|
|
42
|
-
);
|
|
43
|
-
});
|
|
44
|
-
|
|
45
|
-
export default home;
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|