@mpxjs/core 2.9.70-alpha.0 → 2.9.70

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.
Files changed (34) hide show
  1. package/@types/global.d.ts +1 -1
  2. package/LICENSE +433 -0
  3. package/package.json +9 -6
  4. package/src/convertor/convertor.js +0 -2
  5. package/src/convertor/getConvertMode.js +0 -1
  6. package/src/core/proxy.js +8 -9
  7. package/src/index.js +3 -14
  8. package/src/observer/reactive.js +4 -3
  9. package/src/platform/builtInMixins/directiveHelperMixin.ios.js +4 -1
  10. package/src/platform/builtInMixins/index.js +0 -5
  11. package/src/platform/builtInMixins/styleHelperMixin.ios.js +1 -1
  12. package/src/platform/createApp.ios.js +24 -23
  13. package/src/platform/createApp.js +5 -14
  14. package/src/platform/env/event.js +108 -0
  15. package/src/platform/env/index.ios.js +51 -0
  16. package/src/platform/env/index.js +8 -0
  17. package/src/platform/env/index.web.js +48 -0
  18. package/src/{external → platform/env}/vuePlugin.js +1 -1
  19. package/src/platform/export/index.js +1 -1
  20. package/src/platform/patch/builtInKeysMap.js +1 -1
  21. package/src/platform/patch/getDefaultOptions.ios.js +9 -13
  22. package/src/platform/patch/index.js +3 -3
  23. package/src/convertor/wxToTenon.js +0 -86
  24. package/src/external/vue.js +0 -1
  25. package/src/external/vue.tenon.js +0 -13
  26. package/src/external/vue.web.js +0 -6
  27. package/src/platform/builtInMixins/pageStatusMixin.tenon.js +0 -40
  28. package/src/platform/builtInMixins/proxyEventMixin.tenon.js +0 -46
  29. package/src/platform/export/apiInject.tenon.js +0 -1
  30. package/src/platform/export/index.tenon.js +0 -78
  31. package/src/platform/patch/getDefaultOptions.tenon.js +0 -99
  32. package/src/platform/patch/lifecycle/index.tenon.js +0 -52
  33. /package/src/platform/export/{apiInject.js → inject.js} +0 -0
  34. /package/src/platform/export/{apiInject.web.js → inject.web.js} +0 -0
