@tarojs/plugin-platform-harmony-cpp 4.1.0 → 4.1.1-alpha.1
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 +0 -7
- package/dist/index.js +1236 -0
- package/dist/runtime/apis/apis.ts +20 -0
- package/dist/runtime/apis/base/crypto.ts +4 -0
- package/dist/runtime/apis/base/debug.ts +5 -0
- package/dist/runtime/apis/base/index.ts +13 -0
- package/dist/runtime/apis/base/performance.ts +8 -0
- package/dist/runtime/apis/base/system.ts +181 -0
- package/dist/runtime/apis/base/update.ts +5 -0
- package/dist/runtime/apis/base/weapp/app-event.ts +75 -0
- package/dist/runtime/apis/base/weapp/life-cycle.ts +21 -0
- package/dist/runtime/apis/canvas/index.ts +27 -0
- package/dist/runtime/apis/data-analysis/index.ts +6 -0
- package/dist/runtime/apis/device/accelerometer.ts +79 -0
- package/dist/runtime/apis/device/accessibility.ts +4 -0
- package/dist/runtime/apis/device/battery.ts +24 -0
- package/dist/runtime/apis/device/bluetooth-ble.ts +19 -0
- package/dist/runtime/apis/device/bluetooth-peripheral.ts +6 -0
- package/dist/runtime/apis/device/bluetooth.ts +16 -0
- package/dist/runtime/apis/device/calendar.ts +5 -0
- package/dist/runtime/apis/device/clipboard.ts +85 -0
- package/dist/runtime/apis/device/compass.ts +21 -0
- package/dist/runtime/apis/device/contact.ts +5 -0
- package/dist/runtime/apis/device/crypto.ts +4 -0
- package/dist/runtime/apis/device/gyroscope.ts +77 -0
- package/dist/runtime/apis/device/iBeacon.ts +10 -0
- package/dist/runtime/apis/device/index.ts +24 -0
- package/dist/runtime/apis/device/keyboard.ts +63 -0
- package/dist/runtime/apis/device/memory.ts +11 -0
- package/dist/runtime/apis/device/motion.ts +6 -0
- package/dist/runtime/apis/device/network.ts +123 -0
- package/dist/runtime/apis/device/nfc.ts +10 -0
- package/dist/runtime/apis/device/phone.ts +44 -0
- package/dist/runtime/apis/device/scan.ts +4 -0
- package/dist/runtime/apis/device/screen.ts +80 -0
- package/dist/runtime/apis/device/sms.ts +4 -0
- package/dist/runtime/apis/device/vibrate.ts +32 -0
- package/dist/runtime/apis/device/wifi.ts +15 -0
- package/dist/runtime/apis/ext/index.ts +5 -0
- package/dist/runtime/apis/files/index.ts +136 -0
- package/dist/runtime/apis/files/manager.ts +942 -0
- package/dist/runtime/apis/framework/index.ts +48 -0
- package/dist/runtime/apis/harmony/task-pool.ts +39 -0
- package/dist/runtime/apis/index.ts +61 -0
- package/dist/runtime/apis/location/index.ts +133 -0
- package/dist/runtime/apis/media/EditorContext.ts +32 -0
- package/dist/runtime/apis/media/audio/index.ts +36 -0
- package/dist/runtime/apis/media/background-audio/index.ts +16 -0
- package/dist/runtime/apis/media/camera.ts +16 -0
- package/dist/runtime/apis/media/common.ts +58 -0
- package/dist/runtime/apis/media/image/index.ts +291 -0
- package/dist/runtime/apis/media/index.ts +13 -0
- package/dist/runtime/apis/media/live.ts +5 -0
- package/dist/runtime/apis/media/map.ts +4 -0
- package/dist/runtime/apis/media/media-recorder.ts +4 -0
- package/dist/runtime/apis/media/recorder.ts +6 -0
- package/dist/runtime/apis/media/video/VideoContext.ts +67 -0
- package/dist/runtime/apis/media/video/index.ts +45 -0
- package/dist/runtime/apis/media/video-decoder.ts +4 -0
- package/dist/runtime/apis/media/video-processing.ts +4 -0
- package/dist/runtime/apis/media/voip.ts +19 -0
- package/dist/runtime/apis/navigate/index.ts +8 -0
- package/dist/runtime/apis/network/downloadFile.ts +85 -0
- package/dist/runtime/apis/network/index.ts +7 -0
- package/dist/runtime/apis/network/mdns.ts +13 -0
- package/dist/runtime/apis/network/request.ts +140 -0
- package/dist/runtime/apis/network/tcp.ts +4 -0
- package/dist/runtime/apis/network/udp.ts +4 -0
- package/dist/runtime/apis/network/uploadFile.ts +105 -0
- package/dist/runtime/apis/network/webSocket.ts +126 -0
- package/dist/runtime/apis/open-api/account.ts +4 -0
- package/dist/runtime/apis/open-api/address.ts +4 -0
- package/dist/runtime/apis/open-api/authorize.ts +5 -0
- package/dist/runtime/apis/open-api/card.ts +5 -0
- package/dist/runtime/apis/open-api/channels-live.ts +11 -0
- package/dist/runtime/apis/open-api/customer-service.ts +4 -0
- package/dist/runtime/apis/open-api/device-voip.ts +5 -0
- package/dist/runtime/apis/open-api/facial.ts +7 -0
- package/dist/runtime/apis/open-api/favorites.ts +5 -0
- package/dist/runtime/apis/open-api/group.ts +4 -0
- package/dist/runtime/apis/open-api/index.ts +21 -0
- package/dist/runtime/apis/open-api/invoice.ts +5 -0
- package/dist/runtime/apis/open-api/license-plate.ts +4 -0
- package/dist/runtime/apis/open-api/login.ts +6 -0
- package/dist/runtime/apis/open-api/my-miniprogram.ts +4 -0
- package/dist/runtime/apis/open-api/privacy.ts +7 -0
- package/dist/runtime/apis/open-api/red-package.ts +4 -0
- package/dist/runtime/apis/open-api/settings.ts +5 -0
- package/dist/runtime/apis/open-api/soter.ts +6 -0
- package/dist/runtime/apis/open-api/subscribe-message.ts +6 -0
- package/dist/runtime/apis/open-api/user-info.ts +70 -0
- package/dist/runtime/apis/open-api/werun.ts +5 -0
- package/dist/runtime/apis/payment/index.ts +6 -0
- package/dist/runtime/apis/route/index.ts +88 -0
- package/dist/runtime/apis/share/index.ts +33 -0
- package/dist/runtime/apis/storage/background-fetch.ts +7 -0
- package/dist/runtime/apis/storage/cache-manager.ts +4 -0
- package/dist/runtime/apis/storage/index.ts +203 -0
- package/dist/runtime/apis/ui/animation/animation.ts +264 -0
- package/dist/runtime/apis/ui/animation/index.ts +7 -0
- package/dist/runtime/apis/ui/background.ts +20 -0
- package/dist/runtime/apis/ui/custom-component.ts +1 -0
- package/dist/runtime/apis/ui/fonts.ts +4 -0
- package/dist/runtime/apis/ui/index.ts +12 -0
- package/dist/runtime/apis/ui/interaction/index.ts +198 -0
- package/dist/runtime/apis/ui/menu.ts +4 -0
- package/dist/runtime/apis/ui/navigation-bar/index.ts +72 -0
- package/dist/runtime/apis/ui/pull-down-refresh.ts +47 -0
- package/dist/runtime/apis/ui/scroll/index.ts +82 -0
- package/dist/runtime/apis/ui/sticky.ts +4 -0
- package/dist/runtime/apis/ui/tab-bar.ts +144 -0
- package/dist/runtime/apis/ui/window.ts +20 -0
- package/dist/runtime/apis/utils/constant.ts +1 -0
- package/dist/runtime/apis/utils/handler.ts +117 -0
- package/dist/runtime/apis/utils/index.ts +105 -0
- package/dist/runtime/apis/utils/permissions.ts +6 -0
- package/dist/runtime/apis/utils/types.ts +12 -0
- package/dist/runtime/apis/utils/unit.ts +104 -0
- package/dist/runtime/apis/utils/validate.ts +87 -0
- package/dist/runtime/apis/worker/index.ts +4 -0
- package/dist/runtime/apis/wxml/index.ts +17 -0
- package/dist/runtime/apis/wxml/intersectionObserver.ts +100 -0
- package/dist/runtime/apis/wxml/nodesRef.ts +58 -0
- package/dist/runtime/apis/wxml/selectorQuery.ts +221 -0
- package/dist/runtime/apischunk/index.d.ts +802 -0
- package/dist/runtime/apischunk/index.js +5054 -0
- package/dist/runtime/components/deprecated.ets +43 -0
- package/dist/runtime/components/index.ets +49 -0
- package/dist/runtime/components/innerHtml.ets +16 -0
- package/dist/runtime/components/navigationBar.ets +65 -0
- package/dist/runtime/components/pageMeta.ets +94 -0
- package/dist/runtime/components/richText.ets +24 -0
- package/dist/runtime/components/slider.ets +119 -0
- package/dist/runtime/components/style.ets +286 -0
- package/dist/runtime/components/switch.ets +73 -0
- package/dist/runtime/components/tag.ts +58 -0
- package/dist/runtime/components/utils/AttributeManager.ets +252 -0
- package/dist/runtime/components/utils/DynamicCenter.ts +41 -0
- package/dist/runtime/components/utils/constant/event.ets +25 -0
- package/dist/runtime/components/utils/constant/style.ets +91 -0
- package/dist/runtime/components/utils/events.ts +26 -0
- package/dist/runtime/components/utils/flexManager.ets +49 -0
- package/dist/runtime/components/utils/helper.ets +51 -0
- package/dist/runtime/components/utils/htmlParser/HarmonyHTMLParser.ts +100 -0
- package/dist/runtime/components/utils/htmlParser/index.ts +58 -0
- package/dist/runtime/components/utils/index.ts +77 -0
- package/dist/runtime/components/utils/styles.ets +41 -0
- package/dist/runtime/components/video.ets +119 -0
- package/dist/runtime/components/webView.ets +55 -0
- package/dist/runtime/components/xComponent.ets +89 -0
- package/dist/runtime/framework/app.ts +248 -0
- package/dist/runtime/framework/connect.ts +24 -0
- package/dist/runtime/framework/constant.ts +3 -0
- package/dist/runtime/framework/hooks.ts +99 -0
- package/dist/runtime/framework/index.ts +15 -0
- package/dist/runtime/framework/native-page.ts +511 -0
- package/dist/runtime/framework/page.ts +256 -0
- package/dist/runtime/framework/utils/index.ts +17 -0
- package/dist/runtime/framework/utils/is.ts +26 -0
- package/dist/runtime/framework-reconciler/componentTree.ts +81 -0
- package/dist/runtime/framework-reconciler/constant.ts +86 -0
- package/dist/runtime/framework-reconciler/domInput.ts +90 -0
- package/dist/runtime/framework-reconciler/event.ts +108 -0
- package/dist/runtime/framework-reconciler/index.ts +99 -0
- package/dist/runtime/framework-reconciler/inputValueTracking.ts +106 -0
- package/dist/runtime/framework-reconciler/props.ts +132 -0
- package/dist/runtime/framework-reconciler/reconciler.ts +202 -0
- package/dist/runtime/framework-reconciler/render.ts +139 -0
- package/dist/runtime/framework-reconciler/workTags.ts +53 -0
- package/dist/runtime/runtime-cpp/bom/URL.ts +2 -0
- package/dist/runtime/runtime-cpp/bom/document.ts +45 -0
- package/dist/runtime/runtime-cpp/bom/history.ts +1 -0
- package/dist/runtime/runtime-cpp/bom/location.ts +1 -0
- package/dist/runtime/runtime-cpp/bom/navigator.ts +1 -0
- package/dist/runtime/runtime-cpp/bom/raf.ts +1 -0
- package/dist/runtime/runtime-cpp/bom/window.ts +57 -0
- package/dist/runtime/runtime-cpp/constant.ts +29 -0
- package/dist/runtime/runtime-cpp/current.ts +48 -0
- package/dist/runtime/runtime-cpp/dom/class-list.ts +41 -0
- package/dist/runtime/runtime-cpp/dom/comment.ts +9 -0
- package/dist/runtime/runtime-cpp/dom/dataSource.ts +87 -0
- package/dist/runtime/runtime-cpp/dom/document.ts +113 -0
- package/dist/runtime/runtime-cpp/dom/element/canvas.ts +285 -0
- package/dist/runtime/runtime-cpp/dom/element/element.ts +262 -0
- package/dist/runtime/runtime-cpp/dom/element/form.ts +371 -0
- package/dist/runtime/runtime-cpp/dom/element/index.ts +129 -0
- package/dist/runtime/runtime-cpp/dom/element/movable.ts +250 -0
- package/dist/runtime/runtime-cpp/dom/element/normal.ts +123 -0
- package/dist/runtime/runtime-cpp/dom/element/scroll_view.ts +32 -0
- package/dist/runtime/runtime-cpp/dom/element/text.ts +9 -0
- package/dist/runtime/runtime-cpp/dom/element/video.ts +66 -0
- package/dist/runtime/runtime-cpp/dom/element/web_view.ts +72 -0
- package/dist/runtime/runtime-cpp/dom/event-source.ts +1 -0
- package/dist/runtime/runtime-cpp/dom/event.ts +187 -0
- package/dist/runtime/runtime-cpp/dom/eventTarget.ts +81 -0
- package/dist/runtime/runtime-cpp/dom/node.ts +307 -0
- package/dist/runtime/runtime-cpp/dom/style.ts +44 -0
- package/dist/runtime/runtime-cpp/dom/stylesheet/index.ts +379 -0
- package/dist/runtime/runtime-cpp/dom/stylesheet/type.ts +212 -0
- package/dist/runtime/runtime-cpp/dom/stylesheet/util.ts +186 -0
- package/dist/runtime/runtime-cpp/emitter/emitter.ts +29 -0
- package/dist/runtime/runtime-cpp/env.ts +1 -0
- package/dist/runtime/runtime-cpp/harmony-library.ts +1 -0
- package/dist/runtime/runtime-cpp/index.ts +79 -0
- package/dist/runtime/runtime-cpp/interface/event.ts +10 -0
- package/dist/runtime/runtime-cpp/interface/index.ts +7 -0
- package/dist/runtime/runtime-cpp/next-tick.ts +14 -0
- package/dist/runtime/runtime-cpp/system.ts +213 -0
- package/dist/runtime/runtime-cpp/utils/index.ts +63 -0
- package/dist/runtime/runtime-cpp/utils/info.ts +123 -0
- package/dist/runtime/runtime-cpp/utils/page.ts +12 -0
- package/dist/runtime/runtime-cpp/utils/router.ts +1 -0
- package/dist/runtime/runtime-harmony/apis/helper.ets +33 -0
- package/dist/runtime/runtime-harmony/apis/network/common.ets +41 -0
- package/dist/runtime/runtime-harmony/apis/network/downloadFile.ets +327 -0
- package/dist/runtime/runtime-harmony/apis/network/index.ets +58 -0
- package/dist/runtime/runtime-harmony/apis/network/request.ets +206 -0
- package/dist/runtime/runtime-harmony/apis/network/uploadFile.ets +190 -0
- package/dist/runtime/runtime-harmony/apis/route.ets +110 -0
- package/dist/runtime/runtime-harmony/apis/taskpool.ets +149 -0
- package/dist/runtime/runtime-harmony/index.ets +41 -0
- package/dist/runtime/runtime-harmony/utils.ts +53 -0
- package/package.json +25 -23
- package/static/@taro-oh/library-4.1.1-alpha.0.har +0 -0
- package/LICENSE +0 -174
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
export type WorkTag =
|
|
2
|
+
| 0
|
|
3
|
+
| 1
|
|
4
|
+
| 2
|
|
5
|
+
| 3
|
|
6
|
+
| 4
|
|
7
|
+
| 5
|
|
8
|
+
| 6
|
|
9
|
+
| 7
|
|
10
|
+
| 8
|
|
11
|
+
| 9
|
|
12
|
+
| 10
|
|
13
|
+
| 11
|
|
14
|
+
| 12
|
|
15
|
+
| 13
|
|
16
|
+
| 14
|
|
17
|
+
| 15
|
|
18
|
+
| 16
|
|
19
|
+
| 17
|
|
20
|
+
| 18
|
|
21
|
+
| 19
|
|
22
|
+
| 20
|
|
23
|
+
| 21
|
|
24
|
+
| 22
|
|
25
|
+
| 23
|
|
26
|
+
| 24
|
|
27
|
+
| 25
|
|
28
|
+
|
|
29
|
+
export const FunctionComponent = 0
|
|
30
|
+
export const ClassComponent = 1
|
|
31
|
+
export const IndeterminateComponent = 2 // Before we know whether it is function or class
|
|
32
|
+
export const HostRoot = 3 // Root of a host tree. Could be nested inside another node.
|
|
33
|
+
export const HostPortal = 4 // A subtree. Could be an entry point to a different renderer.
|
|
34
|
+
export const HostComponent = 5
|
|
35
|
+
export const HostText = 6
|
|
36
|
+
export const Fragment = 7
|
|
37
|
+
export const Mode = 8
|
|
38
|
+
export const ContextConsumer = 9
|
|
39
|
+
export const ContextProvider = 10
|
|
40
|
+
export const ForwardRef = 11
|
|
41
|
+
export const Profiler = 12
|
|
42
|
+
export const SuspenseComponent = 13
|
|
43
|
+
export const MemoComponent = 14
|
|
44
|
+
export const SimpleMemoComponent = 15
|
|
45
|
+
export const LazyComponent = 16
|
|
46
|
+
export const IncompleteClassComponent = 17
|
|
47
|
+
export const DehydratedFragment = 18
|
|
48
|
+
export const SuspenseListComponent = 19
|
|
49
|
+
export const ScopeComponent = 21
|
|
50
|
+
export const OffscreenComponent = 22
|
|
51
|
+
export const LegacyHiddenComponent = 23
|
|
52
|
+
export const CacheComponent = 24
|
|
53
|
+
export const TracingMarkerComponent = 25
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { APP, BODY, HEAD, HTML } from '../constant'
|
|
2
|
+
import { TaroDocument } from '../dom/document'
|
|
3
|
+
import { window } from './window'
|
|
4
|
+
|
|
5
|
+
function createDocument (): TaroDocument {
|
|
6
|
+
/**
|
|
7
|
+
* <html> <--- document.documentElement
|
|
8
|
+
* <head></head> <--- document.head
|
|
9
|
+
* <body> <--- document.body
|
|
10
|
+
* <container>
|
|
11
|
+
* <app id="app" />
|
|
12
|
+
* </container>
|
|
13
|
+
* </body>
|
|
14
|
+
* </html>
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
const doc = new TaroDocument(window)
|
|
18
|
+
const documentCreateElement = doc.createElement.bind(doc)
|
|
19
|
+
const html = documentCreateElement(HTML)
|
|
20
|
+
const head = documentCreateElement(HEAD)
|
|
21
|
+
const body = documentCreateElement(BODY)
|
|
22
|
+
const container = documentCreateElement('container') // 多包一层主要为了兼容 vue
|
|
23
|
+
const app = documentCreateElement(APP)
|
|
24
|
+
const entryAsync = documentCreateElement('entryAsync')
|
|
25
|
+
app.id = 'app'
|
|
26
|
+
entryAsync.id = 'entryAsync'
|
|
27
|
+
|
|
28
|
+
doc.appendChild(html)
|
|
29
|
+
html.appendChild(head)
|
|
30
|
+
html.appendChild(body)
|
|
31
|
+
body.appendChild(container)
|
|
32
|
+
container.appendChild(app)
|
|
33
|
+
container.appendChild(entryAsync)
|
|
34
|
+
|
|
35
|
+
doc.documentElement = html
|
|
36
|
+
doc.head = head
|
|
37
|
+
doc.body = body
|
|
38
|
+
doc.container = container
|
|
39
|
+
doc.app = app
|
|
40
|
+
doc.entryAsync = entryAsync
|
|
41
|
+
|
|
42
|
+
return doc
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
export const document = createDocument()
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { History } from '@tarojs/runtime/dist/runtime.esm'
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { Location } from '@tarojs/runtime/dist/runtime.esm'
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { navigator } from '@tarojs/runtime/dist/runtime.esm'
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { cancelAnimationFrame, now, requestAnimationFrame } from '@tarojs/runtime/dist/runtime.esm'
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import _display from '@ohos.display'
|
|
2
|
+
import ohosWindow from '@ohos.window'
|
|
3
|
+
|
|
4
|
+
import { TaroEventTarget } from '../dom/eventTarget'
|
|
5
|
+
import { History } from './history'
|
|
6
|
+
import { Location } from './location'
|
|
7
|
+
import { navigator as nav } from './navigator'
|
|
8
|
+
|
|
9
|
+
import type { TaroDocument } from '../dom/document'
|
|
10
|
+
import type { TaroElement } from '../dom/element/element'
|
|
11
|
+
|
|
12
|
+
export class Window extends TaroEventTarget {
|
|
13
|
+
public _doc: TaroDocument
|
|
14
|
+
public __taroAppConfig: any
|
|
15
|
+
public __ohos = ohosWindow
|
|
16
|
+
public __oh_display: typeof _display
|
|
17
|
+
|
|
18
|
+
public location: any
|
|
19
|
+
public history: any
|
|
20
|
+
public navigator = nav
|
|
21
|
+
|
|
22
|
+
constructor () {
|
|
23
|
+
super()
|
|
24
|
+
|
|
25
|
+
this.location = new Location({ window: this })
|
|
26
|
+
this.history = new History(this.location, { window: this })
|
|
27
|
+
this.__oh_display = _display.getDefaultDisplaySync()
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
get document (): TaroDocument {
|
|
31
|
+
return this._doc
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
get devicePixelRatio () {
|
|
35
|
+
return this.__oh_display.densityPixels
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
get getComputedStyle () {
|
|
39
|
+
return this.document.getComputedStyle
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
setTimeout (...args: Parameters<typeof setTimeout>) {
|
|
43
|
+
setTimeout(...args)
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
clearTimeout (...args: Parameters<typeof clearTimeout>) {
|
|
47
|
+
clearTimeout(...args)
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
export const getComputedStyle = (element: TaroElement) => {
|
|
52
|
+
return element.getComputedStyle()
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
export const window = new Window()
|
|
56
|
+
export const location = window.location
|
|
57
|
+
export const history = window.history
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
export {
|
|
2
|
+
A, APP, BEHAVIORS, BODY,
|
|
3
|
+
CATCH_VIEW, CATCHMOVE, CHANGE,
|
|
4
|
+
CLASS, COMMENT, COMPILE_MODE,
|
|
5
|
+
CONFIRM, CONTAINER, CONTEXT_ACTIONS,
|
|
6
|
+
CURRENT_TARGET, CUSTOM_WRAPPER,
|
|
7
|
+
DATASET, DATE, DOCUMENT_ELEMENT_NAME,
|
|
8
|
+
DOCUMENT_FRAGMENT, EVENT_CALLBACK_RESULT,
|
|
9
|
+
EXTERNAL_CLASSES, FOCUS, HEAD,
|
|
10
|
+
HOOKS_APP_ID, HTML, ID, INPUT,
|
|
11
|
+
KEY_CODE, OBJECT, ON_HIDE, ON_LOAD,
|
|
12
|
+
ON_READY, ON_SHOW, OPTIONS, PAGE_INIT,
|
|
13
|
+
PROPERTY_THRESHOLD, PROPS, PURE_VIEW, ROOT_STR,
|
|
14
|
+
SET_DATA, SET_TIMEOUT, STATIC_VIEW, STYLE,
|
|
15
|
+
TARGET, TARO_RUNTIME, TIME_STAMP,
|
|
16
|
+
TOUCHMOVE, TYPE, UID, VALUE, VIEW
|
|
17
|
+
} from '@tarojs/runtime/dist/runtime.esm'
|
|
18
|
+
|
|
19
|
+
export const ATTRIBUTES_CALLBACK_TRIGGER_MAP = {
|
|
20
|
+
focus: {
|
|
21
|
+
triggerName: 'focus',
|
|
22
|
+
},
|
|
23
|
+
animation: {
|
|
24
|
+
triggerName: 'animation',
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
// 折叠屏分割临界宽度, 大于1500视为折叠屏
|
|
29
|
+
export const FOLD_SPLIT_MAX_WIDTH = 600
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { TaroNativeModule } from './harmony-library'
|
|
2
|
+
|
|
3
|
+
export const context: any = {
|
|
4
|
+
resolver: null,
|
|
5
|
+
value: null
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
export const uiContext: any = {
|
|
9
|
+
resolver: null,
|
|
10
|
+
value: null
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export const Current: any = {
|
|
14
|
+
app: null,
|
|
15
|
+
entryAsync: null,
|
|
16
|
+
isDebug: false,
|
|
17
|
+
get uiContext () {
|
|
18
|
+
return uiContext.value
|
|
19
|
+
},
|
|
20
|
+
set uiContext (e) {
|
|
21
|
+
uiContext.resolver(e)
|
|
22
|
+
},
|
|
23
|
+
router: {},
|
|
24
|
+
taro: {},
|
|
25
|
+
contextPromise: new Promise(resolve => {
|
|
26
|
+
context.resolver = resolve
|
|
27
|
+
|
|
28
|
+
return resolve
|
|
29
|
+
}).then(e => {
|
|
30
|
+
context.value = e
|
|
31
|
+
|
|
32
|
+
return e
|
|
33
|
+
}),
|
|
34
|
+
uiContextPromise: new Promise(resolve => {
|
|
35
|
+
uiContext.resolver = resolve
|
|
36
|
+
|
|
37
|
+
return resolve
|
|
38
|
+
}).then((e) => {
|
|
39
|
+
uiContext.value = e
|
|
40
|
+
|
|
41
|
+
return e
|
|
42
|
+
}),
|
|
43
|
+
nativeModule: TaroNativeModule,
|
|
44
|
+
createHarmonyElement: null,
|
|
45
|
+
audioSessionManager: null
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
export const getCurrentInstance = () => Current
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { TaroNativeModule } from '../harmony-library'
|
|
2
|
+
|
|
3
|
+
export class ClassList {
|
|
4
|
+
private el: any
|
|
5
|
+
|
|
6
|
+
constructor (el: any) {
|
|
7
|
+
this.el = el
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
public get value () {
|
|
11
|
+
return this.toString()
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
public get length () {
|
|
15
|
+
return TaroNativeModule.executeNodeFunc(this.el, 'classList.length', [])
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
add (...tokens: string[]) {
|
|
19
|
+
return TaroNativeModule.executeNodeFunc(this.el, 'classList.add', tokens)
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
remove (...tokens: string[]) {
|
|
23
|
+
return TaroNativeModule.executeNodeFunc(this.el, 'classList.remove', tokens)
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
contains (token: string) {
|
|
27
|
+
return TaroNativeModule.executeNodeFunc(this.el, 'classList.contains', token)
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
toggle (token: string, force: boolean) {
|
|
31
|
+
return TaroNativeModule.executeNodeFunc(this.el, 'classList.toggle', [token, force])
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
replace (token: string, replacement_token: string) {
|
|
35
|
+
return TaroNativeModule.executeNodeFunc(this.el, 'classList.replace', [token, replacement_token])
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
toString () {
|
|
39
|
+
return TaroNativeModule.executeNodeFunc(this.el, 'classList.toString', [])
|
|
40
|
+
}
|
|
41
|
+
}
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import { TaroNode } from './node'
|
|
2
|
+
|
|
3
|
+
/** FIXME 后续删除 */
|
|
4
|
+
export class TaroDataSourceElement extends TaroNode implements IDataSource {
|
|
5
|
+
protected listeners: DataChangeListener[] = []
|
|
6
|
+
|
|
7
|
+
// 以下属性为半编译模式下才会赋值和使用的属性
|
|
8
|
+
// 半编译节点更新触发器
|
|
9
|
+
public _updateTrigger = 0
|
|
10
|
+
// 是否为半编译模板下的节点
|
|
11
|
+
public _isCompileMode = false
|
|
12
|
+
// 是否为半编译模板下拥有自主更新权的节点
|
|
13
|
+
public _isDynamicNode = false
|
|
14
|
+
|
|
15
|
+
public findIndex (refChild?: TaroNode): number {
|
|
16
|
+
return this.childNodes.findIndex(node => node._nid === refChild?._nid)
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
totalCount(): number {
|
|
20
|
+
return this.childNodes?.length || 0
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
// 更新对应的 ArkUI 组件
|
|
24
|
+
public updateComponent () {
|
|
25
|
+
// 非半编译模式或者半编译模式下拥有自主更新权力的节点走 @State 的更新模式
|
|
26
|
+
if (this._isDynamicNode || (!this._isCompileMode && this._instance)) {
|
|
27
|
+
this._updateTrigger++
|
|
28
|
+
} else {
|
|
29
|
+
(this.parentNode as TaroDataSourceElement)?.updateComponent?.()
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
getData(index: number) {
|
|
34
|
+
return this.childNodes[index] as TaroNode
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
// 该方法为框架侧调用,为 LazyForEach 组件向其数据源处添加 listener 监听
|
|
38
|
+
registerDataChangeListener(listener: DataChangeListener): void {
|
|
39
|
+
if (this.listeners.indexOf(listener) < 0) {
|
|
40
|
+
this.listeners.push(listener)
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
// 该方法为框架侧调用,为对应的 LazyForEach 组件在数据源处去除 listener 监听
|
|
45
|
+
unregisterDataChangeListener(listener: DataChangeListener): void {
|
|
46
|
+
const pos = this.listeners.indexOf(listener)
|
|
47
|
+
|
|
48
|
+
if (pos >= 0) {
|
|
49
|
+
this.listeners.splice(pos, 1)
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
// 通知 LazyForEach 组件需要重载所有子组件
|
|
54
|
+
notifyDataReload(): void {
|
|
55
|
+
this.listeners.forEach(listener => {
|
|
56
|
+
listener.onDataReloaded()
|
|
57
|
+
})
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
// 通知 LazyForEach 组件需要将 from 对应索引处的子组件移动到 to 索引处
|
|
61
|
+
notifyDataMove(from: number, to: number): void {
|
|
62
|
+
this.listeners.forEach(listener => {
|
|
63
|
+
listener.onDataMove(from, to)
|
|
64
|
+
})
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
// 通知 LazyForEach 组件需要在 index 对应索引处添加子组件
|
|
68
|
+
notifyDataAdd(index: number): void {
|
|
69
|
+
this.listeners.forEach(listener => {
|
|
70
|
+
listener.onDataAdd(index)
|
|
71
|
+
})
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
// 通知 LazyForEach 组件在 index 对应索引处数据有变化,需要重建该子组件
|
|
75
|
+
notifyDataChange(index: number): void {
|
|
76
|
+
this.listeners.forEach(listener => {
|
|
77
|
+
listener.onDataChange(index)
|
|
78
|
+
})
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
// 通知 LazyForEach 组件需要在 index 对应索引处删除该子组件
|
|
82
|
+
notifyDataDelete(index: number): void {
|
|
83
|
+
this.listeners.forEach(listener => {
|
|
84
|
+
listener.onDataDelete(index)
|
|
85
|
+
})
|
|
86
|
+
}
|
|
87
|
+
}
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
import { Current } from '../current'
|
|
2
|
+
import { TaroNativeModule } from '../harmony-library'
|
|
3
|
+
import { getPageScrollerOrNode } from '../utils'
|
|
4
|
+
import { TaroComment } from './comment'
|
|
5
|
+
import { TaroElement } from './element/element'
|
|
6
|
+
import { NodeType, TaroNode, TaroTextNode } from './node'
|
|
7
|
+
|
|
8
|
+
import type { Window } from '../bom/window'
|
|
9
|
+
|
|
10
|
+
class TaroDocument extends TaroNode {
|
|
11
|
+
public documentElement: TaroElement
|
|
12
|
+
public head: TaroElement
|
|
13
|
+
public body: TaroElement
|
|
14
|
+
public container: TaroElement
|
|
15
|
+
public app: TaroElement
|
|
16
|
+
public entryAsync: TaroElement
|
|
17
|
+
public cookie = ''
|
|
18
|
+
private _win: Window
|
|
19
|
+
|
|
20
|
+
constructor(window: Window) {
|
|
21
|
+
super('#document', NodeType.DOCUMENT_NODE)
|
|
22
|
+
this._win = window
|
|
23
|
+
window._doc = this
|
|
24
|
+
TaroNativeModule.createTaroNode(this)
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
get defaultView (): Window {
|
|
28
|
+
return this._win
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
get currentPageNode (): TaroElement {
|
|
32
|
+
const taro = Current.taro
|
|
33
|
+
const page = taro.getCurrentInstance().page
|
|
34
|
+
return getPageScrollerOrNode(page?.node, page)
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
public createElement (tagName: string): TaroElement {
|
|
38
|
+
let node: TaroElement
|
|
39
|
+
// TODO: 仍需补充更多节点解析和它默认样式行为的转换,比如h1\h2
|
|
40
|
+
switch (tagName) {
|
|
41
|
+
case 'root': tagName = 'view'; break
|
|
42
|
+
case 'img': tagName = 'image'; break
|
|
43
|
+
case 'div': tagName = 'view'; break
|
|
44
|
+
case 'p': tagName = 'text'; break
|
|
45
|
+
case 'span': tagName = 'text'; break
|
|
46
|
+
case 'a': tagName = 'text'; break
|
|
47
|
+
}
|
|
48
|
+
if (Current?.createHarmonyElement) {
|
|
49
|
+
node = Current.createHarmonyElement(tagName)
|
|
50
|
+
} else {
|
|
51
|
+
node = new TaroElement(tagName)
|
|
52
|
+
}
|
|
53
|
+
node._doc = this
|
|
54
|
+
return node
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
public createTextNode (value: string): TaroTextNode | void {
|
|
58
|
+
if (!Current?.createTextNode) return
|
|
59
|
+
|
|
60
|
+
const node = Current.createTextNode(value)
|
|
61
|
+
node._doc = this
|
|
62
|
+
return node
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
public createComment (data: string): TaroComment {
|
|
66
|
+
return new TaroComment(data)
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
public getElementById<T extends TaroNode = TaroElement> (id?: string): T | null {
|
|
70
|
+
// FIXME 使用页面实例,将会导致组件模式注入的节点无法获取
|
|
71
|
+
console.warn('getElementById: 在 document 上查询所有元素性能较差,请谨慎使用!')
|
|
72
|
+
return super.getElementById.call(this, id)
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
public getElementsByTagName<T extends TaroNode = TaroElement>(tagName: string): T[] {
|
|
76
|
+
console.error('getElementsByTagName: 不支持在 document 上查询所有元素,自动降级到当前页面内查询!')
|
|
77
|
+
if (!this.currentPageNode) {
|
|
78
|
+
console.error('getElementsByTagName: 当前页面不存在!')
|
|
79
|
+
return []
|
|
80
|
+
}
|
|
81
|
+
return super.getElementsByTagName.call(this.currentPageNode, tagName)
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
public getElementsByClassName<T extends TaroNode = TaroElement>(className: string): T[] {
|
|
85
|
+
console.error('getElementsByClassName: 不支持在 document 上查询所有元素,自动降级到当前页面内查询!')
|
|
86
|
+
if (!this.currentPageNode) {
|
|
87
|
+
console.error('getElementsByClassName: 当前页面不存在!')
|
|
88
|
+
return []
|
|
89
|
+
}
|
|
90
|
+
return super.getElementsByClassName.call(this.currentPageNode, className)
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
public querySelector (selectors: string): TaroElement | null {
|
|
94
|
+
console.warn('querySelector: 在 document 上查询所有元素性能较差,请谨慎使用!')
|
|
95
|
+
return super.querySelector.call(this, selectors)
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
public querySelectorAll (selectors: string): TaroElement[] {
|
|
99
|
+
console.error('querySelectorAll: 不支持在 document 上查询所有元素,自动降级到当前页面内查询!')
|
|
100
|
+
if (!this.currentPageNode) {
|
|
101
|
+
console.error('querySelectorAll: 当前页面不存在!')
|
|
102
|
+
return []
|
|
103
|
+
}
|
|
104
|
+
return super.querySelectorAll.call(this.currentPageNode, selectors)
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
// TODO public createElementNS
|
|
108
|
+
public getComputedStyle (): any {
|
|
109
|
+
return super.getComputedStyle.call(this)
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
export { TaroDocument }
|