提交 bf16c135 编写于 作者: DCloud-WZF's avatar DCloud-WZF 💬

wip(uts): automator

上级 44ae5f89
......@@ -3,7 +3,7 @@ import { JSONObject } from 'com.alibaba.fastjson'
import { getChildrenText, toCamelCase } from './util.uts'
export type GetElementParams = {
pageId: number
pageId: string
nodeId?: number | null
elementId?: string | null
selector: string
......@@ -43,7 +43,7 @@ export const getElements = (params: GetElementParams): void => {
}
export type GetDOMPropertiesParams = {
pageId: number
pageId: string
elementId?: string | null
nodeId?: number | null
names: string[]
......@@ -77,7 +77,7 @@ export const getDOMProperties = (params: GetDOMPropertiesParams): void => {
}
export type GetPropertiesParams = {
pageId: number
pageId: string
elementId?: string | null
nodeId?: number | null
names: string[]
......@@ -100,7 +100,7 @@ export const getProperties = (params: GetPropertiesParams): void => {
}
export type GetAttributesParams = {
pageId: number
pageId: string
elementId?: string | null
nodeId?: number | null
names: string[]
......@@ -121,7 +121,7 @@ export const getAttributes = (params: GetAttributesParams): void => {
}
export type CallFunctionParams = {
pageId: number
pageId: string
elementId: string
functionName: string
args: any[]
......@@ -141,7 +141,7 @@ export const callFunction = (params: CallFunctionParams): void => {
}
export type TapParams = {
pageId: number
pageId: string
elementId?: string | null
nodeId?: number | null
callback: (result: any | null, error: any | null) => void
......@@ -158,7 +158,7 @@ export const tap = (params: TapParams): void => {
}
export type CallMethodParams = {
pageId: number
pageId: string
nodeId: number
method: string
args: any[]
......@@ -174,7 +174,7 @@ export const callMethod = (params: CallMethodParams): void => {
}
export type GetDataParams = {
pageId: number
pageId: string
nodeId: number
path: string
callback: (result: any | null, error: any | null) => void
......@@ -188,7 +188,7 @@ export const getData = (params: GetDataParams): void => {
}
export type SetDataParams = {
pageId: number
pageId: string
nodeId: number
data: UTSJSONObject
callback: (result: any | null, error: any | null) => void
......@@ -202,7 +202,7 @@ export const setData = (params: SetDataParams): void => {
}
export type GetOffsetParams = {
pageId: number
pageId: string
elementId?: string | null
nodeId?: number | null
callback: (result: any | null, error: any | null) => void
......@@ -216,7 +216,7 @@ export const getOffset = (params: GetOffsetParams): void => {
}
export type LongpressParams = {
pageId: number
pageId: string
elementId?: string | null
nodeId?: number | null
callback: (result: any | null, error: any | null) => void
......@@ -233,7 +233,7 @@ export const longpress = (params: LongpressParams): void => {
}
export type HandleTouchEventParams = {
pageId: number
pageId: string
elementId?: string | null
nodeId?: number | null
eventName: string
......@@ -264,7 +264,7 @@ function getTouches(touches: any[]): Touch[] {
}
export type GetStylesParams = {
pageId: number
pageId: string
elementId?: string | null
nodeId?: number | null
names: string[]
......
import { pageGetData, pageSetData, getPageVm, getValidComponentsOrNodes } from './util.uts'
export type GetDataParams = {
pageId: number
pageId: string
path: string
callback: (result: any | null, error: any | null) => void
}
......@@ -17,7 +17,7 @@ export const getData = (params: GetDataParams): void => {
}
export type SetDataParams = {
pageId: number
pageId: string
data: UTSJSONObject
callback: (result: any | null, error: any | null) => void
}
......@@ -33,7 +33,7 @@ export const setData = (params: SetDataParams): void => {
}
}
export type CallMethodParams = {
pageId: number
pageId: string
method: string
args: any[]
callback: (result: any | null, error: any | null) => void
......@@ -52,7 +52,7 @@ export const callMethod = (params: CallMethodParams): void => {
}
export type GetElementParams = {
pageId: number
pageId: string
selector: string
callback: (result: any | null, error: any | null) => void
}
......@@ -91,7 +91,7 @@ export const getElements = (params: GetElementParams): void => {
}
export type GetWindowPropertiesParams = {
pageId: number,
pageId: string,
names: string[],
callback: (result: any | null, error: any | null) => void
}
......
function getPageId(page: BasePage): number {
return page.$.uid
function getPageId(page: BasePage): string {
return page.$appPage!.pageId
}
function getPagePath(page: BasePage): string {
......@@ -10,7 +10,7 @@ function getPageQuery(page: BasePage): Map<string, string | null> {
return page.options
}
function getPageById(id: number): BasePage | null {
function getPageById(id: string): BasePage | null {
const pages = getCurrentPages()
let result: BasePage | null = null
pages.forEach((page: BasePage) => {
......@@ -21,7 +21,7 @@ function getPageById(id: number): BasePage | null {
return result
}
export function getPageVm(id: number): BasePage | null {
export function getPageVm(id: string): BasePage | null {
return getPageById(id)
}
......@@ -54,7 +54,7 @@ export function parsePage(page: BasePage): UTSJSONObject {
} as UTSJSONObject
}
export function getComponentVmBySelector(pageId: number, selector: string, callback: (result: any | null, error: any | null) => void): ComponentPublicInstance | null {
export function getComponentVmBySelector(pageId: string, selector: string, callback: (result: any | null, error: any | null) => void): ComponentPublicInstance | null {
const page = getPageVm(pageId)
if (page == null) {
callback(null, { errMsg: `Page[${pageId}] not exists` })
......@@ -68,7 +68,7 @@ export function getComponentVmBySelector(pageId: number, selector: string, callb
return component
}
export function getComponentVmByNodeId(pageId: number, nodeId: number, callback: (result: any | null, error: any | null) => void): ComponentPublicInstance | null {
export function getComponentVmByNodeId(pageId: string, nodeId: number, callback: (result: any | null, error: any | null) => void): ComponentPublicInstance | null {
const page = getPageVm(pageId)
if (page == null) {
callback(null, { errMsg: `Page[${pageId}] not exists` })
......@@ -76,7 +76,7 @@ export function getComponentVmByNodeId(pageId: number, nodeId: number, callback:
}
let component: ComponentPublicInstance | null = null
function getComponentChild(parent: ComponentPublicInstance) {
if (parent.$.uid == nodeId) {
if (parent.$.uid.toInt() == nodeId) {
component = parent
return
}
......@@ -92,7 +92,7 @@ export function getComponentVmByNodeId(pageId: number, nodeId: number, callback:
return component
}
export function getElementByIdOrNodeId(pageId: number, elementId: string | null, nodeId: number | null, callback: (result: any | null, error: any | null) => void): INode | null {
export function getElementByIdOrNodeId(pageId: string, elementId: string | null, nodeId: number | null, callback: (result: any | null, error: any | null) => void): INode | null {
if (nodeId != null) {
return getComponentDomByNodeId(pageId, nodeId, callback)
} else if (elementId != null) {
......@@ -101,7 +101,7 @@ export function getElementByIdOrNodeId(pageId: number, elementId: string | null,
return null
}
export function getComponentDomByNodeId(pageId: number, nodeId: number, callback: (result: any | null, error: any | null) => void): INode | null {
export function getComponentDomByNodeId(pageId: string, nodeId: number, callback: (result: any | null, error: any | null) => void): INode | null {
const component = getComponentVmByNodeId(pageId, nodeId, callback)
if (component == null) {
return null
......@@ -109,7 +109,7 @@ export function getComponentDomByNodeId(pageId: number, nodeId: number, callback
return component.$el
}
export function getElementByNodeIdOrElementId(pageId: number, nodeId: number | null, elementId: string | null, callback: (result: any | null, error: any | null) => void): INode | null {
export function getElementByNodeIdOrElementId(pageId: string, nodeId: number | null, elementId: string | null, callback: (result: any | null, error: any | null) => void): INode | null {
const page = getPageVm(pageId)
if (page == null) {
callback(null, { errMsg: `Page[${pageId}] not exists` })
......@@ -123,7 +123,7 @@ export function getElementByNodeIdOrElementId(pageId: number, nodeId: number | n
return null
}
export function getElementById(pageId: number, elementId: string, callback: (result: any | null, error: any | null) => void): INode | null {
export function getElementById(pageId: string, elementId: string, callback: (result: any | null, error: any | null) => void): INode | null {
const page = getPageVm(pageId)
if (page == null) {
callback(null, { errMsg: `Page[${pageId}] not exists` })
......
......@@ -104,7 +104,7 @@ export function onMessage(msg: string) {
break
}
} else if (method.startsWith('Page.')) {
const pageId = params['pageId'] as number
const pageId = params['pageId'] as string
switch (method) {
case 'Page.getData':
const path = params['path'] != null ? (params['path'] as string) : ''
......@@ -136,7 +136,7 @@ export function onMessage(msg: string) {
break
}
} else if (method.startsWith('Element.')) {
const pageId = params['pageId'] as number
const pageId = params['pageId'] as string
switch (method) {
case 'Element.getElement':
const getElementElementId = params['elementId'] != null ? params['elementId'] as string : null
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册