@variousjs/various 0.6.1 → 1.1.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,18 +1,19 @@
1
1
  declare module '@variousjs/various' {
2
2
  import { ComponentType } from 'react'
3
3
 
4
- type $dispatch = (type: string, method: string, value?: any) => unknown
4
+ type $dispatch = (type: string, method: string, value?: any) => Promise<any>
5
5
  type $render = (params: {
6
6
  name: string,
7
7
  url?: string,
8
8
  module?: string,
9
- props?: { [key: string]: any },
9
+ props?: Record<string, any>,
10
10
  target: Element | null,
11
11
  onMounted?: () => void,
12
12
  }) => () => void
13
13
  type $preload = (names: string[]) => Promise<void>
14
14
  type $postMessage = (name: string, value?: any) => void
15
15
  type $getMountedComponents = () => string[]
16
+ type $t = (key: string, defaultText?: string) => string | undefined
16
17
 
17
18
  export { default as Store, Connect, Dispatch } from 'nycticorax'
18
19
 
@@ -24,12 +25,13 @@ declare module '@variousjs/various' {
24
25
  $preload: $preload,
25
26
  $postMessage: $postMessage,
26
27
  $getMountedComponents: $getMountedComponents,
28
+ $t: $t,
27
29
  }
28
30
 
29
31
  export interface ErrorProps {
30
- reload?: () => void,
31
- type: 'LOADING_ERROR' | 'DEPENDENCIES_LOADING_ERROR' | 'NOT_DEFINED' | 'INVALID_COMPONENT' | 'SCRIPT_ERROR' | 'CONTAINER_ERROR',
32
- message?: string,
32
+ $reload?: () => void,
33
+ $type: 'LOADING_ERROR' | 'DEPENDENCIES_LOADING_ERROR' | 'NOT_DEFINED' | 'INVALID_COMPONENT' | 'SCRIPT_ERROR' | 'CONTAINER_ERROR',
34
+ $message?: string,
33
35
  }
34
36
 
35
37
  export interface ContainerProps<C = {}> {
@@ -40,18 +42,21 @@ declare module '@variousjs/various' {
40
42
  }>,
41
43
  }
42
44
 
43
- type Store<S> = {
44
- getStore: () => S,
45
- dispatch: (next: Partial<S>) => void,
46
- }
45
+ type Dispatch<T> = (
46
+ nycticorax: { getStore: () => T, emit: (next: Partial<T>) => void },
47
+ params: { value?: any, trigger: string },
48
+ ) => Promise<any>
47
49
 
48
- export type Actions<S = {}> = {
49
- [name: string]: (store: Store<S>, ...args: any[]) => unknown,
50
- }
50
+ export type Actions<S = {}> = Record<string, Dispatch<S>>
51
51
 
52
- export type OnMessage = (message: {
53
- type: string,
54
- name: string,
55
- value?: any,
56
- }) => void
52
+ export type MessageInvoker = (
53
+ message: { type: string, name: string, value?: any },
54
+ ) => any
55
+
56
+ export type Invoker = (params: { trigger: string, value?: any }) => any
57
+
58
+ export type Ii8n = () => {
59
+ localeKey: string,
60
+ resources: Record<string, Record<string, string>>,
61
+ }
57
62
  }
package/package.json CHANGED
@@ -1,10 +1,10 @@
1
1
  {
2
2
  "name": "@variousjs/various",
3
- "version": "0.6.1",
3
+ "version": "1.1.0",
4
4
  "description": "RequireJS(AMD) + React",
5
5
  "files": [
6
6
  "dist",
7
- "types"
7
+ "index.d.ts"
8
8
  ],
9
9
  "unpkg": "dist/index.js",
10
10
  "publishConfig": {
@@ -12,17 +12,17 @@
12
12
  },
13
13
  "nyc": {
14
14
  "exclude": [
15
- "demo/*"
15
+ "examples/*"
16
16
  ],
17
17
  "excludeAfterRemap": true
18
18
  },
19
- "types": "types/index.d.ts",
19
+ "types": "index.d.ts",
20
20
  "scripts": {
21
21
  "lint": "tsc --noemit && eslint . --ext .ts,.tsx,.js",
22
+ "prestart": "mkdir -p demo/dist && cp demo/empty.js demo/dist/empty.js",
22
23
  "start": "webpack --config webpack/components.js --progress & webpack serve --config webpack/index.js --progress",
23
24
  "prebuild": "npm run lint",
24
- "build": "NODE_ENV=production webpack --progress --config webpack/components.js && NODE_ENV=production webpack --config webpack/index.js --progress",
25
- "postbuild": "cp -R dist/ docs/dist/",
25
+ "build": "NODE_ENV=production webpack --config webpack/index.js --progress",
26
26
  "cy:run": "cypress run",
27
27
  "ci": "start-server-and-test start http://127.0.0.1:2333 cy:run",
28
28
  "cypress": "cypress open"
@@ -73,6 +73,6 @@
73
73
  "webpack-dev-server": "^4.7.3"
74
74
  },
75
75
  "dependencies": {
76
- "nycticorax": "^2.1.0"
76
+ "nycticorax": "^3.0.3"
77
77
  }
78
78
  }
@@ -1,8 +0,0 @@
1
- /** @license React v16.13.1
2
- * react-is.production.min.js
3
- *
4
- * Copyright (c) Facebook, Inc. and its affiliates.
5
- *
6
- * This source code is licensed under the MIT license found in the
7
- * LICENSE file in the root directory of this source tree.
8
- */