feat(common): use the hotspot function provided by the ArkWeb JS engine to optimize the execution of defineProperties function in the common adaptation layer (#3530)
This commit is contained in:
parent
a602aa5653
commit
66910344ac
|
@ -0,0 +1,52 @@
|
||||||
|
interface ILongque {
|
||||||
|
/**
|
||||||
|
* Harmony API version.
|
||||||
|
*
|
||||||
|
* @since 1
|
||||||
|
*/
|
||||||
|
version: number
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a delegate object for `underlyingObject` or make the `initObject` a delegate for `underlyingObject`.
|
||||||
|
*
|
||||||
|
* @param underlyingObject The underlying object to be delegated.
|
||||||
|
* @param initObject Optional initial delegate object.
|
||||||
|
* @param propertyFilterFlags Optional property filter flags, must use predefined filter flags.
|
||||||
|
* @return If no error throwed, returns the new created delegate object or the `initObject`.
|
||||||
|
*
|
||||||
|
* @since 1
|
||||||
|
*/
|
||||||
|
createDelegate: (underlyingObject: object, initObject?: object, propertyFilterFlags?: number) => object
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The filter flag for `createDelegate`, skip all properties in prototype chain of `underlyingObject`.
|
||||||
|
*
|
||||||
|
* @since 1
|
||||||
|
*/
|
||||||
|
SKIP_PROTOTYPE_CHAIN: 1
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The filter flag for `createDelegate`, skip all properties that starts with '_'.
|
||||||
|
*
|
||||||
|
* @since 1
|
||||||
|
*/
|
||||||
|
SKIP_PREFIX_UNDERSCORE: 2
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The filter flag for `createDelegate`, skip all properties that starts with '$'.
|
||||||
|
*
|
||||||
|
* @since 1
|
||||||
|
*/
|
||||||
|
SKIP_PREFIX_DOLLAR: 4
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The filter flag for `createDelegate`, skip the 'constructor' property.
|
||||||
|
*
|
||||||
|
* @since 1
|
||||||
|
*/
|
||||||
|
SKIP_CONSTRUCTOR: 8
|
||||||
|
}
|
||||||
|
|
||||||
|
interface Window {
|
||||||
|
__Longque__: ILongque
|
||||||
|
}
|
|
@ -0,0 +1,4 @@
|
||||||
|
// 龙雀: ArkWeb JS引擎名称
|
||||||
|
const __TINY__ = typeof window === 'undefined' ? null : window.__Longque__
|
||||||
|
|
||||||
|
export { __TINY__ }
|
|
@ -13,6 +13,7 @@ import Vue from 'vue'
|
||||||
import * as hooks from 'vue'
|
import * as hooks from 'vue'
|
||||||
import { emitter, bindFilter, getElementCssClass, getElementStatusClass } from '../utils'
|
import { emitter, bindFilter, getElementCssClass, getElementStatusClass } from '../utils'
|
||||||
import teleport from '../teleport'
|
import teleport from '../teleport'
|
||||||
|
import { __TINY__ } from '../__longque__'
|
||||||
|
|
||||||
const Teleport = teleport(hooks)
|
const Teleport = teleport(hooks)
|
||||||
|
|
||||||
|
@ -183,8 +184,8 @@ const generateChildren = ($children) => {
|
||||||
return children
|
return children
|
||||||
}
|
}
|
||||||
|
|
||||||
const defineProperties = (vm, instance, filter) => {
|
const originalDefineProperties = (vm, instance, filter) => {
|
||||||
for (let name in instance) {
|
for (const name in instance) {
|
||||||
if (typeof filter === 'function' && filter(name)) continue
|
if (typeof filter === 'function' && filter(name)) continue
|
||||||
|
|
||||||
Object.defineProperty(vm, name, {
|
Object.defineProperty(vm, name, {
|
||||||
|
@ -198,6 +199,13 @@ const defineProperties = (vm, instance, filter) => {
|
||||||
return vm
|
return vm
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const harmonyDefineProperties = (vm, instance) => {
|
||||||
|
const propertyFilterFlags = __TINY__.SKIP_PREFIX_UNDERSCORE | __TINY__.SKIP_PREFIX_DOLLAR | __TINY__.SKIP_CONSTRUCTOR
|
||||||
|
__TINY__.createDelegate(instance, vm, propertyFilterFlags)
|
||||||
|
}
|
||||||
|
|
||||||
|
const defineProperties = __TINY__ ? harmonyDefineProperties : originalDefineProperties
|
||||||
|
|
||||||
const filter = (name) => name.indexOf('$') === 0 || name.indexOf('_') === 0 || name === 'constructor'
|
const filter = (name) => name.indexOf('$') === 0 || name.indexOf('_') === 0 || name === 'constructor'
|
||||||
|
|
||||||
const createVm = (vm, instance, context = undefined) => {
|
const createVm = (vm, instance, context = undefined) => {
|
||||||
|
|
|
@ -3,6 +3,7 @@ import * as compositionHooks from '@vue/composition-api'
|
||||||
import * as vueHooks from 'vue'
|
import * as vueHooks from 'vue'
|
||||||
import { bindFilter, emitter, getElementCssClass, getElementStatusClass } from '../utils'
|
import { bindFilter, emitter, getElementCssClass, getElementStatusClass } from '../utils'
|
||||||
import teleport from '../teleport'
|
import teleport from '../teleport'
|
||||||
|
import { __TINY__ } from '../__longque__'
|
||||||
|
|
||||||
// vue2.7有version字段
|
// vue2.7有version字段
|
||||||
const isVueHooks = Boolean(Vue.version?.includes('2.7'))
|
const isVueHooks = Boolean(Vue.version?.includes('2.7'))
|
||||||
|
@ -179,7 +180,7 @@ const generateChildren = ($children) => {
|
||||||
return children
|
return children
|
||||||
}
|
}
|
||||||
|
|
||||||
const defineProperties = (vm, instance, filter) => {
|
const originalDefineProperties = (vm, instance, filter) => {
|
||||||
for (const name in instance) {
|
for (const name in instance) {
|
||||||
if (typeof filter === 'function' && filter(name)) continue
|
if (typeof filter === 'function' && filter(name)) continue
|
||||||
|
|
||||||
|
@ -194,6 +195,13 @@ const defineProperties = (vm, instance, filter) => {
|
||||||
return vm
|
return vm
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const harmonyDefineProperties = (vm, instance) => {
|
||||||
|
const propertyFilterFlags = __TINY__.SKIP_PREFIX_UNDERSCORE | __TINY__.SKIP_PREFIX_DOLLAR | __TINY__.SKIP_CONSTRUCTOR
|
||||||
|
__TINY__.createDelegate(instance, vm, propertyFilterFlags)
|
||||||
|
}
|
||||||
|
|
||||||
|
const defineProperties = __TINY__ ? harmonyDefineProperties : originalDefineProperties
|
||||||
|
|
||||||
const filter = (name) => name.indexOf('$') === 0 || name.indexOf('_') === 0 || name === 'constructor'
|
const filter = (name) => name.indexOf('$') === 0 || name.indexOf('_') === 0 || name === 'constructor'
|
||||||
|
|
||||||
const createVm = (vm, instance, context = undefined) => {
|
const createVm = (vm, instance, context = undefined) => {
|
||||||
|
|
|
@ -13,6 +13,7 @@ import * as hooks from 'vue'
|
||||||
|
|
||||||
import { camelize, capitalize, hyphenate } from '@opentiny/utils'
|
import { camelize, capitalize, hyphenate } from '@opentiny/utils'
|
||||||
import { bindFilter, emitter, getElementCssClass, getElementStatusClass } from '../utils'
|
import { bindFilter, emitter, getElementCssClass, getElementStatusClass } from '../utils'
|
||||||
|
import { __TINY__ } from '../__longque__'
|
||||||
|
|
||||||
const Teleport = hooks.Teleport
|
const Teleport = hooks.Teleport
|
||||||
|
|
||||||
|
@ -233,7 +234,7 @@ const generateChildren = (subTree) => {
|
||||||
return children
|
return children
|
||||||
}
|
}
|
||||||
|
|
||||||
const defineProperties = (vm, instance, property, filter) => {
|
const originalDefineProperties = (vm, instance, property, filter) => {
|
||||||
for (const name in instance[property]) {
|
for (const name in instance[property]) {
|
||||||
if (typeof filter === 'function' && filter(name)) continue
|
if (typeof filter === 'function' && filter(name)) continue
|
||||||
|
|
||||||
|
@ -248,11 +249,18 @@ const defineProperties = (vm, instance, property, filter) => {
|
||||||
return vm
|
return vm
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const harmonyDefineProperties = (vm, instance, property) => {
|
||||||
|
const propertyFilterFlags = __TINY__.SKIP_PREFIX_UNDERSCORE
|
||||||
|
__TINY__.createDelegate(instance[property], vm, propertyFilterFlags)
|
||||||
|
}
|
||||||
|
|
||||||
|
const defineProperties = __TINY__ ? harmonyDefineProperties : originalDefineProperties
|
||||||
|
|
||||||
const filter = (name) => name.indexOf('_') === 0
|
const filter = (name) => name.indexOf('_') === 0
|
||||||
|
|
||||||
const defineInstanceVm = (vm, instance) => {
|
const defineInstanceVm = (vm, instance) => {
|
||||||
defineProperties(vm, instance, 'setupState', null)
|
originalDefineProperties(vm, instance, 'setupState', null)
|
||||||
defineProperties(vm, instance, 'props', filter)
|
originalDefineProperties(vm, instance, 'props', filter)
|
||||||
defineProperties(vm, instance, 'ctx', filter)
|
defineProperties(vm, instance, 'ctx', filter)
|
||||||
|
|
||||||
return vm
|
return vm
|
||||||
|
|
|
@ -5,36 +5,16 @@
|
||||||
"noImplicitAny": false,
|
"noImplicitAny": false,
|
||||||
"baseUrl": ".",
|
"baseUrl": ".",
|
||||||
"paths": {
|
"paths": {
|
||||||
"@opentiny/vue-huicharts-amap": [
|
"@opentiny/vue-huicharts-amap": ["packages/vue/src/chart/autonavi-map"],
|
||||||
"packages/vue/src/chart/autonavi-map"
|
"@opentiny/vue-huicharts-bmap": ["packages/vue/src/chart/baidu-map"],
|
||||||
],
|
"@opentiny/vue-huicharts-*": ["packages/vue/src/chart/chart-*"],
|
||||||
"@opentiny/vue-huicharts-bmap": [
|
"@opentiny/vue-*": ["packages/vue-*", "packages/vue/src/*"],
|
||||||
"packages/vue/src/chart/baidu-map"
|
"@opentiny/vue-renderless/types*": ["packages/renderless/types*"],
|
||||||
],
|
"@opentiny/vue-renderless*": ["packages/renderless/src*"],
|
||||||
"@opentiny/vue-huicharts-*": [
|
"virtual:common/adapter/vue": ["packages/vue-common/src/adapter/vue2.7/index.ts"],
|
||||||
"packages/vue/src/chart/chart-*"
|
"virtual:locale/vue": ["packages/vue-locale/src/vue2.7/index.ts"]
|
||||||
],
|
|
||||||
"@opentiny/vue-*": [
|
|
||||||
"packages/vue-*",
|
|
||||||
"packages/vue/src/*"
|
|
||||||
],
|
|
||||||
"@opentiny/vue-renderless/types*": [
|
|
||||||
"packages/renderless/types*"
|
|
||||||
],
|
|
||||||
"@opentiny/vue-renderless*": [
|
|
||||||
"packages/renderless/src*"
|
|
||||||
],
|
|
||||||
"virtual:common/adapter/vue": [
|
|
||||||
"packages/vue-common/src/adapter/vue2.7/index.ts"
|
|
||||||
],
|
|
||||||
"virtual:locale/vue": [
|
|
||||||
"packages/vue-locale/src/vue2.7/index.ts"
|
|
||||||
]
|
|
||||||
},
|
},
|
||||||
"types": [
|
"types": ["node", "vite/client"]
|
||||||
"node",
|
|
||||||
"vite/client"
|
|
||||||
]
|
|
||||||
},
|
},
|
||||||
"vueCompilerOptions": {
|
"vueCompilerOptions": {
|
||||||
"target": 2.7
|
"target": 2.7
|
||||||
|
@ -44,11 +24,8 @@
|
||||||
"packages/**/*.tsx",
|
"packages/**/*.tsx",
|
||||||
"packages/**/*.vue",
|
"packages/**/*.vue",
|
||||||
"examples/vue2.7/shims-app.d.ts",
|
"examples/vue2.7/shims-app.d.ts",
|
||||||
"examples/vue2.7/shims-vue.d.ts"
|
"examples/vue2.7/shims-vue.d.ts",
|
||||||
|
"packages/vue-common/src/__longque__.d.ts"
|
||||||
],
|
],
|
||||||
"exclude": [
|
"exclude": ["**/node_modules", "**/dist*", "**/*.md"]
|
||||||
"**/node_modules",
|
|
||||||
"**/dist*",
|
|
||||||
"**/*.md"
|
|
||||||
]
|
|
||||||
}
|
}
|
|
@ -5,36 +5,16 @@
|
||||||
"noImplicitAny": false,
|
"noImplicitAny": false,
|
||||||
"baseUrl": ".",
|
"baseUrl": ".",
|
||||||
"paths": {
|
"paths": {
|
||||||
"@opentiny/vue-huicharts-amap": [
|
"@opentiny/vue-huicharts-amap": ["packages/vue/src/chart/autonavi-map"],
|
||||||
"packages/vue/src/chart/autonavi-map"
|
"@opentiny/vue-huicharts-bmap": ["packages/vue/src/chart/baidu-map"],
|
||||||
],
|
"@opentiny/vue-huicharts-*": ["packages/vue/src/chart/chart-*"],
|
||||||
"@opentiny/vue-huicharts-bmap": [
|
"@opentiny/vue-*": ["packages/vue-*", "packages/vue/src/*"],
|
||||||
"packages/vue/src/chart/baidu-map"
|
"@opentiny/vue-renderless/types*": ["packages/renderless/types*"],
|
||||||
],
|
"@opentiny/vue-renderless*": ["packages/renderless/src*"],
|
||||||
"@opentiny/vue-huicharts-*": [
|
"virtual:common/adapter/vue": ["packages/vue-common/src/adapter/vue2/index.ts"],
|
||||||
"packages/vue/src/chart/chart-*"
|
"virtual:locale/vue": ["packages/vue-locale/src/vue2/index.ts"]
|
||||||
],
|
|
||||||
"@opentiny/vue-*": [
|
|
||||||
"packages/vue-*",
|
|
||||||
"packages/vue/src/*"
|
|
||||||
],
|
|
||||||
"@opentiny/vue-renderless/types*": [
|
|
||||||
"packages/renderless/types*"
|
|
||||||
],
|
|
||||||
"@opentiny/vue-renderless*": [
|
|
||||||
"packages/renderless/src*"
|
|
||||||
],
|
|
||||||
"virtual:common/adapter/vue": [
|
|
||||||
"packages/vue-common/src/adapter/vue2/index.ts"
|
|
||||||
],
|
|
||||||
"virtual:locale/vue": [
|
|
||||||
"packages/vue-locale/src/vue2/index.ts"
|
|
||||||
]
|
|
||||||
},
|
},
|
||||||
"types": [
|
"types": ["node", "vite/client"]
|
||||||
"node",
|
|
||||||
"vite/client"
|
|
||||||
]
|
|
||||||
},
|
},
|
||||||
"vueCompilerOptions": {
|
"vueCompilerOptions": {
|
||||||
"target": 2
|
"target": 2
|
||||||
|
@ -44,11 +24,8 @@
|
||||||
"packages/**/*.tsx",
|
"packages/**/*.tsx",
|
||||||
"packages/**/*.vue",
|
"packages/**/*.vue",
|
||||||
"examples/vue2/shims-app.d.ts",
|
"examples/vue2/shims-app.d.ts",
|
||||||
"examples/vue2/shims-vue.d.ts"
|
"examples/vue2/shims-vue.d.ts",
|
||||||
|
"packages/vue-common/src/__longque__.d.ts"
|
||||||
],
|
],
|
||||||
"exclude": [
|
"exclude": ["**/node_modules", "**/dist*", "**/*.md"]
|
||||||
"**/node_modules",
|
|
||||||
"**/dist*",
|
|
||||||
"**/*.md"
|
|
||||||
]
|
|
||||||
}
|
}
|
|
@ -5,36 +5,16 @@
|
||||||
"noImplicitAny": false,
|
"noImplicitAny": false,
|
||||||
"baseUrl": ".",
|
"baseUrl": ".",
|
||||||
"paths": {
|
"paths": {
|
||||||
"@opentiny/vue-huicharts-amap": [
|
"@opentiny/vue-huicharts-amap": ["packages/vue/src/huicharts/huicharts-amap"],
|
||||||
"packages/vue/src/huicharts/huicharts-amap"
|
"@opentiny/vue-huicharts-bmap": ["packages/vue/src/huicharts/huicharts-bmap"],
|
||||||
],
|
"@opentiny/vue-huicharts-*": ["packages/vue/src/huicharts/chart-*"],
|
||||||
"@opentiny/vue-huicharts-bmap": [
|
"@opentiny/vue-*": ["packages/vue-*", "packages/vue/src/*"],
|
||||||
"packages/vue/src/huicharts/huicharts-bmap"
|
"@opentiny/vue-renderless/types*": ["packages/renderless/types*"],
|
||||||
],
|
"@opentiny/vue-renderless*": ["packages/renderless/src*"],
|
||||||
"@opentiny/vue-huicharts-*": [
|
"virtual:common/adapter/vue": ["packages/vue-common/src/adapter/vue3/index.ts"],
|
||||||
"packages/vue/src/huicharts/chart-*"
|
"virtual:locale/vue": ["packages/vue-locale/src/vue3/index.ts"]
|
||||||
],
|
|
||||||
"@opentiny/vue-*": [
|
|
||||||
"packages/vue-*",
|
|
||||||
"packages/vue/src/*"
|
|
||||||
],
|
|
||||||
"@opentiny/vue-renderless/types*": [
|
|
||||||
"packages/renderless/types*"
|
|
||||||
],
|
|
||||||
"@opentiny/vue-renderless*": [
|
|
||||||
"packages/renderless/src*"
|
|
||||||
],
|
|
||||||
"virtual:common/adapter/vue": [
|
|
||||||
"packages/vue-common/src/adapter/vue3/index.ts"
|
|
||||||
],
|
|
||||||
"virtual:locale/vue": [
|
|
||||||
"packages/vue-locale/src/vue3/index.ts"
|
|
||||||
]
|
|
||||||
},
|
},
|
||||||
"types": [
|
"types": ["node", "vite/client"]
|
||||||
"node",
|
|
||||||
"vite/client"
|
|
||||||
]
|
|
||||||
},
|
},
|
||||||
"vueCompilerOptions": {
|
"vueCompilerOptions": {
|
||||||
"target": 3
|
"target": 3
|
||||||
|
@ -44,11 +24,8 @@
|
||||||
"packages/**/*.tsx",
|
"packages/**/*.tsx",
|
||||||
"packages/**/*.vue",
|
"packages/**/*.vue",
|
||||||
"examples/vue3/shims-app.d.ts",
|
"examples/vue3/shims-app.d.ts",
|
||||||
"examples/vue3/shims-vue.d.ts"
|
"examples/vue3/shims-vue.d.ts",
|
||||||
|
"packages/vue-common/src/__longque__.d.ts"
|
||||||
],
|
],
|
||||||
"exclude": [
|
"exclude": ["**/node_modules", "**/dist*", "**/*.md"]
|
||||||
"**/node_modules",
|
|
||||||
"**/dist*",
|
|
||||||
"**/*.md"
|
|
||||||
]
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue