@variousjs/various 0.4.2 → 0.6.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@variousjs/various",
3
- "version": "0.4.2",
3
+ "version": "0.6.0",
4
4
  "description": "RequireJS(AMD) + React",
5
5
  "files": [
6
6
  "dist",
@@ -14,6 +14,7 @@
14
14
  "scripts": {
15
15
  "lint": "tsc --noemit && eslint . --ext .ts,.tsx,.js",
16
16
  "start": "webpack --config webpack/components.js --progress & webpack serve --config webpack/index.js --progress",
17
+ "prebuild": "npm run lint",
17
18
  "build": "NODE_ENV=production webpack --progress --config webpack/components.js && NODE_ENV=production webpack --config webpack/index.js --progress",
18
19
  "postbuild": "cp -R dist/ docs/dist/"
19
20
  },
@@ -40,6 +41,7 @@
40
41
  "@babel/runtime-corejs3": "^7.14.8",
41
42
  "@types/react": "^17.0.27",
42
43
  "@types/react-dom": "^17.0.9",
44
+ "@types/react-router-dom": "^5.3.2",
43
45
  "@types/requirejs": "^2.1.33",
44
46
  "@typescript-eslint/eslint-plugin": "^4.31.0",
45
47
  "@typescript-eslint/parser": "^4.31.0",
@@ -54,11 +56,9 @@
54
56
  "typescript": "^4.4.2",
55
57
  "webpack": "^5.60.0",
56
58
  "webpack-cli": "^4.9.1",
57
- "webpack-dev-server": "^4.3.1"
59
+ "webpack-dev-server": "^4.7.3"
58
60
  },
59
61
  "dependencies": {
60
- "@types/react-router-dom": "^5.3.2",
61
- "nycticorax": "^2.0.6",
62
- "react-router-dom": "^5.3.0"
62
+ "nycticorax": "^2.1.0"
63
63
  }
64
64
  }
package/types/index.d.ts CHANGED
@@ -1,6 +1,5 @@
1
1
  declare module '@variousjs/various' {
2
- import { RouteComponentProps } from 'react-router-dom'
3
- import { ComponentType, Component } from 'react'
2
+ import { ComponentType } from 'react'
4
3
 
5
4
  type $dispatch = (type: string, method: string, value?: any) => unknown
6
5
  type $render = (params: {
@@ -12,49 +11,35 @@ declare module '@variousjs/various' {
12
11
  onMounted?: () => void,
13
12
  }) => () => void
14
13
  type $preload = (names: string[]) => Promise<void>
14
+ type $postMessage = (name: string, value?: any) => void
15
+ type $getMountedComponents = () => string[]
16
+ type $isComponentLoaded = (name: string) => boolean
15
17
 
16
18
  export { default as Store, Connect, Dispatch } from 'nycticorax'
17
19
 
18
- export class Router extends Component {}
19
- export {
20
- Route,
21
- Link,
22
- generatePath,
23
- Redirect,
24
- Prompt,
25
- NavLink,
26
- matchPath,
27
- Switch,
28
- } from 'react-router-dom'
29
-
30
20
  export interface ComponentProps<S = {}, C = {}> {
31
21
  $config: Readonly<C>,
32
- $mounted: string[],
33
- $router?: RouteComponentProps<{ [key: string]: string }>,
34
22
  $store: Readonly<S>,
35
23
  $dispatch: $dispatch,
36
24
  $render?: $render,
37
- $preload?: $preload,
25
+ $preload: $preload,
26
+ $postMessage: $postMessage,
27
+ $getMountedComponents: $getMountedComponents,
28
+ $isComponentLoaded: $isComponentLoaded,
38
29
  }
39
30
 
40
31
  export interface ErrorProps {
41
32
  reload?: () => void,
42
- type: 'LOADING_ERROR' | 'DEPENDENCIES_LOADING_ERROR' | 'NOT_DEFINED' | 'INVALID_COMPONENT' | 'SCRIPT_ERROR' | 'ROUTER_ERROR' | 'CONTAINER_ERROR',
33
+ type: 'LOADING_ERROR' | 'DEPENDENCIES_LOADING_ERROR' | 'NOT_DEFINED' | 'INVALID_COMPONENT' | 'SCRIPT_ERROR' | 'CONTAINER_ERROR',
43
34
  message?: string,
44
35
  }
45
36
 
46
- export interface ContainerProps<S = {}, C = {}> {
37
+ export interface ContainerProps<C = {}> {
47
38
  $config: Readonly<C>,
48
39
  $component: (name: string) => ComponentType<{
49
- silent?: boolean,
40
+ $silent?: boolean,
50
41
  [key: string]: any,
51
42
  }>,
52
- $store: Readonly<S>,
53
- $mounted: string[],
54
- $dispatch: $dispatch,
55
- $render: $render,
56
- $preload: $preload,
57
- $router: RouteComponentProps<{ [key: string]: string }>,
58
43
  }
59
44
 
60
45
  type Store<S> = {
@@ -65,4 +50,10 @@ declare module '@variousjs/various' {
65
50
  export type Actions<S = {}> = {
66
51
  [name: string]: (store: Store<S>, ...args: any[]) => unknown,
67
52
  }
53
+
54
+ export type OnMessage = (message: {
55
+ type: string,
56
+ name: string,
57
+ value?: any,
58
+ }) => void
68
59
  }