@variousjs/create 1.2.0 → 2.0.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/demo/dist/card.js +1 -1
- package/demo/dist/card.js.map +1 -1
- package/demo/dist/entry.js +1 -1
- package/demo/dist/entry.js.map +1 -1
- package/demo/dist/next.js +1 -1
- package/demo/dist/next.js.map +1 -1
- package/demo/dist/top.js +1 -1
- package/demo/dist/top.js.map +1 -1
- package/demo/index.html +2 -2
- package/package-lock.json.copy +297 -326
- package/package.json +3 -3
- package/package.json.copy +2 -2
- package/src/components/card.tsx +1 -1
- package/src/components/next.tsx +1 -1
- package/src/components/top.tsx +4 -3
- package/src/entry/actions.ts +2 -2
- package/src/entry/container.tsx +17 -6
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@variousjs/create",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "2.0.1",
|
|
4
4
|
"description": "VariousJS boilerplate",
|
|
5
5
|
"bin": "bin/create.js",
|
|
6
6
|
"publishConfig": {
|
|
@@ -38,7 +38,7 @@
|
|
|
38
38
|
"@types/react-router-dom": "^5.3.3",
|
|
39
39
|
"@typescript-eslint/eslint-plugin": "^4.31.2",
|
|
40
40
|
"@typescript-eslint/parser": "^4.31.2",
|
|
41
|
-
"@variousjs/various": "^
|
|
41
|
+
"@variousjs/various": "^3.0.2",
|
|
42
42
|
"babel-loader": "^8.2.2",
|
|
43
43
|
"core-js": "^3.25.1",
|
|
44
44
|
"css-loader": "^6.3.0",
|
|
@@ -52,7 +52,7 @@
|
|
|
52
52
|
"less-loader": "^10.0.1",
|
|
53
53
|
"style-loader": "^3.3.0",
|
|
54
54
|
"typescript": "^4.4.3",
|
|
55
|
-
"webpack": "^5.
|
|
55
|
+
"webpack": "^5.78.0",
|
|
56
56
|
"webpack-cli": "^4.8.0",
|
|
57
57
|
"webpack-dev-server": "^4.7.3"
|
|
58
58
|
},
|
package/package.json.copy
CHANGED
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
"@types/react-router-dom": "^5.3.3",
|
|
22
22
|
"@typescript-eslint/eslint-plugin": "^4.31.2",
|
|
23
23
|
"@typescript-eslint/parser": "^4.31.2",
|
|
24
|
-
"@variousjs/various": "^
|
|
24
|
+
"@variousjs/various": "^3.0.2",
|
|
25
25
|
"babel-loader": "^8.2.2",
|
|
26
26
|
"core-js": "^3.25.1",
|
|
27
27
|
"css-loader": "^6.3.0",
|
|
@@ -35,7 +35,7 @@
|
|
|
35
35
|
"less-loader": "^10.0.1",
|
|
36
36
|
"style-loader": "^3.3.0",
|
|
37
37
|
"typescript": "^4.4.3",
|
|
38
|
-
"webpack": "^5.
|
|
38
|
+
"webpack": "^5.78.0",
|
|
39
39
|
"webpack-cli": "^4.8.0",
|
|
40
40
|
"webpack-dev-server": "^4.7.3"
|
|
41
41
|
},
|
package/src/components/card.tsx
CHANGED
package/src/components/next.tsx
CHANGED
|
@@ -17,7 +17,7 @@ const {
|
|
|
17
17
|
createStore({ value: 0 })
|
|
18
18
|
|
|
19
19
|
class X extends Component<S & ComponentProps<GlobalStore>> {
|
|
20
|
-
static setValue: Invoker = async (
|
|
20
|
+
static setValue: Invoker = async (value) => {
|
|
21
21
|
const store = getStore()
|
|
22
22
|
emit({ value: value + store.value }, true)
|
|
23
23
|
}
|
package/src/components/top.tsx
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import React, { FC, useState, useEffect } from 'react'
|
|
2
|
-
import { ComponentProps } from '@variousjs/various'
|
|
2
|
+
import { ComponentProps, getConfig } from '@variousjs/various'
|
|
3
3
|
import { useLocation, useHistory } from 'react-router-dom'
|
|
4
4
|
import { Radio, Badge, Button } from 'antd'
|
|
5
5
|
import { Config, Store } from '../types'
|
|
6
6
|
|
|
7
|
-
const H: FC<ComponentProps<Store
|
|
7
|
+
const H: FC<ComponentProps<Store>> = (props) => {
|
|
8
|
+
const $config = getConfig() as Config
|
|
8
9
|
const { pathname } = useLocation()
|
|
9
10
|
const history = useHistory()
|
|
10
11
|
const [path, setPath] = useState('')
|
|
@@ -27,7 +28,7 @@ const H: FC<ComponentProps<Store, Config>> = (props) => {
|
|
|
27
28
|
buttonStyle="solid"
|
|
28
29
|
>
|
|
29
30
|
{
|
|
30
|
-
|
|
31
|
+
$config.links.map(({ path, name }) => (
|
|
31
32
|
<Radio.Button key={path} value={path}>
|
|
32
33
|
{name}
|
|
33
34
|
</Radio.Button>
|
package/src/entry/actions.ts
CHANGED
|
@@ -2,7 +2,7 @@ import { Actions } from '@variousjs/various'
|
|
|
2
2
|
import { Store } from '../types'
|
|
3
3
|
|
|
4
4
|
const actions: Actions<Store> = {
|
|
5
|
-
async setName({ emit, getStore },
|
|
5
|
+
async setName({ emit, getStore }, value) {
|
|
6
6
|
await new Promise((r) => setTimeout(r, 1000))
|
|
7
7
|
const { user } = getStore()
|
|
8
8
|
user.name = value
|
|
@@ -12,7 +12,7 @@ const actions: Actions<Store> = {
|
|
|
12
12
|
const { user } = getStore()
|
|
13
13
|
return user.name
|
|
14
14
|
},
|
|
15
|
-
async setLocale({ emit },
|
|
15
|
+
async setLocale({ emit }, value) {
|
|
16
16
|
emit({ locale: value })
|
|
17
17
|
}
|
|
18
18
|
}
|
package/src/entry/container.tsx
CHANGED
|
@@ -1,13 +1,24 @@
|
|
|
1
|
-
import React, { Component, ComponentType } from 'react'
|
|
2
|
-
import {
|
|
1
|
+
import React, { Component, ComponentType, memo } from 'react'
|
|
2
|
+
import { createComponent, getConfig } from '@variousjs/various'
|
|
3
3
|
import { HashRouter as Router, Route } from 'react-router-dom'
|
|
4
4
|
import { Config } from '../types'
|
|
5
5
|
import csses from './entry.less'
|
|
6
6
|
|
|
7
|
-
class Container extends Component
|
|
7
|
+
class Container extends Component {
|
|
8
|
+
config = getConfig() as Config
|
|
9
|
+
|
|
10
|
+
top = memo(createComponent('top'))
|
|
11
|
+
|
|
12
|
+
components = this.config.pages.reduce((prev, current) => {
|
|
13
|
+
current.components.forEach((item) => {
|
|
14
|
+
prev[item] = memo(createComponent(item))
|
|
15
|
+
})
|
|
16
|
+
return prev
|
|
17
|
+
}, {} as Record<string, ReturnType<typeof createComponent>>)
|
|
18
|
+
|
|
8
19
|
render() {
|
|
9
|
-
const
|
|
10
|
-
const
|
|
20
|
+
const Top = this.top
|
|
21
|
+
const $config = this.config
|
|
11
22
|
|
|
12
23
|
return (
|
|
13
24
|
<div className={csses.container}>
|
|
@@ -18,7 +29,7 @@ class Container extends Component<ContainerProps<Config>> {
|
|
|
18
29
|
{
|
|
19
30
|
$config.pages.map(({ path, components }) => {
|
|
20
31
|
const cs = () => components.map((name) => {
|
|
21
|
-
const C =
|
|
32
|
+
const C = this.components[name]
|
|
22
33
|
return (
|
|
23
34
|
<div
|
|
24
35
|
key={name}
|