@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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@variousjs/create",
3
- "version": "1.2.0",
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": "^2.1.3",
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.54.0",
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": "^2.1.3",
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.54.0",
38
+ "webpack": "^5.78.0",
39
39
  "webpack-cli": "^4.8.0",
40
40
  "webpack-dev-server": "^4.7.3"
41
41
  },
@@ -47,6 +47,6 @@ const H: FC<ComponentProps<Store>> & { getName: Invoker } = (props) => {
47
47
  )
48
48
  }
49
49
 
50
- H.getName = (e) => message.info(e.value)
50
+ H.getName = (e) => message.info(e)
51
51
 
52
52
  export default H
@@ -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 ({ value }) => {
20
+ static setValue: Invoker = async (value) => {
21
21
  const store = getStore()
22
22
  emit({ value: value + store.value }, true)
23
23
  }
@@ -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, Config>> = (props) => {
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
- props.$config.links.map(({ path, name }) => (
31
+ $config.links.map(({ path, name }) => (
31
32
  <Radio.Button key={path} value={path}>
32
33
  {name}
33
34
  </Radio.Button>
@@ -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 }, { value }) {
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 }, { value }) {
15
+ async setLocale({ emit }, value) {
16
16
  emit({ locale: value })
17
17
  }
18
18
  }
@@ -1,13 +1,24 @@
1
- import React, { Component, ComponentType } from 'react'
2
- import { ContainerProps } from '@variousjs/various'
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<ContainerProps<Config>> {
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 { $component, $config } = this.props
10
- const Top = $component('top')
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 = $component(name)
32
+ const C = this.components[name]
22
33
  return (
23
34
  <div
24
35
  key={name}