vue 2.6.13 → 2.7.0-alpha.2
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/README.md +17 -295
- package/compiler-sfc/index.d.ts +1 -0
- package/compiler-sfc/index.js +1 -0
- package/compiler-sfc/index.mjs +1 -0
- package/compiler-sfc/package.json +5 -0
- package/dist/vue.common.dev.js +11481 -11946
- package/dist/vue.common.prod.js +8 -3
- package/dist/vue.esm.browser.js +11321 -12011
- package/dist/vue.esm.browser.min.js +8 -3
- package/dist/vue.esm.js +11476 -11984
- package/dist/vue.js +11484 -11949
- package/dist/vue.min.js +8 -3
- package/dist/vue.runtime.common.dev.js +8427 -8421
- package/dist/vue.runtime.common.prod.js +8 -3
- package/dist/vue.runtime.esm.js +8436 -8454
- package/dist/vue.runtime.js +8430 -8424
- package/dist/vue.runtime.min.js +8 -3
- package/package.json +88 -111
- package/packages/compiler-sfc/dist/compiler-sfc.js +7 -0
- package/packages/compiler-sfc/node_modules/.bin/parser +17 -0
- package/packages/compiler-sfc/node_modules/.bin/sass +17 -0
- package/packages/compiler-sfc/package.json +30 -0
- package/src/compiler/{codeframe.js → codeframe.ts} +9 -7
- package/src/compiler/codegen/{events.js → events.ts} +21 -41
- package/src/compiler/codegen/{index.js → index.ts} +146 -136
- package/src/compiler/{create-compiler.js → create-compiler.ts} +26 -18
- package/src/compiler/directives/bind.ts +9 -0
- package/src/compiler/directives/{index.js → index.ts} +0 -2
- package/src/compiler/directives/{model.js → model.ts} +15 -18
- package/src/compiler/directives/{on.js → on.ts} +3 -4
- package/src/compiler/{error-detector.js → error-detector.ts} +61 -31
- package/src/compiler/{helpers.js → helpers.ts} +73 -61
- package/src/compiler/{index.js → index.ts} +2 -3
- package/src/compiler/{optimizer.js → optimizer.ts} +30 -23
- package/src/compiler/parser/{entity-decoder.js → entity-decoder.ts} +1 -3
- package/src/compiler/parser/{filter-parser.js → filter-parser.ts} +43 -24
- package/src/compiler/parser/{html-parser.js → html-parser.ts} +50 -29
- package/src/compiler/parser/{index.js → index.ts} +190 -172
- package/src/compiler/parser/{text-parser.js → text-parser.ts} +8 -9
- package/src/compiler/{to-function.js → to-function.ts} +27 -22
- package/src/core/components/{index.js → index.ts} +0 -0
- package/src/core/components/{keep-alive.js → keep-alive.ts} +42 -30
- package/src/core/{config.js → config.ts} +28 -30
- package/src/core/global-api/{assets.js → assets.ts} +8 -7
- package/src/core/global-api/{extend.js → extend.ts} +10 -13
- package/src/core/global-api/{index.js → index.ts} +4 -5
- package/src/core/global-api/{mixin.js → mixin.ts} +2 -3
- package/src/core/global-api/use.ts +23 -0
- package/src/core/{index.js → index.ts} +1 -1
- package/src/core/instance/{events.js → events.ts} +41 -24
- package/src/core/instance/{index.js → index.ts} +9 -5
- package/src/core/instance/{init.js → init.ts} +26 -15
- package/src/core/instance/inject.ts +72 -0
- package/src/core/instance/{lifecycle.js → lifecycle.ts} +86 -44
- package/src/core/instance/{proxy.js → proxy.ts} +29 -24
- package/src/core/instance/render-helpers/{bind-dynamic-keys.js → bind-dynamic-keys.ts} +6 -5
- package/src/core/instance/render-helpers/{bind-object-listeners.js → bind-object-listeners.ts} +4 -8
- package/src/core/instance/render-helpers/{bind-object-props.js → bind-object-props.ts} +12 -17
- package/src/core/instance/render-helpers/{check-keycodes.js → check-keycodes.ts} +5 -7
- package/src/core/instance/render-helpers/{index.js → index.ts} +1 -3
- package/src/core/instance/render-helpers/{render-list.js → render-list.ts} +12 -13
- package/src/core/instance/render-helpers/{render-slot.js → render-slot.ts} +10 -11
- package/src/core/instance/render-helpers/{render-static.js → render-static.ts} +7 -10
- package/src/core/instance/render-helpers/{resolve-filter.js → resolve-filter.ts} +1 -3
- package/src/core/instance/render-helpers/{resolve-scoped-slots.js → resolve-scoped-slots.ts} +11 -8
- package/src/core/instance/render-helpers/{resolve-slots.js → resolve-slots.ts} +12 -11
- package/src/core/instance/{render.js → render.ts} +66 -29
- package/src/core/instance/{state.js → state.ts} +100 -83
- package/src/core/observer/{array.js → array.ts} +11 -2
- package/src/core/observer/{dep.js → dep.ts} +37 -15
- package/src/core/observer/{index.js → index.ts} +137 -71
- package/src/core/observer/{scheduler.js → scheduler.ts} +42 -43
- package/src/core/observer/{traverse.js → traverse.ts} +10 -7
- package/src/core/observer/{watcher.js → watcher.ts} +88 -60
- package/src/core/util/{debug.js → debug.ts} +38 -34
- package/src/core/util/{env.js → env.ts} +27 -30
- package/src/core/util/{error.js → error.ts} +12 -14
- package/src/core/util/{index.js → index.ts} +0 -2
- package/src/core/util/{lang.js → lang.ts} +6 -7
- package/src/core/util/{next-tick.js → next-tick.ts} +16 -10
- package/src/core/util/{options.js → options.ts} +119 -114
- package/src/core/util/{perf.js → perf.ts} +5 -1
- package/src/core/util/{props.js → props.ts} +54 -50
- package/src/core/vdom/{create-component.js → create-component.ts} +51 -50
- package/src/core/vdom/{create-element.js → create-element.ts} +49 -43
- package/src/core/vdom/{create-functional-component.js → create-functional-component.ts} +52 -27
- package/src/core/vdom/helpers/{extract-props.js → extract-props.ts} +18 -18
- package/src/core/vdom/helpers/{get-first-component-child.js → get-first-component-child.ts} +6 -5
- package/src/core/vdom/helpers/{index.js → index.ts} +0 -2
- package/src/core/vdom/helpers/is-async-placeholder.ts +6 -0
- package/src/core/vdom/helpers/{merge-hook.js → merge-hook.ts} +7 -5
- package/src/core/vdom/helpers/{normalize-children.js → normalize-children.ts} +26 -16
- package/src/core/vdom/helpers/{normalize-scoped-slots.js → normalize-scoped-slots.ts} +23 -17
- package/src/core/vdom/helpers/{resolve-async-component.js → resolve-async-component.ts} +29 -37
- package/src/core/vdom/helpers/update-listeners.ts +101 -0
- package/src/core/vdom/modules/{directives.js → directives.ts} +20 -14
- package/src/core/vdom/modules/index.ts +4 -0
- package/src/core/vdom/modules/template-ref.ts +96 -0
- package/src/core/vdom/{patch.js → patch.ts} +239 -138
- package/src/core/vdom/{vnode.js → vnode.ts} +36 -31
- package/src/global.d.ts +15 -0
- package/src/platforms/web/compiler/directives/html.ts +8 -0
- package/src/platforms/web/compiler/directives/{index.js → index.ts} +0 -0
- package/src/platforms/web/compiler/directives/{model.js → model.ts} +47 -41
- package/src/platforms/web/compiler/directives/{text.js → text.ts} +2 -3
- package/src/platforms/web/compiler/{index.js → index.ts} +0 -2
- package/src/platforms/web/compiler/modules/{class.js → class.ts} +10 -15
- package/src/platforms/web/compiler/modules/{index.js → index.ts} +1 -5
- package/src/platforms/web/compiler/modules/{model.js → model.ts} +6 -11
- package/src/platforms/web/compiler/modules/{style.js → style.ts} +9 -14
- package/src/platforms/web/compiler/{options.js → options.ts} +1 -2
- package/src/platforms/web/compiler/{util.js → util.ts} +5 -7
- package/src/platforms/web/entry-compiler-sfc.ts +1 -0
- package/src/platforms/web/{entry-compiler.js → entry-compiler.ts} +1 -3
- package/src/platforms/web/{entry-runtime.js → entry-runtime-esm.ts} +2 -2
- package/src/platforms/web/entry-runtime-with-compiler-esm.ts +5 -0
- package/src/platforms/web/entry-runtime-with-compiler.ts +10 -0
- package/src/platforms/web/entry-runtime.ts +7 -0
- package/src/platforms/web/runtime/{class-util.js → class-util.ts} +2 -4
- package/src/platforms/web/runtime/components/{index.js → index.ts} +0 -0
- package/src/platforms/web/runtime/components/{transition-group.js → transition-group.ts} +59 -46
- package/src/platforms/web/runtime/components/{transition.js → transition.ts} +43 -36
- package/src/platforms/web/runtime/directives/{index.js → index.ts} +0 -0
- package/src/platforms/web/runtime/directives/{model.js → model.ts} +22 -21
- package/src/platforms/web/runtime/directives/{show.js → show.ts} +11 -10
- package/src/platforms/web/runtime/{index.js → index.ts} +9 -10
- package/src/platforms/web/runtime/modules/{attrs.js → attrs.ts} +12 -16
- package/src/platforms/web/runtime/modules/{class.js → class.ts} +7 -18
- package/src/platforms/web/runtime/modules/{dom-props.js → dom-props.ts} +24 -17
- package/src/platforms/web/runtime/modules/{events.js → events.ts} +22 -15
- package/src/platforms/web/runtime/modules/{index.js → index.ts} +1 -8
- package/src/platforms/web/runtime/modules/{style.js → style.ts} +24 -13
- package/src/platforms/web/runtime/modules/{transition.js → transition.ts} +61 -63
- package/src/platforms/web/runtime/node-ops.ts +66 -0
- package/src/platforms/web/runtime/{patch.js → patch.ts} +0 -2
- package/src/platforms/web/runtime/{transition-util.js → transition-util.ts} +63 -38
- package/src/platforms/web/{entry-runtime-with-compiler.js → runtime-with-compiler.ts} +28 -19
- package/src/platforms/web/util/{attrs.js → attrs.ts} +18 -14
- package/src/platforms/web/util/{class.js → class.ts} +23 -21
- package/src/platforms/web/util/{compat.js → compat.ts} +4 -4
- package/src/platforms/web/util/{element.js → element.ts} +21 -22
- package/src/platforms/web/util/{index.js → index.ts} +2 -6
- package/src/platforms/web/util/{style.js → style.ts} +12 -12
- package/src/sfc/{parser.js → parser.ts} +18 -15
- package/src/shared/{constants.js → constants.ts} +2 -6
- package/src/shared/{util.js → util.ts} +78 -55
- package/src/types/compiler.ts +224 -0
- package/src/types/component.ts +209 -0
- package/src/types/global-api.ts +37 -0
- package/src/types/modules.d.ts +15 -0
- package/src/types/options.ts +120 -0
- package/src/types/ssr.ts +27 -0
- package/src/types/utils.ts +3 -0
- package/src/types/vnode.ts +127 -0
- package/src/v3/apiInject.ts +66 -0
- package/src/v3/apiLifecycle.ts +53 -0
- package/src/v3/apiSetup.ts +161 -0
- package/src/v3/apiWatch.ts +355 -0
- package/src/v3/currentInstance.ts +23 -0
- package/src/v3/debug.ts +21 -0
- package/src/v3/h.ts +18 -0
- package/src/v3/index.ts +77 -0
- package/src/v3/reactivity/computed.ts +100 -0
- package/src/v3/reactivity/effect.ts +20 -0
- package/src/v3/reactivity/effectScope.ts +134 -0
- package/src/v3/reactivity/operations.ts +14 -0
- package/src/v3/reactivity/reactive.ts +123 -0
- package/src/v3/reactivity/readonly.ts +121 -0
- package/src/v3/reactivity/ref.ts +249 -0
- package/types/index.d.ts +10 -13
- package/types/options.d.ts +265 -132
- package/types/plugin.d.ts +4 -4
- package/types/umd.d.ts +47 -27
- package/types/v3-generated.d.ts +389 -0
- package/types/v3.d.ts +16 -0
- package/types/vnode.d.ts +70 -57
- package/types/vue.d.ts +292 -88
- package/dist/README.md +0 -122
- package/src/compiler/directives/bind.js +0 -11
- package/src/core/global-api/use.js +0 -23
- package/src/core/instance/inject.js +0 -73
- package/src/core/vdom/helpers/is-async-placeholder.js +0 -5
- package/src/core/vdom/helpers/update-listeners.js +0 -95
- package/src/core/vdom/modules/index.js +0 -7
- package/src/core/vdom/modules/ref.js +0 -45
- package/src/platforms/web/compiler/directives/html.js +0 -9
- package/src/platforms/web/entry-server-basic-renderer.js +0 -13
- package/src/platforms/web/entry-server-renderer.js +0 -27
- package/src/platforms/web/runtime/node-ops.js +0 -59
- package/src/platforms/web/server/compiler.js +0 -11
- package/src/platforms/web/server/directives/index.js +0 -7
- package/src/platforms/web/server/directives/model.js +0 -44
- package/src/platforms/web/server/directives/show.js +0 -12
- package/src/platforms/web/server/modules/attrs.js +0 -67
- package/src/platforms/web/server/modules/class.js +0 -11
- package/src/platforms/web/server/modules/dom-props.js +0 -50
- package/src/platforms/web/server/modules/index.js +0 -11
- package/src/platforms/web/server/modules/style.js +0 -41
- package/src/platforms/web/server/util.js +0 -101
- package/src/platforms/weex/compiler/directives/index.js +0 -5
- package/src/platforms/weex/compiler/directives/model.js +0 -33
- package/src/platforms/weex/compiler/index.js +0 -52
- package/src/platforms/weex/compiler/modules/append.js +0 -27
- package/src/platforms/weex/compiler/modules/class.js +0 -74
- package/src/platforms/weex/compiler/modules/index.js +0 -13
- package/src/platforms/weex/compiler/modules/props.js +0 -37
- package/src/platforms/weex/compiler/modules/recycle-list/component-root.js +0 -13
- package/src/platforms/weex/compiler/modules/recycle-list/component.js +0 -16
- package/src/platforms/weex/compiler/modules/recycle-list/index.js +0 -60
- package/src/platforms/weex/compiler/modules/recycle-list/recycle-list.js +0 -50
- package/src/platforms/weex/compiler/modules/recycle-list/text.js +0 -23
- package/src/platforms/weex/compiler/modules/recycle-list/v-bind.js +0 -21
- package/src/platforms/weex/compiler/modules/recycle-list/v-for.js +0 -33
- package/src/platforms/weex/compiler/modules/recycle-list/v-if.js +0 -63
- package/src/platforms/weex/compiler/modules/recycle-list/v-on.js +0 -25
- package/src/platforms/weex/compiler/modules/recycle-list/v-once.js +0 -19
- package/src/platforms/weex/compiler/modules/style.js +0 -87
- package/src/platforms/weex/entry-compiler.js +0 -2
- package/src/platforms/weex/entry-framework.js +0 -187
- package/src/platforms/weex/entry-runtime-factory.js +0 -6
- package/src/platforms/weex/runtime/components/index.js +0 -9
- package/src/platforms/weex/runtime/components/richtext.js +0 -82
- package/src/platforms/weex/runtime/components/transition-group.js +0 -148
- package/src/platforms/weex/runtime/components/transition.js +0 -9
- package/src/platforms/weex/runtime/directives/index.js +0 -2
- package/src/platforms/weex/runtime/index.js +0 -42
- package/src/platforms/weex/runtime/modules/attrs.js +0 -44
- package/src/platforms/weex/runtime/modules/class.js +0 -76
- package/src/platforms/weex/runtime/modules/events.js +0 -54
- package/src/platforms/weex/runtime/modules/index.js +0 -13
- package/src/platforms/weex/runtime/modules/style.js +0 -84
- package/src/platforms/weex/runtime/modules/transition.js +0 -270
- package/src/platforms/weex/runtime/node-ops.js +0 -91
- package/src/platforms/weex/runtime/patch.js +0 -16
- package/src/platforms/weex/runtime/recycle-list/render-component-template.js +0 -34
- package/src/platforms/weex/runtime/recycle-list/virtual-component.js +0 -136
- package/src/platforms/weex/runtime/text-node.js +0 -9
- package/src/platforms/weex/util/element.js +0 -52
- package/src/platforms/weex/util/index.js +0 -40
- package/src/platforms/weex/util/parser.js +0 -60
- package/src/server/bundle-renderer/create-bundle-renderer.js +0 -151
- package/src/server/bundle-renderer/create-bundle-runner.js +0 -150
- package/src/server/bundle-renderer/source-map-support.js +0 -45
- package/src/server/create-basic-renderer.js +0 -37
- package/src/server/create-renderer.js +0 -152
- package/src/server/optimizing-compiler/codegen.js +0 -264
- package/src/server/optimizing-compiler/index.js +0 -20
- package/src/server/optimizing-compiler/modules.js +0 -124
- package/src/server/optimizing-compiler/optimizer.js +0 -141
- package/src/server/optimizing-compiler/runtime-helpers.js +0 -150
- package/src/server/render-context.js +0 -130
- package/src/server/render-stream.js +0 -95
- package/src/server/render.js +0 -437
- package/src/server/template-renderer/create-async-file-mapper.js +0 -57
- package/src/server/template-renderer/index.js +0 -277
- package/src/server/template-renderer/parse-template.js +0 -42
- package/src/server/template-renderer/template-stream.js +0 -82
- package/src/server/util.js +0 -18
- package/src/server/webpack-plugin/client.js +0 -65
- package/src/server/webpack-plugin/server.js +0 -66
- package/src/server/webpack-plugin/util.js +0 -34
- package/src/server/write.js +0 -50
|
@@ -1,187 +0,0 @@
|
|
|
1
|
-
/* @flow */
|
|
2
|
-
|
|
3
|
-
// this will be preserved during build
|
|
4
|
-
// $flow-disable-line
|
|
5
|
-
const VueFactory = require('./factory')
|
|
6
|
-
|
|
7
|
-
const instanceOptions: { [key: string]: WeexInstanceOption } = {}
|
|
8
|
-
|
|
9
|
-
/**
|
|
10
|
-
* Create instance context.
|
|
11
|
-
*/
|
|
12
|
-
export function createInstanceContext (
|
|
13
|
-
instanceId: string,
|
|
14
|
-
runtimeContext: WeexRuntimeContext,
|
|
15
|
-
data: Object = {}
|
|
16
|
-
): WeexInstanceContext {
|
|
17
|
-
const weex: Weex = runtimeContext.weex
|
|
18
|
-
const instance: WeexInstanceOption = instanceOptions[instanceId] = {
|
|
19
|
-
instanceId,
|
|
20
|
-
config: weex.config,
|
|
21
|
-
document: weex.document,
|
|
22
|
-
data
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
// Each instance has a independent `Vue` module instance
|
|
26
|
-
const Vue = instance.Vue = createVueModuleInstance(instanceId, weex)
|
|
27
|
-
|
|
28
|
-
// DEPRECATED
|
|
29
|
-
const timerAPIs = getInstanceTimer(instanceId, weex.requireModule)
|
|
30
|
-
|
|
31
|
-
const instanceContext = Object.assign({ Vue }, timerAPIs)
|
|
32
|
-
Object.freeze(instanceContext)
|
|
33
|
-
return instanceContext
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
/**
|
|
37
|
-
* Destroy an instance with id. It will make sure all memory of
|
|
38
|
-
* this instance released and no more leaks.
|
|
39
|
-
*/
|
|
40
|
-
export function destroyInstance (instanceId: string): void {
|
|
41
|
-
const instance = instanceOptions[instanceId]
|
|
42
|
-
if (instance && instance.app instanceof instance.Vue) {
|
|
43
|
-
try {
|
|
44
|
-
instance.app.$destroy()
|
|
45
|
-
instance.document.destroy()
|
|
46
|
-
} catch (e) {}
|
|
47
|
-
delete instance.document
|
|
48
|
-
delete instance.app
|
|
49
|
-
}
|
|
50
|
-
delete instanceOptions[instanceId]
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
/**
|
|
54
|
-
* Refresh an instance with id and new top-level component data.
|
|
55
|
-
* It will use `Vue.set` on all keys of the new data. So it's better
|
|
56
|
-
* define all possible meaningful keys when instance created.
|
|
57
|
-
*/
|
|
58
|
-
export function refreshInstance (
|
|
59
|
-
instanceId: string,
|
|
60
|
-
data: Object
|
|
61
|
-
): Error | void {
|
|
62
|
-
const instance = instanceOptions[instanceId]
|
|
63
|
-
if (!instance || !(instance.app instanceof instance.Vue)) {
|
|
64
|
-
return new Error(`refreshInstance: instance ${instanceId} not found!`)
|
|
65
|
-
}
|
|
66
|
-
if (instance.Vue && instance.Vue.set) {
|
|
67
|
-
for (const key in data) {
|
|
68
|
-
instance.Vue.set(instance.app, key, data[key])
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
// Finally `refreshFinish` signal needed.
|
|
72
|
-
instance.document.taskCenter.send('dom', { action: 'refreshFinish' }, [])
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
/**
|
|
76
|
-
* Create a fresh instance of Vue for each Weex instance.
|
|
77
|
-
*/
|
|
78
|
-
function createVueModuleInstance (
|
|
79
|
-
instanceId: string,
|
|
80
|
-
weex: Weex
|
|
81
|
-
): GlobalAPI {
|
|
82
|
-
const exports = {}
|
|
83
|
-
VueFactory(exports, weex.document)
|
|
84
|
-
const Vue = exports.Vue
|
|
85
|
-
|
|
86
|
-
const instance = instanceOptions[instanceId]
|
|
87
|
-
|
|
88
|
-
// patch reserved tag detection to account for dynamically registered
|
|
89
|
-
// components
|
|
90
|
-
const weexRegex = /^weex:/i
|
|
91
|
-
const isReservedTag = Vue.config.isReservedTag || (() => false)
|
|
92
|
-
const isRuntimeComponent = Vue.config.isRuntimeComponent || (() => false)
|
|
93
|
-
Vue.config.isReservedTag = name => {
|
|
94
|
-
return (!isRuntimeComponent(name) && weex.supports(`@component/${name}`)) ||
|
|
95
|
-
isReservedTag(name) ||
|
|
96
|
-
weexRegex.test(name)
|
|
97
|
-
}
|
|
98
|
-
Vue.config.parsePlatformTagName = name => name.replace(weexRegex, '')
|
|
99
|
-
|
|
100
|
-
// expose weex-specific info
|
|
101
|
-
Vue.prototype.$instanceId = instanceId
|
|
102
|
-
Vue.prototype.$document = instance.document
|
|
103
|
-
|
|
104
|
-
// expose weex native module getter on subVue prototype so that
|
|
105
|
-
// vdom runtime modules can access native modules via vnode.context
|
|
106
|
-
Vue.prototype.$requireWeexModule = weex.requireModule
|
|
107
|
-
|
|
108
|
-
// Hack `Vue` behavior to handle instance information and data
|
|
109
|
-
// before root component created.
|
|
110
|
-
Vue.mixin({
|
|
111
|
-
beforeCreate () {
|
|
112
|
-
const options = this.$options
|
|
113
|
-
// root component (vm)
|
|
114
|
-
if (options.el) {
|
|
115
|
-
// set external data of instance
|
|
116
|
-
const dataOption = options.data
|
|
117
|
-
const internalData = (typeof dataOption === 'function' ? dataOption() : dataOption) || {}
|
|
118
|
-
options.data = Object.assign(internalData, instance.data)
|
|
119
|
-
// record instance by id
|
|
120
|
-
instance.app = this
|
|
121
|
-
}
|
|
122
|
-
},
|
|
123
|
-
mounted () {
|
|
124
|
-
const options = this.$options
|
|
125
|
-
// root component (vm)
|
|
126
|
-
if (options.el && weex.document && instance.app === this) {
|
|
127
|
-
try {
|
|
128
|
-
// Send "createFinish" signal to native.
|
|
129
|
-
weex.document.taskCenter.send('dom', { action: 'createFinish' }, [])
|
|
130
|
-
} catch (e) {}
|
|
131
|
-
}
|
|
132
|
-
}
|
|
133
|
-
})
|
|
134
|
-
|
|
135
|
-
/**
|
|
136
|
-
* @deprecated Just instance variable `weex.config`
|
|
137
|
-
* Get instance config.
|
|
138
|
-
* @return {object}
|
|
139
|
-
*/
|
|
140
|
-
Vue.prototype.$getConfig = function () {
|
|
141
|
-
if (instance.app instanceof Vue) {
|
|
142
|
-
return instance.config
|
|
143
|
-
}
|
|
144
|
-
}
|
|
145
|
-
|
|
146
|
-
return Vue
|
|
147
|
-
}
|
|
148
|
-
|
|
149
|
-
/**
|
|
150
|
-
* DEPRECATED
|
|
151
|
-
* Generate HTML5 Timer APIs. An important point is that the callback
|
|
152
|
-
* will be converted into callback id when sent to native. So the
|
|
153
|
-
* framework can make sure no side effect of the callback happened after
|
|
154
|
-
* an instance destroyed.
|
|
155
|
-
*/
|
|
156
|
-
function getInstanceTimer (
|
|
157
|
-
instanceId: string,
|
|
158
|
-
moduleGetter: Function
|
|
159
|
-
): Object {
|
|
160
|
-
const instance = instanceOptions[instanceId]
|
|
161
|
-
const timer = moduleGetter('timer')
|
|
162
|
-
const timerAPIs = {
|
|
163
|
-
setTimeout: (...args) => {
|
|
164
|
-
const handler = function () {
|
|
165
|
-
args[0](...args.slice(2))
|
|
166
|
-
}
|
|
167
|
-
|
|
168
|
-
timer.setTimeout(handler, args[1])
|
|
169
|
-
return instance.document.taskCenter.callbackManager.lastCallbackId.toString()
|
|
170
|
-
},
|
|
171
|
-
setInterval: (...args) => {
|
|
172
|
-
const handler = function () {
|
|
173
|
-
args[0](...args.slice(2))
|
|
174
|
-
}
|
|
175
|
-
|
|
176
|
-
timer.setInterval(handler, args[1])
|
|
177
|
-
return instance.document.taskCenter.callbackManager.lastCallbackId.toString()
|
|
178
|
-
},
|
|
179
|
-
clearTimeout: (n) => {
|
|
180
|
-
timer.clearTimeout(n)
|
|
181
|
-
},
|
|
182
|
-
clearInterval: (n) => {
|
|
183
|
-
timer.clearInterval(n)
|
|
184
|
-
}
|
|
185
|
-
}
|
|
186
|
-
return timerAPIs
|
|
187
|
-
}
|
|
@@ -1,82 +0,0 @@
|
|
|
1
|
-
/* @flow */
|
|
2
|
-
|
|
3
|
-
function getVNodeType (vnode: VNode): string {
|
|
4
|
-
if (!vnode.tag) {
|
|
5
|
-
return ''
|
|
6
|
-
}
|
|
7
|
-
return vnode.tag.replace(/vue\-component\-(\d+\-)?/, '')
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
function isSimpleSpan (vnode: VNode): boolean {
|
|
11
|
-
return vnode.children &&
|
|
12
|
-
vnode.children.length === 1 &&
|
|
13
|
-
!vnode.children[0].tag
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
function parseStyle (vnode: VNode): Object | void {
|
|
17
|
-
if (!vnode || !vnode.data) {
|
|
18
|
-
return
|
|
19
|
-
}
|
|
20
|
-
const { staticStyle, staticClass } = vnode.data
|
|
21
|
-
if (vnode.data.style || vnode.data.class || staticStyle || staticClass) {
|
|
22
|
-
const styles = Object.assign({}, staticStyle, vnode.data.style)
|
|
23
|
-
const cssMap = vnode.context.$options.style || {}
|
|
24
|
-
const classList = [].concat(staticClass, vnode.data.class)
|
|
25
|
-
classList.forEach(name => {
|
|
26
|
-
if (name && cssMap[name]) {
|
|
27
|
-
Object.assign(styles, cssMap[name])
|
|
28
|
-
}
|
|
29
|
-
})
|
|
30
|
-
return styles
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
function convertVNodeChildren (children: Array<VNode>): Array<VNode> | void {
|
|
35
|
-
if (!children.length) {
|
|
36
|
-
return
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
return children.map(vnode => {
|
|
40
|
-
const type: string = getVNodeType(vnode)
|
|
41
|
-
const props: Object = { type }
|
|
42
|
-
|
|
43
|
-
// convert raw text node
|
|
44
|
-
if (!type) {
|
|
45
|
-
props.type = 'span'
|
|
46
|
-
props.attr = {
|
|
47
|
-
value: (vnode.text || '').trim()
|
|
48
|
-
}
|
|
49
|
-
} else {
|
|
50
|
-
props.style = parseStyle(vnode)
|
|
51
|
-
if (vnode.data) {
|
|
52
|
-
props.attr = vnode.data.attrs
|
|
53
|
-
if (vnode.data.on) {
|
|
54
|
-
props.events = vnode.data.on
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
if (type === 'span' && isSimpleSpan(vnode)) {
|
|
58
|
-
props.attr = props.attr || {}
|
|
59
|
-
props.attr.value = vnode.children[0].text.trim()
|
|
60
|
-
return props
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
if (vnode.children && vnode.children.length) {
|
|
65
|
-
props.children = convertVNodeChildren(vnode.children)
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
return props
|
|
69
|
-
})
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
export default {
|
|
73
|
-
name: 'richtext',
|
|
74
|
-
render (h: Function) {
|
|
75
|
-
return h('weex:richtext', {
|
|
76
|
-
on: this._events,
|
|
77
|
-
attrs: {
|
|
78
|
-
value: convertVNodeChildren(this.$options._renderChildren || [])
|
|
79
|
-
}
|
|
80
|
-
})
|
|
81
|
-
}
|
|
82
|
-
}
|
|
@@ -1,148 +0,0 @@
|
|
|
1
|
-
import { warn, extend } from 'core/util/index'
|
|
2
|
-
import { transitionProps, extractTransitionData } from './transition'
|
|
3
|
-
|
|
4
|
-
const props = extend({
|
|
5
|
-
tag: String,
|
|
6
|
-
moveClass: String
|
|
7
|
-
}, transitionProps)
|
|
8
|
-
|
|
9
|
-
delete props.mode
|
|
10
|
-
|
|
11
|
-
export default {
|
|
12
|
-
props,
|
|
13
|
-
|
|
14
|
-
created () {
|
|
15
|
-
const dom = this.$requireWeexModule('dom')
|
|
16
|
-
this.getPosition = el => new Promise((resolve, reject) => {
|
|
17
|
-
dom.getComponentRect(el.ref, res => {
|
|
18
|
-
if (!res.result) {
|
|
19
|
-
reject(new Error(`failed to get rect for element: ${el.tag}`))
|
|
20
|
-
} else {
|
|
21
|
-
resolve(res.size)
|
|
22
|
-
}
|
|
23
|
-
})
|
|
24
|
-
})
|
|
25
|
-
|
|
26
|
-
const animation = this.$requireWeexModule('animation')
|
|
27
|
-
this.animate = (el, options) => new Promise(resolve => {
|
|
28
|
-
animation.transition(el.ref, options, resolve)
|
|
29
|
-
})
|
|
30
|
-
},
|
|
31
|
-
|
|
32
|
-
render (h) {
|
|
33
|
-
const tag = this.tag || this.$vnode.data.tag || 'span'
|
|
34
|
-
const map = Object.create(null)
|
|
35
|
-
const prevChildren = this.prevChildren = this.children
|
|
36
|
-
const rawChildren = this.$slots.default || []
|
|
37
|
-
const children = this.children = []
|
|
38
|
-
const transitionData = extractTransitionData(this)
|
|
39
|
-
|
|
40
|
-
for (let i = 0; i < rawChildren.length; i++) {
|
|
41
|
-
const c = rawChildren[i]
|
|
42
|
-
if (c.tag) {
|
|
43
|
-
if (c.key != null && String(c.key).indexOf('__vlist') !== 0) {
|
|
44
|
-
children.push(c)
|
|
45
|
-
map[c.key] = c
|
|
46
|
-
;(c.data || (c.data = {})).transition = transitionData
|
|
47
|
-
} else if (process.env.NODE_ENV !== 'production') {
|
|
48
|
-
const opts = c.componentOptions
|
|
49
|
-
const name = opts
|
|
50
|
-
? (opts.Ctor.options.name || opts.tag)
|
|
51
|
-
: c.tag
|
|
52
|
-
warn(`<transition-group> children must be keyed: <${name}>`)
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
if (prevChildren) {
|
|
58
|
-
const kept = []
|
|
59
|
-
const removed = []
|
|
60
|
-
prevChildren.forEach(c => {
|
|
61
|
-
c.data.transition = transitionData
|
|
62
|
-
|
|
63
|
-
// TODO: record before patch positions
|
|
64
|
-
|
|
65
|
-
if (map[c.key]) {
|
|
66
|
-
kept.push(c)
|
|
67
|
-
} else {
|
|
68
|
-
removed.push(c)
|
|
69
|
-
}
|
|
70
|
-
})
|
|
71
|
-
this.kept = h(tag, null, kept)
|
|
72
|
-
this.removed = removed
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
return h(tag, null, children)
|
|
76
|
-
},
|
|
77
|
-
|
|
78
|
-
beforeUpdate () {
|
|
79
|
-
// force removing pass
|
|
80
|
-
this.__patch__(
|
|
81
|
-
this._vnode,
|
|
82
|
-
this.kept,
|
|
83
|
-
false, // hydrating
|
|
84
|
-
true // removeOnly (!important, avoids unnecessary moves)
|
|
85
|
-
)
|
|
86
|
-
this._vnode = this.kept
|
|
87
|
-
},
|
|
88
|
-
|
|
89
|
-
updated () {
|
|
90
|
-
const children = this.prevChildren
|
|
91
|
-
const moveClass = this.moveClass || ((this.name || 'v') + '-move')
|
|
92
|
-
const moveData = children.length && this.getMoveData(children[0].context, moveClass)
|
|
93
|
-
if (!moveData) {
|
|
94
|
-
return
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
// TODO: finish implementing move animations once
|
|
98
|
-
// we have access to sync getComponentRect()
|
|
99
|
-
|
|
100
|
-
// children.forEach(callPendingCbs)
|
|
101
|
-
|
|
102
|
-
// Promise.all(children.map(c => {
|
|
103
|
-
// const oldPos = c.data.pos
|
|
104
|
-
// const newPos = c.data.newPos
|
|
105
|
-
// const dx = oldPos.left - newPos.left
|
|
106
|
-
// const dy = oldPos.top - newPos.top
|
|
107
|
-
// if (dx || dy) {
|
|
108
|
-
// c.data.moved = true
|
|
109
|
-
// return this.animate(c.elm, {
|
|
110
|
-
// styles: {
|
|
111
|
-
// transform: `translate(${dx}px,${dy}px)`
|
|
112
|
-
// }
|
|
113
|
-
// })
|
|
114
|
-
// }
|
|
115
|
-
// })).then(() => {
|
|
116
|
-
// children.forEach(c => {
|
|
117
|
-
// if (c.data.moved) {
|
|
118
|
-
// this.animate(c.elm, {
|
|
119
|
-
// styles: {
|
|
120
|
-
// transform: ''
|
|
121
|
-
// },
|
|
122
|
-
// duration: moveData.duration || 0,
|
|
123
|
-
// delay: moveData.delay || 0,
|
|
124
|
-
// timingFunction: moveData.timingFunction || 'linear'
|
|
125
|
-
// })
|
|
126
|
-
// }
|
|
127
|
-
// })
|
|
128
|
-
// })
|
|
129
|
-
},
|
|
130
|
-
|
|
131
|
-
methods: {
|
|
132
|
-
getMoveData (context, moveClass) {
|
|
133
|
-
const stylesheet = context.$options.style || {}
|
|
134
|
-
return stylesheet['@TRANSITION'] && stylesheet['@TRANSITION'][moveClass]
|
|
135
|
-
}
|
|
136
|
-
}
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
// function callPendingCbs (c) {
|
|
140
|
-
// /* istanbul ignore if */
|
|
141
|
-
// if (c.elm._moveCb) {
|
|
142
|
-
// c.elm._moveCb()
|
|
143
|
-
// }
|
|
144
|
-
// /* istanbul ignore if */
|
|
145
|
-
// if (c.elm._enterCb) {
|
|
146
|
-
// c.elm._enterCb()
|
|
147
|
-
// }
|
|
148
|
-
// }
|
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
/* @flow */
|
|
2
|
-
|
|
3
|
-
import Vue from 'core/index'
|
|
4
|
-
import { patch } from 'weex/runtime/patch'
|
|
5
|
-
import { mountComponent } from 'core/instance/lifecycle'
|
|
6
|
-
import platformDirectives from 'weex/runtime/directives/index'
|
|
7
|
-
import platformComponents from 'weex/runtime/components/index'
|
|
8
|
-
|
|
9
|
-
import {
|
|
10
|
-
query,
|
|
11
|
-
mustUseProp,
|
|
12
|
-
isReservedTag,
|
|
13
|
-
isRuntimeComponent,
|
|
14
|
-
isUnknownElement
|
|
15
|
-
} from 'weex/util/element'
|
|
16
|
-
|
|
17
|
-
// install platform specific utils
|
|
18
|
-
Vue.config.mustUseProp = mustUseProp
|
|
19
|
-
Vue.config.isReservedTag = isReservedTag
|
|
20
|
-
Vue.config.isRuntimeComponent = isRuntimeComponent
|
|
21
|
-
Vue.config.isUnknownElement = isUnknownElement
|
|
22
|
-
|
|
23
|
-
// install platform runtime directives and components
|
|
24
|
-
Vue.options.directives = platformDirectives
|
|
25
|
-
Vue.options.components = platformComponents
|
|
26
|
-
|
|
27
|
-
// install platform patch function
|
|
28
|
-
Vue.prototype.__patch__ = patch
|
|
29
|
-
|
|
30
|
-
// wrap mount
|
|
31
|
-
Vue.prototype.$mount = function (
|
|
32
|
-
el?: any,
|
|
33
|
-
hydrating?: boolean
|
|
34
|
-
): Component {
|
|
35
|
-
return mountComponent(
|
|
36
|
-
this,
|
|
37
|
-
el && query(el, this.$document),
|
|
38
|
-
hydrating
|
|
39
|
-
)
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
export default Vue
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
/* @flow */
|
|
2
|
-
|
|
3
|
-
import { extend } from 'shared/util'
|
|
4
|
-
|
|
5
|
-
function updateAttrs (oldVnode: VNodeWithData, vnode: VNodeWithData) {
|
|
6
|
-
if (!oldVnode.data.attrs && !vnode.data.attrs) {
|
|
7
|
-
return
|
|
8
|
-
}
|
|
9
|
-
let key, cur, old
|
|
10
|
-
const elm = vnode.elm
|
|
11
|
-
const oldAttrs = oldVnode.data.attrs || {}
|
|
12
|
-
let attrs = vnode.data.attrs || {}
|
|
13
|
-
// clone observed objects, as the user probably wants to mutate it
|
|
14
|
-
if (attrs.__ob__) {
|
|
15
|
-
attrs = vnode.data.attrs = extend({}, attrs)
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
const supportBatchUpdate = typeof elm.setAttrs === 'function'
|
|
19
|
-
const batchedAttrs = {}
|
|
20
|
-
for (key in attrs) {
|
|
21
|
-
cur = attrs[key]
|
|
22
|
-
old = oldAttrs[key]
|
|
23
|
-
if (old !== cur) {
|
|
24
|
-
supportBatchUpdate
|
|
25
|
-
? (batchedAttrs[key] = cur)
|
|
26
|
-
: elm.setAttr(key, cur)
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
for (key in oldAttrs) {
|
|
30
|
-
if (attrs[key] == null) {
|
|
31
|
-
supportBatchUpdate
|
|
32
|
-
? (batchedAttrs[key] = undefined)
|
|
33
|
-
: elm.setAttr(key)
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
if (supportBatchUpdate) {
|
|
37
|
-
elm.setAttrs(batchedAttrs)
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
export default {
|
|
42
|
-
create: updateAttrs,
|
|
43
|
-
update: updateAttrs
|
|
44
|
-
}
|
|
@@ -1,76 +0,0 @@
|
|
|
1
|
-
/* @flow */
|
|
2
|
-
|
|
3
|
-
import { extend, isObject } from 'shared/util'
|
|
4
|
-
|
|
5
|
-
function updateClass (oldVnode: VNodeWithData, vnode: VNodeWithData) {
|
|
6
|
-
const el = vnode.elm
|
|
7
|
-
const ctx = vnode.context
|
|
8
|
-
|
|
9
|
-
const data: VNodeData = vnode.data
|
|
10
|
-
const oldData: VNodeData = oldVnode.data
|
|
11
|
-
if (!data.staticClass &&
|
|
12
|
-
!data.class &&
|
|
13
|
-
(!oldData || (!oldData.staticClass && !oldData.class))
|
|
14
|
-
) {
|
|
15
|
-
return
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
const oldClassList = makeClassList(oldData)
|
|
19
|
-
const classList = makeClassList(data)
|
|
20
|
-
|
|
21
|
-
if (typeof el.setClassList === 'function') {
|
|
22
|
-
el.setClassList(classList)
|
|
23
|
-
} else {
|
|
24
|
-
const style = getStyle(oldClassList, classList, ctx)
|
|
25
|
-
if (typeof el.setStyles === 'function') {
|
|
26
|
-
el.setStyles(style)
|
|
27
|
-
} else {
|
|
28
|
-
for (const key in style) {
|
|
29
|
-
el.setStyle(key, style[key])
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
function makeClassList (data: VNodeData): Array<string> {
|
|
36
|
-
const classList = []
|
|
37
|
-
// unlike web, weex vnode staticClass is an Array
|
|
38
|
-
const staticClass: any = data.staticClass
|
|
39
|
-
const dataClass = data.class
|
|
40
|
-
if (staticClass) {
|
|
41
|
-
classList.push.apply(classList, staticClass)
|
|
42
|
-
}
|
|
43
|
-
if (Array.isArray(dataClass)) {
|
|
44
|
-
classList.push.apply(classList, dataClass)
|
|
45
|
-
} else if (isObject(dataClass)) {
|
|
46
|
-
classList.push.apply(classList, Object.keys(dataClass).filter(className => dataClass[className]))
|
|
47
|
-
} else if (typeof dataClass === 'string') {
|
|
48
|
-
classList.push.apply(classList, dataClass.trim().split(/\s+/))
|
|
49
|
-
}
|
|
50
|
-
return classList
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
function getStyle (oldClassList: Array<string>, classList: Array<string>, ctx: Component): Object {
|
|
54
|
-
// style is a weex-only injected object
|
|
55
|
-
// compiled from <style> tags in weex files
|
|
56
|
-
const stylesheet: any = ctx.$options.style || {}
|
|
57
|
-
const result = {}
|
|
58
|
-
classList.forEach(name => {
|
|
59
|
-
const style = stylesheet[name]
|
|
60
|
-
extend(result, style)
|
|
61
|
-
})
|
|
62
|
-
oldClassList.forEach(name => {
|
|
63
|
-
const style = stylesheet[name]
|
|
64
|
-
for (const key in style) {
|
|
65
|
-
if (!result.hasOwnProperty(key)) {
|
|
66
|
-
result[key] = ''
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
})
|
|
70
|
-
return result
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
export default {
|
|
74
|
-
create: updateClass,
|
|
75
|
-
update: updateClass
|
|
76
|
-
}
|
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
/* @flow */
|
|
2
|
-
|
|
3
|
-
import { updateListeners } from 'core/vdom/helpers/update-listeners'
|
|
4
|
-
|
|
5
|
-
let target: any
|
|
6
|
-
|
|
7
|
-
function createOnceHandler (event, handler, capture) {
|
|
8
|
-
const _target = target // save current target element in closure
|
|
9
|
-
return function onceHandler () {
|
|
10
|
-
const res = handler.apply(null, arguments)
|
|
11
|
-
if (res !== null) {
|
|
12
|
-
remove(event, onceHandler, capture, _target)
|
|
13
|
-
}
|
|
14
|
-
}
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
function add (
|
|
18
|
-
event: string,
|
|
19
|
-
handler: Function,
|
|
20
|
-
capture: boolean,
|
|
21
|
-
passive?: boolean,
|
|
22
|
-
params?: Array<any>
|
|
23
|
-
) {
|
|
24
|
-
if (capture) {
|
|
25
|
-
console.log('Weex do not support event in bubble phase.')
|
|
26
|
-
return
|
|
27
|
-
}
|
|
28
|
-
target.addEvent(event, handler, params)
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
function remove (
|
|
32
|
-
event: string,
|
|
33
|
-
handler: any,
|
|
34
|
-
capture: any,
|
|
35
|
-
_target?: any
|
|
36
|
-
) {
|
|
37
|
-
(_target || target).removeEvent(event)
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
function updateDOMListeners (oldVnode: VNodeWithData, vnode: VNodeWithData) {
|
|
41
|
-
if (!oldVnode.data.on && !vnode.data.on) {
|
|
42
|
-
return
|
|
43
|
-
}
|
|
44
|
-
const on = vnode.data.on || {}
|
|
45
|
-
const oldOn = oldVnode.data.on || {}
|
|
46
|
-
target = vnode.elm
|
|
47
|
-
updateListeners(on, oldOn, add, remove, createOnceHandler, vnode.context)
|
|
48
|
-
target = undefined
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
export default {
|
|
52
|
-
create: updateDOMListeners,
|
|
53
|
-
update: updateDOMListeners
|
|
54
|
-
}
|