diff --git a/shell/platform/ohos/flutter_embedding/flutter/oh-package-lock.json5 b/shell/platform/ohos/flutter_embedding/flutter/oh-package-lock.json5 new file mode 100644 index 0000000000000000000000000000000000000000..2055b7a254233e7730feb37234e91b752e751b92 --- /dev/null +++ b/shell/platform/ohos/flutter_embedding/flutter/oh-package-lock.json5 @@ -0,0 +1,28 @@ +/* +* Copyright (c) 2023 Hunan OpenValley Digital Industry Development Co., Ltd. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +{ + "lockfileVersion": 3, + "ATTENTION": "THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.", + "specifiers": { + "@types/libflutter.so@src/main/cpp/types/libflutter": "@types/libflutter.so@src/main/cpp/types/libflutter" + }, + "packages": { + "@types/libflutter.so@src/main/cpp/types/libflutter": { + "mtime": "1708499704157.7893", + "resolved": "src/main/cpp/types/libflutter" + } + } +} \ No newline at end of file diff --git a/shell/platform/ohos/flutter_embedding/flutter/oh_modules/@types/libflutter.so/index.d.ets b/shell/platform/ohos/flutter_embedding/flutter/oh_modules/@types/libflutter.so/index.d.ets new file mode 100644 index 0000000000000000000000000000000000000000..c53957c7aaee4402afa25585c981d83830351ce5 --- /dev/null +++ b/shell/platform/ohos/flutter_embedding/flutter/oh_modules/@types/libflutter.so/index.d.ets @@ -0,0 +1,102 @@ +/* +* Copyright (c) 2023 Hunan OpenValley Digital Industry Development Co., Ltd. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +import common from '@ohos.app.ability.common'; +import resourceManager from '@ohos.resourceManager'; +import image from '@ohos.multimedia.image'; +import FlutterNapi from '../../../ets/embedding/engine/FlutterNapi'; + +export const getContext: (a: number) => napiContext; + +export class napiContext { + onPageShow(): void; + + onPageHide(): void; +} + +/** + * 设置刷新率 + */ +export const nativeUpdateRefreshRate: ( + ate: number +) => void; + +/** + * 初始化dart vm和flutter engine + */ +export const nativeInit: ( + context: common.Context, + args: Array, + bundlePath: string, + appStoragePath: string, + engineCachesPath: string, + initTimeMillis: number +) => void; + +export const nativeAttach: (napi: FlutterNapi) => number; + +export const nativeSpawn: ( + nativeSpawningShellId: number | null, + entrypointFunctionName: string, + pathToEntrypointFunction: string, + initialRoute: string, + entrypointArgs: Array, + napi: FlutterNapi +) => number; + +export const nativeRunBundleAndSnapshotFromLibrary: ( + nativeShellHolderId: number, + bundlePath: string, + entrypointFunctionName: string, + pathToEntrypointFunction: string, + assetManager: resourceManager.ResourceManager, + entrypointArgs: Array +) => void; + +//Send a data-carrying response to a platform message received from Dart. +export const nativeInvokePlatformMessageResponseCallback: (nativeShellHolderId: number, responseId: number, message: ArrayBuffer, position: number) => void; + +// Send an empty response to a platform message received from Dart. +export const nativeInvokePlatformMessageEmptyResponseCallback: (nativeShellHolderId: number, responseId: number) => void; + +// Send a data-carrying platform message to Dart. +export const nativeDispatchPlatformMessage: (nativeShellHolderId: number, channel: String, message: ArrayBuffer, position: number, responseId: number) => void; + +// Send an empty platform message to Dart. +export const nativeDispatchEmptyPlatformMessage: (nativeShellHolderId: number, channel: String, responseId: number) => void; + +export const nativeSetViewportMetrics: (nativeShellHolderId: number, devicePixelRatio: number, physicalWidth: number + , physicalHeight: number, physicalPaddingTop: number, physicalPaddingRight: number + , physicalPaddingBottom: number, physicalPaddingLeft: number, physicalViewInsetTop: number + , physicalViewInsetRight: number, physicalViewInsetBottom: number, physicalViewInsetLeft: number + , systemGestureInsetTop: number, systemGestureInsetRight: number, systemGestureInsetBottom: number + , systemGestureInsetLeft: number, physicalTouchSlop: number, displayFeaturesBounds: Array + , displayFeaturesType: Array, displayFeaturesState: Array) => void; + +export const nativeImageDecodeCallback: (width: number, height: number, imageGeneratorPointer: number, pixelMap : image.PixelMap | null) => void; + +export const nativeGetSystemLanguages: (nativeShellHolderId: number, languages: Array) => void; + +export const nativeXComponentAttachFlutterEngine: (xcomponentId: number, nativeShellHolderId: number) => void; + +export const nativeXComponentDetachFlutterEngine: (xcomponentId: number, nativeShellHolderId: number) => void; + +/** + * Detaches flutterNapi和engine之间的关联 + * 这个方法执行前提是flutterNapi已经和engine关联 + */ +export const nativeDestroy: ( + nativeShellHolderId: number +) => void; \ No newline at end of file diff --git a/shell/platform/ohos/flutter_embedding/flutter/oh_modules/@types/libflutter.so/index_actual.d.ets b/shell/platform/ohos/flutter_embedding/flutter/oh_modules/@types/libflutter.so/index_actual.d.ets new file mode 100644 index 0000000000000000000000000000000000000000..d3f5c0a65d28cebdd24c8c79f062c64e0d490e65 --- /dev/null +++ b/shell/platform/ohos/flutter_embedding/flutter/oh_modules/@types/libflutter.so/index_actual.d.ets @@ -0,0 +1,268 @@ +/* +* Copyright (c) 2023 Hunan OpenValley Digital Industry Development Co., Ltd. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +import common from '@ohos.app.ability.common'; +import resourceManager from '@ohos.resourceManager'; +import FlutterNapi from '../../../ets/embedding/engine/FlutterNapi'; +import image from '@ohos.multimedia.image'; + +/** + * 设置刷新率 + */ +export const nativeUpdateRefreshRate: ( + ate: number +) => void; + +/** + * 初始化dart vm和flutter engine + */ +export const nativeInit: ( + context: common.Context, + args: Array, + bundlePath: string, + appStoragePath: string, + engineCachesPath: string, + initTimeMillis: number +) => void; + + +/** + * 加载dart工程构建产物 + */ +export const nativeRunBundleAndSnapshotFromLibrary: ( + bundlePath: string, + entrypointFunctionName: string, + pathToEntrypointFunction: string, + assetManager: resourceManager.ResourceManager, + entrypointArgs: Array +) => void; + +/** + * 初始化SkFontMgr::RefDefault(),skia引擎文字管理初始化 + */ +export const nativePrefetchDefaultFontManager: () => void; + +/** + * 返回是否支持软件绘制 + */ +export const nativeGetIsSoftwareRenderingEnabled: () => boolean; + +/** + * attach flutterNapi实例给到 native engine,这个支持rkts到flutter平台的无关引擎之间的通信。 + * attach只需要执行一次 + */ +export const nativeAttach: (flutterNapi: FlutterNapi) => number; + +/** + * 从当前的flutterNapi复制一个新的实例 + */ +export const nativeSpawn: ( + nativeSpawningShellId: number, + entrypointFunctionName: string, + pathToEntrypointFunction: string, + initialRoute: string, + entrypointArgs: Array, + napi: FlutterNapi +) => number; + +/** + * Detaches flutterNapi和engine之间的关联 + * 这个方法执行前提是flutterNapi已经和engine关联 + */ +export const nativeDestroy: ( + nativeShellHolderId: number +) => void; + +// 不需要实现,未使用到 +// export const nativeImageHeaderCallback: ( +// imageGeneratorPointer: number, +// width: number, +// height: number +// ) => void; + +/** + * 不需要实现,c++层已有nativeSurface回调 + */ +// export const nativeSurfaceCreated: ( +// nativeShellHolderId: number +// ) => void; + + +/** + * 不需要实现,c++层已有nativeSurface回调 + */ +// export const nativeSurfaceWindowChanged: ( +// nativeShellHolderId: number +// ) => void; + + +/** + * 不需要实现,c++层已有nativeSurface回调 + */ +// export const nativeSurfaceChanged: ( +// nativeShellHolderId: number, +// width: number, +// height: number +// ) => void; + +/** + * 不需要实现,c++层已有nativeSurface回调 + */ +// export const nativeSurfaceDestroyed: ( +// nativeShellHolderId: number +// ) => void; + +/** + * 把物理屏幕参数通知到native + */ +export const nativeSetViewportMetrics: ( + nativeShellHolderId: number, + devicePixelRatio: number, + physicalWidth: number, + physicalHeight: number, + physicalPaddingTop: number, + physicalPaddingRight: number, + physicalPaddingBottom: number, + physicalPaddingLeft: number, + physicalViewInsetTop: number, + physicalViewInsetRight: number, + physicalViewInsetBottom: number, + physicalViewInsetLeft: number, + systemGestureInsetTop: number, + systemGestureInsetRight: number, + systemGestureInsetBottom: number, + systemGestureInsetLeft: number, + physicalTouchSlop: number, + displayFeaturesBounds: Array, + displayFeaturesType: Array, + displayFeaturesState: Array +) => void; + +/** + * 设置能力参数 + */ +export const nativeSetAccessibilityFeatures: ( + nativeShellHolderId: number, + flags: number +) => void; + +/** + * 清除某个messageData + */ +export const nativeCleanupMessageData: ( + messageData: number +) => void; + +/** + * 发送一个空的PlatformMessage + */ +export const nativeDispatchEmptyPlatformMessage: ( + nativeShellHolderId: number, + channel: string, + responseId: number +) => void; + +/** + * 发送一个PlatformMessage + */ +export const nativeDispatchPlatformMessage: ( + nativeShellHolderId: number, + channel: string, + message: ArrayBuffer, + position: number, + responseId: number +) => void; + +/** + * 空的PlatformMessage响应回调 + */ +export const nativeInvokePlatformMessageEmptyResponseCallback: ( + nativeShellHolderId: number, + responseId: number +) => void; + +/** + * PlatformMessage响应回调 + */ +export const nativeInvokePlatformMessageResponseCallback: ( + nativeShellHolderId: number, + responseId: number, + message: ArrayBuffer, + position: number +) => void; + + +/** + * load一个合法的.so文件到dart vm + */ +export const nativeLoadDartDeferredLibrary: ( + nativeShellHolderId: number, + loadingUnitId: number, + searchPaths: Array +) => void; + +/** + * 设置ResourceManager和assetBundlePath到engine + */ +export const nativeUpdateOhosAssetManager: ( + nativeShellHolderId: number, + resourceManager: resourceManager.ResourceManager, + assetBundlePath: string +) => void; + +/** + * 加载动态库,或者dart库失败时的通知 + */ +export const nativeDeferredComponentInstallFailure: ( + loadingUnitId: number, + error: string, + isTransient: boolean +) => void; + +/** + * 从engine获取当前绘制pixelMap + */ +export const nativeGetPixelMap: () => image.PixelMap; + +/** + * 应用低内存警告 + */ +export const nativeNotifyLowMemoryWarning: ( + nativeShellHolderId: number +) => void; + +// ----- Start FlutterTextUtils Methods ---- +/** + * 下面的方法,从键盘输入中判断当前字符是否是emoji,实现优先级低 + */ +export const nativeFlutterTextUtilsIsEmoji: ( + codePoint: number +) => boolean; + +export const nativeFlutterTextUtilsIsEmojiModifier: ( + codePoint: number +) => boolean; + +export const nativeFlutterTextUtilsIsEmojiModifierBase: ( + codePoint: number +) => boolean; + +export const nativeFlutterTextUtilsIsVariationSelector: ( + codePoint: number +) => boolean; + +export const nativeFlutterTextUtilsIsRegionalIndicator: ( + codePoint: number +) => boolean; \ No newline at end of file diff --git a/shell/platform/ohos/flutter_embedding/flutter/oh_modules/@types/libflutter.so/oh-package.json5 b/shell/platform/ohos/flutter_embedding/flutter/oh_modules/@types/libflutter.so/oh-package.json5 new file mode 100644 index 0000000000000000000000000000000000000000..5d1822ef86535e3d92242c5cb99af8dd46b2204f --- /dev/null +++ b/shell/platform/ohos/flutter_embedding/flutter/oh_modules/@types/libflutter.so/oh-package.json5 @@ -0,0 +1,21 @@ +/* +* Copyright (c) 2023 Hunan OpenValley Digital Industry Development Co., Ltd. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +{ + "name": "libflutter.so", + "types": "./index.d.ets", + "version": "", + "description": "Please describe the basic information." +} \ No newline at end of file diff --git a/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/embedding/ohos/FlutterPage.ets b/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/embedding/ohos/FlutterPage.ets index 53e7ef62d1d0724238bbdf4e2cfe58bf1de4eb64..e29e877c56c919d1c3249469efb1b3fb1c3bf0fd 100644 --- a/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/embedding/ohos/FlutterPage.ets +++ b/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/embedding/ohos/FlutterPage.ets @@ -35,13 +35,13 @@ const TAG = "FlutterPage"; */ @Component export struct FlutterPage { - @State rootDvModel: DVModel | undefined = undefined + @State rootDvModel: DVModelChildren | undefined = undefined @Prop viewId: string = "" private flutterView?: FlutterView | null aboutToAppear() { this.flutterView = FlutterManager.getInstance().getFlutterView(this.viewId); - this.rootDvModel = this.flutterView!!.getDVModel() + this.rootDvModel = this.flutterView!!.getDVModel().children } build() { @@ -56,13 +56,14 @@ export struct FlutterPage { Log.d(TAG, "XComponent onDestroy "); this.flutterView?.onSurfaceDestroyed() }) - DynamicView({ - model: this.rootDvModel, - params: this.rootDvModel!!.params as DVModelParameters, - events: this.rootDvModel!!.events as DVModelEvents, - children: this.rootDvModel!!.children as DVModelChildren, - customBuilder: this.rootDvModel!!.builder as ($$: Record<"params", DVModelParameters>) => void - //customBuilder: this.rootDvModel.model.builder as ($$: { params: DVModelParameters }) => void + ForEach(this.rootDvModel!!, (child:ESObject) =>{ + DynamicView({ + model: child as DVModel, + params:child.params, + events:child.events, + children:child.children, + customBuilder:child.builder + }) }) } .onAreaChange((oldValue: Area, newValue: Area) => { diff --git a/shell/platform/ohos/flutter_embedding/local.properties b/shell/platform/ohos/flutter_embedding/local.properties index 42b3cf913edcd8d66de22dd116909893a09e7550..a53b31e5015b546f59385da20ae9e361ce7f2828 100755 --- a/shell/platform/ohos/flutter_embedding/local.properties +++ b/shell/platform/ohos/flutter_embedding/local.properties @@ -1,23 +1,22 @@ -# Copyright (c) 2023 Hunan OpenValley Digital Industry Development Co., Ltd. -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -# This file is automatically generated by DevEco Studio. -# Do not modify this file -- YOUR CHANGES WILL BE ERASED! -# -# This file should *NOT* be checked into Version Control Systems, -# as it contains information specific to your local configuration. -# -# For customization when using a Version Control System, please read the header note. -sdk.dir= -nodejs.dir= - +# Copyright (c) 2023 Hunan OpenValley Digital Industry Development Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# This file is automatically generated by DevEco Studio. +# Do not modify this file -- YOUR CHANGES WILL BE ERASED! +# +# This file should *NOT* be checked into Version Control Systems, +# as it contains information specific to your local configuration. +# +# For customization when using a Version Control System, please read the header note. +sdk.dir= +nodejs.dir= \ No newline at end of file diff --git a/shell/platform/ohos/flutter_embedding/oh-package-lock.json5 b/shell/platform/ohos/flutter_embedding/oh-package-lock.json5 index 1171a787ccbe8a160fae3b16422800af1563e12d..634d9d31ebc130ba3180b45b9b3122d172888c57 100755 --- a/shell/platform/ohos/flutter_embedding/oh-package-lock.json5 +++ b/shell/platform/ohos/flutter_embedding/oh-package-lock.json5 @@ -12,17 +12,19 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + { - "lockfileVersion": 1, + "lockfileVersion": 3, "ATTENTION": "THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.", "specifiers": { - "@ohos/hypium@1.0.6": "@ohos/hypium@1.0.6", - "@ohos/hypium@^1.0.6": "@ohos/hypium@1.0.6" + "@ohos/hypium@1.0.6": "@ohos/hypium@1.0.6" }, "packages": { "@ohos/hypium@1.0.6": { + "integrity": "sha512-bb3DWeWhYrFqj9mPFV3yZQpkm36kbcK+YYaeY9g292QKSjOdmhEIQR2ULPvyMsgSR4usOBf5nnYrDmaCCXirgQ==", "resolved": "https://repo.harmonyos.com/ohpm/@ohos/hypium/-/hypium-1.0.6.tgz", - "integrity": "sha512-bb3DWeWhYrFqj9mPFV3yZQpkm36kbcK+YYaeY9g292QKSjOdmhEIQR2ULPvyMsgSR4usOBf5nnYrDmaCCXirgQ==" + "shasum": "3f5fed65372633233264b3447705b0831dfe7ea1", + "registryType": "ohpm" } } } \ No newline at end of file