mirror of
https://github.com/Gongxh0901/kunpolibrary
synced 2025-10-30 10:55:40 +00:00
仓库中添加内置的demo
This commit is contained in:
12
demo/native/engine/harmonyos-next/.gitignore
vendored
Normal file
12
demo/native/engine/harmonyos-next/.gitignore
vendored
Normal file
@@ -0,0 +1,12 @@
|
||||
/node_modules
|
||||
/local.properties
|
||||
/oh_modules
|
||||
/.idea
|
||||
**/build
|
||||
/.hvigor
|
||||
log.txt
|
||||
oh-package-lock.json5
|
||||
.clang-format
|
||||
.clang-tidy
|
||||
.clangd
|
||||
/entry/oh_modules
|
||||
11
demo/native/engine/harmonyos-next/AppScope/app.json5
Normal file
11
demo/native/engine/harmonyos-next/AppScope/app.json5
Normal file
@@ -0,0 +1,11 @@
|
||||
{
|
||||
"app": {
|
||||
"bundleName": "com.kunpo.test",
|
||||
"vendor": "example",
|
||||
"versionCode": 1,
|
||||
"versionName": "0.0.1",
|
||||
"icon": "$media:app_icon",
|
||||
"label": "$string:app_name",
|
||||
"distributedNotificationEnabled": true
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
{
|
||||
"string": [
|
||||
{
|
||||
"name": "app_name",
|
||||
"value": "kunpocreator"
|
||||
}
|
||||
]
|
||||
}
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 9.7 KiB |
19
demo/native/engine/harmonyos-next/CMakeLists.txt
Normal file
19
demo/native/engine/harmonyos-next/CMakeLists.txt
Normal file
@@ -0,0 +1,19 @@
|
||||
# the minimum version of CMake.
|
||||
|
||||
cmake_minimum_required(VERSION 3.8)
|
||||
set(CC_LIB_NAME cocos)
|
||||
set(CC_PROJ_SOURCES)
|
||||
set(CC_COMMON_SOURCES)
|
||||
set(CC_ALL_SOURCES)
|
||||
|
||||
option(APP_NAME "Project Name" "test-cases")
|
||||
project(${APP_NAME} CXX)
|
||||
|
||||
set(CMAKE_CXX_FLAGS_DEBUG "$ENV{CXXFLAGS} -O0 -Wall -g -ggdb -Werror=return-type")
|
||||
set(CMAKE_CXX_FLAGS_RELEASE "$ENV{CXXFLAGS} -O3 -Wall")
|
||||
|
||||
include(${COMMON_DIR}/CMakeLists.txt)
|
||||
|
||||
cc_openharmony_before_target(${CC_LIB_NAME})
|
||||
add_library(${CC_LIB_NAME} SHARED ${CC_ALL_SOURCES})
|
||||
cc_openharmony_after_target(${CC_LIB_NAME})
|
||||
36
demo/native/engine/harmonyos-next/build-profile.json5
Normal file
36
demo/native/engine/harmonyos-next/build-profile.json5
Normal file
@@ -0,0 +1,36 @@
|
||||
{
|
||||
"app": {
|
||||
"signingConfigs": [
|
||||
],
|
||||
"products": [
|
||||
{
|
||||
"name": "default",
|
||||
"signingConfig": "default",
|
||||
"compatibleSdkVersion": "5.0.1(13)",
|
||||
"runtimeOS": "HarmonyOS"
|
||||
}
|
||||
],
|
||||
"buildModeSet": [
|
||||
{
|
||||
"name": "debug"
|
||||
},
|
||||
{
|
||||
"name": "release"
|
||||
}
|
||||
]
|
||||
},
|
||||
"modules": [
|
||||
{
|
||||
"name": "entry",
|
||||
"srcPath": "./entry",
|
||||
"targets": [
|
||||
{
|
||||
"name": "default",
|
||||
"applyToProducts": [
|
||||
"default"
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
4
demo/native/engine/harmonyos-next/entry/.gitignore
vendored
Normal file
4
demo/native/engine/harmonyos-next/entry/.gitignore
vendored
Normal file
@@ -0,0 +1,4 @@
|
||||
/oh_modules
|
||||
/.preview
|
||||
/build
|
||||
/.cxx
|
||||
18
demo/native/engine/harmonyos-next/entry/build-profile.json5
Normal file
18
demo/native/engine/harmonyos-next/entry/build-profile.json5
Normal file
@@ -0,0 +1,18 @@
|
||||
{
|
||||
apiType: 'stageMode',
|
||||
buildOption: {
|
||||
externalNativeOptions: {
|
||||
path: '../CMakeLists.txt',
|
||||
arguments: 'arm-linux-ohos -DOHOS_STL=c++_shared -DRES_DIR=/Users/gongxh/work/kunpo-lib/KunpoDemo/build/harmonyos-next -DCOMMON_DIR=/Users/gongxh/work/kunpo-lib/KunpoDemo/native/engine/common -DOPENHARMONY=1',
|
||||
abiFilters: [
|
||||
'arm64-v8a',
|
||||
],
|
||||
cppFlags: '',
|
||||
},
|
||||
},
|
||||
targets: [
|
||||
{
|
||||
name: 'default',
|
||||
},
|
||||
],
|
||||
}
|
||||
2
demo/native/engine/harmonyos-next/entry/hvigorfile.ts
Normal file
2
demo/native/engine/harmonyos-next/entry/hvigorfile.ts
Normal file
@@ -0,0 +1,2 @@
|
||||
// Script for compiling build behavior. It is built in the build plug-in and cannot be modified currently.
|
||||
export { hapTasks } from '@ohos/hvigor-ohos-plugin';
|
||||
12
demo/native/engine/harmonyos-next/entry/oh-package.json5
Normal file
12
demo/native/engine/harmonyos-next/entry/oh-package.json5
Normal file
@@ -0,0 +1,12 @@
|
||||
{
|
||||
"license": "",
|
||||
"devDependencies": {},
|
||||
"author": "",
|
||||
"name": "entry",
|
||||
"description": "Please describe the basic information.",
|
||||
"main": "",
|
||||
"version": "1.0.0",
|
||||
"dependencies": {
|
||||
"libcocos.so": "file:./src/main/cpp/types/libcocos"
|
||||
}
|
||||
}
|
||||
32
demo/native/engine/harmonyos-next/entry/src/main/cpp/types/libcocos/index.d.ts
vendored
Normal file
32
demo/native/engine/harmonyos-next/entry/src/main/cpp/types/libcocos/index.d.ts
vendored
Normal file
@@ -0,0 +1,32 @@
|
||||
import { ContextType } from '../../../ets/common/Constants';
|
||||
import resourceManager from '@ohos.resourceManager';
|
||||
|
||||
export interface context {
|
||||
onPageShow: () => void;
|
||||
onPageHide: () => void;
|
||||
workerInit: () => void;
|
||||
postMessage: (msgType: string, msgData: string) => void;
|
||||
postSyncMessage: (msgType: string, msgData: string) => Promise<boolean | string | number>;
|
||||
setPostMessageFunction: (postMessage: (msgType: string, msgData: string) => void) => void;
|
||||
setPostSyncMessageFunction: (postSyncMessage: (msgType: string, msgData: string) => void) => void;
|
||||
nativeEngineInit: () => void;
|
||||
nativeEngineStart: () => void;
|
||||
onTextChange: (param: string) => void;
|
||||
onComplete: (param: string) => void;
|
||||
onConfirm: (param: string) => void;
|
||||
shouldStartLoading: (viewTag: number, url: string) => void;
|
||||
finishLoading: (viewTag: number, url: string) => void;
|
||||
failLoading: (viewTag: number, url: string) => void;
|
||||
onBackPress: () => void;
|
||||
onCreate: () => void;
|
||||
onDestroy: () => void;
|
||||
onShow: () => void;
|
||||
onHide: () => void;
|
||||
resourceManagerInit: (resourceManager: resourceManager.ResourceManager) => void;
|
||||
writablePathInit: (cacheDir: string) => void;
|
||||
onVideoEvent: (param: string) => void;
|
||||
registerFunction: (name:string ,fun:Function) => void;
|
||||
}
|
||||
|
||||
export const getContext: (type: ContextType) => context;
|
||||
export const evalString: (value: string) => any;
|
||||
@@ -0,0 +1,6 @@
|
||||
{
|
||||
"name": "libcocos.so",
|
||||
"types": "./index.d.ts",
|
||||
"version": "1.0.0",
|
||||
"description": "Please describe the basic information."
|
||||
}
|
||||
@@ -0,0 +1,57 @@
|
||||
/****************************************************************************
|
||||
Copyright (c) 2022-2023 Xiamen Yaji Software Co., Ltd.
|
||||
|
||||
http://www.cocos.com
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated engine source code (the "Software"), a limited,
|
||||
worldwide, royalty-free, non-assignable, revocable and non-exclusive license
|
||||
to use Cocos Creator solely to develop games on your target platforms. You shall
|
||||
not use Cocos Creator software for developing other software or tools that's
|
||||
used for developing games. You are not granted to publish, distribute,
|
||||
sublicense, and/or sell copies of Cocos Creator.
|
||||
|
||||
The software or tools in this License Agreement are licensed, not sold.
|
||||
Xiamen Yaji Software Co., Ltd. reserves all rights not expressly granted to you.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
****************************************************************************/
|
||||
|
||||
import worker from '@ohos.worker';
|
||||
import { Constants } from '../common/Constants'
|
||||
|
||||
export class WorkerManager {
|
||||
private cocosWorker: worker.ThreadWorker;
|
||||
|
||||
private constructor() {
|
||||
this.cocosWorker = new worker.ThreadWorker("entry/ets/workers/cocos_worker.ts", {
|
||||
type: "classic",
|
||||
name: "CocosWorker"
|
||||
});
|
||||
this.cocosWorker.onerror = (e) => {
|
||||
let msg = e.message;
|
||||
let filename = e.filename;
|
||||
let lineno = e.lineno;
|
||||
let colno = e.colno;
|
||||
console.error(`on Error ${msg} ${filename} ${lineno} ${colno}`);
|
||||
}
|
||||
}
|
||||
|
||||
public static getInstance(): WorkerManager {
|
||||
if (AppStorage.get(Constants.APP_KEY_WORKER_MANAGER) as WorkerManager == undefined) {
|
||||
AppStorage.setOrCreate(Constants.APP_KEY_WORKER_MANAGER, new WorkerManager);
|
||||
}
|
||||
return AppStorage.get(Constants.APP_KEY_WORKER_MANAGER) as WorkerManager;
|
||||
}
|
||||
|
||||
public getWorker(): worker.ThreadWorker {
|
||||
return this.cocosWorker;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,168 @@
|
||||
/****************************************************************************
|
||||
Copyright (c) 2022-2023 Xiamen Yaji Software Co., Ltd.
|
||||
|
||||
http://www.cocos.com
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated engine source code (the "Software"), a limited,
|
||||
worldwide, royalty-free, non-assignable, revocable and non-exclusive license
|
||||
to use Cocos Creator solely to develop games on your target platforms. You shall
|
||||
not use Cocos Creator software for developing other software or tools that's
|
||||
used for developing games. You are not granted to publish, distribute,
|
||||
sublicense, and/or sell copies of Cocos Creator.
|
||||
|
||||
The software or tools in this License Agreement are licensed, not sold.
|
||||
Xiamen Yaji Software Co., Ltd. reserves all rights not expressly granted to you.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
****************************************************************************/
|
||||
import display from '@ohos.display';
|
||||
import I18n from '@ohos.i18n';
|
||||
import deviceInfo from '@ohos.deviceInfo';
|
||||
import batteryInfo from '@ohos.batteryInfo';
|
||||
import connection from '@ohos.net.connection'
|
||||
import vibrator from '@ohos.vibrator';
|
||||
import process from '@ohos.process';
|
||||
import { ContextType } from "../../common/Constants"
|
||||
import cocos from "libcocos.so";
|
||||
|
||||
const displayUtils = cocos.getContext(ContextType.DISPLAY_UTILS);
|
||||
|
||||
let pro = new process.ProcessManager();
|
||||
let cutout = {
|
||||
left: 0,
|
||||
top: 0,
|
||||
width: 0,
|
||||
height: 0
|
||||
};
|
||||
|
||||
globalThis.getSystemLanguage = function () {
|
||||
return I18n.System.getSystemLanguage();
|
||||
}
|
||||
|
||||
globalThis.getOSFullName = function () {
|
||||
return deviceInfo.osFullName;
|
||||
}
|
||||
|
||||
globalThis.getDeviceModel = function () {
|
||||
return deviceInfo.productModel;
|
||||
}
|
||||
|
||||
globalThis.getBatteryLevel = function () {
|
||||
return batteryInfo.batterySOC;
|
||||
}
|
||||
|
||||
globalThis.getDPI = function () {
|
||||
var displayClass = display.getDefaultDisplaySync();
|
||||
return displayClass.densityDPI;
|
||||
}
|
||||
|
||||
globalThis.getPixelRation = function () {
|
||||
var displayClass = display.getDefaultDisplaySync();
|
||||
return displayClass.densityPixels;
|
||||
}
|
||||
|
||||
let onDisplayChange = (data) => {
|
||||
// Monitor changes in screen orientation.
|
||||
displayUtils.onDisplayChange(globalThis.getDeviceOrientation());
|
||||
|
||||
// update screen cutout info
|
||||
globalThis.initScreenInfo();
|
||||
}
|
||||
|
||||
try {
|
||||
display.on("change", onDisplayChange);
|
||||
} catch (exception) {
|
||||
console.log('Failed to register callback. Code: ' + JSON.stringify(exception));
|
||||
}
|
||||
|
||||
globalThis.getDeviceOrientation = function () {
|
||||
var displayClass = display.getDefaultDisplaySync();
|
||||
return displayClass.rotation;
|
||||
}
|
||||
|
||||
globalThis.getNetworkType = function () {
|
||||
let netHandle = connection.getDefaultNetSync();
|
||||
if(netHandle && netHandle.netId != 0) {
|
||||
let result = connection.getNetCapabilitiesSync(netHandle);
|
||||
if (result && result.bearerTypes) {
|
||||
return result.bearerTypes[0];
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
globalThis.vibrate = function (duration) {
|
||||
console.log('begin to vibrate, duration is.' + duration);
|
||||
try {
|
||||
vibrator.startVibration({
|
||||
type: 'time',
|
||||
duration: duration * 1000
|
||||
}, {
|
||||
id: 0,
|
||||
usage: 'alarm'
|
||||
}, (error) => {
|
||||
if (error) {
|
||||
console.error('vibrate fail, error.code: ' + error.code + 'error.message: ', + error.message);
|
||||
return error.code;
|
||||
}
|
||||
console.log('Vibration start sucessful.');
|
||||
return 0;
|
||||
});
|
||||
} catch (err) {
|
||||
console.error('errCode: ' + err.code + ' ,msg: ' + err.message);
|
||||
}
|
||||
}
|
||||
|
||||
globalThis.terminateProcess = function () {
|
||||
pro.exit(0);
|
||||
}
|
||||
|
||||
globalThis.initScreenInfo = function () {
|
||||
display.getDefaultDisplaySync().getCutoutInfo().then((data) => {
|
||||
if (data.boundingRects.length == 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
cutout.left = data.boundingRects[0].left;
|
||||
cutout.top = data.boundingRects[0].top;
|
||||
cutout.width = data.boundingRects[0].width;
|
||||
cutout.height = data.boundingRects[0].height;
|
||||
}).catch((err) => {
|
||||
console.log("get cutout info error!");
|
||||
});
|
||||
};
|
||||
globalThis.initScreenInfo();
|
||||
|
||||
globalThis.getCutoutWidth = function () {
|
||||
if(!cutout.width) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
let disPlayWidth = display.getDefaultDisplaySync().width;
|
||||
if(cutout.left + cutout.width > disPlayWidth - cutout.left) {
|
||||
return disPlayWidth - cutout.left;
|
||||
}
|
||||
return cutout.left + cutout.width;
|
||||
}
|
||||
|
||||
globalThis.getCutoutHeight = function () {
|
||||
if(!cutout.height) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
let orientation = globalThis.getDeviceOrientation();
|
||||
if (orientation == display.Orientation.PORTRAIT) {
|
||||
return cutout.top + cutout.height;
|
||||
} else if(orientation == display.Orientation.PORTRAIT_INVERTED) {
|
||||
let displayHeight = display.getDefaultDisplaySync().height;
|
||||
return displayHeight - cutout.top;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
/****************************************************************************
|
||||
Copyright (c) 2022-2023 Xiamen Yaji Software Co., Ltd.
|
||||
|
||||
http://www.cocos.com
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated engine source code (the "Software"), a limited,
|
||||
worldwide, royalty-free, non-assignable, revocable and non-exclusive license
|
||||
to use Cocos Creator solely to develop games on your target platforms. You shall
|
||||
not use Cocos Creator software for developing other software or tools that's
|
||||
used for developing games. You are not granted to publish, distribute,
|
||||
sublicense, and/or sell copies of Cocos Creator.
|
||||
|
||||
The software or tools in this License Agreement are licensed, not sold.
|
||||
Xiamen Yaji Software Co., Ltd. reserves all rights not expressly granted to you.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
****************************************************************************/
|
||||
export enum ContextType {
|
||||
APP_LIFECYCLE = 0,
|
||||
JSPAGE_LIFECYCLE,
|
||||
XCOMPONENT_CONTEXT,
|
||||
XCOMPONENT_REGISTER_LIFECYCLE_CALLBACK,
|
||||
NATIVE_RENDER_API,
|
||||
WORKER_INIT,
|
||||
ENGINE_UTILS,
|
||||
EDITBOX_UTILS,
|
||||
WEBVIEW_UTILS,
|
||||
DISPLAY_UTILS,
|
||||
UV_ASYNC_SEND,
|
||||
VIDEO_UTILS
|
||||
}
|
||||
|
||||
export class Constants {
|
||||
static readonly APP_KEY_WORKER_MANAGER = "app_key_worker_manager";
|
||||
}
|
||||
@@ -0,0 +1,76 @@
|
||||
/****************************************************************************
|
||||
Copyright (c) 2022-2023 Xiamen Yaji Software Co., Ltd.
|
||||
|
||||
http://www.cocos.com
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated engine source code (the "Software"), a limited,
|
||||
worldwide, royalty-free, non-assignable, revocable and non-exclusive license
|
||||
to use Cocos Creator solely to develop games on your target platforms. You shall
|
||||
not use Cocos Creator software for developing other software or tools that's
|
||||
used for developing games. You are not granted to publish, distribute,
|
||||
sublicense, and/or sell copies of Cocos Creator.
|
||||
|
||||
The software or tools in this License Agreement are licensed, not sold.
|
||||
Xiamen Yaji Software Co., Ltd. reserves all rights not expressly granted to you.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
****************************************************************************/
|
||||
import { ThreadWorkerGlobalScope } from '@ohos.worker';
|
||||
import { MessageEvent } from '@ohos.worker';
|
||||
|
||||
export class PortProxy {
|
||||
private autoId: number = 0;
|
||||
public actionHandleMap = {}
|
||||
private port: ThreadWorkerGlobalScope = null;
|
||||
|
||||
public _messageHandle?: (e: MessageEvent<any>) => void;
|
||||
|
||||
constructor(worker) {
|
||||
this.port = worker;
|
||||
this.port.onmessage = this.onMessage.bind(this);
|
||||
}
|
||||
|
||||
public onMessage(e) {
|
||||
let data = e['data'];
|
||||
if (data.type != "syncResult" && this._messageHandle) {
|
||||
this._messageHandle(e);
|
||||
} else if (data.type == "syncResult") {
|
||||
const { id, response } = data.data;
|
||||
if (!this.actionHandleMap[id]) {
|
||||
return;
|
||||
}
|
||||
this.actionHandleMap[id].call(this, response);
|
||||
delete this.actionHandleMap[id];
|
||||
}
|
||||
}
|
||||
|
||||
public postReturnMessage(e: any, res: any) {
|
||||
if (e.type == "sync" && res != null && res != undefined) {
|
||||
this.port.postMessage({ type: "syncResult", data: { id: e.data.cbId, response: res } });
|
||||
}
|
||||
}
|
||||
|
||||
public postMessage(msgName: string, msgData: any) {
|
||||
this.port.postMessage({ type: "async", data: { name: msgName, param: msgData } });
|
||||
}
|
||||
|
||||
public postSyncMessage(msgName: string, msgData: any) {
|
||||
const id = this.autoId++;
|
||||
return new Promise((resolve, reject) => {
|
||||
const message = {
|
||||
type: "sync", data: { cbId: id, name: msgName, param: msgData }
|
||||
}
|
||||
this.port.postMessage(message);
|
||||
this.actionHandleMap[id] = (response) => {
|
||||
resolve(response)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,145 @@
|
||||
/****************************************************************************
|
||||
Copyright (c) 2022-2023 Xiamen Yaji Software Co., Ltd.
|
||||
|
||||
http://www.cocos.com
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated engine source code (the "Software"), a limited,
|
||||
worldwide, royalty-free, non-assignable, revocable and non-exclusive license
|
||||
to use Cocos Creator solely to develop games on your target platforms. You shall
|
||||
not use Cocos Creator software for developing other software or tools that's
|
||||
used for developing games. You are not granted to publish, distribute,
|
||||
sublicense, and/or sell copies of Cocos Creator.
|
||||
|
||||
The software or tools in this License Agreement are licensed, not sold.
|
||||
Xiamen Yaji Software Co., Ltd. reserves all rights not expressly granted to you.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
****************************************************************************/
|
||||
import { PortProxy } from '../common/PortProxy';
|
||||
|
||||
enum EventType {
|
||||
PLAYING = 0,
|
||||
PAUSED,
|
||||
STOPPED,
|
||||
COMPLETED,
|
||||
META_LOADED,
|
||||
CLICKED,
|
||||
READY_TO_PLAY,
|
||||
UPDATE,
|
||||
QUIT_FULLSCREEN = 1000
|
||||
}
|
||||
|
||||
interface param {
|
||||
videoTag?: number,
|
||||
videoEvent?: EventType,
|
||||
args?: number
|
||||
}
|
||||
|
||||
@Observed
|
||||
export class VideoInfo {
|
||||
public x: number = 0;
|
||||
public y: number = 0;
|
||||
public w: number = 0;
|
||||
public h: number = 0;
|
||||
// url
|
||||
public url: string | Resource = "";
|
||||
public viewTag: number = 0;
|
||||
public visible: boolean = true;
|
||||
public duration: number = 0;
|
||||
public currentTime: number = 0;
|
||||
public isFullScreen: boolean = false;
|
||||
public currentProgressRate?: number | string | PlaybackSpeed;
|
||||
public resourceType: number = 0;
|
||||
public isPreparedStart: boolean = false;
|
||||
/**
|
||||
* https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/reference/arkui-ts/ts-media-components-video.md#videocontroller
|
||||
*
|
||||
*/
|
||||
public controller: VideoController = new VideoController()
|
||||
|
||||
constructor(x: number, y: number, w: number, h: number, viewTag: number) {
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
this.w = w;
|
||||
this.h = h;
|
||||
this.viewTag = viewTag
|
||||
}
|
||||
}
|
||||
|
||||
@Component
|
||||
export struct CocosVideoPlayer {
|
||||
@ObjectLink videoInfo: VideoInfo;
|
||||
public workPort: PortProxy | null = null;
|
||||
|
||||
build() {
|
||||
Video({
|
||||
src: this.videoInfo.url,
|
||||
controller: this.videoInfo.controller,
|
||||
currentProgressRate: this.videoInfo.currentProgressRate as number | string | PlaybackSpeed
|
||||
})
|
||||
.position({ x: this.videoInfo.x, y: this.videoInfo.y })
|
||||
.width(this.videoInfo.w)
|
||||
.height(this.videoInfo.h)
|
||||
.controls(false)
|
||||
.autoPlay(false)
|
||||
.onStart(() => {
|
||||
this.workPort?.postMessage("onVideoEvent", {
|
||||
videoTag: this.videoInfo.viewTag as number,
|
||||
videoEvent: EventType.PLAYING as EventType
|
||||
} as param);
|
||||
})
|
||||
.onPause(() => {
|
||||
this.workPort?.postMessage("onVideoEvent", {
|
||||
videoTag: this.videoInfo.viewTag as number,
|
||||
videoEvent: EventType.PAUSED as EventType
|
||||
} as param);
|
||||
})
|
||||
.onFinish(() => {
|
||||
this.workPort?.postMessage("onVideoEvent", {
|
||||
videoTag: this.videoInfo.viewTag,
|
||||
videoEvent: EventType.COMPLETED
|
||||
} as param);
|
||||
})
|
||||
.onPrepared((event): void => {
|
||||
this.videoInfo.isPreparedStart && this.videoInfo.controller.start();
|
||||
|
||||
this.videoInfo.duration = event?.duration as number;
|
||||
this.workPort?.postMessage("onVideoEvent", {
|
||||
videoTag: this.videoInfo.viewTag,
|
||||
videoEvent: EventType.READY_TO_PLAY,
|
||||
args: event?.duration
|
||||
} as param);
|
||||
})
|
||||
.onClick((event): void => {
|
||||
this.workPort?.postMessage("onVideoEvent", {
|
||||
videoTag: this.videoInfo.viewTag,
|
||||
videoEvent: EventType.CLICKED
|
||||
} as param);
|
||||
})
|
||||
.onUpdate((event) => {
|
||||
this.videoInfo.currentTime = event?.time as number;
|
||||
this.workPort?.postMessage("onVideoEvent", {
|
||||
videoTag: this.videoInfo.viewTag,
|
||||
videoEvent: EventType.UPDATE,
|
||||
args: event?.time
|
||||
} as param);
|
||||
})
|
||||
.onFullscreenChange((event) => {
|
||||
if (!event?.fullscreen) {
|
||||
this.workPort?.postMessage("onVideoEvent", {
|
||||
videoTag: this.videoInfo.viewTag,
|
||||
videoEvent: EventType.QUIT_FULLSCREEN
|
||||
} as param);
|
||||
}
|
||||
this.videoInfo.isFullScreen = event?.fullscreen as boolean;
|
||||
})
|
||||
.visibility(this.videoInfo.visible ? Visibility.Visible : Visibility.None)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,104 @@
|
||||
/****************************************************************************
|
||||
Copyright (c) 2022-2023 Xiamen Yaji Software Co., Ltd.
|
||||
|
||||
http://www.cocos.com
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated engine source code (the "Software"), a limited,
|
||||
worldwide, royalty-free, non-assignable, revocable and non-exclusive license
|
||||
to use Cocos Creator solely to develop games on your target platforms. You shall
|
||||
not use Cocos Creator software for developing other software or tools that's
|
||||
used for developing games. You are not granted to publish, distribute,
|
||||
sublicense, and/or sell copies of Cocos Creator.
|
||||
|
||||
The software or tools in this License Agreement are licensed, not sold.
|
||||
Xiamen Yaji Software Co., Ltd. reserves all rights not expressly granted to you.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
****************************************************************************/
|
||||
import { PortProxy } from '../common/PortProxy';
|
||||
import web from '@ohos.web.webview';
|
||||
|
||||
interface param {
|
||||
viewTag: number,
|
||||
url: string,
|
||||
}
|
||||
|
||||
@Observed
|
||||
export class WebViewInfo {
|
||||
// position
|
||||
public x: number = 0;
|
||||
public y: number = 0;
|
||||
// size
|
||||
public w: number = 0;
|
||||
public h: number = 0;
|
||||
// url
|
||||
public url: string = '';
|
||||
// tag
|
||||
public viewTag: number = 0;
|
||||
// Whether to display
|
||||
public visible: boolean = true;
|
||||
/*
|
||||
* doc : https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-web.md#webcontroller
|
||||
*/
|
||||
public controller: web.WebviewController = new web.WebviewController();
|
||||
|
||||
constructor(x: number, y: number, w: number, h: number, viewTag: number) {
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
this.w = w;
|
||||
this.h = h;
|
||||
this.viewTag = viewTag;
|
||||
|
||||
web.once("webInited", () => {
|
||||
if (this.url != '') {
|
||||
this.controller.loadUrl(this.url);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@Component
|
||||
export struct CocosWebView {
|
||||
@ObjectLink viewInfo: WebViewInfo;
|
||||
public workPort: PortProxy | null = null;
|
||||
|
||||
build() {
|
||||
Web({ src: this.viewInfo.url, controller: this.viewInfo.controller })
|
||||
.position({ x: this.viewInfo.x, y: this.viewInfo.y })
|
||||
.width(this.viewInfo.w)
|
||||
.height(this.viewInfo.h)
|
||||
.border({ width: 1 })
|
||||
.onControllerAttached(() => {
|
||||
if (this.viewInfo.url != '') {
|
||||
this.viewInfo.controller.loadUrl(this.viewInfo.url);
|
||||
}
|
||||
})
|
||||
.onPageBegin((event) => {
|
||||
this.workPort?.postMessage("onPageBegin", {
|
||||
viewTag: this.viewInfo.viewTag as number,
|
||||
url: event?.url as string
|
||||
} as param);
|
||||
})
|
||||
.onPageEnd((event) => {
|
||||
this.workPort?.postMessage("onPageEnd", { viewTag: this.viewInfo.viewTag as number, url: event?.url as string } as param)
|
||||
})
|
||||
.onErrorReceive((event) => {
|
||||
this.workPort?.postMessage("onErrorReceive", { viewTag: this.viewInfo.viewTag as number, url: this.viewInfo.url as string } as param)
|
||||
})
|
||||
.onHttpErrorReceive((event) => {
|
||||
this.workPort?.postMessage("onErrorReceive", { viewTag: this.viewInfo.viewTag as number, url: this.viewInfo.url as string } as param)
|
||||
})
|
||||
.domStorageAccess(true)// enable DOM storage permissions
|
||||
.databaseAccess(true)// enable database storage permissions
|
||||
.imageAccess(true)// enable image loading permissions
|
||||
.javaScriptAccess(true)// support JS code running
|
||||
.visibility(this.viewInfo.visible ? Visibility.Visible : Visibility.None)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,89 @@
|
||||
/****************************************************************************
|
||||
Copyright (c) 2022-2023 Xiamen Yaji Software Co., Ltd.
|
||||
|
||||
http://www.cocos.com
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated engine source code (the "Software"), a limited,
|
||||
worldwide, royalty-free, non-assignable, revocable and non-exclusive license
|
||||
to use Cocos Creator solely to develop games on your target platforms. You shall
|
||||
not use Cocos Creator software for developing other software or tools that's
|
||||
used for developing games. You are not granted to publish, distribute,
|
||||
sublicense, and/or sell copies of Cocos Creator.
|
||||
|
||||
The software or tools in this License Agreement are licensed, not sold.
|
||||
Xiamen Yaji Software Co., Ltd. reserves all rights not expressly granted to you.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
****************************************************************************/
|
||||
@Observed
|
||||
export class EditboxShowInfo {
|
||||
public backgroundColor: number = 0xFFFFFFFF;
|
||||
public enterKeyType: EnterKeyType = EnterKeyType.Done;
|
||||
public type:InputType = InputType.Normal;
|
||||
public maxLength: number = 65536;
|
||||
public defaultMessage: string = '';
|
||||
public textAlign: TextAlign = TextAlign.Start;
|
||||
public showUnderline: boolean = false;
|
||||
public multiLines: boolean = false;
|
||||
// API12
|
||||
public underLineColor: number = 0xFFFFFFFF;
|
||||
}
|
||||
|
||||
@CustomDialog
|
||||
export struct EditBoxDialog {
|
||||
private inputMessage: string = ''
|
||||
@ObjectLink showInfo: EditboxShowInfo;
|
||||
onTextChange?: (msg: string) => void;
|
||||
accept?: (msg: string) => void;
|
||||
controller?: CustomDialogController;
|
||||
cancel?: () => void;
|
||||
confirm?: (msg: string) => void;
|
||||
|
||||
build() {
|
||||
Column() {
|
||||
Row() {
|
||||
TextInput({ text: this.showInfo.defaultMessage })
|
||||
.defaultFocus(true)
|
||||
.backgroundColor('#ffffff')
|
||||
.backgroundColor(this.showInfo.backgroundColor)
|
||||
.type(this.showInfo.type)
|
||||
.maxLength(this.showInfo.maxLength)
|
||||
.textAlign(this.showInfo.textAlign)
|
||||
.showUnderline(this.showInfo.showUnderline)
|
||||
.enterKeyType(this.showInfo.enterKeyType)
|
||||
.layoutWeight(1)
|
||||
.onChange((value) => {
|
||||
if (this.onTextChange) {
|
||||
this.onTextChange(value);
|
||||
}
|
||||
this.inputMessage = value;
|
||||
})
|
||||
.onSubmit((value) => {
|
||||
if(this.confirm) {
|
||||
this.confirm(this.inputMessage);
|
||||
}
|
||||
this.controller?.close();
|
||||
})
|
||||
Blank(8).width(16)
|
||||
Button('完成').onClick(() => {
|
||||
if (this.accept) {
|
||||
this.accept(this.inputMessage);
|
||||
}
|
||||
this.controller?.close();
|
||||
})
|
||||
}.padding({ left: 8, right: 8, top: 8, bottom: 8 })
|
||||
.backgroundColor(Color.Gray)
|
||||
.offset({ x : 0, y : 15 })
|
||||
}
|
||||
.width('100%')
|
||||
|
||||
.justifyContent(FlexAlign.End)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,92 @@
|
||||
import UIAbility from '@ohos.app.ability.UIAbility';
|
||||
import cocos, { context } from 'libcocos.so';
|
||||
import { ContextType } from '../common/Constants';
|
||||
import window from '@ohos.window';
|
||||
import { BusinessError } from '@kit.BasicServicesKit';
|
||||
import { AbilityConstant, Want } from '@kit.AbilityKit';
|
||||
|
||||
const nativeContext: context = cocos.getContext(ContextType.ENGINE_UTILS);
|
||||
const nativeAppLifecycle: context = cocos.getContext(ContextType.APP_LIFECYCLE);
|
||||
enum windowStageType {
|
||||
hide,
|
||||
show
|
||||
}
|
||||
export default class EntryAbility extends UIAbility {
|
||||
private windowStageType: windowStageType = windowStageType.hide;
|
||||
|
||||
onCreate(want: Want, launchParam: AbilityConstant.LaunchParam) {
|
||||
globalThis.abilityWant = want;
|
||||
nativeAppLifecycle.onCreate();
|
||||
nativeContext.resourceManagerInit(this.context.resourceManager);
|
||||
}
|
||||
|
||||
onDestroy() {
|
||||
nativeAppLifecycle.onDestroy();
|
||||
}
|
||||
|
||||
onWindowStageCreate(windowStage: window.WindowStage) {
|
||||
nativeContext.writablePathInit(this.context.cacheDir);
|
||||
|
||||
// Get the Main window instance
|
||||
let windowClass: window.Window | undefined = undefined;
|
||||
windowStage.getMainWindow((err: BusinessError, data) => {
|
||||
if (err.code) {
|
||||
console.error('Failed to obtain the main window. Cause: ' + JSON.stringify(err));
|
||||
return;
|
||||
}
|
||||
windowClass = data;
|
||||
// Set whether to display the status bar and navigation bar. If they are not displayed, [] is displayed.
|
||||
let systemBarPromise = windowClass.setWindowSystemBarEnable([]);
|
||||
// Whether the window layout is displayed in full screen mode
|
||||
let fullScreenPromise = windowClass.setWindowLayoutFullScreen(true);
|
||||
// Sets whether the screen is always on.
|
||||
let keepScreenOnPromise = windowClass.setWindowKeepScreenOn(true);
|
||||
Promise.all([systemBarPromise, fullScreenPromise, keepScreenOnPromise]).then(() => {
|
||||
console.info('Succeeded in setting the window');
|
||||
}).catch((err:BusinessError) => {
|
||||
console.error('Failed to set the window, cause ' + JSON.stringify(err));
|
||||
});
|
||||
});
|
||||
// Main window is created, set main page for this ability
|
||||
windowStage.loadContent("pages/index", (err, data) => {
|
||||
if (err.code) {
|
||||
console.error('Failed to load the content. Cause:' + JSON.stringify(err));
|
||||
return;
|
||||
}
|
||||
});
|
||||
windowStage.on("windowStageEvent", (data) => {
|
||||
let stageEventType: window.WindowStageEventType = data;
|
||||
switch (stageEventType) {
|
||||
case window.WindowStageEventType.RESUMED:
|
||||
this.onChangeWinodowStageType(windowStageType.show);
|
||||
break;
|
||||
case window.WindowStageEventType.PAUSED:
|
||||
this.onChangeWinodowStageType(windowStageType.hide);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
onWindowStageDestroy() {
|
||||
|
||||
}
|
||||
|
||||
onForeground() {
|
||||
// Ability has brought to foreground
|
||||
this.onChangeWinodowStageType(windowStageType.show);
|
||||
}
|
||||
|
||||
onBackground() {
|
||||
// Ability has back to background
|
||||
this.onChangeWinodowStageType(windowStageType.hide);
|
||||
}
|
||||
|
||||
onChangeWinodowStageType(type: windowStageType) {
|
||||
if (this.windowStageType != type) {
|
||||
this.windowStageType = type;
|
||||
this.windowStageType === windowStageType.show ? nativeAppLifecycle.onShow() : nativeAppLifecycle.onHide();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,460 @@
|
||||
/****************************************************************************
|
||||
Copyright (c) 2022-2023 Xiamen Yaji Software Co., Ltd.
|
||||
|
||||
http://www.cocos.com
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated engine source code (the "Software"), a limited,
|
||||
worldwide, royalty-free, non-assignable, revocable and non-exclusive license
|
||||
to use Cocos Creator solely to develop games on your target platforms. You shall
|
||||
not use Cocos Creator software for developing other software or tools that's
|
||||
used for developing games. You are not granted to publish, distribute,
|
||||
sublicense, and/or sell copies of Cocos Creator.
|
||||
|
||||
The software or tools in this License Agreement are licensed, not sold.
|
||||
Xiamen Yaji Software Co., Ltd. reserves all rights not expressly granted to you.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
****************************************************************************/
|
||||
import nativerender,{context} from 'libcocos.so';
|
||||
|
||||
import { WorkerManager } from '../cocos/WorkerManager';
|
||||
import { ContextType } from '../common/Constants';
|
||||
import { EditBoxDialog, EditboxShowInfo } from '../components/EditBoxDialog';
|
||||
import { CocosWebView, WebViewInfo } from '../components/CocosWebView';
|
||||
import { CocosVideoPlayer, VideoInfo } from '../components/CocosVideoPlayer';
|
||||
import { MessageEvent } from '@ohos.worker';
|
||||
import { PortProxy } from '../common/PortProxy';
|
||||
import { common } from '@kit.AbilityKit';
|
||||
import { BusinessError } from '@kit.BasicServicesKit';
|
||||
|
||||
const nativePageLifecycle :context = nativerender.getContext(ContextType.JSPAGE_LIFECYCLE);
|
||||
const engineUtils :context = nativerender.getContext(ContextType.ENGINE_UTILS);
|
||||
|
||||
|
||||
function executeMethodAsync(nativeFunc: Function, funcData: string, funCb: Function): void {
|
||||
nativeFunc && nativeFunc(funcData, funCb);
|
||||
}
|
||||
function executeMethodSync(nativeFunc: Function, funcData: string): string|boolean|number {
|
||||
return nativeFunc && nativeFunc(funcData);
|
||||
}
|
||||
engineUtils.registerFunction("executeMethodAsync", executeMethodAsync);
|
||||
engineUtils.registerFunction("executeMethodSync", executeMethodSync);
|
||||
|
||||
interface WorkerMessage {
|
||||
type: string;
|
||||
data: data;
|
||||
}
|
||||
|
||||
interface data {
|
||||
id: string,
|
||||
name: string,
|
||||
param: number | string | param
|
||||
}
|
||||
|
||||
interface param {
|
||||
tag?: number,
|
||||
url?: string,
|
||||
contents?: string,
|
||||
mimeType?: string,
|
||||
encoding?: string,
|
||||
baseUrl?: string,
|
||||
jsContents?: string,
|
||||
x?: number,
|
||||
y?: number,
|
||||
w?: number,
|
||||
h?: number,
|
||||
visible?: boolean,
|
||||
resourceType?: number,
|
||||
time?: number,
|
||||
fullScreen?: boolean
|
||||
}
|
||||
|
||||
interface editboxShowInfo {
|
||||
defaultValue?: string;
|
||||
confirmType?: string;
|
||||
inputType?: string;
|
||||
maxLength?: number;
|
||||
x?:number;
|
||||
y?:number;
|
||||
width?:number;
|
||||
height?:number;
|
||||
confirmHold?: boolean;
|
||||
isMultiline?: boolean;
|
||||
fontSize?: number;
|
||||
fontColor?: number;
|
||||
backColor?: number;
|
||||
backgroundColor?: number;
|
||||
isBold?: boolean;
|
||||
isItalic?: boolean;
|
||||
isUnderline?: boolean;
|
||||
underlineColor?: number;
|
||||
textAlignment?: number;
|
||||
}
|
||||
|
||||
@Entry
|
||||
@Component
|
||||
struct Index {
|
||||
@State showInfo: EditboxShowInfo = new EditboxShowInfo;
|
||||
@State webViewArray: WebViewInfo[] = [];
|
||||
@State videoArray: VideoInfo[] = [];
|
||||
private webViewIndexMap: Map<number, number> = new Map<number, number>();
|
||||
private videoIndexMap: Map<number, number> = new Map<number, number>();
|
||||
private workPort: PortProxy = new PortProxy(WorkerManager.getInstance().getWorker());
|
||||
dialogController: CustomDialogController = new CustomDialogController({
|
||||
builder: EditBoxDialog({
|
||||
showInfo: this.showInfo,
|
||||
onTextChange: (msg: string): void => {
|
||||
this.showInfo.defaultMessage = msg;
|
||||
this.workPort.postMessage('onTextInput', msg);
|
||||
},
|
||||
accept: (msg: string): void => {
|
||||
this.showInfo.defaultMessage = msg;
|
||||
this.workPort.postMessage('onComplete', msg);
|
||||
},
|
||||
confirm: (msg: string): void => {
|
||||
this.showInfo.defaultMessage = msg;
|
||||
this.workPort.postMessage('onConfirm', msg);
|
||||
this.workPort.postMessage('onComplete', msg);
|
||||
},
|
||||
}),
|
||||
cancel: (): void => {
|
||||
this.workPort.postMessage('onComplete', this.showInfo.defaultMessage);
|
||||
},
|
||||
autoCancel: true,
|
||||
alignment: DialogAlignment.Bottom,
|
||||
customStyle: true,
|
||||
})
|
||||
|
||||
aboutToAppear(): void {
|
||||
console.log('[LIFECYCLE-Index] cocos aboutToAppear');
|
||||
this.workPort._messageHandle = async (e: MessageEvent<WorkerMessage>): Promise<void> => {
|
||||
let data: WorkerMessage = e.data;
|
||||
let msg = data.data;
|
||||
let result: boolean | string | number | null = null;
|
||||
switch (msg.name) {
|
||||
// EditBox
|
||||
case "showEditBox": {
|
||||
let param = msg.param as editboxShowInfo;
|
||||
this.showInfo.defaultMessage = param?.defaultValue as string;
|
||||
this.showInfo.backgroundColor = param?.backColor as number;
|
||||
if(param?.confirmType == 'done') {
|
||||
this.showInfo.enterKeyType = EnterKeyType.Done;
|
||||
} else if(param?.confirmType == 'send') {
|
||||
this.showInfo.enterKeyType = EnterKeyType.Send;
|
||||
} else if(param?.confirmType == 'search') {
|
||||
this.showInfo.enterKeyType = EnterKeyType.Search;
|
||||
} else if(param?.confirmType == 'go') {
|
||||
this.showInfo.enterKeyType = EnterKeyType.Go;
|
||||
} else if(param?.confirmType == 'next') {
|
||||
this.showInfo.enterKeyType = EnterKeyType.Next;
|
||||
} else {
|
||||
this.showInfo.enterKeyType = EnterKeyType.Done;
|
||||
}
|
||||
if(param?.inputType == 'password') {
|
||||
this.showInfo.type = InputType.Password;
|
||||
} else if(param?.inputType === 'email') {
|
||||
this.showInfo.type = InputType.Email;
|
||||
} else if(param?.inputType === 'number') {
|
||||
this.showInfo.type = InputType.Number;
|
||||
} else if(param?.inputType === 'digit') {
|
||||
this.showInfo.type = InputType.NUMBER_DECIMAL;
|
||||
} else if(param?.inputType === 'tel') {
|
||||
this.showInfo.type = InputType.PhoneNumber;
|
||||
} else if(param?.inputType === 'url') {
|
||||
// No url support
|
||||
} else {
|
||||
this.showInfo.type = InputType.Normal;
|
||||
}
|
||||
if(param?.maxLength != undefined && param?.maxLength > 0) {
|
||||
this.showInfo.maxLength = param.maxLength;
|
||||
} else {
|
||||
this.showInfo.maxLength = 65536;
|
||||
}
|
||||
|
||||
if(param?.isUnderline != undefined) {
|
||||
this.showInfo.showUnderline = param?.isUnderline;
|
||||
this.showInfo.underLineColor = param?.underlineColor as number;
|
||||
} else {
|
||||
this.showInfo.showUnderline = false;
|
||||
}
|
||||
|
||||
if(param?.textAlignment == 0) {
|
||||
this.showInfo.textAlign = TextAlign.Start;
|
||||
} else if(param?.textAlignment == 1) {
|
||||
this.showInfo.textAlign = TextAlign.Center;
|
||||
} else if(param?.textAlignment == 2) {
|
||||
this.showInfo.textAlign = TextAlign.End;
|
||||
} else {
|
||||
this.showInfo.textAlign = TextAlign.Start;
|
||||
}
|
||||
this.dialogController.open();
|
||||
break;
|
||||
}
|
||||
case "hideEditBox": {
|
||||
this.showInfo.defaultMessage = '';
|
||||
this.dialogController.close();
|
||||
break;
|
||||
}
|
||||
// WebView
|
||||
case "createWebView": {
|
||||
this.webViewArray.push(new WebViewInfo(0, 0, 0, 0, msg.param as number));
|
||||
this.webViewIndexMap.set(msg.param as number, this.webViewArray.length - 1);
|
||||
break;
|
||||
}
|
||||
case "removeWebView": {
|
||||
if (this.webViewArray.length > 0) {
|
||||
this.webViewArray.splice(this.webViewIndexMap.get(msg?.param as number) as number, 1);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case "loadUrl": {
|
||||
let web = msg.param as param;
|
||||
let index = this.webViewIndexMap.get(web?.tag as number) as number;
|
||||
this.webViewArray[index].url = web?.url as string;
|
||||
this.webViewArray[index].controller.loadUrl(web?.url as string);
|
||||
break;
|
||||
}
|
||||
case "loadHTMLString": {
|
||||
let web = msg.param as param;
|
||||
let index = this.webViewIndexMap.get(web?.tag as number) as number;
|
||||
this.webViewArray[index].controller.loadData(
|
||||
web?.contents as string,
|
||||
"text/html",
|
||||
"UTF-8",
|
||||
web?.baseUrl
|
||||
);
|
||||
break;
|
||||
}
|
||||
case "loadData": {
|
||||
let web = msg.param as param;
|
||||
let index = this.webViewIndexMap.get(web?.tag as number) as number;
|
||||
this.webViewArray[index].controller.loadData(
|
||||
web?.contents as string,
|
||||
web?.mimeType as string,
|
||||
web?.encoding as string,
|
||||
web?.baseUrl as string
|
||||
);
|
||||
break;
|
||||
}
|
||||
case "evaluateJS": {
|
||||
let web = msg.param as param;
|
||||
let index = this.webViewIndexMap.get(web?.tag as number) as number;
|
||||
this.webViewArray[index].controller.runJavaScript(web?.jsContents as string);
|
||||
break;
|
||||
}
|
||||
case "reload": {
|
||||
let index = this.webViewIndexMap.get(msg.param as number) as number;
|
||||
this.webViewArray[index].controller.refresh();
|
||||
break;
|
||||
}
|
||||
case "stopLoading": {
|
||||
let index = this.webViewIndexMap.get(msg.param as number) as number;
|
||||
this.webViewArray[index].controller.stop();
|
||||
break;
|
||||
}
|
||||
case "canGoForward": {
|
||||
let index = this.webViewIndexMap.get(msg.param as number) as number;
|
||||
result = this.webViewArray[index].controller.accessForward();
|
||||
break;
|
||||
}
|
||||
case "canGoBack": {
|
||||
let index = this.webViewIndexMap.get(msg.param as number) as number;
|
||||
result = this.webViewArray[index].controller.accessBackward();
|
||||
break;
|
||||
}
|
||||
case "goForward": {
|
||||
let index = this.webViewIndexMap.get(msg.param as number) as number;
|
||||
this.webViewArray[index].controller.forward();
|
||||
break;
|
||||
}
|
||||
case "goBack": {
|
||||
let index = this.webViewIndexMap.get(msg.param as number) as number;
|
||||
this.webViewArray[index].controller.backward();
|
||||
break;
|
||||
}
|
||||
case "setWebViewRect": {
|
||||
let web = msg.param as param
|
||||
let index = this.webViewIndexMap.get(web?.tag as number) as number;
|
||||
this.webViewArray[index].x = px2vp(web?.x as number) as number;
|
||||
this.webViewArray[index].y = px2vp(web?.y as number) as number;
|
||||
this.webViewArray[index].w = px2vp(web?.w as number) as number;
|
||||
this.webViewArray[index].h = px2vp(web?.h as number) as number;
|
||||
break;
|
||||
}
|
||||
case "setVisible": {
|
||||
let web = msg.param as param;
|
||||
let index = this.webViewIndexMap.get(web?.tag as number) as number;
|
||||
this.webViewArray[index].visible = web?.visible as boolean;
|
||||
break;
|
||||
}
|
||||
// video
|
||||
case "createVideo": {
|
||||
this.videoArray.push(new VideoInfo(0, 0, 0, 0, msg.param as number));
|
||||
this.videoIndexMap.set(msg.param as number, this.videoArray.length - 1);
|
||||
break;
|
||||
}
|
||||
case "removeVideo": {
|
||||
if (this.videoArray.length > 0) {
|
||||
this.videoArray.splice(this.videoIndexMap.get(msg.param as number) as number, 1);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case "setVideoUrl":
|
||||
let video = msg.param as param;
|
||||
let index = this.videoIndexMap.get(video?.tag as number) as number;
|
||||
let resourceType = video.resourceType;
|
||||
if (resourceType == 1) {
|
||||
video.url = 'Resources/' + video.url;
|
||||
this.videoArray[index].url = $rawfile(video.url as string);
|
||||
} else {
|
||||
this.videoArray[index].url = video.url as string;
|
||||
}
|
||||
break;
|
||||
case "setVideoRect": {
|
||||
let video = msg.param as param;
|
||||
let index = this.videoIndexMap.get(video?.tag as number) as number;
|
||||
this.videoArray[index].x = px2vp(video?.x as number) as number;
|
||||
this.videoArray[index].y = px2vp(video?.y as number) as number;
|
||||
this.videoArray[index].w = px2vp(video?.w as number) as number;
|
||||
this.videoArray[index].h = px2vp(video?.h as number) as number;
|
||||
break;
|
||||
}
|
||||
case "startVideo": {
|
||||
let index = this.videoIndexMap.get(msg.param as number) as number;
|
||||
if(this.videoArray[index].duration){
|
||||
this.videoArray[index].controller.start();
|
||||
}else{
|
||||
this.videoArray[index].isPreparedStart = true;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case "pauseVideo": {
|
||||
let index = this.videoIndexMap.get(msg.param as number) as number;
|
||||
this.videoArray[index].controller.pause();
|
||||
break;
|
||||
}
|
||||
case "stopVideo": {
|
||||
let index = this.videoIndexMap.get(msg.param as number) as number;
|
||||
this.videoArray[index].controller.stop();
|
||||
break;
|
||||
}
|
||||
case "resumeVideo": {
|
||||
let index = this.videoIndexMap.get(msg.param as number) as number;
|
||||
this.videoArray[index].controller.start();
|
||||
break;
|
||||
}
|
||||
case "getVideoDuration": {
|
||||
let index = this.videoIndexMap.get(msg.param as number) as number;
|
||||
result = this.videoArray[index].duration;
|
||||
break;
|
||||
}
|
||||
case "seekVideoTo": {
|
||||
let video = msg.param as param;
|
||||
let index = this.videoIndexMap.get(video?.tag as number) as number;
|
||||
this.videoArray[index].controller.setCurrentTime(video?.time as number, SeekMode.Accurate);
|
||||
break;
|
||||
}
|
||||
case "setVideoVisible": {
|
||||
let video = msg.param as param;
|
||||
let index = this.videoIndexMap.get(video?.tag as number) as number;
|
||||
this.videoArray[index].visible = video.visible as boolean;
|
||||
break;
|
||||
}
|
||||
case "setFullScreenEnabled": {
|
||||
let video = msg.param as param;
|
||||
let index = this.videoIndexMap.get(video?.tag as number) as number;
|
||||
this.videoArray[index].isFullScreen = video.fullScreen as boolean;
|
||||
break;
|
||||
}
|
||||
case "currentTime": {
|
||||
let index = this.videoIndexMap.get(msg.param as number) as number;
|
||||
result = this.videoArray[index].currentTime;
|
||||
break;
|
||||
}
|
||||
case "exitGame": {
|
||||
this.terminateSelf();
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
|
||||
}
|
||||
}
|
||||
if (result != null || result != undefined) {
|
||||
this.workPort.postReturnMessage(data, result);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
aboutToDisappear(): void {
|
||||
console.log('[LIFECYCLE-Index] cocos aboutToDisappear');
|
||||
// this.cocosWorker.postMessage({type: "JSPageLifecycle", data: "aboutToAppear"});
|
||||
// nativePageLifecycle.aboutToDisappear();
|
||||
}
|
||||
|
||||
onPageShow(): void {
|
||||
console.log('[LIFECYCLE-Page] cocos onPageShow');
|
||||
nativePageLifecycle.onPageShow();
|
||||
}
|
||||
|
||||
onPageHide(): void {
|
||||
console.log('[LIFECYCLE-Page] cocos onPageHide');
|
||||
nativePageLifecycle.onPageHide();
|
||||
}
|
||||
|
||||
onBackPress() {
|
||||
console.log("[LIFECYCLE-Page] cocos onBackPress");
|
||||
this.workPort.postMessage("backPress", "");
|
||||
// If disable system exit needed, remove comment "return true"
|
||||
// return true;
|
||||
}
|
||||
|
||||
terminateSelf() {
|
||||
try {
|
||||
(getContext(this) as common.UIAbilityContext).terminateSelf((err: BusinessError) => {
|
||||
if (err.code) {
|
||||
console.error(`terminateSelf failed, code is ${err.code}, message is ${err.message}`);
|
||||
return;
|
||||
}
|
||||
console.info('terminateSelf succeed');
|
||||
});
|
||||
} catch (err) {
|
||||
let code = (err as BusinessError).code;
|
||||
let message = (err as BusinessError).message;
|
||||
console.error(`terminateSelf failed, code is ${code}, message is ${message}`);
|
||||
}
|
||||
}
|
||||
|
||||
build() {
|
||||
Flex({
|
||||
direction: FlexDirection.Column,
|
||||
alignItems: ItemAlign.Center,
|
||||
justifyContent: FlexAlign.Center
|
||||
} as FlexOptions) {
|
||||
XComponent({ id: 'xcomponentId', type: 'surface', libraryname: 'cocos' })
|
||||
.onLoad((context) => {
|
||||
// Set the cache directory in the ts layer.
|
||||
this.workPort.postMessage("onXCLoad", "XComponent");
|
||||
})
|
||||
.onDestroy(() => {
|
||||
console.log('cocos onDestroy')
|
||||
})
|
||||
|
||||
ForEach(this.webViewArray, (item: WebViewInfo) => {
|
||||
CocosWebView({ viewInfo: item, workPort: this.workPort })
|
||||
}, (item: WebViewInfo): string => item.viewTag.toString())
|
||||
|
||||
ForEach(this.videoArray, (item: VideoInfo) => {
|
||||
CocosVideoPlayer({ videoInfo: item, workPort: this.workPort })
|
||||
}, (item: VideoInfo): string => item.viewTag.toString())
|
||||
}
|
||||
.width('100%')
|
||||
.height('100%')
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,120 @@
|
||||
/****************************************************************************
|
||||
Copyright (c) 2022-2023 Xiamen Yaji Software Co., Ltd.
|
||||
|
||||
http://www.cocos.com
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated engine source code (the "Software"), a limited,
|
||||
worldwide, royalty-free, non-assignable, revocable and non-exclusive license
|
||||
to use Cocos Creator solely to develop games on your target platforms. You shall
|
||||
not use Cocos Creator software for developing other software or tools that's
|
||||
used for developing games. You are not granted to publish, distribute,
|
||||
sublicense, and/or sell copies of Cocos Creator.
|
||||
|
||||
The software or tools in this License Agreement are licensed, not sold.
|
||||
Xiamen Yaji Software Co., Ltd. reserves all rights not expressly granted to you.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
****************************************************************************/
|
||||
|
||||
import worker from '@ohos.worker';
|
||||
import cocos from 'libcocos.so';
|
||||
import hilog from '@ohos.hilog';
|
||||
|
||||
import { ContextType } from '../common/Constants';
|
||||
|
||||
import { PortProxy } from '../common/PortProxy';
|
||||
|
||||
|
||||
globalThis.importPolyfill = async function () {
|
||||
await import('../cocos/oh-adapter/sys-ability-polyfill.js');
|
||||
}
|
||||
globalThis.importPolyfill();
|
||||
globalThis.oh = {};
|
||||
|
||||
|
||||
if (!(console as any).assert) {
|
||||
(console as any).assert = function(cond, msg) {
|
||||
if (!cond) {
|
||||
throw new Error(msg);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
const nativeContext = cocos.getContext(ContextType.WORKER_INIT);
|
||||
nativeContext.workerInit();
|
||||
|
||||
const nativeEditBox = cocos.getContext(ContextType.EDITBOX_UTILS);
|
||||
const nativeWebView = cocos.getContext(ContextType.WEBVIEW_UTILS);
|
||||
const appLifecycle = cocos.getContext(ContextType.APP_LIFECYCLE);
|
||||
const nativeVideo = cocos.getContext(ContextType.VIDEO_UTILS);
|
||||
|
||||
let uiPort = new PortProxy(worker.workerPort);
|
||||
|
||||
nativeContext.postMessage = function (msgType: string, msgData: string): void {
|
||||
uiPort.postMessage(msgType, msgData);
|
||||
}
|
||||
|
||||
nativeContext.postSyncMessage = async function (msgType: string, msgData: string): Promise<boolean | string | number> {
|
||||
const result = await uiPort.postSyncMessage(msgType, msgData) as boolean | string | number;
|
||||
return result;
|
||||
}
|
||||
|
||||
// The purpose of this is to avoid being GC
|
||||
nativeContext.setPostMessageFunction.call(nativeContext, nativeContext.postMessage)
|
||||
nativeContext.setPostSyncMessageFunction.call(nativeContext, nativeContext.postSyncMessage)
|
||||
|
||||
globalThis.terminateProcess = function () {
|
||||
uiPort.postMessage("exitGame",0);
|
||||
}
|
||||
|
||||
uiPort._messageHandle = function (e) {
|
||||
var data = e.data;
|
||||
var msg = data.data;
|
||||
|
||||
switch (msg.name) {
|
||||
case "onXCLoad":
|
||||
const renderContext = cocos.getContext(ContextType.NATIVE_RENDER_API);
|
||||
renderContext.nativeEngineInit();
|
||||
|
||||
// @ts-ignore
|
||||
globalThis.oh.postMessage = nativeContext.postMessage;
|
||||
// @ts-ignore
|
||||
globalThis.oh.postSyncMessage = nativeContext.postSyncMessage;
|
||||
renderContext.nativeEngineStart();
|
||||
break;
|
||||
case "onTextInput":
|
||||
nativeEditBox.onTextChange(msg.param);
|
||||
break;
|
||||
case "onComplete":
|
||||
nativeEditBox.onComplete(msg.param);
|
||||
break;
|
||||
case "onConfirm":
|
||||
nativeEditBox.onConfirm(msg.param);
|
||||
break;
|
||||
case "onPageBegin":
|
||||
nativeWebView.shouldStartLoading(msg.param.viewTag, msg.param.url);
|
||||
break;
|
||||
case "onPageEnd":
|
||||
nativeWebView.finishLoading(msg.param.viewTag, msg.param.url);
|
||||
break;
|
||||
case "onErrorReceive":
|
||||
nativeWebView.failLoading(msg.param.viewTag, msg.param.url);
|
||||
break;
|
||||
case "onVideoEvent":
|
||||
nativeVideo.onVideoEvent(JSON.stringify(msg.param));
|
||||
break;
|
||||
case "backPress":
|
||||
appLifecycle.onBackPress();
|
||||
break;
|
||||
default:
|
||||
console.error("cocos worker: message type unknown");
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,58 @@
|
||||
{
|
||||
"module": {
|
||||
"name": "entry",
|
||||
"type": "entry",
|
||||
"description": "$string:entry_desc",
|
||||
"mainElement": "EntryAbility",
|
||||
"deviceTypes": [
|
||||
"default"
|
||||
],
|
||||
"requestPermissions": [
|
||||
{
|
||||
"name": "ohos.permission.INTERNET"
|
||||
},
|
||||
{
|
||||
"name": "ohos.permission.VIBRATE"
|
||||
},
|
||||
{
|
||||
"name": "ohos.permission.GET_NETWORK_INFO"
|
||||
},
|
||||
{
|
||||
"name": "ohos.permission.ACCELEROMETER"
|
||||
},
|
||||
{
|
||||
"name": "ohos.permission.GYROSCOPE"
|
||||
}
|
||||
],
|
||||
"deliveryWithInstall": true,
|
||||
"installationFree": false,
|
||||
"pages": "$profile:main_pages",
|
||||
"abilities": [
|
||||
{
|
||||
"name": "EntryAbility",
|
||||
"srcEntry": "./ets/entryability/EntryAbility.ets",
|
||||
"description": "$string:MainAbility_desc",
|
||||
"orientation": "portrait",
|
||||
"icon": "$media:icon",
|
||||
"label": "$string:MainAbility_label",
|
||||
"startWindowIcon": "$media:icon",
|
||||
"removeMissionAfterTerminate": true,
|
||||
"startWindowBackground": "$color:white",
|
||||
"supportWindowMode": [
|
||||
"fullscreen"
|
||||
],
|
||||
"exported": true,
|
||||
"skills": [
|
||||
{
|
||||
"entities": [
|
||||
"entity.system.home"
|
||||
],
|
||||
"actions": [
|
||||
"action.system.home"
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
2
demo/native/engine/harmonyos-next/entry/src/main/resources/.gitignore
vendored
Executable file
2
demo/native/engine/harmonyos-next/entry/src/main/resources/.gitignore
vendored
Executable file
@@ -0,0 +1,2 @@
|
||||
/rawfile/
|
||||
.DS_Store
|
||||
@@ -0,0 +1,12 @@
|
||||
{
|
||||
"color": [
|
||||
{
|
||||
"name": "white",
|
||||
"value": "#FFFFFF"
|
||||
},
|
||||
{
|
||||
"name": "black",
|
||||
"value": "#000000"
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
{
|
||||
"string": [
|
||||
{
|
||||
"name": "entry_desc",
|
||||
"value": "description"
|
||||
},
|
||||
{
|
||||
"name": "MainAbility_label",
|
||||
"value": "kunpocreator"
|
||||
},
|
||||
{
|
||||
"name": "MainAbility_desc",
|
||||
"value": "description"
|
||||
},
|
||||
{
|
||||
"name": "permissions_label",
|
||||
"value": "label"
|
||||
}
|
||||
]
|
||||
}
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 9.7 KiB |
@@ -0,0 +1,5 @@
|
||||
{
|
||||
"src": [
|
||||
"pages/index"
|
||||
]
|
||||
}
|
||||
22
demo/native/engine/harmonyos-next/hvigor/hvigor-config.json5
Normal file
22
demo/native/engine/harmonyos-next/hvigor/hvigor-config.json5
Normal file
@@ -0,0 +1,22 @@
|
||||
{
|
||||
"modelVersion": "5.0.0",
|
||||
"dependencies": {
|
||||
},
|
||||
"execution": {
|
||||
// "analyze": "normal", /* Define the build analyze mode. Value: [ "normal" | "advanced" | false ]. Default: "normal" */
|
||||
// "daemon": true, /* Enable daemon compilation. Value: [ true | false ]. Default: true */
|
||||
// "incremental": true, /* Enable incremental compilation. Value: [ true | false ]. Default: true */
|
||||
// "parallel": true, /* Enable parallel compilation. Value: [ true | false ]. Default: true */
|
||||
// "typeCheck": false, /* Enable typeCheck. Value: [ true | false ]. Default: false */
|
||||
},
|
||||
"logging": {
|
||||
// "level": "info" /* Define the log level. Value: [ "debug" | "info" | "warn" | "error" ]. Default: "info" */
|
||||
},
|
||||
"debugging": {
|
||||
// "stacktrace": false /* Disable stacktrace compilation. Value: [ true | false ]. Default: false */
|
||||
},
|
||||
"nodeOptions": {
|
||||
// "maxOldSpaceSize": 8192 /* Enable nodeOptions maxOldSpaceSize compilation. Unit M. Used for the daemon process. Default: 8192*/
|
||||
// "exposeGC": true /* Enable to trigger garbage collection explicitly. Default: true*/
|
||||
}
|
||||
}
|
||||
6
demo/native/engine/harmonyos-next/hvigorfile.ts
Normal file
6
demo/native/engine/harmonyos-next/hvigorfile.ts
Normal file
@@ -0,0 +1,6 @@
|
||||
import { appTasks } from '@ohos/hvigor-ohos-plugin';
|
||||
|
||||
export default {
|
||||
system: appTasks, /* Built-in plugin of Hvigor. It cannot be modified. */
|
||||
plugins:[] /* Custom plugin to extend the functionality of Hvigor. */
|
||||
}
|
||||
13
demo/native/engine/harmonyos-next/oh-package.json5
Normal file
13
demo/native/engine/harmonyos-next/oh-package.json5
Normal file
@@ -0,0 +1,13 @@
|
||||
{
|
||||
modelVersion: '5.0.0',
|
||||
devDependencies: {
|
||||
'@ohos/hypium': '1.0.18',
|
||||
'@ohos/hamock': '1.0.0',
|
||||
},
|
||||
author: '',
|
||||
name: 'kunpocreator',
|
||||
description: 'example description',
|
||||
main: '',
|
||||
version: '1.0.0',
|
||||
dependencies: {},
|
||||
}
|
||||
Reference in New Issue
Block a user