@@ -1,78 +0,0 @@
1
- import {
2
- effectScope as vueEffectScope,
3
- getCurrentScope as getCurrentVueScope,
4
- onScopeDispose
5
- } from '@hummer/tenon-vue'
6
-
7
- import {
8
- hasOwn,
9
- isValidArrayIndex
10
- } from '@mpxjs/utils'
11
-
12
- export {
13
- // watch
14
- watchEffect,
15
- watchSyncEffect,
16
- watchPostEffect,
17
- watch,
18
- // reactive
19
- reactive,
20
- isReactive,
21
- shallowReactive,
22
- markRaw,
23
- // ref
24
- ref,
25
- unref,
26
- toRef,
27
- toRefs,
28
- isRef,
29
- customRef,
30
- shallowRef,
31
- triggerRef,
32
- // computed
33
- computed,
34
- // instance
35
- getCurrentInstance,
36
- provide,
37
- inject
38
- } from '@hummer/tenon-vue'
39
-
40
- export function set (target, key, val) {
41
- if (Array.isArray(target) && isValidArrayIndex(key)) {
42
- target.length = Math.max(target.length, key)
43
- target.splice(key, 1, val)
44
- return val
45
- }
46
- target[key] = val
47
- return val
48
- }
49
-
50
- export function del (target, key) {
51
- if (Array.isArray(target) && isValidArrayIndex(key)) {
52
- target.splice(key, 1)
53
- return
54
- }
55
- if (!hasOwn(target, key)) {
56
- return
57
- }
58
- delete target[key]
59
- }
60
-
61
- const noop = () => {
62
- }
63
-
64
- const fixEffectScope = (scope) => {
65
- scope.pause = noop
66
- scope.resume = noop
67
- return scope
68
- }
69
-
70
- const effectScope = (detached) => fixEffectScope(vueEffectScope(detached))
71
- const getCurrentScope = () => fixEffectScope(getCurrentVueScope())
72
-
73
- export {
74
- // effectScope
75
- effectScope,
76
- getCurrentScope,
77
- onScopeDispose
78
- }
@@ -1,99 +0,0 @@
1
- import builtInKeysMap from './builtInKeysMap'
2
- import mergeOptions from '../../core/mergeOptions'
3
- import { getCurrentInstance as getCurrentVueInstance } from '../export/index'
4
- import MpxProxy, { setCurrentInstance, unsetCurrentInstance } from '../../core/proxy'
5
- import { diffAndCloneA, warn, wrapMethodsWithErrorHandling } from '@mpxjs/utils'
6
- import { UPDATED, CREATED, MOUNTED, UNMOUNTED } from '../../core/innerLifecycle'
7
-
8
- function filterOptions (options) {
9
- const newOptions = {}
10
- Object.keys(options).forEach(key => {
11
- if (builtInKeysMap[key]) {
12
- return
13
- }
14
- if (key === 'data' || key === 'dataFn') {
15
- newOptions.data = function mergeFn () {
16
- return Object.assign(
17
- diffAndCloneA(options.data || {}).clone,
18
- options.dataFn && options.dataFn.call(this)
19
- )
20
- }
21
- } else if (key === 'methods') {
22
- newOptions[key] = wrapMethodsWithErrorHandling(options[key])
23
- } else {
24
- newOptions[key] = options[key]
25
- }
26
- })
27
- return newOptions
28
- }
29
-
30
- function initProxy (context, rawOptions) {
31
- if (!context.__mpxProxy) {
32
- // 缓存options
33
- context.$rawOptions = rawOptions
34
- // 创建proxy对象
35
- context.__mpxProxy = new MpxProxy(rawOptions, context)
36
- // todo 待问题修复后需要还原
37
- // context.__mpxProxy.callHook(CREATED, Hummer.pageInfo && Hummer.pageInfo.params && [Hummer.pageInfo.params])
38
- }
39
- }
40
-
41
- export function getDefaultOptions ({type, rawOptions = {}, currentInject }) {
42
- const rawSetup = rawOptions.setup
43
- if (rawSetup) {
44
- rawOptions.setup = (props) => {
45
- const { proxy: instance } = getCurrentVueInstance()
46
- initProxy(instance, rawOptions)
47
- setCurrentInstance(instance.__mpxProxy)
48
- const newContext = {
49
- triggerEvent: (eventName, eventDetail) => {
50
- return instance.$emit(eventName, {
51
- type: eventName,
52
- detail: eventDetail
53
- })
54
- },
55
- get refs () { return instance.$refs },
56
- forceUpdate: instance.$forceUpdate.bind(instance),
57
- selectComponent: () => {
58
- warn('selectComponent is not supported in Tenon')
59
- },
60
- selectAllComponents: () => {
61
- warn('selectAllComponents is not supported in Tenon')
62
- },
63
- createSelectorQuery: () => {
64
- warn('createSelectorQuery is not supported in Tenon')
65
- },
66
- createIntersectionObserver: () => {
67
- warn('createIntersectionObserver is not supported in Tenon')
68
- }
69
- }
70
- const setupRes = rawSetup(props, newContext)
71
- unsetCurrentInstance(instance.__mpxProxy)
72
- return setupRes
73
- }
74
- }
75
-
76
- const hookNames = type === 'page' ? ['onLoad', 'onReady', 'onUnload'] : ['created', 'mounted', 'unmounted']
77
- const rootMixins = [{
78
- [hookNames[0]] (...params) {
79
- if (!this.__mpxProxy) {
80
- initProxy(this, rawOptions, currentInject, params)
81
- }
82
- // todo 待问题修复后需要移除,目前逻辑是已经创建实例的情况下依旧会重复执行
83
- this.__mpxProxy.callHook(CREATED, Hummer.pageInfo && Hummer.pageInfo.params && [Hummer.pageInfo.params])
84
- },
85
- [hookNames[1]] () {
86
- this.__mpxProxy && this.__mpxProxy.callHook(MOUNTED, Hummer.pageInfo && Hummer.pageInfo.params && [Hummer.pageInfo.params])
87
- },
88
- updated () {
89
- this.__mpxProxy && this.__mpxProxy.callHook(UPDATED)
90
- },
91
- [hookNames[2]] () {
92
- this.__mpxProxy && this.__mpxProxy.callHook(UNMOUNTED)
93
- }
94
- }]
95
- // 为了在builtMixin中可以使用某些rootMixin实现的特性(如数据响应等),此处builtInMixin在rootMixin之后执行,但是当builtInMixin使用存在对应内建生命周期的目标平台声明周期写法时,可能会出现用户生命周期比builtInMixin中的生命周期先执行的情况,为了避免这种情况发生,builtInMixin应该尽可能使用内建生命周期来编写
96
- rawOptions.mixins = rawOptions.mixins ? rootMixins.concat(rawOptions.mixins) : rootMixins
97
- rawOptions = mergeOptions(rawOptions, type, false)
98
- return filterOptions(rawOptions)
99
- }
@@ -1,52 +0,0 @@
1
- const COMPONENT_HOOKS = [
2
- 'beforeCreate',
3
- 'created',
4
- 'beforeMount',
5
- 'mounted',
6
- 'beforeUpdate',
7
- 'updated',
8
- // 'activated',
9
- // 'deactivated',
10
- 'beforeDestroy',
11
- 'destroyed',
12
- 'errorCaptured',
13
- 'beforeUnmount',
14
- 'unmounted'
15
- // 'onPageNotFound'
16
- ]
17
-
18
- const PAGE_HOOKS = [
19
- ...COMPONENT_HOOKS,
20
- 'onLoad',
21
- 'onReady',
22
- 'onShow',
23
- 'onHide',
24
- 'onUnload'
25
- // 'onBack',
26
- // 'onPullDownRefresh',
27
- // 'onReachBottom',
28
- // 'onPageScroll',
29
- // 'onTabItemTap',
30
- // 'onResize'
31
- ]
32
-
33
- const APP_HOOKS = [
34
- ...COMPONENT_HOOKS,
35
- 'onLaunch',
36
- 'onShow',
37
- 'onHide',
38
- 'onError'
39
- // 'onPageNotFound',
40
- // 'onUnhandledRejection',
41
- // 'onThemeChange'
42
- ]
43
-
44
- export const LIFECYCLE = {
45
- APP_HOOKS,
46
- PAGE_HOOKS,
47
- COMPONENT_HOOKS
48
- }
49
-
50
- export const pageMode = ''
51
-
52
- export const lifecycleProxyMap = {}
File without changes