@mpxjs/core 2.8.6 → 2.8.8

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/@types/index.d.ts CHANGED
@@ -193,6 +193,10 @@ export interface MpxComponentIns {
193
193
  $watch (expr: string | (() => any), handler: WatchHandler | WatchOptWithHandler, options?: WatchOpt): () => void
194
194
  $forceUpdate (params?: object, callback?: () => void): void
195
195
  $nextTick (fn: () => void): void
196
+ $i18n: {
197
+ locale: string
198
+ fallbackLocale: string
199
+ }
196
200
  $t: typeof t
197
201
  $tc: typeof tc
198
202
  $te: typeof te
@@ -300,6 +304,12 @@ export interface Mpx {
300
304
  i18n: {
301
305
  readonly global: UseI18n
302
306
  dispose (): void
307
+ locale: string
308
+ fallbackLocale: string
309
+ t: typeof t
310
+ tc: typeof tc
311
+ te: typeof te
312
+ tm: typeof tm
303
313
  }
304
314
  }
305
315
 
@@ -452,13 +462,11 @@ interface UseI18n {
452
462
  inheritLocale: boolean
453
463
  fallbackRoot: boolean
454
464
 
455
- t (key: string, values?: I18nValues): string
456
-
457
- t (key: string, choice: number, values?: I18nValues): string
465
+ t: typeof t | typeof tc
458
466
 
459
- te (key: string): boolean
467
+ te: typeof te
460
468
 
461
- tm (key: string): any
469
+ tm: typeof tm
462
470
 
463
471
  getLocaleMessage (locale: string): StringObj
464
472
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mpxjs/core",
3
- "version": "2.8.6",
3
+ "version": "2.8.8",
4
4
  "description": "mpx runtime core",
5
5
  "keywords": [
6
6
  "miniprogram",
@@ -47,5 +47,5 @@
47
47
  "url": "https://github.com/didi/mpx/issues"
48
48
  },
49
49
  "sideEffects": false,
50
- "gitHead": "c4261c7ea5a16ee3ceaac78afad09e5e0b35d39a"
50
+ "gitHead": "23a729d198962e2b1d7a5d5672066d39e7271949"
51
51
  }
@@ -48,30 +48,31 @@ if (isBrowser) {
48
48
  }
49
49
 
50
50
  export default function pageStatusMixin (mixinType) {
51
+ const mixin = {}
52
+
51
53
  if (mixinType === 'page') {
52
- return {
54
+ Object.assign(mixin, {
53
55
  data: {
54
- mpxPageStatus: 'show'
56
+ mpxPageStatus: null
55
57
  },
56
58
  activated () {
57
59
  this.mpxPageStatus = 'show'
58
- this.__mpxProxy.callHook(ONSHOW)
59
60
  },
60
61
  deactivated () {
61
62
  this.mpxPageStatus = 'hide'
62
- this.__mpxProxy.callHook(ONHIDE)
63
63
  },
64
64
  created () {
65
65
  // onLoad应该在用户声明周期CREATED后再执行,故此处使用原生created声明周期来触发onLoad
66
66
  const query = (global.__mpxRouter && global.__mpxRouter.currentRoute && global.__mpxRouter.currentRoute.query) || {}
67
67
  this.__mpxProxy.callHook(ONLOAD, [query])
68
68
  }
69
- }
69
+ })
70
70
  }
71
- return {
71
+
72
+ Object.assign(mixin, {
72
73
  [CREATED] () {
73
- const pageInstance = getCurrentPageInstance()
74
- if (!pageInstance) {
74
+ const pageInstance = mixinType === 'page' ? this : getCurrentPageInstance()
75
+ if (pageInstance) {
75
76
  this.$watch(() => pageInstance.mpxPageStatus, status => {
76
77
  if (!status) return
77
78
  if (status === 'show') this.__mpxProxy.callHook(ONSHOW)
@@ -91,5 +92,7 @@ export default function pageStatusMixin (mixinType) {
91
92
  })
92
93
  }
93
94
  }
94
- }
95
+ })
96
+
97
+ return mixin
95
98
  }
@@ -7,7 +7,6 @@ const APIs = {
7
7
  mixin: injectMixins,
8
8
  observable: reactive,
9
9
  watch,
10
- // use,
11
10
  set,
12
11
  delete: del
13
12
  }
@@ -1,25 +1,23 @@
1
1
  import Vue from '../../vue'
2
2
  import { injectMixins } from '../../core/injectMixins'
3
3
 
4
- function initApi () {
5
- const vm = new Vue()
6
- const observable = Vue.observable.bind(Vue)
7
- const watch = vm.$watch.bind(vm)
8
- const set = Vue.set.bind(Vue)
9
- const del = Vue.delete.bind(Vue)
10
- APIs = {
11
- injectMixins,
12
- mixin: injectMixins,
13
- observable,
14
- watch,
15
- // use,
16
- set,
17
- delete: del
18
- }
19
- return APIs
4
+ const vm = new Vue()
5
+ const observable = Vue.observable.bind(Vue)
6
+ const watch = vm.$watch.bind(vm)
7
+ const set = Vue.set.bind(Vue)
8
+ const del = Vue.delete.bind(Vue)
9
+
10
+ const APIs = {
11
+ injectMixins,
12
+ mixin: injectMixins,
13
+ observable,
14
+ watch,
15
+ set,
16
+ delete: del
20
17
  }
21
- let APIs = initApi()
18
+
22
19
  const InstanceAPIs = {}
20
+
23
21
  export {
24
22
  APIs,
25
23
  InstanceAPIs
@@ -7,7 +7,7 @@ import { getDefaultOptions as getWebDefaultOptions } from './web/getDefaultOptio
7
7
  import { error } from '@mpxjs/utils'
8
8
 
9
9
  export default function createFactory (type) {
10
- return (options, { isNative, customCtor, customCtorType } = {}) => {
10
+ return (options = {}, { isNative, customCtor, customCtorType } = {}) => {
11
11
  options.__nativeRender__ = !!isNative
12
12
  options.__type__ = type
13
13
  let ctor