@variousjs/various 4.3.0 → 5.0.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/dist/index.dev.js +1741 -0
- package/dist/index.dev.js.map +1 -0
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/loader.js +1 -1
- package/dist/loader.js.map +1 -1
- package/index.d.ts +51 -32
- package/package.json +8 -4
package/index.d.ts
CHANGED
|
@@ -5,6 +5,12 @@ declare module '@variousjs/various' {
|
|
|
5
5
|
|
|
6
6
|
export { default as Nycticorax, Dispatch } from 'nycticorax'
|
|
7
7
|
|
|
8
|
+
export interface ModuleDefined { name: string, module?: string }
|
|
9
|
+
|
|
10
|
+
export type ObjectRecord<T = any> = Record<string, T>
|
|
11
|
+
|
|
12
|
+
export type VariousComponentType = 'react' | 'vue3'
|
|
13
|
+
|
|
8
14
|
export type ErrorType =
|
|
9
15
|
'LOADING_ERROR' |
|
|
10
16
|
'SUBMODULE_LOADING_ERROR' |
|
|
@@ -20,20 +26,20 @@ declare module '@variousjs/various' {
|
|
|
20
26
|
|
|
21
27
|
export interface ComponentDefaultProps {
|
|
22
28
|
$silent?: boolean,
|
|
29
|
+
/**
|
|
30
|
+
* for React Component only
|
|
31
|
+
*/
|
|
23
32
|
$ref?: RefObject<unknown>,
|
|
33
|
+
[k: string]: any,
|
|
24
34
|
}
|
|
25
35
|
|
|
26
36
|
export interface VariousError extends Error {
|
|
27
37
|
type: ErrorType,
|
|
28
38
|
originalError: Error,
|
|
29
|
-
module?:
|
|
30
|
-
name:
|
|
39
|
+
module?: ModuleDefined['module'],
|
|
40
|
+
name: ModuleDefined['name'],
|
|
31
41
|
}
|
|
32
42
|
|
|
33
|
-
type ObjectAny = Record<string, any>
|
|
34
|
-
|
|
35
|
-
export interface ModuleDefined { name: string, module?: string }
|
|
36
|
-
|
|
37
43
|
interface Message { event: string, value: any, trigger: ModuleDefined }
|
|
38
44
|
|
|
39
45
|
type $dispatch = (args: ModuleDefined & {
|
|
@@ -48,16 +54,19 @@ declare module '@variousjs/various' {
|
|
|
48
54
|
error: (message: any, type?: string) => void,
|
|
49
55
|
}
|
|
50
56
|
|
|
51
|
-
export type Intl = (
|
|
57
|
+
export type Intl = ((
|
|
52
58
|
key: string,
|
|
53
59
|
paramsOrDefaultText?: Record<string, string | number> | string,
|
|
54
60
|
defaultText?: string,
|
|
55
|
-
) => string
|
|
61
|
+
) => string) & {
|
|
62
|
+
update: (config: Partial<I18nConfig>, type?: 'app') => void,
|
|
63
|
+
}
|
|
56
64
|
|
|
57
65
|
export type PublicAction = (value: any, trigger: ModuleDefined) => any
|
|
58
66
|
|
|
59
67
|
export interface I18nConfig {
|
|
60
|
-
|
|
68
|
+
/** app store key */
|
|
69
|
+
lngStoreKey: string,
|
|
61
70
|
resources: Record<string, Record<string, string>>,
|
|
62
71
|
}
|
|
63
72
|
|
|
@@ -72,8 +81,8 @@ declare module '@variousjs/various' {
|
|
|
72
81
|
}
|
|
73
82
|
|
|
74
83
|
export type ComponentProps<
|
|
75
|
-
S extends object =
|
|
76
|
-
P extends object =
|
|
84
|
+
S extends object = ObjectRecord,
|
|
85
|
+
P extends object = ObjectRecord
|
|
77
86
|
> = {
|
|
78
87
|
$store: Readonly<S>,
|
|
79
88
|
$dispatch: $dispatch,
|
|
@@ -87,23 +96,23 @@ declare module '@variousjs/various' {
|
|
|
87
96
|
P extends object = {}
|
|
88
97
|
> = FC<ComponentProps<S, P>> & StaticProps
|
|
89
98
|
|
|
90
|
-
export interface ErrorNodeProps<S extends object =
|
|
91
|
-
$reload
|
|
99
|
+
export interface ErrorNodeProps<S extends object = ObjectRecord> {
|
|
100
|
+
$reload: () => void,
|
|
92
101
|
$error: VariousError,
|
|
93
102
|
$store: Readonly<S>,
|
|
94
|
-
$name:
|
|
95
|
-
$module?:
|
|
103
|
+
$name: ModuleDefined['name'],
|
|
104
|
+
$module?: ModuleDefined['module'],
|
|
96
105
|
}
|
|
97
|
-
export type ErrorNode<S extends object =
|
|
106
|
+
export type ErrorNode<S extends object = ObjectRecord> = ComponentType<ErrorNodeProps<S>>
|
|
98
107
|
|
|
99
|
-
export interface LoaderNodeProps<S extends object =
|
|
108
|
+
export interface LoaderNodeProps<S extends object = ObjectRecord> {
|
|
100
109
|
$store: Readonly<S>,
|
|
101
|
-
$name:
|
|
102
|
-
$module?:
|
|
110
|
+
$name: ModuleDefined['name'],
|
|
111
|
+
$module?: ModuleDefined['module'],
|
|
103
112
|
}
|
|
104
|
-
export type LoaderNode<S extends object =
|
|
113
|
+
export type LoaderNode<S extends object = ObjectRecord> = ComponentType<LoaderNodeProps<S>>
|
|
105
114
|
|
|
106
|
-
type Dispatch<T extends object =
|
|
115
|
+
type Dispatch<T extends object = ObjectRecord> = (
|
|
107
116
|
nycticorax: {
|
|
108
117
|
getStore: <K extends keyof T | undefined = undefined>(k?: K | undefined) =>
|
|
109
118
|
K extends keyof T ? T[K] : T,
|
|
@@ -145,7 +154,7 @@ declare module '@variousjs/various' {
|
|
|
145
154
|
export type ErrorEvent = (e: VariousError) => void
|
|
146
155
|
export type LogEvent = (e: LogArgs) => boolean
|
|
147
156
|
|
|
148
|
-
export interface App<S extends object =
|
|
157
|
+
export interface App<S extends object = ObjectRecord> {
|
|
149
158
|
store?: readonly S,
|
|
150
159
|
Error?: ErrorNode<S>,
|
|
151
160
|
Loader?: LoaderNode<S>,
|
|
@@ -167,6 +176,7 @@ declare module '@variousjs/various' {
|
|
|
167
176
|
'@variousjs/various'?: string,
|
|
168
177
|
react?: string,
|
|
169
178
|
'react-dom'?: string,
|
|
179
|
+
vue?: string,
|
|
170
180
|
[x: string]: string,
|
|
171
181
|
},
|
|
172
182
|
root?: string,
|
|
@@ -175,36 +185,45 @@ declare module '@variousjs/various' {
|
|
|
175
185
|
}
|
|
176
186
|
|
|
177
187
|
export function createComponent<
|
|
178
|
-
S extends object =
|
|
179
|
-
P extends object =
|
|
188
|
+
S extends object = ObjectRecord,
|
|
189
|
+
P extends object = ObjectRecord
|
|
180
190
|
>(
|
|
181
|
-
config: ModuleDefined & { url?: string },
|
|
191
|
+
config: ModuleDefined & { url?: string, type?: VariousComponentType },
|
|
182
192
|
storeKeys?: (keyof S)[],
|
|
183
193
|
): ComponentType<ComponentDefaultProps & P>
|
|
184
194
|
|
|
185
195
|
export function createModule<T = unknown> (params: ModuleDefined & {
|
|
186
196
|
url?: string,
|
|
187
|
-
}): Promise<T>
|
|
197
|
+
}, logError?: boolean): Promise<T>
|
|
188
198
|
|
|
189
|
-
export function renderComponent<P extends object =
|
|
199
|
+
export function renderComponent<P extends object = ObjectRecord>(params: ModuleDefined & {
|
|
190
200
|
url?: string,
|
|
201
|
+
type?: VariousComponentType,
|
|
191
202
|
props?: P & ComponentDefaultProps,
|
|
192
203
|
target: Element | null,
|
|
193
204
|
renderNode?: (children: ReactNode) => ReactNode,
|
|
194
205
|
onMounted?: () => void,
|
|
195
206
|
}): () => Promise<void>
|
|
196
207
|
|
|
197
|
-
export
|
|
208
|
+
export interface VueVarious<S extends object = ObjectRecord> {
|
|
209
|
+
$dispatch: $dispatch,
|
|
210
|
+
$logger: $logger,
|
|
211
|
+
$postMessage: $postMessage,
|
|
212
|
+
$t: Intl,
|
|
213
|
+
$store: Readonly<S>,
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
export const isModuleLoaded: (name: string) => boolean
|
|
198
217
|
export const getMountedComponents: () => ModuleDefined[]
|
|
199
|
-
export const
|
|
218
|
+
export const preloadModules: (name: string | string[]) => Promise<void>
|
|
200
219
|
export const onComponentMounted: (
|
|
201
220
|
name: ModuleDefined | ModuleDefined[], callback: () => void
|
|
202
|
-
) => () => void
|
|
221
|
+
) => (() => void) | void
|
|
203
222
|
export const defineDependencies: (deps: Record<string, string>) => void
|
|
204
223
|
|
|
205
224
|
export const version: string
|
|
206
|
-
export function getConfig<C extends object =
|
|
207
|
-
export function getStore<S extends object =
|
|
225
|
+
export function getConfig<C extends object = ObjectRecord>(): C
|
|
226
|
+
export function getStore<S extends object = ObjectRecord>(): S
|
|
208
227
|
|
|
209
228
|
export const createDispatch: (m: ModuleDefined) => $dispatch
|
|
210
229
|
export const createPostMessage: (m: ModuleDefined) => $postMessage
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@variousjs/various",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "5.0.0",
|
|
4
4
|
"description": "RequireJS(AMD) + React",
|
|
5
5
|
"files": [
|
|
6
6
|
"dist",
|
|
@@ -19,10 +19,11 @@
|
|
|
19
19
|
"types": "index.d.ts",
|
|
20
20
|
"scripts": {
|
|
21
21
|
"lint": "tsc --noemit && eslint . --ext .ts,.tsx,.js",
|
|
22
|
-
"prestart": "mkdir -p
|
|
22
|
+
"prestart": "mkdir -p docs/dist && touch docs/dist/empty.js",
|
|
23
23
|
"start": "webpack --config webpack/components.js --progress & webpack serve --config webpack/index.js --progress --no-client-overlay",
|
|
24
|
-
"prebuild": "npm run lint",
|
|
25
|
-
"build": "
|
|
24
|
+
"prebuild": "npm run lint && rm -rf dist && rm -rf docs/dist",
|
|
25
|
+
"build": "NODE_ENV=production webpack --config webpack/components.js --progress && NODE_ENV=production webpack --config webpack/index.js --progress",
|
|
26
|
+
"postbuild": "cp dist/* docs/dist/ && touch docs/dist/empty.js",
|
|
26
27
|
"cy:run": "rm -rf .nyc_output && cypress run",
|
|
27
28
|
"ci": "start-server-and-test start http://127.0.0.1:2333 cy:run",
|
|
28
29
|
"cypress": "cypress open"
|
|
@@ -56,6 +57,7 @@
|
|
|
56
57
|
"@types/requirejs": "^2.1.34",
|
|
57
58
|
"@typescript-eslint/eslint-plugin": "^4.33.0",
|
|
58
59
|
"@typescript-eslint/parser": "^4.33.0",
|
|
60
|
+
"@vue/compiler-sfc": "^3.5.22",
|
|
59
61
|
"babel-loader": "^8.2.5",
|
|
60
62
|
"babel-plugin-istanbul": "^6.1.1",
|
|
61
63
|
"cypress": "^9.7.0",
|
|
@@ -69,6 +71,8 @@
|
|
|
69
71
|
"eslint-plugin-react-hooks": "^4.6.0",
|
|
70
72
|
"start-server-and-test": "^2.0.3",
|
|
71
73
|
"typescript": "^4.9.5",
|
|
74
|
+
"vue": "^3.5.21",
|
|
75
|
+
"vue-loader": "^17.3.1",
|
|
72
76
|
"webpack": "^5.101.0",
|
|
73
77
|
"webpack-bundle-analyzer": "^4.6.1",
|
|
74
78
|
"webpack-cli": "^4.10.0",
|