@variousjs/various 5.2.0 → 5.3.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 +75 -33
- package/dist/index.dev.js.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/standalone.js +83 -37
- package/dist/standalone.js.map +1 -1
- package/index.d.ts +31 -7
- package/package.json +1 -1
- package/standalone.d.ts +5 -2
package/index.d.ts
CHANGED
|
@@ -111,11 +111,26 @@ declare module '@variousjs/various' {
|
|
|
111
111
|
): Promise<M[T][A]['result']>
|
|
112
112
|
}
|
|
113
113
|
|
|
114
|
+
export type DefineAppActions<T extends PublicActionDef = {}> = DefineActions<{
|
|
115
|
+
setLocale: {
|
|
116
|
+
payload: string,
|
|
117
|
+
result: string,
|
|
118
|
+
},
|
|
119
|
+
getLocale: {
|
|
120
|
+
payload: undefined,
|
|
121
|
+
result: string,
|
|
122
|
+
},
|
|
123
|
+
updateI18nConfig: {
|
|
124
|
+
payload: Partial<I18nConfig>,
|
|
125
|
+
result: string,
|
|
126
|
+
},
|
|
127
|
+
} & T>
|
|
128
|
+
|
|
114
129
|
type $postMessage<T extends MessagesDef = never> = [T] extends [never]
|
|
115
130
|
? (params: { event: string, payload?: any }) => void
|
|
116
131
|
: <K extends keyof T>(params: { event: K, payload?: T[K]['payload'] }) => void
|
|
117
132
|
|
|
118
|
-
|
|
133
|
+
type $logger = {
|
|
119
134
|
info: (message: any, type?: string) => void,
|
|
120
135
|
warn: (message: any, type?: string) => void,
|
|
121
136
|
error: (message: any, type?: string) => void,
|
|
@@ -126,7 +141,7 @@ declare module '@variousjs/various' {
|
|
|
126
141
|
paramsOrDefaultText?: Record<string, string | number> | string,
|
|
127
142
|
defaultText?: string,
|
|
128
143
|
) => string) & {
|
|
129
|
-
update: (config: Partial<I18nConfig
|
|
144
|
+
update: (config: Partial<I18nConfig>) => void,
|
|
130
145
|
}
|
|
131
146
|
|
|
132
147
|
interface ComponentBuiltinProps<
|
|
@@ -140,16 +155,20 @@ declare module '@variousjs/various' {
|
|
|
140
155
|
$t: Intl,
|
|
141
156
|
$logger: $logger,
|
|
142
157
|
$self: { url: string, module: ModuleDef },
|
|
158
|
+
$locale: string,
|
|
143
159
|
}
|
|
144
160
|
|
|
145
161
|
export interface I18nConfig {
|
|
146
|
-
/** app store key */
|
|
147
|
-
lngStoreKey: string,
|
|
148
162
|
resources: Record<string, Record<string, string>>,
|
|
149
163
|
}
|
|
150
164
|
|
|
151
165
|
export type I18n = () => I18nConfig | Promise<I18nConfig>
|
|
152
166
|
|
|
167
|
+
export type GlobalI18n = {
|
|
168
|
+
defaultLocale?: string, // en
|
|
169
|
+
getResources?: () => I18nConfig | Promise<I18nConfig>
|
|
170
|
+
}
|
|
171
|
+
|
|
153
172
|
export type OnMessage<T extends MessagesDef = never> = (message: Message<T>) => void
|
|
154
173
|
|
|
155
174
|
export type VariousProps<
|
|
@@ -172,6 +191,7 @@ declare module '@variousjs/various' {
|
|
|
172
191
|
$error: VariousError,
|
|
173
192
|
$store: Readonly<Store>,
|
|
174
193
|
$self: { url: string, module: ModuleDef },
|
|
194
|
+
$locale: string,
|
|
175
195
|
}
|
|
176
196
|
export type ErrorFallbackNode<
|
|
177
197
|
Store extends object = ObjectRecord
|
|
@@ -180,6 +200,7 @@ declare module '@variousjs/various' {
|
|
|
180
200
|
export interface FallbackProps<Store extends object = ObjectRecord> {
|
|
181
201
|
$store: Readonly<Store>,
|
|
182
202
|
$self: { url: string, module: ModuleDef },
|
|
203
|
+
$locale: string,
|
|
183
204
|
}
|
|
184
205
|
export type FallbackNode<
|
|
185
206
|
Store extends object = ObjectRecord
|
|
@@ -242,7 +263,7 @@ declare module '@variousjs/various' {
|
|
|
242
263
|
onDispatch?: DispatchEvent,
|
|
243
264
|
onLog?: LogEvent,
|
|
244
265
|
},
|
|
245
|
-
i18n?:
|
|
266
|
+
i18n?: GlobalI18n,
|
|
246
267
|
}
|
|
247
268
|
|
|
248
269
|
export interface Config {
|
|
@@ -260,14 +281,17 @@ declare module '@variousjs/various' {
|
|
|
260
281
|
|
|
261
282
|
export function createComponent<
|
|
262
283
|
Props extends object = ObjectRecord,
|
|
263
|
-
|
|
264
|
-
|
|
284
|
+
Ref = unknown,
|
|
285
|
+
Store extends object = ObjectRecord
|
|
265
286
|
>(
|
|
266
287
|
config: {
|
|
267
288
|
url?: string,
|
|
268
289
|
type?: VariousComponentType,
|
|
269
290
|
module: ModuleDef,
|
|
270
291
|
},
|
|
292
|
+
/**
|
|
293
|
+
* set store keys if component created before store initialization
|
|
294
|
+
*/
|
|
271
295
|
storeKeys?: (keyof Store)[],
|
|
272
296
|
): ComponentType<ComponentDefaultProps<Ref> & Props>
|
|
273
297
|
|
package/package.json
CHANGED
package/standalone.d.ts
CHANGED
|
@@ -17,8 +17,8 @@ declare module '@variousjs/various/standalone' {
|
|
|
17
17
|
|
|
18
18
|
export function createComponent<
|
|
19
19
|
Props extends object = ObjectRecord,
|
|
20
|
-
Store extends object = ObjectRecord,
|
|
21
20
|
Ref = unknown,
|
|
21
|
+
Store extends object = ObjectRecord
|
|
22
22
|
>(
|
|
23
23
|
config: {
|
|
24
24
|
module: ModuleDef,
|
|
@@ -28,6 +28,9 @@ declare module '@variousjs/various/standalone' {
|
|
|
28
28
|
string,
|
|
29
29
|
DependencyType
|
|
30
30
|
>>,
|
|
31
|
+
/**
|
|
32
|
+
* set store keys if component created before store initialization
|
|
33
|
+
*/
|
|
31
34
|
storeKeys?: (keyof Store)[],
|
|
32
35
|
},
|
|
33
36
|
): ComponentType<Props & {
|
|
@@ -39,7 +42,7 @@ declare module '@variousjs/various/standalone' {
|
|
|
39
42
|
|
|
40
43
|
export type AppConfig<Store extends object = ObjectRecord> = Pick<
|
|
41
44
|
App<Store>,
|
|
42
|
-
'actions' | 'store' | 'Fallback' | 'ErrorFallback'
|
|
45
|
+
'actions' | 'store' | 'Fallback' | 'ErrorFallback' | 'i18n'
|
|
43
46
|
> & {
|
|
44
47
|
dependencies: Partial<Record<
|
|
45
48
|
string,
|