@variousjs/various 5.2.1 → 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/index.d.ts CHANGED
@@ -111,6 +111,21 @@ 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
@@ -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>, type?: 'app') => void,
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?: I18n,
266
+ i18n?: GlobalI18n,
246
267
  }
247
268
 
248
269
  export interface Config {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@variousjs/various",
3
- "version": "5.2.1",
3
+ "version": "5.3.0",
4
4
  "description": "RequireJS(AMD) + React",
5
5
  "files": [
6
6
  "dist",
package/standalone.d.ts CHANGED
@@ -42,7 +42,7 @@ declare module '@variousjs/various/standalone' {
42
42
 
43
43
  export type AppConfig<Store extends object = ObjectRecord> = Pick<
44
44
  App<Store>,
45
- 'actions' | 'store' | 'Fallback' | 'ErrorFallback'
45
+ 'actions' | 'store' | 'Fallback' | 'ErrorFallback' | 'i18n'
46
46
  > & {
47
47
  dependencies: Partial<Record<
48
48
  string,