diff --git a/packages/uni-app-plus/__tests__/service/dom/dom.spec.ts b/packages/uni-app-plus/__tests__/service/dom/dom.spec.ts index 7d3fee3f045975641ee0acf295c41f181bb8aa77..c84d58e32177fd6c52c67ce189c2b945d1876154 100644 --- a/packages/uni-app-plus/__tests__/service/dom/dom.spec.ts +++ b/packages/uni-app-plus/__tests__/service/dom/dom.spec.ts @@ -1,23 +1,25 @@ -import { encodeEvent, encodeTag, UniEventListener } from '@dcloudio/uni-shared' +import { + ACTION_TYPE_ADD_EVENT, + ACTION_TYPE_CREATE, + ACTION_TYPE_INSERT, + ACTION_TYPE_REMOVE, + ACTION_TYPE_REMOVE_ATTRIBUTE, + ACTION_TYPE_REMOVE_EVENT, + ACTION_TYPE_SET_ATTRIBUTE, + ACTION_TYPE_SET_TEXT, + CreateAction, + encodeEvent, + encodeTag, + InsertAction, + SetAttributeAction, + UniEventListener, +} from '@dcloudio/uni-shared' import { createPageNode } from '../../../src/service/framework/dom/Page' import { createElement, createTextNode, withModifiers, } from '../../../../uni-app-vue/lib/service.runtime.esm' -import { - InsertAction, - ACTION_TYPE_INSERT, - SetAttributeAction, - ACTION_TYPE_SET_ATTRIBUTE, - ACTION_TYPE_REMOVE_ATTRIBUTE, - ACTION_TYPE_SET_TEXT, - ACTION_TYPE_REMOVE, - CreateAction, - ACTION_TYPE_CREATE, - ACTION_TYPE_ADD_EVENT, - ACTION_TYPE_REMOVE_EVENT, -} from '../../../src/PageAction' import { EventModifierFlags } from '@dcloudio/uni-shared' describe('dom', () => { diff --git a/packages/uni-app-plus/dist/uni-app-service.es.js b/packages/uni-app-plus/dist/uni-app-service.es.js index 76794bb8ce5cd18d6f502e180764ef38a15620a2..c9c6b8dd3c175beb5e35fb3d2257353d24f7723d 100644 --- a/packages/uni-app-plus/dist/uni-app-service.es.js +++ b/packages/uni-app-plus/dist/uni-app-service.es.js @@ -986,6 +986,18 @@ var serviceContext = (function (vue) { } } + const ACTION_TYPE_PAGE_CREATE = 1; + const ACTION_TYPE_PAGE_CREATED = 2; + const ACTION_TYPE_CREATE = 3; + const ACTION_TYPE_INSERT = 4; + const ACTION_TYPE_REMOVE = 5; + const ACTION_TYPE_SET_ATTRIBUTE = 6; + const ACTION_TYPE_REMOVE_ATTRIBUTE = 7; + const ACTION_TYPE_ADD_EVENT = 8; + const ACTION_TYPE_REMOVE_EVENT = 9; + const ACTION_TYPE_SET_TEXT = 10; + const ACTION_TYPE_EVENT = 20; + function cache(fn) { const cache = Object.create(null); return (str) => { @@ -8208,18 +8220,6 @@ var serviceContext = (function (vue) { const INVOKE_VIEW_API = 'invokeViewApi'; const INVOKE_SERVICE_API = 'invokeServiceApi'; - const ACTION_TYPE_PAGE_CREATE = 1; - const ACTION_TYPE_PAGE_CREATED = 2; - const ACTION_TYPE_CREATE = 3; - const ACTION_TYPE_INSERT = 4; - const ACTION_TYPE_REMOVE = 5; - const ACTION_TYPE_SET_ATTRIBUTE = 6; - const ACTION_TYPE_REMOVE_ATTRIBUTE = 7; - const ACTION_TYPE_ADD_EVENT = 8; - const ACTION_TYPE_REMOVE_EVENT = 9; - const ACTION_TYPE_SET_TEXT = 10; - const ACTION_TYPE_EVENT = 20; - function onNodeEvent(nodeId, evt, pageNode) { pageNode.fireEvent(nodeId, evt); } diff --git a/packages/uni-app-plus/dist/uni-app-view.umd.js b/packages/uni-app-plus/dist/uni-app-view.umd.js index 1705cc369ab5df2993eb4d9f63e6702c965fa8a2..463400ef5ce97dcf512644ddba1ba784b6c5cf47 100644 --- a/packages/uni-app-plus/dist/uni-app-view.umd.js +++ b/packages/uni-app-plus/dist/uni-app-view.umd.js @@ -270,6 +270,17 @@ function decodeAttr(name) { return DECODED_ATTR_MAP[name] || name; } + const ACTION_TYPE_PAGE_CREATE = 1; + const ACTION_TYPE_PAGE_CREATED = 2; + const ACTION_TYPE_CREATE = 3; + const ACTION_TYPE_INSERT = 4; + const ACTION_TYPE_REMOVE = 5; + const ACTION_TYPE_SET_ATTRIBUTE = 6; + const ACTION_TYPE_REMOVE_ATTRIBUTE = 7; + const ACTION_TYPE_ADD_EVENT = 8; + const ACTION_TYPE_REMOVE_EVENT = 9; + const ACTION_TYPE_SET_TEXT = 10; + const ACTION_TYPE_EVENT = 20; function cache(fn) { const cache2 = Object.create(null); return (str) => { @@ -5820,17 +5831,6 @@ }); } } - const ACTION_TYPE_PAGE_CREATE = 1; - const ACTION_TYPE_PAGE_CREATED = 2; - const ACTION_TYPE_CREATE = 3; - const ACTION_TYPE_INSERT = 4; - const ACTION_TYPE_REMOVE = 5; - const ACTION_TYPE_SET_ATTRIBUTE = 6; - const ACTION_TYPE_REMOVE_ATTRIBUTE = 7; - const ACTION_TYPE_ADD_EVENT = 8; - const ACTION_TYPE_REMOVE_EVENT = 9; - const ACTION_TYPE_SET_TEXT = 10; - const ACTION_TYPE_EVENT = 20; class UniNode { constructor(id2, tag, parentNodeId, element) { this.isMounted = false; @@ -14443,9 +14443,14 @@ super(id2, "uni-button", Button, parentNodeId, nodeJson); } } - class UniCamera extends UniNode { - constructor(id2) { - super(id2, "uni-camera"); + class UniTodoNode extends UniNode { + constructor(id2, tag, parentNodeId) { + super(id2, tag, parentNodeId); + } + } + class UniCamera extends UniTodoNode { + constructor(id2, parentNodeId) { + super(id2, "uni-camera", parentNodeId); } } var canvas = "uni-canvas {\n width: 300px;\n height: 150px;\n display: block;\n position: relative;\n}\n\nuni-canvas > .uni-canvas-canvas {\n position: absolute;\n top: 0;\n left: 0;\n width: 100%;\n height: 100%;\n}\n"; @@ -14873,9 +14878,9 @@ super(id2, "uni-form", Form, parentNodeId, nodeJson, "span"); } } - class UniFunctionalPageNavigator extends UniNode { - constructor(id2) { - super(id2, "uni-functional-page-navigator"); + class UniFunctionalPageNavigator extends UniTodoNode { + constructor(id2, parentNodeId) { + super(id2, "uni-functional-page-navigator", parentNodeId); } } var icon = "uni-icon {\n display: inline-block;\n font-size: 0;\n box-sizing: border-box;\n}\n\nuni-icon[hidden] {\n display: none;\n}\n"; @@ -14902,14 +14907,14 @@ super(id2, "uni-label", Label, parentNodeId, nodeJson); } } - class UniLivePlayer extends UniNode { - constructor(id2) { - super(id2, "uni-live-player"); + class UniLivePlayer extends UniTodoNode { + constructor(id2, parentNodeId) { + super(id2, "uni-live-player", parentNodeId); } } - class UniLivePusher extends UniNode { - constructor(id2) { - super(id2, "uni-live-pusher"); + class UniLivePusher extends UniTodoNode { + constructor(id2, parentNodeId) { + super(id2, "uni-live-pusher", parentNodeId); } } var Map$1 = /* @__PURE__ */ defineBuiltInComponent({ @@ -14938,14 +14943,14 @@ super(id2, "uni-navigator", Navigator, parentNodeId, nodeJson); } } - class UniOfficialAccount extends UniNode { - constructor(id2) { - super(id2, "uni-official-account"); + class UniOfficialAccount extends UniTodoNode { + constructor(id2, parentNodeId) { + super(id2, "uni-official-account", parentNodeId); } } - class UniOpenData extends UniNode { - constructor(id2) { - super(id2, "uni-open-data"); + class UniOpenData extends UniTodoNode { + constructor(id2, parentNodeId) { + super(id2, "uni-open-data", parentNodeId); } } var Picker = /* @__PURE__ */ defineBuiltInComponent({ diff --git a/packages/uni-app-plus/src/service/framework/dom/Page.ts b/packages/uni-app-plus/src/service/framework/dom/Page.ts index 4153c9f536cd436fd2401bab21b5996e3af37fad..5415a2dcad399897e1e7ee81ebc1b8bb463ca1dc 100644 --- a/packages/uni-app-plus/src/service/framework/dom/Page.ts +++ b/packages/uni-app-plus/src/service/framework/dom/Page.ts @@ -7,24 +7,23 @@ import { formatLog, UniEvent, UniNodeJSON, -} from '@dcloudio/uni-shared' -import { - PageCreateAction, - PageCreatedAction, - PageAction, - PageNodeOptions, + ACTION_TYPE_ADD_EVENT, ACTION_TYPE_CREATE, ACTION_TYPE_INSERT, + ACTION_TYPE_PAGE_CREATE, + ACTION_TYPE_PAGE_CREATED, ACTION_TYPE_REMOVE, - ACTION_TYPE_SET_ATTRIBUTE, ACTION_TYPE_REMOVE_ATTRIBUTE, + ACTION_TYPE_REMOVE_EVENT, + ACTION_TYPE_SET_ATTRIBUTE, ACTION_TYPE_SET_TEXT, - ACTION_TYPE_PAGE_CREATE, - ACTION_TYPE_PAGE_CREATED, CreateAction, - ACTION_TYPE_ADD_EVENT, - ACTION_TYPE_REMOVE_EVENT, -} from '../../../PageAction' + PageAction, + PageCreateAction, + PageCreatedAction, + PageNodeOptions, +} from '@dcloudio/uni-shared' + import { VD_SYNC } from '../../../constants' export default class UniPageNode extends UniNode implements IUniPageNode { diff --git a/packages/uni-app-plus/src/service/framework/dom/decodeActions.ts b/packages/uni-app-plus/src/service/framework/dom/decodeActions.ts index c21af424b35e1ce39fcc204aee86dcbae40ca297..318a9805e18e93466316b31f7c762463884e5ca8 100644 --- a/packages/uni-app-plus/src/service/framework/dom/decodeActions.ts +++ b/packages/uni-app-plus/src/service/framework/dom/decodeActions.ts @@ -1,27 +1,27 @@ -import { decodeTag } from '@dcloudio/uni-shared' import { - CreateAction, - InsertAction, - RemoveAction, - SetAttributeAction, - RemoveAttributeAction, - SetTextAction, + ACTION_TYPE_ADD_EVENT, ACTION_TYPE_CREATE, ACTION_TYPE_INSERT, + ACTION_TYPE_PAGE_CREATE, + ACTION_TYPE_PAGE_CREATED, ACTION_TYPE_REMOVE, - ACTION_TYPE_SET_ATTRIBUTE, ACTION_TYPE_REMOVE_ATTRIBUTE, + ACTION_TYPE_REMOVE_EVENT, + ACTION_TYPE_SET_ATTRIBUTE, ACTION_TYPE_SET_TEXT, + AddEventAction, + CreateAction, + decodeTag, + InsertAction, PageAction, PageCreateAction, PageCreatedAction, - ACTION_TYPE_PAGE_CREATE, - ACTION_TYPE_PAGE_CREATED, - AddEventAction, + RemoveAction, + RemoveAttributeAction, RemoveEventAction, - ACTION_TYPE_ADD_EVENT, - ACTION_TYPE_REMOVE_EVENT, -} from '../../../PageAction' + SetAttributeAction, + SetTextAction, +} from '@dcloudio/uni-shared' function decodePageCreateAction([, pageCreateData]: PageCreateAction) { return ['pageCreate', pageCreateData] diff --git a/packages/uni-app-plus/src/service/framework/dom/index.ts b/packages/uni-app-plus/src/service/framework/dom/index.ts index c06cb0627313c8334bca658601483e7b6935aebb..bd110f4cdced71bec6b171d90ddd6fbd877689f2 100644 --- a/packages/uni-app-plus/src/service/framework/dom/index.ts +++ b/packages/uni-app-plus/src/service/framework/dom/index.ts @@ -1,8 +1,7 @@ import { getPageById } from '@dcloudio/uni-core' -import { formatLog } from '@dcloudio/uni-shared' +import { ACTION_TYPE_EVENT, formatLog } from '@dcloudio/uni-shared' import { ComponentPublicInstance } from 'vue' -import { ACTION_TYPE_EVENT, EventAction } from '../../../PageAction' -import { onNodeEvent } from './onNodeEvent' +import { EventAction, onNodeEvent } from './onNodeEvent' import UniPageNode from './Page' export function onVdSync(actions: EventAction[], pageId: string) { diff --git a/packages/uni-app-plus/src/service/framework/dom/onNodeEvent.ts b/packages/uni-app-plus/src/service/framework/dom/onNodeEvent.ts index 7ae3bff0653d57f77f261564cc193ca31ab5ac37..50d0cea66ed34378db8af6aad46c96c84002878a 100644 --- a/packages/uni-app-plus/src/service/framework/dom/onNodeEvent.ts +++ b/packages/uni-app-plus/src/service/framework/dom/onNodeEvent.ts @@ -1,6 +1,12 @@ -import { UniEvent } from '@dcloudio/uni-shared' +import { ACTION_TYPE_EVENT, UniEvent } from '@dcloudio/uni-shared' import UniPageNode from './Page' +export type EventAction = [ + typeof ACTION_TYPE_EVENT, + Parameters[0], + Parameters[1] +] + export function onNodeEvent( nodeId: number, evt: UniEvent, diff --git a/packages/uni-app-plus/src/service/framework/page/define.ts b/packages/uni-app-plus/src/service/framework/page/define.ts index f05fde765048e5a49fbcccffed2d1f8bec538c5d..90a6cfddd612ee66da38f79f60fb1189fe754cb8 100644 --- a/packages/uni-app-plus/src/service/framework/page/define.ts +++ b/packages/uni-app-plus/src/service/framework/page/define.ts @@ -1,9 +1,8 @@ -import { once } from '@dcloudio/uni-shared' +import { once, PageNodeOptions } from '@dcloudio/uni-shared' import { createApp, DefineComponent } from 'vue' import { createPageNode } from '../dom/Page' import { setupPage } from './setup' import __vuePlugin from '../plugin' -import { PageNodeOptions } from '../../../PageAction' export type VuePageComponent = DefineComponent diff --git a/packages/uni-app-plus/src/service/framework/page/register.ts b/packages/uni-app-plus/src/service/framework/page/register.ts index 76e887ed55976f8142f9a8087d3933f065e2ca03..0a061801f73a2cdd225db376c04d688066d7e188 100644 --- a/packages/uni-app-plus/src/service/framework/page/register.ts +++ b/packages/uni-app-plus/src/service/framework/page/register.ts @@ -4,6 +4,7 @@ import { formatLog, NAVBAR_HEIGHT, ON_REACH_BOTTOM_DISTANCE, + PageNodeOptions, } from '@dcloudio/uni-shared' import { initPageInternalInstance } from '@dcloudio/uni-core' @@ -11,7 +12,6 @@ import { initEntry } from '../app/initEntry' import { initRouteOptions } from './routeOptions' import { createWebview, initWebview } from '../webview' import { createPage } from './define' -import { PageNodeOptions } from '../../../PageAction' import { getStatusbarHeight } from '../../../helpers/statusBar' import tabBar from '../app/tabBar' import { addCurrentPage } from './getCurrentPages' diff --git a/packages/uni-app-plus/src/view/framework/dom/components/UniCamera.ts b/packages/uni-app-plus/src/view/framework/dom/components/UniCamera.ts index 8495577ed9c20fd8ed65432ac3542aab76576505..ee7195fd4073352431930ee7483131d23ef72df1 100644 --- a/packages/uni-app-plus/src/view/framework/dom/components/UniCamera.ts +++ b/packages/uni-app-plus/src/view/framework/dom/components/UniCamera.ts @@ -1,7 +1,7 @@ -import { UniNode } from '../elements/UniNode' +import { UniTodoNode } from '../elements/UniTodoNode' -export class UniCamera extends UniNode { - constructor(id: number) { - super(id, 'uni-camera') +export class UniCamera extends UniTodoNode { + constructor(id: number, parentNodeId: number) { + super(id, 'uni-camera', parentNodeId) } } diff --git a/packages/uni-app-plus/src/view/framework/dom/components/UniFunctionalPageNavigator.ts b/packages/uni-app-plus/src/view/framework/dom/components/UniFunctionalPageNavigator.ts index 759c1fe294c679ff7a9f628d6d0a1a58a4e96a89..47e08b5d8866e813554ded0a1bb52ba42fef9640 100644 --- a/packages/uni-app-plus/src/view/framework/dom/components/UniFunctionalPageNavigator.ts +++ b/packages/uni-app-plus/src/view/framework/dom/components/UniFunctionalPageNavigator.ts @@ -1,7 +1,7 @@ -import { UniNode } from '../elements/UniNode' +import { UniTodoNode } from '../elements/UniTodoNode' -export class UniFunctionalPageNavigator extends UniNode { - constructor(id: number) { - super(id, 'uni-functional-page-navigator') +export class UniFunctionalPageNavigator extends UniTodoNode { + constructor(id: number, parentNodeId: number) { + super(id, 'uni-functional-page-navigator', parentNodeId) } } diff --git a/packages/uni-app-plus/src/view/framework/dom/components/UniLivePlayer.ts b/packages/uni-app-plus/src/view/framework/dom/components/UniLivePlayer.ts index 0ff9170ad3566643d3da439becae7fef6a99f0f5..303fd42897d858f3e5829fb688f4e13ca8d75605 100644 --- a/packages/uni-app-plus/src/view/framework/dom/components/UniLivePlayer.ts +++ b/packages/uni-app-plus/src/view/framework/dom/components/UniLivePlayer.ts @@ -1,7 +1,7 @@ -import { UniNode } from '../elements/UniNode' +import { UniTodoNode } from '../elements/UniTodoNode' -export class UniLivePlayer extends UniNode { - constructor(id: number) { - super(id, 'uni-live-player') +export class UniLivePlayer extends UniTodoNode { + constructor(id: number, parentNodeId: number) { + super(id, 'uni-live-player', parentNodeId) } } diff --git a/packages/uni-app-plus/src/view/framework/dom/components/UniLivePusher.ts b/packages/uni-app-plus/src/view/framework/dom/components/UniLivePusher.ts index 3ce395dfd503b2b945f784e98ff9a5a164af3942..658ee758bacac3696c2e3724f5a01b82fc1ddadb 100644 --- a/packages/uni-app-plus/src/view/framework/dom/components/UniLivePusher.ts +++ b/packages/uni-app-plus/src/view/framework/dom/components/UniLivePusher.ts @@ -1,7 +1,7 @@ -import { UniNode } from '../elements/UniNode' +import { UniTodoNode } from '../elements/UniTodoNode' -export class UniLivePusher extends UniNode { - constructor(id: number) { - super(id, 'uni-live-pusher') +export class UniLivePusher extends UniTodoNode { + constructor(id: number, parentNodeId: number) { + super(id, 'uni-live-pusher', parentNodeId) } } diff --git a/packages/uni-app-plus/src/view/framework/dom/components/UniOfficialAccount.ts b/packages/uni-app-plus/src/view/framework/dom/components/UniOfficialAccount.ts index 29772ea697ff53283d2d44337ece267db7c797bb..65700066a7e4a3a5b7729d79e0d2959aaaa01ef5 100644 --- a/packages/uni-app-plus/src/view/framework/dom/components/UniOfficialAccount.ts +++ b/packages/uni-app-plus/src/view/framework/dom/components/UniOfficialAccount.ts @@ -1,7 +1,7 @@ -import { UniNode } from '../elements/UniNode' +import { UniTodoNode } from '../elements/UniTodoNode' -export class UniOfficialAccount extends UniNode { - constructor(id: number) { - super(id, 'uni-official-account') +export class UniOfficialAccount extends UniTodoNode { + constructor(id: number, parentNodeId: number) { + super(id, 'uni-official-account', parentNodeId) } } diff --git a/packages/uni-app-plus/src/view/framework/dom/components/UniOpenData.ts b/packages/uni-app-plus/src/view/framework/dom/components/UniOpenData.ts index e59d359333dbdab950ba3d43324923e969e0422b..35b560f6ad0aecd915b86d4cf233722a9e1e11a1 100644 --- a/packages/uni-app-plus/src/view/framework/dom/components/UniOpenData.ts +++ b/packages/uni-app-plus/src/view/framework/dom/components/UniOpenData.ts @@ -1,7 +1,7 @@ -import { UniNode } from '../elements/UniNode' +import { UniTodoNode } from '../elements/UniTodoNode' -export class UniOpenData extends UniNode { - constructor(id: number) { - super(id, 'uni-open-data') +export class UniOpenData extends UniTodoNode { + constructor(id: number, parentNodeId: number) { + super(id, 'uni-open-data', parentNodeId) } } diff --git a/packages/uni-app-plus/src/view/framework/dom/elements/UniHoverElement.ts b/packages/uni-app-plus/src/view/framework/dom/elements/UniHoverElement.ts index edff16ecd2216edb5beecd38d1e78b234cc662fd..706f720203bf63336a4627ce99aeea2f8a118c0c 100644 --- a/packages/uni-app-plus/src/view/framework/dom/elements/UniHoverElement.ts +++ b/packages/uni-app-plus/src/view/framework/dom/elements/UniHoverElement.ts @@ -1,5 +1,4 @@ import { formatLog, UniNodeJSON } from '@dcloudio/uni-shared' -import { UniCustomElement } from '../components' import { UniElement } from './UniElement' interface HoverProps { diff --git a/packages/uni-app-plus/src/view/framework/dom/elements/UniTodoNode.ts b/packages/uni-app-plus/src/view/framework/dom/elements/UniTodoNode.ts new file mode 100644 index 0000000000000000000000000000000000000000..19df8d382f17abd6bcdb0b533d73c506f6cce4ff --- /dev/null +++ b/packages/uni-app-plus/src/view/framework/dom/elements/UniTodoNode.ts @@ -0,0 +1,7 @@ +import { UniNode } from '../elements/UniNode' + +export class UniTodoNode extends UniNode { + constructor(id: number, tag: string, parentNodeId: number) { + super(id, tag, parentNodeId) + } +} diff --git a/packages/uni-app-plus/src/view/framework/dom/index.ts b/packages/uni-app-plus/src/view/framework/dom/index.ts index 27eba5df9ba5afa38ceaa102a659d4159ecccc47..ca9f137018b3a5d9bcd776f8cb4102520649a9a9 100644 --- a/packages/uni-app-plus/src/view/framework/dom/index.ts +++ b/packages/uni-app-plus/src/view/framework/dom/index.ts @@ -1,16 +1,16 @@ import { - ACTION_TYPE_ADD_EVENT, - ACTION_TYPE_CREATE, - ACTION_TYPE_INSERT, + PageAction, ACTION_TYPE_PAGE_CREATE, ACTION_TYPE_PAGE_CREATED, + ACTION_TYPE_CREATE, + ACTION_TYPE_INSERT, ACTION_TYPE_REMOVE, + ACTION_TYPE_SET_ATTRIBUTE, ACTION_TYPE_REMOVE_ATTRIBUTE, + ACTION_TYPE_ADD_EVENT, ACTION_TYPE_REMOVE_EVENT, - ACTION_TYPE_SET_ATTRIBUTE, ACTION_TYPE_SET_TEXT, - PageAction, -} from '../../../PageAction' +} from '@dcloudio/uni-shared' import { $, createElement, onPageCreate, onPageCreated } from './page' import { flushPostActionJobs } from './scheduler' diff --git a/packages/uni-app-plus/src/view/framework/dom/modules/events.ts b/packages/uni-app-plus/src/view/framework/dom/modules/events.ts index 4916dca8b8337969d3b350a77ff216d7aa8acd7f..d311b9940b94fa97e18866e6729d06a8e35d1e77 100644 --- a/packages/uni-app-plus/src/view/framework/dom/modules/events.ts +++ b/packages/uni-app-plus/src/view/framework/dom/modules/events.ts @@ -6,9 +6,9 @@ import { formatLog, EventModifierFlags, normalizeEventType, + ACTION_TYPE_EVENT, } from '@dcloudio/uni-shared' import { VD_SYNC } from '../../../../constants' -import { ACTION_TYPE_EVENT } from '../../../../PageAction' import { UniCustomElement } from '../components' export function patchEvent(el: UniCustomElement, name: string, flag: number) { diff --git a/packages/uni-shared/dist/uni-shared.cjs.js b/packages/uni-shared/dist/uni-shared.cjs.js index 7b1f5aa381b81cd59ae7978e6592a1694e588e6d..5998b0d90ff96120748d29f4fadc64c92d1f8d61 100644 --- a/packages/uni-shared/dist/uni-shared.cjs.js +++ b/packages/uni-shared/dist/uni-shared.cjs.js @@ -904,6 +904,18 @@ function decodeTag(tag) { return (DECODED_COMPONENT_ARR[tag] || tag); } +const ACTION_TYPE_PAGE_CREATE = 1; +const ACTION_TYPE_PAGE_CREATED = 2; +const ACTION_TYPE_CREATE = 3; +const ACTION_TYPE_INSERT = 4; +const ACTION_TYPE_REMOVE = 5; +const ACTION_TYPE_SET_ATTRIBUTE = 6; +const ACTION_TYPE_REMOVE_ATTRIBUTE = 7; +const ACTION_TYPE_ADD_EVENT = 8; +const ACTION_TYPE_REMOVE_EVENT = 9; +const ACTION_TYPE_SET_TEXT = 10; +const ACTION_TYPE_EVENT = 20; + function cache(fn) { const cache = Object.create(null); return (str) => { @@ -1014,6 +1026,17 @@ function getEnvLocale() { return (lang && lang.replace(/[.:].*/, '')) || 'en'; } +exports.ACTION_TYPE_ADD_EVENT = ACTION_TYPE_ADD_EVENT; +exports.ACTION_TYPE_CREATE = ACTION_TYPE_CREATE; +exports.ACTION_TYPE_EVENT = ACTION_TYPE_EVENT; +exports.ACTION_TYPE_INSERT = ACTION_TYPE_INSERT; +exports.ACTION_TYPE_PAGE_CREATE = ACTION_TYPE_PAGE_CREATE; +exports.ACTION_TYPE_PAGE_CREATED = ACTION_TYPE_PAGE_CREATED; +exports.ACTION_TYPE_REMOVE = ACTION_TYPE_REMOVE; +exports.ACTION_TYPE_REMOVE_ATTRIBUTE = ACTION_TYPE_REMOVE_ATTRIBUTE; +exports.ACTION_TYPE_REMOVE_EVENT = ACTION_TYPE_REMOVE_EVENT; +exports.ACTION_TYPE_SET_ATTRIBUTE = ACTION_TYPE_SET_ATTRIBUTE; +exports.ACTION_TYPE_SET_TEXT = ACTION_TYPE_SET_TEXT; exports.BACKGROUND_COLOR = BACKGROUND_COLOR; exports.BUILT_IN_TAGS = BUILT_IN_TAGS; exports.COMPONENT_NAME_PREFIX = COMPONENT_NAME_PREFIX; diff --git a/packages/uni-shared/dist/uni-shared.d.ts b/packages/uni-shared/dist/uni-shared.d.ts index f10289b8e627a3fd5a26e0caa5843d95e2b5f2c6..866531459e07aa15879b4058bb49de208571f1ee 100644 --- a/packages/uni-shared/dist/uni-shared.d.ts +++ b/packages/uni-shared/dist/uni-shared.d.ts @@ -1,5 +1,39 @@ import { FontFaceDescriptors } from 'css-font-loading-module'; +export declare const ACTION_TYPE_ADD_EVENT = 8; + +export declare const ACTION_TYPE_CREATE = 3; + +export declare const ACTION_TYPE_EVENT = 20; + +export declare const ACTION_TYPE_INSERT = 4; + +export declare const ACTION_TYPE_PAGE_CREATE = 1; + +export declare const ACTION_TYPE_PAGE_CREATED = 2; + +export declare const ACTION_TYPE_REMOVE = 5; + +export declare const ACTION_TYPE_REMOVE_ATTRIBUTE = 7; + +export declare const ACTION_TYPE_REMOVE_EVENT = 9; + +export declare const ACTION_TYPE_SET_ATTRIBUTE = 6; + +export declare const ACTION_TYPE_SET_TEXT = 10; + +/** + * nodeId + * event + * flag + */ +export declare type AddEventAction = [ +typeof ACTION_TYPE_ADD_EVENT, +number, +string, +number +]; + export declare function addFont(family: string, source: string, desc?: FontFaceDescriptors): Promise; export declare const BACKGROUND_COLOR = "#f7f7f7"; @@ -23,6 +57,20 @@ export declare const COMPONENT_PREFIX: string; export declare const COMPONENT_SELECTOR_PREFIX = "uni-"; +/** + * nodeId + * tag + * parentNodeId + * nodeJson + */ +export declare type CreateAction = [ +typeof ACTION_TYPE_CREATE, +number, +string | number, +number, +Partial? +]; + export declare function createRpx2Unit(unit: string, unitRatio: number, unitPrecision: number): (val: string) => string; export declare const DATA_RE: RegExp; @@ -86,6 +134,13 @@ declare interface HTMLElementWithDataset extends HTMLElement { export declare function initCustomDataset(): void; +/** + * nodeId + * parentNodeId + * refNodeId + */ +export declare type InsertAction = [typeof ACTION_TYPE_INSERT, number, number, number]; + export declare const invokeArrayFns: (fns: Function[], arg?: any) => any; export declare function isBuiltInComponent(tag: string): boolean; @@ -146,6 +201,34 @@ declare interface Options { complete?: (res: any) => void; } +export declare type PageAction = PageCreateAction | PageCreatedAction | PageUpdateAction; + +export declare type PageCreateAction = [typeof ACTION_TYPE_PAGE_CREATE, PageCreateData]; + +export declare type PageCreatedAction = [typeof ACTION_TYPE_PAGE_CREATED]; + +export declare interface PageCreateData extends PageNodeOptions { +} + +export declare interface PageNodeOptions { + css: boolean; + route: string; + version: number; + locale: string; + platform: string; + pixelRatio: number; + windowWidth: number; + disableScroll: boolean; + onPageScroll: boolean; + onPageReachBottom: boolean; + onReachBottomDistance: number; + statusbarHeight: number; + windowTop: number; + windowBottom: number; +} + +export declare type PageUpdateAction = CreateAction | InsertAction | RemoveAction | AddEventAction | RemoveEventAction | SetAttributeAction | RemoveAttributeAction | SetTextAction; + export declare function parseEventName(name: string): [string, EventListenerOptions | undefined]; /** @@ -172,6 +255,31 @@ export declare function plusReady(callback: () => void): void; export declare const PRIMARY_COLOR = "#007aff"; +/** + * nodeId + */ +export declare type RemoveAction = [typeof ACTION_TYPE_REMOVE, number]; + +/** + * nodeId + * name + */ +export declare type RemoveAttributeAction = [ +typeof ACTION_TYPE_REMOVE_ATTRIBUTE, +number, +string +]; + +/** + * nodeId + * event + */ +export declare type RemoveEventAction = [ +typeof ACTION_TYPE_REMOVE_EVENT, +number, +string +]; + export declare function removeLeadingSlash(str: string): string; export declare const RESPONSIVE_MIN_WIDTH = 768; @@ -187,6 +295,24 @@ export { scrollTo_2 as scrollTo } export declare const SELECTED_COLOR = "#0062cc"; +/** + * nodeId + * name + * value + */ +export declare type SetAttributeAction = [ +typeof ACTION_TYPE_SET_ATTRIBUTE, +number, +string, +unknown +]; + +/** + * nodeId + * text + */ +export declare type SetTextAction = [typeof ACTION_TYPE_SET_TEXT, number, string]; + export declare function stringifyQuery(obj?: Record, encodeStr?: typeof encodeURIComponent): string; export declare const TABBAR_HEIGHT = 50; diff --git a/packages/uni-shared/dist/uni-shared.es.js b/packages/uni-shared/dist/uni-shared.es.js index 83d7cd4a50e030773b497952f9401147ecc7b7ec..e3fc9f727b3443345041e9010916ed584a33c84d 100644 --- a/packages/uni-shared/dist/uni-shared.es.js +++ b/packages/uni-shared/dist/uni-shared.es.js @@ -900,6 +900,18 @@ function decodeTag(tag) { return (DECODED_COMPONENT_ARR[tag] || tag); } +const ACTION_TYPE_PAGE_CREATE = 1; +const ACTION_TYPE_PAGE_CREATED = 2; +const ACTION_TYPE_CREATE = 3; +const ACTION_TYPE_INSERT = 4; +const ACTION_TYPE_REMOVE = 5; +const ACTION_TYPE_SET_ATTRIBUTE = 6; +const ACTION_TYPE_REMOVE_ATTRIBUTE = 7; +const ACTION_TYPE_ADD_EVENT = 8; +const ACTION_TYPE_REMOVE_EVENT = 9; +const ACTION_TYPE_SET_TEXT = 10; +const ACTION_TYPE_EVENT = 20; + function cache(fn) { const cache = Object.create(null); return (str) => { @@ -1010,4 +1022,4 @@ function getEnvLocale() { return (lang && lang.replace(/[.:].*/, '')) || 'en'; } -export { BACKGROUND_COLOR, BUILT_IN_TAGS, COMPONENT_NAME_PREFIX, COMPONENT_PREFIX, COMPONENT_SELECTOR_PREFIX, DATA_RE, EventModifierFlags, NAVBAR_HEIGHT, NODE_TYPE_COMMENT, NODE_TYPE_ELEMENT, NODE_TYPE_PAGE, NODE_TYPE_TEXT, ON_REACH_BOTTOM_DISTANCE, PLUS_RE, PRIMARY_COLOR, RESPONSIVE_MIN_WIDTH, SCHEME_RE, SELECTED_COLOR, TABBAR_HEIGHT, TAGS, UNI_SSR, UNI_SSR_DATA, UNI_SSR_GLOBAL_DATA, UNI_SSR_STORE, UNI_SSR_TITLE, UniBaseNode, UniCommentNode, UniElement, UniEvent, UniInputElement, UniNode, UniTextAreaElement, UniTextNode, WEB_INVOKE_APPSERVICE, addFont, cache, cacheStringFunction, callOptions, createRpx2Unit, debounce, decode, decodeAttr, decodeEvent, decodeTag, decodedQuery, defaultRpx2Unit, encodeAttr, encodeEvent, encodeTag, formatDateTime, formatLog, getCustomDataset, getEnvLocale, getLen, initCustomDataset, invokeArrayFns, isBuiltInComponent, isCustomElement, isNativeTag, isServiceCustomElement, isServiceNativeTag, normalizeDataset, normalizeEventType, normalizeTarget, once, parseEventName, parseQuery, parseUrl, passive, plusReady, removeLeadingSlash, sanitise, scrollTo, stringifyQuery, updateElementStyle }; +export { ACTION_TYPE_ADD_EVENT, ACTION_TYPE_CREATE, ACTION_TYPE_EVENT, ACTION_TYPE_INSERT, ACTION_TYPE_PAGE_CREATE, ACTION_TYPE_PAGE_CREATED, ACTION_TYPE_REMOVE, ACTION_TYPE_REMOVE_ATTRIBUTE, ACTION_TYPE_REMOVE_EVENT, ACTION_TYPE_SET_ATTRIBUTE, ACTION_TYPE_SET_TEXT, BACKGROUND_COLOR, BUILT_IN_TAGS, COMPONENT_NAME_PREFIX, COMPONENT_PREFIX, COMPONENT_SELECTOR_PREFIX, DATA_RE, EventModifierFlags, NAVBAR_HEIGHT, NODE_TYPE_COMMENT, NODE_TYPE_ELEMENT, NODE_TYPE_PAGE, NODE_TYPE_TEXT, ON_REACH_BOTTOM_DISTANCE, PLUS_RE, PRIMARY_COLOR, RESPONSIVE_MIN_WIDTH, SCHEME_RE, SELECTED_COLOR, TABBAR_HEIGHT, TAGS, UNI_SSR, UNI_SSR_DATA, UNI_SSR_GLOBAL_DATA, UNI_SSR_STORE, UNI_SSR_TITLE, UniBaseNode, UniCommentNode, UniElement, UniEvent, UniInputElement, UniNode, UniTextAreaElement, UniTextNode, WEB_INVOKE_APPSERVICE, addFont, cache, cacheStringFunction, callOptions, createRpx2Unit, debounce, decode, decodeAttr, decodeEvent, decodeTag, decodedQuery, defaultRpx2Unit, encodeAttr, encodeEvent, encodeTag, formatDateTime, formatLog, getCustomDataset, getEnvLocale, getLen, initCustomDataset, invokeArrayFns, isBuiltInComponent, isCustomElement, isNativeTag, isServiceCustomElement, isServiceNativeTag, normalizeDataset, normalizeEventType, normalizeTarget, once, parseEventName, parseQuery, parseUrl, passive, plusReady, removeLeadingSlash, sanitise, scrollTo, stringifyQuery, updateElementStyle }; diff --git a/packages/uni-app-plus/src/PageAction.ts b/packages/uni-shared/src/vdom/Action.ts similarity index 61% rename from packages/uni-app-plus/src/PageAction.ts rename to packages/uni-shared/src/vdom/Action.ts index f9d0c50bf605d1f8f5e1d3b8cd4fd83f028cc7b9..82587e777fa60a496a57932a5a772dbbbc11b415 100644 --- a/packages/uni-app-plus/src/PageAction.ts +++ b/packages/uni-shared/src/vdom/Action.ts @@ -1,6 +1,4 @@ -import { onNodeEvent } from './service/framework/dom/onNodeEvent' -import { createElement } from './view/framework/dom/page' -import { UniElement } from './view/framework/dom/elements/UniElement' +import { UniNodeJSON } from './Node' export const ACTION_TYPE_PAGE_CREATE = 1 export const ACTION_TYPE_PAGE_CREATED = 2 @@ -37,53 +35,81 @@ export interface PageCreateData extends PageNodeOptions {} export type PageCreateAction = [typeof ACTION_TYPE_PAGE_CREATE, PageCreateData] export type PageCreatedAction = [typeof ACTION_TYPE_PAGE_CREATED] -export type EventAction = [ - typeof ACTION_TYPE_EVENT, - Parameters[0], - Parameters[1] -] - +/** + * nodeId + * tag + * parentNodeId + * nodeJson + */ export type CreateAction = [ typeof ACTION_TYPE_CREATE, - ...Parameters -] - -type NodeAction> = [/* nodeId */ number, ...T] - -export type InsertAction = [ - typeof ACTION_TYPE_INSERT, - ...NodeAction['insert']>> -] - -export type RemoveAction = [ - typeof ACTION_TYPE_REMOVE, - ...NodeAction['remove']>> + number, + string | number, + number, + Partial? ] +/** + * nodeId + * parentNodeId + * refNodeId + */ +export type InsertAction = [typeof ACTION_TYPE_INSERT, number, number, number] + +/** + * nodeId + */ +export type RemoveAction = [typeof ACTION_TYPE_REMOVE, number] + +/** + * nodeId + * event + * flag + */ export type AddEventAction = [ typeof ACTION_TYPE_ADD_EVENT, - ...NodeAction['addEvent']>> + number, + string, + number ] +/** + * nodeId + * event + */ export type RemoveEventAction = [ typeof ACTION_TYPE_REMOVE_EVENT, - ...NodeAction['removeEvent']>> + number, + string ] +/** + * nodeId + * name + * value + */ export type SetAttributeAction = [ typeof ACTION_TYPE_SET_ATTRIBUTE, - ...NodeAction['setAttr']>> + number, + string, + unknown ] +/** + * nodeId + * name + */ export type RemoveAttributeAction = [ typeof ACTION_TYPE_REMOVE_ATTRIBUTE, - ...NodeAction['removeAttr']>> + number, + string ] -export type SetTextAction = [ - typeof ACTION_TYPE_SET_TEXT, - ...NodeAction['setText']>> -] +/** + * nodeId + * text + */ +export type SetTextAction = [typeof ACTION_TYPE_SET_TEXT, number, string] export type PageUpdateAction = | CreateAction diff --git a/packages/uni-shared/src/vdom/constants.ts b/packages/uni-shared/src/vdom/constants.ts new file mode 100644 index 0000000000000000000000000000000000000000..9c128cc4d9be132d6472dd31e9728855668887e2 --- /dev/null +++ b/packages/uni-shared/src/vdom/constants.ts @@ -0,0 +1 @@ +export const ACTION_MINIFY = true diff --git a/packages/uni-shared/src/vdom/index.ts b/packages/uni-shared/src/vdom/index.ts index 197861a480b8514ea98da133ed08f7050d4ab2d2..422c5039d1519b852d25bbc0b53453dddc3bf5b3 100644 --- a/packages/uni-shared/src/vdom/index.ts +++ b/packages/uni-shared/src/vdom/index.ts @@ -20,3 +20,4 @@ export { UniTextNode } from './Text' export { encodeAttr, encodeEvent, encodeTag } from './encode' export { decodeAttr, decodeEvent, decodeTag } from './decode' export { EventModifierFlags } from './encode' +export * from './Action'