diff --git a/sample/EnhanceSampleArk1.2/ConcurrentModule/.gitignore b/sample/EnhanceSampleArk1.2/ConcurrentModule/.gitignore new file mode 100644 index 0000000000000000000000000000000000000000..fbabf771011fe78f9919db0b1195ab6cadffc2b0 --- /dev/null +++ b/sample/EnhanceSampleArk1.2/ConcurrentModule/.gitignore @@ -0,0 +1,11 @@ +/node_modules +/oh_modules +/local.properties +/.idea +**/build +/.hvigor +.cxx +/.clangd +/.clang-format +/.clang-tidy +**/.test \ No newline at end of file diff --git a/sample/EnhanceSampleArk1.2/ConcurrentModule/AppScope/app.json5 b/sample/EnhanceSampleArk1.2/ConcurrentModule/AppScope/app.json5 new file mode 100644 index 0000000000000000000000000000000000000000..5a35ef2b308d10bbbcf9098abdb27a128fdd3cc0 --- /dev/null +++ b/sample/EnhanceSampleArk1.2/ConcurrentModule/AppScope/app.json5 @@ -0,0 +1,25 @@ +/* + * Copyright (c) 2023 Huawei Device 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. + */ + +{ + "app": { + "bundleName": "com.samples.concurrentmodule", + "vendor": "example", + "versionCode": 1000000, + "versionName": "1.0.0", + "icon": "$media:app_icon", + "label": "$string:app_name" + } +} diff --git a/sample/EnhanceSampleArk1.2/ConcurrentModule/AppScope/resources/base/element/string.json b/sample/EnhanceSampleArk1.2/ConcurrentModule/AppScope/resources/base/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..33d5dba8d042bb35eb2f204d772df8ca550489f2 --- /dev/null +++ b/sample/EnhanceSampleArk1.2/ConcurrentModule/AppScope/resources/base/element/string.json @@ -0,0 +1,8 @@ +{ + "string": [ + { + "name": "app_name", + "value": "ConcurrentModule" + } + ] +} diff --git a/sample/EnhanceSampleArk1.2/ConcurrentModule/AppScope/resources/base/media/app_icon.png b/sample/EnhanceSampleArk1.2/ConcurrentModule/AppScope/resources/base/media/app_icon.png new file mode 100644 index 0000000000000000000000000000000000000000..ce307a8827bd75456441ceb57d530e4c8d45d36c Binary files /dev/null and b/sample/EnhanceSampleArk1.2/ConcurrentModule/AppScope/resources/base/media/app_icon.png differ diff --git a/sample/EnhanceSampleArk1.2/ConcurrentModule/README.md b/sample/EnhanceSampleArk1.2/ConcurrentModule/README.md new file mode 100644 index 0000000000000000000000000000000000000000..5c819950eac958f7911f3e31bf1cbadf8c1bd502 --- /dev/null +++ b/sample/EnhanceSampleArk1.2/ConcurrentModule/README.md @@ -0,0 +1,50 @@ +# Starting a Multi-Threaded Task + + +### Introduction + +This sample show how to start worker threads and taskpool threads. + +### Related Concepts + +worker: A worker is an independent thread that runs in parallel with the main thread. The thread that creates the worker is called the hosting thread, while the worker thread itself is called the worker thread. The URL file passed to the worker when it is created is executed in the worker thread, which can handle time-consuming operations but cannot directly manipulate the UI. + +taskpool: A taskpool can be used to create background tasks and manage their execution, cancellation, etc. + +### Required Permissions + +No permissions are required. + +### Usage + +worker: + +1. Select the Worker tab and enter the string to be sorted, separated by commas. + +2. Click the **Sort String** button, which will send the unsorted string to the worker thread for sorting. The sorted string will then be sent back to the main thread for display. + +3. Click the **Clear** button to clear the string. + +taskpool: + +1. Select the Taskpool tab and enter the string to be sorted, separated by commas. + +2.Click the * * String Sort * * button will send the pre sorted string to the worker thread, where string sorting is implemented. Then, the sorted string will be sent to the main thread, which will display the sorted string. + +3. Click the **Execute Immediately** button to execute the task immediately, and the sorted string will be displayed after the task completes. + +4. Click the **Execute After 3s** button to delay the task execution by 3 seconds, and the sorted string will be displayed after the task completes. + +5. Click the **Function Task** button to execute the operation directly, and the sorted string will be displayed after the task completes. Note that the task created using Function Task cannot be cancelled. + +6. Click the **Cancel Task** button to cancel the last unexecuted task. Note that cancellation can only be successful if the number of tasks is greater than the maximum number of threads and the task has started executing. + +7. Click the **Clear** button to clear the string. + +8. Click the **Pass SendableClass** button to transfer SendableClass through memory sharing. + +### Constraints and Limitations + +1. This example only supports running on a standard system. + +2. This example requires DevEco Studio 4.0 Release (Build Version: 4.0.0.600, built on October 17, 2023) to compile and run. diff --git a/sample/EnhanceSampleArk1.2/ConcurrentModule/README_zh.md b/sample/EnhanceSampleArk1.2/ConcurrentModule/README_zh.md new file mode 100644 index 0000000000000000000000000000000000000000..ac511faabaaf46b26f01e1d6fbb105abe0e026e8 --- /dev/null +++ b/sample/EnhanceSampleArk1.2/ConcurrentModule/README_zh.md @@ -0,0 +1,118 @@ +# 多线程任务 + +### 介绍 + +本示例通过[@ohos.taskpool](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/reference/apis-arkts/js-apis-taskpool.md) +和[@ohos.worker](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/reference/apis-arkts/js-apis-worker.md) 接口,展示了如何启动worker线程和taskpool线程。 + +### 效果预览 + +| 首页 | 拷贝文件 | worker页面 | 任务池页面 | +| --------------------------------- | ------------------------------------ | ------------------------------------- | ------------------------------------ | +| ![](screenshots/device/index.jpg) | ![](screenshots/device/copyFile.jpg) | ![](screenshots/device/workerTab.jpg) | ![](screenshots/device/taskpoolTab.jpg) | + +使用说明 + +1. 在主界面,可以点击**字符串排序**和**拷贝文件**按钮进入对应的界面; + +2. 点击**字符串排序**按钮进入多线程界面: + + worker: + + 1. 选择**Worker**页签,输入待排序的字符串,并以逗号分割。 + + 2. 点击**字符串排序**按钮,会将排序前的字符串发送给worker线程,在worker线程实现字符串排序,然后将排序后的字符串发送给主线程,主线程中显示排序后的字符串。 + + 3. 点击**清除**按钮,清除字符串。 + + taskpool: + + 1. 选择**TaskPool**页签,输入待排序的字符串,并以逗号分割。 + + 2. 选择**添加至任务组**按钮,将当前字符串的排序任务添加至任务组。 + + 3. 点击**立即执行**按钮,如之前有添加至任务组操作则任务组执行完成后将排序后的字符串显示出来;如没有上述操作则执行当前任务完成,将排序后的字符串显示出来。 + + 4. 点击**超时3s执行**按钮,任务延迟3s后执行,执行完成后将排序后的字符串显示出来。 + + 5. 点击**函数任务**按钮,直接调用执行操作,执行完成后将排序后的字符串显示出来。需要注意的是,通过**函数任务**创建的task任务不支持取消。 + + 6. 点击**取消任务**按钮,会取消最后一个未执行的task任务。需要注意的是,只有当任务数大于最大线程数且任务未开始执行时才可以取消成功。 + + 7. 点击**清除**按钮,清除字符串。 + + 8. 点击**传递SendableClass**按钮,内存共享方式传递SendableClass。 + +3. 点击**拷贝文件**按钮进入文件拷贝界面: + + 选择需要拷贝的文件,然后点击**拷贝文件**按钮,文件拷贝成功,触发事件日志显示沙箱下文件个数以及显示部分拷贝成功的文件名。 + +### 工程目录 + +``` +entry/src/main/ets/ +|---common +| |---Common.ts // 公用方法,如bufferToString +|   |---Logger.ts             // 日志 +|---component +| |---TaskPoolTab.ets // taskpool页签 +| |---WorkerTab.ets // worker页签 +|---entryability +|---pages +| |---CopyFile.ets // 拷贝文件界面,可选择把文件进行拷贝并显示触发事件后日志 +| |---Index.ets // 首页 +| |---StrSort.ets // worker和taskpool页签都在这里调用 +|---workers +| |---Worker.ts // worker线程 +| |---Worker03.ts // 拷贝文件的worker线程 +``` + +### 具体实现 + +* worker页签的实现在字符串排序页面调用,源码参考[StrSort.ets](entry/src/main/ets/pages/StrSort.ets) + * 字符串排序:通过调用executeWorkerFunc()创建一个worker线程,把待排序字符串发送给worker线程,等worker线程排序完成后再把结果返回。 + * 清除:把字符串输入框和结果都清除。 + +* taskpool页签的实现在字符串排序页面调用,源码参考[StrSort.ets](entry/src/main/ets/pages/StrSort.ets) + * 立即执行:如没有添加至任务组操作,通过调用executeImmediately()创建一个task任务,这个任务是立即执行字符串排序;如先进行了添加至任务组操作,则通过调用executeImmediately()将任务组执行完毕。 + * 超时3s执行:通过调用executeDelay()创建一个task任务,这个任务是延迟3s后执行字符串排序。 + * 函数任务:调用executeFunc()接口,不创建task任务,直接调用taskpool.execute()执行字符串排序。 + * 取消任务:调用cancelTask()接口,取消最后一个未执行的task任务。 + * 清除:把字符串输入框和结果都清除。 + * 添加至任务组:调用addTask()接口,将当前任务添加至任务组。 + +* 内存共享的实现在taskpool页面调用,源码参考[TaskPoolTab.ets](entry/src/main/ets/component/TaskPoolTab.ets) + +* 批量拷贝文件的功能封装在MyWorker,源码参考:[MyWorker.ets](entry/src/main/ets/fileFs/MyWorker.ets) + + * 拷贝文件:在[CopyFile.ets](entry/src/main/ets/pages/CopyFile.ets) + + 中调用MyWorker.WorkToCopyFiles(),在WorkToCopyFiles方法中向worker03线程发消息,并在worker03线程中批量拷贝,拷贝完成后将结果返回。 + +### 相关权限 + +不涉及。 + +### 依赖 + +不涉及。 + +### 约束与限制 + +1.本示例仅支持标准系统上运行, 支持设备:RK3568;。 + +2.本示例为Stage模型,支持API12版本SDK,版本号:5.0.0.21,镜像版本号:OpenHarmony 5.0.0.21。 + +3.本示例需要使用DevEco Studio NEXT Developer Preview1 (Build Version: 4.1.3.501, built on February 5, 2024)及以上版本才可编译运行。 + +### 下载 + +如需单独下载本工程,执行如下命令: + +```` +git init +git config core.sparsecheckout true +echo code/LaunguageBaseClassLibrary/ConcurrentModule/ > .git/info/sparse-checkout +git remote add origin https://gitee.com/openharmony/applications_app_samples.git +git pull origin master +```` \ No newline at end of file diff --git a/sample/EnhanceSampleArk1.2/ConcurrentModule/build-profile.json5 b/sample/EnhanceSampleArk1.2/ConcurrentModule/build-profile.json5 new file mode 100644 index 0000000000000000000000000000000000000000..6755644553d13a6cb28e3537529701e3952c61e6 --- /dev/null +++ b/sample/EnhanceSampleArk1.2/ConcurrentModule/build-profile.json5 @@ -0,0 +1,43 @@ +/* + * Copyright (c) 2024 Huawei Device 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. + */ + +{ + "app": { + "signingConfigs": [], + "products": [ + { + "name": "default", + "signingConfig": "default", + "compileSdkVersion": 12, + "compatibleSdkVersion": 12, + "runtimeOS": "OpenHarmony", + } + ] + }, + "modules": [ + { + "name": "entry", + "srcPath": "./entry", + "targets": [ + { + "name": "default", + "applyToProducts": [ + "default" + ] + } + ] + } + ] +} \ No newline at end of file diff --git a/sample/EnhanceSampleArk1.2/ConcurrentModule/entry/.gitignore b/sample/EnhanceSampleArk1.2/ConcurrentModule/entry/.gitignore new file mode 100644 index 0000000000000000000000000000000000000000..e2713a2779c5a3e0eb879efe6115455592caeea5 --- /dev/null +++ b/sample/EnhanceSampleArk1.2/ConcurrentModule/entry/.gitignore @@ -0,0 +1,6 @@ +/node_modules +/oh_modules +/.preview +/build +/.cxx +/.test \ No newline at end of file diff --git a/sample/EnhanceSampleArk1.2/ConcurrentModule/entry/build-profile.json5 b/sample/EnhanceSampleArk1.2/ConcurrentModule/entry/build-profile.json5 new file mode 100644 index 0000000000000000000000000000000000000000..0d0cc70644830558add6a79f59c8d47815428d92 --- /dev/null +++ b/sample/EnhanceSampleArk1.2/ConcurrentModule/entry/build-profile.json5 @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2024 Huawei Device 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. + */ + +{ + "apiType": 'stageMode', + "buildOption": { + "sourceOption": { + "workers": [ + './src/main/ets/workers/Worker.ts', + "./src/main/ets/workers/WorkerCopy.ts", + ] + } + }, + "targets": [ + { + "name": "default", + }, + { + "name": "ohosTest", + } + ] +} \ No newline at end of file diff --git a/sample/EnhanceSampleArk1.2/ConcurrentModule/entry/hvigorfile.ts b/sample/EnhanceSampleArk1.2/ConcurrentModule/entry/hvigorfile.ts new file mode 100644 index 0000000000000000000000000000000000000000..80e4ec5b81689f238c34614b167a0b9e9c83e8d9 --- /dev/null +++ b/sample/EnhanceSampleArk1.2/ConcurrentModule/entry/hvigorfile.ts @@ -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'; diff --git a/sample/EnhanceSampleArk1.2/ConcurrentModule/entry/oh-package.json5 b/sample/EnhanceSampleArk1.2/ConcurrentModule/entry/oh-package.json5 new file mode 100644 index 0000000000000000000000000000000000000000..3fbe67bbf8193c883bab1ccea7be318bc3a65bdb --- /dev/null +++ b/sample/EnhanceSampleArk1.2/ConcurrentModule/entry/oh-package.json5 @@ -0,0 +1,25 @@ +/* + * Copyright (c) 2023 Huawei Device 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. + */ + +{ + "license": "", + "devDependencies": {}, + "author": "", + "name": "entry", + "description": "Please describe the basic information.", + "main": "", + "version": "1.0.0", + "dependencies": {} +} diff --git a/sample/EnhanceSampleArk1.2/ConcurrentModule/entry/src/main/ets/common/Common.ets b/sample/EnhanceSampleArk1.2/ConcurrentModule/entry/src/main/ets/common/Common.ets new file mode 100644 index 0000000000000000000000000000000000000000..786b9bbae1244bf0d56c68daf9b56727a01e76f2 --- /dev/null +++ b/sample/EnhanceSampleArk1.2/ConcurrentModule/entry/src/main/ets/common/Common.ets @@ -0,0 +1,87 @@ +/* + * Copyright (c) 2023 Shenzhen Kaihong 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 abilityAccessCtrl, { Permissions } from '@ohos.abilityAccessCtrl'; +import { describe, it, expect } from '@ohos/hypium'; +import util from '@ohos.util'; +import Logger from '../common/Logger'; + +const INDEX: number = 2; +const SLEEP_TIME: number = 10; +const RADIX: number = 16; + +export function strToUtf8Bytes(content: string): Array { + const code = encodeURIComponent(content); + let bytes: Array = []; + for (let i = 0; i < code.length; i++) { + const char: string = code.charAt(i); + if (char === '%') { + const hex: string = code.charAt(i + 1) + code.charAt(i + INDEX); + const hexValue: number = Math.floor(Number(hex)); + // const hexValue: number = parseInt(hex, RADIX); + bytes.push(hexValue); + i += INDEX; + } else { + bytes.push(char.charCodeAt(0)); + } + } + return bytes; +} + +export function strToArrayBuffer(text: string): ArrayBuffer { + const bytes: number[] = strToUtf8Bytes(text); + const buffer: ArrayBuffer = new ArrayBuffer(bytes.length); + const bufView: DataView = new DataView(buffer); + for (let i: number = 0; i < bytes.length; i++) { + bufView.setUint8(i, bytes[i]); + } + return buffer; +} + +export async function sleep(times: number): Promise { + if (!times) { + times = SLEEP_TIME; + } + await new Promise((res) => setTimeout(res, times)); +} + +export function randomString(num: number, chars: string): string { + let len = num; + let maxPos = chars.length; + let pwd = ''; + for (let i = 0; i < len; i++) { + pwd += chars.charAt(Math.floor(Math.random() * maxPos)); + } + return pwd; +} + +export function bufferToString(buffer: ArrayBuffer): string { + let textDecoder = new util.TextDecoder('utf-8', { + ignoreBOM: true + }); + let resultPut = textDecoder.decodeWithStream(new Uint8Array(buffer), { + stream: true + }); + return resultPut; +} + +export function stringToBuffer(content: string): Uint8Array { + let textEncoder = new util.TextEncoder('utf-8'); + let resultBuf = textEncoder.encodeInto(content); + return resultBuf; +} + +export { + describe, it, expect, Logger +}; \ No newline at end of file diff --git a/sample/EnhanceSampleArk1.2/ConcurrentModule/entry/src/main/ets/common/Logger.ts b/sample/EnhanceSampleArk1.2/ConcurrentModule/entry/src/main/ets/common/Logger.ts new file mode 100644 index 0000000000000000000000000000000000000000..8a8540de464dd2a2b0cb262fc7d55896b0699694 --- /dev/null +++ b/sample/EnhanceSampleArk1.2/ConcurrentModule/entry/src/main/ets/common/Logger.ts @@ -0,0 +1,56 @@ +/* + * Copyright (c) 2023 Shenzhen Kaihong 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 hilog from '@ohos.hilog'; + +/** + * Common log for all features. + */ +export class Logger { + private domain: number; + private prefix: string; + private format: string = '%{public}s, %{public}s'; + + constructor(prefix: string) { + this.prefix = prefix; + this.domain = 0xFF00; + } + + debug(...args: string[]): void { + hilog.debug(this.domain, this.prefix, this.format, args); + } + + info(...args: string[]): void { + hilog.info(this.domain, this.prefix, this.format, args); + } + + warn(...args: string[]): void { + hilog.warn(this.domain, this.prefix, this.format, args); + } + + error(...args: string[]): void { + hilog.error(this.domain, this.prefix, this.format, args); + } + + fatal(...args: string[]): void { + hilog.fatal(this.domain, this.prefix, this.format, args); + } + + isLoggable(level: number): void { + hilog.isLoggable(this.domain, this.prefix, level); + } +} + +export default new Logger('[Sample_ConcurrentModule]'); + diff --git a/sample/EnhanceSampleArk1.2/ConcurrentModule/entry/src/main/ets/component/SendableTest.ets b/sample/EnhanceSampleArk1.2/ConcurrentModule/entry/src/main/ets/component/SendableTest.ets new file mode 100644 index 0000000000000000000000000000000000000000..aa5c9fa9930a8c167efc7a59c03f7987cff5cc68 --- /dev/null +++ b/sample/EnhanceSampleArk1.2/ConcurrentModule/entry/src/main/ets/component/SendableTest.ets @@ -0,0 +1,27 @@ +/* + * Copyright (c) 2024 Huawei Device 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 { TestA, TestB } from './test' + +@Sendable +export class SendableClass { + data1: TestA = new TestA(); + data2: TestB = new TestB(); + + constructor() { + } +} + +export let a: SendableClass = new SendableClass(); \ No newline at end of file diff --git a/sample/EnhanceSampleArk1.2/ConcurrentModule/entry/src/main/ets/component/TaskPoolTab.ets b/sample/EnhanceSampleArk1.2/ConcurrentModule/entry/src/main/ets/component/TaskPoolTab.ets new file mode 100644 index 0000000000000000000000000000000000000000..3c31ad51e26d94f433349a92ddc87bbaae5cb0fd --- /dev/null +++ b/sample/EnhanceSampleArk1.2/ConcurrentModule/entry/src/main/ets/component/TaskPoolTab.ets @@ -0,0 +1,430 @@ +/* + * Copyright (c) 2024 Huawei Device 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 taskpool from '@ohos.taskpool'; +import utils from '@arkts.utils'; +import stack from '@ohos.util.Stack'; +import { BusinessError } from '@ohos.base'; +import { SendableClass, a } from './SendableTest'; +import { TestA, TestB } from './test' + +@Component +export struct TaskPoolTab { + @State taskPoolOutPutStr: string = ''; + @State taskPoolInPutStr: string = ''; + taskPoolInPutArr: string[] = []; + isTaskGroup : boolean = false; + gStack: stack = new stack(); + taskGroup: taskpool.TaskGroup = new taskpool.TaskGroup(); + + + build() { + Column() { + Text($r('app.string.Text_desc')) + .width("100%") + .height("48vp") + .position({ x: "7%", y: "0" }) + .fontFamily("HarmonyHeiTi-Medium") + .fontSize("16fp") + .fontColor("#182431") + .lineHeight(22) + .fontWeight(500) + + Button() { + Row() { + Image($r('app.media.public_add')) + .width(20) + .height(20) + .margin({ left: 4 }) + Text($r('app.string.Add_task')) + .width("75%") + .height("22") + .fontFamily("HarmonyHeiTi-Medium") + .fontSize("14fp") + .fontColor("#182431") + .textAlign(TextAlign.Center) + .lineHeight(22) + .fontWeight(500) + } + } + .id("addButton") + .height("10vp") + .borderRadius("10vp") + .backgroundColor("#00000000") + .position({ x: "67%", y: "1.5%" }) + .width(135) + .height(35) + .onClick(() => { + this.taskAdd(); + }) + + Button() { + Row() { + Image($r('app.media.empties')) + .width(20) + .height(20) + .margin({ left: 4 }) + Text($r('app.string.Clear_desc')) + .width("35%") + .height("22") + .fontFamily("HarmonyHeiTi-Medium") + .fontSize("14fp") + .fontColor("#182431") + .textAlign(TextAlign.Center) + .lineHeight(22) + .fontWeight(500) + } + } + .id("taskPoolClearButton") + .height("10vp") + .borderRadius("10vp") + .backgroundColor("#00000000") + .position({ x: "71%", y: "31.5%" }) + .width(135) + .height(35) + .onClick(() => { + this.Clear(); + }) + + TextArea({placeholder:$r('app.string.Default_desc'), text:this.taskPoolInPutStr}) + .id("taskPoolInPutTextArea") + .width("93.3%") + .height("139vp") + .position({ x: "3.3%", y: "48vp" }) + .textAlign(TextAlign.Start) + .borderRadius("24vp") + .backgroundColor("#ffffff") + .fontFamily("HarmonyHeiTi") + .fontSize("16fp") + .fontColor("#182431") + .fontWeight(400) + .padding({ top: "8vp" , left: "16vp", right: "16vp", bottom: "21vp" }) + .onChange((value: string) => { + this.taskPoolInPutStr = value; + this.taskPoolInPutArr = this.taskPoolInPutStr.trim().split(','); + this.taskPoolOutPutStr = ''; + }) + + Text($r('app.string.Result_desc')) + .width("50%") + .height("48") + .position({ x: "7%", y: "187vp" }) + .fontFamily("HarmonyHeiTi-Medium") + .fontSize("16fp") + .fontColor("#182431") + .lineHeight(22) + .fontWeight(500) + + Scroll() { + Text(this.taskPoolOutPutStr) + .id("taskPoolOutPutText") + .fontFamily("HarmonyHeiTi") + .fontSize("16fp") + .fontColor("#182431") + .fontWeight(400) + .padding({ top: "8vp" , left: "16vp", right: "16vp", bottom: "21vp" }) + } + .id("taskPoolOutPutScroll") + .width("93.3%") + .height("139vp") + .position({ x: "3.3%", y: "235vp" }) + .borderRadius("24vp") + .backgroundColor("#ffffff") + .align(Alignment.TopStart) + + GridRow({columns: 4, + gutter: { x: 12, y: 12 }, + breakpoints: { value: ["360vp", "480vp"]}, + direction: GridRowDirection.Row}) { + GridCol ({ span: 2, offset: 0 }) { + Button() { + Text($r('app.string.Execute_After_3s_desc')) + .width("100%") + .height("22") + .fontFamily("HarmonyHeiTi-Medium") + .fontSize("16fp") + .fontColor("#007DFF") + .textAlign(TextAlign.Center) + .lineHeight(22) + .fontWeight(500) + } + .id("exeDelayButton") + .height("40vp") + .borderRadius("20vp") + .backgroundColor("rgba(24,36,49,0.05)") + .onClick(()=>{ + this.executeDelay(); + }) + } + + GridCol ({ span: 2, offset: 0 }) { + Button() { + Text($r('app.string.Execute_Immediately_desc')) + .width("100%") + .height("22") + .fontFamily("HarmonyHeiTi-Medium") + .fontSize("16fp") + .fontColor("#FFFFFF") + .textAlign(TextAlign.Center) + .lineHeight(22) + .fontWeight(500) + } + .id("exeImmButton") + .height("40vp") + .borderRadius("20vp") + .backgroundColor("#007DFF") + .onClick(()=>{ + if(this.isTaskGroup == true) { + this.TaskGroupExec(); + } else { + this.executeImmediately(); + } + }) + } + + GridCol ({ span: 2, offset: 0 }) { + Button() { + Text($r('app.string.Function_Task_desc')) + .width("100%") + .height("22") + .fontFamily("HarmonyHeiTi-Medium") + .fontSize("16fp") + .fontColor("#007DFF") + .textAlign(TextAlign.Center) + .lineHeight(22) + .fontWeight(500) + } + .id("exeFunctionButton") + .height("40vp") + .borderRadius("20vp") + .backgroundColor("rgba(24,36,49,0.05)") + .onClick(()=>{ + this.executeFunc(); + }) + } + + GridCol ({ span: 2, offset: 0 }) { + Button() { + Text($r('app.string.Cancel_Task_desc')) + .width("100%") + .height("22") + .fontFamily("HarmonyHeiTi-Medium") + .fontSize("16fp") + .fontColor("#FFFFFF") + .textAlign(TextAlign.Center) + .lineHeight(22) + .fontWeight(500) + } + .id("exeCancelButton") + .height("40vp") + .borderRadius("20vp") + .backgroundColor("#007DFF") + .onClick(()=>{ + this.cancelTask(); + }) + } + + GridCol ({ span: 4, offset: 0 }) { + Button() { + Text($r('app.string.transferSendableClass')) + .width("100%") + .height("22") + .fontFamily("HarmonyHeiTi-Medium") + .fontSize("16fp") + .fontColor("#007DFF") + .textAlign(TextAlign.Center) + .lineHeight(22) + .fontWeight(500) + } + .id("sendableButton") + .height("40vp") + .borderRadius("20vp") + .backgroundColor("rgba(24,36,49,0.05)") + .onClick(()=>{ + this.sendableTask(); + }) + } + } + .width("100%") + .height("168vp") + .position({ x: "0", y: "73%" }) + .padding({ left: "25vp", right: "25vp" }) + } + .width("100%") + .height("100%") + .justifyContent(FlexAlign.Center) + } + + async executeImmediately(): Promise { + if (!this.taskPoolInPutStr.length) { + this.taskPoolOutPutStr = "No input for the string to be sorted.\n"; + return; + } + let task = new taskpool.Task(strSort,this.taskPoolInPutArr); + this.gStack.push(task); + try { + let result: taskpool.Task = await taskpool.execute(task) as taskpool.Task; + this.taskPoolOutPutStr += "Task executed successfully: "+ result.toString()+ "\n"; + } catch(e) { + this.taskPoolOutPutStr += "Task executed failed: "+ (e as BusinessError).toString()+ "\n"; + } + this.gStack.pop(); + } + + async executeDelay(): Promise { + if (!this.taskPoolInPutStr.length) { + this.taskPoolOutPutStr = "No input for the string to be sorted.\n"; + return; + } + let task = new taskpool.Task(strSortDelay,this.taskPoolInPutArr); + this.gStack.push(task); + try { + let result: string[] = await taskpool.execute(task) as string[]; + this.taskPoolOutPutStr += "Task executed successfully: "+ result.toString()+ "\n"; + } catch(e) { + this.taskPoolOutPutStr += "Task executed failed: "+ (e as BusinessError).toString() + "\n"; + } + this.gStack.pop(); + } + + async executeFunc(): Promise { + if (!this.taskPoolInPutStr.length) { + this.taskPoolOutPutStr = "No input for the string to be sorted.\n"; + return; + } + try { + let result: string[] = await taskpool.execute(strSort,this.taskPoolInPutArr) as string[]; + this.taskPoolOutPutStr += "Task executed successfully: "+ result.toString()+ "\n"; + } catch(e) { + this.taskPoolOutPutStr += "Task executed failed: "+ (e as BusinessError).toString()+ "\n"; + } + } + + async taskAdd(): Promise { + if (!this.taskPoolInPutStr.length) { + this.taskPoolOutPutStr = "No input for the string to be sorted.\n"; + return; + } + try { + let task: taskpool.Task = new taskpool.Task(strSort, this.taskPoolInPutArr); + this.taskGroup.addTask(task); + this.isTaskGroup = true; + this.taskPoolOutPutStr += "TaskGroup addTask successfully.\n"; + } catch (e) { + this.taskPoolOutPutStr += "TaskGroup addTask failed: "+ (e as BusinessError).toString()+ "\n"; + } + } + + Clear(): void { + this.taskPoolInPutStr = ''; + this.taskPoolInPutArr = this.taskPoolInPutStr.trim().split(','); + this.taskPoolOutPutStr = ''; + } + + async TaskGroupExec(): Promise { + try { + let res: string[] = await taskpool.execute(this.taskGroup) as string[]; + this.taskPoolOutPutStr += "TaskGroup executed successfully: "+ res.toString()+ "\n"; + } catch(e) { + this.taskPoolOutPutStr += "TaskGroup executed failed: "+ (e as BusinessError).toString()+ "\n"; + } + this.isTaskGroup = false; + } + + async cancelTask(): Promise { + if (this.gStack.isEmpty()) { + this.taskPoolOutPutStr += "The current task queue has no cancellable tasks."+ "\n"; + } else { + let task: taskpool.Task = this.gStack.peek() as taskpool.Task; + try { + taskpool.cancel(task); + this.taskPoolOutPutStr += "Task canceled successfully."+ "\n"; + this.gStack.pop(); + } catch(e) { + this.taskPoolOutPutStr += "Task canceled failed: "+ (e as BusinessError).toString()+ "\n"; + } + } + } + + async sendableTask(): Promise { + // 定义主线程异步锁sendableTask_lock + let lock: utils.locks.AsyncLock = utils.locks.AsyncLock.request("sendableTask_lock"); + let count: number = 0; + lock.lockAsync(async () => { + // 主线程调用实例a.data1的方法setCount、getCount + a.data1.setCount(111); + count = await a.data1.getCount(); + console.info("this data1 count is: " + await a.data1.getCount()); + }) + let task: taskpool.Task = new taskpool.Task(createSendableData, a); + try { + await taskpool.execute(task); + this.taskPoolOutPutStr += "sendableTask execute successfully."+ "\n"; + // 访问子线程返回的实例a中的各个属性 + this.taskPoolOutPutStr += "Sendable data TestA v1 is: " + a.data1.v1 + "\n"; + this.taskPoolOutPutStr += "Sendable data TestA v2 is: " + a.data1.v2 + "\n"; + this.taskPoolOutPutStr += "Sendable data TestA v3 is: " + a.data1.v3 + "\n"; + this.taskPoolOutPutStr += "Sendable data TestA count is: " + count + "\n"; + this.taskPoolOutPutStr += "Sendable data TestB v1 length is: " + a.data2.v1.length + "\n"; + this.taskPoolOutPutStr += "Sendable data TestB v2 has key: " + a.data2.v2.has(100) + "\n"; + this.taskPoolOutPutStr += "Sendable data TestB v3 size is: " + a.data2.v3.size + "\n"; + } catch(e) { + this.taskPoolOutPutStr += "Task execute failed: "+ (e as BusinessError).toString()+ "\n"; + } + } +} + +@Concurrent +function strSort(inPutArr: string[]) : string[] { + let newArr: string[] = inPutArr.sort(); + return newArr; +} + +@Concurrent +function strSortDelay(inPutArr: string[]) : string[] { + let start: number= new Date().getTime(); + while (new Date().getTime() - start < 3000) { + continue; + } + let newArr: string[] = inPutArr.sort(); + return newArr; +} + +@Concurrent +async function createSendableData(data: SendableClass): Promise { + // 定义taskpool子线程异步锁sendableTask_lock + let lock: utils.locks.AsyncLock = utils.locks.AsyncLock.request("sendableTask_lock"); + + // 构造TestA、TestB实例,组装SendableClass实例 + let d1: TestA = new TestA(); + d1.v1 = 1010; + d1.v2 = "aaa"; + d1.v3 = true; + let d2: TestB = new TestB(); + d2.v2.set(100, "aaa"); + for(let i = 0;i < 1000;i++) { + d2.v1.push(i); + } + d2.v3.add("hello"); + + lock.lockAsync(async () => { + // 子线程调用实例方法setCount、getCount + await d1.setCount(10); + console.info("taskpool: this data1 count is: " + await d1.getCount()); + }) + + data.data1 = d1; + data.data2 = d2; +} \ No newline at end of file diff --git a/sample/EnhanceSampleArk1.2/ConcurrentModule/entry/src/main/ets/component/WorkerTab.ets b/sample/EnhanceSampleArk1.2/ConcurrentModule/entry/src/main/ets/component/WorkerTab.ets new file mode 100644 index 0000000000000000000000000000000000000000..1f8c1885a6e492ab63779bce308f6bb76b21f9b6 --- /dev/null +++ b/sample/EnhanceSampleArk1.2/ConcurrentModule/entry/src/main/ets/component/WorkerTab.ets @@ -0,0 +1,168 @@ +/* + * Copyright (c) 2023 Huawei Device 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 worker from '@ohos.worker'; + +@Component +export struct WorkerTab { + @State jsWorkerOutPutStr: string = ''; + @State jsWorkerInPutStr: string = ''; + jsWorkerInPutArr: string[] = []; + isDone: boolean = false; + myWorker: worker.ThreadWorker = new worker.ThreadWorker("entry/ets/workers/Worker.ts"); + + build() { + Column() { + Text($r('app.string.Text_desc')) + .width("100%") + .height("48vp") + .position({ x: "7%", y: "0vp" }) + .fontFamily("HarmonyHeiTi-Medium") + .fontSize("16fp") + .fontColor("#182431") + .lineHeight(22) + .fontWeight(500) + + TextArea({text:this.jsWorkerInPutStr}) + .id("jsWorkerInPutTextArea") + .width("93.3%") + .height("139vp") + .position({ x: "3.3%", y: "48vp" }) + .textAlign(TextAlign.Start) + .fontFamily("HarmonyHeiTi") + .fontSize("16fp") + .fontColor("#182431") + .fontWeight(400) + .padding({ top: "8vp" , left: "16vp", right: "16vp", bottom: "21vp" }) + .borderRadius("24vp") + .backgroundColor("#ffffff") + .onChange((value: string) => { + this.jsWorkerInPutStr = value; + this.jsWorkerInPutArr = value.trim().split(','); + this.jsWorkerOutPutStr = ''; + }) + + Text($r('app.string.Result_desc')) + .width("100%") + .height("48") + .position({ x: "7%", y: "187vp" }) + .fontFamily("HarmonyHeiTi-Medium") + .fontSize("16fp") + .fontColor("#182431") + .lineHeight(22) + .fontWeight(500) + + Scroll() { + Text(this.jsWorkerOutPutStr) + .id("jsWorkerOutPutText") + .fontFamily("HarmonyHeiTi") + .fontSize("16fp") + .fontColor("#182431") + .fontWeight(400) + .padding({ top: "8vp" , left: "16vp", right: "16vp", bottom: "21vp" }) + } + .id("jsWorkerOutPutScroll") + .width("93.3%") + .height("139vp") + .position({ x: "3.3%", y: "235vp" }) + .borderRadius("24vp") + .backgroundColor("#ffffff") + .align(Alignment.TopStart) + + GridRow({columns: 4, + gutter: { x: 12, y: 12 }, + breakpoints: { value: ["360vp", "480vp"]}, + direction: GridRowDirection.Row}) { + GridCol ({ span: 2, offset: 0 }) { + Button() { + Text($r('app.string.Clear_desc')) + .width("100%") + .height("22") + .fontFamily("HarmonyHeiTi-Medium") + .fontSize("16fp") + .fontColor("#007DFF") + .textAlign(TextAlign.Center) + .lineHeight(22) + .fontWeight(500) + } + .id("workerClearButton") + .height("40vp") + .borderRadius("20vp") + .backgroundColor("rgba(24,36,49,0.05)") + .onClick(()=>{ + this.jsWorkerInPutStr = ''; + this.jsWorkerOutPutStr = ''; + }) + } + + GridCol ({ span: 2, offset: 0 }) { + Button() { + Text($r('app.string.SortString_desc')) + .width("100%") + .height("22") + .fontFamily("HarmonyHeiTi-Medium") + .fontSize("16fp") + .fontColor("#FFFFFF") + .textAlign(TextAlign.Center) + .lineHeight(22) + .fontWeight(500) + } + .id("workerStrSort") + .height("40vp") + .borderRadius("20vp") + .backgroundColor("#007DFF") + .onClick(()=>{ + this.executeWorkerFunc(this.jsWorkerInPutArr); + }) + } + } + .width("100%") + .height("40vp") + .position({ x: "0", y: "555vp" }) + .padding({ left: "24vp", right: "24vp" }) + } + .width("100%") + .height("100%") + .justifyContent(FlexAlign.Center) + } + + async executeWorkerFunc(inPutArr: string[]): Promise { + if (!this.jsWorkerInPutStr.length) { + this.jsWorkerOutPutStr = "No input for the string to be sorted.\n"; + return; + } + this.myWorker.postMessage(inPutArr); + let strFlag = false; + let outPutStr = ''; + this.myWorker.onmessage = (e) => { + outPutStr = e.data.toString(); + strFlag = true; + } + while(!strFlag) { + await promiseCase(); + } + this.jsWorkerOutPutStr = outPutStr; + } +} + +function promiseCase() : Promise { + let p: Promise = new Promise((resolve: Function, reject: Function) => { + setTimeout(() => { + resolve(1) + }, 100) + }).then(undefined, () => { + }) + return p; +} \ No newline at end of file diff --git a/sample/EnhanceSampleArk1.2/ConcurrentModule/entry/src/main/ets/component/test.ets b/sample/EnhanceSampleArk1.2/ConcurrentModule/entry/src/main/ets/component/test.ets new file mode 100644 index 0000000000000000000000000000000000000000..f27d71873c78fe271c664eb7b49aa40e0e479bf9 --- /dev/null +++ b/sample/EnhanceSampleArk1.2/ConcurrentModule/entry/src/main/ets/component/test.ets @@ -0,0 +1,50 @@ +/* + * Copyright (c) 2024 Huawei Device 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 collections from '@arkts.collections'; +import utils from '@arkts.utils'; +@Sendable +export class TestA { + v1: number = 0; + v2: string = ""; + v3: boolean = false; + count_: number = 0; + async getCount(): Promise { + let lock: utils.locks.AsyncLock = utils.locks.AsyncLock.request("lock_1"); + return lock.lockAsync(() => { + return this.count_; + }) + } + async setCount(count: number) { + let lock: utils.locks.AsyncLock = utils.locks.AsyncLock.request("lock_1"); + await lock.lockAsync(() => { + this.count_ = count; + }) + } + + constructor() { + } +} + + +@Sendable +export class TestB { + v1: collections.Array = new collections.Array(); + v2: collections.Map = new collections.Map(); + v3: collections.Set = new collections.Set(); + + constructor() { + } +} \ No newline at end of file diff --git a/sample/EnhanceSampleArk1.2/ConcurrentModule/entry/src/main/ets/entryability/EntryAbility.ets b/sample/EnhanceSampleArk1.2/ConcurrentModule/entry/src/main/ets/entryability/EntryAbility.ets new file mode 100644 index 0000000000000000000000000000000000000000..22bae535fd56fad168b3875ba4ec833593cf49e3 --- /dev/null +++ b/sample/EnhanceSampleArk1.2/ConcurrentModule/entry/src/main/ets/entryability/EntryAbility.ets @@ -0,0 +1,113 @@ +/* + * Copyright (c) 2023 Huawei Device 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 UIAbility from '@ohos.app.ability.UIAbility'; +import hilog from '@ohos.hilog'; +import window from '@ohos.window'; +import Want from '@ohos.app.ability.Want'; +import AbilityConstant from '@ohos.app.ability.AbilityConstant'; +import { BusinessError } from '@ohos.base'; + + +export default class EntryAbility extends UIAbility { + onCreate(want: Want, launchParam: AbilityConstant.LaunchParam) { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); + } + + onDestroy() { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage) { + // Main window is created, set main page for this ability + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); + let filesDir = this.context.filesDir; + AppStorage.SetOrCreate('sanBoxFileDir', filesDir); + this.getResourceStr(); + windowStage.loadContent('pages/Index', (err, data) => { + if (err.code) { + hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); + return; + } + hilog.info(0x0000, 'testTag', 'Succeeded in loading the content. Data: %{public}s', JSON.stringify(data) ?? ''); + }); + } + + getResourceStr(): void { + try { + this.context.resourceManager.getStringValue($r('app.string.workerLog1').id) + .then(value => { + AppStorage.SetOrCreate('copyFileLog1', value); + hilog.info(0x0000, 'testTag', '%{public}s', 'getStringValue value' + value); + }) + .catch((error: BusinessError) => { + hilog.error(0x0000, 'testTag', 'Failed to getStringValue. Cause: %{public}s', error ?? ''); + }); + + this.context.resourceManager.getStringValue($r('app.string.workerLog2').id) + .then(value => { + AppStorage.SetOrCreate('copyFileLog2', value); + hilog.info(0x0000, 'testTag', '%{public}s', 'getStringValue value' + value); + }) + .catch((error: BusinessError) => { + hilog.error(0x0000, 'testTag', 'Failed to getStringValue. Cause: %{public}s', error ?? ''); + }); + + this.context.resourceManager.getStringValue($r('app.string.workerLog3').id) + .then(value => { + AppStorage.SetOrCreate('copyFileLog3', value); + hilog.info(0x0000, 'testTag', '%{public}s', 'getStringValue value' + value); + }) + .catch((error: BusinessError) => { + hilog.error(0x0000, 'testTag', 'Failed to getStringValue. Cause: %{public}s', error ?? ''); + }); + + this.context.resourceManager.getStringValue($r('app.string.workerLog4').id) + .then(value => { + AppStorage.SetOrCreate('copyFileLog4', value); + hilog.info(0x0000, 'testTag', '%{public}s', 'getStringValue value' + value); + }) + .catch((error: BusinessError) => { + hilog.error(0x0000, 'testTag', 'Failed to getStringValue. Cause: %{public}s', error ?? ''); + }); + + this.context.resourceManager.getStringValue($r('app.string.workerLog5').id) + .then(value => { + AppStorage.SetOrCreate('copyFileLog5', value); + hilog.info(0x0000, 'testTag', '%{public}s', 'getStringValue value' + value); + }) + .catch((error: BusinessError) => { + hilog.error(0x0000, 'testTag', 'Failed to getStringValue. Cause: %{public}s', error ?? ''); + }); + } catch (error) { + hilog.error(0x0000, 'testTag', 'callback getStringValue failed. Cause: %{public}s', error.message ?? ''); + } + } + + onWindowStageDestroy() { + // Main window is destroyed, release UI related resources + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); + } + + onForeground() { + // Ability has brought to foreground + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); + } + + onBackground() { + // Ability has back to background + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); + } +} diff --git a/sample/EnhanceSampleArk1.2/ConcurrentModule/entry/src/main/ets/fileFs/MyWorker.ets b/sample/EnhanceSampleArk1.2/ConcurrentModule/entry/src/main/ets/fileFs/MyWorker.ets new file mode 100644 index 0000000000000000000000000000000000000000..bddb9f83f7b0ddaeb4c6d7ef0950c180d4d1bda1 --- /dev/null +++ b/sample/EnhanceSampleArk1.2/ConcurrentModule/entry/src/main/ets/fileFs/MyWorker.ets @@ -0,0 +1,198 @@ +/* + * Copyright (c) 2023 Shenzhen Kaihong 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 worker from '@ohos.worker'; +import fs from '@ohos.file.fs'; +import { Logger, sleep } from '../common/Common'; +import { BusinessError } from '@ohos.base'; + +const CONTENT = 'hello world'; +const TAG: string = '[ConcurrentModule].[MyWorker]'; +const FILE_NUM: number = 200; // 预制200 1m以下的小文件 +const FILE_NUMBER: number = 9; // 文件1-9命名时加上0 +const LIST_FILE_TWO: number = 2; // 显示拷贝成功后的第二个文件名 +const SLEEP_TIME: number = 100; // 睡眠时间 + +let workerInstance: worker.ThreadWorker | null = null; +let fileFlag: boolean = false; + +export default class MyFile { + public baseDir: string | undefined = ''; + public filesCount: number = 0; + private flag: boolean = false; + public realFileNames: Array = []; + + constructor() { + this.baseDir = AppStorage.Get('sanBoxFileDir'); + } + + readyFileToFileFs(): void { + let fileFsDir = this.baseDir + '/fileFs'; + try { + if (!fs.accessSync(fileFsDir)) { + fs.mkdirSync(fileFsDir); + } + Logger.info(TAG, 'readyFileToFileFs successful'); + } catch (e) { + Logger.error(TAG, `readyFileToFileFs has failed for: {message: ${(e as BusinessError).message}, code: ${(e as BusinessError).code}}`); + } + } + + // worker file + readyFilesToWorker(): void { + let content = CONTENT + CONTENT + new Date() + '\n'; + let workerDir = this.baseDir + '/workerDir'; + + try { + if (!fs.accessSync(workerDir)) { + fs.mkdirSync(workerDir); + } + Logger.info(TAG, 'readyFilesToWorker dpath = ' + workerDir); + for (let i = 0; i < FILE_NUM; i++) { + let myFile = ''; + if (i < FILE_NUMBER) { + myFile = workerDir + `/TestFile0${i + 1}.txt`; + } else { + myFile = workerDir + `/TestFile${i + 1}.txt`; + } + Logger.info(TAG, 'readyFilesToWorker myFile = ' + myFile); + let file = fs.openSync(myFile, fs.OpenMode.CREATE | fs.OpenMode.READ_WRITE); + fs.writeSync(file.fd, content); + fs.closeSync(file); + } + Logger.info(TAG, 'readyFilesToWorker successful'); + } catch (e) { + Logger.error(TAG, `readyFilesToWorker has failed for: {message: ${(e as BusinessError).message}, code: ${(e as BusinessError).code}}`); + } + } + + async workToCopyFiles(files: Array, filePath: string): Promise { + try { + Logger.info(TAG, 'WorkCreator start to create worker'); + let destPath = filePath; + Logger.info(TAG, 'Workerets destPath ' + destPath); + if (!fs.accessSync(destPath)) { + fs.mkdirSync(destPath); + } + if (fs.accessSync(destPath)) { + fs.listFile(destPath).then((filenames) => { + Logger.info(TAG, 'listFile succeed'); + for (let i = 0; i < filenames.length; i++) { + Logger.info(TAG, 'Workerets fileName: ' + filenames[i]); + } + }).catch((err: BusinessError) => { + Logger.info(TAG, 'list file failed with error message: ' + err.message + ', error code: ' + err.code); + }); + } + if (files !== null) { + this.realFileNames.length = 0; + for (let i = 0; i < files.length; i++) { + if (files[i] === 'deletedTag') { + continue; + } + this.realFileNames.push(files[i]); + } + } + let count = this.realFileNames.length; + for (let j = 0; j < count; j++) { + Logger.info(TAG, 'workToCopyFiles this.realFileNames = ' + this.realFileNames[j]); + } + workerInstance = new worker.ThreadWorker('entry/ets/workers/WorkerCopy.ts'); + if (this.realFileNames !== null) { + let srcPath = this.baseDir + '/workerDir'; + workerInstance.postMessage({ + srcDir: srcPath, + destDir: destPath, + fileNames: this.realFileNames + }); + } + + workerInstance.onexit = (code): void => { + Logger.info(TAG, `workerInstance::onexit has been exit ${code}`); + }; + workerInstance.onerror = (err): void => { + Logger.info(TAG, `workerInstance::onerror has errors: ${JSON.stringify(err)}`); + }; + workerInstance.onmessageerror = (event): void => { + Logger.info(TAG, `workerInstance::onmessageerror has errors: ${JSON.stringify(event)}`); + }; + workerInstance.onmessage = (message): void => { + Logger.info(TAG, `workerInstance::onmessage receive data: ${JSON.stringify(message.data)}`); + if (message.data.hasOwnProperty('count')) { + Logger.info(TAG, `workerInstance::onmessage receive data length = ${message.data.count}`); + this.filesCount = message.data.count; + fileFlag = message.data.strFlag; + this.flag = true; + let fileName1: string | null = null; + let fileName2: string | null = null; + for (let i: number = 0; i < message.data.listFileNames.length; i++) { + Logger.info(TAG, `Worker workerInstance::onmessage receive listFileNames: ${message.data.listFileNames[i]}`); + } + if (message.data.listFileNames[0] !== undefined && message.data.listFileNames[1] !== undefined && message.data.listFileNames[LIST_FILE_TWO] === undefined) { + fileName1 = message.data.listFileNames[0] + '、'; + fileName2 = message.data.listFileNames[1]; + } else if (message.data.listFileNames[0] !== undefined && message.data.listFileNames[1] === undefined) { + fileName1 = message.data.listFileNames[0]; + fileName2 = ''; + } else { + fileName1 = message.data.listFileNames[0] + '、'; + let copyFileLog: string | undefined = AppStorage.Get('copyFileLog5'); + fileName2 = message.data.listFileNames[1] + copyFileLog; + } + AppStorage.SetOrCreate('fileListName1', fileName1); + AppStorage.SetOrCreate('fileListName2', fileName2); + let copyFileLog3: string | undefined = AppStorage.Get('copyFileLog3'); + let copyFileLog4: string | undefined = AppStorage.Get('copyFileLog4'); + let copyFileLog = '2、' + fileName1 + fileName2 + copyFileLog3 + 'copy' + copyFileLog4; + if (fileName1 !== 'undefined、') { + AppStorage.SetOrCreate('copyFileShowLog', copyFileLog); + } else { + AppStorage.SetOrCreate('copyFileShowLog', $r('app.string.workerLogChooseFile')); + } + Logger.info(TAG, `Worker workerInstance::onmessage receive count: ${JSON.stringify(this.filesCount)}`); + } + if (this.filesCount !== 0) { + AppStorage.SetOrCreate('fileNumber', JSON.stringify(this.filesCount)); + } else { + AppStorage.SetOrCreate('fileNumber', '0'); + AppStorage.SetOrCreate('fileListName1', ''); + AppStorage.SetOrCreate('fileListName2', ''); + } + Logger.info(TAG, 'workerInstance::onmessage Finish to process data from WorkerCopy.ts'); + workerInstance?.terminate(); + }; + while (!fileFlag) { + await sleep(SLEEP_TIME); + } + } catch (e) { + Logger.error(TAG, `Worker WorkCreator error package: message: ${(e as BusinessError).message}, code: ${(e as BusinessError).code}`); + } + } + + deleteCopyFile(filePath: string): void { + Logger.info(TAG, 'deleteCopyFile destCopyFilePath = ' + filePath); + try { + if (fs.accessSync(filePath)) { + let isDirectory = fs.statSync(filePath).isDirectory(); + if (isDirectory) { + fs.rmdirSync(filePath); + fs.mkdirSync(filePath); + } + } + } catch (e) { + Logger.error(TAG, `delete workerCopyFile error package: message: ${(e as BusinessError).message}, code: ${(e as BusinessError).code}`); + } + } +} \ No newline at end of file diff --git a/sample/EnhanceSampleArk1.2/ConcurrentModule/entry/src/main/ets/pages/CopyFile.ets b/sample/EnhanceSampleArk1.2/ConcurrentModule/entry/src/main/ets/pages/CopyFile.ets new file mode 100644 index 0000000000000000000000000000000000000000..f30e1dfcf6d2bfcd8dd657c8c88de52de9292b00 --- /dev/null +++ b/sample/EnhanceSampleArk1.2/ConcurrentModule/entry/src/main/ets/pages/CopyFile.ets @@ -0,0 +1,253 @@ +/* + * Copyright (c) 2023 Shenzhen Kaihong 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 MyWorker from '../fileFs/MyWorker'; +import common from '@ohos.app.ability.common'; +import fs from '@ohos.file.fs'; +import router from '@ohos.router'; +import { Logger } from '../common/Common'; + +const TAG: string = '[ConcurrentModule].[CopyFile]'; +@Entry +@Component +struct Watcher { + @State message: Resource = $r('app.string.copyFileText'); + @State myContext: common.UIAbilityContext = getContext(this) as common.UIAbilityContext; + @State filePathSize: Array = []; + @State showFilePath: Array = []; + @State eventFilePath: Array = []; + @State fileListNames: Array = []; + @StorageLink('fileNumber') fileNum: string = '0'; + @StorageLink('fileListName1') fileListName1: string = ' '; + @StorageLink('fileListName2') fileListName2: string = ''; + @StorageLink('copyFileLog1') copyFileLog1: string = ''; + @StorageLink('copyFileLog2') copyFileLog2: string = ''; + @StorageLink('copyFileLog3') copyFileLog3: string = ''; + @StorageLink('copyFileLog4') copyFileLog4: string = ''; + @StorageLink('copyFileShowLog') copyFileShowLog: string = ''; + myWorker: MyWorker = new MyWorker(); + scroller: Scroller = new Scroller(); + public dirPath: string = ''; + public baseDir: string | undefined = AppStorage.Get('sanBoxFileDir'); + + onPageShow() { + this.myWorker.readyFilesToWorker(); + let filePathDir = this.baseDir + '/workerDir'; + let filenames = fs.listFileSync(filePathDir); + Logger.info(TAG, 'listFile succeed'); + for (let i = 0; i < filenames.length; i++) { + Logger.info(TAG, 'filename: %s', filenames[i]); + this.showFilePath[i] = filenames[i]; + let filePath = filePathDir + '/' + filenames[i] + this.filePathSize[i] = fs.statSync(filePath).size; + } + this.dirPath = this.baseDir + '/workerCopy'; + if (!fs.accessSync(this.dirPath)) { + fs.mkdirSync(this.dirPath); + } + } + + onPageHide() { + this.dirPath = this.baseDir + '/workerCopy'; + let isDirectory = fs.statSync(this.dirPath).isDirectory(); + if (isDirectory) { + fs.rmdirSync(this.dirPath); + AppStorage.SetOrCreate('fileNumber', '0'); + AppStorage.SetOrCreate('fileListName1', ''); + AppStorage.SetOrCreate('fileListName2', ''); + AppStorage.SetOrCreate('copyFileShowLog', ''); + } + let filePathDir = this.baseDir + '/workerDir'; + let isDir = fs.statSync(filePathDir).isDirectory(); + if (isDir) { + fs.rmdirSync(filePathDir); + } + } + + build() { + Scroll(this.scroller) { + Row() { + Column() { + Row() { + Image($r('app.media.ic_back')) + .id('backIndex2') + .width(20) + .height(18) + .align(Alignment.Start) + .margin({ top: 13, bottom: 15, left: 26, right: 18 }) + .onClick(() => { + router.back(); + }) + Text(this.message) + .fontSize(20) + .fontColor('#182431') + .textAlign(TextAlign.Start) + .lineHeight(28) + .fontWeight(700) + .margin({ top: 13, bottom: 15 }) + } + .width('100%') + .height(56) + .backgroundColor('#f1f3f5') + .align(Alignment.Start) + + Flex({ direction: FlexDirection.Column }) { + + Column() { + Row() { + Row() { + Text($r('app.string.workerTitleText')) + .fontSize(14) + .margin({ top: 19.5, bottom: 9.5 }) + .lineHeight(19) + .width(176) + .fontColor('#182431') + .fontWeight(500) + .textAlign(TextAlign.Start) + } + .width('100%') + .backgroundColor('#f1f3f5') + } + .margin({ left: 24, right: 52 }) + .height(48) + .backgroundColor('#f1f3f5') + + Column() { + List({ space: 12, initialIndex: 0 }) { + ForEach(this.showFilePath, (item: string, index: number) => { + ListItem() { + Row() { + Text(item) + .fontSize(16) + .fontColor('#182431') + .width('86%') + .lineHeight(22) + .textAlign(TextAlign.Start) + .fontWeight(500) + .margin({ left: 12 }) + .borderRadius(10) + .backgroundColor(0xFFFFFF) + Row() { + Checkbox() + .select(false) + .id('checkbox' + index) + .width(20) + .height(20) + .margin({ right: 12 }) + .selectedColor('#007DFF') + .borderRadius(4) + .onChange((value: boolean) => { + Logger.info(TAG, 'Checkbox1 change is' + value); + if (value) { + Logger.info(TAG, 'Workerets Checkbox1 index ' + index + ' is true'); + this.eventFilePath.push(this.showFilePath[index]); + } else { + for (let i: number = 0; i < this.eventFilePath.length; i++) { + if (this.eventFilePath[i] === this.showFilePath[index]) { + this.eventFilePath[i] = 'deletedTag'; + } + } + } + }) + } + .id('row' + index) + .width('9%') + } + .borderRadius(20) + .margin({ left: 12, right: 12 }) + .height(56) + .backgroundColor(0xFFFFFF) + } + .id('listItem') + }, (item: string) => item) + } + .id('listWorkerFile') + .alignListItem(ListItemAlign.Center) + .scrollBar(BarState.Auto) + } + .backgroundColor('#f1f3f5') + .height(436) + .align(Alignment.Center) + + Column() { + Row() { + Text($r('app.string.logTitle')) + .fontSize(14) + .fontColor('#182431') + .textAlign(TextAlign.Start) + .lineHeight(19) + .fontWeight(500) + .margin({ top: 19.5, left: 24 }) + .width(176) + } + .width('100%') + .align(Alignment.Start) + + Column() { + Column() { + Text(this.copyFileLog1 + this.fileNum + this.copyFileLog2) + .fontSize(16) + .fontColor('#182431') + .fontWeight(400) + .width('100%') + Text(this.copyFileShowLog) + .fontSize(16) + .id("copyFileLog") + .fontColor('#182431') + .fontWeight(400) + .width('100%') + } + .margin({ top: 8, left: 12, right: 12, bottom: 8 }) + .height(64) + } + .borderRadius(20) + .height(80) + .margin({ top: 9.5, left: 16, right: 16 }) + .backgroundColor('#ffffff') + + Row({ space: 1 }) { + Column() { + Button($r('app.string.copyFileText')) + .fontSize(16) + .width(312) + .height(40) + .fontColor('#FFFFFF') + .fontWeight(500) + .id('copyFile') + .onClick(async () => { + this.myWorker.deleteCopyFile(this.dirPath); + await this.myWorker.workToCopyFiles(this.eventFilePath, this.dirPath); + }) + } + .width('100%') + .align(Alignment.End) + } + .align(Alignment.Center) + .width('100%') + .margin({ top: 24, left: 24, right: 24, bottom: 24 }) + } + .backgroundColor('#f1f3f5') + .width('100%') + .height(216) + } + .backgroundColor('#f1f3f5') + .width('100%') + } + .width('100%') + } + .height('100%') + } + } + } +} \ No newline at end of file diff --git a/sample/EnhanceSampleArk1.2/ConcurrentModule/entry/src/main/ets/pages/Index.ets b/sample/EnhanceSampleArk1.2/ConcurrentModule/entry/src/main/ets/pages/Index.ets new file mode 100644 index 0000000000000000000000000000000000000000..aa691681ca5f53a898d97c766426e3423cadc63e --- /dev/null +++ b/sample/EnhanceSampleArk1.2/ConcurrentModule/entry/src/main/ets/pages/Index.ets @@ -0,0 +1,71 @@ +/* + * Copyright (c) 2023 Shenzhen Kaihong 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 router from '@ohos.router'; +import { Logger } from '../common/Common'; +import fs from '@ohos.file.fs'; + +@Entry +@Component +struct Index { + scroller: Scroller = new Scroller(); + + build() { + Scroll(this.scroller) { + Row() { + Column() { + Button($r('app.string.strSortText')) + .fontSize(16) + .fontColor('#FFFFFF') + .fontWeight(500) + .padding(15) + .margin(10) + .width('300') + .height('60') + .id('strSort') + .onClick(() => { + router.pushUrl({ + url: 'pages/StrSort', + params: { + data: 'message', + } + }, router.RouterMode.Standard); + }) + + Button($r('app.string.copyFileText')) + .fontSize(16) + .fontColor('#FFFFFF') + .fontWeight(500) + .padding(15) + .margin(10) + .width('300') + .height('60') + .id('fileCopy') + .onClick(() => { + router.pushUrl({ + url: 'pages/CopyFile', + params: { + data3: 'message', + } + }, router.RouterMode.Standard); + }) + } + .width('100%') + } + .backgroundColor('#f1f3f5') + .height('100%') + } + } +} \ No newline at end of file diff --git a/sample/EnhanceSampleArk1.2/ConcurrentModule/entry/src/main/ets/pages/StrSort.ets b/sample/EnhanceSampleArk1.2/ConcurrentModule/entry/src/main/ets/pages/StrSort.ets new file mode 100644 index 0000000000000000000000000000000000000000..d1bf96725c8d58a7fd20a6245b5e15b3ab50e8f7 --- /dev/null +++ b/sample/EnhanceSampleArk1.2/ConcurrentModule/entry/src/main/ets/pages/StrSort.ets @@ -0,0 +1,134 @@ +/* + * Copyright (c) 2023 Huawei Device 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 { WorkerTab } from '../component/WorkerTab'; +import { TaskPoolTab } from '../component/TaskPoolTab'; + +@Entry +@Component +struct Index { + private controller: TabsController = new TabsController(); + @State index: number = 0; + + @Builder tabJsWorker() { + Column() { + Text("Worker") + .width("57vp") + .height("22vp") + .position({ x: "0vp", y: "17vp" }) + .fontFamily("HarmonyHeiTi-Medium") + .fontSize(16) + .fontColor(this.index === 0 ? "#007DFF" : "#182431") + .textAlign(TextAlign.Center) + .lineHeight(22) + .fontWeight(this.index === 0 ? 500 : 400) + .opacity(this.index === 0 ? 1 : 0.6) + Line() + .width("57vp") + .height("2vp") + .position({ x: "0", y: "46vp" }) + .backgroundColor(this.index === 0 ? "#007DFF" : "linear-gradient(269deg,rgba(0,0,0,0.00)%,#FFFFFF 10%)") + } + .id("tabJsWorker") + .width("100%") + .height("100%") + .position({ x: "65%", y: "0vp" }) + .onClick(() => { + this.index = 0; + this.controller.changeIndex(this.index); + }) + } + + @Builder tabTaskPool() { + Column() { + Text("TaskPool") + .width("68vp") + .height("22vp") + .position({ x: "10vp", y: "17vp" }) + .fontFamily("HarmonyHeiTi-Medium") + .fontSize(16) + .fontColor(this.index === 1 ? "#007DFF" : "#182431") + .textAlign(TextAlign.Center) + .lineHeight(22) + .fontWeight(this.index === 1 ? 500 : 400) + .opacity(this.index === 1 ? 1 : 0.6) + Line() + .width("68vp") + .height("2vp") + .position({ x: "10vp", y: "46vp" }) + .backgroundColor(this.index === 1 ? "#007DFF" : "linear-gradient(269deg,rgba(0,0,0,0.00)%,#FFFFFF 10%)") + } + .id("tabTaskPool") + .height("100%") + .width("100%") + .position({ x: "4%", y: "0" }) + .onClick(() => { + this.index = 1; + this.controller.changeIndex(this.index); + }) + } + + build() { + Row() { + Column() { + Text("ConcurrentModule") + .width("100%") + .height("41vp") + .position({ x: "7%", y: "31vp" }) + .fontColor("#182431") + .fontSize("30fp") + .fontFamily("HarmonyHeiTi-Bold") + .lineHeight(41) + .fontWeight(700) + .textAlign(TextAlign.Start) + + Tabs({ + barPosition: BarPosition.Start, + controller: this.controller + }) { + TabContent() { + WorkerTab(); + } + .width("100%") + .height("100%") + .tabBar(this.tabJsWorker) + + TabContent() { + TaskPoolTab(); + } + .width("100%") + .height("100%") + .tabBar(this.tabTaskPool) + } + .width("100%") + .height("696vp") + .barWidth("100%") + .barHeight("56vp") + .position({ x: "0vp", y: "80vp" }) + .padding({ bottom: "24vp" }) + .backgroundImage("linear-gradient(269deg,rgba(0,0,0,0.00)%,#FFFFFF 10%)") + .barMode(BarMode.Fixed) + .onChange((index: number) => { + this.index = index; + }) + } + .backgroundColor("#f1f3f5") + .width("100%") + .height("100%") + } + .width("100%") + .height("100%") + } +} diff --git a/sample/EnhanceSampleArk1.2/ConcurrentModule/entry/src/main/ets/workers/Worker.ts b/sample/EnhanceSampleArk1.2/ConcurrentModule/entry/src/main/ets/workers/Worker.ts new file mode 100644 index 0000000000000000000000000000000000000000..9548948a9de16697c9907e46001d6351a25d2109 --- /dev/null +++ b/sample/EnhanceSampleArk1.2/ConcurrentModule/entry/src/main/ets/workers/Worker.ts @@ -0,0 +1,54 @@ +/* + * Copyright (c) 2023 Huawei Device 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 worker, { ThreadWorkerGlobalScope, MessageEvents, ErrorEvent } from '@ohos.worker'; + +let workerPort : ThreadWorkerGlobalScope = worker.workerPort; + +/** + * Defines the event handler to be called when the worker thread receives a message sent by the host thread. + * The event handler is executed in the worker thread. + * + * @param e message data + */ +workerPort.onmessage = function(e : MessageEvents) { + let oldArr = e.data; + let newArr = strSort(oldArr); + workerPort.postMessage(newArr); +} + +/** + * Defines the event handler to be called when the worker receives a message that cannot be deserialized. + * The event handler is executed in the worker thread. + * + * @param e message data + */ +workerPort.onmessageerror = function(e : MessageEvents) { + console.log("worker::error = " + e.data); +} + +/** + * Defines the event handler to be called when an exception occurs during worker execution. + * The event handler is executed in the worker thread. + * + * @param e error message + */ +workerPort.onerror = function(e : ErrorEvent) { +} + +function strSort(inPutArr) : string { + let newArr = inPutArr.sort(); + return newArr; +} \ No newline at end of file diff --git a/sample/EnhanceSampleArk1.2/ConcurrentModule/entry/src/main/ets/workers/WorkerCopy.ts b/sample/EnhanceSampleArk1.2/ConcurrentModule/entry/src/main/ets/workers/WorkerCopy.ts new file mode 100644 index 0000000000000000000000000000000000000000..a5dc11386b3ffd5b7236582b3d9d51c8a5d1223f --- /dev/null +++ b/sample/EnhanceSampleArk1.2/ConcurrentModule/entry/src/main/ets/workers/WorkerCopy.ts @@ -0,0 +1,67 @@ +/* + * Copyright (c) 2023 Shenzhen Kaihong 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 worker from '@ohos.worker'; +import type { ThreadWorkerGlobalScope } from '@ohos.worker'; +import Logger from '../common/Logger'; +import fs from '@ohos.file.fs'; + +const workerPort: ThreadWorkerGlobalScope = worker.workerPort; +const TAG: string = '[ConcurrentModule].[WorkerCopy]'; + +workerPort.onmessage = (message): void => { + let srcPath: string = null; + let destPath: string = null; + let fileNames: string = message.data.fileNames; + for (let i = 0; i < fileNames.length; i++) { + srcPath = message.data.srcDir + '/' + fileNames[i]; + Logger.info(TAG, ' srcPath ' + srcPath); + destPath = message.data.destDir + '/' + fileNames[i]; + Logger.info(TAG, ' destPath ' + destPath); + try { + fs.copyFileSync(srcPath, destPath); + let countTest = fs.listFileSync(message.data.destDir).length; + Logger.info(TAG, `Worker workerInstance::onmessage receive countTest: ${countTest}`); + } catch (e) { + Logger.error(TAG, 'WorkerCopy::copyFile has failed for: ' + JSON.stringify(e)); + } + } + let listFileNames = []; + listFileNames.length = 0; + try { + let count = fs.listFileSync(message.data.destDir).length; + let listFiles = fs.listFileSync(message.data.destDir); + Logger.info(TAG, 'listFile succeed'); + for (let i = 0; i < listFiles.length; i++) { + listFileNames[i] = listFiles[i]; + Logger.info(TAG, `Worker workerInstance::onmessage receive listFileNames: ${listFileNames[i]}`); + } + workerPort.postMessage({ + count: count, + strFlag: true, + listFileNames: listFileNames + }); + Logger.info(TAG, 'WorkerCopy::onmessage thread post message successfully'); + } catch (e) { + Logger.error(TAG, 'WorkerCopy::onmessage has failed for: ' + JSON.stringify(e)); + } +}; + +workerPort.onmessageerror = async (message): Promise => { + Logger.error(TAG, 'WorkerCopy::onmessageerror : ' + JSON.stringify(message)); +}; + +workerPort.onerror = (e): void => { + Logger.error(TAG, 'WorkerCopy::onerror : ' + JSON.stringify(e)); +}; \ No newline at end of file diff --git a/sample/EnhanceSampleArk1.2/ConcurrentModule/entry/src/main/module.json5 b/sample/EnhanceSampleArk1.2/ConcurrentModule/entry/src/main/module.json5 new file mode 100644 index 0000000000000000000000000000000000000000..e42c2962094ce21b5300a2e19e780aa0b1b84002 --- /dev/null +++ b/sample/EnhanceSampleArk1.2/ConcurrentModule/entry/src/main/module.json5 @@ -0,0 +1,52 @@ +/* + * Copyright (c) 2023 Huawei Device 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. + */ + +{ + "module": { + "name": "entry", + "type": "entry", + "description": "$string:module_desc", + "mainElement": "EntryAbility", + "deviceTypes": [ + "default", + "tablet" + ], + "deliveryWithInstall": true, + "installationFree": false, + "pages": "$profile:main_pages", + "abilities": [ + { + "name": "EntryAbility", + "srcEntry": "./ets/entryability/EntryAbility.ets", + "description": "$string:EntryAbility_desc", + "icon": "$media:icon", + "label": "$string:EntryAbility_label", + "startWindowIcon": "$media:icon", + "startWindowBackground": "$color:start_window_background", + "exported": true, + "skills": [ + { + "entities": [ + "entity.system.home" + ], + "actions": [ + "action.system.home" + ] + } + ] + } + ] + } +} \ No newline at end of file diff --git a/sample/EnhanceSampleArk1.2/ConcurrentModule/entry/src/main/resources/base/element/color.json b/sample/EnhanceSampleArk1.2/ConcurrentModule/entry/src/main/resources/base/element/color.json new file mode 100644 index 0000000000000000000000000000000000000000..3c712962da3c2751c2b9ddb53559afcbd2b54a02 --- /dev/null +++ b/sample/EnhanceSampleArk1.2/ConcurrentModule/entry/src/main/resources/base/element/color.json @@ -0,0 +1,8 @@ +{ + "color": [ + { + "name": "start_window_background", + "value": "#FFFFFF" + } + ] +} \ No newline at end of file diff --git a/sample/EnhanceSampleArk1.2/ConcurrentModule/entry/src/main/resources/base/element/string.json b/sample/EnhanceSampleArk1.2/ConcurrentModule/entry/src/main/resources/base/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..98b1870edddbe8c42819f9e32cb4208b316af431 --- /dev/null +++ b/sample/EnhanceSampleArk1.2/ConcurrentModule/entry/src/main/resources/base/element/string.json @@ -0,0 +1,100 @@ +{ + "string": [ + { + "name": "module_desc", + "value": "module description" + }, + { + "name": "EntryAbility_desc", + "value": "description" + }, + { + "name": "EntryAbility_label", + "value": "ConcurrentModule" + }, + { + "name": "Text_desc", + "value": "enter the string to be sorted, separated by commas" + }, + { + "name": "Default_desc", + "value": "enter the string to be sorted" + }, + { + "name": "Add_task", + "value": "add task to taskGroup" + }, + { + "name": "Result_desc", + "value": "execution result" + }, + { + "name": "SortString_desc", + "value": "Sort String" + }, + { + "name": "Clear_desc", + "value": "Clear" + }, + { + "name": "Execute_After_3s_desc", + "value": "Execute After 3s" + }, + { + "name": "Execute_Immediately_desc", + "value": "Execute Immediately" + }, + { + "name": "Function_Task_desc", + "value": "Function Task" + }, + { + "name": "Cancel_Task_desc", + "value": "Cancel Task" + }, + { + "name": "strSortText", + "value": "String Sort Text" + }, + { + "name": "copyFileText", + "value": "CopyFile Text" + }, + { + "name": "workerTitleText", + "value": "Worker Title Text" + }, + { + "name": "logTitle", + "value": "Log Title" + }, + { + "name": "workerLog1", + "value": "Sandbox File Number" + }, + { + "name": "workerLog2", + "value": "Sandbox File Number Unit" + }, + { + "name": "workerLog3", + "value": "File" + }, + { + "name": "workerLog4", + "value": "Finish" + }, + { + "name": "workerLog5", + "value": "And So On" + }, + { + "name": "workerLogChooseFile", + "value": "Please select a file" + }, + { + "name": "transferSendableClass", + "value": "transfer SendableClass" + } + ] +} \ No newline at end of file diff --git a/sample/EnhanceSampleArk1.2/ConcurrentModule/entry/src/main/resources/base/media/c_Checkbox_Selected.svg b/sample/EnhanceSampleArk1.2/ConcurrentModule/entry/src/main/resources/base/media/c_Checkbox_Selected.svg new file mode 100644 index 0000000000000000000000000000000000000000..a2c0c722e4db8e7b707829dad10bbb64ea8b6f11 --- /dev/null +++ b/sample/EnhanceSampleArk1.2/ConcurrentModule/entry/src/main/resources/base/media/c_Checkbox_Selected.svg @@ -0,0 +1,8 @@ + + + c_Checkbox_Selected + + + + + \ No newline at end of file diff --git a/sample/EnhanceSampleArk1.2/ConcurrentModule/entry/src/main/resources/base/media/empties.svg b/sample/EnhanceSampleArk1.2/ConcurrentModule/entry/src/main/resources/base/media/empties.svg new file mode 100644 index 0000000000000000000000000000000000000000..1509066912a8861e0ecb17b578d8cb2a9d0b580f --- /dev/null +++ b/sample/EnhanceSampleArk1.2/ConcurrentModule/entry/src/main/resources/base/media/empties.svg @@ -0,0 +1,24 @@ + + + empties + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/sample/EnhanceSampleArk1.2/ConcurrentModule/entry/src/main/resources/base/media/ic_Checkbox_Selected_Enabled.svg b/sample/EnhanceSampleArk1.2/ConcurrentModule/entry/src/main/resources/base/media/ic_Checkbox_Selected_Enabled.svg new file mode 100644 index 0000000000000000000000000000000000000000..229a81975188a62f603c99934645dc64f15a887c --- /dev/null +++ b/sample/EnhanceSampleArk1.2/ConcurrentModule/entry/src/main/resources/base/media/ic_Checkbox_Selected_Enabled.svg @@ -0,0 +1,24 @@ + + + ic_Checkbox_Selected_Enabled + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/sample/EnhanceSampleArk1.2/ConcurrentModule/entry/src/main/resources/base/media/ic_back.svg b/sample/EnhanceSampleArk1.2/ConcurrentModule/entry/src/main/resources/base/media/ic_back.svg new file mode 100644 index 0000000000000000000000000000000000000000..5e82eaf2dd24d2e4b33bd767d27946d0de4a2c5c --- /dev/null +++ b/sample/EnhanceSampleArk1.2/ConcurrentModule/entry/src/main/resources/base/media/ic_back.svg @@ -0,0 +1,13 @@ + + + ic_back + + + + + + + + + + \ No newline at end of file diff --git a/sample/EnhanceSampleArk1.2/ConcurrentModule/entry/src/main/resources/base/media/ic_backward.svg b/sample/EnhanceSampleArk1.2/ConcurrentModule/entry/src/main/resources/base/media/ic_backward.svg new file mode 100644 index 0000000000000000000000000000000000000000..837626b4444b3ddd05e93a1d2476085e7a6c5058 --- /dev/null +++ b/sample/EnhanceSampleArk1.2/ConcurrentModule/entry/src/main/resources/base/media/ic_backward.svg @@ -0,0 +1,7 @@ + + + ic_backward + + + + \ No newline at end of file diff --git a/sample/EnhanceSampleArk1.2/ConcurrentModule/entry/src/main/resources/base/media/ic_backward_right.svg b/sample/EnhanceSampleArk1.2/ConcurrentModule/entry/src/main/resources/base/media/ic_backward_right.svg new file mode 100644 index 0000000000000000000000000000000000000000..ffa29203496ea78a28aa31de42d94b4703355c17 --- /dev/null +++ b/sample/EnhanceSampleArk1.2/ConcurrentModule/entry/src/main/resources/base/media/ic_backward_right.svg @@ -0,0 +1,7 @@ + + + ic_backward_right + + + + \ No newline at end of file diff --git a/sample/EnhanceSampleArk1.2/ConcurrentModule/entry/src/main/resources/base/media/ic_delete.svg b/sample/EnhanceSampleArk1.2/ConcurrentModule/entry/src/main/resources/base/media/ic_delete.svg new file mode 100644 index 0000000000000000000000000000000000000000..45ff3a08efface1fc7df4978b328ddb2b3aa0511 --- /dev/null +++ b/sample/EnhanceSampleArk1.2/ConcurrentModule/entry/src/main/resources/base/media/ic_delete.svg @@ -0,0 +1,14 @@ + + + ic_delete + + + + + + + + + + + \ No newline at end of file diff --git a/sample/EnhanceSampleArk1.2/ConcurrentModule/entry/src/main/resources/base/media/ic_edit.svg b/sample/EnhanceSampleArk1.2/ConcurrentModule/entry/src/main/resources/base/media/ic_edit.svg new file mode 100644 index 0000000000000000000000000000000000000000..c844d3c530a40bd9d6f45f253eb094c856be279d --- /dev/null +++ b/sample/EnhanceSampleArk1.2/ConcurrentModule/entry/src/main/resources/base/media/ic_edit.svg @@ -0,0 +1,14 @@ + + + ic_edit + + + + + + + + + + + \ No newline at end of file diff --git a/sample/EnhanceSampleArk1.2/ConcurrentModule/entry/src/main/resources/base/media/ic_ok.svg b/sample/EnhanceSampleArk1.2/ConcurrentModule/entry/src/main/resources/base/media/ic_ok.svg new file mode 100644 index 0000000000000000000000000000000000000000..480dfdfc7c060116b9305f0f38e28453cb5b5239 --- /dev/null +++ b/sample/EnhanceSampleArk1.2/ConcurrentModule/entry/src/main/resources/base/media/ic_ok.svg @@ -0,0 +1,13 @@ + + + ic_ok + + + + + + + + + + \ No newline at end of file diff --git a/sample/EnhanceSampleArk1.2/ConcurrentModule/entry/src/main/resources/base/media/icon.png b/sample/EnhanceSampleArk1.2/ConcurrentModule/entry/src/main/resources/base/media/icon.png new file mode 100644 index 0000000000000000000000000000000000000000..ce307a8827bd75456441ceb57d530e4c8d45d36c Binary files /dev/null and b/sample/EnhanceSampleArk1.2/ConcurrentModule/entry/src/main/resources/base/media/icon.png differ diff --git a/sample/EnhanceSampleArk1.2/ConcurrentModule/entry/src/main/resources/base/media/public_add.svg b/sample/EnhanceSampleArk1.2/ConcurrentModule/entry/src/main/resources/base/media/public_add.svg new file mode 100644 index 0000000000000000000000000000000000000000..8536bf7af1ace815e983dceb9746f6768bc71510 --- /dev/null +++ b/sample/EnhanceSampleArk1.2/ConcurrentModule/entry/src/main/resources/base/media/public_add.svg @@ -0,0 +1,24 @@ + + + public_add + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/sample/EnhanceSampleArk1.2/ConcurrentModule/entry/src/main/resources/base/profile/main_pages.json b/sample/EnhanceSampleArk1.2/ConcurrentModule/entry/src/main/resources/base/profile/main_pages.json new file mode 100644 index 0000000000000000000000000000000000000000..315cfa0bea445df106069d7007b9af11f6794af1 --- /dev/null +++ b/sample/EnhanceSampleArk1.2/ConcurrentModule/entry/src/main/resources/base/profile/main_pages.json @@ -0,0 +1,7 @@ +{ + "src": [ + "pages/StrSort", + "pages/Index", + "pages/CopyFile" + ] +} diff --git a/sample/EnhanceSampleArk1.2/ConcurrentModule/entry/src/main/resources/en_US/element/string.json b/sample/EnhanceSampleArk1.2/ConcurrentModule/entry/src/main/resources/en_US/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..986ceb7f467876d96b92009baba466f39b073a6a --- /dev/null +++ b/sample/EnhanceSampleArk1.2/ConcurrentModule/entry/src/main/resources/en_US/element/string.json @@ -0,0 +1,100 @@ +{ + "string": [ + { + "name": "module_desc", + "value": "module description" + }, + { + "name": "EntryAbility_desc", + "value": "description" + }, + { + "name": "EntryAbility_label", + "value": "ConcurrentModule" + }, + { + "name": "Text_desc", + "value": "enter the string to be sorted" + }, + { + "name": "Default_desc", + "value": "enter the string to be sorted, separated by commas" + }, + { + "name": "Add_task", + "value": "add task to taskGroup" + }, + { + "name": "Result_desc", + "value": "execution result" + }, + { + "name": "SortString_desc", + "value": "Sort String" + }, + { + "name": "Clear_desc", + "value": "Clear" + }, + { + "name": "Execute_After_3s_desc", + "value": "Execute After 3s" + }, + { + "name": "Execute_Immediately_desc", + "value": "Execute Immediately" + }, + { + "name": "Function_Task_desc", + "value": "Function Task" + }, + { + "name": "Cancel_Task_desc", + "value": "Cancel Task" + }, + { + "name": "strSortText", + "value": "String Sort Text" + }, + { + "name": "copyFileText", + "value": "CopyFile Text" + }, + { + "name": "workerTitleText", + "value": "Worker Title Text" + }, + { + "name": "logTitle", + "value": "Log Title" + }, + { + "name": "workerLog1", + "value": "Sandbox File Number" + }, + { + "name": "workerLog2", + "value": "Sandbox File Number Unit" + }, + { + "name": "workerLog3", + "value": "File" + }, + { + "name": "workerLog4", + "value": "Finish" + }, + { + "name": "workerLog5", + "value": "And So On" + }, + { + "name": "workerLogChooseFile", + "value": "Please select a file" + }, + { + "name": "transferSendableClass", + "value": "transfer SendableClass" + } + ] +} \ No newline at end of file diff --git a/sample/EnhanceSampleArk1.2/ConcurrentModule/entry/src/main/resources/zh_CN/element/string.json b/sample/EnhanceSampleArk1.2/ConcurrentModule/entry/src/main/resources/zh_CN/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..741184c6cc41415c82eab7bad89cd87980b4e6fa --- /dev/null +++ b/sample/EnhanceSampleArk1.2/ConcurrentModule/entry/src/main/resources/zh_CN/element/string.json @@ -0,0 +1,100 @@ +{ + "string": [ + { + "name": "module_desc", + "value": "模块描述" + }, + { + "name": "EntryAbility_desc", + "value": "description" + }, + { + "name": "EntryAbility_label", + "value": "ConcurrentModule" + }, + { + "name": "Text_desc", + "value": "请输入待排序字符串" + }, + { + "name": "Default_desc", + "value": "请输入待排序字符串,并以逗号分割" + }, + { + "name": "Result_desc", + "value": "执行结果" + }, + { + "name": "Add_task", + "value": "添加至任务组" + }, + { + "name": "SortString_desc", + "value": "字符串排序" + }, + { + "name": "Clear_desc", + "value": "清除" + }, + { + "name": "Execute_After_3s_desc", + "value": "超时3s执行" + }, + { + "name": "Execute_Immediately_desc", + "value": "立即执行" + }, + { + "name": "Function_Task_desc", + "value": "函数任务" + }, + { + "name": "Cancel_Task_desc", + "value": "取消任务" + }, + { + "name": "strSortText", + "value": "字符串排序" + }, + { + "name": "copyFileText", + "value": "拷贝文件" + }, + { + "name": "workerTitleText", + "value": "公共目录下文件列表" + }, + { + "name": "logTitle", + "value": "触发事件后日志" + }, + { + "name": "workerLog1", + "value": "1、沙箱目录文件个数" + }, + { + "name": "workerLog2", + "value": "个" + }, + { + "name": "workerLog3", + "value": "文件" + }, + { + "name": "workerLog4", + "value": "完成" + }, + { + "name": "workerLog5", + "value": "等" + }, + { + "name": "workerLogChooseFile", + "value": "2、请选择文件" + }, + { + "name": "transferSendableClass", + "value": "传递SendableClass" + } + ] +} \ No newline at end of file diff --git a/sample/EnhanceSampleArk1.2/ConcurrentModule/entry/src/ohosTest/ets/TestRunner/OpenHarmonyTestRunner.ts b/sample/EnhanceSampleArk1.2/ConcurrentModule/entry/src/ohosTest/ets/TestRunner/OpenHarmonyTestRunner.ts new file mode 100644 index 0000000000000000000000000000000000000000..27f45c4eb4ed33b4f21d13a8b9ca04b5a67a53db --- /dev/null +++ b/sample/EnhanceSampleArk1.2/ConcurrentModule/entry/src/ohosTest/ets/TestRunner/OpenHarmonyTestRunner.ts @@ -0,0 +1,63 @@ +/* + * Copyright (c) 2023 Huawei Device 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 hilog from '@ohos.hilog'; +import TestRunner from '@ohos.application.testRunner'; +import AbilityDelegatorRegistry from '@ohos.app.ability.abilityDelegatorRegistry'; + +var abilityDelegator = undefined; +var abilityDelegatorArguments = undefined; + +async function onAbilityCreateCallback() { + hilog.info(0x0000, 'testTag', '%{public}s', 'onAbilityCreateCallback'); +} + +async function addAbilityMonitorCallback(err: any) { + hilog.info(0x0000, 'testTag', 'addAbilityMonitorCallback : %{public}s', JSON.stringify(err) ?? ''); +} + +export default class OpenHarmonyTestRunner implements TestRunner { + constructor() { + } + + onPrepare() { + hilog.info(0x0000, 'testTag', '%{public}s', 'OpenHarmonyTestRunner OnPrepare '); + } + + async onRun() { + hilog.info(0x0000, 'testTag', '%{public}s', 'OpenHarmonyTestRunner onRun run'); + abilityDelegatorArguments = AbilityDelegatorRegistry.getArguments(); + abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator(); + var testAbilityName = abilityDelegatorArguments.bundleName + '.TestAbility'; + let lMonitor = { + abilityName: testAbilityName, + onAbilityCreate: onAbilityCreateCallback, + }; + abilityDelegator.addAbilityMonitor(lMonitor, addAbilityMonitorCallback); + var cmd = 'aa start -d 0 -a TestAbility' + ' -b ' + abilityDelegatorArguments.bundleName; + var debug = abilityDelegatorArguments.parameters['-D']; + if (debug == 'true') { + cmd += ' -D'; + } + hilog.info(0x0000, 'testTag', 'cmd : %{public}s', cmd); + abilityDelegator.executeShellCommand(cmd, + (err: any, d: any) => { + hilog.info(0x0000, 'testTag', 'executeShellCommand : err : %{public}s', JSON.stringify(err) ?? ''); + hilog.info(0x0000, 'testTag', 'executeShellCommand : data : %{public}s', d.stdResult ?? ''); + hilog.info(0x0000, 'testTag', 'executeShellCommand : data : %{public}s', d.exitCode ?? ''); + }) + hilog.info(0x0000, 'testTag', '%{public}s', 'OpenHarmonyTestRunner onRun end'); + } +} \ No newline at end of file diff --git a/sample/EnhanceSampleArk1.2/ConcurrentModule/entry/src/ohosTest/ets/test/Ability.test.ets b/sample/EnhanceSampleArk1.2/ConcurrentModule/entry/src/ohosTest/ets/test/Ability.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..796059c0156e8cf6aa0a6d31aebe4a6c939cca1f --- /dev/null +++ b/sample/EnhanceSampleArk1.2/ConcurrentModule/entry/src/ohosTest/ets/test/Ability.test.ets @@ -0,0 +1,432 @@ +/* + * Copyright (c) 2024 Huawei Device 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 hilog from '@ohos.hilog'; +import { describe, it, expect } from '@ohos/hypium'; +import { Driver, ON} from '@ohos.UiTest'; +import AbilityDelegatorRegistry from '@ohos.app.ability.abilityDelegatorRegistry'; +import worker from '@ohos.worker'; +import taskpool from '@ohos.taskpool'; +import { SendableClass} from '../../../main/ets/component/SendableTest'; +import { TestA, TestB } from '../../../main/ets/component/test'; +import { BusinessError } from '@kit.BasicServicesKit'; +import utils from '@arkts.utils'; + +const TAG = '[Sample_JSConcurrent]'; +const DOMAIN = 0xF811; +const BUNDLE = 'JSConcurrent_'; + +let abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator() +let resourceManager = abilityDelegator.getAppContext().resourceManager; +// 资源本地化 +async function getResourceString(resource: Resource): Promise { + let manage = abilityDelegator.getAppContext().resourceManager + let text = await manage.getStringValue(resource) + return text +} + +function promiseCase() : Promise { + let p: Promise = new Promise((resolve: Function, reject: Function) => { + setTimeout(() => { + resolve(1) + }, 100) + }).then(undefined, () => { + }) + return p; +} + +async function executeWorkerFunc(inPutArr: string[]): Promise { + let myWorker: worker.ThreadWorker = new worker.ThreadWorker("entry/ets/workers/Worker.ts"); + myWorker.postMessage(inPutArr); + let outPutStr: string = ''; + let strFlag = false; + myWorker.onmessage = (e) => { + outPutStr = e.data.toString(); + strFlag = true; + } + while(!strFlag) { + await promiseCase(); + } + return outPutStr; + +} + +@Concurrent +function strSort(inPutArr: string[]) : string[] { + let newArr: string[] = inPutArr.sort(); + return newArr; +} + +@Concurrent +function strSortDelay(inPutArr: string[]) : string[] { + let start: number= new Date().getTime(); + while (new Date().getTime() - start < 3000) { + continue; + } + let newArr: string[] = inPutArr.sort(); + return newArr; +} + +@Concurrent +async function createSendableData(data: SendableClass): Promise { + // 定义taskpool子线程异步锁sendableTask_lock + let lock: utils.locks.AsyncLock = utils.locks.AsyncLock.request("testTask_lock"); + + // 构造TestA、TestB实例,组装SendableClass实例 + let d1: TestA = new TestA(); + d1.v1 = 1010; + d1.v2 = "aaa"; + d1.v3 = true; + let d2: TestB = new TestB(); + d2.v2.set(100, "aaa"); + for(let i = 0;i < 1000;i++) { + d2.v1.push(i); + d2.v3.add("hello"); + } + + lock.lockAsync(async () => { + // 子线程调用实例方法setCount、getCount + await d1.setCount(10); + console.info("taskpool: this data1 count is: " + await d1.getCount()); + }) + + data.data1 = d1; + data.data2 = d2; +} + +export default function abilityTest() { + describe('abilityTest', () => { + /** + * @tc.number : StartAbilityFunction_001 + * @tc.name : Start ability + * @tc.desc : Start an application + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('StartAbilityFunction_001', 0, async (done: Function) => { + hilog.info(DOMAIN, TAG, BUNDLE + 'StartAbilityFunction_001 begin'); + let abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator(); + try { + await abilityDelegator.startAbility({ + bundleName: "com.samples.concurrentmodule", + abilityName: "EntryAbility" + }); + done(); + } catch (err) { + expect(err.code).assertEqual(0); + done(); + } + hilog.info(DOMAIN, TAG, BUNDLE + 'StartAbilityFunction_001 end'); + }) + + /** + * @tc.number : WorkerCopyFileFunction_001 + * @tc.name : WorkerCopyFile + * @tc.desc : Click the copy file button + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + // 点击拷贝文件按钮 + it('WorkerCopyFileFunction_001', 0, async (done: Function) => { + hilog.info(DOMAIN, TAG, BUNDLE + 'WorkerCopyFileFunction_001 begin'); + let driver = Driver.create(); + await driver.delayMs(500); + await driver.assertComponentExist(ON.id('fileCopy')); + let fileCopy = await driver.findComponent(ON.id('fileCopy')); + await fileCopy.click(); + let copyFileLog1 = await getResourceString($r('app.string.copyFileLog1')) + expect(copyFileLog1).assertEqual(await resourceManager.getStringValue($r('app.string.copyFileLog1'))); + await driver.delayMs(200); + done(); + hilog.info(DOMAIN, TAG, BUNDLE + 'WorkerCopyFileFunction_001 end'); + }) + + /** + * @tc.number : WorkerCopyFileButtonFunction_001 + * @tc.name : WorkerCopyFile + * @tc.desc : Click the copy file button + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + // 进入页面直接点击拷贝文件按钮 + it('WorkerCopyFileButtonFunction_001', 0, async (done: Function) => { + hilog.info(DOMAIN, TAG, BUNDLE + 'WorkerCopyFileButtonFunction_001 begin'); + let driver = Driver.create(); + await driver.delayMs(1000); + await driver.assertComponentExist(ON.id('copyFile')); + let copyFile = await driver.findComponent(ON.id('copyFile')); + await copyFile.click(); + await driver.assertComponentExist(ON.id('copyFile')); + let copyFileLog = await driver.findComponent(ON.id('copyFileLog')); + let strValue = await copyFileLog.getText(); + expect(strValue).assertEqual(await resourceManager.getStringValue($r('app.string.workerLogChooseFile'))); + await driver.delayMs(500); + done(); + hilog.info(DOMAIN, TAG, BUNDLE + 'WorkerCopyFileButtonFunction_001 end'); + }) + + /** + * @tc.number : WorkerCopyFileFunction_002 + * @tc.name : WorkerCopyFile + * @tc.desc : Select file copy + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + // 选择文件拷贝 + it('WorkerCopyFileFunction_002', 0, async (done: Function) => { + hilog.info(DOMAIN, TAG, BUNDLE + 'WorkerCopyFileFunction_002 begin'); + let driver = Driver.create(); + await driver.delayMs(500); + // 使用id寻找组件并点击,时间超过3min,因此采用坐标点击 + let copy1 = await driver.findComponent(ON.id('checkbox0')); + await copy1.click(); + let copy2 = await driver.findComponent(ON.id('checkbox1')); + await copy2.click(); + let copy3 = await driver.findComponent(ON.id('checkbox2')); + await copy3.click(); + let copyFileLog = await driver.findComponent(ON.id('copyFileLog')); + let strValue = await copyFileLog.getText(); + expect(strValue).assertEqual(await resourceManager.getStringValue($r('app.string.workerLogChooseFile'))); + await driver.delayMs(200); + done(); + hilog.info(DOMAIN, TAG, BUNDLE + 'WorkerCopyFileFunction_002 end'); + }) + + /** + * @tc.number : WorkerFunction_001 + * @tc.name : Worker string sorting + * @tc.desc : Enter the string to be sorted + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + // worker执行排序字符串 + it('WorkerFunction_001', 0, async (done: Function) => { + hilog.info(DOMAIN, TAG, BUNDLE + 'WorkerFunction_001 begin'); + + let value: string = "add,dses,ssdf"; + let arr = value.trim().split(','); + let outPutStr = await executeWorkerFunc(arr); + expect(outPutStr).assertEqual('add,dses,ssdf'); + done(); + hilog.info(DOMAIN, TAG, BUNDLE + 'WorkerFunction_001 end'); + }) + + /** + * @tc.number : TaskPoolFunction_001 + * @tc.name : TaskPool string sorting + * @tc.desc : Click on the TaskPool tab + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + // TaskPool立即执行字符串排序 + it('TaskPoolFunction_001', 0, async (done: Function) => { + hilog.info(DOMAIN, TAG, BUNDLE + 'TaskPoolFunction_001 begin'); + let value: string = "add,dses,ssdf"; + let arr = value.trim().split(','); + let taskPoolOutPutStr = ''; + let task = new taskpool.Task(strSort, arr); + try { + let result: taskpool.Task = await taskpool.execute(task) as taskpool.Task; + taskPoolOutPutStr += "Task executed successfully: "+ result.toString()+ "\n"; + } catch(e) { + taskPoolOutPutStr += "Task executed failed: "+ (e as BusinessError).toString()+ "\n"; + } + expect(taskPoolOutPutStr).assertEqual("Task executed successfully: add,dses,ssdf\n"); + done(); + hilog.info(DOMAIN, TAG, BUNDLE + 'TaskPoolFunction_001 end'); + }) + + /** + * @tc.number : TaskPoolFunction_002 + * @tc.name : TaskPool execute string sorting task + * @tc.desc : Enter the string to be sorted + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + // TaskPool延时执行字符串排序任务 + it('TaskPoolFunction_002', 0, async (done: Function) => { + hilog.info(DOMAIN, TAG, BUNDLE + 'TaskPoolFunction_002 begin'); + let value: string = "add,dses,ssdf"; + let arr = value.trim().split(','); + let taskPoolOutPutStr = ''; + let task = new taskpool.Task(strSortDelay, arr); + try { + let result: taskpool.Task = await taskpool.execute(task) as taskpool.Task; + taskPoolOutPutStr += "Task executed successfully: "+ result.toString()+ "\n"; + } catch(e) { + taskPoolOutPutStr += "Task executed failed: "+ (e as BusinessError).toString()+ "\n"; + } + expect(taskPoolOutPutStr).assertEqual("Task executed successfully: add,dses,ssdf\n"); + done(); + hilog.info(DOMAIN, TAG, BUNDLE + 'TaskPoolFunction_002 end') + }) + + /** + * @tc.number : TaskPoolFunction_003 + * @tc.name : TaskPool execute string sorting func + * @tc.desc : Enter the string to be sorted + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + // TaskPool延时执行字符串排序任务 + it('TaskPoolFunction_003', 0, async (done: Function) => { + hilog.info(DOMAIN, TAG, BUNDLE + 'TaskPoolFunction_002 begin'); + let value: string = "add,dses,ssdf"; + let arr = value.trim().split(','); + let taskPoolOutPutStr = ''; + try { + let result: taskpool.Task = await taskpool.execute(strSortDelay, arr) as taskpool.Task; + taskPoolOutPutStr += "Task executed successfully: "+ result.toString()+ "\n"; + } catch(e) { + taskPoolOutPutStr += "Task executed failed: "+ (e as BusinessError).toString()+ "\n"; + } + expect(taskPoolOutPutStr).assertEqual("Task executed successfully: add,dses,ssdf\n"); + done(); + hilog.info(DOMAIN, TAG, BUNDLE + 'TaskPoolFunction_002 end') + }) + + /** + * @tc.number : TaskPoolFunction_004 + * @tc.name : TaskPool cancel string sorting task + * @tc.desc : Cancel string sorting task + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + // TaskPool延时执行字符串排序 + it('TaskPoolFunction_004', 0, async (done: Function) => { + hilog.info(DOMAIN, TAG, BUNDLE + 'TaskPoolFunction_002 begin'); + let value: string = "add,dses,ssdf"; + let arr = value.trim().split(','); + let taskPoolOutPutStr = ''; + let task = new taskpool.Task(strSortDelay, arr); + try { + taskpool.execute(task).then((res) => { + taskPoolOutPutStr += "Task executed successfully: "+ res.toString()+ "\n"; + }).catch((e: BusinessError) => { + taskPoolOutPutStr += "Task executed failed: "+ e.toString()+ "\n"; + }); + taskpool.cancel(task); + } catch(e) { + taskPoolOutPutStr += "Task executed failed: "+ (e as BusinessError).toString()+ "\n"; + } + expect(taskPoolOutPutStr).assertEqual(""); + done(); + hilog.info(DOMAIN, TAG, BUNDLE + 'TaskPoolFunction_002 end') + }) + + /** + * @tc.number : TaskPoolFunction_005 + * @tc.name : TaskPool Group execute string sorting + * @tc.desc : Execute string sorting TaskPool Group + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + // TaskPool Group执行字符串排序 + it('TaskPoolFunction_005', 0, async (done: Function) => { + hilog.info(DOMAIN, TAG, BUNDLE + 'TaskPoolFunction_003 begin'); + let value: string = "add,dses,ssdf"; + let arr = value.trim().split(','); + let value1: string = "mnf,csfg,brsf"; + let arr1 = value1.trim().split(','); + let value2: string = "rkg,abhg,ungb"; + let arr2 = value2.trim().split(','); + let taskPoolOutPutStr = ''; + try { + let task1: taskpool.Task = new taskpool.Task(strSort, arr); + let task2: taskpool.Task = new taskpool.Task(strSort, arr1); + let task3: taskpool.Task = new taskpool.Task(strSort, arr2); + + let taskGroup:taskpool.TaskGroup = new taskpool.TaskGroup(); + taskGroup.addTask(task1); + taskGroup.addTask(task2); + taskGroup.addTask(task3); + let res: string[] = await taskpool.execute(taskGroup) as string[]; + taskPoolOutPutStr += "TaskGroup executed successfully: "+ res.toString()+ "\n"; + expect(taskPoolOutPutStr).assertEqual("TaskGroup executed successfully: add,dses,ssdf,brsf,csfg,mnf,abhg,rkg,ungb\n"); + } catch (e) { + taskPoolOutPutStr += "TaskGroup executed failed: "+ (e as BusinessError).toString()+ "\n"; + } + done(); + hilog.info(DOMAIN, TAG, BUNDLE + 'TaskPoolFunction_003 end'); + }) + + /** + * @tc.number : TaskPoolSendable_006 + * @tc.name : TaskPool execute SendableClass task + * @tc.desc : Inspection results + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('TaskPoolSendable_006', 0, async (done: Function) => { + hilog.info(DOMAIN, TAG, BUNDLE + 'TaskPoolSendable_001 begin'); + let a: SendableClass = new SendableClass(); + // 定义主线程异步锁sendableTask_lock + let lock: utils.locks.AsyncLock = utils.locks.AsyncLock.request("testTask_lock"); + let count: number = 0; + lock.lockAsync(async () => { + // 主线程调用实例a.data1的方法setCount、getCount + a.data1.setCount(111); + count = await a.data1.getCount(); + console.info("this data1 count is: " + await a.data1.getCount()); + }) + let task: taskpool.Task = new taskpool.Task(createSendableData, a); + let taskPoolOutPutStr1 = ''; + let taskPoolOutPutStr2 = ''; + let taskPoolOutPutStr3 = ''; + let taskPoolOutPutStr4 = ''; + let taskPoolOutPutStr5 = ''; + let taskPoolOutPutStr6 = ''; + let taskPoolOutPutStr7 = ''; + let taskPoolOutPutStr8 = ''; + + try { + await taskpool.execute(task); + taskPoolOutPutStr1 = "sendableTask execute successfully."; + // 访问子线程返回的实例a中的各个属性 + taskPoolOutPutStr2 = "Sendable data TestA v1 is: " + a.data1.v1; + taskPoolOutPutStr3 = "Sendable data TestA v2 is: " + a.data1.v2; + taskPoolOutPutStr4 = "Sendable data TestA v3 is: " + a.data1.v3; + taskPoolOutPutStr5 = "Sendable data TestA count is: " + count; + taskPoolOutPutStr6 = "Sendable data TestB v1 length is: " + a.data2.v1.length; + taskPoolOutPutStr7 = "Sendable data TestB v2 has key: " + a.data2.v2.has(100); + taskPoolOutPutStr8 = "Sendable data TestB v3 size is: " + a.data2.v2.size; + } catch(e) { + taskPoolOutPutStr1 = "Task execute failed: "+ (e as BusinessError).toString()+ "\n"; + } + expect(taskPoolOutPutStr1).assertEqual("sendableTask execute successfully.") + expect(taskPoolOutPutStr2).assertEqual("Sendable data TestA v1 is: 1010") + expect(taskPoolOutPutStr3).assertEqual("Sendable data TestA v2 is: aaa") + expect(taskPoolOutPutStr4).assertEqual("Sendable data TestA v3 is: true") + expect(taskPoolOutPutStr5).assertEqual("Sendable data TestA count is: 111") + expect(taskPoolOutPutStr6).assertEqual("Sendable data TestB v1 length is: 1000") + expect(taskPoolOutPutStr7).assertEqual("Sendable data TestB v2 has key: true") + expect(taskPoolOutPutStr8).assertEqual("Sendable data TestB v3 size is: 1") + + done(); + hilog.info(DOMAIN, TAG, BUNDLE + 'TaskPoolSendable_001 end'); + }) + }) +} \ No newline at end of file diff --git a/sample/EnhanceSampleArk1.2/ConcurrentModule/entry/src/ohosTest/ets/test/List.test.ets b/sample/EnhanceSampleArk1.2/ConcurrentModule/entry/src/ohosTest/ets/test/List.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..70ea5798490dde55fff1e94ea4bf90cbab1119b2 --- /dev/null +++ b/sample/EnhanceSampleArk1.2/ConcurrentModule/entry/src/ohosTest/ets/test/List.test.ets @@ -0,0 +1,20 @@ +/* + * Copyright (c) 2023 Huawei Device 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 abilityTest from './Ability.test'; + +export default function testsuite() { + abilityTest() +} \ No newline at end of file diff --git a/sample/EnhanceSampleArk1.2/ConcurrentModule/entry/src/ohosTest/ets/testability/TestAbility.ets b/sample/EnhanceSampleArk1.2/ConcurrentModule/entry/src/ohosTest/ets/testability/TestAbility.ets new file mode 100644 index 0000000000000000000000000000000000000000..df024854b8399e2663c9e843925fcb9e925be76d --- /dev/null +++ b/sample/EnhanceSampleArk1.2/ConcurrentModule/entry/src/ohosTest/ets/testability/TestAbility.ets @@ -0,0 +1,65 @@ +/* + * Copyright (c) 2023 Huawei Device 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 UIAbility from '@ohos.app.ability.UIAbility'; +import AbilityDelegatorRegistry from '@ohos.app.ability.abilityDelegatorRegistry'; +import hilog from '@ohos.hilog'; +import { Hypium } from '@ohos/hypium'; +import testsuite from '../test/List.test'; +import window from '@ohos.window'; +import Want from '@ohos.app.ability.Want'; +import AbilityConstant from '@ohos.app.ability.AbilityConstant'; + +export default class TestAbility extends UIAbility { + onCreate(want: Want, launchParam: AbilityConstant.LaunchParam) { + hilog.info(0x0000, 'testTag', '%{public}s', 'TestAbility onCreate'); + hilog.info(0x0000, 'testTag', '%{public}s', 'want param:' + JSON.stringify(want) ?? ''); + hilog.info(0x0000, 'testTag', '%{public}s', 'launchParam:'+ JSON.stringify(launchParam) ?? ''); + let abilityDelegator: AbilityDelegatorRegistry.AbilityDelegator; + abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator(); + let abilityDelegatorArguments: AbilityDelegatorRegistry.AbilityDelegatorArgs; + abilityDelegatorArguments= AbilityDelegatorRegistry.getArguments(); + hilog.info(0x0000, 'testTag', '%{public}s', 'start run testcase!!!'); + Hypium.hypiumTest(abilityDelegator, abilityDelegatorArguments, testsuite); + } + + onDestroy() { + hilog.info(0x0000, 'testTag', '%{public}s', 'TestAbility onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage) { + hilog.info(0x0000, 'testTag', '%{public}s', 'TestAbility onWindowStageCreate'); + windowStage.loadContent('testability/pages/Index', (err, data) => { + if (err.code) { + hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); + return; + } + hilog.info(0x0000, 'testTag', 'Succeeded in loading the content. Data: %{public}s', + JSON.stringify(data) ?? ''); + }); + } + + onWindowStageDestroy() { + hilog.info(0x0000, 'testTag', '%{public}s', 'TestAbility onWindowStageDestroy'); + } + + onForeground() { + hilog.info(0x0000, 'testTag', '%{public}s', 'TestAbility onForeground'); + } + + onBackground() { + hilog.info(0x0000, 'testTag', '%{public}s', 'TestAbility onBackground'); + } +} \ No newline at end of file diff --git a/sample/EnhanceSampleArk1.2/ConcurrentModule/entry/src/ohosTest/ets/testability/pages/Index.ets b/sample/EnhanceSampleArk1.2/ConcurrentModule/entry/src/ohosTest/ets/testability/pages/Index.ets new file mode 100644 index 0000000000000000000000000000000000000000..665f69164491949c1af84482eb68918519c6e103 --- /dev/null +++ b/sample/EnhanceSampleArk1.2/ConcurrentModule/entry/src/ohosTest/ets/testability/pages/Index.ets @@ -0,0 +1,50 @@ +/* + * Copyright (c) 2023 Huawei Device 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 hilog from '@ohos.hilog'; + +@Entry +@Component +struct Index { + aboutToAppear() { + hilog.info(0x0000, 'testTag', '%{public}s', 'TestAbility index aboutToAppear'); + } + @State message: string = 'Hello World'; + build() { + Row() { + Column() { + Text(this.message) + .fontSize(50) + .fontWeight(FontWeight.Bold) + Button() { + Text('next page') + .fontSize(20) + .fontWeight(FontWeight.Bold) + } + .type(ButtonType.Capsule) + .margin({ + top: 20 + }) + .backgroundColor('#0D9FFB') + .width('35%') + .height('5%') + .onClick(()=>{ + }) + } + .width('100%') + } + .height('100%') + } +} \ No newline at end of file diff --git a/sample/EnhanceSampleArk1.2/ConcurrentModule/entry/src/ohosTest/module.json5 b/sample/EnhanceSampleArk1.2/ConcurrentModule/entry/src/ohosTest/module.json5 new file mode 100644 index 0000000000000000000000000000000000000000..c6ad62fbbd46259bb51381022bcdce57349e123c --- /dev/null +++ b/sample/EnhanceSampleArk1.2/ConcurrentModule/entry/src/ohosTest/module.json5 @@ -0,0 +1,51 @@ +/* + * Copyright (c) 2023 Huawei Device 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. + */ + +{ + "module": { + "name": "entry_test", + "type": "feature", + "description": "$string:module_test_desc", + "mainElement": "TestAbility", + "deviceTypes": [ + "default" + ], + "deliveryWithInstall": true, + "installationFree": false, + "pages": "$profile:test_pages", + "abilities": [ + { + "name": "TestAbility", + "srcEntry": "./ets/testability/TestAbility.ets", + "description": "$string:TestAbility_desc", + "icon": "$media:icon", + "label": "$string:TestAbility_label", + "exported": true, + "startWindowIcon": "$media:icon", + "startWindowBackground": "$color:start_window_background", + "skills": [ + { + "actions": [ + "action.system.home" + ], + "entities": [ + "entity.system.home" + ] + } + ] + } + ] + } +} diff --git a/sample/EnhanceSampleArk1.2/ConcurrentModule/entry/src/ohosTest/resources/base/element/color.json b/sample/EnhanceSampleArk1.2/ConcurrentModule/entry/src/ohosTest/resources/base/element/color.json new file mode 100644 index 0000000000000000000000000000000000000000..3c712962da3c2751c2b9ddb53559afcbd2b54a02 --- /dev/null +++ b/sample/EnhanceSampleArk1.2/ConcurrentModule/entry/src/ohosTest/resources/base/element/color.json @@ -0,0 +1,8 @@ +{ + "color": [ + { + "name": "start_window_background", + "value": "#FFFFFF" + } + ] +} \ No newline at end of file diff --git a/sample/EnhanceSampleArk1.2/ConcurrentModule/entry/src/ohosTest/resources/base/element/string.json b/sample/EnhanceSampleArk1.2/ConcurrentModule/entry/src/ohosTest/resources/base/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..1ad9f2b4d5df9d2e3ff05249b4bfb11670deb94c --- /dev/null +++ b/sample/EnhanceSampleArk1.2/ConcurrentModule/entry/src/ohosTest/resources/base/element/string.json @@ -0,0 +1,28 @@ +{ + "string": [ + { + "name": "module_test_desc", + "value": "test ability description" + }, + { + "name": "TestAbility_desc", + "value": "the test ability" + }, + { + "name": "TestAbility_label", + "value": "test label" + }, + { + "name": "copyFileLog1", + "value": "1. Number of sandbox directory files: 2" + }, + { + "name": "copyFileLog2", + "value": "2. File TestFile01.txt, TestFile02.txt and other files are copied" + }, + { + "name": "workerLogChooseFile", + "value": "2.Please select a file" + } + ] +} \ No newline at end of file diff --git a/sample/EnhanceSampleArk1.2/ConcurrentModule/entry/src/ohosTest/resources/base/media/icon.png b/sample/EnhanceSampleArk1.2/ConcurrentModule/entry/src/ohosTest/resources/base/media/icon.png new file mode 100644 index 0000000000000000000000000000000000000000..ce307a8827bd75456441ceb57d530e4c8d45d36c Binary files /dev/null and b/sample/EnhanceSampleArk1.2/ConcurrentModule/entry/src/ohosTest/resources/base/media/icon.png differ diff --git a/sample/EnhanceSampleArk1.2/ConcurrentModule/entry/src/ohosTest/resources/base/profile/test_pages.json b/sample/EnhanceSampleArk1.2/ConcurrentModule/entry/src/ohosTest/resources/base/profile/test_pages.json new file mode 100644 index 0000000000000000000000000000000000000000..b7e7343cacb32ce982a45e76daad86e435e054fe --- /dev/null +++ b/sample/EnhanceSampleArk1.2/ConcurrentModule/entry/src/ohosTest/resources/base/profile/test_pages.json @@ -0,0 +1,5 @@ +{ + "src": [ + "testability/pages/Index" + ] +} diff --git a/sample/EnhanceSampleArk1.2/ConcurrentModule/entry/src/ohosTest/resources/en/element/string.json b/sample/EnhanceSampleArk1.2/ConcurrentModule/entry/src/ohosTest/resources/en/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..24e9409ef276143862d223682022acffe4d7c3dd --- /dev/null +++ b/sample/EnhanceSampleArk1.2/ConcurrentModule/entry/src/ohosTest/resources/en/element/string.json @@ -0,0 +1,16 @@ +{ + "string": [ + { + "name": "copyFileLog1", + "value": "1. Number of sandbox directory files: 2" + }, + { + "name": "copyFileLog2", + "value": "2. File TestFile01.txt, TestFile02.txt and other files are copied" + }, + { + "name": "workerLogChooseFile", + "value": "2.Please select a file" + } + ] +} \ No newline at end of file diff --git a/sample/EnhanceSampleArk1.2/ConcurrentModule/entry/src/ohosTest/resources/zh/element/string.json b/sample/EnhanceSampleArk1.2/ConcurrentModule/entry/src/ohosTest/resources/zh/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..11994ea6d353766fa67eaea90f9562c0f7dd188b --- /dev/null +++ b/sample/EnhanceSampleArk1.2/ConcurrentModule/entry/src/ohosTest/resources/zh/element/string.json @@ -0,0 +1,16 @@ +{ + "string": [ + { + "name": "copyFileLog1", + "value": "1、沙箱目录文件个数3个" + }, + { + "name": "copyFileLog2", + "value": "2、TestFile01.txt、TestFile02.txt等文件copy完成" + }, + { + "name": "workerLogChooseFile", + "value": "2、请选择文件" + } + ] +} \ No newline at end of file diff --git a/sample/EnhanceSampleArk1.2/ConcurrentModule/hvigor/hvigor-config.json5 b/sample/EnhanceSampleArk1.2/ConcurrentModule/hvigor/hvigor-config.json5 new file mode 100644 index 0000000000000000000000000000000000000000..909bc9a52c9871b7a12b665460a7cb3cea6d50c5 --- /dev/null +++ b/sample/EnhanceSampleArk1.2/ConcurrentModule/hvigor/hvigor-config.json5 @@ -0,0 +1,21 @@ +/* + * Copyright (c) 2023 Huawei Device 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. + */ + +{ + "hvigorVersion": "4.0.4", + "dependencies": { + "@ohos/hvigor-ohos-plugin": "4.0.4" + } +} \ No newline at end of file diff --git a/sample/EnhanceSampleArk1.2/ConcurrentModule/hvigor/hvigor-wrapper.js b/sample/EnhanceSampleArk1.2/ConcurrentModule/hvigor/hvigor-wrapper.js new file mode 100644 index 0000000000000000000000000000000000000000..372eae8eb4a124095936f9cd78df5c6756746f3f --- /dev/null +++ b/sample/EnhanceSampleArk1.2/ConcurrentModule/hvigor/hvigor-wrapper.js @@ -0,0 +1 @@ +"use strict";var u=require("path"),D=require("os"),e=require("fs"),t=require("crypto"),r=require("child_process"),n="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},i={},C={},F=n&&n.__importDefault||function(u){return u&&u.__esModule?u:{default:u}};Object.defineProperty(C,"__esModule",{value:!0}),C.maxPathLength=C.isMac=C.isLinux=C.isWindows=void 0;const E=F(D),A="Windows_NT",o="Darwin";function a(){return E.default.type()===A}function c(){return E.default.type()===o}C.isWindows=a,C.isLinux=function(){return"Linux"===E.default.type()},C.isMac=c,C.maxPathLength=function(){return c()?1016:a()?259:4095},function(e){var t=n&&n.__createBinding||(Object.create?function(u,D,e,t){void 0===t&&(t=e);var r=Object.getOwnPropertyDescriptor(D,e);r&&!("get"in r?!D.__esModule:r.writable||r.configurable)||(r={enumerable:!0,get:function(){return D[e]}}),Object.defineProperty(u,t,r)}:function(u,D,e,t){void 0===t&&(t=e),u[t]=D[e]}),r=n&&n.__setModuleDefault||(Object.create?function(u,D){Object.defineProperty(u,"default",{enumerable:!0,value:D})}:function(u,D){u.default=D}),i=n&&n.__importStar||function(u){if(u&&u.__esModule)return u;var D={};if(null!=u)for(var e in u)"default"!==e&&Object.prototype.hasOwnProperty.call(u,e)&&t(D,u,e);return r(D,u),D};Object.defineProperty(e,"__esModule",{value:!0}),e.WORK_SPACE=e.HVIGOR_PROJECT_WRAPPER_HOME=e.HVIGOR_PROJECT_ROOT_DIR=e.HVIGOR_PROJECT_CACHES_HOME=e.HVIGOR_PNPM_STORE_PATH=e.HVIGOR_WRAPPER_PNPM_SCRIPT_PATH=e.PROJECT_CACHES=e.HVIGOR_WRAPPER_TOOLS_HOME=e.HVIGOR_USER_HOME=e.DEFAULT_PACKAGE_JSON=e.DEFAULT_HVIGOR_CONFIG_JSON_FILE_NAME=e.PNPM=e.HVIGOR=e.NPM_TOOL=e.PNPM_TOOL=e.HVIGOR_ENGINE_PACKAGE_NAME=void 0;const F=i(D),E=i(u),A=C;e.HVIGOR_ENGINE_PACKAGE_NAME="@ohos/hvigor",e.PNPM_TOOL=(0,A.isWindows)()?"pnpm.cmd":"pnpm",e.NPM_TOOL=(0,A.isWindows)()?"npm.cmd":"npm",e.HVIGOR="hvigor",e.PNPM="pnpm",e.DEFAULT_HVIGOR_CONFIG_JSON_FILE_NAME="hvigor-config.json5",e.DEFAULT_PACKAGE_JSON="package.json",e.HVIGOR_USER_HOME=E.resolve(F.homedir(),".hvigor"),e.HVIGOR_WRAPPER_TOOLS_HOME=E.resolve(e.HVIGOR_USER_HOME,"wrapper","tools"),e.PROJECT_CACHES="project_caches",e.HVIGOR_WRAPPER_PNPM_SCRIPT_PATH=E.resolve(e.HVIGOR_WRAPPER_TOOLS_HOME,"node_modules",".bin",e.PNPM_TOOL),e.HVIGOR_PNPM_STORE_PATH=E.resolve(e.HVIGOR_USER_HOME,"caches"),e.HVIGOR_PROJECT_CACHES_HOME=E.resolve(e.HVIGOR_USER_HOME,e.PROJECT_CACHES),e.HVIGOR_PROJECT_ROOT_DIR=process.cwd(),e.HVIGOR_PROJECT_WRAPPER_HOME=E.resolve(e.HVIGOR_PROJECT_ROOT_DIR,e.HVIGOR),e.WORK_SPACE="workspace"}(i);var s={},l={};Object.defineProperty(l,"__esModule",{value:!0}),l.logInfoPrintConsole=l.logErrorAndExit=void 0,l.logErrorAndExit=function(u){u instanceof Error?console.error(u.message):console.error(u),process.exit(-1)},l.logInfoPrintConsole=function(u){console.log(u)};var B=n&&n.__createBinding||(Object.create?function(u,D,e,t){void 0===t&&(t=e);var r=Object.getOwnPropertyDescriptor(D,e);r&&!("get"in r?!D.__esModule:r.writable||r.configurable)||(r={enumerable:!0,get:function(){return D[e]}}),Object.defineProperty(u,t,r)}:function(u,D,e,t){void 0===t&&(t=e),u[t]=D[e]}),d=n&&n.__setModuleDefault||(Object.create?function(u,D){Object.defineProperty(u,"default",{enumerable:!0,value:D})}:function(u,D){u.default=D}),f=n&&n.__importStar||function(u){if(u&&u.__esModule)return u;var D={};if(null!=u)for(var e in u)"default"!==e&&Object.prototype.hasOwnProperty.call(u,e)&&B(D,u,e);return d(D,u),D};Object.defineProperty(s,"__esModule",{value:!0});var _=s.executeBuild=void 0;const p=f(e),O=f(u),h=l;_=s.executeBuild=function(u){const D=O.resolve(u,"node_modules","@ohos","hvigor","bin","hvigor.js");try{const u=p.realpathSync(D);require(u)}catch(e){(0,h.logErrorAndExit)(`Error: ENOENT: no such file ${D},delete ${u} and retry.`)}};var P={},v={};!function(u){var D=n&&n.__importDefault||function(u){return u&&u.__esModule?u:{default:u}};Object.defineProperty(u,"__esModule",{value:!0}),u.hashFile=u.hash=u.createHash=void 0;const r=D(t),i=D(e);u.createHash=(u="MD5")=>r.default.createHash(u);u.hash=(D,e)=>(0,u.createHash)(e).update(D).digest("hex");u.hashFile=(D,e)=>{if(i.default.existsSync(D))return(0,u.hash)(i.default.readFileSync(D,"utf-8"),e)}}(v);var g={},m={},R={};Object.defineProperty(R,"__esModule",{value:!0}),R.Unicode=void 0;class y{}R.Unicode=y,y.SPACE_SEPARATOR=/[\u1680\u2000-\u200A\u202F\u205F\u3000]/,y.ID_START=/[\xAA\xB5\xBA\xC0-\xD6\xD8-\xF6\xF8-\u02C1\u02C6-\u02D1\u02E0-\u02E4\u02EC\u02EE\u0370-\u0374\u0376\u0377\u037A-\u037D\u037F\u0386\u0388-\u038A\u038C\u038E-\u03A1\u03A3-\u03F5\u03F7-\u0481\u048A-\u052F\u0531-\u0556\u0559\u0561-\u0587\u05D0-\u05EA\u05F0-\u05F2\u0620-\u064A\u066E\u066F\u0671-\u06D3\u06D5\u06E5\u06E6\u06EE\u06EF\u06FA-\u06FC\u06FF\u0710\u0712-\u072F\u074D-\u07A5\u07B1\u07CA-\u07EA\u07F4\u07F5\u07FA\u0800-\u0815\u081A\u0824\u0828\u0840-\u0858\u0860-\u086A\u08A0-\u08B4\u08B6-\u08BD\u0904-\u0939\u093D\u0950\u0958-\u0961\u0971-\u0980\u0985-\u098C\u098F\u0990\u0993-\u09A8\u09AA-\u09B0\u09B2\u09B6-\u09B9\u09BD\u09CE\u09DC\u09DD\u09DF-\u09E1\u09F0\u09F1\u09FC\u0A05-\u0A0A\u0A0F\u0A10\u0A13-\u0A28\u0A2A-\u0A30\u0A32\u0A33\u0A35\u0A36\u0A38\u0A39\u0A59-\u0A5C\u0A5E\u0A72-\u0A74\u0A85-\u0A8D\u0A8F-\u0A91\u0A93-\u0AA8\u0AAA-\u0AB0\u0AB2\u0AB3\u0AB5-\u0AB9\u0ABD\u0AD0\u0AE0\u0AE1\u0AF9\u0B05-\u0B0C\u0B0F\u0B10\u0B13-\u0B28\u0B2A-\u0B30\u0B32\u0B33\u0B35-\u0B39\u0B3D\u0B5C\u0B5D\u0B5F-\u0B61\u0B71\u0B83\u0B85-\u0B8A\u0B8E-\u0B90\u0B92-\u0B95\u0B99\u0B9A\u0B9C\u0B9E\u0B9F\u0BA3\u0BA4\u0BA8-\u0BAA\u0BAE-\u0BB9\u0BD0\u0C05-\u0C0C\u0C0E-\u0C10\u0C12-\u0C28\u0C2A-\u0C39\u0C3D\u0C58-\u0C5A\u0C60\u0C61\u0C80\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8\u0CAA-\u0CB3\u0CB5-\u0CB9\u0CBD\u0CDE\u0CE0\u0CE1\u0CF1\u0CF2\u0D05-\u0D0C\u0D0E-\u0D10\u0D12-\u0D3A\u0D3D\u0D4E\u0D54-\u0D56\u0D5F-\u0D61\u0D7A-\u0D7F\u0D85-\u0D96\u0D9A-\u0DB1\u0DB3-\u0DBB\u0DBD\u0DC0-\u0DC6\u0E01-\u0E30\u0E32\u0E33\u0E40-\u0E46\u0E81\u0E82\u0E84\u0E87\u0E88\u0E8A\u0E8D\u0E94-\u0E97\u0E99-\u0E9F\u0EA1-\u0EA3\u0EA5\u0EA7\u0EAA\u0EAB\u0EAD-\u0EB0\u0EB2\u0EB3\u0EBD\u0EC0-\u0EC4\u0EC6\u0EDC-\u0EDF\u0F00\u0F40-\u0F47\u0F49-\u0F6C\u0F88-\u0F8C\u1000-\u102A\u103F\u1050-\u1055\u105A-\u105D\u1061\u1065\u1066\u106E-\u1070\u1075-\u1081\u108E\u10A0-\u10C5\u10C7\u10CD\u10D0-\u10FA\u10FC-\u1248\u124A-\u124D\u1250-\u1256\u1258\u125A-\u125D\u1260-\u1288\u128A-\u128D\u1290-\u12B0\u12B2-\u12B5\u12B8-\u12BE\u12C0\u12C2-\u12C5\u12C8-\u12D6\u12D8-\u1310\u1312-\u1315\u1318-\u135A\u1380-\u138F\u13A0-\u13F5\u13F8-\u13FD\u1401-\u166C\u166F-\u167F\u1681-\u169A\u16A0-\u16EA\u16EE-\u16F8\u1700-\u170C\u170E-\u1711\u1720-\u1731\u1740-\u1751\u1760-\u176C\u176E-\u1770\u1780-\u17B3\u17D7\u17DC\u1820-\u1877\u1880-\u1884\u1887-\u18A8\u18AA\u18B0-\u18F5\u1900-\u191E\u1950-\u196D\u1970-\u1974\u1980-\u19AB\u19B0-\u19C9\u1A00-\u1A16\u1A20-\u1A54\u1AA7\u1B05-\u1B33\u1B45-\u1B4B\u1B83-\u1BA0\u1BAE\u1BAF\u1BBA-\u1BE5\u1C00-\u1C23\u1C4D-\u1C4F\u1C5A-\u1C7D\u1C80-\u1C88\u1CE9-\u1CEC\u1CEE-\u1CF1\u1CF5\u1CF6\u1D00-\u1DBF\u1E00-\u1F15\u1F18-\u1F1D\u1F20-\u1F45\u1F48-\u1F4D\u1F50-\u1F57\u1F59\u1F5B\u1F5D\u1F5F-\u1F7D\u1F80-\u1FB4\u1FB6-\u1FBC\u1FBE\u1FC2-\u1FC4\u1FC6-\u1FCC\u1FD0-\u1FD3\u1FD6-\u1FDB\u1FE0-\u1FEC\u1FF2-\u1FF4\u1FF6-\u1FFC\u2071\u207F\u2090-\u209C\u2102\u2107\u210A-\u2113\u2115\u2119-\u211D\u2124\u2126\u2128\u212A-\u212D\u212F-\u2139\u213C-\u213F\u2145-\u2149\u214E\u2160-\u2188\u2C00-\u2C2E\u2C30-\u2C5E\u2C60-\u2CE4\u2CEB-\u2CEE\u2CF2\u2CF3\u2D00-\u2D25\u2D27\u2D2D\u2D30-\u2D67\u2D6F\u2D80-\u2D96\u2DA0-\u2DA6\u2DA8-\u2DAE\u2DB0-\u2DB6\u2DB8-\u2DBE\u2DC0-\u2DC6\u2DC8-\u2DCE\u2DD0-\u2DD6\u2DD8-\u2DDE\u2E2F\u3005-\u3007\u3021-\u3029\u3031-\u3035\u3038-\u303C\u3041-\u3096\u309D-\u309F\u30A1-\u30FA\u30FC-\u30FF\u3105-\u312E\u3131-\u318E\u31A0-\u31BA\u31F0-\u31FF\u3400-\u4DB5\u4E00-\u9FEA\uA000-\uA48C\uA4D0-\uA4FD\uA500-\uA60C\uA610-\uA61F\uA62A\uA62B\uA640-\uA66E\uA67F-\uA69D\uA6A0-\uA6EF\uA717-\uA71F\uA722-\uA788\uA78B-\uA7AE\uA7B0-\uA7B7\uA7F7-\uA801\uA803-\uA805\uA807-\uA80A\uA80C-\uA822\uA840-\uA873\uA882-\uA8B3\uA8F2-\uA8F7\uA8FB\uA8FD\uA90A-\uA925\uA930-\uA946\uA960-\uA97C\uA984-\uA9B2\uA9CF\uA9E0-\uA9E4\uA9E6-\uA9EF\uA9FA-\uA9FE\uAA00-\uAA28\uAA40-\uAA42\uAA44-\uAA4B\uAA60-\uAA76\uAA7A\uAA7E-\uAAAF\uAAB1\uAAB5\uAAB6\uAAB9-\uAABD\uAAC0\uAAC2\uAADB-\uAADD\uAAE0-\uAAEA\uAAF2-\uAAF4\uAB01-\uAB06\uAB09-\uAB0E\uAB11-\uAB16\uAB20-\uAB26\uAB28-\uAB2E\uAB30-\uAB5A\uAB5C-\uAB65\uAB70-\uABE2\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFA6D\uFA70-\uFAD9\uFB00-\uFB06\uFB13-\uFB17\uFB1D\uFB1F-\uFB28\uFB2A-\uFB36\uFB38-\uFB3C\uFB3E\uFB40\uFB41\uFB43\uFB44\uFB46-\uFBB1\uFBD3-\uFD3D\uFD50-\uFD8F\uFD92-\uFDC7\uFDF0-\uFDFB\uFE70-\uFE74\uFE76-\uFEFC\uFF21-\uFF3A\uFF41-\uFF5A\uFF66-\uFFBE\uFFC2-\uFFC7\uFFCA-\uFFCF\uFFD2-\uFFD7\uFFDA-\uFFDC]|\uD800[\uDC00-\uDC0B\uDC0D-\uDC26\uDC28-\uDC3A\uDC3C\uDC3D\uDC3F-\uDC4D\uDC50-\uDC5D\uDC80-\uDCFA\uDD40-\uDD74\uDE80-\uDE9C\uDEA0-\uDED0\uDF00-\uDF1F\uDF2D-\uDF4A\uDF50-\uDF75\uDF80-\uDF9D\uDFA0-\uDFC3\uDFC8-\uDFCF\uDFD1-\uDFD5]|\uD801[\uDC00-\uDC9D\uDCB0-\uDCD3\uDCD8-\uDCFB\uDD00-\uDD27\uDD30-\uDD63\uDE00-\uDF36\uDF40-\uDF55\uDF60-\uDF67]|\uD802[\uDC00-\uDC05\uDC08\uDC0A-\uDC35\uDC37\uDC38\uDC3C\uDC3F-\uDC55\uDC60-\uDC76\uDC80-\uDC9E\uDCE0-\uDCF2\uDCF4\uDCF5\uDD00-\uDD15\uDD20-\uDD39\uDD80-\uDDB7\uDDBE\uDDBF\uDE00\uDE10-\uDE13\uDE15-\uDE17\uDE19-\uDE33\uDE60-\uDE7C\uDE80-\uDE9C\uDEC0-\uDEC7\uDEC9-\uDEE4\uDF00-\uDF35\uDF40-\uDF55\uDF60-\uDF72\uDF80-\uDF91]|\uD803[\uDC00-\uDC48\uDC80-\uDCB2\uDCC0-\uDCF2]|\uD804[\uDC03-\uDC37\uDC83-\uDCAF\uDCD0-\uDCE8\uDD03-\uDD26\uDD50-\uDD72\uDD76\uDD83-\uDDB2\uDDC1-\uDDC4\uDDDA\uDDDC\uDE00-\uDE11\uDE13-\uDE2B\uDE80-\uDE86\uDE88\uDE8A-\uDE8D\uDE8F-\uDE9D\uDE9F-\uDEA8\uDEB0-\uDEDE\uDF05-\uDF0C\uDF0F\uDF10\uDF13-\uDF28\uDF2A-\uDF30\uDF32\uDF33\uDF35-\uDF39\uDF3D\uDF50\uDF5D-\uDF61]|\uD805[\uDC00-\uDC34\uDC47-\uDC4A\uDC80-\uDCAF\uDCC4\uDCC5\uDCC7\uDD80-\uDDAE\uDDD8-\uDDDB\uDE00-\uDE2F\uDE44\uDE80-\uDEAA\uDF00-\uDF19]|\uD806[\uDCA0-\uDCDF\uDCFF\uDE00\uDE0B-\uDE32\uDE3A\uDE50\uDE5C-\uDE83\uDE86-\uDE89\uDEC0-\uDEF8]|\uD807[\uDC00-\uDC08\uDC0A-\uDC2E\uDC40\uDC72-\uDC8F\uDD00-\uDD06\uDD08\uDD09\uDD0B-\uDD30\uDD46]|\uD808[\uDC00-\uDF99]|\uD809[\uDC00-\uDC6E\uDC80-\uDD43]|[\uD80C\uD81C-\uD820\uD840-\uD868\uD86A-\uD86C\uD86F-\uD872\uD874-\uD879][\uDC00-\uDFFF]|\uD80D[\uDC00-\uDC2E]|\uD811[\uDC00-\uDE46]|\uD81A[\uDC00-\uDE38\uDE40-\uDE5E\uDED0-\uDEED\uDF00-\uDF2F\uDF40-\uDF43\uDF63-\uDF77\uDF7D-\uDF8F]|\uD81B[\uDF00-\uDF44\uDF50\uDF93-\uDF9F\uDFE0\uDFE1]|\uD821[\uDC00-\uDFEC]|\uD822[\uDC00-\uDEF2]|\uD82C[\uDC00-\uDD1E\uDD70-\uDEFB]|\uD82F[\uDC00-\uDC6A\uDC70-\uDC7C\uDC80-\uDC88\uDC90-\uDC99]|\uD835[\uDC00-\uDC54\uDC56-\uDC9C\uDC9E\uDC9F\uDCA2\uDCA5\uDCA6\uDCA9-\uDCAC\uDCAE-\uDCB9\uDCBB\uDCBD-\uDCC3\uDCC5-\uDD05\uDD07-\uDD0A\uDD0D-\uDD14\uDD16-\uDD1C\uDD1E-\uDD39\uDD3B-\uDD3E\uDD40-\uDD44\uDD46\uDD4A-\uDD50\uDD52-\uDEA5\uDEA8-\uDEC0\uDEC2-\uDEDA\uDEDC-\uDEFA\uDEFC-\uDF14\uDF16-\uDF34\uDF36-\uDF4E\uDF50-\uDF6E\uDF70-\uDF88\uDF8A-\uDFA8\uDFAA-\uDFC2\uDFC4-\uDFCB]|\uD83A[\uDC00-\uDCC4\uDD00-\uDD43]|\uD83B[\uDE00-\uDE03\uDE05-\uDE1F\uDE21\uDE22\uDE24\uDE27\uDE29-\uDE32\uDE34-\uDE37\uDE39\uDE3B\uDE42\uDE47\uDE49\uDE4B\uDE4D-\uDE4F\uDE51\uDE52\uDE54\uDE57\uDE59\uDE5B\uDE5D\uDE5F\uDE61\uDE62\uDE64\uDE67-\uDE6A\uDE6C-\uDE72\uDE74-\uDE77\uDE79-\uDE7C\uDE7E\uDE80-\uDE89\uDE8B-\uDE9B\uDEA1-\uDEA3\uDEA5-\uDEA9\uDEAB-\uDEBB]|\uD869[\uDC00-\uDED6\uDF00-\uDFFF]|\uD86D[\uDC00-\uDF34\uDF40-\uDFFF]|\uD86E[\uDC00-\uDC1D\uDC20-\uDFFF]|\uD873[\uDC00-\uDEA1\uDEB0-\uDFFF]|\uD87A[\uDC00-\uDFE0]|\uD87E[\uDC00-\uDE1D]/,y.ID_CONTINUE=/[\xAA\xB5\xBA\xC0-\xD6\xD8-\xF6\xF8-\u02C1\u02C6-\u02D1\u02E0-\u02E4\u02EC\u02EE\u0300-\u0374\u0376\u0377\u037A-\u037D\u037F\u0386\u0388-\u038A\u038C\u038E-\u03A1\u03A3-\u03F5\u03F7-\u0481\u0483-\u0487\u048A-\u052F\u0531-\u0556\u0559\u0561-\u0587\u0591-\u05BD\u05BF\u05C1\u05C2\u05C4\u05C5\u05C7\u05D0-\u05EA\u05F0-\u05F2\u0610-\u061A\u0620-\u0669\u066E-\u06D3\u06D5-\u06DC\u06DF-\u06E8\u06EA-\u06FC\u06FF\u0710-\u074A\u074D-\u07B1\u07C0-\u07F5\u07FA\u0800-\u082D\u0840-\u085B\u0860-\u086A\u08A0-\u08B4\u08B6-\u08BD\u08D4-\u08E1\u08E3-\u0963\u0966-\u096F\u0971-\u0983\u0985-\u098C\u098F\u0990\u0993-\u09A8\u09AA-\u09B0\u09B2\u09B6-\u09B9\u09BC-\u09C4\u09C7\u09C8\u09CB-\u09CE\u09D7\u09DC\u09DD\u09DF-\u09E3\u09E6-\u09F1\u09FC\u0A01-\u0A03\u0A05-\u0A0A\u0A0F\u0A10\u0A13-\u0A28\u0A2A-\u0A30\u0A32\u0A33\u0A35\u0A36\u0A38\u0A39\u0A3C\u0A3E-\u0A42\u0A47\u0A48\u0A4B-\u0A4D\u0A51\u0A59-\u0A5C\u0A5E\u0A66-\u0A75\u0A81-\u0A83\u0A85-\u0A8D\u0A8F-\u0A91\u0A93-\u0AA8\u0AAA-\u0AB0\u0AB2\u0AB3\u0AB5-\u0AB9\u0ABC-\u0AC5\u0AC7-\u0AC9\u0ACB-\u0ACD\u0AD0\u0AE0-\u0AE3\u0AE6-\u0AEF\u0AF9-\u0AFF\u0B01-\u0B03\u0B05-\u0B0C\u0B0F\u0B10\u0B13-\u0B28\u0B2A-\u0B30\u0B32\u0B33\u0B35-\u0B39\u0B3C-\u0B44\u0B47\u0B48\u0B4B-\u0B4D\u0B56\u0B57\u0B5C\u0B5D\u0B5F-\u0B63\u0B66-\u0B6F\u0B71\u0B82\u0B83\u0B85-\u0B8A\u0B8E-\u0B90\u0B92-\u0B95\u0B99\u0B9A\u0B9C\u0B9E\u0B9F\u0BA3\u0BA4\u0BA8-\u0BAA\u0BAE-\u0BB9\u0BBE-\u0BC2\u0BC6-\u0BC8\u0BCA-\u0BCD\u0BD0\u0BD7\u0BE6-\u0BEF\u0C00-\u0C03\u0C05-\u0C0C\u0C0E-\u0C10\u0C12-\u0C28\u0C2A-\u0C39\u0C3D-\u0C44\u0C46-\u0C48\u0C4A-\u0C4D\u0C55\u0C56\u0C58-\u0C5A\u0C60-\u0C63\u0C66-\u0C6F\u0C80-\u0C83\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8\u0CAA-\u0CB3\u0CB5-\u0CB9\u0CBC-\u0CC4\u0CC6-\u0CC8\u0CCA-\u0CCD\u0CD5\u0CD6\u0CDE\u0CE0-\u0CE3\u0CE6-\u0CEF\u0CF1\u0CF2\u0D00-\u0D03\u0D05-\u0D0C\u0D0E-\u0D10\u0D12-\u0D44\u0D46-\u0D48\u0D4A-\u0D4E\u0D54-\u0D57\u0D5F-\u0D63\u0D66-\u0D6F\u0D7A-\u0D7F\u0D82\u0D83\u0D85-\u0D96\u0D9A-\u0DB1\u0DB3-\u0DBB\u0DBD\u0DC0-\u0DC6\u0DCA\u0DCF-\u0DD4\u0DD6\u0DD8-\u0DDF\u0DE6-\u0DEF\u0DF2\u0DF3\u0E01-\u0E3A\u0E40-\u0E4E\u0E50-\u0E59\u0E81\u0E82\u0E84\u0E87\u0E88\u0E8A\u0E8D\u0E94-\u0E97\u0E99-\u0E9F\u0EA1-\u0EA3\u0EA5\u0EA7\u0EAA\u0EAB\u0EAD-\u0EB9\u0EBB-\u0EBD\u0EC0-\u0EC4\u0EC6\u0EC8-\u0ECD\u0ED0-\u0ED9\u0EDC-\u0EDF\u0F00\u0F18\u0F19\u0F20-\u0F29\u0F35\u0F37\u0F39\u0F3E-\u0F47\u0F49-\u0F6C\u0F71-\u0F84\u0F86-\u0F97\u0F99-\u0FBC\u0FC6\u1000-\u1049\u1050-\u109D\u10A0-\u10C5\u10C7\u10CD\u10D0-\u10FA\u10FC-\u1248\u124A-\u124D\u1250-\u1256\u1258\u125A-\u125D\u1260-\u1288\u128A-\u128D\u1290-\u12B0\u12B2-\u12B5\u12B8-\u12BE\u12C0\u12C2-\u12C5\u12C8-\u12D6\u12D8-\u1310\u1312-\u1315\u1318-\u135A\u135D-\u135F\u1380-\u138F\u13A0-\u13F5\u13F8-\u13FD\u1401-\u166C\u166F-\u167F\u1681-\u169A\u16A0-\u16EA\u16EE-\u16F8\u1700-\u170C\u170E-\u1714\u1720-\u1734\u1740-\u1753\u1760-\u176C\u176E-\u1770\u1772\u1773\u1780-\u17D3\u17D7\u17DC\u17DD\u17E0-\u17E9\u180B-\u180D\u1810-\u1819\u1820-\u1877\u1880-\u18AA\u18B0-\u18F5\u1900-\u191E\u1920-\u192B\u1930-\u193B\u1946-\u196D\u1970-\u1974\u1980-\u19AB\u19B0-\u19C9\u19D0-\u19D9\u1A00-\u1A1B\u1A20-\u1A5E\u1A60-\u1A7C\u1A7F-\u1A89\u1A90-\u1A99\u1AA7\u1AB0-\u1ABD\u1B00-\u1B4B\u1B50-\u1B59\u1B6B-\u1B73\u1B80-\u1BF3\u1C00-\u1C37\u1C40-\u1C49\u1C4D-\u1C7D\u1C80-\u1C88\u1CD0-\u1CD2\u1CD4-\u1CF9\u1D00-\u1DF9\u1DFB-\u1F15\u1F18-\u1F1D\u1F20-\u1F45\u1F48-\u1F4D\u1F50-\u1F57\u1F59\u1F5B\u1F5D\u1F5F-\u1F7D\u1F80-\u1FB4\u1FB6-\u1FBC\u1FBE\u1FC2-\u1FC4\u1FC6-\u1FCC\u1FD0-\u1FD3\u1FD6-\u1FDB\u1FE0-\u1FEC\u1FF2-\u1FF4\u1FF6-\u1FFC\u203F\u2040\u2054\u2071\u207F\u2090-\u209C\u20D0-\u20DC\u20E1\u20E5-\u20F0\u2102\u2107\u210A-\u2113\u2115\u2119-\u211D\u2124\u2126\u2128\u212A-\u212D\u212F-\u2139\u213C-\u213F\u2145-\u2149\u214E\u2160-\u2188\u2C00-\u2C2E\u2C30-\u2C5E\u2C60-\u2CE4\u2CEB-\u2CF3\u2D00-\u2D25\u2D27\u2D2D\u2D30-\u2D67\u2D6F\u2D7F-\u2D96\u2DA0-\u2DA6\u2DA8-\u2DAE\u2DB0-\u2DB6\u2DB8-\u2DBE\u2DC0-\u2DC6\u2DC8-\u2DCE\u2DD0-\u2DD6\u2DD8-\u2DDE\u2DE0-\u2DFF\u2E2F\u3005-\u3007\u3021-\u302F\u3031-\u3035\u3038-\u303C\u3041-\u3096\u3099\u309A\u309D-\u309F\u30A1-\u30FA\u30FC-\u30FF\u3105-\u312E\u3131-\u318E\u31A0-\u31BA\u31F0-\u31FF\u3400-\u4DB5\u4E00-\u9FEA\uA000-\uA48C\uA4D0-\uA4FD\uA500-\uA60C\uA610-\uA62B\uA640-\uA66F\uA674-\uA67D\uA67F-\uA6F1\uA717-\uA71F\uA722-\uA788\uA78B-\uA7AE\uA7B0-\uA7B7\uA7F7-\uA827\uA840-\uA873\uA880-\uA8C5\uA8D0-\uA8D9\uA8E0-\uA8F7\uA8FB\uA8FD\uA900-\uA92D\uA930-\uA953\uA960-\uA97C\uA980-\uA9C0\uA9CF-\uA9D9\uA9E0-\uA9FE\uAA00-\uAA36\uAA40-\uAA4D\uAA50-\uAA59\uAA60-\uAA76\uAA7A-\uAAC2\uAADB-\uAADD\uAAE0-\uAAEF\uAAF2-\uAAF6\uAB01-\uAB06\uAB09-\uAB0E\uAB11-\uAB16\uAB20-\uAB26\uAB28-\uAB2E\uAB30-\uAB5A\uAB5C-\uAB65\uAB70-\uABEA\uABEC\uABED\uABF0-\uABF9\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFA6D\uFA70-\uFAD9\uFB00-\uFB06\uFB13-\uFB17\uFB1D-\uFB28\uFB2A-\uFB36\uFB38-\uFB3C\uFB3E\uFB40\uFB41\uFB43\uFB44\uFB46-\uFBB1\uFBD3-\uFD3D\uFD50-\uFD8F\uFD92-\uFDC7\uFDF0-\uFDFB\uFE00-\uFE0F\uFE20-\uFE2F\uFE33\uFE34\uFE4D-\uFE4F\uFE70-\uFE74\uFE76-\uFEFC\uFF10-\uFF19\uFF21-\uFF3A\uFF3F\uFF41-\uFF5A\uFF66-\uFFBE\uFFC2-\uFFC7\uFFCA-\uFFCF\uFFD2-\uFFD7\uFFDA-\uFFDC]|\uD800[\uDC00-\uDC0B\uDC0D-\uDC26\uDC28-\uDC3A\uDC3C\uDC3D\uDC3F-\uDC4D\uDC50-\uDC5D\uDC80-\uDCFA\uDD40-\uDD74\uDDFD\uDE80-\uDE9C\uDEA0-\uDED0\uDEE0\uDF00-\uDF1F\uDF2D-\uDF4A\uDF50-\uDF7A\uDF80-\uDF9D\uDFA0-\uDFC3\uDFC8-\uDFCF\uDFD1-\uDFD5]|\uD801[\uDC00-\uDC9D\uDCA0-\uDCA9\uDCB0-\uDCD3\uDCD8-\uDCFB\uDD00-\uDD27\uDD30-\uDD63\uDE00-\uDF36\uDF40-\uDF55\uDF60-\uDF67]|\uD802[\uDC00-\uDC05\uDC08\uDC0A-\uDC35\uDC37\uDC38\uDC3C\uDC3F-\uDC55\uDC60-\uDC76\uDC80-\uDC9E\uDCE0-\uDCF2\uDCF4\uDCF5\uDD00-\uDD15\uDD20-\uDD39\uDD80-\uDDB7\uDDBE\uDDBF\uDE00-\uDE03\uDE05\uDE06\uDE0C-\uDE13\uDE15-\uDE17\uDE19-\uDE33\uDE38-\uDE3A\uDE3F\uDE60-\uDE7C\uDE80-\uDE9C\uDEC0-\uDEC7\uDEC9-\uDEE6\uDF00-\uDF35\uDF40-\uDF55\uDF60-\uDF72\uDF80-\uDF91]|\uD803[\uDC00-\uDC48\uDC80-\uDCB2\uDCC0-\uDCF2]|\uD804[\uDC00-\uDC46\uDC66-\uDC6F\uDC7F-\uDCBA\uDCD0-\uDCE8\uDCF0-\uDCF9\uDD00-\uDD34\uDD36-\uDD3F\uDD50-\uDD73\uDD76\uDD80-\uDDC4\uDDCA-\uDDCC\uDDD0-\uDDDA\uDDDC\uDE00-\uDE11\uDE13-\uDE37\uDE3E\uDE80-\uDE86\uDE88\uDE8A-\uDE8D\uDE8F-\uDE9D\uDE9F-\uDEA8\uDEB0-\uDEEA\uDEF0-\uDEF9\uDF00-\uDF03\uDF05-\uDF0C\uDF0F\uDF10\uDF13-\uDF28\uDF2A-\uDF30\uDF32\uDF33\uDF35-\uDF39\uDF3C-\uDF44\uDF47\uDF48\uDF4B-\uDF4D\uDF50\uDF57\uDF5D-\uDF63\uDF66-\uDF6C\uDF70-\uDF74]|\uD805[\uDC00-\uDC4A\uDC50-\uDC59\uDC80-\uDCC5\uDCC7\uDCD0-\uDCD9\uDD80-\uDDB5\uDDB8-\uDDC0\uDDD8-\uDDDD\uDE00-\uDE40\uDE44\uDE50-\uDE59\uDE80-\uDEB7\uDEC0-\uDEC9\uDF00-\uDF19\uDF1D-\uDF2B\uDF30-\uDF39]|\uD806[\uDCA0-\uDCE9\uDCFF\uDE00-\uDE3E\uDE47\uDE50-\uDE83\uDE86-\uDE99\uDEC0-\uDEF8]|\uD807[\uDC00-\uDC08\uDC0A-\uDC36\uDC38-\uDC40\uDC50-\uDC59\uDC72-\uDC8F\uDC92-\uDCA7\uDCA9-\uDCB6\uDD00-\uDD06\uDD08\uDD09\uDD0B-\uDD36\uDD3A\uDD3C\uDD3D\uDD3F-\uDD47\uDD50-\uDD59]|\uD808[\uDC00-\uDF99]|\uD809[\uDC00-\uDC6E\uDC80-\uDD43]|[\uD80C\uD81C-\uD820\uD840-\uD868\uD86A-\uD86C\uD86F-\uD872\uD874-\uD879][\uDC00-\uDFFF]|\uD80D[\uDC00-\uDC2E]|\uD811[\uDC00-\uDE46]|\uD81A[\uDC00-\uDE38\uDE40-\uDE5E\uDE60-\uDE69\uDED0-\uDEED\uDEF0-\uDEF4\uDF00-\uDF36\uDF40-\uDF43\uDF50-\uDF59\uDF63-\uDF77\uDF7D-\uDF8F]|\uD81B[\uDF00-\uDF44\uDF50-\uDF7E\uDF8F-\uDF9F\uDFE0\uDFE1]|\uD821[\uDC00-\uDFEC]|\uD822[\uDC00-\uDEF2]|\uD82C[\uDC00-\uDD1E\uDD70-\uDEFB]|\uD82F[\uDC00-\uDC6A\uDC70-\uDC7C\uDC80-\uDC88\uDC90-\uDC99\uDC9D\uDC9E]|\uD834[\uDD65-\uDD69\uDD6D-\uDD72\uDD7B-\uDD82\uDD85-\uDD8B\uDDAA-\uDDAD\uDE42-\uDE44]|\uD835[\uDC00-\uDC54\uDC56-\uDC9C\uDC9E\uDC9F\uDCA2\uDCA5\uDCA6\uDCA9-\uDCAC\uDCAE-\uDCB9\uDCBB\uDCBD-\uDCC3\uDCC5-\uDD05\uDD07-\uDD0A\uDD0D-\uDD14\uDD16-\uDD1C\uDD1E-\uDD39\uDD3B-\uDD3E\uDD40-\uDD44\uDD46\uDD4A-\uDD50\uDD52-\uDEA5\uDEA8-\uDEC0\uDEC2-\uDEDA\uDEDC-\uDEFA\uDEFC-\uDF14\uDF16-\uDF34\uDF36-\uDF4E\uDF50-\uDF6E\uDF70-\uDF88\uDF8A-\uDFA8\uDFAA-\uDFC2\uDFC4-\uDFCB\uDFCE-\uDFFF]|\uD836[\uDE00-\uDE36\uDE3B-\uDE6C\uDE75\uDE84\uDE9B-\uDE9F\uDEA1-\uDEAF]|\uD838[\uDC00-\uDC06\uDC08-\uDC18\uDC1B-\uDC21\uDC23\uDC24\uDC26-\uDC2A]|\uD83A[\uDC00-\uDCC4\uDCD0-\uDCD6\uDD00-\uDD4A\uDD50-\uDD59]|\uD83B[\uDE00-\uDE03\uDE05-\uDE1F\uDE21\uDE22\uDE24\uDE27\uDE29-\uDE32\uDE34-\uDE37\uDE39\uDE3B\uDE42\uDE47\uDE49\uDE4B\uDE4D-\uDE4F\uDE51\uDE52\uDE54\uDE57\uDE59\uDE5B\uDE5D\uDE5F\uDE61\uDE62\uDE64\uDE67-\uDE6A\uDE6C-\uDE72\uDE74-\uDE77\uDE79-\uDE7C\uDE7E\uDE80-\uDE89\uDE8B-\uDE9B\uDEA1-\uDEA3\uDEA5-\uDEA9\uDEAB-\uDEBB]|\uD869[\uDC00-\uDED6\uDF00-\uDFFF]|\uD86D[\uDC00-\uDF34\uDF40-\uDFFF]|\uD86E[\uDC00-\uDC1D\uDC20-\uDFFF]|\uD873[\uDC00-\uDEA1\uDEB0-\uDFFF]|\uD87A[\uDC00-\uDFE0]|\uD87E[\uDC00-\uDE1D]|\uDB40[\uDD00-\uDDEF]/,Object.defineProperty(m,"__esModule",{value:!0}),m.JudgeUtil=void 0;const I=R;m.JudgeUtil=class{static isIgnoreChar(u){return"string"==typeof u&&("\t"===u||"\v"===u||"\f"===u||" "===u||" "===u||"\ufeff"===u||"\n"===u||"\r"===u||"\u2028"===u||"\u2029"===u)}static isSpaceSeparator(u){return"string"==typeof u&&I.Unicode.SPACE_SEPARATOR.test(u)}static isIdStartChar(u){return"string"==typeof u&&(u>="a"&&u<="z"||u>="A"&&u<="Z"||"$"===u||"_"===u||I.Unicode.ID_START.test(u))}static isIdContinueChar(u){return"string"==typeof u&&(u>="a"&&u<="z"||u>="A"&&u<="Z"||u>="0"&&u<="9"||"$"===u||"_"===u||"‌"===u||"‍"===u||I.Unicode.ID_CONTINUE.test(u))}static isDigitWithoutZero(u){return/[1-9]/.test(u)}static isDigit(u){return"string"==typeof u&&/[0-9]/.test(u)}static isHexDigit(u){return"string"==typeof u&&/[0-9A-Fa-f]/.test(u)}};var N=n&&n.__importDefault||function(u){return u&&u.__esModule?u:{default:u}};Object.defineProperty(g,"__esModule",{value:!0}),g.parseJsonText=g.parseJsonFile=void 0;const b=N(e),S=N(D),w=N(u),H=m;var x;!function(u){u[u.Char=0]="Char",u[u.EOF=1]="EOF",u[u.Identifier=2]="Identifier"}(x||(x={}));let M,T,V,G,j,J,W="start",U=[],L=0,$=1,k=0,K=!1,z="default",q="'",Z=1;function X(u,D=!1){T=String(u),W="start",U=[],L=0,$=1,k=0,G=void 0,K=D;do{M=Q(),nu[W]()}while("eof"!==M.type);return G}function Q(){for(z="default",j="",q="'",Z=1;;){J=Y();const u=Du[z]();if(u)return u}}function Y(){if(T[L])return String.fromCodePoint(T.codePointAt(L))}function uu(){const u=Y();return"\n"===u?($++,k=0):u?k+=u.length:k++,u&&(L+=u.length),u}g.parseJsonFile=function(u,D=!1,e="utf-8"){const t=b.default.readFileSync(w.default.resolve(u),{encoding:e});try{return X(t,D)}catch(D){if(D instanceof SyntaxError){const e=D.message.split("at");if(2===e.length)throw new Error(`${e[0].trim()}${S.default.EOL}\t at ${u}:${e[1].trim()}`)}throw new Error(`${u} is not in valid JSON/JSON5 format.`)}},g.parseJsonText=X;const Du={default(){switch(J){case"/":return uu(),void(z="comment");case void 0:return uu(),eu("eof")}if(!H.JudgeUtil.isIgnoreChar(J)&&!H.JudgeUtil.isSpaceSeparator(J))return Du[W]();uu()},start(){z="value"},beforePropertyName(){switch(J){case"$":case"_":return j=uu(),void(z="identifierName");case"\\":return uu(),void(z="identifierNameStartEscape");case"}":return eu("punctuator",uu());case'"':case"'":return q=J,uu(),void(z="string")}if(H.JudgeUtil.isIdStartChar(J))return j+=uu(),void(z="identifierName");throw Eu(x.Char,uu())},afterPropertyName(){if(":"===J)return eu("punctuator",uu());throw Eu(x.Char,uu())},beforePropertyValue(){z="value"},afterPropertyValue(){switch(J){case",":case"}":return eu("punctuator",uu())}throw Eu(x.Char,uu())},beforeArrayValue(){if("]"===J)return eu("punctuator",uu());z="value"},afterArrayValue(){switch(J){case",":case"]":return eu("punctuator",uu())}throw Eu(x.Char,uu())},end(){throw Eu(x.Char,uu())},comment(){switch(J){case"*":return uu(),void(z="multiLineComment");case"/":return uu(),void(z="singleLineComment")}throw Eu(x.Char,uu())},multiLineComment(){switch(J){case"*":return uu(),void(z="multiLineCommentAsterisk");case void 0:throw Eu(x.Char,uu())}uu()},multiLineCommentAsterisk(){switch(J){case"*":return void uu();case"/":return uu(),void(z="default");case void 0:throw Eu(x.Char,uu())}uu(),z="multiLineComment"},singleLineComment(){switch(J){case"\n":case"\r":case"\u2028":case"\u2029":return uu(),void(z="default");case void 0:return uu(),eu("eof")}uu()},value(){switch(J){case"{":case"[":return eu("punctuator",uu());case"n":return uu(),tu("ull"),eu("null",null);case"t":return uu(),tu("rue"),eu("boolean",!0);case"f":return uu(),tu("alse"),eu("boolean",!1);case"-":case"+":return"-"===uu()&&(Z=-1),void(z="numerical");case".":case"0":case"I":case"N":return void(z="numerical");case'"':case"'":return q=J,uu(),j="",void(z="string")}if(void 0===J||!H.JudgeUtil.isDigitWithoutZero(J))throw Eu(x.Char,uu());z="numerical"},numerical(){switch(J){case".":return j=uu(),void(z="decimalPointLeading");case"0":return j=uu(),void(z="zero");case"I":return uu(),tu("nfinity"),eu("numeric",Z*(1/0));case"N":return uu(),tu("aN"),eu("numeric",NaN)}if(void 0!==J&&H.JudgeUtil.isDigitWithoutZero(J))return j=uu(),void(z="decimalInteger");throw Eu(x.Char,uu())},zero(){switch(J){case".":case"e":case"E":return void(z="decimal");case"x":case"X":return j+=uu(),void(z="hexadecimal")}return eu("numeric",0)},decimalInteger(){switch(J){case".":case"e":case"E":return void(z="decimal")}if(!H.JudgeUtil.isDigit(J))return eu("numeric",Z*Number(j));j+=uu()},decimal(){switch(J){case".":j+=uu(),z="decimalFraction";break;case"e":case"E":j+=uu(),z="decimalExponent"}},decimalPointLeading(){if(H.JudgeUtil.isDigit(J))return j+=uu(),void(z="decimalFraction");throw Eu(x.Char,uu())},decimalFraction(){switch(J){case"e":case"E":return j+=uu(),void(z="decimalExponent")}if(!H.JudgeUtil.isDigit(J))return eu("numeric",Z*Number(j));j+=uu()},decimalExponent(){switch(J){case"+":case"-":return j+=uu(),void(z="decimalExponentSign")}if(H.JudgeUtil.isDigit(J))return j+=uu(),void(z="decimalExponentInteger");throw Eu(x.Char,uu())},decimalExponentSign(){if(H.JudgeUtil.isDigit(J))return j+=uu(),void(z="decimalExponentInteger");throw Eu(x.Char,uu())},decimalExponentInteger(){if(!H.JudgeUtil.isDigit(J))return eu("numeric",Z*Number(j));j+=uu()},hexadecimal(){if(H.JudgeUtil.isHexDigit(J))return j+=uu(),void(z="hexadecimalInteger");throw Eu(x.Char,uu())},hexadecimalInteger(){if(!H.JudgeUtil.isHexDigit(J))return eu("numeric",Z*Number(j));j+=uu()},identifierNameStartEscape(){if("u"!==J)throw Eu(x.Char,uu());uu();const u=ru();switch(u){case"$":case"_":break;default:if(!H.JudgeUtil.isIdStartChar(u))throw Eu(x.Identifier)}j+=u,z="identifierName"},identifierName(){switch(J){case"$":case"_":case"‌":case"‍":return void(j+=uu());case"\\":return uu(),void(z="identifierNameEscape")}if(!H.JudgeUtil.isIdContinueChar(J))return eu("identifier",j);j+=uu()},identifierNameEscape(){if("u"!==J)throw Eu(x.Char,uu());uu();const u=ru();switch(u){case"$":case"_":case"‌":case"‍":break;default:if(!H.JudgeUtil.isIdContinueChar(u))throw Eu(x.Identifier)}j+=u,z="identifierName"},string(){switch(J){case"\\":return uu(),void(j+=function(){const u=Y(),D=function(){switch(Y()){case"b":return uu(),"\b";case"f":return uu(),"\f";case"n":return uu(),"\n";case"r":return uu(),"\r";case"t":return uu(),"\t";case"v":return uu(),"\v"}return}();if(D)return D;switch(u){case"0":if(uu(),H.JudgeUtil.isDigit(Y()))throw Eu(x.Char,uu());return"\0";case"x":return uu(),function(){let u="",D=Y();if(!H.JudgeUtil.isHexDigit(D))throw Eu(x.Char,uu());if(u+=uu(),D=Y(),!H.JudgeUtil.isHexDigit(D))throw Eu(x.Char,uu());return u+=uu(),String.fromCodePoint(parseInt(u,16))}();case"u":return uu(),ru();case"\n":case"\u2028":case"\u2029":return uu(),"";case"\r":return uu(),"\n"===Y()&&uu(),""}if(void 0===u||H.JudgeUtil.isDigitWithoutZero(u))throw Eu(x.Char,uu());return uu()}());case'"':case"'":if(J===q){const u=eu("string",j);return uu(),u}return void(j+=uu());case"\n":case"\r":case void 0:throw Eu(x.Char,uu());case"\u2028":case"\u2029":!function(u){console.warn(`JSON5: '${Fu(u)}' in strings is not valid ECMAScript; consider escaping.`)}(J)}j+=uu()}};function eu(u,D){return{type:u,value:D,line:$,column:k}}function tu(u){for(const D of u){if(Y()!==D)throw Eu(x.Char,uu());uu()}}function ru(){let u="",D=4;for(;D-- >0;){const D=Y();if(!H.JudgeUtil.isHexDigit(D))throw Eu(x.Char,uu());u+=uu()}return String.fromCodePoint(parseInt(u,16))}const nu={start(){if("eof"===M.type)throw Eu(x.EOF);iu()},beforePropertyName(){switch(M.type){case"identifier":case"string":return V=M.value,void(W="afterPropertyName");case"punctuator":return void Cu();case"eof":throw Eu(x.EOF)}},afterPropertyName(){if("eof"===M.type)throw Eu(x.EOF);W="beforePropertyValue"},beforePropertyValue(){if("eof"===M.type)throw Eu(x.EOF);iu()},afterPropertyValue(){if("eof"===M.type)throw Eu(x.EOF);switch(M.value){case",":return void(W="beforePropertyName");case"}":Cu()}},beforeArrayValue(){if("eof"===M.type)throw Eu(x.EOF);"punctuator"!==M.type||"]"!==M.value?iu():Cu()},afterArrayValue(){if("eof"===M.type)throw Eu(x.EOF);switch(M.value){case",":return void(W="beforeArrayValue");case"]":Cu()}},end(){}};function iu(){const u=function(){let u;switch(M.type){case"punctuator":switch(M.value){case"{":u={};break;case"[":u=[]}break;case"null":case"boolean":case"numeric":case"string":u=M.value}return u}();if(K&&"object"==typeof u&&(u._line=$,u._column=k),void 0===G)G=u;else{const D=U[U.length-1];Array.isArray(D)?K&&"object"!=typeof u?D.push({value:u,_line:$,_column:k}):D.push(u):D[V]=K&&"object"!=typeof u?{value:u,_line:$,_column:k}:u}!function(u){if(u&&"object"==typeof u)U.push(u),W=Array.isArray(u)?"beforeArrayValue":"beforePropertyName";else{const u=U[U.length-1];W=u?Array.isArray(u)?"afterArrayValue":"afterPropertyValue":"end"}}(u)}function Cu(){U.pop();const u=U[U.length-1];W=u?Array.isArray(u)?"afterArrayValue":"afterPropertyValue":"end"}function Fu(u){const D={"'":"\\'",'"':'\\"',"\\":"\\\\","\b":"\\b","\f":"\\f","\n":"\\n","\r":"\\r","\t":"\\t","\v":"\\v","\0":"\\0","\u2028":"\\u2028","\u2029":"\\u2029"};if(D[u])return D[u];if(u<" "){const D=u.charCodeAt(0).toString(16);return`\\x${`00${D}`.substring(D.length)}`}return u}function Eu(u,D){let e="";switch(u){case x.Char:e=void 0===D?`JSON5: invalid end of input at ${$}:${k}`:`JSON5: invalid character '${Fu(D)}' at ${$}:${k}`;break;case x.EOF:e=`JSON5: invalid end of input at ${$}:${k}`;break;case x.Identifier:k-=5,e=`JSON5: invalid identifier character at ${$}:${k}`}const t=new Au(e);return t.lineNumber=$,t.columnNumber=k,t}class Au extends SyntaxError{}var ou={},au=n&&n.__createBinding||(Object.create?function(u,D,e,t){void 0===t&&(t=e);var r=Object.getOwnPropertyDescriptor(D,e);r&&!("get"in r?!D.__esModule:r.writable||r.configurable)||(r={enumerable:!0,get:function(){return D[e]}}),Object.defineProperty(u,t,r)}:function(u,D,e,t){void 0===t&&(t=e),u[t]=D[e]}),cu=n&&n.__setModuleDefault||(Object.create?function(u,D){Object.defineProperty(u,"default",{enumerable:!0,value:D})}:function(u,D){u.default=D}),su=n&&n.__importStar||function(u){if(u&&u.__esModule)return u;var D={};if(null!=u)for(var e in u)"default"!==e&&Object.prototype.hasOwnProperty.call(u,e)&&au(D,u,e);return cu(D,u),D},lu=n&&n.__importDefault||function(u){return u&&u.__esModule?u:{default:u}};Object.defineProperty(ou,"__esModule",{value:!0}),ou.isFileExists=ou.offlinePluginConversion=ou.executeCommand=ou.getNpmPath=ou.hasNpmPackInPaths=void 0;const Bu=r,du=lu(e),fu=su(u),_u=i,pu=l;ou.hasNpmPackInPaths=function(u,D){try{return require.resolve(u,{paths:[...D]}),!0}catch(u){return!1}},ou.getNpmPath=function(){const u=process.execPath;return fu.join(fu.dirname(u),_u.NPM_TOOL)},ou.executeCommand=function(u,D,e){0!==(0,Bu.spawnSync)(u,D,e).status&&(0,pu.logErrorAndExit)(`Error: ${u} ${D} execute failed.See above for details.`)},ou.offlinePluginConversion=function(u,D){return D.startsWith("file:")||D.endsWith(".tgz")?fu.resolve(u,_u.HVIGOR,D.replace("file:","")):D},ou.isFileExists=function(u){return du.default.existsSync(u)&&du.default.statSync(u).isFile()};var Ou=n&&n.__createBinding||(Object.create?function(u,D,e,t){void 0===t&&(t=e);var r=Object.getOwnPropertyDescriptor(D,e);r&&!("get"in r?!D.__esModule:r.writable||r.configurable)||(r={enumerable:!0,get:function(){return D[e]}}),Object.defineProperty(u,t,r)}:function(u,D,e,t){void 0===t&&(t=e),u[t]=D[e]}),hu=n&&n.__setModuleDefault||(Object.create?function(u,D){Object.defineProperty(u,"default",{enumerable:!0,value:D})}:function(u,D){u.default=D}),Pu=n&&n.__importStar||function(u){if(u&&u.__esModule)return u;var D={};if(null!=u)for(var e in u)"default"!==e&&Object.prototype.hasOwnProperty.call(u,e)&&Ou(D,u,e);return hu(D,u),D},vu=n&&n.__importDefault||function(u){return u&&u.__esModule?u:{default:u}};Object.defineProperty(P,"__esModule",{value:!0});var gu=P.initProjectWorkSpace=void 0;const mu=Pu(e),Ru=vu(D),yu=Pu(u),Iu=v,Nu=i,bu=g,Su=l,wu=ou;let Hu,xu,Mu;function Tu(u,D,e){return void 0!==e.dependencies&&(0,wu.offlinePluginConversion)(Nu.HVIGOR_PROJECT_ROOT_DIR,D.dependencies[u])===yu.normalize(e.dependencies[u])}function Vu(){const u=yu.join(Mu,Nu.WORK_SPACE);if((0,Su.logInfoPrintConsole)("Hvigor cleaning..."),!mu.existsSync(u))return;const D=mu.readdirSync(u);if(!D||0===D.length)return;const e=yu.resolve(Mu,"node_modules","@ohos","hvigor","bin","hvigor.js");mu.existsSync(e)&&(0,wu.executeCommand)(process.argv[0],[e,"--stop-daemon"],{});try{D.forEach((D=>{mu.rmSync(yu.resolve(u,D),{recursive:!0})}))}catch(D){(0,Su.logErrorAndExit)(`The hvigor build tool cannot be installed. Please manually clear the workspace directory and synchronize the project again.\n\n Workspace Path: ${u}.`)}}gu=P.initProjectWorkSpace=function(){if(Hu=function(){const u=yu.resolve(Nu.HVIGOR_PROJECT_WRAPPER_HOME,Nu.DEFAULT_HVIGOR_CONFIG_JSON_FILE_NAME);mu.existsSync(u)||(0,Su.logErrorAndExit)(`Error: Hvigor config file ${u} does not exist.`);return(0,bu.parseJsonFile)(u)}(),Mu=function(u){let D;D=function(u){let D=u.hvigorVersion;if(D.startsWith("file:")||D.endsWith(".tgz"))return!1;const e=u.dependencies,t=Object.getOwnPropertyNames(e);for(const u of t){const D=e[u];if(D.startsWith("file:")||D.endsWith(".tgz"))return!1}if(1===t.length&&"@ohos/hvigor-ohos-plugin"===t[0])return D>"2.5.0";return!1}(u)?function(u){let D=`${Nu.HVIGOR_ENGINE_PACKAGE_NAME}@${u.hvigorVersion}`;const e=u.dependencies;if(e){Object.getOwnPropertyNames(e).sort().forEach((u=>{D+=`,${u}@${e[u]}`}))}return(0,Iu.hash)(D)}(u):(0,Iu.hash)(process.cwd());return yu.resolve(Ru.default.homedir(),".hvigor","project_caches",D)}(Hu),xu=function(){const u=yu.resolve(Mu,Nu.WORK_SPACE,Nu.DEFAULT_PACKAGE_JSON);return mu.existsSync(u)?(0,bu.parseJsonFile)(u):{dependencies:{}}}(),!(0,wu.hasNpmPackInPaths)(Nu.HVIGOR_ENGINE_PACKAGE_NAME,[yu.join(Mu,Nu.WORK_SPACE)])||(0,wu.offlinePluginConversion)(Nu.HVIGOR_PROJECT_ROOT_DIR,Hu.hvigorVersion)!==xu.dependencies[Nu.HVIGOR_ENGINE_PACKAGE_NAME]||!function(){function u(u){const D=null==u?void 0:u.dependencies;return void 0===D?0:Object.getOwnPropertyNames(D).length}const D=u(Hu),e=u(xu);if(D+1!==e)return!1;for(const u in null==Hu?void 0:Hu.dependencies)if(!(0,wu.hasNpmPackInPaths)(u,[yu.join(Mu,Nu.WORK_SPACE)])||!Tu(u,Hu,xu))return!1;return!0}()){Vu();try{!function(){(0,Su.logInfoPrintConsole)("Hvigor installing...");for(const u in Hu.dependencies)Hu.dependencies[u]&&(Hu.dependencies[u]=(0,wu.offlinePluginConversion)(Nu.HVIGOR_PROJECT_ROOT_DIR,Hu.dependencies[u]));const u={dependencies:{...Hu.dependencies}};u.dependencies[Nu.HVIGOR_ENGINE_PACKAGE_NAME]=(0,wu.offlinePluginConversion)(Nu.HVIGOR_PROJECT_ROOT_DIR,Hu.hvigorVersion);const D=yu.join(Mu,Nu.WORK_SPACE);try{mu.mkdirSync(D,{recursive:!0});const e=yu.resolve(D,Nu.DEFAULT_PACKAGE_JSON);mu.writeFileSync(e,JSON.stringify(u))}catch(u){(0,Su.logErrorAndExit)(u)}(function(){const u=["config","set","store-dir",Nu.HVIGOR_PNPM_STORE_PATH],D={cwd:yu.join(Mu,Nu.WORK_SPACE),stdio:["inherit","inherit","inherit"]};(0,wu.executeCommand)(Nu.HVIGOR_WRAPPER_PNPM_SCRIPT_PATH,u,D)})(),function(){const u=["install"],D={cwd:yu.join(Mu,Nu.WORK_SPACE),stdio:["inherit","inherit","inherit"]};(0,wu.executeCommand)(Nu.HVIGOR_WRAPPER_PNPM_SCRIPT_PATH,u,D)}(),(0,Su.logInfoPrintConsole)("Hvigor install success.")}()}catch(u){Vu()}}return Mu};var Gu={};!function(t){var C=n&&n.__createBinding||(Object.create?function(u,D,e,t){void 0===t&&(t=e);var r=Object.getOwnPropertyDescriptor(D,e);r&&!("get"in r?!D.__esModule:r.writable||r.configurable)||(r={enumerable:!0,get:function(){return D[e]}}),Object.defineProperty(u,t,r)}:function(u,D,e,t){void 0===t&&(t=e),u[t]=D[e]}),F=n&&n.__setModuleDefault||(Object.create?function(u,D){Object.defineProperty(u,"default",{enumerable:!0,value:D})}:function(u,D){u.default=D}),E=n&&n.__importStar||function(u){if(u&&u.__esModule)return u;var D={};if(null!=u)for(var e in u)"default"!==e&&Object.prototype.hasOwnProperty.call(u,e)&&C(D,u,e);return F(D,u),D},A=n&&n.__importDefault||function(u){return u&&u.__esModule?u:{default:u}};Object.defineProperty(t,"__esModule",{value:!0}),t.executeInstallPnpm=t.isPnpmInstalled=t.environmentHandler=t.checkNpmConifg=t.PNPM_VERSION=void 0;const o=r,a=E(e),c=A(D),s=E(u),B=i,d=l,f=ou;t.PNPM_VERSION="7.30.0",t.checkNpmConifg=function(){const u=s.resolve(B.HVIGOR_PROJECT_ROOT_DIR,".npmrc"),D=s.resolve(c.default.homedir(),".npmrc");if((0,f.isFileExists)(u)||(0,f.isFileExists)(D))return;const e=(0,f.getNpmPath)(),t=(0,o.spawnSync)(e,["config","get","prefix"],{cwd:B.HVIGOR_PROJECT_ROOT_DIR});if(0!==t.status||!t.stdout)return void(0,d.logErrorAndExit)("Error: The hvigor depends on the npmrc file. Configure the npmrc file first.");const r=s.resolve(`${t.stdout}`.replace(/[\r\n]/gi,""),".npmrc");(0,f.isFileExists)(r)||(0,d.logErrorAndExit)("Error: The hvigor depends on the npmrc file. Configure the npmrc file first.")},t.environmentHandler=function(){process.env["npm_config_update-notifier"]="false"},t.isPnpmInstalled=function(){return!!a.existsSync(B.HVIGOR_WRAPPER_PNPM_SCRIPT_PATH)&&(0,f.hasNpmPackInPaths)("pnpm",[B.HVIGOR_WRAPPER_TOOLS_HOME])},t.executeInstallPnpm=function(){(0,d.logInfoPrintConsole)(`Installing pnpm@${t.PNPM_VERSION}...`);const u=(0,f.getNpmPath)();!function(){const u=s.resolve(B.HVIGOR_WRAPPER_TOOLS_HOME,B.DEFAULT_PACKAGE_JSON);try{a.existsSync(B.HVIGOR_WRAPPER_TOOLS_HOME)||a.mkdirSync(B.HVIGOR_WRAPPER_TOOLS_HOME,{recursive:!0});const D={dependencies:{}};D.dependencies[B.PNPM]=t.PNPM_VERSION,a.writeFileSync(u,JSON.stringify(D))}catch(D){(0,d.logErrorAndExit)(`Error: EPERM: operation not permitted,create ${u} failed.`)}}(),(0,f.executeCommand)(u,["install","pnpm"],{cwd:B.HVIGOR_WRAPPER_TOOLS_HOME,stdio:["inherit","inherit","inherit"],env:process.env}),(0,d.logInfoPrintConsole)("Pnpm install success.")}}(Gu),function(){Gu.checkNpmConifg(),Gu.environmentHandler(),Gu.isPnpmInstalled()||Gu.executeInstallPnpm();const D=gu();_(u.join(D,i.WORK_SPACE))}(); \ No newline at end of file diff --git a/sample/EnhanceSampleArk1.2/ConcurrentModule/hvigorfile.ts b/sample/EnhanceSampleArk1.2/ConcurrentModule/hvigorfile.ts new file mode 100644 index 0000000000000000000000000000000000000000..6478186902c0c1ad7c966a929c7d6b7d8ae7a9f3 --- /dev/null +++ b/sample/EnhanceSampleArk1.2/ConcurrentModule/hvigorfile.ts @@ -0,0 +1,2 @@ +// Script for compiling build behavior. It is built in the build plug-in and cannot be modified currently. +export { appTasks } from '@ohos/hvigor-ohos-plugin'; \ No newline at end of file diff --git a/sample/EnhanceSampleArk1.2/ConcurrentModule/hvigorw b/sample/EnhanceSampleArk1.2/ConcurrentModule/hvigorw new file mode 100644 index 0000000000000000000000000000000000000000..0576aadb4186f97941d687f221099bd29c2cdba0 --- /dev/null +++ b/sample/EnhanceSampleArk1.2/ConcurrentModule/hvigorw @@ -0,0 +1,61 @@ +#!/bin/bash +# ---------------------------------------------------------------------------- +# Copyright (c) 2023 Huawei Device 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. +# ---------------------------------------------------------------------------- +# ---------------------------------------------------------------------------- +# Hvigor startup script, version 1.0.0 +# +# Required ENV vars: +# ------------------ +# NODE_HOME - location of a Node home dir +# or +# Add /usr/local/nodejs/bin to the PATH environment variable +# ---------------------------------------------------------------------------- + +HVIGOR_APP_HOME=$(dirname $(readlink -f $0)) +HVIGOR_WRAPPER_SCRIPT=${HVIGOR_APP_HOME}/hvigor/hvigor-wrapper.js +warn() { + echo "" + echo -e "\033[1;33m`date '+[%Y-%m-%d %H:%M:%S]'`$@\033[0m" +} + +error() { + echo "" + echo -e "\033[1;31m`date '+[%Y-%m-%d %H:%M:%S]'`$@\033[0m" +} + +fail() { + error "$@" + exit 1 +} + +# Determine node to start hvigor wrapper script +if [ -n "${NODE_HOME}" ];then + EXECUTABLE_NODE="${NODE_HOME}/bin/node" + if [ ! -x "$EXECUTABLE_NODE" ];then + fail "ERROR: NODE_HOME is set to an invalid directory,check $NODE_HOME\n\nPlease set NODE_HOME in your environment to the location where your nodejs installed" + fi +else + EXECUTABLE_NODE="node" + which ${EXECUTABLE_NODE} > /dev/null 2>&1 || fail "ERROR: NODE_HOME is not set and not 'node' command found in your path" +fi + +# Check hvigor wrapper script +if [ ! -r "$HVIGOR_WRAPPER_SCRIPT" ];then + fail "ERROR: Couldn't find hvigor/hvigor-wrapper.js in ${HVIGOR_APP_HOME}" +fi + +# start hvigor-wrapper script +exec "${EXECUTABLE_NODE}" \ + "${HVIGOR_WRAPPER_SCRIPT}" "$@" diff --git a/sample/EnhanceSampleArk1.2/ConcurrentModule/hvigorw.bat b/sample/EnhanceSampleArk1.2/ConcurrentModule/hvigorw.bat new file mode 100644 index 0000000000000000000000000000000000000000..af893e9a2c9170d04610c906f1cf1b6f3ac144ac --- /dev/null +++ b/sample/EnhanceSampleArk1.2/ConcurrentModule/hvigorw.bat @@ -0,0 +1,72 @@ +:: Copyright (c) 2023 Huawei Device 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. + +@echo off + +@if "%DEBUG%" == "" @echo off +@rem ########################################################################## +@rem +@rem Hvigor startup script for Windows +@rem +@rem ########################################################################## + +@rem Set local scope for the variables with windows NT shell +if "%OS%"=="Windows_NT" setlocal + +set DIRNAME=%~dp0 +if "%DIRNAME%" == "" set DIRNAME=. +set APP_BASE_NAME=%~n0 +set APP_HOME=%DIRNAME% + +@rem Resolve any "." and ".." in APP_HOME to make it shorter. +for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi + +set WRAPPER_MODULE_PATH=%APP_HOME%\hvigor\hvigor-wrapper.js +set NODE_EXE=node.exe + +goto start + +:start +@rem Find node.exe +if defined NODE_HOME goto findNodeFromNodeHome + +%NODE_EXE% --version >NUL 2>&1 +if "%ERRORLEVEL%" == "0" goto execute + +echo. +echo ERROR: NODE_HOME is not set and no 'node' command could be found in your PATH. +echo. +echo Please set the NODE_HOME variable in your environment to match the +echo location of your NodeJs installation. + +goto fail + +:findNodeFromNodeHome +set NODE_HOME=%NODE_HOME:"=% +set NODE_EXE_PATH=%NODE_HOME%/%NODE_EXE% + +if exist "%NODE_EXE_PATH%" goto execute +echo. +echo ERROR: NODE_HOME is not set and no 'node' command could be found in your PATH. +echo. +echo Please set the NODE_HOME variable in your environment to match the +echo location of your NodeJs installation. + +goto fail + +:execute +@rem Execute hvigor +"%NODE_EXE%" %WRAPPER_MODULE_PATH% %* + +:fail +exit /b 1 diff --git a/sample/EnhanceSampleArk1.2/ConcurrentModule/oh-package.json5 b/sample/EnhanceSampleArk1.2/ConcurrentModule/oh-package.json5 new file mode 100644 index 0000000000000000000000000000000000000000..ac21a550a2b71be3fcb99c6577a806b43240c96e --- /dev/null +++ b/sample/EnhanceSampleArk1.2/ConcurrentModule/oh-package.json5 @@ -0,0 +1,27 @@ +/* + * Copyright (c) 2023 Huawei Device 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. + */ + +{ + "license": "", + "devDependencies": { + "@ohos/hypium": "1.0.6" + }, + "author": "", + "name": "concurrentmodule", + "description": "Please describe the basic information.", + "main": "", + "version": "1.0.0", + "dependencies": {} +} diff --git a/sample/EnhanceSampleArk1.2/ConcurrentModule/ohosTest.md b/sample/EnhanceSampleArk1.2/ConcurrentModule/ohosTest.md new file mode 100644 index 0000000000000000000000000000000000000000..ba0405da61e984e68f6d001b8bf77b9fc5ab6c01 --- /dev/null +++ b/sample/EnhanceSampleArk1.2/ConcurrentModule/ohosTest.md @@ -0,0 +1,10 @@ +| 测试功能 | 预置条件 | 输入 | 预期输出 |是否自动|测试结果| +|---------------|----------|---------------------|-----------------------------------------------------|--------------------------------|--------------------------------| +| 拉起应用 | 设备正常运行 | | 成功拉起应用 |是|Pass| +| 文件拷贝 | 进入首页 | 点击文件拷贝按钮 | 点击文件拷贝按钮 |是|Pass| +| 选择文件并拷贝 | 进入文件拷贝界面 | 点击checkbox选择需要拷贝的文件 | 文件选择完成 |是|Pass| +| 拷贝文件 | 进入文件拷贝界面 | 点击文件拷贝按钮,然后点击返回图标 | 文件拷贝完成并显示相应日志 |是|Pass| +| Worker功能测试 | 执行用例 | 不涉及 | 不涉及 |是|Pass| +| Taskpool功能测试 | 执行用例 | 不涉及 | 不涉及 |是|Pass| +| TaskGroup功能测试 | 执行用例 | 不涉及 | 不涉及 |是|Pass| +| SendableClass功能测试 | 执行用例 | 不涉及 | 不涉及 |是|Pass| \ No newline at end of file diff --git a/sample/EnhanceSampleArk1.2/ConcurrentModule/screenshots/device/copyFile.jpg b/sample/EnhanceSampleArk1.2/ConcurrentModule/screenshots/device/copyFile.jpg new file mode 100644 index 0000000000000000000000000000000000000000..3d1848067e0c0fa3690de3f84a197c3cc7ae0e5e Binary files /dev/null and b/sample/EnhanceSampleArk1.2/ConcurrentModule/screenshots/device/copyFile.jpg differ diff --git a/sample/EnhanceSampleArk1.2/ConcurrentModule/screenshots/device/index.jpg b/sample/EnhanceSampleArk1.2/ConcurrentModule/screenshots/device/index.jpg new file mode 100644 index 0000000000000000000000000000000000000000..019a57097f2294e1abdf7a637eee0351903fb201 Binary files /dev/null and b/sample/EnhanceSampleArk1.2/ConcurrentModule/screenshots/device/index.jpg differ diff --git a/sample/EnhanceSampleArk1.2/ConcurrentModule/screenshots/device/taskpoolTab.jpg b/sample/EnhanceSampleArk1.2/ConcurrentModule/screenshots/device/taskpoolTab.jpg new file mode 100644 index 0000000000000000000000000000000000000000..38a5ec74d691a0c22a4b7f9517a23915005ed20d Binary files /dev/null and b/sample/EnhanceSampleArk1.2/ConcurrentModule/screenshots/device/taskpoolTab.jpg differ diff --git a/sample/EnhanceSampleArk1.2/ConcurrentModule/screenshots/device/workerTab.jpg b/sample/EnhanceSampleArk1.2/ConcurrentModule/screenshots/device/workerTab.jpg new file mode 100644 index 0000000000000000000000000000000000000000..8fa3260d093937f7266446ae92ecdc33fe38e977 Binary files /dev/null and b/sample/EnhanceSampleArk1.2/ConcurrentModule/screenshots/device/workerTab.jpg differ diff --git a/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/.gitignore b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/.gitignore new file mode 100644 index 0000000000000000000000000000000000000000..f0b9dc0066df0394eda177867467b1e0bf1539c6 --- /dev/null +++ b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/.gitignore @@ -0,0 +1,10 @@ +/local.properties +/.idea +**/build +/.hvigor +.cxx +/.clangd +/.clang-format +/.clang-tidy +**/oh_modules +**/oh-package-lock.json5 \ No newline at end of file diff --git a/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/AppScope/app.json5 b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/AppScope/app.json5 new file mode 100644 index 0000000000000000000000000000000000000000..f17606675dd273842d798f2594ad664b3d388c06 --- /dev/null +++ b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/AppScope/app.json5 @@ -0,0 +1,26 @@ +/* + * Copyright (c) 2023 Huawei Device 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. + */ + +{ + "app": { + "bundleName": "com.samples.languagebaseclasslibrary", + "vendor": "samples", + "versionCode": 1000000, + "versionName": "1.0.0", + "icon": "$media:app_icon", + "label": "$string:app_name", + "distributedNotificationEnabled": true + } +} diff --git a/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/AppScope/resources/base/element/string.json b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/AppScope/resources/base/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..9523fbcc55715a9210d0913d29d4b8e612cfef0e --- /dev/null +++ b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/AppScope/resources/base/element/string.json @@ -0,0 +1,8 @@ +{ + "string": [ + { + "name": "app_name", + "value": "LanguageBaseClassLibrary" + } + ] +} diff --git a/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/AppScope/resources/base/media/app_icon.png b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/AppScope/resources/base/media/app_icon.png new file mode 100644 index 0000000000000000000000000000000000000000..ce307a8827bd75456441ceb57d530e4c8d45d36c Binary files /dev/null and b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/AppScope/resources/base/media/app_icon.png differ diff --git a/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/README_zh.md b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/README_zh.md new file mode 100644 index 0000000000000000000000000000000000000000..31c58ee866a611ed833ff095333598fd508f3a52 --- /dev/null +++ b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/README_zh.md @@ -0,0 +1,184 @@ +# 语言基础类库 + +### 介绍 +本示例集合语言基础类库的各个子模块,展示了各个模块的基础功能,包含: + +- [@ohos.buffer (Buffer)](https://gitee.com/openharmony/docs/blob/OpenHarmony-3.2-Release/zh-cn/application-dev/reference/apis/js-apis-buffer.md) +- [@ohos.convertxml (xml转换JavaScript)](https://gitee.com/openharmony/docs/blob/OpenHarmony-3.2-Release/zh-cn/application-dev/reference/apis/js-apis-convertxml.md) +- [@ohos.process (获取进程相关的信息)](https://gitee.com/openharmony/docs/blob/OpenHarmony-3.2-Release/zh-cn/application-dev/reference/apis/js-apis-process.md) +- [@ohos.taskpool (启动任务池)](https://gitee.com/openharmony/docs/blob/OpenHarmony-3.2-Release/zh-cn/application-dev/reference/apis/js-apis-taskpool.md) +- [@ohos.uri (URI字符串解析)](https://gitee.com/openharmony/docs/blob/OpenHarmony-3.2-Release/zh-cn/application-dev/reference/apis/js-apis-uri.md) +- [@ohos.url (URL字符串解析)](https://gitee.com/openharmony/docs/blob/OpenHarmony-3.2-Release/zh-cn/application-dev/reference/apis/js-apis-url.md) +- [@ohos.util (util工具函数)](https://gitee.com/openharmony/docs/blob/OpenHarmony-3.2-Release/zh-cn/application-dev/reference/apis/js-apis-util.md) +- [@ohos.util.ArrayList (线性容器ArrayList)](https://gitee.com/openharmony/docs/blob/OpenHarmony-3.2-Release/zh-cn/application-dev/reference/apis/js-apis-arraylist.md) +- [@ohos.util.Deque (线性容器Deque)](https://gitee.com/openharmony/docs/blob/OpenHarmony-3.2-Release/zh-cn/application-dev/reference/apis/js-apis-deque.md) +- [@ohos.util.HashMap (非线性容器HashMap)](https://gitee.com/openharmony/docs/blob/OpenHarmony-3.2-Release/zh-cn/application-dev/reference/apis/js-apis-hashmap.md) +- [@ohos.util.HashSet (非线性容器HashSet)](https://gitee.com/openharmony/docs/blob/OpenHarmony-3.2-Release/zh-cn/application-dev/reference/apis/js-apis-hashset.md) +- [@ohos.util.LightWeightMap (非线性容器LightWeightMap)](https://gitee.com/openharmony/docs/blob/OpenHarmony-3.2-Release/zh-cn/application-dev/reference/apis/js-apis-lightweightmap.md) +- [@ohos.util.LightWeightSet (非线性容器LightWeightSet)](https://gitee.com/openharmony/docs/blob/OpenHarmony-3.2-Release/zh-cn/application-dev/reference/apis/js-apis-lightweightset.md) +- [@ohos.util.LinkedList (线性容器LinkedList)](https://gitee.com/openharmony/docs/blob/OpenHarmony-3.2-Release/zh-cn/application-dev/reference/apis/js-apis-linkedlist.md) +- [@ohos.util.List (线性容器List)](https://gitee.com/openharmony/docs/blob/OpenHarmony-3.2-Release/zh-cn/application-dev/reference/apis/js-apis-list.md) +- [@ohos.util.PlainArray (非线性容器PlainArray)](https://gitee.com/openharmony/docs/blob/OpenHarmony-3.2-Release/zh-cn/application-dev/reference/apis/js-apis-plainarray.md) +- [@ohos.util.Queue (线性容器Queue)](https://gitee.com/openharmony/docs/blob/OpenHarmony-3.2-Release/zh-cn/application-dev/reference/apis/js-apis-queue.md) +- [@ohos.util.Stack (线性容器Stack)](https://gitee.com/openharmony/docs/blob/OpenHarmony-3.2-Release/zh-cn/application-dev/reference/apis/js-apis-stack.md) +- [@ohos.util.TreeMap (非线性容器TreeMap)](https://gitee.com/openharmony/docs/blob/OpenHarmony-3.2-Release/zh-cn/application-dev/reference/apis/js-apis-treemap.md) +- [@ohos.util.TreeSet (非线性容器TreeSet)](https://gitee.com/openharmony/docs/blob/OpenHarmony-3.2-Release/zh-cn/application-dev/reference/apis/js-apis-treeset.md) +- [@ohos.util.Vector (线性容器Vector)](https://gitee.com/openharmony/docs/blob/OpenHarmony-3.2-Release/zh-cn/application-dev/reference/apis/js-apis-vector.md) +- [@ohos.xml (xml解析与生成)](https://gitee.com/openharmony/docs/blob/OpenHarmony-3.2-Release/zh-cn/application-dev/reference/apis/js-apis-xml.md) + +### 效果预览 + +| **主页** | **Util** | ConvertXml | +| :---------------------------------------: | :---------------------------------------: | :--------------------------------------: | +| ![home](screenshots/devices/home.jpg) | ![util](screenshots/devices/util.jpg) | ![convertxml](screenshots/devices/convertxml.jpg) | + +使用说明 + +1. 首页展示语言基础类库各个子模块菜单,点击进入对应的模块页面。 +2. 各个子模块界面中点击功能按钮完成各个功能。 +3. Util中有二级菜单,点击进入对应的二级界面,包含: + * StringCode:字符串编解码,点击功能按钮完成各个功能。 + * RationnalNumber:有理数比较,点击功能按钮完成各个功能。 + * LRUCache:LRU缓冲区,点击功能按钮完成各个功能。 + * ScopeHelper:范围判断,点击功能按钮完成各个功能。 + * Base64Helper:Base64编解码,点击功能按钮完成各个功能。 + * TypeCheck:类型检查,点击功能按钮完成各个功能。 +4. Process界面中,先安装[ProcessMessage](lib/ProcessMessage-1.0.0.hap),点击按钮跳转,点击功能按钮实现获取进程相关信息的功能。 +5. TaskPool界面中,点击Execute task执行任务,点击Cancel task取消任务。 +6. ArrayList界面中,点击+号添加数据后展示数据,点击删除按钮删除对应的一条数据。 +7. Deque界面中,点击+号添加数据后展示数据,点击删除按钮删除对应的一条数据。 +8. HashMap界面中,点击+号添加数据后展示数据,点击删除按钮删除对应的一条数据。 +9. HashSet界面中,点击+号添加数据后展示数据,点击删除按钮删除对应的一条数据。 +10. LightWeightMap界面中,点击+号添加数据后展示数据,点击删除按钮删除对应的一条数据。 +11. LightWeightSet界面中,点击+号添加数据后展示数据,点击删除按钮删除对应的一条数据。 +12. LinkedList界面中,点击+号添加数据后展示数据,点击删除按钮删除对应的一条数据。 +13. List界面中,点击+号添加数据后展示数据,点击删除按钮删除对应的一条数据。 +14. PlainArray界面中,点击+号添加数据后展示数据,点击删除按钮删除对应的一条数据。 +15. Queue界面中,点击+号添加数据后展示数据,点击删除按钮删除对应的一条数据。 +16. Stack界面中,点击+号添加数据后展示数据,点击删除按钮删除对应的一条数据。 +17. TreeMap界面中,点击+号添加数据后展示数据,点击删除按钮删除对应的一条数据。 +18. TreeSet界面中,点击+号添加数据后展示数据,点击删除按钮删除对应的一条数据。 +19. Vector界面中,点击+号添加数据后展示数据,点击删除按钮删除对应的一条数据。 + +### 工程目录 + +``` +LanguageBaseClassLibrary +├── AppScope +│ └── app.json5 //APP信息配置文件 +├── entry/src/main //语言基础类库应用首页 +│ ├── ets +│ │ ├── entryability +│ │ ├── pages +│ │ │ ├── Index.ets //主页入口 +│ │ │ ├── AddInformationView.ets //添加联系人页面 +│ │ │ ├── AddKeyValuePairView.ets //添加Key/Value页面 +│ │ │ ├── AddStringView.ets //添加String页面 +│ │ │ ├── compnents +│ │ │ │ └── Capabilities.ets //根据点击的菜单,展示对应的子界面 +│ └── module.json5 +│ +├── common/src/main //公共组件及工具类 +│ ├── ets +│ │ ├── components +│ │ │ └── CustomDataSource.ets //自定义DataSource,LazyForEach时使用 +│ │ ├── util +│ │ │ ├── Logger.ets //日志工具类 +│ │ │ └── ResourceUtil.ets //资源管理工具类 +│ └── module.json5 +│ +├── menuitems/src/main //菜单 +│ ├── ets +│ │ ├── Index.ets //对外提供的接口列表 +│ │ ├── menulist //菜单组件 +│ │ │ └── MenuList.ets +│ │ ├── components //菜单相关自定义组件 +│ └── module.json5 +│ +├── capabilities/src/main //功能集 +│ ├── ets +│ │ ├── capabilities //各个子模块功能组件 +│ │ ├── components //子模块相关组件 +│ │ │ ├── arraylistcomponents //arraylist相关组件 +│ │ │ ├── dequecomponents //deque相关组件 +│ │ │ ├── hashmapcomponents //hashmap相关组件 +│ │ │ ├── hashsetcomponents //hashset相关组件 +│ │ │ ├── lightweightmapcomponents //lightweightmap相关组件 +│ │ │ ├── lightweightsetcomponents //lightweightset相关组件 +│ │ │ ├── linkedlistcomponents //linkedlist相关组件 +│ │ │ ├── listcomponents //list相关组件 +│ │ │ ├── plainarraycomponents //plainarray相关组件 +│ │ │ ├── queuecomponents //queue相关组件 +│ │ │ ├── stackcomponents //stack相关组件 +│ │ │ ├── treemapcomponents //treemap相关组件 +│ │ │ ├── treesetcomponents //treeset相关组件 +│ │ │ ├── utilcomponents //util相关组件 +│ │ │ ├── vectorcomponents //vector相关组件 +│ │ │ ├── ColumnOperation.ets //展示一列功能按钮的组件 +│ │ │ ├── DeleteView.ets //删除按钮的组件 +│ │ │ ├── GridOperation.ets //根据窗口大小展示不同列的功能按钮的组件 +│ │ │ ├── InformationItemView.ets //联系人Item的组件 +│ │ │ ├── KeyValueItemView.ets //Key/Value Item的组件 +│ │ │ └── ValueItemView.ets //Value Item的组件 +│ │ ├── model //相关数据模型 +│ │ ├── utils //相关工具类 +│ │ └── Constant.ts //EmitterId +│ └── module.json5 +``` + +### 具体实现 + +1. 首页菜单展示:使用一个module,menuitems完成菜单组件的实现,传入要展示的菜单的strarray类型的资源和菜单点击对应的组件即可。使用Navigation和NavRouter组件实现菜单点击进入功能界面,使用LocalStorage实现应用内Ability内数据共享,点击菜单时标记selectedLabel,在entry中的Capabilities组件中,通过selectedLabel显示对应的功能组件。 +2. Xml & ConvertXml:使用[xml](https://gitee.com/openharmony/docs/blob/OpenHarmony-3.2-Release/zh-cn/application-dev/reference/apis/js-apis-xml.md) 和[convertxml](https://gitee.com/openharmony/docs/blob/OpenHarmony-3.2-Release/zh-cn/application-dev/reference/apis/js-apis-convertxml.md) 实现xml的解析和生成以及xml转换为js对象,点击按钮实现对应的功能。 +3. Process:使用[process](https://gitee.com/openharmony/docs/blob/OpenHarmony-3.2-Release/zh-cn/application-dev/reference/apis/js-apis-process.md) 实现获取进程相关信息的功能,点击按钮实现对应的功能。 +4. TaskPool:使用[taskpool](https://docs.openharmony.cn/pages/v3.2/zh-cn/application-dev/reference/apis/js-apis-taskpool.md/) 实现创建后台任务(Task),并对所创建的任务进行如任务执行、任务取消的操作。 +5. Url:使用[URL](https://gitee.com/openharmony/docs/blob/OpenHarmony-3.2-Release/zh-cn/application-dev/reference/apis/js-apis-url.md) 对URL字符串的查找参数进行了增删改查的一系列操作,使得读者对URL的结构用途更加明了,点击按钮实现对应的功能。 +6. Util,使用util中不同的功能函数实现以下功能: + * StringCode:字符串编解码。 + * RationnalNumber:有理数比较。 + * LRUCache:LRU缓冲区。 + * ScopeHelper:范围判断。 + * Base64Helper:Base64编解码。 + * TypeCheck:类型检查。 +7. ArrayList:展示线性容器ArrayList的数据类型的使用,包括添加、删除。 +8. Deque:展示线性容器Deque的数据类型的使用,包括头部插入、头部删除、尾部删除。 +9. HashMap:展示非线性容器HashMap的数据类型的使用,包括添加键值对、删除键值对。 +10. HashSet:展示非线性容器HashSet的数据类型的使用,包括添加、删除。 +11. LightWeightMap:展示非线性容器LightWeightMap的数据类型的使用,包括添加键值对、删除键值对。 +12. LightWeightSet:展示非线性容器LightWeightSet的数据类型的使用,包括添加、删除。 +13. LinkedList:展示线性容器LinkedList的数据类型的使用,包括尾部添加、头部删除、尾部删除。 +14. List:展示线性容器List的数据类型的使用,包括添加、删除。 +15. PlainArray:展示非线性容器PlainArray的数据类型的使用,包括添加、删除。 +16. Queue:展示线性容器Queue的数据类型的使用,包括尾部添加、头部删除。 +17. Stack:展示线性容器Stack的数据类型的使用,包括尾部添加、尾部删除。 +18. TreeMap:展示非线性容器TreeMap的数据类型的使用,包括添加键值对、删除键值对。 +19. TreeSet:展示非线性容器TreeSet的数据类型的使用,包括添加、删除。 +20. Vector:展示线性容器Vector的数据类型的使用,包括添加、删除。 + +### 相关权限 + +不涉及。 + +### 依赖 + +不涉及。 + +### 约束与限制 + +1. 本示例仅支持标准系统上运行。 + +2. 本示例支持API10版本SDK,SDK版本号(API Version 10 Release),镜像版本号(4.0 Release)。 + +3. 本示例需要使用DevEco Studio 版本号(4.0 Release)及以上版本才可编译运行。 + +### 下载 + +如需单独下载本工程,执行如下命令: + +``` +git init +git config core.sparsecheckout true +echo code/LaunguageBaseClassLibrary/LanguageBaseClassLibrary/ > .git/info/sparse-checkout +git remote add origin https://gitee.com/openharmony/applications_app_samples.git +git pull origin master +``` \ No newline at end of file diff --git a/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/build-profile.json5 b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/build-profile.json5 new file mode 100644 index 0000000000000000000000000000000000000000..d618c219f991269ca4a3a15e7d09d8a894d06b15 --- /dev/null +++ b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/build-profile.json5 @@ -0,0 +1,55 @@ +/* + * Copyright (c) 2023 Huawei Device 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. + */ + +{ + "app": { + "signingConfigs": [], + "products": [ + { + "name": "default", + "signingConfig": "default", + "compileSdkVersion": 10, + "compatibleSdkVersion": 10, + "runtimeOS": "OpenHarmony" + } + ] + }, + "modules": [ + { + "name": "entry", + "srcPath": "./entry", + "targets": [ + { + "name": "default", + "applyToProducts": [ + "default" + ] + } + ] + }, + { + "name": "menuitems", + "srcPath": "./feature/menuitems" + }, + { + "name": "capabilities", + "srcPath": "./feature/capabilities" + }, + { + "name": "common", + "srcPath": "./common" + } + ] +} \ No newline at end of file diff --git a/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/common/.gitignore b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/common/.gitignore new file mode 100644 index 0000000000000000000000000000000000000000..4f9a973815d0b5e49bc8547681a6b4bc7a178d12 --- /dev/null +++ b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/common/.gitignore @@ -0,0 +1,3 @@ +/node_modules +/.preview +/build \ No newline at end of file diff --git a/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/common/Index.ets b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/common/Index.ets new file mode 100644 index 0000000000000000000000000000000000000000..eea56ec42d86318775e6182cf6b5e94b7857589b --- /dev/null +++ b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/common/Index.ets @@ -0,0 +1,24 @@ +/* + * Copyright (c) 2023 Huawei Device 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. + */ + +export { logger } from './src/main/ets/util/Logger'; + +export { CustomDataSource } from './src/main/ets/components/CustomDataSource'; + +export { getString, getStringArray } from './src/main/ets/util/ResourceUtil'; + +export { BaseDataSource } from './src/main/ets/components/BaseDataSource'; + +export { EmptyPage } from './src/main/ets/components/EmptyPage'; diff --git a/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/common/build-profile.json5 b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/common/build-profile.json5 new file mode 100644 index 0000000000000000000000000000000000000000..431999870d30f72c7c6e728d63eb40d9b271f976 --- /dev/null +++ b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/common/build-profile.json5 @@ -0,0 +1,20 @@ +/* + * Copyright (c) 2023 Huawei Device 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. + */ + +{ + "apiType": "stageMode", + "buildOption": { + } +} diff --git a/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/common/hvigorfile.ts b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/common/hvigorfile.ts new file mode 100644 index 0000000000000000000000000000000000000000..9c3992ac05f1a4b3c5c93a44388308fd1dc45aa8 --- /dev/null +++ b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/common/hvigorfile.ts @@ -0,0 +1,17 @@ +/** + * Copyright (c) 2023 Huawei Device 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. + */ +// Script for compiling build behavior. It is built in the build plug-in and cannot be modified currently. +module.exports = require('@ohos/hvigor-ohos-plugin').harTasks + diff --git a/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/common/oh-package.json5 b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/common/oh-package.json5 new file mode 100644 index 0000000000000000000000000000000000000000..995e5e09e22ed718cd915ea42801ba00217f734e --- /dev/null +++ b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/common/oh-package.json5 @@ -0,0 +1,26 @@ +/* + * Copyright (c) 2023 Huawei Device 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. + */ + +{ + "license": "ISC", + "types": "", + "devDependencies": {}, + "name": "@ohos/common", + "description": "a npm package which contains arkUI2.0 page", + "main": "Index.ets", + "repository": {}, + "version": "1.0.0", + "dependencies": {} +} diff --git a/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/common/src/main/ets/components/BaseDataSource.ets b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/common/src/main/ets/components/BaseDataSource.ets new file mode 100644 index 0000000000000000000000000000000000000000..d65bcf278cdc9c44e9a4901d2f69118cc9664ee5 --- /dev/null +++ b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/common/src/main/ets/components/BaseDataSource.ets @@ -0,0 +1,75 @@ +/* +* 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 { logger } from '../util/Logger'; + +const TAG: string = 'BaseDataSource'; + +export class BaseDataSource implements IDataSource { + private listeners: DataChangeListener[] = []; + + public totalCount(): number { + return 0; + } + + public getData(index: number): Object { + return ''; + } + + registerDataChangeListener(listener: DataChangeListener): void { + if (this.listeners.indexOf(listener) < 0) { + logger.info(TAG, 'add listener'); + this.listeners.push(listener); + } + } + + unregisterDataChangeListener(listener: DataChangeListener): void { + const pos = this.listeners.indexOf(listener); + if (pos >= 0) { + logger.info(TAG, 'remove listener'); + this.listeners.splice(pos, 1); + } + } + + notifyDataReload(): void { + this.listeners.forEach(listener => { + listener.onDataReloaded(); + }) + } + + notifyDataAdd(index: number): void { + this.listeners.forEach(listener => { + listener.onDataAdd(index); + }) + } + + notifyDataChange(index: number): void { + this.listeners.forEach(listener => { + listener.onDataChange(index); + }) + } + + notifyDataDelete(index: number): void { + this.listeners.forEach(listener => { + listener.onDataDelete(index); + }) + } + + notifyDataMove(from: number, to: number): void { + this.listeners.forEach(listener => { + listener.onDataMove(from, to); + }) + } + +} \ No newline at end of file diff --git a/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/common/src/main/ets/components/CustomDataSource.ets b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/common/src/main/ets/components/CustomDataSource.ets new file mode 100644 index 0000000000000000000000000000000000000000..24104d2f4b8653a647ceb856470df1776badfcaa --- /dev/null +++ b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/common/src/main/ets/components/CustomDataSource.ets @@ -0,0 +1,81 @@ +/** + * Copyright (c) 2023 Huawei Device 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. + */ + +class BasicDataSource implements IDataSource { + private listeners: DataChangeListener[] = []; + + public totalCount(): number { + return 0; + } + + public getData(index: number): Object { + return ''; + } + + registerDataChangeListener(listener: DataChangeListener): void { + if (this.listeners.indexOf(listener) < 0) { + this.listeners.push(listener); + } + } + + unregisterDataChangeListener(listener: DataChangeListener): void { + const pos = this.listeners.indexOf(listener); + if (pos >= 0) { + this.listeners.splice(pos, 1); + } + } + + notifyDataReload(): void { + this.listeners.forEach(listener => { + listener.onDataReloaded(); + }) + } + + notifyDataAdd(index: number): void { + this.listeners.forEach(listener => { + listener.onDataAdded(index); + }) + } + + notifyDataChange(index: number): void { + this.listeners.forEach(listener => { + listener.onDataChanged(index); + }) + } +} + +export class CustomDataSource extends BasicDataSource { + public dataArray: string[] = []; + + constructor(ele: string[]) { + super(); + for (let index = 0;index < ele.length; index++) { + this.dataArray.push(ele[index]); + } + } + + public totalCount(): number { + return this.dataArray.length; + } + + public getData(index: number): string { + return this.dataArray[index]; + } + + public addData(index: number, data: string): void { + this.dataArray.splice(index, 0, data); + this.notifyDataAdd(index); + } +} \ No newline at end of file diff --git a/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/common/src/main/ets/components/EmptyPage.ets b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/common/src/main/ets/components/EmptyPage.ets new file mode 100644 index 0000000000000000000000000000000000000000..c9b0c8007bf9a135a023e9434691d370e2f82157 --- /dev/null +++ b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/common/src/main/ets/components/EmptyPage.ets @@ -0,0 +1,37 @@ +/* +* 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. +*/ + +@Component +export struct EmptyPage { + private img: string | PixelMap | Resource = $r('app.media.bg_empty_page'); + private message: ResourceStr = $r('app.string.tv_no_data'); + + build() { + Column() { + Image(this.img) + .width(120) + .aspectRatio(1) + + Text(this.message) + .fontSize(14) + .fontColor($r('app.color.text_color_second')) + .margin({ top: 8 }) + } + .width('100%') + .height('100%') + .justifyContent(FlexAlign.Center) + .alignItems(HorizontalAlign.Center) + } +} \ No newline at end of file diff --git a/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/common/src/main/ets/util/Logger.ets b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/common/src/main/ets/util/Logger.ets new file mode 100644 index 0000000000000000000000000000000000000000..c5bb2fd8d05446d40ade74e069f6c55e5edb0a13 --- /dev/null +++ b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/common/src/main/ets/util/Logger.ets @@ -0,0 +1,45 @@ +/* + * Copyright (c) 2023 Huawei Device 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 hilog from '@ohos.hilog'; + +class Logger { + private domain: number; + private prefix: string; + private format: string = '%{public}s, %{public}s'; + + constructor(prefix: string) { + this.prefix = prefix; + this.domain = 0xFF00; + } + + debug(...args: string[]): void { + hilog.debug(this.domain, this.prefix, this.format, args); + } + + info(...args: string[]): void { + hilog.info(this.domain, this.prefix, this.format, args); + } + + warn(...args: string[]): void { + hilog.warn(this.domain, this.prefix, this.format, args); + } + + error(...args: string[]): void { + hilog.error(this.domain, this.prefix, this.format, args); + } +} + +export const logger = new Logger('Sample_LanguageBaseClassLibrary'); \ No newline at end of file diff --git a/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/common/src/main/ets/util/ResourceUtil.ets b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/common/src/main/ets/util/ResourceUtil.ets new file mode 100644 index 0000000000000000000000000000000000000000..ec54102cf9de20bbc14b8957ff0a8993ab5445c9 --- /dev/null +++ b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/common/src/main/ets/util/ResourceUtil.ets @@ -0,0 +1,27 @@ +/* + * Copyright (c) 2023 Huawei Device 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'; + +export async function getStringArray(resource: Resource): Promise> { + let context = getContext() as common.UIAbilityContext; + let menuList: Array = await context.resourceManager.getStringArrayValue(resource); + return menuList; +} + +export function getString(resource: Resource): string { + let context = getContext() as common.UIAbilityContext; + return context.resourceManager.getStringSync(resource); +} diff --git a/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/common/src/main/module.json5 b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/common/src/main/module.json5 new file mode 100644 index 0000000000000000000000000000000000000000..922bccb772db0e621d51b402ed41626ab05d47d4 --- /dev/null +++ b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/common/src/main/module.json5 @@ -0,0 +1,25 @@ +/* + * Copyright (c) 2023 Huawei Device 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. + */ + +{ + "module": { + "name": "common", + "type": "har", + "deviceTypes": [ + "default", + "tablet" + ] + } +} diff --git a/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/common/src/main/resources/base/element/color.json b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/common/src/main/resources/base/element/color.json new file mode 100644 index 0000000000000000000000000000000000000000..cfd45be17eb157231179b546d58b85462dfdc8f0 --- /dev/null +++ b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/common/src/main/resources/base/element/color.json @@ -0,0 +1,36 @@ +{ + "color": [ + { + "name": "start_window_background", + "value": "#FFFFFF" + }, + { + "name": "text_color_accent", + "value": "#FF007DFF" + }, + { + "name": "text_color_primary", + "value": "#E6000000" + }, + { + "name": "text_color_second", + "value": "#99000000" + }, + { + "name": "text_color_tertiary", + "value": "#66000000" + }, + { + "name": "text_color_red", + "value": "#FFE84026" + }, + { + "name": "bg_btn_red", + "value": "#FFD94838" + }, + { + "name": "bg_btn_grey", + "value": "#0D000000" + } + ] +} \ No newline at end of file diff --git a/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/common/src/main/resources/base/element/string.json b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/common/src/main/resources/base/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..9bfeb22586ce292fc9a1219b0a65417ef879858a --- /dev/null +++ b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/common/src/main/resources/base/element/string.json @@ -0,0 +1,64 @@ +{ + "string": [ + { + "name": "page_show", + "value": "page from npm package" + }, + { + "name": "tv_no_data", + "value": "No data" + }, + { + "name": "deque", + "value": "Deque (Linear Container Deque)" + }, + { + "name": "hash_map", + "value": "HashMap (NoLinear Container HashMap)" + }, + { + "name": "hash_set", + "value": "HashSet (NoLinear Container HashSet)" + }, + { + "name": "light_weight_map", + "value": "LightWeightMap (NoLinear Container LightWeightMap)" + }, + { + "name": "light_weight_set", + "value": "LightWeightSet (NoLinear Container LightWeightSet)" + }, + { + "name": "linked_list", + "value": "LinkedList (Linear Container LinkedList)" + }, + { + "name": "list", + "value": "List (Linear Container List)" + }, + { + "name": "plain_array", + "value": "PlainArray (NoLinear Container PlainArray)" + }, + { + "name": "queue", + "value": "Queue (Linear Container Queue)" + }, + { + "name": "stack", + "value": "Stack (Linear Container Stack)" + }, + { + "name": "tree_map", + "value": "TreeMap (NoLinear Container TreeMap)" + }, + { + "name": "tree_set", + "value": "TreeSet (NoLinear Container TreeSet)" + }, + { + "name": "vector", + "value": "Vector (Linear Container Vector)" + } + ] +} diff --git a/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/common/src/main/resources/base/media/bg_empty_page.svg b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/common/src/main/resources/base/media/bg_empty_page.svg new file mode 100644 index 0000000000000000000000000000000000000000..038a4c3caab2d07cc7db6d699cd2b3f24bd67bd1 --- /dev/null +++ b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/common/src/main/resources/base/media/bg_empty_page.svg @@ -0,0 +1,104 @@ + + + + + + + + + + + + + + + + + + + + + + diff --git a/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/common/src/main/resources/en_US/element/string.json b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/common/src/main/resources/en_US/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..9bfeb22586ce292fc9a1219b0a65417ef879858a --- /dev/null +++ b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/common/src/main/resources/en_US/element/string.json @@ -0,0 +1,64 @@ +{ + "string": [ + { + "name": "page_show", + "value": "page from npm package" + }, + { + "name": "tv_no_data", + "value": "No data" + }, + { + "name": "deque", + "value": "Deque (Linear Container Deque)" + }, + { + "name": "hash_map", + "value": "HashMap (NoLinear Container HashMap)" + }, + { + "name": "hash_set", + "value": "HashSet (NoLinear Container HashSet)" + }, + { + "name": "light_weight_map", + "value": "LightWeightMap (NoLinear Container LightWeightMap)" + }, + { + "name": "light_weight_set", + "value": "LightWeightSet (NoLinear Container LightWeightSet)" + }, + { + "name": "linked_list", + "value": "LinkedList (Linear Container LinkedList)" + }, + { + "name": "list", + "value": "List (Linear Container List)" + }, + { + "name": "plain_array", + "value": "PlainArray (NoLinear Container PlainArray)" + }, + { + "name": "queue", + "value": "Queue (Linear Container Queue)" + }, + { + "name": "stack", + "value": "Stack (Linear Container Stack)" + }, + { + "name": "tree_map", + "value": "TreeMap (NoLinear Container TreeMap)" + }, + { + "name": "tree_set", + "value": "TreeSet (NoLinear Container TreeSet)" + }, + { + "name": "vector", + "value": "Vector (Linear Container Vector)" + } + ] +} diff --git a/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/common/src/main/resources/zh_CN/element/string.json b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/common/src/main/resources/zh_CN/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..627e1976e8c8fcb0ec04521ba809e04a87d4d21f --- /dev/null +++ b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/common/src/main/resources/zh_CN/element/string.json @@ -0,0 +1,64 @@ +{ + "string": [ + { + "name": "page_show", + "value": "page from npm package" + }, + { + "name": "tv_no_data", + "value": "无数据" + }, + { + "name": "deque", + "value": "Deque (线性容器Deque)" + }, + { + "name": "hash_map", + "value": "HashMap (非线性容器HashMap)" + }, + { + "name": "hash_set", + "value": "HashSet (非线性容器HashSet)" + }, + { + "name": "light_weight_map", + "value": "LightWeightMap (非线性容器LightWeightMap)" + }, + { + "name": "light_weight_set", + "value": "LightWeightSet (非线性容器LightWeightSet)" + }, + { + "name": "linked_list", + "value": "LinkedList (线性容器LinkedList)" + }, + { + "name": "list", + "value": "List (线性容器List)" + }, + { + "name": "plain_array", + "value": "PlainArray (非线性容器PlainArray)" + }, + { + "name": "queue", + "value": "Queue (线性容器Queue)" + }, + { + "name": "stack", + "value": "Stack (线性容器Stack)" + }, + { + "name": "tree_map", + "value": "TreeMap (非线性容器TreeMap)" + }, + { + "name": "tree_set", + "value": "TreeSet (非线性容器TreeSet)" + }, + { + "name": "vector", + "value": "Vector (线性容器Vector)" + } + ] +} diff --git a/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/entry/.gitignore b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/entry/.gitignore new file mode 100644 index 0000000000000000000000000000000000000000..5a6ba80fa3d9498a23ae8ae7d9518f8743fa8a96 --- /dev/null +++ b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/entry/.gitignore @@ -0,0 +1,4 @@ +/node_modules +/.preview +/build +/.cxx \ No newline at end of file diff --git a/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/entry/build-profile.json5 b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/entry/build-profile.json5 new file mode 100644 index 0000000000000000000000000000000000000000..ddd6e5f1ac23a18a1d1d0d8d7470c6d4726ef66e --- /dev/null +++ b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/entry/build-profile.json5 @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2023 Huawei Device 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. + */ + +{ + "apiType": 'stageMode', + "buildOption": { + }, + "targets": [ + { + "name": "default" + }, + { + "name": "ohosTest", + } + ] +} \ No newline at end of file diff --git a/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/entry/hvigorfile.ts b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/entry/hvigorfile.ts new file mode 100644 index 0000000000000000000000000000000000000000..27a66d9a3cbadf06e3a3857221a0a1b7c1087e89 --- /dev/null +++ b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/entry/hvigorfile.ts @@ -0,0 +1,16 @@ +/** + * Copyright (c) 2023 Huawei Device 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. + */ +// 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'; diff --git a/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/entry/oh-package.json5 b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/entry/oh-package.json5 new file mode 100644 index 0000000000000000000000000000000000000000..d83add340b607163a1c7ed16d7aa7b98177c934a --- /dev/null +++ b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/entry/oh-package.json5 @@ -0,0 +1,27 @@ +/* + * Copyright (c) 2023 Huawei Device 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. + */ +{ + "license": "ISC", + "devDependencies": {}, + "name": "entry", + "description": "example description", + "repository": {}, + "version": "1.0.0", + "dependencies": { + "@ohos/capabilities": "file:../feature/capabilities", + "@ohos/menuitems": "file:../feature/menuitems", + "@ohos/common": "file:../common" + } +} diff --git a/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/entry/src/main/ets/entryability/EntryAbility.ets b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/entry/src/main/ets/entryability/EntryAbility.ets new file mode 100644 index 0000000000000000000000000000000000000000..9120754461e81263643c5569b98e88757083bff7 --- /dev/null +++ b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/entry/src/main/ets/entryability/EntryAbility.ets @@ -0,0 +1,99 @@ +/* + * Copyright (c) 2023 Huawei Device 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 display from '@ohos.display'; +import UIAbility from '@ohos.app.ability.UIAbility'; +import window from '@ohos.window'; +import { logger } from '@ohos/common/src/main/ets/util/Logger'; +import Want from '@ohos.app.ability.Want'; +import AbilityConstant from '@ohos.app.ability.AbilityConstant'; + +const BREAKPOINT_MD: number = 600; +const BREAKPOINT_BIG: number = 840; +const PARAMS_PX_TO_VP: number = 160; +const TAG: string = 'EntryAbility'; + +export default class EntryAbility extends UIAbility { + onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { + logger.info(TAG, 'Ability onCreate'); + AppStorage.setOrCreate('selectedLabel', ''); + AppStorage.setOrCreate('selectedSecondLabel', ''); + AppStorage.setOrCreate('context', this.context); + } + + updateBreakpoint(windowWidth: number): void { + let windowWidthVp: number = windowWidth / (display.getDefaultDisplaySync().densityDPI / PARAMS_PX_TO_VP); + let curBp: string; + if (windowWidthVp < BREAKPOINT_MD) { + curBp = 'sm'; + } else if (windowWidthVp < BREAKPOINT_BIG) { + curBp = 'md'; + } else { + curBp = 'lg'; + } + logger.info(TAG, 'window width: ' + windowWidth + ', window width vp: ' + windowWidthVp + ', breakpoint: ' + curBp); + AppStorage.SetOrCreate('currentBreakpoint', curBp); + AppStorage.SetOrCreate('windowWidth', windowWidthVp); + AppStorage.SetOrCreate('isSplitMode', curBp === 'sm' ? false : true); + } + + onDestroy(): void { + logger.info(TAG, 'Ability onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage): void { + // Main window is created, set main page for this ability + logger.info(TAG, 'Ability onWindowStageCreate'); + + windowStage.getMainWindow().then((windowObj: window.Window) => { + let windowWidth: number = windowObj.getWindowProperties().windowRect.width; + this.updateBreakpoint(windowWidth); + windowObj.on('windowSizeChange', (newSize: window.Size) => { + let windowWidth: number = newSize.width; + this.updateBreakpoint(windowWidth); + + if (windowObj.getWindowProperties().isFullScreen) { + logger.info(TAG, 'isFullScreen'); + } + if (windowObj.getWindowProperties().isLayoutFullScreen) { + logger.info(TAG, 'isLayoutFullScreen'); + } + }); + }); + + windowStage.loadContent('pages/Index', (err, data) => { + if (err.code) { + logger.error(TAG, `Failed to load the content. Cause: ${JSON.stringify(err)}`); + return; + } + logger.info(TAG, `Succeeded in loading the content. Data: ${JSON.stringify(data)}`); + }); + } + + onWindowStageDestroy(): void { + // Main window is destroyed, release UI related resources + logger.info(TAG, 'Ability onWindowStageDestroy'); + } + + onForeground(): void { + // Ability has brought to foreground + logger.info(TAG, 'Ability onForeground'); + } + + onBackground(): void { + // Ability has back to background + logger.info(TAG, 'Ability onBackground'); + } +} diff --git a/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/entry/src/main/ets/pages/AddInformationView.ets b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/entry/src/main/ets/pages/AddInformationView.ets new file mode 100644 index 0000000000000000000000000000000000000000..ba17d42047dc335ca254a3093ea73b8f3ad44046 --- /dev/null +++ b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/entry/src/main/ets/pages/AddInformationView.ets @@ -0,0 +1,296 @@ +/* +* 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 router from '@ohos.router'; +import emitter from '@ohos.events.emitter'; +import { Constant, Information } from '@ohos/capabilities'; +import { getString } from '@ohos/common/src/main/ets/util/ResourceUtil'; + +const MIN_AGE = 1; +const AGE_RANGE = 9; +const AGE_DEFAULT = 0; + +const arr = Array(AGE_RANGE) + .fill(0) + .map((_: number, i: number) => `${i + MIN_AGE}${getString($r('app.string.old'))}`); + +@CustomDialog +struct AgePickDialog { + private controller?: CustomDialogController; + private sure: (age: number) => void = () => { + }; + @State select: number = AGE_DEFAULT; + + build() { + Column() { + Text($r('app.string.age')) + .margin({ left: 24, top: 14 }) + .width('100%') + .fontColor($r('app.color.text_color_primary')) + .fontSize(20) + .textAlign(TextAlign.Start) + + Column() { + TextPicker({ range: arr, selected: this.select }) + .onChange((value: string | string[], index: number | number[]) => { + if (typeof index === 'number') { + this.select = index; + } + }) + } + .width('100%') + .height(238) + + Row() { + Text($r('app.string.cancel')) + .height('100%') + .width('50%') + .textAlign(TextAlign.Center) + .fontSize(16) + .fontColor($r('app.color.text_color_accent')) + .onClick(() => { + this.controller?.close(); + }) + Divider() + .vertical(true) + .height('100%') + Text($r('app.string.sure')) + .id('add_sure') + .height('100%') + .width('50%') + .textAlign(TextAlign.Center) + .fontSize(16) + .fontColor($r('app.color.text_color_accent')) + .onClick(() => { + this.sure(this.select + MIN_AGE) + this.controller?.close(); + }) + } + .height(40) + } + .height(328) + .margin({ left: 12, right: 12, bottom: 16 }) + .borderRadius(24) + .backgroundColor($r('app.color.bg_white')) + } +} + +@Entry +@Component +export struct AddInformationView { + @State information: Information = new Information('', 0, '', true) + private dialogController: CustomDialogController = new CustomDialogController({ + builder: AgePickDialog({ sure: (age: number) => { + this.information.age = age; + } }), + customStyle: false, + alignment: DialogAlignment.Bottom + }) + @State flag: string = ''; + + aboutToAppear() { + let tem: string = (router.getParams() as Record)['title'] as string; + if (!tem) { + return; + } + this.flag = tem; + } + + build() { + Column() { + Row() { + Row() { + Image($r("app.media.ic_public_back")) + .height(24) + .aspectRatio(1) + .objectFit(ImageFit.Contain) + } + .height('100%') + .aspectRatio(1) + .padding({ left: 24 }) + .onClick(() => { + router.back(); + }) + + Text($r('app.string.add_new_contact')) + .fontColor($r('app.color.text_color_primary')) + .fontSize(20) + .margin({ left: 24 }) + + Blank() + + Row() { + Image($r('app.media.ic_public_confirm')) + .height(24) + .aspectRatio(1) + .objectFit(ImageFit.Contain) + } + .id('add_confirm') + .height('100%') + .aspectRatio(1) + .padding({ right: 24 }) + .onClick(() => { + let eventId = Constant.EMITTER_ID_DEFAULT; + switch (this.flag) { + case getString($r('app.string.deque')): + eventId = Constant.EMITTER_ID_DEQUE; + break; + case getString($r('app.string.linked_list')): + eventId = Constant.EMITTER_ID_LINKED_LIST; + break; + case getString($r('app.string.list')): + eventId = Constant.EMITTER_ID_LIST; + break; + case getString($r('app.string.queue')): + eventId = Constant.EMITTER_ID_QUEUE; + break; + case getString($r('app.string.stack')): + eventId = Constant.EMITTER_ID_STACK; + break; + case getString($r('app.string.vector')): + eventId = Constant.EMITTER_ID_VECTOR; + break; + default: + eventId = Constant.EMITTER_ID_DEFAULT; + break; + } + + let event: emitter.InnerEvent = { + eventId: eventId, + priority: emitter.EventPriority.HIGH + }; + + let eventData: emitter.EventData = { + data: { + 'name': this.information.name, + 'age': this.information.age, + 'phone': this.information.phone, + 'clickAble': this.information.clickAble + } + }; + + emitter.emit(event, eventData); + router.back(); + }) + + } + .width('100%') + .height(56) + + Row() { + Image($r('app.media.ic_public_user')) + .margin({ left: 19 }) + .width(19) + .aspectRatio(1) + Text($r('app.string.names')) + .margin({ left: 19 }) + .fontSize(16) + .fontColor($r('app.color.text_color_primary')) + Column() { + TextInput({ placeholder: $r('app.string.input_name') }) + .id('add_name') + .height(48) + .fontSize(16) + .backgroundColor($r('sys.color.ohos_id_color_background_transparent')) + .onChange((value: string) => { + this.information.name = value; + }) + } + .layoutWeight(1) + .margin({ left: 52, right: 16 }) + } + .height(64) + .width('100%') + .borderRadius(16) + .backgroundColor($r('app.color.bg_white')) + .margin({ top: 12 }) + + Row() { + Image($r('app.media.ic_age')) + .margin({ left: 19 }) + .width(19) + .aspectRatio(1) + Text($r('app.string.age')) + .margin({ left: 19 }) + .fontSize(16) + .fontColor($r('app.color.text_color_primary')) + Column() { + Image($r('app.media.ic_public_spinner_down')) + .height(24) + .width(12) + } + .id('add_age') + .justifyContent(FlexAlign.Center) + .width(54) + .height('100%') + .onClick(() => { + this.dialogController.open(); + }) + + Column() { + TextInput({ + text: this.information.age === 0 ? '' : `${this.information.age}`, + placeholder: $r('app.string.please_choose') + }) + .height(48) + .fontSize(16) + .focusable(false) + .backgroundColor($r('sys.color.ohos_id_color_background_transparent')) + .onClick(() => { + this.dialogController.open(); + }) + } + .layoutWeight(1) + .margin({ right: 16 }) + } + .height(64) + .width('100%') + .borderRadius(16) + .backgroundColor($r('app.color.bg_white')) + .margin({ top: 12 }) + + Row() { + Image($r('app.media.ic_public_phone')) + .margin({ left: 19 }) + .width(19) + .aspectRatio(1) + Text($r('app.string.contact_phone')) + .margin({ left: 19 }) + .fontSize(16) + .fontColor($r('app.color.text_color_primary')) + Column() { + TextInput({ placeholder: $r('app.string.input_phone') }) + .id('add_phone') + .height(48) + .fontSize(16) + .backgroundColor($r('sys.color.ohos_id_color_background_transparent')) + .onChange((value: string) => { + this.information.phone = value; + }) + } + .layoutWeight(1) + .margin({ left: 52, right: 16 }) + } + .height(64) + .width('100%') + .borderRadius(16) + .backgroundColor($r('app.color.bg_white')) + .margin({ top: 12 }) + } + .height('100%') + .backgroundColor($r('sys.color.ohos_id_color_sub_background')) + .padding({ left: 12, right: 12 }) + } +} \ No newline at end of file diff --git a/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/entry/src/main/ets/pages/AddKeyValuePairView.ets b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/entry/src/main/ets/pages/AddKeyValuePairView.ets new file mode 100644 index 0000000000000000000000000000000000000000..3d60ee4a07e7cf4e9315190a53dfab252524777c --- /dev/null +++ b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/entry/src/main/ets/pages/AddKeyValuePairView.ets @@ -0,0 +1,165 @@ +/* +* 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 router from '@ohos.router'; +import emitter from '@ohos.events.emitter'; +import { Constant, KeyValuePair } from '@ohos/capabilities'; +import { getString } from '@ohos/common/src/main/ets/util/ResourceUtil'; + +@Entry +@Component +export struct AddKeyValueView { + @State keyValuePair: KeyValuePair = new KeyValuePair('', '') + @State title: string = ''; + @State flag: string = ''; + + aboutToAppear() { + let tem: string = (router.getParams() as Record)['title'] as string; + if (!tem) { + return; + } + this.flag = tem; + let matchArr: RegExpMatchArray | null = tem.match(new RegExp('.*(?=\\(|()')); + if (matchArr !== null) { + this.title = `${getString($r('app.string.add'))}${matchArr[0]}`; + } + } + + build() { + Column() { + Row() { + Row() { + Image($r("app.media.ic_public_back")) + .height(24) + .aspectRatio(1) + .objectFit(ImageFit.Contain) + } + .height('100%') + .aspectRatio(1) + .padding({ left: 24 }) + .onClick(() => { + router.back(); + }) + + Text(this.title) + .fontColor($r('app.color.text_color_primary')) + .fontSize(20) + .margin({ left: 24 }) + + Blank() + + Row() { + Image($r("app.media.ic_public_confirm")) + .height(24) + .aspectRatio(1) + .objectFit(ImageFit.Contain) + } + .id('add_confirm') + .height('100%') + .aspectRatio(1) + .padding({ right: 24 }) + .onClick(() => { + let eventId = Constant.EMITTER_ID_DEFAULT; + switch (this.flag) { + case getString($r('app.string.hash_map')): + eventId = Constant.EMITTER_ID_HASH_MAP; + break; + case getString($r('app.string.light_weight_map')): + eventId = Constant.EMITTER_ID_LIGHT_WEIGHT_MAP; + break; + case getString($r('app.string.plain_array')): + eventId = Constant.EMITTER_ID_PLAIN_ARRAY; + break; + case getString($r('app.string.tree_map')): + eventId = Constant.EMITTER_ID_TREE_MAP; + break; + default: + eventId = Constant.EMITTER_ID_DEFAULT; + break; + } + + let event: emitter.InnerEvent = { + eventId: eventId, + priority: emitter.EventPriority.HIGH + }; + + let eventData: emitter.EventData = { + data: { + 'key': this.keyValuePair.key, + 'value': this.keyValuePair.value + } + }; + + emitter.emit(event, eventData); + router.back(); + }) + } + .width('100%') + .height(56) + + Row() { + Text('Key') + .width(44) + .margin({ left: 19 }) + .fontSize(16) + .fontColor($r('app.color.text_color_primary')) + Column() { + TextInput({ placeholder: $r('app.string.input_key') }) + .id('add_key') + .height(48) + .fontSize(16) + .backgroundColor($r('sys.color.ohos_id_color_background_transparent')) + .onChange((value: string) => { + this.keyValuePair.key = value; + }) + } + .layoutWeight(1) + .margin({ left: 52, right: 16 }) + } + .height(64) + .width('100%') + .borderRadius(16) + .backgroundColor($r('app.color.bg_white')) + .margin({ top: 12 }) + + Row() { + Text('Value') + .margin({ left: 19 }) + .fontSize(16) + .fontColor($r('app.color.text_color_primary')) + Column() { + TextInput({ placeholder: $r('app.string.input_value') }) + .id('add_value') + .height(48) + .fontSize(16) + .backgroundColor($r('sys.color.ohos_id_color_background_transparent')) + .onChange((value: string) => { + this.keyValuePair.value = value; + }) + } + .layoutWeight(1) + .margin({ left: 52, right: 16 }) + } + .height(64) + .width('100%') + .borderRadius(16) + .backgroundColor($r('app.color.bg_white')) + .margin({ top: 12 }) + } + .height('100%') + .backgroundColor($r('sys.color.ohos_id_color_sub_background')) + .padding({ left: 12, right: 12 }) + } +} \ No newline at end of file diff --git a/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/entry/src/main/ets/pages/AddStringView.ets b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/entry/src/main/ets/pages/AddStringView.ets new file mode 100644 index 0000000000000000000000000000000000000000..425ec83579d1b069bf70aae3a3e8f6f0bb5e156c --- /dev/null +++ b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/entry/src/main/ets/pages/AddStringView.ets @@ -0,0 +1,135 @@ +/* +* 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 router from '@ohos.router'; +import emitter from '@ohos.events.emitter'; +import { getString } from '@ohos/common/src/main/ets/util/ResourceUtil'; +import { Constant } from '@ohos/capabilities'; + +@Entry +@Component +export struct AddKeyValueView { + @State value: string = '' + @State title: string = ''; + @State flag: string = ''; + + aboutToAppear() { + let tem: string = (router.getParams() as Record)['title'] as string; + if (!tem) { + return; + } + this.flag = tem; + let regex: RegExp = new RegExp('.*(?=\\(|()'); + let matchArr: RegExpMatchArray | null = tem.match(regex); + if (matchArr !== null) { + this.title = `${getString($r('app.string.add'))}${matchArr[0]}`; + } + } + + build() { + Column() { + Row() { + Row() { + Image($r("app.media.ic_public_back")) + .height(24) + .aspectRatio(1) + .objectFit(ImageFit.Contain) + } + .height('100%') + .aspectRatio(1) + .padding({ left: 24 }) + .onClick(() => { + router.back(); + }) + + Text(this.title) + .fontColor($r('app.color.text_color_primary')) + .fontSize(20) + .margin({ left: 24 }) + + Blank() + + Row() { + Image($r("app.media.ic_public_confirm")) + .height(24) + .aspectRatio(1) + .objectFit(ImageFit.Contain) + } + .id('add_confirm') + .height('100%') + .aspectRatio(1) + .padding({ right: 24 }) + .onClick(() => { + let eventId = Constant.EMITTER_ID_DEFAULT; + switch (this.flag) { + case getString($r('app.string.hash_set')): + eventId = Constant.EMITTER_ID_HASH_SET; + break; + case getString($r('app.string.light_weight_set')): + eventId = Constant.EMITTER_ID_LIGHT_WEIGHT_SET; + break; + case getString($r('app.string.tree_set')): + eventId = Constant.EMITTER_ID_TREE_SET; + break; + default: + eventId = Constant.EMITTER_ID_DEFAULT; + break; + } + + let event: emitter.InnerEvent = { + eventId: eventId, + priority: emitter.EventPriority.HIGH + }; + + let eventData: emitter.EventData = { + data: { 'value': this.value } + }; + + emitter.emit(event, eventData); + router.back(); + }) + } + .width('100%') + .height(56) + + Row() { + Text('Value') + .margin({ left: 19 }) + .fontSize(16) + .fontColor($r('app.color.text_color_primary')) + Column() { + TextInput({ placeholder: $r('app.string.input_value') }) + .id('add_value') + .height(48) + .fontSize(16) + .backgroundColor($r('sys.color.ohos_id_color_background_transparent')) + .onChange((value: string) => { + this.value = value; + }) + } + .layoutWeight(1) + .margin({ left: 52, right: 16 }) + } + .height(64) + .width('100%') + .borderRadius(16) + .backgroundColor($r('app.color.bg_white')) + .margin({ top: 12 }) + } + .height('100%') + .backgroundColor($r('sys.color.ohos_id_color_sub_background')) + .padding({ left: 12, right: 12 }) + } +} \ No newline at end of file diff --git a/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/entry/src/main/ets/pages/Index.ets b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/entry/src/main/ets/pages/Index.ets new file mode 100644 index 0000000000000000000000000000000000000000..f318e089b7e52a8ce6d23f0141576c0815e33c0d --- /dev/null +++ b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/entry/src/main/ets/pages/Index.ets @@ -0,0 +1,91 @@ +/* + * Copyright (c) 2023 Huawei Device 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 router from '@ohos.router'; +import { Capabilities } from './components/Capabilities'; +import { MenuList } from '@ohos/menuitems'; +import { logger } from '@ohos/common/src/main/ets/util/Logger'; +import { getString } from '@ohos/common/src/main/ets/util/ResourceUtil'; + +const TAG: string = 'Index'; + +@Entry +@Component +struct Index { + @StorageProp('windowWidth') windowWidth: number = 300; + @StorageProp('isSplitMode') isSplitMode: boolean = false; + @State title: string = ''; + + aboutToAppear() { + this.title = getContext().resourceManager.getStringSync($r('app.string.lable_name').id); + } + + build() { + Navigation() { + Divider() + .strokeWidth('1px') + .color($r('sys.color.ohos_id_color_list_separator')) + MenuList({ + menuList: $r('app.strarray.language_base_class_library_list'), + addAction: (title: string) => { + logger.info(TAG, `addAction: title = ${title}`) + switch (title) { + case getString($r('app.string.deque')): + case getString($r('app.string.linked_list')): + case getString($r('app.string.list')): + case getString($r('app.string.queue')): + case getString($r('app.string.stack')): + case getString($r('app.string.vector')): + router.pushUrl({ url: 'pages/AddInformationView', params: { 'title': title } }) + break; + case getString($r('app.string.hash_map')): + case getString($r('app.string.light_weight_map')): + case getString($r('app.string.plain_array')): + case getString($r('app.string.tree_map')): + router.pushUrl({ url: 'pages/AddKeyValuePairView', params: { 'title': title } }) + break; + case getString($r('app.string.hash_set')): + case getString($r('app.string.light_weight_set')): + case getString($r('app.string.tree_set')): + router.pushUrl({ url: 'pages/AddStringView', params: { 'title': title } }) + break; + } + } + }) { + Capabilities() + } + } + .title(this.CustomTitle()) + .mode(this.isSplitMode ? NavigationMode.Split : NavigationMode.Stack) + .navBarWidth(0.4 * this.windowWidth) + .titleMode(NavigationTitleMode.Mini) + .hideToolBar(true) + .width('100%') + .height('100%') + .backgroundColor($r("sys.color.ohos_id_color_sub_background")) + } + + @Builder + CustomTitle() { + Row() { + Text(this.title) + .fontColor($r('app.color.black')) + .fontSize(26) + .fontWeight(FontWeight.Bold) + } + .height(56) + .width('100%') + } +} \ No newline at end of file diff --git a/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/entry/src/main/ets/pages/components/Capabilities.ets b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/entry/src/main/ets/pages/components/Capabilities.ets new file mode 100644 index 0000000000000000000000000000000000000000..49cbb344a204dffc6d086b2385dfa15a967b0a49 --- /dev/null +++ b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/entry/src/main/ets/pages/components/Capabilities.ets @@ -0,0 +1,111 @@ +/** + * Copyright (c) 2023 Huawei Device 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 { getString } from '@ohos/common/src/main/ets/util/ResourceUtil'; +import { + ArrayListView, + ConvertXml, + Url, + Util, + ProcessMessage, + TaskPool, + DequeView, + HashMapView, + HashSetView, + LightWeightMapView, + LightWeightSetView, + LinkedListView, + ListView, + PlainArrayView, + QueueView, + StackView, + TreeMapView, + TreeSetView, + VectorView +} from '@ohos/capabilities'; + +@Component +export struct Capabilities { + @StorageLink('selectedLabel') selectedLabel: string = ''; + + build() { + Column() { + Divider() + .strokeWidth('1px') + .color($r('sys.color.ohos_id_color_list_separator')) + Column() { + // 此处根据选中的菜单,显示对应的页面内容 + if (this.selectedLabel === getString($r('app.string.xml'))) { + ConvertXml() + } + if (this.selectedLabel === getString($r('app.string.util'))) { + Util() + } + if (this.selectedLabel === getString($r('app.string.process'))) { + ProcessMessage() + } + if (this.selectedLabel === getString($r('app.string.url'))) { + Url() + } + if (this.selectedLabel === getString($r('app.string.array_list'))) { + ArrayListView() + } + if (this.selectedLabel === getString($r('app.string.task_pool'))) { + TaskPool() + } + if (this.selectedLabel === getString($r('app.string.deque'))) { + DequeView() + } + if (this.selectedLabel === getString($r('app.string.hash_map'))) { + HashMapView() + } + if (this.selectedLabel === getString($r('app.string.hash_set'))) { + HashSetView() + } + if (this.selectedLabel === getString($r('app.string.light_weight_map'))) { + LightWeightMapView() + } + if (this.selectedLabel === getString($r('app.string.light_weight_set'))) { + LightWeightSetView() + } + if (this.selectedLabel === getString($r('app.string.linked_list'))) { + LinkedListView() + } + if (this.selectedLabel === getString($r('app.string.list'))) { + ListView() + } + if (this.selectedLabel === getString($r('app.string.plain_array'))) { + PlainArrayView() + } + if (this.selectedLabel === getString($r('app.string.queue'))) { + QueueView() + } + if (this.selectedLabel === getString($r('app.string.stack'))) { + StackView() + } + if (this.selectedLabel === getString($r('app.string.tree_map'))) { + TreeMapView() + } + if (this.selectedLabel === getString($r('app.string.tree_set'))) { + TreeSetView() + } + if (this.selectedLabel === getString($r('app.string.vector'))) { + VectorView() + } + } + .padding({ left: 12, right: 12 }) + } + } +} \ No newline at end of file diff --git a/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/entry/src/main/module.json5 b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/entry/src/main/module.json5 new file mode 100644 index 0000000000000000000000000000000000000000..7d12c705277fc6c991239661dc30f9695f6c2d66 --- /dev/null +++ b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/entry/src/main/module.json5 @@ -0,0 +1,52 @@ +/* + * Copyright (c) 2023 Huawei Device 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. + */ + +{ + "module": { + "name": "entry", + "type": "entry", + "description": "$string:module_desc", + "mainElement": "EntryAbility", + "deviceTypes": [ + "default", + "tablet" + ], + "deliveryWithInstall": true, + "installationFree": false, + "pages": "$profile:main_pages", + "abilities": [ + { + "name": "EntryAbility", + "srcEntrance": "./ets/entryability/EntryAbility.ets", + "description": "$string:EntryAbility_desc", + "icon": "$media:icon", + "label": "$string:lable_name", + "startWindowIcon": "$media:icon", + "startWindowBackground": "$color:start_window_background", + "visible": true, + "skills": [ + { + "entities": [ + "entity.system.home" + ], + "actions": [ + "action.system.home" + ] + } + ] + } + ] + } +} \ No newline at end of file diff --git a/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/entry/src/main/resources/base/element/color.json b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/entry/src/main/resources/base/element/color.json new file mode 100644 index 0000000000000000000000000000000000000000..3c712962da3c2751c2b9ddb53559afcbd2b54a02 --- /dev/null +++ b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/entry/src/main/resources/base/element/color.json @@ -0,0 +1,8 @@ +{ + "color": [ + { + "name": "start_window_background", + "value": "#FFFFFF" + } + ] +} \ No newline at end of file diff --git a/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/entry/src/main/resources/base/element/strarray.json b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/entry/src/main/resources/base/element/strarray.json new file mode 100644 index 0000000000000000000000000000000000000000..6f294c6c424ba0e2b8491fe60cd1439003530752 --- /dev/null +++ b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/entry/src/main/resources/base/element/strarray.json @@ -0,0 +1,67 @@ +{ + "strarray": [ + { + "name": "language_base_class_library_list", + "value": [ + + { + "value": "Xml & ConvertXml (XML Parsing,Generation and convert)" + }, + { + "value": "Process (Obtaining Process Information)" + }, + { + "value": "TaskPool (Using the Task Pool)" + }, + { + "value": "Url (URL String Parsing)" + }, + { + "value": "Util (util)" + }, + { + "value": "ArrayList (Linear Container ArrayList)" + }, + { + "value": "Deque (Linear Container ArrayList)" + }, + { + "value": "HashMap (Nonlinear Container HashMap)" + }, + { + "value": "HashSet (Nonlinear Container HashSet)" + }, + { + "value": "LightWeightMap (Nonlinear Container LightWeightMap)" + }, + { + "value": "LightWeightSet (Nonlinear Container LightWeightMap)" + }, + { + "value": "LinkedList (Nonlinear Container LightWeightMap)" + }, + { + "value": "List (Nonlinear Container LightWeightMap)" + }, + { + "value": "PlainArray (Nonlinear Container PlainArray)" + }, + { + "value": "Queue (Linear Container Queue)" + }, + { + "value": "Stack (Linear Container Stack)" + }, + { + "value": "TreeMap (Nonlinear Container TreeMap)" + }, + { + "value": "TreeSet (Nonlinear Container TreeSet)" + }, + { + "value": "Vector (Linear Container Vector)" + } + ] + } + ] +} \ No newline at end of file diff --git a/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/entry/src/main/resources/base/element/string.json b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/entry/src/main/resources/base/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..3bcb2fe11547eed4598db7116fa8254f51ff01cb --- /dev/null +++ b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/entry/src/main/resources/base/element/string.json @@ -0,0 +1,128 @@ +{ + "string": [ + { + "name": "module_desc", + "value": "module description" + }, + { + "name": "EntryAbility_desc", + "value": "description" + }, + { + "name": "lable_name", + "value": "LanguageBaseClassLibrary" + }, + { + "name": "xml", + "value": "Xml & ConvertXml (XML Parsing,Generation and convert)" + }, + { + "name": "url", + "value": "Url (URL String Parsing)" + }, + { + "name": "util", + "value": "Util (util)" + }, + { + "name": "process", + "value": "Process (Obtaining Process Information)" + }, + { + "name": "array_list", + "value": "ArrayList (Linear Container ArrayList)" + }, + { + "name": "task_pool", + "value": "TaskPool (Start Task Pool)" + }, + { + "name": "deque", + "value": "Deque (Linear Container Deque)" + }, + { + "name": "hash_map", + "value": "HashMap (NoLinear Container HashMap)" + }, + { + "name": "hash_set", + "value": "HashSet (NoLinear Container HashSet)" + }, + { + "name": "light_weight_map", + "value": "LightWeightMap (NoLinear Container LightWeightMap)" + }, + { + "name": "light_weight_set", + "value": "LightWeightSet (NoLinear Container LightWeightSet)" + }, + { + "name": "linked_list", + "value": "LinkedList (Linear Container LinkedList)" + }, + { + "name": "list", + "value": "List (Linear Container List)" + }, + { + "name": "plain_array", + "value": "PlainArray (NoLinear Container PlainArray)" + }, + { + "name": "queue", + "value": "Queue (Linear Container Queue)" + }, + { + "name": "stack", + "value": "Stack (Linear Container Stack)" + }, + { + "name": "tree_map", + "value": "TreeMap (NoLinear Container TreeMap)" + }, + { + "name": "tree_set", + "value": "TreeSet (NoLinear Container TreeSet)" + }, + { + "name": "vector", + "value": "Vector (Linear Container Vector)" + }, + { + "name": "age", + "value": "Age" + }, + { + "name": "cancel", + "value": "Cancel" + }, + { + "name": "sure", + "value": "Sure" + }, + { + "name": "add_new_contact", + "value": "Add new contact" + }, + { + "name": "names", + "value": "Name" + }, + { + "name": "please_choose", + "value": "Please choose" + }, + { + "name": "add", + "value": "Add" + }, + { + "name": "input_key", + "value": "Please input key" + }, + { + "name": "input_value", + "value": "Please input value" + } + ] +} \ No newline at end of file diff --git a/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/entry/src/main/resources/base/media/ic_age.svg b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/entry/src/main/resources/base/media/ic_age.svg new file mode 100644 index 0000000000000000000000000000000000000000..57041b2fb3dc9ad64a623a8a4efc9cae2e5e71e6 --- /dev/null +++ b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/entry/src/main/resources/base/media/ic_age.svg @@ -0,0 +1,15 @@ + + + + + + + + + + + + + + + diff --git a/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/entry/src/main/resources/base/media/ic_public_back.svg b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/entry/src/main/resources/base/media/ic_public_back.svg new file mode 100644 index 0000000000000000000000000000000000000000..3cb3450459799c3eae71e6b064c62ca07e6f4dc8 --- /dev/null +++ b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/entry/src/main/resources/base/media/ic_public_back.svg @@ -0,0 +1,5 @@ + + + + + diff --git a/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/entry/src/main/resources/base/media/ic_public_confirm.svg b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/entry/src/main/resources/base/media/ic_public_confirm.svg new file mode 100644 index 0000000000000000000000000000000000000000..7cbd6159e6b3cbc1d79e8a375f0f127d84097650 --- /dev/null +++ b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/entry/src/main/resources/base/media/ic_public_confirm.svg @@ -0,0 +1,5 @@ + + + + + diff --git a/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/entry/src/main/resources/base/media/ic_public_phone.svg b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/entry/src/main/resources/base/media/ic_public_phone.svg new file mode 100644 index 0000000000000000000000000000000000000000..e2aad498b3946bc6f3f9a2ba1e77c8b25a218e38 --- /dev/null +++ b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/entry/src/main/resources/base/media/ic_public_phone.svg @@ -0,0 +1,7 @@ + + + + + + + diff --git a/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/entry/src/main/resources/base/media/ic_public_spinner_down.svg b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/entry/src/main/resources/base/media/ic_public_spinner_down.svg new file mode 100644 index 0000000000000000000000000000000000000000..e22aa83ad6cf3ec4c86bf7b03ecf8c663cfefe95 --- /dev/null +++ b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/entry/src/main/resources/base/media/ic_public_spinner_down.svg @@ -0,0 +1,5 @@ + + + + + diff --git a/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/entry/src/main/resources/base/media/ic_public_user.svg b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/entry/src/main/resources/base/media/ic_public_user.svg new file mode 100644 index 0000000000000000000000000000000000000000..dacbc0f1404d9389da82919bc0b39d1f07bedb7d --- /dev/null +++ b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/entry/src/main/resources/base/media/ic_public_user.svg @@ -0,0 +1,7 @@ + + + + + + + diff --git a/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/entry/src/main/resources/base/media/icon.png b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/entry/src/main/resources/base/media/icon.png new file mode 100644 index 0000000000000000000000000000000000000000..ce307a8827bd75456441ceb57d530e4c8d45d36c Binary files /dev/null and b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/entry/src/main/resources/base/media/icon.png differ diff --git a/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/entry/src/main/resources/base/profile/main_pages.json b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/entry/src/main/resources/base/profile/main_pages.json new file mode 100644 index 0000000000000000000000000000000000000000..3de427eaa714dc55d3030120bc850c2b4a63b310 --- /dev/null +++ b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/entry/src/main/resources/base/profile/main_pages.json @@ -0,0 +1,8 @@ +{ + "src": [ + "pages/Index", + "pages/AddInformationView", + "pages/AddKeyValuePairView", + "pages/AddStringView" + ] +} \ No newline at end of file diff --git a/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/entry/src/main/resources/en_US/element/strarray.json b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/entry/src/main/resources/en_US/element/strarray.json new file mode 100644 index 0000000000000000000000000000000000000000..6f294c6c424ba0e2b8491fe60cd1439003530752 --- /dev/null +++ b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/entry/src/main/resources/en_US/element/strarray.json @@ -0,0 +1,67 @@ +{ + "strarray": [ + { + "name": "language_base_class_library_list", + "value": [ + + { + "value": "Xml & ConvertXml (XML Parsing,Generation and convert)" + }, + { + "value": "Process (Obtaining Process Information)" + }, + { + "value": "TaskPool (Using the Task Pool)" + }, + { + "value": "Url (URL String Parsing)" + }, + { + "value": "Util (util)" + }, + { + "value": "ArrayList (Linear Container ArrayList)" + }, + { + "value": "Deque (Linear Container ArrayList)" + }, + { + "value": "HashMap (Nonlinear Container HashMap)" + }, + { + "value": "HashSet (Nonlinear Container HashSet)" + }, + { + "value": "LightWeightMap (Nonlinear Container LightWeightMap)" + }, + { + "value": "LightWeightSet (Nonlinear Container LightWeightMap)" + }, + { + "value": "LinkedList (Nonlinear Container LightWeightMap)" + }, + { + "value": "List (Nonlinear Container LightWeightMap)" + }, + { + "value": "PlainArray (Nonlinear Container PlainArray)" + }, + { + "value": "Queue (Linear Container Queue)" + }, + { + "value": "Stack (Linear Container Stack)" + }, + { + "value": "TreeMap (Nonlinear Container TreeMap)" + }, + { + "value": "TreeSet (Nonlinear Container TreeSet)" + }, + { + "value": "Vector (Linear Container Vector)" + } + ] + } + ] +} \ No newline at end of file diff --git a/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/entry/src/main/resources/en_US/element/string.json b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/entry/src/main/resources/en_US/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..3bcb2fe11547eed4598db7116fa8254f51ff01cb --- /dev/null +++ b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/entry/src/main/resources/en_US/element/string.json @@ -0,0 +1,128 @@ +{ + "string": [ + { + "name": "module_desc", + "value": "module description" + }, + { + "name": "EntryAbility_desc", + "value": "description" + }, + { + "name": "lable_name", + "value": "LanguageBaseClassLibrary" + }, + { + "name": "xml", + "value": "Xml & ConvertXml (XML Parsing,Generation and convert)" + }, + { + "name": "url", + "value": "Url (URL String Parsing)" + }, + { + "name": "util", + "value": "Util (util)" + }, + { + "name": "process", + "value": "Process (Obtaining Process Information)" + }, + { + "name": "array_list", + "value": "ArrayList (Linear Container ArrayList)" + }, + { + "name": "task_pool", + "value": "TaskPool (Start Task Pool)" + }, + { + "name": "deque", + "value": "Deque (Linear Container Deque)" + }, + { + "name": "hash_map", + "value": "HashMap (NoLinear Container HashMap)" + }, + { + "name": "hash_set", + "value": "HashSet (NoLinear Container HashSet)" + }, + { + "name": "light_weight_map", + "value": "LightWeightMap (NoLinear Container LightWeightMap)" + }, + { + "name": "light_weight_set", + "value": "LightWeightSet (NoLinear Container LightWeightSet)" + }, + { + "name": "linked_list", + "value": "LinkedList (Linear Container LinkedList)" + }, + { + "name": "list", + "value": "List (Linear Container List)" + }, + { + "name": "plain_array", + "value": "PlainArray (NoLinear Container PlainArray)" + }, + { + "name": "queue", + "value": "Queue (Linear Container Queue)" + }, + { + "name": "stack", + "value": "Stack (Linear Container Stack)" + }, + { + "name": "tree_map", + "value": "TreeMap (NoLinear Container TreeMap)" + }, + { + "name": "tree_set", + "value": "TreeSet (NoLinear Container TreeSet)" + }, + { + "name": "vector", + "value": "Vector (Linear Container Vector)" + }, + { + "name": "age", + "value": "Age" + }, + { + "name": "cancel", + "value": "Cancel" + }, + { + "name": "sure", + "value": "Sure" + }, + { + "name": "add_new_contact", + "value": "Add new contact" + }, + { + "name": "names", + "value": "Name" + }, + { + "name": "please_choose", + "value": "Please choose" + }, + { + "name": "add", + "value": "Add" + }, + { + "name": "input_key", + "value": "Please input key" + }, + { + "name": "input_value", + "value": "Please input value" + } + ] +} \ No newline at end of file diff --git a/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/entry/src/main/resources/zh_CN/element/strarray.json b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/entry/src/main/resources/zh_CN/element/strarray.json new file mode 100644 index 0000000000000000000000000000000000000000..c0e7094d86a455daaaee82a2cf42564c640c62fa --- /dev/null +++ b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/entry/src/main/resources/zh_CN/element/strarray.json @@ -0,0 +1,67 @@ +{ + "strarray": [ + { + "name": "language_base_class_library_list", + "value": [ + + { + "value": "Xml & ConvertXml (XML解析,生成与转换)" + }, + { + "value": "Process (获取进程相关的信息)" + }, + { + "value": "TaskPool (启动任务池)" + }, + { + "value": "Url (Url字符串解析)" + }, + { + "value": "Util (util工具函数)" + }, + { + "value": "ArrayList (线性容器ArrayList)" + }, + { + "value": "Deque (线性容器Deque)" + }, + { + "value": "HashMap (非线性容器HashMap)" + }, + { + "value": "HashSet (非线性容器HashSet)" + }, + { + "value": "LightWeightMap (非线性容器LightWeightMap)" + }, + { + "value": "LightWeightSet (非线性容器LightWeightSet)" + }, + { + "value": "LinkedList (线性容器LinkedList)" + }, + { + "value": "List (线性容器List)" + }, + { + "value": "PlainArray (非线性容器PlainArray)" + }, + { + "value": "Queue (线性容器Queue)" + }, + { + "value": "Stack (线性容器Stack)" + }, + { + "value": "TreeMap (非线性容器TreeMap)" + }, + { + "value": "TreeSet (非线性容器TreeSet)" + }, + { + "value": "Vector (线性容器Vector)" + } + ] + } + ] +} \ No newline at end of file diff --git a/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/entry/src/main/resources/zh_CN/element/string.json b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/entry/src/main/resources/zh_CN/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..3ff4715154e9024d4658464fd94a78c66aac7172 --- /dev/null +++ b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/entry/src/main/resources/zh_CN/element/string.json @@ -0,0 +1,128 @@ +{ + "string": [ + { + "name": "module_desc", + "value": "模块描述" + }, + { + "name": "EntryAbility_desc", + "value": "description" + }, + { + "name": "lable_name", + "value": "语言基础类库" + }, + { + "name": "xml", + "value": "Xml & ConvertXml (XML解析,生成与转换)" + }, + { + "name": "url", + "value": "Url (Url字符串解析)" + }, + { + "name": "util", + "value": "Util (util工具函数)" + }, + { + "name": "process", + "value": "Process (获取进程相关的信息)" + }, + { + "name": "array_list", + "value": "ArrayList (线性容器ArrayList)" + }, + { + "name": "task_pool", + "value": "TaskPool (启动任务池)" + }, + { + "name": "deque", + "value": "Deque (线性容器Deque)" + }, + { + "name": "hash_map", + "value": "HashMap (非线性容器HashMap)" + }, + { + "name": "hash_set", + "value": "HashSet (非线性容器HashSet)" + }, + { + "name": "light_weight_map", + "value": "LightWeightMap (非线性容器LightWeightMap)" + }, + { + "name": "light_weight_set", + "value": "LightWeightSet (非线性容器LightWeightSet)" + }, + { + "name": "linked_list", + "value": "LinkedList (线性容器LinkedList)" + }, + { + "name": "list", + "value": "List (线性容器List)" + }, + { + "name": "plain_array", + "value": "PlainArray (非线性容器PlainArray)" + }, + { + "name": "queue", + "value": "Queue (线性容器Queue)" + }, + { + "name": "stack", + "value": "Stack (线性容器Stack)" + }, + { + "name": "tree_map", + "value": "TreeMap (非线性容器TreeMap)" + }, + { + "name": "tree_set", + "value": "TreeSet (非线性容器TreeSet)" + }, + { + "name": "vector", + "value": "Vector (线性容器Vector)" + }, + { + "name": "age", + "value": "年龄" + }, + { + "name": "cancel", + "value": "取消" + }, + { + "name": "sure", + "value": "确定" + }, + { + "name": "add_new_contact", + "value": "新增联系人" + }, + { + "name": "names", + "value": "姓名" + }, + { + "name": "please_choose", + "value": "请选择" + }, + { + "name": "add", + "value": "新增" + }, + { + "name": "input_key", + "value": "请输入key" + }, + { + "name": "input_value", + "value": "请输入value" + } + ] +} \ No newline at end of file diff --git a/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/entry/src/ohosTest/ets/TestRunner/OpenHarmonyTestRunner.ts b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/entry/src/ohosTest/ets/TestRunner/OpenHarmonyTestRunner.ts new file mode 100644 index 0000000000000000000000000000000000000000..d25d79095872f62e17581b09ec737092852f9db9 --- /dev/null +++ b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/entry/src/ohosTest/ets/TestRunner/OpenHarmonyTestRunner.ts @@ -0,0 +1,67 @@ +/* + * Copyright (c) 2023 Huawei Device 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 AbilityDelegatorRegistry from '@ohos.app.ability.abilityDelegatorRegistry'; +import type TestRunner from '@ohos.application.testRunner'; +import { logger } from '../util/Logger'; + +let abilityDelegator = undefined; +let abilityDelegatorArguments = undefined; +const TAG: string = 'OpenHarmonyTestRunner'; + +async function onAbilityCreateCallback() { + logger.info(TAG, 'onAbilityCreateCallback'); +} + +async function addAbilityMonitorCallback(err: any) { + logger.info(TAG, `addAbilityMonitorCallback : ${JSON.stringify(err) ?? ''} `); +} + +export default class OpenHarmonyTestRunner implements TestRunner { + constructor() { + } + + onPrepare() { + logger.info(TAG, 'OpenHarmonyTestRunner OnPrepare '); + } + + async onRun() { + logger.info(TAG, 'OpenHarmonyTestRunner onRun run'); + abilityDelegatorArguments = AbilityDelegatorRegistry.getArguments(); + abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator(); + let testAbilityName = abilityDelegatorArguments.bundleName + '.TestAbility'; + let lMonitor = { + abilityName: testAbilityName, + onAbilityCreate: onAbilityCreateCallback, + }; + abilityDelegator.addAbilityMonitor(lMonitor, addAbilityMonitorCallback); + let cmd = 'aa start -d 0 -a TestAbility' + ' -b ' + abilityDelegatorArguments.bundleName; + let debug = abilityDelegatorArguments.parameters['-D']; + if (debug == 'true') { + cmd += ' -D'; + } + logger.info(TAG, `cmd : ${cmd}`); + abilityDelegator.executeShellCommand(cmd, + (err: Error, d: { + stdResult: string, + exitCode: number + }) => { + logger.info(TAG, `executeShellCommand : err : ${JSON.stringify(err) ?? ''}`); + logger.info(TAG, `executeShellCommand : data : ${d.stdResult ?? ''}`); + logger.info(TAG, `executeShellCommand : data : ${d.exitCode ?? ''}`); + }); + logger.info(TAG, 'OpenHarmonyTestRunner onRun end'); + } +} \ No newline at end of file diff --git a/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/entry/src/ohosTest/ets/test/Ability.test.ets b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/entry/src/ohosTest/ets/test/Ability.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..240281c6eed4878238dde5054ef16eae5fb05101 --- /dev/null +++ b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/entry/src/ohosTest/ets/test/Ability.test.ets @@ -0,0 +1,886 @@ +/* + * Copyright (c) 2023 Huawei Device 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 AbilityDelegatorRegistry from '@ohos.app.ability.abilityDelegatorRegistry'; +import { describe, it, expect } from '@ohos/hypium'; +import { Driver, ON, MatchPattern } from '@ohos.UiTest'; +import { logger } from '../util/Logger'; +import Want from '@ohos.app.ability.Want'; + +const TAG: string = 'Sample_LanguageBaseClassLibraryTest'; +const BUNDLE = 'LanguageBaseClassLibrary'; +const delegator = AbilityDelegatorRegistry.getAbilityDelegator() +const driver: Driver = Driver.create(); + +// 资源本地化 +async function getResourceString(resource: Resource): Promise { + let manage = delegator.getAppContext().resourceManager + let text = await manage.getStringValue(resource) + return text +} + +async function addContact(driver: Driver, name: string, phone: string) { + // 进入新增联系人 + await driver.assertComponentExist(ON.id('add')); + let addBtn = await driver.findComponent(ON.id('add')); + await addBtn.click(); + await driver.delayMs(200); + // 点击姓名输入框 + await driver.assertComponentExist(ON.id('add_name')); + let addNameTextInput = await driver.findComponent(ON.id('add_name')); + await addNameTextInput.inputText(name); + await driver.delayMs(200); + // 点击年龄输入框 + await driver.assertComponentExist(ON.id('add_age')); + let addAgeComponent = await driver.findComponent(ON.id('add_age')); + await addAgeComponent.click(); + await driver.delayMs(200); + // 点击确定按钮 + await driver.assertComponentExist(ON.id('add_sure')); + let addSureBtn = await driver.findComponent(ON.id('add_sure')); + await addSureBtn.click(); + await driver.delayMs(200); + // 点击电话输入框 + await driver.assertComponentExist(ON.id('add_phone')); + let addPhoneTextInput = await driver.findComponent(ON.id('add_phone')); + await addPhoneTextInput.inputText(phone); + await driver.delayMs(200); + // 点击完成按钮 + await driver.assertComponentExist(ON.id('add_confirm')); + let addConfirmBtn = await driver.findComponent(ON.id('add_confirm')); + await addConfirmBtn.click(); + await driver.delayMs(200); +} + +async function deleteItem(driver: Driver, id: string) { + await driver.assertComponentExist(ON.id(id)); + let deleteBtn = await driver.findComponent(ON.id(id)); + await deleteBtn.click(); + await driver.delayMs(200); +} + +async function addKeyValue(driver: Driver, key: string, value: string) { + // 进入新增Key/Value + await driver.assertComponentExist(ON.id('add')); + let addBtn = await driver.findComponent(ON.id('add')); + await addBtn.click(); + await driver.delayMs(200); + // 点击Key输入框 + await driver.assertComponentExist(ON.id('add_key')); + let addKeyTextInput = await driver.findComponent(ON.id('add_key')); + await addKeyTextInput.inputText(key); + await driver.delayMs(200); + // 点击Value输入框 + await driver.assertComponentExist(ON.id('add_value')); + let addValueTextInput = await driver.findComponent(ON.id('add_value')); + await addValueTextInput.inputText(value); + await driver.delayMs(200); + // 点击完成按钮 + await driver.assertComponentExist(ON.id('add_confirm')); + let addConfirmBtn = await driver.findComponent(ON.id('add_confirm')); + await addConfirmBtn.click(); + await driver.delayMs(200); +} + +async function addValue(driver: Driver, value: string) { + // 进入新增Value + await driver.assertComponentExist(ON.id('add')); + let addBtn = await driver.findComponent(ON.id('add')); + await addBtn.click(); + await driver.delayMs(200); + // 点击Value输入框 + await driver.assertComponentExist(ON.id('add_value')); + let addValueTextInput = await driver.findComponent(ON.id('add_value')); + await addValueTextInput.inputText(value); + await driver.delayMs(200); + // 点击完成按钮 + await driver.assertComponentExist(ON.id('add_confirm')); + let addConfirmBtn = await driver.findComponent(ON.id('add_confirm')); + await addConfirmBtn.click(); + await driver.delayMs(200); +} + +export default function abilityTest() { + describe('ActsAbilityTest', () => { + // 打开应用 + it(BUNDLE + 'StartAbility_001', 0, async (done: Function) => { + logger.info(TAG, `${BUNDLE}StartAbility_001 begin`); + let want: Want = { + bundleName: 'com.samples.languagebaseclasslibrary', + abilityName: 'EntryAbility' + }; + delegator.startAbility(want, (err) => { + logger.info(TAG, `${BUNDLE}_startAbility end err ${JSON.stringify(err)}`); + }) + await driver.delayMs(1000); + logger.info(TAG, `${BUNDLE}StartAbility_001 end`); + done(); + }) + + // 进入xml解析、生成与转换页面 + it(BUNDLE + 'Xml_ConvertXml_001', 0, async (done: Function) => { + logger.info(TAG, `${BUNDLE}Xml_ConvertXml_001 begin`); + await driver.delayMs(200); + // find component on text 'Xml' + await driver.assertComponentExist(ON.text(await getResourceString($r('app.string.xml')))); + let button = await driver.findComponent(ON.text(await getResourceString($r('app.string.xml')))); + await button.click(); + await driver.delayMs(200); + // 点击Xml生成 + await driver.assertComponentExist(ON.text(await getResourceString($r('app.string.serializer')), MatchPattern.CONTAINS)); + let serializer = await driver.findComponent(ON.text(await getResourceString($r('app.string.serializer')), MatchPattern.CONTAINS)); + await serializer.click(); + await driver.delayMs(1000); + logger.info(TAG, BUNDLE + 'ClickXmlFunction_001 clickParserXml'); + // 点击Xml解析 + await driver.assertComponentExist(ON.text(await getResourceString($r('app.string.parser')), MatchPattern.CONTAINS)); + let parser = await driver.findComponent(ON.text(await getResourceString($r('app.string.parser')), MatchPattern.CONTAINS)); + await parser.click(); + await driver.delayMs(1000); + logger.info(TAG, BUNDLE + 'ClickXmlFunction_001 clickConvertXml'); + // 点击Xml转换 + let convert = await driver.findComponent(ON.text(await getResourceString($r('app.string.convert')), MatchPattern.CONTAINS)); + await convert.click(); + await driver.delayMs(1000); + // 校验是否进入对应页面 + await driver.assertComponentExist(ON.text(await getResourceString($r('app.string.xml')))); + await driver.delayMs(200); + await driver.pressBack(); + done(); + logger.info(TAG, `${BUNDLE}Xml_ConvertXml_001 end`); + }) + + // 进入Util界面 + it(BUNDLE + 'util_001', 0, async (done: Function) => { + logger.info(TAG, `${BUNDLE}util_001 begin`); + await driver.delayMs(200); + // check text + await driver.assertComponentExist(ON.text(await getResourceString($r('app.string.util')))); + let button = await driver.findComponent(ON.text(await getResourceString($r('app.string.util')))); + await button.click(); + await driver.delayMs(200); + done(); + logger.info(TAG, `${BUNDLE}util_001 end`); + }) + + // StringCode(字符串编码) + it(BUNDLE + 'StringCodeFunction_001', 0, async (done: Function) => { + logger.info(TAG, `${BUNDLE} StringCodeFunction_001 begin`); + await driver.delayMs(200); + // 进入字符串编解码界面 + await driver.assertComponentExist(ON.text(await getResourceString($r('app.string.string_code')))); + let strBtn = await driver.findComponent(ON.text(await getResourceString($r('app.string.string_code')))); + await strBtn.click(); + await driver.delayMs(200); + // 点击特定格式输出 + await driver.assertComponentExist(ON.id('specFormatOutput')); + let specOutputBtn = await driver.findComponent(ON.id('specFormatOutput')); + await specOutputBtn.click(); + await driver.delayMs(200); + // 点击文本编码器 + await driver.assertComponentExist(ON.id('textEncoder')); + let textEncoderBtn = await driver.findComponent(ON.id('textEncoder')); + await textEncoderBtn.click(); + await driver.delayMs(200); + // 判断读取信息是否正确 + await driver.assertComponentExist(ON.id('read')); + let readInfo = await driver.findComponent(ON.id('read')); + let readValue = await readInfo.getText(); + logger.info(TAG, `${BUNDLE}clickTextEncoderFunction_001 readValue:${readValue}`); + expect(readValue).assertEqual('23'); + // 判断写入信息是否正确 + await driver.assertComponentExist(ON.id('write')); + let writeInfo = await driver.findComponent(ON.id('write')); + let writeValue = await writeInfo.getText(); + logger.info(TAG, `${BUNDLE}clickTextEncoderFunction_001 writeValue:${writeValue}`); + expect(writeValue).assertEqual('39'); + // 点击文本译码器 + await driver.assertComponentExist(ON.id('textDecoder')); + let textDecoderBtn = await driver.findComponent(ON.id('textDecoder')); + await textDecoderBtn.click(); + await driver.delayMs(200); + // 获取译码文本,判断是否是原字符串 + await driver.assertComponentExist(ON.id('decRes')); + let decRes = await driver.findComponent(ON.id('decRes')); + let decodeValue = await decRes.getText(); + expect(decodeValue).assertContain('OpenHarmony 3.0'); + // 返回首页 + await driver.pressBack(); + done(); + logger.info(TAG, `${BUNDLE} StringCodeFunction_001 end`); + }) + + // RationalNumber(有理数) + it(BUNDLE + 'RationalNumber_001', 0, async (done: Function) => { + logger.info(TAG, `${BUNDLE}RationalNumber_001 begin`); + await driver.delayMs(200); + // 进入有理数界面 + await driver.assertComponentExist(ON.text(await getResourceString($r('app.string.rational_number')))); + let button = await driver.findComponent(ON.text(await getResourceString($r('app.string.rational_number')))); + await button.click(); + await driver.delayMs(200); + + await driver.assertComponentExist(ON.text(await getResourceString($r('app.string.compare')))); + let compare = await driver.findComponent(ON.text(await getResourceString($r('app.string.compare')))); + await compare.click(); + await driver.assertComponentExist(ON.text(await getResourceString($r('app.string.less_than')))); + + await driver.assertComponentExist(ON.text(await getResourceString($r('app.string.get')))); + let getValue = await driver.findComponent(ON.text(await getResourceString($r('app.string.get')))); + await getValue.click(); + await driver.assertComponentExist(ON.text(await getResourceString($r('app.string.get_value')), MatchPattern.CONTAINS)); + + await driver.assertComponentExist(ON.text(await getResourceString($r('app.string.getDenominator')))); + let operation0 = await driver.findComponent(ON.text(await getResourceString($r('app.string.getDenominator')))); + await operation0.click(); + await driver.assertComponentExist(ON.text(await getResourceString($r('app.string.numerator')), MatchPattern.CONTAINS)); + + await driver.assertComponentExist(ON.text(await getResourceString($r('app.string.isZero')))); + let operation1 = await driver.findComponent(ON.text(await getResourceString($r('app.string.isZero')))); + await operation1.click(); + await driver.assertComponentExist(ON.text(await getResourceString($r('app.string.rational_number_is')), MatchPattern.CONTAINS)); + + await driver.assertComponentExist(ON.text(await getResourceString($r('app.string.isNaN')))); + let operation2 = await driver.findComponent(ON.text(await getResourceString($r('app.string.isNaN')))); + await operation2.click(); + await driver.assertComponentExist(ON.text(await getResourceString($r('app.string.rational_number_is_not_nan')), MatchPattern.CONTAINS)); + + await driver.assertComponentExist(ON.text(await getResourceString($r('app.string.isFinite')))); + let operation3 = await driver.findComponent(ON.text(await getResourceString($r('app.string.isFinite')))); + await operation3.click(); + await driver.assertComponentExist(ON.text('Finite', MatchPattern.CONTAINS)); + + await driver.pressBack(); + done(); + logger.info(TAG, `${BUNDLE}RationalNumber_001 end`); + }) + + // 进入到LRUCache (缓冲区) + it(BUNDLE + 'UtilLruBuffer_001', 0, async (done: Function) => { + logger.info(TAG, `${BUNDLE}UtilLruBuffer_001 begin`); + await driver.delayMs(200); + // find component on text 'LRUCache' + await driver.assertComponentExist(ON.text(await getResourceString($r('app.string.lru_cache')))); + let button = await driver.findComponent(ON.text(await getResourceString($r('app.string.lru_cache')))); + await button.click(); + await driver.delayMs(200); + logger.info(TAG, BUNDLE + 'UtilLruBuffer_001 clickCheckPresetValue'); + // 点击初始化缓冲区 + await driver.assertComponentExist(ON.text(await getResourceString($r('app.string.initialize_buffer')))); + let initializeBtn = await driver.findComponent(ON.text(await getResourceString($r('app.string.initialize_buffer')))); + await initializeBtn.click(); + await driver.delayMs(200); + logger.info(TAG, BUNDLE + 'UtilLruBuffer_001 clickCheckPresetValue'); + // 点击获取缓冲区容量 + await driver.assertComponentExist(ON.text(await getResourceString($r('app.string.get_buffer_capacity')))); + let getBufferBtn = await driver.findComponent(ON.text(await getResourceString($r('app.string.get_buffer_capacity')))); + await getBufferBtn.click(); + await driver.delayMs(200); + logger.info(TAG, BUNDLE + 'UtilLruBuffer_001 clickCheckPresetValue'); + // 点击更新缓冲区容量 + await driver.assertComponentExist(ON.text(await getResourceString($r('app.string.update_buffer_capacity')))); + let updateBufferBtn = await driver.findComponent(ON.text(await getResourceString($r('app.string.update_buffer_capacity')))); + await updateBufferBtn.click(); + await driver.delayMs(200); + logger.info(TAG, BUNDLE + 'UtilLruBuffer_001 clickCheckPresetValue'); + // 点击获取缓冲区字符串 + await driver.assertComponentExist(ON.text(await getResourceString($r('app.string.get_buffer_string')))); + let getBufferCharacterBtn = await driver.findComponent(ON.text(await getResourceString($r('app.string.get_buffer_string')))); + await getBufferCharacterBtn.click(); + await driver.delayMs(200); + logger.info(TAG, BUNDLE + 'UtilLruBuffer_001 clickCheckPresetValue'); + // 点击添加键值对 + await driver.assertComponentExist(ON.text(await getResourceString($r('app.string.add_key_value')))); + let addBtn = await driver.findComponent(ON.text(await getResourceString($r('app.string.add_key_value')))); + await addBtn.click(); + await driver.delayMs(200); + logger.info(TAG, BUNDLE + 'UtilLruBuffer_001 clickCheckPresetValue'); + // 点击获取键对应的值 + await driver.assertComponentExist(ON.text(await getResourceString($r('app.string.get_value_with_key')))); + let getBtn = await driver.findComponent(ON.text(await getResourceString($r('app.string.get_value_with_key')))); + await getBtn.click(); + await driver.delayMs(200); + logger.info(TAG, BUNDLE + 'UtilLruBuffer_001 clickCheckPresetValue'); + // 关闭弹窗 + let getDialogBtn = await driver.findComponent(ON.type('Dialog')); + await getDialogBtn.click(); + await driver.delayMs(200); + logger.info(TAG, BUNDLE + 'UtilLruBuffer_001 clickCheckPresetValue'); + // 点击获取所有键值对 + await driver.assertComponentExist(ON.text(await getResourceString($r('app.string.get_all_key_values')))); + let getAllBtn = await driver.findComponent(ON.text(await getResourceString($r('app.string.get_all_key_values')))); + await getAllBtn.click(); + await driver.delayMs(200); + logger.info(TAG, BUNDLE + 'UtilLruBuffer_001 clickCheckPresetValue'); + // 点击删除指定键及关联值 + await driver.assertComponentExist(ON.text(await getResourceString($r('app.string.delete_key_and_value')))); + let deleteBtn = await driver.findComponent(ON.text(await getResourceString($r('app.string.delete_key_and_value')))); + await deleteBtn.click(); + await driver.delayMs(200); + logger.info(TAG, BUNDLE + 'UtilLruBuffer_001 clickCheckPresetValue'); + // 关闭弹窗 + let deleteDialogBtn = await driver.findComponent(ON.type('Dialog')); + await deleteDialogBtn.click(); + await driver.delayMs(200); + logger.info(TAG, BUNDLE + 'UtilLruBuffer_001 clickCheckPresetValue'); + // 点击清除所有键值对 + await driver.assertComponentExist(ON.text(await getResourceString($r('app.string.clear_all_key_values')))); + let eliminateBtn = await driver.findComponent(ON.text(await getResourceString($r('app.string.clear_all_key_values')))); + await eliminateBtn.click(); + await driver.delayMs(200); + logger.info(TAG, BUNDLE + 'UtilLruBuffer_001 clickCheckPresetValue'); + // 点击查看操作记录 + await driver.assertComponentExist(ON.text(await getResourceString($r('app.string.view_operation_record')))); + let operatingBtn = await driver.findComponent(ON.text(await getResourceString($r('app.string.view_operation_record')))); + await operatingBtn.click(); + await driver.delayMs(200); + await driver.pressBack(); + done(); + logger.info(TAG, `${BUNDLE}UtilLruBuffer_001 end`); + }) + + // Base64Helper (Base64编解码) + it(BUNDLE + 'UtilBase64Codec_001', 0, async (done: Function) => { + logger.info(TAG, `${BUNDLE}UtilBase64Codec_001 begin`); + await driver.delayMs(200); + // 进入Base64编解码 + await driver.assertComponentExist(ON.text(await getResourceString($r('app.string.base64')))); + let typeBtn = await driver.findComponent(ON.text(await getResourceString($r('app.string.base64')))); + await typeBtn.click(); + await driver.delayMs(200); + // 点击编码 + await driver.assertComponentExist(ON.text(await getResourceString($r('app.string.encode')))); + let codeBtn = await driver.findComponent(ON.text(await getResourceString($r('app.string.encode')))); + await codeBtn.click(); + await driver.delayMs(200); + logger.info(TAG, BUNDLE + 'UtilBase64Codec_001 clickCheckPresetValue'); + // 点击解码 + await driver.assertComponentExist(ON.text(await getResourceString($r('app.string.decode')))); + let decodeBtn = await driver.findComponent(ON.text(await getResourceString($r('app.string.decode')))); + await decodeBtn.click(); + await driver.delayMs(1000); + await driver.pressBack(); + done(); + logger.info(TAG, `${BUNDLE}UtilBase64Codec_001 begin`); + }) + + // TypeCheck (类型检查) + it(BUNDLE + 'TypeCheck_001', 0, async (done: Function) => { + logger.info(TAG, `${BUNDLE}TypeCheck_001 begin`); + await driver.delayMs(200); + // 进入类型检查 + await driver.assertComponentExist(ON.text(await getResourceString($r('app.string.type_check')))); + let typeBtn = await driver.findComponent(ON.text(await getResourceString($r('app.string.type_check')))); + await typeBtn.click(); + await driver.delayMs(1000); + // 点击显示预置值 + await driver.assertComponentExist(ON.id('displayPresetValue')); + let displayPresetValueBtn = await driver.findComponent(ON.id('displayPresetValue')); + await displayPresetValueBtn.click(); + await driver.delayMs(200); + logger.info(TAG, BUNDLE + 'TypeCheck_001 clickCheckPresetValue'); + // 点击校验预置值 + await driver.assertComponentExist(ON.id('checkPresetValue')); + let checkPresetValueBtn = await driver.findComponent(ON.id('checkPresetValue')); + await checkPresetValueBtn.click(); + await driver.delayMs(200); + await driver.pressBack(); + await driver.pressBack(); + await driver.delayMs(1000); + done(); + + logger.info(TAG, `${BUNDLE}TypeCheck_001 begin`) + }) + + // 进入Url字符串解析页面 + it(BUNDLE + 'Url_001', 0, async (done: Function) => { + logger.info(TAG, `${BUNDLE}Url_001 begin`); + await driver.delayMs(500); + // find component on text 'Xml' + await driver.assertComponentExist(ON.text('Url (Url字符串解析)')); + let button = await driver.findComponent(ON.text('Url (Url字符串解析)')); + await button.click(); + await driver.delayMs(1000); + // check text + await driver.assertComponentExist(ON.text('Url (Url字符串解析)')); + await driver.delayMs(1000); + done() + logger.info(TAG, `${BUNDLE}Url_001 end`); + }) + + // Url字符串解析 + it(BUNDLE + 'ClickUrlStringBtnFunction_001', 0, async (done: Function) => { + logger.info(TAG, BUNDLE + 'ClickUrlStringBtnFunction_001 begin') + await driver.delayMs(1000) + // 点击插入键值对到查询字符串 + await driver.assertComponentExist(ON.id('item0')) + let insertKeyValuePairs = await driver.findComponent(ON.id('item0')) + await insertKeyValuePairs.click() + await driver.delayMs(500) + // 是否成功插入 + await driver.assertComponentExist(ON.id('output')) + let outputInsert = await driver.findComponent(ON.id('output')) + let insertValue = await outputInsert.getText() + await driver.delayMs(1000); + expect(insertValue).assertContain('node=nodeValue1') + // 点击删除键值对 + await driver.assertComponentExist(ON.id('item1')) + let deleteKeyValuePairs = await driver.findComponent(ON.id('item1')) + await deleteKeyValuePairs.click() + await driver.delayMs(500) + // 是否成功删除 + await driver.assertComponentExist(ON.id('output')) + let outputDelete = await driver.findComponent(ON.id('output')) + let deleteValue = await outputDelete.getText() + await driver.delayMs(1000); + expect(deleteValue).assertEqual('https://gitee.com/openharmony/'); + // 点击获取指定名称对应的第一个值 + await driver.assertComponentExist(ON.id('item0')) + let insertKeyValue = await driver.findComponent(ON.id('item0')) + await insertKeyValue.click() + await driver.delayMs(500) + await driver.assertComponentExist(ON.id('item2')) + let getFirstValue = await driver.findComponent(ON.id('item2')) + await getFirstValue.click() + await driver.delayMs(500) + // 是否成功获取 + await driver.assertComponentExist(ON.id('output')) + let outputGet = await driver.findComponent(ON.id('output')) + let getValue = await outputGet.getText() + await driver.delayMs(1000); + expect(getValue).assertContain('nodeValue1') + // 点击设置键的新值 + await driver.assertComponentExist(ON.id('item3')) + let setNewValue = await driver.findComponent(ON.id('item3')) + await setNewValue.click() + await driver.delayMs(500) + // 是否成功设置新值 + await driver.assertComponentExist(ON.id('output')) + let outputSet = await driver.findComponent(ON.id('output')) + let setValue = await outputSet.getText() + await driver.delayMs(1000); + expect(setValue).assertContain('newValue') + // 返回首页 + await driver.pressBack(); + done(); + logger.info(TAG, BUNDLE + 'ClickUrlStringBtnFunction_001 end') + }) + + // 进入TaskPool页面 + it(BUNDLE + 'TaskPool_001', 0, async (done: Function) => { + logger.info(TAG, `${BUNDLE}TaskPool_001 begin`); + await driver.delayMs(200); + // 滚动到TaskPool + await driver.assertComponentExist(ON.id('menu_list')); + let menuList = await driver.findComponent(ON.id('menu_list')); + // find component on text 'TaskPool' + let button = await menuList.scrollSearch(ON.text(await getResourceString($r('app.string.task_pool')))); + await button.click(); + await driver.delayMs(200); + // 点击Execute task + await driver.assertComponentExist(ON.id('execute_task')); + let executeTask = await driver.findComponent(ON.id('execute_task')); + await executeTask.click(); + await driver.delayMs(1000); + logger.info(TAG, BUNDLE + 'ClickTaskPoolFunction_001 clickExecuteTask'); + // 点击Cancel task + await driver.assertComponentExist(ON.id('cancel_task')); + let parser = await driver.findComponent(ON.id('cancel_task')); + await parser.click(); + await driver.delayMs(1000); + logger.info(TAG, BUNDLE + 'ClickTaskPoolFunction_001 clickCancelTask'); + await driver.pressBack(); + done(); + logger.info(TAG, `${BUNDLE}TaskPool_001 end`); + }) + + // 进入Deque界面 + it(BUNDLE + 'deque_001', 0, async (done: Function) => { + logger.info(TAG, `${BUNDLE}deque_001 begin`); + await driver.delayMs(200); + // 滚动到Deque + await driver.assertComponentExist(ON.id('menu_list')); + let menuList = await driver.findComponent(ON.id('menu_list')); + //find component on text 'Deque' + let button = await menuList.scrollSearch(ON.text(await getResourceString($r('app.string.deque')))); + await button.click(); + await driver.delayMs(200); + //check text + await driver.assertComponentExist(ON.text(await getResourceString($r('app.string.deque')))); + await driver.delayMs(200); + done(); + logger.info(TAG, `${BUNDLE}deque_001 end`); + }) + + // 新增数据 + it(BUNDLE + 'DequeAddFunction_001', 0, async (done: Function) => { + logger.info(TAG, `${BUNDLE} DequeAddFunction_001 begin`); + await driver.delayMs(200); + // 添加三条数据 + await addContact(driver, '1', '1'); + await addContact(driver, '2', '2'); + await addContact(driver, '3', '3'); + // 删除三条数据 + await deleteItem(driver, 'delete2'); + await deleteItem(driver, 'delete0'); + await deleteItem(driver, 'delete0'); + // 返回上一页 + await driver.pressBack(); + done(); + logger.info(TAG, `${BUNDLE} DequeAddFunction_001 end`); + }) + + // 进入HashMap界面 + it(BUNDLE + 'hash_map_001', 0, async (done: Function) => { + logger.info(TAG, `${BUNDLE}hash_map_001 begin`); + await driver.delayMs(200); + // 滚动到HashMap + await driver.assertComponentExist(ON.id('menu_list')); + let menuList = await driver.findComponent(ON.id('menu_list')); + //find component on text 'HashMap' + let button = await menuList.scrollSearch(ON.text(await getResourceString($r('app.string.hash_map')))); + await button.click(); + await driver.delayMs(200); + //check text + await driver.assertComponentExist(ON.text(await getResourceString($r('app.string.hash_map')))); + await driver.delayMs(200); + done(); + logger.info(TAG, `${BUNDLE}hash_map_001 end`); + }) + + // 新增数据 + it(BUNDLE + 'HashMapAddFunction_001', 0, async (done: Function) => { + logger.info(TAG, `${BUNDLE} HashMapAddFunction_001 begin`); + await driver.delayMs(200); + // 添加三条数据 + await addKeyValue(driver, '1', '1'); + await addKeyValue(driver, '2', '2'); + await addKeyValue(driver, '3', '3'); + // 删除三条数据 + await deleteItem(driver, 'delete0'); + await deleteItem(driver, 'delete0'); + await deleteItem(driver, 'delete0'); + // 返回上一页 + await driver.pressBack(); + done(); + logger.info(TAG, `${BUNDLE} HashMapAddFunction_001 end`); + }) + + // 进入HashSet界面 + it(BUNDLE + 'hash_set_001', 0, async (done: Function) => { + logger.info(TAG, `${BUNDLE}hash_set_001 begin`); + await driver.delayMs(200); + // 滚动到HashSet + await driver.assertComponentExist(ON.id('menu_list')); + let menuList = await driver.findComponent(ON.id('menu_list')); + //find component on text 'HashSet' + let button = await menuList.scrollSearch(ON.text(await getResourceString($r('app.string.hash_set')))); + await button.click(); + await driver.delayMs(200); + //check text + await driver.assertComponentExist(ON.text(await getResourceString($r('app.string.hash_set')))); + await driver.delayMs(200); + done(); + logger.info(TAG, `${BUNDLE}hash_set_001 end`); + }) + + // 新增数据 + it(BUNDLE + 'HashSetAddFunction_001', 0, async (done: Function) => { + logger.info(TAG, `${BUNDLE} HashSetAddFunction_001 begin`); + await driver.delayMs(200); + // 添加三条数据 + await addValue(driver, '1'); + await addValue(driver, '2'); + await addValue(driver, '3'); + // 删除三条数据 + await deleteItem(driver, 'delete0'); + await deleteItem(driver, 'delete0'); + await deleteItem(driver, 'delete0'); + // 返回上一页 + await driver.pressBack(); + done(); + logger.info(TAG, `${BUNDLE} HashSetAddFunction_001 end`); + }) + + // 进入LightWeightMap界面 + it(BUNDLE + 'light_weight_map_001', 0, async (done: Function) => { + logger.info(TAG, `${BUNDLE}light_weight_map_001 begin`); + await driver.delayMs(200); + // 滚动到LightWeightMap + await driver.assertComponentExist(ON.id('menu_list')); + let menuList = await driver.findComponent(ON.id('menu_list')); + //find component on text 'LightWeightMap' + let button = await menuList.scrollSearch(ON.text(await getResourceString($r('app.string.light_weight_map')))); + await button.click(); + await driver.delayMs(200); + //check text + await driver.assertComponentExist(ON.text(await getResourceString($r('app.string.light_weight_map')))); + await driver.delayMs(200); + done(); + logger.info(TAG, `${BUNDLE}light_weight_map_001 end`); + }) + + // 新增数据 + it(BUNDLE + 'LightWeightMapAddFunction_001', 0, async (done: Function) => { + logger.info(TAG, `${BUNDLE} LightWeightMapAddFunction_001 begin`); + await driver.delayMs(200); + // 添加三条数据 + await addKeyValue(driver, '1', '1'); + await addKeyValue(driver, '2', '2'); + await addKeyValue(driver, '3', '3'); + // 删除三条数据 + await deleteItem(driver, 'delete0'); + await deleteItem(driver, 'delete0'); + await deleteItem(driver, 'delete0'); + // 返回上一页 + await driver.pressBack(); + done(); + logger.info(TAG, `${BUNDLE} LightWeightMapAddFunction_001 end`); + }) + + // 进入LightWeightSet界面 + it(BUNDLE + 'light_weight_set_001', 0, async (done: Function) => { + logger.info(TAG, `${BUNDLE}light_weight_set_001 begin`); + await driver.delayMs(200); + // 滚动到LightWeightSet + await driver.assertComponentExist(ON.id('menu_list')); + let menuList = await driver.findComponent(ON.id('menu_list')); + //find component on text 'LightWeightSet' + let button = await menuList.scrollSearch(ON.text(await getResourceString($r('app.string.light_weight_set')))); + await button.click(); + await driver.delayMs(200); + //check text + await driver.assertComponentExist(ON.text(await getResourceString($r('app.string.light_weight_set')))); + await driver.delayMs(200); + done(); + logger.info(TAG, `${BUNDLE}light_weight_set_001 end`); + }) + + // 新增数据 + it(BUNDLE + 'LightWeightSetAddFunction_001', 0, async (done: Function) => { + logger.info(TAG, `${BUNDLE} LightWeightSetAddFunction_001 begin`); + await driver.delayMs(200); + // 添加三条数据 + await addValue(driver, '1'); + await addValue(driver, '2'); + await addValue(driver, '3'); + // 删除三条数据 + await deleteItem(driver, 'delete0'); + await deleteItem(driver, 'delete0'); + await deleteItem(driver, 'delete0'); + // 返回上一页 + await driver.pressBack(); + done(); + logger.info(TAG, `${BUNDLE} LightWeightSetAddFunction_001 end`); + }) + + // 进入LinkedList界面 + it(BUNDLE + 'linked_list_001', 0, async (done: Function) => { + logger.info(TAG, `${BUNDLE}linked_list_001 begin`); + await driver.delayMs(200); + // 滚动到LinkedList + await driver.assertComponentExist(ON.id('menu_list')); + let menuList = await driver.findComponent(ON.id('menu_list')); + //find component on text 'LinkedList' + let button = await menuList.scrollSearch(ON.text(await getResourceString($r('app.string.linked_list')))); + await button.click(); + await driver.delayMs(200); + //check text + await driver.assertComponentExist(ON.text(await getResourceString($r('app.string.linked_list')))); + await driver.delayMs(200); + done(); + logger.info(TAG, `${BUNDLE}linked_list_001 end`); + }) + + // 新增数据 + it(BUNDLE + 'LinkedListAddFunction_001', 0, async (done: Function) => { + logger.info(TAG, `${BUNDLE} LinkedListAddFunction_001 begin`); + await driver.delayMs(200); + // 添加三条数据 + await addContact(driver, '1', '1'); + await addContact(driver, '2', '2'); + await addContact(driver, '3', '3'); + // 删除三条数据 + await deleteItem(driver, 'delete2'); + await deleteItem(driver, 'delete0'); + await deleteItem(driver, 'delete0'); + // 返回上一页 + await driver.pressBack(); + done(); + logger.info(TAG, `${BUNDLE} LinkedListAddFunction_001 end`); + }) + + // 进入List页面 + it(BUNDLE + 'list_001', 0, async (done: Function) => { + logger.info(TAG, `${BUNDLE} list_001 begin`); + await driver.delayMs(200); + //find component on text 'list' + let scrollBar = await driver.findComponent(ON.id('menu_list')); + let button = await scrollBar.scrollSearch(ON.text(await getResourceString($r('app.string.list')))); + await button.click() + await driver.delayMs(200); + // list添加数据 + await addContact(driver, '1', '1'); + await addContact(driver, '2', '2'); + await addContact(driver, '3', '3'); + // list删除数据 + await deleteItem(driver, 'delete2') + await deleteItem(driver, 'delete1') + await deleteItem(driver, 'delete0') + await driver.pressBack(); + await driver.delayMs(3000); + done(); + logger.info(TAG, `${BUNDLE} list_001 end`); + }) + + // 进入plain_array页面 + it(BUNDLE + 'plain_array_001', 0, async (done: Function) => { + logger.info(TAG, `${BUNDLE} plain_array_001 begin`); + await driver.delayMs(200); + //find component on text 'plain_array' + let scrollBar = await driver.findComponent(ON.id('menu_list')); + let button = await scrollBar.scrollSearch(ON.text(await getResourceString($r('app.string.plain_array')))); + await button.click() + await driver.delayMs(200); + // PlainArray添加数据 + await addKeyValue(driver, '1', '1'); + await addKeyValue(driver, '2', '2'); + await addKeyValue(driver, '3', '3'); + // PlainArray删除数据 + await deleteItem(driver, 'delete2') + await deleteItem(driver, 'delete1') + await deleteItem(driver, 'delete0') + await driver.pressBack(); + await driver.delayMs(3000); + done(); + logger.info(TAG, `${BUNDLE} plain_array_001 end`); + }) + + // 进入queue页面 + it(BUNDLE + 'queue_001', 0, async (done: Function) => { + logger.info(TAG, `${BUNDLE} queue_001 begin`); + await driver.delayMs(200); + //find component on text 'queue' + let scrollBar = await driver.findComponent(ON.id('menu_list')); + let button = await scrollBar.scrollSearch(ON.text(await getResourceString($r('app.string.queue')))); + await button.click() + await driver.delayMs(200); + // queue添加数据 + await addContact(driver, '1', '1'); + await addContact(driver, '2', '2'); + await addContact(driver, '3', '3'); + // queue删除数据 + await deleteItem(driver, 'delete0') + await deleteItem(driver, 'delete0') + await deleteItem(driver, 'delete0') + await driver.pressBack(); + await driver.delayMs(3000); + done(); + logger.info(TAG, `${BUNDLE} queue_001 end`); + }) + + // 进入stack页面 + it(BUNDLE + 'stack_001', 0, async (done: Function) => { + logger.info(TAG, `${BUNDLE} stack_001 begin`); + await driver.delayMs(200); + // find component on text 'stack' + let scrollBar = await driver.findComponent(ON.id('menu_list')); + let button = await scrollBar.scrollSearch(ON.text(await getResourceString($r('app.string.stack')))); + await button.click() + await driver.delayMs(200); + // stack添加数据 + await addContact(driver, '1', '1'); + await addContact(driver, '2', '2'); + await addContact(driver, '3', '3'); + // stack删除数据 + await deleteItem(driver, 'delete2') + await deleteItem(driver, 'delete1') + await deleteItem(driver, 'delete0') + await driver.pressBack(); + await driver.delayMs(3000); + done(); + logger.info(TAG, `${BUNDLE} stack_001 end`); + }) + + // 进入tree_map页面 + it(BUNDLE + 'tree_map_001', 0, async (done: Function) => { + logger.info(TAG, `${BUNDLE} tree_map_001 begin`); + await driver.delayMs(200); + //find component on text 'tree_map' + let scrollBar = await driver.findComponent(ON.id('menu_list')); + let button = await scrollBar.scrollSearch(ON.text(await getResourceString($r('app.string.tree_map')))); + await button.click() + await driver.delayMs(200); + // tree_map添加数据 + await addKeyValue(driver, '1', '1'); + await addKeyValue(driver, '2', '2'); + await addKeyValue(driver, '3', '3'); + // tree_map删除数据 + await deleteItem(driver, 'delete2') + await deleteItem(driver, 'delete1') + await deleteItem(driver, 'delete0') + await driver.pressBack(); + await driver.delayMs(3000); + done(); + logger.info(TAG, `${BUNDLE} tree_map_001 end`); + }) + + // 进入tree_set页面 + it(BUNDLE + 'tree_set_001', 0, async (done: Function) => { + logger.info(TAG, `${BUNDLE} tree_set_001 begin`); + await driver.delayMs(200); + //find component on text 'tree_set' + let scrollBar = await driver.findComponent(ON.id('menu_list')); + let button = await scrollBar.scrollSearch(ON.text(await getResourceString($r('app.string.tree_set')))); + await button.click() + await driver.delayMs(200); + // tree_set添加数据 + await addValue(driver, '1'); + await addValue(driver, '2'); + await addValue(driver, '3'); + // tree_set删除数据 + await deleteItem(driver, 'delete2') + await deleteItem(driver, 'delete1') + await deleteItem(driver, 'delete0') + await driver.pressBack(); + await driver.delayMs(3000); + done(); + logger.info(TAG, `${BUNDLE} tree_set_001 end`); + }) + + // 进入vector页面 + it(BUNDLE + 'vector_001', 0, async (done: Function) => { + logger.info(TAG, `${BUNDLE} vector_001 begin`); + await driver.delayMs(200); + //find component on text 'vector' + let scrollBar = await driver.findComponent(ON.id('menu_list')); + let button = await scrollBar.scrollSearch(ON.text(await getResourceString($r('app.string.vector')))); + await button.click() + await driver.delayMs(200); + // vector添加数据 + await addContact(driver, '1', '1'); + await addContact(driver, '2', '2'); + await addContact(driver, '3', '3'); + // vector删除数据 + await deleteItem(driver, 'delete2') + await deleteItem(driver, 'delete1') + await deleteItem(driver, 'delete0') + await driver.pressBack(); + await driver.delayMs(3000); + done(); + logger.info(TAG, `${BUNDLE} vector_001 end`); + }) + }) +} \ No newline at end of file diff --git a/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/entry/src/ohosTest/ets/test/List.test.ets b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/entry/src/ohosTest/ets/test/List.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..657d194164f932396390ddb56c59cbd65c7d1259 --- /dev/null +++ b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/entry/src/ohosTest/ets/test/List.test.ets @@ -0,0 +1,20 @@ +/* + * Copyright (c) 2023 Huawei Device 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 abilityTest from './Ability.test'; + +export default function testsuite() { + abilityTest(); +} \ No newline at end of file diff --git a/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/entry/src/ohosTest/ets/testability/TestAbility.ets b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/entry/src/ohosTest/ets/testability/TestAbility.ets new file mode 100644 index 0000000000000000000000000000000000000000..b2d6c3a3989b163a884e5e5359adc028c70aa799 --- /dev/null +++ b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/entry/src/ohosTest/ets/testability/TestAbility.ets @@ -0,0 +1,64 @@ +/* + * Copyright (c) 2023 Huawei Device 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 AbilityDelegatorRegistry from '@ohos.app.ability.abilityDelegatorRegistry'; +import testsuite from '../test/List.test'; +import UIAbility from '@ohos.app.ability.UIAbility'; +import window from '@ohos.window'; +import { Hypium } from '@ohos/hypium'; +import { logger } from '../util/Logger'; +import Want from '@ohos.app.ability.Want'; +import AbilityConstant from '@ohos.app.ability.AbilityConstant'; + +const TAG: string = 'TestAbility'; + +export default class TestAbility extends UIAbility { + onCreate(want: Want, launchParam: AbilityConstant.LaunchParam) { + logger.info(TAG, `TestAbility onCreate`); + setTimeout(() => { + let abilityDelegator: AbilityDelegatorRegistry.AbilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator(); + let abilityDelegatorArguments: AbilityDelegatorRegistry.AbilityDelegatorArgs = AbilityDelegatorRegistry.getArguments(); + logger.info(TAG, 'start run testcase!!!'); + Hypium.hypiumTest(abilityDelegator, abilityDelegatorArguments, testsuite); + }, 1500); + } + + onDestroy() { + logger.info(TAG, 'TestAbility onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage) { + logger.info(TAG, 'TestAbility onWindowStageCreate'); + windowStage.loadContent('testability/pages/Index', (err, data) => { + if (err.code) { + logger.error(TAG, `Failed to load the content. Cause: ${JSON.stringify(err)}`); + return; + } + logger.info(TAG, `Succeeded in loading the content. Data: ${JSON.stringify(data) ?? ''}`); + }); + } + + onWindowStageDestroy() { + logger.info(TAG, 'TestAbility onWindowStageDestroy'); + } + + onForeground() { + logger.info(TAG, 'TestAbility onForeground'); + } + + onBackground() { + logger.info(TAG, 'TestAbility onBackground'); + } +} \ No newline at end of file diff --git a/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/entry/src/ohosTest/ets/testability/pages/Index.ets b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/entry/src/ohosTest/ets/testability/pages/Index.ets new file mode 100644 index 0000000000000000000000000000000000000000..b3180f1c7fbebf168a9f0377142c95f0dbf533ec --- /dev/null +++ b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/entry/src/ohosTest/ets/testability/pages/Index.ets @@ -0,0 +1,54 @@ +/* + * Copyright (c) 2023 Huawei Device 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 { logger } from '../../util/Logger'; + +const TAG: string = 'TestIndex'; + +@Entry +@Component +struct Index { + @State message: string = 'Hello World'; + + aboutToAppear() { + logger.info(TAG, 'TestAbility index aboutToAppear'); + } + + build() { + Row() { + Column() { + Text(this.message) + .fontSize(50) + .fontWeight(FontWeight.Bold) + Button() { + Text('next page') + .fontSize(20) + .fontWeight(FontWeight.Bold) + } + .type(ButtonType.Capsule) + .margin({ + top: 20 + }) + .backgroundColor('#0D9FFB') + .width('35%') + .height('5%') + .onClick(() => { + }) + } + .width('100%') + } + .height('100%') + } +} \ No newline at end of file diff --git a/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/entry/src/ohosTest/ets/util/Logger.ts b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/entry/src/ohosTest/ets/util/Logger.ts new file mode 100644 index 0000000000000000000000000000000000000000..ebea3407a1a8a5b9547d2f2d6d9ae045c49508b0 --- /dev/null +++ b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/entry/src/ohosTest/ets/util/Logger.ts @@ -0,0 +1,40 @@ +/* + * Copyright (c) 2023 Huawei Device 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 hilog from '@ohos.hilog'; + +const DOMAIN: number = 0xF811; +const PREFIX = 'Sample_LanguageBaseClassLibraryTest'; +const FORMAT = '%{public}s, %{public}s'; + +class Logger { + debug(...args: string[]): void { + hilog.debug(DOMAIN, PREFIX, FORMAT, args); + } + + info(...args: string[]): void { + hilog.info(DOMAIN, PREFIX, FORMAT, args); + } + + warn(...args: string[]): void { + hilog.warn(DOMAIN, PREFIX, FORMAT, args); + } + + error(...args: string[]): void { + hilog.error(DOMAIN, PREFIX, FORMAT, args); + } +} + +export const logger = new Logger(); \ No newline at end of file diff --git a/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/entry/src/ohosTest/module.json5 b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/entry/src/ohosTest/module.json5 new file mode 100644 index 0000000000000000000000000000000000000000..22e2c611f379dbb0fddf452b259ef27c508d058b --- /dev/null +++ b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/entry/src/ohosTest/module.json5 @@ -0,0 +1,52 @@ +/* + * Copyright (c) 2023 Huawei Device 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. + */ + +{ + "module": { + "name": "entry_test", + "type": "feature", + "description": "$string:module_test_desc", + "mainElement": "TestAbility", + "deviceTypes": [ + "default", + "tablet" + ], + "deliveryWithInstall": true, + "installationFree": false, + "pages": "$profile:test_pages", + "abilities": [ + { + "name": "TestAbility", + "srcEntrance": "./ets/testability/TestAbility.ets", + "description": "$string:TestAbility_desc", + "icon": "$media:icon", + "label": "$string:TestAbility_label", + "visible": true, + "startWindowIcon": "$media:icon", + "startWindowBackground": "$color:start_window_background", + "skills": [ + { + "actions": [ + "action.system.home" + ], + "entities": [ + "entity.system.home" + ] + } + ] + } + ] + } +} diff --git a/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/entry/src/ohosTest/resources/base/element/color.json b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/entry/src/ohosTest/resources/base/element/color.json new file mode 100644 index 0000000000000000000000000000000000000000..3c712962da3c2751c2b9ddb53559afcbd2b54a02 --- /dev/null +++ b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/entry/src/ohosTest/resources/base/element/color.json @@ -0,0 +1,8 @@ +{ + "color": [ + { + "name": "start_window_background", + "value": "#FFFFFF" + } + ] +} \ No newline at end of file diff --git a/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/entry/src/ohosTest/resources/base/element/string.json b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/entry/src/ohosTest/resources/base/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..505f35cb2d498c309bebaf441d6ee385c4a02e0e --- /dev/null +++ b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/entry/src/ohosTest/resources/base/element/string.json @@ -0,0 +1,224 @@ +{ + "string": [ + { + "name": "module_test_desc", + "value": "test ability description" + }, + { + "name": "TestAbility_desc", + "value": "the test ability" + }, + { + "name": "TestAbility_label", + "value": "test label" + }, + { + "name": "xml", + "value": "Xml & ConvertXml (XML Parsing,Generation and convert)" + }, + { + "name": "serializer", + "value": "Xml Serializer" + }, + { + "name": "parser", + "value": "Xml Pull Parser" + }, + { + "name": "convert", + "value": "Xml Convert" + }, + { + "name": "url", + "value": "Url (URL String Parsing)" + }, + { + "name": "util", + "value": "Util (util)" + }, + { + "name": "process", + "value": "Process (Obtaining Process Information)" + }, + { + "name": "array_list", + "value": "ArrayList (Linear Container ArrayList)" + }, + { + "name": "string_code", + "value": "StringCode (String encoding and decoding)" + }, + { + "name": "rational_number", + "value": "RationalNumber (RationalNumber)" + }, + { + "name": "rationalNumber", + "value": "Rational number:" + }, + { + "name": "numerator", + "value": "Numerator:" + }, + { + "name": "denominator", + "value": "Denominator:" + }, + { + "name": "compare", + "value": "Compare rational numbers" + }, + { + "name": "less_than", + "value": "FirstRationalNumber id less than SecondRationalNumber" + }, + { + "name": "get", + "value": "Get rational number value" + }, + { + "name": "get_value", + "value": "Get Value" + }, + { + "name": "getDenominator", + "value": "Get numerator and denominator" + }, + { + "name": "isZero", + "value": "Check for zero" + }, + { + "name": "rational_number_is", + "value": "Rational Number1 is" + }, + { + "name": "isNaN", + "value": "Check for NaN" + }, + { + "name": "rational_number_is_not_nan", + "value": "Rational Number1 is not NaN" + }, + { + "name": "isFinite", + "value": "Check for finite number" + }, + { + "name": "lru_cache", + "value": "LRUCache (Lru cache)" + }, + { + "name": "initialize_buffer", + "value": "Initialize buffer" + }, + { + "name": "get_buffer_capacity", + "value": "Get buffer capacity" + }, + { + "name": "update_buffer_capacity", + "value": "Update buffer capacity" + }, + { + "name": "get_buffer_string", + "value": "Get buffer string" + }, + { + "name": "add_key_value", + "value": "Add key value pair" + }, + { + "name": "get_value_with_key", + "value": "Get value with key" + }, + { + "name": "get_all_key_values", + "value": "Get all key-values" + }, + { + "name": "delete_key_and_value", + "value": "Delete the value of key" + }, + { + "name": "clear_all_key_values", + "value": "Clear all key-values" + }, + { + "name": "view_operation_record", + "value": "View operation record" + }, + { + "name": "base64", + "value": "Base64Helper (Base64 codec)" + }, + { + "name": "encode", + "value": "Encode" + }, + { + "name": "decode", + "value": "Decode" + }, + { + "name": "type_check", + "value": "TypeCheck (Type check)" + }, + { + "name": "task_pool", + "value": "TaskPool (Using the Task Pool)" + }, + { + "name": "deque", + "value": "Deque (Linear Container Deque)" + }, + { + "name": "hash_map", + "value": "HashMap (NoLinear Container HashMap)" + }, + { + "name": "hash_set", + "value": "HashSet (NoLinear Container HashSet)" + }, + { + "name": "light_weight_map", + "value": "LightWeightMap (NoLinear Container LightWeightMap)" + }, + { + "name": "light_weight_set", + "value": "LightWeightSet (NoLinear Container LightWeightSet)" + }, + { + "name": "linked_list", + "value": "LinkedList (Linear Container LinkedList)" + }, + { + "name": "list", + "value": "List (Linear Container List)" + }, + { + "name": "plain_array", + "value": "PlainArray (NoLinear Container PlainArray)" + }, + { + "name": "queue", + "value": "Queue (Linear Container Queue)" + }, + { + "name": "stack", + "value": "Stack (Linear Container Stack)" + }, + { + "name": "tree_map", + "value": "TreeMap (NoLinear Container TreeMap)" + }, + { + "name": "tree_set", + "value": "TreeSet (NoLinear Container TreeSet)" + }, + { + "name": "vector", + "value": "Vector (Linear Container Vector)" + } + ] +} diff --git a/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/entry/src/ohosTest/resources/base/media/icon.png b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/entry/src/ohosTest/resources/base/media/icon.png new file mode 100644 index 0000000000000000000000000000000000000000..ce307a8827bd75456441ceb57d530e4c8d45d36c Binary files /dev/null and b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/entry/src/ohosTest/resources/base/media/icon.png differ diff --git a/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/entry/src/ohosTest/resources/base/profile/test_pages.json b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/entry/src/ohosTest/resources/base/profile/test_pages.json new file mode 100644 index 0000000000000000000000000000000000000000..b7e7343cacb32ce982a45e76daad86e435e054fe --- /dev/null +++ b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/entry/src/ohosTest/resources/base/profile/test_pages.json @@ -0,0 +1,5 @@ +{ + "src": [ + "testability/pages/Index" + ] +} diff --git a/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/entry/src/ohosTest/resources/en_US/element/strarray.json b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/entry/src/ohosTest/resources/en_US/element/strarray.json new file mode 100644 index 0000000000000000000000000000000000000000..b515cca9adb61eb95b3b8098717e5e7116a5e9b8 --- /dev/null +++ b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/entry/src/ohosTest/resources/en_US/element/strarray.json @@ -0,0 +1,72 @@ +{ + "strarray": [ + { + "name": "language_base_class_library_list", + "value": [ + { + "value": "Buffer (Buffer)" + }, + { + "value": "Xml & ConvertXml (XML Parsing,Generation and convert)" + }, + { + "value": "Process (Obtaining Process Information)" + }, + { + "value": "TaskPool (Using the Task Pool)" + }, + { + "value": "Uri (URI String Parsing)" + }, + { + "value": "Url (URL String Parsing)" + }, + { + "value": "Util (util)" + }, + { + "value": "ArrayList (Linear Container ArrayList)" + }, + { + "value": "Deque (Linear Container ArrayList)" + }, + { + "value": "HashMap (Nonlinear Container HashMap)" + }, + { + "value": "HashSet (Nonlinear Container HashSet)" + }, + { + "value": "LightWeightMap (Nonlinear Container LightWeightMap)" + }, + { + "value": "LightWeightSet (Nonlinear Container LightWeightMap)" + }, + { + "value": "LinkedList (Nonlinear Container LightWeightMap)" + }, + { + "value": "List (Nonlinear Container LightWeightMap)" + }, + { + "value": "PlainArray (Nonlinear Container PlainArray)" + }, + { + "value": "Queue (Linear Container Queue)" + }, + { + "value": "Stack (Linear Container Stack)" + }, + { + "value": "TreeMap (Nonlinear Container TreeMap)" + }, + { + "value": "TreeSet (Nonlinear Container TreeSet)" + }, + { + "value": "Vector (Linear Container Vector)" + } + ] + } + ] +} \ No newline at end of file diff --git a/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/entry/src/ohosTest/resources/en_US/element/string.json b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/entry/src/ohosTest/resources/en_US/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..d560e5088dc356e2bdb10c533f0f116c18c2115a --- /dev/null +++ b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/entry/src/ohosTest/resources/en_US/element/string.json @@ -0,0 +1,224 @@ +{ + "string": [ + { + "name": "module_test_desc", + "value": "test ability description" + }, + { + "name": "TestAbility_desc", + "value": "the test ability" + }, + { + "name": "TestAbility_label", + "value": "test label" + }, + { + "name": "xml", + "value": "Xml & ConvertXml (XML Parsing,Generation and convert)" + }, + { + "name": "serializer", + "value": "Xml Serializer" + }, + { + "name": "parser", + "value": "Xml Pull Parser" + }, + { + "name": "convert", + "value": "Xml Convert" + }, + { + "name": "url", + "value": "Url (URL String Parsing)" + }, + { + "name": "util", + "value": "Util (util)" + }, + { + "name": "process", + "value": "Process (Obtaining Process Information)" + }, + { + "name": "array_list", + "value": "ArrayList (Linear Container ArrayList)" + }, + { + "name": "string_code", + "value": "StringCode (String encoding and decoding)" + }, + { + "name": "rational_number", + "value": "RationalNumber (RationalNumber)" + }, + { + "name": "rationalNumber", + "value": "Rational number:" + }, + { + "name": "numerator", + "value": "Numerator:" + }, + { + "name": "denominator", + "value": "Denominator:" + }, + { + "name": "compare", + "value": "Compare rational numbers" + }, + { + "name": "less_than", + "value": "FirstRationalNumber id less than SecondRationalNumber" + }, + { + "name": "get", + "value": "Get rational number value" + }, + { + "name": "get_value", + "value": "Get Value" + }, + { + "name": "getDenominator", + "value": "Get numerator and denominator" + }, + { + "name": "isZero", + "value": "Check for zero" + }, + { + "name": "rational_number_is", + "value": "Rational Number1 is" + }, + { + "name": "isNaN", + "value": "Check for NaN" + }, + { + "name": "rational_number_is_not_nan", + "value": "Rational Number1 is not NaN" + }, + { + "name": "isFinite", + "value": "Check for finite number" + }, + { + "name": "lru_cache", + "value": "LRUCache (Lru cache)" + }, + { + "name": "initialize_buffer", + "value": "Initialize buffer" + }, + { + "name": "get_buffer_capacity", + "value": "Get buffer capacity" + }, + { + "name": "update_buffer_capacity", + "value": "Update buffer capacity" + }, + { + "name": "get_buffer_string", + "value": "Get buffer string" + }, + { + "name": "add_key_value", + "value": "Add key value pair" + }, + { + "name": "get_value_with_key", + "value": "Get value with key" + }, + { + "name": "get_all_key_values", + "value": "Get all key-values" + }, + { + "name": "delete_key_and_value", + "value": "Delete the value of key" + }, + { + "name": "clear_all_key_values", + "value": "Clear all key-values" + }, + { + "name": "view_operation_record", + "value": "View operation record" + }, + { + "name": "base64", + "value": "Base64Helper (Base64 codec)" + }, + { + "name": "encode", + "value": "Encode" + }, + { + "name": "decode", + "value": "Decode" + }, + { + "name": "type_check", + "value": "TypeCheck (Type check)" + }, + { + "name": "task_pool", + "value": "TaskPool (Using the Task Pool)" + }, + { + "name": "deque", + "value": "Deque (Linear Container Deque)" + }, + { + "name": "hash_map", + "value": "HashMap (NoLinear Container HashMap)" + }, + { + "name": "hash_set", + "value": "HashSet (NoLinear Container HashSet)" + }, + { + "name": "light_weight_map", + "value": "LightWeightMap (NoLinear Container LightWeightMap)" + }, + { + "name": "light_weight_set", + "value": "LightWeightSet (NoLinear Container LightWeightSet)" + }, + { + "name": "linked_list", + "value": "LinkedList (Linear Container LinkedList)" + }, + { + "name": "list", + "value": "List (Linear Container List)" + }, + { + "name": "plain_array", + "value": "PlainArray (NoLinear Container PlainArray)" + }, + { + "name": "queue", + "value": "Queue (Linear Container Queue)" + }, + { + "name": "stack", + "value": "Stack (Linear Container Stack)" + }, + { + "name": "tree_map", + "value": "TreeMap (NoLinear Container TreeMap)" + }, + { + "name": "tree_set", + "value": "TreeSet (NoLinear Container TreeSet)" + }, + { + "name": "vector", + "value": "Vector (Linear Container Vector)" + } + ] +} \ No newline at end of file diff --git a/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/entry/src/ohosTest/resources/zh_CN/element/strarray.json b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/entry/src/ohosTest/resources/zh_CN/element/strarray.json new file mode 100644 index 0000000000000000000000000000000000000000..6e1f68df953292d6a02bf3742d4d5668f183e590 --- /dev/null +++ b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/entry/src/ohosTest/resources/zh_CN/element/strarray.json @@ -0,0 +1,72 @@ +{ + "strarray": [ + { + "name": "language_base_class_library_list", + "value": [ + { + "value": "Buffer (Buffer)" + }, + { + "value": "Xml & ConvertXml (XML解析,生成与转换)" + }, + { + "value": "Process (获取进程相关的信息)" + }, + { + "value": "TaskPool (启动任务池)" + }, + { + "value": "Uri (URI字符串解析)" + }, + { + "value": "Url (Url字符串解析)" + }, + { + "value": "Util (util工具函数)" + }, + { + "value": "ArrayList (线性容器ArrayList)" + }, + { + "value": "Deque (线性容器Deque)" + }, + { + "value": "HashMap (线性容器Deque)" + }, + { + "value": "HashSet (非线性容器HashSet)" + }, + { + "value": "LightWeightMap (非线性容器HashSet)" + }, + { + "value": "LightWeightSet (非线性容器HashSet)" + }, + { + "value": "LinkedList (非线性容器HashSet)" + }, + { + "value": "List (线性容器List)" + }, + { + "value": "PlainArray (非线性容器PlainArray)" + }, + { + "value": "Queue (线性容器Queue)" + }, + { + "value": "Stack (线性容器Stack)" + }, + { + "value": "TreeMap (非线性容器TreeMap)" + }, + { + "value": "TreeSet (非线性容器TreeSet)" + }, + { + "value": "Vector (线性容器Vector)" + } + ] + } + ] +} \ No newline at end of file diff --git a/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/entry/src/ohosTest/resources/zh_CN/element/string.json b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/entry/src/ohosTest/resources/zh_CN/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..d5cea4c843449de0808755d02148116a3f4df02b --- /dev/null +++ b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/entry/src/ohosTest/resources/zh_CN/element/string.json @@ -0,0 +1,223 @@ +{ + "string": [ + { + "name": "module_test_desc", + "value": "test ability description" + }, + { + "name": "TestAbility_desc", + "value": "the test ability" + }, + { + "name": "TestAbility_label", + "value": "test label" + }, + { + "name": "xml", + "value": "Xml & ConvertXml (XML解析,生成与转换)" + }, + { + "name": "serializer", + "value": "Xml 生成" + }, + { + "name": "parser", + "value": "Xml 解析" + }, + { + "name": "convert", + "value": "Xml 转换" + }, + { + "name": "url", + "value": "Url (Url字符串解析)" + }, + { + "name": "util", + "value": "Util (util工具函数)" + }, + { + "name": "process", + "value": "Process (获取进程相关的信息)" + }, + { + "name": "array_list", + "value": "ArrayList (线性容器ArrayList)" + }, + { + "name": "string_code", + "value": "StringCode (字符串编解码)" + }, + { + "name": "rational_number", + "value": "RationalNumber (有理数)" + }, + { + "name": "rationalNumber", + "value": "有理数:" + }, + { + "name": "numerator", + "value": "分子:" + }, + { + "name": "denominator", + "value": "分母:" + }, + { + "name": "compare", + "value": "有理数比较" + }, + { + "name": "less_than", + "value": "有理数1小于有理数2" + }, + { + "name": "get", + "value": "获取有理数的值" + }, + { + "name": "get_value", + "value": "的值是" + }, + { + "name": "getDenominator", + "value": "获取有理数分子分母" + }, + { + "name": "isZero", + "value": "检查是否为0" + }, + { + "name": "rational_number_is", + "value": "有理数1 is" + }, + { + "name": "isNaN", + "value": "检查是否表示NaN" + }, + { + "name": "rational_number_is_not_nan", + "value": "有理数1 is not NaN" + }, + { + "name": "isFinite", + "value": "检查是否为有限值" + }, + { + "name": "lru_cache", + "value": "LRUCache (缓冲区)" + }, { + "name": "initialize_buffer", + "value": "初始化缓冲区" + }, + { + "name": "get_buffer_capacity", + "value": "获取缓冲区容量" + }, + { + "name": "update_buffer_capacity", + "value": "更新缓冲区容量" + }, + { + "name": "get_buffer_string", + "value": "获取缓冲区字符串" + }, + { + "name": "add_key_value", + "value": "添加键值对" + }, + { + "name": "get_value_with_key", + "value": "获取键对应的值" + }, + { + "name": "get_all_key_values", + "value": "获取所有键值对" + }, + { + "name": "delete_key_and_value", + "value": "删除指定键及关联值" + }, + { + "name": "clear_all_key_values", + "value": "清除所有键值对" + }, + { + "name": "view_operation_record", + "value": "查看操作记录" + }, + { + "name": "base64", + "value": "Base64Helper (Base64编解码)" + }, + { + "name": "encode", + "value": "编码" + }, + { + "name": "decode", + "value": "解码" + }, + { + "name": "type_check", + "value": "TypeCheck (类型检查)" + }, + { + "name": "task_pool", + "value": "TaskPool (启动任务池)" + }, + { + "name": "deque", + "value": "Deque (线性容器Deque)" + }, + { + "name": "hash_map", + "value": "HashMap (非线性容器HashMap)" + }, + { + "name": "hash_set", + "value": "HashSet (非线性容器HashSet)" + }, + { + "name": "light_weight_map", + "value": "LightWeightMap (非线性容器LightWeightMap)" + }, + { + "name": "light_weight_set", + "value": "LightWeightSet (非线性容器LightWeightSet)" + }, + { + "name": "linked_list", + "value": "LinkedList (线性容器LinkedList)" + }, + { + "name": "list", + "value": "List (线性容器List)" + }, + { + "name": "plain_array", + "value": "PlainArray (非线性容器PlainArray)" + }, + { + "name": "queue", + "value": "Queue (线性容器Queue)" + }, + { + "name": "stack", + "value": "Stack (线性容器Stack)" + }, + { + "name": "tree_map", + "value": "TreeMap (非线性容器TreeMap)" + }, + { + "name": "tree_set", + "value": "TreeSet (非线性容器TreeSet)" + }, + { + "name": "vector", + "value": "Vector (线性容器Vector)" + } + ] +} \ No newline at end of file diff --git a/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/capabilities/.gitignore b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/capabilities/.gitignore new file mode 100644 index 0000000000000000000000000000000000000000..5a6ba80fa3d9498a23ae8ae7d9518f8743fa8a96 --- /dev/null +++ b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/capabilities/.gitignore @@ -0,0 +1,4 @@ +/node_modules +/.preview +/build +/.cxx \ No newline at end of file diff --git a/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/capabilities/build-profile.json5 b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/capabilities/build-profile.json5 new file mode 100644 index 0000000000000000000000000000000000000000..12fe2d844bdb69584fd05ebaa3e1cb197a25c3f1 --- /dev/null +++ b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/capabilities/build-profile.json5 @@ -0,0 +1,25 @@ +/* + * Copyright (c) 2023 Huawei Device 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. + */ + +{ + "apiType": "stageMode", + "buildOption": { + }, + "targets": [ + { + "name": "default" + } + ] +} diff --git a/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/capabilities/hvigorfile.ts b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/capabilities/hvigorfile.ts new file mode 100644 index 0000000000000000000000000000000000000000..6522df25794b80abde0b0aa8654f3970c4a35cfa --- /dev/null +++ b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/capabilities/hvigorfile.ts @@ -0,0 +1,16 @@ +/** + * Copyright (c) 2023 Huawei Device 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. + */ +// Script for compiling build behavior. It is built in the build plug-in and cannot be modified currently. +export { harTasks } from '@ohos/hvigor-ohos-plugin'; \ No newline at end of file diff --git a/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/capabilities/index.ets b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/capabilities/index.ets new file mode 100644 index 0000000000000000000000000000000000000000..31eb8377d10574cbe72798997e653fefee8fbc49 --- /dev/null +++ b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/capabilities/index.ets @@ -0,0 +1,58 @@ +/* + * Copyright (c) 2023 Huawei Device 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. + */ + +export { ArrayListView } from './src/main/ets/capabilities/ArrayListView'; + +export { ConvertXml } from './src/main/ets/capabilities/ConvertXml'; + +export { ProcessMessage } from './src/main/ets/capabilities/ProcessMessage'; + +export { Url } from './src/main/ets/capabilities/Url'; + +export { Util } from './src/main/ets/capabilities/Util'; + +export { TaskPool } from './src/main/ets/capabilities/TaskPool'; + +export { DequeView } from './src/main/ets/capabilities/DequeView'; + +export { HashMapView } from './src/main/ets/capabilities/HashMapView'; + +export { HashSetView } from './src/main/ets/capabilities/HashSetView'; + +export { LightWeightMapView } from './src/main/ets/capabilities/LightWeightMapView'; + +export { LightWeightSetView } from './src/main/ets/capabilities/LightWeightSetView'; + +export { LinkedListView } from './src/main/ets/capabilities/LinkedListView'; + +export { ListView } from './src/main/ets/capabilities/ListView'; + +export { PlainArrayView } from './src/main/ets/capabilities/PlainArrayView'; + +export { QueueView } from './src/main/ets/capabilities/QueueView'; + +export { StackView } from './src/main/ets/capabilities/StackView'; + +export { TreeMapView } from './src/main/ets/capabilities/TreeMapView'; + +export { TreeSetView } from './src/main/ets/capabilities/TreeSetView'; + +export { VectorView } from './src/main/ets/capabilities/VectorView'; + +export { KeyValuePair } from './src/main/ets/model/KeyValuePair'; + +export { Information } from './src/main/ets/model/Information'; + +export { Constant as Constant } from './src/main/ets/Constant'; diff --git a/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/capabilities/oh-package.json5 b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/capabilities/oh-package.json5 new file mode 100644 index 0000000000000000000000000000000000000000..9fc812a73e677983097f75112620bb697d3f8015 --- /dev/null +++ b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/capabilities/oh-package.json5 @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2023 Huawei Device 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. + */ + +{ + "license": "ISC", + "types": "", + "devDependencies": {}, + "name": "capabilities", + "description": "a npm package which contains arkUI2.0 page", + "main": "index.ets", + "version": "1.0.0", + "dependencies": { + "@ohos/menuitems": "file:../menuitems", + "@ohos/common": "file:../../common" + } +} diff --git a/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/Constant.ts b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/Constant.ts new file mode 100644 index 0000000000000000000000000000000000000000..b98aae7d47f6194edd70d972da27c3ad97992f50 --- /dev/null +++ b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/Constant.ts @@ -0,0 +1,31 @@ +/* +* 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. +*/ + +export class Constant { + public static readonly EMITTER_ID_DEFAULT = 0x10000; + public static readonly EMITTER_ID_DEQUE = 0x10001; + public static readonly EMITTER_ID_HASH_MAP = 0x10002; + public static readonly EMITTER_ID_HASH_SET = 0x10003; + public static readonly EMITTER_ID_LIGHT_WEIGHT_MAP = 0x10004; + public static readonly EMITTER_ID_LIGHT_WEIGHT_SET = 0x10005; + public static readonly EMITTER_ID_LINKED_LIST = 0x10006; + public static readonly EMITTER_ID_LIST = 0x10007; + public static readonly EMITTER_ID_PLAIN_ARRAY = 0x10008; + public static readonly EMITTER_ID_QUEUE = 0x10009; + public static readonly EMITTER_ID_STACK = 0x10010; + public static readonly EMITTER_ID_TREE_MAP = 0x10011; + public static readonly EMITTER_ID_TREE_SET = 0x10012; + public static readonly EMITTER_ID_VECTOR = 0x10013; +} \ No newline at end of file diff --git a/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/capabilities/ArrayListView.ets b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/capabilities/ArrayListView.ets new file mode 100644 index 0000000000000000000000000000000000000000..9999f152441c4ce45e13993922f61f747b5597f3 --- /dev/null +++ b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/capabilities/ArrayListView.ets @@ -0,0 +1,81 @@ +/* + * Copyright (c) 2023 Huawei Device 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 ArrayList from '@ohos.util.ArrayList'; +import { AddDialog } from '../components/arraylistcomponents/AddDialog'; +import { ArrayListItem } from '../components/arraylistcomponents/ArrayListItem'; +import { Information } from '../model/Information'; +import { logger } from '@ohos/common/src/main/ets/util/Logger'; + +const TAG: string = 'ArrayListView'; + +@Preview +@Component +export struct ArrayListView { + @State dataSource: Information[] = []; + private informations: ArrayList = new ArrayList(); + private dialogController: CustomDialogController = new CustomDialogController({ + builder: AddDialog({ + saveData: (writeInformation: Information) => { + this.informations.add(writeInformation); + this.dataSource = this.informations.convertToArray(); + logger.info(TAG, `this.list= ${this.dataSource.length}`); + } + }), + autoCancel: true, + alignment: DialogAlignment.Default + }); + + build() { + Column() { + Row() { + Blank() + Button() { + Image($r('app.media.ic_add')) + .height(35) + .width('100%') + .objectFit(ImageFit.Contain) + .align(Alignment.End) + } + .key('addBtn') + .width(35) + .type(ButtonType.Normal) + .backgroundColor($r("app.color.button_bg")) + .align(Alignment.End) + .onClick(() => { + this.dialogController.open(); + logger.info(TAG, `enter the AddDialog`); + }) + } + .width('100%') + + List({ space: 12 }) { + ForEach(this.dataSource, (item: Information, index: number) => { + ListItem() { + ArrayListItem({ information: item, index: index, handleOnClick: this.handleOnClick }) + } + }, (item: Information, index: number) => JSON.stringify(item) + index) + } + .margin({ top: 10 }) + } + .width('100%') + .height('100%') + } + + handleOnClick = (index: number) => { + this.informations.removeByIndex(index); + this.dataSource = this.informations.convertToArray(); + } +} \ No newline at end of file diff --git a/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/capabilities/ConvertXml.ets b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/capabilities/ConvertXml.ets new file mode 100644 index 0000000000000000000000000000000000000000..55dcf9fb5720204a9b60592cd2f6a8fa50c368a8 --- /dev/null +++ b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/capabilities/ConvertXml.ets @@ -0,0 +1,64 @@ +/* + * Copyright (c) 2023 Huawei Device 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 { ColumnOperation } from '../components/ColumnOperation'; +import { serializerNode, parserNode, convertNode } from '../util/ConvertXmlUtil'; + +@Component +export struct ConvertXml { + @State output: string = `eTSXmlTextConvert`; + @State input: string = + ` + + Happy + Work + Play + `; + + build() { + Scroll() { + Column() { + Text(this.output) + .width('90%') + .height('60%') + .fontSize(15) + .padding(10) + .margin({ left: 10, right: 10, top: 20, bottom: 10 }) + .border({ width: 2, radius: 5, color: Color.Gray }) + ColumnOperation({ operationRes: $r('app.strarray.convert_xml_operations'), doOperation: this.doOperation }) + } + .width('100%') + .padding(16) + } + .scrollBar(BarState.Off) + .align(Alignment.Start) + } + + doOperation = (index: number) => { + switch (index) { + case 0: + this.output = serializerNode(); + break; + case 1: + this.output = parserNode(this.input); + break; + case 2: + this.output = convertNode(this.input); + break; + default: + break; + } + } +} \ No newline at end of file diff --git a/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/capabilities/DequeView.ets b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/capabilities/DequeView.ets new file mode 100644 index 0000000000000000000000000000000000000000..e78ff50b8895c2bb2ce2f267d33cb7057f1e8090 --- /dev/null +++ b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/capabilities/DequeView.ets @@ -0,0 +1,78 @@ +/* +* 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 emitter from "@ohos.events.emitter"; +import { EmptyPage } from '@ohos/common/src/main/ets/components/EmptyPage'; +import { logger } from '@ohos/common/src/main/ets/util/Logger'; +import { Information } from '../model/Information' +import { InformationItemView } from '../components/InformationItemView'; +import { DequeDataSource } from '../components/dequecomponents/DequeDataSource'; +import { Constant } from "../Constant"; + +const TAG = 'DequeView'; + +@Component +export struct DequeView { + @State totalCount: number = 0; + private dataSource: DequeDataSource = new DequeDataSource(); + + aboutToAppear() { + emitter.on({ eventId: Constant.EMITTER_ID_DEQUE }, (eventData) => { + let item = eventData.data as Information; + this.dataSource.insertFront(item); + this.totalCount = this.dataSource.totalCount(); + }); + } + + aboutToDisappear() { + emitter.off(Constant.EMITTER_ID_DEQUE); + } + + build() { + Column() { + if (this.totalCount != 0) { + List() { + LazyForEach(this.dataSource, (item: Information, index: number) => { + ListItem() { + InformationItemView({ + index: index, + information: item, + deleteAction: () => { + logger.info(TAG, `deleteAction: ${JSON.stringify(item)}`); + if (index === 0) { + this.dataSource.deleteFront(); + this.totalCount = this.dataSource.totalCount(); + } else if (index === this.totalCount - 1) { + this.dataSource.deleteEnd(); + this.totalCount = this.dataSource.totalCount(); + } + } + }) + } + .height(72) + .width('100%') + .margin({ bottom: 20 }) + }, (item: Information, index: number) => JSON.stringify(item) + index) + } + .width('100%') + .height('100%') + .padding({ top: 8, left: 12, right: 12 }) + } else { + EmptyPage() + } + } + .backgroundColor($r('sys.color.ohos_id_color_sub_background')) + } +} \ No newline at end of file diff --git a/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/capabilities/HashMapView.ets b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/capabilities/HashMapView.ets new file mode 100644 index 0000000000000000000000000000000000000000..e0a3290fcd7dede5921ee5075ac3db95467f84df --- /dev/null +++ b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/capabilities/HashMapView.ets @@ -0,0 +1,76 @@ +/* +* 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 HashMap from '@ohos.util.HashMap'; +import emitter from '@ohos.events.emitter'; +import { EmptyPage } from '@ohos/common/src/main/ets/components/EmptyPage'; +import { logger } from '@ohos/common/src/main/ets/util/Logger'; +import { KeyValueItemView } from '../components/KeyValueItemView'; +import { KeyValuePair } from '../model/KeyValuePair'; +import { HashMapDataSource } from '../components/hashmapcomponents/HashMapDataSource'; +import { Constant } from '../Constant'; + +const TAG = 'HashMapView'; + +@Component +export struct HashMapView { + @State totalCount: number = 0; + private hashMap: HashMap = new HashMap(); + private dataSource: HashMapDataSource = new HashMapDataSource(); + + aboutToAppear() { + emitter.on({ eventId: Constant.EMITTER_ID_HASH_MAP }, (eventData) => { + let item: KeyValuePair = eventData.data as KeyValuePair; + this.dataSource.addData(item); + this.totalCount = this.dataSource.totalCount(); + this.hashMap.set(item.key, item.value); + }); + } + + aboutToDisappear() { + emitter.off(Constant.EMITTER_ID_HASH_MAP); + } + + build() { + Column() { + if (this.totalCount != 0) { + List({ space: 12 }) { + LazyForEach(this.dataSource, (item: KeyValuePair, index: number) => { + ListItem() { + KeyValueItemView({ + index: index, + keyValuePair: item, + deleteAction: () => { + logger.info(TAG, `item = ${JSON.stringify(item)}`) + this.dataSource.deleteData(item, index); + this.totalCount = this.dataSource.totalCount(); + this.hashMap.remove(item.key); + } + }) + } + .height(72) + .width('100%') + }, (item: KeyValuePair, index: number) => JSON.stringify(item) + index) + } + .width('100%') + .height('100%') + .padding({ top: 8, left: 12, right: 12 }) + } else { + EmptyPage() + } + } + .backgroundColor($r('sys.color.ohos_id_color_sub_background')) + } +} \ No newline at end of file diff --git a/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/capabilities/HashSetView.ets b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/capabilities/HashSetView.ets new file mode 100644 index 0000000000000000000000000000000000000000..061e18cc9ad7662afe222d2b3cfd8bee29070956 --- /dev/null +++ b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/capabilities/HashSetView.ets @@ -0,0 +1,78 @@ +/* +* 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 HashSet from '@ohos.util.HashSet'; +import emitter from '@ohos.events.emitter'; +import { EmptyPage } from '@ohos/common/src/main/ets/components/EmptyPage'; +import { logger } from '@ohos/common/src/main/ets/util/Logger'; +import { ValueItemView } from '../components/ValueItemView'; +import { HashSetDataSource } from '../components/hashsetcomponents/HashSetDataSource'; +import { Constant } from '../Constant'; + +const TAG = 'HashSetView' + +@Component +export struct HashSetView { + @State totalCount: number = 0; + private hashSet: HashSet = new HashSet(); + private dataSource: HashSetDataSource = new HashSetDataSource(); + + aboutToAppear() { + emitter.on({ eventId: Constant.EMITTER_ID_HASH_SET }, (eventData: emitter.EventData) => { + if (eventData.data === undefined) { + return; + } + let item: string = eventData.data.value; + this.dataSource.addData(item); + this.totalCount = this.dataSource.totalCount(); + this.hashSet.add(item); + }); + } + + aboutToDisappear() { + emitter.off(Constant.EMITTER_ID_HASH_SET); + } + + build() { + Column() { + if (this.totalCount != 0) { + List({ space: 12 }) { + LazyForEach(this.dataSource, (item: string, index: number) => { + ListItem() { + ValueItemView({ + index: index, + value: item, + deleteAction: () => { + logger.info(TAG, `item = ${JSON.stringify(item)}`) + this.dataSource.deleteData(item, index); + this.totalCount = this.dataSource.totalCount(); + this.hashSet.remove(item); + } + }) + } + .height(72) + .width('100%') + }, (item: string, index: number) => JSON.stringify(item) + index) + } + .width('100%') + .height('100%') + .padding({ top: 8, left: 12, right: 12 }) + } else { + EmptyPage() + } + } + .backgroundColor($r('sys.color.ohos_id_color_sub_background')) + } +} \ No newline at end of file diff --git a/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/capabilities/LightWeightMapView.ets b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/capabilities/LightWeightMapView.ets new file mode 100644 index 0000000000000000000000000000000000000000..0e7b57cf008bc7fa9eebf4e1cb42708f0a11bad5 --- /dev/null +++ b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/capabilities/LightWeightMapView.ets @@ -0,0 +1,76 @@ +/* +* 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 LightWeightMap from '@ohos.util.LightWeightMap'; +import emitter from '@ohos.events.emitter'; +import { EmptyPage } from '@ohos/common/src/main/ets/components/EmptyPage'; +import { logger } from '@ohos/common/src/main/ets/util/Logger'; +import { KeyValueItemView } from '../components/KeyValueItemView'; +import { KeyValuePair } from '../model/KeyValuePair'; +import { LightWeightMapDataSource } from '../components/lightweightmapcomponents/LightWeightMapDataSource'; +import { Constant } from '../Constant'; + +const TAG = 'LightWeightMapView'; + +@Component +export struct LightWeightMapView { + @State totalCount: number = 0; + private lightWeightMap: LightWeightMap = new LightWeightMap(); + private dataSource: LightWeightMapDataSource = new LightWeightMapDataSource(); + + aboutToAppear() { + emitter.on({ eventId: Constant.EMITTER_ID_LIGHT_WEIGHT_MAP }, (eventData) => { + let item: KeyValuePair = eventData.data as KeyValuePair; + this.dataSource.addData(item); + this.totalCount = this.dataSource.totalCount(); + this.lightWeightMap.set(item.key, item.value); + }); + } + + aboutToDisappear() { + emitter.off(Constant.EMITTER_ID_LIGHT_WEIGHT_MAP); + } + + build() { + Column() { + if (this.totalCount != 0) { + List({ space: 12 }) { + LazyForEach(this.dataSource, (item: KeyValuePair, index: number) => { + ListItem() { + KeyValueItemView({ + index: index, + keyValuePair: item, + deleteAction: () => { + logger.info(TAG, `item = ${JSON.stringify(item)}`) + this.dataSource.deleteData(item, index); + this.totalCount = this.dataSource.totalCount(); + this.lightWeightMap.remove(item.key); + } + }) + } + .height(72) + .width('100%') + }, (item: KeyValuePair, index: number) => JSON.stringify(item) + index) + } + .width('100%') + .height('100%') + .padding({ top: 8, left: 12, right: 12 }) + } else { + EmptyPage() + } + } + .backgroundColor($r('sys.color.ohos_id_color_sub_background')) + } +} \ No newline at end of file diff --git a/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/capabilities/LightWeightSetView.ets b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/capabilities/LightWeightSetView.ets new file mode 100644 index 0000000000000000000000000000000000000000..d4116ffc45b895dfbda982e2de457ac3e85e4f6f --- /dev/null +++ b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/capabilities/LightWeightSetView.ets @@ -0,0 +1,78 @@ +/* +* 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 LightWeightSet from '@ohos.util.LightWeightSet'; +import emitter from '@ohos.events.emitter'; +import { EmptyPage } from '@ohos/common/src/main/ets/components/EmptyPage'; +import { logger } from '@ohos/common/src/main/ets/util/Logger'; +import { ValueItemView } from '../components/ValueItemView'; +import { LightWeightSetDataSource } from '../components/lightweightsetcomponents/LightWeightSetDataSource'; +import { Constant } from '../Constant'; + +const TAG = 'LightWeightSetView'; + +@Component +export struct LightWeightSetView { + @State totalCount: number = 0; + @State lightWeightSet: LightWeightSet = new LightWeightSet(); + private dataSource: LightWeightSetDataSource = new LightWeightSetDataSource(); + + aboutToAppear() { + emitter.on({ eventId: Constant.EMITTER_ID_LIGHT_WEIGHT_SET }, (eventData: emitter.EventData) => { + if (eventData.data === undefined) { + return; + } + let item: string = eventData.data.value; + this.dataSource.addData(item); + this.lightWeightSet.add(item); + this.totalCount = this.dataSource.totalCount(); + }); + } + + aboutToDisappear() { + emitter.off(Constant.EMITTER_ID_LIGHT_WEIGHT_SET); + } + + build() { + Column() { + if (this.totalCount != 0) { + List({ space: 12 }) { + LazyForEach(this.dataSource, (item: string, index: number) => { + ListItem() { + ValueItemView({ + index: index, + value: item, + deleteAction: () => { + logger.info(TAG, `item = ${JSON.stringify(item)}`) + this.dataSource.deleteData(item, index); + this.totalCount = this.dataSource.totalCount(); + this.lightWeightSet.remove(item); + } + }) + } + .height(72) + .width('100%') + }, (item: string, index: number) => JSON.stringify(item) + index) + } + .width('100%') + .height('100%') + .padding({ top: 8, left: 12, right: 12 }) + } else { + EmptyPage() + } + } + .backgroundColor($r('sys.color.ohos_id_color_sub_background')) + } +} \ No newline at end of file diff --git a/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/capabilities/LinkedListView.ets b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/capabilities/LinkedListView.ets new file mode 100644 index 0000000000000000000000000000000000000000..cc9135bffb2ee83d7f91bbcedcab7ecf20746e53 --- /dev/null +++ b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/capabilities/LinkedListView.ets @@ -0,0 +1,81 @@ +/* +* 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 emitter from '@ohos.events.emitter'; +import { EmptyPage } from '@ohos/common/src/main/ets/components/EmptyPage'; +import { logger } from '@ohos/common/src/main/ets/util/Logger'; +import { Information } from '../model/Information' +import { InformationItemView } from '../components/InformationItemView'; +import { LinkedListDataSource } from '../components/linkedlistcomponents/LinkedListDataSource' +import { Constant } from '../Constant'; + +const TAG = 'LinkedListView' + +@Component +export struct LinkedListView { + @State totalCount: number = 0; + private dataSource: LinkedListDataSource = new LinkedListDataSource(); + + aboutToAppear() { + emitter.on({ eventId: Constant.EMITTER_ID_LINKED_LIST }, (eventData) => { + let item = eventData.data as Information; + this.dataSource.addData(item); + this.totalCount = this.dataSource.totalCount(); + }); + } + + aboutToDisappear() { + emitter.off(Constant.EMITTER_ID_LINKED_LIST); + } + + build() { + Column() { + if (this.totalCount != 0) { + List() { + LazyForEach(this.dataSource, (item: Information, index: number) => { + ListItem() { + InformationItemView({ + index: index, + information: item, + deleteAction: () => { + logger.info(TAG, `deleteAction: ${JSON.stringify(item)}`); + if (index === 0) { + this.dataSource.deleteFirst(); + this.totalCount = this.dataSource.totalCount(); + } else if (index === this.totalCount - 1) { + this.dataSource.deleteLast(); + this.totalCount = this.dataSource.totalCount(); + } else { + this.dataSource.deleteData(index); + this.totalCount = this.dataSource.totalCount(); + } + } + }) + } + .height(72) + .width('100%') + .margin({ bottom: 20 }) + }, (item: Information, index: number) => JSON.stringify(item) + index) + } + .width('100%') + .height('100%') + .padding({ top: 8, left: 12, right: 12 }) + } else { + EmptyPage() + } + } + .backgroundColor($r('sys.color.ohos_id_color_sub_background')) + } +} \ No newline at end of file diff --git a/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/capabilities/ListView.ets b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/capabilities/ListView.ets new file mode 100644 index 0000000000000000000000000000000000000000..f6485cc220245254309880126e15bfa383d9ecce --- /dev/null +++ b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/capabilities/ListView.ets @@ -0,0 +1,67 @@ +/* +* 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 emitter from '@ohos.events.emitter'; +import { EmptyPage } from '@ohos/common/src/main/ets/components/EmptyPage'; +import { Information } from '../model/Information'; +import { ListDateSource } from '../components/listcomponents/ListDataSource'; +import { InformationItemView } from '../components/InformationItemView'; +import { Constant } from '../Constant'; + +const MIN_LENGTH = 0; + +@Entry +@Component +export struct ListView { + private dataSource: ListDateSource = new ListDateSource(); + @State totalCount: number = MIN_LENGTH; + + aboutToAppear() { + emitter.on({ eventId: Constant.EMITTER_ID_LIST }, (eventData) => { + this.dataSource.addData(eventData.data as Information); + this.totalCount = this.dataSource.totalCount(); + }); + } + + aboutToDisappear() { + emitter.off(Constant.EMITTER_ID_LIST); + } + + build() { + Column() { + if (this.totalCount > MIN_LENGTH) { + List() { + LazyForEach(this.dataSource, (item: Information, index: number) => { + ListItem() { + InformationItemView({ index: index, information: item, deleteAction: () => { + this.dataSource.deleteData(index); + this.totalCount = this.dataSource.totalCount(); + } }) + } + .height(72) + .width('100%') + .margin({ bottom: 20 }) + }, (item: Information, index: number) => JSON.stringify(item) + index) + } + .width('100%') + .layoutWeight(1) + + } else { + EmptyPage() + } + } + .backgroundColor($r('sys.color.ohos_id_color_sub_background')) + } +} \ No newline at end of file diff --git a/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/capabilities/PlainArrayView.ets b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/capabilities/PlainArrayView.ets new file mode 100644 index 0000000000000000000000000000000000000000..08303ae54b4f9a660429bfd2fbd71d02507001e6 --- /dev/null +++ b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/capabilities/PlainArrayView.ets @@ -0,0 +1,76 @@ +/* +* 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 emitter from '@ohos.events.emitter'; +import promptAction from '@ohos.promptAction'; +import { EmptyPage } from '@ohos/common/src/main/ets/components/EmptyPage'; +import { KeyValuePair } from '../model/KeyValuePair'; +import { PlainArrayDataSource } from '../components/plainarraycomponents/PlainArrayDataSource'; +import { KeyValueItemView } from '../components/KeyValueItemView'; +import { Constant } from '../Constant'; + +const MIN_LENGTH = 0; +const isNaturalNumber = (str: string): boolean => { + let regExp: RegExp = new RegExp('^\\d+$'); + return regExp.test(str); +}; + +@Component +export struct PlainArrayView { + private dataSource: PlainArrayDataSource = new PlainArrayDataSource(); + @State totalCount: number = MIN_LENGTH; + + aboutToAppear() { + emitter.on({ eventId: Constant.EMITTER_ID_PLAIN_ARRAY }, (eventData) => { + let data = eventData.data as KeyValuePair; + if (isNaturalNumber(data.key)) { + this.dataSource.addData(eventData.data as KeyValuePair); + this.totalCount = this.dataSource.totalCount(); + } else { + promptAction.showToast({ message: $r('app.string.key_limit') }); + } + }); + } + + aboutToDisappear() { + emitter.off(Constant.EMITTER_ID_PLAIN_ARRAY); + } + + build() { + Column() { + if (this.totalCount > MIN_LENGTH) { + List() { + LazyForEach(this.dataSource, (item: KeyValuePair, index: number) => { + ListItem() { + KeyValueItemView({ index: index, keyValuePair: item, deleteAction: () => { + this.dataSource.deleteData(index); + this.totalCount = this.dataSource.totalCount(); + } }) + } + .height(72) + .width('100%') + .margin({ bottom: 20 }) + }, (item: KeyValuePair, index: number) => JSON.stringify(item) + index) + } + .width('100%') + .layoutWeight(1) + + } else { + EmptyPage() + } + } + .backgroundColor($r('sys.color.ohos_id_color_sub_background')) + } +} \ No newline at end of file diff --git a/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/capabilities/Process.ets b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/capabilities/Process.ets new file mode 100644 index 0000000000000000000000000000000000000000..7ee21aaa14d3e0dd2f5c9c697d18e0f8f3f85b07 --- /dev/null +++ b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/capabilities/Process.ets @@ -0,0 +1,99 @@ +/* + * Copyright (c) 2023 Huawei Device 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 process from '@ohos.process'; +import { ColumnOperation } from '../components/ColumnOperation'; +import { getString } from '@ohos/common/src/main/ets/util/ResourceUtil'; +import { logger } from '@ohos/common/src/main/ets/util/Logger'; + +let child: process.ChildProcess | undefined = undefined; +const TAG: string = 'Process'; + +@Component +export struct Process { + @State result: string = ''; + + build() { + Scroll() { + Column() { + Text(this.result) + .width('100%') + .height(100) + .backgroundColor('#DFDFDF') + .fontSize(20) + .margin({ top: 20 }) + .textAlign(TextAlign.Start) + .padding(10) + ColumnOperation({ operationRes: $r('app.strarray.process_operations'), doOperation: this.doOperation }) + } + .width('100%') + .padding(16) + } + .scrollBar(BarState.Off) + .align(Alignment.Start) + } + + doOperation = (index: number) => { + let proManager = new process.ProcessManager(); + switch (index) { + case 0: + this.result = process.uptime().toString() + 's'; + logger.info(TAG, 'uptime=' + this.result); + break; + case 1: + logger.info(TAG, 'process cwd'); + this.result = process.cwd().toString(); + break; + case 2: + logger.info(TAG, 'process change dir'); + process.chdir('/system'); + this.result = process.cwd().toString(); + break; + case 3: + child = process.runCmd('sleep 2;ls'); + this.result = child == null ? 'failed' : 'succeed'; + logger.info(TAG, 'runCmd=' + this.result); + let childResult = child.wait(); + childResult.then(val => { + this.result = 'child process run finish' + JSON.stringify(val); + logger.info(TAG, 'runCmd result =' + val); + }) + break; + case 4: + if (child != null) { + this.result = getString($r('app.string.close_success')); + child.close(); + } else { + this.result = getString($r('app.string.child_null')); + } + logger.info(TAG, this.result); + break; + case 5: + let pres = process.pid; + let result = proManager.kill(28, pres); + if (result === true) { + this.result = getString($r('app.string.success')); + } else { + this.result = getString($r('app.string.failed')); + } + break; + case 6: + proManager.exit(0); + break; + default: + break; + } + } +} \ No newline at end of file diff --git a/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/capabilities/ProcessMessage.ets b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/capabilities/ProcessMessage.ets new file mode 100644 index 0000000000000000000000000000000000000000..a32d916cf28c1151e06985d71864138890776600 --- /dev/null +++ b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/capabilities/ProcessMessage.ets @@ -0,0 +1,52 @@ +/* + * Copyright (c) 2024 Huawei Device 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 { BusinessError } from '@ohos.base'; +import Want from '@ohos.app.ability.Want'; +import common from '@ohos.app.ability.common'; +import { logger } from '@ohos/common/src/main/ets/util/Logger'; + +@Component +export struct ProcessMessage { + + build() { + Column() { + Button() { + Text($r('app.string.process')) + .fontSize(16) + .fontColor(Color.White) + } + .width('100%') + .height(50) + .type(ButtonType.Capsule) + .onClick(() => { + let context: common.UIAbilityContext | undefined = AppStorage.get('context'); + let want: Want = { + bundleName: "com.samples.process_message", + abilityName: "EntryAbility", + }; + context && context.startAbility(want, (err: BusinessError) => { + if (err.code) { + logger.error('StartAbility', `Failed to startAbility. Code: ${err.code}, message: ${err.message}`); + } + }); + }) + } + .width('100%') + .height('100%') + .justifyContent(FlexAlign.Center) + .alignItems(HorizontalAlign.Center) + } +} \ No newline at end of file diff --git a/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/capabilities/QueueView.ets b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/capabilities/QueueView.ets new file mode 100644 index 0000000000000000000000000000000000000000..3fe07c476b3cdc96be960c8be16ae275c58f79dd --- /dev/null +++ b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/capabilities/QueueView.ets @@ -0,0 +1,66 @@ +/* +* 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 emitter from '@ohos.events.emitter'; +import { EmptyPage } from '@ohos/common/src/main/ets/components/EmptyPage'; +import { Information } from '../model/Information'; +import { QueueDataSource } from '../components/queuecomponents/QueueDataSource'; +import { InformationItemView } from '../components/InformationItemView'; +import { Constant } from '../Constant'; + +const MIN_LENGTH = 0; + +@Component +export struct QueueView { + private dataSource: QueueDataSource = new QueueDataSource(); + @State totalCount: number = MIN_LENGTH; + + aboutToAppear() { + emitter.on({ eventId: Constant.EMITTER_ID_QUEUE }, (eventData) => { + this.dataSource.addData(eventData.data as Information); + this.totalCount = this.dataSource.totalCount(); + }); + } + + aboutToDisappear() { + emitter.off(Constant.EMITTER_ID_QUEUE); + } + + build() { + Column() { + if (this.totalCount > MIN_LENGTH) { + List() { + LazyForEach(this.dataSource, (item: Information, index: number) => { + ListItem() { + InformationItemView({ index: index, information: item, deleteAction: () => { + this.dataSource.deleteData(); + this.totalCount = this.dataSource.totalCount(); + } }) + } + .height(72) + .width('100%') + .margin({ bottom: 20 }) + }, (item: Information, index: number) => JSON.stringify(item) + index) + } + .width('100%') + .layoutWeight(1) + + } else { + EmptyPage() + } + } + .backgroundColor($r('sys.color.ohos_id_color_sub_background')) + } +} \ No newline at end of file diff --git a/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/capabilities/StackView.ets b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/capabilities/StackView.ets new file mode 100644 index 0000000000000000000000000000000000000000..1360f913d85636c402ad9dd88869e4c0014dcfc5 --- /dev/null +++ b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/capabilities/StackView.ets @@ -0,0 +1,70 @@ +/* +* 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 emitter from '@ohos.events.emitter'; +import { EmptyPage } from '@ohos/common/src/main/ets/components/EmptyPage'; +import { Information } from '../model/Information'; +import { StackDataSource } from '../components/stackcomponents/StackDataSource'; +import { InformationItemView } from '../components/InformationItemView'; +import { Constant } from '../Constant'; + +const MIN_LENGTH = 0; + +@Component +export struct StackView { + private dataSource: StackDataSource = new StackDataSource(); + @State totalCount: number = MIN_LENGTH; + + aboutToAppear() { + emitter.on({ eventId: Constant.EMITTER_ID_STACK }, (eventData) => { + this.dataSource.addData(eventData.data as Information); + this.totalCount = this.dataSource.totalCount(); + }); + } + + aboutToDisappear() { + emitter.off(Constant.EMITTER_ID_STACK); + } + + build() { + Column() { + if (this.totalCount > MIN_LENGTH) { + List() { + LazyForEach(this.dataSource, (item: Information, index: number) => { + ListItem() { + InformationItemView({ + index: index, + information: item, + deleteAction: () => { + this.dataSource.deleteData(); + this.totalCount = this.dataSource.totalCount(); + } + }) + } + .height(72) + .width('100%') + .margin({ bottom: 20 }) + }, (item: Information, index: number) => JSON.stringify(item) + index) + } + .width('100%') + .layoutWeight(1) + + } else { + EmptyPage() + } + } + .backgroundColor($r('sys.color.ohos_id_color_sub_background')) + } +} \ No newline at end of file diff --git a/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/capabilities/TaskPool.ets b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/capabilities/TaskPool.ets new file mode 100644 index 0000000000000000000000000000000000000000..a012667e43e23e4b6c032868906de374798e363c --- /dev/null +++ b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/capabilities/TaskPool.ets @@ -0,0 +1,115 @@ +/* +* 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 taskpool from '@ohos.taskpool' +import router from '@ohos.router' + +function functionForTasks(numberOfExecutions: number) { + "use concurrent" + return numberOfExecutions + 1 +} + +@Component +export struct TaskPool { + @State numberOfExecutions: number = 0; + private isExecute = true; + private clickAble = true; + @State task: taskpool.Task | null = null; + @State msg: string = 'task ready'; + + build() { + Column() { + Row() { + Text($r('app.string.click_exec_add_one')) + .margin({ top: 22 }) + } + .width('90%') + + Column() { + Row() { + Text('numberOfExecutions:') + .fontColor($r('sys.color.ohos_id_color_text_primary')) + Text(this.numberOfExecutions.toString()) + .fontColor($r('sys.color.ohos_id_color_text_primary')) + } + .width('100%') + + Row() { + Text('task status:') + .fontColor($r('sys.color.ohos_id_color_text_primary')) + Text(this.msg) + .fontColor($r('sys.color.ohos_id_color_text_primary')) + } + .width('100%') + } + .height(160) + .margin({ top: 12 }) + .padding(16) + .borderRadius(16) + .backgroundColor($r('app.color.bg_white')) + + Blank() + .layoutWeight(1) + + Row({ space: 20 }) { + Button('Execute task') + .id('execute_task') + .type(ButtonType.Capsule) + .width('45%') + .fontColor($r('app.color.text_color_accent')) + .backgroundColor($r('app.color.bg_btn_grey')) + .onClick(async () => { + if (!this.clickAble) { + return; + } + for (let i = 0; i > -1; i++) { + this.task = new taskpool.Task(functionForTasks, i); + if (!this.isExecute) { + this.isExecute = true; + taskpool.cancel(this.task); + } else { + this.clickAble = false; + this.msg = 'task is running'; + await taskpool.execute(this.task) + .then((res: Object) => { + this.numberOfExecutions = Number(JSON.parse(JSON.stringify(res))); + }); + } + } + }) + + Button('Cancel task') + .id('cancel_task') + .type(ButtonType.Capsule) + .width('45%') + .fontColor($r('app.color.text_color_red')) + .backgroundColor($r('app.color.bg_btn_grey')) + .onClick(() => { + if (!this.clickAble) { + this.msg = 'task cancel'; + this.clickAble = true; + this.isExecute = !this.isExecute; + } + }) + } + .width('100%') + .margin({ top: 12, bottom: 16 }) + .justifyContent(FlexAlign.Center) + } + .width('100%') + .height('100%') + .backgroundColor($r('sys.color.ohos_id_color_sub_background')) + } +} \ No newline at end of file diff --git a/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/capabilities/TreeMapView.ets b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/capabilities/TreeMapView.ets new file mode 100644 index 0000000000000000000000000000000000000000..60c819468ff458ad2a1589ded665b98500c04ceb --- /dev/null +++ b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/capabilities/TreeMapView.ets @@ -0,0 +1,66 @@ +/* +* 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 emitter from '@ohos.events.emitter'; +import { EmptyPage } from '@ohos/common/src/main/ets/components/EmptyPage'; +import { KeyValuePair } from '../model/KeyValuePair'; +import { TreeMapDataSource } from '../components/treemapcomponents/TreeMapDataSource'; +import { KeyValueItemView } from '../components/KeyValueItemView'; +import { Constant } from '../Constant'; + +const MIN_LENGTH = 0; + +@Component +export struct TreeMapView { + private dataSource: TreeMapDataSource = new TreeMapDataSource(); + @State totalCount: number = MIN_LENGTH; + + aboutToAppear() { + emitter.on({ eventId: Constant.EMITTER_ID_TREE_MAP }, (eventData) => { + this.dataSource.addData(eventData.data as KeyValuePair); + this.totalCount = this.dataSource.totalCount(); + }); + } + + aboutToDisappear() { + emitter.off(Constant.EMITTER_ID_TREE_MAP); + } + + build() { + Column() { + if (this.totalCount > MIN_LENGTH) { + List() { + LazyForEach(this.dataSource, (item: KeyValuePair, index: number) => { + ListItem() { + KeyValueItemView({ index: index, keyValuePair: item, deleteAction: () => { + this.dataSource.deleteData(item.key); + this.totalCount = this.dataSource.totalCount(); + } }) + } + .height(72) + .width('100%') + .margin({ bottom: 20 }) + }, (item: KeyValuePair, index: number) => JSON.stringify(item) + index) + } + .width('100%') + .layoutWeight(1) + + } else { + EmptyPage() + } + } + .backgroundColor($r('sys.color.ohos_id_color_sub_background')) + } +} \ No newline at end of file diff --git a/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/capabilities/TreeSetView.ets b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/capabilities/TreeSetView.ets new file mode 100644 index 0000000000000000000000000000000000000000..ab739671a042afeb47e0c11d480008a8f10dbb7a --- /dev/null +++ b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/capabilities/TreeSetView.ets @@ -0,0 +1,66 @@ +/* +* 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 emitter from '@ohos.events.emitter'; +import { EmptyPage } from '@ohos/common/src/main/ets/components/EmptyPage'; +import { TreeSetDataSource } from '../components/treesetcomponents/TreeSetDataSource'; +import { ValueItemView } from '../components/ValueItemView'; +import { Constant } from '../Constant'; + +const MIN_LENGTH = 0; + +@Component +export struct TreeSetView { + private dataSource: TreeSetDataSource = new TreeSetDataSource(); + @State totalCount: number = MIN_LENGTH; + + aboutToAppear() { + emitter.on({ eventId: Constant.EMITTER_ID_TREE_SET }, (eventData) => { + this.dataSource.addData((eventData.data as Record)['value'] as string); + this.totalCount = this.dataSource.totalCount(); + }); + } + + aboutToDisappear() { + emitter.off(Constant.EMITTER_ID_TREE_SET); + } + + build() { + Column() { + if (this.totalCount > MIN_LENGTH) { + List() { + LazyForEach(this.dataSource, (item: string, index: number) => { + ListItem() { + ValueItemView({ index: index, value: item, deleteAction: () => { + this.dataSource.deleteData(item, index); + this.totalCount = this.dataSource.totalCount(); + } }) + } + .height(72) + .width('100%') + .margin({ bottom: 20 }) + }, (item: string, index: number) => JSON.stringify(item) + index) + } + .width('100%') + .layoutWeight(1) + + } else { + EmptyPage() + } + } + .backgroundColor($r('sys.color.ohos_id_color_sub_background')) + } +} \ No newline at end of file diff --git a/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/capabilities/Url.ets b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/capabilities/Url.ets new file mode 100644 index 0000000000000000000000000000000000000000..25704027712116871b58c12c579099f0485adc28 --- /dev/null +++ b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/capabilities/Url.ets @@ -0,0 +1,68 @@ +/* + * Copyright (c) 2023 Huawei Device 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 { ColumnOperation } from '../components/ColumnOperation'; +import { changeValue, deleteNode, getFirstNode, insertNode } from '../util/UrlUtil'; + +const URL_NET: string = 'https://gitee.com/openharmony/'; + +@Preview +@Component +export struct Url { + @State output: string = URL_NET; + + build() { + Scroll() { + Column() { + Text(this.output) + .id('output') + .width('95%') + .height('30%') + .fontSize(15) + .padding(10) + .margin({ left: 10, right: 10, top: 10 }) + .border({ width: 2, radius: 5, color: Color.Gray }) + Text(URL_NET) + .fontSize(15) + .margin({ top: 15 }) + .fontWeight(FontWeight.Bold) + ColumnOperation({ operationRes: $r('app.strarray.url_operations'), doOperation: this.doOperation }) + } + .width('100%') + .padding(16) + } + .scrollBar(BarState.Off) + .align(Alignment.Start) + } + + doOperation = (index: number) => { + switch (index) { + case 0: + this.output = insertNode(); + break; + case 1: + this.output = deleteNode(); + break; + case 2: + this.output = getFirstNode(); + break; + case 3: + this.output = changeValue(); + break; + default: + break; + } + } +} \ No newline at end of file diff --git a/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/capabilities/Util.ets b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/capabilities/Util.ets new file mode 100644 index 0000000000000000000000000000000000000000..fd71ca42db6837efd102ac9d89c9e9f9c5817207 --- /dev/null +++ b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/capabilities/Util.ets @@ -0,0 +1,64 @@ +/* + * Copyright (c) 2023 Huawei Device 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 { getString } from '@ohos/common/src/main/ets/util/ResourceUtil'; +import { LRUCache } from '../components/utilcomponents/LRUCache'; +import { Base64Helper } from '../components/utilcomponents/Base64Helper'; +import { MenuList } from '@ohos/menuitems'; +import { RationalNumber } from '../components/utilcomponents/RationalNumber'; +import { ScopeHelper } from '../components/utilcomponents/ScopeHelper'; +import { StringCode } from '../components/utilcomponents/StringCode'; +import { TypeCheck } from '../components/utilcomponents/TypeCheck'; + +@Component +export struct Util { + @StorageLink('selectedSecondLabel') selectedSecondLabel: string = ''; + + @Builder + UtilCapabilities() { + if (this.selectedSecondLabel === getString($r('app.string.lru_cache'))) { + LRUCache() + } + if (this.selectedSecondLabel === getString($r('app.string.base64'))) { + Base64Helper() + } + if (this.selectedSecondLabel === getString($r('app.string.string_code'))) { + StringCode() + } + if (this.selectedSecondLabel === getString($r('app.string.rational_number'))) { + RationalNumber() + } + if (this.selectedSecondLabel === getString($r('app.string.type_check'))) { + TypeCheck() + } + if (this.selectedSecondLabel === getString($r('app.string.scope_helper'))) { + ScopeHelper() + } + } + + build() { + Column() { + MenuList({ menuList: $r('app.strarray.util_menu') }) { + Column() { + Divider() + .strokeWidth('1px') + .color($r('sys.color.ohos_id_color_list_separator')) + this.UtilCapabilities() + } + } + } + .margin({ left: -12, right: -12 }) + } +} \ No newline at end of file diff --git a/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/capabilities/VectorView.ets b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/capabilities/VectorView.ets new file mode 100644 index 0000000000000000000000000000000000000000..b1d4443d35c40e68985311bea1be32d24349ef30 --- /dev/null +++ b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/capabilities/VectorView.ets @@ -0,0 +1,66 @@ +/* +* 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 emitter from '@ohos.events.emitter'; +import { EmptyPage } from '@ohos/common/src/main/ets/components/EmptyPage'; +import { Information } from '../model/Information'; +import { VectorDataSource } from '../components/vectorcomponents/VectorDataSource'; +import { InformationItemView } from '../components/InformationItemView'; +import { Constant } from '../Constant'; + +const MIN_LENGTH = 0; + +@Component +export struct VectorView { + private dataSource: VectorDataSource = new VectorDataSource(); + @State totalCount: number = MIN_LENGTH; + + aboutToAppear() { + emitter.on({ eventId: Constant.EMITTER_ID_VECTOR }, (eventData) => { + this.dataSource.addData(eventData.data as Information); + this.totalCount = this.dataSource.totalCount(); + }); + } + + aboutToDisappear() { + emitter.off(Constant.EMITTER_ID_VECTOR); + } + + build() { + Column() { + if (this.totalCount > MIN_LENGTH) { + List() { + LazyForEach(this.dataSource, (item: Information, index: number) => { + ListItem() { + InformationItemView({ index: index, information: item, deleteAction: () => { + this.dataSource.deleteData(index); + this.totalCount = this.dataSource.totalCount(); + } }) + } + .height(72) + .width('100%') + .margin({ bottom: 20 }) + }, (item: Information, index: number) => JSON.stringify(item) + index) + } + .width('100%') + .layoutWeight(1) + + } else { + EmptyPage() + } + } + .backgroundColor($r('sys.color.ohos_id_color_sub_background')) + } +} \ No newline at end of file diff --git a/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/components/ColumnOperation.ets b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/components/ColumnOperation.ets new file mode 100644 index 0000000000000000000000000000000000000000..5fd6bc7adf4046ee573a73ecf9d4679bc248ea58 --- /dev/null +++ b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/components/ColumnOperation.ets @@ -0,0 +1,57 @@ +/* + * Copyright (c) 2023 Huawei Device 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 { getStringArray } from '@ohos/common/src/main/ets/util/ResourceUtil'; + +@Component +export struct ColumnOperation { + private operationRes: Resource | undefined = undefined; + @State operationSource: string[] = []; + private doOperation: (index: number) => void = () => { + }; + + build() { + Column() { + ForEach(this.operationSource, (item: string, index: number) => { + Row() { + Button() { + Text(item) + .fontSize(16) + .fontColor(Color.White) + } + .id(`item${index}`) + .width('100%') + .height(50) + .type(ButtonType.Capsule) + .margin({ right: 15, top: 15 }) + .onClick(() => { + this.doOperation(index); + }) + } + .width('100%') + .justifyContent(FlexAlign.Center) + }, (index: string) => index) + } + .width('100%') + .padding({ bottom: 15 }) + } + + async aboutToAppear() { + if (this.operationRes) { + let menuList = await getStringArray(this.operationRes); + this.operationSource = menuList; + } + } +} \ No newline at end of file diff --git a/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/components/DeleteView.ets b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/components/DeleteView.ets new file mode 100644 index 0000000000000000000000000000000000000000..51fd28c58cd53920b325a25d3ca3e1b2c27c3384 --- /dev/null +++ b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/components/DeleteView.ets @@ -0,0 +1,34 @@ +/* +* 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. +*/ + +@Component +export struct DeleteView { + private enable: boolean = false; + + build() { + Row() { + Image($r('app.media.ic_delete_plane')) + .width(24) + .aspectRatio(1) + } + .width(40) + .aspectRatio(1) + .borderRadius(20) + .justifyContent(FlexAlign.Center) + .alignItems(VerticalAlign.Center) + .backgroundColor($r('app.color.bg_btn_red')) + .opacity(this.enable ? 1.0 : 0.25) + } +} \ No newline at end of file diff --git a/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/components/GridOperation.ets b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/components/GridOperation.ets new file mode 100644 index 0000000000000000000000000000000000000000..85df4446b846d333bff663b9f41503a0d03a949b --- /dev/null +++ b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/components/GridOperation.ets @@ -0,0 +1,60 @@ +/* + * Copyright (c) 2023 Huawei Device 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 { getStringArray } from '@ohos/common/src/main/ets/util/ResourceUtil'; + +@Component +export struct GridOperation { + private operationRes: Resource | undefined = undefined; + @State operationSource: string[] = []; + private doOperation: (index: number) => void = () => {}; + + build() { + Column() { + GridRow({ columns: 12, gutter: { x: 2, y: 5 }, + direction: GridRowDirection.Row + }) { + ForEach(this.operationSource, (item: string, index: number) => { + GridCol({ span: { xs: 6, sm: 6, md: 4, lg: 4 } }) { + Row() { + Button() { + Text(item) + .fontSize(16) + .fontColor(Color.White) + } + .width(160) + .height(50) + .type(ButtonType.Capsule) + .margin({ right: 10, top: 10 }) + .onClick(() => { + this.doOperation(index); + }) + } + .justifyContent(FlexAlign.Center) + } + }, (index: string) => index) + } + } + .width('100%') + .padding({ bottom: 15 }) + } + + async aboutToAppear() { + if (this.operationRes) { + let menuList = await getStringArray(this.operationRes); + this.operationSource = menuList; + } + } +} \ No newline at end of file diff --git a/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/components/InformationItemView.ets b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/components/InformationItemView.ets new file mode 100644 index 0000000000000000000000000000000000000000..3040517e70b29594924959152465f69917ffb536 --- /dev/null +++ b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/components/InformationItemView.ets @@ -0,0 +1,61 @@ +/* +* 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 { Information } from '../model/Information'; +import { DeleteView } from './DeleteView'; +import { getString } from '@ohos/common/src/main/ets/util/ResourceUtil'; + +@Component +export struct InformationItemView { + @ObjectLink information: Information; + private deleteAction: (event?: ClickEvent) => void = () => { + }; + private index: number = 0; + + build() { + Row() { + Row() { + Column() { + Text(this.information.name) + .fontColor($r('app.color.text_color_primary')) + .fontSize(16) + Text(this.information.phone) + .fontColor($r('app.color.text_color_second')) + .fontSize(14) + .margin({ top: 5 }) + } + + Blank() + Text(`${this.information.age}${getString($r('app.string.old'))}`) + .fontColor($r('app.color.text_color_second')) + .fontSize(12) + } + .height(72) + .layoutWeight(1) + .padding({ left: 16, right: 15 }) + .margin({ right: 12 }) + .backgroundColor($r('app.color.bg_white')) + .borderRadius(16) + + DeleteView({ enable: this.information.clickAble }) + .id(`delete${this.index}`) + .enabled(this.information.clickAble) + .onClick(this.deleteAction) + } + .padding({ left: 12 }) + .width('100%') + .margin({ top: 12, right: 12 }) + } +} \ No newline at end of file diff --git a/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/components/KeyValueItemView.ets b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/components/KeyValueItemView.ets new file mode 100644 index 0000000000000000000000000000000000000000..4f6510570c9e03c87c1b7774a8c55163e414e475 --- /dev/null +++ b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/components/KeyValueItemView.ets @@ -0,0 +1,54 @@ +/* +* 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 { KeyValuePair } from '../model/KeyValuePair'; +import { DeleteView } from './DeleteView'; + +@Component +export struct KeyValueItemView { + @ObjectLink keyValuePair: KeyValuePair; + @State deleteEnabled: boolean = true; + private deleteAction: (event?: ClickEvent) => void = () => { + }; + private index: number = 0; + + build() { + Row() { + Column() { + Text(`Key: ${this.keyValuePair.key}`) + .fontColor($r('app.color.text_color_primary')) + .fontSize(16) + Text(`Value: ${this.keyValuePair.value}`) + .fontColor($r('app.color.text_color_second')) + .fontSize(14) + } + .height('100%') + .layoutWeight(1) + .padding({ left: 16, right: 16, top: 12, bottom: 12 }) + .borderRadius(16) + .backgroundColor($r('app.color.bg_white')) + .alignItems(HorizontalAlign.Start) + + DeleteView({ enable: this.deleteEnabled }) + .id(`delete${this.index}`) + .margin({ left: 12 }) + .enabled(this.deleteEnabled) + .onClick(this.deleteAction) + } + .width('100%') + .height(64) + .alignItems(VerticalAlign.Center) + } +} \ No newline at end of file diff --git a/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/components/ValueItemView.ets b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/components/ValueItemView.ets new file mode 100644 index 0000000000000000000000000000000000000000..89641acd95f06be706c256071314756b4b9564ee --- /dev/null +++ b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/components/ValueItemView.ets @@ -0,0 +1,50 @@ +/* +* 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 { DeleteView } from './DeleteView'; + +@Component +export struct ValueItemView { + @State deleteEnabled: boolean = true; + private value: string = ''; + private deleteAction: (event?: ClickEvent) => void = () => {}; + private index: number = 0; + + build() { + Row() { + Column() { + Text(`Value: ${this.value}`) + .fontColor($r('app.color.text_color_primary')) + .fontSize(16) + } + .height('100%') + .layoutWeight(1) + .padding({ left: 16, right: 16, top: 12, bottom: 12 }) + .borderRadius(16) + .backgroundColor($r('app.color.bg_white')) + .justifyContent(FlexAlign.Center) + .alignItems(HorizontalAlign.Start) + + DeleteView({ enable: this.deleteEnabled }) + .id(`delete${this.index}`) + .margin({ left: 12 }) + .enabled(this.deleteEnabled) + .onClick(this.deleteAction) + } + .width('100%') + .height(64) + .alignItems(VerticalAlign.Center) + } +} \ No newline at end of file diff --git a/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/components/arraylistcomponents/AddDialog.ets b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/components/arraylistcomponents/AddDialog.ets new file mode 100644 index 0000000000000000000000000000000000000000..3537b75c05536c83982517b22aecc3e825058474 --- /dev/null +++ b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/components/arraylistcomponents/AddDialog.ets @@ -0,0 +1,158 @@ +/* + * Copyright (c) 2023 Huawei Device 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 prompt from '@ohos.promptAction'; +import { Information } from '../../model/Information'; +import { logger } from '@ohos/common/src/main/ets/util/Logger'; + +const TAG: string = 'AddDialog'; + +@CustomDialog +export struct AddDialog { + @State writeInformation: Information = new Information('', Number.NaN, '') + private saveData: (information: Information) => void = () => { + }; + private controller?: CustomDialogController; + + build() { + Column() { + Text($r('app.string.contact_information')) + .fontSize(24) + .fontColor(Color.Black) + .fontWeight(FontWeight.Bold) + .margin({ top: 12 }) + Row() { + Text($r('app.string.contact_name')) + .width(65) + .fontSize(20) + .fontColor(Color.Black) + .fontWeight(FontWeight.Medium) + .margin({ left: 10 }) + + TextInput({ placeholder: $r('app.string.input_name'), text: this.writeInformation.name }) + .key('inputPhone') + .layoutWeight(1) + .type(InputType.Normal) + .placeholderColor(Color.Gray) + .fontSize(19) + .maxLength(11) + .margin({ right: 10 }) + .onChange((value: string) => { + this.writeInformation.name = value; + logger.info(TAG, ` this.writeInformation.name = ${value}`); + }) + } + .margin({ top: 12 }) + + Row() { + Text($r('app.string.contact_age')) + .width(65) + .fontSize(20) + .fontColor(Color.Black) + .fontWeight(FontWeight.Medium) + .margin({ left: 10 }) + + TextInput({ placeholder: $r('app.string.input_age') }) + .key('inputPhone') + .layoutWeight(1) + .type(InputType.Number) + .placeholderColor(Color.Gray) + .fontSize(19) + .maxLength(11) + .margin({ right: 10 }) + .onChange((value: string) => { + this.writeInformation.age = Number(value); + }) + } + .margin({ top: 12 }) + + Row() { + Text($r('app.string.contact_phone')) + .width(65) + .fontSize(20) + .fontColor(Color.Black) + .fontWeight(FontWeight.Medium) + .margin({ left: 10 }) + + TextInput({ placeholder: $r('app.string.input_phone'), text: this.writeInformation.phone }) + .key('inputPhone') + .layoutWeight(1) + .type(InputType.Number) + .placeholderColor(Color.Gray) + .fontSize(19) + .maxLength(11) + .margin({ right: 10 }) + .onChange((value: string) => { + this.writeInformation.phone = value; + }) + } + .margin({ top: 12 }) + + Row() { + Button() { + Text($r("app.string.button_confirm")) + .key('confirm') + .fontColor(Color.Blue) + .fontSize(17) + } + .layoutWeight(7) + .backgroundColor(Color.White) + .margin(5) + .onClick(() => { + this.addInformation(); + }) + + Divider() + .height(30) + .vertical(true) + .strokeWidth(2) + .color('#999999') + + Button() { + Text($r('app.string.button_cancel')) + .fontColor(Color.Red) + .fontSize(17) + } + .margin(5) + .layoutWeight(7) + .backgroundColor(Color.White) + .onClick(() => { + this.controller?.close(); + }) + } + .margin({ top: 12 }) + } + .padding(12) + } + + addInformation() { + if (this.writeInformation.name === '') { + prompt.showToast({ message: $r('app.string.name_null') }); + return; + } + if (this.writeInformation.age < 1 || Number.isNaN(this.writeInformation.age)) { + prompt.showToast({ message: $r('app.string.age_null') }); + return; + } + if (this.writeInformation.phone === '') { + prompt.showToast({ message: $r('app.string.phone_null') }); + return; + } + if (this.writeInformation.name !== '' && this.writeInformation.phone !== '' && this.writeInformation.age > 0) { + this.saveData(this.writeInformation); + } + this.controller?.close(); + } +} \ No newline at end of file diff --git a/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/components/arraylistcomponents/ArrayListItem.ets b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/components/arraylistcomponents/ArrayListItem.ets new file mode 100644 index 0000000000000000000000000000000000000000..fe6f99ee816e06713ea6b630e254f074b7d5ba85 --- /dev/null +++ b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/components/arraylistcomponents/ArrayListItem.ets @@ -0,0 +1,89 @@ +/* + * Copyright (c) 2023 Huawei Device 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 { Information } from '../../model/Information'; + +@Component +export struct ArrayListItem { + @ObjectLink information: Information; + private index: number = 0; + private handleOnClick: (index: number) => void = () => {}; + + build() { + Row() { + Image($r('app.media.contact')) + .width('20%') + .objectFit(ImageFit.Contain) + Column() { + Row() { + Text($r("app.string.contact_name")) + .fontSize(24) + .fontColor(Color.Black) + Text(this.information.name) + .fontColor(Color.Black) + .fontSize(24) + } + .width('100%') + .margin({ top: 5 }) + + Row() { + Text($r("app.string.contact_age")) + .fontColor(Color.Black) + .fontSize(24) + Text(this.information.age.toString()) + .fontColor(Color.Black) + .fontSize(24) + } + .width('100%') + .margin({ top: 5 }) + + Row() { + Text($r("app.string.contact_phone")) + .fontColor(Color.Black) + .fontSize(24) + Text(this.information.phone) + .fontColor(Color.Black) + .fontSize(24) + } + .width('100%') + .margin({ top: 5 }) + } + .width('55%') + .margin({ left: 10 }) + .justifyContent(FlexAlign.Start) + + Blank() + Button() { + Text($r('app.string.button_delete')) + .key('delContact') + .fontColor(Color.Red) + .fontSize(19) + .width(100) + .textAlign(TextAlign.Center) + } + .type(ButtonType.Capsule) + .backgroundColor($r("app.color.button_bg")) + .height(40) + .onClick(() => { + this.handleOnClick(this.index); + }) + } + .width('100%') + .padding(10) + .align(Alignment.Center) + .borderRadius(20) + .backgroundColor(Color.White) + } +} \ No newline at end of file diff --git a/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/components/arraylistcomponents/MyDataSource.ets b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/components/arraylistcomponents/MyDataSource.ets new file mode 100644 index 0000000000000000000000000000000000000000..afea36a0e1557e35257194ec08e11019dbca01b3 --- /dev/null +++ b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/components/arraylistcomponents/MyDataSource.ets @@ -0,0 +1,72 @@ +/* + * Copyright (c) 2023 Huawei Device 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 ArrayList from '@ohos.util.ArrayList'; +import { Information } from '../../model/Information'; + +export class MyDataSource { + public dataArray: ArrayList = new ArrayList(); + private listeners: DataChangeListener[] = []; + + constructor(ele: ArrayList) { + for (let index = 0;index < ele.length; index++) { + this.dataArray.add(ele[index]); + } + } + + public totalCount(): number { + return this.dataArray.length; + } + + public getData(index: number): Information { + return this.dataArray[index]; + } + + public addData(index: number, data: Information): void { + this.dataArray.removeByIndex(index); + this.notifyDataAdd(index); + } + + registerDataChangeListener(listener: DataChangeListener): void { + if (this.listeners.indexOf(listener) < 0) { + this.listeners.push(listener); + } + } + + unregisterDataChangeListener(listener: DataChangeListener): void { + const pos = this.listeners.indexOf(listener); + if (pos >= 0) { + this.listeners.splice(pos, 1); + } + } + + notifyDataReload(): void { + this.listeners.forEach(listener => { + listener.onDataReloaded(); + }) + } + + notifyDataAdd(index: number): void { + this.listeners.forEach(listener => { + listener.onDataAdd(index); + }) + } + + notifyDataChange(index: number): void { + this.listeners.forEach(listener => { + listener.onDataChange(index); + }) + } +} \ No newline at end of file diff --git a/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/components/dequecomponents/DequeDataSource.ets b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/components/dequecomponents/DequeDataSource.ets new file mode 100644 index 0000000000000000000000000000000000000000..a3b8d19ca57843aa1d46da5b5a7e10417d09bacb --- /dev/null +++ b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/components/dequecomponents/DequeDataSource.ets @@ -0,0 +1,62 @@ +/* +* 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 Deque from '@ohos.util.Deque'; +import { BaseDataSource } from '@ohos/common/src/main/ets/components/BaseDataSource'; +import { Information } from '../../model/Information'; + +export class DequeDataSource extends BaseDataSource { + private deque = new Deque(); + + public totalCount(): number { + return this.deque.length + } + + public getData(index: number): Information { + return this.deque[index] + } + + public insertFront(information: Information): void { + this.deque.insertFront(information); + this.deque.forEach((value, index) => { + value.clickAble = index === 0 || index === this.deque.length - 1; + }); + this.notifyDataReload(); + } + + public insertEnd(information: Information): void { + this.deque.insertEnd(information); + this.deque.forEach((value, index) => { + value.clickAble = index === 0 || index === this.deque.length - 1; + }); + this.notifyDataReload(); + } + + public deleteFront(): void { + this.deque.popFirst(); + this.deque.forEach((value, index) => { + value.clickAble = index === 0 || index === this.deque.length - 1; + }); + this.notifyDataReload(); + } + + public deleteEnd(): void { + this.deque.popLast(); + this.deque.forEach((value, index) => { + value.clickAble = index === 0 || index === this.deque.length - 1; + }); + this.notifyDataReload(); + } +} \ No newline at end of file diff --git a/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/components/hashmapcomponents/HashMapDataSource.ets b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/components/hashmapcomponents/HashMapDataSource.ets new file mode 100644 index 0000000000000000000000000000000000000000..2cac4c37ca068a38b2e5fbf7b6f692faf3e3515e --- /dev/null +++ b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/components/hashmapcomponents/HashMapDataSource.ets @@ -0,0 +1,41 @@ +/* +* 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 { BaseDataSource } from '@ohos/common/src/main/ets/components/BaseDataSource'; +import { KeyValuePair } from '../../model/KeyValuePair'; + +export class HashMapDataSource extends BaseDataSource { + public dataArr: KeyValuePair[] = []; + + public totalCount(): number { + return this.dataArr.length; + } + + public getData(index: number): KeyValuePair { + return this.dataArr[index]; + } + + public addData(item: KeyValuePair): void { + this.dataArr.push(item); + this.notifyDataAdd(this.dataArr.length - 1); + this.notifyDataReload(); + } + + public deleteData(item: KeyValuePair, index: number): void { + this.notifyDataDelete(index); + this.dataArr.splice(index, 1); + this.notifyDataReload(); + } +} \ No newline at end of file diff --git a/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/components/hashsetcomponents/HashSetDataSource.ets b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/components/hashsetcomponents/HashSetDataSource.ets new file mode 100644 index 0000000000000000000000000000000000000000..7e52c42c39703ad313a68ec439823f86bfd8e307 --- /dev/null +++ b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/components/hashsetcomponents/HashSetDataSource.ets @@ -0,0 +1,40 @@ +/* +* 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 { BaseDataSource } from '@ohos/common/src/main/ets/components/BaseDataSource'; + +export class HashSetDataSource extends BaseDataSource { + public dataArr: string[] = []; + + public totalCount(): number { + return this.dataArr.length + } + + public getData(index: number): string { + return this.dataArr[index]; + } + + public addData(item: string): void { + this.dataArr.push(item); + this.notifyDataAdd(this.dataArr.length - 1); + this.notifyDataReload(); + } + + public deleteData(item: string, index: number): void { + this.dataArr.splice(index, 1); + this.notifyDataDelete(index); + this.notifyDataReload(); + } +} \ No newline at end of file diff --git a/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/components/lightweightmapcomponents/LightWeightMapDataSource.ets b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/components/lightweightmapcomponents/LightWeightMapDataSource.ets new file mode 100644 index 0000000000000000000000000000000000000000..b18a663ea2cf65315c3a9744e5f465872638518d --- /dev/null +++ b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/components/lightweightmapcomponents/LightWeightMapDataSource.ets @@ -0,0 +1,41 @@ +/* +* 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 { BaseDataSource } from '@ohos/common/src/main/ets/components/BaseDataSource'; +import { KeyValuePair } from '../../model/KeyValuePair'; + +export class LightWeightMapDataSource extends BaseDataSource { + public dataArr: KeyValuePair[] = []; + + public totalCount(): number { + return this.dataArr.length; + } + + public getData(index: number): KeyValuePair { + return this.dataArr[index]; + } + + public addData(item: KeyValuePair): void { + this.dataArr.push(item); + this.notifyDataAdd(this.dataArr.length - 1); + this.notifyDataReload(); + } + + public deleteData(item: KeyValuePair, index: number): void { + this.dataArr.splice(index, 1); + this.notifyDataDelete(index); + this.notifyDataReload(); + } +} \ No newline at end of file diff --git a/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/components/lightweightsetcomponents/LightWeightSetDataSource.ets b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/components/lightweightsetcomponents/LightWeightSetDataSource.ets new file mode 100644 index 0000000000000000000000000000000000000000..660df7559ca49a9b9c3a0d339fe077d7a5acc0de --- /dev/null +++ b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/components/lightweightsetcomponents/LightWeightSetDataSource.ets @@ -0,0 +1,40 @@ +/* +* 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 { BaseDataSource } from '@ohos/common/src/main/ets/components/BaseDataSource'; + +export class LightWeightSetDataSource extends BaseDataSource { + public dataArr: string[] = [] + + public totalCount(): number { + return this.dataArr.length; + } + + public getData(index: number): string { + return this.dataArr[index]; + } + + public addData(item: string): void { + this.dataArr.push(item); + this.notifyDataAdd(this.dataArr.length - 1); + this.notifyDataReload(); + } + + public deleteData(item: string, index: number): void { + this.dataArr.splice(index, 1); + this.notifyDataDelete(index); + this.notifyDataReload(); + } +} \ No newline at end of file diff --git a/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/components/linkedlistcomponents/LinkedListDataSource.ets b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/components/linkedlistcomponents/LinkedListDataSource.ets new file mode 100644 index 0000000000000000000000000000000000000000..43684afa80e5ab4b5bf6575762eb73d1b4626f84 --- /dev/null +++ b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/components/linkedlistcomponents/LinkedListDataSource.ets @@ -0,0 +1,54 @@ +/* +* 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 LinkedList from '@ohos.util.LinkedList'; +import { BaseDataSource } from '@ohos/common/src/main/ets/components/BaseDataSource'; +import { Information } from '../../model/Information'; + +export class LinkedListDataSource extends BaseDataSource { + private linkedList: LinkedList = new LinkedList(); + + public totalCount(): number { + return this.linkedList.length; + } + + public getData(index: number): Information { + return this.linkedList[index]; + } + + public addData(item: Information): void { + this.linkedList.add(item); + this.notifyDataAdd(this.linkedList.length - 1); + this.notifyDataReload(); + } + + public deleteFirst(): void { + this.linkedList.removeFirst(); + this.notifyDataDelete(0); + this.notifyDataReload(); + } + + public deleteLast(): void { + this.linkedList.removeLast(); + this.notifyDataDelete(this.linkedList.length - 1); + this.notifyDataReload(); + } + + public deleteData(index: number): void { + this.linkedList.removeByIndex(index); + this.notifyDataDelete(index); + this.notifyDataReload(); + } +} \ No newline at end of file diff --git a/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/components/listcomponents/ListDataSource.ets b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/components/listcomponents/ListDataSource.ets new file mode 100644 index 0000000000000000000000000000000000000000..d25893ad212229401808912302e56024bb51f960 --- /dev/null +++ b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/components/listcomponents/ListDataSource.ets @@ -0,0 +1,42 @@ +/* +* 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 ListUtil from '@ohos.util.List'; +import { BaseDataSource } from '@ohos/common/src/main/ets/components/BaseDataSource'; +import { Information } from '../../model/Information'; + +export class ListDateSource extends BaseDataSource { + private dataArr: ListUtil = new ListUtil(); + + public totalCount(): number { + return this.dataArr.length; + } + + public getData(index: number): Information { + return this.dataArr.get(index); + } + + public addData(information: Information): void { + this.dataArr.add(information); + this.notifyDataAdd(this.dataArr.length - 1); + this.notifyDataReload(); + } + + public deleteData(index: number): void { + this.dataArr.removeByIndex(index); + this.notifyDataDelete(index); + this.notifyDataReload(); + } +} \ No newline at end of file diff --git a/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/components/plainarraycomponents/PlainArrayDataSource.ets b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/components/plainarraycomponents/PlainArrayDataSource.ets new file mode 100644 index 0000000000000000000000000000000000000000..77ef76fd1d3aa1ced4e34706a518645c83c97025 --- /dev/null +++ b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/components/plainarraycomponents/PlainArrayDataSource.ets @@ -0,0 +1,53 @@ +/* +* 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 PlainArray from '@ohos.util.PlainArray'; +import ArrayList from '@ohos.util.ArrayList'; +import { BaseDataSource } from '@ohos/common/src/main/ets/components/BaseDataSource'; +import { KeyValuePair } from '../../model/KeyValuePair'; + +export class PlainArrayDataSource extends BaseDataSource { + private dataArr: PlainArray = new PlainArray(); + private arr: ArrayList = new ArrayList(); + + public totalCount(): number { + return this.arr.length; + } + + public getData(index: number): KeyValuePair { + let key: number = this.arr[index]; + let value: string = this.dataArr.get(key); + this.dataArr.get(this.arr[index]); + let keyValuePair: KeyValuePair = new KeyValuePair(`${this.arr[index]}`, value); + return keyValuePair; + } + + public addData(keyValuePair: KeyValuePair): void { + let key: number = Number(keyValuePair.key); + if (!this.dataArr.has(key)) { + this.arr.add(key) + } + this.dataArr.add(key, keyValuePair.value); + this.notifyDataAdd(this.dataArr.length - 1); + this.notifyDataReload(); + } + + public deleteData(index: number): void { + this.dataArr.removeAt(index); + this.arr.removeByIndex(index); + this.notifyDataDelete(index); + this.notifyDataReload(); + } +} \ No newline at end of file diff --git a/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/components/queuecomponents/QueueDataSource.ets b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/components/queuecomponents/QueueDataSource.ets new file mode 100644 index 0000000000000000000000000000000000000000..fff7d9eac539b0928a667a2bb3c36a6d14c9b581 --- /dev/null +++ b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/components/queuecomponents/QueueDataSource.ets @@ -0,0 +1,48 @@ +/* +* 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 Queue from '@ohos.util.Queue'; +import { BaseDataSource } from '@ohos/common/src/main/ets/components/BaseDataSource'; +import { Information } from '../../model/Information'; + +export class QueueDataSource extends BaseDataSource { + private dataArr: Queue = new Queue(); + + public totalCount(): number { + return this.dataArr.length; + } + + public getData(index: number): Information { + return this.dataArr[index]; + } + + public addData(information: Information): void { + this.dataArr.add(information); + this.dataArr.forEach((value, index) => { + value.clickAble = index === 0; + }); + this.notifyDataAdd(this.dataArr.length - 1); + this.notifyDataReload(); + } + + public deleteData(): void { + this.dataArr.pop(); + this.dataArr.forEach((value, index) => { + value.clickAble = index === 0; + }); + this.notifyDataDelete(0); + this.notifyDataReload(); + } +} \ No newline at end of file diff --git a/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/components/stackcomponents/StackDataSource.ets b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/components/stackcomponents/StackDataSource.ets new file mode 100644 index 0000000000000000000000000000000000000000..92239bc34a89a8e3e78a105329917dd505c54535 --- /dev/null +++ b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/components/stackcomponents/StackDataSource.ets @@ -0,0 +1,48 @@ +/* +* 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 Stack from '@ohos.util.Stack'; +import { BaseDataSource } from '@ohos/common/src/main/ets/components/BaseDataSource'; +import { Information } from '../../model/Information'; + +export class StackDataSource extends BaseDataSource { + private dataArr: Stack = new Stack(); + + public totalCount(): number { + return this.dataArr.length; + } + + public getData(index: number): Information { + return this.dataArr[index]; + } + + public addData(information: Information): void { + this.dataArr.push(information); + this.dataArr.forEach((value, index) => { + value.clickAble = index === this.dataArr.length - 1; + }); + this.notifyDataAdd(this.dataArr.length - 1); + this.notifyDataReload(); + } + + public deleteData(): void { + this.dataArr.pop(); + this.dataArr.forEach((value, index) => { + value.clickAble = index === this.dataArr.length - 1; + }); + this.notifyDataDelete(this.dataArr.length - 1); + this.notifyDataReload(); + } +} \ No newline at end of file diff --git a/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/components/treemapcomponents/TreeMapDataSource.ets b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/components/treemapcomponents/TreeMapDataSource.ets new file mode 100644 index 0000000000000000000000000000000000000000..629a08d6d04acdb2915b3d2621044c80f9de7604 --- /dev/null +++ b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/components/treemapcomponents/TreeMapDataSource.ets @@ -0,0 +1,53 @@ +/* +* 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 TreeMap from '@ohos.util.TreeMap'; +import ArrayList from '@ohos.util.ArrayList'; +import { BaseDataSource } from '@ohos/common/src/main/ets/components/BaseDataSource'; +import { KeyValuePair } from '../../model/KeyValuePair'; + +export class TreeMapDataSource extends BaseDataSource { + private dataArr: TreeMap = new TreeMap(); + private arr: ArrayList = new ArrayList(); + + public totalCount(): number { + return this.arr.length; + } + + public getData(index: number): KeyValuePair { + let key: string = this.arr[index]; + let value: string = this.dataArr.get(key); + this.dataArr.get(this.arr[index]); + let keyValuePair: KeyValuePair = new KeyValuePair(`${this.arr[index]}`, value); + return keyValuePair; + } + + public addData(keyValuePair: KeyValuePair): void { + if (!this.dataArr.hasKey(keyValuePair.key)) { + this.arr.add(keyValuePair.key) + } + this.dataArr.set(keyValuePair.key, keyValuePair.value); + this.notifyDataChange(this.dataArr.length - 1); + this.notifyDataReload(); + } + + public deleteData(key: string): void { + this.dataArr.remove(key); + let index = this.arr.getIndexOf(key); + this.arr.remove(key); + this.notifyDataDelete(index); + this.notifyDataReload(); + } +} \ No newline at end of file diff --git a/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/components/treesetcomponents/TreeSetDataSource.ets b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/components/treesetcomponents/TreeSetDataSource.ets new file mode 100644 index 0000000000000000000000000000000000000000..86889ed72252733d55bae2bafe19e293d00028cd --- /dev/null +++ b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/components/treesetcomponents/TreeSetDataSource.ets @@ -0,0 +1,45 @@ +/* +* 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 TreeSet from '@ohos.util.TreeSet'; +import ArrayList from '@ohos.util.ArrayList'; +import { BaseDataSource } from '@ohos/common/src/main/ets/components/BaseDataSource'; + +export class TreeSetDataSource extends BaseDataSource { + private dataArr: TreeSet = new TreeSet(); + private arr: ArrayList = new ArrayList(); + + public totalCount(): number { + return this.dataArr.length; + } + + public getData(index: number): string { + return this.arr[index]; + } + + public addData(value: string): void { + this.dataArr.add(value); + this.arr.add(value); + this.notifyDataAdd(this.dataArr.length - 1); + this.notifyDataReload(); + } + + public deleteData(value: string, index: number): void { + this.dataArr.remove(value); + this.arr.removeByIndex(index); + this.notifyDataDelete(index); + this.notifyDataReload(); + } +} \ No newline at end of file diff --git a/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/components/utilcomponents/Base64Helper.ets b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/components/utilcomponents/Base64Helper.ets new file mode 100644 index 0000000000000000000000000000000000000000..7908c1325be271efd67681afcb3fd83cd743b0b7 --- /dev/null +++ b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/components/utilcomponents/Base64Helper.ets @@ -0,0 +1,112 @@ +/* + * Copyright (c) 2023 Huawei Device 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 util from '@ohos.util'; + +@Component +export struct Base64Helper { + @State resultEncode: string = ''; + @State resultDecode: string = ''; + @State input: string = 'harmony'; + + build() { + Scroll() { + Column({ space: 12 }) { + Row() { + Text($r('app.string.change_str')) + .fontSize(20) + .fontWeight(FontWeight.Bold) + .textAlign(TextAlign.End) + + Text(this.input) + .fontSize(20) + .fontWeight(FontWeight.Bold) + .textAlign(TextAlign.Start) + } + .width('100%') + .height('10%') + + Text(this.resultEncode) + .width('100%') + .height('10%') + .padding({ left: 10 }) + .fontSize(20) + .fontWeight(FontWeight.Bold) + .border({ width: 2, radius: 10, color: Color.Black }) + + Button() { + Text($r("app.string.encode")) + .fontSize(25) + .fontColor(Color.White) + } + .key('encodeBtn') + .width('100%') + .height(50) + .type(ButtonType.Capsule) + .onClick(() => { + this.encode(); + }) + + Text(this.resultDecode) + .width('100%') + .height('10%') + .fontSize(20) + .padding({ left: 10 }) + .fontWeight(FontWeight.Bold) + .border({ width: 2, radius: 10, color: Color.Black }) + .margin({ top: 50 }) + + Button() { + Text($r("app.string.decode")) + .fontSize(25) + .fontColor(Color.White) + } + .key('decodeBtn') + .width('100%') + .height(50) + .type(ButtonType.Capsule) + .onClick(() => { + this.decode(); + }) + } + .width('100%') + .padding(16) + } + .scrollBar(BarState.Off) + .align(Alignment.Start) + } + + encode() { + let strToAscii: number[] = []; + for (let i = 0;i < this.input.length; i++) { + strToAscii.push(this.input.charCodeAt(i)); + } + let that = new util.Base64Helper(); + let encodeNum = new Uint8Array(strToAscii); + this.resultEncode = that.encodeToStringSync(encodeNum); + } + + decode() { + let that = new util.Base64Helper(); + if (this.resultEncode === undefined || this.resultEncode === '') { + return; + } + let decodeNum = that.decodeSync(this.resultEncode); + this.resultDecode = ''; + for (let i = 0; i < decodeNum.length; i++) { + this.resultDecode += String.fromCharCode(decodeNum[i]); + } + } +} \ No newline at end of file diff --git a/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/components/utilcomponents/LRUCache.ets b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/components/utilcomponents/LRUCache.ets new file mode 100644 index 0000000000000000000000000000000000000000..f3c9d436c40d933cf523228cc899109024bcc903 --- /dev/null +++ b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/components/utilcomponents/LRUCache.ets @@ -0,0 +1,124 @@ +/* + * Copyright (c) 2023 Huawei Device 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 { ActionSheetDialog } from './lrucache/ActionSheetDialog'; +import { GridOperation } from '../GridOperation'; +import { + clear, + getCapacity, + getAllKeyValues, + getCacheString, + initLRUCache, + lruBuffer, + operationLog, + putKeyValue, + updateCapacity +} from '../../util/LRUCacheUtil'; + +@Component +export struct LRUCache { + @State resultText: string = ''; + @State actionSheets: Array = []; + private isGet: boolean = true; + + build() { + Scroll() { + Column() { + Scroll() { + Text(this.resultText) + .width('100%') + .fontSize(16) + } + .width('90%') + .height(240) + .margin({ top: 10 }) + .border({ width: 1, color: Color.Gray, radius: 15 }) + .scrollBar(BarState.Off) + .padding(15) + + GridOperation({ operationRes: $r('app.strarray.lru_cache_operations'), doOperation: this.doOperation }) + } + .width('100%') + .padding(16) + } + .scrollBar(BarState.Off) + .align(Alignment.Start) + } + + action = (key: string) => { + if (this.isGet) { + if (lruBuffer.contains(key)) { + let value: string = lruBuffer.get(key) as string; + this.resultText = `key = ${key}, value=${value}`; + } else { + this.resultText = `the key:${key} is not found`; + } + } else { + lruBuffer.remove(key); + this.resultText = `key:${key} is removed\n`; + } + } + private actionDialogController: CustomDialogController = new CustomDialogController({ + builder: ActionSheetDialog({ + title: 'Click the key', + sheets: this.actionSheets, + action: this.action + }), + autoCancel: true + }); + doOperation = (index: number) => { + if (index !== 0 && lruBuffer === null) { + this.resultText = 'Click the first button and then operate'; + return; + } + switch (index) { + case 0: + this.resultText = initLRUCache(); + break; + case 1: + this.resultText = getCapacity(); + break; + case 2: + this.resultText = updateCapacity(); + break; + case 3: + this.resultText = getCacheString(); + break; + case 4: + this.resultText = putKeyValue(); + break; + case 5: + this.isGet = true; + this.actionSheets = lruBuffer.keys() as string[]; + this.actionDialogController.open(); + break; + case 6: + this.resultText = getAllKeyValues(); + break; + case 7: + this.isGet = false; + this.actionSheets = lruBuffer.keys() as string[]; + this.actionDialogController.open(); + break; + case 8: + this.resultText = clear(); + break; + case 9: + this.resultText = operationLog(); + default: + break; + } + } +} \ No newline at end of file diff --git a/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/components/utilcomponents/RationalNumber.ets b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/components/utilcomponents/RationalNumber.ets new file mode 100644 index 0000000000000000000000000000000000000000..c6c402440925f57d78e75d3d1d90b851d09a3b8f --- /dev/null +++ b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/components/utilcomponents/RationalNumber.ets @@ -0,0 +1,108 @@ +/* + * Copyright (c) 2023 Huawei Device 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 { compareTo, getDenominator, getValueOf, isFinite, isNaN, isZero } from '../../util/RationalNumberUtil'; +import { GridOperation } from '../GridOperation'; + +const NUMERATOR1: number = 1; +const DENOMINATOR1: number = 2; +const NUMERATOR2: number = 3; +const DENOMINATOR2: number = 4; + +@Extend(Text) function textStyle() { + .border({ width: 1, color: '#000000', radius: 10, style: BorderStyle.Solid }) + .fontSize(24) + .textAlign(TextAlign.Center) +} + +@Preview +@Component +export struct RationalNumber { + @State resultText: string = ''; + + build() { + Scroll() { + Column({ space: 12 }) { + Text($r('app.string.first_rational_number')) + .width('100%') + .fontSize(24) + .textAlign(TextAlign.Start) + this.Texts(NUMERATOR1, DENOMINATOR1) + Text($r('app.string.second_rational_number')) + .width('100%') + .fontSize(24) + .textAlign(TextAlign.Start) + this.Texts(NUMERATOR2, DENOMINATOR2) + Text(this.resultText) + .textStyle() + .width('100%') + .height(100) + GridOperation({ operationRes: $r('app.strarray.rational_number_operations'), doOperation: this.doOperation }) + } + .width('100%') + .padding(16) + } + .scrollBar(BarState.Off) + .align(Alignment.Start) + } + + @Builder + Texts(numerator: number, denominator: number) { + Row() { + Text($r('app.string.numerator')) + .fontSize(24) + .fontWeight(FontWeight.Bold) + Text(`${numerator}`) + .textStyle() + .margin({ left: 5 }) + .layoutWeight(1) + Text($r('app.string.denominator')) + .fontSize(24) + .fontWeight(FontWeight.Bold) + Text(`${denominator}`) + .textStyle() + .margin({ left: 5 }) + .layoutWeight(1) + } + .width('100%') + .alignItems(VerticalAlign.Center) + .justifyContent(FlexAlign.SpaceAround) + } + + doOperation = (index: number) => { + switch (index) { + case 0: + this.resultText = compareTo(); + break; + case 1: + this.resultText = getValueOf(); + break; + case 2: + this.resultText = getDenominator(); + break; + case 3: + this.resultText = isZero(); + break; + case 4: + this.resultText = isNaN(); + break; + case 5: + this.resultText = isFinite(); + break; + default: + break; + } + } +} \ No newline at end of file diff --git a/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/components/utilcomponents/ScopeHelper.ets b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/components/utilcomponents/ScopeHelper.ets new file mode 100644 index 0000000000000000000000000000000000000000..632feed72505064ec294e98368a8dfff51a0a620 --- /dev/null +++ b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/components/utilcomponents/ScopeHelper.ets @@ -0,0 +1,107 @@ +/* + * Copyright (c) 2023 Huawei Device 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 util from '@ohos.util'; +import { ScopeNumber } from '../../model/ScopeNumber'; +import { TempView } from './scopehelper/TempView'; +import { SleepView } from './scopehelper/SleepView'; + +const AGE_MIN: number = 16; +const AGE_MAX: number = 62; + +@Preview +@Component +export struct ScopeHelper { + @State age: number = 0; + @State tempMorning: number = 0; + @State tempNoon: number = 1; + @State tempNight: number = 2; + @State shortTime: number = 0; + @State longTime: number = 0; + + build() { + Scroll() { + Column({ space: 12 }) { + Text($r('app.string.judge_age')) + .fontSize(20) + .fontColor(Color.White) + .backgroundColor(Color.Gray) + .textAlign(TextAlign.Start) + Row({ space: 5 }) { + TextInput({ placeholder: $r('app.string.age_placeholder') }) + .key('inputAge') + .height('100%') + .layoutWeight(6) + .type(InputType.Number) + .fontSize(24) + .fontStyle(FontStyle.Italic) + .maxLength(20) + .fontWeight(FontWeight.Bold) + .placeholderFont({ size: 24, weight: FontWeight.Normal }) + .enterKeyType(EnterKeyType.Go) + .onChange((value: string) => { + this.age = Number(value); + }) + + Button() { + Text($r('app.string.age_analyse')) + .fontColor(Color.White) + .fontSize(16) + } + .key('ageAnalysis') + .layoutWeight(4) + .height(40) + .type(ButtonType.Capsule) + .onClick(() => { + this.ageRange(); + }) + } + .height(50) + TempView() + SleepView() + } + .width('100%') + .padding(16) + } + .scrollBar(BarState.Off) + .align(Alignment.Start) + } + + dialog(title: ResourceStr, message: ResourceStr, value: ResourceStr) { + AlertDialog.show( + { + title: title, + message: message, + confirm: { + value: value, + action: () => { + } + }, + } + ); + } + + ageRange() { + let tempLower = new ScopeNumber(AGE_MIN); + let tempUpper = new ScopeNumber(AGE_MAX); + let range = new util.Scope(tempLower, tempUpper); + let ageTemp = new ScopeNumber(this.age); + if (range.contains(ageTemp)) { + this.dialog($r('app.string.age'), $r('app.string.age_message_confirm'), $r('app.string.determine')); + } else { + this.dialog($r('app.string.age'), $r('app.string.age_message_not_confirm'), $r('app.string.determine')); + } + } +} \ No newline at end of file diff --git a/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/components/utilcomponents/StringCode.ets b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/components/utilcomponents/StringCode.ets new file mode 100644 index 0000000000000000000000000000000000000000..68a22787150b30f83994c0eea02c9574e73a1710 --- /dev/null +++ b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/components/utilcomponents/StringCode.ets @@ -0,0 +1,194 @@ +/* + * Copyright (c) 2023 Huawei Device 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 util from '@ohos.util'; +import { getString } from '@ohos/common/src/main/ets/util/ResourceUtil'; +import { SpecInput } from './stringcode/SpecInput'; + +@Preview +@Component +export struct StringCode { + @State specStrInput_f: string = ''; + @State specStrInput_s: string = ''; + @State specStrInput_d: string = ''; + @State specStrInput_i: string = ''; + @State resen: string = ''; + @State resdec: string = ''; + @State read: string = ''; + @State write: string = ''; + private resArray: Uint8Array | undefined = undefined; + + build() { + Scroll() { + Column({ space: 12 }) { + Row() { + Text($r('app.string.SpecString')) + .fontSize(15) + .textAlign(TextAlign.Start) + Text($r('app.string.SpecString_info')) + .fontSize(15) + .textAlign(TextAlign.Start) + } + + SpecInput({ result_str: $r('app.string.result_f'), specStrInput: $specStrInput_f }) + SpecInput({ result_str: $r('app.string.result_i'), specStrInput: $specStrInput_i }) + SpecInput({ result_str: $r('app.string.result_d'), specStrInput: $specStrInput_d }) + SpecInput({ result_str: $r('app.string.result_s'), specStrInput: $specStrInput_s }) + Button() { + Text($r('app.string.SpecFormOutput')) + .fontSize(15) + .fontWeight(FontWeight.Bold) + .fontColor(Color.White) + } + .id('specFormatOutput') + .width('100%') + .height(40) + .onClick(() => { + this.specStrInput_f = util.format("%f", "OpenHarmony 3.0") + this.specStrInput_i = util.format("%i", "OpenHarmony 3.0") + this.specStrInput_d = util.format("%d", "OpenHarmony 3.0") + this.specStrInput_s = util.format("%s", "OpenHarmony 3.0") + }) + + Divider() + .strokeWidth(4) + .color($r('sys.color.ohos_id_color_floating_button_shadow_end')) + + Row() { + Text($r('app.string.SpecString')) + .fontSize(15) + .textAlign(TextAlign.Start) + Text($r('app.string.StringCodec_info')) + .fontSize(15) + .margin({ left: 5 }) + .textAlign(TextAlign.Start) + } + + Row() { + Text($r('app.string.result')) + .width('20%') + .height(30) + .fontSize(15) + .textAlign(TextAlign.Start) + Text(this.resen) + .height(60) + .fontSize(15) + .layoutWeight(1) + .maxLines(2) + .textAlign(TextAlign.Start) + .border({ width: 2, radius: 5, color: $r('app.color.text_color') }) + } + .margin({ top: 20 }) + .width('100%') + + Row() { + Text($r('app.string.read')) + .width('20%') + .fontSize(15) + .textAlign(TextAlign.Start) + Text(this.read) + .id('read') + .width('30%') + .fontSize(15) + .height(30) + .textAlign(TextAlign.Start) + .border({ width: 2, radius: 5, color: $r('app.color.text_color') }) + Text($r('app.string.write')) + .width('20%') + .fontSize(15) + .textAlign(TextAlign.Center) + Text(this.write) + .id('write') + .width('30%') + .fontSize(15) + .height(30) + .textAlign(TextAlign.Start) + .border({ width: 2, radius: 5, color: $r('app.color.text_color') }) + } + .width('100%') + + Button() { + Text($r('app.string.Text_encoder')) + .fontColor(Color.White) + .fontSize(15) + .fontWeight(FontWeight.Bold) + } + .id('textEncoder') + .width('100%') + .height(40) + .onClick(() => { + this.textEncode(); + }) + + Row() { + Text($r('app.string.result')) + .width('20%') + .height(30) + .fontSize(15) + .textAlign(TextAlign.Start) + .fontColor(Color.Black) + Text(this.resdec) + .id('decRes') + .width('80%') + .height(60) + .fontSize(15) + .textAlign(TextAlign.Start) + .maxLines(2) + .border({ width: 2, radius: 5, color: $r('app.color.text_color') }) + } + .margin({ top: 20 }) + .width(300) + + Button() { + Text($r('app.string.Text_decoder')) + .fontColor(Color.White) + .fontSize(15) + .fontWeight(FontWeight.Bold) + } + .id('textDecoder') + .width('100%') + .height(40) + .margin({ bottom: 50 }) + .onClick(() => { + this.textDecode(); + }) + } + .width('100%') + .padding(16) + } + .scrollBar(BarState.Off) + .align(Alignment.Start) + } + + textEncode() { + let textEncoder = new util.TextEncoder(); + let buffer = new ArrayBuffer(100); + this.resArray = new Uint8Array(buffer); + this.resArray = textEncoder.encodeInto(getString($r('app.string.message'))); + let resArratNum = textEncoder.encodeIntoUint8Array(getString($r('app.string.message')), this.resArray); + this.resen = this.resArray.toString(); + this.read = JSON.stringify(resArratNum.read); + this.write = JSON.stringify(resArratNum.written); + } + + textDecode() { + let textDecoder = util.TextDecoder.create('utf-8', { ignoreBOM: true }); + if (this.resArray === undefined) { + return; + } + this.resdec = textDecoder.decodeWithStream(this.resArray, { stream: false }); + } +} + diff --git a/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/components/utilcomponents/TypeCheck.ets b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/components/utilcomponents/TypeCheck.ets new file mode 100644 index 0000000000000000000000000000000000000000..bf847a1f05eaaad1cd849c64973088a49d39400c --- /dev/null +++ b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/components/utilcomponents/TypeCheck.ets @@ -0,0 +1,54 @@ +/* + * Copyright (c) 2023 Huawei Device 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 { ShowKey } from './typecheck/ShowKey'; +import { CheckType } from './typecheck/CheckType'; + + +let int8Array: Int8Array = new Int8Array(new ArrayBuffer(8)); +let numVal: Number = new Number(55); +let strVal: String = new String('zhangsan'); +let boolVal: Boolean = new Boolean(true); +; +for (let i = 0; i < int8Array.length; i++) { + int8Array[i] = i; +} + +@Preview +@Component +export struct TypeCheck { + @State checkResult: string = ''; + @State presetValue: Array = [numVal, strVal, boolVal, int8Array]; + + build() { + Scroll() { + Column() { + Text(this.checkResult) + .width('100%') + .height(200) + .fontSize(20) + .margin(20) + .padding({ left: 5, right: 5 }) + .border({ width: 2, radius: 15, color: Color.Gray }) + ShowKey({ presetValue: $presetValue, checkResult: $checkResult }) + CheckType({ presetValue: $presetValue, checkResult: $checkResult }) + } + .width('100%') + .padding(16) + } + .scrollBar(BarState.Off) + .align(Alignment.Start) + } +} \ No newline at end of file diff --git a/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/components/utilcomponents/lrucache/ActionSheetDialog.ets b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/components/utilcomponents/lrucache/ActionSheetDialog.ets new file mode 100644 index 0000000000000000000000000000000000000000..bfab941052f74c224281ef8fd8e989410b6f8ccc --- /dev/null +++ b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/components/utilcomponents/lrucache/ActionSheetDialog.ets @@ -0,0 +1,59 @@ +/* + * Copyright (c) 2023 Huawei Device 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. + */ + +@CustomDialog +export struct ActionSheetDialog { + private controller?: CustomDialogController; + private title: string = ''; + private sheets: string[] = []; + private action: (key: string) => void = () => {}; + + build() { + Column() { + Text(this.title) + .width('100%') + .fontSize(18) + .fontColor(Color.Black) + .textAlign(TextAlign.Center) + .margin({ top: 10, bottom: 10 }) + List() { + ForEach(this.sheets, (item: string) => { + ListItem() { + Row() { + Text('key:') + .fontSize(18) + .fontColor(Color.Gray) + Text(item) + .fontSize(18) + .fontColor(Color.Gray) + } + .key('getValueOfTheKey') + .width('100%') + .margin(10) + } + .width('100%') + .onClick(() => { + this.controller?.close(); + this.action(item); + }) + }) + } + .width('100%') + .margin({ bottom: 56 }) + .divider({ strokeWidth: 1, color: Color.Gray, startMargin: 5, endMargin: 5 }) + } + .width('80%') + } +} \ No newline at end of file diff --git a/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/components/utilcomponents/scopehelper/InputItem.ets b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/components/utilcomponents/scopehelper/InputItem.ets new file mode 100644 index 0000000000000000000000000000000000000000..012caaf2d0975405ef713db007f49f21d8286bbb --- /dev/null +++ b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/components/utilcomponents/scopehelper/InputItem.ets @@ -0,0 +1,42 @@ +/* + * Copyright (c) 2023 Huawei Device 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. + */ + +@Component +export struct InputItem { + @Link value: number; + private textValue: Resource = $r('app.string.short_sleep'); + private placeHolder: Resource = $r('app.string.enter_sleep_time'); + + build() { + Row() { + Text(this.textValue) + .layoutWeight(1) + .fontSize(20) + TextInput({ placeholder: this.placeHolder }) + .key('shortestSleepTime') + .layoutWeight(1) + .type(InputType.Normal) + .fontSize(20) + .fontStyle(FontStyle.Italic) + .maxLength(20) + .fontWeight(FontWeight.Bold) + .placeholderFont({ size: 16, weight: FontWeight.Normal }) + .enterKeyType(EnterKeyType.Go) + .onChange((value: string) => { + this.value = Number(value); + }) + } + } +} \ No newline at end of file diff --git a/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/components/utilcomponents/scopehelper/SleepView.ets b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/components/utilcomponents/scopehelper/SleepView.ets new file mode 100644 index 0000000000000000000000000000000000000000..11c3c4eb9e3824bafd7dddcce1c6bb5f3feef001 --- /dev/null +++ b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/components/utilcomponents/scopehelper/SleepView.ets @@ -0,0 +1,115 @@ +/* + * Copyright (c) 2023 Huawei Device 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 promptAction from '@ohos.promptAction'; +import util from '@ohos.util'; +import { getString } from '@ohos/common/src/main/ets/util/ResourceUtil'; +import { InputItem } from './InputItem'; +import { ScopeNumber } from '../../../model/ScopeNumber'; + +const ZERO: number = 0; +const SLEEP_TIME_SHORT: number = 7; +const SLEEP_TIME_LONG: number = 10; + +@Component +export struct SleepView { + @State shortTime: number = ZERO; + @State longTime: number = ZERO; + + build() { + Column({ space: 12 }) { + Text($r('app.string.judge_sleep')) + .fontSize(20) + .fontColor(Color.White) + .backgroundColor(Color.Gray) + .textAlign(TextAlign.Start) + .margin({ top: 2 }) + + InputItem({ + textValue: $r('app.string.short_sleep'), + placeHolder: $r('app.string.enter_sleep_time'), + value: $shortTime + }) + InputItem({ + textValue: $r('app.string.long_sleep'), + placeHolder: $r('app.string.enter_sleep_time'), + value: $longTime + }) + + Text($r('app.string.sleep_time')) + .fontSize(18) + .fontColor(Color.Red) + + Button() { + Text($r('app.string.sleep_analyse')) + .fontColor(Color.White) + .fontSize(16) + .textAlign(TextAlign.Center) + } + .key('sleepAnalysis') + .type(ButtonType.Capsule) + .width('100%') + .height(45) + .margin({ top: 10, bottom: 10 }) + .backgroundColor(0x317aff) + .onClick(() => { + this.sleepRange(); + }) + } + .alignItems(HorizontalAlign.Center) + .justifyContent(FlexAlign.Start) + .width('100%') + } + + sleepRange() { + if (this.shortTime <= ZERO || this.longTime <= ZERO) { + promptAction.showToast({ message: $r("app.string.scope_sleep_tips") }); + return; + } + if (this.longTime <= this.shortTime) { + promptAction.showToast({ message: $r("app.string.scope_sleep_tips_less") }); + return; + } + let timeLower = new ScopeNumber(SLEEP_TIME_SHORT); + let timeUpper = new ScopeNumber(SLEEP_TIME_LONG); + let timeRange = new util.ScopeHelper(timeLower, timeUpper); + let yTimeLower = new ScopeNumber(this.shortTime); + let yTimeUpper = new ScopeNumber(this.longTime); + let yTimeRange = new util.ScopeHelper(yTimeLower, yTimeUpper); + let message = getString($r("app.string.scope_expand")); + try { + message += `${timeRange.expand(yTimeRange)}`; + } catch { + message += getString($r('app.string.empty')); + } + message += getString($r("app.string.scope_intersect")); + try { + message += `${timeRange.intersect(yTimeRange)}`; + } catch { + message += getString($r('app.string.empty')); + } + AlertDialog.show( + { + title: $r('app.string.sleep_analyse'), + message: message, + confirm: { + value: $r('app.string.determine'), + action: () => { + } + }, + } + ); + } +} \ No newline at end of file diff --git a/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/components/utilcomponents/scopehelper/TempView.ets b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/components/utilcomponents/scopehelper/TempView.ets new file mode 100644 index 0000000000000000000000000000000000000000..4f82613f65b9c886fb5dac2c275b27a456d3827e --- /dev/null +++ b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/components/utilcomponents/scopehelper/TempView.ets @@ -0,0 +1,106 @@ +/* + * Copyright (c) 2023 Huawei Device 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 promptAction from '@ohos.promptAction'; +import util from '@ohos.util'; +import { getString } from '@ohos/common/src/main/ets/util/ResourceUtil'; +import { InputItem } from './InputItem'; +import { ScopeNumber } from '../../../model/ScopeNumber'; + +const ZERO: number = 0; +const TEMPERATURE_MIN: number = 36; +const TEMPERATURE_MAX: number = 37.2; + +@Component +export struct TempView { + @State tempMorning: number = ZERO; + @State tempNoon: number = ZERO; + @State tempNight: number = ZERO; + + build() { + Column({ space: 12 }) { + Text($r('app.string.judge_temp')) + .fontSize(20) + .fontColor(Color.White) + .backgroundColor(Color.Gray) + .textAlign(TextAlign.Start) + .margin({ top: 2 }) + InputItem({ + textValue: $r('app.string.temp_morning'), + placeHolder: $r('app.string.morning_placeholder'), + value: $tempMorning + }) + InputItem({ + textValue: $r('app.string.temp_noon'), + placeHolder: $r('app.string.noon_placeholder'), + value: $tempNoon + }) + InputItem({ + textValue: $r('app.string.temp_night'), + placeHolder: $r('app.string.night_placeholder'), + value: $tempNight + }) + Button() { + Text($r('app.string.temp_analyse')) + .fontColor(Color.White) + .fontSize(16) + } + .key('temperatureAnalysis') + .type(ButtonType.Capsule) + .width('100%') + .height(45) + .backgroundColor(0x317aff) + .onClick(() => { + this.tempRange(); + }) + } + .alignItems(HorizontalAlign.Center) + .justifyContent(FlexAlign.Start) + .width('100%') + } + + alertDialog(title: ResourceStr, message: ResourceStr, value: ResourceStr) { + AlertDialog.show( + { + title: title, + message: message, + confirm: { + value: value, + action: () => { + } + }, + } + ); + } + + tempRange() { + if (this.tempMorning <= ZERO || this.tempNoon <= ZERO || this.tempNight <= ZERO) { + promptAction.showToast({ message: $r("app.string.scope_temp_tips") }); + return; + } + let arr = [this.tempMorning, this.tempNoon, this.tempNight].sort(); + let max = new ScopeNumber(arr[2]); + let min = new ScopeNumber(arr[0]); + let tempLower = new ScopeNumber(TEMPERATURE_MIN); + let tempUpper = new ScopeNumber(TEMPERATURE_MAX); + let standardRange = new util.ScopeHelper(tempLower, tempUpper); + if (standardRange.contains(min) && standardRange.contains(max)) { + this.alertDialog($r('app.string.temperature'), getString($r('app.string.temp_min')) + min + getString($r('app.string.temp_max')) + + max + getString($r('app.string.temp_normal_range')), $r('app.string.determine')); + } else { + this.alertDialog($r('app.string.temperature'), $r('app.string.temp_message_abnormal'), $r('app.string.determine')); + } + } +} \ No newline at end of file diff --git a/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/components/utilcomponents/stringcode/SpecInput.ets b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/components/utilcomponents/stringcode/SpecInput.ets new file mode 100644 index 0000000000000000000000000000000000000000..f9404fbd506b82544ec533c29d2467b6b8d807fe --- /dev/null +++ b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/components/utilcomponents/stringcode/SpecInput.ets @@ -0,0 +1,36 @@ +/* + * Copyright (c) 2023 Huawei Device 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. + */ + +@Component +export struct SpecInput { + private result_str: Resource = $r('app.string.result_f'); + @Link specStrInput: string; + + build() { + Row() { + Text(this.result_str) + .height(30) + .fontSize(15) + .textAlign(TextAlign.Start) + Text(this.specStrInput) + .height(30) + .layoutWeight(1) + .fontSize(15) + .textAlign(TextAlign.Start) + .border({ width: 2, radius: 5, color: "#0D9FFB" }) + } + .width('100%') + } +} \ No newline at end of file diff --git a/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/components/utilcomponents/typecheck/CheckType.ets b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/components/utilcomponents/typecheck/CheckType.ets new file mode 100644 index 0000000000000000000000000000000000000000..10127b79b153eeffe807c53862561d8f25a657c5 --- /dev/null +++ b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/components/utilcomponents/typecheck/CheckType.ets @@ -0,0 +1,75 @@ +/* + * Copyright (c) 2023 Huawei Device 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 util from '@ohos.util'; + +@Component +export struct CheckType { + @State result: string = ' '; + @Link checkResult: string; + @Link presetValue: Array; + + check(value: Object) { + let utilType: util.types = new util.types(); + let utilData: Map | null = new Map([ + ['ArrayBuffer', utilType.isAnyArrayBuffer(value)], + ['Int8Array', utilType.isInt8Array(value)], + ['Number', utilType.isNumberObject(value)], + ['String', utilType.isStringObject(value)], + ['Boolean', utilType.isBooleanObject(value)], + ['ArrayBuffer', utilType.isAnyArrayBuffer(value)], + ['DataView', utilType.isDataView(value)], + ['Arguments', utilType.isArgumentsObject(value)], + ['AsyncFunction', utilType.isAsyncFunction(value)], + ['External', utilType.isExternal(value)], + ['Float32Array', utilType.isFloat32Array(value)], + ['Generator', utilType.isGeneratorFunction(value)] + ]); + for (let item of utilData) { + if (item[1] === true) { + this.result = item[0]; + } + } + utilData = null; + return this.result; + } + + show() { + let showResult: string = ''; + for (let i = 0; i < this.presetValue.length; i++) { + let typeResult = this.check(this.presetValue[i]); + showResult = showResult + `${this.presetValue[i]} check success,this value type is ${typeResult}\n`; + } + this.checkResult = showResult; + } + + build() { + Button() { + Text($r('app.string.check')) + .fontColor(Color.Black) + .fontSize(20) + .textAlign(TextAlign.Center) + .width('85%') + } + .key('checkPresetValue') + .type(ButtonType.Capsule) + .backgroundColor('#0D9FFB') + .padding(5) + .margin({ top: 10 }) + .onClick(() => { + this.show(); + }) + } +} \ No newline at end of file diff --git a/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/components/utilcomponents/typecheck/ShowKey.ets b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/components/utilcomponents/typecheck/ShowKey.ets new file mode 100644 index 0000000000000000000000000000000000000000..72f894af5974b73f9d295494e474c3a5ac75efd7 --- /dev/null +++ b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/components/utilcomponents/typecheck/ShowKey.ets @@ -0,0 +1,42 @@ +/* + * Copyright (c) 2023 Huawei Device 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. + */ + +@Component +export struct ShowKey { + @State result: string = ' '; + @Link checkResult: string; + @Link presetValue: Array; + + build() { + Button() { + Text($r('app.string.show')) + .fontColor(Color.Black) + .fontSize(20) + .textAlign(TextAlign.Center) + .width('85%') + } + .key('displayPresetValue') + .type(ButtonType.Capsule) + .backgroundColor('#0D9FFB') + .padding(5) + .margin({ top: 10 }) + .onClick(() => { + this.checkResult = `numberVal = ${this.presetValue[0]}\n` + +`stringVal = ${this.presetValue[1]}\n` + +`booleanVal = ${this.presetValue[2]}\n` + +`int8Array = ${this.presetValue[3]}`; + }) + } +} \ No newline at end of file diff --git a/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/components/vectorcomponents/VectorDataSource.ets b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/components/vectorcomponents/VectorDataSource.ets new file mode 100644 index 0000000000000000000000000000000000000000..dd4541357ea133b38e696358ac5e5be1ff79579c --- /dev/null +++ b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/components/vectorcomponents/VectorDataSource.ets @@ -0,0 +1,42 @@ +/* +* 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 Vector from '@ohos.util.Vector'; +import { BaseDataSource } from '@ohos/common/src/main/ets/components/BaseDataSource'; +import { Information } from '../../model/Information'; + +export class VectorDataSource extends BaseDataSource { + private dataArr: Vector = new Vector(); + + public totalCount(): number { + return this.dataArr.length; + } + + public getData(index: number): Information { + return this.dataArr.get(index); + } + + public addData(information: Information): void { + this.dataArr.add(information); + this.notifyDataAdd(this.dataArr.length - 1); + this.notifyDataReload(); + } + + public deleteData(index: number): void { + this.dataArr.removeByIndex(index); + this.notifyDataDelete(index); + this.notifyDataReload(); + } +} \ No newline at end of file diff --git a/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/model/Information.ets b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/model/Information.ets new file mode 100644 index 0000000000000000000000000000000000000000..457c17a207e362187c71cb9f04457557c28540b6 --- /dev/null +++ b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/model/Information.ets @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2023 Huawei Device 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. + */ + +@Observed +export class Information { + name: string; + age: number; + phone: string; + clickAble?: boolean; + + constructor(name: string, age: number, phone: string, clickAble?: boolean) { + this.name = name; + this.age = age; + this.phone = phone; + this.clickAble = clickAble; + } +} \ No newline at end of file diff --git a/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/model/KeyValuePair.ets b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/model/KeyValuePair.ets new file mode 100644 index 0000000000000000000000000000000000000000..fe895a771e55174d7d8fffeeed5249937b2c2fce --- /dev/null +++ b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/model/KeyValuePair.ets @@ -0,0 +1,25 @@ +/* +* 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. +*/ + +@Observed +export class KeyValuePair { + key: string; + value: string; + + constructor(key: string, value: string) { + this.key = key; + this.value = value; + } +} \ No newline at end of file diff --git a/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/model/ScopeNumber.ets b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/model/ScopeNumber.ets new file mode 100644 index 0000000000000000000000000000000000000000..8afb73ba29ee9f32868d825e5f58ac215bbf3cc6 --- /dev/null +++ b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/model/ScopeNumber.ets @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2023 Huawei Device 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. + */ + +export class ScopeNumber { + temp: number; + + constructor(value: number) { + this.temp = value; + } + + compareTo(value: ScopeNumber) { + return this.temp >= value.getTemp(); + } + + getTemp() { + return this.temp; + } + + toString() { + return this.temp.toString(); + } +} \ No newline at end of file diff --git a/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/util/ConvertXmlUtil.ets b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/util/ConvertXmlUtil.ets new file mode 100644 index 0000000000000000000000000000000000000000..9e8406bc84b4059a170eb20ecdef4b0e82d3a1d3 --- /dev/null +++ b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/util/ConvertXmlUtil.ets @@ -0,0 +1,92 @@ +/* + * Copyright (c) 2023 Huawei Device 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 ConvertXML from '@ohos.convertxml'; +import xml from '@ohos.xml'; +import { logger } from '@ohos/common/src/main/ets/util/Logger'; + +const TAG: string = 'ConvertXmlUtil'; + +export function serializerNode(): string { + let arrayBuffer = new ArrayBuffer(1024); + let serializer = new xml.XmlSerializer(arrayBuffer); + serializer.setDeclaration(); + serializer.setNamespace('h', 'https://gitee.com/openharmony'); + serializer.startElement('note'); + serializer.setAttributes('importance', 'high'); + serializer.addEmptyElement('b'); + serializer.setComment('contact information'); + serializer.setText('ZhangSan 18712345678'); + serializer.setCDATA('CData'); + serializer.setDocType('DocType'); + serializer.endElement(); + let array = new Uint8Array(arrayBuffer); + let serializerStr = ''; + for (let i = 0; i < array.length; ++i) { + serializerStr = serializerStr + String.fromCodePoint(array[i]); + } + return serializerStr; +} + +export function parserNode(input: string): string { + let arrayBuffer = new ArrayBuffer(input.length * 2); + let bufView = new Uint8Array(arrayBuffer); + let strLen = input.length; + for (let k = 0; k < strLen; ++k) { + bufView[k] = input.charCodeAt(k); + } + let parser = new xml.XmlPullParser(arrayBuffer); + let arr: Record = {}; + let i = 0; + + let func = (key: xml.EventType, info: xml.ParseInfo) => { + arr[i] = `key:${key}, value:${info.getDepth()} ${info.getColumnNumber()} ` + + `${info.getLineNumber()} ${info.getAttributeCount()} ${info.getName()} ` + + `${info.getText()} ${info.isEmptyElementTag()} ${info.isWhitespace()}\n`; + i++; + return true; + } + + let options: xml.ParseOptions = { supportDoctype: true, ignoreNameSpace: true, tokenValueCallbackFunction: func }; + parser.parse(options); + let str = ''; + for (let j = 0; j < i; ++j) { + str = str + arr[j]; + } + return str; +} + +export function convertNode(input: string): string { + logger.info(TAG, 'convertNode start'); + let options: ConvertXML.ConvertOptions = { + trim: false, + declarationKey: "_declaration", + instructionKey: "_instruction", + attributesKey: "_attributes", + textKey: "_text", + cdataKey: "_cdata", + doctypeKey: "_doctype", + commentKey: "_comment", + parentKey: "_parent", + typeKey: "_type", + nameKey: "_name", + elementsKey: "_elements" + }; + let conv = new ConvertXML.ConvertXML(); + logger.info(TAG, 'convertNode new ConvertXML'); + let result = JSON.stringify(conv.convertToJSObject(input, options)); + logger.info(TAG, `convertNode conv.convert result = ${result}`); + return JSON.stringify(result); +} diff --git a/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/util/LRUCacheUtil.ets b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/util/LRUCacheUtil.ets new file mode 100644 index 0000000000000000000000000000000000000000..12dc354b094a55c62746d7f26d53bf521744bfa8 --- /dev/null +++ b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/util/LRUCacheUtil.ets @@ -0,0 +1,85 @@ +/* + * Copyright (c) 2023 Huawei Device 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 util from '@ohos.util'; + +export let lruBuffer: util.LRUCache = new util.LRUCache(); + +export function initLRUCache(): string { + lruBuffer = new util.LRUCache(); + return getString($r('app.string.create_lru_cache')); +} + +export function getCapacity(): string { + return `capacity = ${lruBuffer.getCapacity()}`; +} + +export function updateCapacity(): string { + lruBuffer.updateCapacity(100); + return `update capacity success,capacity=${lruBuffer.getCapacity()}`; +} + +export function getCacheString(): string { + return lruBuffer.toString(); +} + +export function clear(): string { + lruBuffer.clear(); + return getString($r('app.string.clear')); +} + +export function putKeyValue(): string { + lruBuffer.put(randomString(3), randomString(5)); + return getString($r('app.string.put_success')); +} + +export function operationLog(): string { + lruBuffer.createDefault('10'); + lruBuffer.get('10'); + return `getCreateCount=${lruBuffer.getCreateCount()}\n` + + `getMissCount=${lruBuffer.getMissCount()}\n` + + `getRemovalCount=${lruBuffer.getRemovalCount()}\n` + + `getMatchCount=${lruBuffer.getMatchCount()}\n` + + `getPutCount=${lruBuffer.getPutCount()}\n`; +} + +export function getString(resource: Resource) { + let context = getContext() as common.UIAbilityContext; + let resultStr = context.resourceManager.getStringSync(resource); + return resultStr; +} + +export function randomString(length: number): string { + length = length || 32; + let string = 'abcdefhijkmnprstwxyz123456789'; + let maxLength = string.length; + let resultString = ''; + for (let i = 0; i < length; i++) { + resultString += string.charAt(Math.floor(Math.random() * maxLength)); + } + return resultString; +} + +export function getAllKeyValues(): string { + let result = ''; + let keyArr: string[] = lruBuffer.keys(); + let valueArr: string[] = lruBuffer.values(); + keyArr.forEach((key: string, index: number) => { + result += `key: ${key}, value: ${valueArr[index]}\n`; + }) + + return result; +} \ No newline at end of file diff --git a/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/util/RationalNumberUtil.ets b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/util/RationalNumberUtil.ets new file mode 100644 index 0000000000000000000000000000000000000000..7e5051ffc13418e02ddcf3a4023caea0a3b4e5b0 --- /dev/null +++ b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/util/RationalNumberUtil.ets @@ -0,0 +1,78 @@ +/* + * Copyright (c) 2023 Huawei Device 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 util from '@ohos.util'; +import { getString } from '@ohos/common/src/main/ets/util/ResourceUtil'; + +const NUMERATOR1: number = 1; +const DENOMINATOR1: number = 2; +const NUMERATOR2: number = 3; +const DENOMINATOR2: number = 4; +const RATIONAL_NUMBER1 = util.RationalNumber.parseRationalNumber(NUMERATOR1, DENOMINATOR1); +const RATIONAL_NUMBER2 = util.RationalNumber.parseRationalNumber(NUMERATOR2, DENOMINATOR2); + +export function compareTo(): string { + let result = RATIONAL_NUMBER1.compare(RATIONAL_NUMBER2) + if (result === 0) { + return getString($r('app.string.equal_to')); + } + if (result === 1) { + return getString($r('app.string.greater_than')); + } + if (result === -1) { + return getString($r('app.string.less_than')); + } + return ''; +} + +export function getValueOf(): string { + let valueOf = RATIONAL_NUMBER1.valueOf(); + return `${getString($r('app.string.rational_number_value_of'))}${valueOf}`; +} + +export function getDenominator(): string { + let numerator = RATIONAL_NUMBER1.getNumerator(); + let denominator = RATIONAL_NUMBER1.getDenominator(); + return `${getString($r('app.string.numerator'))}${numerator}, ${getString($r('app.string.denominator'))}${denominator}`; +} + +export function isZero(): string { + let isZero = RATIONAL_NUMBER1.isZero(); + console.log('ButtonComponent isZero' + isZero); + if (isZero) { + return `${getString($r('app.string.first_rational_number'))} is zero`; + } else { + return `${getString($r('app.string.first_rational_number'))} is not zero`; + } +} + +export function isNaN(): string { + let isNaN = RATIONAL_NUMBER1.isNaN(); + if (isNaN) { + return `${getString($r('app.string.first_rational_number'))} is NaN`; + } else { + return `${getString($r('app.string.first_rational_number'))} is not NaN`; + } +} + +export function isFinite(): string { + let isFinite = RATIONAL_NUMBER1.isFinite(); + if (isFinite) { + return `${getString($r('app.string.first_rational_number'))} is Finite`; + } else { + return `${getString($r('app.string.first_rational_number'))} is not Finite`; + } +} + diff --git a/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/util/UrlUtil.ets b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/util/UrlUtil.ets new file mode 100644 index 0000000000000000000000000000000000000000..a1ac820ccee104ee94c326cf9cfde0c2d17b6ab8 --- /dev/null +++ b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/util/UrlUtil.ets @@ -0,0 +1,54 @@ +/* +* Copyright (c) 2023 Huawei Device 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 url from '@ohos.url'; +import { getString } from '@ohos/common/src/main/ets/util/ResourceUtil'; + +let urlObject = url.URL.parseURL('https://gitee.com/openharmony/'); +let paramsObject = new url.URLParams(urlObject.search.slice(1)); +let nodeValue: string = 'nodeValue'; +let nodeKey: string = 'node'; +let nodeNum: number = 0; + +export function insertNode(): string { + nodeNum++; + paramsObject.append(nodeKey, nodeValue + nodeNum); + return urlObject.toString() + paramsObject.toString(); +} + +export function deleteNode(): string { + if (paramsObject.has(nodeKey)) { + paramsObject.delete(nodeKey); + nodeNum = 0; + return urlObject.toString() + paramsObject.toString(); + } else { + return "It does not exist. Please insert first"; + } +} + +export function getFirstNode(): string { + if (paramsObject.has(nodeKey)) { + let fod = paramsObject.get(nodeKey); + return fod !== null ? fod.toString() : ''; + } else { + return getString($r('app.string.please_insert')); + } +} + +export function changeValue(): string { + paramsObject.set(nodeKey, 'newValue'); + nodeNum = 0; + return urlObject.toString() + paramsObject.toString(); +} \ No newline at end of file diff --git a/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/capabilities/src/main/module.json5 b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/capabilities/src/main/module.json5 new file mode 100644 index 0000000000000000000000000000000000000000..2cff837a1f1873cb9ad84518e5b6fa847767c2ba --- /dev/null +++ b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/capabilities/src/main/module.json5 @@ -0,0 +1,25 @@ +/* + * Copyright (c) 2023 Huawei Device 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. + */ + +{ + "module": { + "name": "capabilities", + "type": "har", + "deviceTypes": [ + "default", + "tablet" + ] + } +} \ No newline at end of file diff --git a/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/capabilities/src/main/resources/base/element/color.json b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/capabilities/src/main/resources/base/element/color.json new file mode 100644 index 0000000000000000000000000000000000000000..d62691aa81f6dba76b940c6fd695aae48203d6bc --- /dev/null +++ b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/capabilities/src/main/resources/base/element/color.json @@ -0,0 +1,16 @@ +{ + "color": [ + { + "name": "text_color", + "value": "#0D9FFB" + }, + { + "name": "button_bg", + "value": "#00FFFFFF" + }, + { + "name": "bg_white", + "value": "#FFFFFF" + } + ] +} \ No newline at end of file diff --git a/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/capabilities/src/main/resources/base/element/strarray.json b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/capabilities/src/main/resources/base/element/strarray.json new file mode 100644 index 0000000000000000000000000000000000000000..e55764a28aa41be456bd22ec94be31f789e8ebdd --- /dev/null +++ b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/capabilities/src/main/resources/base/element/strarray.json @@ -0,0 +1,142 @@ +{ + "strarray": [ + { + "name": "util_menu", + "value": [ + { + "value": "StringCode (String encoding and decoding)" + }, + { + "value": "RationalNumber (RationalNumber)" + }, + { + "value": "LRUCache (Lru cache)" + }, + { + "value": "ScopeHelper (Scope judgment)" + }, + { + "value": "Base64Helper (Base64 codec)" + }, + { + "value": "TypeCheck (Type check)" + } + ] + }, + { + "name": "convert_xml_operations", + "value": [ + { + "value": "Xml Serializer" + }, + { + "value": "Xml Pull Parser" + }, + { + "value": "Xml Convert" + } + ] + }, + { + "name": "lru_cache_operations", + "value": [ + { + "value": "Initialize buffer" + }, + { + "value": "Get buffer capacity" + }, + { + "value": "Update buffer capacity" + }, + { + "value": "Get buffer string" + }, + { + "value": "Add key value pair" + }, + { + "value": "Get value with key" + }, + { + "value": "Get all key-values" + }, + { + "value": "Delete the value of key" + }, + { + "value": "Clear all key-values" + }, + { + "value": "View operation record" + } + ] + }, + { + "name": "process_operations", + "value": [ + { + "value": "Get current process rum time" + }, + { + "value": "Get process work directory" + }, + { + "value": "Change work directory" + }, + { + "value": "Start a child process" + }, + { + "value": "Close the child process" + }, + { + "value": "send signal to process" + }, + { + "value": "Exit the process" + } + ] + }, + { + "name": "rational_number_operations", + "value": [ + { + "value": "Compare rational numbers" + }, + { + "value": "Get rational number value" + }, + { + "value": "Get numerator and denominator" + }, + { + "value": "Check for zero" + }, + { + "value": "Check for NaN" + }, + { + "value": "Check for finite number" + } + ] + }, + { + "name": "url_operations", + "value": [ + { + "value": "Insert Key-value" + }, + { + "value": "Delete Key-value" + }, + { + "value": "GetFirst Key-value" + }, + { + "value": "Set new value of key" + } + ] + } + ] +} \ No newline at end of file diff --git a/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/capabilities/src/main/resources/base/element/string.json b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/capabilities/src/main/resources/base/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..f0ca7048c81c72859e39de84e272290ac446e712 --- /dev/null +++ b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/capabilities/src/main/resources/base/element/string.json @@ -0,0 +1,392 @@ +{ + "string": [ + { + "name": "page_show", + "value": "page from npm package" + }, + { + "name": "string_code", + "value": "StringCode (String encoding and decoding)" + }, + { + "name": "rational_number", + "value": "RationalNumber (RationalNumber)" + }, + { + "name": "lru_cache", + "value": "LRUCache (Lru cache)" + }, + { + "name": "scope_helper", + "value": "ScopeHelper (Scope judgment)" + }, + { + "name": "base64", + "value": "Base64Helper (Base64 codec)" + }, + { + "name": "type_check", + "value": "TypeCheck (Type check)" + }, + { + "name": "create_lru_cache", + "value": "create LruCache success" + }, + { + "name": "put_success", + "value": "put success" + }, + { + "name": "clear", + "value": "clear success" + }, + { + "name": "success", + "value": "success" + }, + { + "name": "close_success", + "value": "close success" + }, + { + "name": "child_null", + "value": "child process is null" + }, + { + "name": "failed", + "value": "failed" + }, + { + "name": "change_str", + "value": "String to convert:" + }, + { + "name": "encode", + "value": "encode" + }, + { + "name": "decode", + "value": "decode" + }, + { + "name": "SpecString", + "value": "specString:" + }, + { + "name": "SpecString_info", + "value": "OpenHarmony 3.0" + }, + { + "name": "result", + "value": "result = " + }, + { + "name": "result_f", + "value": "result[%f] = " + }, + { + "name": "result_i", + "value": "result[%i] = " + }, + { + "name": "result_d", + "value": "result[%d] = " + }, + { + "name": "result_s", + "value": "result[%s] = " + }, + { + "name": "SpecFormOutput", + "value": "specific format output" + }, + { + "name": "StringCodec_info", + "value": "OpenHarmony 3.0 has a track to follow in the future!" + }, + { + "name": "read", + "value": "read:" + }, + { + "name": "write", + "value": "write:" + }, + { + "name": "Text_encoder", + "value": "text encoder" + }, + { + "name": "Text_decoder", + "value": "text decoder" + }, + { + "name": "message", + "value": "OpenHarmony 3.0 has a track to follow in the future!" + }, + { + "name": "numerator", + "value": "Numerator:" + }, + { + "name": "denominator", + "value": "Denominator:" + }, + { + "name": "first_rational_number", + "value": "FirstRationalNumber" + }, + { + "name": "second_rational_number", + "value": "SecondRationalNumber" + }, + { + "name": "less_than", + "value": "FirstRationalNumber id less than SecondRationalNumber" + }, + { + "name": "equal_to", + "value": "FirstRationalNumber id equal to SecondRationalNumber" + }, + { + "name": "greater_than", + "value": "FirstRationalNumber id greater than SecondRationalNumber" + }, + { + "name": "rational_number_value_of", + "value": "The value of the rational number 1 obtained as an integer or as a floating-point number is" + }, + { + "name": "show", + "value": "Display preset value" + }, + { + "name": "check", + "value": "Check preset value" + }, + { + "name": "age", + "value": "Age judgment" + }, + { + "name": "temperature", + "value": "Temperature detection" + }, + { + "name": "range", + "value": "Range judgment" + }, + { + "name": "judge_age", + "value": "Determine whether the age is within the limit" + }, + { + "name": "age_analyse", + "value": "Age analysis" + }, + { + "name": "judge_temp", + "value": "Judge whether your temperature is normal" + }, + { + "name": "temp_morning", + "value": "What's your temperature in the morning:" + }, + { + "name": "temp_noon", + "value": "What's your temperature at noon:" + }, + { + "name": "temp_night", + "value": "What's your temperature at night:" + }, + { + "name": "temp_min", + "value": "Your minimum temperature today is" + }, + { + "name": "temp_max", + "value": "Your maximum temperature today is" + }, + { + "name": "temp_normal_range", + "value": "Your temperature is in the normal range" + }, + { + "name": "judge_sleep", + "value": "Judge whether you have enough sleep:" + }, + { + "name": "short_sleep", + "value": "What is your shortest sleep time this month:" + }, + { + "name": "long_sleep", + "value": "What is your longest sleep time this month:" + }, + { + "name": "sleep_analyse", + "value": "Sleep analysis" + }, + { + "name": "sleep_time", + "value": "*A person's normal sleep time is 7 to 10 hours" + }, + { + "name": "temp_analyse", + "value": "Temperature analysis" + }, + { + "name": "determine", + "value": "determine" + }, + { + "name": "age_message_confirm", + "value": "Your age meets the requirements" + }, + { + "name": "age_message_not_confirm", + "value": "Sorry, your age doesn't meet the requirements" + }, + { + "name": "temp_message_lower", + "value": "What's your minimum temperature today" + }, + { + "name": "temp_message_upper", + "value": "What's your maximum temperature today" + }, + { + "name": "temp_message_normal", + "value": "Your temperature is in the normal range" + }, + { + "name": "temp_message_abnormal", + "value": "Your temperature is abnormal today. Please see a doctor as soon as possible and pay attention to your health!" + }, + { + "name": "combine", + "value": "The sleep interval and the normal sleep interval are combined as" + }, + { + "name": "interval", + "value": "The intersection of sleep interval and normal sleep interval is" + }, + { + "name": "age_placeholder", + "value": "Please enter your age" + }, + { + "name": "morning_placeholder", + "value": "Please enter your morning temperature" + }, + { + "name": "noon_placeholder", + "value": "Please enter your temperature at noon" + }, + { + "name": "night_placeholder", + "value": "Please enter your temperature at night" + }, + { + "name": "enter_sleep_time", + "value": "Please enter sleep time" + }, + { + "name": "upper", + "value": "37" + }, + { + "name": "scope_temp_tips", + "value": "Please make sure that you enter your body temperature for all three time periods and that your body temperature is greater than 0" + }, + { + "name": "scope_sleep_tips", + "value": "Please enter the minimum and maximum sleep time" + }, + { + "name": "scope_sleep_tips_less", + "value": "The maximum sleep time is less than or equal to the minimum sleep time, please re-enter" + }, + { + "name": "scope_expand", + "value": "The union of the sleep interval and the normal sleep interval is" + }, + { + "name": "scope_intersect", + "value": "The intersection of the sleep zone and the normal sleep zone is" + }, + { + "name": "empty", + "value": "empty" + }, + { + "name": "please_insert", + "value": "It does not exist. Insert key-value pair first." + }, + { + "name": "contact_name", + "value": "Name:" + }, + { + "name": "contact_age", + "value": "Age:" + }, + { + "name": "contact_phone", + "value": "Phone:" + }, + { + "name": "button_delete", + "value": "Delete" + }, + { + "name": "button_confirm", + "value": "OK" + }, + { + "name": "button_cancel", + "value": "Cancel" + }, + { + "name": "contact_information", + "value": "Contact Information" + }, + { + "name": "input_name", + "value": "Enter a name" + }, + { + "name": "input_age", + "value": "Enter the age" + }, + { + "name": "input_phone", + "value": "Enter a phone" + }, + { + "name": "name_null", + "value": "The name cannot be empty" + }, + { + "name": "age_null", + "value": "The age cannot be empty" + }, + { + "name": "phone_null", + "value": "The phone number cannot be empty" + }, + { + "name": "click_exec_add_one", + "value": "Click execute task to make numberOfExecutions++" + }, + { + "name": "old", + "value": "years old" + }, + { + "name": "key_limit", + "value": "key must be a number" + } + ] +} diff --git a/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/capabilities/src/main/resources/base/media/bg_empty_page.svg b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/capabilities/src/main/resources/base/media/bg_empty_page.svg new file mode 100644 index 0000000000000000000000000000000000000000..038a4c3caab2d07cc7db6d699cd2b3f24bd67bd1 --- /dev/null +++ b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/capabilities/src/main/resources/base/media/bg_empty_page.svg @@ -0,0 +1,104 @@ + + + + + + + + + + + + + + + + + + + + + + diff --git a/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/capabilities/src/main/resources/base/media/contact.png b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/capabilities/src/main/resources/base/media/contact.png new file mode 100644 index 0000000000000000000000000000000000000000..705a27f8c2dd9d962bbcc1b8c24aa6fcd34103d3 Binary files /dev/null and b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/capabilities/src/main/resources/base/media/contact.png differ diff --git a/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/capabilities/src/main/resources/base/media/ic_add.png b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/capabilities/src/main/resources/base/media/ic_add.png new file mode 100644 index 0000000000000000000000000000000000000000..fe1f93dfe0882b204163603401ec9f441017f062 Binary files /dev/null and b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/capabilities/src/main/resources/base/media/ic_add.png differ diff --git a/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/capabilities/src/main/resources/base/media/ic_delete_plane.svg b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/capabilities/src/main/resources/base/media/ic_delete_plane.svg new file mode 100644 index 0000000000000000000000000000000000000000..f2d283d4b54d554a0936ad0530a78a7e17c844d7 --- /dev/null +++ b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/capabilities/src/main/resources/base/media/ic_delete_plane.svg @@ -0,0 +1,16 @@ + + + + + + + diff --git a/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/capabilities/src/main/resources/en_US/element/strarray.json b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/capabilities/src/main/resources/en_US/element/strarray.json new file mode 100644 index 0000000000000000000000000000000000000000..e55764a28aa41be456bd22ec94be31f789e8ebdd --- /dev/null +++ b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/capabilities/src/main/resources/en_US/element/strarray.json @@ -0,0 +1,142 @@ +{ + "strarray": [ + { + "name": "util_menu", + "value": [ + { + "value": "StringCode (String encoding and decoding)" + }, + { + "value": "RationalNumber (RationalNumber)" + }, + { + "value": "LRUCache (Lru cache)" + }, + { + "value": "ScopeHelper (Scope judgment)" + }, + { + "value": "Base64Helper (Base64 codec)" + }, + { + "value": "TypeCheck (Type check)" + } + ] + }, + { + "name": "convert_xml_operations", + "value": [ + { + "value": "Xml Serializer" + }, + { + "value": "Xml Pull Parser" + }, + { + "value": "Xml Convert" + } + ] + }, + { + "name": "lru_cache_operations", + "value": [ + { + "value": "Initialize buffer" + }, + { + "value": "Get buffer capacity" + }, + { + "value": "Update buffer capacity" + }, + { + "value": "Get buffer string" + }, + { + "value": "Add key value pair" + }, + { + "value": "Get value with key" + }, + { + "value": "Get all key-values" + }, + { + "value": "Delete the value of key" + }, + { + "value": "Clear all key-values" + }, + { + "value": "View operation record" + } + ] + }, + { + "name": "process_operations", + "value": [ + { + "value": "Get current process rum time" + }, + { + "value": "Get process work directory" + }, + { + "value": "Change work directory" + }, + { + "value": "Start a child process" + }, + { + "value": "Close the child process" + }, + { + "value": "send signal to process" + }, + { + "value": "Exit the process" + } + ] + }, + { + "name": "rational_number_operations", + "value": [ + { + "value": "Compare rational numbers" + }, + { + "value": "Get rational number value" + }, + { + "value": "Get numerator and denominator" + }, + { + "value": "Check for zero" + }, + { + "value": "Check for NaN" + }, + { + "value": "Check for finite number" + } + ] + }, + { + "name": "url_operations", + "value": [ + { + "value": "Insert Key-value" + }, + { + "value": "Delete Key-value" + }, + { + "value": "GetFirst Key-value" + }, + { + "value": "Set new value of key" + } + ] + } + ] +} \ No newline at end of file diff --git a/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/capabilities/src/main/resources/en_US/element/string.json b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/capabilities/src/main/resources/en_US/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..f0ca7048c81c72859e39de84e272290ac446e712 --- /dev/null +++ b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/capabilities/src/main/resources/en_US/element/string.json @@ -0,0 +1,392 @@ +{ + "string": [ + { + "name": "page_show", + "value": "page from npm package" + }, + { + "name": "string_code", + "value": "StringCode (String encoding and decoding)" + }, + { + "name": "rational_number", + "value": "RationalNumber (RationalNumber)" + }, + { + "name": "lru_cache", + "value": "LRUCache (Lru cache)" + }, + { + "name": "scope_helper", + "value": "ScopeHelper (Scope judgment)" + }, + { + "name": "base64", + "value": "Base64Helper (Base64 codec)" + }, + { + "name": "type_check", + "value": "TypeCheck (Type check)" + }, + { + "name": "create_lru_cache", + "value": "create LruCache success" + }, + { + "name": "put_success", + "value": "put success" + }, + { + "name": "clear", + "value": "clear success" + }, + { + "name": "success", + "value": "success" + }, + { + "name": "close_success", + "value": "close success" + }, + { + "name": "child_null", + "value": "child process is null" + }, + { + "name": "failed", + "value": "failed" + }, + { + "name": "change_str", + "value": "String to convert:" + }, + { + "name": "encode", + "value": "encode" + }, + { + "name": "decode", + "value": "decode" + }, + { + "name": "SpecString", + "value": "specString:" + }, + { + "name": "SpecString_info", + "value": "OpenHarmony 3.0" + }, + { + "name": "result", + "value": "result = " + }, + { + "name": "result_f", + "value": "result[%f] = " + }, + { + "name": "result_i", + "value": "result[%i] = " + }, + { + "name": "result_d", + "value": "result[%d] = " + }, + { + "name": "result_s", + "value": "result[%s] = " + }, + { + "name": "SpecFormOutput", + "value": "specific format output" + }, + { + "name": "StringCodec_info", + "value": "OpenHarmony 3.0 has a track to follow in the future!" + }, + { + "name": "read", + "value": "read:" + }, + { + "name": "write", + "value": "write:" + }, + { + "name": "Text_encoder", + "value": "text encoder" + }, + { + "name": "Text_decoder", + "value": "text decoder" + }, + { + "name": "message", + "value": "OpenHarmony 3.0 has a track to follow in the future!" + }, + { + "name": "numerator", + "value": "Numerator:" + }, + { + "name": "denominator", + "value": "Denominator:" + }, + { + "name": "first_rational_number", + "value": "FirstRationalNumber" + }, + { + "name": "second_rational_number", + "value": "SecondRationalNumber" + }, + { + "name": "less_than", + "value": "FirstRationalNumber id less than SecondRationalNumber" + }, + { + "name": "equal_to", + "value": "FirstRationalNumber id equal to SecondRationalNumber" + }, + { + "name": "greater_than", + "value": "FirstRationalNumber id greater than SecondRationalNumber" + }, + { + "name": "rational_number_value_of", + "value": "The value of the rational number 1 obtained as an integer or as a floating-point number is" + }, + { + "name": "show", + "value": "Display preset value" + }, + { + "name": "check", + "value": "Check preset value" + }, + { + "name": "age", + "value": "Age judgment" + }, + { + "name": "temperature", + "value": "Temperature detection" + }, + { + "name": "range", + "value": "Range judgment" + }, + { + "name": "judge_age", + "value": "Determine whether the age is within the limit" + }, + { + "name": "age_analyse", + "value": "Age analysis" + }, + { + "name": "judge_temp", + "value": "Judge whether your temperature is normal" + }, + { + "name": "temp_morning", + "value": "What's your temperature in the morning:" + }, + { + "name": "temp_noon", + "value": "What's your temperature at noon:" + }, + { + "name": "temp_night", + "value": "What's your temperature at night:" + }, + { + "name": "temp_min", + "value": "Your minimum temperature today is" + }, + { + "name": "temp_max", + "value": "Your maximum temperature today is" + }, + { + "name": "temp_normal_range", + "value": "Your temperature is in the normal range" + }, + { + "name": "judge_sleep", + "value": "Judge whether you have enough sleep:" + }, + { + "name": "short_sleep", + "value": "What is your shortest sleep time this month:" + }, + { + "name": "long_sleep", + "value": "What is your longest sleep time this month:" + }, + { + "name": "sleep_analyse", + "value": "Sleep analysis" + }, + { + "name": "sleep_time", + "value": "*A person's normal sleep time is 7 to 10 hours" + }, + { + "name": "temp_analyse", + "value": "Temperature analysis" + }, + { + "name": "determine", + "value": "determine" + }, + { + "name": "age_message_confirm", + "value": "Your age meets the requirements" + }, + { + "name": "age_message_not_confirm", + "value": "Sorry, your age doesn't meet the requirements" + }, + { + "name": "temp_message_lower", + "value": "What's your minimum temperature today" + }, + { + "name": "temp_message_upper", + "value": "What's your maximum temperature today" + }, + { + "name": "temp_message_normal", + "value": "Your temperature is in the normal range" + }, + { + "name": "temp_message_abnormal", + "value": "Your temperature is abnormal today. Please see a doctor as soon as possible and pay attention to your health!" + }, + { + "name": "combine", + "value": "The sleep interval and the normal sleep interval are combined as" + }, + { + "name": "interval", + "value": "The intersection of sleep interval and normal sleep interval is" + }, + { + "name": "age_placeholder", + "value": "Please enter your age" + }, + { + "name": "morning_placeholder", + "value": "Please enter your morning temperature" + }, + { + "name": "noon_placeholder", + "value": "Please enter your temperature at noon" + }, + { + "name": "night_placeholder", + "value": "Please enter your temperature at night" + }, + { + "name": "enter_sleep_time", + "value": "Please enter sleep time" + }, + { + "name": "upper", + "value": "37" + }, + { + "name": "scope_temp_tips", + "value": "Please make sure that you enter your body temperature for all three time periods and that your body temperature is greater than 0" + }, + { + "name": "scope_sleep_tips", + "value": "Please enter the minimum and maximum sleep time" + }, + { + "name": "scope_sleep_tips_less", + "value": "The maximum sleep time is less than or equal to the minimum sleep time, please re-enter" + }, + { + "name": "scope_expand", + "value": "The union of the sleep interval and the normal sleep interval is" + }, + { + "name": "scope_intersect", + "value": "The intersection of the sleep zone and the normal sleep zone is" + }, + { + "name": "empty", + "value": "empty" + }, + { + "name": "please_insert", + "value": "It does not exist. Insert key-value pair first." + }, + { + "name": "contact_name", + "value": "Name:" + }, + { + "name": "contact_age", + "value": "Age:" + }, + { + "name": "contact_phone", + "value": "Phone:" + }, + { + "name": "button_delete", + "value": "Delete" + }, + { + "name": "button_confirm", + "value": "OK" + }, + { + "name": "button_cancel", + "value": "Cancel" + }, + { + "name": "contact_information", + "value": "Contact Information" + }, + { + "name": "input_name", + "value": "Enter a name" + }, + { + "name": "input_age", + "value": "Enter the age" + }, + { + "name": "input_phone", + "value": "Enter a phone" + }, + { + "name": "name_null", + "value": "The name cannot be empty" + }, + { + "name": "age_null", + "value": "The age cannot be empty" + }, + { + "name": "phone_null", + "value": "The phone number cannot be empty" + }, + { + "name": "click_exec_add_one", + "value": "Click execute task to make numberOfExecutions++" + }, + { + "name": "old", + "value": "years old" + }, + { + "name": "key_limit", + "value": "key must be a number" + } + ] +} diff --git a/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/capabilities/src/main/resources/zh_CN/element/strarray.json b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/capabilities/src/main/resources/zh_CN/element/strarray.json new file mode 100644 index 0000000000000000000000000000000000000000..371dbce80cb96e782df96cf2eb71d2b7f6c00e3f --- /dev/null +++ b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/capabilities/src/main/resources/zh_CN/element/strarray.json @@ -0,0 +1,142 @@ +{ + "strarray": [ + { + "name": "util_menu", + "value": [ + { + "value": "StringCode (字符串编解码)" + }, + { + "value": "RationalNumber (有理数)" + }, + { + "value": "LRUCache (缓冲区)" + }, + { + "value": "ScopeHelper (范围判断)" + }, + { + "value": "Base64Helper (Base64编解码)" + }, + { + "value": "TypeCheck (类型检查)" + } + ] + }, + { + "name": "convert_xml_operations", + "value": [ + { + "value": "Xml 生成" + }, + { + "value": "Xml 解析" + }, + { + "value": "Xml 转换" + } + ] + }, + { + "name": "lru_cache_operations", + "value": [ + { + "value": "初始化缓冲区" + }, + { + "value": "获取缓冲区容量" + }, + { + "value": "更新缓冲区容量" + }, + { + "value": "获取缓冲区字符串" + }, + { + "value": "添加键值对" + }, + { + "value": "获取键对应的值" + }, + { + "value": "获取所有键值对" + }, + { + "value": "删除指定键及关联值" + }, + { + "value": "清除所有键值对" + }, + { + "value": "查看操作记录" + } + ] + }, + { + "name": "process_operations", + "value": [ + { + "value": "获取当前系统运行时间" + }, + { + "value": "获取进程当前工作目录" + }, + { + "value": "更改进程当前工作目录" + }, + { + "value": "启动一个子进程" + }, + { + "value": "关闭子进程" + }, + { + "value": "发送signal到指定的进程" + }, + { + "value": "退出当前进程" + } + ] + }, + { + "name": "rational_number_operations", + "value": [ + { + "value": "有理数比较" + }, + { + "value": "获取有理数的值" + }, + { + "value": "获取有理数分子分母" + }, + { + "value": "检查是否为0" + }, + { + "value": "检查是否表示NaN" + }, + { + "value": "检查是否为有限值" + } + ] + }, + { + "name": "url_operations", + "value": [ + { + "value": "插入键值对到查询字符串" + }, + { + "value": "删除键值对" + }, + { + "value": "获取指定名称对应的第一个值" + }, + { + "value": "设置键的新值" + } + ] + } + ] +} \ No newline at end of file diff --git a/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/capabilities/src/main/resources/zh_CN/element/string.json b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/capabilities/src/main/resources/zh_CN/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..1e50719464441db7478287dd3c560a91471415d4 --- /dev/null +++ b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/capabilities/src/main/resources/zh_CN/element/string.json @@ -0,0 +1,392 @@ +{ + "string": [ + { + "name": "page_show", + "value": "page from npm package" + }, + { + "name": "string_code", + "value": "StringCode (字符串编解码)" + }, + { + "name": "rational_number", + "value": "RationalNumber (有理数)" + }, + { + "name": "lru_cache", + "value": "LRUCache (缓冲区)" + }, + { + "name": "scope_helper", + "value": "ScopeHelper (范围判断)" + }, + { + "name": "base64", + "value": "Base64Helper (Base64编解码)" + }, + { + "name": "type_check", + "value": "TypeCheck (类型检查)" + }, + { + "name": "create_lru_cache", + "value": "创建LruCache成功" + }, + { + "name": "put_success", + "value": "添加成功" + }, + { + "name": "clear", + "value": "清除缓冲区成功" + }, + { + "name": "success", + "value": "成功" + }, + { + "name": "close_success", + "value": "关闭成功" + }, + { + "name": "child_null", + "value": "子进程为空" + }, + { + "name": "failed", + "value": "失败" + }, + { + "name": "change_str", + "value": "要转换的字符串:" + }, + { + "name": "encode", + "value": "编码" + }, + { + "name": "decode", + "value": "解码" + }, + { + "name": "SpecString", + "value": "字符串 : " + }, + { + "name": "SpecString_info", + "value": "OpenHarmony 3.0" + }, + { + "name": "result", + "value": "result = " + }, + { + "name": "result_f", + "value": "result[%f] = " + }, + { + "name": "result_i", + "value": "result[%i] = " + }, + { + "name": "result_d", + "value": "result[%d] = " + }, + { + "name": "result_s", + "value": "result[%s] = " + }, + { + "name": "SpecFormOutput", + "value": "特定格式输出" + }, + { + "name": "StringCodec_info", + "value": "OpenHarmony 3.0,未来有迹可循!" + }, + { + "name": "read", + "value": "读取:" + }, + { + "name": "write", + "value": "写入:" + }, + { + "name": "Text_encoder", + "value": "文本编码器" + }, + { + "name": "Text_decoder", + "value": "文本译码器" + }, + { + "name": "message", + "value": "OpenHarmony 3.0,未来有迹可循!" + }, + { + "name": "numerator", + "value": "分子:" + }, + { + "name": "denominator", + "value": "分母:" + }, + { + "name": "first_rational_number", + "value": "有理数1" + }, + { + "name": "second_rational_number", + "value": "有理数2" + }, + { + "name": "less_than", + "value": "有理数1小于有理数2" + }, + { + "name": "equal_to", + "value": "有理数1等于有理数2" + }, + { + "name": "greater_than", + "value": "有理数1大于有理数2" + }, + { + "name": "rational_number_value_of", + "value": "以整数形式或者浮点数的形式获取有理数1的值是" + }, + { + "name": "show", + "value": "显示预置值" + }, + { + "name": "check", + "value": "校验预置值" + }, + { + "name": "age", + "value": "年龄判断" + }, + { + "name": "temperature", + "value": "体温检测" + }, + { + "name": "range", + "value": "范围判断" + }, + { + "name": "judge_age", + "value": "判断年龄是否在限制内" + }, + { + "name": "age_analyse", + "value": "年龄分析" + }, + { + "name": "judge_temp", + "value": "判断您的体温是否正常" + }, + { + "name": "temp_morning", + "value": "您早上的体温是:" + }, + { + "name": "temp_noon", + "value": "您中午的体温是:" + }, + { + "name": "temp_night", + "value": "您晚上的体温是:" + }, + { + "name": "temp_min", + "value": "您今天的最低体温是" + }, + { + "name": "temp_max", + "value": "您今天的最高体温是" + }, + { + "name": "temp_normal_range", + "value": "您的体温在正常范围" + }, + { + "name": "judge_sleep", + "value": "判断您的睡眠是否充足:" + }, + { + "name": "short_sleep", + "value": "这一个月,您最短的睡眠时间是几小时:" + }, + { + "name": "long_sleep", + "value": "这一个月,您最长的睡眠时间是几小时:" + }, + { + "name": "sleep_analyse", + "value": "睡眠分析" + }, + { + "name": "sleep_time", + "value": "*人的正常睡眠时间是7到10个小时" + }, + { + "name": "temp_analyse", + "value": "体温分析" + }, + { + "name": "determine", + "value": "确定" + }, + { + "name": "age_message_confirm", + "value": "您的年龄符合规定" + }, + { + "name": "age_message_not_confirm", + "value": "对不起,您的年龄不符合规定" + }, + { + "name": "temp_message_lower", + "value": "您今天的最低体温是" + }, + { + "name": "temp_message_upper", + "value": "您今天的最高体温是" + }, + { + "name": "temp_message_normal", + "value": "您的体温在正常范围" + }, + { + "name": "temp_message_abnormal", + "value": "您今天的体温不正常,还望您尽快就医,注意身体!" + }, + { + "name": "combine", + "value": "睡眠区间和正常的睡眠区间的并集为" + }, + { + "name": "interval", + "value": "睡眠区间和正常的睡眠区间的交集为" + }, + { + "name": "age_placeholder", + "value": "请输入您的年龄" + }, + { + "name": "morning_placeholder", + "value": "请输入您早上的体温" + }, + { + "name": "noon_placeholder", + "value": "请输入您中午的体温" + }, + { + "name": "night_placeholder", + "value": "请输入您晚上的体温" + }, + { + "name": "enter_sleep_time", + "value": "请输入睡眠时间" + }, + { + "name": "upper", + "value": "37" + }, + { + "name": "scope_temp_tips", + "value": "请确认输入三个时间段的体温,且体温均大于0" + }, + { + "name": "scope_sleep_tips", + "value": "请输入最长和最短睡眠时间" + }, + { + "name": "scope_sleep_tips_less", + "value": "最长睡眠时间小于或等于最短睡眠时间,请重新输入" + }, + { + "name": "scope_expand", + "value": "睡眠区间和正常的睡眠区间的并集为" + }, + { + "name": "scope_intersect", + "value": "T睡眠区间和正常的睡眠区间的交集为" + }, + { + "name": "empty", + "value": "空" + }, + { + "name": "please_insert", + "value": "不存在,请先插入." + }, + { + "name": "contact_name", + "value": "姓名:" + }, + { + "name": "contact_age", + "value": "年龄:" + }, + { + "name": "contact_phone", + "value": "电话:" + }, + { + "name": "button_delete", + "value": "删除" + }, + { + "name": "button_confirm", + "value": "确认" + }, + { + "name": "button_cancel", + "value": "取消" + }, + { + "name": "contact_information", + "value": "联系人信息" + }, + { + "name": "input_name", + "value": "请输入姓名" + }, + { + "name": "input_age", + "value": "请输入年龄" + }, + { + "name": "input_phone", + "value": "请输入电话" + }, + { + "name": "name_null", + "value": "姓名不能为空" + }, + { + "name": "age_null", + "value": "年龄不能为空" + }, + { + "name": "phone_null", + "value": "电话号码不能为空" + }, + { + "name": "click_exec_add_one", + "value": "点击execute task使numberOfExecutions++" + }, + { + "name": "old", + "value": "岁" + }, + { + "name": "key_limit", + "value": "key必须为数字" + } + ] +} diff --git a/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/menuitems/.gitignore b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/menuitems/.gitignore new file mode 100644 index 0000000000000000000000000000000000000000..5a6ba80fa3d9498a23ae8ae7d9518f8743fa8a96 --- /dev/null +++ b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/menuitems/.gitignore @@ -0,0 +1,4 @@ +/node_modules +/.preview +/build +/.cxx \ No newline at end of file diff --git a/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/menuitems/build-profile.json5 b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/menuitems/build-profile.json5 new file mode 100644 index 0000000000000000000000000000000000000000..12fe2d844bdb69584fd05ebaa3e1cb197a25c3f1 --- /dev/null +++ b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/menuitems/build-profile.json5 @@ -0,0 +1,25 @@ +/* + * Copyright (c) 2023 Huawei Device 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. + */ + +{ + "apiType": "stageMode", + "buildOption": { + }, + "targets": [ + { + "name": "default" + } + ] +} diff --git a/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/menuitems/hvigorfile.ts b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/menuitems/hvigorfile.ts new file mode 100644 index 0000000000000000000000000000000000000000..6522df25794b80abde0b0aa8654f3970c4a35cfa --- /dev/null +++ b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/menuitems/hvigorfile.ts @@ -0,0 +1,16 @@ +/** + * Copyright (c) 2023 Huawei Device 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. + */ +// Script for compiling build behavior. It is built in the build plug-in and cannot be modified currently. +export { harTasks } from '@ohos/hvigor-ohos-plugin'; \ No newline at end of file diff --git a/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/menuitems/index.ets b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/menuitems/index.ets new file mode 100644 index 0000000000000000000000000000000000000000..4bf4e3a769b3ca072777bf2cbf56ccd1615a07bb --- /dev/null +++ b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/menuitems/index.ets @@ -0,0 +1,18 @@ +/* + * Copyright (c) 2023 Huawei Device 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. + */ + +export { MenuList } from './src/main/ets/menulist/MenuList'; + +export { MenuNavRouter } from './src/main/ets/components/MenuNavRouter'; diff --git a/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/menuitems/oh-package.json5 b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/menuitems/oh-package.json5 new file mode 100644 index 0000000000000000000000000000000000000000..e6ebdefa6c9f787dd38f8fd8b10f43ed1db852dd --- /dev/null +++ b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/menuitems/oh-package.json5 @@ -0,0 +1,27 @@ +/* + * Copyright (c) 2023 Huawei Device 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. + */ + +{ + "license": "ISC", + "types": "", + "devDependencies": {}, + "name": "menuitems", + "description": "a npm package which contains arkUI2.0 page", + "main": "index.ets", + "version": "1.0.0", + "dependencies": { + "@ohos/common": "file:../../common" + } +} diff --git a/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/menuitems/src/main/ets/components/ItemGroup.ets b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/menuitems/src/main/ets/components/ItemGroup.ets new file mode 100644 index 0000000000000000000000000000000000000000..9a483d10cde5d1d930a66416f4025ec917a98082 --- /dev/null +++ b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/menuitems/src/main/ets/components/ItemGroup.ets @@ -0,0 +1,30 @@ +/** + * Copyright (c) 2023 Huawei Device 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. + */ + +@Component +export struct ItemGroup { + @BuilderParam noParam: () => void; + + build() { + Column() { + this.noParam() + } + .width('100%') + .borderRadius(24) + .backgroundColor($r('sys.color.ohos_id_color_foreground_contrary')) + .padding(4) + .margin({ bottom: 12 }) + } +} \ No newline at end of file diff --git a/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/menuitems/src/main/ets/components/MainItem.ets b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/menuitems/src/main/ets/components/MainItem.ets new file mode 100644 index 0000000000000000000000000000000000000000..d9051ac740a123d5c969c569d8f4f2c10681163c --- /dev/null +++ b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/menuitems/src/main/ets/components/MainItem.ets @@ -0,0 +1,55 @@ +/** + * Copyright (c) 2023 Huawei Device 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. + */ + +@Component +export struct MainItem { + private title: string | Resource = ''; + @LocalStorageProp('isSplitMode') isSplitMode: boolean = false; + @State isTouched: boolean = false; + + build() { + Row() { + Text(this.title) + .fontSize(16) + .lineHeight(22) + .fontWeight(FontWeight.Medium) + .fontFamily('HarmonyHeiTi') + .fontColor($r('sys.color.ohos_id_color_text_primary')) + .align(Alignment.Start) + .margin({ left: 16 }) + + Blank() + + Image($r('app.media.ic_arrow')) + .width(12) + .height(24) + .margin({ left: 4 }) + .fillColor($r('sys.color.ohos_id_color_fourth')) + } + .alignItems(VerticalAlign.Center) + .width('100%') + .height(56) + .borderRadius(20) + .padding({ left: 8, right: 8 }) + .backgroundColor(this.isTouched ? $r('app.color.itemActivated') : $r('app.color.itemInactivated')) + .onTouch((event: TouchEvent) => { + if (event.type === TouchType.Down) { + this.isTouched = true; + } else if (event.type === TouchType.Up) { + this.isTouched = false; + } + }) + } +} \ No newline at end of file diff --git a/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/menuitems/src/main/ets/components/MenuNavRouter.ets b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/menuitems/src/main/ets/components/MenuNavRouter.ets new file mode 100644 index 0000000000000000000000000000000000000000..7f0bcc43562ec6a5b3a631e750855e0b970ac882 --- /dev/null +++ b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/menuitems/src/main/ets/components/MenuNavRouter.ets @@ -0,0 +1,134 @@ +/** + * Copyright (c) 2023 Huawei Device 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 { ItemGroup } from './ItemGroup'; +import { logger } from '@ohos/common/src/main/ets/util/Logger'; +import { getString } from '@ohos/common/src/main/ets/util/ResourceUtil'; +import { MainItem } from './MainItem'; + +const TAG: string = 'MenuNavRouter'; + +@Component +export struct MenuNavRouter { + @StorageLink('selectedLabel') selectedLabel: string = ''; + @StorageLink('selectedSecondLabel') selectedSecondLabel: string = ''; + @BuilderParam navDestination: () => void; + private childList: Array = []; + private addAction?: (title: string) => void; + + @Builder CustomDivider() { + Divider() + .strokeWidth('1px') + .color($r('sys.color.ohos_id_color_list_separator')) + .margin({ left: 8, right: 8 }) + } + + build() { + ItemGroup() { + Column() { + ForEach(this.childList, (item: string, index: number) => { + if (index > 0) { + this.CustomDivider() + } + NavRouter() { + MainItem({ + title: item + }) + NavDestination() { + this.navDestination() + } + .title(this.CustomTitle(item)) + .backgroundColor($r('sys.color.ohos_id_color_sub_background')) + } + .onStateChange((isActivated: boolean) => { + // 组件激活状态切换时 + if (isActivated) { + // 点击一级路由菜单进入时 + if (this.addAction) { + this.selectedLabel = item; + logger.info(TAG, `NavRouter isActivated= ${isActivated}, selectedLabel=${item}`); + } + // 点击二级路由菜单进入时 + else { + this.selectedSecondLabel = item; + logger.info(TAG, `NavRouter isActivated= ${isActivated}, selectedSecondLabel=${item}`); + } + } + }) + }, (item: string) => JSON.stringify(item)) + } + } + } + + @Builder + CustomTitle(title: string) { + Row() { + Text(title) + .fontColor($r('app.color.black')) + .fontSize(16) + .fontWeight(FontWeight.Bold) + + Row() { + Image($r('app.media.ic_public_add')) + .height(24) + .aspectRatio(1) + .objectFit(ImageFit.Contain) + } + .id('add') + .height('100%') + .aspectRatio(1) + .visibility(this.showAddButton(title) ? Visibility.Visible : Visibility.None) + .onClick(() => { + logger.info(TAG, 'addAction') + if (this.addAction) { + this.addAction(title) + } + }) + } + .width('85%') + .height(56) + .justifyContent(FlexAlign.SpaceBetween) + } + + showAddButton(title: string) { + let ret = false + switch (title) { + case getString($r('app.string.deque')): + case getString($r('app.string.hash_map')): + case getString($r('app.string.hash_set')): + case getString($r('app.string.light_weight_map')): + case getString($r('app.string.light_weight_set')): + case getString($r('app.string.linked_list')): + case getString($r('app.string.list')): + case getString($r('app.string.plain_array')): + case getString($r('app.string.queue')): + case getString($r('app.string.stack')): + case getString($r('app.string.tree_map')): + case getString($r('app.string.tree_set')): + case getString($r('app.string.vector')): + ret = true + break; + } + return ret + } + + getString(resource: Resource) { + let context = getContext(this) as common.UIAbilityContext; + let resultStr = context.resourceManager.getStringSync(resource); + logger.info(TAG, `getString = ${resultStr}`); + return resultStr; + } +} \ No newline at end of file diff --git a/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/menuitems/src/main/ets/menulist/MenuList.ets b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/menuitems/src/main/ets/menulist/MenuList.ets new file mode 100644 index 0000000000000000000000000000000000000000..6ac095f8b95046c8d867429db787183927bdbefc --- /dev/null +++ b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/menuitems/src/main/ets/menulist/MenuList.ets @@ -0,0 +1,53 @@ +/* + * Copyright (c) 2023 Huawei Device 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 { getStringArray } from '@ohos/common/src/main/ets/util/ResourceUtil'; +import { MenuNavRouter } from '../components/MenuNavRouter'; + +@Component +export struct MenuList { + @State menuListData: Array = []; + @BuilderParam childNavDestination: () => void; + private menuList: Resource | undefined = undefined; + private addAction?: (title: string) => void; + + build() { + List({ space: 12 }) { + ListItem() { + if (this.menuListData.length > 0) { + MenuNavRouter({ childList: this.menuListData, addAction: this.addAction }) { + this.childNavDestination() + } + } + } + } + .id('menu_list') + .width('100%') + .padding({ left: 12, right: 12 }) + .margin({ top: 12 }) + .backgroundColor($r('sys.color.ohos_id_color_sub_background')) + .scrollBar(BarState.Off) + } + + aboutToAppear() { + this.getData(); + } + + getData = async () => { + if (this.menuList) { + this.menuListData = await getStringArray(this.menuList); + } + } +} \ No newline at end of file diff --git a/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/menuitems/src/main/module.json5 b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/menuitems/src/main/module.json5 new file mode 100644 index 0000000000000000000000000000000000000000..d5bce3912c27bc0bb32977eb83fc2493c46e5af3 --- /dev/null +++ b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/menuitems/src/main/module.json5 @@ -0,0 +1,25 @@ +/* + * Copyright (c) 2023 Huawei Device 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. + */ + +{ + "module": { + "name": "menuitems", + "type": "har", + "deviceTypes": [ + "default", + "tablet" + ] + } +} \ No newline at end of file diff --git a/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/menuitems/src/main/resources/base/element/color.json b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/menuitems/src/main/resources/base/element/color.json new file mode 100644 index 0000000000000000000000000000000000000000..af2a41bdb8dd0a2235a7a35dbddacf0793ba2e22 --- /dev/null +++ b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/menuitems/src/main/resources/base/element/color.json @@ -0,0 +1,24 @@ +{ + "color": [ + { + "name": "white", + "value": "#FFFFFF" + }, + { + "name": "black", + "value": "#000000" + }, + { + "name": "itemActivated", + "value": "#335291FF" + }, + { + "name": "itemInactivated", + "value": "#FFFFFF" + }, + { + "name": "level_title", + "value": "#77000000" + } + ] +} \ No newline at end of file diff --git a/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/menuitems/src/main/resources/base/element/string.json b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/menuitems/src/main/resources/base/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..1e76de0c66777cfe83568615c5c2e68c61d23fed --- /dev/null +++ b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/menuitems/src/main/resources/base/element/string.json @@ -0,0 +1,8 @@ +{ + "string": [ + { + "name": "page_show", + "value": "page from npm package" + } + ] +} diff --git a/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/menuitems/src/main/resources/base/media/ic_add.png b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/menuitems/src/main/resources/base/media/ic_add.png new file mode 100644 index 0000000000000000000000000000000000000000..fe1f93dfe0882b204163603401ec9f441017f062 Binary files /dev/null and b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/menuitems/src/main/resources/base/media/ic_add.png differ diff --git a/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/menuitems/src/main/resources/base/media/ic_arrow.svg b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/menuitems/src/main/resources/base/media/ic_arrow.svg new file mode 100644 index 0000000000000000000000000000000000000000..643c0ded5cffaa25e1970f8878b3307d5d763e26 --- /dev/null +++ b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/menuitems/src/main/resources/base/media/ic_arrow.svg @@ -0,0 +1,16 @@ + + + + + diff --git a/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/menuitems/src/main/resources/base/media/ic_public_add.svg b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/menuitems/src/main/resources/base/media/ic_public_add.svg new file mode 100644 index 0000000000000000000000000000000000000000..7408e5cf30864de089f352778f38594de0ce87da --- /dev/null +++ b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/menuitems/src/main/resources/base/media/ic_public_add.svg @@ -0,0 +1,15 @@ + + + + + diff --git a/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/menuitems/src/main/resources/en_US/element/string.json b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/menuitems/src/main/resources/en_US/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..1e76de0c66777cfe83568615c5c2e68c61d23fed --- /dev/null +++ b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/menuitems/src/main/resources/en_US/element/string.json @@ -0,0 +1,8 @@ +{ + "string": [ + { + "name": "page_show", + "value": "page from npm package" + } + ] +} diff --git a/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/menuitems/src/main/resources/zh_CN/element/string.json b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/menuitems/src/main/resources/zh_CN/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..1e76de0c66777cfe83568615c5c2e68c61d23fed --- /dev/null +++ b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/feature/menuitems/src/main/resources/zh_CN/element/string.json @@ -0,0 +1,8 @@ +{ + "string": [ + { + "name": "page_show", + "value": "page from npm package" + } + ] +} diff --git a/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/hvigor/hvigor-config.json5 b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/hvigor/hvigor-config.json5 new file mode 100644 index 0000000000000000000000000000000000000000..e75281b258e8cec776a34fd96a3c117c58afb9cb --- /dev/null +++ b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/hvigor/hvigor-config.json5 @@ -0,0 +1,6 @@ +{ + "hvigorVersion": "3.0.2", + "dependencies": { + "@ohos/hvigor-ohos-plugin": "3.0.2" + } +} \ No newline at end of file diff --git a/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/hvigor/hvigor-wrapper.js b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/hvigor/hvigor-wrapper.js new file mode 100644 index 0000000000000000000000000000000000000000..994f22987bd0739b9faa07c966b066c2d9218602 --- /dev/null +++ b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/hvigor/hvigor-wrapper.js @@ -0,0 +1,2 @@ +"use strict";var e=require("fs"),t=require("path"),n=require("os"),r=require("crypto"),u=require("child_process"),o=require("constants"),i=require("stream"),s=require("util"),c=require("assert"),a=require("tty"),l=require("zlib"),f=require("net");function d(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var D=d(e),p=d(t),E=d(n),m=d(r),h=d(u),y=d(o),C=d(i),F=d(s),g=d(c),A=d(a),v=d(l),S=d(f),w="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},O={},b={},_={},B=w&&w.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(_,"__esModule",{value:!0}),_.isMac=_.isLinux=_.isWindows=void 0;const P=B(E.default),k="Windows_NT",x="Linux",N="Darwin";_.isWindows=function(){return P.default.type()===k},_.isLinux=function(){return P.default.type()===x},_.isMac=function(){return P.default.type()===N};var I={},T=w&&w.__createBinding||(Object.create?function(e,t,n,r){void 0===r&&(r=n);var u=Object.getOwnPropertyDescriptor(t,n);u&&!("get"in u?!t.__esModule:u.writable||u.configurable)||(u={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,r,u)}:function(e,t,n,r){void 0===r&&(r=n),e[r]=t[n]}),R=w&&w.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),M=w&&w.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var n in e)"default"!==n&&Object.prototype.hasOwnProperty.call(e,n)&&T(t,e,n);return R(t,e),t};Object.defineProperty(I,"__esModule",{value:!0}),I.hash=void 0;const L=M(m.default);I.hash=function(e,t="md5"){return L.createHash(t).update(e,"utf-8").digest("hex")},function(e){var t=w&&w.__createBinding||(Object.create?function(e,t,n,r){void 0===r&&(r=n);var u=Object.getOwnPropertyDescriptor(t,n);u&&!("get"in u?!t.__esModule:u.writable||u.configurable)||(u={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,r,u)}:function(e,t,n,r){void 0===r&&(r=n),e[r]=t[n]}),n=w&&w.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),r=w&&w.__importStar||function(e){if(e&&e.__esModule)return e;var r={};if(null!=e)for(var u in e)"default"!==u&&Object.prototype.hasOwnProperty.call(e,u)&&t(r,e,u);return n(r,e),r};Object.defineProperty(e,"__esModule",{value:!0}),e.HVIGOR_BOOT_JS_FILE_PATH=e.HVIGOR_PROJECT_DEPENDENCY_PACKAGE_JSON_PATH=e.HVIGOR_PROJECT_DEPENDENCIES_HOME=e.HVIGOR_PROJECT_WRAPPER_HOME=e.HVIGOR_PROJECT_NAME=e.HVIGOR_PROJECT_ROOT_DIR=e.HVIGOR_PROJECT_CACHES_HOME=e.HVIGOR_PNPM_STORE_PATH=e.HVIGOR_WRAPPER_PNPM_SCRIPT_PATH=e.HVIGOR_WRAPPER_TOOLS_HOME=e.HVIGOR_USER_HOME=e.DEFAULT_PACKAGE_JSON=e.DEFAULT_HVIGOR_CONFIG_JSON_FILE_NAME=e.PNPM=e.HVIGOR=e.NPM_TOOL=e.PNPM_TOOL=e.HVIGOR_ENGINE_PACKAGE_NAME=void 0;const u=r(p.default),o=r(E.default),i=_,s=I;e.HVIGOR_ENGINE_PACKAGE_NAME="@ohos/hvigor",e.PNPM_TOOL=(0,i.isWindows)()?"pnpm.cmd":"pnpm",e.NPM_TOOL=(0,i.isWindows)()?"npm.cmd":"npm",e.HVIGOR="hvigor",e.PNPM="pnpm",e.DEFAULT_HVIGOR_CONFIG_JSON_FILE_NAME="hvigor-config.json5",e.DEFAULT_PACKAGE_JSON="package.json",e.HVIGOR_USER_HOME=u.resolve(o.homedir(),".hvigor"),e.HVIGOR_WRAPPER_TOOLS_HOME=u.resolve(e.HVIGOR_USER_HOME,"wrapper","tools"),e.HVIGOR_WRAPPER_PNPM_SCRIPT_PATH=u.resolve(e.HVIGOR_WRAPPER_TOOLS_HOME,"node_modules",".bin",e.PNPM_TOOL),e.HVIGOR_PNPM_STORE_PATH=u.resolve(e.HVIGOR_USER_HOME,"caches"),e.HVIGOR_PROJECT_CACHES_HOME=u.resolve(e.HVIGOR_USER_HOME,"project_caches"),e.HVIGOR_PROJECT_ROOT_DIR=process.cwd(),e.HVIGOR_PROJECT_NAME=u.basename((0,s.hash)(e.HVIGOR_PROJECT_ROOT_DIR)),e.HVIGOR_PROJECT_WRAPPER_HOME=u.resolve(e.HVIGOR_PROJECT_ROOT_DIR,e.HVIGOR),e.HVIGOR_PROJECT_DEPENDENCIES_HOME=u.resolve(e.HVIGOR_PROJECT_CACHES_HOME,e.HVIGOR_PROJECT_NAME,"workspace"),e.HVIGOR_PROJECT_DEPENDENCY_PACKAGE_JSON_PATH=u.resolve(e.HVIGOR_PROJECT_DEPENDENCIES_HOME,e.DEFAULT_PACKAGE_JSON),e.HVIGOR_BOOT_JS_FILE_PATH=u.resolve(e.HVIGOR_PROJECT_DEPENDENCIES_HOME,"node_modules","@ohos","hvigor","bin","hvigor.js")}(b);var j={},$={};Object.defineProperty($,"__esModule",{value:!0}),$.logInfoPrintConsole=$.logErrorAndExit=void 0,$.logErrorAndExit=function(e){e instanceof Error?console.error(e.message):console.error(e),process.exit(-1)},$.logInfoPrintConsole=function(e){console.log(e)};var H=w&&w.__createBinding||(Object.create?function(e,t,n,r){void 0===r&&(r=n);var u=Object.getOwnPropertyDescriptor(t,n);u&&!("get"in u?!t.__esModule:u.writable||u.configurable)||(u={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,r,u)}:function(e,t,n,r){void 0===r&&(r=n),e[r]=t[n]}),J=w&&w.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),G=w&&w.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var n in e)"default"!==n&&Object.prototype.hasOwnProperty.call(e,n)&&H(t,e,n);return J(t,e),t},V=w&&w.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(j,"__esModule",{value:!0}),j.isFileExists=j.offlinePluginConversion=j.executeCommand=j.getNpmPath=j.hasNpmPackInPaths=void 0;const U=h.default,W=G(p.default),z=b,K=$,q=V(D.default);j.hasNpmPackInPaths=function(e,t){try{return require.resolve(e,{paths:[...t]}),!0}catch(e){return!1}},j.getNpmPath=function(){const e=process.execPath;return W.join(W.dirname(e),z.NPM_TOOL)},j.executeCommand=function(e,t,n){0!==(0,U.spawnSync)(e,t,n).status&&(0,K.logErrorAndExit)(`Error: ${e} ${t} execute failed.See above for details.`)},j.offlinePluginConversion=function(e,t){return t.startsWith("file:")||t.endsWith(".tgz")?W.resolve(e,z.HVIGOR,t.replace("file:","")):t},j.isFileExists=function(e){return q.default.existsSync(e)&&q.default.statSync(e).isFile()},function(e){var t=w&&w.__createBinding||(Object.create?function(e,t,n,r){void 0===r&&(r=n);var u=Object.getOwnPropertyDescriptor(t,n);u&&!("get"in u?!t.__esModule:u.writable||u.configurable)||(u={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,r,u)}:function(e,t,n,r){void 0===r&&(r=n),e[r]=t[n]}),n=w&&w.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),r=w&&w.__importStar||function(e){if(e&&e.__esModule)return e;var r={};if(null!=e)for(var u in e)"default"!==u&&Object.prototype.hasOwnProperty.call(e,u)&&t(r,e,u);return n(r,e),r},u=w&&w.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(e,"__esModule",{value:!0}),e.executeInstallPnpm=e.isPnpmAvailable=e.environmentHandler=e.checkNpmConifg=e.PNPM_VERSION=void 0;const o=r(D.default),i=b,s=j,c=r(p.default),a=$,l=h.default,f=u(E.default);e.PNPM_VERSION="7.30.0",e.checkNpmConifg=function(){const e=c.resolve(i.HVIGOR_PROJECT_ROOT_DIR,".npmrc"),t=c.resolve(f.default.homedir(),".npmrc");if((0,s.isFileExists)(e)||(0,s.isFileExists)(t))return;const n=(0,s.getNpmPath)(),r=(0,l.spawnSync)(n,["config","get","prefix"],{cwd:i.HVIGOR_PROJECT_ROOT_DIR});if(0!==r.status||!r.stdout)return void(0,a.logErrorAndExit)("Error: The hvigor depends on the npmrc file. Configure the npmrc file first.");const u=c.resolve(`${r.stdout}`.replace(/[\r\n]/gi,""),".npmrc");(0,s.isFileExists)(u)||(0,a.logErrorAndExit)("Error: The hvigor depends on the npmrc file. Configure the npmrc file first.")},e.environmentHandler=function(){process.env["npm_config_update-notifier"]="false"},e.isPnpmAvailable=function(){return!!o.existsSync(i.HVIGOR_WRAPPER_PNPM_SCRIPT_PATH)&&(0,s.hasNpmPackInPaths)("pnpm",[i.HVIGOR_WRAPPER_TOOLS_HOME])},e.executeInstallPnpm=function(){(0,a.logInfoPrintConsole)(`Installing pnpm@${e.PNPM_VERSION}...`);const t=(0,s.getNpmPath)();!function(){const t=c.resolve(i.HVIGOR_WRAPPER_TOOLS_HOME,i.DEFAULT_PACKAGE_JSON);try{o.existsSync(i.HVIGOR_WRAPPER_TOOLS_HOME)||o.mkdirSync(i.HVIGOR_WRAPPER_TOOLS_HOME,{recursive:!0});const n={dependencies:{}};n.dependencies[i.PNPM]=e.PNPM_VERSION,o.writeFileSync(t,JSON.stringify(n))}catch(e){(0,a.logErrorAndExit)(`Error: EPERM: operation not permitted,create ${t} failed.`)}}(),(0,s.executeCommand)(t,["install","pnpm"],{cwd:i.HVIGOR_WRAPPER_TOOLS_HOME,stdio:["inherit","inherit","inherit"],env:process.env}),(0,a.logInfoPrintConsole)("Pnpm install success.")}}(O);var Y={},X={},Z={},Q={};Object.defineProperty(Q,"__esModule",{value:!0}),Q.Unicode=void 0;class ee{}Q.Unicode=ee,ee.Space_Separator=/[\u1680\u2000-\u200A\u202F\u205F\u3000]/,ee.ID_Start=/[\xAA\xB5\xBA\xC0-\xD6\xD8-\xF6\xF8-\u02C1\u02C6-\u02D1\u02E0-\u02E4\u02EC\u02EE\u0370-\u0374\u0376\u0377\u037A-\u037D\u037F\u0386\u0388-\u038A\u038C\u038E-\u03A1\u03A3-\u03F5\u03F7-\u0481\u048A-\u052F\u0531-\u0556\u0559\u0561-\u0587\u05D0-\u05EA\u05F0-\u05F2\u0620-\u064A\u066E\u066F\u0671-\u06D3\u06D5\u06E5\u06E6\u06EE\u06EF\u06FA-\u06FC\u06FF\u0710\u0712-\u072F\u074D-\u07A5\u07B1\u07CA-\u07EA\u07F4\u07F5\u07FA\u0800-\u0815\u081A\u0824\u0828\u0840-\u0858\u0860-\u086A\u08A0-\u08B4\u08B6-\u08BD\u0904-\u0939\u093D\u0950\u0958-\u0961\u0971-\u0980\u0985-\u098C\u098F\u0990\u0993-\u09A8\u09AA-\u09B0\u09B2\u09B6-\u09B9\u09BD\u09CE\u09DC\u09DD\u09DF-\u09E1\u09F0\u09F1\u09FC\u0A05-\u0A0A\u0A0F\u0A10\u0A13-\u0A28\u0A2A-\u0A30\u0A32\u0A33\u0A35\u0A36\u0A38\u0A39\u0A59-\u0A5C\u0A5E\u0A72-\u0A74\u0A85-\u0A8D\u0A8F-\u0A91\u0A93-\u0AA8\u0AAA-\u0AB0\u0AB2\u0AB3\u0AB5-\u0AB9\u0ABD\u0AD0\u0AE0\u0AE1\u0AF9\u0B05-\u0B0C\u0B0F\u0B10\u0B13-\u0B28\u0B2A-\u0B30\u0B32\u0B33\u0B35-\u0B39\u0B3D\u0B5C\u0B5D\u0B5F-\u0B61\u0B71\u0B83\u0B85-\u0B8A\u0B8E-\u0B90\u0B92-\u0B95\u0B99\u0B9A\u0B9C\u0B9E\u0B9F\u0BA3\u0BA4\u0BA8-\u0BAA\u0BAE-\u0BB9\u0BD0\u0C05-\u0C0C\u0C0E-\u0C10\u0C12-\u0C28\u0C2A-\u0C39\u0C3D\u0C58-\u0C5A\u0C60\u0C61\u0C80\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8\u0CAA-\u0CB3\u0CB5-\u0CB9\u0CBD\u0CDE\u0CE0\u0CE1\u0CF1\u0CF2\u0D05-\u0D0C\u0D0E-\u0D10\u0D12-\u0D3A\u0D3D\u0D4E\u0D54-\u0D56\u0D5F-\u0D61\u0D7A-\u0D7F\u0D85-\u0D96\u0D9A-\u0DB1\u0DB3-\u0DBB\u0DBD\u0DC0-\u0DC6\u0E01-\u0E30\u0E32\u0E33\u0E40-\u0E46\u0E81\u0E82\u0E84\u0E87\u0E88\u0E8A\u0E8D\u0E94-\u0E97\u0E99-\u0E9F\u0EA1-\u0EA3\u0EA5\u0EA7\u0EAA\u0EAB\u0EAD-\u0EB0\u0EB2\u0EB3\u0EBD\u0EC0-\u0EC4\u0EC6\u0EDC-\u0EDF\u0F00\u0F40-\u0F47\u0F49-\u0F6C\u0F88-\u0F8C\u1000-\u102A\u103F\u1050-\u1055\u105A-\u105D\u1061\u1065\u1066\u106E-\u1070\u1075-\u1081\u108E\u10A0-\u10C5\u10C7\u10CD\u10D0-\u10FA\u10FC-\u1248\u124A-\u124D\u1250-\u1256\u1258\u125A-\u125D\u1260-\u1288\u128A-\u128D\u1290-\u12B0\u12B2-\u12B5\u12B8-\u12BE\u12C0\u12C2-\u12C5\u12C8-\u12D6\u12D8-\u1310\u1312-\u1315\u1318-\u135A\u1380-\u138F\u13A0-\u13F5\u13F8-\u13FD\u1401-\u166C\u166F-\u167F\u1681-\u169A\u16A0-\u16EA\u16EE-\u16F8\u1700-\u170C\u170E-\u1711\u1720-\u1731\u1740-\u1751\u1760-\u176C\u176E-\u1770\u1780-\u17B3\u17D7\u17DC\u1820-\u1877\u1880-\u1884\u1887-\u18A8\u18AA\u18B0-\u18F5\u1900-\u191E\u1950-\u196D\u1970-\u1974\u1980-\u19AB\u19B0-\u19C9\u1A00-\u1A16\u1A20-\u1A54\u1AA7\u1B05-\u1B33\u1B45-\u1B4B\u1B83-\u1BA0\u1BAE\u1BAF\u1BBA-\u1BE5\u1C00-\u1C23\u1C4D-\u1C4F\u1C5A-\u1C7D\u1C80-\u1C88\u1CE9-\u1CEC\u1CEE-\u1CF1\u1CF5\u1CF6\u1D00-\u1DBF\u1E00-\u1F15\u1F18-\u1F1D\u1F20-\u1F45\u1F48-\u1F4D\u1F50-\u1F57\u1F59\u1F5B\u1F5D\u1F5F-\u1F7D\u1F80-\u1FB4\u1FB6-\u1FBC\u1FBE\u1FC2-\u1FC4\u1FC6-\u1FCC\u1FD0-\u1FD3\u1FD6-\u1FDB\u1FE0-\u1FEC\u1FF2-\u1FF4\u1FF6-\u1FFC\u2071\u207F\u2090-\u209C\u2102\u2107\u210A-\u2113\u2115\u2119-\u211D\u2124\u2126\u2128\u212A-\u212D\u212F-\u2139\u213C-\u213F\u2145-\u2149\u214E\u2160-\u2188\u2C00-\u2C2E\u2C30-\u2C5E\u2C60-\u2CE4\u2CEB-\u2CEE\u2CF2\u2CF3\u2D00-\u2D25\u2D27\u2D2D\u2D30-\u2D67\u2D6F\u2D80-\u2D96\u2DA0-\u2DA6\u2DA8-\u2DAE\u2DB0-\u2DB6\u2DB8-\u2DBE\u2DC0-\u2DC6\u2DC8-\u2DCE\u2DD0-\u2DD6\u2DD8-\u2DDE\u2E2F\u3005-\u3007\u3021-\u3029\u3031-\u3035\u3038-\u303C\u3041-\u3096\u309D-\u309F\u30A1-\u30FA\u30FC-\u30FF\u3105-\u312E\u3131-\u318E\u31A0-\u31BA\u31F0-\u31FF\u3400-\u4DB5\u4E00-\u9FEA\uA000-\uA48C\uA4D0-\uA4FD\uA500-\uA60C\uA610-\uA61F\uA62A\uA62B\uA640-\uA66E\uA67F-\uA69D\uA6A0-\uA6EF\uA717-\uA71F\uA722-\uA788\uA78B-\uA7AE\uA7B0-\uA7B7\uA7F7-\uA801\uA803-\uA805\uA807-\uA80A\uA80C-\uA822\uA840-\uA873\uA882-\uA8B3\uA8F2-\uA8F7\uA8FB\uA8FD\uA90A-\uA925\uA930-\uA946\uA960-\uA97C\uA984-\uA9B2\uA9CF\uA9E0-\uA9E4\uA9E6-\uA9EF\uA9FA-\uA9FE\uAA00-\uAA28\uAA40-\uAA42\uAA44-\uAA4B\uAA60-\uAA76\uAA7A\uAA7E-\uAAAF\uAAB1\uAAB5\uAAB6\uAAB9-\uAABD\uAAC0\uAAC2\uAADB-\uAADD\uAAE0-\uAAEA\uAAF2-\uAAF4\uAB01-\uAB06\uAB09-\uAB0E\uAB11-\uAB16\uAB20-\uAB26\uAB28-\uAB2E\uAB30-\uAB5A\uAB5C-\uAB65\uAB70-\uABE2\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFA6D\uFA70-\uFAD9\uFB00-\uFB06\uFB13-\uFB17\uFB1D\uFB1F-\uFB28\uFB2A-\uFB36\uFB38-\uFB3C\uFB3E\uFB40\uFB41\uFB43\uFB44\uFB46-\uFBB1\uFBD3-\uFD3D\uFD50-\uFD8F\uFD92-\uFDC7\uFDF0-\uFDFB\uFE70-\uFE74\uFE76-\uFEFC\uFF21-\uFF3A\uFF41-\uFF5A\uFF66-\uFFBE\uFFC2-\uFFC7\uFFCA-\uFFCF\uFFD2-\uFFD7\uFFDA-\uFFDC]|\uD800[\uDC00-\uDC0B\uDC0D-\uDC26\uDC28-\uDC3A\uDC3C\uDC3D\uDC3F-\uDC4D\uDC50-\uDC5D\uDC80-\uDCFA\uDD40-\uDD74\uDE80-\uDE9C\uDEA0-\uDED0\uDF00-\uDF1F\uDF2D-\uDF4A\uDF50-\uDF75\uDF80-\uDF9D\uDFA0-\uDFC3\uDFC8-\uDFCF\uDFD1-\uDFD5]|\uD801[\uDC00-\uDC9D\uDCB0-\uDCD3\uDCD8-\uDCFB\uDD00-\uDD27\uDD30-\uDD63\uDE00-\uDF36\uDF40-\uDF55\uDF60-\uDF67]|\uD802[\uDC00-\uDC05\uDC08\uDC0A-\uDC35\uDC37\uDC38\uDC3C\uDC3F-\uDC55\uDC60-\uDC76\uDC80-\uDC9E\uDCE0-\uDCF2\uDCF4\uDCF5\uDD00-\uDD15\uDD20-\uDD39\uDD80-\uDDB7\uDDBE\uDDBF\uDE00\uDE10-\uDE13\uDE15-\uDE17\uDE19-\uDE33\uDE60-\uDE7C\uDE80-\uDE9C\uDEC0-\uDEC7\uDEC9-\uDEE4\uDF00-\uDF35\uDF40-\uDF55\uDF60-\uDF72\uDF80-\uDF91]|\uD803[\uDC00-\uDC48\uDC80-\uDCB2\uDCC0-\uDCF2]|\uD804[\uDC03-\uDC37\uDC83-\uDCAF\uDCD0-\uDCE8\uDD03-\uDD26\uDD50-\uDD72\uDD76\uDD83-\uDDB2\uDDC1-\uDDC4\uDDDA\uDDDC\uDE00-\uDE11\uDE13-\uDE2B\uDE80-\uDE86\uDE88\uDE8A-\uDE8D\uDE8F-\uDE9D\uDE9F-\uDEA8\uDEB0-\uDEDE\uDF05-\uDF0C\uDF0F\uDF10\uDF13-\uDF28\uDF2A-\uDF30\uDF32\uDF33\uDF35-\uDF39\uDF3D\uDF50\uDF5D-\uDF61]|\uD805[\uDC00-\uDC34\uDC47-\uDC4A\uDC80-\uDCAF\uDCC4\uDCC5\uDCC7\uDD80-\uDDAE\uDDD8-\uDDDB\uDE00-\uDE2F\uDE44\uDE80-\uDEAA\uDF00-\uDF19]|\uD806[\uDCA0-\uDCDF\uDCFF\uDE00\uDE0B-\uDE32\uDE3A\uDE50\uDE5C-\uDE83\uDE86-\uDE89\uDEC0-\uDEF8]|\uD807[\uDC00-\uDC08\uDC0A-\uDC2E\uDC40\uDC72-\uDC8F\uDD00-\uDD06\uDD08\uDD09\uDD0B-\uDD30\uDD46]|\uD808[\uDC00-\uDF99]|\uD809[\uDC00-\uDC6E\uDC80-\uDD43]|[\uD80C\uD81C-\uD820\uD840-\uD868\uD86A-\uD86C\uD86F-\uD872\uD874-\uD879][\uDC00-\uDFFF]|\uD80D[\uDC00-\uDC2E]|\uD811[\uDC00-\uDE46]|\uD81A[\uDC00-\uDE38\uDE40-\uDE5E\uDED0-\uDEED\uDF00-\uDF2F\uDF40-\uDF43\uDF63-\uDF77\uDF7D-\uDF8F]|\uD81B[\uDF00-\uDF44\uDF50\uDF93-\uDF9F\uDFE0\uDFE1]|\uD821[\uDC00-\uDFEC]|\uD822[\uDC00-\uDEF2]|\uD82C[\uDC00-\uDD1E\uDD70-\uDEFB]|\uD82F[\uDC00-\uDC6A\uDC70-\uDC7C\uDC80-\uDC88\uDC90-\uDC99]|\uD835[\uDC00-\uDC54\uDC56-\uDC9C\uDC9E\uDC9F\uDCA2\uDCA5\uDCA6\uDCA9-\uDCAC\uDCAE-\uDCB9\uDCBB\uDCBD-\uDCC3\uDCC5-\uDD05\uDD07-\uDD0A\uDD0D-\uDD14\uDD16-\uDD1C\uDD1E-\uDD39\uDD3B-\uDD3E\uDD40-\uDD44\uDD46\uDD4A-\uDD50\uDD52-\uDEA5\uDEA8-\uDEC0\uDEC2-\uDEDA\uDEDC-\uDEFA\uDEFC-\uDF14\uDF16-\uDF34\uDF36-\uDF4E\uDF50-\uDF6E\uDF70-\uDF88\uDF8A-\uDFA8\uDFAA-\uDFC2\uDFC4-\uDFCB]|\uD83A[\uDC00-\uDCC4\uDD00-\uDD43]|\uD83B[\uDE00-\uDE03\uDE05-\uDE1F\uDE21\uDE22\uDE24\uDE27\uDE29-\uDE32\uDE34-\uDE37\uDE39\uDE3B\uDE42\uDE47\uDE49\uDE4B\uDE4D-\uDE4F\uDE51\uDE52\uDE54\uDE57\uDE59\uDE5B\uDE5D\uDE5F\uDE61\uDE62\uDE64\uDE67-\uDE6A\uDE6C-\uDE72\uDE74-\uDE77\uDE79-\uDE7C\uDE7E\uDE80-\uDE89\uDE8B-\uDE9B\uDEA1-\uDEA3\uDEA5-\uDEA9\uDEAB-\uDEBB]|\uD869[\uDC00-\uDED6\uDF00-\uDFFF]|\uD86D[\uDC00-\uDF34\uDF40-\uDFFF]|\uD86E[\uDC00-\uDC1D\uDC20-\uDFFF]|\uD873[\uDC00-\uDEA1\uDEB0-\uDFFF]|\uD87A[\uDC00-\uDFE0]|\uD87E[\uDC00-\uDE1D]/,ee.ID_Continue=/[\xAA\xB5\xBA\xC0-\xD6\xD8-\xF6\xF8-\u02C1\u02C6-\u02D1\u02E0-\u02E4\u02EC\u02EE\u0300-\u0374\u0376\u0377\u037A-\u037D\u037F\u0386\u0388-\u038A\u038C\u038E-\u03A1\u03A3-\u03F5\u03F7-\u0481\u0483-\u0487\u048A-\u052F\u0531-\u0556\u0559\u0561-\u0587\u0591-\u05BD\u05BF\u05C1\u05C2\u05C4\u05C5\u05C7\u05D0-\u05EA\u05F0-\u05F2\u0610-\u061A\u0620-\u0669\u066E-\u06D3\u06D5-\u06DC\u06DF-\u06E8\u06EA-\u06FC\u06FF\u0710-\u074A\u074D-\u07B1\u07C0-\u07F5\u07FA\u0800-\u082D\u0840-\u085B\u0860-\u086A\u08A0-\u08B4\u08B6-\u08BD\u08D4-\u08E1\u08E3-\u0963\u0966-\u096F\u0971-\u0983\u0985-\u098C\u098F\u0990\u0993-\u09A8\u09AA-\u09B0\u09B2\u09B6-\u09B9\u09BC-\u09C4\u09C7\u09C8\u09CB-\u09CE\u09D7\u09DC\u09DD\u09DF-\u09E3\u09E6-\u09F1\u09FC\u0A01-\u0A03\u0A05-\u0A0A\u0A0F\u0A10\u0A13-\u0A28\u0A2A-\u0A30\u0A32\u0A33\u0A35\u0A36\u0A38\u0A39\u0A3C\u0A3E-\u0A42\u0A47\u0A48\u0A4B-\u0A4D\u0A51\u0A59-\u0A5C\u0A5E\u0A66-\u0A75\u0A81-\u0A83\u0A85-\u0A8D\u0A8F-\u0A91\u0A93-\u0AA8\u0AAA-\u0AB0\u0AB2\u0AB3\u0AB5-\u0AB9\u0ABC-\u0AC5\u0AC7-\u0AC9\u0ACB-\u0ACD\u0AD0\u0AE0-\u0AE3\u0AE6-\u0AEF\u0AF9-\u0AFF\u0B01-\u0B03\u0B05-\u0B0C\u0B0F\u0B10\u0B13-\u0B28\u0B2A-\u0B30\u0B32\u0B33\u0B35-\u0B39\u0B3C-\u0B44\u0B47\u0B48\u0B4B-\u0B4D\u0B56\u0B57\u0B5C\u0B5D\u0B5F-\u0B63\u0B66-\u0B6F\u0B71\u0B82\u0B83\u0B85-\u0B8A\u0B8E-\u0B90\u0B92-\u0B95\u0B99\u0B9A\u0B9C\u0B9E\u0B9F\u0BA3\u0BA4\u0BA8-\u0BAA\u0BAE-\u0BB9\u0BBE-\u0BC2\u0BC6-\u0BC8\u0BCA-\u0BCD\u0BD0\u0BD7\u0BE6-\u0BEF\u0C00-\u0C03\u0C05-\u0C0C\u0C0E-\u0C10\u0C12-\u0C28\u0C2A-\u0C39\u0C3D-\u0C44\u0C46-\u0C48\u0C4A-\u0C4D\u0C55\u0C56\u0C58-\u0C5A\u0C60-\u0C63\u0C66-\u0C6F\u0C80-\u0C83\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8\u0CAA-\u0CB3\u0CB5-\u0CB9\u0CBC-\u0CC4\u0CC6-\u0CC8\u0CCA-\u0CCD\u0CD5\u0CD6\u0CDE\u0CE0-\u0CE3\u0CE6-\u0CEF\u0CF1\u0CF2\u0D00-\u0D03\u0D05-\u0D0C\u0D0E-\u0D10\u0D12-\u0D44\u0D46-\u0D48\u0D4A-\u0D4E\u0D54-\u0D57\u0D5F-\u0D63\u0D66-\u0D6F\u0D7A-\u0D7F\u0D82\u0D83\u0D85-\u0D96\u0D9A-\u0DB1\u0DB3-\u0DBB\u0DBD\u0DC0-\u0DC6\u0DCA\u0DCF-\u0DD4\u0DD6\u0DD8-\u0DDF\u0DE6-\u0DEF\u0DF2\u0DF3\u0E01-\u0E3A\u0E40-\u0E4E\u0E50-\u0E59\u0E81\u0E82\u0E84\u0E87\u0E88\u0E8A\u0E8D\u0E94-\u0E97\u0E99-\u0E9F\u0EA1-\u0EA3\u0EA5\u0EA7\u0EAA\u0EAB\u0EAD-\u0EB9\u0EBB-\u0EBD\u0EC0-\u0EC4\u0EC6\u0EC8-\u0ECD\u0ED0-\u0ED9\u0EDC-\u0EDF\u0F00\u0F18\u0F19\u0F20-\u0F29\u0F35\u0F37\u0F39\u0F3E-\u0F47\u0F49-\u0F6C\u0F71-\u0F84\u0F86-\u0F97\u0F99-\u0FBC\u0FC6\u1000-\u1049\u1050-\u109D\u10A0-\u10C5\u10C7\u10CD\u10D0-\u10FA\u10FC-\u1248\u124A-\u124D\u1250-\u1256\u1258\u125A-\u125D\u1260-\u1288\u128A-\u128D\u1290-\u12B0\u12B2-\u12B5\u12B8-\u12BE\u12C0\u12C2-\u12C5\u12C8-\u12D6\u12D8-\u1310\u1312-\u1315\u1318-\u135A\u135D-\u135F\u1380-\u138F\u13A0-\u13F5\u13F8-\u13FD\u1401-\u166C\u166F-\u167F\u1681-\u169A\u16A0-\u16EA\u16EE-\u16F8\u1700-\u170C\u170E-\u1714\u1720-\u1734\u1740-\u1753\u1760-\u176C\u176E-\u1770\u1772\u1773\u1780-\u17D3\u17D7\u17DC\u17DD\u17E0-\u17E9\u180B-\u180D\u1810-\u1819\u1820-\u1877\u1880-\u18AA\u18B0-\u18F5\u1900-\u191E\u1920-\u192B\u1930-\u193B\u1946-\u196D\u1970-\u1974\u1980-\u19AB\u19B0-\u19C9\u19D0-\u19D9\u1A00-\u1A1B\u1A20-\u1A5E\u1A60-\u1A7C\u1A7F-\u1A89\u1A90-\u1A99\u1AA7\u1AB0-\u1ABD\u1B00-\u1B4B\u1B50-\u1B59\u1B6B-\u1B73\u1B80-\u1BF3\u1C00-\u1C37\u1C40-\u1C49\u1C4D-\u1C7D\u1C80-\u1C88\u1CD0-\u1CD2\u1CD4-\u1CF9\u1D00-\u1DF9\u1DFB-\u1F15\u1F18-\u1F1D\u1F20-\u1F45\u1F48-\u1F4D\u1F50-\u1F57\u1F59\u1F5B\u1F5D\u1F5F-\u1F7D\u1F80-\u1FB4\u1FB6-\u1FBC\u1FBE\u1FC2-\u1FC4\u1FC6-\u1FCC\u1FD0-\u1FD3\u1FD6-\u1FDB\u1FE0-\u1FEC\u1FF2-\u1FF4\u1FF6-\u1FFC\u203F\u2040\u2054\u2071\u207F\u2090-\u209C\u20D0-\u20DC\u20E1\u20E5-\u20F0\u2102\u2107\u210A-\u2113\u2115\u2119-\u211D\u2124\u2126\u2128\u212A-\u212D\u212F-\u2139\u213C-\u213F\u2145-\u2149\u214E\u2160-\u2188\u2C00-\u2C2E\u2C30-\u2C5E\u2C60-\u2CE4\u2CEB-\u2CF3\u2D00-\u2D25\u2D27\u2D2D\u2D30-\u2D67\u2D6F\u2D7F-\u2D96\u2DA0-\u2DA6\u2DA8-\u2DAE\u2DB0-\u2DB6\u2DB8-\u2DBE\u2DC0-\u2DC6\u2DC8-\u2DCE\u2DD0-\u2DD6\u2DD8-\u2DDE\u2DE0-\u2DFF\u2E2F\u3005-\u3007\u3021-\u302F\u3031-\u3035\u3038-\u303C\u3041-\u3096\u3099\u309A\u309D-\u309F\u30A1-\u30FA\u30FC-\u30FF\u3105-\u312E\u3131-\u318E\u31A0-\u31BA\u31F0-\u31FF\u3400-\u4DB5\u4E00-\u9FEA\uA000-\uA48C\uA4D0-\uA4FD\uA500-\uA60C\uA610-\uA62B\uA640-\uA66F\uA674-\uA67D\uA67F-\uA6F1\uA717-\uA71F\uA722-\uA788\uA78B-\uA7AE\uA7B0-\uA7B7\uA7F7-\uA827\uA840-\uA873\uA880-\uA8C5\uA8D0-\uA8D9\uA8E0-\uA8F7\uA8FB\uA8FD\uA900-\uA92D\uA930-\uA953\uA960-\uA97C\uA980-\uA9C0\uA9CF-\uA9D9\uA9E0-\uA9FE\uAA00-\uAA36\uAA40-\uAA4D\uAA50-\uAA59\uAA60-\uAA76\uAA7A-\uAAC2\uAADB-\uAADD\uAAE0-\uAAEF\uAAF2-\uAAF6\uAB01-\uAB06\uAB09-\uAB0E\uAB11-\uAB16\uAB20-\uAB26\uAB28-\uAB2E\uAB30-\uAB5A\uAB5C-\uAB65\uAB70-\uABEA\uABEC\uABED\uABF0-\uABF9\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFA6D\uFA70-\uFAD9\uFB00-\uFB06\uFB13-\uFB17\uFB1D-\uFB28\uFB2A-\uFB36\uFB38-\uFB3C\uFB3E\uFB40\uFB41\uFB43\uFB44\uFB46-\uFBB1\uFBD3-\uFD3D\uFD50-\uFD8F\uFD92-\uFDC7\uFDF0-\uFDFB\uFE00-\uFE0F\uFE20-\uFE2F\uFE33\uFE34\uFE4D-\uFE4F\uFE70-\uFE74\uFE76-\uFEFC\uFF10-\uFF19\uFF21-\uFF3A\uFF3F\uFF41-\uFF5A\uFF66-\uFFBE\uFFC2-\uFFC7\uFFCA-\uFFCF\uFFD2-\uFFD7\uFFDA-\uFFDC]|\uD800[\uDC00-\uDC0B\uDC0D-\uDC26\uDC28-\uDC3A\uDC3C\uDC3D\uDC3F-\uDC4D\uDC50-\uDC5D\uDC80-\uDCFA\uDD40-\uDD74\uDDFD\uDE80-\uDE9C\uDEA0-\uDED0\uDEE0\uDF00-\uDF1F\uDF2D-\uDF4A\uDF50-\uDF7A\uDF80-\uDF9D\uDFA0-\uDFC3\uDFC8-\uDFCF\uDFD1-\uDFD5]|\uD801[\uDC00-\uDC9D\uDCA0-\uDCA9\uDCB0-\uDCD3\uDCD8-\uDCFB\uDD00-\uDD27\uDD30-\uDD63\uDE00-\uDF36\uDF40-\uDF55\uDF60-\uDF67]|\uD802[\uDC00-\uDC05\uDC08\uDC0A-\uDC35\uDC37\uDC38\uDC3C\uDC3F-\uDC55\uDC60-\uDC76\uDC80-\uDC9E\uDCE0-\uDCF2\uDCF4\uDCF5\uDD00-\uDD15\uDD20-\uDD39\uDD80-\uDDB7\uDDBE\uDDBF\uDE00-\uDE03\uDE05\uDE06\uDE0C-\uDE13\uDE15-\uDE17\uDE19-\uDE33\uDE38-\uDE3A\uDE3F\uDE60-\uDE7C\uDE80-\uDE9C\uDEC0-\uDEC7\uDEC9-\uDEE6\uDF00-\uDF35\uDF40-\uDF55\uDF60-\uDF72\uDF80-\uDF91]|\uD803[\uDC00-\uDC48\uDC80-\uDCB2\uDCC0-\uDCF2]|\uD804[\uDC00-\uDC46\uDC66-\uDC6F\uDC7F-\uDCBA\uDCD0-\uDCE8\uDCF0-\uDCF9\uDD00-\uDD34\uDD36-\uDD3F\uDD50-\uDD73\uDD76\uDD80-\uDDC4\uDDCA-\uDDCC\uDDD0-\uDDDA\uDDDC\uDE00-\uDE11\uDE13-\uDE37\uDE3E\uDE80-\uDE86\uDE88\uDE8A-\uDE8D\uDE8F-\uDE9D\uDE9F-\uDEA8\uDEB0-\uDEEA\uDEF0-\uDEF9\uDF00-\uDF03\uDF05-\uDF0C\uDF0F\uDF10\uDF13-\uDF28\uDF2A-\uDF30\uDF32\uDF33\uDF35-\uDF39\uDF3C-\uDF44\uDF47\uDF48\uDF4B-\uDF4D\uDF50\uDF57\uDF5D-\uDF63\uDF66-\uDF6C\uDF70-\uDF74]|\uD805[\uDC00-\uDC4A\uDC50-\uDC59\uDC80-\uDCC5\uDCC7\uDCD0-\uDCD9\uDD80-\uDDB5\uDDB8-\uDDC0\uDDD8-\uDDDD\uDE00-\uDE40\uDE44\uDE50-\uDE59\uDE80-\uDEB7\uDEC0-\uDEC9\uDF00-\uDF19\uDF1D-\uDF2B\uDF30-\uDF39]|\uD806[\uDCA0-\uDCE9\uDCFF\uDE00-\uDE3E\uDE47\uDE50-\uDE83\uDE86-\uDE99\uDEC0-\uDEF8]|\uD807[\uDC00-\uDC08\uDC0A-\uDC36\uDC38-\uDC40\uDC50-\uDC59\uDC72-\uDC8F\uDC92-\uDCA7\uDCA9-\uDCB6\uDD00-\uDD06\uDD08\uDD09\uDD0B-\uDD36\uDD3A\uDD3C\uDD3D\uDD3F-\uDD47\uDD50-\uDD59]|\uD808[\uDC00-\uDF99]|\uD809[\uDC00-\uDC6E\uDC80-\uDD43]|[\uD80C\uD81C-\uD820\uD840-\uD868\uD86A-\uD86C\uD86F-\uD872\uD874-\uD879][\uDC00-\uDFFF]|\uD80D[\uDC00-\uDC2E]|\uD811[\uDC00-\uDE46]|\uD81A[\uDC00-\uDE38\uDE40-\uDE5E\uDE60-\uDE69\uDED0-\uDEED\uDEF0-\uDEF4\uDF00-\uDF36\uDF40-\uDF43\uDF50-\uDF59\uDF63-\uDF77\uDF7D-\uDF8F]|\uD81B[\uDF00-\uDF44\uDF50-\uDF7E\uDF8F-\uDF9F\uDFE0\uDFE1]|\uD821[\uDC00-\uDFEC]|\uD822[\uDC00-\uDEF2]|\uD82C[\uDC00-\uDD1E\uDD70-\uDEFB]|\uD82F[\uDC00-\uDC6A\uDC70-\uDC7C\uDC80-\uDC88\uDC90-\uDC99\uDC9D\uDC9E]|\uD834[\uDD65-\uDD69\uDD6D-\uDD72\uDD7B-\uDD82\uDD85-\uDD8B\uDDAA-\uDDAD\uDE42-\uDE44]|\uD835[\uDC00-\uDC54\uDC56-\uDC9C\uDC9E\uDC9F\uDCA2\uDCA5\uDCA6\uDCA9-\uDCAC\uDCAE-\uDCB9\uDCBB\uDCBD-\uDCC3\uDCC5-\uDD05\uDD07-\uDD0A\uDD0D-\uDD14\uDD16-\uDD1C\uDD1E-\uDD39\uDD3B-\uDD3E\uDD40-\uDD44\uDD46\uDD4A-\uDD50\uDD52-\uDEA5\uDEA8-\uDEC0\uDEC2-\uDEDA\uDEDC-\uDEFA\uDEFC-\uDF14\uDF16-\uDF34\uDF36-\uDF4E\uDF50-\uDF6E\uDF70-\uDF88\uDF8A-\uDFA8\uDFAA-\uDFC2\uDFC4-\uDFCB\uDFCE-\uDFFF]|\uD836[\uDE00-\uDE36\uDE3B-\uDE6C\uDE75\uDE84\uDE9B-\uDE9F\uDEA1-\uDEAF]|\uD838[\uDC00-\uDC06\uDC08-\uDC18\uDC1B-\uDC21\uDC23\uDC24\uDC26-\uDC2A]|\uD83A[\uDC00-\uDCC4\uDCD0-\uDCD6\uDD00-\uDD4A\uDD50-\uDD59]|\uD83B[\uDE00-\uDE03\uDE05-\uDE1F\uDE21\uDE22\uDE24\uDE27\uDE29-\uDE32\uDE34-\uDE37\uDE39\uDE3B\uDE42\uDE47\uDE49\uDE4B\uDE4D-\uDE4F\uDE51\uDE52\uDE54\uDE57\uDE59\uDE5B\uDE5D\uDE5F\uDE61\uDE62\uDE64\uDE67-\uDE6A\uDE6C-\uDE72\uDE74-\uDE77\uDE79-\uDE7C\uDE7E\uDE80-\uDE89\uDE8B-\uDE9B\uDEA1-\uDEA3\uDEA5-\uDEA9\uDEAB-\uDEBB]|\uD869[\uDC00-\uDED6\uDF00-\uDFFF]|\uD86D[\uDC00-\uDF34\uDF40-\uDFFF]|\uD86E[\uDC00-\uDC1D\uDC20-\uDFFF]|\uD873[\uDC00-\uDEA1\uDEB0-\uDFFF]|\uD87A[\uDC00-\uDFE0]|\uD87E[\uDC00-\uDE1D]|\uDB40[\uDD00-\uDDEF]/,Object.defineProperty(Z,"__esModule",{value:!0}),Z.JudgeUtil=void 0;const te=Q;Z.JudgeUtil=class{static isIgnoreChar(e){return"string"==typeof e&&("\t"===e||"\v"===e||"\f"===e||" "===e||" "===e||"\ufeff"===e||"\n"===e||"\r"===e||"\u2028"===e||"\u2029"===e)}static isSpaceSeparator(e){return"string"==typeof e&&te.Unicode.Space_Separator.test(e)}static isIdStartChar(e){return"string"==typeof e&&(e>="a"&&e<="z"||e>="A"&&e<="Z"||"$"===e||"_"===e||te.Unicode.ID_Start.test(e))}static isIdContinueChar(e){return"string"==typeof e&&(e>="a"&&e<="z"||e>="A"&&e<="Z"||e>="0"&&e<="9"||"$"===e||"_"===e||"‌"===e||"‍"===e||te.Unicode.ID_Continue.test(e))}static isDigitWithoutZero(e){return/[1-9]/.test(e)}static isDigit(e){return"string"==typeof e&&/[0-9]/.test(e)}static isHexDigit(e){return"string"==typeof e&&/[0-9A-Fa-f]/.test(e)}};var ne={},re={fromCallback:function(e){return Object.defineProperty((function(...t){if("function"!=typeof t[t.length-1])return new Promise(((n,r)=>{e.call(this,...t,((e,t)=>null!=e?r(e):n(t)))}));e.apply(this,t)}),"name",{value:e.name})},fromPromise:function(e){return Object.defineProperty((function(...t){const n=t[t.length-1];if("function"!=typeof n)return e.apply(this,t);e.apply(this,t.slice(0,-1)).then((e=>n(null,e)),n)}),"name",{value:e.name})}},ue=y.default,oe=process.cwd,ie=null,se=process.env.GRACEFUL_FS_PLATFORM||process.platform;process.cwd=function(){return ie||(ie=oe.call(process)),ie};try{process.cwd()}catch(e){}if("function"==typeof process.chdir){var ce=process.chdir;process.chdir=function(e){ie=null,ce.call(process,e)},Object.setPrototypeOf&&Object.setPrototypeOf(process.chdir,ce)}var ae=function(e){ue.hasOwnProperty("O_SYMLINK")&&process.version.match(/^v0\.6\.[0-2]|^v0\.5\./)&&function(e){e.lchmod=function(t,n,r){e.open(t,ue.O_WRONLY|ue.O_SYMLINK,n,(function(t,u){t?r&&r(t):e.fchmod(u,n,(function(t){e.close(u,(function(e){r&&r(t||e)}))}))}))},e.lchmodSync=function(t,n){var r,u=e.openSync(t,ue.O_WRONLY|ue.O_SYMLINK,n),o=!0;try{r=e.fchmodSync(u,n),o=!1}finally{if(o)try{e.closeSync(u)}catch(e){}else e.closeSync(u)}return r}}(e);e.lutimes||function(e){ue.hasOwnProperty("O_SYMLINK")&&e.futimes?(e.lutimes=function(t,n,r,u){e.open(t,ue.O_SYMLINK,(function(t,o){t?u&&u(t):e.futimes(o,n,r,(function(t){e.close(o,(function(e){u&&u(t||e)}))}))}))},e.lutimesSync=function(t,n,r){var u,o=e.openSync(t,ue.O_SYMLINK),i=!0;try{u=e.futimesSync(o,n,r),i=!1}finally{if(i)try{e.closeSync(o)}catch(e){}else e.closeSync(o)}return u}):e.futimes&&(e.lutimes=function(e,t,n,r){r&&process.nextTick(r)},e.lutimesSync=function(){})}(e);e.chown=r(e.chown),e.fchown=r(e.fchown),e.lchown=r(e.lchown),e.chmod=t(e.chmod),e.fchmod=t(e.fchmod),e.lchmod=t(e.lchmod),e.chownSync=u(e.chownSync),e.fchownSync=u(e.fchownSync),e.lchownSync=u(e.lchownSync),e.chmodSync=n(e.chmodSync),e.fchmodSync=n(e.fchmodSync),e.lchmodSync=n(e.lchmodSync),e.stat=o(e.stat),e.fstat=o(e.fstat),e.lstat=o(e.lstat),e.statSync=i(e.statSync),e.fstatSync=i(e.fstatSync),e.lstatSync=i(e.lstatSync),e.chmod&&!e.lchmod&&(e.lchmod=function(e,t,n){n&&process.nextTick(n)},e.lchmodSync=function(){});e.chown&&!e.lchown&&(e.lchown=function(e,t,n,r){r&&process.nextTick(r)},e.lchownSync=function(){});"win32"===se&&(e.rename="function"!=typeof e.rename?e.rename:function(t){function n(n,r,u){var o=Date.now(),i=0;t(n,r,(function s(c){if(c&&("EACCES"===c.code||"EPERM"===c.code||"EBUSY"===c.code)&&Date.now()-o<6e4)return setTimeout((function(){e.stat(r,(function(e,o){e&&"ENOENT"===e.code?t(n,r,s):u(c)}))}),i),void(i<100&&(i+=10));u&&u(c)}))}return Object.setPrototypeOf&&Object.setPrototypeOf(n,t),n}(e.rename));function t(t){return t?function(n,r,u){return t.call(e,n,r,(function(e){s(e)&&(e=null),u&&u.apply(this,arguments)}))}:t}function n(t){return t?function(n,r){try{return t.call(e,n,r)}catch(e){if(!s(e))throw e}}:t}function r(t){return t?function(n,r,u,o){return t.call(e,n,r,u,(function(e){s(e)&&(e=null),o&&o.apply(this,arguments)}))}:t}function u(t){return t?function(n,r,u){try{return t.call(e,n,r,u)}catch(e){if(!s(e))throw e}}:t}function o(t){return t?function(n,r,u){function o(e,t){t&&(t.uid<0&&(t.uid+=4294967296),t.gid<0&&(t.gid+=4294967296)),u&&u.apply(this,arguments)}return"function"==typeof r&&(u=r,r=null),r?t.call(e,n,r,o):t.call(e,n,o)}:t}function i(t){return t?function(n,r){var u=r?t.call(e,n,r):t.call(e,n);return u&&(u.uid<0&&(u.uid+=4294967296),u.gid<0&&(u.gid+=4294967296)),u}:t}function s(e){return!e||("ENOSYS"===e.code||!(process.getuid&&0===process.getuid()||"EINVAL"!==e.code&&"EPERM"!==e.code))}e.read="function"!=typeof e.read?e.read:function(t){function n(n,r,u,o,i,s){var c;if(s&&"function"==typeof s){var a=0;c=function(l,f,d){if(l&&"EAGAIN"===l.code&&a<10)return a++,t.call(e,n,r,u,o,i,c);s.apply(this,arguments)}}return t.call(e,n,r,u,o,i,c)}return Object.setPrototypeOf&&Object.setPrototypeOf(n,t),n}(e.read),e.readSync="function"!=typeof e.readSync?e.readSync:(c=e.readSync,function(t,n,r,u,o){for(var i=0;;)try{return c.call(e,t,n,r,u,o)}catch(e){if("EAGAIN"===e.code&&i<10){i++;continue}throw e}});var c};var le=C.default.Stream,fe=function(e){return{ReadStream:function t(n,r){if(!(this instanceof t))return new t(n,r);le.call(this);var u=this;this.path=n,this.fd=null,this.readable=!0,this.paused=!1,this.flags="r",this.mode=438,this.bufferSize=65536,r=r||{};for(var o=Object.keys(r),i=0,s=o.length;ithis.end)throw new Error("start must be <= end");this.pos=this.start}if(null!==this.fd)return void process.nextTick((function(){u._read()}));e.open(this.path,this.flags,this.mode,(function(e,t){if(e)return u.emit("error",e),void(u.readable=!1);u.fd=t,u.emit("open",t),u._read()}))},WriteStream:function t(n,r){if(!(this instanceof t))return new t(n,r);le.call(this),this.path=n,this.fd=null,this.writable=!0,this.flags="w",this.encoding="binary",this.mode=438,this.bytesWritten=0,r=r||{};for(var u=Object.keys(r),o=0,i=u.length;o= zero");this.pos=this.start}this.busy=!1,this._queue=[],null===this.fd&&(this._open=e.open,this._queue.push([this._open,this.path,this.flags,this.mode,void 0]),this.flush())}}};var de=function(e){if(null===e||"object"!=typeof e)return e;if(e instanceof Object)var t={__proto__:De(e)};else t=Object.create(null);return Object.getOwnPropertyNames(e).forEach((function(n){Object.defineProperty(t,n,Object.getOwnPropertyDescriptor(e,n))})),t},De=Object.getPrototypeOf||function(e){return e.__proto__};var pe,Ee,me=D.default,he=ae,ye=fe,Ce=de,Fe=F.default;function ge(e,t){Object.defineProperty(e,pe,{get:function(){return t}})}"function"==typeof Symbol&&"function"==typeof Symbol.for?(pe=Symbol.for("graceful-fs.queue"),Ee=Symbol.for("graceful-fs.previous")):(pe="___graceful-fs.queue",Ee="___graceful-fs.previous");var Ae=function(){};if(Fe.debuglog?Ae=Fe.debuglog("gfs4"):/\bgfs4\b/i.test(process.env.NODE_DEBUG||"")&&(Ae=function(){var e=Fe.format.apply(Fe,arguments);e="GFS4: "+e.split(/\n/).join("\nGFS4: "),console.error(e)}),!me[pe]){var ve=w[pe]||[];ge(me,ve),me.close=function(e){function t(t,n){return e.call(me,t,(function(e){e||_e(),"function"==typeof n&&n.apply(this,arguments)}))}return Object.defineProperty(t,Ee,{value:e}),t}(me.close),me.closeSync=function(e){function t(t){e.apply(me,arguments),_e()}return Object.defineProperty(t,Ee,{value:e}),t}(me.closeSync),/\bgfs4\b/i.test(process.env.NODE_DEBUG||"")&&process.on("exit",(function(){Ae(me[pe]),g.default.equal(me[pe].length,0)}))}w[pe]||ge(w,me[pe]);var Se,we=Oe(Ce(me));function Oe(e){he(e),e.gracefulify=Oe,e.createReadStream=function(t,n){return new e.ReadStream(t,n)},e.createWriteStream=function(t,n){return new e.WriteStream(t,n)};var t=e.readFile;e.readFile=function(e,n,r){"function"==typeof n&&(r=n,n=null);return function e(n,r,u,o){return t(n,r,(function(t){!t||"EMFILE"!==t.code&&"ENFILE"!==t.code?"function"==typeof u&&u.apply(this,arguments):be([e,[n,r,u],t,o||Date.now(),Date.now()])}))}(e,n,r)};var n=e.writeFile;e.writeFile=function(e,t,r,u){"function"==typeof r&&(u=r,r=null);return function e(t,r,u,o,i){return n(t,r,u,(function(n){!n||"EMFILE"!==n.code&&"ENFILE"!==n.code?"function"==typeof o&&o.apply(this,arguments):be([e,[t,r,u,o],n,i||Date.now(),Date.now()])}))}(e,t,r,u)};var r=e.appendFile;r&&(e.appendFile=function(e,t,n,u){"function"==typeof n&&(u=n,n=null);return function e(t,n,u,o,i){return r(t,n,u,(function(r){!r||"EMFILE"!==r.code&&"ENFILE"!==r.code?"function"==typeof o&&o.apply(this,arguments):be([e,[t,n,u,o],r,i||Date.now(),Date.now()])}))}(e,t,n,u)});var u=e.copyFile;u&&(e.copyFile=function(e,t,n,r){"function"==typeof n&&(r=n,n=0);return function e(t,n,r,o,i){return u(t,n,r,(function(u){!u||"EMFILE"!==u.code&&"ENFILE"!==u.code?"function"==typeof o&&o.apply(this,arguments):be([e,[t,n,r,o],u,i||Date.now(),Date.now()])}))}(e,t,n,r)});var o=e.readdir;e.readdir=function(e,t,n){"function"==typeof t&&(n=t,t=null);var r=i.test(process.version)?function(e,t,n,r){return o(e,u(e,t,n,r))}:function(e,t,n,r){return o(e,t,u(e,t,n,r))};return r(e,t,n);function u(e,t,n,u){return function(o,i){!o||"EMFILE"!==o.code&&"ENFILE"!==o.code?(i&&i.sort&&i.sort(),"function"==typeof n&&n.call(this,o,i)):be([r,[e,t,n],o,u||Date.now(),Date.now()])}}};var i=/^v[0-5]\./;if("v0.8"===process.version.substr(0,4)){var s=ye(e);d=s.ReadStream,D=s.WriteStream}var c=e.ReadStream;c&&(d.prototype=Object.create(c.prototype),d.prototype.open=function(){var e=this;E(e.path,e.flags,e.mode,(function(t,n){t?(e.autoClose&&e.destroy(),e.emit("error",t)):(e.fd=n,e.emit("open",n),e.read())}))});var a=e.WriteStream;a&&(D.prototype=Object.create(a.prototype),D.prototype.open=function(){var e=this;E(e.path,e.flags,e.mode,(function(t,n){t?(e.destroy(),e.emit("error",t)):(e.fd=n,e.emit("open",n))}))}),Object.defineProperty(e,"ReadStream",{get:function(){return d},set:function(e){d=e},enumerable:!0,configurable:!0}),Object.defineProperty(e,"WriteStream",{get:function(){return D},set:function(e){D=e},enumerable:!0,configurable:!0});var l=d;Object.defineProperty(e,"FileReadStream",{get:function(){return l},set:function(e){l=e},enumerable:!0,configurable:!0});var f=D;function d(e,t){return this instanceof d?(c.apply(this,arguments),this):d.apply(Object.create(d.prototype),arguments)}function D(e,t){return this instanceof D?(a.apply(this,arguments),this):D.apply(Object.create(D.prototype),arguments)}Object.defineProperty(e,"FileWriteStream",{get:function(){return f},set:function(e){f=e},enumerable:!0,configurable:!0});var p=e.open;function E(e,t,n,r){return"function"==typeof n&&(r=n,n=null),function e(t,n,r,u,o){return p(t,n,r,(function(i,s){!i||"EMFILE"!==i.code&&"ENFILE"!==i.code?"function"==typeof u&&u.apply(this,arguments):be([e,[t,n,r,u],i,o||Date.now(),Date.now()])}))}(e,t,n,r)}return e.open=E,e}function be(e){Ae("ENQUEUE",e[0].name,e[1]),me[pe].push(e),Be()}function _e(){for(var e=Date.now(),t=0;t2&&(me[pe][t][3]=e,me[pe][t][4]=e);Be()}function Be(){if(clearTimeout(Se),Se=void 0,0!==me[pe].length){var e=me[pe].shift(),t=e[0],n=e[1],r=e[2],u=e[3],o=e[4];if(void 0===u)Ae("RETRY",t.name,n),t.apply(null,n);else if(Date.now()-u>=6e4){Ae("TIMEOUT",t.name,n);var i=n.pop();"function"==typeof i&&i.call(null,r)}else{var s=Date.now()-o,c=Math.max(o-u,1);s>=Math.min(1.2*c,100)?(Ae("RETRY",t.name,n),t.apply(null,n.concat([u]))):me[pe].push(e)}void 0===Se&&(Se=setTimeout(Be,0))}}process.env.TEST_GRACEFUL_FS_GLOBAL_PATCH&&!me.__patched&&(we=Oe(me),me.__patched=!0),function(e){const t=re.fromCallback,n=we,r=["access","appendFile","chmod","chown","close","copyFile","fchmod","fchown","fdatasync","fstat","fsync","ftruncate","futimes","lchmod","lchown","link","lstat","mkdir","mkdtemp","open","opendir","readdir","readFile","readlink","realpath","rename","rm","rmdir","stat","symlink","truncate","unlink","utimes","writeFile"].filter((e=>"function"==typeof n[e]));Object.assign(e,n),r.forEach((r=>{e[r]=t(n[r])})),e.realpath.native=t(n.realpath.native),e.exists=function(e,t){return"function"==typeof t?n.exists(e,t):new Promise((t=>n.exists(e,t)))},e.read=function(e,t,r,u,o,i){return"function"==typeof i?n.read(e,t,r,u,o,i):new Promise(((i,s)=>{n.read(e,t,r,u,o,((e,t,n)=>{if(e)return s(e);i({bytesRead:t,buffer:n})}))}))},e.write=function(e,t,...r){return"function"==typeof r[r.length-1]?n.write(e,t,...r):new Promise(((u,o)=>{n.write(e,t,...r,((e,t,n)=>{if(e)return o(e);u({bytesWritten:t,buffer:n})}))}))},"function"==typeof n.writev&&(e.writev=function(e,t,...r){return"function"==typeof r[r.length-1]?n.writev(e,t,...r):new Promise(((u,o)=>{n.writev(e,t,...r,((e,t,n)=>{if(e)return o(e);u({bytesWritten:t,buffers:n})}))}))})}(ne);var Pe={},ke={};const xe=p.default;ke.checkPath=function(e){if("win32"===process.platform){if(/[<>:"|?*]/.test(e.replace(xe.parse(e).root,""))){const t=new Error(`Path contains invalid characters: ${e}`);throw t.code="EINVAL",t}}};const Ne=ne,{checkPath:Ie}=ke,Te=e=>"number"==typeof e?e:{mode:511,...e}.mode;Pe.makeDir=async(e,t)=>(Ie(e),Ne.mkdir(e,{mode:Te(t),recursive:!0})),Pe.makeDirSync=(e,t)=>(Ie(e),Ne.mkdirSync(e,{mode:Te(t),recursive:!0}));const Re=re.fromPromise,{makeDir:Me,makeDirSync:Le}=Pe,je=Re(Me);var $e={mkdirs:je,mkdirsSync:Le,mkdirp:je,mkdirpSync:Le,ensureDir:je,ensureDirSync:Le};const He=re.fromPromise,Je=ne;var Ge={pathExists:He((function(e){return Je.access(e).then((()=>!0)).catch((()=>!1))})),pathExistsSync:Je.existsSync};const Ve=we;var Ue=function(e,t,n,r){Ve.open(e,"r+",((e,u)=>{if(e)return r(e);Ve.futimes(u,t,n,(e=>{Ve.close(u,(t=>{r&&r(e||t)}))}))}))},We=function(e,t,n){const r=Ve.openSync(e,"r+");return Ve.futimesSync(r,t,n),Ve.closeSync(r)};const ze=ne,Ke=p.default,qe=F.default;function Ye(e,t,n){const r=n.dereference?e=>ze.stat(e,{bigint:!0}):e=>ze.lstat(e,{bigint:!0});return Promise.all([r(e),r(t).catch((e=>{if("ENOENT"===e.code)return null;throw e}))]).then((([e,t])=>({srcStat:e,destStat:t})))}function Xe(e,t){return t.ino&&t.dev&&t.ino===e.ino&&t.dev===e.dev}function Ze(e,t){const n=Ke.resolve(e).split(Ke.sep).filter((e=>e)),r=Ke.resolve(t).split(Ke.sep).filter((e=>e));return n.reduce(((e,t,n)=>e&&r[n]===t),!0)}function Qe(e,t,n){return`Cannot ${n} '${e}' to a subdirectory of itself, '${t}'.`}var et={checkPaths:function(e,t,n,r,u){qe.callbackify(Ye)(e,t,r,((r,o)=>{if(r)return u(r);const{srcStat:i,destStat:s}=o;if(s){if(Xe(i,s)){const r=Ke.basename(e),o=Ke.basename(t);return"move"===n&&r!==o&&r.toLowerCase()===o.toLowerCase()?u(null,{srcStat:i,destStat:s,isChangingCase:!0}):u(new Error("Source and destination must not be the same."))}if(i.isDirectory()&&!s.isDirectory())return u(new Error(`Cannot overwrite non-directory '${t}' with directory '${e}'.`));if(!i.isDirectory()&&s.isDirectory())return u(new Error(`Cannot overwrite directory '${t}' with non-directory '${e}'.`))}return i.isDirectory()&&Ze(e,t)?u(new Error(Qe(e,t,n))):u(null,{srcStat:i,destStat:s})}))},checkPathsSync:function(e,t,n,r){const{srcStat:u,destStat:o}=function(e,t,n){let r;const u=n.dereference?e=>ze.statSync(e,{bigint:!0}):e=>ze.lstatSync(e,{bigint:!0}),o=u(e);try{r=u(t)}catch(e){if("ENOENT"===e.code)return{srcStat:o,destStat:null};throw e}return{srcStat:o,destStat:r}}(e,t,r);if(o){if(Xe(u,o)){const r=Ke.basename(e),i=Ke.basename(t);if("move"===n&&r!==i&&r.toLowerCase()===i.toLowerCase())return{srcStat:u,destStat:o,isChangingCase:!0};throw new Error("Source and destination must not be the same.")}if(u.isDirectory()&&!o.isDirectory())throw new Error(`Cannot overwrite non-directory '${t}' with directory '${e}'.`);if(!u.isDirectory()&&o.isDirectory())throw new Error(`Cannot overwrite directory '${t}' with non-directory '${e}'.`)}if(u.isDirectory()&&Ze(e,t))throw new Error(Qe(e,t,n));return{srcStat:u,destStat:o}},checkParentPaths:function e(t,n,r,u,o){const i=Ke.resolve(Ke.dirname(t)),s=Ke.resolve(Ke.dirname(r));if(s===i||s===Ke.parse(s).root)return o();ze.stat(s,{bigint:!0},((i,c)=>i?"ENOENT"===i.code?o():o(i):Xe(n,c)?o(new Error(Qe(t,r,u))):e(t,n,s,u,o)))},checkParentPathsSync:function e(t,n,r,u){const o=Ke.resolve(Ke.dirname(t)),i=Ke.resolve(Ke.dirname(r));if(i===o||i===Ke.parse(i).root)return;let s;try{s=ze.statSync(i,{bigint:!0})}catch(e){if("ENOENT"===e.code)return;throw e}if(Xe(n,s))throw new Error(Qe(t,r,u));return e(t,n,i,u)},isSrcSubdir:Ze,areIdentical:Xe};const tt=we,nt=p.default,rt=$e.mkdirs,ut=Ge.pathExists,ot=Ue,it=et;function st(e,t,n,r,u){const o=nt.dirname(n);ut(o,((i,s)=>i?u(i):s?at(e,t,n,r,u):void rt(o,(o=>o?u(o):at(e,t,n,r,u)))))}function ct(e,t,n,r,u,o){Promise.resolve(u.filter(n,r)).then((i=>i?e(t,n,r,u,o):o()),(e=>o(e)))}function at(e,t,n,r,u){(r.dereference?tt.stat:tt.lstat)(t,((o,i)=>o?u(o):i.isDirectory()?function(e,t,n,r,u,o){return t?Dt(n,r,u,o):function(e,t,n,r,u){tt.mkdir(n,(o=>{if(o)return u(o);Dt(t,n,r,(t=>t?u(t):dt(n,e,u)))}))}(e.mode,n,r,u,o)}(i,e,t,n,r,u):i.isFile()||i.isCharacterDevice()||i.isBlockDevice()?function(e,t,n,r,u,o){return t?function(e,t,n,r,u){if(!r.overwrite)return r.errorOnExist?u(new Error(`'${n}' already exists`)):u();tt.unlink(n,(o=>o?u(o):lt(e,t,n,r,u)))}(e,n,r,u,o):lt(e,n,r,u,o)}(i,e,t,n,r,u):i.isSymbolicLink()?function(e,t,n,r,u){tt.readlink(t,((t,o)=>t?u(t):(r.dereference&&(o=nt.resolve(process.cwd(),o)),e?void tt.readlink(n,((t,i)=>t?"EINVAL"===t.code||"UNKNOWN"===t.code?tt.symlink(o,n,u):u(t):(r.dereference&&(i=nt.resolve(process.cwd(),i)),it.isSrcSubdir(o,i)?u(new Error(`Cannot copy '${o}' to a subdirectory of itself, '${i}'.`)):e.isDirectory()&&it.isSrcSubdir(i,o)?u(new Error(`Cannot overwrite '${i}' with '${o}'.`)):function(e,t,n){tt.unlink(t,(r=>r?n(r):tt.symlink(e,t,n)))}(o,n,u)))):tt.symlink(o,n,u))))}(e,t,n,r,u):i.isSocket()?u(new Error(`Cannot copy a socket file: ${t}`)):i.isFIFO()?u(new Error(`Cannot copy a FIFO pipe: ${t}`)):u(new Error(`Unknown file: ${t}`))))}function lt(e,t,n,r,u){tt.copyFile(t,n,(o=>o?u(o):r.preserveTimestamps?function(e,t,n,r){if(function(e){return 0==(128&e)}(e))return function(e,t,n){return dt(e,128|t,n)}(n,e,(u=>u?r(u):ft(e,t,n,r)));return ft(e,t,n,r)}(e.mode,t,n,u):dt(n,e.mode,u)))}function ft(e,t,n,r){!function(e,t,n){tt.stat(e,((e,r)=>e?n(e):ot(t,r.atime,r.mtime,n)))}(t,n,(t=>t?r(t):dt(n,e,r)))}function dt(e,t,n){return tt.chmod(e,t,n)}function Dt(e,t,n,r){tt.readdir(e,((u,o)=>u?r(u):pt(o,e,t,n,r)))}function pt(e,t,n,r,u){const o=e.pop();return o?function(e,t,n,r,u,o){const i=nt.join(n,t),s=nt.join(r,t);it.checkPaths(i,s,"copy",u,((t,c)=>{if(t)return o(t);const{destStat:a}=c;!function(e,t,n,r,u){r.filter?ct(at,e,t,n,r,u):at(e,t,n,r,u)}(a,i,s,u,(t=>t?o(t):pt(e,n,r,u,o)))}))}(e,o,t,n,r,u):u()}var Et=function(e,t,n,r){"function"!=typeof n||r?"function"==typeof n&&(n={filter:n}):(r=n,n={}),r=r||function(){},(n=n||{}).clobber=!("clobber"in n)||!!n.clobber,n.overwrite="overwrite"in n?!!n.overwrite:n.clobber,n.preserveTimestamps&&"ia32"===process.arch&&console.warn("fs-extra: Using the preserveTimestamps option in 32-bit node is not recommended;\n\n see https://github.com/jprichardson/node-fs-extra/issues/269"),it.checkPaths(e,t,"copy",n,((u,o)=>{if(u)return r(u);const{srcStat:i,destStat:s}=o;it.checkParentPaths(e,i,t,"copy",(u=>u?r(u):n.filter?ct(st,s,e,t,n,r):st(s,e,t,n,r)))}))};const mt=we,ht=p.default,yt=$e.mkdirsSync,Ct=We,Ft=et;function gt(e,t,n,r){const u=(r.dereference?mt.statSync:mt.lstatSync)(t);if(u.isDirectory())return function(e,t,n,r,u){return t?St(n,r,u):function(e,t,n,r){return mt.mkdirSync(n),St(t,n,r),vt(n,e)}(e.mode,n,r,u)}(u,e,t,n,r);if(u.isFile()||u.isCharacterDevice()||u.isBlockDevice())return function(e,t,n,r,u){return t?function(e,t,n,r){if(r.overwrite)return mt.unlinkSync(n),At(e,t,n,r);if(r.errorOnExist)throw new Error(`'${n}' already exists`)}(e,n,r,u):At(e,n,r,u)}(u,e,t,n,r);if(u.isSymbolicLink())return function(e,t,n,r){let u=mt.readlinkSync(t);r.dereference&&(u=ht.resolve(process.cwd(),u));if(e){let e;try{e=mt.readlinkSync(n)}catch(e){if("EINVAL"===e.code||"UNKNOWN"===e.code)return mt.symlinkSync(u,n);throw e}if(r.dereference&&(e=ht.resolve(process.cwd(),e)),Ft.isSrcSubdir(u,e))throw new Error(`Cannot copy '${u}' to a subdirectory of itself, '${e}'.`);if(mt.statSync(n).isDirectory()&&Ft.isSrcSubdir(e,u))throw new Error(`Cannot overwrite '${e}' with '${u}'.`);return function(e,t){return mt.unlinkSync(t),mt.symlinkSync(e,t)}(u,n)}return mt.symlinkSync(u,n)}(e,t,n,r);if(u.isSocket())throw new Error(`Cannot copy a socket file: ${t}`);if(u.isFIFO())throw new Error(`Cannot copy a FIFO pipe: ${t}`);throw new Error(`Unknown file: ${t}`)}function At(e,t,n,r){return mt.copyFileSync(t,n),r.preserveTimestamps&&function(e,t,n){(function(e){return 0==(128&e)})(e)&&function(e,t){vt(e,128|t)}(n,e);(function(e,t){const n=mt.statSync(e);Ct(t,n.atime,n.mtime)})(t,n)}(e.mode,t,n),vt(n,e.mode)}function vt(e,t){return mt.chmodSync(e,t)}function St(e,t,n){mt.readdirSync(e).forEach((r=>function(e,t,n,r){const u=ht.join(t,e),o=ht.join(n,e),{destStat:i}=Ft.checkPathsSync(u,o,"copy",r);return function(e,t,n,r){if(!r.filter||r.filter(t,n))return gt(e,t,n,r)}(i,u,o,r)}(r,e,t,n)))}var wt=function(e,t,n){"function"==typeof n&&(n={filter:n}),(n=n||{}).clobber=!("clobber"in n)||!!n.clobber,n.overwrite="overwrite"in n?!!n.overwrite:n.clobber,n.preserveTimestamps&&"ia32"===process.arch&&console.warn("fs-extra: Using the preserveTimestamps option in 32-bit node is not recommended;\n\n see https://github.com/jprichardson/node-fs-extra/issues/269");const{srcStat:r,destStat:u}=Ft.checkPathsSync(e,t,"copy",n);return Ft.checkParentPathsSync(e,r,t,"copy"),function(e,t,n,r){if(r.filter&&!r.filter(t,n))return;const u=ht.dirname(n);mt.existsSync(u)||yt(u);return gt(e,t,n,r)}(u,e,t,n)};var Ot={copy:(0,re.fromCallback)(Et),copySync:wt};const bt=we,_t=p.default,Bt=g.default,Pt="win32"===process.platform;function kt(e){["unlink","chmod","stat","lstat","rmdir","readdir"].forEach((t=>{e[t]=e[t]||bt[t],e[t+="Sync"]=e[t]||bt[t]})),e.maxBusyTries=e.maxBusyTries||3}function xt(e,t,n){let r=0;"function"==typeof t&&(n=t,t={}),Bt(e,"rimraf: missing path"),Bt.strictEqual(typeof e,"string","rimraf: path should be a string"),Bt.strictEqual(typeof n,"function","rimraf: callback function required"),Bt(t,"rimraf: invalid options argument provided"),Bt.strictEqual(typeof t,"object","rimraf: options should be object"),kt(t),Nt(e,t,(function u(o){if(o){if(("EBUSY"===o.code||"ENOTEMPTY"===o.code||"EPERM"===o.code)&&rNt(e,t,u)),100*r)}"ENOENT"===o.code&&(o=null)}n(o)}))}function Nt(e,t,n){Bt(e),Bt(t),Bt("function"==typeof n),t.lstat(e,((r,u)=>r&&"ENOENT"===r.code?n(null):r&&"EPERM"===r.code&&Pt?It(e,t,r,n):u&&u.isDirectory()?Rt(e,t,r,n):void t.unlink(e,(r=>{if(r){if("ENOENT"===r.code)return n(null);if("EPERM"===r.code)return Pt?It(e,t,r,n):Rt(e,t,r,n);if("EISDIR"===r.code)return Rt(e,t,r,n)}return n(r)}))))}function It(e,t,n,r){Bt(e),Bt(t),Bt("function"==typeof r),t.chmod(e,438,(u=>{u?r("ENOENT"===u.code?null:n):t.stat(e,((u,o)=>{u?r("ENOENT"===u.code?null:n):o.isDirectory()?Rt(e,t,n,r):t.unlink(e,r)}))}))}function Tt(e,t,n){let r;Bt(e),Bt(t);try{t.chmodSync(e,438)}catch(e){if("ENOENT"===e.code)return;throw n}try{r=t.statSync(e)}catch(e){if("ENOENT"===e.code)return;throw n}r.isDirectory()?Lt(e,t,n):t.unlinkSync(e)}function Rt(e,t,n,r){Bt(e),Bt(t),Bt("function"==typeof r),t.rmdir(e,(u=>{!u||"ENOTEMPTY"!==u.code&&"EEXIST"!==u.code&&"EPERM"!==u.code?u&&"ENOTDIR"===u.code?r(n):r(u):function(e,t,n){Bt(e),Bt(t),Bt("function"==typeof n),t.readdir(e,((r,u)=>{if(r)return n(r);let o,i=u.length;if(0===i)return t.rmdir(e,n);u.forEach((r=>{xt(_t.join(e,r),t,(r=>{if(!o)return r?n(o=r):void(0==--i&&t.rmdir(e,n))}))}))}))}(e,t,r)}))}function Mt(e,t){let n;kt(t=t||{}),Bt(e,"rimraf: missing path"),Bt.strictEqual(typeof e,"string","rimraf: path should be a string"),Bt(t,"rimraf: missing options"),Bt.strictEqual(typeof t,"object","rimraf: options should be object");try{n=t.lstatSync(e)}catch(n){if("ENOENT"===n.code)return;"EPERM"===n.code&&Pt&&Tt(e,t,n)}try{n&&n.isDirectory()?Lt(e,t,null):t.unlinkSync(e)}catch(n){if("ENOENT"===n.code)return;if("EPERM"===n.code)return Pt?Tt(e,t,n):Lt(e,t,n);if("EISDIR"!==n.code)throw n;Lt(e,t,n)}}function Lt(e,t,n){Bt(e),Bt(t);try{t.rmdirSync(e)}catch(r){if("ENOTDIR"===r.code)throw n;if("ENOTEMPTY"===r.code||"EEXIST"===r.code||"EPERM"===r.code)!function(e,t){if(Bt(e),Bt(t),t.readdirSync(e).forEach((n=>Mt(_t.join(e,n),t))),!Pt){return t.rmdirSync(e,t)}{const n=Date.now();do{try{return t.rmdirSync(e,t)}catch{}}while(Date.now()-n<500)}}(e,t);else if("ENOENT"!==r.code)throw r}}var jt=xt;xt.sync=Mt;const $t=we,Ht=re.fromCallback,Jt=jt;var Gt={remove:Ht((function(e,t){if($t.rm)return $t.rm(e,{recursive:!0,force:!0},t);Jt(e,t)})),removeSync:function(e){if($t.rmSync)return $t.rmSync(e,{recursive:!0,force:!0});Jt.sync(e)}};const Vt=re.fromPromise,Ut=ne,Wt=p.default,zt=$e,Kt=Gt,qt=Vt((async function(e){let t;try{t=await Ut.readdir(e)}catch{return zt.mkdirs(e)}return Promise.all(t.map((t=>Kt.remove(Wt.join(e,t)))))}));function Yt(e){let t;try{t=Ut.readdirSync(e)}catch{return zt.mkdirsSync(e)}t.forEach((t=>{t=Wt.join(e,t),Kt.removeSync(t)}))}var Xt={emptyDirSync:Yt,emptydirSync:Yt,emptyDir:qt,emptydir:qt};const Zt=re.fromCallback,Qt=p.default,en=we,tn=$e;var nn={createFile:Zt((function(e,t){function n(){en.writeFile(e,"",(e=>{if(e)return t(e);t()}))}en.stat(e,((r,u)=>{if(!r&&u.isFile())return t();const o=Qt.dirname(e);en.stat(o,((e,r)=>{if(e)return"ENOENT"===e.code?tn.mkdirs(o,(e=>{if(e)return t(e);n()})):t(e);r.isDirectory()?n():en.readdir(o,(e=>{if(e)return t(e)}))}))}))})),createFileSync:function(e){let t;try{t=en.statSync(e)}catch{}if(t&&t.isFile())return;const n=Qt.dirname(e);try{en.statSync(n).isDirectory()||en.readdirSync(n)}catch(e){if(!e||"ENOENT"!==e.code)throw e;tn.mkdirsSync(n)}en.writeFileSync(e,"")}};const rn=re.fromCallback,un=p.default,on=we,sn=$e,cn=Ge.pathExists,{areIdentical:an}=et;var ln={createLink:rn((function(e,t,n){function r(e,t){on.link(e,t,(e=>{if(e)return n(e);n(null)}))}on.lstat(t,((u,o)=>{on.lstat(e,((u,i)=>{if(u)return u.message=u.message.replace("lstat","ensureLink"),n(u);if(o&&an(i,o))return n(null);const s=un.dirname(t);cn(s,((u,o)=>u?n(u):o?r(e,t):void sn.mkdirs(s,(u=>{if(u)return n(u);r(e,t)}))))}))}))})),createLinkSync:function(e,t){let n;try{n=on.lstatSync(t)}catch{}try{const t=on.lstatSync(e);if(n&&an(t,n))return}catch(e){throw e.message=e.message.replace("lstat","ensureLink"),e}const r=un.dirname(t);return on.existsSync(r)||sn.mkdirsSync(r),on.linkSync(e,t)}};const fn=p.default,dn=we,Dn=Ge.pathExists;var pn={symlinkPaths:function(e,t,n){if(fn.isAbsolute(e))return dn.lstat(e,(t=>t?(t.message=t.message.replace("lstat","ensureSymlink"),n(t)):n(null,{toCwd:e,toDst:e})));{const r=fn.dirname(t),u=fn.join(r,e);return Dn(u,((t,o)=>t?n(t):o?n(null,{toCwd:u,toDst:e}):dn.lstat(e,(t=>t?(t.message=t.message.replace("lstat","ensureSymlink"),n(t)):n(null,{toCwd:e,toDst:fn.relative(r,e)})))))}},symlinkPathsSync:function(e,t){let n;if(fn.isAbsolute(e)){if(n=dn.existsSync(e),!n)throw new Error("absolute srcpath does not exist");return{toCwd:e,toDst:e}}{const r=fn.dirname(t),u=fn.join(r,e);if(n=dn.existsSync(u),n)return{toCwd:u,toDst:e};if(n=dn.existsSync(e),!n)throw new Error("relative srcpath does not exist");return{toCwd:e,toDst:fn.relative(r,e)}}}};const En=we;var mn={symlinkType:function(e,t,n){if(n="function"==typeof t?t:n,t="function"!=typeof t&&t)return n(null,t);En.lstat(e,((e,r)=>{if(e)return n(null,"file");t=r&&r.isDirectory()?"dir":"file",n(null,t)}))},symlinkTypeSync:function(e,t){let n;if(t)return t;try{n=En.lstatSync(e)}catch{return"file"}return n&&n.isDirectory()?"dir":"file"}};const hn=re.fromCallback,yn=p.default,Cn=ne,Fn=$e.mkdirs,gn=$e.mkdirsSync,An=pn.symlinkPaths,vn=pn.symlinkPathsSync,Sn=mn.symlinkType,wn=mn.symlinkTypeSync,On=Ge.pathExists,{areIdentical:bn}=et;function _n(e,t,n,r){An(e,t,((u,o)=>{if(u)return r(u);e=o.toDst,Sn(o.toCwd,n,((n,u)=>{if(n)return r(n);const o=yn.dirname(t);On(o,((n,i)=>n?r(n):i?Cn.symlink(e,t,u,r):void Fn(o,(n=>{if(n)return r(n);Cn.symlink(e,t,u,r)}))))}))}))}var Bn={createSymlink:hn((function(e,t,n,r){r="function"==typeof n?n:r,n="function"!=typeof n&&n,Cn.lstat(t,((u,o)=>{!u&&o.isSymbolicLink()?Promise.all([Cn.stat(e),Cn.stat(t)]).then((([u,o])=>{if(bn(u,o))return r(null);_n(e,t,n,r)})):_n(e,t,n,r)}))})),createSymlinkSync:function(e,t,n){let r;try{r=Cn.lstatSync(t)}catch{}if(r&&r.isSymbolicLink()){const n=Cn.statSync(e),r=Cn.statSync(t);if(bn(n,r))return}const u=vn(e,t);e=u.toDst,n=wn(u.toCwd,n);const o=yn.dirname(t);return Cn.existsSync(o)||gn(o),Cn.symlinkSync(e,t,n)}};const{createFile:Pn,createFileSync:kn}=nn,{createLink:xn,createLinkSync:Nn}=ln,{createSymlink:In,createSymlinkSync:Tn}=Bn;var Rn={createFile:Pn,createFileSync:kn,ensureFile:Pn,ensureFileSync:kn,createLink:xn,createLinkSync:Nn,ensureLink:xn,ensureLinkSync:Nn,createSymlink:In,createSymlinkSync:Tn,ensureSymlink:In,ensureSymlinkSync:Tn};var Mn={stringify:function(e,{EOL:t="\n",finalEOL:n=!0,replacer:r=null,spaces:u}={}){const o=n?t:"";return JSON.stringify(e,r,u).replace(/\n/g,t)+o},stripBom:function(e){return Buffer.isBuffer(e)&&(e=e.toString("utf8")),e.replace(/^\uFEFF/,"")}};let Ln;try{Ln=we}catch(e){Ln=D.default}const jn=re,{stringify:$n,stripBom:Hn}=Mn;const Jn=jn.fromPromise((async function(e,t={}){"string"==typeof t&&(t={encoding:t});const n=t.fs||Ln,r=!("throws"in t)||t.throws;let u,o=await jn.fromCallback(n.readFile)(e,t);o=Hn(o);try{u=JSON.parse(o,t?t.reviver:null)}catch(t){if(r)throw t.message=`${e}: ${t.message}`,t;return null}return u}));const Gn=jn.fromPromise((async function(e,t,n={}){const r=n.fs||Ln,u=$n(t,n);await jn.fromCallback(r.writeFile)(e,u,n)}));const Vn={readFile:Jn,readFileSync:function(e,t={}){"string"==typeof t&&(t={encoding:t});const n=t.fs||Ln,r=!("throws"in t)||t.throws;try{let r=n.readFileSync(e,t);return r=Hn(r),JSON.parse(r,t.reviver)}catch(t){if(r)throw t.message=`${e}: ${t.message}`,t;return null}},writeFile:Gn,writeFileSync:function(e,t,n={}){const r=n.fs||Ln,u=$n(t,n);return r.writeFileSync(e,u,n)}};var Un={readJson:Vn.readFile,readJsonSync:Vn.readFileSync,writeJson:Vn.writeFile,writeJsonSync:Vn.writeFileSync};const Wn=re.fromCallback,zn=we,Kn=p.default,qn=$e,Yn=Ge.pathExists;var Xn={outputFile:Wn((function(e,t,n,r){"function"==typeof n&&(r=n,n="utf8");const u=Kn.dirname(e);Yn(u,((o,i)=>o?r(o):i?zn.writeFile(e,t,n,r):void qn.mkdirs(u,(u=>{if(u)return r(u);zn.writeFile(e,t,n,r)}))))})),outputFileSync:function(e,...t){const n=Kn.dirname(e);if(zn.existsSync(n))return zn.writeFileSync(e,...t);qn.mkdirsSync(n),zn.writeFileSync(e,...t)}};const{stringify:Zn}=Mn,{outputFile:Qn}=Xn;var er=async function(e,t,n={}){const r=Zn(t,n);await Qn(e,r,n)};const{stringify:tr}=Mn,{outputFileSync:nr}=Xn;var rr=function(e,t,n){const r=tr(t,n);nr(e,r,n)};const ur=re.fromPromise,or=Un;or.outputJson=ur(er),or.outputJsonSync=rr,or.outputJSON=or.outputJson,or.outputJSONSync=or.outputJsonSync,or.writeJSON=or.writeJson,or.writeJSONSync=or.writeJsonSync,or.readJSON=or.readJson,or.readJSONSync=or.readJsonSync;var ir=or;const sr=we,cr=p.default,ar=Ot.copy,lr=Gt.remove,fr=$e.mkdirp,dr=Ge.pathExists,Dr=et;function pr(e,t,n,r,u){return r?Er(e,t,n,u):n?lr(t,(r=>r?u(r):Er(e,t,n,u))):void dr(t,((r,o)=>r?u(r):o?u(new Error("dest already exists.")):Er(e,t,n,u)))}function Er(e,t,n,r){sr.rename(e,t,(u=>u?"EXDEV"!==u.code?r(u):function(e,t,n,r){const u={overwrite:n,errorOnExist:!0};ar(e,t,u,(t=>t?r(t):lr(e,r)))}(e,t,n,r):r()))}var mr=function(e,t,n,r){"function"==typeof n&&(r=n,n={});const u=n.overwrite||n.clobber||!1;Dr.checkPaths(e,t,"move",n,((n,o)=>{if(n)return r(n);const{srcStat:i,isChangingCase:s=!1}=o;Dr.checkParentPaths(e,i,t,"move",(n=>n?r(n):function(e){const t=cr.dirname(e);return cr.parse(t).root===t}(t)?pr(e,t,u,s,r):void fr(cr.dirname(t),(n=>n?r(n):pr(e,t,u,s,r)))))}))};const hr=we,yr=p.default,Cr=Ot.copySync,Fr=Gt.removeSync,gr=$e.mkdirpSync,Ar=et;function vr(e,t,n){try{hr.renameSync(e,t)}catch(r){if("EXDEV"!==r.code)throw r;return function(e,t,n){const r={overwrite:n,errorOnExist:!0};return Cr(e,t,r),Fr(e)}(e,t,n)}}var Sr=function(e,t,n){const r=(n=n||{}).overwrite||n.clobber||!1,{srcStat:u,isChangingCase:o=!1}=Ar.checkPathsSync(e,t,"move",n);return Ar.checkParentPathsSync(e,u,t,"move"),function(e){const t=yr.dirname(e);return yr.parse(t).root===t}(t)||gr(yr.dirname(t)),function(e,t,n,r){if(r)return vr(e,t,n);if(n)return Fr(t),vr(e,t,n);if(hr.existsSync(t))throw new Error("dest already exists.");return vr(e,t,n)}(e,t,r,o)};var wr,Or,br,_r,Br,Pr={move:(0,re.fromCallback)(mr),moveSync:Sr},kr={...ne,...Ot,...Xt,...Rn,...ir,...$e,...Pr,...Xn,...Ge,...Gt},xr={},Nr={exports:{}},Ir={exports:{}};function Tr(){if(Or)return wr;Or=1;var e=1e3,t=60*e,n=60*t,r=24*n,u=7*r,o=365.25*r;function i(e,t,n,r){var u=t>=1.5*n;return Math.round(e/n)+" "+r+(u?"s":"")}return wr=function(s,c){c=c||{};var a=typeof s;if("string"===a&&s.length>0)return function(i){if((i=String(i)).length>100)return;var s=/^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(i);if(!s)return;var c=parseFloat(s[1]);switch((s[2]||"ms").toLowerCase()){case"years":case"year":case"yrs":case"yr":case"y":return c*o;case"weeks":case"week":case"w":return c*u;case"days":case"day":case"d":return c*r;case"hours":case"hour":case"hrs":case"hr":case"h":return c*n;case"minutes":case"minute":case"mins":case"min":case"m":return c*t;case"seconds":case"second":case"secs":case"sec":case"s":return c*e;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return c;default:return}}(s);if("number"===a&&isFinite(s))return c.long?function(u){var o=Math.abs(u);if(o>=r)return i(u,o,r,"day");if(o>=n)return i(u,o,n,"hour");if(o>=t)return i(u,o,t,"minute");if(o>=e)return i(u,o,e,"second");return u+" ms"}(s):function(u){var o=Math.abs(u);if(o>=r)return Math.round(u/r)+"d";if(o>=n)return Math.round(u/n)+"h";if(o>=t)return Math.round(u/t)+"m";if(o>=e)return Math.round(u/e)+"s";return u+"ms"}(s);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(s))}}function Rr(){if(_r)return br;return _r=1,br=function(e){function t(e){let r,u,o,i=null;function s(...e){if(!s.enabled)return;const n=s,u=Number(new Date),o=u-(r||u);n.diff=o,n.prev=r,n.curr=u,r=u,e[0]=t.coerce(e[0]),"string"!=typeof e[0]&&e.unshift("%O");let i=0;e[0]=e[0].replace(/%([a-zA-Z%])/g,((r,u)=>{if("%%"===r)return"%";i++;const o=t.formatters[u];if("function"==typeof o){const t=e[i];r=o.call(n,t),e.splice(i,1),i--}return r})),t.formatArgs.call(n,e);(n.log||t.log).apply(n,e)}return s.namespace=e,s.useColors=t.useColors(),s.color=t.selectColor(e),s.extend=n,s.destroy=t.destroy,Object.defineProperty(s,"enabled",{enumerable:!0,configurable:!1,get:()=>null!==i?i:(u!==t.namespaces&&(u=t.namespaces,o=t.enabled(e)),o),set:e=>{i=e}}),"function"==typeof t.init&&t.init(s),s}function n(e,n){const r=t(this.namespace+(void 0===n?":":n)+e);return r.log=this.log,r}function r(e){return e.toString().substring(2,e.toString().length-2).replace(/\.\*\?$/,"*")}return t.debug=t,t.default=t,t.coerce=function(e){if(e instanceof Error)return e.stack||e.message;return e},t.disable=function(){const e=[...t.names.map(r),...t.skips.map(r).map((e=>"-"+e))].join(",");return t.enable(""),e},t.enable=function(e){let n;t.save(e),t.namespaces=e,t.names=[],t.skips=[];const r=("string"==typeof e?e:"").split(/[\s,]+/),u=r.length;for(n=0;n{t[n]=e[n]})),t.names=[],t.skips=[],t.formatters={},t.selectColor=function(e){let n=0;for(let t=0;t{const n=e.startsWith("-")?"":1===e.length?"-":"--",r=t.indexOf(n+e),u=t.indexOf("--");return-1!==r&&(-1===u||r{}),"Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`."),t.colors=[6,2,3,4,5,1];try{const e=function(){if($r)return jr;$r=1;const e=E.default,t=A.default,n=Vr(),{env:r}=process;let u;function o(e){return 0!==e&&{level:e,hasBasic:!0,has256:e>=2,has16m:e>=3}}function i(t,o){if(0===u)return 0;if(n("color=16m")||n("color=full")||n("color=truecolor"))return 3;if(n("color=256"))return 2;if(t&&!o&&void 0===u)return 0;const i=u||0;if("dumb"===r.TERM)return i;if("win32"===process.platform){const t=e.release().split(".");return Number(t[0])>=10&&Number(t[2])>=10586?Number(t[2])>=14931?3:2:1}if("CI"in r)return["TRAVIS","CIRCLECI","APPVEYOR","GITLAB_CI","GITHUB_ACTIONS","BUILDKITE"].some((e=>e in r))||"codeship"===r.CI_NAME?1:i;if("TEAMCITY_VERSION"in r)return/^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(r.TEAMCITY_VERSION)?1:0;if("truecolor"===r.COLORTERM)return 3;if("TERM_PROGRAM"in r){const e=parseInt((r.TERM_PROGRAM_VERSION||"").split(".")[0],10);switch(r.TERM_PROGRAM){case"iTerm.app":return e>=3?3:2;case"Apple_Terminal":return 2}}return/-256(color)?$/i.test(r.TERM)?2:/^screen|^xterm|^vt100|^vt220|^rxvt|color|ansi|cygwin|linux/i.test(r.TERM)||"COLORTERM"in r?1:i}return n("no-color")||n("no-colors")||n("color=false")||n("color=never")?u=0:(n("color")||n("colors")||n("color=true")||n("color=always"))&&(u=1),"FORCE_COLOR"in r&&(u="true"===r.FORCE_COLOR?1:"false"===r.FORCE_COLOR?0:0===r.FORCE_COLOR.length?1:Math.min(parseInt(r.FORCE_COLOR,10),3)),jr={supportsColor:function(e){return o(i(e,e&&e.isTTY))},stdout:o(i(!0,t.isatty(1))),stderr:o(i(!0,t.isatty(2)))}}();e&&(e.stderr||e).level>=2&&(t.colors=[20,21,26,27,32,33,38,39,40,41,42,43,44,45,56,57,62,63,68,69,74,75,76,77,78,79,80,81,92,93,98,99,112,113,128,129,134,135,148,149,160,161,162,163,164,165,166,167,168,169,170,171,172,173,178,179,184,185,196,197,198,199,200,201,202,203,204,205,206,207,208,209,214,215,220,221])}catch(e){}t.inspectOpts=Object.keys(process.env).filter((e=>/^debug_/i.test(e))).reduce(((e,t)=>{const n=t.substring(6).toLowerCase().replace(/_([a-z])/g,((e,t)=>t.toUpperCase()));let r=process.env[t];return r=!!/^(yes|on|true|enabled)$/i.test(r)||!/^(no|off|false|disabled)$/i.test(r)&&("null"===r?null:Number(r)),e[n]=r,e}),{}),e.exports=Rr()(t);const{formatters:u}=e.exports;u.o=function(e){return this.inspectOpts.colors=this.useColors,r.inspect(e,this.inspectOpts).split("\n").map((e=>e.trim())).join(" ")},u.O=function(e){return this.inspectOpts.colors=this.useColors,r.inspect(e,this.inspectOpts)}}(Gr,Gr.exports)),Gr.exports}Jr=Nr,"undefined"==typeof process||"renderer"===process.type||!0===process.browser||process.__nwjs?Jr.exports=(Br||(Br=1,function(e,t){t.formatArgs=function(t){if(t[0]=(this.useColors?"%c":"")+this.namespace+(this.useColors?" %c":" ")+t[0]+(this.useColors?"%c ":" ")+"+"+e.exports.humanize(this.diff),!this.useColors)return;const n="color: "+this.color;t.splice(1,0,n,"color: inherit");let r=0,u=0;t[0].replace(/%[a-zA-Z%]/g,(e=>{"%%"!==e&&(r++,"%c"===e&&(u=r))})),t.splice(u,0,n)},t.save=function(e){try{e?t.storage.setItem("debug",e):t.storage.removeItem("debug")}catch(e){}},t.load=function(){let e;try{e=t.storage.getItem("debug")}catch(e){}return!e&&"undefined"!=typeof process&&"env"in process&&(e=process.env.DEBUG),e},t.useColors=function(){return!("undefined"==typeof window||!window.process||"renderer"!==window.process.type&&!window.process.__nwjs)||("undefined"==typeof navigator||!navigator.userAgent||!navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/))&&("undefined"!=typeof document&&document.documentElement&&document.documentElement.style&&document.documentElement.style.WebkitAppearance||"undefined"!=typeof window&&window.console&&(window.console.firebug||window.console.exception&&window.console.table)||"undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/)&&parseInt(RegExp.$1,10)>=31||"undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/))},t.storage=function(){try{return localStorage}catch(e){}}(),t.destroy=(()=>{let e=!1;return()=>{e||(e=!0,console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`."))}})(),t.colors=["#0000CC","#0000FF","#0033CC","#0033FF","#0066CC","#0066FF","#0099CC","#0099FF","#00CC00","#00CC33","#00CC66","#00CC99","#00CCCC","#00CCFF","#3300CC","#3300FF","#3333CC","#3333FF","#3366CC","#3366FF","#3399CC","#3399FF","#33CC00","#33CC33","#33CC66","#33CC99","#33CCCC","#33CCFF","#6600CC","#6600FF","#6633CC","#6633FF","#66CC00","#66CC33","#9900CC","#9900FF","#9933CC","#9933FF","#99CC00","#99CC33","#CC0000","#CC0033","#CC0066","#CC0099","#CC00CC","#CC00FF","#CC3300","#CC3333","#CC3366","#CC3399","#CC33CC","#CC33FF","#CC6600","#CC6633","#CC9900","#CC9933","#CCCC00","#CCCC33","#FF0000","#FF0033","#FF0066","#FF0099","#FF00CC","#FF00FF","#FF3300","#FF3333","#FF3366","#FF3399","#FF33CC","#FF33FF","#FF6600","#FF6633","#FF9900","#FF9933","#FFCC00","#FFCC33"],t.log=console.debug||console.log||(()=>{}),e.exports=Rr()(t);const{formatters:n}=e.exports;n.j=function(e){try{return JSON.stringify(e)}catch(e){return"[UnexpectedJSONParseError]: "+e.message}}}(Ir,Ir.exports)),Ir.exports):Jr.exports=Ur();var Wr=function(e){return(e=e||{}).circles?function(e){var t=[],n=[];return e.proto?function e(u){if("object"!=typeof u||null===u)return u;if(u instanceof Date)return new Date(u);if(Array.isArray(u))return r(u,e);if(u instanceof Map)return new Map(r(Array.from(u),e));if(u instanceof Set)return new Set(r(Array.from(u),e));var o={};for(var i in t.push(u),n.push(o),u){var s=u[i];if("object"!=typeof s||null===s)o[i]=s;else if(s instanceof Date)o[i]=new Date(s);else if(s instanceof Map)o[i]=new Map(r(Array.from(s),e));else if(s instanceof Set)o[i]=new Set(r(Array.from(s),e));else if(ArrayBuffer.isView(s))o[i]=zr(s);else{var c=t.indexOf(s);o[i]=-1!==c?n[c]:e(s)}}return t.pop(),n.pop(),o}:function e(u){if("object"!=typeof u||null===u)return u;if(u instanceof Date)return new Date(u);if(Array.isArray(u))return r(u,e);if(u instanceof Map)return new Map(r(Array.from(u),e));if(u instanceof Set)return new Set(r(Array.from(u),e));var o={};for(var i in t.push(u),n.push(o),u)if(!1!==Object.hasOwnProperty.call(u,i)){var s=u[i];if("object"!=typeof s||null===s)o[i]=s;else if(s instanceof Date)o[i]=new Date(s);else if(s instanceof Map)o[i]=new Map(r(Array.from(s),e));else if(s instanceof Set)o[i]=new Set(r(Array.from(s),e));else if(ArrayBuffer.isView(s))o[i]=zr(s);else{var c=t.indexOf(s);o[i]=-1!==c?n[c]:e(s)}}return t.pop(),n.pop(),o};function r(e,r){for(var u=Object.keys(e),o=new Array(u.length),i=0;i!e,Qr=e=>e&&"object"==typeof e&&!Array.isArray(e),eu=(e,t,n)=>{(Array.isArray(t)?t:[t]).forEach((t=>{if(t)throw new Error(`Problem with log4js configuration: (${Kr.inspect(e,{depth:5})}) - ${n}`)}))};var tu={configure:e=>{qr("New configuration to be validated: ",e),eu(e,Zr(Qr(e)),"must be an object."),qr(`Calling pre-processing listeners (${Yr.length})`),Yr.forEach((t=>t(e))),qr("Configuration pre-processing finished."),qr(`Calling configuration listeners (${Xr.length})`),Xr.forEach((t=>t(e))),qr("Configuration finished.")},addListener:e=>{Xr.push(e),qr(`Added listener, now ${Xr.length} listeners`)},addPreProcessingListener:e=>{Yr.push(e),qr(`Added pre-processing listener, now ${Yr.length} listeners`)},throwExceptionIf:eu,anObject:Qr,anInteger:e=>e&&"number"==typeof e&&Number.isInteger(e),validIdentifier:e=>/^[A-Za-z][A-Za-z0-9_]*$/g.test(e),not:Zr},nu={exports:{}};!function(e){function t(e,t){for(var n=e.toString();n.length-1?s:c,l=n(u.getHours()),f=n(u.getMinutes()),d=n(u.getSeconds()),D=t(u.getMilliseconds(),3),p=function(e){var t=Math.abs(e),n=String(Math.floor(t/60)),r=String(t%60);return n=("0"+n).slice(-2),r=("0"+r).slice(-2),0===e?"Z":(e<0?"+":"-")+n+":"+r}(u.getTimezoneOffset());return r.replace(/dd/g,o).replace(/MM/g,i).replace(/y{1,4}/g,a).replace(/hh/g,l).replace(/mm/g,f).replace(/ss/g,d).replace(/SSS/g,D).replace(/O/g,p)}function u(e,t,n,r){e["set"+(r?"":"UTC")+t](n)}e.exports=r,e.exports.asString=r,e.exports.parse=function(t,n,r){if(!t)throw new Error("pattern must be supplied");return function(t,n,r){var o=t.indexOf("O")<0,i=!1,s=[{pattern:/y{1,4}/,regexp:"\\d{1,4}",fn:function(e,t){u(e,"FullYear",t,o)}},{pattern:/MM/,regexp:"\\d{1,2}",fn:function(e,t){u(e,"Month",t-1,o),e.getMonth()!==t-1&&(i=!0)}},{pattern:/dd/,regexp:"\\d{1,2}",fn:function(e,t){i&&u(e,"Month",e.getMonth()-1,o),u(e,"Date",t,o)}},{pattern:/hh/,regexp:"\\d{1,2}",fn:function(e,t){u(e,"Hours",t,o)}},{pattern:/mm/,regexp:"\\d\\d",fn:function(e,t){u(e,"Minutes",t,o)}},{pattern:/ss/,regexp:"\\d\\d",fn:function(e,t){u(e,"Seconds",t,o)}},{pattern:/SSS/,regexp:"\\d\\d\\d",fn:function(e,t){u(e,"Milliseconds",t,o)}},{pattern:/O/,regexp:"[+-]\\d{1,2}:?\\d{2}?|Z",fn:function(e,t){t="Z"===t?0:t.replace(":","");var n=Math.abs(t),r=(t>0?-1:1)*(n%100+60*Math.floor(n/100));e.setUTCMinutes(e.getUTCMinutes()+r)}}],c=s.reduce((function(e,t){return t.pattern.test(e.regexp)?(t.index=e.regexp.match(t.pattern).index,e.regexp=e.regexp.replace(t.pattern,"("+t.regexp+")")):t.index=-1,e}),{regexp:t,index:[]}),a=s.filter((function(e){return e.index>-1}));a.sort((function(e,t){return e.index-t.index}));var l=new RegExp(c.regexp).exec(n);if(l){var f=r||e.exports.now();return a.forEach((function(e,t){e.fn(f,l[t+1])})),f}throw new Error("String '"+n+"' could not be parsed as '"+t+"'")}(t,n,r)},e.exports.now=function(){return new Date},e.exports.ISO8601_FORMAT="yyyy-MM-ddThh:mm:ss.SSS",e.exports.ISO8601_WITH_TZ_OFFSET_FORMAT="yyyy-MM-ddThh:mm:ss.SSSO",e.exports.DATETIME_FORMAT="dd MM yyyy hh:mm:ss.SSS",e.exports.ABSOLUTETIME_FORMAT="hh:mm:ss.SSS"}(nu);const ru=nu.exports,uu=E.default,ou=F.default,iu=p.default,su={bold:[1,22],italic:[3,23],underline:[4,24],inverse:[7,27],white:[37,39],grey:[90,39],black:[90,39],blue:[34,39],cyan:[36,39],green:[32,39],magenta:[35,39],red:[91,39],yellow:[33,39]};function cu(e){return e?`[${su[e][0]}m`:""}function au(e){return e?`[${su[e][1]}m`:""}function lu(e,t){return n=ou.format("[%s] [%s] %s - ",ru.asString(e.startTime),e.level.toString(),e.categoryName),cu(r=t)+n+au(r);var n,r}function fu(e){return lu(e)+ou.format(...e.data)}function du(e){return lu(e,e.level.colour)+ou.format(...e.data)}function Du(e){return ou.format(...e.data)}function pu(e){return e.data[0]}function Eu(e,t){const n=/%(-?[0-9]+)?(\.?-?[0-9]+)?([[\]cdhmnprzxXyflos%])(\{([^}]+)\})?|([^%]+)/;function r(e){return e&&e.pid?e.pid.toString():process.pid.toString()}e=e||"%r %p %c - %m%n";const u={c:function(e,t){let n=e.categoryName;if(t){const e=parseInt(t,10),r=n.split(".");ee&&(n=r.slice(-e).join(iu.sep))}return n},l:function(e){return e.lineNumber?`${e.lineNumber}`:""},o:function(e){return e.columnNumber?`${e.columnNumber}`:""},s:function(e){return e.callStack||""}};function o(e,t,n){return u[e](t,n)}function i(e,t,n){let r=e;return r=function(e,t){let n;return e?(n=parseInt(e.substr(1),10),n>0?t.slice(0,n):t.slice(n)):t}(t,r),r=function(e,t){let n;if(e)if("-"===e.charAt(0))for(n=parseInt(e.substr(1),10);t.lengthDu,basic:()=>fu,colored:()=>du,coloured:()=>du,pattern:e=>Eu(e&&e.pattern,e&&e.tokens),dummy:()=>pu};var hu={basicLayout:fu,messagePassThroughLayout:Du,patternLayout:Eu,colouredLayout:du,coloredLayout:du,dummyLayout:pu,addLayout(e,t){mu[e]=t},layout:(e,t)=>mu[e]&&mu[e](t)};const yu=tu,Cu=["white","grey","black","blue","cyan","green","magenta","red","yellow"];class Fu{constructor(e,t,n){this.level=e,this.levelStr=t,this.colour=n}toString(){return this.levelStr}static getLevel(e,t){return e?e instanceof Fu?e:(e instanceof Object&&e.levelStr&&(e=e.levelStr),Fu[e.toString().toUpperCase()]||t):t}static addLevels(e){if(e){Object.keys(e).forEach((t=>{const n=t.toUpperCase();Fu[n]=new Fu(e[t].value,n,e[t].colour);const r=Fu.levels.findIndex((e=>e.levelStr===n));r>-1?Fu.levels[r]=Fu[n]:Fu.levels.push(Fu[n])})),Fu.levels.sort(((e,t)=>e.level-t.level))}}isLessThanOrEqualTo(e){return"string"==typeof e&&(e=Fu.getLevel(e)),this.level<=e.level}isGreaterThanOrEqualTo(e){return"string"==typeof e&&(e=Fu.getLevel(e)),this.level>=e.level}isEqualTo(e){return"string"==typeof e&&(e=Fu.getLevel(e)),this.level===e.level}}Fu.levels=[],Fu.addLevels({ALL:{value:Number.MIN_VALUE,colour:"grey"},TRACE:{value:5e3,colour:"blue"},DEBUG:{value:1e4,colour:"cyan"},INFO:{value:2e4,colour:"green"},WARN:{value:3e4,colour:"yellow"},ERROR:{value:4e4,colour:"red"},FATAL:{value:5e4,colour:"magenta"},MARK:{value:9007199254740992,colour:"grey"},OFF:{value:Number.MAX_VALUE,colour:"grey"}}),yu.addListener((e=>{const t=e.levels;if(t){yu.throwExceptionIf(e,yu.not(yu.anObject(t)),"levels must be an object");Object.keys(t).forEach((n=>{yu.throwExceptionIf(e,yu.not(yu.validIdentifier(n)),`level name "${n}" is not a valid identifier (must start with a letter, only contain A-Z,a-z,0-9,_)`),yu.throwExceptionIf(e,yu.not(yu.anObject(t[n])),`level "${n}" must be an object`),yu.throwExceptionIf(e,yu.not(t[n].value),`level "${n}" must have a 'value' property`),yu.throwExceptionIf(e,yu.not(yu.anInteger(t[n].value)),`level "${n}".value must have an integer value`),yu.throwExceptionIf(e,yu.not(t[n].colour),`level "${n}" must have a 'colour' property`),yu.throwExceptionIf(e,yu.not(Cu.indexOf(t[n].colour)>-1),`level "${n}".colour must be one of ${Cu.join(", ")}`)}))}})),yu.addListener((e=>{Fu.addLevels(e.levels)}));var gu=Fu,Au={exports:{}},vu={};/*! (c) 2020 Andrea Giammarchi */ +const{parse:Su,stringify:wu}=JSON,{keys:Ou}=Object,bu=String,_u="string",Bu={},Pu="object",ku=(e,t)=>t,xu=e=>e instanceof bu?bu(e):e,Nu=(e,t)=>typeof t===_u?new bu(t):t,Iu=(e,t,n,r)=>{const u=[];for(let o=Ou(n),{length:i}=o,s=0;s{const r=bu(t.push(n)-1);return e.set(n,r),r},Ru=(e,t)=>{const n=Su(e,Nu).map(xu),r=n[0],u=t||ku,o=typeof r===Pu&&r?Iu(n,new Set,r,u):r;return u.call({"":o},"",o)};vu.parse=Ru;const Mu=(e,t,n)=>{const r=t&&typeof t===Pu?(e,n)=>""===e||-1Su(Mu(e));vu.fromJSON=e=>Ru(wu(e));const Lu=vu,ju=gu;class $u{constructor(e,t,n,r,u){this.startTime=new Date,this.categoryName=e,this.data=n,this.level=t,this.context=Object.assign({},r),this.pid=process.pid,u&&(this.functionName=u.functionName,this.fileName=u.fileName,this.lineNumber=u.lineNumber,this.columnNumber=u.columnNumber,this.callStack=u.callStack)}serialise(){const e=this.data.map((e=>(e&&e.message&&e.stack&&(e=Object.assign({message:e.message,stack:e.stack},e)),e)));return this.data=e,Lu.stringify(this)}static deserialise(e){let t;try{const n=Lu.parse(e);n.data=n.data.map((e=>{if(e&&e.message&&e.stack){const t=new Error(e);Object.keys(e).forEach((n=>{t[n]=e[n]})),e=t}return e})),t=new $u(n.categoryName,ju.getLevel(n.level.levelStr),n.data,n.context),t.startTime=new Date(n.startTime),t.pid=n.pid,t.cluster=n.cluster}catch(n){t=new $u("log4js",ju.ERROR,["Unable to parse log:",e,"because: ",n])}return t}}var Hu=$u;const Ju=Nr.exports("log4js:clustering"),Gu=Hu,Vu=tu;let Uu=!1,Wu=null;try{Wu=require("cluster")}catch(e){Ju("cluster module not present"),Uu=!0}const zu=[];let Ku=!1,qu="NODE_APP_INSTANCE";const Yu=()=>Ku&&"0"===process.env[qu],Xu=()=>Uu||Wu.isMaster||Yu(),Zu=e=>{zu.forEach((t=>t(e)))},Qu=(e,t)=>{if(Ju("cluster message received from worker ",e,": ",t),e.topic&&e.data&&(t=e,e=void 0),t&&t.topic&&"log4js:message"===t.topic){Ju("received message: ",t.data);const e=Gu.deserialise(t.data);Zu(e)}};Uu||Vu.addListener((e=>{zu.length=0,({pm2:Ku,disableClustering:Uu,pm2InstanceVar:qu="NODE_APP_INSTANCE"}=e),Ju(`clustering disabled ? ${Uu}`),Ju(`cluster.isMaster ? ${Wu&&Wu.isMaster}`),Ju(`pm2 enabled ? ${Ku}`),Ju(`pm2InstanceVar = ${qu}`),Ju(`process.env[${qu}] = ${process.env[qu]}`),Ku&&process.removeListener("message",Qu),Wu&&Wu.removeListener&&Wu.removeListener("message",Qu),Uu||e.disableClustering?Ju("Not listening for cluster messages, because clustering disabled."):Yu()?(Ju("listening for PM2 broadcast messages"),process.on("message",Qu)):Wu.isMaster?(Ju("listening for cluster messages"),Wu.on("message",Qu)):Ju("not listening for messages, because we are not a master process")}));var eo={onlyOnMaster:(e,t)=>Xu()?e():t,isMaster:Xu,send:e=>{Xu()?Zu(e):(Ku||(e.cluster={workerId:Wu.worker.id,worker:process.pid}),process.send({topic:"log4js:message",data:e.serialise()}))},onMessage:e=>{zu.push(e)}},to={};function no(e){if("number"==typeof e&&Number.isInteger(e))return e;const t={K:1024,M:1048576,G:1073741824},n=Object.keys(t),r=e.substr(e.length-1).toLocaleUpperCase(),u=e.substring(0,e.length-1).trim();if(n.indexOf(r)<0||!Number.isInteger(Number(u)))throw Error(`maxLogSize: "${e}" is invalid`);return u*t[r]}function ro(e){return function(e,t){const n=Object.assign({},t);return Object.keys(e).forEach((r=>{n[r]&&(n[r]=e[r](t[r]))})),n}({maxLogSize:no},e)}const uo={file:ro,fileSync:ro};to.modifyConfig=e=>uo[e.type]?uo[e.type](e):e;var oo={};const io=console.log.bind(console);oo.configure=function(e,t){let n=t.colouredLayout;return e.layout&&(n=t.layout(e.layout.type,e.layout)),function(e,t){return n=>{io(e(n,t))}}(n,e.timezoneOffset)};var so={};so.configure=function(e,t){let n=t.colouredLayout;return e.layout&&(n=t.layout(e.layout.type,e.layout)),function(e,t){return n=>{process.stdout.write(`${e(n,t)}\n`)}}(n,e.timezoneOffset)};var co={};co.configure=function(e,t){let n=t.colouredLayout;return e.layout&&(n=t.layout(e.layout.type,e.layout)),function(e,t){return n=>{process.stderr.write(`${e(n,t)}\n`)}}(n,e.timezoneOffset)};var ao={};ao.configure=function(e,t,n,r){const u=n(e.appender);return function(e,t,n,r){const u=r.getLevel(e),o=r.getLevel(t,r.FATAL);return e=>{const t=e.level;t.isGreaterThanOrEqualTo(u)&&t.isLessThanOrEqualTo(o)&&n(e)}}(e.level,e.maxLevel,u,r)};var lo={};const fo=Nr.exports("log4js:categoryFilter");lo.configure=function(e,t,n){const r=n(e.appender);return function(e,t){return"string"==typeof e&&(e=[e]),n=>{fo(`Checking ${n.categoryName} against ${e}`),-1===e.indexOf(n.categoryName)&&(fo("Not excluded, sending to appender"),t(n))}}(e.exclude,r)};var Do={};const po=Nr.exports("log4js:noLogFilter");Do.configure=function(e,t,n){const r=n(e.appender);return function(e,t){return n=>{po(`Checking data: ${n.data} against filters: ${e}`),"string"==typeof e&&(e=[e]),e=e.filter((e=>null!=e&&""!==e));const r=new RegExp(e.join("|"),"i");(0===e.length||n.data.findIndex((e=>r.test(e)))<0)&&(po("Not excluded, sending to appender"),t(n))}}(e.exclude,r)};var Eo={},mo={exports:{}},ho={},yo={fromCallback:function(e){return Object.defineProperty((function(){if("function"!=typeof arguments[arguments.length-1])return new Promise(((t,n)=>{arguments[arguments.length]=(e,r)=>{if(e)return n(e);t(r)},arguments.length++,e.apply(this,arguments)}));e.apply(this,arguments)}),"name",{value:e.name})},fromPromise:function(e){return Object.defineProperty((function(){const t=arguments[arguments.length-1];if("function"!=typeof t)return e.apply(this,arguments);e.apply(this,arguments).then((e=>t(null,e)),t)}),"name",{value:e.name})}};!function(e){const t=yo.fromCallback,n=we,r=["access","appendFile","chmod","chown","close","copyFile","fchmod","fchown","fdatasync","fstat","fsync","ftruncate","futimes","lchown","lchmod","link","lstat","mkdir","mkdtemp","open","readFile","readdir","readlink","realpath","rename","rmdir","stat","symlink","truncate","unlink","utimes","writeFile"].filter((e=>"function"==typeof n[e]));Object.keys(n).forEach((t=>{"promises"!==t&&(e[t]=n[t])})),r.forEach((r=>{e[r]=t(n[r])})),e.exists=function(e,t){return"function"==typeof t?n.exists(e,t):new Promise((t=>n.exists(e,t)))},e.read=function(e,t,r,u,o,i){return"function"==typeof i?n.read(e,t,r,u,o,i):new Promise(((i,s)=>{n.read(e,t,r,u,o,((e,t,n)=>{if(e)return s(e);i({bytesRead:t,buffer:n})}))}))},e.write=function(e,t,...r){return"function"==typeof r[r.length-1]?n.write(e,t,...r):new Promise(((u,o)=>{n.write(e,t,...r,((e,t,n)=>{if(e)return o(e);u({bytesWritten:t,buffer:n})}))}))},"function"==typeof n.realpath.native&&(e.realpath.native=t(n.realpath.native))}(ho);const Co=p.default;function Fo(e){return(e=Co.normalize(Co.resolve(e)).split(Co.sep)).length>0?e[0]:null}const go=/[<>:"|?*]/;var Ao=function(e){const t=Fo(e);return e=e.replace(t,""),go.test(e)};const vo=we,So=p.default,wo=Ao,Oo=parseInt("0777",8);var bo=function e(t,n,r,u){if("function"==typeof n?(r=n,n={}):n&&"object"==typeof n||(n={mode:n}),"win32"===process.platform&&wo(t)){const e=new Error(t+" contains invalid WIN32 path characters.");return e.code="EINVAL",r(e)}let o=n.mode;const i=n.fs||vo;void 0===o&&(o=Oo&~process.umask()),u||(u=null),r=r||function(){},t=So.resolve(t),i.mkdir(t,o,(o=>{if(!o)return r(null,u=u||t);if("ENOENT"===o.code){if(So.dirname(t)===t)return r(o);e(So.dirname(t),n,((u,o)=>{u?r(u,o):e(t,n,r,o)}))}else i.stat(t,((e,t)=>{e||!t.isDirectory()?r(o,u):r(null,u)}))}))};const _o=we,Bo=p.default,Po=Ao,ko=parseInt("0777",8);var xo=function e(t,n,r){n&&"object"==typeof n||(n={mode:n});let u=n.mode;const o=n.fs||_o;if("win32"===process.platform&&Po(t)){const e=new Error(t+" contains invalid WIN32 path characters.");throw e.code="EINVAL",e}void 0===u&&(u=ko&~process.umask()),r||(r=null),t=Bo.resolve(t);try{o.mkdirSync(t,u),r=r||t}catch(u){if("ENOENT"===u.code){if(Bo.dirname(t)===t)throw u;r=e(Bo.dirname(t),n,r),e(t,n,r)}else{let e;try{e=o.statSync(t)}catch(e){throw u}if(!e.isDirectory())throw u}}return r};const No=(0,yo.fromCallback)(bo);var Io={mkdirs:No,mkdirsSync:xo,mkdirp:No,mkdirpSync:xo,ensureDir:No,ensureDirSync:xo};const To=we;E.default,p.default;var Ro=function(e,t,n,r){To.open(e,"r+",((e,u)=>{if(e)return r(e);To.futimes(u,t,n,(e=>{To.close(u,(t=>{r&&r(e||t)}))}))}))},Mo=function(e,t,n){const r=To.openSync(e,"r+");return To.futimesSync(r,t,n),To.closeSync(r)};const Lo=we,jo=p.default,$o=10,Ho=5,Jo=0,Go=process.versions.node.split("."),Vo=Number.parseInt(Go[0],10),Uo=Number.parseInt(Go[1],10),Wo=Number.parseInt(Go[2],10);function zo(){if(Vo>$o)return!0;if(Vo===$o){if(Uo>Ho)return!0;if(Uo===Ho&&Wo>=Jo)return!0}return!1}function Ko(e,t){const n=jo.resolve(e).split(jo.sep).filter((e=>e)),r=jo.resolve(t).split(jo.sep).filter((e=>e));return n.reduce(((e,t,n)=>e&&r[n]===t),!0)}function qo(e,t,n){return`Cannot ${n} '${e}' to a subdirectory of itself, '${t}'.`}var Yo,Xo,Zo={checkPaths:function(e,t,n,r){!function(e,t,n){zo()?Lo.stat(e,{bigint:!0},((e,r)=>{if(e)return n(e);Lo.stat(t,{bigint:!0},((e,t)=>e?"ENOENT"===e.code?n(null,{srcStat:r,destStat:null}):n(e):n(null,{srcStat:r,destStat:t})))})):Lo.stat(e,((e,r)=>{if(e)return n(e);Lo.stat(t,((e,t)=>e?"ENOENT"===e.code?n(null,{srcStat:r,destStat:null}):n(e):n(null,{srcStat:r,destStat:t})))}))}(e,t,((u,o)=>{if(u)return r(u);const{srcStat:i,destStat:s}=o;return s&&s.ino&&s.dev&&s.ino===i.ino&&s.dev===i.dev?r(new Error("Source and destination must not be the same.")):i.isDirectory()&&Ko(e,t)?r(new Error(qo(e,t,n))):r(null,{srcStat:i,destStat:s})}))},checkPathsSync:function(e,t,n){const{srcStat:r,destStat:u}=function(e,t){let n,r;n=zo()?Lo.statSync(e,{bigint:!0}):Lo.statSync(e);try{r=zo()?Lo.statSync(t,{bigint:!0}):Lo.statSync(t)}catch(e){if("ENOENT"===e.code)return{srcStat:n,destStat:null};throw e}return{srcStat:n,destStat:r}}(e,t);if(u&&u.ino&&u.dev&&u.ino===r.ino&&u.dev===r.dev)throw new Error("Source and destination must not be the same.");if(r.isDirectory()&&Ko(e,t))throw new Error(qo(e,t,n));return{srcStat:r,destStat:u}},checkParentPaths:function e(t,n,r,u,o){const i=jo.resolve(jo.dirname(t)),s=jo.resolve(jo.dirname(r));if(s===i||s===jo.parse(s).root)return o();zo()?Lo.stat(s,{bigint:!0},((i,c)=>i?"ENOENT"===i.code?o():o(i):c.ino&&c.dev&&c.ino===n.ino&&c.dev===n.dev?o(new Error(qo(t,r,u))):e(t,n,s,u,o))):Lo.stat(s,((i,c)=>i?"ENOENT"===i.code?o():o(i):c.ino&&c.dev&&c.ino===n.ino&&c.dev===n.dev?o(new Error(qo(t,r,u))):e(t,n,s,u,o)))},checkParentPathsSync:function e(t,n,r,u){const o=jo.resolve(jo.dirname(t)),i=jo.resolve(jo.dirname(r));if(i===o||i===jo.parse(i).root)return;let s;try{s=zo()?Lo.statSync(i,{bigint:!0}):Lo.statSync(i)}catch(e){if("ENOENT"===e.code)return;throw e}if(s.ino&&s.dev&&s.ino===n.ino&&s.dev===n.dev)throw new Error(qo(t,r,u));return e(t,n,i,u)},isSrcSubdir:Ko};const Qo=we,ei=p.default,ti=Io.mkdirsSync,ni=Mo,ri=Zo;function ui(e,t,n,r){if(!r.filter||r.filter(t,n))return function(e,t,n,r){const u=r.dereference?Qo.statSync:Qo.lstatSync,o=u(t);if(o.isDirectory())return function(e,t,n,r,u){if(!t)return function(e,t,n,r){return Qo.mkdirSync(n),ii(t,n,r),Qo.chmodSync(n,e.mode)}(e,n,r,u);if(t&&!t.isDirectory())throw new Error(`Cannot overwrite non-directory '${r}' with directory '${n}'.`);return ii(n,r,u)}(o,e,t,n,r);if(o.isFile()||o.isCharacterDevice()||o.isBlockDevice())return function(e,t,n,r,u){return t?function(e,t,n,r){if(r.overwrite)return Qo.unlinkSync(n),oi(e,t,n,r);if(r.errorOnExist)throw new Error(`'${n}' already exists`)}(e,n,r,u):oi(e,n,r,u)}(o,e,t,n,r);if(o.isSymbolicLink())return function(e,t,n,r){let u=Qo.readlinkSync(t);r.dereference&&(u=ei.resolve(process.cwd(),u));if(e){let e;try{e=Qo.readlinkSync(n)}catch(e){if("EINVAL"===e.code||"UNKNOWN"===e.code)return Qo.symlinkSync(u,n);throw e}if(r.dereference&&(e=ei.resolve(process.cwd(),e)),ri.isSrcSubdir(u,e))throw new Error(`Cannot copy '${u}' to a subdirectory of itself, '${e}'.`);if(Qo.statSync(n).isDirectory()&&ri.isSrcSubdir(e,u))throw new Error(`Cannot overwrite '${e}' with '${u}'.`);return function(e,t){return Qo.unlinkSync(t),Qo.symlinkSync(e,t)}(u,n)}return Qo.symlinkSync(u,n)}(e,t,n,r)}(e,t,n,r)}function oi(e,t,n,r){return"function"==typeof Qo.copyFileSync?(Qo.copyFileSync(t,n),Qo.chmodSync(n,e.mode),r.preserveTimestamps?ni(n,e.atime,e.mtime):void 0):function(e,t,n,r){const u=65536,o=(Xo?Yo:(Xo=1,Yo=function(e){if("function"==typeof Buffer.allocUnsafe)try{return Buffer.allocUnsafe(e)}catch(t){return new Buffer(e)}return new Buffer(e)}))(u),i=Qo.openSync(t,"r"),s=Qo.openSync(n,"w",e.mode);let c=0;for(;cfunction(e,t,n,r){const u=ei.join(t,e),o=ei.join(n,e),{destStat:i}=ri.checkPathsSync(u,o,"copy");return ui(i,u,o,r)}(r,e,t,n)))}var si=function(e,t,n){"function"==typeof n&&(n={filter:n}),(n=n||{}).clobber=!("clobber"in n)||!!n.clobber,n.overwrite="overwrite"in n?!!n.overwrite:n.clobber,n.preserveTimestamps&&"ia32"===process.arch&&console.warn("fs-extra: Using the preserveTimestamps option in 32-bit node is not recommended;\n\n see https://github.com/jprichardson/node-fs-extra/issues/269");const{srcStat:r,destStat:u}=ri.checkPathsSync(e,t,"copy");return ri.checkParentPathsSync(e,r,t,"copy"),function(e,t,n,r){if(r.filter&&!r.filter(t,n))return;const u=ei.dirname(n);Qo.existsSync(u)||ti(u);return ui(e,t,n,r)}(u,e,t,n)},ci={copySync:si};const ai=yo.fromPromise,li=ho;var fi={pathExists:ai((function(e){return li.access(e).then((()=>!0)).catch((()=>!1))})),pathExistsSync:li.existsSync};const di=we,Di=p.default,pi=Io.mkdirs,Ei=fi.pathExists,mi=Ro,hi=Zo;function yi(e,t,n,r,u){const o=Di.dirname(n);Ei(o,((i,s)=>i?u(i):s?Fi(e,t,n,r,u):void pi(o,(o=>o?u(o):Fi(e,t,n,r,u)))))}function Ci(e,t,n,r,u,o){Promise.resolve(u.filter(n,r)).then((i=>i?e(t,n,r,u,o):o()),(e=>o(e)))}function Fi(e,t,n,r,u){return r.filter?Ci(gi,e,t,n,r,u):gi(e,t,n,r,u)}function gi(e,t,n,r,u){(r.dereference?di.stat:di.lstat)(t,((o,i)=>o?u(o):i.isDirectory()?function(e,t,n,r,u,o){if(!t)return function(e,t,n,r,u){di.mkdir(n,(o=>{if(o)return u(o);Si(t,n,r,(t=>t?u(t):di.chmod(n,e.mode,u)))}))}(e,n,r,u,o);if(t&&!t.isDirectory())return o(new Error(`Cannot overwrite non-directory '${r}' with directory '${n}'.`));return Si(n,r,u,o)}(i,e,t,n,r,u):i.isFile()||i.isCharacterDevice()||i.isBlockDevice()?function(e,t,n,r,u,o){return t?function(e,t,n,r,u){if(!r.overwrite)return r.errorOnExist?u(new Error(`'${n}' already exists`)):u();di.unlink(n,(o=>o?u(o):Ai(e,t,n,r,u)))}(e,n,r,u,o):Ai(e,n,r,u,o)}(i,e,t,n,r,u):i.isSymbolicLink()?function(e,t,n,r,u){di.readlink(t,((t,o)=>t?u(t):(r.dereference&&(o=Di.resolve(process.cwd(),o)),e?void di.readlink(n,((t,i)=>t?"EINVAL"===t.code||"UNKNOWN"===t.code?di.symlink(o,n,u):u(t):(r.dereference&&(i=Di.resolve(process.cwd(),i)),hi.isSrcSubdir(o,i)?u(new Error(`Cannot copy '${o}' to a subdirectory of itself, '${i}'.`)):e.isDirectory()&&hi.isSrcSubdir(i,o)?u(new Error(`Cannot overwrite '${i}' with '${o}'.`)):function(e,t,n){di.unlink(t,(r=>r?n(r):di.symlink(e,t,n)))}(o,n,u)))):di.symlink(o,n,u))))}(e,t,n,r,u):void 0))}function Ai(e,t,n,r,u){return"function"==typeof di.copyFile?di.copyFile(t,n,(t=>t?u(t):vi(e,n,r,u))):function(e,t,n,r,u){const o=di.createReadStream(t);o.on("error",(e=>u(e))).once("open",(()=>{const t=di.createWriteStream(n,{mode:e.mode});t.on("error",(e=>u(e))).on("open",(()=>o.pipe(t))).once("close",(()=>vi(e,n,r,u)))}))}(e,t,n,r,u)}function vi(e,t,n,r){di.chmod(t,e.mode,(u=>u?r(u):n.preserveTimestamps?mi(t,e.atime,e.mtime,r):r()))}function Si(e,t,n,r){di.readdir(e,((u,o)=>u?r(u):wi(o,e,t,n,r)))}function wi(e,t,n,r,u){const o=e.pop();return o?function(e,t,n,r,u,o){const i=Di.join(n,t),s=Di.join(r,t);hi.checkPaths(i,s,"copy",((t,c)=>{if(t)return o(t);const{destStat:a}=c;Fi(a,i,s,u,(t=>t?o(t):wi(e,n,r,u,o)))}))}(e,o,t,n,r,u):u()}var Oi=function(e,t,n,r){"function"!=typeof n||r?"function"==typeof n&&(n={filter:n}):(r=n,n={}),r=r||function(){},(n=n||{}).clobber=!("clobber"in n)||!!n.clobber,n.overwrite="overwrite"in n?!!n.overwrite:n.clobber,n.preserveTimestamps&&"ia32"===process.arch&&console.warn("fs-extra: Using the preserveTimestamps option in 32-bit node is not recommended;\n\n see https://github.com/jprichardson/node-fs-extra/issues/269"),hi.checkPaths(e,t,"copy",((u,o)=>{if(u)return r(u);const{srcStat:i,destStat:s}=o;hi.checkParentPaths(e,i,t,"copy",(u=>u?r(u):n.filter?Ci(yi,s,e,t,n,r):yi(s,e,t,n,r)))}))};var bi={copy:(0,yo.fromCallback)(Oi)};const _i=we,Bi=p.default,Pi=g.default,ki="win32"===process.platform;function xi(e){["unlink","chmod","stat","lstat","rmdir","readdir"].forEach((t=>{e[t]=e[t]||_i[t],e[t+="Sync"]=e[t]||_i[t]})),e.maxBusyTries=e.maxBusyTries||3}function Ni(e,t,n){let r=0;"function"==typeof t&&(n=t,t={}),Pi(e,"rimraf: missing path"),Pi.strictEqual(typeof e,"string","rimraf: path should be a string"),Pi.strictEqual(typeof n,"function","rimraf: callback function required"),Pi(t,"rimraf: invalid options argument provided"),Pi.strictEqual(typeof t,"object","rimraf: options should be object"),xi(t),Ii(e,t,(function u(o){if(o){if(("EBUSY"===o.code||"ENOTEMPTY"===o.code||"EPERM"===o.code)&&rIi(e,t,u)),100*r)}"ENOENT"===o.code&&(o=null)}n(o)}))}function Ii(e,t,n){Pi(e),Pi(t),Pi("function"==typeof n),t.lstat(e,((r,u)=>r&&"ENOENT"===r.code?n(null):r&&"EPERM"===r.code&&ki?Ti(e,t,r,n):u&&u.isDirectory()?Mi(e,t,r,n):void t.unlink(e,(r=>{if(r){if("ENOENT"===r.code)return n(null);if("EPERM"===r.code)return ki?Ti(e,t,r,n):Mi(e,t,r,n);if("EISDIR"===r.code)return Mi(e,t,r,n)}return n(r)}))))}function Ti(e,t,n,r){Pi(e),Pi(t),Pi("function"==typeof r),n&&Pi(n instanceof Error),t.chmod(e,438,(u=>{u?r("ENOENT"===u.code?null:n):t.stat(e,((u,o)=>{u?r("ENOENT"===u.code?null:n):o.isDirectory()?Mi(e,t,n,r):t.unlink(e,r)}))}))}function Ri(e,t,n){let r;Pi(e),Pi(t),n&&Pi(n instanceof Error);try{t.chmodSync(e,438)}catch(e){if("ENOENT"===e.code)return;throw n}try{r=t.statSync(e)}catch(e){if("ENOENT"===e.code)return;throw n}r.isDirectory()?ji(e,t,n):t.unlinkSync(e)}function Mi(e,t,n,r){Pi(e),Pi(t),n&&Pi(n instanceof Error),Pi("function"==typeof r),t.rmdir(e,(u=>{!u||"ENOTEMPTY"!==u.code&&"EEXIST"!==u.code&&"EPERM"!==u.code?u&&"ENOTDIR"===u.code?r(n):r(u):function(e,t,n){Pi(e),Pi(t),Pi("function"==typeof n),t.readdir(e,((r,u)=>{if(r)return n(r);let o,i=u.length;if(0===i)return t.rmdir(e,n);u.forEach((r=>{Ni(Bi.join(e,r),t,(r=>{if(!o)return r?n(o=r):void(0==--i&&t.rmdir(e,n))}))}))}))}(e,t,r)}))}function Li(e,t){let n;xi(t=t||{}),Pi(e,"rimraf: missing path"),Pi.strictEqual(typeof e,"string","rimraf: path should be a string"),Pi(t,"rimraf: missing options"),Pi.strictEqual(typeof t,"object","rimraf: options should be object");try{n=t.lstatSync(e)}catch(n){if("ENOENT"===n.code)return;"EPERM"===n.code&&ki&&Ri(e,t,n)}try{n&&n.isDirectory()?ji(e,t,null):t.unlinkSync(e)}catch(n){if("ENOENT"===n.code)return;if("EPERM"===n.code)return ki?Ri(e,t,n):ji(e,t,n);if("EISDIR"!==n.code)throw n;ji(e,t,n)}}function ji(e,t,n){Pi(e),Pi(t),n&&Pi(n instanceof Error);try{t.rmdirSync(e)}catch(r){if("ENOTDIR"===r.code)throw n;if("ENOTEMPTY"===r.code||"EEXIST"===r.code||"EPERM"===r.code)!function(e,t){if(Pi(e),Pi(t),t.readdirSync(e).forEach((n=>Li(Bi.join(e,n),t))),!ki){return t.rmdirSync(e,t)}{const n=Date.now();do{try{return t.rmdirSync(e,t)}catch(e){}}while(Date.now()-n<500)}}(e,t);else if("ENOENT"!==r.code)throw r}}var $i=Ni;Ni.sync=Li;const Hi=$i;var Ji={remove:(0,yo.fromCallback)(Hi),removeSync:Hi.sync};const Gi=yo.fromCallback,Vi=we,Ui=p.default,Wi=Io,zi=Ji,Ki=Gi((function(e,t){t=t||function(){},Vi.readdir(e,((n,r)=>{if(n)return Wi.mkdirs(e,t);r=r.map((t=>Ui.join(e,t))),function e(){const n=r.pop();if(!n)return t();zi.remove(n,(n=>{if(n)return t(n);e()}))}()}))}));function qi(e){let t;try{t=Vi.readdirSync(e)}catch(t){return Wi.mkdirsSync(e)}t.forEach((t=>{t=Ui.join(e,t),zi.removeSync(t)}))}var Yi={emptyDirSync:qi,emptydirSync:qi,emptyDir:Ki,emptydir:Ki};const Xi=yo.fromCallback,Zi=p.default,Qi=we,es=Io,ts=fi.pathExists;var ns={createFile:Xi((function(e,t){function n(){Qi.writeFile(e,"",(e=>{if(e)return t(e);t()}))}Qi.stat(e,((r,u)=>{if(!r&&u.isFile())return t();const o=Zi.dirname(e);ts(o,((e,r)=>e?t(e):r?n():void es.mkdirs(o,(e=>{if(e)return t(e);n()}))))}))})),createFileSync:function(e){let t;try{t=Qi.statSync(e)}catch(e){}if(t&&t.isFile())return;const n=Zi.dirname(e);Qi.existsSync(n)||es.mkdirsSync(n),Qi.writeFileSync(e,"")}};const rs=yo.fromCallback,us=p.default,os=we,is=Io,ss=fi.pathExists;var cs={createLink:rs((function(e,t,n){function r(e,t){os.link(e,t,(e=>{if(e)return n(e);n(null)}))}ss(t,((u,o)=>u?n(u):o?n(null):void os.lstat(e,(u=>{if(u)return u.message=u.message.replace("lstat","ensureLink"),n(u);const o=us.dirname(t);ss(o,((u,i)=>u?n(u):i?r(e,t):void is.mkdirs(o,(u=>{if(u)return n(u);r(e,t)}))))}))))})),createLinkSync:function(e,t){if(os.existsSync(t))return;try{os.lstatSync(e)}catch(e){throw e.message=e.message.replace("lstat","ensureLink"),e}const n=us.dirname(t);return os.existsSync(n)||is.mkdirsSync(n),os.linkSync(e,t)}};const as=p.default,ls=we,fs=fi.pathExists;var ds={symlinkPaths:function(e,t,n){if(as.isAbsolute(e))return ls.lstat(e,(t=>t?(t.message=t.message.replace("lstat","ensureSymlink"),n(t)):n(null,{toCwd:e,toDst:e})));{const r=as.dirname(t),u=as.join(r,e);return fs(u,((t,o)=>t?n(t):o?n(null,{toCwd:u,toDst:e}):ls.lstat(e,(t=>t?(t.message=t.message.replace("lstat","ensureSymlink"),n(t)):n(null,{toCwd:e,toDst:as.relative(r,e)})))))}},symlinkPathsSync:function(e,t){let n;if(as.isAbsolute(e)){if(n=ls.existsSync(e),!n)throw new Error("absolute srcpath does not exist");return{toCwd:e,toDst:e}}{const r=as.dirname(t),u=as.join(r,e);if(n=ls.existsSync(u),n)return{toCwd:u,toDst:e};if(n=ls.existsSync(e),!n)throw new Error("relative srcpath does not exist");return{toCwd:e,toDst:as.relative(r,e)}}}};const Ds=we;var ps={symlinkType:function(e,t,n){if(n="function"==typeof t?t:n,t="function"!=typeof t&&t)return n(null,t);Ds.lstat(e,((e,r)=>{if(e)return n(null,"file");t=r&&r.isDirectory()?"dir":"file",n(null,t)}))},symlinkTypeSync:function(e,t){let n;if(t)return t;try{n=Ds.lstatSync(e)}catch(e){return"file"}return n&&n.isDirectory()?"dir":"file"}};const Es=yo.fromCallback,ms=p.default,hs=we,ys=Io.mkdirs,Cs=Io.mkdirsSync,Fs=ds.symlinkPaths,gs=ds.symlinkPathsSync,As=ps.symlinkType,vs=ps.symlinkTypeSync,Ss=fi.pathExists;var ws={createSymlink:Es((function(e,t,n,r){r="function"==typeof n?n:r,n="function"!=typeof n&&n,Ss(t,((u,o)=>u?r(u):o?r(null):void Fs(e,t,((u,o)=>{if(u)return r(u);e=o.toDst,As(o.toCwd,n,((n,u)=>{if(n)return r(n);const o=ms.dirname(t);Ss(o,((n,i)=>n?r(n):i?hs.symlink(e,t,u,r):void ys(o,(n=>{if(n)return r(n);hs.symlink(e,t,u,r)}))))}))}))))})),createSymlinkSync:function(e,t,n){if(hs.existsSync(t))return;const r=gs(e,t);e=r.toDst,n=vs(r.toCwd,n);const u=ms.dirname(t);return hs.existsSync(u)||Cs(u),hs.symlinkSync(e,t,n)}};var Os,bs={createFile:ns.createFile,createFileSync:ns.createFileSync,ensureFile:ns.createFile,ensureFileSync:ns.createFileSync,createLink:cs.createLink,createLinkSync:cs.createLinkSync,ensureLink:cs.createLink,ensureLinkSync:cs.createLinkSync,createSymlink:ws.createSymlink,createSymlinkSync:ws.createSymlinkSync,ensureSymlink:ws.createSymlink,ensureSymlinkSync:ws.createSymlinkSync};try{Os=we}catch(e){Os=D.default}function _s(e,t){var n,r="\n";return"object"==typeof t&&null!==t&&(t.spaces&&(n=t.spaces),t.EOL&&(r=t.EOL)),JSON.stringify(e,t?t.replacer:null,n).replace(/\n/g,r)+r}function Bs(e){return Buffer.isBuffer(e)&&(e=e.toString("utf8")),e=e.replace(/^\uFEFF/,"")}var Ps={readFile:function(e,t,n){null==n&&(n=t,t={}),"string"==typeof t&&(t={encoding:t});var r=(t=t||{}).fs||Os,u=!0;"throws"in t&&(u=t.throws),r.readFile(e,t,(function(r,o){if(r)return n(r);var i;o=Bs(o);try{i=JSON.parse(o,t?t.reviver:null)}catch(t){return u?(t.message=e+": "+t.message,n(t)):n(null,null)}n(null,i)}))},readFileSync:function(e,t){"string"==typeof(t=t||{})&&(t={encoding:t});var n=t.fs||Os,r=!0;"throws"in t&&(r=t.throws);try{var u=n.readFileSync(e,t);return u=Bs(u),JSON.parse(u,t.reviver)}catch(t){if(r)throw t.message=e+": "+t.message,t;return null}},writeFile:function(e,t,n,r){null==r&&(r=n,n={});var u=(n=n||{}).fs||Os,o="";try{o=_s(t,n)}catch(e){return void(r&&r(e,null))}u.writeFile(e,o,n,r)},writeFileSync:function(e,t,n){var r=(n=n||{}).fs||Os,u=_s(t,n);return r.writeFileSync(e,u,n)}},ks=Ps;const xs=yo.fromCallback,Ns=ks;var Is={readJson:xs(Ns.readFile),readJsonSync:Ns.readFileSync,writeJson:xs(Ns.writeFile),writeJsonSync:Ns.writeFileSync};const Ts=p.default,Rs=Io,Ms=fi.pathExists,Ls=Is;var js=function(e,t,n,r){"function"==typeof n&&(r=n,n={});const u=Ts.dirname(e);Ms(u,((o,i)=>o?r(o):i?Ls.writeJson(e,t,n,r):void Rs.mkdirs(u,(u=>{if(u)return r(u);Ls.writeJson(e,t,n,r)}))))};const $s=we,Hs=p.default,Js=Io,Gs=Is;var Vs=function(e,t,n){const r=Hs.dirname(e);$s.existsSync(r)||Js.mkdirsSync(r),Gs.writeJsonSync(e,t,n)};const Us=yo.fromCallback,Ws=Is;Ws.outputJson=Us(js),Ws.outputJsonSync=Vs,Ws.outputJSON=Ws.outputJson,Ws.outputJSONSync=Ws.outputJsonSync,Ws.writeJSON=Ws.writeJson,Ws.writeJSONSync=Ws.writeJsonSync,Ws.readJSON=Ws.readJson,Ws.readJSONSync=Ws.readJsonSync;var zs=Ws;const Ks=we,qs=p.default,Ys=ci.copySync,Xs=Ji.removeSync,Zs=Io.mkdirpSync,Qs=Zo;function ec(e,t,n){try{Ks.renameSync(e,t)}catch(r){if("EXDEV"!==r.code)throw r;return function(e,t,n){const r={overwrite:n,errorOnExist:!0};return Ys(e,t,r),Xs(e)}(e,t,n)}}var tc=function(e,t,n){const r=(n=n||{}).overwrite||n.clobber||!1,{srcStat:u}=Qs.checkPathsSync(e,t,"move");return Qs.checkParentPathsSync(e,u,t,"move"),Zs(qs.dirname(t)),function(e,t,n){if(n)return Xs(t),ec(e,t,n);if(Ks.existsSync(t))throw new Error("dest already exists.");return ec(e,t,n)}(e,t,r)},nc={moveSync:tc};const rc=we,uc=p.default,oc=bi.copy,ic=Ji.remove,sc=Io.mkdirp,cc=fi.pathExists,ac=Zo;function lc(e,t,n,r){rc.rename(e,t,(u=>u?"EXDEV"!==u.code?r(u):function(e,t,n,r){const u={overwrite:n,errorOnExist:!0};oc(e,t,u,(t=>t?r(t):ic(e,r)))}(e,t,n,r):r()))}var fc=function(e,t,n,r){"function"==typeof n&&(r=n,n={});const u=n.overwrite||n.clobber||!1;ac.checkPaths(e,t,"move",((n,o)=>{if(n)return r(n);const{srcStat:i}=o;ac.checkParentPaths(e,i,t,"move",(n=>{if(n)return r(n);sc(uc.dirname(t),(n=>n?r(n):function(e,t,n,r){if(n)return ic(t,(u=>u?r(u):lc(e,t,n,r)));cc(t,((u,o)=>u?r(u):o?r(new Error("dest already exists.")):lc(e,t,n,r)))}(e,t,u,r)))}))}))};var dc={move:(0,yo.fromCallback)(fc)};const Dc=yo.fromCallback,pc=we,Ec=p.default,mc=Io,hc=fi.pathExists;var yc={outputFile:Dc((function(e,t,n,r){"function"==typeof n&&(r=n,n="utf8");const u=Ec.dirname(e);hc(u,((o,i)=>o?r(o):i?pc.writeFile(e,t,n,r):void mc.mkdirs(u,(u=>{if(u)return r(u);pc.writeFile(e,t,n,r)}))))})),outputFileSync:function(e,...t){const n=Ec.dirname(e);if(pc.existsSync(n))return pc.writeFileSync(e,...t);mc.mkdirsSync(n),pc.writeFileSync(e,...t)}};!function(e){e.exports=Object.assign({},ho,ci,bi,Yi,bs,zs,Io,nc,dc,yc,fi,Ji);const t=D.default;Object.getOwnPropertyDescriptor(t,"promises")&&Object.defineProperty(e.exports,"promises",{get:()=>t.promises})}(mo);const Cc=Nr.exports("streamroller:fileNameFormatter"),Fc=p.default;const gc=Nr.exports("streamroller:fileNameParser"),Ac=nu.exports;const vc=Nr.exports("streamroller:moveAndMaybeCompressFile"),Sc=mo.exports,wc=v.default;var Oc=async(e,t,n)=>{if(n=function(e){const t={mode:parseInt("0600",8),compress:!1},n=Object.assign({},t,e);return vc(`_parseOption: moveAndMaybeCompressFile called with option=${JSON.stringify(n)}`),n}(n),e!==t){if(await Sc.pathExists(e))if(vc(`moveAndMaybeCompressFile: moving file from ${e} to ${t} ${n.compress?"with":"without"} compress`),n.compress)await new Promise(((r,u)=>{let o=!1;const i=Sc.createWriteStream(t,{mode:n.mode,flags:"wx"}).on("open",(()=>{o=!0;const t=Sc.createReadStream(e).on("open",(()=>{t.pipe(wc.createGzip()).pipe(i)})).on("error",(t=>{vc(`moveAndMaybeCompressFile: error reading ${e}`,t),i.destroy(t)}))})).on("finish",(()=>{vc(`moveAndMaybeCompressFile: finished compressing ${t}, deleting ${e}`),Sc.unlink(e).then(r).catch((t=>{vc(`moveAndMaybeCompressFile: error deleting ${e}, truncating instead`,t),Sc.truncate(e).then(r).catch((t=>{vc(`moveAndMaybeCompressFile: error truncating ${e}`,t),u(t)}))}))})).on("error",(e=>{o?(vc(`moveAndMaybeCompressFile: error writing ${t}, deleting`,e),Sc.unlink(t).then((()=>{u(e)})).catch((e=>{vc(`moveAndMaybeCompressFile: error deleting ${t}`,e),u(e)}))):(vc(`moveAndMaybeCompressFile: error creating ${t}`,e),u(e))}))})).catch((()=>{}));else{vc(`moveAndMaybeCompressFile: renaming ${e} to ${t}`);try{await Sc.move(e,t,{overwrite:!0})}catch(n){if(vc(`moveAndMaybeCompressFile: error renaming ${e} to ${t}`,n),"ENOENT"!==n.code){vc("moveAndMaybeCompressFile: trying copy+truncate instead");try{await Sc.copy(e,t,{overwrite:!0}),await Sc.truncate(e)}catch(e){vc("moveAndMaybeCompressFile: error copy+truncate",e)}}}}}else vc("moveAndMaybeCompressFile: source and target are the same, not doing anything")};const bc=Nr.exports("streamroller:RollingFileWriteStream"),_c=mo.exports,Bc=p.default,Pc=E.default,kc=()=>new Date,xc=nu.exports,{Writable:Nc}=C.default,Ic=({file:e,keepFileExt:t,needsIndex:n,alwaysIncludeDate:r,compress:u,fileNameSep:o})=>{let i=o||".";const s=Fc.join(e.dir,e.name),c=t=>t+e.ext,a=(e,t,r)=>!n&&r||!t?e:e+i+t,l=(e,t,n)=>(t>0||r)&&n?e+i+n:e,f=(e,t)=>t&&u?e+".gz":e,d=t?[l,a,c,f]:[c,l,a,f];return({date:e,index:t})=>(Cc(`_formatFileName: date=${e}, index=${t}`),d.reduce(((n,r)=>r(n,t,e)),s))},Tc=({file:e,keepFileExt:t,pattern:n,fileNameSep:r})=>{let u=r||".";const o="__NOT_MATCHING__";let i=[(e,t)=>e.endsWith(".gz")?(gc("it is gzipped"),t.isCompressed=!0,e.slice(0,-1*".gz".length)):e,t?t=>t.startsWith(e.name)&&t.endsWith(e.ext)?(gc("it starts and ends with the right things"),t.slice(e.name.length+1,-1*e.ext.length)):o:t=>t.startsWith(e.base)?(gc("it starts with the right things"),t.slice(e.base.length+1)):o,n?(e,t)=>{const r=e.split(u);let o=r[r.length-1];gc("items: ",r,", indexStr: ",o);let i=e;void 0!==o&&o.match(/^\d+$/)?(i=e.slice(0,-1*(o.length+1)),gc(`dateStr is ${i}`),n&&!i&&(i=o,o="0")):o="0";try{const r=Ac.parse(n,i,new Date(0,0));return Ac.asString(n,r)!==i?e:(t.index=parseInt(o,10),t.date=i,t.timestamp=r.getTime(),"")}catch(t){return gc(`Problem parsing ${i} as ${n}, error was: `,t),e}}:(e,t)=>e.match(/^\d+$/)?(gc("it has an index"),t.index=parseInt(e,10),""):e];return e=>{let t={filename:e,index:0,isCompressed:!1};return i.reduce(((e,n)=>n(e,t)),e)?null:t}},Rc=Oc;var Mc=class extends Nc{constructor(e,t){if(bc(`constructor: creating RollingFileWriteStream. path=${e}`),"string"!=typeof e||0===e.length)throw new Error(`Invalid filename: ${e}`);if(e.endsWith(Bc.sep))throw new Error(`Filename is a directory: ${e}`);0===e.indexOf(`~${Bc.sep}`)&&(e=e.replace("~",Pc.homedir())),super(t),this.options=this._parseOption(t),this.fileObject=Bc.parse(e),""===this.fileObject.dir&&(this.fileObject=Bc.parse(Bc.join(process.cwd(),e))),this.fileFormatter=Ic({file:this.fileObject,alwaysIncludeDate:this.options.alwaysIncludePattern,needsIndex:this.options.maxSize 0`)}else delete n.maxSize;if(n.numBackups||0===n.numBackups){if(n.numBackups<0)throw new Error(`options.numBackups (${n.numBackups}) should be >= 0`);if(n.numBackups>=Number.MAX_SAFE_INTEGER)throw new Error(`options.numBackups (${n.numBackups}) should be < Number.MAX_SAFE_INTEGER`);n.numToKeep=n.numBackups+1}else if(n.numToKeep<=0)throw new Error(`options.numToKeep (${n.numToKeep}) should be > 0`);return bc(`_parseOption: creating stream with option=${JSON.stringify(n)}`),n}_final(e){this.currentFileStream.end("",this.options.encoding,e)}_write(e,t,n){this._shouldRoll().then((()=>{bc(`_write: writing chunk. file=${this.currentFileStream.path} state=${JSON.stringify(this.state)} chunk=${e}`),this.currentFileStream.write(e,t,(t=>{this.state.currentSize+=e.length,n(t)}))}))}async _shouldRoll(){(this._dateChanged()||this._tooBig())&&(bc(`_shouldRoll: rolling because dateChanged? ${this._dateChanged()} or tooBig? ${this._tooBig()}`),await this._roll())}_dateChanged(){return this.state.currentDate&&this.state.currentDate!==xc(this.options.pattern,kc())}_tooBig(){return this.state.currentSize>=this.options.maxSize}_roll(){return bc("_roll: closing the current stream"),new Promise(((e,t)=>{this.currentFileStream.end("",this.options.encoding,(()=>{this._moveOldFiles().then(e).catch(t)}))}))}async _moveOldFiles(){const e=await this._getExistingFiles();for(let t=(this.state.currentDate?e.filter((e=>e.date===this.state.currentDate)):e).length;t>=0;t--){bc(`_moveOldFiles: i = ${t}`);const e=this.fileFormatter({date:this.state.currentDate,index:t}),n=this.fileFormatter({date:this.state.currentDate,index:t+1}),r={compress:this.options.compress&&0===t,mode:this.options.mode};await Rc(e,n,r)}this.state.currentSize=0,this.state.currentDate=this.state.currentDate?xc(this.options.pattern,kc()):null,bc(`_moveOldFiles: finished rolling files. state=${JSON.stringify(this.state)}`),this._renewWriteStream(),await new Promise(((e,t)=>{this.currentFileStream.write("","utf8",(()=>{this._clean().then(e).catch(t)}))}))}async _getExistingFiles(){const e=await _c.readdir(this.fileObject.dir).catch((()=>[]));bc(`_getExistingFiles: files=${e}`);const t=e.map((e=>this.fileNameParser(e))).filter((e=>e)),n=e=>(e.timestamp?e.timestamp:kc().getTime())-e.index;return t.sort(((e,t)=>n(e)-n(t))),t}_renewWriteStream(){const e=this.fileFormatter({date:this.state.currentDate,index:0}),t=e=>{try{return _c.mkdirSync(e,{recursive:!0})}catch(n){if("ENOENT"===n.code)return t(Bc.dirname(e)),t(e);if("EEXIST"!==n.code&&"EROFS"!==n.code)throw n;try{if(_c.statSync(e).isDirectory())return e;throw n}catch(e){throw n}}};t(this.fileObject.dir);const n={flags:this.options.flags,encoding:this.options.encoding,mode:this.options.mode};var r,u;_c.appendFileSync(e,"",(r={...n},u="flags",r["flag"]=r[u],delete r[u],r)),this.currentFileStream=_c.createWriteStream(e,n),this.currentFileStream.on("error",(e=>{this.emit("error",e)}))}async _clean(){const e=await this._getExistingFiles();if(bc(`_clean: numToKeep = ${this.options.numToKeep}, existingFiles = ${e.length}`),bc("_clean: existing files are: ",e),this._tooManyFiles(e.length)){const n=e.slice(0,e.length-this.options.numToKeep).map((e=>Bc.format({dir:this.fileObject.dir,base:e.filename})));await(t=n,bc(`deleteFiles: files to delete: ${t}`),Promise.all(t.map((e=>_c.unlink(e).catch((t=>{bc(`deleteFiles: error when unlinking ${e}, ignoring. Error was ${t}`)}))))))}var t}_tooManyFiles(e){return this.options.numToKeep>0&&e>this.options.numToKeep}};const Lc=Mc;var jc=class extends Lc{constructor(e,t,n,r){r||(r={}),t&&(r.maxSize=t),r.numBackups||0===r.numBackups||(n||0===n||(n=1),r.numBackups=n),super(e,r),this.backups=r.numBackups,this.size=this.options.maxSize}get theStream(){return this.currentFileStream}};const $c=Mc;var Hc={RollingFileWriteStream:Mc,RollingFileStream:jc,DateRollingFileStream:class extends $c{constructor(e,t,n){t&&"object"==typeof t&&(n=t,t=null),n||(n={}),t||(t="yyyy-MM-dd"),n.pattern=t,n.numBackups||0===n.numBackups?n.daysToKeep=n.numBackups:(n.daysToKeep||0===n.daysToKeep?process.emitWarning("options.daysToKeep is deprecated due to the confusion it causes when used together with file size rolling. Please use options.numBackups instead.","DeprecationWarning","streamroller-DEP0001"):n.daysToKeep=1,n.numBackups=n.daysToKeep),super(e,n),this.mode=this.options.mode}get theStream(){return this.currentFileStream}}};const Jc=Nr.exports("log4js:file"),Gc=p.default,Vc=Hc,Uc=E.default.EOL;let Wc=!1;const zc=new Set;function Kc(){zc.forEach((e=>{e.sighupHandler()}))}function qc(e,t,n,r){const u=new Vc.RollingFileStream(e,t,n,r);return u.on("error",(t=>{console.error("log4js.fileAppender - Writing to file %s, error happened ",e,t)})),u.on("drain",(()=>{process.emit("log4js:pause",!1)})),u}Eo.configure=function(e,t){let n=t.basicLayout;return e.layout&&(n=t.layout(e.layout.type,e.layout)),e.mode=e.mode||384,function(e,t,n,r,u,o){e=Gc.normalize(e),Jc("Creating file appender (",e,", ",n,", ",r=r||0===r?r:5,", ",u,", ",o,")");let i=qc(e,n,r,u);const s=function(e){if(i.writable){if(!0===u.removeColor){const t=/\x1b[[0-9;]*m/g;e.data=e.data.map((e=>"string"==typeof e?e.replace(t,""):e))}i.write(t(e,o)+Uc,"utf8")||process.emit("log4js:pause",!0)}};return s.reopen=function(){i.end((()=>{i=qc(e,n,r,u)}))},s.sighupHandler=function(){Jc("SIGHUP handler called."),s.reopen()},s.shutdown=function(e){zc.delete(s),0===zc.size&&Wc&&(process.removeListener("SIGHUP",Kc),Wc=!1),i.end("","utf-8",e)},zc.add(s),Wc||(process.on("SIGHUP",Kc),Wc=!0),s}(e.filename,n,e.maxLogSize,e.backups,e,e.timezoneOffset)};var Yc={};const Xc=Hc,Zc=E.default.EOL;function Qc(e,t,n,r,u){r.maxSize=r.maxLogSize;const o=function(e,t,n){const r=new Xc.DateRollingFileStream(e,t,n);return r.on("error",(t=>{console.error("log4js.dateFileAppender - Writing to file %s, error happened ",e,t)})),r.on("drain",(()=>{process.emit("log4js:pause",!1)})),r}(e,t,r),i=function(e){o.writable&&(o.write(n(e,u)+Zc,"utf8")||process.emit("log4js:pause",!0))};return i.shutdown=function(e){o.end("","utf-8",e)},i}Yc.configure=function(e,t){let n=t.basicLayout;return e.layout&&(n=t.layout(e.layout.type,e.layout)),e.alwaysIncludePattern||(e.alwaysIncludePattern=!1),e.mode=e.mode||384,Qc(e.filename,e.pattern,n,e,e.timezoneOffset)};var ea={};const ta=Nr.exports("log4js:fileSync"),na=p.default,ra=D.default,ua=E.default.EOL||"\n";function oa(e,t){if(ra.existsSync(e))return;const n=ra.openSync(e,t.flags,t.mode);ra.closeSync(n)}class ia{constructor(e,t,n,r){ta("In RollingFileStream"),function(){if(!e||!t||t<=0)throw new Error("You must specify a filename and file size")}(),this.filename=e,this.size=t,this.backups=n,this.options=r,this.currentSize=0,this.currentSize=function(e){let t=0;try{t=ra.statSync(e).size}catch(t){oa(e,r)}return t}(this.filename)}shouldRoll(){return ta("should roll with current size %d, and max size %d",this.currentSize,this.size),this.currentSize>=this.size}roll(e){const t=this,n=new RegExp(`^${na.basename(e)}`);function r(e){return n.test(e)}function u(t){return parseInt(t.substring(`${na.basename(e)}.`.length),10)||0}function o(e,t){return u(e)>u(t)?1:u(e) ${e}.${r+1}`),ra.renameSync(na.join(na.dirname(e),n),`${e}.${r+1}`)}}ta("Rolling, rolling, rolling"),ta("Renaming the old files"),ra.readdirSync(na.dirname(e)).filter(r).sort(o).reverse().forEach(i)}write(e,t){const n=this;ta("in write"),this.shouldRoll()&&(this.currentSize=0,this.roll(this.filename)),ta("writing the chunk to the file"),n.currentSize+=e.length,ra.appendFileSync(n.filename,e)}}ea.configure=function(e,t){let n=t.basicLayout;e.layout&&(n=t.layout(e.layout.type,e.layout));const r={flags:e.flags||"a",encoding:e.encoding||"utf8",mode:e.mode||384};return function(e,t,n,r,u,o){ta("fileSync appender created");const i=function(e,t,n){let r;var u;return t?r=new ia(e,t,n,o):(oa(u=e,o),r={write(e){ra.appendFileSync(u,e)}}),r}(e=na.normalize(e),n,r=r||0===r?r:5);return e=>{i.write(t(e,u)+ua)}}(e.filename,n,e.maxLogSize,e.backups,e.timezoneOffset,r)};var sa={};const ca=Nr.exports("log4js:tcp"),aa=S.default;sa.configure=function(e,t){ca(`configure with config = ${e}`);let n=function(e){return e.serialise()};return e.layout&&(n=t.layout(e.layout.type,e.layout)),function(e,t){let n=!1;const r=[];let u,o=3,i="__LOG4JS__";function s(e){ca("Writing log event to socket"),n=u.write(`${t(e)}${i}`,"utf8")}function c(){let e;for(ca("emptying buffer");e=r.shift();)s(e)}function a(e){n?s(e):(ca("buffering log event because it cannot write at the moment"),r.push(e))}return function t(){ca(`appender creating socket to ${e.host||"localhost"}:${e.port||5e3}`),i=`${e.endMsg||"__LOG4JS__"}`,u=aa.createConnection(e.port||5e3,e.host||"localhost"),u.on("connect",(()=>{ca("socket connected"),c(),n=!0})),u.on("drain",(()=>{ca("drain event received, emptying buffer"),n=!0,c()})),u.on("timeout",u.end.bind(u)),u.on("error",(e=>{ca("connection error",e),n=!1,c()})),u.on("close",t)}(),a.shutdown=function(e){ca("shutdown called"),r.length&&o?(ca("buffer has items, waiting 100ms to empty"),o-=1,setTimeout((()=>{a.shutdown(e)}),100)):(u.removeAllListeners("close"),u.end(e))},a}(e,n)};const la=p.default,fa=Nr.exports("log4js:appenders"),da=tu,Da=eo,pa=gu,Ea=hu,ma=to,ha=new Map;ha.set("console",oo),ha.set("stdout",so),ha.set("stderr",co),ha.set("logLevelFilter",ao),ha.set("categoryFilter",lo),ha.set("noLogFilter",Do),ha.set("file",Eo),ha.set("dateFile",Yc),ha.set("fileSync",ea),ha.set("tcp",sa);const ya=new Map,Ca=(e,t)=>{fa("Loading module from ",e);try{return require(e)}catch(n){return void da.throwExceptionIf(t,"MODULE_NOT_FOUND"!==n.code,`appender "${e}" could not be loaded (error was: ${n})`)}},Fa=new Set,ga=(e,t)=>{if(ya.has(e))return ya.get(e);if(!t.appenders[e])return!1;if(Fa.has(e))throw new Error(`Dependency loop detected for appender ${e}.`);Fa.add(e),fa(`Creating appender ${e}`);const n=Aa(e,t);return Fa.delete(e),ya.set(e,n),n},Aa=(e,t)=>{const n=t.appenders[e],r=n.type.configure?n.type:((e,t)=>ha.get(e)||Ca(`./${e}`,t)||Ca(e,t)||require.main&&Ca(la.join(la.dirname(require.main.filename),e),t)||Ca(la.join(process.cwd(),e),t))(n.type,t);return da.throwExceptionIf(t,da.not(r),`appender "${e}" is not valid (type "${n.type}" could not be found)`),r.appender&&fa(`DEPRECATION: Appender ${n.type} exports an appender function.`),r.shutdown&&fa(`DEPRECATION: Appender ${n.type} exports a shutdown function.`),fa(`${e}: clustering.isMaster ? ${Da.isMaster()}`),fa(`${e}: appenderModule is ${F.default.inspect(r)}`),Da.onlyOnMaster((()=>(fa(`calling appenderModule.configure for ${e} / ${n.type}`),r.configure(ma.modifyConfig(n),Ea,(e=>ga(e,t)),pa))),(()=>{}))},va=e=>{ya.clear(),Fa.clear();const t=[];Object.values(e.categories).forEach((e=>{t.push(...e.appenders)})),Object.keys(e.appenders).forEach((n=>{(t.includes(n)||"tcp-server"===e.appenders[n].type)&&ga(n,e)}))},Sa=()=>{va({appenders:{out:{type:"stdout"}},categories:{default:{appenders:["out"],level:"trace"}}})};Sa(),da.addListener((e=>{da.throwExceptionIf(e,da.not(da.anObject(e.appenders)),'must have a property "appenders" of type object.');const t=Object.keys(e.appenders);da.throwExceptionIf(e,da.not(t.length),"must define at least one appender."),t.forEach((t=>{da.throwExceptionIf(e,da.not(e.appenders[t].type),`appender "${t}" is not valid (must be an object with property "type")`)}))})),da.addListener(va),Au.exports=ya,Au.exports.init=Sa;var wa={exports:{}};!function(e){const t=Nr.exports("log4js:categories"),n=tu,r=gu,u=Au.exports,o=new Map;function i(e,t,n){if(!1===t.inherit)return;const r=n.lastIndexOf(".");if(r<0)return;const u=n.substring(0,r);let o=e.categories[u];o||(o={inherit:!0,appenders:[]}),i(e,o,u),!e.categories[u]&&o.appenders&&o.appenders.length&&o.level&&(e.categories[u]=o),t.appenders=t.appenders||[],t.level=t.level||o.level,o.appenders.forEach((e=>{t.appenders.includes(e)||t.appenders.push(e)})),t.parent=o}function s(e){if(!e.categories)return;Object.keys(e.categories).forEach((t=>{const n=e.categories[t];i(e,n,t)}))}n.addPreProcessingListener((e=>s(e))),n.addListener((e=>{n.throwExceptionIf(e,n.not(n.anObject(e.categories)),'must have a property "categories" of type object.');const t=Object.keys(e.categories);n.throwExceptionIf(e,n.not(t.length),"must define at least one category."),t.forEach((t=>{const o=e.categories[t];n.throwExceptionIf(e,[n.not(o.appenders),n.not(o.level)],`category "${t}" is not valid (must be an object with properties "appenders" and "level")`),n.throwExceptionIf(e,n.not(Array.isArray(o.appenders)),`category "${t}" is not valid (appenders must be an array of appender names)`),n.throwExceptionIf(e,n.not(o.appenders.length),`category "${t}" is not valid (appenders must contain at least one appender name)`),Object.prototype.hasOwnProperty.call(o,"enableCallStack")&&n.throwExceptionIf(e,"boolean"!=typeof o.enableCallStack,`category "${t}" is not valid (enableCallStack must be boolean type)`),o.appenders.forEach((r=>{n.throwExceptionIf(e,n.not(u.get(r)),`category "${t}" is not valid (appender "${r}" is not defined)`)})),n.throwExceptionIf(e,n.not(r.getLevel(o.level)),`category "${t}" is not valid (level "${o.level}" not recognised; valid levels are ${r.levels.join(", ")})`)})),n.throwExceptionIf(e,n.not(e.categories.default),'must define a "default" category.')}));const c=e=>{o.clear();Object.keys(e.categories).forEach((n=>{const i=e.categories[n],s=[];i.appenders.forEach((e=>{s.push(u.get(e)),t(`Creating category ${n}`),o.set(n,{appenders:s,level:r.getLevel(i.level),enableCallStack:i.enableCallStack||!1})}))}))},a=()=>{c({categories:{default:{appenders:["out"],level:"OFF"}}})};a(),n.addListener(c);const l=e=>(t(`configForCategory: searching for config for ${e}`),o.has(e)?(t(`configForCategory: ${e} exists in config, returning it`),o.get(e)):e.indexOf(".")>0?(t(`configForCategory: ${e} has hierarchy, searching for parents`),l(e.substring(0,e.lastIndexOf(".")))):(t("configForCategory: returning config for default category"),l("default")));e.exports=o,e.exports=Object.assign(e.exports,{appendersForCategory:e=>l(e).appenders,getLevelForCategory:e=>l(e).level,setLevelForCategory:(e,n)=>{let r=o.get(e);if(t(`setLevelForCategory: found ${r} for ${e}`),!r){const n=l(e);t(`setLevelForCategory: no config found for category, found ${n} for parents of ${e}`),r={appenders:n.appenders}}r.level=n,o.set(e,r)},getEnableCallStackForCategory:e=>!0===l(e).enableCallStack,setEnableCallStackForCategory:(e,t)=>{l(e).enableCallStack=t},init:a})}(wa);const Oa=Nr.exports("log4js:logger"),ba=Hu,_a=gu,Ba=eo,Pa=wa.exports,ka=tu,xa=/at (?:(.+)\s+\()?(?:(.+?):(\d+)(?::(\d+))?|([^)]+))\)?/;function Na(e,t=4){const n=e.stack.split("\n").slice(t),r=xa.exec(n[0]);return r&&6===r.length?{functionName:r[1],fileName:r[2],lineNumber:parseInt(r[3],10),columnNumber:parseInt(r[4],10),callStack:n.join("\n")}:null}class Ia{constructor(e){if(!e)throw new Error("No category provided.");this.category=e,this.context={},this.parseCallStack=Na,Oa(`Logger created (${this.category}, ${this.level})`)}get level(){return _a.getLevel(Pa.getLevelForCategory(this.category),_a.TRACE)}set level(e){Pa.setLevelForCategory(this.category,_a.getLevel(e,this.level))}get useCallStack(){return Pa.getEnableCallStackForCategory(this.category)}set useCallStack(e){Pa.setEnableCallStackForCategory(this.category,!0===e)}log(e,...t){let n=_a.getLevel(e);n||(this._log(_a.WARN,"log4js:logger.log: invalid value for log-level as first parameter given: ",e),n=_a.INFO),this.isLevelEnabled(n)&&this._log(n,t)}isLevelEnabled(e){return this.level.isLessThanOrEqualTo(e)}_log(e,t){Oa(`sending log data (${e}) to appenders`);const n=new ba(this.category,e,t,this.context,this.useCallStack&&this.parseCallStack(new Error));Ba.send(n)}addContext(e,t){this.context[e]=t}removeContext(e){delete this.context[e]}clearContext(){this.context={}}setParseCallStackFunction(e){this.parseCallStack=e}}function Ta(e){const t=_a.getLevel(e),n=t.toString().toLowerCase().replace(/_([a-z])/g,(e=>e[1].toUpperCase())),r=n[0].toUpperCase()+n.slice(1);Ia.prototype[`is${r}Enabled`]=function(){return this.isLevelEnabled(t)},Ia.prototype[n]=function(...e){this.log(t,...e)}}_a.levels.forEach(Ta),ka.addListener((()=>{_a.levels.forEach(Ta)}));var Ra=Ia;const Ma=gu;function La(e){return e.originalUrl||e.url}function ja(e,t){for(let n=0;ne.source?e.source:e));t=new RegExp(n.join("|"))}return t}(t.nolog);return(e,i,s)=>{if(e._logging)return s();if(o&&o.test(e.originalUrl))return s();if(n.isLevelEnabled(r)||"auto"===t.level){const o=new Date,{writeHead:s}=i;e._logging=!0,i.writeHead=(e,t)=>{i.writeHead=s,i.writeHead(e,t),i.__statusCode=e,i.__headers=t||{}},i.on("finish",(()=>{i.responseTime=new Date-o,i.statusCode&&"auto"===t.level&&(r=Ma.INFO,i.statusCode>=300&&(r=Ma.WARN),i.statusCode>=400&&(r=Ma.ERROR)),r=function(e,t,n){let r=t;if(n){const t=n.find((t=>{let n=!1;return n=t.from&&t.to?e>=t.from&&e<=t.to:-1!==t.codes.indexOf(e),n}));t&&(r=Ma.getLevel(t.level,r))}return r}(i.statusCode,r,t.statusRules);const s=function(e,t,n){const r=[];return r.push({token:":url",replacement:La(e)}),r.push({token:":protocol",replacement:e.protocol}),r.push({token:":hostname",replacement:e.hostname}),r.push({token:":method",replacement:e.method}),r.push({token:":status",replacement:t.__statusCode||t.statusCode}),r.push({token:":response-time",replacement:t.responseTime}),r.push({token:":date",replacement:(new Date).toUTCString()}),r.push({token:":referrer",replacement:e.headers.referer||e.headers.referrer||""}),r.push({token:":http-version",replacement:`${e.httpVersionMajor}.${e.httpVersionMinor}`}),r.push({token:":remote-addr",replacement:e.headers["x-forwarded-for"]||e.ip||e._remoteAddress||e.socket&&(e.socket.remoteAddress||e.socket.socket&&e.socket.socket.remoteAddress)}),r.push({token:":user-agent",replacement:e.headers["user-agent"]}),r.push({token:":content-length",replacement:t.getHeader("content-length")||t.__headers&&t.__headers["Content-Length"]||"-"}),r.push({token:/:req\[([^\]]+)]/g,replacement:(t,n)=>e.headers[n.toLowerCase()]}),r.push({token:/:res\[([^\]]+)]/g,replacement:(e,n)=>t.getHeader(n.toLowerCase())||t.__headers&&t.__headers[n]}),(e=>{const t=e.concat();for(let e=0;eja(e,s)));t&&n.log(r,t)}else n.log(r,ja(u,s));t.context&&n.removeContext("res")}))}return s()}},nl=Va;let rl=!1;function ul(e){if(!rl)return;Ua("Received log event ",e);Za.appendersForCategory(e.categoryName).forEach((t=>{t(e)}))}function ol(e){rl&&il();let t=e;return"string"==typeof t&&(t=function(e){Ua(`Loading configuration from ${e}`);try{return JSON.parse(Wa.readFileSync(e,"utf8"))}catch(t){throw new Error(`Problem reading config from file "${e}". Error was ${t.message}`,t)}}(e)),Ua(`Configuration is ${t}`),Ka.configure(za(t)),el.onMessage(ul),rl=!0,sl}function il(e){Ua("Shutdown called. Disabling all log writing."),rl=!1;const t=Array.from(Xa.values());Xa.init(),Za.init();const n=t.reduceRight(((e,t)=>t.shutdown?e+1:e),0);if(0===n)return Ua("No appenders with shutdown functions found."),void 0!==e&&e();let r,u=0;function o(t){r=r||t,u+=1,Ua(`Appender shutdowns complete: ${u} / ${n}`),u>=n&&(Ua("All shutdown functions completed."),e&&e(r))}return Ua(`Found ${n} appenders with shutdown functions.`),t.filter((e=>e.shutdown)).forEach((e=>e.shutdown(o))),null}const sl={getLogger:function(e){return rl||ol(process.env.LOG4JS_CONFIG||{appenders:{out:{type:"stdout"}},categories:{default:{appenders:["out"],level:"OFF"}}}),new Qa(e||"default")},configure:ol,shutdown:il,connectLogger:tl,levels:Ya,addLayout:qa.addLayout,recording:function(){return nl}};var cl=sl,al={};Object.defineProperty(al,"__esModule",{value:!0}),al.levelMap=al.getLevel=al.setCategoriesLevel=al.getConfiguration=al.setConfiguration=void 0;const ll=cl;let fl={appenders:{debug:{type:"stdout",layout:{type:"pattern",pattern:"[%d] > hvigor %p %c %[%m%]"}},info:{type:"stdout",layout:{type:"pattern",pattern:"[%d] > hvigor %[%m%]"}},"no-pattern-info":{type:"stdout",layout:{type:"pattern",pattern:"%m"}},wrong:{type:"stderr",layout:{type:"pattern",pattern:"[%d] > hvigor %[%p: %m%]"}},"just-debug":{type:"logLevelFilter",appender:"debug",level:"debug",maxLevel:"debug"},"just-info":{type:"logLevelFilter",appender:"info",level:"info",maxLevel:"info"},"just-wrong":{type:"logLevelFilter",appender:"wrong",level:"warn",maxLevel:"error"}},categories:{default:{appenders:["just-debug","just-info","just-wrong"],level:"debug"},"no-pattern-info":{appenders:["no-pattern-info"],level:"info"}}};al.setConfiguration=e=>{fl=e};al.getConfiguration=()=>fl;let dl=ll.levels.DEBUG;al.setCategoriesLevel=(e,t)=>{dl=e;const n=fl.categories;for(const r in n)(null==t?void 0:t.includes(r))||Object.prototype.hasOwnProperty.call(n,r)&&(n[r].level=e.levelStr)};al.getLevel=()=>dl,al.levelMap=new Map([["ALL",ll.levels.ALL],["MARK",ll.levels.MARK],["TRACE",ll.levels.TRACE],["DEBUG",ll.levels.DEBUG],["INFO",ll.levels.INFO],["WARN",ll.levels.WARN],["ERROR",ll.levels.ERROR],["FATAL",ll.levels.FATAL],["OFF",ll.levels.OFF]]);var Dl=w&&w.__createBinding||(Object.create?function(e,t,n,r){void 0===r&&(r=n);var u=Object.getOwnPropertyDescriptor(t,n);u&&!("get"in u?!t.__esModule:u.writable||u.configurable)||(u={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,r,u)}:function(e,t,n,r){void 0===r&&(r=n),e[r]=t[n]}),pl=w&&w.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),El=w&&w.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var n in e)"default"!==n&&Object.prototype.hasOwnProperty.call(e,n)&&Dl(t,e,n);return pl(t,e),t};Object.defineProperty(xr,"__esModule",{value:!0}),xr.evaluateLogLevel=xr.HvigorLogger=void 0;const ml=El(cl),hl=cl,yl=El(F.default),Cl=al;class Fl{constructor(e){ml.configure((0,Cl.getConfiguration)()),this._logger=ml.getLogger(e),this._logger.level=(0,Cl.getLevel)()}static getLogger(e){return new Fl(e)}log(e,...t){this._logger.log(e,...t)}debug(e,...t){this._logger.debug(e,...t)}info(e,...t){this._logger.info(e,...t)}warn(e,...t){void 0!==e&&""!==e&&this._logger.warn(e,...t)}error(e,...t){this._logger.error(e,...t)}_printTaskExecuteInfo(e,t){this.info(`Finished :${e}... after ${t}`)}_printFailedTaskInfo(e){this.error(`Failed :${e}... `)}_printDisabledTaskInfo(e){this.info(`Disabled :${e}... `)}_printUpToDateTaskInfo(e){this.info(`UP-TO-DATE :${e}... `)}errorMessageExit(e,...t){throw new Error(yl.format(e,...t))}errorExit(e,t,...n){t&&this._logger.error(t,n),this._logger.error(e.stack)}setLevel(e,t){(0,Cl.setCategoriesLevel)(e,t),ml.shutdown(),ml.configure((0,Cl.getConfiguration)())}getLevel(){return this._logger.level}configure(e){const t=(0,Cl.getConfiguration)(),n={appenders:{...t.appenders,...e.appenders},categories:{...t.categories,...e.categories}};(0,Cl.setConfiguration)(n),ml.shutdown(),ml.configure(n)}}xr.HvigorLogger=Fl,xr.evaluateLogLevel=function(e,t){t.debug?e.setLevel(hl.levels.DEBUG):t.warn?e.setLevel(hl.levels.WARN):t.error?e.setLevel(hl.levels.ERROR):e.setLevel(hl.levels.INFO)};var gl=w&&w.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(X,"__esModule",{value:!0}),X.parseJsonText=X.parseJsonFile=void 0;const Al=Z,vl=gl(kr),Sl=gl(p.default),wl=gl(E.default),Ol=xr.HvigorLogger.getLogger("parse-json-util");var bl;!function(e){e[e.Char=0]="Char",e[e.EOF=1]="EOF",e[e.Identifier=2]="Identifier"}(bl||(bl={}));let _l,Bl,Pl,kl,xl,Nl,Il="start",Tl=[],Rl=0,Ml=1,Ll=0,jl=!1,$l="default",Hl="'",Jl=1;function Gl(e,t=!1){Bl=String(e),Il="start",Tl=[],Rl=0,Ml=1,Ll=0,kl=void 0,jl=t;do{_l=Vl(),Xl[Il]()}while("eof"!==_l.type);return kl}function Vl(){for($l="default",xl="",Hl="'",Jl=1;;){Nl=Ul();const e=zl[$l]();if(e)return e}}function Ul(){if(Bl[Rl])return String.fromCodePoint(Bl.codePointAt(Rl))}function Wl(){const e=Ul();return"\n"===e?(Ml++,Ll=0):e?Ll+=e.length:Ll++,e&&(Rl+=e.length),e}X.parseJsonFile=function(e,t=!1,n="utf-8"){const r=vl.default.readFileSync(Sl.default.resolve(e),{encoding:n});try{return Gl(r,t)}catch(t){if(t instanceof SyntaxError){const n=t.message.split("at");2===n.length&&Ol.errorMessageExit(`${n[0].trim()}${wl.default.EOL}\t at ${e}:${n[1].trim()}`)}Ol.errorMessageExit(`${e} is not in valid JSON/JSON5 format.`)}},X.parseJsonText=Gl;const zl={default(){switch(Nl){case"/":return Wl(),void($l="comment");case void 0:return Wl(),Kl("eof")}if(!Al.JudgeUtil.isIgnoreChar(Nl)&&!Al.JudgeUtil.isSpaceSeparator(Nl))return zl[Il]();Wl()},start(){$l="value"},beforePropertyName(){switch(Nl){case"$":case"_":return xl=Wl(),void($l="identifierName");case"\\":return Wl(),void($l="identifierNameStartEscape");case"}":return Kl("punctuator",Wl());case'"':case"'":return Hl=Nl,Wl(),void($l="string")}if(Al.JudgeUtil.isIdStartChar(Nl))return xl+=Wl(),void($l="identifierName");throw tf(bl.Char,Wl())},afterPropertyName(){if(":"===Nl)return Kl("punctuator",Wl());throw tf(bl.Char,Wl())},beforePropertyValue(){$l="value"},afterPropertyValue(){switch(Nl){case",":case"}":return Kl("punctuator",Wl())}throw tf(bl.Char,Wl())},beforeArrayValue(){if("]"===Nl)return Kl("punctuator",Wl());$l="value"},afterArrayValue(){switch(Nl){case",":case"]":return Kl("punctuator",Wl())}throw tf(bl.Char,Wl())},end(){throw tf(bl.Char,Wl())},comment(){switch(Nl){case"*":return Wl(),void($l="multiLineComment");case"/":return Wl(),void($l="singleLineComment")}throw tf(bl.Char,Wl())},multiLineComment(){switch(Nl){case"*":return Wl(),void($l="multiLineCommentAsterisk");case void 0:throw tf(bl.Char,Wl())}Wl()},multiLineCommentAsterisk(){switch(Nl){case"*":return void Wl();case"/":return Wl(),void($l="default");case void 0:throw tf(bl.Char,Wl())}Wl(),$l="multiLineComment"},singleLineComment(){switch(Nl){case"\n":case"\r":case"\u2028":case"\u2029":return Wl(),void($l="default");case void 0:return Wl(),Kl("eof")}Wl()},value(){switch(Nl){case"{":case"[":return Kl("punctuator",Wl());case"n":return Wl(),ql("ull"),Kl("null",null);case"t":return Wl(),ql("rue"),Kl("boolean",!0);case"f":return Wl(),ql("alse"),Kl("boolean",!1);case"-":case"+":return"-"===Wl()&&(Jl=-1),void($l="numerical");case".":case"0":case"I":case"N":return void($l="numerical");case'"':case"'":return Hl=Nl,Wl(),xl="",void($l="string")}if(void 0===Nl||!Al.JudgeUtil.isDigitWithoutZero(Nl))throw tf(bl.Char,Wl());$l="numerical"},numerical(){switch(Nl){case".":return xl=Wl(),void($l="decimalPointLeading");case"0":return xl=Wl(),void($l="zero");case"I":return Wl(),ql("nfinity"),Kl("numeric",Jl*(1/0));case"N":return Wl(),ql("aN"),Kl("numeric",NaN)}if(void 0!==Nl&&Al.JudgeUtil.isDigitWithoutZero(Nl))return xl=Wl(),void($l="decimalInteger");throw tf(bl.Char,Wl())},zero(){switch(Nl){case".":case"e":case"E":return void($l="decimal");case"x":case"X":return xl+=Wl(),void($l="hexadecimal")}return Kl("numeric",0)},decimalInteger(){switch(Nl){case".":case"e":case"E":return void($l="decimal")}if(!Al.JudgeUtil.isDigit(Nl))return Kl("numeric",Jl*Number(xl));xl+=Wl()},decimal(){switch(Nl){case".":xl+=Wl(),$l="decimalFraction";break;case"e":case"E":xl+=Wl(),$l="decimalExponent"}},decimalPointLeading(){if(Al.JudgeUtil.isDigit(Nl))return xl+=Wl(),void($l="decimalFraction");throw tf(bl.Char,Wl())},decimalFraction(){switch(Nl){case"e":case"E":return xl+=Wl(),void($l="decimalExponent")}if(!Al.JudgeUtil.isDigit(Nl))return Kl("numeric",Jl*Number(xl));xl+=Wl()},decimalExponent(){switch(Nl){case"+":case"-":return xl+=Wl(),void($l="decimalExponentSign")}if(Al.JudgeUtil.isDigit(Nl))return xl+=Wl(),void($l="decimalExponentInteger");throw tf(bl.Char,Wl())},decimalExponentSign(){if(Al.JudgeUtil.isDigit(Nl))return xl+=Wl(),void($l="decimalExponentInteger");throw tf(bl.Char,Wl())},decimalExponentInteger(){if(!Al.JudgeUtil.isDigit(Nl))return Kl("numeric",Jl*Number(xl));xl+=Wl()},hexadecimal(){if(Al.JudgeUtil.isHexDigit(Nl))return xl+=Wl(),void($l="hexadecimalInteger");throw tf(bl.Char,Wl())},hexadecimalInteger(){if(!Al.JudgeUtil.isHexDigit(Nl))return Kl("numeric",Jl*Number(xl));xl+=Wl()},identifierNameStartEscape(){if("u"!==Nl)throw tf(bl.Char,Wl());Wl();const e=Yl();switch(e){case"$":case"_":break;default:if(!Al.JudgeUtil.isIdStartChar(e))throw tf(bl.Identifier)}xl+=e,$l="identifierName"},identifierName(){switch(Nl){case"$":case"_":case"‌":case"‍":return void(xl+=Wl());case"\\":return Wl(),void($l="identifierNameEscape")}if(!Al.JudgeUtil.isIdContinueChar(Nl))return Kl("identifier",xl);xl+=Wl()},identifierNameEscape(){if("u"!==Nl)throw tf(bl.Char,Wl());Wl();const e=Yl();switch(e){case"$":case"_":case"‌":case"‍":break;default:if(!Al.JudgeUtil.isIdContinueChar(e))throw tf(bl.Identifier)}xl+=e,$l="identifierName"},string(){switch(Nl){case"\\":return Wl(),void(xl+=function(){const e=Ul(),t=function(){switch(Ul()){case"b":return Wl(),"\b";case"f":return Wl(),"\f";case"n":return Wl(),"\n";case"r":return Wl(),"\r";case"t":return Wl(),"\t";case"v":return Wl(),"\v"}return}();if(t)return t;switch(e){case"0":if(Wl(),Al.JudgeUtil.isDigit(Ul()))throw tf(bl.Char,Wl());return"\0";case"x":return Wl(),function(){let e="",t=Ul();if(!Al.JudgeUtil.isHexDigit(t))throw tf(bl.Char,Wl());if(e+=Wl(),t=Ul(),!Al.JudgeUtil.isHexDigit(t))throw tf(bl.Char,Wl());return e+=Wl(),String.fromCodePoint(parseInt(e,16))}();case"u":return Wl(),Yl();case"\n":case"\u2028":case"\u2029":return Wl(),"";case"\r":return Wl(),"\n"===Ul()&&Wl(),""}if(void 0===e||Al.JudgeUtil.isDigitWithoutZero(e))throw tf(bl.Char,Wl());return Wl()}());case'"':case"'":if(Nl===Hl){const e=Kl("string",xl);return Wl(),e}return void(xl+=Wl());case"\n":case"\r":case void 0:throw tf(bl.Char,Wl());case"\u2028":case"\u2029":!function(e){Ol.warn(`JSON5: '${ef(e)}' in strings is not valid ECMAScript; consider escaping.`)}(Nl)}xl+=Wl()}};function Kl(e,t){return{type:e,value:t,line:Ml,column:Ll}}function ql(e){for(const t of e){if(Ul()!==t)throw tf(bl.Char,Wl());Wl()}}function Yl(){let e="",t=4;for(;t-- >0;){const t=Ul();if(!Al.JudgeUtil.isHexDigit(t))throw tf(bl.Char,Wl());e+=Wl()}return String.fromCodePoint(parseInt(e,16))}const Xl={start(){if("eof"===_l.type)throw tf(bl.EOF);Zl()},beforePropertyName(){switch(_l.type){case"identifier":case"string":return Pl=_l.value,void(Il="afterPropertyName");case"punctuator":return void Ql();case"eof":throw tf(bl.EOF)}},afterPropertyName(){if("eof"===_l.type)throw tf(bl.EOF);Il="beforePropertyValue"},beforePropertyValue(){if("eof"===_l.type)throw tf(bl.EOF);Zl()},afterPropertyValue(){if("eof"===_l.type)throw tf(bl.EOF);switch(_l.value){case",":return void(Il="beforePropertyName");case"}":Ql()}},beforeArrayValue(){if("eof"===_l.type)throw tf(bl.EOF);"punctuator"!==_l.type||"]"!==_l.value?Zl():Ql()},afterArrayValue(){if("eof"===_l.type)throw tf(bl.EOF);switch(_l.value){case",":return void(Il="beforeArrayValue");case"]":Ql()}},end(){}};function Zl(){const e=function(){let e;switch(_l.type){case"punctuator":switch(_l.value){case"{":e={};break;case"[":e=[]}break;case"null":case"boolean":case"numeric":case"string":e=_l.value}return e}();if(jl&&"object"==typeof e&&(e._line=Ml,e._column=Ll),void 0===kl)kl=e;else{const t=Tl[Tl.length-1];Array.isArray(t)?jl&&"object"!=typeof e?t.push({value:e,_line:Ml,_column:Ll}):t.push(e):t[Pl]=jl&&"object"!=typeof e?{value:e,_line:Ml,_column:Ll}:e}!function(e){if(e&&"object"==typeof e)Tl.push(e),Il=Array.isArray(e)?"beforeArrayValue":"beforePropertyName";else{const e=Tl[Tl.length-1];Il=e?Array.isArray(e)?"afterArrayValue":"afterPropertyValue":"end"}}(e)}function Ql(){Tl.pop();const e=Tl[Tl.length-1];Il=e?Array.isArray(e)?"afterArrayValue":"afterPropertyValue":"end"}function ef(e){const t={"'":"\\'",'"':'\\"',"\\":"\\\\","\b":"\\b","\f":"\\f","\n":"\\n","\r":"\\r","\t":"\\t","\v":"\\v","\0":"\\0","\u2028":"\\u2028","\u2029":"\\u2029"};if(t[e])return t[e];if(e<" "){const t=e.charCodeAt(0).toString(16);return`\\x${`00${t}`.substring(t.length)}`}return e}function tf(e,t){let n="";switch(e){case bl.Char:n=void 0===t?`JSON5: invalid end of input at ${Ml}:${Ll}`:`JSON5: invalid character '${ef(t)}' at ${Ml}:${Ll}`;break;case bl.EOF:n=`JSON5: invalid end of input at ${Ml}:${Ll}`;break;case bl.Identifier:Ll-=5,n=`JSON5: invalid identifier character at ${Ml}:${Ll}`}const r=new nf(n);return r.lineNumber=Ml,r.columnNumber=Ll,r}class nf extends SyntaxError{}var rf=w&&w.__createBinding||(Object.create?function(e,t,n,r){void 0===r&&(r=n);var u=Object.getOwnPropertyDescriptor(t,n);u&&!("get"in u?!t.__esModule:u.writable||u.configurable)||(u={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,r,u)}:function(e,t,n,r){void 0===r&&(r=n),e[r]=t[n]}),uf=w&&w.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),of=w&&w.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var n in e)"default"!==n&&Object.prototype.hasOwnProperty.call(e,n)&&rf(t,e,n);return uf(t,e),t};Object.defineProperty(Y,"__esModule",{value:!0});var sf=Y.cleanWorkSpace=Ff=Y.executeInstallHvigor=yf=Y.isHvigorInstalled=mf=Y.isAllDependenciesInstalled=void 0;const cf=of(D.default),af=of(p.default),lf=b,ff=j,df=$,Df=X;let pf,Ef;var mf=Y.isAllDependenciesInstalled=function(){function e(e){const t=null==e?void 0:e.dependencies;return void 0===t?0:Object.getOwnPropertyNames(t).length}if(pf=gf(),Ef=Af(),e(pf)+1!==e(Ef))return!1;for(const e in null==pf?void 0:pf.dependencies)if(!(0,ff.hasNpmPackInPaths)(e,[lf.HVIGOR_PROJECT_DEPENDENCIES_HOME])||!hf(e,pf,Ef))return!1;return!0};function hf(e,t,n){return void 0!==n.dependencies&&(0,ff.offlinePluginConversion)(lf.HVIGOR_PROJECT_ROOT_DIR,t.dependencies[e])===n.dependencies[e]}var yf=Y.isHvigorInstalled=function(){return pf=gf(),Ef=Af(),(0,ff.hasNpmPackInPaths)(lf.HVIGOR_ENGINE_PACKAGE_NAME,[lf.HVIGOR_PROJECT_DEPENDENCIES_HOME])&&(0,ff.offlinePluginConversion)(lf.HVIGOR_PROJECT_ROOT_DIR,pf.hvigorVersion)===Ef.dependencies[lf.HVIGOR_ENGINE_PACKAGE_NAME]};const Cf={cwd:lf.HVIGOR_PROJECT_DEPENDENCIES_HOME,stdio:["inherit","inherit","inherit"]};var Ff=Y.executeInstallHvigor=function(){(0,df.logInfoPrintConsole)("Hvigor installing...");const e={dependencies:{}};e.dependencies[lf.HVIGOR_ENGINE_PACKAGE_NAME]=(0,ff.offlinePluginConversion)(lf.HVIGOR_PROJECT_ROOT_DIR,pf.hvigorVersion);try{cf.mkdirSync(lf.HVIGOR_PROJECT_DEPENDENCIES_HOME,{recursive:!0});const t=af.resolve(lf.HVIGOR_PROJECT_DEPENDENCIES_HOME,lf.DEFAULT_PACKAGE_JSON);cf.writeFileSync(t,JSON.stringify(e))}catch(e){(0,df.logErrorAndExit)(e)}!function(){const e=["config","set","store-dir",lf.HVIGOR_PNPM_STORE_PATH];(0,ff.executeCommand)(lf.HVIGOR_WRAPPER_PNPM_SCRIPT_PATH,e,Cf)}(),(0,ff.executeCommand)(lf.HVIGOR_WRAPPER_PNPM_SCRIPT_PATH,["install"],Cf)};function gf(){const e=af.resolve(lf.HVIGOR_PROJECT_WRAPPER_HOME,lf.DEFAULT_HVIGOR_CONFIG_JSON_FILE_NAME);return cf.existsSync(e)||(0,df.logErrorAndExit)(`Error: Hvigor config file ${e} does not exist.`),(0,Df.parseJsonFile)(e)}function Af(){return cf.existsSync(lf.HVIGOR_PROJECT_DEPENDENCY_PACKAGE_JSON_PATH)?(0,Df.parseJsonFile)(lf.HVIGOR_PROJECT_DEPENDENCY_PACKAGE_JSON_PATH):{dependencies:{}}}sf=Y.cleanWorkSpace=function(){if((0,df.logInfoPrintConsole)("Hvigor cleaning..."),!cf.existsSync(lf.HVIGOR_PROJECT_DEPENDENCIES_HOME))return;const e=cf.readdirSync(lf.HVIGOR_PROJECT_DEPENDENCIES_HOME);if(e&&0!==e.length){cf.existsSync(lf.HVIGOR_BOOT_JS_FILE_PATH)&&(0,ff.executeCommand)(process.argv[0],[lf.HVIGOR_BOOT_JS_FILE_PATH,"--stop-daemon"],{});try{e.forEach((e=>{cf.rmSync(af.resolve(lf.HVIGOR_PROJECT_DEPENDENCIES_HOME,e),{recursive:!0})}))}catch(e){(0,df.logErrorAndExit)(`The hvigor build tool cannot be installed. Please manually clear the workspace directory and synchronize the project again.\n\n Workspace Path: ${lf.HVIGOR_PROJECT_DEPENDENCIES_HOME}.`)}}};var vf={},Sf=w&&w.__createBinding||(Object.create?function(e,t,n,r){void 0===r&&(r=n);var u=Object.getOwnPropertyDescriptor(t,n);u&&!("get"in u?!t.__esModule:u.writable||u.configurable)||(u={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,r,u)}:function(e,t,n,r){void 0===r&&(r=n),e[r]=t[n]}),wf=w&&w.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),Of=w&&w.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var n in e)"default"!==n&&Object.prototype.hasOwnProperty.call(e,n)&&Sf(t,e,n);return wf(t,e),t};Object.defineProperty(vf,"__esModule",{value:!0});var bf=vf.executeBuild=void 0;const _f=b,Bf=Of(D.default),Pf=Of(p.default),kf=$;bf=vf.executeBuild=function(){const e=Pf.resolve(_f.HVIGOR_PROJECT_DEPENDENCIES_HOME,"node_modules","@ohos","hvigor","bin","hvigor.js");try{const t=Bf.realpathSync(e);require(t)}catch(t){(0,kf.logErrorAndExit)(`Error: ENOENT: no such file ${e},delete ${_f.HVIGOR_PROJECT_DEPENDENCIES_HOME} and retry.`)}},function(){if(O.checkNpmConifg(),O.environmentHandler(),O.isPnpmAvailable()||O.executeInstallPnpm(),yf()&&mf())bf();else{sf();try{Ff()}catch(e){return void sf()}bf()}}(); \ No newline at end of file diff --git a/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/hvigorfile.ts b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/hvigorfile.ts new file mode 100644 index 0000000000000000000000000000000000000000..988feb9d12f64df2ee8460ffcaee81e8c2a010c7 --- /dev/null +++ b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/hvigorfile.ts @@ -0,0 +1,16 @@ +/** + * Copyright (c) 2023 Huawei Device 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. + */ +// Script for compiling build behavior. It is built in the build plug-in and cannot be modified currently. +export { appTasks } from '@ohos/hvigor-ohos-plugin'; \ No newline at end of file diff --git a/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/hvigorw b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/hvigorw new file mode 100644 index 0000000000000000000000000000000000000000..0576aadb4186f97941d687f221099bd29c2cdba0 --- /dev/null +++ b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/hvigorw @@ -0,0 +1,61 @@ +#!/bin/bash +# ---------------------------------------------------------------------------- +# Copyright (c) 2023 Huawei Device 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. +# ---------------------------------------------------------------------------- +# ---------------------------------------------------------------------------- +# Hvigor startup script, version 1.0.0 +# +# Required ENV vars: +# ------------------ +# NODE_HOME - location of a Node home dir +# or +# Add /usr/local/nodejs/bin to the PATH environment variable +# ---------------------------------------------------------------------------- + +HVIGOR_APP_HOME=$(dirname $(readlink -f $0)) +HVIGOR_WRAPPER_SCRIPT=${HVIGOR_APP_HOME}/hvigor/hvigor-wrapper.js +warn() { + echo "" + echo -e "\033[1;33m`date '+[%Y-%m-%d %H:%M:%S]'`$@\033[0m" +} + +error() { + echo "" + echo -e "\033[1;31m`date '+[%Y-%m-%d %H:%M:%S]'`$@\033[0m" +} + +fail() { + error "$@" + exit 1 +} + +# Determine node to start hvigor wrapper script +if [ -n "${NODE_HOME}" ];then + EXECUTABLE_NODE="${NODE_HOME}/bin/node" + if [ ! -x "$EXECUTABLE_NODE" ];then + fail "ERROR: NODE_HOME is set to an invalid directory,check $NODE_HOME\n\nPlease set NODE_HOME in your environment to the location where your nodejs installed" + fi +else + EXECUTABLE_NODE="node" + which ${EXECUTABLE_NODE} > /dev/null 2>&1 || fail "ERROR: NODE_HOME is not set and not 'node' command found in your path" +fi + +# Check hvigor wrapper script +if [ ! -r "$HVIGOR_WRAPPER_SCRIPT" ];then + fail "ERROR: Couldn't find hvigor/hvigor-wrapper.js in ${HVIGOR_APP_HOME}" +fi + +# start hvigor-wrapper script +exec "${EXECUTABLE_NODE}" \ + "${HVIGOR_WRAPPER_SCRIPT}" "$@" diff --git a/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/hvigorw.bat b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/hvigorw.bat new file mode 100644 index 0000000000000000000000000000000000000000..0a70d2833935ece44b6d53f1d5eeb4f264e2948e --- /dev/null +++ b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/hvigorw.bat @@ -0,0 +1,78 @@ +:: 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. + +@Echo off +@if "%DEBUG%" == "" @echo off +@rem ########################################################################## +@rem +@rem Hvigor startup script for Windows +@rem +@rem ########################################################################## + +@rem Set local scope for the variables with windows NT shell +if "%OS%"=="Windows_NT" setlocal + +set DIRNAME=%~dp0 +if "%DIRNAME%" == "" set DIRNAME=. +set APP_BASE_NAME=%~n0 +set APP_HOME=%DIRNAME% + +@rem Resolve any "." and ".." in APP_HOME to make it shorter. +for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi + +set WRAPPER_MODULE_PATH=%APP_HOME%\hvigor\hvigor-wrapper.js +set NODE_EXE=node.exe + +goto start + +:start +@rem Find node.exe +if defined NODE_HOME goto findNodeFromNodeHome + +%NODE_EXE% --version >NUL 2>&1 +if "%ERRORLEVEL%" == "0" goto execute + +echo. +echo ERROR: NODE_HOME is not set and no 'node' command could be found in your PATH. +echo. +echo Please set the NODE_HOME variable in your environment to match the +echo location of your NodeJs installation. + +goto fail + +:findNodeFromNodeHome +set NODE_HOME=%NODE_HOME:"=% +set NODE_EXE_PATH=%NODE_HOME%/%NODE_EXE% + +if exist "%NODE_EXE_PATH%" goto execute +echo. +echo ERROR: NODE_HOME is not set and no 'node' command could be found in your PATH. +echo. +echo Please set the NODE_HOME variable in your environment to match the +echo location of your NodeJs installation. + +goto fail + +:execute +@rem Execute hvigor +"%NODE_EXE%" %WRAPPER_MODULE_PATH% %* + +if "%ERRORLEVEL%" == "0" goto hvigorwEnd + +:fail +exit /b 1 + +:hvigorwEnd +if "%OS%" == "Windows_NT" endlocal + +:end diff --git a/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/lib/ProcessMessage-1.0.0.hap b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/lib/ProcessMessage-1.0.0.hap new file mode 100644 index 0000000000000000000000000000000000000000..80e4063583cb9523ecc2f7504757366fdbf9ebb2 Binary files /dev/null and b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/lib/ProcessMessage-1.0.0.hap differ diff --git a/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/lib/ProcessMessage-1.0.0.tgz b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/lib/ProcessMessage-1.0.0.tgz new file mode 100644 index 0000000000000000000000000000000000000000..23e8404fb8bd796cb2331cfae34ef38873c7fd99 Binary files /dev/null and b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/lib/ProcessMessage-1.0.0.tgz differ diff --git a/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/oh-package.json5 b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/oh-package.json5 new file mode 100644 index 0000000000000000000000000000000000000000..20e090ffed4f154a8aa9f2787b33ad18019e7735 --- /dev/null +++ b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/oh-package.json5 @@ -0,0 +1,26 @@ +/* + * Copyright (c) 2023 Huawei Device 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. + */ + +{ + "license": "ISC", + "devDependencies": { + "@ohos/hypium": "1.0.6" + }, + "name": "devicemanagementcollection", + "description": "example description", + "repository": {}, + "version": "1.0.0", + "dependencies": {} +} diff --git a/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/ohosTest.md b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/ohosTest.md new file mode 100644 index 0000000000000000000000000000000000000000..cd2a2b07dd18e38b5c750b7990348279b949ff73 --- /dev/null +++ b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/ohosTest.md @@ -0,0 +1,152 @@ +# 语言基础类库测试用例归档 + +## 用例表 + +|测试功能|预置条件|输入|预期输出|测试结果| +|--------------------------------|--------------------------------|--------------------------------|--------------------------------|--------------------------------| +|拉起应用 | 设备正常运行| 无 |成功拉起应用|Pass| +|查看应用菜单显示| 成功拉起应用| 无 |显示内容正常|Pass| +|Xml & ConvertXml(XML解析,生成与转换)| 成功拉起应用,位于首页 | 点击首页菜单中**Xml & ConvertXml(XML解析,生成与转换)** |进入Xml界面,内容显示正常|Pass| +|构建xml文本功能测试| 位于Xml页| 点击Xml 生成按钮| 构建xml文本,并在按钮上方的文本框显示xml文本内容|Pass| +|解析已经预置的xml文本功能测试| 位于Xml页| 点击Xml 解析按钮| 会解析已经预置的xml文本,并在文本框显示解析信息|Pass| +|将预置的xml文本转换为JavaScript对象功能测试| 位于Xml页| 点击Xml 转换按钮| 会将预置的xml文本转换为JavaScript对象,并在文本框显示|Pass| +|util工具函数| 成功拉起应用,位于首页 | 点击首页菜单中**Util工具函数** |进入Util界面,内容显示正常|Pass| +|字符串编解码| 位于Util页面 | 点击util页面中的**StringCode(字符串编解码)** |进入字符串编解码界面,内容显示正常|Pass| +|字符串编解码| 位于字符串编解码页面 | 点击特定格式输出 |输出不同格式的结果|Pass| +|字符串编解码| 位于字符串编解码页面 | 点击文本编码器 |输出编码后的文本,返回读取与写入信息|Pass| +|字符串编解码| 位于字符串编解码页面 | 点击文本译码器 |输出译码后的文本|Pass| +|有理数| 位于Util页面 | 点击util页面中的**有理数** |进入有理数界面,内容显示正常|Pass| +|有理数| 位于有理数页面 | 点击有理数界面的功能按钮 |界面中的显示框中显示获取的结果值|Pass| +|LRUCache (缓冲区)| 位于Util页面 | 点击util页面中的**缓冲区** |进入缓冲区界面,内容显示正常|Pass| +|验证点击初始化缓冲区是否正常显示缓冲区内容| 位于缓冲区页面| 点击初始化缓冲区| 正常显示缓冲区内容|Pass| +|验证点击获取缓冲区容量是否正常显示缓冲区内容| 位于缓冲区页面| 点击获取缓冲区容量| 正常显示获取缓冲区容量|Pass| +|验证点击更新缓冲区容量是否正常显示缓冲区内容| 位于缓冲区页面| 点击更新缓冲区容量| 正常显示更新缓冲区容量|Pass| +|验证点击获取缓冲区字符串是否正常显示缓冲区内容| 位于缓冲区页面| 点击获取缓冲区字符串| 正常获取缓冲区字符串|Pass| +|验证点击添加键值对是否正常显示缓冲区内容| 位于缓冲区页面| 点击添加键值对| 正常添加键值对|Pass| +|验证点击获取键对应的值是否正常显示缓冲区内容| 位于缓冲区页面| 点击获取键对应的值| 正常获取键对应的值|Pass| +|验证点击获取所有键值对是否正常显示缓冲区内容| 位于缓冲区页面| 点击获取所有键值对| 正常获取所有键值对|Pass| +|验证点击删除指定键及关联值是否正常显示缓冲区内容| 位于缓冲区页面| 点击删除指定键及关联值| 正常删除指定键及关联值|Pass| +|验证点击清除所有键值对是否正常显示缓冲区内容| 位于缓冲区页面| 点击清除所有键值对| 正常清除所有键值对|Pass| +|验证点击查看操作记录是否正常显示缓冲区内容| 位于缓冲区页面| 点击查看操作记录| 正常查看操作记录|Pass| +|Base64Helper (Base64编解码)| 位于Util页面 | 点击util页面中的**Base64编解码** |进入Base64编解码界面,内容显示正常|Pass| +|验证编码功能| 位于Base64编解码页面| 点击编码| 正常显示编码后的内容|Pass| +|验证解码功能| 位于Base64编解码页面| 点击解码| 正常显示解码后的内容|Pass| +|TypeCheck (类型检查)| 位于Util页面 | 点击util页面中的**类型检查** |进入类型检查界面,内容显示正常|Pass| +|显示预置值功能测试| 位于类型检查页| 点击显示预置值按钮| 显示预置值|Pass| +|校验预置值功能测试| 类型检查页| 点击校验预置值按钮| 对预置值进行校验,并输出校验结果|Pass| +|Url字符串解析| 成功拉起应用,位于首页 | 点击首页菜单中**Url字符串解析** |进入Url字符串解析界面,内容显示正常|Pass| +|验证点击插入键值对到查询字符串,查询字符串是否成功插入键值对| 位于URL字符串解析页面| 点击插入键值对到查询字符串| 插入键值对到查询字符串|Pass| +|验证点击删除键值对,查询字符串是否成功删除键值对| 位于URL字符串解析页面| 点击删除键值对| 查询字符串成功删除键值对|Pass| +|验证点击获取指定名称对应的第一个值,查询字符串是否成功获取指定名称对应的第一个值| 位于URL字符串解析页面| 点击获取指定名称对应的第一个值| 查询字符串成功获取指定名称对应的第一个值|Pass| +|验证点击设置键的新值,查询字符串是否成功设置键的新值| 位于URL字符串解析页面| 点击设置键的新值| 查询字符串成功设置键的新值|Pass| +|TaskPool启动任务池| 成功拉起应用,位于首页 | 点击首页菜单中**TaskPool(启动任务池)** | 进入TaskPool启动任务池界面,内容显示正常 |Pass| +|验证点击Execute task| 位于TaskPool启动任务池页面 | 点击Execute task按钮 | 正常启动Task,开始计数 |Pass| +|验证点击Cancel task| 位于TaskPool启动任务池页面 | 点击Cancel task按钮 | 正常取消Task,停止计数 |Pass| +|Deque线性容器| 成功拉起应用,位于首页 | 点击首页菜单中**Deque线性容器** | 进入Deque线性容器界面,内容显示正常 |Pass| +| 验证点击加号,是否正常跳转到新增联系人页面 | 位于Deque线性容器页面 | 点击加号按钮 | 进入新增联系人页面 |Pass| +|验证点击请输入姓名输入框,是否弹出输入法并能进行数据输入| 位于新增联系人页面 | 点击请输入姓名输入框 | 弹出输入法,可进行数据输入 |Pass| +|验证点击请选择文本框,是否弹出文本选择框| 位于新增联系人页面 | 点击请选择文本框 | 弹出文本选择框 |Pass| +|验证点击文本选择框的取消按钮,是否正常关闭文本选择框| 位于新增联系人页面 | 点击取消按钮 | 关闭文本选择框 |Pass| +|验证点击文本选择框的确定按钮,是否正常关闭文本选择框并把当前选择的文本填充到请选择文本框中| 位于新增联系人页面 | 点击取消按钮 | 关闭文本选择框并把当前选择的文本填充到请选择文本框中 |Pass| +|验证点击请输入电话输入框,是否弹出输入法并能进行数据输入| 位于新增联系人页面 | 点击请输入姓名输入框 | 弹出输入法,可进行数据输入 |Pass| +|验证点击对勾按钮,是否关闭当前页面返回到上一页,新增一条新的联系人数据并刷新Deque线性容器页面列表| 位于新增联系人页面 | 点击对勾按钮 | 关闭当前页面返回到上一页,新增一条新的联系人数据并刷新Deque线性容器页面列表 | Pass | +|新增三条联系人数据后,验证第二条数据删除按钮是否不可点击| 位于Deque线性容器页面 | 点击删除按钮 | 删除按钮不可点击(点击后无任何操作被执行) | Pass | +|新增三条联系人数据后,验证点击第一条数据删除按钮,是否正常删除列表数据并刷新列表| 位于Deque线性容器页面 | 点击删除按钮 | 可删除第一条数据并刷新列表 | Pass | +|新增三条联系人数据后,验证点击第三条数据删除按钮,是否正常删除列表数据并刷新列表| 位于Deque线性容器页面 | 点击删除按钮 | 可删除第三条数据并刷新列表 | Pass | +|HashMap非线性容器| 成功拉起应用,位于首页 | 点击首页菜单中**HashMap非线性容器** | 进入HashMap非线性容器界面,内容显示正常 | Pass | +|验证点击加号,是否正常跳转到新增HashMap页面| 位于HashMap非线性容器页面 | 点击加号按钮 | 进入新增HashMap页面 | Pass | +|验证点击请输入Key输入框,是否弹出输入法并能进行数据输入| 位于新增HasMap页面 | 点击请输入Key输入框 | 弹出输入法,可进行数据输入 | Pass | +|验证点击请输入Value输入框,是否弹出输入法并能进行数据输入| 位于新增HasMap页面 | 点击请输入Value输入框 | 弹出输入法,可进行数据输入 | Pass | +|验证点击对勾按钮,是否关闭当前页面返回到上一页,新增一条新的HashMap数据并刷新HashMap非线性容器页面列表| 位于新增HasMap页面 | 点击对勾按钮 | 关闭当前页面返回到上一页,新增一条新的HashMap数据并刷新HashMap非线性容器页面列表 | Pass | +|新增三条Key/Value数据后,验证点击第一条数据删除按钮,是否正常删除列表数据并刷新列表| 位于HashMap非线性容器页面 | 点击删除按钮 | 可删除第一条数据并刷新列表 | Pass | +|新增三条Key/Value数据后,验证点击第二条数据删除按钮,是否正常删除列表数据并刷新列表| 位于HashMap非线性容器页面 | 点击删除按钮 | 可删除第二条数据并刷新列表 | Pass | +|新增三条Key/Value数据后,验证点击第三条数据删除按钮,是否正常删除列表数据并刷新列表| 位于HashMap非线性容器页面 | 点击删除按钮 | 可删除第三条数据并刷新列表 | Pass | +|HashSet非线性容器| 成功拉起应用,位于首页 | 点击首页菜单中**HashSet非线性容器** | 进入HashSet非线性容器界面,内容显示正常 | Pass | +|验证点击加号,是否正常跳转到新增HashSet页面| 位于HashSet非线性容器页面 | 点击加号按钮 | 进入新增HashSet页面 | Pass | +|验证点击请输入Value输入框,是否弹出输入法并能进行数据输入| 位于新增HasSet页面 | 点击请输入Value输入框 | 弹出输入法,可进行数据输入 | Pass | +|验证点击对勾按钮,是否关闭当前页面返回到上一页,新增一条新的HashSet数据并刷新HashSet非线性容器页面列表| 位于新增HasSet页面 | 点击对勾按钮 | 关闭当前页面返回到上一页,新增一条新的HashSet数据并刷新HashSet非线性容器页面列表 | Pass | +|新增三条Value数据后,验证点击第一条数据删除按钮,是否正常删除列表数据并刷新列表| 位于HashSet非线性容器页面 | 点击删除按钮 | 可删除第一条数据并刷新列表 | Pass | +|新增三条Value数据后,验证点击第二条数据删除按钮,是否正常删除列表数据并刷新列表| 位于HashSet非线性容器页面 | 点击删除按钮 | 可删除第二条数据并刷新列表 | Pass | +|新增三条Value数据后,验证点击第三条数据删除按钮,是否正常删除列表数据并刷新列表| 位于HashSet非线性容器页面 | 点击删除按钮 | 可删除第三条数据并刷新列表 | Pass | +|LightWeightMap非线性容器| 成功拉起应用,位于首页 | 点击首页菜单中**LightWeightMap非线性容器** | 进入LightWeightMap非线性容器界面,内容显示正常 | Pass | +|验证点击加号,是否正常跳转到新增LightWeightMap页面| 位于LightWeightMap非线性容器页面 | 点击加号按钮 | 进入新增LightWeightMap页面 | Pass | +|验证点击请输入Key输入框,是否弹出输入法并能进行数据输入| 位于新增LightWeightMap页面 | 点击请输入Key输入框 | 弹出输入法,可进行数据输入 | Pass | +| 验证点击请输入Value输入框,是否弹出输入法并能进行数据输入 | 位于新增LightWeightMap页面 | 点击请输入Value输入框 | 弹出输入法,可进行数据输入 | Pass | +|验证点击对勾按钮,是否关闭当前页面返回到上一页,新增一条新的LightWeightMap数据并刷新LightWeightMap非线性容器页面列表| 位于新增LightWeightMap页面 | 点击对勾按钮 | 关闭当前页面返回到上一页,新增一条新的LightWeightMap数据并刷新LightWeightMap非线性容器页面列表 |Pass| +|新增三条Key/Value数据后,验证点击第一条数据删除按钮,是否正常删除列表数据并刷新列表| 位于LightWeightMap非线性容器页面 | 点击删除按钮 | 可删除第一条数据并刷新列表 | Pass | +|新增三条Key/Value数据后,验证点击第二条数据删除按钮,是否正常删除列表数据并刷新列表| 位于LightWeightMap非线性容器页面 | 点击删除按钮 | 可删除第二条数据并刷新列表 | Pass | +|新增三条Key/Value数据后,验证点击第三条数据删除按钮,是否正常删除列表数据并刷新列表| 位于LightWeightMap非线性容器页面 | 点击删除按钮 | 可删除第三条数据并刷新列表 | Pass | +|LightWeightSet非线性容器| 成功拉起应用,位于首页 | 点击首页菜单中**LightWeightSet非线性容器** | 进入LightWeightSet非线性容器界面,内容显示正常 |Pass| +|验证点击加号,是否正常跳转到新增LightWeightSet页面| 位于LightWeightSet非线性容器页面 | 点击加号按钮 | 进入新增LightWeightSet页面 |Pass| +|验证点击请输入Value输入框,是否弹出输入法并能进行数据输入| 位于新增LightWeightSet页面 | 点击请输入Value输入框 | 弹出输入法,可进行数据输入 |Pass| +|验证点击对勾按钮,是否关闭当前页面返回到上一页,新增一条新的LightWeightSet数据并刷新LightWeightSet非线性容器页面列表| 位于新增LightWeightSet页面 | 点击对勾按钮 | 关闭当前页面返回到上一页,新增一条新的LightWeightSet数据并刷新LightWeightSet非线性容器页面列表 |Pass| +|新增三条Value数据后,验证点击第一条数据删除按钮,是否正常删除列表数据并刷新列表| 位于LightWeightSet非线性容器页面 | 点击删除按钮 | 可删除第一条数据并刷新列表 | Pass | +|新增三条Value数据后,验证点击第二条数据删除按钮,是否正常删除列表数据并刷新列表| 位于LightWeightSet非线性容器页面 | 点击删除按钮 | 可删除第二条数据并刷新列表 | Pass | +|新增三条Value数据后,验证点击第三条数据删除按钮,是否正常删除列表数据并刷新列表| 位于LightWeightSet非线性容器页面 | 点击删除按钮 | 可删除第三条数据并刷新列表 | Pass | +|LinkedList线性容器| 成功拉起应用,位于首页 | 点击首页菜单中**LinkedList线性容器** | 进入LinkedList线性容器界面,内容显示正常 |Pass| +| 验证点击加号,是否正常跳转到新增联系人页面 | 位于LinkedList线性容器页面 | 点击加号按钮 | 进入新增联系人页面 |Pass| +|验证点击请输入姓名输入框,是否弹出输入法并能进行数据输入| 位于新增联系人页面 | 点击请输入姓名输入框 | 弹出输入法,可进行数据输入 |Pass| +|验证点击请选择文本框,是否弹出文本选择框| 位于新增联系人页面 | 点击请选择文本框 | 弹出文本选择框 |Pass| +|验证点击文本选择框的取消按钮,是否正常关闭文本选择框| 位于新增联系人页面 | 点击取消按钮 | 关闭文本选择框 |Pass| +|验证点击文本选择框的确定按钮,是否正常关闭文本选择框并把当前选择的文本填充到请选择文本框中| 位于新增联系人页面 | 点击取消按钮 | 关闭文本选择框并把当前选择的文本填充到请选择文本框中 |Pass| +|验证点击请输入电话输入框,是否弹出输入法并能进行数据输入| 位于新增联系人页面 | 点击请输入姓名输入框 | 弹出输入法,可进行数据输入 |Pass| +|验证点击对勾按钮,是否关闭当前页面返回到上一页,新增一条新的联系人数据并刷新LinkedList线性容器页面列表| 位于新增联系人页面 | 点击对勾按钮 | 关闭当前页面返回到上一页,新增一条新的联系人数据并刷新LinkedList线性容器页面列表 | Pass | +|新增三条联系人数据后,验证点击第一条数据删除按钮,是否正常删除列表数据并刷新列表| 位于LinkedList线性容器页面 | 点击删除按钮 | 可删除第一条数据并刷新列表 | Pass | +|新增三条联系人数据后,验证点击第二条数据删除按钮,是否正常删除列表数据并刷新列表| 位于LinkedList线性容器页面 | 点击删除按钮 | 可删除第二条数据并刷新列表 | Pass | +|新增三条联系人数据后,验证点击第三条数据删除按钮,是否正常删除列表数据并刷新列表| 位于LinkedList线性容器页面 | 点击删除按钮 | 可删除第三条数据并刷新列表 | Pass | +|PlainArray非线性容器| 成功拉起应用,位于首页 | 点击首页菜单中**PlainArray非线性容器** | 进入PlainArray非线性容器界面,内容显示正常 | Pass | +|验证点击加号,是否正常跳转到新增PlainArray页面| 位于PlainArray非线性容器页面 | 点击加号按钮 | 进入新增PlainArray页面 | Pass | +|验证点击请输入Key输入框,是否弹出输入法并能进行数据输入| 位于新增PlainArray页面 | 点击请输入Key输入框 | 弹出输入法,可进行数据输入 | Pass | +| 验证点击请输入Value输入框,是否弹出输入法并能进行数据输入 | 位于新增PlainArray页面 | 点击请输入Value输入框 | 弹出输入法,可进行数据输入 | Pass | +|验证点击对勾按钮,是否关闭当前页面返回到上一页,新增一条新的PlainArray数据并刷新PlainArray非线性容器页面列表| 位于新增PlainArray页面 | 点击对勾按钮 | 关闭当前页面返回到上一页,新增一条新的PlainArray数据并刷新PlainArray非线性容器页面列表 |Pass| +|新增三条Key/Value数据后,验证点击第一条数据删除按钮,是否正常删除列表数据并刷新列表| 位于PlainArray非线性容器页面 | 点击删除按钮 | 可删除第一条数据并刷新列表 | Pass | +|新增三条Key/Value数据后,验证点击第二条数据删除按钮,是否正常删除列表数据并刷新列表| 位于PlainArray非线性容器页面 | 点击删除按钮 | 可删除第二条数据并刷新列表 | Pass | +|新增三条Key/Value数据后,验证点击第三条数据删除按钮,是否正常删除列表数据并刷新列表| 位于PlainArray非线性容器页面 | 点击删除按钮 | 可删除第三条数据并刷新列表 | Pass | +|Queue线性容器| 成功拉起应用,位于首页 | 点击首页菜单中**Queue线性容器** | 进入Queue线性容器界面,内容显示正常 |Pass| +| 验证点击加号,是否正常跳转到新增联系人页面 | 位于Queue线性容器页面 | 点击加号按钮 | 进入新增联系人页面 |Pass| +|验证点击请输入姓名输入框,是否弹出输入法并能进行数据输入| 位于新增联系人页面 | 点击请输入姓名输入框 | 弹出输入法,可进行数据输入 |Pass| +|验证点击请选择文本框,是否弹出文本选择框| 位于新增联系人页面 | 点击请选择文本框 | 弹出文本选择框 |Pass| +|验证点击文本选择框的取消按钮,是否正常关闭文本选择框| 位于新增联系人页面 | 点击取消按钮 | 关闭文本选择框 |Pass| +|验证点击文本选择框的确定按钮,是否正常关闭文本选择框并把当前选择的文本填充到请选择文本框中| 位于新增联系人页面 | 点击取消按钮 | 关闭文本选择框并把当前选择的文本填充到请选择文本框中 |Pass| +|验证点击请输入电话输入框,是否弹出输入法并能进行数据输入| 位于新增联系人页面 | 点击请输入姓名输入框 | 弹出输入法,可进行数据输入 |Pass| +|验证点击对勾按钮,是否关闭当前页面返回到上一页,新增一条新的联系人数据并刷新Queue线性容器页面列表| 位于新增联系人页面 | 点击对勾按钮 | 关闭当前页面返回到上一页,新增一条新的联系人数据并刷新Queue线性容器页面列表 | Pass | +|新增三条联系人数据后,验证点击第一条数据删除按钮,是否正常删除列表数据并刷新列表| 位于Queue线性容器页面 | 点击删除按钮 | 可删除第一条数据并刷新列表 | Pass | +|新增三条联系人数据后,验证第二条数据删除按钮是否不可点击| 位于Queue线性容器页面 | 点击删除按钮 | 删除按钮不可点击(点击后无任何操作被执行) | Pass | +|新增三条联系人数据后,验证第三条数据删除按钮是否不可点击| 位于Queue线性容器页面 | 点击删除按钮 | 删除按钮不可点击(点击后无任何操作被执行) | Pass | +|Stack线性容器| 成功拉起应用,位于首页 | 点击首页菜单中**Stack线性容器** | 进入Stack线性容器界面,内容显示正常 |Pass| +| 验证点击加号,是否正常跳转到新增联系人页面 | 位于Queue线性容器页面 | 点击加号按钮 | 进入新增联系人页面 |Pass| +|验证点击请输入姓名输入框,是否弹出输入法并能进行数据输入| 位于新增联系人页面 | 点击请输入姓名输入框 | 弹出输入法,可进行数据输入 |Pass| +|验证点击请选择文本框,是否弹出文本选择框| 位于新增联系人页面 | 点击请选择文本框 | 弹出文本选择框 |Pass| +|验证点击文本选择框的取消按钮,是否正常关闭文本选择框| 位于新增联系人页面 | 点击取消按钮 | 关闭文本选择框 |Pass| +|验证点击文本选择框的确定按钮,是否正常关闭文本选择框并把当前选择的文本填充到请选择文本框中| 位于新增联系人页面 | 点击取消按钮 | 关闭文本选择框并把当前选择的文本填充到请选择文本框中 |Pass| +|验证点击请输入电话输入框,是否弹出输入法并能进行数据输入| 位于新增联系人页面 | 点击请输入姓名输入框 | 弹出输入法,可进行数据输入 |Pass| +|验证点击对勾按钮,是否关闭当前页面返回到上一页,新增一条新的联系人数据并刷新Stack线性容器页面列表| 位于新增联系人页面 | 点击对勾按钮 | 关闭当前页面返回到上一页,新增一条新的联系人数据并刷新Stack线性容器页面列表 | Pass | +|新增三条联系人数据后,验证第一条数据删除按钮是否不可点击| 位于Stack线性容器页面 | 点击删除按钮 | 删除按钮不可点击(点击后无任何操作被执行) | Pass | +|新增三条联系人数据后,验证第二条数据删除按钮是否不可点击| 位于Stack线性容器页面 | 点击删除按钮 | 删除按钮不可点击(点击后无任何操作被执行) | Pass | +|新增三条联系人数据后,验证点击第三条数据删除按钮,是否正常删除列表数据并刷新列表| 位于Stack线性容器页面 | 点击删除按钮 | 可删除第三条数据并刷新列表 | Pass | +|TreeMap非线性容器| 成功拉起应用,位于首页 | 点击首页菜单中**TreeMap非线性容器** | 进入TreeMap非线性容器界面,内容显示正常 | Pass | +|验证点击加号,是否正常跳转到新增TreeMap页面| 位于TreeMap非线性容器页面 | 点击加号按钮 | 进入新增TreeMap页面 | Pass | +|验证点击请输入Key输入框,是否弹出输入法并能进行数据输入| 位于新增TreeMap页面 | 点击请输入Key输入框 | 弹出输入法,可进行数据输入 | Pass | +|验证点击请输入Value输入框,是否弹出输入法并能进行数据输入| 位于新增TreeMap页面 | 点击请输入Value输入框 | 弹出输入法,可进行数据输入 | Pass | +|验证点击对勾按钮,是否关闭当前页面返回到上一页,新增一条新的TreeMap数据并刷新TreeMap非线性容器页面列表| 位于新增TreeMap页面 | 点击对勾按钮 | 关闭当前页面返回到上一页,新增一条新的TreeMap数据并刷新TreeMap非线性容器页面列表 | Pass | +|新增三条Key/Value数据后,验证点击第一条数据删除按钮,是否正常删除列表数据并刷新列表| 位于TreeMap非线性容器页面 | 点击删除按钮 | 可删除第一条数据并刷新列表 | Pass | +|新增三条Key/Value数据后,验证点击第二条数据删除按钮,是否正常删除列表数据并刷新列表| 位于TreeMap非线性容器页面 | 点击删除按钮 | 可删除第二条数据并刷新列表 | Pass | +|新增三条Key/Value数据后,验证点击第三条数据删除按钮,是否正常删除列表数据并刷新列表| 位于TreeMap非线性容器页面 | 点击删除按钮 | 可删除第三条数据并刷新列表 | Pass | +|TreeSet非线性容器| 成功拉起应用,位于首页 | 点击首页菜单中**TreeSet非线性容器** | 进入TreeSet非线性容器界面,内容显示正常 | Pass | +|验证点击加号,是否正常跳转到新增HashSet页面| 位于TreeSet非线性容器页面 | 点击加号按钮 | 进入新增TreeSet页面 | Pass | +|验证点击请输入Value输入框,是否弹出输入法并能进行数据输入| 位于新增TreeSet页面 | 点击请输入Value输入框 | 弹出输入法,可进行数据输入 | Pass | +|验证点击对勾按钮,是否关闭当前页面返回到上一页,新增一条新的TreeSet数据并刷新TreeSet非线性容器页面列表| 位于新增TreeSet页面 | 点击对勾按钮 | 关闭当前页面返回到上一页,新增一条新的TreeSet数据并刷新TreeSet非线性容器页面列表 | Pass | +|新增三条Value数据后,验证点击第一条数据删除按钮,是否正常删除列表数据并刷新列表| 位于TreeSet非线性容器页面 | 点击删除按钮 | 可删除第一条数据并刷新列表 | Pass | +|新增三条Value数据后,验证点击第二条数据删除按钮,是否正常删除列表数据并刷新列表| 位于TreeSet非线性容器页面 | 点击删除按钮 | 可删除第二条数据并刷新列表 | Pass | +|新增三条Value数据后,验证点击第三条数据删除按钮,是否正常删除列表数据并刷新列表| 位于TreeSet非线性容器页面 | 点击删除按钮 | 可删除第三条数据并刷新列表 | Pass | +|Vector线性容器| 成功拉起应用,位于首页 | 点击首页菜单中**Vector线性容器** | 进入Vector线性容器界面,内容显示正常 |Pass| +| 验证点击加号,是否正常跳转到新增联系人页面 | 位于Queue线性容器页面 | 点击加号按钮 | 进入新增联系人页面 |Pass| +|验证点击请输入姓名输入框,是否弹出输入法并能进行数据输入| 位于新增联系人页面 | 点击请输入姓名输入框 | 弹出输入法,可进行数据输入 |Pass| +|验证点击请选择文本框,是否弹出文本选择框| 位于新增联系人页面 | 点击请选择文本框 | 弹出文本选择框 |Pass| +|验证点击文本选择框的取消按钮,是否正常关闭文本选择框| 位于新增联系人页面 | 点击取消按钮 | 关闭文本选择框 |Pass| +|验证点击文本选择框的确定按钮,是否正常关闭文本选择框并把当前选择的文本填充到请选择文本框中| 位于新增联系人页面 | 点击取消按钮 | 关闭文本选择框并把当前选择的文本填充到请选择文本框中 |Pass| +|验证点击请输入电话输入框,是否弹出输入法并能进行数据输入| 位于新增联系人页面 | 点击请输入姓名输入框 | 弹出输入法,可进行数据输入 |Pass| +|验证点击对勾按钮,是否关闭当前页面返回到上一页,新增一条新的联系人数据并刷新Vector线性容器页面列表| 位于新增联系人页面 | 点击对勾按钮 | 关闭当前页面返回到上一页,新增一条新的联系人数据并刷新Vector线性容器页面列表 | Pass | +|新增三条联系人数据后,验证点击第一条数据删除按钮,是否正常删除列表数据并刷新列表| 位于Vector线性容器页面 | 点击删除按钮 | 可删除第一条数据并刷新列表 | Pass | +|新增三条联系人数据后,验证点击第二条数据删除按钮,是否正常删除列表数据并刷新列表| 位于Vector线性容器页面 | 点击删除按钮 | 可删除第二条数据并刷新列表 | Pass | +|新增三条联系人数据后,验证点击第三条数据删除按钮,是否正常删除列表数据并刷新列表| 位于Vector线性容器页面 | 点击删除按钮 | 可删除第三条数据并刷新列表 | Pass | \ No newline at end of file diff --git a/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/screenshots/devices/arraylist.jpg b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/screenshots/devices/arraylist.jpg new file mode 100644 index 0000000000000000000000000000000000000000..f0f3b5b0f2db36293c10ad4cbfa844be4fcbec38 Binary files /dev/null and b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/screenshots/devices/arraylist.jpg differ diff --git a/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/screenshots/devices/base64.jpg b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/screenshots/devices/base64.jpg new file mode 100644 index 0000000000000000000000000000000000000000..2e190932b4d128088a2cf7d0384738f1f68c63aa Binary files /dev/null and b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/screenshots/devices/base64.jpg differ diff --git a/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/screenshots/devices/convertxml.jpg b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/screenshots/devices/convertxml.jpg new file mode 100644 index 0000000000000000000000000000000000000000..03fde7086e4305167235a197f62c06744532402c Binary files /dev/null and b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/screenshots/devices/convertxml.jpg differ diff --git a/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/screenshots/devices/home.jpg b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/screenshots/devices/home.jpg new file mode 100644 index 0000000000000000000000000000000000000000..d62a1135c8f616ef6ca987fcb5dc88ceea88dbfe Binary files /dev/null and b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/screenshots/devices/home.jpg differ diff --git a/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/screenshots/devices/lrucache.jpg b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/screenshots/devices/lrucache.jpg new file mode 100644 index 0000000000000000000000000000000000000000..2967a10efcde614c92f2c2debe2d6e7b18448d80 Binary files /dev/null and b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/screenshots/devices/lrucache.jpg differ diff --git a/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/screenshots/devices/process.jpg b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/screenshots/devices/process.jpg new file mode 100644 index 0000000000000000000000000000000000000000..7ef4cc75eaa16f00efbd33a0971d84e121fa7cf3 Binary files /dev/null and b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/screenshots/devices/process.jpg differ diff --git a/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/screenshots/devices/rationalnumber.jpg b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/screenshots/devices/rationalnumber.jpg new file mode 100644 index 0000000000000000000000000000000000000000..a563d96f0bb302645db5ee1c604d4c51f31c9407 Binary files /dev/null and b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/screenshots/devices/rationalnumber.jpg differ diff --git a/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/screenshots/devices/scopehelper.jpg b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/screenshots/devices/scopehelper.jpg new file mode 100644 index 0000000000000000000000000000000000000000..64748977d4bfa0231ad88e8a6727a10c0ddd6451 Binary files /dev/null and b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/screenshots/devices/scopehelper.jpg differ diff --git a/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/screenshots/devices/stringcode.jpg b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/screenshots/devices/stringcode.jpg new file mode 100644 index 0000000000000000000000000000000000000000..ec9626facda4e7291712c47cab3bb27c114f2ab8 Binary files /dev/null and b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/screenshots/devices/stringcode.jpg differ diff --git a/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/screenshots/devices/typecheck.jpg b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/screenshots/devices/typecheck.jpg new file mode 100644 index 0000000000000000000000000000000000000000..12f6fa162249e6a1ef485159bf1f84680769121b Binary files /dev/null and b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/screenshots/devices/typecheck.jpg differ diff --git a/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/screenshots/devices/url.jpg b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/screenshots/devices/url.jpg new file mode 100644 index 0000000000000000000000000000000000000000..1de5634dc2bb2f3dbf776b3935b0a7677189b53f Binary files /dev/null and b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/screenshots/devices/url.jpg differ diff --git a/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/screenshots/devices/util.jpg b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/screenshots/devices/util.jpg new file mode 100644 index 0000000000000000000000000000000000000000..08b664cf32d40909537df8be16347649c5a1cefe Binary files /dev/null and b/sample/EnhanceSampleArk1.2/LanguageBaseClassLibrary/screenshots/devices/util.jpg differ diff --git a/sample/EnhanceSampleArk1.2/PageLoading/.gitignore b/sample/EnhanceSampleArk1.2/PageLoading/.gitignore new file mode 100644 index 0000000000000000000000000000000000000000..d2ff20141ceed86d87c0ea5d99481973005bab2b --- /dev/null +++ b/sample/EnhanceSampleArk1.2/PageLoading/.gitignore @@ -0,0 +1,12 @@ +/node_modules +/oh_modules +/local.properties +/.idea +**/build +/.hvigor +.cxx +/.clangd +/.clang-format +/.clang-tidy +**/.test +/.appanalyzer \ No newline at end of file diff --git a/sample/EnhanceSampleArk1.2/PageLoading/AppScope/app.json5 b/sample/EnhanceSampleArk1.2/PageLoading/AppScope/app.json5 new file mode 100644 index 0000000000000000000000000000000000000000..9711c4662a885db3c7c7fd5b4a3364476a738270 --- /dev/null +++ b/sample/EnhanceSampleArk1.2/PageLoading/AppScope/app.json5 @@ -0,0 +1,25 @@ +/* + * Copyright (c) 2025 Huawei Device 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. + */ + +{ + "app": { + "bundleName": "com.samples.pageloading", + "vendor": "samples", + "versionCode": 1000000, + "versionName": "1.0.0", + "icon": "$media:app_icon", + "label": "$string:app_name" + } +} diff --git a/sample/EnhanceSampleArk1.2/PageLoading/AppScope/resources/base/element/string.json b/sample/EnhanceSampleArk1.2/PageLoading/AppScope/resources/base/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..179f90c33a8387324e3ca320d7e8e9fb643c9f3b --- /dev/null +++ b/sample/EnhanceSampleArk1.2/PageLoading/AppScope/resources/base/element/string.json @@ -0,0 +1,8 @@ +{ + "string": [ + { + "name": "app_name", + "value": "PageLoading" + } + ] +} diff --git a/sample/EnhanceSampleArk1.2/PageLoading/AppScope/resources/base/media/app_icon.png b/sample/EnhanceSampleArk1.2/PageLoading/AppScope/resources/base/media/app_icon.png new file mode 100644 index 0000000000000000000000000000000000000000..a39445dc87828b76fed6d2ec470dd455c45319e3 Binary files /dev/null and b/sample/EnhanceSampleArk1.2/PageLoading/AppScope/resources/base/media/app_icon.png differ diff --git a/sample/EnhanceSampleArk1.2/PageLoading/AppScope/resources/base/media/background.png b/sample/EnhanceSampleArk1.2/PageLoading/AppScope/resources/base/media/background.png new file mode 100644 index 0000000000000000000000000000000000000000..923f2b3f27e915d6871871deea0420eb45ce102f Binary files /dev/null and b/sample/EnhanceSampleArk1.2/PageLoading/AppScope/resources/base/media/background.png differ diff --git a/sample/EnhanceSampleArk1.2/PageLoading/AppScope/resources/base/media/foreground.png b/sample/EnhanceSampleArk1.2/PageLoading/AppScope/resources/base/media/foreground.png new file mode 100644 index 0000000000000000000000000000000000000000..eb9427585b36d14b12477435b6419d1f07b3e0bb Binary files /dev/null and b/sample/EnhanceSampleArk1.2/PageLoading/AppScope/resources/base/media/foreground.png differ diff --git a/sample/EnhanceSampleArk1.2/PageLoading/AppScope/resources/base/media/layered_image.json b/sample/EnhanceSampleArk1.2/PageLoading/AppScope/resources/base/media/layered_image.json new file mode 100644 index 0000000000000000000000000000000000000000..fb49920440fb4d246c82f9ada275e26123a2136a --- /dev/null +++ b/sample/EnhanceSampleArk1.2/PageLoading/AppScope/resources/base/media/layered_image.json @@ -0,0 +1,7 @@ +{ + "layered-image": + { + "background" : "$media:background", + "foreground" : "$media:foreground" + } +} \ No newline at end of file diff --git a/sample/EnhanceSampleArk1.2/PageLoading/README.md b/sample/EnhanceSampleArk1.2/PageLoading/README.md new file mode 100644 index 0000000000000000000000000000000000000000..62ddbee3dfd0b59d65df6c017802f7fccf576169 --- /dev/null +++ b/sample/EnhanceSampleArk1.2/PageLoading/README.md @@ -0,0 +1,163 @@ +# 页面加载效果实现案例 + +### 介绍 + +本示例介绍Stack堆叠组件和LoadingProgress加载组件模拟首次进入页面实现页面加载的效果。加载完成后,LoadingProgress组件会消失并展示加载结果页(即商品页)。 + +### 效果图预览 + +![](pageloading/src/main/resources/base/media/page_loading.gif) + +**使用说明** + +1. 进入页面开始加载,加载完成后显示整个界面。 + +### 实现思路 + +1. 为了实现在页面初次加载时即展现出加载提示效果,预先定义了一个布尔类型的变量isLoading,并将其初始值设定为true。在页面加载初期,这一变量状态将触发加载页的显现,传达数据正在加载的即时信息。 +```javascript +build() { + Stack() { + if (this.isLoading) { + // 加载页 + LoadingHUD(); + } else { + // 商品页 + CommodityList(); + } + } + .width('100%') + .height('100%') + .backgroundColor(Color.White) +} +``` +2. 使用Canvas播放lottie动画以及Progress组件实现进度条 +```javascript +Canvas(this.politeChickyController) + .width($r('app.integer.lottie_view_canvas_size')) + .height($r('app.integer.lottie_view_canvas_size')) + .borderRadius($r('app.string.ohos_id_corner_radius_default_m')) + .onReady(() => { + // TODO:知识点:必须要Canvas组件初始化之后才能执行lottie.loadAnimation方法去加载动画。 + this.initAnimation(); + }) +Row() { + Progress({ value: this.nowProgress, total: 100, type: ProgressType.Linear }) + .style({ strokeWidth: 10, enableSmoothEffect: true }) + .color(this.gradientColor) +} +.width('60%') +.margin({ top: $r('app.integer.lottie_view_canvas_height') }) +``` +3. 为了模拟真实的网络加载情景,设置了5秒的延迟加载机制。在页面初次加载后的5秒钟内,isLoading变量保持为true,保持加载页的展示。当5秒时限到达时,将isLoading变量的值更新为false,代表加载状态的loadingHUD将会消失,真正的加载结果CommodityList商品列表页面便会呈现出来。 +```javascript +aboutToAppear(): void { + // 模拟网络请求操作,请求网络3秒后得到数据,通知组件,变更列表数据 + setTimeout(() => { + this.isLoading = false; + }, MILLISECONDS); +} +``` +4. CommodityList商品列表页面采用[RelativeContainer](pageloading/src/main/ets/view/CommodityList.ets)相对布局组件,容器内子组件区分水平方向,垂直方向,子组件可以将容器或者其他子组件设为锚点。 +```javascript +RelativeContainer() { + // 商品图片 + Image(item.uri) + ... + .alignRules({ + top: { anchor: '__container__', align: VerticalAlign.Top }, + left: { anchor: '__container__', align: HorizontalAlign.Start } + }) + .id('image') + // 保价标签 + Text(item.insurance) + ... + .alignRules({ + right: { anchor: '__container__', align: HorizontalAlign.End }, + center: { anchor: '__container__', align: VerticalAlign.Center } + }) + .id('insurance') + // 浏览量 + Row() { + Image($r('app.media.page_loading_views')) + ... + Text(item.views) + ... + } + .alignRules({ + middle: { anchor: 'insurance', align: HorizontalAlign.Center }, + top: { anchor: 'insurance', align: VerticalAlign.Bottom } + }) + .id('views') + // 标题和价格标签 + Column() { + Text(item.title) + ... + Text(item.price) + ... + } + .alignRules({ + left: { anchor: 'image', align: HorizontalAlign.End }, + right: { anchor: 'insurance', align: HorizontalAlign.Start }, + center: { anchor: 'image', align: VerticalAlign.Center } + }) + .id('column') +} + +``` + +### 高性能知识点 + +本示例使用了[LazyForEach](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/reference/apis-arkui/arkui-ts/ts-rendering-control-lazyforeach.md)进行数据懒加载,LazyForEach懒加载可以通过设置cachedCount属性来指定缓存数量,同时搭配[组件复用](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/performance/component-reuse-overview.md)能力以达到性能最优效果。 + +### 工程结构&模块类型 + +``` +pageloading // har类型 +|---mock +| |---CommodityMock.ets // 本地数据源 +|---model +| |---CommodityDataModel.ets // 数据类型定义 +| |---CommodityDataSource.ets // 列表数据模型 +|---view +| |---CommodityList.ets // 商品列表自定义组件 +| |---LoadingHUD.ets // 加载自定义组件 +| |---PageLoading.ets // 主页面 +``` + +### 模块依赖 + +不涉及 + +### 参考资料 + +[Stack](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/reference/apis-arkui/arkui-ts/ts-container-stack.md) + +[Progress](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/reference/apis-arkui/arkui-ts/ts-basic-components-progress.md) + +[RelativeContainer](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/reference/apis-arkui/arkui-ts/ts-container-relativecontainer.md) + +### 相关权限 + +不涉及 + +### 约束与限制 + +1.本示例仅支持在标准系统上运行,支持设备:RK3568。 + +2.本示例为Stage模型,支持API12版本SDK,SDK版本号(API Version 12 Release)。 + +3.本示例需要使用DevEco Studio 5.0.0 Release 才可编译运行。 + +### 下载 + +如需单独下载本工程,执行如下命令: +```javascript +git init +git config core.sparsecheckout true +echo code/UI/PageLoading/ > .git/info/sparse-checkout +git remote add origin https://gitee.com/openharmony/applications_app_samples.git +git pull origin master +``` + + diff --git a/sample/EnhanceSampleArk1.2/PageLoading/build-profile.json5 b/sample/EnhanceSampleArk1.2/PageLoading/build-profile.json5 new file mode 100644 index 0000000000000000000000000000000000000000..04124e5d40e9cc5527c140cc22453b006144172c --- /dev/null +++ b/sample/EnhanceSampleArk1.2/PageLoading/build-profile.json5 @@ -0,0 +1,62 @@ +/* + * Copyright (c) 2025 Huawei Device 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. + */ + +{ + "app": { + "signingConfigs": [], + "products": [ + { + "name": "default", + "signingConfig": "default", + "targetSdkVersion": "20", + "compileSdkVersion": "20", + "compatibleSdkVersion": "20", + "runtimeOS": "OpenHarmony", + "buildOption": { + "strictMode": { + "caseSensitiveCheck": true, + "useNormalizedOHMUrl": true + } + } + } + ], + "buildModeSet": [ + { + "name": "debug", + }, + { + "name": "release" + } + ] + }, + "modules": [ + { + "name": "entry", + "srcPath": "./entry", + "targets": [ + { + "name": "default", + "applyToProducts": [ + "default" + ] + } + ] + }, + { + "name": "pageloading", + "srcPath": "./pageloading", + } + ] +} \ No newline at end of file diff --git a/sample/EnhanceSampleArk1.2/PageLoading/code-linter.json5 b/sample/EnhanceSampleArk1.2/PageLoading/code-linter.json5 new file mode 100644 index 0000000000000000000000000000000000000000..ed05653cca31b61d64cf6471529eaf50d4f70709 --- /dev/null +++ b/sample/EnhanceSampleArk1.2/PageLoading/code-linter.json5 @@ -0,0 +1,47 @@ +/* + * Copyright (c) 2025 Huawei Device 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. + */ + +{ + "files": [ + "**/*.ets" + ], + "ignore": [ + "**/src/ohosTest/**/*", + "**/src/test/**/*", + "**/src/mock/**/*", + "**/node_modules/**/*", + "**/oh_modules/**/*", + "**/build/**/*", + "**/.preview/**/*" + ], + "ruleSet": [ + "plugin:@performance/recommended", + "plugin:@typescript-eslint/recommended" + ], + "rules": { + "@security/no-unsafe-aes": "error", + "@security/no-unsafe-hash": "error", + "@security/no-unsafe-mac": "warn", + "@security/no-unsafe-dh": "error", + "@security/no-unsafe-dsa": "error", + "@security/no-unsafe-ecdsa": "error", + "@security/no-unsafe-rsa-encrypt": "error", + "@security/no-unsafe-rsa-sign": "error", + "@security/no-unsafe-rsa-key": "error", + "@security/no-unsafe-dsa-key": "error", + "@security/no-unsafe-dh-key": "error", + "@security/no-unsafe-3des": "error" + } +} \ No newline at end of file diff --git a/sample/EnhanceSampleArk1.2/PageLoading/entry/.gitignore b/sample/EnhanceSampleArk1.2/PageLoading/entry/.gitignore new file mode 100644 index 0000000000000000000000000000000000000000..e2713a2779c5a3e0eb879efe6115455592caeea5 --- /dev/null +++ b/sample/EnhanceSampleArk1.2/PageLoading/entry/.gitignore @@ -0,0 +1,6 @@ +/node_modules +/oh_modules +/.preview +/build +/.cxx +/.test \ No newline at end of file diff --git a/sample/EnhanceSampleArk1.2/PageLoading/entry/build-profile.json5 b/sample/EnhanceSampleArk1.2/PageLoading/entry/build-profile.json5 new file mode 100644 index 0000000000000000000000000000000000000000..a550e7dba921ce69e5433641e615dbbe85703877 --- /dev/null +++ b/sample/EnhanceSampleArk1.2/PageLoading/entry/build-profile.json5 @@ -0,0 +1,44 @@ +/* + * Copyright (c) 2025 Huawei Device 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. + */ + +{ + "apiType": "stageMode", + "arkTSVersion": "1.2", + "buildOption": { + }, + "buildOptionSet": [ + { + "name": "release", + "arkOptions": { + "obfuscation": { + "ruleOptions": { + "enable": false, + "files": [ + "./obfuscation-rules.txt" + ] + } + } + } + }, + ], + "targets": [ + { + "name": "default" + }, + { + "name": "ohosTest", + } + ] +} \ No newline at end of file diff --git a/sample/EnhanceSampleArk1.2/PageLoading/entry/hvigorfile.ts b/sample/EnhanceSampleArk1.2/PageLoading/entry/hvigorfile.ts new file mode 100644 index 0000000000000000000000000000000000000000..b0e3a1ab98a91bc918d6404b2413111a5011f14a --- /dev/null +++ b/sample/EnhanceSampleArk1.2/PageLoading/entry/hvigorfile.ts @@ -0,0 +1,6 @@ +import { hapTasks } from '@ohos/hvigor-ohos-plugin'; + +export default { + system: hapTasks, /* Built-in plugin of Hvigor. It cannot be modified. */ + plugins: [] /* Custom plugin to extend the functionality of Hvigor. */ +} \ No newline at end of file diff --git a/sample/EnhanceSampleArk1.2/PageLoading/entry/obfuscation-rules.txt b/sample/EnhanceSampleArk1.2/PageLoading/entry/obfuscation-rules.txt new file mode 100644 index 0000000000000000000000000000000000000000..272efb6ca3f240859091bbbfc7c5802d52793b0b --- /dev/null +++ b/sample/EnhanceSampleArk1.2/PageLoading/entry/obfuscation-rules.txt @@ -0,0 +1,23 @@ +# Define project specific obfuscation rules here. +# You can include the obfuscation configuration files in the current module's build-profile.json5. +# +# For more details, see +# https://developer.huawei.com/consumer/cn/doc/harmonyos-guides-V5/source-obfuscation-V5 + +# Obfuscation options: +# -disable-obfuscation: disable all obfuscations +# -enable-property-obfuscation: obfuscate the property names +# -enable-toplevel-obfuscation: obfuscate the names in the global scope +# -compact: remove unnecessary blank spaces and all line feeds +# -remove-log: remove all console.* statements +# -print-namecache: print the name cache that contains the mapping from the old names to new names +# -apply-namecache: reuse the given cache file + +# Keep options: +# -keep-property-name: specifies property names that you want to keep +# -keep-global-name: specifies names that you want to keep in the global scope + +-enable-property-obfuscation +-enable-toplevel-obfuscation +-enable-filename-obfuscation +-enable-export-obfuscation \ No newline at end of file diff --git a/sample/EnhanceSampleArk1.2/PageLoading/entry/oh-package-lock.json5 b/sample/EnhanceSampleArk1.2/PageLoading/entry/oh-package-lock.json5 new file mode 100644 index 0000000000000000000000000000000000000000..2bec7083d7b99a894fcc50e60a67b385e1118655 --- /dev/null +++ b/sample/EnhanceSampleArk1.2/PageLoading/entry/oh-package-lock.json5 @@ -0,0 +1,30 @@ +{ + "meta": { + "stableOrder": true, + "enableUnifiedLockfile": false + }, + "lockfileVersion": 3, + "ATTENTION": "THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.", + "specifiers": { + "@ohos/lottie@2.0.0": "@ohos/lottie@2.0.0", + "pageloading@../pageloading": "pageloading@../pageloading" + }, + "packages": { + "@ohos/lottie@2.0.0": { + "name": "@ohos/lottie", + "version": "2.0.0", + "integrity": "sha512-jFEFYfuqGO323aMiwtzHmDGRJI0qTxjZD2Lzbn+LxRdoHSfu5OVu22I8gVm5ej019tCw3WOk547NHZ2GuWiNSg==", + "resolved": "https://ohpm.openharmony.cn/ohpm/@ohos/lottie/-/lottie-2.0.0.har", + "registryType": "ohpm" + }, + "pageloading@../pageloading": { + "name": "pageloading", + "version": "1.0.0", + "resolved": "", + "registryType": "local", + "dependencies": { + "@ohos/lottie": "2.0.0" + } + } + } +} \ No newline at end of file diff --git a/sample/EnhanceSampleArk1.2/PageLoading/entry/oh-package.json5 b/sample/EnhanceSampleArk1.2/PageLoading/entry/oh-package.json5 new file mode 100644 index 0000000000000000000000000000000000000000..7134a93557deb6999c82b8d208804f6083aa8527 --- /dev/null +++ b/sample/EnhanceSampleArk1.2/PageLoading/entry/oh-package.json5 @@ -0,0 +1,27 @@ +/* + * Copyright (c) 2025 Huawei Device 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": "entry", + "version": "1.0.0", + "description": "Please describe the basic information.", + "main": "", + "author": "", + "license": "", + "dependencies": { + "pageloading": "file:../pageloading" + } +} + diff --git a/sample/EnhanceSampleArk1.2/PageLoading/entry/src/main/ets/common/lottie/pageLoading.json b/sample/EnhanceSampleArk1.2/PageLoading/entry/src/main/ets/common/lottie/pageLoading.json new file mode 100644 index 0000000000000000000000000000000000000000..89edde9ea1febf70bd417a335fee9164ce638ab6 --- /dev/null +++ b/sample/EnhanceSampleArk1.2/PageLoading/entry/src/main/ets/common/lottie/pageLoading.json @@ -0,0 +1 @@ +{"v":"5.9.6","fr":25,"ip":0,"op":101,"w":600,"h":600,"nm":"huakuai","ddd":0,"assets":[],"layers":[{"ddd":0,"ind":1,"ty":4,"nm":"five","sr":1,"ks":{"o":{"a":0,"k":100,"ix":11},"r":{"a":1,"k":[{"i":{"x":[0.667],"y":[1]},"o":{"x":[0.333],"y":[0]},"t":15,"s":[0]},{"i":{"x":[0.667],"y":[1]},"o":{"x":[0.333],"y":[0]},"t":21,"s":[10]},{"i":{"x":[0.833],"y":[1]},"o":{"x":[0.167],"y":[0]},"t":26,"s":[0]},{"i":{"x":[0.667],"y":[1]},"o":{"x":[0.333],"y":[0]},"t":51,"s":[0]},{"i":{"x":[0.667],"y":[1]},"o":{"x":[0.333],"y":[0]},"t":57,"s":[-10]},{"t":62,"s":[0]}],"ix":10},"p":{"a":1,"k":[{"i":{"x":0.351,"y":1},"o":{"x":0.276,"y":0},"t":15,"s":[520,360,0],"to":[-4.667,-15,0],"ti":[22.917,0,0]},{"i":{"x":0.351,"y":1},"o":{"x":0.276,"y":0},"t":21,"s":[465,250,0],"to":[-22.917,0,0],"ti":[0,0,0]},{"i":{"x":0.416,"y":0.416},"o":{"x":0.317,"y":0.317},"t":26,"s":[410,360,0],"to":[0,0,0],"ti":[0,0,0]},{"i":{"x":0.467,"y":0.739},"o":{"x":0.225,"y":0},"t":51,"s":[410,360,0],"to":[0,0,0],"ti":[-18.333,0,0]},{"i":{"x":0.579,"y":1},"o":{"x":0.256,"y":0.125},"t":56,"s":[464.291,250,0],"to":[18.333,0,0],"ti":[0,0,0]},{"t":61,"s":[520,360,0]}],"ix":2,"l":2},"a":{"a":0,"k":[-162,-58,0],"ix":1,"l":2},"s":{"a":1,"k":[{"i":{"x":[0.667,0.667,0.667],"y":[1,1,1]},"o":{"x":[0.333,0.333,0.333],"y":[0,0,0]},"t":15,"s":[100,100,100]},{"i":{"x":[0.667,0.667,0.667],"y":[1,1,1]},"o":{"x":[0.333,0.333,0.333],"y":[0,0,0]},"t":21,"s":[90,110,100]},{"i":{"x":[0.667,0.667,0.667],"y":[1,1,1]},"o":{"x":[0.333,0.333,0.333],"y":[0,0,0]},"t":25,"s":[100,100,100]},{"i":{"x":[0.667,0.667,0.667],"y":[1,1,1]},"o":{"x":[0.333,0.333,0.333],"y":[0,0,0]},"t":27,"s":[120,70,100]},{"i":{"x":[0.833,0.833,0.833],"y":[1,1,1]},"o":{"x":[0.167,0.167,0.167],"y":[0,0,0]},"t":29,"s":[100,100,100]},{"i":{"x":[0.667,0.667,0.667],"y":[1,1,1]},"o":{"x":[0.333,0.333,0.333],"y":[0,0,0]},"t":51,"s":[100,100,100]},{"i":{"x":[0.667,0.667,0.667],"y":[1,1,1]},"o":{"x":[0.333,0.333,0.333],"y":[0,0,0]},"t":57,"s":[90,110,100]},{"i":{"x":[0.667,0.667,0.667],"y":[1,1,1]},"o":{"x":[0.333,0.333,0.333],"y":[0,0,0]},"t":61,"s":[100,100,100]},{"i":{"x":[0.667,0.667,0.667],"y":[1,1,1]},"o":{"x":[0.333,0.333,0.333],"y":[0,0,0]},"t":63,"s":[120,70,100]},{"t":65,"s":[100,100,100]}],"ix":6,"l":2}},"ao":0,"shapes":[{"ty":"gr","it":[{"ty":"rc","d":1,"s":{"a":0,"k":[80,80],"ix":2},"p":{"a":0,"k":[0,0],"ix":3},"r":{"a":0,"k":10,"ix":4},"nm":"Rectangle Path 1","mn":"ADBE Vector Shape - Rect","hd":false},{"ty":"fl","c":{"a":1,"k":[{"i":{"x":[0.667],"y":[1]},"o":{"x":[0.333],"y":[0]},"t":15,"s":[0.623529434204,0.917647063732,0.494117647409,1]},{"i":{"x":[0.667],"y":[1]},"o":{"x":[0.333],"y":[0]},"t":26,"s":[0.443137258291,0.737254917622,0.078431375325,1]},{"i":{"x":[0.667],"y":[1]},"o":{"x":[0.333],"y":[0]},"t":51,"s":[0.443137258291,0.737254917622,0.078431375325,1]},{"t":61,"s":[0.623529434204,0.917647063732,0.494117647409,1]}],"ix":4},"o":{"a":0,"k":100,"ix":5},"r":1,"bm":0,"nm":"Fill 1","mn":"ADBE Vector Graphic - Fill","hd":false},{"ty":"tr","p":{"a":0,"k":[-162,-98],"ix":2},"a":{"a":0,"k":[0,0],"ix":1},"s":{"a":0,"k":[100,100],"ix":3},"r":{"a":0,"k":0,"ix":6},"o":{"a":0,"k":100,"ix":7},"sk":{"a":0,"k":0,"ix":4},"sa":{"a":0,"k":0,"ix":5},"nm":"Transform"}],"nm":"Rectangle 1","np":3,"cix":2,"bm":0,"ix":1,"mn":"ADBE Vector Group","hd":false}],"ip":0,"op":101,"st":0,"ct":1,"bm":0},{"ddd":0,"ind":2,"ty":4,"nm":"four","sr":1,"ks":{"o":{"a":0,"k":100,"ix":11},"r":{"a":1,"k":[{"i":{"x":[0.667],"y":[1]},"o":{"x":[0.333],"y":[0]},"t":11,"s":[0]},{"i":{"x":[0.667],"y":[1]},"o":{"x":[0.333],"y":[0]},"t":16,"s":[10]},{"i":{"x":[0.833],"y":[1]},"o":{"x":[0.167],"y":[0]},"t":21,"s":[0]},{"i":{"x":[0.667],"y":[1]},"o":{"x":[0.333],"y":[0]},"t":56,"s":[0]},{"i":{"x":[0.667],"y":[1]},"o":{"x":[0.333],"y":[0]},"t":61,"s":[-10]},{"t":66,"s":[0]}],"ix":10},"p":{"a":1,"k":[{"i":{"x":0.316,"y":1},"o":{"x":0.24,"y":0},"t":11,"s":[410,360,0],"to":[-4.667,-15,0],"ti":[22.917,0,0]},{"i":{"x":0.316,"y":1},"o":{"x":0.24,"y":0},"t":16,"s":[355,250,0],"to":[-22.917,0,0],"ti":[6.307,-19.302,0]},{"i":{"x":0.316,"y":1},"o":{"x":0.167,"y":0},"t":21,"s":[300,360,0],"to":[-0.116,0.355,0],"ti":[0,0,0]},{"i":{"x":0.583,"y":0.775},"o":{"x":0.167,"y":0},"t":56,"s":[300,360,0],"to":[0,0,0],"ti":[-27.317,0.053,0]},{"i":{"x":0.833,"y":1},"o":{"x":0.417,"y":0.224},"t":61,"s":[354.435,250,0],"to":[28.392,-0.055,0],"ti":[-2.765,-8.21,0]},{"t":66,"s":[410,360,0]}],"ix":2,"l":2},"a":{"a":0,"k":[-162,-58,0],"ix":1,"l":2},"s":{"a":1,"k":[{"i":{"x":[0.667,0.667,0.667],"y":[1,1,1]},"o":{"x":[0.333,0.333,0.333],"y":[0,0,0]},"t":11,"s":[100,100,100]},{"i":{"x":[0.667,0.667,0.667],"y":[1,1,1]},"o":{"x":[0.333,0.333,0.333],"y":[0,0,0]},"t":16,"s":[90,110,100]},{"i":{"x":[0.667,0.667,0.667],"y":[1,1,1]},"o":{"x":[0.333,0.333,0.333],"y":[0,0,0]},"t":20,"s":[100,100,100]},{"i":{"x":[0.667,0.667,0.667],"y":[1,1,1]},"o":{"x":[0.333,0.333,0.333],"y":[0,0,0]},"t":22,"s":[120,70,100]},{"i":{"x":[0.833,0.833,0.833],"y":[1,1,1]},"o":{"x":[0.167,0.167,0.167],"y":[0,0,0]},"t":24,"s":[100,100,100]},{"i":{"x":[0.667,0.667,0.667],"y":[1,1,1]},"o":{"x":[0.333,0.333,0.333],"y":[0,0,0]},"t":56,"s":[100,100,100]},{"i":{"x":[0.667,0.667,0.667],"y":[1,1,1]},"o":{"x":[0.333,0.333,0.333],"y":[0,0,0]},"t":61,"s":[90,110,100]},{"i":{"x":[0.667,0.667,0.667],"y":[1,1,1]},"o":{"x":[0.333,0.333,0.333],"y":[0,0,0]},"t":65,"s":[100,100,100]},{"i":{"x":[0.667,0.667,0.667],"y":[1,1,1]},"o":{"x":[0.333,0.333,0.333],"y":[0,0,0]},"t":67,"s":[120,70,100]},{"t":69,"s":[100,100,100]}],"ix":6,"l":2}},"ao":0,"shapes":[{"ty":"gr","it":[{"ty":"rc","d":1,"s":{"a":0,"k":[80,80],"ix":2},"p":{"a":0,"k":[0,0],"ix":3},"r":{"a":0,"k":10,"ix":4},"nm":"Rectangle Path 1","mn":"ADBE Vector Shape - Rect","hd":false},{"ty":"fl","c":{"a":1,"k":[{"i":{"x":[0.667],"y":[1]},"o":{"x":[0.333],"y":[0]},"t":11,"s":[0.443137258291,0.737254917622,0.078431375325,1]},{"i":{"x":[0.667],"y":[1]},"o":{"x":[0.167],"y":[0]},"t":21,"s":[0.298039227724,0.623529434204,0.043137256056,1]},{"i":{"x":[0.833],"y":[1]},"o":{"x":[0.167],"y":[0]},"t":56,"s":[0.298039227724,0.623529434204,0.043137256056,1]},{"t":66,"s":[0.443137258291,0.737254917622,0.078431375325,1]}],"ix":4},"o":{"a":0,"k":100,"ix":5},"r":1,"bm":0,"nm":"Fill 1","mn":"ADBE Vector Graphic - Fill","hd":false},{"ty":"tr","p":{"a":0,"k":[-162,-98],"ix":2},"a":{"a":0,"k":[0,0],"ix":1},"s":{"a":0,"k":[100,100],"ix":3},"r":{"a":0,"k":0,"ix":6},"o":{"a":0,"k":100,"ix":7},"sk":{"a":0,"k":0,"ix":4},"sa":{"a":0,"k":0,"ix":5},"nm":"Transform"}],"nm":"Rectangle 1","np":3,"cix":2,"bm":0,"ix":1,"mn":"ADBE Vector Group","hd":false}],"ip":0,"op":101,"st":0,"ct":1,"bm":0},{"ddd":0,"ind":3,"ty":4,"nm":"three","sr":1,"ks":{"o":{"a":0,"k":100,"ix":11},"r":{"a":1,"k":[{"i":{"x":[0.667],"y":[1]},"o":{"x":[0.333],"y":[0]},"t":6,"s":[0]},{"i":{"x":[0.667],"y":[1]},"o":{"x":[0.333],"y":[0]},"t":11,"s":[10]},{"i":{"x":[0.833],"y":[1]},"o":{"x":[0.167],"y":[0]},"t":16,"s":[0]},{"i":{"x":[0.667],"y":[1]},"o":{"x":[0.333],"y":[0]},"t":61,"s":[0]},{"i":{"x":[0.667],"y":[1]},"o":{"x":[0.333],"y":[0]},"t":66,"s":[-10]},{"t":71,"s":[0]}],"ix":10},"p":{"a":1,"k":[{"i":{"x":0.369,"y":1},"o":{"x":0.258,"y":0},"t":6,"s":[300,360,0],"to":[-5.167,-18.5,0],"ti":[22.917,0,0]},{"i":{"x":0.369,"y":1},"o":{"x":0.258,"y":0},"t":11,"s":[245,250,0],"to":[-22.917,0,0],"ti":[2.434,-10.892,0]},{"i":{"x":0.369,"y":1},"o":{"x":0.167,"y":0},"t":16,"s":[190,360,0],"to":[-0.385,1.723,0],"ti":[0,0,0]},{"i":{"x":0.583,"y":0.776},"o":{"x":0.167,"y":0},"t":61,"s":[190,360,0],"to":[0,0,0],"ti":[-29.055,-0.462,0]},{"i":{"x":0.833,"y":1},"o":{"x":0.417,"y":0.224},"t":66,"s":[245.406,250,0],"to":[28.268,0.45,0],"ti":[-3.029,-9.151,0]},{"t":71,"s":[300,360,0]}],"ix":2,"l":2},"a":{"a":0,"k":[-162,-58,0],"ix":1,"l":2},"s":{"a":1,"k":[{"i":{"x":[0.667,0.667,0.667],"y":[1,1,1]},"o":{"x":[0.333,0.333,0.333],"y":[0,0,0]},"t":6,"s":[100,100,100]},{"i":{"x":[0.667,0.667,0.667],"y":[1,1,1]},"o":{"x":[0.333,0.333,0.333],"y":[0,0,0]},"t":11,"s":[90,110,100]},{"i":{"x":[0.667,0.667,0.667],"y":[1,1,1]},"o":{"x":[0.333,0.333,0.333],"y":[0,0,0]},"t":15,"s":[100,100,100]},{"i":{"x":[0.667,0.667,0.667],"y":[1,1,1]},"o":{"x":[0.333,0.333,0.333],"y":[0,0,0]},"t":17,"s":[120,70,100]},{"i":{"x":[0.833,0.833,0.833],"y":[1,1,1]},"o":{"x":[0.167,0.167,0.167],"y":[0,0,0]},"t":19,"s":[100,100,100]},{"i":{"x":[0.667,0.667,0.667],"y":[1,1,1]},"o":{"x":[0.333,0.333,0.333],"y":[0,0,0]},"t":61,"s":[100,100,100]},{"i":{"x":[0.667,0.667,0.667],"y":[1,1,1]},"o":{"x":[0.333,0.333,0.333],"y":[0,0,0]},"t":66,"s":[90,110,100]},{"i":{"x":[0.667,0.667,0.667],"y":[1,1,1]},"o":{"x":[0.333,0.333,0.333],"y":[0,0,0]},"t":70,"s":[100,100,100]},{"i":{"x":[0.667,0.667,0.667],"y":[1,1,1]},"o":{"x":[0.333,0.333,0.333],"y":[0,0,0]},"t":72,"s":[120,70,100]},{"t":74,"s":[100,100,100]}],"ix":6,"l":2}},"ao":0,"shapes":[{"ty":"gr","it":[{"ty":"rc","d":1,"s":{"a":0,"k":[80,80],"ix":2},"p":{"a":0,"k":[0,0],"ix":3},"r":{"a":0,"k":10,"ix":4},"nm":"Rectangle Path 1","mn":"ADBE Vector Shape - Rect","hd":false},{"ty":"fl","c":{"a":1,"k":[{"i":{"x":[0.667],"y":[1]},"o":{"x":[0.333],"y":[0]},"t":6,"s":[0.298039227724,0.623529434204,0.043137256056,1]},{"i":{"x":[0.667],"y":[1]},"o":{"x":[0.167],"y":[0]},"t":16,"s":[0.176470592618,0.474509805441,0.023529412225,1]},{"i":{"x":[0.833],"y":[1]},"o":{"x":[0.167],"y":[0]},"t":61,"s":[0.176470592618,0.474509805441,0.023529412225,1]},{"t":71,"s":[0.298039227724,0.623529434204,0.043137256056,1]}],"ix":4},"o":{"a":0,"k":100,"ix":5},"r":1,"bm":0,"nm":"Fill 1","mn":"ADBE Vector Graphic - Fill","hd":false},{"ty":"tr","p":{"a":0,"k":[-162,-98],"ix":2},"a":{"a":0,"k":[0,0],"ix":1},"s":{"a":0,"k":[100,100],"ix":3},"r":{"a":0,"k":0,"ix":6},"o":{"a":0,"k":100,"ix":7},"sk":{"a":0,"k":0,"ix":4},"sa":{"a":0,"k":0,"ix":5},"nm":"Transform"}],"nm":"Rectangle 1","np":3,"cix":2,"bm":0,"ix":1,"mn":"ADBE Vector Group","hd":false}],"ip":0,"op":101,"st":0,"ct":1,"bm":0},{"ddd":0,"ind":4,"ty":4,"nm":"two","sr":1,"ks":{"o":{"a":0,"k":100,"ix":11},"r":{"a":1,"k":[{"i":{"x":[0.667],"y":[1]},"o":{"x":[0.333],"y":[0]},"t":1,"s":[0]},{"i":{"x":[0.667],"y":[1]},"o":{"x":[0.333],"y":[0]},"t":6,"s":[10]},{"i":{"x":[0.833],"y":[1]},"o":{"x":[0.167],"y":[0]},"t":11,"s":[0]},{"i":{"x":[0.667],"y":[1]},"o":{"x":[0.333],"y":[0]},"t":67,"s":[0]},{"i":{"x":[0.667],"y":[1]},"o":{"x":[0.333],"y":[0]},"t":73,"s":[-10]},{"t":79,"s":[0]}],"ix":10},"p":{"a":1,"k":[{"i":{"x":0.458,"y":1},"o":{"x":0.222,"y":0},"t":1,"s":[190,360,0],"to":[-2.417,-11.5,0],"ti":[22.917,0,0]},{"i":{"x":0.458,"y":1},"o":{"x":0.222,"y":0},"t":6,"s":[135,250,0],"to":[-22.917,0,0],"ti":[2.778,-8.535,0]},{"i":{"x":0.458,"y":1},"o":{"x":0.167,"y":0},"t":11,"s":[80,360,0],"to":[-0.664,2.04,0],"ti":[0,0,0]},{"i":{"x":0.583,"y":0.731},"o":{"x":0.167,"y":0},"t":67,"s":[80,360,0],"to":[0,0,0],"ti":[-28.172,-0.208,0]},{"i":{"x":0.833,"y":1},"o":{"x":0.417,"y":0.269},"t":73,"s":[135.986,250,0],"to":[26.782,0.198,0],"ti":[3.225,8.657,0]},{"t":79,"s":[190,360,0]}],"ix":2,"l":2},"a":{"a":0,"k":[-162,-58,0],"ix":1,"l":2},"s":{"a":1,"k":[{"i":{"x":[0.667,0.667,0.667],"y":[1,1,1]},"o":{"x":[0.333,0.333,0.333],"y":[0,0,0]},"t":1,"s":[100,100,100]},{"i":{"x":[0.667,0.667,0.667],"y":[1,1,1]},"o":{"x":[0.333,0.333,0.333],"y":[0,0,0]},"t":6,"s":[90,110,100]},{"i":{"x":[0.667,0.667,0.667],"y":[1,1,1]},"o":{"x":[0.333,0.333,0.333],"y":[0,0,0]},"t":10,"s":[100,100,100]},{"i":{"x":[0.667,0.667,0.667],"y":[1,1,1]},"o":{"x":[0.333,0.333,0.333],"y":[0,0,0]},"t":12,"s":[120,70,100]},{"i":{"x":[0.833,0.833,0.833],"y":[1,1,1]},"o":{"x":[0.167,0.167,0.167],"y":[0,0,0]},"t":14,"s":[100,100,100]},{"i":{"x":[0.667,0.667,0.667],"y":[1,1,1]},"o":{"x":[0.333,0.333,0.333],"y":[0,0,0]},"t":67,"s":[100,100,100]},{"i":{"x":[0.667,0.667,0.667],"y":[1,1,1]},"o":{"x":[0.333,0.333,0.333],"y":[0,0,0]},"t":73,"s":[90,110,100]},{"i":{"x":[0.667,0.667,0.667],"y":[1,1,1]},"o":{"x":[0.333,0.333,0.333],"y":[0,0,0]},"t":78,"s":[100,100,100]},{"i":{"x":[0.667,0.667,0.667],"y":[1,1,1]},"o":{"x":[0.333,0.333,0.333],"y":[0,0,0]},"t":80,"s":[120,70,100]},{"t":82,"s":[100,100,100]}],"ix":6,"l":2}},"ao":0,"shapes":[{"ty":"gr","it":[{"ty":"rc","d":1,"s":{"a":0,"k":[80,80],"ix":2},"p":{"a":0,"k":[0,0],"ix":3},"r":{"a":0,"k":10,"ix":4},"nm":"Rectangle Path 1","mn":"ADBE Vector Shape - Rect","hd":false},{"ty":"fl","c":{"a":1,"k":[{"i":{"x":[0.667],"y":[1]},"o":{"x":[0.333],"y":[0]},"t":1,"s":[0.176470592618,0.474509805441,0.023529412225,1]},{"i":{"x":[0.667],"y":[1]},"o":{"x":[0.167],"y":[0]},"t":11,"s":[0.141176477075,0.388235300779,0.019607843831,1]},{"i":{"x":[0.833],"y":[1]},"o":{"x":[0.167],"y":[0]},"t":67,"s":[0.141176477075,0.388235300779,0.019607843831,1]},{"t":79,"s":[0.176470592618,0.474509805441,0.023529412225,1]}],"ix":4},"o":{"a":0,"k":100,"ix":5},"r":1,"bm":0,"nm":"Fill 1","mn":"ADBE Vector Graphic - Fill","hd":false},{"ty":"tr","p":{"a":0,"k":[-162,-98],"ix":2},"a":{"a":0,"k":[0,0],"ix":1},"s":{"a":0,"k":[100,100],"ix":3},"r":{"a":0,"k":0,"ix":6},"o":{"a":0,"k":100,"ix":7},"sk":{"a":0,"k":0,"ix":4},"sa":{"a":0,"k":0,"ix":5},"nm":"Transform"}],"nm":"Rectangle 1","np":3,"cix":2,"bm":0,"ix":1,"mn":"ADBE Vector Group","hd":false}],"ip":0,"op":101,"st":0,"ct":1,"bm":0},{"ddd":0,"ind":5,"ty":4,"nm":"one","sr":1,"ks":{"o":{"a":0,"k":100,"ix":11},"r":{"a":0,"k":0,"ix":10},"p":{"a":1,"k":[{"i":{"x":0.111,"y":1},"o":{"x":0.26,"y":0},"t":0,"s":[80,320,0],"to":[73.333,0,0],"ti":[-73.333,0,0]},{"i":{"x":0.082,"y":0.082},"o":{"x":0.213,"y":0.213},"t":39.967,"s":[520,320,0],"to":[0,0,0],"ti":[0,0,0]},{"i":{"x":0.112,"y":1},"o":{"x":0.26,"y":0},"t":50,"s":[520,320,0],"to":[-73.333,0,0],"ti":[73.333,0,0]},{"t":90,"s":[80,320,0]}],"ix":2,"l":2},"a":{"a":0,"k":[-162,-98,0],"ix":1,"l":2},"s":{"a":0,"k":[100,100,100],"ix":6,"l":2}},"ao":0,"shapes":[{"ty":"gr","it":[{"ty":"rc","d":1,"s":{"a":0,"k":[80,80],"ix":2},"p":{"a":0,"k":[0,0],"ix":3},"r":{"a":0,"k":10,"ix":4},"nm":"Rectangle Path 1","mn":"ADBE Vector Shape - Rect","hd":false},{"ty":"fl","c":{"a":1,"k":[{"i":{"x":[0.444],"y":[1]},"o":{"x":[0.249],"y":[0]},"t":0,"s":[0.141176477075,0.388235300779,0.019607843831,1]},{"i":{"x":[0],"y":[1]},"o":{"x":[0.333],"y":[0]},"t":40,"s":[0.623529434204,0.917647063732,0.494117647409,1]},{"i":{"x":[0.444],"y":[1]},"o":{"x":[0.333],"y":[0]},"t":50,"s":[0.623529434204,0.917647063732,0.494117647409,1]},{"t":90,"s":[0.141176477075,0.388235300779,0.019607843831,1]}],"ix":4},"o":{"a":0,"k":100,"ix":5},"r":1,"bm":0,"nm":"Fill 1","mn":"ADBE Vector Graphic - Fill","hd":false},{"ty":"tr","p":{"a":0,"k":[-162,-98],"ix":2},"a":{"a":0,"k":[0,0],"ix":1},"s":{"a":0,"k":[100,100],"ix":3},"r":{"a":0,"k":0,"ix":6},"o":{"a":0,"k":100,"ix":7},"sk":{"a":0,"k":0,"ix":4},"sa":{"a":0,"k":0,"ix":5},"nm":"Transform"}],"nm":"Rectangle 1","np":3,"cix":2,"bm":0,"ix":1,"mn":"ADBE Vector Group","hd":false}],"ip":0,"op":101,"st":0,"ct":1,"bm":0}],"markers":[]} \ No newline at end of file diff --git a/sample/EnhanceSampleArk1.2/PageLoading/entry/src/main/ets/entryability/EntryAbility.ets b/sample/EnhanceSampleArk1.2/PageLoading/entry/src/main/ets/entryability/EntryAbility.ets new file mode 100644 index 0000000000000000000000000000000000000000..24adc51c1b35b12ed18a7958ea667bde03713efe --- /dev/null +++ b/sample/EnhanceSampleArk1.2/PageLoading/entry/src/main/ets/entryability/EntryAbility.ets @@ -0,0 +1,62 @@ +'use static' +/* + * Copyright (c) 2025 Huawei Device 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 UIAbility from '@ohos.app.ability.UIAbility'; +import AbilityConstant from '@ohos.app.ability.AbilityConstant'; +import Want from '@ohos.app.ability.Want'; +import window from '@ohos.window'; +import { BusinessError } from '@ohos.base' +import hilog from '@ohos.hilog'; +import ConfigurationConstant from '@ohos.app.ability.ConfigurationConstant'; + +export default class EntryAbility extends UIAbility { + onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { + this.context.getApplicationContext().setColorMode(ConfigurationConstant.ColorMode.COLOR_MODE_NOT_SET); + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); + } + + onDestroy(): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage): void { + // Main window is created, set main page for this ability + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); + + windowStage.loadContent('pages/Index', (err: BusinessError | null): void => { + if (err && err.code) { + hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); + return; + } + hilog.info(0x0000, 'testTag', 'Succeeded in loading the content.'); + }); + } + + onWindowStageDestroy(): void { + // Main window is destroyed, release UI related resources + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); + } + + onForeground(): void { + // Ability has brought to foreground + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); + } + + onBackground(): void { + // Ability has back to background + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); + } +} \ No newline at end of file diff --git a/sample/EnhanceSampleArk1.2/PageLoading/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets b/sample/EnhanceSampleArk1.2/PageLoading/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets new file mode 100644 index 0000000000000000000000000000000000000000..4f5067f24c5e622f6431b2120b8e2c26b075c5cf --- /dev/null +++ b/sample/EnhanceSampleArk1.2/PageLoading/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets @@ -0,0 +1,29 @@ +'use static' +/* + * Copyright (c) 2025 Huawei Device 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 hilog from '@ohos.hilog'; +import BackupExtensionAbility from '@ohos.application.BackupExtensionAbility'; +import { BundleVersion } from '@ohos.application.BackupExtensionAbility'; + +export default class EntryBackupAbility extends BackupExtensionAbility { + onBackup() { + hilog.info(0x0000, 'testTag', 'onBackup ok'); + } + + onRestore(bundleVersion: BundleVersion) { + hilog.info(0x0000, 'testTag', 'onRestore ok %{public}s', JSON.stringify(bundleVersion)); + } +} \ No newline at end of file diff --git a/sample/EnhanceSampleArk1.2/PageLoading/entry/src/main/ets/pages/Index.ets b/sample/EnhanceSampleArk1.2/PageLoading/entry/src/main/ets/pages/Index.ets new file mode 100644 index 0000000000000000000000000000000000000000..6191f83dd94322d98137c83b2b2fc0288a07bc61 --- /dev/null +++ b/sample/EnhanceSampleArk1.2/PageLoading/entry/src/main/ets/pages/Index.ets @@ -0,0 +1,35 @@ +'use static' +/* + * Copyright (c) 2025 Huawei Device 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 { + Entry, + Component, + Column, +} from '@kit.ArkUI'; + +import { PageLoadingComponent } from 'pageloading'; + +@Entry +@Component +struct Index { + build() { + Column() { + PageLoadingComponent() + } + .height('100%') + .width('100%') + } +} \ No newline at end of file diff --git a/sample/EnhanceSampleArk1.2/PageLoading/entry/src/main/module.json5 b/sample/EnhanceSampleArk1.2/PageLoading/entry/src/main/module.json5 new file mode 100644 index 0000000000000000000000000000000000000000..4144486d1af4c03b0d767cce1cda86fc0d697f91 --- /dev/null +++ b/sample/EnhanceSampleArk1.2/PageLoading/entry/src/main/module.json5 @@ -0,0 +1,66 @@ +/* + * Copyright (c) 2025 Huawei Device 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. + */ + +{ + "module": { + "name": "entry", + "type": "entry", + "description": "$string:module_desc", + "mainElement": "EntryAbility", + "deviceTypes": [ + "default", + "tablet" + ], + "deliveryWithInstall": true, + "installationFree": false, + "pages": "$profile:main_pages", + "abilities": [ + { + "name": "EntryAbility", + "srcEntry": "./ets/entryability/EntryAbility.ets", + "description": "$string:EntryAbility_desc", + "icon": "$media:layered_image", + "label": "$string:EntryAbility_label", + "startWindowIcon": "$media:startIcon", + "startWindowBackground": "$color:start_window_background", + "exported": true, + "skills": [ + { + "entities": [ + "entity.system.home" + ], + "actions": [ + "action.system.home" + ] + } + ] + } + ], + "extensionAbilities": [ + { + "name": "EntryBackupAbility", + "srcEntry": "./ets/entrybackupability/EntryBackupAbility.ets", + "type": "backup", + "exported": false, + "metadata": [ + { + "name": "ohos.extension.backup", + "resource": "$profile:backup_config" + } + ] + } + ] + } +} \ No newline at end of file diff --git a/sample/EnhanceSampleArk1.2/PageLoading/entry/src/main/resources/base/element/color.json b/sample/EnhanceSampleArk1.2/PageLoading/entry/src/main/resources/base/element/color.json new file mode 100644 index 0000000000000000000000000000000000000000..3c712962da3c2751c2b9ddb53559afcbd2b54a02 --- /dev/null +++ b/sample/EnhanceSampleArk1.2/PageLoading/entry/src/main/resources/base/element/color.json @@ -0,0 +1,8 @@ +{ + "color": [ + { + "name": "start_window_background", + "value": "#FFFFFF" + } + ] +} \ No newline at end of file diff --git a/sample/EnhanceSampleArk1.2/PageLoading/entry/src/main/resources/base/element/string.json b/sample/EnhanceSampleArk1.2/PageLoading/entry/src/main/resources/base/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..f7e4e8e2b173384a155fa1bae516a02672f78622 --- /dev/null +++ b/sample/EnhanceSampleArk1.2/PageLoading/entry/src/main/resources/base/element/string.json @@ -0,0 +1,16 @@ +{ + "string": [ + { + "name": "module_desc", + "value": "module description" + }, + { + "name": "EntryAbility_desc", + "value": "description" + }, + { + "name": "EntryAbility_label", + "value": "pageloading" + } + ] +} \ No newline at end of file diff --git a/sample/EnhanceSampleArk1.2/PageLoading/entry/src/main/resources/base/media/background.png b/sample/EnhanceSampleArk1.2/PageLoading/entry/src/main/resources/base/media/background.png new file mode 100644 index 0000000000000000000000000000000000000000..f939c9fa8cc8914832e602198745f592a0dfa34d Binary files /dev/null and b/sample/EnhanceSampleArk1.2/PageLoading/entry/src/main/resources/base/media/background.png differ diff --git a/sample/EnhanceSampleArk1.2/PageLoading/entry/src/main/resources/base/media/foreground.png b/sample/EnhanceSampleArk1.2/PageLoading/entry/src/main/resources/base/media/foreground.png new file mode 100644 index 0000000000000000000000000000000000000000..4483ddad1f079e1089d685bd204ee1cfe1d01902 Binary files /dev/null and b/sample/EnhanceSampleArk1.2/PageLoading/entry/src/main/resources/base/media/foreground.png differ diff --git a/sample/EnhanceSampleArk1.2/PageLoading/entry/src/main/resources/base/media/layered_image.json b/sample/EnhanceSampleArk1.2/PageLoading/entry/src/main/resources/base/media/layered_image.json new file mode 100644 index 0000000000000000000000000000000000000000..fb49920440fb4d246c82f9ada275e26123a2136a --- /dev/null +++ b/sample/EnhanceSampleArk1.2/PageLoading/entry/src/main/resources/base/media/layered_image.json @@ -0,0 +1,7 @@ +{ + "layered-image": + { + "background" : "$media:background", + "foreground" : "$media:foreground" + } +} \ No newline at end of file diff --git a/sample/EnhanceSampleArk1.2/PageLoading/entry/src/main/resources/base/media/startIcon.png b/sample/EnhanceSampleArk1.2/PageLoading/entry/src/main/resources/base/media/startIcon.png new file mode 100644 index 0000000000000000000000000000000000000000..205ad8b5a8a42e8762fbe4899b8e5e31ce822b8b Binary files /dev/null and b/sample/EnhanceSampleArk1.2/PageLoading/entry/src/main/resources/base/media/startIcon.png differ diff --git a/sample/EnhanceSampleArk1.2/PageLoading/entry/src/main/resources/base/profile/backup_config.json b/sample/EnhanceSampleArk1.2/PageLoading/entry/src/main/resources/base/profile/backup_config.json new file mode 100644 index 0000000000000000000000000000000000000000..78f40ae7c494d71e2482278f359ec790ca73471a --- /dev/null +++ b/sample/EnhanceSampleArk1.2/PageLoading/entry/src/main/resources/base/profile/backup_config.json @@ -0,0 +1,3 @@ +{ + "allowToBackupRestore": true +} \ No newline at end of file diff --git a/sample/EnhanceSampleArk1.2/PageLoading/entry/src/main/resources/base/profile/main_pages.json b/sample/EnhanceSampleArk1.2/PageLoading/entry/src/main/resources/base/profile/main_pages.json new file mode 100644 index 0000000000000000000000000000000000000000..1898d94f58d6128ab712be2c68acc7c98e9ab9ce --- /dev/null +++ b/sample/EnhanceSampleArk1.2/PageLoading/entry/src/main/resources/base/profile/main_pages.json @@ -0,0 +1,5 @@ +{ + "src": [ + "pages/Index" + ] +} diff --git a/sample/EnhanceSampleArk1.2/PageLoading/entry/src/main/resources/dark/element/color.json b/sample/EnhanceSampleArk1.2/PageLoading/entry/src/main/resources/dark/element/color.json new file mode 100644 index 0000000000000000000000000000000000000000..79b11c2747aec33e710fd3a7b2b3c94dd9965499 --- /dev/null +++ b/sample/EnhanceSampleArk1.2/PageLoading/entry/src/main/resources/dark/element/color.json @@ -0,0 +1,8 @@ +{ + "color": [ + { + "name": "start_window_background", + "value": "#000000" + } + ] +} \ No newline at end of file diff --git a/sample/EnhanceSampleArk1.2/PageLoading/entry/src/ohosTest/ets/test/Ability.test.ets b/sample/EnhanceSampleArk1.2/PageLoading/entry/src/ohosTest/ets/test/Ability.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..dd5460b73720d4e0d41ecb70bc1cb8ad13837b3c --- /dev/null +++ b/sample/EnhanceSampleArk1.2/PageLoading/entry/src/ohosTest/ets/test/Ability.test.ets @@ -0,0 +1,67 @@ +'use static' +/* + * Copyright (c) 2025 Huawei Device 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 { describe, it, expect } from '@ohos/hypium'; +import AbilityDelegatorRegistry from '@ohos.app.ability.abilityDelegatorRegistry'; +import { Driver, ON } from '@ohos.UiTest'; +import { logger } from '../utils/logger'; + +const BUNDLE: string = 'PageLoading'; +const TAG: string = '[PageLoading_Test]'; + +export default function abilityTest() { + describe('ActsAbilityTest', () => { + + /** + * 打开应用 + */ + it(BUNDLE + '_StartAbility', 0.0, async (done: Function) => { + logger.info(TAG, BUNDLE + '_StartAbility start'); + let abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator(); + try { + await abilityDelegator.startAbility({ + bundleName: 'com.samples.pageloading', + abilityName: 'EntryAbility' + }); + } catch (exception) { + logger.error(TAG, BUNDLE + '_StartAbility error'); + expect().assertFail(); + } + logger.info(TAG, BUNDLE + '_StartAbility end'); + done.unsafeCall(); + }) + + /** + * 页面加载效果实现案例只能断言页面加载后的列表是否正常滚动和展示(加载lottie动画需手工用例进行测试) + */ + it(BUNDLE, 0.0, async (done: Function) => { + let driver = Driver.create(); + + await driver.delayMs((5000.0).toInt()); // 进度条加载耗时 + + const loadProgressHide = await driver.findComponent(ON.id('loadingHUD')); + expect(loadProgressHide).assertEqual(null); // 断言界面数据正在加载完成并消失 + + await driver.assertComponentExist(ON.id('commodity_list')); // 断言数据列表加载成功 + await driver.swipe((200.0).toInt().toInt(), (1500.0).toInt().toInt(), (200.0).toInt(), (100.0).toInt().toInt(), (2200.0).toInt().toInt()); // 向上滑动 + await driver.delayMs((1000.0).toInt()); + const isScroll = await (await driver.findComponent(ON.id('commodity_list'))).isScrollable(); + expect(isScroll).assertEqual(true); // 断言商品列表可滚动 + + done.unsafeCall(); + }) + }) +} \ No newline at end of file diff --git a/sample/EnhanceSampleArk1.2/PageLoading/entry/src/ohosTest/ets/test/List.test.ets b/sample/EnhanceSampleArk1.2/PageLoading/entry/src/ohosTest/ets/test/List.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..f89c252313b624e271f55bb143a3e815afc26571 --- /dev/null +++ b/sample/EnhanceSampleArk1.2/PageLoading/entry/src/ohosTest/ets/test/List.test.ets @@ -0,0 +1,21 @@ +'use static' +/* + * Copyright (c) 2025 Huawei Device 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 abilityTest from './Ability.test'; + +export default function testsuite() { + abilityTest(); +} \ No newline at end of file diff --git a/sample/EnhanceSampleArk1.2/PageLoading/entry/src/ohosTest/ets/utils/logger.ets b/sample/EnhanceSampleArk1.2/PageLoading/entry/src/ohosTest/ets/utils/logger.ets new file mode 100644 index 0000000000000000000000000000000000000000..eb76ca7ee54f0c5b6a02a1f83462f51d0d12f46e --- /dev/null +++ b/sample/EnhanceSampleArk1.2/PageLoading/entry/src/ohosTest/ets/utils/logger.ets @@ -0,0 +1,50 @@ +'use static' +/* + * Copyright (c) 2025 Huawei Device 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 hilog from '@ohos.hilog'; + +/** + * 日志打印类 + */ +class Logger { + private domain: number; + private prefix: string; + private format: string = '%{public}s, %{public}s'; + + constructor(prefix: string) { + this.prefix = prefix; + this.domain = 0xFF00; + this.format.toUpperCase(); + } + + debug(...args: string[]) { + hilog.debug(this.domain, this.prefix, this.format, args); + } + + info(...args: string[]) { + hilog.info(this.domain, this.prefix, this.format, args); + } + + warn(...args: string[]) { + hilog.warn(this.domain, this.prefix, this.format, args); + } + + error(...args: string[]) { + hilog.error(this.domain, this.prefix, this.format, args); + } +} + +export let logger = new Logger('[CommonAppDevelopment]') \ No newline at end of file diff --git a/sample/EnhanceSampleArk1.2/PageLoading/entry/src/ohosTest/module.json5 b/sample/EnhanceSampleArk1.2/PageLoading/entry/src/ohosTest/module.json5 new file mode 100644 index 0000000000000000000000000000000000000000..c3fd9dda3040d888d9d8b0b62bcb5d3b6fbeb614 --- /dev/null +++ b/sample/EnhanceSampleArk1.2/PageLoading/entry/src/ohosTest/module.json5 @@ -0,0 +1,27 @@ +/* + * Copyright (c) 2025 Huawei Device 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. + */ + +{ + "module": { + "name": "entry_test", + "type": "feature", + "deviceTypes": [ + "default", + "tablet" + ], + "deliveryWithInstall": true, + "installationFree": false + } +} diff --git a/sample/EnhanceSampleArk1.2/PageLoading/entry/src/test/List.test.ets b/sample/EnhanceSampleArk1.2/PageLoading/entry/src/test/List.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..0f183d30893443cdbc4b23cb4c683b2e89185d4e --- /dev/null +++ b/sample/EnhanceSampleArk1.2/PageLoading/entry/src/test/List.test.ets @@ -0,0 +1,21 @@ +'use static' +/* + * Copyright (c) 2025 Huawei Device 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 localUnitTest from './LocalUnit.test'; + +export default function testsuite() { + localUnitTest(); +} \ No newline at end of file diff --git a/sample/EnhanceSampleArk1.2/PageLoading/entry/src/test/LocalUnit.test.ets b/sample/EnhanceSampleArk1.2/PageLoading/entry/src/test/LocalUnit.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..6a9f26d3208b50c31a0314bf868952f661b0d2b9 --- /dev/null +++ b/sample/EnhanceSampleArk1.2/PageLoading/entry/src/test/LocalUnit.test.ets @@ -0,0 +1,49 @@ +'use static' +/* + * Copyright (c) 2025 Huawei Device 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 { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium'; + +export default function localUnitTest() { + describe('localUnitTest', () => { + // Defines a test suite. Two parameters are supported: test suite name and test suite function. + beforeAll(() => { + // Presets an action, which is performed only once before all test cases of the test suite start. + // This API supports only one parameter: preset action function. + }); + beforeEach(() => { + // Presets an action, which is performed before each unit test case starts. + // The number of execution times is the same as the number of test cases defined by **it**. + // This API supports only one parameter: preset action function. + }); + afterEach(() => { + // Presets a clear action, which is performed after each unit test case ends. + // The number of execution times is the same as the number of test cases defined by **it**. + // This API supports only one parameter: clear action function. + }); + afterAll(() => { + // Presets a clear action, which is performed after all test cases of the test suite end. + // This API supports only one parameter: clear action function. + }); + it('assertContain', 0.0, () => { + // Defines a test case. This API supports three parameters: test case name, filter parameter, and test case function. + let a = 'abc'; + let b = 'b'; + // Defines a variety of assertion methods, which are used to declare expected boolean conditions. + expect(a).assertContain(b); + expect(a).assertEqual(a); + }); + }); +} \ No newline at end of file diff --git a/sample/EnhanceSampleArk1.2/PageLoading/hvigor/hvigor-config.json5 b/sample/EnhanceSampleArk1.2/PageLoading/hvigor/hvigor-config.json5 new file mode 100644 index 0000000000000000000000000000000000000000..7a7ab8914d8db6ab89758e185df5855dffe88d04 --- /dev/null +++ b/sample/EnhanceSampleArk1.2/PageLoading/hvigor/hvigor-config.json5 @@ -0,0 +1,23 @@ +{ + "modelVersion": "6.0.0", + "dependencies": { + }, + "execution": { + // "analyze": "normal", /* Define the build analyze mode. Value: [ "normal" | "advanced" | "ultrafine" | 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 */ + // "optimizationStrategy": "memory" /* Define the optimization strategy. Value: [ "memory" | "performance" ]. Default: "memory" */ + }, + "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*/ + } +} diff --git a/sample/EnhanceSampleArk1.2/PageLoading/hvigorfile.ts b/sample/EnhanceSampleArk1.2/PageLoading/hvigorfile.ts new file mode 100644 index 0000000000000000000000000000000000000000..47113e2e36ecefde41c136272a0bd6ff745cffe4 --- /dev/null +++ b/sample/EnhanceSampleArk1.2/PageLoading/hvigorfile.ts @@ -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. */ +} \ No newline at end of file diff --git a/sample/EnhanceSampleArk1.2/PageLoading/oh-package-lock.json5 b/sample/EnhanceSampleArk1.2/PageLoading/oh-package-lock.json5 new file mode 100644 index 0000000000000000000000000000000000000000..5228468e42bf0223ddadb188bf2763b4afdb28e6 --- /dev/null +++ b/sample/EnhanceSampleArk1.2/PageLoading/oh-package-lock.json5 @@ -0,0 +1,28 @@ +{ + "meta": { + "stableOrder": true, + "enableUnifiedLockfile": false + }, + "lockfileVersion": 3, + "ATTENTION": "THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.", + "specifiers": { + "@ohos/hamock@1.0.0": "@ohos/hamock@1.0.0", + "@ohos/hypium@1.0.19": "@ohos/hypium@1.0.19" + }, + "packages": { + "@ohos/hamock@1.0.0": { + "name": "@ohos/hamock", + "version": "1.0.0", + "integrity": "sha512-K6lDPYc6VkKe6ZBNQa9aoG+ZZMiwqfcR/7yAVFSUGIuOAhPvCJAo9+t1fZnpe0dBRBPxj2bxPPbKh69VuyAtDg==", + "resolved": "https://ohpm.openharmony.cn/ohpm/@ohos/hamock/-/hamock-1.0.0.har", + "registryType": "ohpm" + }, + "@ohos/hypium@1.0.19": { + "name": "@ohos/hypium", + "version": "1.0.19", + "integrity": "sha512-cEjDgLFCm3cWZDeRXk7agBUkPqjWxUo6AQeiu0gEkb3J8ESqlduQLSIXeo3cCsm8U/asL7iKjF85ZyOuufAGSQ==", + "resolved": "https://ohpm.openharmony.cn/ohpm/@ohos/hypium/-/hypium-1.0.19.har", + "registryType": "ohpm" + } + } +} \ No newline at end of file diff --git a/sample/EnhanceSampleArk1.2/PageLoading/oh-package.json5 b/sample/EnhanceSampleArk1.2/PageLoading/oh-package.json5 new file mode 100644 index 0000000000000000000000000000000000000000..55dde11e8f90e502327a7cac24bab7c692cdf069 --- /dev/null +++ b/sample/EnhanceSampleArk1.2/PageLoading/oh-package.json5 @@ -0,0 +1,10 @@ +{ + "modelVersion": "6.0.0", + "description": "Please describe the basic information.", + "dependencies": { + }, + "devDependencies": { + "@ohos/hypium": "1.0.19", + "@ohos/hamock": "1.0.0" + } +} diff --git a/sample/EnhanceSampleArk1.2/PageLoading/ohosTest.md b/sample/EnhanceSampleArk1.2/PageLoading/ohosTest.md new file mode 100644 index 0000000000000000000000000000000000000000..b7a9cd827314cd54be205d700698c6e57a0513b9 --- /dev/null +++ b/sample/EnhanceSampleArk1.2/PageLoading/ohosTest.md @@ -0,0 +1,8 @@ +# 页面加载效果实现案例测试用例 + +## 用例表 + +| 测试功能 | 预置条件 | 输入 | 预期输出 | 是否自动 | 测试结果 | +|--------------|---------------------------|---------------|-----------------------------------------------------|------|------| +| 访问【页面加载效果实现案例】 | 启动【页面加载效果实现案例】 | 访问【页面加载效果实现案例】 | 进入会出现【页面加载效果实现案例】页面,先出现lottie记载动画,加载完成后消失,页面数据成功加载。 | 是 | Pass | +| 列表加载正常 | 启动【页面加载效果实现案例】 | 向上滑动 | 页面正常加载,无卡顿 | 是 | Pass | diff --git a/sample/EnhanceSampleArk1.2/PageLoading/pageloading/.gitignore b/sample/EnhanceSampleArk1.2/PageLoading/pageloading/.gitignore new file mode 100644 index 0000000000000000000000000000000000000000..e2713a2779c5a3e0eb879efe6115455592caeea5 --- /dev/null +++ b/sample/EnhanceSampleArk1.2/PageLoading/pageloading/.gitignore @@ -0,0 +1,6 @@ +/node_modules +/oh_modules +/.preview +/build +/.cxx +/.test \ No newline at end of file diff --git a/sample/EnhanceSampleArk1.2/PageLoading/pageloading/Index.ets b/sample/EnhanceSampleArk1.2/PageLoading/pageloading/Index.ets new file mode 100644 index 0000000000000000000000000000000000000000..ff959a0b11b1ca0f883d7a55e531b8492f216e9f --- /dev/null +++ b/sample/EnhanceSampleArk1.2/PageLoading/pageloading/Index.ets @@ -0,0 +1,17 @@ +'use static' +/* + * Copyright (c) 2025 Huawei Device 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. + */ + +export { PageLoadingComponent } from './src/main/ets/view/PageLoading'; diff --git a/sample/EnhanceSampleArk1.2/PageLoading/pageloading/build-profile.json5 b/sample/EnhanceSampleArk1.2/PageLoading/pageloading/build-profile.json5 new file mode 100644 index 0000000000000000000000000000000000000000..315f414afe40e533b4959a9576f1c04e2399a985 --- /dev/null +++ b/sample/EnhanceSampleArk1.2/PageLoading/pageloading/build-profile.json5 @@ -0,0 +1,47 @@ +/* + * Copyright (c) 2025 Huawei Device 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. + */ + +{ + "apiType": "stageMode", + "arkTSVersion": "1.2", + "buildOption": { + }, + "buildOptionSet": [ + { + "name": "release", + "arkOptions": { + "obfuscation": { + "ruleOptions": { + "enable": false, + "files": [ + "./obfuscation-rules.txt" + ] + }, + "consumerFiles": [ + "./consumer-rules.txt" + ] + } + }, + }, + ], + "targets": [ + { + "name": "default" + }, + { + "name": "ohosTest" + } + ] +} diff --git a/sample/EnhanceSampleArk1.2/PageLoading/pageloading/consumer-rules.txt b/sample/EnhanceSampleArk1.2/PageLoading/pageloading/consumer-rules.txt new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/sample/EnhanceSampleArk1.2/PageLoading/pageloading/hvigorfile.ts b/sample/EnhanceSampleArk1.2/PageLoading/pageloading/hvigorfile.ts new file mode 100644 index 0000000000000000000000000000000000000000..0785a511e1f806573e5208d382645d48719a0f06 --- /dev/null +++ b/sample/EnhanceSampleArk1.2/PageLoading/pageloading/hvigorfile.ts @@ -0,0 +1,21 @@ +/* + * Copyright (c) 2025 Huawei Device 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 { harTasks } from '@ohos/hvigor-ohos-plugin'; + +export default { + system: harTasks, /* Built-in plugin of Hvigor. It cannot be modified. */ + plugins:[] /* Custom plugin to extend the functionality of Hvigor. */ +} diff --git a/sample/EnhanceSampleArk1.2/PageLoading/pageloading/obfuscation-rules.txt b/sample/EnhanceSampleArk1.2/PageLoading/pageloading/obfuscation-rules.txt new file mode 100644 index 0000000000000000000000000000000000000000..272efb6ca3f240859091bbbfc7c5802d52793b0b --- /dev/null +++ b/sample/EnhanceSampleArk1.2/PageLoading/pageloading/obfuscation-rules.txt @@ -0,0 +1,23 @@ +# Define project specific obfuscation rules here. +# You can include the obfuscation configuration files in the current module's build-profile.json5. +# +# For more details, see +# https://developer.huawei.com/consumer/cn/doc/harmonyos-guides-V5/source-obfuscation-V5 + +# Obfuscation options: +# -disable-obfuscation: disable all obfuscations +# -enable-property-obfuscation: obfuscate the property names +# -enable-toplevel-obfuscation: obfuscate the names in the global scope +# -compact: remove unnecessary blank spaces and all line feeds +# -remove-log: remove all console.* statements +# -print-namecache: print the name cache that contains the mapping from the old names to new names +# -apply-namecache: reuse the given cache file + +# Keep options: +# -keep-property-name: specifies property names that you want to keep +# -keep-global-name: specifies names that you want to keep in the global scope + +-enable-property-obfuscation +-enable-toplevel-obfuscation +-enable-filename-obfuscation +-enable-export-obfuscation \ No newline at end of file diff --git a/sample/EnhanceSampleArk1.2/PageLoading/pageloading/oh-package-lock.json5 b/sample/EnhanceSampleArk1.2/PageLoading/pageloading/oh-package-lock.json5 new file mode 100644 index 0000000000000000000000000000000000000000..9a1a02f84b921eb21507e9e20b936e777122dd7b --- /dev/null +++ b/sample/EnhanceSampleArk1.2/PageLoading/pageloading/oh-package-lock.json5 @@ -0,0 +1,20 @@ +{ + "meta": { + "stableOrder": true, + "enableUnifiedLockfile": false + }, + "lockfileVersion": 3, + "ATTENTION": "THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.", + "specifiers": { + "@ohos/lottie@2.0.0": "@ohos/lottie@2.0.0" + }, + "packages": { + "@ohos/lottie@2.0.0": { + "name": "@ohos/lottie", + "version": "2.0.0", + "integrity": "sha512-jFEFYfuqGO323aMiwtzHmDGRJI0qTxjZD2Lzbn+LxRdoHSfu5OVu22I8gVm5ej019tCw3WOk547NHZ2GuWiNSg==", + "resolved": "https://ohpm.openharmony.cn/ohpm/@ohos/lottie/-/lottie-2.0.0.har", + "registryType": "ohpm" + } + } +} \ No newline at end of file diff --git a/sample/EnhanceSampleArk1.2/PageLoading/pageloading/oh-package.json5 b/sample/EnhanceSampleArk1.2/PageLoading/pageloading/oh-package.json5 new file mode 100644 index 0000000000000000000000000000000000000000..37a34245bc90dff2b30743cc6588afa68f8e4469 --- /dev/null +++ b/sample/EnhanceSampleArk1.2/PageLoading/pageloading/oh-package.json5 @@ -0,0 +1,27 @@ +/* + * Copyright (c) 2025 Huawei Device 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": "pageloading", + "version": "1.0.0", + "description": "Please describe the basic information.", + "main": "Index.ets", + "author": "", + "license": "Apache-2.0", + "dependencies": { + // Lottie模块 + "@ohos/lottie": "2.0.0" + } +} diff --git a/sample/EnhanceSampleArk1.2/PageLoading/pageloading/src/main/ets/mock/CommodityMock.ets b/sample/EnhanceSampleArk1.2/PageLoading/pageloading/src/main/ets/mock/CommodityMock.ets new file mode 100644 index 0000000000000000000000000000000000000000..010abe387cdc946936d5ed500eec433782fe7128 --- /dev/null +++ b/sample/EnhanceSampleArk1.2/PageLoading/pageloading/src/main/ets/mock/CommodityMock.ets @@ -0,0 +1,42 @@ +'use static' +/* + * Copyright (c) 2025 Huawei Device 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 { CommodityDataModel } from '../model/CommodityDataModel'; +import { $r } from '@ohos.arkui.component'; + +/** + * 商品列表数据源 + */ +export const PRODUCTS_DATA: CommodityDataModel[] = [ + new CommodityDataModel(0.0, $r('app.media.page_loading_commodity00'), $r('app.string.page_loading_commodity_title00'), + $r('app.string.page_loading_commodity_price00'), $r('app.string.page_loading_commodity_view00'), + $r('app.string.page_loading_commodity_insurance00')), + new CommodityDataModel(1.0, $r('app.media.page_loading_commodity01'), $r('app.string.page_loading_commodity_title01'), + $r('app.string.page_loading_commodity_price01'), $r('app.string.page_loading_commodity_view01'), + $r('app.string.page_loading_commodity_insurance01')), + new CommodityDataModel(2.0, $r('app.media.page_loading_commodity02'), $r('app.string.page_loading_commodity_title02'), + $r('app.string.page_loading_commodity_price02'), $r('app.string.page_loading_commodity_view02'), + $r('app.string.page_loading_commodity_insurance02')), + new CommodityDataModel(3.0, $r('app.media.page_loading_commodity03'), $r('app.string.page_loading_commodity_title03'), + $r('app.string.page_loading_commodity_price03'), $r('app.string.page_loading_commodity_view03'), + $r('app.string.page_loading_commodity_insurance03')), + new CommodityDataModel(4.0, $r('app.media.page_loading_commodity04'), $r('app.string.page_loading_commodity_title04'), + $r('app.string.page_loading_commodity_price04'), $r('app.string.page_loading_commodity_view04'), + $r('app.string.page_loading_commodity_insurance04')), + new CommodityDataModel(5.0, $r('app.media.page_loading_commodity05'), $r('app.string.page_loading_commodity_title05'), + $r('app.string.page_loading_commodity_price05'), $r('app.string.page_loading_commodity_view05'), + $r('app.string.page_loading_commodity_insurance05')) +]; \ No newline at end of file diff --git a/sample/EnhanceSampleArk1.2/PageLoading/pageloading/src/main/ets/model/CommodityDataModel.ets b/sample/EnhanceSampleArk1.2/PageLoading/pageloading/src/main/ets/model/CommodityDataModel.ets new file mode 100644 index 0000000000000000000000000000000000000000..0ec8e3c2b288a9e1f970f50b7390535ab2e5c226 --- /dev/null +++ b/sample/EnhanceSampleArk1.2/PageLoading/pageloading/src/main/ets/model/CommodityDataModel.ets @@ -0,0 +1,47 @@ +'use static' +/* + * Copyright (c) 2025 Huawei Device 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 { Observed } from '@kit.ArkUI'; + +import { ResourceStr } from '@kit.ArkUI'; + +@Observed +export class CommodityDataModel { + public id: number; + public uri: ResourceStr; + public title: ResourceStr; + public price: ResourceStr; + public views: ResourceStr; + public insurance: ResourceStr; + + constructor(id: number, uri: ResourceStr, title: ResourceStr, price: ResourceStr, views: ResourceStr, + insurance: ResourceStr) { + this.id = id; + this.uri = uri; + this.title = title; + this.price = price; + this.views = views; + this.insurance = insurance; + } + + toString(): string { + return this.id.toString() + ' ' + this.title; + } +} \ No newline at end of file diff --git a/sample/EnhanceSampleArk1.2/PageLoading/pageloading/src/main/ets/model/CommodityDataSource.ets b/sample/EnhanceSampleArk1.2/PageLoading/pageloading/src/main/ets/model/CommodityDataSource.ets new file mode 100644 index 0000000000000000000000000000000000000000..69dfae3877217dde6b60a4dc0593686a4f21b742 --- /dev/null +++ b/sample/EnhanceSampleArk1.2/PageLoading/pageloading/src/main/ets/model/CommodityDataSource.ets @@ -0,0 +1,139 @@ +'use static' +/* + * Copyright (c) 2025 Huawei Device 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 { + IDataSource, + DataChangeListener, +} from '@kit.ArkUI'; + +import { logger } from '../utils/logger'; + +import { CommodityDataModel } from './CommodityDataModel'; + +/** + * Basic implementation of IDataSource to handle data listener + */ +export class BasicDataSource implements IDataSource { + // 数据变化监听器 + private listeners: DataChangeListener[] = []; + private tList: T[] = []; + + /** + * 获取数据的长度 + */ + public totalCount(): number { + return 0.0; + } + + /** + * 获取指定数据项 + */ + public getData(index: number): T { + return this.tList[index as int]; + } + + /** + * 存储数据到懒加载数据源中 + */ + pushData(data: T[]): void { + this.tList.push(...data); + this.notifyDataAdd(this.tList.length - 1.0); + } + + /** + * 该方法为框架侧调用,为LazyForEach组件向其数据源处添加listener监听 + */ + registerDataChangeListener(listener: DataChangeListener): void { + if (this.listeners.indexOf(listener) < 0.0) { + logger.info('add listener'); + this.listeners.push(listener); + } + } + + /** + * 该方法为框架侧调用,为对应的LazyForEach组件在数据源处去除listener监听 + */ + unregisterDataChangeListener(listener: DataChangeListener): void { + const pos: number = this.listeners.indexOf(listener); + if (pos >= 0.0) { + logger.info('remove listener'); + this.listeners.splice(pos, 1.0); + } + } + + /** + * 通知LazyForEach组件需要重载所有子组件 + */ + notifyDataReload(): void { + this.listeners.forEach(listener => { + listener.onDataReloaded(); + }) + } + + /** + * 通知LazyForEach组件需要在index对应索引处添加子组件 + */ + notifyDataAdd(index: number): void { + this.listeners.forEach(listener => { + listener.onDataAdd(index); + }) + } + + /** + * 通知LazyForEach组件在index对应索引处数据有变化,需要重建该子组件 + */ + notifyDataChange(index: number): void { + this.listeners.forEach(listener => { + listener.onDataChange(index); + }) + } + + /** + * 通知LazyForEach组件需要在index对应索引处删除该子组件 + */ + notifyDataDelete(index: number): void { + this.listeners.forEach(listener => { + listener.onDataDelete(index); + }) + } +} + +export class CommodityDataSource extends BasicDataSource { + // 懒加载数据 + private commodityList: CommodityDataModel[] = [] + + /** + * 获取懒加载数据源的数据长度 + */ + totalCount(): number { + return this.commodityList.length; + } + + /** + * 获取指定数据项 + */ + getData(index: number): CommodityDataModel { + return this.commodityList[index as int]; + } + + /** + * 存储数据到懒加载数据源中 + */ + pushData(data: CommodityDataModel[]): void { + this.commodityList.push(...data); + this.notifyDataAdd(this.commodityList.length - 1.0); + } +} \ No newline at end of file diff --git a/sample/EnhanceSampleArk1.2/PageLoading/pageloading/src/main/ets/utils/logger.ets b/sample/EnhanceSampleArk1.2/PageLoading/pageloading/src/main/ets/utils/logger.ets new file mode 100644 index 0000000000000000000000000000000000000000..524d8c05680bf1b7cd7bfbaecac9ce421ae13f1c --- /dev/null +++ b/sample/EnhanceSampleArk1.2/PageLoading/pageloading/src/main/ets/utils/logger.ets @@ -0,0 +1,50 @@ +'use static' +/* + * Copyright (c) 2025 Huawei Device 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 hilog from '@ohos.hilog'; + +/** + * 日志打印类 + */ +class Logger { + private domain: int; + private prefix: string; + private format: string = '%{public}s, %{public}s'; + + constructor(prefix: string) { + this.prefix = prefix; + this.domain = 0xFF00; + this.format.toUpperCase(); + } + + debug(...args: string[]) { + hilog.debug(this.domain, this.prefix, this.format, args); + } + + info(...args: string[]) { + hilog.info(this.domain, this.prefix, this.format, args); + } + + warn(...args: string[]) { + hilog.warn(this.domain, this.prefix, this.format, args); + } + + error(...args: string[]) { + hilog.error(this.domain, this.prefix, this.format, args); + } +} + +export let logger = new Logger('[Samples_pageloading]'); \ No newline at end of file diff --git a/sample/EnhanceSampleArk1.2/PageLoading/pageloading/src/main/ets/view/CommodityList.ets b/sample/EnhanceSampleArk1.2/PageLoading/pageloading/src/main/ets/view/CommodityList.ets new file mode 100644 index 0000000000000000000000000000000000000000..459cd9b83fdb7c8aaad2f5159f51133960f5a21a --- /dev/null +++ b/sample/EnhanceSampleArk1.2/PageLoading/pageloading/src/main/ets/view/CommodityList.ets @@ -0,0 +1,203 @@ +'use static' +/* + * Copyright (c) 2025 Huawei Device 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 { + Component, + Column, + Image, + ImageFit, + Text, + Color, + FontWeight, + TextAlign, + List, + LazyForEach, + ListItem, + RelativeContainer, + VerticalAlign, + HorizontalAlign, + Row, + FlexAlign, + Padding, + Margin, + ShadowOptions, + $r, +} from '@kit.ArkUI'; + +import { PRODUCTS_DATA } from '../mock/CommodityMock'; +import { CommodityDataModel } from '../model/CommodityDataModel'; +import { CommodityDataSource } from '../model/CommodityDataSource'; +import { Position } from '@ohos.arkui.component'; +import { UIContext } from '@ohos.arkui.UIContext'; + +const IMAGE_ASPECT_RATIO: number = 1.0; // 图片的宽高比 +const OFFSET: number = -4.0; // 价格控件偏移量 +const OFFSETX: number = 10.0; // banner阴影X轴偏移量 +const OFFSETY: number = 10.0; // banner阴影Y轴偏移量 +const LAYOUT_WEIGHT: number = 1.0; // 分配剩余空间 +const ANGLE: number = 180.0; // 自上而下渐变 + +@Component +export struct CommodityList { + private commodityData: CommodityDataSource = new CommodityDataSource(); + + aboutToAppear() { + this.commodityData.pushData(PRODUCTS_DATA) + } + + build() { + Column() { + Column() { + Image($r('app.media.page_loading_light_mode_banner')) + .objectFit(ImageFit.Contain) + .borderRadius($r('app.integer.page_loading_banner_border_radius')) + .margin({ top: $r('app.integer.page_loading_banner_margin_top') } as Margin) + .width('100%') + .shadow({ + radius: $r('app.integer.page_loading_banner_shadow_border_radius'), + color: $r('app.color.page_loading_banner_shadow_color'), + offsetX: OFFSETX, + offsetY: OFFSETY + } as ShadowOptions) + + Text($r('app.string.page_loading_goods_title_text')) + .fontColor(Color.Black) + .fontSize($r('app.integer.page_loading_commodity_font')) + .fontWeight(FontWeight.Bold) + .height($r('app.integer.page_loading_new_commodity_height')) + .width('100%') + .textAlign(TextAlign.Center) + } + .padding({ left: $r('app.integer.page_loading_column_padding_left'), right: $r('app.integer.page_loading_column_padding_right') } as Padding) + .backgroundColor(Color.White) + + List() { + LazyForEach(this.commodityData, (item: CommodityDataModel) => { + ListItem() { + ItemView({ item: item }) + } + .padding({ + left: $r('app.integer.page_loading_commodity_list_item_padding'), + right: $r('app.integer.page_loading_commodity_list_item_padding') + } as Padding) + .margin({ top: $r('app.integer.page_loading_commodity_list_item_margin_top') } as Margin) + }, (item: CommodityDataModel) => item.id.toString()) + } + .id('commodity_list') + .width('100%') + .layoutWeight(LAYOUT_WEIGHT) + } + // 设置背景颜色渐变 + .linearGradient({ + angle: ANGLE, + colors: [[0xFFFFFF, 0.0], [0xdddddd, 1.0]] + }) + } +} + +@Component +struct ItemView { + item: CommodityDataModel = new CommodityDataModel(0.0, '', '', '', '', ''); + + build() { + // TODO: 知识点:相对布局组件,用于复杂场景中元素对齐的布局,容器内子组件区分水平方向,垂直方向子组件可以将容器或者其他子组件设为锚点。 + RelativeContainer() { + Image(this.item.uri) + .width($r('app.integer.page_loading_commodity_image_width')) + .aspectRatio(IMAGE_ASPECT_RATIO) + .objectFit(ImageFit.Contain) + .padding({ + top: $r('app.integer.page_loading_commodity_image_padding_top'), + bottom: $r('app.integer.page_loading_commodity_image_padding_bottom') + } as Padding) + .alignRules({ + top: { anchor: '__container__', align: VerticalAlign.Top }, + left: { anchor: '__container__', align: HorizontalAlign.Start } + }) + .id('image') + + Text(this.item.insurance) + .fontSize($r('app.integer.page_loading_commodity_insurance_font_size')) + .fontColor($r('app.color.page_loading_goods_insurance_text_color')) + .borderColor($r('app.color.page_loading_goods_insurance_border_color')) + .borderWidth($r('app.integer.page_loading_commodity_insurance_border_width')) + .borderRadius($r('app.integer.page_loading_commodity_insurance_border_radius')) + .padding({ + left: $r('app.integer.page_loading_commodity_insurance_padding_left'), + right: $r('app.integer.page_loading_commodity_insurance_padding_right'), + top: $r('app.integer.page_loading_commodity_insurance_padding_top'), + bottom: $r('app.integer.page_loading_commodity_insurance_padding_bottom') + } as Padding) + .margin({ right: $r('app.integer.page_loading_commodity_insurance_margin_right') } as Margin) + .alignRules({ + right: { anchor: '__container__', align: HorizontalAlign.End }, + center: { anchor: '__container__', align: VerticalAlign.Center } + }) + .id('insurance') + + Row() { + Image($r('app.media.page_loading_views')) + .width($r('app.integer.page_loading_views_image_width')) + .aspectRatio(IMAGE_ASPECT_RATIO) + .objectFit(ImageFit.Contain) + + Text(this.item.views) + .fontSize($r('app.integer.page_loading_views_font')) + .margin({ left: $r('app.integer.page_loading_views_margin_left') } as Margin) + .fontColor(Color.Black) + } + .height($r('app.integer.page_loading_views_height')) + .width($r('app.integer.page_loading_views_width')) + .margin({ top: $r('app.integer.page_loading_views_margin_top') } as Margin) + .justifyContent(FlexAlign.End) + .alignRules({ + middle: { anchor: 'insurance', align: HorizontalAlign.Center }, + top: { anchor: 'insurance', align: VerticalAlign.Bottom } + }) + .id('views') + + Column() { + Text(this.item.title) + .fontSize($r('app.integer.page_loading_commodity_title_text_font_size')) + .fontWeight(FontWeight.Bold) + .fontColor(Color.Black) + .width('100%') + + Text(this.item.price) + .fontSize($r('app.integer.page_loading_commodity_price_text_font_size')) + .fontWeight(FontWeight.Bold) + .offset({ x: OFFSET } as Position)// 因为¥是中文字符,上面的是中文字符,占的宽度不一样,所以需要对齐,添加offset + .fontColor($r('app.color.page_loading_goods_price_text_color')) + .margin({ top: $r('app.integer.page_loading_commodity_price_margin_top') } as Margin) + .width('100%') + } + .justifyContent(FlexAlign.Start) + .alignRules({ + left: { anchor: 'image', align: HorizontalAlign.End }, + right: { anchor: 'insurance', align: HorizontalAlign.Start }, + center: { anchor: 'image', align: VerticalAlign.Center } + }) + .id('column') + .onClick((): void => { + this.getUIContext().getPromptAction().showToast({ message: $r('app.string.page_loading_commodity_other_function') }); + }) + } + .height($r('app.integer.page_loading_commodity_list_item_height')) + .borderRadius($r('app.integer.page_loading_commodity_border_radius')) + .width('100%') + .backgroundColor(Color.White) + } +} \ No newline at end of file diff --git a/sample/EnhanceSampleArk1.2/PageLoading/pageloading/src/main/ets/view/LoadingHUD.ets b/sample/EnhanceSampleArk1.2/PageLoading/pageloading/src/main/ets/view/LoadingHUD.ets new file mode 100644 index 0000000000000000000000000000000000000000..1ea47d4ffd25b8da7d25131451ee7de3833b8bd4 --- /dev/null +++ b/sample/EnhanceSampleArk1.2/PageLoading/pageloading/src/main/ets/view/LoadingHUD.ets @@ -0,0 +1,98 @@ +'use static' +/* + * Copyright (c) 2025 Huawei Device 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 { + Component, + Link, + CanvasRenderingContext2D, + LinearGradient, + Color, + Column, + Stack, + Canvas, + Row, + Progress, + ProgressType, + Text, + FlexAlign, + Margin, + ProgressStyleOptions, + $r, +} from '@kit.ArkUI'; + +// import lottie from '@ohos/lottie'; + +/** + * HUD全称Heads-Up Display(抬头显示) + */ + +@Component +export struct LoadingHUD { + @Link nowProgress: number; + private politeChickyController: CanvasRenderingContext2D = + new CanvasRenderingContext2D(); // CanvasRenderingContext2D对象 + private politeChicky: string = 'pageLoading'; // 动画名称 + private politeChickyPath: string = 'common/lottie/pageLoading.json'; // hap包内动画资源文件路径,仅支持json格式 + private gradientColor: LinearGradient = new LinearGradient([{ color: Color.Yellow, offset: 0.5 }, + { color: Color.Orange, offset: 1.0 }]) + + /** + * 加载动画 + * @param autoplay 控制动画是否自动播放参数 + */ + initAnimation() { + // TODO:知识点:lottie.loadAnimation将json数据生成动画 + // lottie.loadAnimation({ + // container: this.politeChickyController, + // renderer: 'canvas', + // loop: true, + // autoplay: true, + // name: this.politeChicky, + // path: this.politeChickyPath, + // }) + } + + build() { + Column() { + Stack() { + Canvas(this.politeChickyController) + .width($r('app.integer.lottie_view_canvas_size')) + .height($r('app.integer.lottie_view_canvas_size')) + .borderRadius($r('app.string.page_loading_corner_radius_default_m')) + .onReady(() => { + // TODO:知识点:必须要Canvas组件初始化之后才能执行lottie.loadAnimation方法去加载动画。 + this.initAnimation(); + }) + Row() { + Progress({ value: this.nowProgress, total: 100.0, type: ProgressType.Linear }) + .style({ strokeWidth: 10.0, enableSmoothEffect: true } as ProgressStyleOptions) + .color(this.gradientColor) + } + .width('60%') + .margin({ top: $r('app.integer.lottie_view_canvas_height') } as Margin) + }.height($r('app.integer.lottie_view_canvas_size')) + + Text(`当前已加载${this.nowProgress}%`) + .fontSize($r('app.integer.page_loading_progress_font_size')) + .fontColor(Color.White) + } + .id('loadingHUD') + .width('100%') + .height('100%') + .backgroundColor($r('app.color.page_loading_progress_background')) + .justifyContent(FlexAlign.Center) + } +} \ No newline at end of file diff --git a/sample/EnhanceSampleArk1.2/PageLoading/pageloading/src/main/ets/view/PageLoading.ets b/sample/EnhanceSampleArk1.2/PageLoading/pageloading/src/main/ets/view/PageLoading.ets new file mode 100644 index 0000000000000000000000000000000000000000..3883a561adcaff4702fbc20627966c2830be6c6c --- /dev/null +++ b/sample/EnhanceSampleArk1.2/PageLoading/pageloading/src/main/ets/view/PageLoading.ets @@ -0,0 +1,72 @@ +'use static' +/* + * Copyright (c) 2025 Huawei Device 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 { + Component, + State, + Stack, + Color, +} from '@kit.ArkUI'; + +import { CommodityList } from './CommodityList'; +import { LoadingHUD } from './LoadingHUD'; + +/** + * 功能描述:本示例介绍Stack堆叠组件和LoadingProgress加载组件模拟首次进入页面实现页面加载的效果。加载完成后,LoadingProgress组件会消失并展示加载结果页(即商品页)。 + * + * 推荐场景:应用加载缓慢的页面,如商城页面首页等场景,为了提升用户点击响应的体验。 + * + * 核心组件: + * 1.LoadingHUD + * + * 实现步骤: + * 1.创建一个Stack组件,LoadingHUD是加载页,内部的GoodsList为商品列表页。 + * 2.进入页面首先展示LoadingHUD加载页,5秒后,LoadingHUD加载页消失且出现GoodsList商品列表页。 + */ + +const MILLISECONDS: int = 5000; // 毫秒数 + +@Component +export struct PageLoadingComponent { + @State isLoading: Boolean = true; + @State nowProgress: number = 0.0; + + aboutToAppear(): void { + // 模拟网络请求操作,请求网络3秒后得到数据,通知组件,变更列表数据 + setTimeout(() => { + this.isLoading = false; + }, MILLISECONDS); + //模拟进度,开发者可在实际业务中与服务端协调当前进度,自行实现 + setInterval(()=>{ + this.nowProgress += 10 + },MILLISECONDS / 10) + } + + build() { + Stack() { + if (this.isLoading) { + // 加载页-HUD全称Heads-Up Display(抬头显示) + LoadingHUD({nowProgress:this.nowProgress}); + } else { + // 商品页 + CommodityList(); + } + } + .width('100%') + .height('100%') + .backgroundColor(Color.White) + } +} \ No newline at end of file diff --git a/sample/EnhanceSampleArk1.2/PageLoading/pageloading/src/main/module.json5 b/sample/EnhanceSampleArk1.2/PageLoading/pageloading/src/main/module.json5 new file mode 100644 index 0000000000000000000000000000000000000000..7fdaa587523210550736973a7f0ca109d30ac7e9 --- /dev/null +++ b/sample/EnhanceSampleArk1.2/PageLoading/pageloading/src/main/module.json5 @@ -0,0 +1,24 @@ +/* + * Copyright (c) 2025 Huawei Device 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. + */ +{ + "module": { + "name": "pageloading", + "type": "har", + "deviceTypes": [ + "default", + "tablet" + ] + } +} \ No newline at end of file diff --git a/sample/EnhanceSampleArk1.2/PageLoading/pageloading/src/main/resources/base/element/color.json b/sample/EnhanceSampleArk1.2/PageLoading/pageloading/src/main/resources/base/element/color.json new file mode 100644 index 0000000000000000000000000000000000000000..d76ad48ce0f9ebb3db0c05dce54c0e6b25ecde11 --- /dev/null +++ b/sample/EnhanceSampleArk1.2/PageLoading/pageloading/src/main/resources/base/element/color.json @@ -0,0 +1,24 @@ +{ + "color": [ + { + "name": "page_loading_progress_background", + "value": "#40000000" + }, + { + "name": "page_loading_banner_shadow_color", + "value": "#AAAAAA" + }, + { + "name": "page_loading_goods_price_text_color", + "value": "#E84026" + }, + { + "name": "page_loading_goods_insurance_text_color", + "value": "#ED6F21" + }, + { + "name": "page_loading_goods_insurance_border_color", + "value": "#ED6F21" + } + ] +} \ No newline at end of file diff --git a/sample/EnhanceSampleArk1.2/PageLoading/pageloading/src/main/resources/base/element/integer.json b/sample/EnhanceSampleArk1.2/PageLoading/pageloading/src/main/resources/base/element/integer.json new file mode 100644 index 0000000000000000000000000000000000000000..ff31aec0080aa25a94269ab55fce50641c29c5b3 --- /dev/null +++ b/sample/EnhanceSampleArk1.2/PageLoading/pageloading/src/main/resources/base/element/integer.json @@ -0,0 +1,148 @@ +{ + "integer": [ + { + "name": "page_loading_progress_width", + "value": 80 + }, + { + "name": "page_loading_progress_height", + "value": 80 + }, + { + "name": "page_loading_progress_font_size", + "value": 16 + }, + { + "name": "page_loading_banner_border_radius", + "value": 25 + }, + { + "name": "page_loading_banner_margin_top", + "value": 12 + }, + { + "name": "page_loading_banner_shadow_border_radius", + "value": 25 + }, + { + "name": "page_loading_commodity_font", + "value": 18 + }, + { + "name": "page_loading_new_commodity_height", + "value": 50 + }, + { + "name": "page_loading_column_padding_left", + "value": 12 + }, + { + "name": "page_loading_column_padding_right", + "value": 12 + }, + { + "name": "page_loading_commodity_image_width", + "value": 130 + }, + { + "name": "page_loading_commodity_image_padding_top", + "value": 10 + }, + { + "name": "page_loading_commodity_image_padding_bottom", + "value": 10 + }, + { + "name": "page_loading_commodity_title_text_font_size", + "value": 16 + }, + { + "name": "page_loading_commodity_price_text_font_size", + "value": 20 + }, + { + "name": "page_loading_commodity_price_margin_top", + "value": 12 + }, + { + "name": "page_loading_commodity_border_radius", + "value": 10 + }, + { + "name": "page_loading_commodity_insurance_font_size", + "value": 12 + }, + { + "name": "page_loading_commodity_insurance_border_width", + "value": 1 + }, + { + "name": "page_loading_commodity_insurance_border_radius", + "value": 4 + }, + { + "name": "page_loading_commodity_insurance_padding_left", + "value": 8 + }, + { + "name": "page_loading_commodity_insurance_padding_right", + "value": 8 + }, + { + "name": "page_loading_commodity_insurance_padding_top", + "value": 3 + }, + { + "name": "page_loading_commodity_insurance_padding_bottom", + "value": 3 + }, + { + "name": "page_loading_commodity_insurance_margin_right", + "value": 12 + }, + { + "name": "page_loading_views_image_width", + "value": 20 + }, + { + "name": "page_loading_views_font", + "value": 16 + }, + { + "name": "page_loading_views_margin_left", + "value": 5 + }, + { + "name": "page_loading_views_height", + "value": 20 + }, + { + "name": "page_loading_views_width", + "value": 60 + }, + { + "name": "page_loading_views_margin_top", + "value": 12 + }, + { + "name": "page_loading_commodity_list_item_height", + "value": 130 + }, + { + "name": "page_loading_commodity_list_item_padding", + "value": 12 + }, + { + "name": "page_loading_commodity_list_item_margin_top", + "value": 12 + }, + { + "name": "lottie_view_canvas_height", + "value": 100 + }, + { + "name": "lottie_view_canvas_size", + "value": 150 + } + ] +} \ No newline at end of file diff --git a/sample/EnhanceSampleArk1.2/PageLoading/pageloading/src/main/resources/base/element/string.json b/sample/EnhanceSampleArk1.2/PageLoading/pageloading/src/main/resources/base/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..ffdf8b209d48b3684344922615b709a504f8abe3 --- /dev/null +++ b/sample/EnhanceSampleArk1.2/PageLoading/pageloading/src/main/resources/base/element/string.json @@ -0,0 +1,116 @@ +{ + "string": [ + { + "name": "page_loading_progress_text", + "value": "努力加载中..." + }, + { + "name": "page_loading_goods_title_text", + "value": "商品精选" + }, + { + "name": "page_loading_commodity_title00", + "value": "大容量充电宝智能安全保护" + }, + { + "name": "page_loading_commodity_title01", + "value": "高性能轻薄便携笔记本电脑" + }, + { + "name": "page_loading_commodity_title02", + "value": "时尚轻巧智能手机高清大屏" + }, + { + "name": "page_loading_commodity_title03", + "value": "豪华智能电动按摩椅尽享舒适生活" + }, + { + "name": "page_loading_commodity_title04", + "value": "超窄边框设计沉浸式视觉体验" + }, + { + "name": "page_loading_commodity_title05", + "value": "时尚简约设计潮流双肩背包" + }, + { + "name": "page_loading_commodity_price00", + "value": "¥79.9" + }, + { + "name": "page_loading_commodity_price01", + "value": "¥6975.8" + }, + { + "name": "page_loading_commodity_price02", + "value": "¥4279.6" + }, + { + "name": "page_loading_commodity_price03", + "value": "¥5385.4" + }, + { + "name": "page_loading_commodity_price04", + "value": "¥12500" + }, + { + "name": "page_loading_commodity_price05", + "value": "¥105.3" + }, + { + "name": "page_loading_commodity_view00", + "value": "3.2W" + }, + { + "name": "page_loading_commodity_view01", + "value": "9.8k" + }, + { + "name": "page_loading_commodity_view02", + "value": "1.8k" + }, + { + "name": "page_loading_commodity_view03", + "value": "859" + }, + { + "name": "page_loading_commodity_view04", + "value": "4.7W" + }, + { + "name": "page_loading_commodity_view05", + "value": "1.2W" + }, + { + "name": "page_loading_commodity_insurance00", + "value": "7天保价" + }, + { + "name": "page_loading_commodity_insurance01", + "value": "15天保价" + }, + { + "name": "page_loading_commodity_insurance02", + "value": "30天保价" + }, + { + "name": "page_loading_commodity_insurance03", + "value": "7天保价" + }, + { + "name": "page_loading_commodity_insurance04", + "value": "30天保价" + }, + { + "name": "page_loading_commodity_insurance05", + "value": "30天保价" + }, + { + "name": "page_loading_commodity_other_function", + "value": "仅演示,可自行实现业务功能" + }, + { + "name": "page_loading_corner_radius_default_m", + "value": "12" + } + ] +} diff --git a/sample/EnhanceSampleArk1.2/PageLoading/pageloading/src/main/resources/base/media/page_loading.gif b/sample/EnhanceSampleArk1.2/PageLoading/pageloading/src/main/resources/base/media/page_loading.gif new file mode 100644 index 0000000000000000000000000000000000000000..32e94e15ed29a5227d4f73a53489750da1ee35a8 Binary files /dev/null and b/sample/EnhanceSampleArk1.2/PageLoading/pageloading/src/main/resources/base/media/page_loading.gif differ diff --git a/sample/EnhanceSampleArk1.2/PageLoading/pageloading/src/main/resources/base/media/page_loading_commodity00.png b/sample/EnhanceSampleArk1.2/PageLoading/pageloading/src/main/resources/base/media/page_loading_commodity00.png new file mode 100644 index 0000000000000000000000000000000000000000..0836f3e45030a303486db7f368d61e8c5fe31daf Binary files /dev/null and b/sample/EnhanceSampleArk1.2/PageLoading/pageloading/src/main/resources/base/media/page_loading_commodity00.png differ diff --git a/sample/EnhanceSampleArk1.2/PageLoading/pageloading/src/main/resources/base/media/page_loading_commodity01.png b/sample/EnhanceSampleArk1.2/PageLoading/pageloading/src/main/resources/base/media/page_loading_commodity01.png new file mode 100644 index 0000000000000000000000000000000000000000..fc998c51ae7fbf2e9d92850d7828082aa68b872f Binary files /dev/null and b/sample/EnhanceSampleArk1.2/PageLoading/pageloading/src/main/resources/base/media/page_loading_commodity01.png differ diff --git a/sample/EnhanceSampleArk1.2/PageLoading/pageloading/src/main/resources/base/media/page_loading_commodity02.png b/sample/EnhanceSampleArk1.2/PageLoading/pageloading/src/main/resources/base/media/page_loading_commodity02.png new file mode 100644 index 0000000000000000000000000000000000000000..f5896010b24d0f8571e3a7795506a087e7401fba Binary files /dev/null and b/sample/EnhanceSampleArk1.2/PageLoading/pageloading/src/main/resources/base/media/page_loading_commodity02.png differ diff --git a/sample/EnhanceSampleArk1.2/PageLoading/pageloading/src/main/resources/base/media/page_loading_commodity03.png b/sample/EnhanceSampleArk1.2/PageLoading/pageloading/src/main/resources/base/media/page_loading_commodity03.png new file mode 100644 index 0000000000000000000000000000000000000000..b8e65ebffb6d65b6c4e5a53d5b5051d4aaef3a39 Binary files /dev/null and b/sample/EnhanceSampleArk1.2/PageLoading/pageloading/src/main/resources/base/media/page_loading_commodity03.png differ diff --git a/sample/EnhanceSampleArk1.2/PageLoading/pageloading/src/main/resources/base/media/page_loading_commodity04.png b/sample/EnhanceSampleArk1.2/PageLoading/pageloading/src/main/resources/base/media/page_loading_commodity04.png new file mode 100644 index 0000000000000000000000000000000000000000..b2c84a35e62cc920dd359ad2ee6b404f4957f376 Binary files /dev/null and b/sample/EnhanceSampleArk1.2/PageLoading/pageloading/src/main/resources/base/media/page_loading_commodity04.png differ diff --git a/sample/EnhanceSampleArk1.2/PageLoading/pageloading/src/main/resources/base/media/page_loading_commodity05.png b/sample/EnhanceSampleArk1.2/PageLoading/pageloading/src/main/resources/base/media/page_loading_commodity05.png new file mode 100644 index 0000000000000000000000000000000000000000..a0a50da0ef61692f020e4c29bfe972edfc5c4216 Binary files /dev/null and b/sample/EnhanceSampleArk1.2/PageLoading/pageloading/src/main/resources/base/media/page_loading_commodity05.png differ diff --git a/sample/EnhanceSampleArk1.2/PageLoading/pageloading/src/main/resources/base/media/page_loading_light_mode_banner.jpg b/sample/EnhanceSampleArk1.2/PageLoading/pageloading/src/main/resources/base/media/page_loading_light_mode_banner.jpg new file mode 100644 index 0000000000000000000000000000000000000000..915315db0921ca5d6b8a10e39a05f551aa5b30d3 Binary files /dev/null and b/sample/EnhanceSampleArk1.2/PageLoading/pageloading/src/main/resources/base/media/page_loading_light_mode_banner.jpg differ diff --git a/sample/EnhanceSampleArk1.2/PageLoading/pageloading/src/main/resources/base/media/page_loading_views.svg b/sample/EnhanceSampleArk1.2/PageLoading/pageloading/src/main/resources/base/media/page_loading_views.svg new file mode 100644 index 0000000000000000000000000000000000000000..a8fc8a619e4c7b6610ac18d742be38a281fffd25 --- /dev/null +++ b/sample/EnhanceSampleArk1.2/PageLoading/pageloading/src/main/resources/base/media/page_loading_views.svg @@ -0,0 +1,7 @@ + + + + + + + \ No newline at end of file diff --git a/sample/EnhanceSampleArk1.2/PageLoading/pageloading/src/main/resources/rawfile/routerMap/pageloading.json b/sample/EnhanceSampleArk1.2/PageLoading/pageloading/src/main/resources/rawfile/routerMap/pageloading.json new file mode 100644 index 0000000000000000000000000000000000000000..fa1931b27c89e450eea40d359e8c4967f9815945 --- /dev/null +++ b/sample/EnhanceSampleArk1.2/PageLoading/pageloading/src/main/resources/rawfile/routerMap/pageloading.json @@ -0,0 +1,10 @@ +{ + "routerMap": [ + { + "name": "pageloading/PageLoading", + "pageModule": "pageloading", + "pageSourceFile": "src/main/ets/generated/RouterBuilder.ets", + "registerFunction": "pageLoadingRegister" + } + ] +} \ No newline at end of file diff --git a/sample/EnhanceSampleArk1.2/PageLoading/pageloading/src/ohosTest/ets/test/Ability.test.ets b/sample/EnhanceSampleArk1.2/PageLoading/pageloading/src/ohosTest/ets/test/Ability.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..2e13ff4ec7ea70e2c1398f1772e9c36d37c88cbc --- /dev/null +++ b/sample/EnhanceSampleArk1.2/PageLoading/pageloading/src/ohosTest/ets/test/Ability.test.ets @@ -0,0 +1,51 @@ +'use static' +/* + * Copyright (c) 2025 Huawei Device 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 { hilog } from '@kit.PerformanceAnalysisKit'; +import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium'; + +export default function abilityTest() { + describe('ActsAbilityTest', () => { + // Defines a test suite. Two parameters are supported: test suite name and test suite function. + beforeAll(() => { + // Presets an action, which is performed only once before all test cases of the test suite start. + // This API supports only one parameter: preset action function. + }) + beforeEach(() => { + // Presets an action, which is performed before each unit test case starts. + // The number of execution times is the same as the number of test cases defined by **it**. + // This API supports only one parameter: preset action function. + }) + afterEach(() => { + // Presets a clear action, which is performed after each unit test case ends. + // The number of execution times is the same as the number of test cases defined by **it**. + // This API supports only one parameter: clear action function. + }) + afterAll(() => { + // Presets a clear action, which is performed after all test cases of the test suite end. + // This API supports only one parameter: clear action function. + }) + it('assertContain', 0.0, () => { + // Defines a test case. This API supports three parameters: test case name, filter parameter, and test case function. + hilog.info(0x0000, 'testTag', '%{public}s', 'it begin'); + let a = 'abc'; + let b = 'b'; + // Defines a variety of assertion methods, which are used to declare expected boolean conditions. + expect(a).assertContain(b); + expect(a).assertEqual(a); + }) + }) +} \ No newline at end of file diff --git a/sample/EnhanceSampleArk1.2/PageLoading/pageloading/src/ohosTest/ets/test/List.test.ets b/sample/EnhanceSampleArk1.2/PageLoading/pageloading/src/ohosTest/ets/test/List.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..f89c252313b624e271f55bb143a3e815afc26571 --- /dev/null +++ b/sample/EnhanceSampleArk1.2/PageLoading/pageloading/src/ohosTest/ets/test/List.test.ets @@ -0,0 +1,21 @@ +'use static' +/* + * Copyright (c) 2025 Huawei Device 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 abilityTest from './Ability.test'; + +export default function testsuite() { + abilityTest(); +} \ No newline at end of file diff --git a/sample/EnhanceSampleArk1.2/PageLoading/pageloading/src/ohosTest/module.json5 b/sample/EnhanceSampleArk1.2/PageLoading/pageloading/src/ohosTest/module.json5 new file mode 100644 index 0000000000000000000000000000000000000000..41b2a99db679972c0a7557457595e4d17f2913b8 --- /dev/null +++ b/sample/EnhanceSampleArk1.2/PageLoading/pageloading/src/ohosTest/module.json5 @@ -0,0 +1,27 @@ +/* + * Copyright (c) 2025 Huawei Device 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. + */ + +{ + "module": { + "name": "pageloading_test", + "type": "feature", + "deviceTypes": [ + "default", + "tablet" + ], + "deliveryWithInstall": true, + "installationFree": false + } +} diff --git a/sample/EnhanceSampleArk1.2/PageLoading/pageloading/src/test/List.test.ets b/sample/EnhanceSampleArk1.2/PageLoading/pageloading/src/test/List.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..0f183d30893443cdbc4b23cb4c683b2e89185d4e --- /dev/null +++ b/sample/EnhanceSampleArk1.2/PageLoading/pageloading/src/test/List.test.ets @@ -0,0 +1,21 @@ +'use static' +/* + * Copyright (c) 2025 Huawei Device 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 localUnitTest from './LocalUnit.test'; + +export default function testsuite() { + localUnitTest(); +} \ No newline at end of file diff --git a/sample/EnhanceSampleArk1.2/PageLoading/pageloading/src/test/LocalUnit.test.ets b/sample/EnhanceSampleArk1.2/PageLoading/pageloading/src/test/LocalUnit.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..6a9f26d3208b50c31a0314bf868952f661b0d2b9 --- /dev/null +++ b/sample/EnhanceSampleArk1.2/PageLoading/pageloading/src/test/LocalUnit.test.ets @@ -0,0 +1,49 @@ +'use static' +/* + * Copyright (c) 2025 Huawei Device 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 { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium'; + +export default function localUnitTest() { + describe('localUnitTest', () => { + // Defines a test suite. Two parameters are supported: test suite name and test suite function. + beforeAll(() => { + // Presets an action, which is performed only once before all test cases of the test suite start. + // This API supports only one parameter: preset action function. + }); + beforeEach(() => { + // Presets an action, which is performed before each unit test case starts. + // The number of execution times is the same as the number of test cases defined by **it**. + // This API supports only one parameter: preset action function. + }); + afterEach(() => { + // Presets a clear action, which is performed after each unit test case ends. + // The number of execution times is the same as the number of test cases defined by **it**. + // This API supports only one parameter: clear action function. + }); + afterAll(() => { + // Presets a clear action, which is performed after all test cases of the test suite end. + // This API supports only one parameter: clear action function. + }); + it('assertContain', 0.0, () => { + // Defines a test case. This API supports three parameters: test case name, filter parameter, and test case function. + let a = 'abc'; + let b = 'b'; + // Defines a variety of assertion methods, which are used to declare expected boolean conditions. + expect(a).assertContain(b); + expect(a).assertEqual(a); + }); + }); +} \ No newline at end of file diff --git a/sample/EnhanceSampleArk1.2/READEME.md b/sample/EnhanceSampleArk1.2/READEME.md new file mode 100644 index 0000000000000000000000000000000000000000..87970cddc789206a7cb5db06801980aa2f8b92e4 --- /dev/null +++ b/sample/EnhanceSampleArk1.2/READEME.md @@ -0,0 +1,49 @@ +# ArkTS1.2迁移升级说明 + + +## 一、概述 +核心目标是通过 **一键迁移工具辅助 + 有限手动修正**(手动修改占比严格控制在 5%–10%),实现工程完整运行。 + + +## 二、升级步骤 + +### 1. 工程迁移与版本备份 +- **拉取代码**:获取四个工程的代码。 +- **自动迁移**:使用官方 **一键迁移工具** 执行 1.2 版本自动转换,生成初始迁移工程。 +- **版本记录**:通过 `git` 提交迁移后代码(备注:`迁移工具初始输出 - Ark1.2`),固化迁移基线,便于后续对比追溯。 + + +### 2. 迁移工具报错处理 +- **收集报错**:运行迁移工具后,汇总所有报错信息(含语法错误、配置冲突、API 废弃等)。 +- **分类处理**: + - **可修复项**:直接修改代码修复(如路径配置更新、简单 API 替换)。 + - **疑难项**:整理报错场景(代码片段 + 报错日志),提交至 **迁移问题跟踪表**(同步工具团队或技术负责人)。 + + +### 3. 报错修复与问题提单 +- **优先修复明确报错**:确保迁移工具层面的错误全部解决,工程通过工具校验。 +- **阻断性问题提单**:对于工具无法自动修复、手动修改困难的问题(如框架逻辑冲突),提交 **高优先级问题单**(标注 `迁移阻断`),协同解决。 + + +### 4. 编译阶段 TypeError 修复 +迁移后编译会触发 **类型不匹配(TypeError)** 问题,需手动修正(聚焦工具未覆盖场景)。 +- **修复范围**:变量类型对齐、方法参数匹配、组件属性约束、异步逻辑类型定义等。 +- **比例控制**:单工程手动修改量 **≤10%**(整体三个工程平均目标 ≤7%),通过注释标记手动修改点(如 `// 1.2迁移手动修复:类型对齐`)。 + + +## 三、Sample 升级核心内容 +1. **工具自动适配**: + - ArkUI 1.2 API 替换(组件、接口升级)。 + - 工程配置文件(如依赖、清单)自动更新。 +2. **手动修正焦点**: + - 类型系统细化:修复 `number/string` 混淆、泛型约束问题; + - 异步流程:调整 Promise、异步组件的类型定义; + - 自定义逻辑:修正工具未覆盖的参数/返回值类型错误。 + + +## 四、后续流程 +1. **内部评审**:组织全流程评审(代码规范、功能运行、性能基线),验证升级效果。 +2. **问题闭环**:评审问题回归至步骤 2-4 修复,直至满足可运行标准。 +3. **仓库上传**:内部检视通过后,推送代码至目标仓库。 + +**关键原则**:过程中记录手动修改点,便于工具优化反馈,保障后续版本迁移效率。 \ No newline at end of file diff --git a/sample/EnhanceSampleArk1.2/StateManagement/.gitignore b/sample/EnhanceSampleArk1.2/StateManagement/.gitignore new file mode 100644 index 0000000000000000000000000000000000000000..42904af5b47e3e3d92fc65587d8ce8df0c459281 --- /dev/null +++ b/sample/EnhanceSampleArk1.2/StateManagement/.gitignore @@ -0,0 +1,10 @@ +/node_modules +/local.properties +/.idea +**/build +/.hvigor +.cxx +/.clangd +/.clang-format +/.clang-tidy +/oh_modules \ No newline at end of file diff --git a/sample/EnhanceSampleArk1.2/StateManagement/AppScope/app.json5 b/sample/EnhanceSampleArk1.2/StateManagement/AppScope/app.json5 new file mode 100644 index 0000000000000000000000000000000000000000..10a0cdb2d305c1882f5711aee7ab34dd96750e11 --- /dev/null +++ b/sample/EnhanceSampleArk1.2/StateManagement/AppScope/app.json5 @@ -0,0 +1,26 @@ +/* + * Copyright (c) 2023 Huawei Device 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. + */ + +{ + "app": { + "bundleName": "com.samples.statemanagement", + "vendor": "samples", + "versionCode": 1000000, + "versionName": "1.0.0", + "icon": "$media:app_icon", + "label": "$string:app_name", + "distributedNotificationEnabled": true + } +} diff --git a/sample/EnhanceSampleArk1.2/StateManagement/AppScope/resources/base/element/string.json b/sample/EnhanceSampleArk1.2/StateManagement/AppScope/resources/base/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..1080233f01384411ec684b58955cb8808746fdd3 --- /dev/null +++ b/sample/EnhanceSampleArk1.2/StateManagement/AppScope/resources/base/element/string.json @@ -0,0 +1,8 @@ +{ + "string": [ + { + "name": "app_name", + "value": "MyApplication" + } + ] +} diff --git a/sample/EnhanceSampleArk1.2/StateManagement/AppScope/resources/base/media/app_icon.png b/sample/EnhanceSampleArk1.2/StateManagement/AppScope/resources/base/media/app_icon.png new file mode 100644 index 0000000000000000000000000000000000000000..ce307a8827bd75456441ceb57d530e4c8d45d36c Binary files /dev/null and b/sample/EnhanceSampleArk1.2/StateManagement/AppScope/resources/base/media/app_icon.png differ diff --git a/sample/EnhanceSampleArk1.2/StateManagement/README_zh.md b/sample/EnhanceSampleArk1.2/StateManagement/README_zh.md new file mode 100644 index 0000000000000000000000000000000000000000..a8b598db1c57455af0cb8f7ce9831cddbd20df5d --- /dev/null +++ b/sample/EnhanceSampleArk1.2/StateManagement/README_zh.md @@ -0,0 +1,173 @@ +# 状态管理 + +### 介绍 + +本示例通过使用[页面级的状态变量](https://docs.openharmony.cn/pages/v3.2/zh-cn/application-dev/quick-start/arkts-localstorage.md/) +和[应用级的状态变量](https://docs.openharmony.cn/pages/v3.2/zh-cn/application-dev/quick-start/arkts-appstorage.md/) +来实现应用的状态管理。 + +### 效果预览 + +|主页|子组件同步父组件部分内容|爷孙组件之间状态同步|应用内全局数据与UI之间的状态同步| +|--------------------------------|--------------------------------|--------------------------------|--------------------------------| +|![](screenshots/device/Home.jpeg)|![](screenshots/device/ParentChildPartialContentSync.jpeg)|![](screenshots/device/DeepNestComponent.jpeg)|![](screenshots/device/ApplyGlobalDataSync.jpeg)| + +使用说明 + +1.点击首页中的基本类型进入对应页面,点击按钮可以更改圆形的颜色;点击查看源码可以展示基本类型功能效果的源码。 + +2.点击首页中的数组类型进入对应页面,点击新增元素可以添加数据;点击删除元素可以删除数据,当数据为空时,点击删除会弹出一个提示窗;点击更新数组中的某个元素,可以更改第一条数据的age属性,当数据为空时,同样会弹出一个提示窗;点击查看源码可以展示数组类型功能效果的源码。 + +3.点击首页中的类对象类型进入对应页面,点击更新对象可以更改对象属性和对象属性中的属性;点击更新对象属性,对象属性数据发生变化;点击更新属性中的属性,对象属性的属性数据发生变化;点击查看源码可以展示类对象类型功能效果的源码。 + +4.点击首页中的只更新所绑定的组件进入对应页面,点击修改标题和内容,标题和内容数据都发生变化,页面更新标题数据,内容数据不刷新;点击查看源码可以展示类对象类型功能效果的源码。 + +5.点击单、双向同步进入对应页面,点击设置为粉色按钮,父组件圆形颜色更新,两个子组件颜色同步更新;点击设置为蓝色按钮,子组件A圆形颜色更新,父组件和子组件B颜色不更新;点击设置为红色按钮,子组件B圆形颜色更新,父组件和子组件A圆形颜色同步更新,点击查看源码可以展示单、双向同步功能效果的源码。 + +6.点击子组件同步父组件的部分内容进入对应页面,点击父组件中的属性1修改数据,子组件中的属性1数据同步,点击子组件的属性1修改数据,父组件中的属性1数据同步,点击查看源码可以展示子组件同步父组件的部分内容功能效果的源码。 + +7.点击爷孙组件之间状态同步进入对应页面,点击爷组件下拉框组件选择颜色,下拉框文本和圆形颜色改变,孙组件下拉框文本和圆形颜色同步刷新;点击孙组件下拉框选择颜色,下拉框文本和圆形颜色改变,爷组件下拉框文本和圆形颜色同步刷新,点击查看源码可以展示爷孙组件之间状态同步功能效果的源码。 + +8.点击兄弟组件之间状态同步进入对应页面,点击兄弟A组件下拉框选择颜色,下拉框文本和圆形颜色改变,兄弟B组件下拉框文本和圆形颜色同步刷新,点击兄弟B组件下拉框选择颜色,下拉框文本和圆形颜色改变,兄弟A组件下拉框文本和圆形颜色同步刷新,点击查看源码可以展示爷孙组件之间状态同步功能效果的源码。 + +9.点击应用内全局数据与UI之间的状态同步进入对应页面,点击修改夜间模式状态和字体大小,当前夜间模式状态以及字体大小发生变化,进入Ability1和Ability2页面,夜间模式状态以及字体大小同步更新;在Ability1界面中改变夜间模式状态和字体大小,夜间模式状态和字体大小发生变化,进入到主页面和Ability2页面,夜间模式状态同步更新,字体大小不变;在Ability2界面中修改夜间模式状态,夜间模式状态发生改变,进入到主页面和Ability1页面,夜间模式状态同步,点击查看源码可以展示应用内全局数据与UI之间的状态同步功能效果的源码。 + +10.点击Ability内全局数据与UI之间的状态同步进入对应页面,点击修改夜间模式状态和字体大小,当前夜间模式状态以及字体大小发生变化时,进入Page1和Page2以及跨Ability不同步页面,Page1和Page2夜间模式状态以及字体大小同步更新,跨Ability页面不同步更新;在Page1界面中改变夜间模式状态和字体大小,夜间模式状态和字体大小发生变化,进入到主页面、Page2和跨Ability不同步页面,主页面和Page2夜间模式状态同步更新,但是字体不发生变化,跨Ability页面夜间模式状态和字体都不同步更新;在Page2界面中修改夜间模式状态,夜间模式状态发生改变,进入到主页面、Page1页面和跨Ability不同步页面,主页和Page1夜间模式状态同步,跨Ability页面都不同步更新;在跨Ability界面中修改夜间模式状态,夜间模式状态发生改变,进入主页、Page1和Page2页面,夜间模式状态不同步,点击查看源码可以展示Ability内全局数据与UI之间的状态同步功能效果的源码。 + +### 工程目录 + +``` +entry/src/main/ets/ +|---commoncomponents +| |---CodeView.ets // 代码展示组件 +| |---TitleBar.ets // 标题组件 +| |---TitleBarDark.ets // 夜间模式下标题组件 +| |---ViewCodeText.ets // 查看源码文本组件 +|---entryability +| |---EntryAbility.ts +|---outofsyncability +| |---OutOfSyncAbility.ts +|---MainAbility +|---pages +| |---applylevelstagemanagement // 应用级状态管理 +| | |---abilityglobaldatasync // Ability内全局数据与UI之间的状态同步 +| | | |---AbilityGlobalDataSync.ets +| | | |---AbilityGlobalDataSyncCode.ets // Ability内全局数据与UI之间的状态同步主页 +| | | |---AbilityOutOfSyncPage.ets // 跨Ability页面 +| | | |---LocalStorageLinkPage.ets // 展示LocalStorageLink效果页面 +| | | |---LocalStoragePropPage.ets // 展示LocalStorageProp效果页面 +| | |---applyglobaldatasync // 应用内全局数据与UI之间的状态同步 +| | | |---ApplyGlobalDataSync.ets +| | | |---ApplyGlobalDataSyncCode.ets // 应用内全局数据与UI之间的状态同步主页 +| | | |---StorageLinkAbilityPage.ets // 展示StorageLinkAbility页面 +| | | |---StoragePropAbilityPage.ets // 展示StoragePropAbility页面 +| | |---model +| | | |---AbilityConfigType.ets // Ability参数类型 +| | | |---CommonMethods.ets // 公用函数启动Ability +| |---home +| | |---data +| | | |---HomeData.ets // 首页数据 +| | |---model +| | | |---CategoricalDataType.ets // 层级类型 +| | |---Home.ets // 首页 +| | |---TabContentNavigation.ets // Tab内容区组件 +| |---pagelevelstagemanagement // 页面级状态管理 +| | |---multicompomentssync // 自定义组件之间的状态同步 +| | | |---brothercomponentssync // 兄弟组件之间状态同步 +| | | | |---BrotherComponentSync.ets +| | | | |---BrotherComponentSyncCode.ets // 兄弟组件之间状态同步首页 +| | | | |---ConsumeBrotherOneComponent.ets // @Consume状态变量组件 +| | | | |---ConsumeBrotherTwoComponent.ets // @Consume状态变量组件 +| | | | |---LinkBrotherOneComponent.ets // @Link状态变量组件 +| | | | |---LinkBrotherTwoComponent.ets // @Link状态变量组件 +| | | | |---ProvideAndConsumeSync.ets // @Privide状态变量组件 +| | | | |---StateAndLinkSync.ets // @State状态变量组件 +| | | |---data +| | | | |---ColorData.ets // 颜色数据 +| | | |---deepnestcomponentssync // 爷孙组件嵌套 +| | | | |---ConsumeDescendentComponent.ets // @Consume孙组件 +| | | | |---DeepNestComponentsSync.ets +| | | | |---DeepNestComponentsSyncCode.ets // 爷孙组件首页 +| | | | |---LinkDescendentComponent.ets // @Link孙组件 +| | | | |---ProvideAndConsumeSync.ets // @Provide爷组件 +| | | | |---StateAndLinkSync.ets // @State爷组件 +| | | |---model +| | | | |---ColorType.ets // 颜色数据类型 +| | | |---parentchildcomponentsync // 父子组件之间状态同步 +| | | | |---parentchildpartialcontentsync // 子组件同步父组件部分内容 +| | | | | |---ObjectLinkComponent.ets // @ObjectLink子组件 +| | | | | |---ParentChildPartialContentSync.ets +| | | | | |---ParentChildPartialContentSyncCode.ets // @Observer父组件 +| | | | |---uniandbidirectionsync // 单、双向同步 +| | | | | |---ComponentLink.ets // Link组件 +| | | | | |---ComponentProp.ets // Prop组件 +| | | | | |---UniAndBidirectionSync.ets +| | | | | |---UniAndBidirectionSyncCode.ets // @State父组件 +| | |---singlecomponentstatevariables // 单组件的状态同步 +| | | |---decoratedobjecttype // 修饰的对象类型 +| | | | |---arraytype // 数组类型 +| | | | | |---ArrayType.ets +| | | | | |---ArrayTypeCode.ets // 数组类型源码页 +| | | | |---basetype // 基本类型 +| | | | | |---BaseType.ets +| | | | | |---BaseTypeCode.ets // 基本类型源码页 +| | | | |---classobjecttype // 对象类型 +| | | | | |---ClassObjectType.ets +| | | | | |---ClassObjectTypeCode.ets // 对象类型源码页 +| | | |---updatetactics // 更新原理 +| | | | |---updateboundcomponent // 只更新所绑定的组件 +| | | | | |---UpdateBoundComponent.ets +| | | | | |---UpdateBoundComponentCode.ets // 只更新所绑定的组件源码 +|---storagelinkability +| |---StorageLinkAbility.ts +|---storagepropability +| |---StoragePropAbility.ts +|---utils +| |---Logger.ts // 日志文件 +| |---ResourceUtils.ts // 资源转换方法 +| |---StartAbilityUtils.ts // 启动Ability方法 + +``` + +### 具体实现 + +* 查看源码:通过private controller: webView.WebviewController = new webView.WebviewController()声明一个状态变量,使用this.controller.loadUrl(url)来打开web页面,查看对应的源码。 +* 基本类型:使用@State声明一个Resource类型的circleColor状态变量,然后通过点击事件根据circleColor的id来改变圆形颜色。 +* 数组类型:使用@State声明一个数组arrayTypeData状态变量,数据元素为new ArrayDataType(),通过arrayTypeData.push()方法来新增元素数据,arrayTypeData.splice()方法删除元素,更新指定new ArrayDataType()来实现更新某一个元素数据。 +* 类对象类型:使用@Observerd声明一个属性类ChildClass,然后声明一个对象类ParentClass,并将对象的其中一个属性类型设置为属性类,使用@State声明一个类对象数据状态变量classObjectData,更新对象可以通过new ParentClass()生成一个对象并赋值来实现,更新对象属性可以通过this.classOjectData.attribute++来实现,更新对象属性的属性可以通过@ObjectLink声明一个状态变量并更新此状态变量的对象属性来实现。 +* 只更新所绑定的组件:使用@State和Private声明一个titleName和content状态变量,通过点击事件修改这两个状态变量。 +* 单、双向同步:父组件使用@State声明一个状态变量circleColor并作为参数给子组件A和子组件B,子组件A通过@Prop接收,子组件B通过@Link来接收,通过点击事件中的this.circleColor = COLOR_DATA.PINK来更改颜色。 +* 子组件同步父组件部分内容:父组件中使用@State声明一个数组状态变量parentData,@Observed声明数组元素的类,父组件向子组件传递parentData的某一个元素数据,子组件通过@ObjectLink来接收,父组件通过this.childObject.attributeType = value来修改元素数据,子组件同步更新,子组件同样通过this.childObjectData.attributeType = value来修改子组件的数据,父组件同步更新。 +* 爷孙组件之间状态同步:爷组件通过@State声明一个控制圆形颜色的状态变量circleColor和控制当前Select组件Index的状态变量currentSelectIndex,逐层传递给子组件给孙组件,通过@Link接收,爷组件通过onSelect事件来修改circleColor和currentSelectIndex,孙组件同样通过onSelect事件来修改circleColor和currentSelectIndex,然后爷组件通过@Provide声明一个控制圆形颜色的状态变量consumeCircleColor和控制当前Select组件Index的状态变量currentSelectIndex,孙组件通过@Consume来接收,爷组件通过onSelect事件来修改circleColor和currentSelectIndex,孙组件同样通过onSelect事件来修改circleColor和currentSelectIndex。 +* 兄弟组件之间状态同步:父组件通过@State声明一个控制圆形颜色的状态变量circleColor和控制当前Select组件Index的状态变量currentSelectIndex,传递给子组件A和子组件B,两者通过@Link接收,子组件A通过onSelect事件来修改circleColor和currentSelectIndex,子组件B同样通过onSelect事件来修改circleColor和currentSelectIndex;然后父组件通过@Provide声明一个控制圆形颜色的状态变量consumeCircleColor和控制当前Select组件Index的状态变量currentSelectIndex,子组件A和子组件B通过@Consume来接收,子组件A通过onSelect事件来修改circleColor和currentSelectIndex,,子组件B同样通过onSelect事件来修改circleColor和currentSelectIndex。 +* 应用内全局数据与UI之间的状态同步:主页、Ability1页面和Ability2页面通过@StorageLink声明一个控制夜间模式的状态变量currentModelStatus,在主页面通过onChange事件中的AppStorage.SetOrCreate('currentModelStatus', this.currentModelStatus)来更改夜间模式的状态,,在Ability1页面和Ability页面通过onClick事件中的this.currentModelStatus = !this.currentModelStatus,主页和Ability2页面通过@StorageLink声明一个控制字体大小的状态变量contentFontSize,Ability1页面通过@StorageProp声明一个控制字体大小的状态变量contentFontSize,主页使用onChange事件中的this.contentFontSize = value和AppStorage.SetOrCreate('contentFontSize', this.contentFontSize)来更改内容字体的大小,Ability1通过onChange事件中的this.contentFontSize = value来修改内容字体大小。 +* Ability内全局数据与UI之间的状态同步:在Entry当中声明一个storage,并通过this.storage.setOrCreate('currentModelStatus', true)和this.storage.setOrCreate('contentFontSize', 18)来设置夜间模式状态变量currentModelStatus和字体大小状态变量contentFontSize,然后主页、Page1页面、Page2页面和跨Ability页面通过@LocalStorageLink声明一个控制夜间模式的状态变量currentModelStatus,在主页面通过onChange事件中的this.currentModelStatus = isOn来更改夜间模式的状态,Page1页面、Page2页面和跨Ability页面通过onClick事件中的this.currentModelStatus = !this.currentModelStatus来更改夜间模式的状态,主页、Page1页面和跨Ability页面通过@LocalStorageLink声明一个控制字体大小的状态变量contentFontSize,Page1页面通过@LocalStorageProp声明一个控制字体大小的状态变量contentFontSize,主页使用onChange事件中的this.contentFontSize = value和AppStorage.SetOrCreate('contentFontSize', this.contentFontSize)来更改内容字体的大小,Page2通过onChange事件中的this.contentFontSize = value来修改内容字体大小。 + +### 相关权限 + +不涉及。 + +### 依赖 + +不涉及。 + +### 约束与限制 + +1.本示例仅支持标准系统上运行。 + +2.本示例已适配API version 9版本SDK,版本号:4.0.5.2。 + +3.本示例需要使用DevEco Studio 3.1 Beta2 (Build Version: 3.1.0.400, built on April 7, 2023)才可编译运行。 + +### 下载 + +如需单独下载本工程,执行如下命令: + +``` +git init +git config core.sparsecheckout true +echo code/UI/StateManagement/ > .git/info/sparse-checkout +git remote add origin https://gitee.com/openharmony/applications_app_samples.git +git pull origin master + +``` \ No newline at end of file diff --git a/sample/EnhanceSampleArk1.2/StateManagement/build-profile.json5 b/sample/EnhanceSampleArk1.2/StateManagement/build-profile.json5 new file mode 100644 index 0000000000000000000000000000000000000000..23373b246a74ac037e1310485fd4c24baeee72d4 --- /dev/null +++ b/sample/EnhanceSampleArk1.2/StateManagement/build-profile.json5 @@ -0,0 +1,42 @@ +/* + * Copyright (c) 2023 Huawei Device 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. + */ + +{ + "app": { + "signingConfigs": [], + "compileSdkVersion": 9, + "compatibleSdkVersion": 9, + "products": [ + { + "name": "default", + "signingConfig": "default", + } + ] + }, + "modules": [ + { + "name": "entry", + "srcPath": "./entry", + "targets": [ + { + "name": "default", + "applyToProducts": [ + "default" + ] + } + ] + } + ] +} \ No newline at end of file diff --git a/sample/EnhanceSampleArk1.2/StateManagement/entry/.gitignore b/sample/EnhanceSampleArk1.2/StateManagement/entry/.gitignore new file mode 100644 index 0000000000000000000000000000000000000000..5a6ba80fa3d9498a23ae8ae7d9518f8743fa8a96 --- /dev/null +++ b/sample/EnhanceSampleArk1.2/StateManagement/entry/.gitignore @@ -0,0 +1,4 @@ +/node_modules +/.preview +/build +/.cxx \ No newline at end of file diff --git a/sample/EnhanceSampleArk1.2/StateManagement/entry/build-profile.json5 b/sample/EnhanceSampleArk1.2/StateManagement/entry/build-profile.json5 new file mode 100644 index 0000000000000000000000000000000000000000..ddd6e5f1ac23a18a1d1d0d8d7470c6d4726ef66e --- /dev/null +++ b/sample/EnhanceSampleArk1.2/StateManagement/entry/build-profile.json5 @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2023 Huawei Device 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. + */ + +{ + "apiType": 'stageMode', + "buildOption": { + }, + "targets": [ + { + "name": "default" + }, + { + "name": "ohosTest", + } + ] +} \ No newline at end of file diff --git a/sample/EnhanceSampleArk1.2/StateManagement/entry/hvigorfile.ts b/sample/EnhanceSampleArk1.2/StateManagement/entry/hvigorfile.ts new file mode 100644 index 0000000000000000000000000000000000000000..80e4ec5b81689f238c34614b167a0b9e9c83e8d9 --- /dev/null +++ b/sample/EnhanceSampleArk1.2/StateManagement/entry/hvigorfile.ts @@ -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'; diff --git a/sample/EnhanceSampleArk1.2/StateManagement/entry/oh-package.json5 b/sample/EnhanceSampleArk1.2/StateManagement/entry/oh-package.json5 new file mode 100644 index 0000000000000000000000000000000000000000..907d65a0ae8875e2e4edf794a0b25c1be29bb392 --- /dev/null +++ b/sample/EnhanceSampleArk1.2/StateManagement/entry/oh-package.json5 @@ -0,0 +1,24 @@ +/* + * Copyright (c) 2023 Huawei Device 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. + */ + +{ + "license": "ISC", + "devDependencies": {}, + "name": "entry", + "description": "example description", + "repository": {}, + "version": "1.0.0", + "dependencies": {} +} diff --git a/sample/EnhanceSampleArk1.2/StateManagement/entry/src/main/ets/commoncomponents/CodeView.ets b/sample/EnhanceSampleArk1.2/StateManagement/entry/src/main/ets/commoncomponents/CodeView.ets new file mode 100644 index 0000000000000000000000000000000000000000..6b953295107ea1cc32f29f41b4ec50dcc719e813 --- /dev/null +++ b/sample/EnhanceSampleArk1.2/StateManagement/entry/src/main/ets/commoncomponents/CodeView.ets @@ -0,0 +1,84 @@ +/* + * Copyright (c) 2023 Huawei Device 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 webView from '@ohos.web.webview'; +import { TitleBar } from './TitleBar'; + +@Component +export struct CodeView { + @BuilderParam contentView: () => void; + @Link title: Resource; + @StorageLink('sideBarShow') sideBarShow: boolean = false; + @StorageLink('webSrc') @Watch('webSrcChange') webSrc: Resource = $rawfile('BaseTypeCode.ets.html'); + @StorageLink('currentBreakpoint') curBp: string = 'sm'; + private isShowTitle: boolean = true; + private controller: webView.WebviewController = new webView.WebviewController(); + + webSrcChange():void { + this.controller.loadUrl(this.webSrc); + } + + @Builder codeView() { + Column({ space: 10 }) { + Text($r('app.string.close')) + .fontSize($r('app.float.source_code_font_size')) + .fontColor(Color.White) + .alignSelf(ItemAlign.End) + .id('close') + .onClick(() => { + this.sideBarShow = !this.sideBarShow; + }) + Column() { + Web({ src: this.webSrc, controller: this.controller }) + .width('100%') + .height('100%') + } + .height('100%') + .width('100%') + .padding({ bottom: $r('app.float.code_view_bottom') }) + } + .height('100%') + .padding($r('app.float.page_padding')) + .backgroundColor($r('app.color.code_view_background')) + } + + build() { + Column() { + if (this.isShowTitle) { + TitleBar({ title: $title }) + } + SideBarContainer(this.curBp === 'sm' ? SideBarContainerType.Overlay : SideBarContainerType.Embed) { + this.codeView() + Scroll() { + this.contentView() + } + .width('100%') + .height('100%') + .align(Alignment.Top) + .scrollBar(BarState.Off) + } + .autoHide(false) + .showSideBar(this.sideBarShow) + .layoutWeight(1) + .sideBarWidth('100%') + .showControlButton(false) + // 大型设备查看源码和界面4:6的比例,所以占60% + .maxSideBarWidth(this.curBp === 'sm' ? '100%' : '60%') + .sideBarPosition(SideBarPosition.End) + } + .width('100%') + .height('100%') + } +} \ No newline at end of file diff --git a/sample/EnhanceSampleArk1.2/StateManagement/entry/src/main/ets/commoncomponents/TitleBar.ets b/sample/EnhanceSampleArk1.2/StateManagement/entry/src/main/ets/commoncomponents/TitleBar.ets new file mode 100644 index 0000000000000000000000000000000000000000..3f13f2381fabbb7474c8f69a6e186644443edc9c --- /dev/null +++ b/sample/EnhanceSampleArk1.2/StateManagement/entry/src/main/ets/commoncomponents/TitleBar.ets @@ -0,0 +1,56 @@ +/* + * Copyright (c) 2023 Huawei Device 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 router from '@ohos.router'; +import common from '@ohos.app.ability.common'; +import { startSpecifiedAbility } from '../utils/StartAbilityUtils'; + +//声明一个上下文信息 +const CONTEXT: common.UIAbilityContext = getContext(this) as common.UIAbilityContext; + +@Component +export struct TitleBar { + @Link title: Resource; + private isAbility: boolean = false; + + build() { + Column() { + Row() { + Button() { + Image($r('app.media.ic_back')) + .size({ width: $r('app.float.icon_back_size'), height: $r('app.float.icon_back_size') }) + } + .backgroundColor($r('app.color.background_shallow_grey')) + .id('backBtn') + .onClick(() => { + this.isAbility ? startSpecifiedAbility(CONTEXT, 'EntryAbility') : router.back(); + }) + + Text(this.title) + .fontSize($r('app.float.title_font_size')) + .margin({ left: $r('app.float.title_margin') }) + } + .width('100%') + .padding($r('app.float.page_padding')) + + Divider() + .width('100%') + .height($r('app.float.divider_height')) + .color($r('app.color.divider_color')) + .margin({ bottom: 12 }) + } + .width('100%') + } +} \ No newline at end of file diff --git a/sample/EnhanceSampleArk1.2/StateManagement/entry/src/main/ets/commoncomponents/TitleBarDark.ets b/sample/EnhanceSampleArk1.2/StateManagement/entry/src/main/ets/commoncomponents/TitleBarDark.ets new file mode 100644 index 0000000000000000000000000000000000000000..59960259afb87ff004751596b875d56560d65412 --- /dev/null +++ b/sample/EnhanceSampleArk1.2/StateManagement/entry/src/main/ets/commoncomponents/TitleBarDark.ets @@ -0,0 +1,57 @@ +/* + * Copyright (c) 2023 Huawei Device 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 router from '@ohos.router'; +import common from '@ohos.app.ability.common'; +import { startSpecifiedAbility } from '../utils/StartAbilityUtils'; + +//声明一个上下文信息 +const CONTEXT: common.UIAbilityContext = getContext(this) as common.UIAbilityContext; + +@Component +export struct TitleBarDark { + @Link title: Resource; + private isAbility: boolean = false; + + build() { + Column() { + Row() { + Button() { + Image($r('app.media.ic_back_white')) + .size({ width: $r('app.float.icon_back_size'), height: $r('app.float.icon_back_size') }) + } + .id('backBtn') + .onClick(() => { + this.isAbility ? startSpecifiedAbility(CONTEXT, 'EntryAbility') : router.back(); + }) + .backgroundColor($r('app.color.nightnode_color')) + + Text(this.title) + .fontSize($r('app.float.title_font_size')) + .margin({ left: $r('app.float.title_margin') }) + .fontColor(Color.White) + } + .width('100%') + .padding($r('app.float.page_padding')) + + Divider() + .width('100%') + .height($r('app.float.divider_height')) + .color($r('app.color.divider_color')) + .margin({ bottom: 12 }) + } + .width('100%') + } +} \ No newline at end of file diff --git a/sample/EnhanceSampleArk1.2/StateManagement/entry/src/main/ets/commoncomponents/ViewCodeText.ets b/sample/EnhanceSampleArk1.2/StateManagement/entry/src/main/ets/commoncomponents/ViewCodeText.ets new file mode 100644 index 0000000000000000000000000000000000000000..345c0bf8611337325d473054205935d532d6c1a3 --- /dev/null +++ b/sample/EnhanceSampleArk1.2/StateManagement/entry/src/main/ets/commoncomponents/ViewCodeText.ets @@ -0,0 +1,37 @@ +/* + * Copyright (c) 2023 Huawei Device 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. + */ + +@Component +export struct ViewCodeText { + @StorageLink('sideBarShow') sideBarShow: boolean = false; + private webSrc: Resource = $rawfile('BaseTypeCode.ets.html'); + + build() { + Column(){ + Text($r('app.string.source_code')) + .fontColor($r('app.color.source_code_font_color')) + .fontSize($r('app.float.source_code_font_size')) + .alignSelf(ItemAlign.End) + .id('viewSourceCode') + .onClick(() => { + // 点击查看源码 + AppStorage.SetOrCreate('sideBarShow', !this.sideBarShow); + AppStorage.SetOrCreate('webSrc', this.webSrc); + }) + } + .width('100%') + .justifyContent(FlexAlign.End) + } +} \ No newline at end of file diff --git a/sample/EnhanceSampleArk1.2/StateManagement/entry/src/main/ets/entryability/EntryAbility.ts b/sample/EnhanceSampleArk1.2/StateManagement/entry/src/main/ets/entryability/EntryAbility.ts new file mode 100644 index 0000000000000000000000000000000000000000..65e352cddb4785f6c71dd5e95b50c519c3912c9d --- /dev/null +++ b/sample/EnhanceSampleArk1.2/StateManagement/entry/src/main/ets/entryability/EntryAbility.ts @@ -0,0 +1,92 @@ +/* + * Copyright (c) 2023 Huawei Device 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 UIAbility from '@ohos.app.ability.UIAbility'; +import type window from '@ohos.window'; +import Logger from '../utils/Logger'; +import display from '@ohos.display'; + +const TAG: string = 'EntryAbility'; +const FONT_SIZE: number = 18; +const DPI: number = 160; +const SMALL_SCREEN_WIDTH: number = 520; +const MIDDLE_SCREEN_WIDTH: number = 520; + +export default class EntryAbility extends UIAbility { + private storage: LocalStorage; + + onCreate(want, launchParam): void { + this.storage = new LocalStorage(); + this.storage.setOrCreate('currentModelStatus', true); + // 设置当前内容字体为18 + this.storage.setOrCreate('contentFontSize', FONT_SIZE); + Logger.info(TAG, 'Ability onCreate'); + } + + onDestroy(): void { + Logger.info(TAG, 'Ability onDestroy'); + } + + updateBreakpoint(windowWidth: number): void { + let windowWidthVp: number = windowWidth / (display.getDefaultDisplaySync().densityDPI / DPI); + let curBp: string; + // 520以及840分别为小屏和中屏的最大宽度 + if (windowWidthVp < SMALL_SCREEN_WIDTH) { + curBp = 'sm'; + } else if (windowWidthVp < MIDDLE_SCREEN_WIDTH) { + curBp = 'md'; + } else { + curBp = 'lg'; + } + Logger.info(TAG, `breakpoint: ${curBp}`); + AppStorage.SetOrCreate('currentBreakpoint', curBp); + } + + onWindowStageCreate(windowStage: window.WindowStage): void { + // Main window is created, set main page for this ability + Logger.info(TAG, 'Ability onWindowStageCreate'); + windowStage.getMainWindow().then((windowObj) => { + let windowWidth: number = windowObj.getWindowProperties().windowRect.width; + this.updateBreakpoint(windowWidth); + windowObj.on('windowSizeChange', (currentWindowSize) => { + let currentWindowWidth: number = currentWindowSize.width; + this.updateBreakpoint(currentWindowWidth); + + if (windowObj.getWindowProperties().isFullScreen) { + Logger.info(TAG, 'isFullScreen'); + } + if (windowObj.getWindowProperties().isLayoutFullScreen) { + Logger.info(TAG, 'isLayoutFullScreen'); + } + }); + }); + windowStage.loadContent('pages/home/Home', this.storage); + } + + onWindowStageDestroy(): void { + // Main window is destroyed, release UI related resources + Logger.info(TAG, 'Ability onWindowStageDestroy'); + } + + onForeground(): void { + // Ability has brought to foreground + Logger.info(TAG, 'Ability onForeground'); + } + + onBackground(): void { + // Ability has back to background + Logger.info(TAG, 'Ability onBackground'); + } +} diff --git a/sample/EnhanceSampleArk1.2/StateManagement/entry/src/main/ets/outofsyncability/OutOfSyncAbility.ts b/sample/EnhanceSampleArk1.2/StateManagement/entry/src/main/ets/outofsyncability/OutOfSyncAbility.ts new file mode 100644 index 0000000000000000000000000000000000000000..34907c6178fe447ec3b3390de07a62445132e1ba --- /dev/null +++ b/sample/EnhanceSampleArk1.2/StateManagement/entry/src/main/ets/outofsyncability/OutOfSyncAbility.ts @@ -0,0 +1,58 @@ +/* + * Copyright (c) 2023 Huawei Device 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 UIAbility from '@ohos.app.ability.UIAbility'; +import type window from '@ohos.window'; +import Logger from '../utils/Logger'; + +const TAG = 'OutOfSyncAbility'; + +export default class OutOfSyncAbility extends UIAbility { + onCreate(want, launchParam): void { + Logger.info(TAG, 'Ability onCreate'); + } + + onDestroy(): void { + Logger.info(TAG, 'Ability onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage): void { + // Main window is created, set main page for this ability + Logger.info(TAG, 'Ability onWindowStageCreate'); + + windowStage.loadContent('pages/applylevelstagemanagement/abilityglobaldatasync/AbilityOutOfSyncPage', (err, data) => { + if (err.code) { + Logger.error(TAG, `Failed to load the content. Cause: %{public}s${JSON.stringify(err)}`); + return; + } + Logger.info(TAG, `Succeeded in loading the content. Data: %{public}s${JSON.stringify(data)}}`); + }); + } + + onWindowStageDestroy(): void { + // Main window is destroyed, release UI related resources + Logger.info(TAG, 'Ability onWindowStageDestroy'); + } + + onForeground(): void { + // Ability has brought to foreground + Logger.info(TAG, 'Ability onForeground'); + } + + onBackground(): void { + // Ability has back to background + Logger.info(TAG, 'Ability onBackground'); + } +} diff --git a/sample/EnhanceSampleArk1.2/StateManagement/entry/src/main/ets/pages/applylevelstagemanagement/abilityglobaldatasync/AbilityGlobalDataSync.ets b/sample/EnhanceSampleArk1.2/StateManagement/entry/src/main/ets/pages/applylevelstagemanagement/abilityglobaldatasync/AbilityGlobalDataSync.ets new file mode 100644 index 0000000000000000000000000000000000000000..51c5da1f596db38f27f6a233f325d8da4ca90968 --- /dev/null +++ b/sample/EnhanceSampleArk1.2/StateManagement/entry/src/main/ets/pages/applylevelstagemanagement/abilityglobaldatasync/AbilityGlobalDataSync.ets @@ -0,0 +1,50 @@ +/* + * Copyright (c) 2023 Huawei Device 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 { AbilityGlobalDataSyncCode } from './AbilityGlobalDataSyncCode'; +import { CodeView } from '../../../commoncomponents/CodeView'; +import { TitleBarDark } from '../../../commoncomponents/TitleBarDark'; +import { TitleBar } from '../../../commoncomponents/TitleBar'; + +let storage: LocalStorage = LocalStorage.GetShared(); + +@Entry(storage) +@Component +struct AbilityGlobalDataSync { + @State title: Resource = $r('app.string.ability_storage_ui'); + // 初始化夜间模式的状态 + @LocalStorageLink('currentModelStatus') currentModelStatus: boolean = true; + + build() { + Column() { + // 展示不同模式下的标题 + if (this.currentModelStatus) { + TitleBarDark({ title: $title }) + } else { + TitleBar({ title: $title }) + } + CodeView({ title: $title, isShowTitle: false }) { + AbilityGlobalDataSyncCode() + } + } + .width('100%') + .height('100%') + .backgroundColor(this.currentModelStatus ? $r('app.color.nightnode_color') : $r('app.color.background_shallow_grey')) + } + + aboutToDisappear(): void { + AppStorage.SetOrCreate('sideBarShow', false); + } +} \ No newline at end of file diff --git a/sample/EnhanceSampleArk1.2/StateManagement/entry/src/main/ets/pages/applylevelstagemanagement/abilityglobaldatasync/AbilityGlobalDataSyncCode.ets b/sample/EnhanceSampleArk1.2/StateManagement/entry/src/main/ets/pages/applylevelstagemanagement/abilityglobaldatasync/AbilityGlobalDataSyncCode.ets new file mode 100644 index 0000000000000000000000000000000000000000..d3a74ebb44a1f210749e942097170dc6c6c28b80 --- /dev/null +++ b/sample/EnhanceSampleArk1.2/StateManagement/entry/src/main/ets/pages/applylevelstagemanagement/abilityglobaldatasync/AbilityGlobalDataSyncCode.ets @@ -0,0 +1,142 @@ +/* + * Copyright (c) 2023 Huawei Device 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 router from '@ohos.router'; +import common from '@ohos.app.ability.common'; +import { ViewCodeText } from '../../../commoncomponents/ViewCodeText'; +import { startSpecifiedAbility } from '../../../utils/StartAbilityUtils'; + +// 声明一个上下文信息 +const CONTEXT: common.UIAbilityContext = getContext(this) as common.UIAbilityContext; + +@Component +export struct AbilityGlobalDataSyncCode { + // 初始化字体大小最小值 + private minFontSize: number = 10; + // 和主页、Page1、Page2双向同步内容字体大小 + @LocalStorageLink('contentFontSize') contentFontSize: number = 18; + // 和主页、Page1、Page2双向同步夜间模式状态 + @LocalStorageLink('currentModelStatus') currentModelStatus: boolean = true; + + build() { + Column({ space: 10 }) { + // 查看源码 + ViewCodeText({ webSrc: $rawfile('AbilityGlobalDataSyncCode.ets.html') }) + Row() { + Text($r('app.string.nightmode')) + .fontSize(this.contentFontSize) + .fontColor(this.currentModelStatus ? $r('app.color.color_white') : $r('app.color.tips_font_color')) + // 控制夜间模式 + Toggle({ type: ToggleType.Switch, isOn: this.currentModelStatus }) + .id('nightModeSwitch') + .selectedColor(Color.Blue) + .switchPointColor(Color.White) + .onChange((isOn: boolean) => { + // 更新控制夜间模式状态的变量数据,@StorageLink和@StorageLink关联的数据变量刷新 + this.currentModelStatus = isOn; + }) + }.justifyContent(FlexAlign.SpaceAround) + .width('70%') + .border({ radius: 50, color: Color.Grey, width: $r('app.float.border_width') }) + + Text($r('app.string.ability_storage_nightmodelsync')) + .fontSize(this.contentFontSize) + .fontColor(this.currentModelStatus ? $r('app.color.color_white') : $r('app.color.tips_font_color')) + .textAlign(TextAlign.Center) + // slider滑动模块控制字体大小 + Column() { + Text($r('app.string.fontSize_text')) + .fontSize(this.contentFontSize) + .fontColor(this.currentModelStatus ? $r('app.color.color_white') : $r('app.color.tips_font_color')) + .width('100%') + .textAlign(TextAlign.Center) + Row() { + Text(`${this.minFontSize}`) + .fontColor(this.currentModelStatus ? $r('app.color.color_white') : $r('app.color.tips_font_color')) + .fontSize($r('app.float.tips_font_size')) + Slider({ + value: this.contentFontSize, + min: 10, // 字体大小最小值 + max: 30, // 字体大小最大值 + style: SliderStyle.OutSet + }) + .showTips(true) + .onChange((value: number, mode: SliderChangeMode) => { + // 更新控制字体大小状态的变量数据,@LocalStorageLink和@LocalStorageProp关联的数据变量刷新 + this.contentFontSize = value; + }) + // toFixed(0)将滑动条返回值处理为整数精度 + Text(this.contentFontSize.toFixed(0)) + .fontColor(this.currentModelStatus ? $r('app.color.color_white') : $r('app.color.tips_font_color')) + .fontSize($r('app.float.tips_font_size')) + } + .width('80%') + }.margin({ top: 50 }) + + Text($r('app.string.ability_storage_fontsizesync')) + .fontSize(this.contentFontSize) + .fontColor(this.currentModelStatus ? $r('app.color.color_white') : $r('app.color.tips_font_color')) + .width('100%') + .textAlign(TextAlign.Center) + Button() { + Text($r('app.string.enter_pageone')) + .fontColor(this.currentModelStatus ? $r('app.color.color_white') : $r('app.color.button_text_color')) + .fontSize(this.contentFontSize) + .width('60%') + .textAlign(TextAlign.Center) + } + .id('enterPageOne') + .type(ButtonType.Capsule) + .backgroundColor($r('app.color.button_background_color')) + .padding($r('app.float.page_padding')) + .onClick(() => { + router.pushUrl({ url: 'pages/applylevelstagemanagement/abilityglobaldatasync/LocalStoragePropPage' }); + }) + + Button() { + Text($r('app.string.enter_pagetwo')) + .fontColor(this.currentModelStatus ? $r('app.color.color_white') : $r('app.color.button_text_color')) + .fontSize(this.contentFontSize) + .width('60%') + .textAlign(TextAlign.Center) + } + .id('enterPageTwo') + .type(ButtonType.Capsule) + .backgroundColor($r('app.color.button_background_color')) + .padding($r('app.float.page_padding')) + .onClick(() => { + router.pushUrl({ url: 'pages/applylevelstagemanagement/abilityglobaldatasync/LocalStorageLinkPage' }); + }) + + Divider().width('100%').strokeWidth(1) + Button() { + Text($r('app.string.enter_ability_outofsync')) + .fontColor(this.currentModelStatus ? $r('app.color.color_white') : $r('app.color.button_text_color')) + .fontSize(this.contentFontSize) + .width('60%') + .textAlign(TextAlign.Center) + } + .id('enterOutOfAbility') + .type(ButtonType.Capsule) + .backgroundColor($r('app.color.button_background_color')) + .padding($r('app.float.page_padding')) + .onClick(() => { + startSpecifiedAbility(CONTEXT,'OutOfSyncAbility'); + }) + } + .width('100%') + .padding(10) + } +} \ No newline at end of file diff --git a/sample/EnhanceSampleArk1.2/StateManagement/entry/src/main/ets/pages/applylevelstagemanagement/abilityglobaldatasync/AbilityOutOfSyncPage.ets b/sample/EnhanceSampleArk1.2/StateManagement/entry/src/main/ets/pages/applylevelstagemanagement/abilityglobaldatasync/AbilityOutOfSyncPage.ets new file mode 100644 index 0000000000000000000000000000000000000000..3317326af3379a09a7ea812f0058f82d952ceb5c --- /dev/null +++ b/sample/EnhanceSampleArk1.2/StateManagement/entry/src/main/ets/pages/applylevelstagemanagement/abilityglobaldatasync/AbilityOutOfSyncPage.ets @@ -0,0 +1,88 @@ +/* + * Copyright (c) 2023 Huawei Device 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 { CodeView } from '../../../commoncomponents/CodeView'; +import { ViewCodeText } from '../../../commoncomponents/ViewCodeText'; +import { TitleBarDark } from '../../../commoncomponents/TitleBarDark'; +import { TitleBar } from '../../../commoncomponents/TitleBar'; + +let storage: LocalStorage = LocalStorage.GetShared(); + +@Entry(storage) +@Component +struct AbilityOutOfSyncPage { + // 判断是否关联ability的变量 + @State isAbility: boolean = true; + @State title: Resource = $r('app.string.localStorage_abilitytitle'); + // 和主页、Page1、Page2不同步夜间模式状态 + @LocalStorageLink('currentModelStatus') currentModelStatus: boolean = true; + // 和主页、Page1、Page2不同步内容字体大小 + @LocalStorageLink('contentFontSize') contentFontSize: number = 18; + + build() { + Column() { + if (this.currentModelStatus) { + TitleBarDark({ title: $title, isAbility: true }) + } else { + TitleBar({ title: $title, isAbility: true }) + } + CodeView({ title: $title, isShowTitle: false }) { + Column({ space: 30 }) { + // 查看源码 + ViewCodeText({ webSrc: $rawfile('AbilityOutOfSyncPage.ets.html') }) + Text($r('app.string.localStorage_both_data_binding')) + .fontSize(this.contentFontSize) + .fontColor(this.currentModelStatus ? $r('app.color.color_white') : $r('app.color.tips_font_color')) + .width('100%') + .textAlign(TextAlign.Center) + Text($r('app.string.localStorage_single_data_binding')) + .fontSize(this.contentFontSize) + .fontColor(this.currentModelStatus ? $r('app.color.color_white') : $r('app.color.tips_font_color')) + .width('100%') + .textAlign(TextAlign.Center) + Text($r('app.string.enter_ability_outofsync_text')) + .fontSize(this.contentFontSize) + .fontColor(this.currentModelStatus ? $r('app.color.color_white') : $r('app.color.tips_font_color')) + .width('100%') + .textAlign(TextAlign.Center) + Button() { + Text(this.currentModelStatus ? $r('app.string.close_nightmode') : $r('app.string.start_nightmode')) + .fontColor(this.currentModelStatus ? $r('app.color.color_white') : $r('app.color.button_text_color')) + .fontSize(this.contentFontSize) + .width('60%') + .textAlign(TextAlign.Center) + } + .id('nightModeSwitchFour') + .type(ButtonType.Capsule) + .backgroundColor($r('app.color.button_background_color')) + .padding($r('app.float.page_padding')) + .onClick(() => { + // 更新控制夜间模式状态的变量数据,@LocalStorageLink和@LocalStorageProp关联的数据变量刷新 + this.currentModelStatus = !this.currentModelStatus; + }) + } + .height('100%') + .padding($r('app.float.page_padding')) + } + } + .width('100%') + .height('100%') + .backgroundColor(this.currentModelStatus ? $r('app.color.nightnode_color') : $r('app.color.background_shallow_grey')) + } + + aboutToDisappear(): void { + AppStorage.SetOrCreate('sideBarShow', false); + } +} \ No newline at end of file diff --git a/sample/EnhanceSampleArk1.2/StateManagement/entry/src/main/ets/pages/applylevelstagemanagement/abilityglobaldatasync/LocalStorageLinkPage.ets b/sample/EnhanceSampleArk1.2/StateManagement/entry/src/main/ets/pages/applylevelstagemanagement/abilityglobaldatasync/LocalStorageLinkPage.ets new file mode 100644 index 0000000000000000000000000000000000000000..585f6575526f86bcbd7068b7f5bb98c98d7a549c --- /dev/null +++ b/sample/EnhanceSampleArk1.2/StateManagement/entry/src/main/ets/pages/applylevelstagemanagement/abilityglobaldatasync/LocalStorageLinkPage.ets @@ -0,0 +1,87 @@ +/* + * Copyright (c) 2023 Huawei Device 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 { CodeView } from '../../../commoncomponents/CodeView'; +import { ViewCodeText } from '../../../commoncomponents/ViewCodeText'; +import { TitleBarDark } from '../../../commoncomponents/TitleBarDark'; +import { TitleBar } from '../../../commoncomponents/TitleBar'; + +let storage: LocalStorage = LocalStorage.GetShared(); + +@Entry(storage) +@Component +struct StorageLinkAbilityPage { + @State title: Resource = $r('app.string.localStorage_pagetitletwo'); + // 和主页、Page2双向同步夜间模式状态 + @LocalStorageLink('currentModelStatus') currentModelStatus: boolean = true; + // 和主页、Page2双向同步内容字体大小 + @LocalStorageLink('contentFontSize') contentFontSize: number = 18; + + build() { + Column() { + if (this.currentModelStatus) { + TitleBarDark({ title: $title }) + } else { + TitleBar({ title: $title }) + } + CodeView({ title: $title, isShowTitle: false }) { + Column({ space: 30 }) { + // 查看源码 + ViewCodeText({ webSrc: $rawfile('LocalStorageLinkPage.ets.html') }) + Text($r('app.string.localStorage_both_data_binding')) + .fontSize(this.contentFontSize) + .fontColor(this.currentModelStatus ? $r('app.color.color_white') : $r('app.color.tips_font_color')) + .width('100%') + .textAlign(TextAlign.Center) + Text($r('app.string.localStorage_single_data_binding')) + .fontSize(this.contentFontSize) + .fontColor(this.currentModelStatus ? $r('app.color.color_white') : $r('app.color.tips_font_color')) + .width('100%') + .textAlign(TextAlign.Center) + Button() { + Text(this.currentModelStatus ? $r('app.string.close_nightmode') : $r('app.string.start_nightmode')) + .fontColor(this.currentModelStatus ? $r('app.color.color_white') : $r('app.color.button_text_color')) + .fontSize(this.contentFontSize) + .width('60%') + .textAlign(TextAlign.Center) + } + .id('nightModeSwitchThree') + .type(ButtonType.Capsule) + .backgroundColor($r('app.color.button_background_color')) + .padding($r('app.float.page_padding')) + .onClick(() => { + // 更新控制夜间模式状态的变量数据,@LocalStorageLink和@StorageProp关联的数据变量刷新 + this.currentModelStatus = !this.currentModelStatus; + }) + + Text($r('app.string.localStorage_nigntmode_both_binding')) + .fontSize(this.contentFontSize) + .fontColor(this.currentModelStatus ? $r('app.color.color_white') : $r('app.color.tips_font_color')) + .width('100%') + .textAlign(TextAlign.Center) + } + .height('100%') + .padding($r('app.float.page_padding')) + } + } + .width('100%') + .height('100%') + .backgroundColor(this.currentModelStatus ? $r('app.color.nightnode_color') : $r('app.color.background_shallow_grey')) + } + + aboutToDisappear(): void { + AppStorage.SetOrCreate('sideBarShow', false); + } +} \ No newline at end of file diff --git a/sample/EnhanceSampleArk1.2/StateManagement/entry/src/main/ets/pages/applylevelstagemanagement/abilityglobaldatasync/LocalStoragePropPage.ets b/sample/EnhanceSampleArk1.2/StateManagement/entry/src/main/ets/pages/applylevelstagemanagement/abilityglobaldatasync/LocalStoragePropPage.ets new file mode 100644 index 0000000000000000000000000000000000000000..919d3fc2430914ce8f2d09c2f02b59e4110d3f99 --- /dev/null +++ b/sample/EnhanceSampleArk1.2/StateManagement/entry/src/main/ets/pages/applylevelstagemanagement/abilityglobaldatasync/LocalStoragePropPage.ets @@ -0,0 +1,123 @@ +/* + * Copyright (c) 2023 Huawei Device 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 { CodeView } from '../../../commoncomponents/CodeView'; +import { ViewCodeText } from '../../../commoncomponents/ViewCodeText'; +import { TitleBarDark } from '../../../commoncomponents/TitleBarDark'; +import { TitleBar } from '../../../commoncomponents/TitleBar'; + +let storage: LocalStorage = LocalStorage.GetShared(); + +@Entry(storage) +@Component +struct StoragePropAbilityPage { + @State title: Resource = $r('app.string.localStorage_pagetitleone'); + // 初始化字体大小最小值 + private minFontSize: number = 10; + // 和主页、Page1双向同步夜间模式状态 + @LocalStorageLink('currentModelStatus') currentModelStatus: boolean = true; + // 和主页、Page1单向同步内容字体大小 + @LocalStorageProp('contentFontSize') contentFontSize: number = 18; + + build() { + Column() { + if (this.currentModelStatus) { + TitleBarDark({ title: $title }) + } else { + TitleBar({ title: $title }) + } + CodeView({ title: $title, isShowTitle: false }) { + Column({ space: 20 }) { + // 查看源码 + ViewCodeText({ webSrc: $rawfile('LocalStoragePropPage.ets.html') }) + Text($r('app.string.localStorage_both_data_binding')) + .fontSize(this.contentFontSize) + .fontColor(this.currentModelStatus ? $r('app.color.color_white') : $r('app.color.tips_font_color')) + .width('100%') + .textAlign(TextAlign.Center) + Text($r('app.string.localStorage_single_data_binding')) + .fontSize(this.contentFontSize) + .fontColor(this.currentModelStatus ? $r('app.color.color_white') : $r('app.color.tips_font_color')) + .width('100%') + .textAlign(TextAlign.Center) + Button() { + Text(this.currentModelStatus ? $r('app.string.close_nightmode') : $r('app.string.start_nightmode')) + .fontColor(this.currentModelStatus ? $r('app.color.color_white') : $r('app.color.button_text_color')) + .fontSize(this.contentFontSize) + .width('60%') + .textAlign(TextAlign.Center) + } + .id('nightModeSwitchTwo') + .padding($r('app.float.page_padding')) + .type(ButtonType.Capsule) + .backgroundColor($r('app.color.button_background_color')) + .onClick(() => { + // 更新控制夜间模式状态的变量数据,@StorageLink和@StorageProp关联的数据变量刷新 + this.currentModelStatus = !this.currentModelStatus; + }) + + Text($r('app.string.localStorage_nigntmode_both_binding')) + .fontSize(this.contentFontSize) + .fontColor(this.currentModelStatus ? $r('app.color.color_white') : $r('app.color.tips_font_color')) + .width('100%') + .textAlign(TextAlign.Center) + // slider模块控制字体大小 + Column() { + Text($r('app.string.fontSize_text')) + .fontSize(this.contentFontSize) + .fontColor(this.currentModelStatus ? $r('app.color.color_white') : $r('app.color.tips_font_color')) + .width('100%') + .textAlign(TextAlign.Center) + Row() { + Text(`${this.minFontSize}`) + .fontColor(this.currentModelStatus ? $r('app.color.color_white') : $r('app.color.tips_font_color')) + .fontSize($r('app.float.tips_font_size')) + Slider({ + value: this.contentFontSize, + min: 10, // 字体大小最小值 + max: 30, // 字体大小最大值 + style: SliderStyle.OutSet + }) + .showTips(true) + .onChange((value: number, mode: SliderChangeMode) => { + // 更新控制字体大小的变量数据,@LocalStorageLink关联的数据变量不刷新同步 + this.contentFontSize = value; + }) + // toFixed(0)将滑动条返回值处理为整数精度 + Text(this.contentFontSize.toFixed(0)) + .fontColor(this.currentModelStatus ? $r('app.color.color_white') : $r('app.color.tips_font_color')) + .fontSize($r('app.float.tips_font_size')) + } + .width('80%') + }.margin({ top: 50 }) + + Text($r('app.string.localStorage_single_fontsize_binding')) + .fontSize(this.contentFontSize) + .fontColor(this.currentModelStatus ? $r('app.color.color_white') : $r('app.color.tips_font_color')) + .width('100%') + .textAlign(TextAlign.Center) + } + .padding($r('app.float.page_padding')) + } + } + .width('100%') + .height('100%') + .backgroundColor(this.currentModelStatus ? $r('app.color.nightnode_color') : $r('app.color.background_shallow_grey')) + } + + aboutToDisappear(): void { + AppStorage.SetOrCreate('sideBarShow', false); + } +} \ No newline at end of file diff --git a/sample/EnhanceSampleArk1.2/StateManagement/entry/src/main/ets/pages/applylevelstagemanagement/applyglobaldatasync/ApplyGlobalDataSync.ets b/sample/EnhanceSampleArk1.2/StateManagement/entry/src/main/ets/pages/applylevelstagemanagement/applyglobaldatasync/ApplyGlobalDataSync.ets new file mode 100644 index 0000000000000000000000000000000000000000..01bacde198036cb0435fe66c71e28987bc45ca49 --- /dev/null +++ b/sample/EnhanceSampleArk1.2/StateManagement/entry/src/main/ets/pages/applylevelstagemanagement/applyglobaldatasync/ApplyGlobalDataSync.ets @@ -0,0 +1,47 @@ +/* + * Copyright (c) 2023 Huawei Device 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 ApplyGlobalDataSyncCode from './ApplyGlobalDataSyncCode'; +import { CodeView } from '../../../commoncomponents/CodeView'; +import { TitleBarDark } from '../../../commoncomponents/TitleBarDark'; +import { TitleBar } from '../../../commoncomponents/TitleBar'; + +@Entry +@Component +struct ApplyGlobalDataSync { + @State title: Resource = $r('app.string.application_storage_ui'); + // 当前夜间模式的状态 + @StorageLink('currentModelStatus') currentModelStatus: boolean = true; + + build() { + Column() { + // 展示不同模式状态下的标题 + if (this.currentModelStatus) { + TitleBarDark({ title: $title }) + } else { + TitleBar({ title: $title }) + } + CodeView({ title: $title, isShowTitle: false }) { + ApplyGlobalDataSyncCode() + } + }.width('100%') + .height('100%') + .backgroundColor(this.currentModelStatus ? $r('app.color.nightnode_color') : $r('app.color.background_shallow_grey')) + } + + aboutToDisappear(): void { + AppStorage.SetOrCreate('sideBarShow', false); + } +} \ No newline at end of file diff --git a/sample/EnhanceSampleArk1.2/StateManagement/entry/src/main/ets/pages/applylevelstagemanagement/applyglobaldatasync/ApplyGlobalDataSyncCode.ets b/sample/EnhanceSampleArk1.2/StateManagement/entry/src/main/ets/pages/applylevelstagemanagement/applyglobaldatasync/ApplyGlobalDataSyncCode.ets new file mode 100644 index 0000000000000000000000000000000000000000..f0d6ac51887d7cb1381060861825719dcf2799af --- /dev/null +++ b/sample/EnhanceSampleArk1.2/StateManagement/entry/src/main/ets/pages/applylevelstagemanagement/applyglobaldatasync/ApplyGlobalDataSyncCode.ets @@ -0,0 +1,125 @@ +/* + * Copyright (c) 2023 Huawei Device 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 { ViewCodeText } from '../../../commoncomponents/ViewCodeText'; +import { startSpecifiedAbility } from '../../../utils/StartAbilityUtils'; + +// 声明一个上下文信息 +const CONTEXT: common.UIAbilityContext = getContext(this) as common.UIAbilityContext; + +@Component +export default struct ApplyGlobalDataSyncCode { + // 和Ability1、Ability2页面双向同步内容字体大小 + @StorageLink('contentFontSize') contentFontSize: number = 18; + // 和Ability1、Ability2页面双向同步夜间模式状态 + @StorageLink('currentModelStatus') currentModelStatus: boolean = true; + // 初始化字体大小最小值 + private minFontSize: number = 10; + + build() { + Column({ space: 10 }) { + // 查看源码 + ViewCodeText({ webSrc: $rawfile('ApplyGlobalDataSyncCode.ets.html') }) + Row() { + Text($r('app.string.nightmode')) + .fontSize(this.contentFontSize) + .fontColor(this.currentModelStatus ? $r('app.color.color_white') : $r('app.color.tips_font_color')) + // 开发控制夜间模式 + Toggle({ type: ToggleType.Switch, isOn: this.currentModelStatus }) + .id('nightModeSwitch') + .selectedColor(Color.Blue) + .switchPointColor(Color.White) + .onChange((isOn: boolean) => { + // 更新控制夜间模式状态的变量数据,@StorageLink和@StorageLink关联的数据变量刷新 + this.currentModelStatus = isOn; + AppStorage.SetOrCreate('currentModelStatus', this.currentModelStatus); + }) + }.justifyContent(FlexAlign.SpaceAround) + .width('70%') + .border({ radius: 50, color: Color.Grey, width: $r('app.float.border_width') }) + + Text($r('app.string.nightmode_text')) + .fontSize(this.contentFontSize) + .fontColor(this.currentModelStatus ? $r('app.color.color_white') : $r('app.color.tips_font_color')) + .textAlign(TextAlign.Center) + // slider滑动模块控制字体大小 + Column() { + Text($r('app.string.fontSize_text')) + .fontSize(this.contentFontSize) + .fontColor(this.currentModelStatus ? $r('app.color.color_white') : $r('app.color.tips_font_color')) + .width('100%') + .textAlign(TextAlign.Center) + Row() { + Text(`${this.minFontSize}`) + .fontColor(this.currentModelStatus ? $r('app.color.color_white') : $r('app.color.tips_font_color')) + .fontSize($r('app.float.tips_font_size')) + Slider({ + value: this.contentFontSize, + min: this.minFontSize, // 字体大小最小值 + max: 30, // 字体大小最大值 + style: SliderStyle.OutSet + }) + .showTips(true) + .onChange((value: number, mode: SliderChangeMode) => { + // 更新控制字体大小状态的变量数据,@StorageLink和@StorageProp关联的数据变量刷新 + this.contentFontSize = value; + AppStorage.SetOrCreate('contentFontSize', this.contentFontSize); + }) + // toFixed(0)将滑动条返回值处理为整数精度 + Text(this.contentFontSize.toFixed(0)) + .fontColor(this.currentModelStatus ? $r('app.color.color_white') : $r('app.color.tips_font_color')) + .fontSize($r('app.float.tips_font_size')) + } + .width('80%') + }.margin({ top: 50 }) + + Text($r('app.string.fontSize_singlesync_textone')) + .fontSize(this.contentFontSize) + .fontColor(this.currentModelStatus ? $r('app.color.color_white') : $r('app.color.tips_font_color')) + .width('100%') + .textAlign(TextAlign.Center) + Button() { + Text($r('app.string.enter_abilityone')) + .fontColor(this.currentModelStatus ? $r('app.color.color_white') : $r('app.color.button_text_color')) + .fontSize(this.contentFontSize) + .width('60%') + .textAlign(TextAlign.Center) + } + .id('enterAbilityOne') + .type(ButtonType.Capsule) + .backgroundColor($r('app.color.button_background_color')) + .padding($r('app.float.page_padding')) + .onClick(() => { + startSpecifiedAbility(CONTEXT, 'StoragePropAbility'); + }) + + Button() { + Text($r('app.string.enter_abilitytwo')) + .fontColor(this.currentModelStatus ? $r('app.color.color_white') : $r('app.color.button_text_color')) + .fontSize(this.contentFontSize) + .width('60%') + .textAlign(TextAlign.Center) + } + .id('enterAbilityTwo') + .type(ButtonType.Capsule) + .backgroundColor($r('app.color.button_background_color')) + .padding($r('app.float.page_padding')) + .onClick(() => { + startSpecifiedAbility(CONTEXT, 'StorageLinkAbility'); + }) + }.padding($r('app.float.page_padding')) + } +} \ No newline at end of file diff --git a/sample/EnhanceSampleArk1.2/StateManagement/entry/src/main/ets/pages/applylevelstagemanagement/applyglobaldatasync/StorageLinkAbilityPage.ets b/sample/EnhanceSampleArk1.2/StateManagement/entry/src/main/ets/pages/applylevelstagemanagement/applyglobaldatasync/StorageLinkAbilityPage.ets new file mode 100644 index 0000000000000000000000000000000000000000..f7ba7a69e903ff39c588f9e62147c373a5826159 --- /dev/null +++ b/sample/EnhanceSampleArk1.2/StateManagement/entry/src/main/ets/pages/applylevelstagemanagement/applyglobaldatasync/StorageLinkAbilityPage.ets @@ -0,0 +1,86 @@ +/* + * Copyright (c) 2023 Huawei Device 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 { CodeView } from '../../../commoncomponents/CodeView'; +import { ViewCodeText } from '../../../commoncomponents//ViewCodeText'; +import { TitleBarDark } from '../../../commoncomponents/TitleBarDark'; +import { TitleBar } from '../../../commoncomponents/TitleBar'; + +@Entry +@Component +struct StorageLinkAbilityPage { + @State title: Resource = $r('app.string.abilitytwo_page'); + // 判断是否关联ability的变量 + @State isAbility: boolean = true; + // 和主页、Ability1页面双向同步夜间模式状态 + @StorageLink('currentModelStatus') currentModelStatus: boolean = true; + // 和主页、Ability1页面双向同步内容字体大小 + @StorageLink('contentFontSize') contentFontSize: number = 18; + + build() { + Column() { + if (this.currentModelStatus) { + TitleBarDark({ title: $title, isAbility: true }) + } else { + TitleBar({ title: $title, isAbility: true }) + } + CodeView({ title: $title, isShowTitle: false }) { + Column({ space: 30 }) { + // 查看源码 + ViewCodeText({ webSrc: $rawfile('StorageLinkAbilityPage.ets.html') }) + Text($r('app.string.both_data_binding')) + .fontSize(this.contentFontSize) + .fontColor(this.currentModelStatus ? $r('app.color.color_white') : $r('app.color.tips_font_color')) + .width('100%') + .textAlign(TextAlign.Center) + Text($r('app.string.single_data_binding')) + .fontSize(this.contentFontSize) + .fontColor(this.currentModelStatus ? $r('app.color.color_white') : $r('app.color.tips_font_color')) + .width('100%') + .textAlign(TextAlign.Center) + Button() { + Text(this.currentModelStatus ? $r('app.string.close_nightmode') : $r('app.string.start_nightmode')) + .fontColor(this.currentModelStatus ? $r('app.color.color_white') : $r('app.color.button_text_color')) + .fontSize(this.contentFontSize) + .width('60%') + .textAlign(TextAlign.Center) + } + .id('nightModeSwitchThree') + .type(ButtonType.Capsule) + .backgroundColor($r('app.color.button_background_color')) + .padding($r('app.float.page_padding')) + .onClick(() => { + // 更新控制夜间模式状态的变量数据,@StorageLink和@StorageProp关联的数据变量刷新 + this.currentModelStatus = !this.currentModelStatus; + }) + + Text($r('app.string.nigntmode_both_binding')) + .fontSize(this.contentFontSize) + .fontColor(this.currentModelStatus ? $r('app.color.color_white') : $r('app.color.tips_font_color')) + .width('100%') + .textAlign(TextAlign.Center) + } + .padding($r('app.float.page_padding')) + } + }.width('100%') + .height('100%') + .backgroundColor(this.currentModelStatus ? $r('app.color.nightnode_color') : $r('app.color.background_shallow_grey')) + } + + aboutToDisappear(): void { + AppStorage.SetOrCreate('sideBarShow', false); + } +} \ No newline at end of file diff --git a/sample/EnhanceSampleArk1.2/StateManagement/entry/src/main/ets/pages/applylevelstagemanagement/applyglobaldatasync/StoragePropAbilityPage.ets b/sample/EnhanceSampleArk1.2/StateManagement/entry/src/main/ets/pages/applylevelstagemanagement/applyglobaldatasync/StoragePropAbilityPage.ets new file mode 100644 index 0000000000000000000000000000000000000000..d585ec4b7070927edd3ee586c2902c349c0a0856 --- /dev/null +++ b/sample/EnhanceSampleArk1.2/StateManagement/entry/src/main/ets/pages/applylevelstagemanagement/applyglobaldatasync/StoragePropAbilityPage.ets @@ -0,0 +1,121 @@ +/* + * Copyright (c) 2023 Huawei Device 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 { CodeView } from '../../../commoncomponents/CodeView'; +import { ViewCodeText } from '../../../commoncomponents/ViewCodeText'; +import { TitleBarDark } from '../../../commoncomponents/TitleBarDark'; +import { TitleBar } from '../../../commoncomponents/TitleBar'; + +@Entry +@Component +struct StoragePropAbilityPage { + @State title: Resource = $r('app.string.abilityone_page'); + // 初始化字体大小最小值 + private minFontSize: number = 10; + // 和主页、Ability2页面双向同步夜间模式状态 + @StorageLink('currentModelStatus') currentModelStatus: boolean = true; + // 和主页、Ability2页面单向同步内容字体大小 + @StorageProp('contentFontSize') contentFontSize: number = 18; + + build() { + Column() { + if (this.currentModelStatus) { + TitleBarDark({ title: $title, isAbility: true }) + } else { + TitleBar({ title: $title, isAbility: true }) + } + CodeView({ title: $title, isShowTitle: false }) { + Column({ space: 20 }) { + // 查看源码 + ViewCodeText({ webSrc: $rawfile('StoragePropAbilityPage.ets.html') }) + Text($r('app.string.both_data_binding')) + .fontSize(this.contentFontSize) + .fontColor(this.currentModelStatus ? $r('app.color.color_white') : $r('app.color.tips_font_color')) + .width('100%') + .textAlign(TextAlign.Center) + Text($r('app.string.single_data_binding')) + .fontSize(this.contentFontSize) + .fontColor(this.currentModelStatus ? $r('app.color.color_white') : $r('app.color.tips_font_color')) + .width('100%') + .textAlign(TextAlign.Center) + Button() { + Text(this.currentModelStatus ? $r('app.string.close_nightmode') : $r('app.string.start_nightmode')) + .fontColor(this.currentModelStatus ? $r('app.color.color_white') : $r('app.color.button_text_color')) + .fontSize(this.contentFontSize) + .width('60%') + .textAlign(TextAlign.Center) + } + .id('nightModeSwitchTwo') + .padding($r('app.float.page_padding')) + .type(ButtonType.Capsule) + .backgroundColor($r('app.color.button_background_color')) + .onClick(() => { + // 更新控制夜间模式状态的变量数据,@StorageLink和@StorageProp关联的数据变量刷新 + this.currentModelStatus = !this.currentModelStatus; + }) + + Text($r('app.string.nigntmode_both_binding')) + .fontSize(this.contentFontSize) + .fontColor(this.currentModelStatus ? $r('app.color.color_white') : $r('app.color.tips_font_color')) + .width('100%') + .textAlign(TextAlign.Center) + // slider模块控制字体大小 + Column() { + Text($r('app.string.fontSize_text')) + .fontSize(this.contentFontSize) + .fontColor(this.currentModelStatus ? $r('app.color.color_white') : $r('app.color.tips_font_color')) + .width('100%') + .textAlign(TextAlign.Center) + Row() { + Text(`${this.minFontSize}`) + .fontColor(this.currentModelStatus ? $r('app.color.color_white') : $r('app.color.tips_font_color')) + .fontSize($r('app.float.tips_font_size')) + Slider({ + value: this.contentFontSize, + min: this.minFontSize, + max: 30, // 字体大小最大值 + style: SliderStyle.OutSet + }) + .showTips(true) + .onChange((value: number, mode: SliderChangeMode) => { + // 更新控制字体大小的变量数据,@StorageLink关联的数据变量不刷新同步 + this.contentFontSize = value; + }) + // toFixed(0)将滑动条返回值处理为整数精度 + Text(this.contentFontSize.toFixed(0)) + .fontColor(this.currentModelStatus ? $r('app.color.color_white') : $r('app.color.tips_font_color')) + .fontSize($r('app.float.tips_font_size')) + } + .width('80%') + }.margin({ top: 50 }) + + Text($r('app.string.single_fontsize_binding')) + .fontSize(this.contentFontSize) + .fontColor(this.currentModelStatus ? $r('app.color.color_white') : $r('app.color.tips_font_color')) + .width('100%') + .textAlign(TextAlign.Center) + } + .padding($r('app.float.page_padding')) + } + } + .width('100%') + .height('100%') + .backgroundColor(this.currentModelStatus ? $r('app.color.nightnode_color') : $r('app.color.background_shallow_grey')) + } + + aboutToDisappear(): void { + AppStorage.SetOrCreate('sideBarShow', false); + } +} \ No newline at end of file diff --git a/sample/EnhanceSampleArk1.2/StateManagement/entry/src/main/ets/pages/applylevelstagemanagement/model/AbilityConfigType.ts b/sample/EnhanceSampleArk1.2/StateManagement/entry/src/main/ets/pages/applylevelstagemanagement/model/AbilityConfigType.ts new file mode 100644 index 0000000000000000000000000000000000000000..d9e9c567541afb95ca8ed675e29f029fe995c815 --- /dev/null +++ b/sample/EnhanceSampleArk1.2/StateManagement/entry/src/main/ets/pages/applylevelstagemanagement/model/AbilityConfigType.ts @@ -0,0 +1,19 @@ +/* + * Copyright (c) 2023 Huawei Device 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. + */ + +export type AbilityConfigType = { + bundleName: string, + abilityName: string +}; \ No newline at end of file diff --git a/sample/EnhanceSampleArk1.2/StateManagement/entry/src/main/ets/pages/home/Home.ets b/sample/EnhanceSampleArk1.2/StateManagement/entry/src/main/ets/pages/home/Home.ets new file mode 100644 index 0000000000000000000000000000000000000000..ba637567f67399e282343e8a8db09a5c6d8ad0c7 --- /dev/null +++ b/sample/EnhanceSampleArk1.2/StateManagement/entry/src/main/ets/pages/home/Home.ets @@ -0,0 +1,65 @@ +/* + * Copyright (c) 2023 Huawei Device 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 { FirstLevelCategory } from './model/CategoricalDataType'; +import { HOME_TABS } from './data/HomeData'; +import { TabContentNavigation } from './TabContentNavigation'; + +@Entry +@Component +struct Home { + // 初始化tabsBar的index值为0 + @State tabsIndex: number = 0; + @StorageLink('currentBreakpoint') curBp: string = 'sm'; + + build() { + Tabs({ barPosition: this.curBp === 'sm' ? BarPosition.End : BarPosition.Start }) { + ForEach(HOME_TABS, (item: FirstLevelCategory, index: number) => { + TabContent() { + TabContentNavigation({ categories: item.childNodes }) + } + .tabBar(this.CustomTabBar(item, index)) + }, item => JSON.stringify(item)) + } + .vertical(this.curBp === 'sm' ? false : true) + // 大型设备tabbar的高度为40%,小型设备的高度为56vp + .barHeight(this.curBp === 'sm' ? '56vp' : '40%') + // 大型设备tabbar的宽度为56vp,小型设备的宽度为100% + .barWidth(this.curBp === 'sm' ? '100%' : '56vp') + .barMode(BarMode.Fixed) + .backgroundColor($r('app.color.background_shallow_grey')) + .onChange((index: number) => { + this.tabsIndex = index; + }) + } + + @Builder CustomTabBar(item: FirstLevelCategory, index: number) { + Column() { + Image(this.tabsIndex === index ? item.iconSelected : item.icon) + .width(24) + .height(24) + .margin({ bottom: 4 }) + + Text(item.tabBarName) + .fontSize(10) + .fontFamily('HarmonyHeiTi-Medium') + .fontColor(this.tabsIndex === index ? $r('app.color.tab_bar_select') : $r('app.color.tab_bar_unselect')) + } + .width('100%') + .id(`tabBar${index}`) + .padding({ top: 6, bottom: 6 }) + .alignItems(HorizontalAlign.Center) + } +} \ No newline at end of file diff --git a/sample/EnhanceSampleArk1.2/StateManagement/entry/src/main/ets/pages/home/TabContentNavigation.ets b/sample/EnhanceSampleArk1.2/StateManagement/entry/src/main/ets/pages/home/TabContentNavigation.ets new file mode 100644 index 0000000000000000000000000000000000000000..96c4d2696d7c1a892f9237b02edb0d4c501c04e2 --- /dev/null +++ b/sample/EnhanceSampleArk1.2/StateManagement/entry/src/main/ets/pages/home/TabContentNavigation.ets @@ -0,0 +1,176 @@ +/* + * Copyright (c) 2023 Huawei Device 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 router from '@ohos.router'; +import { SecondLevelCategory, ThirdLevelCategory, FourthLevelCategory } from './model/CategoricalDataType'; + +@Extend(Column) function ColumnStyle() { + .width('100%') + .borderRadius(24) + .backgroundColor(Color.White) + .padding({ left: 12, right: 12, bottom: 4, top: 4 }) +} + +@Preview +@Component +export struct TabContentNavigation { + private categories: ThirdLevelCategory[] | SecondLevelCategory[] = []; + + hasSecondLevelCategory(category): boolean { + return category && category.tag ? false : true; + } + + build() { + Column() { + List() { + if (this.categories.length > 0 && this.hasSecondLevelCategory(this.categories[0])) { + ForEach(this.categories, (secondLevelCategory: SecondLevelCategory, secondLevelCategoryIndex: number) => { + ListItem() { + Column() { + Text(secondLevelCategory.title) + .height(48) + .fontSize(14) + .width('100%') + .textAlign(TextAlign.Start) + .fontFamily('HarmonyHeiTi-Medium') + .fontColor($r('app.color.font_color_shallow')) + .padding({ bottom: 4, top: 4, left: 24 }) + + Column() { + ForEach(secondLevelCategory.childNodes, (thirdLevelCategory: ThirdLevelCategory, + thirdLevelCategoryIndex: number) => { + ThirdLevelNavigation({ + thirdLevelCategory: thirdLevelCategory, + secondLevelCategoryIndex: secondLevelCategoryIndex, + ThirdLevelNavigationIndex: thirdLevelCategoryIndex + }) + }) + } + .ColumnStyle() + } + } + }) + } else { + ForEach(this.categories, (thirdLevelCategory: ThirdLevelCategory) => { + ListItem() { + Column() { + ThirdLevelNavigation({ thirdLevelCategory: thirdLevelCategory }) + } + .ColumnStyle() + } + .margin({ top: 4, bottom: 4 }) + }) + } + } + .width('100%') + .layoutWeight(1) + .padding({ left: 16, right: 16, top: 4 }) + + Blank() + + Divider() + .height(0.75) + .width('100%') + .alignSelf(ItemAlign.Baseline) + .color($r('app.color.tab_bar_divider')) + } + .height('100%') + .padding({ top: 12 }) + } +} + +@Component +struct ThirdLevelNavigation { + @State isUnfold: boolean = false; + private thirdLevelCategory: ThirdLevelCategory; + private ThirdLevelNavigationIndex: number; + private secondLevelCategoryIndex: number; + + build() { + Column() { + Row() { + Text(this.thirdLevelCategory.title) + .fontSize(16) + .margin({ left: 16 }) + .fontFamily('HarmonyHeiTi-Medium') + .fontColor($r('app.color.font_color_dark')) + + Blank() + + if (this.thirdLevelCategory.childNodes) { + Image(this.isUnfold ? $r('app.media.ic_down_arrow') : $r('app.media.ic_right_arrow')) + .width(this.isUnfold ? 24 : 12) + .height(this.isUnfold ? 12 : 24) + .margin({ right: this.isUnfold ? 0 : 6 }) + } + } + .height(56) + .width('100%') + .onClick(() => { + if (this.thirdLevelCategory.childNodes === undefined) { + // Click to jump to the corresponding page + router.push({ + url: this.thirdLevelCategory.url + }); + } else { + this.isUnfold = !this.isUnfold; + } + }) + + // Click to expand the fourth-level category + if (this.isUnfold) { + ForEach(this.thirdLevelCategory.childNodes, (fourthLevelCategory: FourthLevelCategory) => { + Column() { + Divider() + .height(1) + .opacity(0.2) + .margin({ left: 42, right: 8 }) + .color($r('app.color.font_color_dark')) + + FourthLevelNavigation({ fourthLevelCategory: fourthLevelCategory }) + } + }, item => JSON.stringify(item)) + } + } + // 整体字符串折行会被识别出来,导致功能异常,只能放在单独一行,1和0分别为首页标题层级index + .id(`secondLevelMenu${this.secondLevelCategoryIndex}${this.secondLevelCategoryIndex === 1 ? 0 : this.ThirdLevelNavigationIndex}`) + } +} + +@Component +struct FourthLevelNavigation { + private fourthLevelCategory: FourthLevelCategory; + + build() { + Row() { + Text(this.fourthLevelCategory.title) + .fontSize(16) + .layoutWeight(1) + .margin({ left: 42 }) + .align(Alignment.Start) + .fontFamily('HarmonyHeiTi-Medium') + .fontColor($r('app.color.font_color_dark')) + Blank() + } + .height(48) + .width('100%') + .onClick(() => { + // Click to jump to the corresponding page + router.push({ + url: this.fourthLevelCategory.url + }); + }) + } +} \ No newline at end of file diff --git a/sample/EnhanceSampleArk1.2/StateManagement/entry/src/main/ets/pages/home/data/HomeData.ets b/sample/EnhanceSampleArk1.2/StateManagement/entry/src/main/ets/pages/home/data/HomeData.ets new file mode 100644 index 0000000000000000000000000000000000000000..69462d47b80bff6e8bf74ccb9598e31646120e71 --- /dev/null +++ b/sample/EnhanceSampleArk1.2/StateManagement/entry/src/main/ets/pages/home/data/HomeData.ets @@ -0,0 +1,127 @@ +/* + * Copyright (c) 2023 Huawei Device 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 { + FirstLevelCategory, + FourthLevelCategory, + SecondLevelCategory, + ThirdLevelCategory +} from '../model/CategoricalDataType'; + + +const DECORATED_OBJECT_TYPE: FourthLevelCategory[] = [ + { + title: $r('app.string.base_type'), + url: 'pages/pagelevelstagemanagement/singlecomponentstatevariables/decoratedobjecttype/basetype/BaseType' + }, + { + title: $r('app.string.array_type'), + url: 'pages/pagelevelstagemanagement/singlecomponentstatevariables/decoratedobjecttype/arraytype/ArrayType' + }, + { + title: $r('app.string.class_type'), + url: 'pages/pagelevelstagemanagement/singlecomponentstatevariables/decoratedobjecttype/classobjecttype/ClassObjectType' + } +]; + +const UPDATE_PRINCIPLE: FourthLevelCategory[] = [ + { + title: $r('app.string.only_update_bound_components'), + url: 'pages/pagelevelstagemanagement/singlecomponentstatevariables/updatetactics/updateboundcomponent/UpdateBoundComponent' + } +]; + +const SINGLE_COMPONENT_CATEGORY: ThirdLevelCategory[] = [ + { + tag: 1, + title: $r('app.string.decorated_object_type'), + childNodes: DECORATED_OBJECT_TYPE + }, + { + tag: 1, + title: $r('app.string.update_principle'), + childNodes: UPDATE_PRINCIPLE + } +]; + +const PARENT_CHILD_SYNC: FourthLevelCategory[] = [ + { + title: $r('app.string.single_and_two_way_sync'), + url: 'pages/pagelevelstagemanagement/multicompomentssync/parentchildcomponentsync/uniandbidirectionsync/UniAndBidirectionSync' + }, + { + title: $r('app.string.partial_sync'), + url: 'pages/pagelevelstagemanagement/multicompomentssync/parentchildcomponentsync/parentchildpartialcontentsync/ParentChildPartialContentSync' + } +]; + +const MULTI_COMPONENTS_CATEGORY: ThirdLevelCategory[] = [ + { + tag: 1, + title: $r('app.string.parent_child_sync'), + childNodes: PARENT_CHILD_SYNC + }, + { + tag: 1, + title: $r('app.string.parent_descendent_sync'), + url: 'pages/pagelevelstagemanagement/multicompomentssync/deepnestcomponentssync/DeepNestComponentsSync' + }, + { + tag: 1, + title: $r('app.string.brother_sync'), + url: 'pages/pagelevelstagemanagement/multicompomentssync/brothercomponentssync/BrotherComponentSync' + } +]; + +const PAGE_LEVEL_CATEGORY: SecondLevelCategory[] = [ + { + title: $r('app.string.single_component_state'), + childNodes: SINGLE_COMPONENT_CATEGORY + }, + { + title: $r('app.string.multi_component_sync'), + childNodes: MULTI_COMPONENTS_CATEGORY + } +]; + + +const APP_LEVEL_CATEGORY: ThirdLevelCategory[] = [ + { + tag: 1, + title: $r('app.string.application_storage_ui'), + url: 'pages/applylevelstagemanagement/applyglobaldatasync/ApplyGlobalDataSync', + }, + { + tag: 1, + title: $r('app.string.ability_storage_ui'), + url: 'pages/applylevelstagemanagement/abilityglobaldatasync/AbilityGlobalDataSync', + } +]; + + +export const HOME_TABS: FirstLevelCategory[] = [ + { + tabBarName: $r('app.string.page_level'), + icon: $r('app.media.page_level'), + iconSelected: $r('app.media.page_level_selected'), + childNodes: PAGE_LEVEL_CATEGORY + }, + { + tabBarName: $r('app.string.app_level'), + icon: $r('app.media.app_level'), + iconSelected: $r('app.media.app_level_selected'), + childNodes: APP_LEVEL_CATEGORY + } +]; diff --git a/sample/EnhanceSampleArk1.2/StateManagement/entry/src/main/ets/pages/home/model/CategoricalDataType.ets b/sample/EnhanceSampleArk1.2/StateManagement/entry/src/main/ets/pages/home/model/CategoricalDataType.ets new file mode 100644 index 0000000000000000000000000000000000000000..0927299ca033a347c77c196a3f1730286524c520 --- /dev/null +++ b/sample/EnhanceSampleArk1.2/StateManagement/entry/src/main/ets/pages/home/model/CategoricalDataType.ets @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2023 Huawei Device 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. + */ + +export interface FirstLevelCategory { + childNodes: SecondLevelCategory[] | ThirdLevelCategory[], + iconSelected: Resource, // The icon for the first-level category is selected + icon: Resource, // The icon for the first-level category is not selected + tabBarName: Resource // First-level category title +} + +export interface SecondLevelCategory { + title: Resource, // Second-level category titles + childNodes: ThirdLevelCategory[] +} + +export interface ThirdLevelCategory { + tag: number, // Third-level category tag + title: Resource, // Third-level category headings + url?: string, // Third-level category detail page URL + childNodes?: FourthLevelCategory[] +} + +export interface FourthLevelCategory { + title: Resource, // Fourth-level category titles + url: string // Fourth-level category detail page URL +} \ No newline at end of file diff --git a/sample/EnhanceSampleArk1.2/StateManagement/entry/src/main/ets/pages/pagelevelstagemanagement/multicompomentssync/brothercomponentssync/BrotherComponentSync.ets b/sample/EnhanceSampleArk1.2/StateManagement/entry/src/main/ets/pages/pagelevelstagemanagement/multicompomentssync/brothercomponentssync/BrotherComponentSync.ets new file mode 100644 index 0000000000000000000000000000000000000000..3feb01eb64d846485f61a94006002d4a35d60e37 --- /dev/null +++ b/sample/EnhanceSampleArk1.2/StateManagement/entry/src/main/ets/pages/pagelevelstagemanagement/multicompomentssync/brothercomponentssync/BrotherComponentSync.ets @@ -0,0 +1,39 @@ +/* + * Copyright (c) 2023 Huawei Device 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 { CodeView } from '../../../../commoncomponents/CodeView'; +import { BrotherComponentSyncCode } from './BrotherComponentSyncCode'; + +@Entry +@Component +struct BrotherComponentSync { + @State title: Resource = $r('app.string.brother_sync'); + + build() { + Column() { + CodeView({ title: $title }) { + BrotherComponentSyncCode() + } + } + .width('100%') + .height('100%') + .padding($r('app.float.page_padding')) + .backgroundColor($r('app.color.background_shallow_grey')) + } + + aboutToDisappear(): void { + AppStorage.SetOrCreate('sideBarShow', false); + } +} \ No newline at end of file diff --git a/sample/EnhanceSampleArk1.2/StateManagement/entry/src/main/ets/pages/pagelevelstagemanagement/multicompomentssync/brothercomponentssync/BrotherComponentSyncCode.ets b/sample/EnhanceSampleArk1.2/StateManagement/entry/src/main/ets/pages/pagelevelstagemanagement/multicompomentssync/brothercomponentssync/BrotherComponentSyncCode.ets new file mode 100644 index 0000000000000000000000000000000000000000..c4e3749a49462cedcab71e75e8e17e0c0f323441 --- /dev/null +++ b/sample/EnhanceSampleArk1.2/StateManagement/entry/src/main/ets/pages/pagelevelstagemanagement/multicompomentssync/brothercomponentssync/BrotherComponentSyncCode.ets @@ -0,0 +1,44 @@ +/* + * Copyright (c) 2023 Huawei Device 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 { ProvideFatherComponent } from './ProvideFatherComponent'; +import { StateFatherComponent } from './StateFatherComponent'; + +@Component +export struct BrotherComponentSyncCode { + + build() { + Column() { + Column() { + Text($r('app.string.realize_by_state_link')) + .fontSize($r('app.float.tips_font_size')) + .width('100%') + .textAlign(TextAlign.Start) + // 共同父组件@State + StateFatherComponent() + } + + Column() { + Text($r('app.string.realize_by_provide_consume')) + .fontSize($r('app.float.tips_font_size')) + .width('100%') + .textAlign(TextAlign.Start) + // 共同父组件@Provide + ProvideFatherComponent() + } + .margin({ top: 10 }) + } + } +} \ No newline at end of file diff --git a/sample/EnhanceSampleArk1.2/StateManagement/entry/src/main/ets/pages/pagelevelstagemanagement/multicompomentssync/brothercomponentssync/ConsumeBrotherOneComponent.ets b/sample/EnhanceSampleArk1.2/StateManagement/entry/src/main/ets/pages/pagelevelstagemanagement/multicompomentssync/brothercomponentssync/ConsumeBrotherOneComponent.ets new file mode 100644 index 0000000000000000000000000000000000000000..2b98e89673c010e3f85652c6bf18e50d8a0b43e9 --- /dev/null +++ b/sample/EnhanceSampleArk1.2/StateManagement/entry/src/main/ets/pages/pagelevelstagemanagement/multicompomentssync/brothercomponentssync/ConsumeBrotherOneComponent.ets @@ -0,0 +1,64 @@ +/* + * Copyright (c) 2023 Huawei Device 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 { ColorType } from '../model/ColorType'; +import { COLOR_SELECT_DATA } from '../data/ColorData'; +import { getResourceString } from '../../../../utils/ResourceUtils'; +import { ViewCodeText } from '../../../../commoncomponents/ViewCodeText'; + +const CONTEXT: common.UIAbilityContext = getContext(this) as common.UIAbilityContext; + +@Component +export struct ConsumeBrotherOneComponent { + @State selectColors: ColorType[] = COLOR_SELECT_DATA; + // 和父组件、子组件B双向同步圆形颜色 + @Consume consumeCircleColor: Resource; + // 和父组件、子组件B双向同步Select组件的Index值 + @Consume currentSelectIndex: number; + + build() { + Column({ space: 10 }) { + // 点击查看源码 + ViewCodeText({ webSrc: $rawfile('ConsumeBrotherOneComponent.ets.html') }) + Text($r('app.string.consume_brothers_title')) + .fontSize($r('app.float.tips_font_size')) + .fontColor($r('app.color.tips_font_color')) + .width('100%') + .textAlign(TextAlign.Center) + Row() { + Select(this.selectColors) + .id('consumeSelectCompA') + .selected(this.currentSelectIndex) + .value(getResourceString(CONTEXT, this.selectColors[this.currentSelectIndex].value)) + .fontColor($r('app.color.button_text_color')) + .font({ size: $r('app.float.select_font_size') }) + .selectedOptionFont({ size: $r('app.float.select_font_size') }) + .optionFont({ size: $r('app.float.select_font_size') }) + .onSelect((index: number) => { + // 此组件@Consume声明的数据页面更新,兄弟组件@Consume的数据页面同步更新 + this.currentSelectIndex = index; + this.consumeCircleColor = this.selectColors[index].color; + }) + Circle() + .size({ width: $r('app.float.circle_size'), height: $r('app.float.circle_size') }) + .fill(this.consumeCircleColor) + }.justifyContent(FlexAlign.SpaceAround) + .width('100%') + } + .padding(10) + .border({ radius: $r('app.float.component_radius'), color: Color.Blue, width: $r('app.float.border_width') }) + } +} \ No newline at end of file diff --git a/sample/EnhanceSampleArk1.2/StateManagement/entry/src/main/ets/pages/pagelevelstagemanagement/multicompomentssync/brothercomponentssync/ConsumeBrotherTwoComponent.ets b/sample/EnhanceSampleArk1.2/StateManagement/entry/src/main/ets/pages/pagelevelstagemanagement/multicompomentssync/brothercomponentssync/ConsumeBrotherTwoComponent.ets new file mode 100644 index 0000000000000000000000000000000000000000..a24969afdb2268f2c33484356ba6907fea162bee --- /dev/null +++ b/sample/EnhanceSampleArk1.2/StateManagement/entry/src/main/ets/pages/pagelevelstagemanagement/multicompomentssync/brothercomponentssync/ConsumeBrotherTwoComponent.ets @@ -0,0 +1,65 @@ +/* + * Copyright (c) 2023 Huawei Device 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 { ColorType } from '../model/ColorType'; +import { COLOR_SELECT_DATA } from '../data/ColorData'; +import { getResourceString } from '../../../../utils/ResourceUtils'; +import { ViewCodeText } from '../../../../commoncomponents/ViewCodeText'; + +@Component +export struct ConsumeBrotherTwoComponent { + @State selectColors: ColorType[] = COLOR_SELECT_DATA; + // 和父组件、子组件B双向同步圆形颜色 + @Consume consumeCircleColor: Resource; + // 和父组件、子组件A双向同步Select组件的Index值 + @Consume currentSelectIndex: number; + + build() { + Column({ space: 10 }) { + // 点击查看源码 + ViewCodeText({ webSrc: $rawfile('ConsumeBrotherTwoComponent.ets.html') }) + Text($r('app.string.consume_brothers_title')) + .fontColor($r('app.color.tips_font_color')) + .fontSize($r('app.float.button_text_size')) + .width('100%') + .textAlign(TextAlign.Center) + .height($r('app.float.button_height')) + Row() { + Select(this.selectColors) + .id('consumeSelectCompB') + .selected(this.currentSelectIndex) + .value(getResourceString(getContext(this) as common.UIAbilityContext, + this.selectColors[this.currentSelectIndex].value)) + .fontColor($r('app.color.button_text_color')) + .font({ size: $r('app.float.select_font_size') }) + .selectedOptionFont({ size: $r('app.float.select_font_size') }) + .optionFont({ size: $r('app.float.select_font_size') }) + .onSelect((index: number) => { + // 此组件@Consume声明的数据页面更新,兄弟组件@Consume的数据页面同步更新 + this.currentSelectIndex = index; + this.consumeCircleColor = this.selectColors[index].color; + }) + Circle() + .size({ width: $r('app.float.circle_size'), height: $r('app.float.circle_size') }) + .fill(this.consumeCircleColor) + + }.justifyContent(FlexAlign.SpaceAround) + .width('100%') + } + .padding(10) + .border({ radius: $r('app.float.component_radius'), color: Color.Blue, width: $r('app.float.border_width') }) + } +} \ No newline at end of file diff --git a/sample/EnhanceSampleArk1.2/StateManagement/entry/src/main/ets/pages/pagelevelstagemanagement/multicompomentssync/brothercomponentssync/LinkBrotherOneComponent.ets b/sample/EnhanceSampleArk1.2/StateManagement/entry/src/main/ets/pages/pagelevelstagemanagement/multicompomentssync/brothercomponentssync/LinkBrotherOneComponent.ets new file mode 100644 index 0000000000000000000000000000000000000000..037aac2d803b2a1e6139f893016d2db571b2054c --- /dev/null +++ b/sample/EnhanceSampleArk1.2/StateManagement/entry/src/main/ets/pages/pagelevelstagemanagement/multicompomentssync/brothercomponentssync/LinkBrotherOneComponent.ets @@ -0,0 +1,66 @@ +/* + * Copyright (c) 2023 Huawei Device 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 { ColorType } from '../model/ColorType'; +import { COLOR_SELECT_DATA } from '../data/ColorData'; +import { getResourceString } from '../../../../utils/ResourceUtils'; +import { ViewCodeText } from '../../../../commoncomponents/ViewCodeText'; + +const CONTEXT: common.UIAbilityContext = getContext(this) as common.UIAbilityContext; + +@Component +export struct LinkBrotherOneComponent { + @State selectColors: ColorType[] = COLOR_SELECT_DATA; + // 和父组件、子组件B双向同步圆形颜色 + @Link circleColor: Resource; + // 和父组件、子组件B双向同步Select组件的Index值 + @Link currentSelectIndex: number; + + build() { + Column({ space: 10 }) { + // 点击查看源码 + ViewCodeText({ webSrc: $rawfile('LinkBrotherOneComponent.ets.html') }) + Text($r('app.string.link_brothers_title')) + .fontSize($r('app.float.tips_font_size')) + .fontColor($r('app.color.tips_font_color')) + .width('100%') + .textAlign(TextAlign.Center) + .fontColor($r('app.color.tips_font_color')) + Row() { + Select(this.selectColors) + .id('linkSelectCompA') + .selected(this.currentSelectIndex) + .value(getResourceString(CONTEXT, this.selectColors[this.currentSelectIndex].value)) + .fontColor($r('app.color.button_text_color')) + .font({ size: $r('app.float.select_font_size') }) + .selectedOptionFont({ size: $r('app.float.select_font_size') }) + .optionFont({ size: $r('app.float.select_font_size') }) + .onSelect((index: number) => { + // 此组件@Link声明的数据页面更新,兄弟组件@Link的数据页面同步更新 + this.currentSelectIndex = index; + this.circleColor = this.selectColors[index].color; + }) + Circle() + .size({ width: $r('app.float.circle_size'), height: $r('app.float.circle_size') }) + .fill(this.circleColor) + }.justifyContent(FlexAlign.SpaceAround) + .width('100%') + + } + .padding(10) + .border({ radius: $r('app.float.component_radius'), color: Color.Blue, width: $r('app.float.border_width') }) + } +} \ No newline at end of file diff --git a/sample/EnhanceSampleArk1.2/StateManagement/entry/src/main/ets/pages/pagelevelstagemanagement/multicompomentssync/brothercomponentssync/LinkBrotherTwoComponent.ets b/sample/EnhanceSampleArk1.2/StateManagement/entry/src/main/ets/pages/pagelevelstagemanagement/multicompomentssync/brothercomponentssync/LinkBrotherTwoComponent.ets new file mode 100644 index 0000000000000000000000000000000000000000..9a36fcb7478f25c38d742a93a4d2194154a81317 --- /dev/null +++ b/sample/EnhanceSampleArk1.2/StateManagement/entry/src/main/ets/pages/pagelevelstagemanagement/multicompomentssync/brothercomponentssync/LinkBrotherTwoComponent.ets @@ -0,0 +1,63 @@ +/* + * Copyright (c) 2023 Huawei Device 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 { ColorType } from '../model/ColorType'; +import { COLOR_SELECT_DATA } from '../data/ColorData'; +import { getResourceString } from '../../../../utils/ResourceUtils'; +import { ViewCodeText } from '../../../../commoncomponents/ViewCodeText'; + +@Component +export struct LinkBrotherTwoComponent { + @State selectColors: ColorType[] = COLOR_SELECT_DATA; + // 和父组件、子组件A双向同步圆形颜色 + @Link circleColor: Resource; + // 和父组件、子组件A双向同步Select的Index值 + @Link currentSelectIndex: number; + + build() { + Column({ space: 10 }) { + // 点击查看源码 + ViewCodeText({ webSrc: $rawfile('LinkBrotherTwoComponent.ets.html') }) + Text($r('app.string.link_brothers_title')) + .fontColor($r('app.color.tips_font_color')) + .fontSize($r('app.float.button_text_size')) + .width('100%') + .textAlign(TextAlign.Center) + .height($r('app.float.button_height')) + Row() { + Select(this.selectColors) + .id('linkSelectCompB') + .selected(this.currentSelectIndex) + .value(getResourceString(getContext(this) as common.UIAbilityContext, this.selectColors[this.currentSelectIndex].value)) + .fontColor($r('app.color.button_text_color')) + .font({ size: $r('app.float.select_font_size') }) + .selectedOptionFont({ size: $r('app.float.select_font_size') }) + .optionFont({ size: $r('app.float.select_font_size') }) + .onSelect((index: number) => { + // 此组件@Link声明的数据页面更新,兄弟组件@Link的数据页面同步更新 + this.currentSelectIndex = index; + this.circleColor = this.selectColors[index].color; + }) + Circle() + .size({ width: $r('app.float.circle_size'), height: $r('app.float.circle_size') }) + .fill(this.circleColor) + }.justifyContent(FlexAlign.SpaceAround) + .width('100%') + } + .padding(10) + .border({ radius: $r('app.float.component_radius'), color: Color.Blue, width: $r('app.float.border_width') }) + } +} \ No newline at end of file diff --git a/sample/EnhanceSampleArk1.2/StateManagement/entry/src/main/ets/pages/pagelevelstagemanagement/multicompomentssync/brothercomponentssync/ProvideFatherComponent.ets b/sample/EnhanceSampleArk1.2/StateManagement/entry/src/main/ets/pages/pagelevelstagemanagement/multicompomentssync/brothercomponentssync/ProvideFatherComponent.ets new file mode 100644 index 0000000000000000000000000000000000000000..4a67f4d0e21022721dbae65370046e752a3b2463 --- /dev/null +++ b/sample/EnhanceSampleArk1.2/StateManagement/entry/src/main/ets/pages/pagelevelstagemanagement/multicompomentssync/brothercomponentssync/ProvideFatherComponent.ets @@ -0,0 +1,48 @@ +/* + * Copyright (c) 2023 Huawei Device 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 { ColorType } from '../model/ColorType'; +import { COLOR_SELECT_DATA } from '../data/ColorData'; +import { ConsumeBrotherOneComponent } from './ConsumeBrotherOneComponent'; +import { ConsumeBrotherTwoComponent } from './ConsumeBrotherTwoComponent'; +import { ViewCodeText } from '../../../../commoncomponents/ViewCodeText'; + +@Component +export struct ProvideFatherComponent { + // 初始化一个颜色数组 + @State selectColors: ColorType[] = COLOR_SELECT_DATA; + // 共同父组件使用@Provide初始化圆形颜色 + @Provide consumeCircleColor: Resource = $r('app.color.circle_blue'); + // 初始化Select组件的Index为0 + @Provide currentSelectIndex: number = 0; + + build() { + Column({ space: 10 }) { + // 点击查看源码 + ViewCodeText({ webSrc: $rawfile('ProvideFatherComponent.ets.html') }) + Text($r('app.string.parent_titletwo')) + .fontSize($r('app.float.tips_font_size')) + .fontColor($r('app.color.tips_font_color')) + .width('100%') + .textAlign(TextAlign.Center) + // 和父组件双向同步子组件A + ConsumeBrotherOneComponent() + // 和父组件双向同步子组件B + ConsumeBrotherTwoComponent() + }.padding(10) + .border({ radius: $r('app.float.component_radius'), color: Color.Grey, width: $r('app.float.border_width') }) + } +} + diff --git a/sample/EnhanceSampleArk1.2/StateManagement/entry/src/main/ets/pages/pagelevelstagemanagement/multicompomentssync/brothercomponentssync/StateFatherComponent.ets b/sample/EnhanceSampleArk1.2/StateManagement/entry/src/main/ets/pages/pagelevelstagemanagement/multicompomentssync/brothercomponentssync/StateFatherComponent.ets new file mode 100644 index 0000000000000000000000000000000000000000..677e589792eb5531557d9d50e6b31d6b0ae1f680 --- /dev/null +++ b/sample/EnhanceSampleArk1.2/StateManagement/entry/src/main/ets/pages/pagelevelstagemanagement/multicompomentssync/brothercomponentssync/StateFatherComponent.ets @@ -0,0 +1,54 @@ +/* + * Copyright (c) 2023 Huawei Device 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 { ColorType } from '../model/ColorType'; +import { COLOR_SELECT_DATA } from '../data/ColorData'; +import { LinkBrotherOneComponent } from './LinkBrotherOneComponent'; +import { LinkBrotherTwoComponent } from './LinkBrotherTwoComponent'; +import { ViewCodeText } from '../../../../commoncomponents/ViewCodeText'; + +@Component +export struct StateFatherComponent { + // 共同父组件使用@State初始化圆形颜色 + @State circleColor: Resource = $r('app.color.circle_blue'); + // 初始化一个颜色数组 + @State selectColors: ColorType[] = COLOR_SELECT_DATA; + // 初始化当前Select的Index为0 + @State currentSelectIndex: number = 0; + + build() { + Column({ space: 10 }) { + // 点击查看源码 + ViewCodeText({ webSrc: $rawfile('StateFatherComponent.ets.html') }) + Text($r('app.string.parent_titleone')) + .fontSize($r('app.float.tips_font_size')) + .fontColor($r('app.color.tips_font_color')) + .width('100%') + .textAlign(TextAlign.Center) + // 和父组件双向同步子组件A + LinkBrotherOneComponent({ + circleColor: $circleColor, + currentSelectIndex: $currentSelectIndex + }) + // 和父组件双向同步子组件B + LinkBrotherTwoComponent({ + circleColor: $circleColor, + currentSelectIndex: $currentSelectIndex + }) + }.padding(10) + .border({ radius: $r('app.float.component_radius'), color: Color.Grey, width: $r('app.float.border_width') }) + } +} + diff --git a/sample/EnhanceSampleArk1.2/StateManagement/entry/src/main/ets/pages/pagelevelstagemanagement/multicompomentssync/data/ColorData.ets b/sample/EnhanceSampleArk1.2/StateManagement/entry/src/main/ets/pages/pagelevelstagemanagement/multicompomentssync/data/ColorData.ets new file mode 100644 index 0000000000000000000000000000000000000000..f5c80e9ad6fe6878851069d409aaa8d557ba990b --- /dev/null +++ b/sample/EnhanceSampleArk1.2/StateManagement/entry/src/main/ets/pages/pagelevelstagemanagement/multicompomentssync/data/ColorData.ets @@ -0,0 +1,27 @@ +/* + * Copyright (c) 2023 Huawei Device 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 { ColorType } from '../model/ColorType' + +export const COLOR_SELECT_DATA: ColorType[] = [ + { + value: $r('app.string.select_colorblue'), + color: $r('app.color.circle_blue') + }, + { + value: $r('app.string.select_colorpink'), + color: $r('app.color.circle_pink') + } +] \ No newline at end of file diff --git a/sample/EnhanceSampleArk1.2/StateManagement/entry/src/main/ets/pages/pagelevelstagemanagement/multicompomentssync/deepnestcomponentssync/ConsumeDescendentComponent.ets b/sample/EnhanceSampleArk1.2/StateManagement/entry/src/main/ets/pages/pagelevelstagemanagement/multicompomentssync/deepnestcomponentssync/ConsumeDescendentComponent.ets new file mode 100644 index 0000000000000000000000000000000000000000..279e8a5313946df6d6ce77a392c133ace8531cd3 --- /dev/null +++ b/sample/EnhanceSampleArk1.2/StateManagement/entry/src/main/ets/pages/pagelevelstagemanagement/multicompomentssync/deepnestcomponentssync/ConsumeDescendentComponent.ets @@ -0,0 +1,69 @@ +/* + * Copyright (c) 2023 Huawei Device 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 { ColorType } from '../model/ColorType'; +import { COLOR_SELECT_DATA } from '../data/ColorData'; +import { getResourceString } from '../../../../utils/ResourceUtils'; +import { ViewCodeText } from '../../../../commoncomponents/ViewCodeText'; + +// 声明一个上下文变量 +const CONTEXT: common.UIAbilityContext = getContext(this) as common.UIAbilityContext; + +@Component +export struct ConsumeDescendentComponent { + // 初始化一个颜色数组数据 + @State selectColors: ColorType[] = COLOR_SELECT_DATA; + // 和爷组件双向同步圆形颜色 + @Consume consumeCircleColor: Resource; + // 和爷组件双向同步Select的Index值 + @Consume currentSelectIndex: number; + + build() { + Column() { + // 点击查看源码 + ViewCodeText({ webSrc: $rawfile('ConsumeDescendentComponent.ets.html') }) + Row() { + Select(this.selectColors) + .selected(this.currentSelectIndex) + .value(getResourceString(CONTEXT, this.selectColors[this.currentSelectIndex].value)) + .fontColor($r('app.color.button_text_color')) + .font({ size: $r('app.float.tips_font_size') }) + .selectedOptionFont({ size: $r('app.float.tips_font_size') }) + .optionFont({ size: $r('app.float.tips_font_size') }) + .id('grandsonCompB') + .onSelect((index: number) => { + // 孙组件@Consume声明的数据页面更新,爷组件@Provide的数据页面同步更新 + this.currentSelectIndex = index; + this.consumeCircleColor = this.selectColors[index].color; + }) + Circle() + .size({ width: $r('app.float.circle_size'), height: $r('app.float.circle_size') }) + .fill(this.consumeCircleColor) + + }.justifyContent(FlexAlign.SpaceAround) + .width('100%') + .margin({ bottom: 6 }) + + Text($r('app.string.deepnest_descendent_titletwo')) + .fontColor($r('app.color.tips_font_color')) + .fontSize($r('app.float.button_text_size')) + .width('100%') + .textAlign(TextAlign.Center) + } + .padding(10) + .border({ radius: $r('app.float.component_radius'), color: Color.Red, width: $r('app.float.border_width') }) + } +} \ No newline at end of file diff --git a/sample/EnhanceSampleArk1.2/StateManagement/entry/src/main/ets/pages/pagelevelstagemanagement/multicompomentssync/deepnestcomponentssync/DeepNestComponentsSync.ets b/sample/EnhanceSampleArk1.2/StateManagement/entry/src/main/ets/pages/pagelevelstagemanagement/multicompomentssync/deepnestcomponentssync/DeepNestComponentsSync.ets new file mode 100644 index 0000000000000000000000000000000000000000..87223be490b30f23dc95f5f80314a38ae2406008 --- /dev/null +++ b/sample/EnhanceSampleArk1.2/StateManagement/entry/src/main/ets/pages/pagelevelstagemanagement/multicompomentssync/deepnestcomponentssync/DeepNestComponentsSync.ets @@ -0,0 +1,39 @@ +/* + * Copyright (c) 2023 Huawei Device 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 { CodeView } from '../../../../commoncomponents/CodeView'; +import { DeepNestComponentsSyncCode } from './DeepNestComponentsSyncCode'; + +@Entry +@Component +struct DeepNestComponentsSync { + @State title: Resource = $r('app.string.parent_descendent_sync'); + + build() { + Column() { + CodeView({ title: $title }) { + DeepNestComponentsSyncCode() + } + } + .width('100%') + .height('100%') + .padding($r('app.float.page_padding')) + .backgroundColor($r('app.color.background_shallow_grey')) + } + + aboutToDisappear(): void { + AppStorage.SetOrCreate('sideBarShow', false); + } +} \ No newline at end of file diff --git a/sample/EnhanceSampleArk1.2/StateManagement/entry/src/main/ets/pages/pagelevelstagemanagement/multicompomentssync/deepnestcomponentssync/DeepNestComponentsSyncCode.ets b/sample/EnhanceSampleArk1.2/StateManagement/entry/src/main/ets/pages/pagelevelstagemanagement/multicompomentssync/deepnestcomponentssync/DeepNestComponentsSyncCode.ets new file mode 100644 index 0000000000000000000000000000000000000000..33b8d37dd66d9141118d434605098ec675a3d438 --- /dev/null +++ b/sample/EnhanceSampleArk1.2/StateManagement/entry/src/main/ets/pages/pagelevelstagemanagement/multicompomentssync/deepnestcomponentssync/DeepNestComponentsSyncCode.ets @@ -0,0 +1,42 @@ +/* + * Copyright (c) 2023 Huawei Device 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 { StateGrandfatherComponent } from './StateGrandfatherComponent'; +import { ProvideGrandfatherComponent } from './ProvideGrandfatherComponent'; + +@Component +export struct DeepNestComponentsSyncCode { + build() { + Column() { + Column() { + Text($r('app.string.realize_by_state_link')) + .fontSize($r('app.float.tips_font_size')) + .width('100%') + .textAlign(TextAlign.Start) + // 爷组件@State + StateGrandfatherComponent() + }.margin({ bottom: 16 }) + + Column() { + Text($r('app.string.realize_by_provide_consume')) + .fontSize($r('app.float.tips_font_size')) + .width('100%') + .textAlign(TextAlign.Start) + // 爷组件@Provide + ProvideGrandfatherComponent() + } + } + } +} \ No newline at end of file diff --git a/sample/EnhanceSampleArk1.2/StateManagement/entry/src/main/ets/pages/pagelevelstagemanagement/multicompomentssync/deepnestcomponentssync/LinkDescendentComponent.ets b/sample/EnhanceSampleArk1.2/StateManagement/entry/src/main/ets/pages/pagelevelstagemanagement/multicompomentssync/deepnestcomponentssync/LinkDescendentComponent.ets new file mode 100644 index 0000000000000000000000000000000000000000..e7f88b7c13a28a448fd2a71d6ada272f14d16a4c --- /dev/null +++ b/sample/EnhanceSampleArk1.2/StateManagement/entry/src/main/ets/pages/pagelevelstagemanagement/multicompomentssync/deepnestcomponentssync/LinkDescendentComponent.ets @@ -0,0 +1,66 @@ +/* + * Copyright (c) 2023 Huawei Device 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 { ColorType } from '../model/ColorType'; +import { COLOR_SELECT_DATA } from '../data/ColorData'; +import { getResourceString } from '../../../../utils/ResourceUtils'; +import { ViewCodeText } from '../../../../commoncomponents/ViewCodeText'; + +const CONTEXT: common.UIAbilityContext = getContext(this) as common.UIAbilityContext; + +@Component +export struct LinkDescendentComponent { + @State selectColors: ColorType[] = COLOR_SELECT_DATA; + // 和父组件和爷组件双向同步圆形颜色 + @Link circleColor: Resource; + // 和父组件和爷组件双向同步Select的Index值 + @Link currentSelectIndex: number; + + build() { + Column() { + // 点击查看源码 + ViewCodeText({ webSrc: $rawfile('LinkDescendentComponent.ets.html') }) + Row() { + Select(this.selectColors) + .selected(this.currentSelectIndex) + .value(getResourceString(CONTEXT, this.selectColors[this.currentSelectIndex].value)) + .fontColor($r('app.color.button_text_color')) + .font({ size: $r('app.float.tips_font_size') }) + .selectedOptionFont({ size: $r('app.float.tips_font_size') }) + .optionFont({ size: $r('app.float.tips_font_size') }) + .id('grandsonCompA') + .onSelect((index: number) => { + // 孙组件@Link组件数据页面更新,爷组件同步更新 + this.currentSelectIndex = index; + this.circleColor = this.selectColors[index].color; + }) + Circle() + .size({ width: $r('app.float.circle_size'), height: $r('app.float.circle_size') }) + .fill(this.circleColor) + }.justifyContent(FlexAlign.SpaceAround) + .width('100%') + .margin({ bottom: 6 }) + + Text($r('app.string.deepnest_descendent_titleone')) + .fontColor($r('app.color.tips_font_color')) + .fontSize($r('app.float.button_text_size')) + .width('100%') + .textAlign(TextAlign.Center) + } + .padding(10) + .border({ radius: $r('app.float.component_radius'), color: Color.Red, width: $r('app.float.border_width') }) + } +} \ No newline at end of file diff --git a/sample/EnhanceSampleArk1.2/StateManagement/entry/src/main/ets/pages/pagelevelstagemanagement/multicompomentssync/deepnestcomponentssync/ProvideGrandfatherComponent.ets b/sample/EnhanceSampleArk1.2/StateManagement/entry/src/main/ets/pages/pagelevelstagemanagement/multicompomentssync/deepnestcomponentssync/ProvideGrandfatherComponent.ets new file mode 100644 index 0000000000000000000000000000000000000000..35aaee32be9c192188cde67c28185b1566e4f374 --- /dev/null +++ b/sample/EnhanceSampleArk1.2/StateManagement/entry/src/main/ets/pages/pagelevelstagemanagement/multicompomentssync/deepnestcomponentssync/ProvideGrandfatherComponent.ets @@ -0,0 +1,88 @@ +/* + * Copyright (c) 2023 Huawei Device 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 { ColorType } from '../model/ColorType'; +import { COLOR_SELECT_DATA } from '../data/ColorData'; +import { ConsumeDescendentComponent } from './ConsumeDescendentComponent'; +import { ViewCodeText } from '../../../../commoncomponents/ViewCodeText'; +import { getResourceString } from '../../../../utils/ResourceUtils'; + +const CONTEXT: common.UIAbilityContext = getContext(this) as common.UIAbilityContext; + +@Component +export struct ProvideGrandfatherComponent { + @State selectColors: ColorType[] = COLOR_SELECT_DATA; + // 初始化爷组件@Provide的原型颜色 + @Provide consumeCircleColor: Resource = $r('app.color.circle_blue'); + // 初始化Select组件的Index + @Provide currentSelectIndex: number = 0; + + build() { + Column() { + // 点击查看源码 + ViewCodeText({ webSrc: $rawfile('ProvideGrandfatherComponent.ets.html') }) + Text($r('app.string.deepnest_parent_titletwo')) + .fontSize($r('app.float.tips_font_size')) + .fontColor($r('app.color.tips_font_color')) + .width('100%') + .textAlign(TextAlign.Center) + .margin({ top: 10 }) + Row() { + Select(this.selectColors) + .selected(this.currentSelectIndex) + .value(getResourceString(CONTEXT, this.selectColors[this.currentSelectIndex].value)) + .fontColor($r('app.color.button_text_color')) + .font({ size: $r('app.float.tips_font_size') }) + .selectedOptionFont({ size: $r('app.float.tips_font_size') }) + .optionFont({ size: $r('app.float.tips_font_size') }) + .id('grandfatherCompB') + .onSelect((index: number) => { + // 爷组件@Provide声明的数据页面更新,孙组件@Consume关联的变量同步更新 + this.currentSelectIndex = index; + this.consumeCircleColor = this.selectColors[index].color; + }) + Circle() + .size({ width: $r('app.float.circle_size'), height: $r('app.float.circle_size') }) + .fill(this.consumeCircleColor) + }.justifyContent(FlexAlign.SpaceAround) + .width('100%') + .margin({ bottom: 6 }) + // 子组件 + ConsumeChildComp() + }.padding(10) + .border({ radius: $r('app.float.component_radius'), color: Color.Grey, width: $r('app.float.border_width') }) + } +} + +@Component +struct ConsumeChildComp { + + build() { + Column() { + Text($r('app.string.deepnest_child_titletwo')) + .fontColor($r('app.color.tips_font_color')) + .fontSize($r('app.float.button_text_size')) + .width('100%') + .textAlign(TextAlign.Center) + .height($r('app.float.button_height')) + // 双向同步孙组件 + ConsumeDescendentComponent() + } + .padding(10) + .border({ radius: $r('app.float.component_radius'), color: Color.Blue, width: $r('app.float.border_width') }) + } +} \ No newline at end of file diff --git a/sample/EnhanceSampleArk1.2/StateManagement/entry/src/main/ets/pages/pagelevelstagemanagement/multicompomentssync/deepnestcomponentssync/StateGrandfatherComponent.ets b/sample/EnhanceSampleArk1.2/StateManagement/entry/src/main/ets/pages/pagelevelstagemanagement/multicompomentssync/deepnestcomponentssync/StateGrandfatherComponent.ets new file mode 100644 index 0000000000000000000000000000000000000000..29c913a5d3f049b5d1e58844459de90ef3e25979 --- /dev/null +++ b/sample/EnhanceSampleArk1.2/StateManagement/entry/src/main/ets/pages/pagelevelstagemanagement/multicompomentssync/deepnestcomponentssync/StateGrandfatherComponent.ets @@ -0,0 +1,94 @@ +/* + * Copyright (c) 2023 Huawei Device 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 { LinkDescendentComponent } from './LinkDescendentComponent'; +import { ColorType } from '../model/ColorType'; +import { COLOR_SELECT_DATA } from '../data/ColorData'; +import { getResourceString } from '../../../../utils/ResourceUtils'; +import { ViewCodeText } from '../../../../commoncomponents/ViewCodeText'; + +// 声明一个上下文变量 +const CONTEXT: common.UIAbilityContext = getContext(this) as common.UIAbilityContext; + +@Component +export struct StateGrandfatherComponent { + // 初始化爷组件@State的圆形颜色 + @State circleColor: Resource = $r('app.color.circle_blue'); + // 初始化一个颜色数组 + @State selectColors: ColorType[] = COLOR_SELECT_DATA; + // 初始化当前select组件的index + @State currentSelectIndex: number = 0; + + build() { + Column({ space: 10 }) { + // 点击查看源码 + ViewCodeText({ webSrc: $rawfile('StateGrandfatherComponent.ets.html') }) + Text($r('app.string.deepnest_parent_titleone')) + .fontSize($r('app.float.tips_font_size')) + .fontColor($r('app.color.tips_font_color')) + .width('100%') + .textAlign(TextAlign.Center) + Row() { + Select(this.selectColors) + .selected(this.currentSelectIndex) + .value(getResourceString(CONTEXT, this.selectColors[this.currentSelectIndex].value)) + .fontColor($r('app.color.button_text_color')) + .font({ size: $r('app.float.tips_font_size') }) + .selectedOptionFont({ size: $r('app.float.tips_font_size') }) + .optionFont({ size: $r('app.float.tips_font_size') }) + .id('grandfatherCompA') + .onSelect((index: number) => { + // 爷组件@State声明的数据页面更新,孙组件@Link关联的变量同步更新 + this.currentSelectIndex = index; + this.circleColor = this.selectColors[index].color; + }) + Circle() + .size({ width: $r('app.float.circle_size'), height: $r('app.float.circle_size') }) + .fill(this.circleColor) + }.justifyContent(FlexAlign.SpaceAround) + .width('100%') + // 双向同步子组件 + LinkChildComp({ circleColor: $circleColor, currentSelectIndex: $currentSelectIndex }) + }.padding(10) + .border({ radius: $r('app.float.component_radius'), color: Color.Grey, width: $r('app.float.border_width') }) + } +} + +@Component +struct LinkChildComp { + // 和父组件和子组件双向同步圆形颜色 + @Link circleColor: Resource; + // 和父组件和子组件双向同步Select的Index值 + @Link currentSelectIndex: number; + + build() { + Column() { + Text($r('app.string.deepnest_child_titleone')) + .fontColor($r('app.color.tips_font_color')) + .fontSize($r('app.float.button_text_size')) + .width('100%') + .textAlign(TextAlign.Center) + .height($r('app.float.button_height')) + // 双向同步孙组件 + LinkDescendentComponent({ + circleColor: $circleColor, + currentSelectIndex: $currentSelectIndex + }) + } + .padding(10) + .border({ radius: $r('app.float.component_radius'), color: Color.Blue, width: $r('app.float.border_width') }) + } +} \ No newline at end of file diff --git a/sample/EnhanceSampleArk1.2/StateManagement/entry/src/main/ets/pages/pagelevelstagemanagement/multicompomentssync/model/ColorType.ets b/sample/EnhanceSampleArk1.2/StateManagement/entry/src/main/ets/pages/pagelevelstagemanagement/multicompomentssync/model/ColorType.ets new file mode 100644 index 0000000000000000000000000000000000000000..4a8789eff9ec9aedf8de0b36669ac074374d2f8b --- /dev/null +++ b/sample/EnhanceSampleArk1.2/StateManagement/entry/src/main/ets/pages/pagelevelstagemanagement/multicompomentssync/model/ColorType.ets @@ -0,0 +1,19 @@ +/* + * Copyright (c) 2023 Huawei Device 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. + */ + +export type ColorType = { + value:Resource, + color:Resource, +}; \ No newline at end of file diff --git a/sample/EnhanceSampleArk1.2/StateManagement/entry/src/main/ets/pages/pagelevelstagemanagement/multicompomentssync/parentchildcomponentsync/parentchildpartialcontentsync/ObjectLinkComponent.ets b/sample/EnhanceSampleArk1.2/StateManagement/entry/src/main/ets/pages/pagelevelstagemanagement/multicompomentssync/parentchildcomponentsync/parentchildpartialcontentsync/ObjectLinkComponent.ets new file mode 100644 index 0000000000000000000000000000000000000000..a966291250b1825c5b650ccdd03d6f6be9eebc27 --- /dev/null +++ b/sample/EnhanceSampleArk1.2/StateManagement/entry/src/main/ets/pages/pagelevelstagemanagement/multicompomentssync/parentchildcomponentsync/parentchildpartialcontentsync/ObjectLinkComponent.ets @@ -0,0 +1,54 @@ +/* + * Copyright (c) 2023 Huawei Device 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 { ClassObject } from './ParentChildPartialContentSyncCode'; +import { ViewCodeText } from '../../../../../commoncomponents/ViewCodeText'; + +@Component +export struct ObjectLinkComponent { + // 使用@ObjectLink修饰,与父组件中元素同步 + @ObjectLink childObjectData: ClassObject; + + build() { + Column({ space: 10 }) { + // 点击查看源码 + ViewCodeText({ webSrc: $rawfile('ObjectLinkComponent.ets.html') }) + + Text($r('app.string.partial_sync_text')) + .fontColor($r('app.color.tips_font_color')) + .fontSize($r('app.float.tips_font_size')) + .width('100%') + .textAlign(TextAlign.Start) + Row() { + Text(this.childObjectData.elementType) + .fontColor($r('app.color.tips_font_color')) + .fontSize($r('app.float.tips_font_size')) + .textAlign(TextAlign.Center) + .layoutWeight(1) + TextInput({ text: this.childObjectData.attributeType }) + .fontSize(20) + .layoutWeight(1) + .id('childAttribute') + .onChange((value: string) => { + // 子组件对象属性更新,父元素同步 + this.childObjectData.attributeType = value; + }) + } + .justifyContent(FlexAlign.SpaceAround) + } + .border({ radius: $r('app.float.component_radius'), color: Color.Blue, width: $r('app.float.border_width') }) + .padding(10) + } +} \ No newline at end of file diff --git a/sample/EnhanceSampleArk1.2/StateManagement/entry/src/main/ets/pages/pagelevelstagemanagement/multicompomentssync/parentchildcomponentsync/parentchildpartialcontentsync/ParentChildPartialContentSync.ets b/sample/EnhanceSampleArk1.2/StateManagement/entry/src/main/ets/pages/pagelevelstagemanagement/multicompomentssync/parentchildcomponentsync/parentchildpartialcontentsync/ParentChildPartialContentSync.ets new file mode 100644 index 0000000000000000000000000000000000000000..f01066b2ac7de4c186547083f23f6ea8d721028d --- /dev/null +++ b/sample/EnhanceSampleArk1.2/StateManagement/entry/src/main/ets/pages/pagelevelstagemanagement/multicompomentssync/parentchildcomponentsync/parentchildpartialcontentsync/ParentChildPartialContentSync.ets @@ -0,0 +1,39 @@ +/* + * Copyright (c) 2023 Huawei Device 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 { ParentChildPartialContentSyncCode } from './ParentChildPartialContentSyncCode'; +import { CodeView } from '../../../../../commoncomponents/CodeView'; + +@Entry +@Component +struct ParentChildPartialContentSync { + @State title: Resource = $r('app.string.partial_sync'); + + build() { + Column() { + CodeView({ title: $title }) { + ParentChildPartialContentSyncCode() + } + } + .width('100%') + .height('100%') + .padding($r('app.float.page_padding')) + .backgroundColor($r('app.color.background_shallow_grey')) + } + + aboutToDisappear(): void { + AppStorage.SetOrCreate('sideBarShow', false); + } +} \ No newline at end of file diff --git a/sample/EnhanceSampleArk1.2/StateManagement/entry/src/main/ets/pages/pagelevelstagemanagement/multicompomentssync/parentchildcomponentsync/parentchildpartialcontentsync/ParentChildPartialContentSyncCode.ets b/sample/EnhanceSampleArk1.2/StateManagement/entry/src/main/ets/pages/pagelevelstagemanagement/multicompomentssync/parentchildcomponentsync/parentchildpartialcontentsync/ParentChildPartialContentSyncCode.ets new file mode 100644 index 0000000000000000000000000000000000000000..412e272ff077ea0d9df79ad8f77399645bc3d922 --- /dev/null +++ b/sample/EnhanceSampleArk1.2/StateManagement/entry/src/main/ets/pages/pagelevelstagemanagement/multicompomentssync/parentchildcomponentsync/parentchildpartialcontentsync/ParentChildPartialContentSyncCode.ets @@ -0,0 +1,108 @@ +/* + * Copyright (c) 2023 Huawei Device 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 { ObjectLinkComponent } from './ObjectLinkComponent'; +import { ViewCodeText } from '../../../../../commoncomponents/ViewCodeText'; + +// 数组中元素的类,使用@Observed修饰 +@Observed +export class ClassObject { + public elementType: Resource; + public attributeType: Resource | string; + + constructor(elementType: Resource, attributeType: Resource | string) { + this.elementType = elementType; + this.attributeType = attributeType; + } +} + +// 初始化父组件中的数据 +const PARENT_DATA: ClassObject[] = [new ClassObject($r('app.string.partial_sync_element_one'), $r('app.string.partial_sync_attribute_one')), + new ClassObject($r('app.string.partial_sync_element_two'), $r('app.string.partial_sync_attribute_two')), + new ClassObject($r('app.string.partial_sync_element_three'), $r('app.string.partial_sync_attribute_three'))]; + +@Component +export struct ParentChildPartialContentSyncCode { + // 初始化父组件中状态变量 + @State parentData: ClassObject[] = PARENT_DATA; + // 与子组件同步的的数据是数组的第几个元素,默认选中第一个 + @State syncIndex: number = 0; + + build() { + Column({ space: 10 }) { + // 点击查看源码 + ViewCodeText({ webSrc: $rawfile('ParentChildPartialContentSyncCode.ets.html') }) + + Text($r('app.string.partial_sync_parent_tips')) + .fontColor($r('app.color.tips_font_color')) + .fontSize($r('app.float.tips_font_size')) + .width('100%') + .textAlign(TextAlign.Start) + // 父组件中List展示状态变量中的内容 + Column() { + ForEach(this.parentData, (item: ClassObject, index: number) => { + Column() { + ParentCompDataItem({ index: index, syncIndex: this.syncIndex, childObject: item }) + } + .backgroundColor(index === this.syncIndex ? $r('app.color.component_background_pink') : undefined) + .onClick(() => { + this.syncIndex = index; + }) + }, item => JSON.stringify(item)) + } + .width('100%') + .backgroundColor($r('app.color.component_background_pink')) + + //与父组件状态同步的子组件 + ObjectLinkComponent({ childObjectData: this.parentData[this.syncIndex] }) + } + .width('100%') + .padding(10) + .border({ radius: $r('app.float.component_radius'), color: Color.Grey, width: $r('app.float.border_width') }) + } +} + +// 展示数组中单个元素的子组件 +@Component +struct ParentCompDataItem { + private index: number; + @Prop syncIndex: number; + // 使用@ObjectLink修饰,与父组件中元素同步 + @ObjectLink childObject: ClassObject; + + build() { + Column() { + Text(this.childObject.elementType) + .width('100%') + .fontSize(20) + if (this.index === this.syncIndex) { + TextInput({ text: this.childObject.attributeType }) + .fontSize(20) + .id(`attribute${this.index + 1}`) + .onChange((value: string) => { + // 更新父组件中元素的属性,子组件同步 + this.childObject.attributeType = value; + }) + } else { + Text(this.childObject.attributeType) + .width('100%') + .fontSize(20) + } + } + .padding(10) + .id(`arrayElement${this.index}`) + } +} + diff --git a/sample/EnhanceSampleArk1.2/StateManagement/entry/src/main/ets/pages/pagelevelstagemanagement/multicompomentssync/parentchildcomponentsync/uniandbidirectionsync/ComponentLink.ets b/sample/EnhanceSampleArk1.2/StateManagement/entry/src/main/ets/pages/pagelevelstagemanagement/multicompomentssync/parentchildcomponentsync/uniandbidirectionsync/ComponentLink.ets new file mode 100644 index 0000000000000000000000000000000000000000..9589375851269fd80843253324159e972a49178a --- /dev/null +++ b/sample/EnhanceSampleArk1.2/StateManagement/entry/src/main/ets/pages/pagelevelstagemanagement/multicompomentssync/parentchildcomponentsync/uniandbidirectionsync/ComponentLink.ets @@ -0,0 +1,62 @@ +/* + * Copyright (c) 2023 Huawei Device 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 { COLOR_DATA } from './UniAndBidirectionSyncCode'; +import { ViewCodeText } from '../../../../../commoncomponents/ViewCodeText'; + +@Component +export struct ChildCompLink { + // 圆形颜色,和父组件中的状态变量双向同步 + @Link circleColor: string; + + build() { + Column({ space: 10 }) { + // 点击查看源码 + ViewCodeText({webSrc: $rawfile('ComponentLink.ets.html')}) + + Text($r('app.string.child_component')) + .fontSize($r('app.float.tips_font_size')) + .width('100%') + .textAlign(TextAlign.Start) + .margin(10) + Text($r('app.string.both_direction_sync_tips')) + .fontColor($r('app.color.tips_font_color')) + .fontSize($r('app.float.tips_font_size')) + .width('100%') + .textAlign(TextAlign.Center) + // 绑定@Link变量的Circle组件 + Circle() + .size({ width: $r('app.float.circle_size'), height: $r('app.float.circle_size') }) + .fill(this.circleColor) + Button() { + Text($r('app.string.both_direction_sync_btn')) + .fontColor($r('app.color.button_text_color')) + .fontSize($r('app.float.button_text_size')) + .width('100%') + .textAlign(TextAlign.Center) + } + .id('redColorBtn') + .height($r('app.float.button_height')) + .type(ButtonType.Capsule) + .backgroundColor($r('app.color.button_background_color')) + .onClick(() => { + // 点击更新子组件@Link声明的变量,此子组件更新,父组件以及@Prop声明的子组件变量同步 + this.circleColor = COLOR_DATA.RED; + }) + } + .padding(10) + .border({ radius: $r('app.float.component_radius'), color: Color.Blue, width: $r('app.float.border_width') }) + } +} \ No newline at end of file diff --git a/sample/EnhanceSampleArk1.2/StateManagement/entry/src/main/ets/pages/pagelevelstagemanagement/multicompomentssync/parentchildcomponentsync/uniandbidirectionsync/ComponentProp.ets b/sample/EnhanceSampleArk1.2/StateManagement/entry/src/main/ets/pages/pagelevelstagemanagement/multicompomentssync/parentchildcomponentsync/uniandbidirectionsync/ComponentProp.ets new file mode 100644 index 0000000000000000000000000000000000000000..8befbad7d724c8239cfd84c6f95fce4ddf030754 --- /dev/null +++ b/sample/EnhanceSampleArk1.2/StateManagement/entry/src/main/ets/pages/pagelevelstagemanagement/multicompomentssync/parentchildcomponentsync/uniandbidirectionsync/ComponentProp.ets @@ -0,0 +1,61 @@ +/* + * Copyright (c) 2023 Huawei Device 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 { COLOR_DATA } from './UniAndBidirectionSyncCode'; +import { ViewCodeText } from '../../../../../commoncomponents/ViewCodeText'; + +@Component +export struct ChildCompProp { + // 圆形颜色,和父组件中的状态变量单向同步,只支持基础类型 + @Prop circleColor: string; + + build() { + Column({ space: 10 }) { + // 点击查看源码 + ViewCodeText({ webSrc: $rawfile('ComponentProp.ets.html') }) + Text($r('app.string.child_component')) + .fontSize($r('app.float.tips_font_size')) + .width('100%') + .textAlign(TextAlign.Start) + .margin(10) + Text($r('app.string.single_direction_sync_tips')) + .fontColor($r('app.color.tips_font_color')) + .fontSize($r('app.float.tips_font_size')) + .width('100%') + .textAlign(TextAlign.Center) + // 绑定@Link变量的Circle组件 + Circle() + .size({ width: $r('app.float.circle_size'), height: $r('app.float.circle_size') }) + .fill(this.circleColor) + Button() { + Text($r('app.string.single_direction_sync_btn')) + .fontColor($r('app.color.button_text_color')) + .fontSize($r('app.float.button_text_size')) + .width('100%') + .textAlign(TextAlign.Center) + } + .id('blueColorBtn') + .height($r('app.float.button_height')) + .type(ButtonType.Capsule) + .backgroundColor($r('app.color.button_background_color')) + .onClick(() => { + // 点击更新子组件@Prop声明的变量,此子组件更新,父组件以及@Link声明的子组件变量不同步 + this.circleColor = COLOR_DATA.BLUE; + }) + } + .padding(10) + .border({ radius: $r('app.float.component_radius'), color: Color.Blue, width: $r('app.float.border_width') }) + } +} \ No newline at end of file diff --git a/sample/EnhanceSampleArk1.2/StateManagement/entry/src/main/ets/pages/pagelevelstagemanagement/multicompomentssync/parentchildcomponentsync/uniandbidirectionsync/UniAndBidirectionSync.ets b/sample/EnhanceSampleArk1.2/StateManagement/entry/src/main/ets/pages/pagelevelstagemanagement/multicompomentssync/parentchildcomponentsync/uniandbidirectionsync/UniAndBidirectionSync.ets new file mode 100644 index 0000000000000000000000000000000000000000..6f28074c7cc7aafb1206bc636a3ee3a3e5bcd737 --- /dev/null +++ b/sample/EnhanceSampleArk1.2/StateManagement/entry/src/main/ets/pages/pagelevelstagemanagement/multicompomentssync/parentchildcomponentsync/uniandbidirectionsync/UniAndBidirectionSync.ets @@ -0,0 +1,39 @@ +/* + * Copyright (c) 2023 Huawei Device 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 { UniAndBidirectionSyncCode } from './UniAndBidirectionSyncCode'; +import { CodeView } from '../../../../../commoncomponents/CodeView'; + +@Entry +@Component +struct UniAndBidirectionSync { + @State title: Resource = $r('app.string.single_and_two_way_sync'); + + build() { + Column() { + CodeView({ title: $title }) { + UniAndBidirectionSyncCode() + } + } + .width('100%') + .height('100%') + .padding($r('app.float.page_padding')) + .backgroundColor($r('app.color.background_shallow_grey')) + } + + aboutToDisappear(): void { + AppStorage.SetOrCreate('sideBarShow', false); + } +} \ No newline at end of file diff --git a/sample/EnhanceSampleArk1.2/StateManagement/entry/src/main/ets/pages/pagelevelstagemanagement/multicompomentssync/parentchildcomponentsync/uniandbidirectionsync/UniAndBidirectionSyncCode.ets b/sample/EnhanceSampleArk1.2/StateManagement/entry/src/main/ets/pages/pagelevelstagemanagement/multicompomentssync/parentchildcomponentsync/uniandbidirectionsync/UniAndBidirectionSyncCode.ets new file mode 100644 index 0000000000000000000000000000000000000000..e2de237b314b317984dfddd4edfd7326e8caffad --- /dev/null +++ b/sample/EnhanceSampleArk1.2/StateManagement/entry/src/main/ets/pages/pagelevelstagemanagement/multicompomentssync/parentchildcomponentsync/uniandbidirectionsync/UniAndBidirectionSyncCode.ets @@ -0,0 +1,74 @@ +/* + * Copyright (c) 2023 Huawei Device 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 { ChildCompLink } from './ComponentLink'; +import { ChildCompProp } from './ComponentProp'; +import { ViewCodeText } from '../../../../../commoncomponents/ViewCodeText'; + +// 初始化圆形的可设置颜色 +export const COLOR_DATA = { + GREY: '#eebebeba', + BLUE: '#4A90E2', + PINK: '#8DF8BEBE', + RED: '#FFF30823', +} + +@Component +export struct UniAndBidirectionSyncCode { + // 初始化圆形颜色的状态变量 + @State circleColor: string = COLOR_DATA.GREY; + + build() { + Column({ space: 10 }) { + Column({ space: 10 }) { + // 点击查看源码 + ViewCodeText({ webSrc: $rawfile('UniAndBidirectionSyncCode.ets.html') }) + Text($r('app.string.parent_component')) + .fontSize($r('app.float.tips_font_size')) + .width('100%') + .textAlign(TextAlign.Start) + .margin(10) + Text($r('app.string.uni_and_bidirection_sync_tips')) + .fontColor($r('app.color.tips_font_color')) + .fontSize($r('app.float.tips_font_size')) + .width('100%') + .textAlign(TextAlign.Center) + Circle() + .size({ width: $r('app.float.circle_size'), height: $r('app.float.circle_size') }) + .fill(this.circleColor) + // 点击更新父组件的圆形颜色变量,父组件更新,子组件@Link以及@Prop继承的变量同步 + Button() { + Text($r('app.string.uni_and_bidirection_sync_btn')) + .fontColor($r('app.color.button_text_color')) + .fontSize($r('app.float.button_text_size')) + .width('100%') + .textAlign(TextAlign.Center) + } + .id('pinkColorBtn') + .height($r('app.float.button_height')) + .type(ButtonType.Capsule) + .backgroundColor($r('app.color.button_background_color')) + .onClick(() => { + this.circleColor = COLOR_DATA.PINK; + }) + } + // 单向同步子组件 + ChildCompProp({ circleColor: this.circleColor }) + // 双向同步子组件 + ChildCompLink({ circleColor: $circleColor }) + } + .padding(10) + .border({ radius: $r('app.float.component_radius'), color: Color.Grey, width: $r('app.float.border_width') }) + } +} \ No newline at end of file diff --git a/sample/EnhanceSampleArk1.2/StateManagement/entry/src/main/ets/pages/pagelevelstagemanagement/singlecomponentstatevariables/decoratedobjecttype/arraytype/ArrayType.ets b/sample/EnhanceSampleArk1.2/StateManagement/entry/src/main/ets/pages/pagelevelstagemanagement/singlecomponentstatevariables/decoratedobjecttype/arraytype/ArrayType.ets new file mode 100644 index 0000000000000000000000000000000000000000..e9499bfce34f405c2f8dddb49eb1a46aa92f0e00 --- /dev/null +++ b/sample/EnhanceSampleArk1.2/StateManagement/entry/src/main/ets/pages/pagelevelstagemanagement/singlecomponentstatevariables/decoratedobjecttype/arraytype/ArrayType.ets @@ -0,0 +1,39 @@ +/* + * Copyright (c) 2023 Huawei Device 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 { ArrayTypeCode } from './ArrayTypeCode'; +import { CodeView } from '../../../../../commoncomponents/CodeView' + +@Entry +@Component +struct ArrayType { + @State title: Resource = $r('app.string.array_type'); + + build() { + Column() { + CodeView({ title: $title }) { + ArrayTypeCode() + } + } + .width('100%') + .height('100%') + .padding($r('app.float.page_padding')) + .backgroundColor($r('app.color.background_shallow_grey')) + } + + aboutToDisappear(): void { + AppStorage.SetOrCreate('sideBarShow', false); + } +} \ No newline at end of file diff --git a/sample/EnhanceSampleArk1.2/StateManagement/entry/src/main/ets/pages/pagelevelstagemanagement/singlecomponentstatevariables/decoratedobjecttype/arraytype/ArrayTypeCode.ets b/sample/EnhanceSampleArk1.2/StateManagement/entry/src/main/ets/pages/pagelevelstagemanagement/singlecomponentstatevariables/decoratedobjecttype/arraytype/ArrayTypeCode.ets new file mode 100644 index 0000000000000000000000000000000000000000..ae538b2dfac18b9b60efedffee67ff0393aba66f --- /dev/null +++ b/sample/EnhanceSampleArk1.2/StateManagement/entry/src/main/ets/pages/pagelevelstagemanagement/singlecomponentstatevariables/decoratedobjecttype/arraytype/ArrayTypeCode.ets @@ -0,0 +1,136 @@ +/* + * Copyright (c) 2023 Huawei Device 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 promptAction from '@ohos.promptAction'; +import { ViewCodeText } from '../../../../../commoncomponents/ViewCodeText' + +// 数组中元素的类 +export class ArrayDataType { + public id: number; + public name: string; + public age: number; + + constructor(id: number, name: string, age: number) { + this.id = id; + this.name = name; + this.age = age; + } +} + +// 初始化数组数据 +const ARRAY_TYPE_AGE_DATA: ArrayDataType[] = [new ArrayDataType(0, 'name', 17), new ArrayDataType(1, 'name', 18), + new ArrayDataType(2, 'name', 19)] +// 初始化功能按钮字符串数据 +const ARRAY_TYPE_BTN: Resource[] = [$r('app.string.array_type_add'), $r('app.string.array_type_delete'), + $r('app.string.array_type_update')]; + +@Component +export struct ArrayTypeCode { + // 数组类型状态变量初始化 + @State arrayTypeData: ArrayDataType[] = ARRAY_TYPE_AGE_DATA; + + build() { + Column({ space: 10 }) { + // 点击查看源码 + ViewCodeText({ webSrc: $rawfile('ArrayTypeCode.ets.html') }) + // 数组内容展示 + List() { + ForEach(this.arrayTypeData, (item: ArrayDataType, index: number) => { + ListItem() { + ArrayDataItem({ arrayDataItem: item, itemIndex: index }) + } + }, item => JSON.stringify(item)) + } + .width('100%') + .height('40%') + .backgroundColor($r('app.color.component_background_pink')) + .padding({ left: 10, right: 10 }) + // 功能按钮区 + ForEach(ARRAY_TYPE_BTN, (item:Resource, index:number) => { + Button(item) + .id(`arrayTypeBtn${index}`) + .width('100%') + .height($r('app.float.button_height')) + .fontColor($r('app.color.button_text_color')) + .fontSize($r('app.float.button_text_size')) + .type(ButtonType.Capsule) + .backgroundColor($r('app.color.button_background_color')) + .onClick(() => { + this.handleButtonClick(index) + }) + }, item => JSON.stringify(item)) + } + .padding(10) + .border({ radius: $r('app.float.component_radius'), color: Color.Grey, width: $r('app.float.border_width') }) + } + + handleButtonClick(index: number){ + switch (index) { + case 0: + // 数组添加元素 + this.arrayTypeData.push(new ArrayDataType(this.arrayTypeData.length, `name`, 18)); // 新增元素数据,age为18 + break; + case 1: + if (this.arrayTypeData.length === 0) { + // 当数据没有数据的时候,点击删除按钮,出现提示弹窗 + promptAction.showToast({ + message: $r('app.string.array_type_deletetoast') + }); + } else { + // 数组删除元素 + this.arrayTypeData.splice(this.arrayTypeData.length - 1, 1); // 删除最后一个元素 + } + break; + case 2: + if (this.arrayTypeData.length === 0) { + // 当数据没有数据的时候,点击更新按钮,出现提示弹窗 + promptAction.showToast({ + message: $r('app.string.array_type_updatetoast') + }); + break; + } + // 初始化一个对象后给数组中的元素赋值,更新数组元素 + let temp = new ArrayDataType(this.arrayTypeData[0].id, this.arrayTypeData[0].name, this.arrayTypeData[0].age + 1); + this.arrayTypeData[0] = temp; + break; + default: + break; + } + } +} + +// 数组Item内容组件 +@Component +struct ArrayDataItem { + private arrayDataItem: ArrayDataType; + private itemIndex: number; + + build() { + Column() { + Text(`${this.arrayDataItem.name}${this.itemIndex}`) + .width('100%') + .fontColor($r('app.color.button_text_color')) + .fontSize(20) + Text(`age:${this.arrayDataItem.age}`) + .width('100%') + .fontColor($r('app.color.button_text_color')) + .fontSize(20) + Divider().width('100%') + .strokeWidth(1) + .margin({ top: 20 }) + } + .margin({ top: 20 }) + } +} \ No newline at end of file diff --git a/sample/EnhanceSampleArk1.2/StateManagement/entry/src/main/ets/pages/pagelevelstagemanagement/singlecomponentstatevariables/decoratedobjecttype/basetype/BaseType.ets b/sample/EnhanceSampleArk1.2/StateManagement/entry/src/main/ets/pages/pagelevelstagemanagement/singlecomponentstatevariables/decoratedobjecttype/basetype/BaseType.ets new file mode 100644 index 0000000000000000000000000000000000000000..f320242808454db84d18aef192a160b340a918d7 --- /dev/null +++ b/sample/EnhanceSampleArk1.2/StateManagement/entry/src/main/ets/pages/pagelevelstagemanagement/singlecomponentstatevariables/decoratedobjecttype/basetype/BaseType.ets @@ -0,0 +1,40 @@ +/* + * Copyright (c) 2023 Huawei Device 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 { BaseTypeCode } from './BaseTypeCode'; +import { CodeView } from '../../../../../commoncomponents/CodeView' + +@Entry +@Component +struct BaseType { + @State title: Resource = $r('app.string.base_type'); + + build() { + Column() { + CodeView({ title: $title}){ + BaseTypeCode() + } + } + .width('100%') + .height('100%') + .padding($r('app.float.page_padding')) + .backgroundColor($r('app.color.background_shallow_grey')) + } + + aboutToDisappear(): void { + AppStorage.SetOrCreate('sideBarShow', false); + } +} \ No newline at end of file diff --git a/sample/EnhanceSampleArk1.2/StateManagement/entry/src/main/ets/pages/pagelevelstagemanagement/singlecomponentstatevariables/decoratedobjecttype/basetype/BaseTypeCode.ets b/sample/EnhanceSampleArk1.2/StateManagement/entry/src/main/ets/pages/pagelevelstagemanagement/singlecomponentstatevariables/decoratedobjecttype/basetype/BaseTypeCode.ets new file mode 100644 index 0000000000000000000000000000000000000000..6ddabf1cefb0c196cf2b86dcc408b3fa297235bf --- /dev/null +++ b/sample/EnhanceSampleArk1.2/StateManagement/entry/src/main/ets/pages/pagelevelstagemanagement/singlecomponentstatevariables/decoratedobjecttype/basetype/BaseTypeCode.ets @@ -0,0 +1,58 @@ +/* + * Copyright (c) 2023 Huawei Device 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 { ViewCodeText } from '../../../../../commoncomponents/ViewCodeText' + +@Component +export struct BaseTypeCode { + @State circleColor: Resource = $r('app.color.circle_pink'); + + build() { + Column({ space: 10 }) { + // 点击查看源码 + ViewCodeText({webSrc: $rawfile('BaseTypeCode.ets.html')}) + + Text($r('app.string.base_type_tip_text')) + .fontColor($r('app.color.tips_font_color')) + .fontSize($r('app.float.tips_font_size')) + .width('100%') + .textAlign(TextAlign.Center) + Circle() + .size({ width: $r('app.float.circle_size'), height: $r('app.float.circle_size') }) + .fill(this.circleColor) + Button() { + Text(this.circleColor.id === $r('app.color.circle_pink') + .id ? $r('app.string.set_to_blue') : $r('app.string.set_to_pink')) + .fontColor($r('app.color.button_text_color')) + .fontSize($r('app.float.button_text_size')) + .width('100%') + .textAlign(TextAlign.Center) + } + .id('circleColorBtn') + .height($r('app.float.button_height')) + .type(ButtonType.Capsule) + .backgroundColor($r('app.color.button_background_color')) + .onClick(() => { + if (this.circleColor.id === $r('app.color.circle_pink').id) { + this.circleColor = $r('app.color.circle_blue'); + } else { + this.circleColor = $r('app.color.circle_pink'); + } + }) + } + .padding(10) + .border({ radius: $r('app.float.component_radius'), color: Color.Grey, width: $r('app.float.border_width') }) + } +} \ No newline at end of file diff --git a/sample/EnhanceSampleArk1.2/StateManagement/entry/src/main/ets/pages/pagelevelstagemanagement/singlecomponentstatevariables/decoratedobjecttype/classobjecttype/ClassObjectType.ets b/sample/EnhanceSampleArk1.2/StateManagement/entry/src/main/ets/pages/pagelevelstagemanagement/singlecomponentstatevariables/decoratedobjecttype/classobjecttype/ClassObjectType.ets new file mode 100644 index 0000000000000000000000000000000000000000..600e637a678835e63b2e2485cf35269b65b37747 --- /dev/null +++ b/sample/EnhanceSampleArk1.2/StateManagement/entry/src/main/ets/pages/pagelevelstagemanagement/singlecomponentstatevariables/decoratedobjecttype/classobjecttype/ClassObjectType.ets @@ -0,0 +1,39 @@ +/* + * Copyright (c) 2023 Huawei Device 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 { ClassObjectTypeCode } from './ClassObjectTypeCode'; +import { CodeView } from '../../../../../commoncomponents/CodeView'; + +@Entry +@Component +struct ClassObjectType { + @State title: Resource = $r('app.string.class_type'); + + build() { + Column() { + CodeView({ title: $title }) { + ClassObjectTypeCode() + } + } + .width('100%') + .height('100%') + .padding($r('app.float.page_padding')) + .backgroundColor($r('app.color.background_shallow_grey')) + } + + aboutToDisappear(): void { + AppStorage.SetOrCreate('sideBarShow', false); + } +} \ No newline at end of file diff --git a/sample/EnhanceSampleArk1.2/StateManagement/entry/src/main/ets/pages/pagelevelstagemanagement/singlecomponentstatevariables/decoratedobjecttype/classobjecttype/ClassObjectTypeCode.ets b/sample/EnhanceSampleArk1.2/StateManagement/entry/src/main/ets/pages/pagelevelstagemanagement/singlecomponentstatevariables/decoratedobjecttype/classobjecttype/ClassObjectTypeCode.ets new file mode 100644 index 0000000000000000000000000000000000000000..b30930aaf27b9c6cbddd8ff14f7cadd19b1a1f7a --- /dev/null +++ b/sample/EnhanceSampleArk1.2/StateManagement/entry/src/main/ets/pages/pagelevelstagemanagement/singlecomponentstatevariables/decoratedobjecttype/classobjecttype/ClassObjectTypeCode.ets @@ -0,0 +1,173 @@ +/* + * Copyright (c) 2023 Huawei Device 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 { ViewCodeText } from '../../../../../commoncomponents/ViewCodeText'; +import { getResourceString } from '../../../../../utils/ResourceUtils'; + +const CONTEXT: common.UIAbilityContext = getContext(this) as common.UIAbilityContext; + +@Component +export struct ClassObjectTypeCode { + // 对象类型状态变量初始化 + @State classObjectData: ParentClass = new ParentClass(getResourceString(CONTEXT, $r('app.string.class_object')), + getResourceString(CONTEXT, $r('app.string.class_attribute')), 1, + new ChildClass(getResourceString(CONTEXT, $r('app.string.class_child_attribute')), 2)); + // 更新对象的次数 + private clickedCount: number = 0; + + build() { + Column({ space: 10 }) { + // 点击查看源码 + ViewCodeText({ webSrc: $rawfile('ClassObjectTypeCode.ets.html') }) + Column({ space: 15 }) { + Row() { + Text(this.classObjectData.title) + .fontSize(20) + .textAlign(TextAlign.End) + Divider() + .layoutWeight(1) + .strokeWidth(1) + .margin({ top: 20, left: 5 }) + } + .width('100%') + + Column() { + Row() { + Text(this.classObjectData.attributeTitle) + .fontSize(20) + Text(`${this.classObjectData.attribute}`) + .fontSize(20) + .textAlign(TextAlign.End) + } + .width('100%') + .justifyContent(FlexAlign.SpaceBetween) + + Divider() + .width('100%') + .strokeWidth(1) + } + .width('100%') + .padding({ left: 50 }) + + ChildObjectComp({ childObject: this.classObjectData.child }) // 对象的属性,使用子组件显示 + } + .width('100%') + .backgroundColor($r('app.color.component_background_pink')) + .padding(10) + // 点击更新对象 + Button($r('app.string.class_type_update_object')) + .onClick(() => { + // 更新对象,把新的对象直接赋值给状态变量 + this.clickedCount++; + let objectTitle: string = getResourceString(CONTEXT, $r('app.string.class_object')) + this.clickedCount; + let attributeTitle: string = getResourceString(CONTEXT, $r('app.string.class_attribute')) + this.clickedCount; + let childAttributeTitle: string = getResourceString(CONTEXT, $r('app.string.class_child_attribute')) + + this.clickedCount; + let newObject = new ParentClass(objectTitle, attributeTitle, this.classObjectData.attribute + 1, + new ChildClass(childAttributeTitle, this.classObjectData.child.attribute + 1)); + this.classObjectData = newObject; + }) + .id('updateObject') + .fontColor($r('app.color.button_text_color')) + .fontSize($r('app.float.button_text_size')) + .type(ButtonType.Capsule) + .buttonStyle() + Button($r('app.string.class_type_update_attribute')) + .onClick(() => { + // 点击更新对象的属性 + this.classObjectData.attribute++; + }) + .id('updateObjectAttribute') + .fontColor($r('app.color.button_text_color')) + .fontSize($r('app.float.button_text_size')) + .type(ButtonType.Capsule) + .buttonStyle() + Button($r('app.string.class_type_update_child_attribute')) + .onClick(() => { + // 点击更新对象属性的属性 + this.classObjectData.child.attribute++; + }) + .id('updateAttributeOfAttribute') + .fontColor($r('app.color.button_text_color')) + .fontSize($r('app.float.button_text_size')) + .type(ButtonType.Capsule) + .buttonStyle() + } + .width('100%') + .padding(10) + .border({ radius: $r('app.float.component_radius'), color: Color.Grey, width: $r('app.float.border_width') }) + } +} + +// 对象中属性的组件 +@Component +struct ChildObjectComp { + // 使用@ObjectLink修饰,与父组件同步对象的属性 + @ObjectLink childObject: ChildClass; + + build() { + Column() { + Row() { + Text(this.childObject.title) + .fontSize(20) + Text(`${this.childObject.attribute}`) + .fontSize(20) + .textAlign(TextAlign.End) + } + .width('100%') + .justifyContent(FlexAlign.SpaceBetween) + + Divider() + .width('100%') + .strokeWidth(1) + } + .width('100%') + .padding({ left: 100 }) + } +} + +@Styles function buttonStyle() { + .width('100%') + .height($r('app.float.button_height')) + .backgroundColor($r('app.color.button_background_color')) +} + +// 要更新对象属性的属性,对象属性的类需要使用@Observed修饰 +@Observed +class ChildClass { + public title: string; + public attribute: number; + + constructor(title: string, attribute: number) { + this.title = title; + this.attribute = attribute; + } +} + +class ParentClass { + public title: string; + public attributeTitle: string; + public attribute: number; + public child: ChildClass; + + constructor(title: string, attributeTitle: string, attribute: number, child: ChildClass) { + this.title = title; + this.attributeTitle = attributeTitle; + this.attribute = attribute; + this.child = child; + + } +} diff --git a/sample/EnhanceSampleArk1.2/StateManagement/entry/src/main/ets/pages/pagelevelstagemanagement/singlecomponentstatevariables/updatetactics/updateboundcomponent/UpdateBoundComponent.ets b/sample/EnhanceSampleArk1.2/StateManagement/entry/src/main/ets/pages/pagelevelstagemanagement/singlecomponentstatevariables/updatetactics/updateboundcomponent/UpdateBoundComponent.ets new file mode 100644 index 0000000000000000000000000000000000000000..eafb21710c67bb1506b61c6c63247b9b0ccb2c76 --- /dev/null +++ b/sample/EnhanceSampleArk1.2/StateManagement/entry/src/main/ets/pages/pagelevelstagemanagement/singlecomponentstatevariables/updatetactics/updateboundcomponent/UpdateBoundComponent.ets @@ -0,0 +1,39 @@ +/* + * Copyright (c) 2023 Huawei Device 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 { UpdateBoundComponentCode } from './UpdateBoundComponentCode'; +import { CodeView } from '../../../../../commoncomponents/CodeView'; + +@Entry +@Component +struct UpdateBoundComponent { + @State title: Resource = $r('app.string.only_update_bound_components'); + + build() { + Column() { + CodeView({ title: $title }) { + UpdateBoundComponentCode() + } + } + .width('100%') + .height('100%') + .padding($r('app.float.page_padding')) + .backgroundColor($r('app.color.background_shallow_grey')) + } + + aboutToDisappear(): void { + AppStorage.SetOrCreate('sideBarShow', false); + } +} \ No newline at end of file diff --git a/sample/EnhanceSampleArk1.2/StateManagement/entry/src/main/ets/pages/pagelevelstagemanagement/singlecomponentstatevariables/updatetactics/updateboundcomponent/UpdateBoundComponentCode.ets b/sample/EnhanceSampleArk1.2/StateManagement/entry/src/main/ets/pages/pagelevelstagemanagement/singlecomponentstatevariables/updatetactics/updateboundcomponent/UpdateBoundComponentCode.ets new file mode 100644 index 0000000000000000000000000000000000000000..41b3b1d051d2d2e2030923dabb03ecda9a91671a --- /dev/null +++ b/sample/EnhanceSampleArk1.2/StateManagement/entry/src/main/ets/pages/pagelevelstagemanagement/singlecomponentstatevariables/updatetactics/updateboundcomponent/UpdateBoundComponentCode.ets @@ -0,0 +1,93 @@ +/* + * Copyright (c) 2023 Huawei Device 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 { ViewCodeText } from '../../../../../commoncomponents/ViewCodeText'; + +@Component +export struct UpdateBoundComponentCode { + // 组件内状态变量 + @State titleName: string = 'title'; + // 组件内private变量 + private content: string = 'content'; + // 组件内变量更新的次数 + private updateCount: number = 0; + + build() { + Column({ space: 10 }) { + // 点击查看源码 + ViewCodeText({webSrc: $rawfile('UpdateBoundComponentCode.ets.html')}) + + Column() { + Text($r('app.string.only_update_state')) + .fontColor($r('app.color.tips_font_color')) + .fontSize($r('app.float.tips_font_size')) + .width('100%') + Row() { + Text($r('app.string.only_update_title')) + .fontColor($r('app.color.button_text_color')) + .fontSize($r('app.float.button_text_size')) + Text(`${this.titleName}`) // titleName为状态变量,绑定Text组件 + .fontColor($r('app.color.button_text_color')) + .fontSize(20) + } + .width('100%') + .margin(10) + + Text($r('app.string.only_update_private')) + .fontColor($r('app.color.tips_font_color')) + .fontSize($r('app.float.tips_font_size')) + .width('100%') + .margin({ top: 20 }) + Row() { + Text($r('app.string.only_update_content')) + .fontColor($r('app.color.button_text_color')) + .fontSize($r('app.float.button_text_size')) + Text(`${this.content}`) // content为private,绑定Text组件 + .fontColor($r('app.color.button_text_color')) + .fontSize(20) + } + .width('100%') + .margin(10) + } + .width('100%') + .padding(10) + .justifyContent(FlexAlign.SpaceAround) + .backgroundColor($r('app.color.component_background_pink')) + + Column() { + Button($r('app.string.update_title_content')) + .onClick(() => { + // 点击更新@State和Private声明的变量,更新策略为:@State和Private的数据发生变化,@State变量绑定的组件更新,Private变量绑定的组件不更新。 + this.updateCount++; + this.content = `content ${this.updateCount}`; + this.titleName = `title ${this.updateCount}`; + }) + .id('titleAndContentBtn') + .width('100%') + .height($r('app.float.button_height')) + .fontColor($r('app.color.button_text_color')) + .fontSize($r('app.float.button_text_size')) + .type(ButtonType.Capsule) + .backgroundColor($r('app.color.button_background_color')) + Text($r('app.string.only_update_state_components')) + .fontColor($r('app.color.tips_font_color')) + .fontSize($r('app.float.button_text_size')) + .margin({ top: 30 }) + }.width('100%') + } + .padding(10) + .border({ radius: $r('app.float.component_radius'), color: Color.Grey, width: $r('app.float.border_width') }) + } +} \ No newline at end of file diff --git a/sample/EnhanceSampleArk1.2/StateManagement/entry/src/main/ets/storagelinkability/StorageLinkAbility.ts b/sample/EnhanceSampleArk1.2/StateManagement/entry/src/main/ets/storagelinkability/StorageLinkAbility.ts new file mode 100644 index 0000000000000000000000000000000000000000..2a7b80476f7cef19a399935a6f083913daf09bb9 --- /dev/null +++ b/sample/EnhanceSampleArk1.2/StateManagement/entry/src/main/ets/storagelinkability/StorageLinkAbility.ts @@ -0,0 +1,58 @@ +/* + * Copyright (c) 2023 Huawei Device 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 UIAbility from '@ohos.app.ability.UIAbility'; +import type window from '@ohos.window'; +import Logger from '../utils/Logger'; + +const TAG = 'StorageLinkAbility'; + +export default class StorageLinkAbility extends UIAbility { + onCreate(want, launchParam): void { + Logger.info(TAG, 'Ability onCreate'); + } + + onDestroy(): void { + Logger.info(TAG, 'Ability onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage): void { + // Main window is created, set main page for this ability + Logger.info(TAG, 'Ability onWindowStageCreate'); + + windowStage.loadContent('pages/applylevelstagemanagement/applyglobaldatasync/StorageLinkAbilityPage', (err, data) => { + if (err.code) { + Logger.error(TAG, 'Failed to load the content. Cause: %{public}s'); + return; + } + Logger.info(TAG, 'Succeeded in loading the content. Data: %{public}s'); + }); + } + + onWindowStageDestroy(): void { + // Main window is destroyed, release UI related resources + Logger.info(TAG, 'Ability onWindowStageDestroy'); + } + + onForeground(): void { + // Ability has brought to foreground + Logger.info(TAG, 'Ability onForeground'); + } + + onBackground(): void { + // Ability has back to background + Logger.info(TAG, 'Ability onBackground'); + } +} diff --git a/sample/EnhanceSampleArk1.2/StateManagement/entry/src/main/ets/storagepropability/StoragePropAbility.ts b/sample/EnhanceSampleArk1.2/StateManagement/entry/src/main/ets/storagepropability/StoragePropAbility.ts new file mode 100644 index 0000000000000000000000000000000000000000..4075bdd8a5ace00f92eb73ae1e170961f9a4be82 --- /dev/null +++ b/sample/EnhanceSampleArk1.2/StateManagement/entry/src/main/ets/storagepropability/StoragePropAbility.ts @@ -0,0 +1,58 @@ +/* + * Copyright (c) 2023 Huawei Device 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 UIAbility from '@ohos.app.ability.UIAbility'; +import type window from '@ohos.window'; +import Logger from '../utils/Logger'; + +const TAG = 'StoragePropAbility'; + +export default class StoragePropAbility extends UIAbility { + onCreate(want, launchParam): void { + Logger.info(TAG, 'Ability onCreate'); + } + + onDestroy(): void { + Logger.info(TAG, 'Ability onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage): void { + // Main window is created, set main page for this ability + Logger.info(TAG, 'Ability onWindowStageCreate'); + + windowStage.loadContent('pages/applylevelstagemanagement/applyglobaldatasync/StoragePropAbilityPage', (err, data) => { + if (err.code) { + Logger.error(TAG, 'Failed to load the content. Cause: %{public}s'); + return; + } + Logger.info(TAG, 'Succeeded in loading the content. Data: %{public}s'); + }); + } + + onWindowStageDestroy(): void { + // Main window is destroyed, release UI related resources + Logger.info(TAG, 'Ability onWindowStageDestroy'); + } + + onForeground(): void { + // Ability has brought to foreground + Logger.info(TAG, 'Ability onForeground'); + } + + onBackground(): void { + // Ability has back to background + Logger.info(TAG, 'Ability onBackground'); + } +} diff --git a/sample/EnhanceSampleArk1.2/StateManagement/entry/src/main/ets/utils/Logger.ts b/sample/EnhanceSampleArk1.2/StateManagement/entry/src/main/ets/utils/Logger.ts new file mode 100644 index 0000000000000000000000000000000000000000..ef1d32053fc81622fe3731799ba17448f6c4c203 --- /dev/null +++ b/sample/EnhanceSampleArk1.2/StateManagement/entry/src/main/ets/utils/Logger.ts @@ -0,0 +1,45 @@ +/* + * Copyright (c) 2023 Huawei Device 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 hilog from '@ohos.hilog'; + +class Logger { + private domain: number; + private prefix: string; + private format: string = '%{public}s, %{public}s'; + + constructor(prefix: string) { + this.prefix = prefix; + this.domain = 0xFF00; + } + + debug(...args: string[]): void { + hilog.debug(this.domain, this.prefix, this.format, args); + } + + info(...args: string[]): void { + hilog.info(this.domain, this.prefix, this.format, args); + } + + warn(...args: string[]): void { + hilog.warn(this.domain, this.prefix, this.format, args); + } + + error(...args: string[]): void { + hilog.error(this.domain, this.prefix, this.format, args); + } +} + +export default new Logger('Sample_StateManagement'); \ No newline at end of file diff --git a/sample/EnhanceSampleArk1.2/StateManagement/entry/src/main/ets/utils/ResourceUtils.ts b/sample/EnhanceSampleArk1.2/StateManagement/entry/src/main/ets/utils/ResourceUtils.ts new file mode 100644 index 0000000000000000000000000000000000000000..2a7938485d5740dc2fa3d2b566ac1cf50ac7354e --- /dev/null +++ b/sample/EnhanceSampleArk1.2/StateManagement/entry/src/main/ets/utils/ResourceUtils.ts @@ -0,0 +1,26 @@ +/* + * Copyright (c) 2023 Huawei Device 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 type common from '@ohos.app.ability.common'; + +/** + * getResourceString将Resource类型的数据转换成string类型的数据 + * @param context + * @param ResourceData + */ +export function getResourceString(context: common.UIAbilityContext, resourceData: Resource): string { + let stringData: string = context.resourceManager.getStringSync(resourceData.id); + return stringData; +} \ No newline at end of file diff --git a/sample/EnhanceSampleArk1.2/StateManagement/entry/src/main/ets/utils/StartAbilityUtils.ts b/sample/EnhanceSampleArk1.2/StateManagement/entry/src/main/ets/utils/StartAbilityUtils.ts new file mode 100644 index 0000000000000000000000000000000000000000..388a260f5834fd3e994e4ab34365e3bfe4b5db64 --- /dev/null +++ b/sample/EnhanceSampleArk1.2/StateManagement/entry/src/main/ets/utils/StartAbilityUtils.ts @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2023 Huawei Device 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 type common from '@ohos.app.ability.common'; +import type { AbilityConfigType } from '../pages/applylevelstagemanagement/model/AbilityConfigType'; +import Logger from './Logger'; + +export function startSpecifiedAbility(context: common.UIAbilityContext, abilityName: string): void { + let abilityConfig: AbilityConfigType = { + bundleName: 'com.samples.statemanagement', + abilityName: abilityName + }; + context.startAbility(abilityConfig, (err) => { + if (err.code) { + // 处理业务逻辑错误 + Logger.error(`startAbility failed, code is ${err.code}, message is ${err.message}`); + return; + } + // 执行正常业务 + Logger.info('startAbility succeed'); + }); +} \ No newline at end of file diff --git a/sample/EnhanceSampleArk1.2/StateManagement/entry/src/main/module.json5 b/sample/EnhanceSampleArk1.2/StateManagement/entry/src/main/module.json5 new file mode 100644 index 0000000000000000000000000000000000000000..862cca180aa4e4e14e7b2adf4c457d3fb70969d4 --- /dev/null +++ b/sample/EnhanceSampleArk1.2/StateManagement/entry/src/main/module.json5 @@ -0,0 +1,87 @@ +/* + * Copyright (c) 2023 Huawei Device 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. + */ + +{ + "module": { + "name": "entry", + "type": "entry", + "description": "$string:module_desc", + "mainElement": "EntryAbility", + "deviceTypes": [ + "default", + "tablet" + ], + "deliveryWithInstall": true, + "installationFree": false, + "pages": "$profile:main_pages", + "abilities": [ + { + "name": "EntryAbility", + "srcEntrance": "./ets/entryability/EntryAbility.ts", + "description": "$string:EntryAbility_desc", + "icon": "$media:icon", + "label": "$string:EntryAbility_label", + "startWindowIcon": "$media:icon", + "startWindowBackground": "$color:start_window_background", + "visible": true, + "skills": [ + { + "entities": [ + "entity.system.home" + ], + "actions": [ + "action.system.home" + ] + } + ] + }, + { + "name": "StoragePropAbility", + "srcEntrance": "./ets/storagepropability/StoragePropAbility.ts", + "description": "$string:storagepropability_desc", + "icon": "$media:icon", + "label": "$string:storagepropability_label", + "startWindowIcon": "$media:icon", + "startWindowBackground": "$color:start_window_background", + "visible": true + }, + { + "name": "StorageLinkAbility", + "srcEntrance": "./ets/storagelinkability/StorageLinkAbility.ts", + "description": "$string:storagelinkability_desc", + "icon": "$media:icon", + "label": "$string:storagelinkability_label", + "startWindowIcon": "$media:icon", + "startWindowBackground": "$color:start_window_background", + "visible": true + }, + { + "name": "OutOfSyncAbility", + "srcEntrance": "./ets/outofsyncability/OutOfSyncAbility.ts", + "description": "$string:outofsyncability_desc", + "icon": "$media:icon", + "label": "$string:outofsyncability_label", + "startWindowIcon": "$media:icon", + "startWindowBackground": "$color:start_window_background", + "visible": true + } + ], + "requestPermissions": [ + { + "name": "ohos.permission.START_ABILITIES_FROM_BACKGROUND" + } + ] + } +} \ No newline at end of file diff --git a/sample/EnhanceSampleArk1.2/StateManagement/entry/src/main/resources/base/element/color.json b/sample/EnhanceSampleArk1.2/StateManagement/entry/src/main/resources/base/element/color.json new file mode 100644 index 0000000000000000000000000000000000000000..ce20782759354f5b0c9d92e4f110d9129770c5f3 --- /dev/null +++ b/sample/EnhanceSampleArk1.2/StateManagement/entry/src/main/resources/base/element/color.json @@ -0,0 +1,81 @@ +{ + "color": [ + { + "name": "start_window_background", + "value": "#FFFFFF" + }, + { + "name": "font_color_shallow", + "value": "#99000000" + }, + { + "name": "font_color_dark", + "value": "#000000" + }, + { + "name": "tab_bar_select", + "value": "#007DFF" + }, + { + "name": "tab_bar_unselect", + "value": "#66182431" + }, + { + "name": "tab_bar_divider", + "value": "#33182431" + }, + { + "name": "background_shallow_grey", + "value": "#F1F3F5" + }, + { + "name": "circle_pink", + "value": "#F7A4A4" + }, + { + "name": "circle_blue", + "value": "#4A90E2" + }, + { + "name": "tips_font_color", + "value": "#660d0d0d" + }, + { + "name": "source_code_font_color", + "value": "#0A8DF2" + }, + { + "name": "button_text_color", + "value": "#0d0d0d" + }, + { + "name": "button_background_color", + "value": "#E5E5E5" + }, + { + "name": "button_border_color", + "value": "#880d0d0d" + }, + { + "name": "divider_color", + "value": "#33182431" + }, + { + "name": "code_view_background", + "value": "#66182431" + }, + { + "name": "component_background_pink", + "value": "#22F7A4A4" + }, + { + "name": "color_white", + "value": "#FFFFFF" + }, + { + "name": "nightnode_color", + "value": "#EE343333" + } + + ] +} \ No newline at end of file diff --git a/sample/EnhanceSampleArk1.2/StateManagement/entry/src/main/resources/base/element/float.json b/sample/EnhanceSampleArk1.2/StateManagement/entry/src/main/resources/base/element/float.json new file mode 100644 index 0000000000000000000000000000000000000000..59052f2e03cb91d9909f291a2480646f01ebd2b5 --- /dev/null +++ b/sample/EnhanceSampleArk1.2/StateManagement/entry/src/main/resources/base/element/float.json @@ -0,0 +1,64 @@ +{ + "float": [ + { + "name": "tips_font_size", + "value": "16" + }, + { + "name": "source_code_font_size", + "value": "12" + }, + { + "name": "circle_size", + "value": "40" + }, + { + "name": "component_radius", + "value": "5" + }, + { + "name": "button_text_size", + "value": "16" + }, + { + "name": "button_height", + "value": "40" + }, + { + "name": "border_width", + "value": "1" + }, + { + "name": "title_bar_height", + "value": "60" + }, + { + "name": "icon_back_size", + "value": "20" + }, + { + "name": "page_padding", + "value": "12" + }, + { + "name": "title_font_size", + "value": "18" + }, + { + "name": "title_margin", + "value": "16" + }, + { + "name": "divider_height", + "value": "1" + }, + { + "name": "code_view_bottom", + "value": "20" + }, + { + "name": "select_font_size", + "value": "16" + } + ] +} \ No newline at end of file diff --git a/sample/EnhanceSampleArk1.2/StateManagement/entry/src/main/resources/base/element/string.json b/sample/EnhanceSampleArk1.2/StateManagement/entry/src/main/resources/base/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..a94a86162adb3b8cbab668b5dd6a70a234ed1c7f --- /dev/null +++ b/sample/EnhanceSampleArk1.2/StateManagement/entry/src/main/resources/base/element/string.json @@ -0,0 +1,432 @@ +{ + "string": [ + { + "name": "module_desc", + "value": "StateManagement entry model" + }, + { + "name": "EntryAbility_desc", + "value": "StateManagement entry ability" + }, + { + "name": "EntryAbility_label", + "value": "StateManagement" + }, + { + "name": "close", + "value": "Close" + }, + { + "name": "page_level", + "value": "PageLevelStageManagement" + }, + { + "name": "app_level", + "value": "AppLevelStageManagement" + }, + { + "name": "single_component_state", + "value": "State variables in single component" + }, + { + "name": "decorated_object_type", + "value": "The decorated object type" + }, + { + "name": "base_type", + "value": "Based type" + }, + { + "name": "array_type", + "value": "Array type" + }, + { + "name": "array_type_add", + "value": "add elements" + }, + { + "name": "array_type_delete", + "value": "delete elements" + }, + { + "name": "array_type_update", + "value": "Update a single element in an array" + }, + { + "name": "array_type_deletetoast", + "value": "The list is empty and cannot be deleted!" + }, + { + "name": "array_type_updatetoast", + "value": "The list is empty and cannot be update!" + }, + { + "name": "class_type", + "value": "Class Object type" + }, + { + "name": "class_type_objectName", + "value": "Chasing the starry sun" + }, + { + "name": "class_object", + "value": "Object" + }, + { + "name": "class_attribute", + "value": "Object Attribute" + }, + { + "name": "class_child_attribute", + "value": "Attribute of attribute" + }, + { + "name": "class_type_update_object", + "value": "Update object:" + }, + { + "name": "class_type_update_attribute", + "value": "Update object attribute" + }, + { + "name": "class_type_update_child_attribute", + "value": "Update attribute of attribute" + }, + { + "name": "update_principle", + "value": "Update principle" + }, + { + "name": "only_update_bound_components", + "value": "Only the components to which you are bound are updated" + }, + { + "name": "only_update_state", + "value": "@State declare variables" + }, + { + "name": "only_update_title", + "value": "title:" + }, + { + "name": "only_update_private", + "value": "Private declare variables" + }, + { + "name": "only_update_content", + "value": "content:" + }, + { + "name": "update_title_content", + "value": "Click to modify the title and content" + }, + { + "name": "only_update_state_components", + "value": "Only update components declared by @State" + }, + { + "name": "update_the_custom_component", + "value": "Where the custom component is updated" + }, + { + "name": "multi_component_sync", + "value": "Status synchronization between components" + }, + { + "name": "parent_child_sync", + "value": "State synchronization between parent and child components" + }, + { + "name": "single_and_two_way_sync", + "value": "Single and two-way synchronization" + }, + { + "name": "parent_component", + "value": "Parent component" + }, + { + "name": "child_component", + "value": "Child component" + }, + { + "name": "uni_and_bidirection_sync_tips", + "value": "The prototype color in the parent component is @ state state state variable" + }, + { + "name": "single_direction_sync_tips", + "value": "The prototype color in the one-way synchronization sub-component is @Prop state variable" + }, + { + "name": "both_direction_sync_tips", + "value": "The prototype color in the bidirectional synchronization sub-component is @Link state variable" + }, + { + "name": "uni_and_bidirection_sync_btn", + "value": "Set to pink, components are updated synchronously" + }, + { + "name": "single_direction_sync_btn", + "value": "Set to blue, parent component is out of sync" + }, + { + "name": "both_direction_sync_btn", + "value": "Set to red, attachment synchronization" + }, + { + "name": "partial_sync", + "value": "The child component synchronizes parts of the parent component" + }, + { + "name": "partial_sync_element_one", + "value": "Elment one" + }, + { + "name": "partial_sync_element_two", + "value": "Elment two" + }, + { + "name": "partial_sync_element_three", + "value": "Elment three" + }, + { + "name": "partial_sync_attribute_one", + "value": "Attribute one" + }, + { + "name": "partial_sync_attribute_two", + "value": "Attribute two" + }, + { + "name": "partial_sync_attribute_three", + "value": "Attribute three" + }, + { + "name": "partial_sync_parent_tips", + "value": "The array in the parent component is a @State state variable, and the classes of the elements of the array are decorated with @observed" + }, + { + "name": "partial_sync_text", + "value": "Use @ObjectLink to modify variables in child components to synchronize data with elements of objects in parent components" + }, + { + "name": "parent_descendent_sync", + "value": "State synchronization between parent and descendent" + }, + { + "name": "select_colorblue", + "value": "Blue" + }, + { + "name": "select_colorpink", + "value": "Pink" + }, + { + "name": "realize_by_state_link", + "value": "Use @State, @Link to realize:" + }, + { + "name": "realize_by_provide_consume", + "value": "Use @Provide, @Consume to realize:" + }, + { + "name": "deepnest_parent_titleone", + "value": "The circular color in the parent component as @State state variable" + }, + { + "name": "deepnest_child_titleone", + "value": "The circular color of the sub-component is @Link, and the state variable is passed to the sub-component" + }, + { + "name": "deepnest_descendent_titleone", + "value": "The circle color in the sub-component is @Link status variable" + }, + { + "name": "deepnest_parent_titletwo", + "value": "The state variable with the circular color of @Provide in the parent component as the data provider" + }, + { + "name": "deepnest_child_titletwo", + "value": "Variables do not need to be set in subcomponents" + }, + { + "name": "deepnest_descendent_titletwo", + "value": "The round color in the sub-component is @Consume variable to sense data changes, update the UI, or reverse synchronization" + }, + { + "name": "brother_sync", + "value": "State synchronization between brother components" + }, + { + "name": "parent_titleone", + "value": "The common parent component circle color is @State variable" + }, + { + "name": "link_brothers_title", + "value": "The brother component circle color is @Link state variable" + }, + { + "name": "parent_titletwo", + "value": "The common parent component circle color is @Provide variable" + }, + { + "name": "consume_brothers_title", + "value": "The brother component circle color is @Consume state variable" + }, + { + "name": "application_storage_ui", + "value": "State synchronization between the app storage and the UI" + }, + { + "name": "nightmode", + "value": "Night mode" + }, + { + "name": "close_nightmode", + "value": "Close night mode" + }, + { + "name": "start_nightmode", + "value": "Start night mode" + }, + { + "name": "nightmode_text", + "value": "Night mode control Ability1, Ability2 interface style" + }, + { + "name": "fontSize_text", + "value": "FontSize" + }, + { + "name": "fontSize_singlesync_textone", + "value": "FontSize one-way synchronization" + }, + { + "name": "enter_abilityone", + "value": "Enter ability1" + }, + { + "name": "enter_abilitytwo", + "value": "Enter ability2" + }, + { + "name": "abilityone_page", + "value": "Ability1" + }, + { + "name": "abilitytwo_page", + "value": "Ability2" + }, + { + "name": "both_data_binding", + "value": "The component establishes two-way binding with AppStorage through the state variable decorated by @StorageLink(key)" + }, + { + "name": "single_data_binding", + "value": "The component establishes a one-way data binding with AppStorage by using the state variable decorated with @StorageProp(key)" + }, + { + "name": "nigntmode_both_binding", + "value": "The night mode in this interface is bidirectional synchronization of @StorageLink(key) variable, and the night mode switch will be synchronized in other capabilities" + }, + { + "name": "single_fontsize_binding", + "value": "The font size in this interface is the @StorageProp(key) variable one-way synchronization, which only changes the font size of the current interface" + }, + { + "name": "ability_storage_ui", + "value": "State synchronization between the ability storage and the UI" + }, + { + "name": "enter_pageone", + "value": "Enter page1" + }, + { + "name": "enter_pagetwo", + "value": "Enter page2" + }, + { + "name": "enter_ability_outofsync", + "value": "Cross Ability out of sync" + }, + { + "name": "ability_storage_nightmodelsync", + "value": "The night mode switch controls the interface style of Page1 and Page2" + }, + { + "name": "ability_storage_fontsizesync", + "value": "Font size control page1, page2 interface font size one-way synchronization" + }, + { + "name": "localStorage_both_data_binding", + "value": "The component establishes two-way binding with LocalStorage through the state variable decorated by @LocalStorageLink(key)" + }, + { + "name": "localStorage_single_data_binding", + "value": "The component establishes a one-way data binding with LocalStorage by using the state variable decorated with @LocalStorageProp(key)" + }, + { + "name": "localStorage_nigntmode_both_binding", + "value": "The night mode in this interface is bidirectional synchronization of @LocalStorageLink (key) variable, and the night mode switch will be synchronized in other capabilities" + }, + { + "name": "localStorage_single_fontsize_binding", + "value": "The font size in this interface is the @StorageProp(key) variable one-way synchronization, which only changes the font size of the current interface" + }, + { + "name": "localStorage_pagetitleone", + "value": "Page1" + }, + { + "name": "localStorage_pagetitletwo", + "value": "Page2" + }, + { + "name": "localStorage_abilitytitle", + "value": "Ability" + }, + { + "name": "enter_ability_outofsync_text", + "value": "The data is not synchronized across capabilities, so the switch of night mode and home page in this interface is not synchronized" + }, + { + "name": "base_type_tip_text", + "value": "The circle color is a @State state variable" + }, + { + "name": "source_code", + "value": "View the source code" + }, + { + "name": "set_to_blue", + "value": "Set to blue" + }, + { + "name": "set_to_pink", + "value": "Set to pink" + }, + { + "name": "storagepropability_desc", + "value": "description" + }, + { + "name": "storagepropability_label", + "value": "label" + }, + { + "name": "storagelinkability_desc", + "value": "description" + }, + { + "name": "storagelinkability_label", + "value": "label" + }, + { + "name": "outofsyncability_desc", + "value": "description" + }, + { + "name": "outofsyncability_label", + "value": "label" + } + ] +} \ No newline at end of file diff --git a/sample/EnhanceSampleArk1.2/StateManagement/entry/src/main/resources/base/media/app_level.svg b/sample/EnhanceSampleArk1.2/StateManagement/entry/src/main/resources/base/media/app_level.svg new file mode 100644 index 0000000000000000000000000000000000000000..13bf19e4a9a9bcba29d554b3ac6769f4c194082a --- /dev/null +++ b/sample/EnhanceSampleArk1.2/StateManagement/entry/src/main/resources/base/media/app_level.svg @@ -0,0 +1,34 @@ + + + + + + + + + + + diff --git a/sample/EnhanceSampleArk1.2/StateManagement/entry/src/main/resources/base/media/app_level_selected.svg b/sample/EnhanceSampleArk1.2/StateManagement/entry/src/main/resources/base/media/app_level_selected.svg new file mode 100644 index 0000000000000000000000000000000000000000..ffc1ffbdf96ce8075feac73f882b108214d1d8bb --- /dev/null +++ b/sample/EnhanceSampleArk1.2/StateManagement/entry/src/main/resources/base/media/app_level_selected.svg @@ -0,0 +1,34 @@ + + + + + + + + + + + diff --git a/sample/EnhanceSampleArk1.2/StateManagement/entry/src/main/resources/base/media/ic_back.svg b/sample/EnhanceSampleArk1.2/StateManagement/entry/src/main/resources/base/media/ic_back.svg new file mode 100644 index 0000000000000000000000000000000000000000..1c9142bf5f366fc0b830ec543bc9697e2ccf1eb9 --- /dev/null +++ b/sample/EnhanceSampleArk1.2/StateManagement/entry/src/main/resources/base/media/ic_back.svg @@ -0,0 +1,13 @@ + + + Public/ic_public_back + + + + + + + + + + \ No newline at end of file diff --git a/sample/EnhanceSampleArk1.2/StateManagement/entry/src/main/resources/base/media/ic_back_white.svg b/sample/EnhanceSampleArk1.2/StateManagement/entry/src/main/resources/base/media/ic_back_white.svg new file mode 100644 index 0000000000000000000000000000000000000000..5c9cb3f7169942d1ef5e027a8ddd3b13528319ed --- /dev/null +++ b/sample/EnhanceSampleArk1.2/StateManagement/entry/src/main/resources/base/media/ic_back_white.svg @@ -0,0 +1,13 @@ + + + Public/ic_public_back + + + + + + + + + + \ No newline at end of file diff --git a/sample/EnhanceSampleArk1.2/StateManagement/entry/src/main/resources/base/media/ic_down_arrow.png b/sample/EnhanceSampleArk1.2/StateManagement/entry/src/main/resources/base/media/ic_down_arrow.png new file mode 100644 index 0000000000000000000000000000000000000000..351af3d6742d880a5fe8a06d57bff53a6624c85b Binary files /dev/null and b/sample/EnhanceSampleArk1.2/StateManagement/entry/src/main/resources/base/media/ic_down_arrow.png differ diff --git a/sample/EnhanceSampleArk1.2/StateManagement/entry/src/main/resources/base/media/ic_right_arrow.png b/sample/EnhanceSampleArk1.2/StateManagement/entry/src/main/resources/base/media/ic_right_arrow.png new file mode 100644 index 0000000000000000000000000000000000000000..d5dc67eec85664a24889404b40174e62278f3c74 Binary files /dev/null and b/sample/EnhanceSampleArk1.2/StateManagement/entry/src/main/resources/base/media/ic_right_arrow.png differ diff --git a/sample/EnhanceSampleArk1.2/StateManagement/entry/src/main/resources/base/media/icon.png b/sample/EnhanceSampleArk1.2/StateManagement/entry/src/main/resources/base/media/icon.png new file mode 100644 index 0000000000000000000000000000000000000000..ce307a8827bd75456441ceb57d530e4c8d45d36c Binary files /dev/null and b/sample/EnhanceSampleArk1.2/StateManagement/entry/src/main/resources/base/media/icon.png differ diff --git a/sample/EnhanceSampleArk1.2/StateManagement/entry/src/main/resources/base/media/page_level.svg b/sample/EnhanceSampleArk1.2/StateManagement/entry/src/main/resources/base/media/page_level.svg new file mode 100644 index 0000000000000000000000000000000000000000..8d62913ab20d6d460c3d4621fb3dc40fe8a2cb12 --- /dev/null +++ b/sample/EnhanceSampleArk1.2/StateManagement/entry/src/main/resources/base/media/page_level.svg @@ -0,0 +1,22 @@ + + + + + + diff --git a/sample/EnhanceSampleArk1.2/StateManagement/entry/src/main/resources/base/media/page_level_selected.svg b/sample/EnhanceSampleArk1.2/StateManagement/entry/src/main/resources/base/media/page_level_selected.svg new file mode 100644 index 0000000000000000000000000000000000000000..90b2f8ca11cff415830cfb3a4fab0229d63556ac --- /dev/null +++ b/sample/EnhanceSampleArk1.2/StateManagement/entry/src/main/resources/base/media/page_level_selected.svg @@ -0,0 +1,22 @@ + + + + + + diff --git a/sample/EnhanceSampleArk1.2/StateManagement/entry/src/main/resources/base/profile/main_pages.json b/sample/EnhanceSampleArk1.2/StateManagement/entry/src/main/resources/base/profile/main_pages.json new file mode 100644 index 0000000000000000000000000000000000000000..402c197f274e4c688e42efca5bf9dd21a5e98484 --- /dev/null +++ b/sample/EnhanceSampleArk1.2/StateManagement/entry/src/main/resources/base/profile/main_pages.json @@ -0,0 +1,20 @@ +{ + "src": [ + "pages/home/Home", + "pages/pagelevelstagemanagement/singlecomponentstatevariables/decoratedobjecttype/basetype/BaseType", + "pages/pagelevelstagemanagement/singlecomponentstatevariables/decoratedobjecttype/arraytype/ArrayType", + "pages/pagelevelstagemanagement/singlecomponentstatevariables/decoratedobjecttype/classobjecttype/ClassObjectType", + "pages/pagelevelstagemanagement/singlecomponentstatevariables/updatetactics/updateboundcomponent/UpdateBoundComponent", + "pages/pagelevelstagemanagement/multicompomentssync/parentchildcomponentsync/uniandbidirectionsync/UniAndBidirectionSync", + "pages/pagelevelstagemanagement/multicompomentssync/parentchildcomponentsync/parentchildpartialcontentsync/ParentChildPartialContentSync", + "pages/pagelevelstagemanagement/multicompomentssync/brothercomponentssync/BrotherComponentSync", + "pages/pagelevelstagemanagement/multicompomentssync/deepnestcomponentssync/DeepNestComponentsSync", + "pages/applylevelstagemanagement/applyglobaldatasync/ApplyGlobalDataSync", + "pages/applylevelstagemanagement/applyglobaldatasync/StorageLinkAbilityPage", + "pages/applylevelstagemanagement/applyglobaldatasync/StoragePropAbilityPage", + "pages/applylevelstagemanagement/abilityglobaldatasync/AbilityGlobalDataSync", + "pages/applylevelstagemanagement/abilityglobaldatasync/LocalStorageLinkPage", + "pages/applylevelstagemanagement/abilityglobaldatasync/LocalStoragePropPage", + "pages/applylevelstagemanagement/abilityglobaldatasync/AbilityOutOfSyncPage" + ] +} \ No newline at end of file diff --git a/sample/EnhanceSampleArk1.2/StateManagement/entry/src/main/resources/en_US/element/string.json b/sample/EnhanceSampleArk1.2/StateManagement/entry/src/main/resources/en_US/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..676e6fcce84a862035b75db2b4d7a609e98c8b9c --- /dev/null +++ b/sample/EnhanceSampleArk1.2/StateManagement/entry/src/main/resources/en_US/element/string.json @@ -0,0 +1,432 @@ +{ + "string": [ + { + "name": "module_desc", + "value": "StateManagement entry model" + }, + { + "name": "EntryAbility_desc", + "value": "StateManagement entry ability" + }, + { + "name": "EntryAbility_label", + "value": "StateManagement" + }, + { + "name": "close", + "value": "Close" + }, + { + "name": "page_level", + "value": "PageLevelStageManagement" + }, + { + "name": "app_level", + "value": "AppLevelStageManagement" + }, + { + "name": "single_component_state", + "value": "State variables in single component" + }, + { + "name": "decorated_object_type", + "value": "The decorated object type" + }, + { + "name": "base_type", + "value": "Based type" + }, + { + "name": "array_type", + "value": "Array type" + }, + { + "name": "array_type_add", + "value": "add elements" + }, + { + "name": "array_type_delete", + "value": "delete elements" + }, + { + "name": "array_type_update", + "value": "Update a single element in an array" + }, + { + "name": "array_type_deletetoast", + "value": "The list is empty and cannot be deleted!" + }, + { + "name": "array_type_updatetoast", + "value": "The list is empty and cannot be update!" + }, + { + "name": "class_type", + "value": "Class Object type" + }, + { + "name": "class_type_objectName", + "value": "Chasing the starry sun" + }, + { + "name": "class_object", + "value": "Object" + }, + { + "name": "class_attribute", + "value": "Object Attribute" + }, + { + "name": "class_child_attribute", + "value": "Attribute of attribute" + }, + { + "name": "class_type_update_object", + "value": "Update object:" + }, + { + "name": "class_type_update_attribute", + "value": "Update object attribute" + }, + { + "name": "class_type_update_child_attribute", + "value": "Update attribute of attribute" + }, + { + "name": "update_principle", + "value": "Update principle" + }, + { + "name": "only_update_bound_components", + "value": "Only the components to which you are bound are updated" + }, + { + "name": "only_update_state", + "value": "@State declare variables" + }, + { + "name": "only_update_title", + "value": "title:" + }, + { + "name": "only_update_private", + "value": "Private declare variables" + }, + { + "name": "only_update_content", + "value": "content:" + }, + { + "name": "update_title_content", + "value": "Click to modify the title and content" + }, + { + "name": "only_update_state_components", + "value": "Only update components declared by @State" + }, + { + "name": "update_the_custom_component", + "value": "Where the custom component is updated" + }, + { + "name": "multi_component_sync", + "value": "Status synchronization between components" + }, + { + "name": "parent_child_sync", + "value": "State synchronization between parent and child components" + }, + { + "name": "single_and_two_way_sync", + "value": "Single and two-way synchronization" + }, + { + "name": "parent_component", + "value": "Parent component" + }, + { + "name": "child_component", + "value": "Child component" + }, + { + "name": "uni_and_bidirection_sync_tips", + "value": "The prototype color in the parent component is @ state state state variable" + }, + { + "name": "single_direction_sync_tips", + "value": "The prototype color in the one-way synchronization sub-component is @Prop state variable" + }, + { + "name": "both_direction_sync_tips", + "value": "The prototype color in the bidirectional synchronization sub-component is @Link state variable" + }, + { + "name": "uni_and_bidirection_sync_btn", + "value": "Set to pink, components are updated synchronously" + }, + { + "name": "single_direction_sync_btn", + "value": "Set to blue, parent component is out of sync" + }, + { + "name": "both_direction_sync_btn", + "value": "Set to red, attachment synchronization" + }, + { + "name": "partial_sync", + "value": "The child component synchronizes parts of the parent component" + }, + { + "name": "partial_sync_element_one", + "value": "Elment one" + }, + { + "name": "partial_sync_element_two", + "value": "Elment two" + }, + { + "name": "partial_sync_element_three", + "value": "Elment three" + }, + { + "name": "partial_sync_attribute_one", + "value": "Attribute one" + }, + { + "name": "partial_sync_attribute_two", + "value": "Attribute two" + }, + { + "name": "partial_sync_attribute_three", + "value": "Attribute three" + }, + { + "name": "partial_sync_parent_tips", + "value": "The array in the parent component is a @State state variable, and the classes of the elements of the array are decorated with @observed" + }, + { + "name": "partial_sync_text", + "value": "Use @ObjectLink to modify variables in child components to synchronize data with elements of objects in parent components" + }, + { + "name": "parent_descendent_sync", + "value": "State synchronization between parent and descendent" + }, + { + "name": "select_colorblue", + "value": "Blue" + }, + { + "name": "select_colorpink", + "value": "Pink" + }, + { + "name": "realize_by_state_link", + "value": "Use @State, @Link to realize:" + }, + { + "name": "realize_by_provide_consume", + "value": "Use @Provide, @Consume to realize:" + }, + { + "name": "deepnest_parent_titleone", + "value": "The circular color in the parent component as @State state variable" + }, + { + "name": "deepnest_child_titleone", + "value": "The circular color of the sub-component is @Link, and the state variable is passed to the sub-component" + }, + { + "name": "deepnest_descendent_titleone", + "value": "The circle color in the sub-component is @Link status variable" + }, + { + "name": "deepnest_parent_titletwo", + "value": "The state variable with the circular color of @Provide in the parent component as the data provider" + }, + { + "name": "deepnest_child_titletwo", + "value": "Variables do not need to be set in subcomponents" + }, + { + "name": "deepnest_descendent_titletwo", + "value": "The round color in the sub-component is @Consume variable to sense data changes, update the UI, or reverse synchronization" + }, + { + "name": "brother_sync", + "value": "State synchronization between brother components" + }, + { + "name": "parent_titleone", + "value": "The common parent component circle color is @State variable" + }, + { + "name": "link_brothers_title", + "value": "The brother component circle color is @Link state variable" + }, + { + "name": "parent_titletwo", + "value": "The common parent component circle color is @Provide variable" + }, + { + "name": "consume_brothers_title", + "value": "The brother component circle color is @Consume state variable" + }, + { + "name": "application_storage_ui", + "value": "State synchronization between the app storage and the UI" + }, + { + "name": "nightmode", + "value": "Night mode" + }, + { + "name": "close_nightmode", + "value": "Close night mode" + }, + { + "name": "start_nightmode", + "value": "Start night mode" + }, + { + "name": "nightmode_text", + "value": "Night mode control Ability1, Ability2 interface style" + }, + { + "name": "fontSize_text", + "value": "FontSize" + }, + { + "name": "fontSize_singlesync_textone", + "value": "FontSize one-way synchronization" + }, + { + "name": "enter_abilityone", + "value": "Enter ability1" + }, + { + "name": "enter_abilitytwo", + "value": "Enter ability2" + }, + { + "name": "abilityone_page", + "value": "Ability1" + }, + { + "name": "abilitytwo_page", + "value": "Ability2" + }, + { + "name": "both_data_binding", + "value": "The component establishes two-way binding with AppStorage through the state variable decorated by @StorageLink(key)" + }, + { + "name": "single_data_binding", + "value": "The component establishes a one-way data binding with AppStorage by using the state variable decorated with @StorageProp(key)" + }, + { + "name": "nigntmode_both_binding", + "value": "The night mode in this interface is bidirectional synchronization of @StorageLink(key) variable, and the night mode switch will be synchronized in other capabilities" + }, + { + "name": "single_fontsize_binding", + "value": "The font size in this interface is the @StorageProp(key) variable one-way synchronization, which only changes the font size of the current interface" + }, + { + "name": "ability_storage_ui", + "value": "State synchronization between the ability storage and the UI" + }, + { + "name": "enter_pageone", + "value": "Enter Page1" + }, + { + "name": "enter_ability_outofsync", + "value": "Cross Ability out of sync" + }, + { + "name": "enter_pagetwo", + "value": "Enter Page2" + }, + { + "name": "ability_storage_nightmodelsync", + "value": "The night mode switch controls the interface style of Page1 and Page2" + }, + { + "name": "ability_storage_fontsizesync", + "value": "Font size control page1, page2 interface font size one-way synchronization" + }, + { + "name": "localStorage_both_data_binding", + "value": "The component establishes two-way binding with LocalStorage through the state variable decorated by @LocalStorageLink(key)" + }, + { + "name": "localStorage_single_data_binding", + "value": "The component establishes a one-way data binding with LocalStorage by using the state variable decorated with @LocalStorageProp(key)" + }, + { + "name": "localStorage_nigntmode_both_binding", + "value": "The night mode in this interface is bidirectional synchronization of @LocalStorageLink (key) variable, and the night mode switch will be synchronized in other capabilities" + }, + { + "name": "localStorage_single_fontsize_binding", + "value": "The font size in this interface is the @StorageProp(key) variable one-way synchronization, which only changes the font size of the current interface" + }, + { + "name": "enter_ability_outofsync_text", + "value": "The data is not synchronized across capabilities, so the switch of night mode and home page in this interface is not synchronized" + }, + { + "name": "localStorage_pagetitleone", + "value": "Page1" + }, + { + "name": "localStorage_pagetitletwo", + "value": "Page2" + }, + { + "name": "localStorage_abilitytitle", + "value": "Ability" + }, + { + "name": "base_type_tip_text", + "value": "The circle color is a @State state variable" + }, + { + "name": "source_code", + "value": "View the source code" + }, + { + "name": "set_to_blue", + "value": "Set to blue" + }, + { + "name": "set_to_pink", + "value": "Set to pink" + }, + { + "name": "storagepropability_desc", + "value": "description" + }, + { + "name": "storagepropability_label", + "value": "label" + }, + { + "name": "storagelinkability_desc", + "value": "description" + }, + { + "name": "storagelinkability_label", + "value": "label" + }, + { + "name": "outofsyncability_desc", + "value": "description" + }, + { + "name": "outofsyncability_label", + "value": "label" + } + ] +} \ No newline at end of file diff --git a/sample/EnhanceSampleArk1.2/StateManagement/entry/src/main/resources/rawfile/AbilityGlobalDataSyncCode.ets.html b/sample/EnhanceSampleArk1.2/StateManagement/entry/src/main/resources/rawfile/AbilityGlobalDataSyncCode.ets.html new file mode 100644 index 0000000000000000000000000000000000000000..1ae652a910d3fade1d18cb0012e149a1a41f2e6e --- /dev/null +++ b/sample/EnhanceSampleArk1.2/StateManagement/entry/src/main/resources/rawfile/AbilityGlobalDataSyncCode.ets.html @@ -0,0 +1,157 @@ + + +AbilityGlobalDataSyncCode.ets + + + + + +
+ +AbilityGlobalDataSyncCode.ets +
+
/* 
+ * Copyright (c) 2023 Huawei Device 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 router from '@ohos.router';
+import { ViewCodeText } from '../../../commoncomponents/ViewCodeText';
+import { startSpecifiedAbility } from '../model/CommonMethods';
+
+@Component
+export struct AbilityGlobalDataSyncCode {
+  // 初始化Slider最小值
+  private minFontSize: number = 10;
+  // 和主页、Page1、Page2双向同步内容字体大小
+  @LocalStorageLink('contentFontSize') contentFontSize: number = 18;
+  // 和主页、Page1、Page2双向同步夜间模式状态
+  @LocalStorageLink('currentModelStatus') currentModelStatus: boolean = true;
+
+  build() {
+    Column({ space: 10 }) {
+      // 查看源码
+      ViewCodeText({ webSrc: $rawfile('AbilityGlobalDataSyncCode.ets.html') })
+      Row() {
+        Text($r('app.string.nightmode'))
+          .fontSize(this.contentFontSize)
+          .fontColor(this.currentModelStatus ? $r('app.color.color_white') : $r('app.color.tips_font_color'))
+        // 控制夜间模式
+        Toggle({ type: ToggleType.Switch, isOn: this.currentModelStatus })
+          .selectedColor(Color.Blue)
+          .switchPointColor(Color.White)
+          .onChange((isOn: boolean) => {
+            // 更新控制夜间模式状态的变量数据,@StorageLink和@StorageLink关联的数据变量刷新
+            this.currentModelStatus = isOn;
+          })
+      }.justifyContent(FlexAlign.SpaceAround)
+      .width('70%')
+      .border({ radius: 50, color: Color.Grey, width: $r('app.float.border_width') })
+
+      Text($r('app.string.ability_storage_nightmodelsync'))
+        .fontSize(this.contentFontSize)
+        .fontColor(this.currentModelStatus ? $r('app.color.color_white') : $r('app.color.tips_font_color'))
+        .textAlign(TextAlign.Center)
+      // slider滑动模块控制字体大小
+      Column() {
+        Text($r('app.string.fontSize_text'))
+          .fontSize(this.contentFontSize)
+          .fontColor(this.currentModelStatus ? $r('app.color.color_white') : $r('app.color.tips_font_color'))
+          .width('100%')
+          .textAlign(TextAlign.Center)
+        Row() {
+          Text(`${this.minFontSize}`)
+            .fontColor(this.currentModelStatus ? $r('app.color.color_white') : $r('app.color.tips_font_color'))
+            .fontSize($r('app.float.tips_font_size'))
+          Slider({
+            value: this.contentFontSize,
+            min: 10, // slider最小值
+            max: 30, // slider最大值
+            style: SliderStyle.OutSet
+          })
+            .showTips(true)
+            .onChange((value: number, mode: SliderChangeMode) => {
+              // 更新控制字体大小状态的变量数据,@LocalStorageLink和@LocalStorageProp关联的数据变量刷新
+              this.contentFontSize = value;
+            })
+          // toFixed(0)将滑动条返回值处理为整数精度
+          Text(this.contentFontSize.toFixed(0))
+            .fontColor(this.currentModelStatus ? $r('app.color.color_white') : $r('app.color.tips_font_color'))
+            .fontSize($r('app.float.tips_font_size'))
+        }
+        .width('80%')
+      }.margin({ top: 50 })
+
+      Text($r('app.string.ability_storage_fontsizesync'))
+        .fontSize(this.contentFontSize)
+        .fontColor(this.currentModelStatus ? $r('app.color.color_white') : $r('app.color.tips_font_color'))
+        .width('100%')
+        .textAlign(TextAlign.Center)
+      Button() {
+        Text($r('app.string.enter_pageone'))
+          .fontColor(this.currentModelStatus ? $r('app.color.color_white') : $r('app.color.button_text_color'))
+          .fontSize(this.contentFontSize)
+          .width('60%')
+          .textAlign(TextAlign.Center)
+      }
+      .type(ButtonType.Capsule)
+      .backgroundColor($r('app.color.button_background_color'))
+      .padding($r('app.float.page_padding'))
+      .onClick(() => {
+        router.pushUrl({ url: 'pages/applylevelstagemanagement/abilityglobaldatasync/LocalStoragePropPage' });
+      })
+
+      Button() {
+        Text($r('app.string.enter_pagetwo'))
+          .fontColor(this.currentModelStatus ? $r('app.color.color_white') : $r('app.color.button_text_color'))
+          .fontSize(this.contentFontSize)
+          .width('60%')
+          .textAlign(TextAlign.Center)
+      }
+      .type(ButtonType.Capsule)
+      .backgroundColor($r('app.color.button_background_color'))
+      .padding($r('app.float.page_padding'))
+      .onClick(() => {
+        router.pushUrl({ url: 'pages/applylevelstagemanagement/abilityglobaldatasync/LocalStorageLinkPage' });
+      })
+
+      Divider().width('100%').strokeWidth(1)
+      Button() {
+        Text($r('app.string.enter_ability_outofsync'))
+          .fontColor(this.currentModelStatus ? $r('app.color.color_white') : $r('app.color.button_text_color'))
+          .fontSize(this.contentFontSize)
+          .width('60%')
+          .textAlign(TextAlign.Center)
+      }
+      .type(ButtonType.Capsule)
+      .backgroundColor($r('app.color.button_background_color'))
+      .padding($r('app.float.page_padding'))
+      .onClick(() => {
+        startSpecifiedAbility('OutOfSyncAbility');
+      })
+    }
+    .width('100%')
+    .padding(10)
+  }
+}
+ + \ No newline at end of file diff --git a/sample/EnhanceSampleArk1.2/StateManagement/entry/src/main/resources/rawfile/AbilityOutOfSyncPage.ets.html b/sample/EnhanceSampleArk1.2/StateManagement/entry/src/main/resources/rawfile/AbilityOutOfSyncPage.ets.html new file mode 100644 index 0000000000000000000000000000000000000000..518834f7176e26c4db3407cb75fd8f3be13f47c9 --- /dev/null +++ b/sample/EnhanceSampleArk1.2/StateManagement/entry/src/main/resources/rawfile/AbilityOutOfSyncPage.ets.html @@ -0,0 +1,110 @@ + + +AbilityOutOfSyncPage.ets + + + + + +
+ +AbilityOutOfSyncPage.ets +
+
/* 
+ * Copyright (c) 2023 Huawei Device 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 { CodeView } from '../../../commoncomponents/CodeView';
+import { ViewCodeText } from '../../../commoncomponents/ViewCodeText';
+import { TitleBarDark } from '../../../commoncomponents/TitleBarDark';
+import { TitleBar } from '../../../commoncomponents/TitleBar';
+
+let storage: LocalStorage = LocalStorage.GetShared();
+
+@Entry(storage)
+@Component
+struct AbilityOutOfSyncPage {
+  // 判断是否关联ability的变量
+  @State isAbility: boolean = true;
+  @State title: Resource = $r('app.string.localStorage_abilitytitle');
+  // 和主页、Page1、Page2不同步夜间模式状态
+  @LocalStorageLink('currentModelStatus') currentModelStatus: boolean = true;
+  // 和主页、Page1、Page2不同步内容字体大小
+  @LocalStorageLink('contentFontSize') contentFontSize: number = 18;
+
+  build() {
+    Column() {
+      if (this.currentModelStatus) {
+        TitleBarDark({ title: $title, isAbility: true })
+      } else {
+        TitleBar({ title: $title, isAbility: true })
+      }
+      CodeView({ title: $title, isShowTitle: false }) {
+        Column({ space: 30 }) {
+          // 查看源码
+          ViewCodeText({ webSrc: $rawfile('AbilityOutOfSyncPage.ets.html') })
+          Text($r('app.string.localStorage_both_data_binding'))
+            .fontSize(this.contentFontSize)
+            .fontColor(this.currentModelStatus ? $r('app.color.color_white') : $r('app.color.tips_font_color'))
+            .width('100%')
+            .textAlign(TextAlign.Center)
+          Text($r('app.string.localStorage_single_data_binding'))
+            .fontSize(this.contentFontSize)
+            .fontColor(this.currentModelStatus ? $r('app.color.color_white') : $r('app.color.tips_font_color'))
+            .width('100%')
+            .textAlign(TextAlign.Center)
+          Text($r('app.string.enter_ability_outofsync_text'))
+            .fontSize(this.contentFontSize)
+            .fontColor(this.currentModelStatus ? $r('app.color.color_white') : $r('app.color.tips_font_color'))
+            .width('100%')
+            .textAlign(TextAlign.Center)
+          Button() {
+            Text(this.currentModelStatus ? $r('app.string.close_nightmode') : $r('app.string.start_nightmode'))
+              .fontColor(this.currentModelStatus ? $r('app.color.color_white') : $r('app.color.button_text_color'))
+              .fontSize(this.contentFontSize)
+              .width('60%')
+              .textAlign(TextAlign.Center)
+          }
+          .type(ButtonType.Capsule)
+          .backgroundColor($r('app.color.button_background_color'))
+          .padding($r('app.float.page_padding'))
+          .onClick(() => {
+            // 更新控制夜间模式状态的变量数据,@LocalStorageLink和@LocalStorageProp关联的数据变量刷新
+            this.currentModelStatus = !this.currentModelStatus;
+          })
+        }
+        .height('100%')
+        .padding($r('app.float.page_padding'))
+      }
+    }
+    .width('100%')
+    .height('100%')
+    .backgroundColor(this.currentModelStatus ? $r('app.color.nightnode_color') : $r('app.color.background_shallow_grey'))
+  }
+
+  aboutToDisappear() {
+    AppStorage.SetOrCreate('sideBarShow', false);
+  }
+}
+ + \ No newline at end of file diff --git a/sample/EnhanceSampleArk1.2/StateManagement/entry/src/main/resources/rawfile/ApplyGlobalDataSyncCode.ets.html b/sample/EnhanceSampleArk1.2/StateManagement/entry/src/main/resources/rawfile/ApplyGlobalDataSyncCode.ets.html new file mode 100644 index 0000000000000000000000000000000000000000..18f1221b23959959bf91a35a84e63fd3952fd114 --- /dev/null +++ b/sample/EnhanceSampleArk1.2/StateManagement/entry/src/main/resources/rawfile/ApplyGlobalDataSyncCode.ets.html @@ -0,0 +1,142 @@ + + +ApplyGlobalDataSyncCode.ets + + + + + +
+ +ApplyGlobalDataSyncCode.ets +
+
/* 
+ * Copyright (c) 2023 Huawei Device 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 { ViewCodeText } from '../../../commoncomponents/ViewCodeText';
+import { startSpecifiedAbility } from '../model/CommonMethods';
+
+@Component
+export default struct ApplyGlobalDataSyncCode {
+  // 和Ability1、Ability2页面双向同步内容字体大小
+  @StorageLink('contentFontSize') contentFontSize: number = 18;
+  // 和Ability1、Ability2页面双向同步夜间模式状态
+  @StorageLink('currentModelStatus') currentModelStatus: boolean = true;
+  // 初始化Slider组件最小值
+  private minFontSize: number = 10;
+
+  build() {
+    Column({ space: 10 }) {
+      // 查看源码
+      ViewCodeText({ webSrc: $rawfile('ApplyGlobalDataSyncCode.ets.html') })
+      Row() {
+        Text($r('app.string.nightmode'))
+          .fontSize(this.contentFontSize)
+          .fontColor(this.currentModelStatus ? $r('app.color.color_white') : $r('app.color.tips_font_color'))
+        // 开发控制夜间模式
+        Toggle({ type: ToggleType.Switch, isOn: this.currentModelStatus })
+          .selectedColor(Color.Blue)
+          .switchPointColor(Color.White)
+          .onChange((isOn: boolean) => {
+            // 更新控制夜间模式状态的变量数据,@StorageLink和@StorageLink关联的数据变量刷新
+            this.currentModelStatus = isOn;
+            AppStorage.SetOrCreate<boolean>('currentModelStatus', this.currentModelStatus);
+          })
+      }.justifyContent(FlexAlign.SpaceAround)
+      .width('70%')
+      .border({ radius: 50, color: Color.Grey, width: $r('app.float.border_width') })
+
+      Text($r('app.string.nightmode_text'))
+        .fontSize(this.contentFontSize)
+        .fontColor(this.currentModelStatus ? $r('app.color.color_white') : $r('app.color.tips_font_color'))
+        .textAlign(TextAlign.Center)
+      // slider滑动模块控制字体大小
+      Column() {
+        Text($r('app.string.fontSize_text'))
+          .fontSize(this.contentFontSize)
+          .fontColor(this.currentModelStatus ? $r('app.color.color_white') : $r('app.color.tips_font_color'))
+          .width('100%')
+          .textAlign(TextAlign.Center)
+        Row() {
+          Text(`${this.minFontSize}`)
+            .fontColor(this.currentModelStatus ? $r('app.color.color_white') : $r('app.color.tips_font_color'))
+            .fontSize($r('app.float.tips_font_size'))
+          Slider({
+            value: this.contentFontSize,
+            min: this.minFontSize, // slider最小值
+            max: 30, // slider最大值
+            style: SliderStyle.OutSet
+          })
+            .showTips(true)
+            .onChange((value: number, mode: SliderChangeMode) => {
+              // 更新控制字体大小状态的变量数据,@StorageLink和@StorageProp关联的数据变量刷新
+              this.contentFontSize = value;
+              AppStorage.SetOrCreate<number>('contentFontSize', this.contentFontSize);
+            })
+          // toFixed(0)将滑动条返回值处理为整数精度
+          Text(this.contentFontSize.toFixed(0))
+            .fontColor(this.currentModelStatus ? $r('app.color.color_white') : $r('app.color.tips_font_color'))
+            .fontSize($r('app.float.tips_font_size'))
+        }
+        .width('80%')
+      }.margin({ top: 50 })
+
+      Text($r('app.string.fontSize_singlesync_textone'))
+        .fontSize(this.contentFontSize)
+        .fontColor(this.currentModelStatus ? $r('app.color.color_white') : $r('app.color.tips_font_color'))
+        .width('100%')
+        .textAlign(TextAlign.Center)
+      Button() {
+        Text($r('app.string.enter_abilityone'))
+          .fontColor(this.currentModelStatus ? $r('app.color.color_white') : $r('app.color.button_text_color'))
+          .fontSize(this.contentFontSize)
+          .width('60%')
+          .textAlign(TextAlign.Center)
+      }
+      .type(ButtonType.Capsule)
+      .backgroundColor($r('app.color.button_background_color'))
+      .padding($r('app.float.page_padding'))
+      .onClick(() => {
+        startSpecifiedAbility('StoragePropAbility');
+      })
+
+      Button() {
+        Text($r('app.string.enter_abilitytwo'))
+          .fontColor(this.currentModelStatus ? $r('app.color.color_white') : $r('app.color.button_text_color'))
+          .fontSize(this.contentFontSize)
+          .width('60%')
+          .textAlign(TextAlign.Center)
+      }
+      .type(ButtonType.Capsule)
+      .backgroundColor($r('app.color.button_background_color'))
+      .padding($r('app.float.page_padding'))
+      .onClick(() => {
+        startSpecifiedAbility('StorageLinkAbility');
+      })
+    }.padding($r('app.float.page_padding'))
+  }
+}
+ + \ No newline at end of file diff --git a/sample/EnhanceSampleArk1.2/StateManagement/entry/src/main/resources/rawfile/ArrayTypeCode.ets.html b/sample/EnhanceSampleArk1.2/StateManagement/entry/src/main/resources/rawfile/ArrayTypeCode.ets.html new file mode 100644 index 0000000000000000000000000000000000000000..46b4f566d59edc4820a33c2d99f3a34ed06280b1 --- /dev/null +++ b/sample/EnhanceSampleArk1.2/StateManagement/entry/src/main/resources/rawfile/ArrayTypeCode.ets.html @@ -0,0 +1,157 @@ + + +ArrayTypeCode.ets + + + + + +
+ +ArrayTypeCode.ets +
+
/* 
+ * Copyright (c) 2023 Huawei Device 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 promptAction from '@ohos.promptAction';
+import { ViewCodeText } from '../../../../../commoncomponents/ViewCodeText'
+
+// 数组中元素的类
+export class ArrayDataType {
+  public id: number;
+  public name: string;
+  public age: number;
+
+  constructor(id: number, name: string, age: number) {
+    this.id = id;
+    this.name = name;
+    this.age = age;
+  }
+}
+
+// 初始化数组数据
+const ARRAY_TYPE_AGE_DATA: ArrayDataType[] = [new ArrayDataType(0, 'name', 17), new ArrayDataType(1, 'name', 18), new ArrayDataType(2, 'name', 19)]
+// 初始化功能按钮字符串数据
+const ARRAY_TYPE_BTN: Resource[] = [$r("app.string.array_type_add"), $r("app.string.array_type_delete"), $r("app.string.array_type_update")];
+
+@Component
+export struct ArrayTypeCode {
+  // 数组类型状态变量初始化
+  @State arrayTypeData: ArrayDataType[] = ARRAY_TYPE_AGE_DATA;
+
+  build() {
+    Column({ space: 10 }) {
+      // 点击查看源码
+      ViewCodeText({ webSrc: $rawfile('ArrayType.ets.html') })
+      // 数组内容展示
+      List() {
+        ForEach(this.arrayTypeData, (item: ArrayDataType, index: number) => {
+          ListItem() {
+            ArrayDataItem({ arrayDataItem: item, itemIndex: index })
+          }
+        }, item => JSON.stringify(item))
+      }
+      .width('100%')
+      .height('40%')
+      .backgroundColor($r('app.color.component_background_pink'))
+      .padding({ left: 10, right: 10 })
+      // 功能按钮区
+      ForEach(ARRAY_TYPE_BTN, (item:Resource, index:number) => {
+        Button(item)
+          .id(`arrayTypeBtn${index}`)
+          .width('100%')
+          .height($r('app.float.button_height'))
+          .fontColor($r('app.color.button_text_color'))
+          .fontSize($r('app.float.button_text_size'))
+          .type(ButtonType.Capsule)
+          .backgroundColor($r('app.color.button_background_color'))
+          .onClick(() => {
+            this.handleButtonClick(index)
+          })
+      }, item => JSON.stringify(item))
+    }
+    .padding(10)
+    .border({ radius: $r('app.float.component_radius'), color: Color.Grey, width: $r('app.float.border_width') })
+  }
+
+  handleButtonClick(index: number){
+    switch (index) {
+      case 0:
+      // 数组添加元素
+        this.arrayTypeData.push(new ArrayDataType(this.arrayTypeData.length, `name`, 18)); // 新增元素数据,age为18
+        break;
+      case 1:
+        if (this.arrayTypeData.length === 0) {
+          // 当数据没有数据的时候,点击删除按钮,出现提示弹窗
+          promptAction.showToast({
+            message: $r('app.string.array_type_deletetoast')
+          });
+        } else {
+          // 数组删除元素
+          this.arrayTypeData.splice(this.arrayTypeData.length - 1, 1); // 删除最后一个元素
+        }
+        break;
+      case 2:
+        if (this.arrayTypeData.length === 0) {
+          // 当数据没有数据的时候,点击更新按钮,出现提示弹窗
+          promptAction.showToast({
+            message: $r('app.string.array_type_updatetoast')
+          });
+          break;
+        }
+      // 初始化一个对象后给数组中的元素赋值,更新数组元素
+        let temp = new ArrayDataType(this.arrayTypeData[0].id, this.arrayTypeData[0].name, this.arrayTypeData[0].age + 1);
+        this.arrayTypeData[0] = temp;
+        break;
+      default:
+        break;
+    }
+  }
+}
+
+// 数组Item内容组件
+@Component
+struct ArrayDataItem {
+  private arrayDataItem: ArrayDataType;
+  private itemIndex: number;
+
+  build() {
+    Column() {
+      Text(`${this.arrayDataItem.name}${this.itemIndex}`)
+        .width('100%')
+        .fontColor($r('app.color.button_text_color'))
+        .fontSize(20)
+      Text(`age:${this.arrayDataItem.age}`)
+        .width('100%')
+        .fontColor($r('app.color.button_text_color'))
+        .fontSize(20)
+      Divider().width('100%')
+        .strokeWidth(1)
+        .margin({ top: 20 })
+    }
+    .margin({ top: 20 })
+  }
+}
+ + \ No newline at end of file diff --git a/sample/EnhanceSampleArk1.2/StateManagement/entry/src/main/resources/rawfile/BaseTypeCode.ets.html b/sample/EnhanceSampleArk1.2/StateManagement/entry/src/main/resources/rawfile/BaseTypeCode.ets.html new file mode 100644 index 0000000000000000000000000000000000000000..923a359077fd32d93ce2672673d64ecb74c0e440 --- /dev/null +++ b/sample/EnhanceSampleArk1.2/StateManagement/entry/src/main/resources/rawfile/BaseTypeCode.ets.html @@ -0,0 +1,81 @@ + + +BaseTypeCode.ets + + + + + +
+ +BaseTypeCode.ets +
+
/* 
+ * Copyright (c) 2023 Huawei Device 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 { ViewCodeText } from '../../../../../commoncomponents/ViewCodeText'
+
+@Component
+export struct BaseTypeCode {
+  @State circleColor: Resource = $r('app.color.circle_pink');
+
+  build() {
+    Column({ space: 10 }) {
+      // 点击查看源码
+      ViewCodeText({webSrc: $rawfile('BaseType.ets.html')})
+
+      Text($r('app.string.base_type_tip_text'))
+        .fontColor($r('app.color.tips_font_color'))
+        .fontSize($r('app.float.tips_font_size'))
+        .width('100%')
+        .textAlign(TextAlign.Center)
+      Circle()
+        .size({ width: $r('app.float.circle_size'), height: $r('app.float.circle_size') })
+        .fill(this.circleColor)
+      Button() {
+        Text(this.circleColor.id === $r('app.color.circle_pink')
+          .id ? $r('app.string.set_to_blue') : $r('app.string.set_to_pink'))
+          .fontColor($r('app.color.button_text_color'))
+          .fontSize($r('app.float.button_text_size'))
+          .width('100%')
+          .textAlign(TextAlign.Center)
+      }
+      .id('circleColorBtn')
+      .height($r('app.float.button_height'))
+      .type(ButtonType.Capsule)
+      .backgroundColor($r('app.color.button_background_color'))
+      .onClick(() => {
+        if (this.circleColor.id === $r('app.color.circle_pink').id) {
+          this.circleColor = $r('app.color.circle_blue');
+        } else {
+          this.circleColor = $r('app.color.circle_pink');
+        }
+      })
+    }
+    .padding(10)
+    .border({ radius: $r('app.float.component_radius'), color: Color.Grey, width: $r('app.float.border_width') })
+  }
+}
+ + \ No newline at end of file diff --git a/sample/EnhanceSampleArk1.2/StateManagement/entry/src/main/resources/rawfile/BrotherComponentSyncCode.ets.html b/sample/EnhanceSampleArk1.2/StateManagement/entry/src/main/resources/rawfile/BrotherComponentSyncCode.ets.html new file mode 100644 index 0000000000000000000000000000000000000000..560c304cea93c2676650d2a546f9e17c65e1c622 --- /dev/null +++ b/sample/EnhanceSampleArk1.2/StateManagement/entry/src/main/resources/rawfile/BrotherComponentSyncCode.ets.html @@ -0,0 +1,67 @@ + + +BrotherComponentSyncCode.ets + + + + + +
+ +BrotherComponentSyncCode.ets +
+
/* 
+ * Copyright (c) 2023 Huawei Device 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 { ProvideFatherComponent } from './ProvideFatherComponent'
+import { StateFatherComponent } from './StateFatherComponent'
+
+@Component
+export struct BrotherComponentSyncCode {
+
+  build() {
+    Column() {
+      Column() {
+        Text($r('app.string.realize_by_state_link'))
+          .fontSize($r('app.float.tips_font_size'))
+          .width('100%')
+          .textAlign(TextAlign.Start)
+        // 共同父组件@State
+        StateFatherComponent()
+      }
+
+      Column() {
+        Text($r('app.string.realize_by_provide_consume'))
+          .fontSize($r('app.float.tips_font_size'))
+          .width('100%')
+          .textAlign(TextAlign.Start)
+        // 共同父组件@Provide
+        ProvideFatherComponent()
+      }
+      .margin({ top: 10 })
+    }
+  }
+}
+ + \ No newline at end of file diff --git a/sample/EnhanceSampleArk1.2/StateManagement/entry/src/main/resources/rawfile/ClassObjectTypeCode.ets.html b/sample/EnhanceSampleArk1.2/StateManagement/entry/src/main/resources/rawfile/ClassObjectTypeCode.ets.html new file mode 100644 index 0000000000000000000000000000000000000000..71509d00e3866557a42e583df42425eac2139510 --- /dev/null +++ b/sample/EnhanceSampleArk1.2/StateManagement/entry/src/main/resources/rawfile/ClassObjectTypeCode.ets.html @@ -0,0 +1,192 @@ + + +ClassObjectTypeCode.ets + + + + + +
+ +ClassObjectTypeCode.ets +
+
/* 
+ * Copyright (c) 2023 Huawei Device 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 { ViewCodeText } from '../../../../../commoncomponents/ViewCodeText';
+import { getResourceString } from '../../../../../utils/ResourceUtils';
+
+let context: common.UIAbilityContext = getContext(this) as common.UIAbilityContext;
+
+@Component
+export struct ClassObjectTypeCode {
+  // 对象类型状态变量初始化
+  @State classObjectData: ParentClass = new ParentClass(getResourceString(context, $r('app.string.class_attribute')), 1,
+    new ChildClass(getResourceString(context, $r('app.string.class_child_attribute')), 2));
+  // 更新对象的次数
+  private clickedCount: number = 0;
+
+  build() {
+    Column({ space: 10 }) {
+      // 点击查看源码
+      ViewCodeText({ webSrc: $rawfile('ClassObjectTypeCode.ets.html') })
+      Column({ space: 15 }) {
+        Row() {
+          Text($r('app.string.class_object'))
+            .fontSize(20)
+            .textAlign(TextAlign.End)
+          Divider()
+            .layoutWeight(1)
+            .strokeWidth(1)
+            .margin({ top: 20, left: 5 })
+        }
+        .width('100%')
+
+        Column() {
+          Row() {
+            Text(this.classObjectData.title)
+              .fontSize(20)
+            Text(`${this.classObjectData.attribute}`)
+              .fontSize(20)
+              .textAlign(TextAlign.End)
+          }
+          .width('100%')
+          .justifyContent(FlexAlign.SpaceBetween)
+
+          Divider()
+            .width('100%')
+            .strokeWidth(1)
+        }
+        .width('100%')
+        .padding({ left: 50 })
+
+        ChildObjectComp({ childObject: this.classObjectData.child }) // 对象的属性,使用子组件显示
+      }
+      .width('100%')
+      .backgroundColor($r('app.color.component_background_pink'))
+      .padding(10)
+      // 点击更新对象
+      Button($r("app.string.class_type_update_object"))
+        .onClick(() => {
+          // 更新对象,把新的对象直接赋值给状态变量
+          this.clickedCount++;
+          let objectTitle: string = getResourceString(context, $r('app.string.class_attribute')) + this.clickedCount;
+          let attributeTitle: string = getResourceString(context, $r('app.string.class_child_attribute'))
+                                       + this.clickedCount;
+          let newObject = new ParentClass(objectTitle, this.classObjectData.attribute + 1,
+            new ChildClass(attributeTitle, this.classObjectData.child.attribute + 1));
+          this.classObjectData = newObject;
+        })
+        .id('updateObject')
+        .fontColor($r('app.color.button_text_color'))
+        .fontSize($r('app.float.button_text_size'))
+        .type(ButtonType.Capsule)
+        .buttonStyle()
+      Button($r("app.string.class_type_update_attribute"))
+        .onClick(() => {
+          // 点击更新对象的属性
+          this.classObjectData.attribute++;
+        })
+        .id('updateObjectAttribute')
+        .fontColor($r('app.color.button_text_color'))
+        .fontSize($r('app.float.button_text_size'))
+        .type(ButtonType.Capsule)
+        .buttonStyle()
+      Button($r("app.string.class_type_update_child_attribute"))
+        .onClick(() => {
+          // 点击更新对象属性的属性
+          this.classObjectData.child.attribute++;
+        })
+        .id('updateAttributeOfAttribute')
+        .fontColor($r('app.color.button_text_color'))
+        .fontSize($r('app.float.button_text_size'))
+        .type(ButtonType.Capsule)
+        .buttonStyle()
+    }
+    .width('100%')
+    .padding(10)
+    .border({ radius: $r('app.float.component_radius'), color: Color.Grey, width: $r('app.float.border_width') })
+  }
+}
+
+// 对象中属性的组件
+@Component
+struct ChildObjectComp {
+  // 使用@ObjectLink修饰,与父组件同步对象的属性
+  @ObjectLink childObject: ChildClass;
+
+  build() {
+    Column() {
+      Row() {
+        Text(this.childObject.title)
+          .fontSize(20)
+        Text(`${this.childObject.attribute}`)
+          .fontSize(20)
+          .textAlign(TextAlign.End)
+      }
+      .width('100%')
+      .justifyContent(FlexAlign.SpaceBetween)
+
+      Divider()
+        .width('100%')
+        .strokeWidth(1)
+    }
+    .width('100%')
+    .padding({ left: 100 })
+  }
+}
+
+@Styles function buttonStyle() {
+  .width('100%')
+  .height($r('app.float.button_height'))
+  .backgroundColor($r('app.color.button_background_color'))
+}
+
+// 要更新对象属性的属性,对象属性的类需要使用@Observed修饰
+@Observed
+class ChildClass {
+  public title: string;
+  public attribute: number;
+
+  constructor(title: string, attribute: number) {
+    this.title = title;
+    this.attribute = attribute;
+  }
+}
+
+class ParentClass {
+  public title: string;
+  public attribute: number;
+  public child: ChildClass;
+
+  constructor(title: string, attribute: number, child: ChildClass) {
+    this.title = title;
+    this.attribute = attribute;
+    this.child = child;
+  }
+}
+
+ + \ No newline at end of file diff --git a/sample/EnhanceSampleArk1.2/StateManagement/entry/src/main/resources/rawfile/ComponentLink.ets.html b/sample/EnhanceSampleArk1.2/StateManagement/entry/src/main/resources/rawfile/ComponentLink.ets.html new file mode 100644 index 0000000000000000000000000000000000000000..81e169faa4d84400542f97dcfd939c10a856f490 --- /dev/null +++ b/sample/EnhanceSampleArk1.2/StateManagement/entry/src/main/resources/rawfile/ComponentLink.ets.html @@ -0,0 +1,85 @@ + + +ComponentLink.ets + + + + + +
+ +ComponentLink.ets +
+
/* 
+ * Copyright (c) 2023 Huawei Device 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 { COLOR_DATA } from './UniAndBidirectionSyncCode'
+import { ViewCodeText } from '../../../../../commoncomponents/ViewCodeText'
+
+@Component
+export struct ChildCompLink {
+  // 圆形颜色,和父组件中的状态变量双向同步
+  @Link circleColor: string;
+
+  build() {
+    Column({ space: 10 }) {
+      // 点击查看源码
+      ViewCodeText({webSrc: $rawfile('ComponentLink.ets.html')})
+
+      Text($r('app.string.child_component'))
+        .fontSize($r('app.float.tips_font_size'))
+        .width('100%')
+        .textAlign(TextAlign.Start)
+        .margin(10)
+      Text($r("app.string.both_direction_sync_tips"))
+        .fontColor($r('app.color.tips_font_color'))
+        .fontSize($r('app.float.tips_font_size'))
+        .width('100%')
+        .textAlign(TextAlign.Center)
+      // 绑定@Link变量的Circle组件
+      Circle()
+        .size({ width: $r('app.float.circle_size'), height: $r('app.float.circle_size') })
+        .fill(this.circleColor)
+      Button() {
+        Text($r("app.string.both_direction_sync_btn"))
+          .fontColor($r('app.color.button_text_color'))
+          .fontSize($r('app.float.button_text_size'))
+          .width('100%')
+          .textAlign(TextAlign.Center)
+      }
+      .id('redColorBtn')
+      .height($r('app.float.button_height'))
+      .type(ButtonType.Capsule)
+      .backgroundColor($r('app.color.button_background_color'))
+      .onClick(() => {
+        // 点击更新子组件@Link声明的变量,此子组件更新,父组件以及@Prop声明的子组件变量同步
+        this.circleColor = COLOR_DATA.RED;
+      })
+    }
+    .padding(10)
+    .border({ radius: $r('app.float.component_radius'), color: Color.Blue, width: $r('app.float.border_width') })
+  }
+}
+ + \ No newline at end of file diff --git a/sample/EnhanceSampleArk1.2/StateManagement/entry/src/main/resources/rawfile/ComponentProp.ets.html b/sample/EnhanceSampleArk1.2/StateManagement/entry/src/main/resources/rawfile/ComponentProp.ets.html new file mode 100644 index 0000000000000000000000000000000000000000..3bf408c2e8ec04e0d26801ce9bc9f6b82c14a8a7 --- /dev/null +++ b/sample/EnhanceSampleArk1.2/StateManagement/entry/src/main/resources/rawfile/ComponentProp.ets.html @@ -0,0 +1,84 @@ + + +ComponentProp.ets + + + + + +
+ +ComponentProp.ets +
+
/* 
+ * Copyright (c) 2023 Huawei Device 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 { COLOR_DATA } from './UniAndBidirectionSyncCode'
+import { ViewCodeText } from '../../../../../commoncomponents/ViewCodeText'
+
+@Component
+export struct ChildCompProp {
+  // 圆形颜色,和父组件中的状态变量单向同步,只支持基础类型
+  @Prop circleColor: string;
+
+  build() {
+    Column({ space: 10 }) {
+      // 点击查看源码
+      ViewCodeText({ webSrc: $rawfile('ComponentProp.ets.html') })
+      Text($r('app.string.child_component'))
+        .fontSize($r('app.float.tips_font_size'))
+        .width('100%')
+        .textAlign(TextAlign.Start)
+        .margin(10)
+      Text($r("app.string.single_direction_sync_tips"))
+        .fontColor($r('app.color.tips_font_color'))
+        .fontSize($r('app.float.tips_font_size'))
+        .width('100%')
+        .textAlign(TextAlign.Center)
+      // 绑定@Link变量的Circle组件
+      Circle()
+        .size({ width: $r('app.float.circle_size'), height: $r('app.float.circle_size') })
+        .fill(this.circleColor)
+      Button() {
+        Text($r("app.string.single_direction_sync_btn"))
+          .fontColor($r('app.color.button_text_color'))
+          .fontSize($r('app.float.button_text_size'))
+          .width('100%')
+          .textAlign(TextAlign.Center)
+      }
+      .id('blueColorBtn')
+      .height($r('app.float.button_height'))
+      .type(ButtonType.Capsule)
+      .backgroundColor($r('app.color.button_background_color'))
+      .onClick(() => {
+        // 点击更新子组件@Prop声明的变量,此子组件更新,父组件以及@Link声明的子组件变量不同步
+        this.circleColor = COLOR_DATA.BLUE;
+      })
+    }
+    .padding(10)
+    .border({ radius: $r('app.float.component_radius'), color: Color.Blue, width: $r('app.float.border_width') })
+  }
+}
+ + \ No newline at end of file diff --git a/sample/EnhanceSampleArk1.2/StateManagement/entry/src/main/resources/rawfile/ConsumeBrotherOneComponent.ets.html b/sample/EnhanceSampleArk1.2/StateManagement/entry/src/main/resources/rawfile/ConsumeBrotherOneComponent.ets.html new file mode 100644 index 0000000000000000000000000000000000000000..4981ab7cf37338a0c937a005a8528254c14ff35c --- /dev/null +++ b/sample/EnhanceSampleArk1.2/StateManagement/entry/src/main/resources/rawfile/ConsumeBrotherOneComponent.ets.html @@ -0,0 +1,87 @@ + + +ConsumeBrotherOneComponent.ets + + + + + +
+ +ConsumeBrotherOneComponent.ets +
+
/* 
+ * Copyright (c) 2023 Huawei Device 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 { ColorType } from '../model/ColorType';
+import { COLOR_SELECT_DATA } from '../data/ColorData';
+import { getResourceString } from '../../../../utils/ResourceUtils';
+import { ViewCodeText } from '../../../../commoncomponents/ViewCodeText';
+
+let context = getContext(this) as common.UIAbilityContext;
+
+@Component
+export struct ConsumeBrotherOneComponent {
+  @State selectColors: ColorType[] = COLOR_SELECT_DATA;
+  // 和父组件、子组件B双向同步圆形颜色
+  @Consume consumeCircleColor: Resource;
+  // 和父组件、子组件B双向同步Select组件的Index值
+  @Consume currentSelectIndex: number;
+
+  build() {
+    Column({ space: 10 }) {
+      // 点击查看源码
+      ViewCodeText({ webSrc: $rawfile('ParentChildPartialContentSyncCode.ets.html') })
+      Text($r('app.string.consume_brothers_title'))
+        .fontSize($r('app.float.tips_font_size'))
+        .fontColor($r('app.color.tips_font_color'))
+        .width('100%')
+        .textAlign(TextAlign.Center)
+      Row() {
+        Select(this.selectColors)
+          .id('consumeSelectCompA')
+          .selected(this.currentSelectIndex)
+          .value(getResourceString(context, this.selectColors[this.currentSelectIndex].value))
+          .fontColor($r('app.color.button_text_color'))
+          .font({ size: $r('app.float.select_font_size') })
+          .selectedOptionFont({ size: $r('app.float.select_font_size') })
+          .optionFont({ size: $r('app.float.select_font_size') })
+          .onSelect((index: number) => {
+            // 此组件@Consume声明的数据页面更新,兄弟组件@Consume的数据页面同步更新
+            this.currentSelectIndex = index;
+            this.consumeCircleColor = this.selectColors[index].color;
+          })
+        Circle()
+          .size({ width: $r('app.float.circle_size'), height: $r('app.float.circle_size') })
+          .fill(this.consumeCircleColor)
+      }.justifyContent(FlexAlign.SpaceAround)
+      .width('100%')
+    }
+    .padding(10)
+    .border({ radius: $r('app.float.component_radius'), color: Color.Blue, width: $r('app.float.border_width') })
+  }
+}
+ + \ No newline at end of file diff --git a/sample/EnhanceSampleArk1.2/StateManagement/entry/src/main/resources/rawfile/ConsumeBrotherTwoComponent.ets.html b/sample/EnhanceSampleArk1.2/StateManagement/entry/src/main/resources/rawfile/ConsumeBrotherTwoComponent.ets.html new file mode 100644 index 0000000000000000000000000000000000000000..e46f4d0940be396a7c3e12862d9d2cbcfdaecc3a --- /dev/null +++ b/sample/EnhanceSampleArk1.2/StateManagement/entry/src/main/resources/rawfile/ConsumeBrotherTwoComponent.ets.html @@ -0,0 +1,87 @@ + + +ConsumeBrotherTwoComponent.ets + + + + + +
+ +ConsumeBrotherTwoComponent.ets +
+
/* 
+ * Copyright (c) 2023 Huawei Device 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 { ColorType } from '../model/ColorType';
+import { COLOR_SELECT_DATA } from '../data/ColorData';
+import { getResourceString } from '../../../../utils/ResourceUtils';
+import { ViewCodeText } from '../../../../commoncomponents/ViewCodeText'
+
+@Component
+export struct ConsumeBrotherTwoComponent {
+  @State selectColors: ColorType[] = COLOR_SELECT_DATA;
+  // 和父组件、子组件B双向同步圆形颜色
+  @Consume consumeCircleColor: Resource;
+  // 和父组件、子组件A双向同步Select组件的Index值
+  @Consume currentSelectIndex: number;
+
+  build() {
+    Column({ space: 10 }) {
+      // 点击查看源码
+      ViewCodeText({ webSrc: $rawfile('ParentChildPartialContentSyncCode.ets.html') })
+      Text($r('app.string.consume_brothers_title'))
+        .fontColor($r('app.color.tips_font_color'))
+        .fontSize($r('app.float.button_text_size'))
+        .width('100%')
+        .textAlign(TextAlign.Center)
+        .height($r('app.float.button_height'))
+      Row() {
+        Select(this.selectColors)
+          .id('consumeSelectCompB')
+          .selected(this.currentSelectIndex)
+          .value(getResourceString(getContext(this) as common.UIAbilityContext, this.selectColors[this.currentSelectIndex].value))
+          .fontColor($r('app.color.button_text_color'))
+          .font({ size: $r('app.float.select_font_size') })
+          .selectedOptionFont({ size: $r('app.float.select_font_size') })
+          .optionFont({ size: $r('app.float.select_font_size') })
+          .onSelect((index: number) => {
+            // 此组件@Consume声明的数据页面更新,兄弟组件@Consume的数据页面同步更新
+            this.currentSelectIndex = index;
+            this.consumeCircleColor = this.selectColors[index].color;
+          })
+        Circle()
+          .size({ width: $r('app.float.circle_size'), height: $r('app.float.circle_size') })
+          .fill(this.consumeCircleColor)
+
+      }.justifyContent(FlexAlign.SpaceAround)
+      .width('100%')
+    }
+    .padding(10)
+    .border({ radius: $r('app.float.component_radius'), color: Color.Blue, width: $r('app.float.border_width') })
+  }
+}
+ + \ No newline at end of file diff --git a/sample/EnhanceSampleArk1.2/StateManagement/entry/src/main/resources/rawfile/ConsumeDescendentComponent.ets.html b/sample/EnhanceSampleArk1.2/StateManagement/entry/src/main/resources/rawfile/ConsumeDescendentComponent.ets.html new file mode 100644 index 0000000000000000000000000000000000000000..c71aefb1c305ac02921c3edc3cfe57d4d74ddf2b --- /dev/null +++ b/sample/EnhanceSampleArk1.2/StateManagement/entry/src/main/resources/rawfile/ConsumeDescendentComponent.ets.html @@ -0,0 +1,92 @@ + + +ConsumeDescendentComponent.ets + + + + + +
+ +ConsumeDescendentComponent.ets +
+
/* 
+ * Copyright (c) 2023 Huawei Device 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 { ColorType } from '../model/ColorType';
+import { COLOR_SELECT_DATA } from '../data/ColorData';
+import { getResourceString } from '../../../../utils/ResourceUtils';
+import { ViewCodeText } from '../../../../commoncomponents/ViewCodeText';
+
+// 声明一个上下文变量
+let context = getContext(this) as common.UIAbilityContext;
+
+@Component
+export struct ConsumeDescendentComponent {
+  // 初始化一个颜色数组数据
+  @State selectColors: ColorType[] = COLOR_SELECT_DATA;
+  // 和爷组件双向同步圆形颜色
+  @Consume consumeCircleColor: Resource;
+  // 和爷组件双向同步Select的Index值
+  @Consume currentSelectIndex: number;
+
+  build() {
+    Column() {
+      // 点击查看源码
+      ViewCodeText({ webSrc: $rawfile('ConsumeDescendentComponent.ets.html') })
+      Row() {
+        Select(this.selectColors)
+          .selected(this.currentSelectIndex)
+          .value(getResourceString(context, this.selectColors[this.currentSelectIndex].value))
+          .fontColor($r('app.color.button_text_color'))
+          .font({ size: $r('app.float.tips_font_size') })
+          .selectedOptionFont({ size: $r('app.float.tips_font_size') })
+          .optionFont({ size: $r('app.float.tips_font_size') })
+          .id('grandsonCompB')
+          .onSelect((index: number) => {
+            // 孙组件@Consume声明的数据页面更新,爷组件@Provide的数据页面同步更新
+            this.currentSelectIndex = index;
+            this.consumeCircleColor = this.selectColors[index].color;
+          })
+        Circle()
+          .size({ width: $r('app.float.circle_size'), height: $r('app.float.circle_size') })
+          .fill(this.consumeCircleColor)
+
+      }.justifyContent(FlexAlign.SpaceAround)
+      .width('100%')
+      .margin({ bottom: 6 })
+
+      Text($r('app.string.deepnest_descendent_titletwo'))
+        .fontColor($r('app.color.tips_font_color'))
+        .fontSize($r('app.float.button_text_size'))
+        .width('100%')
+        .textAlign(TextAlign.Center)
+    }
+    .padding(10)
+    .border({ radius: $r('app.float.component_radius'), color: Color.Red, width: $r('app.float.border_width') })
+  }
+}
+ + \ No newline at end of file diff --git a/sample/EnhanceSampleArk1.2/StateManagement/entry/src/main/resources/rawfile/DeepNestComponentsSyncCode.ets.html b/sample/EnhanceSampleArk1.2/StateManagement/entry/src/main/resources/rawfile/DeepNestComponentsSyncCode.ets.html new file mode 100644 index 0000000000000000000000000000000000000000..5df40d9726e9004fce69f3f240ff1855c667ed87 --- /dev/null +++ b/sample/EnhanceSampleArk1.2/StateManagement/entry/src/main/resources/rawfile/DeepNestComponentsSyncCode.ets.html @@ -0,0 +1,65 @@ + + +DeepNestComponentsSyncCode.ets + + + + + +
+ +DeepNestComponentsSyncCode.ets +
+
/* 
+ * Copyright (c) 2023 Huawei Device 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 { StateGrandfatherComponent } from './StateGrandfatherComponent';
+import { ProvideGrandfatherComponent } from './ProvideGrandfatherComponent';
+
+@Component
+export struct DeepNestComponentsSyncCode {
+  build() {
+    Column() {
+      Column() {
+        Text($r('app.string.realize_by_state_link'))
+          .fontSize($r('app.float.tips_font_size'))
+          .width('100%')
+          .textAlign(TextAlign.Start)
+        // 爷组件@State
+        StateGrandfatherComponent()
+      }.margin({ bottom: 16 })
+
+      Column() {
+        Text($r('app.string.realize_by_provide_consume'))
+          .fontSize($r('app.float.tips_font_size'))
+          .width('100%')
+          .textAlign(TextAlign.Start)
+        // 爷组件@Provide
+        ProvideGrandfatherComponent()
+      }
+    }
+  }
+}
+ + \ No newline at end of file diff --git a/sample/EnhanceSampleArk1.2/StateManagement/entry/src/main/resources/rawfile/LinkBrotherOneComponent.ets.html b/sample/EnhanceSampleArk1.2/StateManagement/entry/src/main/resources/rawfile/LinkBrotherOneComponent.ets.html new file mode 100644 index 0000000000000000000000000000000000000000..b9438fb259ca73e333c6e2ff57e954308410f4ba --- /dev/null +++ b/sample/EnhanceSampleArk1.2/StateManagement/entry/src/main/resources/rawfile/LinkBrotherOneComponent.ets.html @@ -0,0 +1,89 @@ + + +LinkBrotherOneComponent.ets + + + + + +
+ +LinkBrotherOneComponent.ets +
+
/* 
+ * Copyright (c) 2023 Huawei Device 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 { ColorType } from '../model/ColorType';
+import { COLOR_SELECT_DATA } from '../data/ColorData';
+import { getResourceString } from '../../../../utils/ResourceUtils';
+import { ViewCodeText } from '../../../../commoncomponents/ViewCodeText'
+
+let context = getContext(this) as common.UIAbilityContext;
+
+@Component
+export struct LinkBrotherOneComponent {
+  @State selectColors: ColorType[] = COLOR_SELECT_DATA;
+  // 和父组件、子组件B双向同步圆形颜色
+  @Link circleColor: Resource;
+  // 和父组件、子组件B双向同步Select组件的Index值
+  @Link currentSelectIndex: number;
+
+  build() {
+    Column({ space: 10 }) {
+      // 点击查看源码
+      ViewCodeText({ webSrc: $rawfile('LinkBrotherOneComponent.ets.html') })
+      Text($r('app.string.link_brothers_title'))
+        .fontSize($r('app.float.tips_font_size'))
+        .fontColor($r('app.color.tips_font_color'))
+        .width('100%')
+        .textAlign(TextAlign.Center)
+        .fontColor($r('app.color.tips_font_color'))
+      Row() {
+        Select(this.selectColors)
+          .id('linkSelectCompA')
+          .selected(this.currentSelectIndex)
+          .value(getResourceString(context, this.selectColors[this.currentSelectIndex].value))
+          .fontColor($r('app.color.button_text_color'))
+          .font({ size: $r('app.float.select_font_size') })
+          .selectedOptionFont({ size: $r('app.float.select_font_size') })
+          .optionFont({ size: $r('app.float.select_font_size') })
+          .onSelect((index: number) => {
+            // 此组件@Link声明的数据页面更新,兄弟组件@Link的数据页面同步更新
+            this.currentSelectIndex = index;
+            this.circleColor = this.selectColors[index].color;
+          })
+        Circle()
+          .size({ width: $r('app.float.circle_size'), height: $r('app.float.circle_size') })
+          .fill(this.circleColor)
+      }.justifyContent(FlexAlign.SpaceAround)
+      .width('100%')
+
+    }
+    .padding(10)
+    .border({ radius: $r('app.float.component_radius'), color: Color.Blue, width: $r('app.float.border_width') })
+  }
+}
+ + \ No newline at end of file diff --git a/sample/EnhanceSampleArk1.2/StateManagement/entry/src/main/resources/rawfile/LinkBrotherTwoComponent.ets.html b/sample/EnhanceSampleArk1.2/StateManagement/entry/src/main/resources/rawfile/LinkBrotherTwoComponent.ets.html new file mode 100644 index 0000000000000000000000000000000000000000..0f8c892ab38692cbd094cbd257ab793f8c5ecd39 --- /dev/null +++ b/sample/EnhanceSampleArk1.2/StateManagement/entry/src/main/resources/rawfile/LinkBrotherTwoComponent.ets.html @@ -0,0 +1,86 @@ + + +LinkBrotherTwoComponent.ets + + + + + +
+ +LinkBrotherTwoComponent.ets +
+
/* 
+ * Copyright (c) 2023 Huawei Device 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 { ColorType } from '../model/ColorType';
+import { COLOR_SELECT_DATA } from '../data/ColorData';
+import { getResourceString } from '../../../../utils/ResourceUtils'
+import { ViewCodeText } from '../../../../commoncomponents/ViewCodeText'
+
+@Component
+export struct LinkBrotherTwoComponent {
+  @State selectColors: ColorType[] = COLOR_SELECT_DATA;
+  // 和父组件、子组件A双向同步圆形颜色
+  @Link circleColor: Resource;
+  // 和父组件、子组件A双向同步Select的Index值
+  @Link currentSelectIndex: number;
+
+  build() {
+    Column({ space: 10 }) {
+      // 点击查看源码
+      ViewCodeText({ webSrc: $rawfile('ParentChildPartialContentSyncCode.ets.html') })
+      Text($r('app.string.link_brothers_title'))
+        .fontColor($r('app.color.tips_font_color'))
+        .fontSize($r('app.float.button_text_size'))
+        .width('100%')
+        .textAlign(TextAlign.Center)
+        .height($r('app.float.button_height'))
+      Row() {
+        Select(this.selectColors)
+          .id('linkSelectCompB')
+          .selected(this.currentSelectIndex)
+          .value(getResourceString(getContext(this) as common.UIAbilityContext, this.selectColors[this.currentSelectIndex].value))
+          .fontColor($r('app.color.button_text_color'))
+          .font({ size: $r('app.float.select_font_size') })
+          .selectedOptionFont({ size: $r('app.float.select_font_size') })
+          .optionFont({ size: $r('app.float.select_font_size') })
+          .onSelect((index: number) => {
+            // 此组件@Link声明的数据页面更新,兄弟组件@Link的数据页面同步更新
+            this.currentSelectIndex = index;
+            this.circleColor = this.selectColors[index].color;
+          })
+        Circle()
+          .size({ width: $r('app.float.circle_size'), height: $r('app.float.circle_size') })
+          .fill(this.circleColor)
+      }.justifyContent(FlexAlign.SpaceAround)
+      .width('100%')
+    }
+    .padding(10)
+    .border({ radius: $r('app.float.component_radius'), color: Color.Blue, width: $r('app.float.border_width') })
+  }
+}
+ + \ No newline at end of file diff --git a/sample/EnhanceSampleArk1.2/StateManagement/entry/src/main/resources/rawfile/LinkDescendentComponent.ets.html b/sample/EnhanceSampleArk1.2/StateManagement/entry/src/main/resources/rawfile/LinkDescendentComponent.ets.html new file mode 100644 index 0000000000000000000000000000000000000000..0c8d8dc52026c6699579a26518b39a8166314c26 --- /dev/null +++ b/sample/EnhanceSampleArk1.2/StateManagement/entry/src/main/resources/rawfile/LinkDescendentComponent.ets.html @@ -0,0 +1,89 @@ + + +LinkDescendentComponent.ets + + + + + +
+ +LinkDescendentComponent.ets +
+
/* 
+ * Copyright (c) 2023 Huawei Device 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 { ColorType } from '../model/ColorType';
+import { COLOR_SELECT_DATA } from '../data/ColorData';
+import { getResourceString } from '../../../../utils/ResourceUtils';
+import { ViewCodeText } from '../../../../commoncomponents/ViewCodeText';
+
+let context = getContext(this) as common.UIAbilityContext;
+
+@Component
+export struct LinkDescendentComponent {
+  @State selectColors: ColorType[] = COLOR_SELECT_DATA;
+  // 和父组件和爷组件双向同步圆形颜色
+  @Link circleColor: Resource;
+  // 和父组件和爷组件双向同步Select的Index值
+  @Link currentSelectIndex: number;
+
+  build() {
+    Column() {
+      // 点击查看源码
+      ViewCodeText({ webSrc: $rawfile('LinkDescendentComponent.ets.html') })
+      Row() {
+        Select(this.selectColors)
+          .selected(this.currentSelectIndex)
+          .value(getResourceString(context, this.selectColors[this.currentSelectIndex].value))
+          .fontColor($r('app.color.button_text_color'))
+          .font({ size: $r('app.float.tips_font_size') })
+          .selectedOptionFont({ size: $r('app.float.tips_font_size') })
+          .optionFont({ size: $r('app.float.tips_font_size') })
+          .id('grandsonCompA')
+          .onSelect((index: number) => {
+            // 孙组件@Link组件数据页面更新,爷组件同步更新
+            this.currentSelectIndex = index;
+            this.circleColor = this.selectColors[index].color;
+          })
+        Circle()
+          .size({ width: $r('app.float.circle_size'), height: $r('app.float.circle_size') })
+          .fill(this.circleColor)
+      }.justifyContent(FlexAlign.SpaceAround)
+      .width('100%')
+      .margin({ bottom: 6 })
+
+      Text($r('app.string.deepnest_descendent_titleone'))
+        .fontColor($r('app.color.tips_font_color'))
+        .fontSize($r('app.float.button_text_size'))
+        .width('100%')
+        .textAlign(TextAlign.Center)
+    }
+    .padding(10)
+    .border({ radius: $r('app.float.component_radius'), color: Color.Red, width: $r('app.float.border_width') })
+  }
+}
+ + \ No newline at end of file diff --git a/sample/EnhanceSampleArk1.2/StateManagement/entry/src/main/resources/rawfile/LocalStorageLinkPage.ets.html b/sample/EnhanceSampleArk1.2/StateManagement/entry/src/main/resources/rawfile/LocalStorageLinkPage.ets.html new file mode 100644 index 0000000000000000000000000000000000000000..3b4d22a8c6c6b61f2c33f6f119db72164e149258 --- /dev/null +++ b/sample/EnhanceSampleArk1.2/StateManagement/entry/src/main/resources/rawfile/LocalStorageLinkPage.ets.html @@ -0,0 +1,109 @@ + + +LocalStorageLinkPage.ets + + + + + +
+ +LocalStorageLinkPage.ets +
+
/* 
+ * Copyright (c) 2023 Huawei Device 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 { CodeView } from '../../../commoncomponents/CodeView';
+import { ViewCodeText } from '../../../commoncomponents/ViewCodeText';
+import { TitleBarDark } from '../../../commoncomponents/TitleBarDark';
+import { TitleBar } from '../../../commoncomponents/TitleBar';
+
+let storage: LocalStorage = LocalStorage.GetShared();
+
+@Entry(storage)
+@Component
+struct StorageLinkAbilityPage {
+  @State title: Resource = $r('app.string.localStorage_pagetitletwo');
+  // 和主页、Page2双向同步夜间模式状态
+  @LocalStorageLink('currentModelStatus') currentModelStatus: boolean = true;
+  // 和主页、Page2双向同步内容字体大小
+  @LocalStorageLink('contentFontSize') contentFontSize: number = 18;
+
+  build() {
+    Column() {
+      if (this.currentModelStatus) {
+        TitleBarDark({ title: $title })
+      } else {
+        TitleBar({ title: $title })
+      }
+      CodeView({ title: $title, isShowTitle: false }) {
+        Column({ space: 30 }) {
+          // 查看源码
+          ViewCodeText({ webSrc: $rawfile('LocalStorageLinkPage.ets.html') })
+          Text($r('app.string.localStorage_both_data_binding'))
+            .fontSize(this.contentFontSize)
+            .fontColor(this.currentModelStatus ? $r('app.color.color_white') : $r('app.color.tips_font_color'))
+            .width('100%')
+            .textAlign(TextAlign.Center)
+          Text($r('app.string.localStorage_single_data_binding'))
+            .fontSize(this.contentFontSize)
+            .fontColor(this.currentModelStatus ? $r('app.color.color_white') : $r('app.color.tips_font_color'))
+            .width('100%')
+            .textAlign(TextAlign.Center)
+          Button() {
+            Text(this.currentModelStatus ? $r('app.string.close_nightmode') : $r('app.string.start_nightmode'))
+              .fontColor(this.currentModelStatus ? $r('app.color.color_white') : $r('app.color.button_text_color'))
+              .fontSize(this.contentFontSize)
+              .width('60%')
+              .textAlign(TextAlign.Center)
+          }
+          .type(ButtonType.Capsule)
+          .backgroundColor($r('app.color.button_background_color'))
+          .padding($r('app.float.page_padding'))
+          .onClick(() => {
+            // 更新控制夜间模式状态的变量数据,@LocalStorageLink和@StorageProp关联的数据变量刷新
+            this.currentModelStatus = !this.currentModelStatus;
+          })
+
+          Text($r('app.string.localStorage_nigntmode_both_binding'))
+            .fontSize(this.contentFontSize)
+            .fontColor(this.currentModelStatus ? $r('app.color.color_white') : $r('app.color.tips_font_color'))
+            .width('100%')
+            .textAlign(TextAlign.Center)
+        }
+        .height('100%')
+        .padding($r('app.float.page_padding'))
+      }
+    }
+    .width('100%')
+    .height('100%')
+    .backgroundColor(this.currentModelStatus ? $r('app.color.nightnode_color') : $r('app.color.background_shallow_grey'))
+  }
+
+  aboutToDisappear() {
+    AppStorage.SetOrCreate('sideBarShow', false);
+  }
+}
+ + \ No newline at end of file diff --git a/sample/EnhanceSampleArk1.2/StateManagement/entry/src/main/resources/rawfile/LocalStoragePropPage.ets.html b/sample/EnhanceSampleArk1.2/StateManagement/entry/src/main/resources/rawfile/LocalStoragePropPage.ets.html new file mode 100644 index 0000000000000000000000000000000000000000..b3d149d93b38bba43ba4a9b395e5a63b7d6e121c --- /dev/null +++ b/sample/EnhanceSampleArk1.2/StateManagement/entry/src/main/resources/rawfile/LocalStoragePropPage.ets.html @@ -0,0 +1,145 @@ + + +LocalStoragePropPage.ets + + + + + +
+ +LocalStoragePropPage.ets +
+
/* 
+ * Copyright (c) 2023 Huawei Device 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 { CodeView } from '../../../commoncomponents/CodeView';
+import { ViewCodeText } from '../../../commoncomponents/ViewCodeText';
+import { TitleBarDark } from '../../../commoncomponents/TitleBarDark';
+import { TitleBar } from '../../../commoncomponents/TitleBar';
+
+let storage: LocalStorage = LocalStorage.GetShared();
+
+@Entry(storage)
+@Component
+struct StoragePropAbilityPage {
+  @State title: Resource = $r('app.string.localStorage_pagetitleone');
+  // 初始化Slider组件最小值
+  private minFontSize: number = 10;
+  // 和主页、Page1双向同步夜间模式状态
+  @LocalStorageLink('currentModelStatus') currentModelStatus: boolean = true;
+  // 和主页、Page1单向同步内容字体大小
+  @LocalStorageProp('contentFontSize') contentFontSize: number = 18;
+
+  build() {
+    Column() {
+      if (this.currentModelStatus) {
+        TitleBarDark({ title: $title, isAbility: true })
+      } else {
+        TitleBar({ title: $title, isAbility: true })
+      }
+      CodeView({ title: $title, isShowTitle: false }) {
+        Column({ space: 20 }) {
+          // 查看源码
+          ViewCodeText({ webSrc: $rawfile('LocalStoragePropPage.ets.html') })
+          Text($r('app.string.localStorage_both_data_binding'))
+            .fontSize(this.contentFontSize)
+            .fontColor(this.currentModelStatus ? $r('app.color.color_white') : $r('app.color.tips_font_color'))
+            .width('100%')
+            .textAlign(TextAlign.Center)
+          Text($r('app.string.localStorage_single_data_binding'))
+            .fontSize(this.contentFontSize)
+            .fontColor(this.currentModelStatus ? $r('app.color.color_white') : $r('app.color.tips_font_color'))
+            .width('100%')
+            .textAlign(TextAlign.Center)
+          Button() {
+            Text(this.currentModelStatus ? $r('app.string.close_nightmode') : $r('app.string.start_nightmode'))
+              .fontColor(this.currentModelStatus ? $r('app.color.color_white') : $r('app.color.button_text_color'))
+              .fontSize(this.contentFontSize)
+              .width('60%')
+              .textAlign(TextAlign.Center)
+          }
+          .padding($r('app.float.page_padding'))
+          .type(ButtonType.Capsule)
+          .backgroundColor($r('app.color.button_background_color'))
+          .onClick(() => {
+            // 更新控制夜间模式状态的变量数据,@StorageLink和@StorageProp关联的数据变量刷新
+            this.currentModelStatus = !this.currentModelStatus;
+          })
+
+          Text($r('app.string.localStorage_nigntmode_both_binding'))
+            .fontSize(this.contentFontSize)
+            .fontColor(this.currentModelStatus ? $r('app.color.color_white') : $r('app.color.tips_font_color'))
+            .width('100%')
+            .textAlign(TextAlign.Center)
+          // slider模块控制字体大小
+          Column() {
+            Text($r('app.string.fontSize_text'))
+              .fontSize(this.contentFontSize)
+              .fontColor(this.currentModelStatus ? $r('app.color.color_white') : $r('app.color.tips_font_color'))
+              .width('100%')
+              .textAlign(TextAlign.Center)
+            Row() {
+              Text(`${this.minFontSize}`)
+                .fontColor(this.currentModelStatus ? $r('app.color.color_white') : $r('app.color.tips_font_color'))
+                .fontSize($r('app.float.tips_font_size'))
+              Slider({
+                value: this.contentFontSize,
+                min: 10, // slider最小值
+                max: 30, // slider最大值
+                style: SliderStyle.OutSet
+              })
+                .showTips(true)
+                .onChange((value: number, mode: SliderChangeMode) => {
+                  // 更新控制字体大小的变量数据,@LocalStorageLink关联的数据变量不刷新同步
+                  this.contentFontSize = value;
+                })
+              // toFixed(0)将滑动条返回值处理为整数精度
+              Text(this.contentFontSize.toFixed(0))
+                .fontColor(this.currentModelStatus ? $r('app.color.color_white') : $r('app.color.tips_font_color'))
+                .fontSize($r('app.float.tips_font_size'))
+            }
+            .width('80%')
+          }.margin({ top: 50 })
+
+          Text($r('app.string.localStorage_single_fontsize_binding'))
+            .fontSize(this.contentFontSize)
+            .fontColor(this.currentModelStatus ? $r('app.color.color_white') : $r('app.color.tips_font_color'))
+            .width('100%')
+            .textAlign(TextAlign.Center)
+        }
+        .padding($r('app.float.page_padding'))
+      }
+    }
+    .width('100%')
+    .height('100%')
+    .backgroundColor(this.currentModelStatus ? $r('app.color.nightnode_color') : $r('app.color.background_shallow_grey'))
+  }
+
+  aboutToDisappear() {
+    AppStorage.SetOrCreate('sideBarShow', false);
+  }
+}
+ + \ No newline at end of file diff --git a/sample/EnhanceSampleArk1.2/StateManagement/entry/src/main/resources/rawfile/ObjectLinkComponent.ets.html b/sample/EnhanceSampleArk1.2/StateManagement/entry/src/main/resources/rawfile/ObjectLinkComponent.ets.html new file mode 100644 index 0000000000000000000000000000000000000000..a077ce3f71c7575588b1ec1e472b7aa1020d8f43 --- /dev/null +++ b/sample/EnhanceSampleArk1.2/StateManagement/entry/src/main/resources/rawfile/ObjectLinkComponent.ets.html @@ -0,0 +1,77 @@ + + +ObjectLinkComponent.ets + + + + + +
+ +ObjectLinkComponent.ets +
+
/* 
+ * Copyright (c) 2023 Huawei Device 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 { ClassObject } from './ParentChildPartialContentSyncCode';
+import { ViewCodeText } from '../../../../../commoncomponents/ViewCodeText'
+
+@Component
+export struct ObjectLinkComponent {
+  // 使用@ObjectLink修饰,与父组件中元素同步
+  @ObjectLink childObjectData: ClassObject;
+
+  build() {
+    Column({ space: 10 }) {
+      // 点击查看源码
+      ViewCodeText({ webSrc: $rawfile('ObjectLinkComponent.ets.html') })
+
+      Text($r('app.string.partial_sync_text'))
+        .fontColor($r('app.color.tips_font_color'))
+        .fontSize($r('app.float.tips_font_size'))
+        .width('100%')
+        .textAlign(TextAlign.Start)
+      Row() {
+        Text(this.childObjectData.elementType)
+          .fontColor($r('app.color.tips_font_color'))
+          .fontSize($r('app.float.tips_font_size'))
+          .textAlign(TextAlign.Center)
+          .layoutWeight(1)
+        TextInput({ text: this.childObjectData.attributeType })
+          .fontSize(20)
+          .layoutWeight(1)
+          .id('childAttribute')
+          .onChange((value: string) => {
+            // 子组件对象属性更新,父元素同步
+            this.childObjectData.attributeType = value
+          })
+      }
+      .justifyContent(FlexAlign.SpaceAround)
+    }
+    .border({ radius: $r('app.float.component_radius'), color: Color.Blue, width: $r('app.float.border_width') })
+    .padding(10)
+  }
+}
+ + \ No newline at end of file diff --git a/sample/EnhanceSampleArk1.2/StateManagement/entry/src/main/resources/rawfile/ParentChildPartialContentSyncCode.ets.html b/sample/EnhanceSampleArk1.2/StateManagement/entry/src/main/resources/rawfile/ParentChildPartialContentSyncCode.ets.html new file mode 100644 index 0000000000000000000000000000000000000000..3861aa918ca86e9d8b9c7d74e86980d48c8660e9 --- /dev/null +++ b/sample/EnhanceSampleArk1.2/StateManagement/entry/src/main/resources/rawfile/ParentChildPartialContentSyncCode.ets.html @@ -0,0 +1,132 @@ + + +ParentChildPartialContentSyncCode.ets + + + + + +
+ +ParentChildPartialContentSyncCode.ets +
+
/* 
+ * Copyright (c) 2023 Huawei Device 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 { ObjectLinkComponent } from './ObjectLinkComponent';
+import { ViewCodeText } from '../../../../../commoncomponents/ViewCodeText';
+
+// 数组中元素的类,使用@Observed修饰
+@Observed
+export class ClassObject {
+  public elementType: Resource;
+  public attributeType: Resource | string;
+
+  constructor(elementType: Resource, attributeType: Resource | string) {
+    this.elementType = elementType;
+    this.attributeType = attributeType;
+  }
+}
+
+// 初始化父组件中的数据
+const PARENT_DATA: ClassObject[] = [new ClassObject($r("app.string.partial_sync_element_one"), $r("app.string.partial_sync_attribute_one")),
+  new ClassObject($r("app.string.partial_sync_element_two"), $r("app.string.partial_sync_attribute_two")),
+  new ClassObject($r("app.string.partial_sync_element_three"), $r("app.string.partial_sync_attribute_three"))];
+
+@Component
+export struct ParentChildPartialContentSyncCode {
+  // 初始化父组件中状态变量
+  @State parentData: ClassObject[] = PARENT_DATA;
+  // 与子组件同步的的数据是数组的第几个元素,默认选中第一个
+  @State syncIndex: number = 0;
+
+  build() {
+    Column({ space: 10 }) {
+      // 点击查看源码
+      ViewCodeText({ webSrc: $rawfile('ParentChildPartialContentSyncCode.ets.html') })
+
+      Text($r("app.string.partial_sync_parent_tips"))
+        .fontColor($r('app.color.tips_font_color'))
+        .fontSize($r('app.float.tips_font_size'))
+        .width('100%')
+        .textAlign(TextAlign.Start)
+      // 父组件中List展示状态变量中的内容
+      Column() {
+        ForEach(this.parentData, (item: ClassObject, index: number) => {
+          Column() {
+            ParentCompDataItem({ index: index, syncIndex: this.syncIndex, childObject: item })
+          }
+          .backgroundColor(index === this.syncIndex ? $r('app.color.component_background_pink') : undefined)
+          .onClick(() => {
+            this.syncIndex = index;
+          })
+        }, item => JSON.stringify(item))
+      }
+      .width('100%')
+      .backgroundColor($r('app.color.component_background_pink'))
+
+      //与父组件状态同步的子组件
+      ObjectLinkComponent({ childObjectData: this.parentData[this.syncIndex] })
+    }
+    .width('100%')
+    .padding(10)
+    .border({ radius: $r('app.float.component_radius'), color: Color.Grey, width: $r('app.float.border_width') })
+  }
+}
+
+// 展示数组中单个元素的子组件
+@Component
+struct ParentCompDataItem {
+  private index: number;
+  @Prop syncIndex: number;
+  // 使用@ObjectLink修饰,与父组件中元素同步
+  @ObjectLink childObject: ClassObject;
+
+  build() {
+    Column() {
+      Text(this.childObject.elementType)
+        .width('100%')
+        .fontSize(20)
+      if (this.index === this.syncIndex) {
+        TextInput({ text: this.childObject.attributeType })
+          .fontSize(20)
+          .id(`attribute${this.index + 1}`)
+          .onChange((value: string) => {
+            // 更新父组件中元素的属性,子组件同步
+            this.childObject.attributeType = value;
+          })
+      } else {
+        Text(this.childObject.attributeType)
+          .width('100%')
+          .fontSize(20)
+      }
+    }
+    .padding(10)
+    .id(`arrayElement${this.index}`)
+  }
+}
+
+
+ + \ No newline at end of file diff --git a/sample/EnhanceSampleArk1.2/StateManagement/entry/src/main/resources/rawfile/ProvideFatherComponent.ets.html b/sample/EnhanceSampleArk1.2/StateManagement/entry/src/main/resources/rawfile/ProvideFatherComponent.ets.html new file mode 100644 index 0000000000000000000000000000000000000000..b9e0ad83cb79e04d9e26a97c737ed68ac0cc89f2 --- /dev/null +++ b/sample/EnhanceSampleArk1.2/StateManagement/entry/src/main/resources/rawfile/ProvideFatherComponent.ets.html @@ -0,0 +1,72 @@ + + +ProvideFatherComponent.ets + + + + + +
+ +ProvideFatherComponent.ets +
+
/* 
+ * Copyright (c) 2023 Huawei Device 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 { ColorType } from '../model/ColorType';
+import { COLOR_SELECT_DATA } from '../data/ColorData';
+import { ConsumeBrotherOneComponent } from './ConsumeBrotherOneComponent';
+import { ConsumeBrotherTwoComponent } from './ConsumeBrotherTwoComponent';
+import { ViewCodeText } from '../../../../commoncomponents/ViewCodeText'
+
+@Component
+export struct ProvideFatherComponent {
+  // 初始化一个颜色数组
+  @State selectColors: ColorType[] = COLOR_SELECT_DATA;
+  // 共同父组件使用@Provide初始化圆形颜色
+  @Provide consumeCircleColor: Resource = $r('app.color.circle_blue');
+  // 初始化Select组件的Index为0
+  @Provide currentSelectIndex: number = 0;
+
+  build() {
+    Column({ space: 10 }) {
+      // 点击查看源码
+      ViewCodeText({ webSrc: $rawfile('ParentChildPartialContentSyncCode.ets.html') })
+      Text($r('app.string.parent_titletwo'))
+        .fontSize($r('app.float.tips_font_size'))
+        .fontColor($r('app.color.tips_font_color'))
+        .width('100%')
+        .textAlign(TextAlign.Center)
+      // 和父组件双向同步子组件A
+      ConsumeBrotherOneComponent()
+      // 和父组件双向同步子组件B
+      ConsumeBrotherTwoComponent()
+    }.padding(10)
+    .border({ radius: $r('app.float.component_radius'), color: Color.Grey, width: $r('app.float.border_width') })
+  }
+}
+
+
+ + \ No newline at end of file diff --git a/sample/EnhanceSampleArk1.2/StateManagement/entry/src/main/resources/rawfile/ProvideGrandfatherComponent.ets.html b/sample/EnhanceSampleArk1.2/StateManagement/entry/src/main/resources/rawfile/ProvideGrandfatherComponent.ets.html new file mode 100644 index 0000000000000000000000000000000000000000..75747b94a91a8f9de49c19e53da4bdf879a707ab --- /dev/null +++ b/sample/EnhanceSampleArk1.2/StateManagement/entry/src/main/resources/rawfile/ProvideGrandfatherComponent.ets.html @@ -0,0 +1,111 @@ + + +ProvideGrandfatherComponent.ets + + + + + +
+ +ProvideGrandfatherComponent.ets +
+
/* 
+ * Copyright (c) 2023 Huawei Device 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 { ColorType } from '../model/ColorType';
+import { COLOR_SELECT_DATA } from '../data/ColorData';
+import { ConsumeDescendentComponent } from './ConsumeDescendentComponent';
+import { ViewCodeText } from '../../../../commoncomponents/ViewCodeText';
+import { getResourceString } from '../../../../utils/ResourceUtils'
+
+let context = getContext(this) as common.UIAbilityContext;
+
+@Component
+export struct ProvideGrandfatherComponent {
+  @State selectColors: ColorType[] = COLOR_SELECT_DATA;
+  // 初始化爷组件@Provide的原型颜色
+  @Provide consumeCircleColor: Resource = $r('app.color.circle_blue');
+  // 初始化Select组件的Index
+  @Provide currentSelectIndex: number = 0;
+
+  build() {
+    Column() {
+      // 点击查看源码
+      ViewCodeText({ webSrc:  $rawfile('ProvideAndConsumeSync.ets.html') })
+      Text($r('app.string.deepnest_parent_titletwo'))
+        .fontSize($r('app.float.tips_font_size'))
+        .fontColor($r('app.color.tips_font_color'))
+        .width('100%')
+        .textAlign(TextAlign.Center)
+        .margin({ top: 10 })
+      Row() {
+        Select(this.selectColors)
+          .selected(this.currentSelectIndex)
+          .value(getResourceString(context, this.selectColors[this.currentSelectIndex].value))
+          .fontColor($r('app.color.button_text_color'))
+          .font({ size: $r('app.float.tips_font_size') })
+          .selectedOptionFont({ size: $r('app.float.tips_font_size') })
+          .optionFont({ size: $r('app.float.tips_font_size') })
+          .id('grandfatherCompB')
+          .onSelect((index: number) => {
+            // 爷组件@Provide声明的数据页面更新,孙组件@Consume关联的变量同步更新
+            this.currentSelectIndex = index;
+            this.consumeCircleColor = this.selectColors[index].color;
+          })
+        Circle()
+          .size({ width: $r('app.float.circle_size'), height: $r('app.float.circle_size') })
+          .fill(this.consumeCircleColor)
+      }.justifyContent(FlexAlign.SpaceAround)
+      .width('100%')
+      .margin({ bottom: 6 })
+      // 子组件
+      ConsumeChildComp()
+    }.padding(10)
+    .border({ radius: $r('app.float.component_radius'), color: Color.Grey, width: $r('app.float.border_width') })
+  }
+}
+
+@Component
+struct ConsumeChildComp {
+
+  build() {
+    Column() {
+      Text($r('app.string.deepnest_child_titletwo'))
+        .fontColor($r('app.color.tips_font_color'))
+        .fontSize($r('app.float.button_text_size'))
+        .width('100%')
+        .textAlign(TextAlign.Center)
+        .height($r('app.float.button_height'))
+      // 双向同步孙组件
+      ConsumeDescendentComponent()
+    }
+    .padding(10)
+    .border({ radius: $r('app.float.component_radius'), color: Color.Blue, width: $r('app.float.border_width') })
+  }
+}
+ + \ No newline at end of file diff --git a/sample/EnhanceSampleArk1.2/StateManagement/entry/src/main/resources/rawfile/StateFatherComponent.ets.html b/sample/EnhanceSampleArk1.2/StateManagement/entry/src/main/resources/rawfile/StateFatherComponent.ets.html new file mode 100644 index 0000000000000000000000000000000000000000..b1a056d6f4c45d09803a41e9d783eda43245b3a5 --- /dev/null +++ b/sample/EnhanceSampleArk1.2/StateManagement/entry/src/main/resources/rawfile/StateFatherComponent.ets.html @@ -0,0 +1,78 @@ + + +StateFatherComponent.ets + + + + + +
+ +StateFatherComponent.ets +
+
/* 
+ * Copyright (c) 2023 Huawei Device 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 { ColorType } from '../model/ColorType';
+import { COLOR_SELECT_DATA } from '../data/ColorData';
+import { LinkBrotherOneComponent } from './LinkBrotherOneComponent';
+import { LinkBrotherTwoComponent } from './LinkBrotherTwoComponent';
+import { ViewCodeText } from '../../../../commoncomponents/ViewCodeText'
+
+@Component
+export struct StateFatherComponent {
+  // 共同父组件使用@State初始化圆形颜色
+  @State circleColor: Resource = $r('app.color.circle_blue');
+  // 初始化一个颜色数组
+  @State selectColors: ColorType[] = COLOR_SELECT_DATA;
+  // 初始化当前Select的Index为0
+  @State currentSelectIndex: number = 0;
+
+  build() {
+    Column({ space: 10 }) {
+      // 点击查看源码
+      ViewCodeText({ webSrc: $rawfile('ParentChildPartialContentSyncCode.ets.html') })
+      Text($r('app.string.parent_titleone'))
+        .fontSize($r('app.float.tips_font_size'))
+        .fontColor($r('app.color.tips_font_color'))
+        .width('100%')
+        .textAlign(TextAlign.Center)
+      // 和父组件双向同步子组件A
+      LinkBrotherOneComponent({
+        circleColor: $circleColor,
+        currentSelectIndex: $currentSelectIndex
+      })
+      // 和父组件双向同步子组件B
+      LinkBrotherTwoComponent({
+        circleColor: $circleColor,
+        currentSelectIndex: $currentSelectIndex
+      })
+    }.padding(10)
+    .border({ radius: $r('app.float.component_radius'), color: Color.Grey, width: $r('app.float.border_width') })
+  }
+}
+
+
+ + \ No newline at end of file diff --git a/sample/EnhanceSampleArk1.2/StateManagement/entry/src/main/resources/rawfile/StateGrandfatherComponent.ets.html b/sample/EnhanceSampleArk1.2/StateManagement/entry/src/main/resources/rawfile/StateGrandfatherComponent.ets.html new file mode 100644 index 0000000000000000000000000000000000000000..c5bf92c26f22408fb809fbbcff55b9cc0937ad8c --- /dev/null +++ b/sample/EnhanceSampleArk1.2/StateManagement/entry/src/main/resources/rawfile/StateGrandfatherComponent.ets.html @@ -0,0 +1,117 @@ + + +StateGrandfatherComponent.ets + + + + + +
+ +StateGrandfatherComponent.ets +
+
/* 
+ * Copyright (c) 2023 Huawei Device 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 { LinkDescendentComponent } from './LinkDescendentComponent';
+import { ColorType } from '../model/ColorType';
+import { COLOR_SELECT_DATA } from '../data/ColorData';
+import { getResourceString } from '../../../../utils/ResourceUtils';
+import { ViewCodeText } from '../../../../commoncomponents/ViewCodeText';
+
+// 声明一个上下文变量
+let context = getContext(this) as common.UIAbilityContext;
+
+@Component
+export struct StateGrandfatherComponent {
+  // 初始化爷组件@State的圆形颜色
+  @State circleColor: Resource = $r('app.color.circle_blue');
+  // 初始化一个颜色数组
+  @State selectColors: ColorType[] = COLOR_SELECT_DATA;
+  // 初始化当前select组件的index
+  @State currentSelectIndex: number = 0;
+
+  build() {
+    Column({ space: 10 }) {
+      // 点击查看源码
+      ViewCodeText({ webSrc: $rawfile('StateAndLinkSync.ets.html') })
+      Text($r('app.string.deepnest_parent_titleone'))
+        .fontSize($r('app.float.tips_font_size'))
+        .fontColor($r('app.color.tips_font_color'))
+        .width('100%')
+        .textAlign(TextAlign.Center)
+      Row() {
+        Select(this.selectColors)
+          .selected(this.currentSelectIndex)
+          .value(getResourceString(context, this.selectColors[this.currentSelectIndex].value))
+          .fontColor($r('app.color.button_text_color'))
+          .font({ size: $r('app.float.tips_font_size') })
+          .selectedOptionFont({ size: $r('app.float.tips_font_size') })
+          .optionFont({ size: $r('app.float.tips_font_size') })
+          .id('grandfatherCompA')
+          .onSelect((index: number) => {
+            // 爷组件@State声明的数据页面更新,孙组件@Link关联的变量同步更新
+            this.currentSelectIndex = index;
+            this.circleColor = this.selectColors[index].color;
+          })
+        Circle()
+          .size({ width: $r('app.float.circle_size'), height: $r('app.float.circle_size') })
+          .fill(this.circleColor)
+      }.justifyContent(FlexAlign.SpaceAround)
+      .width('100%')
+      // 双向同步子组件
+      LinkChildComp({ circleColor: $circleColor, currentSelectIndex: $currentSelectIndex })
+    }.padding(10)
+    .border({ radius: $r('app.float.component_radius'), color: Color.Grey, width: $r('app.float.border_width') })
+  }
+}
+
+@Component
+struct LinkChildComp {
+  // 和父组件和子组件双向同步圆形颜色
+  @Link circleColor: Resource;
+  // 和父组件和子组件双向同步Select的Index值
+  @Link currentSelectIndex: number;
+
+  build() {
+    Column() {
+      Text($r('app.string.deepnest_child_titleone'))
+        .fontColor($r('app.color.tips_font_color'))
+        .fontSize($r('app.float.button_text_size'))
+        .width('100%')
+        .textAlign(TextAlign.Center)
+        .height($r('app.float.button_height'))
+      // 双向同步孙组件
+      LinkDescendentComponent({
+        circleColor: $circleColor,
+        currentSelectIndex: $currentSelectIndex
+      })
+    }
+    .padding(10)
+    .border({ radius: $r('app.float.component_radius'), color: Color.Blue, width: $r('app.float.border_width') })
+  }
+}
+ + \ No newline at end of file diff --git a/sample/EnhanceSampleArk1.2/StateManagement/entry/src/main/resources/rawfile/StorageLinkAbilityPage.ets.html b/sample/EnhanceSampleArk1.2/StateManagement/entry/src/main/resources/rawfile/StorageLinkAbilityPage.ets.html new file mode 100644 index 0000000000000000000000000000000000000000..8062ce6637d87397a4cd2bec7898cb59db6a6341 --- /dev/null +++ b/sample/EnhanceSampleArk1.2/StateManagement/entry/src/main/resources/rawfile/StorageLinkAbilityPage.ets.html @@ -0,0 +1,108 @@ + + +StorageLinkAbilityPage.ets + + + + + +
+ +StorageLinkAbilityPage.ets +
+
/* 
+ * Copyright (c) 2023 Huawei Device 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 { CodeView } from '../../../commoncomponents/CodeView';
+import { ViewCodeText } from '../../../commoncomponents//ViewCodeText';
+import { TitleBarDark } from '../../../commoncomponents/TitleBarDark';
+import { TitleBar } from '../../../commoncomponents/TitleBar';
+
+@Entry
+@Component
+struct StorageLinkAbilityPage {
+  @State title: Resource = $r('app.string.abilitytwo_page');
+  // 判断是否关联ability的变量
+  @State isAbility: boolean = true;
+  // 和主页、Ability1页面双向同步夜间模式状态
+  @StorageLink('currentModelStatus') currentModelStatus: boolean = true;
+  // 和主页、Ability1页面双向同步内容字体大小
+  @StorageLink('contentFontSize') contentFontSize: number = 18;
+
+  build() {
+    Column() {
+      if (this.currentModelStatus) {
+        TitleBarDark({ title: $title, isAbility: true })
+      } else {
+        TitleBar({ title: $title, isAbility: true })
+      }
+      CodeView({ title: $title, isShowTitle: false }) {
+        Column({ space: 30 }) {
+          // 查看源码
+          ViewCodeText({ webSrc: $rawfile('StorageLinkAbilityPage.ets.html') })
+          Text($r('app.string.both_data_binding'))
+            .fontSize(this.contentFontSize)
+            .fontColor(this.currentModelStatus ? $r('app.color.color_white') : $r('app.color.tips_font_color'))
+            .width('100%')
+            .textAlign(TextAlign.Center)
+          Text($r('app.string.single_data_binding'))
+            .fontSize(this.contentFontSize)
+            .fontColor(this.currentModelStatus ? $r('app.color.color_white') : $r('app.color.tips_font_color'))
+            .width('100%')
+            .textAlign(TextAlign.Center)
+          Button() {
+            Text(this.currentModelStatus ? $r('app.string.close_nightmode') : $r('app.string.start_nightmode'))
+              .fontColor(this.currentModelStatus ? $r('app.color.color_white') : $r('app.color.button_text_color'))
+              .fontSize(this.contentFontSize)
+              .width('60%')
+              .textAlign(TextAlign.Center)
+          }
+          .type(ButtonType.Capsule)
+          .backgroundColor($r('app.color.button_background_color'))
+          .padding($r('app.float.page_padding'))
+          .onClick(() => {
+            // 更新控制夜间模式状态的变量数据,@StorageLink和@StorageProp关联的数据变量刷新
+            this.currentModelStatus = !this.currentModelStatus;
+          })
+
+          Text($r('app.string.nigntmode_both_binding'))
+            .fontSize(this.contentFontSize)
+            .fontColor(this.currentModelStatus ? $r('app.color.color_white') : $r('app.color.tips_font_color'))
+            .width('100%')
+            .textAlign(TextAlign.Center)
+        }
+        .padding($r('app.float.page_padding'))
+      }
+    }.width('100%')
+    .height('100%')
+    .backgroundColor(this.currentModelStatus ? $r('app.color.nightnode_color') : $r('app.color.background_shallow_grey'))
+  }
+
+  aboutToDisappear() {
+    AppStorage.SetOrCreate('sideBarShow', false);
+  }
+}
+ + \ No newline at end of file diff --git a/sample/EnhanceSampleArk1.2/StateManagement/entry/src/main/resources/rawfile/StoragePropAbilityPage.ets.html b/sample/EnhanceSampleArk1.2/StateManagement/entry/src/main/resources/rawfile/StoragePropAbilityPage.ets.html new file mode 100644 index 0000000000000000000000000000000000000000..131cb7811e1eb940e673e576664447e3190630f9 --- /dev/null +++ b/sample/EnhanceSampleArk1.2/StateManagement/entry/src/main/resources/rawfile/StoragePropAbilityPage.ets.html @@ -0,0 +1,143 @@ + + +StoragePropAbilityPage.ets + + + + + +
+ +StoragePropAbilityPage.ets +
+
/* 
+ * Copyright (c) 2023 Huawei Device 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 { CodeView } from '../../../commoncomponents/CodeView';
+import { ViewCodeText } from '../../../commoncomponents/ViewCodeText';
+import { TitleBarDark } from '../../../commoncomponents/TitleBarDark';
+import { TitleBar } from '../../../commoncomponents/TitleBar';
+
+@Entry
+@Component
+struct StoragePropAbilityPage {
+  @State title: Resource = $r('app.string.abilityone_page');
+  // 初始化Slider最小值
+  private minFontSize: number = 10;
+  // 和主页、Ability2页面双向同步夜间模式状态
+  @StorageLink('currentModelStatus') currentModelStatus: boolean = true;
+  // 和主页、Ability2页面单向同步内容字体大小
+  @StorageProp('contentFontSize') contentFontSize: number = 18;
+
+  build() {
+    Column() {
+      if (this.currentModelStatus) {
+        TitleBarDark({ title: $title, isAbility: true })
+      } else {
+        TitleBar({ title: $title, isAbility: true })
+      }
+      CodeView({ title: $title, isShowTitle: false }) {
+        Column({ space: 20 }) {
+          // 查看源码
+          ViewCodeText({ webSrc: $rawfile('StoragePropAbilityPage.ets.html') })
+          Text($r('app.string.both_data_binding'))
+            .fontSize(this.contentFontSize)
+            .fontColor(this.currentModelStatus ? $r('app.color.color_white') : $r('app.color.tips_font_color'))
+            .width('100%')
+            .textAlign(TextAlign.Center)
+          Text($r('app.string.single_data_binding'))
+            .fontSize(this.contentFontSize)
+            .fontColor(this.currentModelStatus ? $r('app.color.color_white') : $r('app.color.tips_font_color'))
+            .width('100%')
+            .textAlign(TextAlign.Center)
+          Button() {
+            Text(this.currentModelStatus ? $r('app.string.close_nightmode') : $r('app.string.start_nightmode'))
+              .fontColor(this.currentModelStatus ? $r('app.color.color_white') : $r('app.color.button_text_color'))
+              .fontSize(this.contentFontSize)
+              .width('60%')
+              .textAlign(TextAlign.Center)
+          }
+          .padding($r('app.float.page_padding'))
+          .type(ButtonType.Capsule)
+          .backgroundColor($r('app.color.button_background_color'))
+          .onClick(() => {
+            // 更新控制夜间模式状态的变量数据,@StorageLink和@StorageProp关联的数据变量刷新
+            this.currentModelStatus = !this.currentModelStatus;
+          })
+
+          Text($r('app.string.nigntmode_both_binding'))
+            .fontSize(this.contentFontSize)
+            .fontColor(this.currentModelStatus ? $r('app.color.color_white') : $r('app.color.tips_font_color'))
+            .width('100%')
+            .textAlign(TextAlign.Center)
+          // slider模块控制字体大小
+          Column() {
+            Text($r('app.string.fontSize_text'))
+              .fontSize(this.contentFontSize)
+              .fontColor(this.currentModelStatus ? $r('app.color.color_white') : $r('app.color.tips_font_color'))
+              .width('100%')
+              .textAlign(TextAlign.Center)
+            Row() {
+              Text(`${this.minFontSize}`)
+                .fontColor(this.currentModelStatus ? $r('app.color.color_white') : $r('app.color.tips_font_color'))
+                .fontSize($r('app.float.tips_font_size'))
+              Slider({
+                value: this.contentFontSize,
+                min: this.minFontSize, // slider最小值
+                max: 30, // slider最大值
+                style: SliderStyle.OutSet
+              })
+                .showTips(true)
+                .onChange((value: number, mode: SliderChangeMode) => {
+                  // 更新控制字体大小的变量数据,@StorageLink关联的数据变量不刷新同步
+                  this.contentFontSize = value;
+                })
+              // toFixed(0)将滑动条返回值处理为整数精度
+              Text(this.contentFontSize.toFixed(0))
+                .fontColor(this.currentModelStatus ? $r('app.color.color_white') : $r('app.color.tips_font_color'))
+                .fontSize($r('app.float.tips_font_size'))
+            }
+            .width('80%')
+          }.margin({ top: 50 })
+
+          Text($r('app.string.single_fontsize_binding'))
+            .fontSize(this.contentFontSize)
+            .fontColor(this.currentModelStatus ? $r('app.color.color_white') : $r('app.color.tips_font_color'))
+            .width('100%')
+            .textAlign(TextAlign.Center)
+        }
+        .padding($r('app.float.page_padding'))
+      }
+    }
+    .width('100%')
+    .height('100%')
+    .backgroundColor(this.currentModelStatus ? $r('app.color.nightnode_color') : $r('app.color.background_shallow_grey'))
+  }
+
+  aboutToDisappear() {
+    AppStorage.SetOrCreate('sideBarShow', false);
+  }
+}
+ + \ No newline at end of file diff --git a/sample/EnhanceSampleArk1.2/StateManagement/entry/src/main/resources/rawfile/UniAndBidirectionSyncCode.ets.html b/sample/EnhanceSampleArk1.2/StateManagement/entry/src/main/resources/rawfile/UniAndBidirectionSyncCode.ets.html new file mode 100644 index 0000000000000000000000000000000000000000..bf281b40416d3375019061ae6f5d8cd2df65d1ea --- /dev/null +++ b/sample/EnhanceSampleArk1.2/StateManagement/entry/src/main/resources/rawfile/UniAndBidirectionSyncCode.ets.html @@ -0,0 +1,97 @@ + + +UniAndBidirectionSyncCode.ets + + + + + +
+ +UniAndBidirectionSyncCode.ets +
+
/* 
+ * Copyright (c) 2023 Huawei Device 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 { ChildCompLink } from './ComponentLink'
+import { ChildCompProp } from './ComponentProp'
+import { ViewCodeText } from '../../../../../commoncomponents/ViewCodeText'
+
+// 初始化圆形的可设置颜色
+export const COLOR_DATA = {
+  GREY: '#eebebeba',
+  BLUE: '#4A90E2',
+  PINK: '#8DF8BEBE',
+  RED: '#FFF30823',
+}
+
+@Component
+export struct UniAndBidirectionSyncCode {
+  // 初始化圆形颜色的状态变量
+  @State circleColor: string = COLOR_DATA.GREY;
+
+  build() {
+    Column({ space: 10 }) {
+      Column({ space: 10 }) {
+        // 点击查看源码
+        ViewCodeText({ webSrc: $rawfile('UniAndBidirectionSyncCode.ets.html') })
+        Text($r('app.string.parent_component'))
+          .fontSize($r('app.float.tips_font_size'))
+          .width('100%')
+          .textAlign(TextAlign.Start)
+          .margin(10)
+        Text($r("app.string.uni_and_bidirection_sync_tips"))
+          .fontColor($r('app.color.tips_font_color'))
+          .fontSize($r('app.float.tips_font_size'))
+          .width('100%')
+          .textAlign(TextAlign.Center)
+        Circle()
+          .size({ width: $r('app.float.circle_size'), height: $r('app.float.circle_size') })
+          .fill(this.circleColor)
+        // 点击更新父组件的圆形颜色变量,父组件更新,子组件@Link以及@Prop继承的变量同步
+        Button() {
+          Text($r("app.string.uni_and_bidirection_sync_btn"))
+            .fontColor($r('app.color.button_text_color'))
+            .fontSize($r('app.float.button_text_size'))
+            .width('100%')
+            .textAlign(TextAlign.Center)
+        }
+        .id('pinkColorBtn')
+        .height($r('app.float.button_height'))
+        .type(ButtonType.Capsule)
+        .backgroundColor($r('app.color.button_background_color'))
+        .onClick(() => {
+          this.circleColor = COLOR_DATA.PINK;
+        })
+      }
+      // 单向同步子组件
+      ChildCompProp({ circleColor: this.circleColor })
+      // 双向同步子组件
+      ChildCompLink({ circleColor: $circleColor })
+    }
+    .padding(10)
+    .border({ radius: $r('app.float.component_radius'), color: Color.Grey, width: $r('app.float.border_width') })
+  }
+}
+ + \ No newline at end of file diff --git a/sample/EnhanceSampleArk1.2/StateManagement/entry/src/main/resources/rawfile/UpdateBoundComponentCode.ets.html b/sample/EnhanceSampleArk1.2/StateManagement/entry/src/main/resources/rawfile/UpdateBoundComponentCode.ets.html new file mode 100644 index 0000000000000000000000000000000000000000..2bf470cbed1832ea3fe9b1293a6979a0f5eb7a18 --- /dev/null +++ b/sample/EnhanceSampleArk1.2/StateManagement/entry/src/main/resources/rawfile/UpdateBoundComponentCode.ets.html @@ -0,0 +1,116 @@ + + +UpdateBoundComponentCode.ets + + + + + +
+ +UpdateBoundComponentCode.ets +
+
/* 
+ * Copyright (c) 2023 Huawei Device 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 { ViewCodeText } from '../../../../../commoncomponents/ViewCodeText'
+
+@Component
+export struct UpdateBoundComponentCode {
+  // 组件内状态变量
+  @State titleName: string = 'title';
+  // 组件内private变量
+  private content: string = 'content';
+  // 组件内变量更新的次数
+  private updateCount: number = 0;
+
+  build() {
+    Column({ space: 10 }) {
+      // 点击查看源码
+      ViewCodeText({webSrc: $rawfile('UpdateBoundComponentCode.ets.html')})
+
+      Column() {
+        Text($r('app.string.only_update_state'))
+          .fontColor($r('app.color.tips_font_color'))
+          .fontSize($r('app.float.tips_font_size'))
+          .width('100%')
+        Row() {
+          Text($r('app.string.only_update_title'))
+            .fontColor($r('app.color.button_text_color'))
+            .fontSize($r('app.float.button_text_size'))
+          Text(`${this.titleName}`) // titleName为状态变量,绑定Text组件
+            .fontColor($r('app.color.button_text_color'))
+            .fontSize(20)
+        }
+        .width('100%')
+        .margin(10)
+
+        Text($r('app.string.only_update_private'))
+          .fontColor($r('app.color.tips_font_color'))
+          .fontSize($r('app.float.tips_font_size'))
+          .width('100%')
+          .margin({ top: 20 })
+        Row() {
+          Text($r('app.string.only_update_content'))
+            .fontColor($r('app.color.button_text_color'))
+            .fontSize($r('app.float.button_text_size'))
+          Text(`${this.content}`) // content为private,绑定Text组件
+            .fontColor($r('app.color.button_text_color'))
+            .fontSize(20)
+        }
+        .width('100%')
+        .margin(10)
+      }
+      .width('100%')
+      .padding(10)
+      .justifyContent(FlexAlign.SpaceAround)
+      .backgroundColor($r('app.color.component_background_pink'))
+
+      Column() {
+        Button($r('app.string.update_title_content'))
+          .onClick(() => {
+            // 点击更新@State和Private声明的变量,更新策略为:@State和Private的数据发生变化,@State变量绑定的组件更新,Private变量绑定的组件不更新。
+            this.updateCount++;
+            this.content = `content ${this.updateCount}`;
+            this.titleName = `title ${this.updateCount}`;
+          })
+          .id('titleAndContentBtn')
+          .width('100%')
+          .height($r('app.float.button_height'))
+          .fontColor($r('app.color.button_text_color'))
+          .fontSize($r('app.float.button_text_size'))
+          .type(ButtonType.Capsule)
+          .backgroundColor($r('app.color.button_background_color'))
+        Text($r('app.string.only_update_state_components'))
+          .fontColor($r('app.color.tips_font_color'))
+          .fontSize($r('app.float.button_text_size'))
+          .margin({ top: 30 })
+      }.width('100%')
+    }
+    .padding(10)
+    .border({ radius: $r('app.float.component_radius'), color: Color.Grey, width: $r('app.float.border_width') })
+  }
+}
+ + \ No newline at end of file diff --git a/sample/EnhanceSampleArk1.2/StateManagement/entry/src/main/resources/zh_CN/element/string.json b/sample/EnhanceSampleArk1.2/StateManagement/entry/src/main/resources/zh_CN/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..ce4556ba12d47bf53d19c2bc5d755a17428beb52 --- /dev/null +++ b/sample/EnhanceSampleArk1.2/StateManagement/entry/src/main/resources/zh_CN/element/string.json @@ -0,0 +1,432 @@ +{ + "string": [ + { + "name": "module_desc", + "value": "StateManagement entry model" + }, + { + "name": "EntryAbility_desc", + "value": "StateManagement entry ability" + }, + { + "name": "EntryAbility_label", + "value": "状态管理" + }, + { + "name": "close", + "value": "关闭" + }, + { + "name": "page_level", + "value": "页面级状态管理" + }, + { + "name": "app_level", + "value": "应用级状态管理" + }, + { + "name": "single_component_state", + "value": "单组件内的状态变量" + }, + { + "name": "decorated_object_type", + "value": "修饰的对象类型" + }, + { + "name": "base_type", + "value": "基础类型" + }, + { + "name": "array_type", + "value": "数组类型" + }, + { + "name": "array_type_add", + "value": "新增元素" + }, + { + "name": "array_type_delete", + "value": "删除元素" + }, + { + "name": "array_type_update", + "value": "更新数组中的单个元素" + }, + { + "name": "array_type_deletetoast", + "value": "列表为空,不能删除!" + }, + { + "name": "array_type_updatetoast", + "value": "列表为空,不能更新!" + }, + { + "name": "class_type", + "value": "类对象类型" + }, + { + "name": "class_type_objectName", + "value": "title" + }, + { + "name": "class_object", + "value": "对象" + }, + { + "name": "class_attribute", + "value": "对象属性" + }, + { + "name": "class_child_attribute", + "value": "属性的属性" + }, + { + "name": "class_type_update_object", + "value": "更新对象" + }, + { + "name": "class_type_update_attribute", + "value": "更新对象属性" + }, + { + "name": "class_type_update_child_attribute", + "value": "更新属性中的属性" + }, + { + "name": "update_principle", + "value": "更新原理" + }, + { + "name": "only_update_bound_components", + "value": "只更新所绑定的组件" + }, + { + "name": "only_update_state", + "value": "@State变量" + }, + { + "name": "only_update_title", + "value": "标题:" + }, + { + "name": "only_update_private", + "value": "private声明变量" + }, + { + "name": "only_update_content", + "value": "内容:" + }, + { + "name": "update_title_content", + "value": "点击修改标题和内容" + }, + { + "name": "only_update_state_components", + "value": "只更新@State变量绑定的组件" + }, + { + "name": "update_the_custom_component", + "value": "所在的自定义组件都更新" + }, + { + "name": "multi_component_sync", + "value": "自定义组件之间的状态同步" + }, + { + "name": "parent_child_sync", + "value": "父子组件之间状态同步" + }, + { + "name": "single_and_two_way_sync", + "value": "单、双向同步" + }, + { + "name": "parent_component", + "value": "父组件" + }, + { + "name": "child_component", + "value": "子组件" + }, + { + "name": "uni_and_bidirection_sync_tips", + "value": "父组件中原型颜色为@State状态变量" + }, + { + "name": "single_direction_sync_tips", + "value": "单向同步 子组件中原型颜色为@Prop状态变量" + }, + { + "name": "both_direction_sync_tips", + "value": "双向同步 子组件中原型颜色为@Link状态变量" + }, + { + "name": "uni_and_bidirection_sync_btn", + "value": "设置为粉色,子组件同步更新" + }, + { + "name": "single_direction_sync_btn", + "value": "设置为蓝色,父组件不同步" + }, + { + "name": "both_direction_sync_btn", + "value": "设置为红色,父组件同步" + }, + { + "name": "partial_sync", + "value": "子组件同步父组件部分内容" + }, + { + "name": "partial_sync_element_one", + "value": "元素1" + }, + { + "name": "partial_sync_element_two", + "value": "元素2" + }, + { + "name": "partial_sync_element_three", + "value": "元素3" + }, + { + "name": "partial_sync_attribute_one", + "value": "属性1" + }, + { + "name": "partial_sync_attribute_two", + "value": "属性2" + }, + { + "name": "partial_sync_attribute_three", + "value": "属性3" + }, + { + "name": "partial_sync_parent_tips", + "value": "父组件中数组为@State状态变量,数组的元素的类用@observed修饰" + }, + { + "name": "partial_sync_text", + "value": "子组件中使用@ObjectLink修饰变量,与父组件中对象的元素同步数据" + }, + { + "name": "parent_descendent_sync", + "value": "爷孙组件之间状态同步" + }, + { + "name": "select_colorblue", + "value": "蓝色" + }, + { + "name": "select_colorpink", + "value": "粉色" + }, + { + "name": "realize_by_state_link", + "value": "使用@State,@Link实现:" + }, + { + "name": "realize_by_provide_consume", + "value": "使用@Provide, @Consume实现:" + }, + { + "name": "deepnest_parent_titleone", + "value": "使用@State,@Link实现父组件中圆形颜色为@State状态变量" + }, + { + "name": "deepnest_child_titleone", + "value": "子组件圆形颜色为@Link状态变量传递给孙组件" + }, + { + "name": "deepnest_descendent_titleone", + "value": "孙组件中圆形颜色为@Link状态变量" + }, + { + "name": "deepnest_parent_titletwo", + "value": "使用@Provide,@Consume实现父组件中圆形颜色为@Provide状态变量作为数据提供方" + }, + { + "name": "deepnest_child_titletwo", + "value": "子组件中不需要设置变量" + }, + { + "name": "deepnest_descendent_titletwo", + "value": "子组件中圆形颜色为@Consume变量感知数据变化,更新UI,也可反向同步" + }, + { + "name": "brother_sync", + "value": "兄弟组件之间状态同步" + }, + { + "name": "parent_titleone", + "value": "共同的父组件圆形颜色为@State变量" + }, + { + "name": "link_brothers_title", + "value": "兄弟组件圆形颜色为@Link状态变量" + }, + { + "name": "parent_titletwo", + "value": "共同的父组件圆形颜色为@Provide变量" + }, + { + "name": "consume_brothers_title", + "value": "兄弟组件圆形颜色为@Consume状态变量" + }, + { + "name": "application_storage_ui", + "value": "应用内全局数据与UI之间的状态同步" + }, + { + "name": "nightmode", + "value": "夜间模式" + }, + { + "name": "close_nightmode", + "value": "关闭夜间模式" + }, + { + "name": "start_nightmode", + "value": "打开夜间模式" + }, + { + "name": "nightmode_text", + "value": "夜间模式控制Ability1,Ability2界面样式" + }, + { + "name": "fontSize_text", + "value": "字体大小" + }, + { + "name": "fontSize_singlesync_textone", + "value": "字体大小控制Ability1,Ability2,界面字体大小单向同步" + }, + { + "name": "enter_abilityone", + "value": "进入ability1" + }, + { + "name": "enter_abilitytwo", + "value": "进入ability2" + }, + { + "name": "abilityone_page", + "value": "Ability1" + }, + { + "name": "abilitytwo_page", + "value": "Ability2" + }, + { + "name": "both_data_binding", + "value": "组件通过@StorageLink(key)装饰的状态变量与AppStorage建立双向绑定" + }, + { + "name": "single_data_binding", + "value": "组件通过使用@StorageProp(key)装饰的状态变量,与AppStorage建立单向数据绑定" + }, + { + "name": "nigntmode_both_binding", + "value": "此界面中夜间模式为@StorageLink(key)变量双向同步,其他Ability中会同步夜间模式开关" + }, + { + "name": "single_fontsize_binding", + "value": "此界面中字体大小为@StorageProp(key)变量单向同步,只改变当前界面的字体大小" + }, + { + "name": "ability_storage_ui", + "value": "Ability内全局数据与UI之间的状态同步" + }, + { + "name": "enter_pageone", + "value": "进入Page1" + }, + { + "name": "enter_pagetwo", + "value": "进入Page2" + }, + { + "name": "enter_ability_outofsync", + "value": "跨Ability不同步" + }, + { + "name": "ability_storage_nightmodelsync", + "value": "夜间模式控制Page1,Page2界面样式" + }, + { + "name": "ability_storage_fontsizesync", + "value": "字体大小控制Page1,Page2界面字体大小单向同步" + }, + { + "name": "localStorage_both_data_binding", + "value": "组件通过@LocalStorageLink(key)装饰的状态变量与LocalStorage建立双向绑定" + }, + { + "name": "localStorage_single_data_binding", + "value": "组件通过使用@LocalStorageProp(key)装饰的状态变量,与LocalStorage建立单向数据绑定" + }, + { + "name": "localStorage_nigntmode_both_binding", + "value": "此界面中夜间模式为@LocaltorageLink(key)变量双向同步,其它页面中会同步夜间模式开关" + }, + { + "name": "localStorage_single_fontsize_binding", + "value": "此界面中字体大小为@LocalStorageProp(key)变量单向同步,只改变当前界面的字体大小" + }, + { + "name": "enter_ability_outofsync_text", + "value": "跨Ability,数据不同步,因此此界面中夜间模式和主页的开关不同步" + }, + { + "name": "localStorage_pagetitleone", + "value": "Page1" + }, + { + "name": "localStorage_pagetitletwo", + "value": "Page2" + }, + { + "name": "localStorage_abilitytitle", + "value": "Ability" + }, + { + "name": "base_type_tip_text", + "value": "圆形颜色为@State状态变量" + }, + { + "name": "source_code", + "value": "查看源码" + }, + { + "name": "set_to_blue", + "value": "设置为蓝色" + }, + { + "name": "set_to_pink", + "value": "设置为粉色" + }, + { + "name": "storagepropability_desc", + "value": "description" + }, + { + "name": "storagepropability_label", + "value": "label" + }, + { + "name": "storagelinkability_desc", + "value": "description" + }, + { + "name": "storagelinkability_label", + "value": "label" + }, + { + "name": "outofsyncability_desc", + "value": "description" + }, + { + "name": "outofsyncability_label", + "value": "label" + } + ] +} \ No newline at end of file diff --git a/sample/EnhanceSampleArk1.2/StateManagement/entry/src/ohosTest/ets/TestRunner/OpenHarmonyTestRunner.ts b/sample/EnhanceSampleArk1.2/StateManagement/entry/src/ohosTest/ets/TestRunner/OpenHarmonyTestRunner.ts new file mode 100644 index 0000000000000000000000000000000000000000..3490d6ed607cad2ed78a02e5786894c2ef3892d5 --- /dev/null +++ b/sample/EnhanceSampleArk1.2/StateManagement/entry/src/ohosTest/ets/TestRunner/OpenHarmonyTestRunner.ts @@ -0,0 +1,62 @@ +/* + * Copyright (c) 2023 Huawei Device 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 type TestRunner from '@ohos.application.testRunner'; +import AbilityDelegatorRegistry from '@ohos.app.ability.abilityDelegatorRegistry'; +import Logger from '../utils/Logger'; + +const TAG = 'OpenHarmonyTestRunner'; +let abilityDelegator = undefined; +let abilityDelegatorArguments = undefined; + +async function onAbilityCreateCallback(): Promise { + Logger.info(TAG, 'onAbilityCreateCallback'); +} + +async function addAbilityMonitorCallback(err: object): Promise { + Logger.info(TAG, `addAbilityMonitorCallback : ${JSON.stringify(err)}`); +} + +export default class OpenHarmonyTestRunner implements TestRunner { + constructor() { + } + + onPrepare(): void { + Logger.info(TAG, 'OpenHarmonyTestRunner OnPrepare '); + } + + async onRun(): Promise { + Logger.info(TAG, 'OpenHarmonyTestRunner onRun run'); + abilityDelegatorArguments = AbilityDelegatorRegistry.getArguments(); + abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator(); + let testAbilityName = abilityDelegatorArguments.bundleName + '.TestAbility'; + let lMonitor = { + abilityName: testAbilityName, + onAbilityCreate: onAbilityCreateCallback, + }; + abilityDelegator.addAbilityMonitor(lMonitor, addAbilityMonitorCallback); + let cmd = 'aa start -d 0 -a TestAbility' + ' -b ' + abilityDelegatorArguments.bundleName; + let debug = abilityDelegatorArguments.parameters['-D']; + if (debug === 'true') { + cmd += ' -D'; + } + Logger.info(TAG, `cmd : ${cmd}`); + abilityDelegator.executeShellCommand(cmd, + (err: object) => { + Logger.info(TAG, `executeShellCommand : err : ${JSON.stringify(err)}`); + }); + Logger.info(TAG, 'OpenHarmonyTestRunner onRun end'); + }; +} \ No newline at end of file diff --git a/sample/EnhanceSampleArk1.2/StateManagement/entry/src/ohosTest/ets/test/Ability.test.ets b/sample/EnhanceSampleArk1.2/StateManagement/entry/src/ohosTest/ets/test/Ability.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..1fdeb369b61b73fa6feda6db8c9adb7aa4f9098c --- /dev/null +++ b/sample/EnhanceSampleArk1.2/StateManagement/entry/src/ohosTest/ets/test/Ability.test.ets @@ -0,0 +1,839 @@ +/* + * Copyright (c) 2023 Huawei Device 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 AbilityDelegatorRegistry from '@ohos.app.ability.abilityDelegatorRegistry'; +import inputMethod from '@ohos.inputMethod'; +import { Driver, ON, MatchPattern } from '@ohos.UiTest'; +import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium'; +import Logger from '../utils/Logger'; + +const TAG = '[Sample_StateManagement]' +const BUNDLE = 'StateManagement_' + +const DELAY_TIME = 1000 +let driver: Driver = Driver.create() + +//通过text验证有没有这个组件 有的话点击一下 +async function checkButtonAndClickWithText(text: string) { + let atom = text + await driver.assertComponentExist(ON.text(atom)) + let button = await driver.findComponent(ON.text(atom)) + await button.click() + await driver.delayMs(DELAY_TIME) + Logger.info(TAG, BUNDLE + atom) +} + +//通过id验证有没有这个组件 有的话点击一下 +async function checkButtonAndClickWithID(text: string) { + let atom = text + await driver.assertComponentExist(ON.id(atom)) + let button = await driver.findComponent(ON.id(atom)) + await button.click() + await driver.delayMs(DELAY_TIME) + Logger.info(TAG, BUNDLE + atom) +} + +//通过id验证有没有这个组件 有的话点击一下 +async function checkButtonAndLongClickWithID(text: string) { + let atom = text + await driver.assertComponentExist(ON.id(atom)) + let button = await driver.findComponent(ON.id(atom)) + await button.longClick() + await driver.delayMs(DELAY_TIME) + Logger.info(TAG, BUNDLE + atom) +} + +async function clickSelectIDAndSelectText(toggleId: string, selectText: string) { + { //展开 + let atom = toggleId + await checkButtonAndClickWithID(atom) + } + { //选择 + let atom = selectText + await checkButtonAndClickWithText(atom) + } +} + +export default function abilityTest() { + describe('ActsAbilityTest', function () { + // Defines a test suite. Two parameters are supported: test suite name and test suite function. + beforeAll(function () { + // Presets an action, which is performed only once before all test cases of the test suite start. + // This API supports only one parameter: preset action function. + }); + beforeEach(function () { + // Presets an action, which is performed before each unit test case starts. + // The number of execution times is the same as the number of test cases defined by **it**. + // This API supports only one parameter: preset action function. + }); + afterEach(function () { + // Presets a clear action, which is performed after each unit test case ends. + // The number of execution times is the same as the number of test cases defined by **it**. + // This API supports only one parameter: clear action function. + }); + afterAll(function () { + // Presets a clear action, which is performed after all test cases of the test suite end. + // This API supports only one parameter: clear action function. + }); + it('assertContain', 0, function () { + + Logger.info("Sample_StateManagement test start") + /** + * 打开应用 + */ + it(BUNDLE + 'StartAbility_001', 0, async function (done) { + Logger.info(TAG, BUNDLE + 'StartAbility_001 begin') + let abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator() + try { + await abilityDelegator.startAbility({ + bundleName: 'com.samples.statemanagement', + abilityName: 'EntryAbility' + }) + done() + } catch (exception) { + Logger.info(TAG, `StartAbility_001 end ${JSON.stringify(exception)}`) + expect(0).assertEqual(exception.code) + done() + } + Logger.info(TAG, BUNDLE + 'StartAbility_001' + ' end') + }) + + /** + * 打开折叠层 + */ + it(BUNDLE + 'FolderLayerFunction_001', 0, async function () { + let testName = 'FolderLayerFunction' + Logger.info(TAG, BUNDLE + testName + ' begin') + + let driver = Driver.create(); + await driver.delayMs(500); + // 打开修饰对象模块的折叠 + await driver.assertComponentExist(ON.id('secondLevelMenu00')); + let decoratedOject = await driver.findComponent(ON.id('secondLevelMenu00')); + await decoratedOject.click(); + await driver.delayMs(500); + await driver.assertComponentExist(ON.id('secondLevelMenu01')); + let updatedBound = await driver.findComponent(ON.id('secondLevelMenu01')); + await updatedBound.click(); + await driver.delayMs(500); + await driver.assertComponentExist(ON.id('secondLevelMenu10')); + let multiComponentsSync = await driver.findComponent(ON.id('secondLevelMenu10')); + await multiComponentsSync.click(); + await driver.delayMs(500); + + Logger.info(TAG, BUNDLE + testName + ' end') + }); + + /** + * 测试基础类型状态管理 + */ + it(BUNDLE + 'BaseTypeFunction_001', 0, async function () { + let testName = 'BaseTypeFunction' + Logger.info(TAG, BUNDLE + testName + ' begin') + + let abilityDelegatorRegistry = AbilityDelegatorRegistry.getAbilityDelegator(); + let context = await abilityDelegatorRegistry.getAppContext(); + let manager = context.resourceManager; + + let driver: Driver = Driver.create(); + await driver.delayMs(500); + // 进入基础类型页面 + await driver.assertComponentExist(ON.text(await manager.getStringValue($r('app.string.base_type')))); + let enterPage = await driver.findComponent(ON.text(await manager.getStringValue($r('app.string.base_type')))); + await enterPage.click(); + await driver.delayMs(500); + // 设置圆形颜色 + await driver.assertComponentExist(ON.id('circleColorBtn')); + let setCircleColor = await driver.findComponent(ON.id('circleColorBtn')); + await setCircleColor.click(); + await driver.delayMs(500); + // 再次设置圆形颜色 + await setCircleColor.click(); + await driver.delayMs(500); + // 查看源码 + await driver.assertComponentExist(ON.id('viewSourceCode')); + let viewSourceCode = await driver.findComponent(ON.id('viewSourceCode')); + await viewSourceCode.click(); + await driver.delayMs(500); + // 关闭web + await driver.assertComponentExist(ON.id('close')); + let closeWebBtn = await driver.findComponent(ON.id('close')); + await closeWebBtn.click(); + await driver.delayMs(500); + // 返回 + await driver.assertComponentExist(ON.id('backBtn')); + let backBtn = await driver.findComponent(ON.id('backBtn')); + await backBtn.click(); + await driver.delayMs(500); + + Logger.info(TAG, BUNDLE + testName + ' end') + }); + + /** + * 测试数组类型状态管理 + */ + it(BUNDLE + 'ArrayTypeFunction_001', 0, async function () { + let testName = 'ArrayTypeFunction' + Logger.info(TAG, BUNDLE + testName + ' begin') + + let abilityDelegatorRegistry = AbilityDelegatorRegistry.getAbilityDelegator(); + let context = await abilityDelegatorRegistry.getAppContext(); + let manager = context.resourceManager; + + let driver: Driver = Driver.create(); + await driver.delayMs(500); + // 进入数组类型页面 + await driver.assertComponentExist(ON.text(await manager.getStringValue($r('app.string.array_type')))); + let enterPage = await driver.findComponent(ON.text(await manager.getStringValue($r('app.string.array_type')))); + await enterPage.click(); + await driver.delayMs(500); + // 点击删除元素 + await driver.assertComponentExist(ON.id('arrayTypeBtn1')); + let arrayTypeDeleteBtn = await driver.findComponent(ON.id('arrayTypeBtn1')); + await arrayTypeDeleteBtn.click(); + await driver.delayMs(500); + await arrayTypeDeleteBtn.click(); + await driver.delayMs(500); + await arrayTypeDeleteBtn.click(); + await driver.delayMs(500); + await arrayTypeDeleteBtn.click(); + await driver.delayMs(500); + // 点击添加元素 + await driver.assertComponentExist(ON.id('arrayTypeBtn0')); + let arrayTypeAddBtn = await driver.findComponent(ON.id('arrayTypeBtn0')); + await arrayTypeAddBtn.click(); + await driver.delayMs(500); + // 点击更新元素 + await driver.assertComponentExist(ON.id('arrayTypeBtn2')); + let arrayTypeUpdateBtn = await driver.findComponent(ON.id('arrayTypeBtn2')); + await arrayTypeUpdateBtn.click(); + await driver.delayMs(500); + await arrayTypeDeleteBtn.click(); + await driver.delayMs(500); + await arrayTypeUpdateBtn.click(); + await driver.delayMs(500); + await arrayTypeAddBtn.click(); + await driver.delayMs(500); + // 展示源码 + await driver.assertComponentExist(ON.id('viewSourceCode')); + let viewSourceCode = await driver.findComponent(ON.id('viewSourceCode')); + await viewSourceCode.click(); + await driver.delayMs(500); + // 关闭web源码 + await driver.assertComponentExist(ON.id('close')); + let closeWebBtn = await driver.findComponent(ON.id('close')); + await closeWebBtn.click(); + await driver.delayMs(500); + // 返回 + await driver.assertComponentExist(ON.id('backBtn')); + let backBtn = await driver.findComponent(ON.id('backBtn')); + await backBtn.click(); + await driver.delayMs(500); + + Logger.info(TAG, BUNDLE + testName + ' end') + }) + + /** + * 测试类对象类型状态管理 + */ + it(BUNDLE + 'ObjectTypeFunction_001', 0, async function () { + let testName = 'ObjectTypeFunction' + Logger.info(TAG, BUNDLE + testName + ' begin') + + let abilityDelegatorRegistry = AbilityDelegatorRegistry.getAbilityDelegator(); + let context = await abilityDelegatorRegistry.getAppContext(); + let manager = context.resourceManager; + + let driver: Driver = Driver.create(); + await driver.delayMs(500); + // 进入类对象类型页面 + await driver.assertComponentExist(ON.text(await manager.getStringValue($r('app.string.class_type')))); + let enterPageText = await driver.findComponent(ON.text(await manager.getStringValue($r('app.string.class_type')))); + await enterPageText.click(); + await driver.delayMs(500); + // 点击更新对象 + await driver.assertComponentExist(ON.id('updateObject')); + let updateObjectBtn = await driver.findComponent(ON.id('updateObject')); + await updateObjectBtn.click(); + await driver.delayMs(500); + await updateObjectBtn.click(); + await driver.delayMs(500); + // 点击更新对象属性 + await driver.assertComponentExist(ON.id('updateObjectAttribute')); + let updateObjectAttributeBtn = await driver.findComponent(ON.id('updateObjectAttribute')); + await updateObjectAttributeBtn.click(); + await driver.delayMs(500); + await updateObjectAttributeBtn.click(); + await driver.delayMs(500); + // 点击更新属性的属性 + await driver.assertComponentExist(ON.id('updateAttributeOfAttribute')); + let updateAttributeOfAttributeBtn = await driver.findComponent(ON.id('updateAttributeOfAttribute')); + await updateAttributeOfAttributeBtn.click(); + await driver.delayMs(500); + await updateAttributeOfAttributeBtn.click(); + await driver.delayMs(500); + // 展示源码 + await driver.assertComponentExist(ON.id('viewSourceCode')); + let viewSourceCode = await driver.findComponent(ON.id('viewSourceCode')); + await viewSourceCode.click(); + await driver.delayMs(500); + // 关闭web源码 + await driver.assertComponentExist(ON.id('close')); + let closeWebBtn = await driver.findComponent(ON.id('close')); + await closeWebBtn.click(); + await driver.delayMs(500); + // 返回 + await driver.assertComponentExist(ON.id('backBtn')); + let backBtn = await driver.findComponent(ON.id('backBtn')); + await backBtn.click(); + await driver.delayMs(500); + + Logger.info(TAG, BUNDLE + testName + ' end') + }); + + /** + * 测试只更新所绑定的组件 + */ + it(BUNDLE + 'UpdateBindComponentFunction_001', 0, async function () { + let testName = 'UpdateBindComponentFunction' + Logger.info(TAG, BUNDLE + testName + ' begin') + + let abilityDelegatorRegistry = AbilityDelegatorRegistry.getAbilityDelegator(); + let context = await abilityDelegatorRegistry.getAppContext(); + let manager = context.resourceManager; + + let driver: Driver = Driver.create(); + await driver.delayMs(500); + // 进入只更新所绑定的组件页面 + await driver.assertComponentExist(ON.text(await manager.getStringValue($r('app.string.only_update_bound_components')))); + let enterPageText = await driver.findComponent(ON.text(await manager.getStringValue($r('app.string.only_update_bound_components')))); + await enterPageText.click(); + await driver.delayMs(500); + // 点击更新对象 + await driver.assertComponentExist(ON.id('titleAndContentBtn')); + let updateTitleAndContent = await driver.findComponent(ON.id('titleAndContentBtn')); + await updateTitleAndContent.click(); + await driver.delayMs(500); + await updateTitleAndContent.click(); + await driver.delayMs(500); + // 展示源码 + await driver.assertComponentExist(ON.id('viewSourceCode')); + let viewSourceCode = await driver.findComponent(ON.id('viewSourceCode')); + await viewSourceCode.click(); + await driver.delayMs(500); + // 关闭web源码 + await driver.assertComponentExist(ON.id('close')); + let closeWebBtn = await driver.findComponent(ON.id('close')); + await closeWebBtn.click(); + await driver.delayMs(500); + // 返回 + await driver.assertComponentExist(ON.id('backBtn')); + let backBtn = await driver.findComponent(ON.id('backBtn')); + await backBtn.click(); + await driver.delayMs(500); + + Logger.info(TAG, BUNDLE + testName + ' end') + }); + + /** + * 测试单、双向同步 + */ + it(BUNDLE + 'SingleBindFunction_001', 0, async function () { + let testName = 'SingleBindFunction' + Logger.info(TAG, BUNDLE + testName + ' begin') + + let abilityDelegatorRegistry = AbilityDelegatorRegistry.getAbilityDelegator(); + let context = await abilityDelegatorRegistry.getAppContext(); + let manager = context.resourceManager; + + let driver: Driver = Driver.create(); + await driver.delayMs(500); + // 进入单双向同步页面 + await driver.assertComponentExist(ON.text(await manager.getStringValue($r('app.string.single_and_two_way_sync')))); + let enterPageText = await driver.findComponent(ON.text(await manager.getStringValue($r('app.string.single_and_two_way_sync')))); + await enterPageText.click(); + await driver.delayMs(500); + // 点击设置粉色 + await driver.assertComponentExist(ON.id('pinkColorBtn')); + let pinkColorBtn = await driver.findComponent(ON.id('pinkColorBtn')); + await pinkColorBtn.click(); + await driver.delayMs(500); + // 设置蓝色 + await driver.assertComponentExist(ON.id('blueColorBtn')); + let blueColorBtn = await driver.findComponent(ON.id('blueColorBtn')); + await blueColorBtn.click(); + await driver.delayMs(500); + // 设置红色 + await driver.assertComponentExist(ON.id('redColorBtn')); + let redColorBtn = await driver.findComponent(ON.id('redColorBtn')); + await redColorBtn.click(); + await driver.delayMs(500); + // 展示源码 + await driver.assertComponentExist(ON.id('viewSourceCode')); + let viewSourceCode = await driver.findComponent(ON.id('viewSourceCode')); + await viewSourceCode.click(); + await driver.delayMs(500); + // 关闭web源码 + await driver.assertComponentExist(ON.id('close')); + let closeWebBtn = await driver.findComponent(ON.id('close')); + await closeWebBtn.click(); + await driver.delayMs(500); + // 返回 + await driver.assertComponentExist(ON.id('backBtn')); + let backBtn = await driver.findComponent(ON.id('backBtn')); + await backBtn.click(); + await driver.delayMs(500); + + Logger.info(TAG, BUNDLE + testName + ' end') + }) + + /** + * 测试子组件同步父组件的内容 + */ + it(BUNDLE + 'ChildParentFunction_001', 0, async function () { + let testName = 'ChildParentFunction' + Logger.info(TAG, BUNDLE + testName + ' begin') + + let abilityDelegatorRegistry = AbilityDelegatorRegistry.getAbilityDelegator(); + let context = await abilityDelegatorRegistry.getAppContext(); + let manager = context.resourceManager; + + let driver: Driver = Driver.create(); + await driver.delayMs(500); + // 进入单双向同步页面 + await driver.assertComponentExist(ON.text(await manager.getStringValue($r('app.string.partial_sync')))); + let enterPageText = await driver.findComponent(ON.text(await manager.getStringValue($r('app.string.partial_sync')))); + await enterPageText.click(); + await driver.delayMs(500); + // 点击修改父组件第一个属性文本 + let inputMethodController = inputMethod.getController(); + await driver.assertComponentExist(ON.id('attribute1')); + let attributeOne = await driver.findComponent(ON.id('attribute1')); + await attributeOne.inputText('123'); + inputMethodController.stopInputSession(); + await driver.delayMs(500); + // 点击修改子组件属性文本 + await driver.assertComponentExist(ON.id('childAttribute')); + let childAttribute = await driver.findComponent(ON.id('childAttribute')); + await childAttribute.click(); + await driver.delayMs(500); + await childAttribute.inputText('321'); + inputMethodController.stopInputSession(); + await driver.delayMs(500); + // 点击修改父组件第二个属性文本 + await driver.assertComponentExist(ON.id('arrayElement1')); + let arrayElementOne = await driver.findComponent(ON.id('arrayElement1')); + await arrayElementOne.click(); + await driver.delayMs(500); + await driver.assertComponentExist(ON.id('attribute2')); + let attributeTwo = await driver.findComponent(ON.id('attribute2')); + await attributeTwo.inputText('456'); + inputMethodController.stopInputSession(); + await driver.delayMs(500); + // 点击修改父组件第三个属性文本 + await driver.assertComponentExist(ON.id('arrayElement2')); + let arrayElementTwo = await driver.findComponent(ON.id('arrayElement2')); + await arrayElementTwo.click(); + await driver.delayMs(500); + await driver.assertComponentExist(ON.id('attribute3')); + let attributeThree = await driver.findComponent(ON.id('attribute3')); + await attributeThree.click(); + await driver.delayMs(500); + await attributeThree.inputText('789'); + inputMethodController.stopInputSession(); + await driver.delayMs(500); + // 展示源码 + await driver.assertComponentExist(ON.id('viewSourceCode')); + let viewSourceCode = await driver.findComponent(ON.id('viewSourceCode')); + await viewSourceCode.click(); + await driver.delayMs(500); + // 关闭web源码 + await driver.assertComponentExist(ON.id('close')); + let closeWebBtn = await driver.findComponent(ON.id('close')); + await closeWebBtn.click(); + await driver.delayMs(500); + // 返回 + await driver.assertComponentExist(ON.id('backBtn')); + let backBtn = await driver.findComponent(ON.id('backBtn')); + await backBtn.click(); + await driver.delayMs(500); + + Logger.info(TAG, BUNDLE + testName + ' end') + }) + + /** + * 测试爷孙组件之间状态同步 + */ + it(BUNDLE + 'DeepBindFunction_001', 0, async function () { + let testName = 'DeepBindFunction' + Logger.info(TAG, BUNDLE + testName + ' begin') + + let abilityDelegatorRegistry = AbilityDelegatorRegistry.getAbilityDelegator(); + let context = await abilityDelegatorRegistry.getAppContext(); + let manager = context.resourceManager; + + let driver: Driver = Driver.create(); + await driver.delayMs(500); + // 进入单双向同步页面 + await driver.assertComponentExist(ON.text(await manager.getStringValue($r('app.string.parent_descendent_sync')))); + let enterPageText = await driver.findComponent(ON.text(await manager.getStringValue($r('app.string.parent_descendent_sync')))); + await enterPageText.click(); + await driver.delayMs(500); + // 点击孙组件select组件并选择颜色 + await driver.assertComponentExist(ON.id('grandsonCompA')); + let grandsonA = await driver.findComponent(ON.id('grandsonCompA')); + await grandsonA.click(); + await driver.delayMs(500); + await driver.assertComponentExist(ON.text(await manager.getStringValue($r('app.string.select_colorpink')))); + let selectedPink = await driver.findComponent(ON.text(await manager.getStringValue($r('app.string.select_colorpink')))); + await selectedPink.click(); + await driver.delayMs(500); + // 点击爷组件select组件并选择颜色 + await driver.assertComponentExist(ON.id('grandfatherCompA')); + let grandfatherCompA = await driver.findComponent(ON.id('grandfatherCompA')); + await grandfatherCompA.click(); + await driver.delayMs(500); + await driver.assertComponentExist(ON.text(await manager.getStringValue($r('app.string.select_colorblue')))); + let selectedBlueCompA = await driver.findComponent(ON.text(await manager.getStringValue($r('app.string.select_colorblue')))); + await selectedBlueCompA.click(); + await driver.delayMs(500); + // 点击孙组件select组件并选择颜色 + await driver.assertComponentExist(ON.id('grandsonCompB')); + let grandsonCompB = await driver.findComponent(ON.id('grandsonCompB')); + await grandsonCompB.click(); + await driver.delayMs(500); + await driver.assertComponentExist(ON.text(await manager.getStringValue($r('app.string.select_colorpink')))); + let selectedPinkCompB = await driver.findComponent(ON.text(await manager.getStringValue($r('app.string.select_colorpink')))); + await selectedPinkCompB.click(); + await driver.delayMs(500); + // 点击爷组件select组件并选择颜色 + await driver.assertComponentExist(ON.id('grandfatherCompB')); + let grandfatherCompB = await driver.findComponent(ON.id('grandfatherCompB')); + await grandfatherCompB.click(); + await driver.delayMs(500); + await driver.assertComponentExist(ON.text(await manager.getStringValue($r('app.string.select_colorblue')))); + let selectedBlueCompB = await driver.findComponent(ON.text(await manager.getStringValue($r('app.string.select_colorblue')))); + await selectedBlueCompB.click(); + await driver.delayMs(500); + // 展示源码 + await driver.assertComponentExist(ON.id('viewSourceCode')); + let viewSourceCode = await driver.findComponent(ON.id('viewSourceCode')); + await viewSourceCode.click(); + await driver.delayMs(500); + // 关闭web源码 + await driver.assertComponentExist(ON.id('close')); + let closeWebBtn = await driver.findComponent(ON.id('close')); + await closeWebBtn.click(); + await driver.delayMs(500); + // 返回 + await driver.assertComponentExist(ON.id('backBtn')); + let backBtn = await driver.findComponent(ON.id('backBtn')); + await backBtn.click(); + await driver.delayMs(500) + + Logger.info(TAG, BUNDLE + testName + ' end') + }); + + /** + * 测试兄弟组件之间状态同步 + */ + it(BUNDLE + 'BrotherBindFunction_001', 0, async function () { + let testName = 'BrotherBindFunction' + Logger.info(TAG, BUNDLE + testName + ' begin') + + let abilityDelegatorRegistry = AbilityDelegatorRegistry.getAbilityDelegator(); + let context = await abilityDelegatorRegistry.getAppContext(); + let manager = context.resourceManager; + + let driver: Driver = Driver.create(); + await driver.delayMs(500); + // 进入单双向同步页面 + await driver.assertComponentExist(ON.text(await manager.getStringValue($r('app.string.brother_sync')))); + let enterPageText = await driver.findComponent(ON.text(await manager.getStringValue($r('app.string.brother_sync')))); + await enterPageText.click(); + await driver.delayMs(500); + // 点击子组件B中的select组件并选择颜色 + await driver.assertComponentExist(ON.id('linkSelectCompB')); + let linkSelectCompB = await driver.findComponent(ON.id('linkSelectCompB')); + await linkSelectCompB.click(); + await driver.delayMs(500); + await driver.assertComponentExist(ON.text(await manager.getStringValue($r('app.string.select_colorpink')))); + let linkselectedPinkB = await driver.findComponent(ON.text(await manager.getStringValue($r('app.string.select_colorpink')))); + await linkselectedPinkB.click(); + await driver.delayMs(500); + // 点击子组件B中的select组件并选择颜色 + await driver.assertComponentExist(ON.id('linkSelectCompA')); + let linkSelectCompA = await driver.findComponent(ON.id('linkSelectCompA')); + await linkSelectCompA.click(); + await driver.delayMs(500); + await driver.assertComponentExist(ON.text(await manager.getStringValue($r('app.string.select_colorblue')))); + let linkselectedBlueA = await driver.findComponent(ON.text(await manager.getStringValue($r('app.string.select_colorblue')))); + await linkselectedBlueA.click(); + await driver.delayMs(500); + // 点击子组件B中的select组件并选择颜色 + await driver.assertComponentExist(ON.id('consumeSelectCompB')); + let consumeSelectCompB = await driver.findComponent(ON.id('consumeSelectCompB')); + await consumeSelectCompB.click(); + await driver.delayMs(500); + await driver.assertComponentExist(ON.text(await manager.getStringValue($r('app.string.select_colorpink')))); + let consumeSelectedPinkB = await driver.findComponent(ON.text(await manager.getStringValue($r('app.string.select_colorpink')))); + await consumeSelectedPinkB.click(); + await driver.delayMs(500); + // 点击子组件B中的select组件并选择颜色 + await driver.assertComponentExist(ON.id('consumeSelectCompA')); + let consumeSelectCompA = await driver.findComponent(ON.id('consumeSelectCompA')); + await consumeSelectCompA.click(); + await driver.delayMs(500); + await driver.assertComponentExist(ON.text(await manager.getStringValue($r('app.string.select_colorblue')))); + let consumeSelectedBlueA = await driver.findComponent(ON.text(await manager.getStringValue($r('app.string.select_colorblue')))); + await consumeSelectedBlueA.click(); + await driver.delayMs(500); + // 展示源码 + await driver.assertComponentExist(ON.id('viewSourceCode')); + let viewSourceCode = await driver.findComponent(ON.id('viewSourceCode')); + await viewSourceCode.click(); + await driver.delayMs(500); + // 关闭web源码 + await driver.assertComponentExist(ON.id('close')); + let closeWebBtn = await driver.findComponent(ON.id('close')); + await closeWebBtn.click(); + await driver.delayMs(500); + // 返回 + await driver.assertComponentExist(ON.id('backBtn')); + let backBtn = await driver.findComponent(ON.id('backBtn')); + await backBtn.click(); + await driver.delayMs(500); + + Logger.info(TAG, BUNDLE + testName + ' end') + }); + + /** + * 应用内全局数据与UI之间的状态同步 + */ + it(BUNDLE + 'GlobalSynFunction_001', 0, async function () { + let testName = 'GlobalSynFunction' + Logger.info(TAG, BUNDLE + testName + ' begin') + + let abilityDelegatorRegistry = AbilityDelegatorRegistry.getAbilityDelegator(); + let context = await abilityDelegatorRegistry.getAppContext(); + let manager = context.resourceManager; + + let driver: Driver = Driver.create(); + await driver.delayMs(500); + // 切换到应用级状态变量 + await driver.assertComponentExist(ON.id('tabBar1')); + let applyLeval = await driver.findComponent(ON.id('tabBar1')); + await applyLeval.click(); + await driver.delayMs(500); + // 进入应用内全局数据与UI之间的状态同步 + await driver.assertComponentExist(ON.text(await manager.getStringValue($r('app.string.application_storage_ui')))); + let enterPageText = await driver.findComponent(ON.text(await manager.getStringValue($r('app.string.application_storage_ui')))); + await enterPageText.click(); + await driver.delayMs(500); + // 点击Toggle组件,控制夜间模式 + await driver.assertComponentExist(ON.id('nightModeSwitch')); + let nightModeSwitch = await driver.findComponent(ON.id('nightModeSwitch')); + await nightModeSwitch.click(); + await driver.delayMs(500); + // 滑动slider调整 固定坐标只支持RK3568,其他设备需要调整 + await driver.drag(320, 473, 420, 473, 800) + await driver.delayMs(500); + // 进入Ability1 + await driver.assertComponentExist(ON.id('enterAbilityOne')); + let enterAbilityOne = await driver.findComponent(ON.id('enterAbilityOne')); + await enterAbilityOne.click(); + await driver.delayMs(500); + // 返回 + await driver.assertComponentExist(ON.id('backBtn')); + let backBtn = await driver.findComponent(ON.id('backBtn')); + await backBtn.click(); + await driver.delayMs(500); + // 进入Ability2 + await driver.assertComponentExist(ON.id('enterAbilityTwo')); + let enterAbilityTwo = await driver.findComponent(ON.id('enterAbilityTwo')); + await enterAbilityTwo.click(); + await driver.delayMs(500); + // 返回 + await driver.pressBack(); + await driver.delayMs(500); + // 再次进入Ability1 + await enterAbilityOne.click(); + await driver.delayMs(500); + // 点击控制夜间模式按钮 + await driver.assertComponentExist(ON.id('nightModeSwitchTwo')); + let nightModeSwitchTwo = await driver.findComponent(ON.id('nightModeSwitchTwo')); + await nightModeSwitchTwo.click(); + await driver.delayMs(500); + // 滑动slider调整 固定坐标只支持RK3568,其他设备需要调整 + await driver.drag(320, 745, 420, 745, 800) + await driver.delayMs(500); + // 返回首页 + await driver.pressBack(); + await driver.delayMs(500); + // 进入Ability2 + await enterAbilityTwo.click(); + await driver.delayMs(500); + // 点击控制夜间模式按钮 + await driver.assertComponentExist(ON.id('nightModeSwitchThree')); + let nightModeSwitchThree = await driver.findComponent(ON.id('nightModeSwitchThree')); + await nightModeSwitchThree.click(); + await driver.delayMs(500); + // 返回首页 + await driver.pressBack(); + await driver.delayMs(500); + // 再次进入Ability1 + await enterAbilityOne.click(); + await driver.delayMs(500); + // 展示源码 + await driver.assertComponentExist(ON.id('viewSourceCode')); + let viewSourceCode = await driver.findComponent(ON.id('viewSourceCode')); + await viewSourceCode.click(); + await driver.delayMs(500); + // 关闭web源码 + await driver.assertComponentExist(ON.id('close')); + let closeWebBtn = await driver.findComponent(ON.id('close')); + await closeWebBtn.click(); + await driver.delayMs(500); + // 返回 + await driver.pressBack(); + await driver.delayMs(500); + await driver.pressBack(); + await driver.delayMs(500) + + Logger.info(TAG, BUNDLE + testName + ' end') + }); + + /** + * 应用内全局数据与UI之间的状态同步 + */ + it(BUNDLE + 'AbilitySynFunction_001', 0, async function () { + let testName = 'AbilitySynFunction' + Logger.info(TAG, BUNDLE + testName + ' begin') + + let abilityDelegatorRegistry = AbilityDelegatorRegistry.getAbilityDelegator(); + let context = await abilityDelegatorRegistry.getAppContext(); + let manager = context.resourceManager; + + let driver: Driver = Driver.create(); + await driver.delayMs(500); + await driver.assertComponentExist(ON.text(await manager.getStringValue($r('app.string.ability_storage_ui')))); + let enterPageText = await driver.findComponent(ON.text(await manager.getStringValue($r('app.string.ability_storage_ui')))); + await enterPageText.click(); + await driver.delayMs(500); + // 点击Toggle组件,控制夜间模式 + await driver.assertComponentExist(ON.id('nightModeSwitch')); + let nightModeSwitch = await driver.findComponent(ON.id('nightModeSwitch')); + await nightModeSwitch.click(); + await driver.delayMs(500); + // 滑动slider调整 固定坐标只支持RK3568,其他设备需要调整 + await driver.drag(320, 470, 420, 470, 800) + await driver.delayMs(500); + // 进入Page1 + await driver.assertComponentExist(ON.id('enterPageOne')); + let enterPageOne = await driver.findComponent(ON.id('enterPageOne')); + await enterPageOne.click(); + await driver.delayMs(500); + // 返回 + await driver.assertComponentExist(ON.id('backBtn')); + let backBtn = await driver.findComponent(ON.id('backBtn')); + await backBtn.click(); + await driver.delayMs(500); + // 进入Page2 + await driver.assertComponentExist(ON.id('enterPageTwo')); + let enterPageTwo = await driver.findComponent(ON.id('enterPageTwo')); + await enterPageTwo.click(); + await driver.delayMs(500); + await driver.pressBack(); + await driver.delayMs(500); + // 进入跨Ability页面 + await driver.assertComponentExist(ON.id('enterOutOfAbility')); + let enterAbility = await driver.findComponent(ON.id('enterOutOfAbility')); + await enterAbility.click(); + await driver.delayMs(500); + // 返回 + await driver.pressBack(); + await driver.delayMs(500); + // 进入Page1 + await enterPageOne.click(); + await driver.delayMs(500); + // 点击控制夜间模式按钮 + await driver.assertComponentExist(ON.id('nightModeSwitchTwo')); + let nightModeSwitchTwo = await driver.findComponent(ON.id('nightModeSwitchTwo')); + await nightModeSwitchTwo.click(); + await driver.delayMs(500); + // 滑动slider调整 固定坐标只支持RK3568,其他设备需要调整 + await driver.drag(320, 745, 380, 745, 800) + await driver.delayMs(500); + // 返回首页 + await driver.pressBack(); + await driver.delayMs(500); + // 进入Ability + await enterAbility.click(); + await driver.delayMs(500); + await driver.pressBack(); + await driver.delayMs(500); + // 进入Page2 + await enterPageTwo.click(); + await driver.delayMs(500); + // 点击控制夜间模式按钮 + await driver.assertComponentExist(ON.id('nightModeSwitchThree')); + let nightModeSwitchThree = await driver.findComponent(ON.id('nightModeSwitchThree')); + await nightModeSwitchThree.click(); + await driver.delayMs(500); + // 返回首页 + await driver.pressBack(); + await driver.delayMs(500); + // 再次进入Page1 + await enterPageOne.click(); + await driver.delayMs(500); + await driver.pressBack(); + await driver.delayMs(500); + // 再次进入Ability + await enterAbility.click(); + await driver.delayMs(500); + await driver.assertComponentExist(ON.id('nightModeSwitchFour')); + let nightModeSwitchFour = await driver.findComponent(ON.id('nightModeSwitchFour')); + await nightModeSwitchFour.click(); + await driver.delayMs(500); + await driver.pressBack(); + await driver.delayMs(500); + // 再次进入Page1 + await enterPageOne.click(); + await driver.delayMs(500); + await driver.pressBack(); + await driver.delayMs(500); + // 进入Page2 + await enterPageTwo.click(); + await driver.delayMs(500); + await driver.pressBack(); + await driver.delayMs(500); + // 展示源码 + await driver.assertComponentExist(ON.id('viewSourceCode')); + let viewSourceCode = await driver.findComponent(ON.id('viewSourceCode')); + await viewSourceCode.click(); + await driver.delayMs(500); + // 关闭web源码 + await driver.assertComponentExist(ON.id('close')); + let closeWebBtn = await driver.findComponent(ON.id('close')); + await closeWebBtn.click(); + await driver.delayMs(500); + + Logger.info(TAG, BUNDLE + testName + ' end') + }); + + Logger.info("Sample_StateManagement test end") + }) + }) +} \ No newline at end of file diff --git a/sample/EnhanceSampleArk1.2/StateManagement/entry/src/ohosTest/ets/test/List.test.ets b/sample/EnhanceSampleArk1.2/StateManagement/entry/src/ohosTest/ets/test/List.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..76e5c3bbf2d0a03d4cecea18328a01d28d7ba6c5 --- /dev/null +++ b/sample/EnhanceSampleArk1.2/StateManagement/entry/src/ohosTest/ets/test/List.test.ets @@ -0,0 +1,22 @@ +/* + * Copyright (c) 2023 Huawei Device 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 abilityTest from './Ability.test'; +//import appTest from './App.test'; + +export default function testsuite() { + abilityTest(); +// appTest(); +} \ No newline at end of file diff --git a/sample/EnhanceSampleArk1.2/StateManagement/entry/src/ohosTest/ets/testability/TestAbility.ets b/sample/EnhanceSampleArk1.2/StateManagement/entry/src/ohosTest/ets/testability/TestAbility.ets new file mode 100644 index 0000000000000000000000000000000000000000..1a2da16d1926ec4bdf07304b1ddbe4d1079891c5 --- /dev/null +++ b/sample/EnhanceSampleArk1.2/StateManagement/entry/src/ohosTest/ets/testability/TestAbility.ets @@ -0,0 +1,61 @@ +/* + * Copyright (c) 2023 Huawei Device 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 UIAbility from '@ohos.app.ability.UIAbility'; +import AbilityDelegatorRegistry from '@ohos.app.ability.abilityDelegatorRegistry'; +import type window from '@ohos.window'; +import { Hypium } from '@ohos/hypium'; +import testsuite from '../test/List.test'; +import Logger from '../utils/Logger'; + +const TAG = 'TestAbility'; + + +export default class TestAbility extends UIAbility { + onCreate() { + Logger.info(TAG, 'TestAbility onCreate'); + let abilityDelegator: AbilityDelegatorRegistry.AbilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator(); + let abilityDelegatorArguments: AbilityDelegatorRegistry.AbilityDelegatorArgs = AbilityDelegatorRegistry.getArguments(); + Logger.info(TAG, 'start run testcase!!!'); + Hypium.hypiumTest(abilityDelegator, abilityDelegatorArguments, testsuite); + } + + onDestroy() { + Logger.info(TAG, 'TestAbility onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage) { + Logger.info(TAG, 'TestAbility onWindowStageCreate'); + windowStage.loadContent('testability/pages/Index', (err) => { + if (err.code) { + Logger.error(TAG, `Failed to load the content. Cause:${JSON.stringify(err)}`); + return; + } + Logger.info(TAG, 'Succeeded in loading the content.'); + }); + } + + onWindowStageDestroy() { + Logger.info(TAG, 'TestAbility onWindowStageDestroy'); + } + + onForeground() { + Logger.info(TAG, 'TestAbility onForeground'); + } + + onBackground() { + Logger.info(TAG, 'TestAbility onBackground'); + } +} \ No newline at end of file diff --git a/sample/EnhanceSampleArk1.2/StateManagement/entry/src/ohosTest/ets/testability/pages/Index.ets b/sample/EnhanceSampleArk1.2/StateManagement/entry/src/ohosTest/ets/testability/pages/Index.ets new file mode 100644 index 0000000000000000000000000000000000000000..7c98007ca2790b537284d67c712bf7345e118f0a --- /dev/null +++ b/sample/EnhanceSampleArk1.2/StateManagement/entry/src/ohosTest/ets/testability/pages/Index.ets @@ -0,0 +1,54 @@ +/* + * Copyright (c) 2023 Huawei Device 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 Logger from '../../utils/Logger'; + +const TAG = 'UitestIndexPage'; + +@Entry +@Component +struct Index { + aboutToAppear() { + Logger.info(TAG, 'TestAbility index aboutToAppear'); + } + + @State message: string = 'Hello World'; + + build() { + Row() { + Column() { + Text(this.message) + .fontSize(50) + .fontWeight(FontWeight.Bold) + Button() { + Text('next page') + .fontSize(20) + .fontWeight(FontWeight.Bold) + } + .type(ButtonType.Capsule) + .margin({ + top: 20 + }) + .backgroundColor('#0D9FFB') + .width('35%') + .height('5%') + .onClick(() => { + }) + } + .width('100%') + } + .height('100%') + } +} \ No newline at end of file diff --git a/sample/EnhanceSampleArk1.2/StateManagement/entry/src/ohosTest/ets/utils/Logger.ts b/sample/EnhanceSampleArk1.2/StateManagement/entry/src/ohosTest/ets/utils/Logger.ts new file mode 100644 index 0000000000000000000000000000000000000000..4a86375ab5c6a63c4545bf22a428a7706edaf67d --- /dev/null +++ b/sample/EnhanceSampleArk1.2/StateManagement/entry/src/ohosTest/ets/utils/Logger.ts @@ -0,0 +1,44 @@ +/* + * Copyright (c) 2023 Huawei Device 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 hilog from '@ohos.hilog'; + +const DOMAIN: number = 0xF811; +const PREFIX = 'Sample_StateManagement'; +const FORMAT = '%{public}s, %{public}s'; + +class Logger { + constructor() { + + } + + debug(...args: string[]): void { + hilog.debug(DOMAIN, PREFIX, FORMAT, args); + } + + info(...args: string[]): void { + hilog.info(DOMAIN, PREFIX, FORMAT, args); + } + + warn(...args: string[]): void { + hilog.warn(DOMAIN, PREFIX, FORMAT, args); + } + + error(...args: string[]): void { + hilog.error(DOMAIN, PREFIX, FORMAT, args); + } +} + +export default new Logger(); \ No newline at end of file diff --git a/sample/EnhanceSampleArk1.2/StateManagement/entry/src/ohosTest/module.json5 b/sample/EnhanceSampleArk1.2/StateManagement/entry/src/ohosTest/module.json5 new file mode 100644 index 0000000000000000000000000000000000000000..22e2c611f379dbb0fddf452b259ef27c508d058b --- /dev/null +++ b/sample/EnhanceSampleArk1.2/StateManagement/entry/src/ohosTest/module.json5 @@ -0,0 +1,52 @@ +/* + * Copyright (c) 2023 Huawei Device 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. + */ + +{ + "module": { + "name": "entry_test", + "type": "feature", + "description": "$string:module_test_desc", + "mainElement": "TestAbility", + "deviceTypes": [ + "default", + "tablet" + ], + "deliveryWithInstall": true, + "installationFree": false, + "pages": "$profile:test_pages", + "abilities": [ + { + "name": "TestAbility", + "srcEntrance": "./ets/testability/TestAbility.ets", + "description": "$string:TestAbility_desc", + "icon": "$media:icon", + "label": "$string:TestAbility_label", + "visible": true, + "startWindowIcon": "$media:icon", + "startWindowBackground": "$color:start_window_background", + "skills": [ + { + "actions": [ + "action.system.home" + ], + "entities": [ + "entity.system.home" + ] + } + ] + } + ] + } +} diff --git a/sample/EnhanceSampleArk1.2/StateManagement/entry/src/ohosTest/resources/base/element/color.json b/sample/EnhanceSampleArk1.2/StateManagement/entry/src/ohosTest/resources/base/element/color.json new file mode 100644 index 0000000000000000000000000000000000000000..3c712962da3c2751c2b9ddb53559afcbd2b54a02 --- /dev/null +++ b/sample/EnhanceSampleArk1.2/StateManagement/entry/src/ohosTest/resources/base/element/color.json @@ -0,0 +1,8 @@ +{ + "color": [ + { + "name": "start_window_background", + "value": "#FFFFFF" + } + ] +} \ No newline at end of file diff --git a/sample/EnhanceSampleArk1.2/StateManagement/entry/src/ohosTest/resources/base/element/string.json b/sample/EnhanceSampleArk1.2/StateManagement/entry/src/ohosTest/resources/base/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..a3b065b6a553a123630af910336a33e493e23edd --- /dev/null +++ b/sample/EnhanceSampleArk1.2/StateManagement/entry/src/ohosTest/resources/base/element/string.json @@ -0,0 +1,64 @@ +{ + "string": [ + { + "name": "module_test_desc", + "value": "test ability description" + }, + { + "name": "TestAbility_desc", + "value": "the test ability" + }, + { + "name": "TestAbility_label", + "value": "test label" + }, + { + "name": "base_type", + "value": "Based type" + }, + { + "name": "array_type", + "value": "Array type" + }, + { + "name": "class_type", + "value": "Class Object type" + }, + { + "name": "only_update_bound_components", + "value": "Only the components to which you are bound are updated" + }, + { + "name": "single_and_two_way_sync", + "value": "Single and two-way synchronization" + }, + { + "name": "partial_sync", + "value": "The child component synchronizes parts of the parent component" + }, + { + "name": "parent_descendent_sync", + "value": "State synchronization between parent and descendent" + }, + { + "name": "select_colorblue", + "value": "Blue" + }, + { + "name": "select_colorpink", + "value": "Pink" + }, + { + "name": "brother_sync", + "value": "State synchronization between brother components" + }, + { + "name": "application_storage_ui", + "value": "State synchronization between the app storage and the UI" + }, + { + "name": "ability_storage_ui", + "value": "State synchronization between the ability storage and the UI" + } + ] +} \ No newline at end of file diff --git a/sample/EnhanceSampleArk1.2/StateManagement/entry/src/ohosTest/resources/base/media/icon.png b/sample/EnhanceSampleArk1.2/StateManagement/entry/src/ohosTest/resources/base/media/icon.png new file mode 100644 index 0000000000000000000000000000000000000000..ce307a8827bd75456441ceb57d530e4c8d45d36c Binary files /dev/null and b/sample/EnhanceSampleArk1.2/StateManagement/entry/src/ohosTest/resources/base/media/icon.png differ diff --git a/sample/EnhanceSampleArk1.2/StateManagement/entry/src/ohosTest/resources/base/profile/test_pages.json b/sample/EnhanceSampleArk1.2/StateManagement/entry/src/ohosTest/resources/base/profile/test_pages.json new file mode 100644 index 0000000000000000000000000000000000000000..b7e7343cacb32ce982a45e76daad86e435e054fe --- /dev/null +++ b/sample/EnhanceSampleArk1.2/StateManagement/entry/src/ohosTest/resources/base/profile/test_pages.json @@ -0,0 +1,5 @@ +{ + "src": [ + "testability/pages/Index" + ] +} diff --git a/sample/EnhanceSampleArk1.2/StateManagement/entry/src/ohosTest/resources/en/element/string.json b/sample/EnhanceSampleArk1.2/StateManagement/entry/src/ohosTest/resources/en/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..080202320b75b61edf4dcaa9dd2ae14b0115132b --- /dev/null +++ b/sample/EnhanceSampleArk1.2/StateManagement/entry/src/ohosTest/resources/en/element/string.json @@ -0,0 +1,60 @@ +{ + "string": [ + { + "name": "back", + "value": "back" + }, + { + "name": "test_add", + "value": "test_add" + }, + { + "name": "base_type", + "value": "Based type" + }, + { + "name": "array_type", + "value": "Array type" + }, + { + "name": "class_type", + "value": "Class Object type" + }, + { + "name": "only_update_bound_components", + "value": "Only the components to which you are bound are updated" + }, + { + "name": "single_and_two_way_sync", + "value": "Single and two-way synchronization" + }, + { + "name": "partial_sync", + "value": "The child component synchronizes parts of the parent component" + }, + { + "name": "parent_descendent_sync", + "value": "State synchronization between parent and descendent" + }, + { + "name": "select_colorblue", + "value": "Blue" + }, + { + "name": "select_colorpink", + "value": "Pink" + }, + { + "name": "brother_sync", + "value": "State synchronization between brother components" + }, + { + "name": "application_storage_ui", + "value": "State synchronization between the app storage and the UI" + }, + { + "name": "ability_storage_ui", + "value": "State synchronization between the ability storage and the UI" + } + ] +} \ No newline at end of file diff --git a/sample/EnhanceSampleArk1.2/StateManagement/entry/src/ohosTest/resources/zh/element/string.json b/sample/EnhanceSampleArk1.2/StateManagement/entry/src/ohosTest/resources/zh/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..623d31d549e3de148e4c91661747c7cbf87f40c1 --- /dev/null +++ b/sample/EnhanceSampleArk1.2/StateManagement/entry/src/ohosTest/resources/zh/element/string.json @@ -0,0 +1,60 @@ +{ + "string": [ + { + "name": "back", + "value": "返回" + }, + { + "name": "test_add", + "value": "test_add" + }, + { + "name": "base_type", + "value": "基础类型" + }, + { + "name": "array_type", + "value": "数组类型" + }, + { + "name": "class_type", + "value": "类对象类型" + }, + { + "name": "only_update_bound_components", + "value": "只更新所绑定的组件" + }, + { + "name": "single_and_two_way_sync", + "value": "单、双向同步" + }, + { + "name": "partial_sync", + "value": "子组件同步父组件部分内容" + }, + { + "name": "parent_descendent_sync", + "value": "爷孙组件之间状态同步" + }, + { + "name": "select_colorblue", + "value": "蓝色" + }, + { + "name": "select_colorpink", + "value": "粉色" + }, + { + "name": "brother_sync", + "value": "兄弟组件之间状态同步" + }, + { + "name": "application_storage_ui", + "value": "应用内全局数据与UI之间的状态同步" + }, + { + "name": "ability_storage_ui", + "value": "Ability内全局数据与UI之间的状态同步" + } + ] +} \ No newline at end of file diff --git a/sample/EnhanceSampleArk1.2/StateManagement/hvigor/hvigor-config.json5 b/sample/EnhanceSampleArk1.2/StateManagement/hvigor/hvigor-config.json5 new file mode 100644 index 0000000000000000000000000000000000000000..835122515a93cc9181bd1fe13e447674a53526cb --- /dev/null +++ b/sample/EnhanceSampleArk1.2/StateManagement/hvigor/hvigor-config.json5 @@ -0,0 +1,21 @@ +/* + * Copyright (c) 2023 Huawei Device 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. + */ + +{ + "hvigorVersion": "2.0.0", + "dependencies": { + "@ohos/hvigor-ohos-plugin": "2.0.0" + } +} diff --git a/sample/EnhanceSampleArk1.2/StateManagement/hvigor/hvigor-wrapper.js b/sample/EnhanceSampleArk1.2/StateManagement/hvigor/hvigor-wrapper.js new file mode 100644 index 0000000000000000000000000000000000000000..994f22987bd0739b9faa07c966b066c2d9218602 --- /dev/null +++ b/sample/EnhanceSampleArk1.2/StateManagement/hvigor/hvigor-wrapper.js @@ -0,0 +1,2 @@ +"use strict";var e=require("fs"),t=require("path"),n=require("os"),r=require("crypto"),u=require("child_process"),o=require("constants"),i=require("stream"),s=require("util"),c=require("assert"),a=require("tty"),l=require("zlib"),f=require("net");function d(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var D=d(e),p=d(t),E=d(n),m=d(r),h=d(u),y=d(o),C=d(i),F=d(s),g=d(c),A=d(a),v=d(l),S=d(f),w="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},O={},b={},_={},B=w&&w.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(_,"__esModule",{value:!0}),_.isMac=_.isLinux=_.isWindows=void 0;const P=B(E.default),k="Windows_NT",x="Linux",N="Darwin";_.isWindows=function(){return P.default.type()===k},_.isLinux=function(){return P.default.type()===x},_.isMac=function(){return P.default.type()===N};var I={},T=w&&w.__createBinding||(Object.create?function(e,t,n,r){void 0===r&&(r=n);var u=Object.getOwnPropertyDescriptor(t,n);u&&!("get"in u?!t.__esModule:u.writable||u.configurable)||(u={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,r,u)}:function(e,t,n,r){void 0===r&&(r=n),e[r]=t[n]}),R=w&&w.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),M=w&&w.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var n in e)"default"!==n&&Object.prototype.hasOwnProperty.call(e,n)&&T(t,e,n);return R(t,e),t};Object.defineProperty(I,"__esModule",{value:!0}),I.hash=void 0;const L=M(m.default);I.hash=function(e,t="md5"){return L.createHash(t).update(e,"utf-8").digest("hex")},function(e){var t=w&&w.__createBinding||(Object.create?function(e,t,n,r){void 0===r&&(r=n);var u=Object.getOwnPropertyDescriptor(t,n);u&&!("get"in u?!t.__esModule:u.writable||u.configurable)||(u={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,r,u)}:function(e,t,n,r){void 0===r&&(r=n),e[r]=t[n]}),n=w&&w.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),r=w&&w.__importStar||function(e){if(e&&e.__esModule)return e;var r={};if(null!=e)for(var u in e)"default"!==u&&Object.prototype.hasOwnProperty.call(e,u)&&t(r,e,u);return n(r,e),r};Object.defineProperty(e,"__esModule",{value:!0}),e.HVIGOR_BOOT_JS_FILE_PATH=e.HVIGOR_PROJECT_DEPENDENCY_PACKAGE_JSON_PATH=e.HVIGOR_PROJECT_DEPENDENCIES_HOME=e.HVIGOR_PROJECT_WRAPPER_HOME=e.HVIGOR_PROJECT_NAME=e.HVIGOR_PROJECT_ROOT_DIR=e.HVIGOR_PROJECT_CACHES_HOME=e.HVIGOR_PNPM_STORE_PATH=e.HVIGOR_WRAPPER_PNPM_SCRIPT_PATH=e.HVIGOR_WRAPPER_TOOLS_HOME=e.HVIGOR_USER_HOME=e.DEFAULT_PACKAGE_JSON=e.DEFAULT_HVIGOR_CONFIG_JSON_FILE_NAME=e.PNPM=e.HVIGOR=e.NPM_TOOL=e.PNPM_TOOL=e.HVIGOR_ENGINE_PACKAGE_NAME=void 0;const u=r(p.default),o=r(E.default),i=_,s=I;e.HVIGOR_ENGINE_PACKAGE_NAME="@ohos/hvigor",e.PNPM_TOOL=(0,i.isWindows)()?"pnpm.cmd":"pnpm",e.NPM_TOOL=(0,i.isWindows)()?"npm.cmd":"npm",e.HVIGOR="hvigor",e.PNPM="pnpm",e.DEFAULT_HVIGOR_CONFIG_JSON_FILE_NAME="hvigor-config.json5",e.DEFAULT_PACKAGE_JSON="package.json",e.HVIGOR_USER_HOME=u.resolve(o.homedir(),".hvigor"),e.HVIGOR_WRAPPER_TOOLS_HOME=u.resolve(e.HVIGOR_USER_HOME,"wrapper","tools"),e.HVIGOR_WRAPPER_PNPM_SCRIPT_PATH=u.resolve(e.HVIGOR_WRAPPER_TOOLS_HOME,"node_modules",".bin",e.PNPM_TOOL),e.HVIGOR_PNPM_STORE_PATH=u.resolve(e.HVIGOR_USER_HOME,"caches"),e.HVIGOR_PROJECT_CACHES_HOME=u.resolve(e.HVIGOR_USER_HOME,"project_caches"),e.HVIGOR_PROJECT_ROOT_DIR=process.cwd(),e.HVIGOR_PROJECT_NAME=u.basename((0,s.hash)(e.HVIGOR_PROJECT_ROOT_DIR)),e.HVIGOR_PROJECT_WRAPPER_HOME=u.resolve(e.HVIGOR_PROJECT_ROOT_DIR,e.HVIGOR),e.HVIGOR_PROJECT_DEPENDENCIES_HOME=u.resolve(e.HVIGOR_PROJECT_CACHES_HOME,e.HVIGOR_PROJECT_NAME,"workspace"),e.HVIGOR_PROJECT_DEPENDENCY_PACKAGE_JSON_PATH=u.resolve(e.HVIGOR_PROJECT_DEPENDENCIES_HOME,e.DEFAULT_PACKAGE_JSON),e.HVIGOR_BOOT_JS_FILE_PATH=u.resolve(e.HVIGOR_PROJECT_DEPENDENCIES_HOME,"node_modules","@ohos","hvigor","bin","hvigor.js")}(b);var j={},$={};Object.defineProperty($,"__esModule",{value:!0}),$.logInfoPrintConsole=$.logErrorAndExit=void 0,$.logErrorAndExit=function(e){e instanceof Error?console.error(e.message):console.error(e),process.exit(-1)},$.logInfoPrintConsole=function(e){console.log(e)};var H=w&&w.__createBinding||(Object.create?function(e,t,n,r){void 0===r&&(r=n);var u=Object.getOwnPropertyDescriptor(t,n);u&&!("get"in u?!t.__esModule:u.writable||u.configurable)||(u={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,r,u)}:function(e,t,n,r){void 0===r&&(r=n),e[r]=t[n]}),J=w&&w.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),G=w&&w.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var n in e)"default"!==n&&Object.prototype.hasOwnProperty.call(e,n)&&H(t,e,n);return J(t,e),t},V=w&&w.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(j,"__esModule",{value:!0}),j.isFileExists=j.offlinePluginConversion=j.executeCommand=j.getNpmPath=j.hasNpmPackInPaths=void 0;const U=h.default,W=G(p.default),z=b,K=$,q=V(D.default);j.hasNpmPackInPaths=function(e,t){try{return require.resolve(e,{paths:[...t]}),!0}catch(e){return!1}},j.getNpmPath=function(){const e=process.execPath;return W.join(W.dirname(e),z.NPM_TOOL)},j.executeCommand=function(e,t,n){0!==(0,U.spawnSync)(e,t,n).status&&(0,K.logErrorAndExit)(`Error: ${e} ${t} execute failed.See above for details.`)},j.offlinePluginConversion=function(e,t){return t.startsWith("file:")||t.endsWith(".tgz")?W.resolve(e,z.HVIGOR,t.replace("file:","")):t},j.isFileExists=function(e){return q.default.existsSync(e)&&q.default.statSync(e).isFile()},function(e){var t=w&&w.__createBinding||(Object.create?function(e,t,n,r){void 0===r&&(r=n);var u=Object.getOwnPropertyDescriptor(t,n);u&&!("get"in u?!t.__esModule:u.writable||u.configurable)||(u={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,r,u)}:function(e,t,n,r){void 0===r&&(r=n),e[r]=t[n]}),n=w&&w.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),r=w&&w.__importStar||function(e){if(e&&e.__esModule)return e;var r={};if(null!=e)for(var u in e)"default"!==u&&Object.prototype.hasOwnProperty.call(e,u)&&t(r,e,u);return n(r,e),r},u=w&&w.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(e,"__esModule",{value:!0}),e.executeInstallPnpm=e.isPnpmAvailable=e.environmentHandler=e.checkNpmConifg=e.PNPM_VERSION=void 0;const o=r(D.default),i=b,s=j,c=r(p.default),a=$,l=h.default,f=u(E.default);e.PNPM_VERSION="7.30.0",e.checkNpmConifg=function(){const e=c.resolve(i.HVIGOR_PROJECT_ROOT_DIR,".npmrc"),t=c.resolve(f.default.homedir(),".npmrc");if((0,s.isFileExists)(e)||(0,s.isFileExists)(t))return;const n=(0,s.getNpmPath)(),r=(0,l.spawnSync)(n,["config","get","prefix"],{cwd:i.HVIGOR_PROJECT_ROOT_DIR});if(0!==r.status||!r.stdout)return void(0,a.logErrorAndExit)("Error: The hvigor depends on the npmrc file. Configure the npmrc file first.");const u=c.resolve(`${r.stdout}`.replace(/[\r\n]/gi,""),".npmrc");(0,s.isFileExists)(u)||(0,a.logErrorAndExit)("Error: The hvigor depends on the npmrc file. Configure the npmrc file first.")},e.environmentHandler=function(){process.env["npm_config_update-notifier"]="false"},e.isPnpmAvailable=function(){return!!o.existsSync(i.HVIGOR_WRAPPER_PNPM_SCRIPT_PATH)&&(0,s.hasNpmPackInPaths)("pnpm",[i.HVIGOR_WRAPPER_TOOLS_HOME])},e.executeInstallPnpm=function(){(0,a.logInfoPrintConsole)(`Installing pnpm@${e.PNPM_VERSION}...`);const t=(0,s.getNpmPath)();!function(){const t=c.resolve(i.HVIGOR_WRAPPER_TOOLS_HOME,i.DEFAULT_PACKAGE_JSON);try{o.existsSync(i.HVIGOR_WRAPPER_TOOLS_HOME)||o.mkdirSync(i.HVIGOR_WRAPPER_TOOLS_HOME,{recursive:!0});const n={dependencies:{}};n.dependencies[i.PNPM]=e.PNPM_VERSION,o.writeFileSync(t,JSON.stringify(n))}catch(e){(0,a.logErrorAndExit)(`Error: EPERM: operation not permitted,create ${t} failed.`)}}(),(0,s.executeCommand)(t,["install","pnpm"],{cwd:i.HVIGOR_WRAPPER_TOOLS_HOME,stdio:["inherit","inherit","inherit"],env:process.env}),(0,a.logInfoPrintConsole)("Pnpm install success.")}}(O);var Y={},X={},Z={},Q={};Object.defineProperty(Q,"__esModule",{value:!0}),Q.Unicode=void 0;class ee{}Q.Unicode=ee,ee.Space_Separator=/[\u1680\u2000-\u200A\u202F\u205F\u3000]/,ee.ID_Start=/[\xAA\xB5\xBA\xC0-\xD6\xD8-\xF6\xF8-\u02C1\u02C6-\u02D1\u02E0-\u02E4\u02EC\u02EE\u0370-\u0374\u0376\u0377\u037A-\u037D\u037F\u0386\u0388-\u038A\u038C\u038E-\u03A1\u03A3-\u03F5\u03F7-\u0481\u048A-\u052F\u0531-\u0556\u0559\u0561-\u0587\u05D0-\u05EA\u05F0-\u05F2\u0620-\u064A\u066E\u066F\u0671-\u06D3\u06D5\u06E5\u06E6\u06EE\u06EF\u06FA-\u06FC\u06FF\u0710\u0712-\u072F\u074D-\u07A5\u07B1\u07CA-\u07EA\u07F4\u07F5\u07FA\u0800-\u0815\u081A\u0824\u0828\u0840-\u0858\u0860-\u086A\u08A0-\u08B4\u08B6-\u08BD\u0904-\u0939\u093D\u0950\u0958-\u0961\u0971-\u0980\u0985-\u098C\u098F\u0990\u0993-\u09A8\u09AA-\u09B0\u09B2\u09B6-\u09B9\u09BD\u09CE\u09DC\u09DD\u09DF-\u09E1\u09F0\u09F1\u09FC\u0A05-\u0A0A\u0A0F\u0A10\u0A13-\u0A28\u0A2A-\u0A30\u0A32\u0A33\u0A35\u0A36\u0A38\u0A39\u0A59-\u0A5C\u0A5E\u0A72-\u0A74\u0A85-\u0A8D\u0A8F-\u0A91\u0A93-\u0AA8\u0AAA-\u0AB0\u0AB2\u0AB3\u0AB5-\u0AB9\u0ABD\u0AD0\u0AE0\u0AE1\u0AF9\u0B05-\u0B0C\u0B0F\u0B10\u0B13-\u0B28\u0B2A-\u0B30\u0B32\u0B33\u0B35-\u0B39\u0B3D\u0B5C\u0B5D\u0B5F-\u0B61\u0B71\u0B83\u0B85-\u0B8A\u0B8E-\u0B90\u0B92-\u0B95\u0B99\u0B9A\u0B9C\u0B9E\u0B9F\u0BA3\u0BA4\u0BA8-\u0BAA\u0BAE-\u0BB9\u0BD0\u0C05-\u0C0C\u0C0E-\u0C10\u0C12-\u0C28\u0C2A-\u0C39\u0C3D\u0C58-\u0C5A\u0C60\u0C61\u0C80\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8\u0CAA-\u0CB3\u0CB5-\u0CB9\u0CBD\u0CDE\u0CE0\u0CE1\u0CF1\u0CF2\u0D05-\u0D0C\u0D0E-\u0D10\u0D12-\u0D3A\u0D3D\u0D4E\u0D54-\u0D56\u0D5F-\u0D61\u0D7A-\u0D7F\u0D85-\u0D96\u0D9A-\u0DB1\u0DB3-\u0DBB\u0DBD\u0DC0-\u0DC6\u0E01-\u0E30\u0E32\u0E33\u0E40-\u0E46\u0E81\u0E82\u0E84\u0E87\u0E88\u0E8A\u0E8D\u0E94-\u0E97\u0E99-\u0E9F\u0EA1-\u0EA3\u0EA5\u0EA7\u0EAA\u0EAB\u0EAD-\u0EB0\u0EB2\u0EB3\u0EBD\u0EC0-\u0EC4\u0EC6\u0EDC-\u0EDF\u0F00\u0F40-\u0F47\u0F49-\u0F6C\u0F88-\u0F8C\u1000-\u102A\u103F\u1050-\u1055\u105A-\u105D\u1061\u1065\u1066\u106E-\u1070\u1075-\u1081\u108E\u10A0-\u10C5\u10C7\u10CD\u10D0-\u10FA\u10FC-\u1248\u124A-\u124D\u1250-\u1256\u1258\u125A-\u125D\u1260-\u1288\u128A-\u128D\u1290-\u12B0\u12B2-\u12B5\u12B8-\u12BE\u12C0\u12C2-\u12C5\u12C8-\u12D6\u12D8-\u1310\u1312-\u1315\u1318-\u135A\u1380-\u138F\u13A0-\u13F5\u13F8-\u13FD\u1401-\u166C\u166F-\u167F\u1681-\u169A\u16A0-\u16EA\u16EE-\u16F8\u1700-\u170C\u170E-\u1711\u1720-\u1731\u1740-\u1751\u1760-\u176C\u176E-\u1770\u1780-\u17B3\u17D7\u17DC\u1820-\u1877\u1880-\u1884\u1887-\u18A8\u18AA\u18B0-\u18F5\u1900-\u191E\u1950-\u196D\u1970-\u1974\u1980-\u19AB\u19B0-\u19C9\u1A00-\u1A16\u1A20-\u1A54\u1AA7\u1B05-\u1B33\u1B45-\u1B4B\u1B83-\u1BA0\u1BAE\u1BAF\u1BBA-\u1BE5\u1C00-\u1C23\u1C4D-\u1C4F\u1C5A-\u1C7D\u1C80-\u1C88\u1CE9-\u1CEC\u1CEE-\u1CF1\u1CF5\u1CF6\u1D00-\u1DBF\u1E00-\u1F15\u1F18-\u1F1D\u1F20-\u1F45\u1F48-\u1F4D\u1F50-\u1F57\u1F59\u1F5B\u1F5D\u1F5F-\u1F7D\u1F80-\u1FB4\u1FB6-\u1FBC\u1FBE\u1FC2-\u1FC4\u1FC6-\u1FCC\u1FD0-\u1FD3\u1FD6-\u1FDB\u1FE0-\u1FEC\u1FF2-\u1FF4\u1FF6-\u1FFC\u2071\u207F\u2090-\u209C\u2102\u2107\u210A-\u2113\u2115\u2119-\u211D\u2124\u2126\u2128\u212A-\u212D\u212F-\u2139\u213C-\u213F\u2145-\u2149\u214E\u2160-\u2188\u2C00-\u2C2E\u2C30-\u2C5E\u2C60-\u2CE4\u2CEB-\u2CEE\u2CF2\u2CF3\u2D00-\u2D25\u2D27\u2D2D\u2D30-\u2D67\u2D6F\u2D80-\u2D96\u2DA0-\u2DA6\u2DA8-\u2DAE\u2DB0-\u2DB6\u2DB8-\u2DBE\u2DC0-\u2DC6\u2DC8-\u2DCE\u2DD0-\u2DD6\u2DD8-\u2DDE\u2E2F\u3005-\u3007\u3021-\u3029\u3031-\u3035\u3038-\u303C\u3041-\u3096\u309D-\u309F\u30A1-\u30FA\u30FC-\u30FF\u3105-\u312E\u3131-\u318E\u31A0-\u31BA\u31F0-\u31FF\u3400-\u4DB5\u4E00-\u9FEA\uA000-\uA48C\uA4D0-\uA4FD\uA500-\uA60C\uA610-\uA61F\uA62A\uA62B\uA640-\uA66E\uA67F-\uA69D\uA6A0-\uA6EF\uA717-\uA71F\uA722-\uA788\uA78B-\uA7AE\uA7B0-\uA7B7\uA7F7-\uA801\uA803-\uA805\uA807-\uA80A\uA80C-\uA822\uA840-\uA873\uA882-\uA8B3\uA8F2-\uA8F7\uA8FB\uA8FD\uA90A-\uA925\uA930-\uA946\uA960-\uA97C\uA984-\uA9B2\uA9CF\uA9E0-\uA9E4\uA9E6-\uA9EF\uA9FA-\uA9FE\uAA00-\uAA28\uAA40-\uAA42\uAA44-\uAA4B\uAA60-\uAA76\uAA7A\uAA7E-\uAAAF\uAAB1\uAAB5\uAAB6\uAAB9-\uAABD\uAAC0\uAAC2\uAADB-\uAADD\uAAE0-\uAAEA\uAAF2-\uAAF4\uAB01-\uAB06\uAB09-\uAB0E\uAB11-\uAB16\uAB20-\uAB26\uAB28-\uAB2E\uAB30-\uAB5A\uAB5C-\uAB65\uAB70-\uABE2\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFA6D\uFA70-\uFAD9\uFB00-\uFB06\uFB13-\uFB17\uFB1D\uFB1F-\uFB28\uFB2A-\uFB36\uFB38-\uFB3C\uFB3E\uFB40\uFB41\uFB43\uFB44\uFB46-\uFBB1\uFBD3-\uFD3D\uFD50-\uFD8F\uFD92-\uFDC7\uFDF0-\uFDFB\uFE70-\uFE74\uFE76-\uFEFC\uFF21-\uFF3A\uFF41-\uFF5A\uFF66-\uFFBE\uFFC2-\uFFC7\uFFCA-\uFFCF\uFFD2-\uFFD7\uFFDA-\uFFDC]|\uD800[\uDC00-\uDC0B\uDC0D-\uDC26\uDC28-\uDC3A\uDC3C\uDC3D\uDC3F-\uDC4D\uDC50-\uDC5D\uDC80-\uDCFA\uDD40-\uDD74\uDE80-\uDE9C\uDEA0-\uDED0\uDF00-\uDF1F\uDF2D-\uDF4A\uDF50-\uDF75\uDF80-\uDF9D\uDFA0-\uDFC3\uDFC8-\uDFCF\uDFD1-\uDFD5]|\uD801[\uDC00-\uDC9D\uDCB0-\uDCD3\uDCD8-\uDCFB\uDD00-\uDD27\uDD30-\uDD63\uDE00-\uDF36\uDF40-\uDF55\uDF60-\uDF67]|\uD802[\uDC00-\uDC05\uDC08\uDC0A-\uDC35\uDC37\uDC38\uDC3C\uDC3F-\uDC55\uDC60-\uDC76\uDC80-\uDC9E\uDCE0-\uDCF2\uDCF4\uDCF5\uDD00-\uDD15\uDD20-\uDD39\uDD80-\uDDB7\uDDBE\uDDBF\uDE00\uDE10-\uDE13\uDE15-\uDE17\uDE19-\uDE33\uDE60-\uDE7C\uDE80-\uDE9C\uDEC0-\uDEC7\uDEC9-\uDEE4\uDF00-\uDF35\uDF40-\uDF55\uDF60-\uDF72\uDF80-\uDF91]|\uD803[\uDC00-\uDC48\uDC80-\uDCB2\uDCC0-\uDCF2]|\uD804[\uDC03-\uDC37\uDC83-\uDCAF\uDCD0-\uDCE8\uDD03-\uDD26\uDD50-\uDD72\uDD76\uDD83-\uDDB2\uDDC1-\uDDC4\uDDDA\uDDDC\uDE00-\uDE11\uDE13-\uDE2B\uDE80-\uDE86\uDE88\uDE8A-\uDE8D\uDE8F-\uDE9D\uDE9F-\uDEA8\uDEB0-\uDEDE\uDF05-\uDF0C\uDF0F\uDF10\uDF13-\uDF28\uDF2A-\uDF30\uDF32\uDF33\uDF35-\uDF39\uDF3D\uDF50\uDF5D-\uDF61]|\uD805[\uDC00-\uDC34\uDC47-\uDC4A\uDC80-\uDCAF\uDCC4\uDCC5\uDCC7\uDD80-\uDDAE\uDDD8-\uDDDB\uDE00-\uDE2F\uDE44\uDE80-\uDEAA\uDF00-\uDF19]|\uD806[\uDCA0-\uDCDF\uDCFF\uDE00\uDE0B-\uDE32\uDE3A\uDE50\uDE5C-\uDE83\uDE86-\uDE89\uDEC0-\uDEF8]|\uD807[\uDC00-\uDC08\uDC0A-\uDC2E\uDC40\uDC72-\uDC8F\uDD00-\uDD06\uDD08\uDD09\uDD0B-\uDD30\uDD46]|\uD808[\uDC00-\uDF99]|\uD809[\uDC00-\uDC6E\uDC80-\uDD43]|[\uD80C\uD81C-\uD820\uD840-\uD868\uD86A-\uD86C\uD86F-\uD872\uD874-\uD879][\uDC00-\uDFFF]|\uD80D[\uDC00-\uDC2E]|\uD811[\uDC00-\uDE46]|\uD81A[\uDC00-\uDE38\uDE40-\uDE5E\uDED0-\uDEED\uDF00-\uDF2F\uDF40-\uDF43\uDF63-\uDF77\uDF7D-\uDF8F]|\uD81B[\uDF00-\uDF44\uDF50\uDF93-\uDF9F\uDFE0\uDFE1]|\uD821[\uDC00-\uDFEC]|\uD822[\uDC00-\uDEF2]|\uD82C[\uDC00-\uDD1E\uDD70-\uDEFB]|\uD82F[\uDC00-\uDC6A\uDC70-\uDC7C\uDC80-\uDC88\uDC90-\uDC99]|\uD835[\uDC00-\uDC54\uDC56-\uDC9C\uDC9E\uDC9F\uDCA2\uDCA5\uDCA6\uDCA9-\uDCAC\uDCAE-\uDCB9\uDCBB\uDCBD-\uDCC3\uDCC5-\uDD05\uDD07-\uDD0A\uDD0D-\uDD14\uDD16-\uDD1C\uDD1E-\uDD39\uDD3B-\uDD3E\uDD40-\uDD44\uDD46\uDD4A-\uDD50\uDD52-\uDEA5\uDEA8-\uDEC0\uDEC2-\uDEDA\uDEDC-\uDEFA\uDEFC-\uDF14\uDF16-\uDF34\uDF36-\uDF4E\uDF50-\uDF6E\uDF70-\uDF88\uDF8A-\uDFA8\uDFAA-\uDFC2\uDFC4-\uDFCB]|\uD83A[\uDC00-\uDCC4\uDD00-\uDD43]|\uD83B[\uDE00-\uDE03\uDE05-\uDE1F\uDE21\uDE22\uDE24\uDE27\uDE29-\uDE32\uDE34-\uDE37\uDE39\uDE3B\uDE42\uDE47\uDE49\uDE4B\uDE4D-\uDE4F\uDE51\uDE52\uDE54\uDE57\uDE59\uDE5B\uDE5D\uDE5F\uDE61\uDE62\uDE64\uDE67-\uDE6A\uDE6C-\uDE72\uDE74-\uDE77\uDE79-\uDE7C\uDE7E\uDE80-\uDE89\uDE8B-\uDE9B\uDEA1-\uDEA3\uDEA5-\uDEA9\uDEAB-\uDEBB]|\uD869[\uDC00-\uDED6\uDF00-\uDFFF]|\uD86D[\uDC00-\uDF34\uDF40-\uDFFF]|\uD86E[\uDC00-\uDC1D\uDC20-\uDFFF]|\uD873[\uDC00-\uDEA1\uDEB0-\uDFFF]|\uD87A[\uDC00-\uDFE0]|\uD87E[\uDC00-\uDE1D]/,ee.ID_Continue=/[\xAA\xB5\xBA\xC0-\xD6\xD8-\xF6\xF8-\u02C1\u02C6-\u02D1\u02E0-\u02E4\u02EC\u02EE\u0300-\u0374\u0376\u0377\u037A-\u037D\u037F\u0386\u0388-\u038A\u038C\u038E-\u03A1\u03A3-\u03F5\u03F7-\u0481\u0483-\u0487\u048A-\u052F\u0531-\u0556\u0559\u0561-\u0587\u0591-\u05BD\u05BF\u05C1\u05C2\u05C4\u05C5\u05C7\u05D0-\u05EA\u05F0-\u05F2\u0610-\u061A\u0620-\u0669\u066E-\u06D3\u06D5-\u06DC\u06DF-\u06E8\u06EA-\u06FC\u06FF\u0710-\u074A\u074D-\u07B1\u07C0-\u07F5\u07FA\u0800-\u082D\u0840-\u085B\u0860-\u086A\u08A0-\u08B4\u08B6-\u08BD\u08D4-\u08E1\u08E3-\u0963\u0966-\u096F\u0971-\u0983\u0985-\u098C\u098F\u0990\u0993-\u09A8\u09AA-\u09B0\u09B2\u09B6-\u09B9\u09BC-\u09C4\u09C7\u09C8\u09CB-\u09CE\u09D7\u09DC\u09DD\u09DF-\u09E3\u09E6-\u09F1\u09FC\u0A01-\u0A03\u0A05-\u0A0A\u0A0F\u0A10\u0A13-\u0A28\u0A2A-\u0A30\u0A32\u0A33\u0A35\u0A36\u0A38\u0A39\u0A3C\u0A3E-\u0A42\u0A47\u0A48\u0A4B-\u0A4D\u0A51\u0A59-\u0A5C\u0A5E\u0A66-\u0A75\u0A81-\u0A83\u0A85-\u0A8D\u0A8F-\u0A91\u0A93-\u0AA8\u0AAA-\u0AB0\u0AB2\u0AB3\u0AB5-\u0AB9\u0ABC-\u0AC5\u0AC7-\u0AC9\u0ACB-\u0ACD\u0AD0\u0AE0-\u0AE3\u0AE6-\u0AEF\u0AF9-\u0AFF\u0B01-\u0B03\u0B05-\u0B0C\u0B0F\u0B10\u0B13-\u0B28\u0B2A-\u0B30\u0B32\u0B33\u0B35-\u0B39\u0B3C-\u0B44\u0B47\u0B48\u0B4B-\u0B4D\u0B56\u0B57\u0B5C\u0B5D\u0B5F-\u0B63\u0B66-\u0B6F\u0B71\u0B82\u0B83\u0B85-\u0B8A\u0B8E-\u0B90\u0B92-\u0B95\u0B99\u0B9A\u0B9C\u0B9E\u0B9F\u0BA3\u0BA4\u0BA8-\u0BAA\u0BAE-\u0BB9\u0BBE-\u0BC2\u0BC6-\u0BC8\u0BCA-\u0BCD\u0BD0\u0BD7\u0BE6-\u0BEF\u0C00-\u0C03\u0C05-\u0C0C\u0C0E-\u0C10\u0C12-\u0C28\u0C2A-\u0C39\u0C3D-\u0C44\u0C46-\u0C48\u0C4A-\u0C4D\u0C55\u0C56\u0C58-\u0C5A\u0C60-\u0C63\u0C66-\u0C6F\u0C80-\u0C83\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8\u0CAA-\u0CB3\u0CB5-\u0CB9\u0CBC-\u0CC4\u0CC6-\u0CC8\u0CCA-\u0CCD\u0CD5\u0CD6\u0CDE\u0CE0-\u0CE3\u0CE6-\u0CEF\u0CF1\u0CF2\u0D00-\u0D03\u0D05-\u0D0C\u0D0E-\u0D10\u0D12-\u0D44\u0D46-\u0D48\u0D4A-\u0D4E\u0D54-\u0D57\u0D5F-\u0D63\u0D66-\u0D6F\u0D7A-\u0D7F\u0D82\u0D83\u0D85-\u0D96\u0D9A-\u0DB1\u0DB3-\u0DBB\u0DBD\u0DC0-\u0DC6\u0DCA\u0DCF-\u0DD4\u0DD6\u0DD8-\u0DDF\u0DE6-\u0DEF\u0DF2\u0DF3\u0E01-\u0E3A\u0E40-\u0E4E\u0E50-\u0E59\u0E81\u0E82\u0E84\u0E87\u0E88\u0E8A\u0E8D\u0E94-\u0E97\u0E99-\u0E9F\u0EA1-\u0EA3\u0EA5\u0EA7\u0EAA\u0EAB\u0EAD-\u0EB9\u0EBB-\u0EBD\u0EC0-\u0EC4\u0EC6\u0EC8-\u0ECD\u0ED0-\u0ED9\u0EDC-\u0EDF\u0F00\u0F18\u0F19\u0F20-\u0F29\u0F35\u0F37\u0F39\u0F3E-\u0F47\u0F49-\u0F6C\u0F71-\u0F84\u0F86-\u0F97\u0F99-\u0FBC\u0FC6\u1000-\u1049\u1050-\u109D\u10A0-\u10C5\u10C7\u10CD\u10D0-\u10FA\u10FC-\u1248\u124A-\u124D\u1250-\u1256\u1258\u125A-\u125D\u1260-\u1288\u128A-\u128D\u1290-\u12B0\u12B2-\u12B5\u12B8-\u12BE\u12C0\u12C2-\u12C5\u12C8-\u12D6\u12D8-\u1310\u1312-\u1315\u1318-\u135A\u135D-\u135F\u1380-\u138F\u13A0-\u13F5\u13F8-\u13FD\u1401-\u166C\u166F-\u167F\u1681-\u169A\u16A0-\u16EA\u16EE-\u16F8\u1700-\u170C\u170E-\u1714\u1720-\u1734\u1740-\u1753\u1760-\u176C\u176E-\u1770\u1772\u1773\u1780-\u17D3\u17D7\u17DC\u17DD\u17E0-\u17E9\u180B-\u180D\u1810-\u1819\u1820-\u1877\u1880-\u18AA\u18B0-\u18F5\u1900-\u191E\u1920-\u192B\u1930-\u193B\u1946-\u196D\u1970-\u1974\u1980-\u19AB\u19B0-\u19C9\u19D0-\u19D9\u1A00-\u1A1B\u1A20-\u1A5E\u1A60-\u1A7C\u1A7F-\u1A89\u1A90-\u1A99\u1AA7\u1AB0-\u1ABD\u1B00-\u1B4B\u1B50-\u1B59\u1B6B-\u1B73\u1B80-\u1BF3\u1C00-\u1C37\u1C40-\u1C49\u1C4D-\u1C7D\u1C80-\u1C88\u1CD0-\u1CD2\u1CD4-\u1CF9\u1D00-\u1DF9\u1DFB-\u1F15\u1F18-\u1F1D\u1F20-\u1F45\u1F48-\u1F4D\u1F50-\u1F57\u1F59\u1F5B\u1F5D\u1F5F-\u1F7D\u1F80-\u1FB4\u1FB6-\u1FBC\u1FBE\u1FC2-\u1FC4\u1FC6-\u1FCC\u1FD0-\u1FD3\u1FD6-\u1FDB\u1FE0-\u1FEC\u1FF2-\u1FF4\u1FF6-\u1FFC\u203F\u2040\u2054\u2071\u207F\u2090-\u209C\u20D0-\u20DC\u20E1\u20E5-\u20F0\u2102\u2107\u210A-\u2113\u2115\u2119-\u211D\u2124\u2126\u2128\u212A-\u212D\u212F-\u2139\u213C-\u213F\u2145-\u2149\u214E\u2160-\u2188\u2C00-\u2C2E\u2C30-\u2C5E\u2C60-\u2CE4\u2CEB-\u2CF3\u2D00-\u2D25\u2D27\u2D2D\u2D30-\u2D67\u2D6F\u2D7F-\u2D96\u2DA0-\u2DA6\u2DA8-\u2DAE\u2DB0-\u2DB6\u2DB8-\u2DBE\u2DC0-\u2DC6\u2DC8-\u2DCE\u2DD0-\u2DD6\u2DD8-\u2DDE\u2DE0-\u2DFF\u2E2F\u3005-\u3007\u3021-\u302F\u3031-\u3035\u3038-\u303C\u3041-\u3096\u3099\u309A\u309D-\u309F\u30A1-\u30FA\u30FC-\u30FF\u3105-\u312E\u3131-\u318E\u31A0-\u31BA\u31F0-\u31FF\u3400-\u4DB5\u4E00-\u9FEA\uA000-\uA48C\uA4D0-\uA4FD\uA500-\uA60C\uA610-\uA62B\uA640-\uA66F\uA674-\uA67D\uA67F-\uA6F1\uA717-\uA71F\uA722-\uA788\uA78B-\uA7AE\uA7B0-\uA7B7\uA7F7-\uA827\uA840-\uA873\uA880-\uA8C5\uA8D0-\uA8D9\uA8E0-\uA8F7\uA8FB\uA8FD\uA900-\uA92D\uA930-\uA953\uA960-\uA97C\uA980-\uA9C0\uA9CF-\uA9D9\uA9E0-\uA9FE\uAA00-\uAA36\uAA40-\uAA4D\uAA50-\uAA59\uAA60-\uAA76\uAA7A-\uAAC2\uAADB-\uAADD\uAAE0-\uAAEF\uAAF2-\uAAF6\uAB01-\uAB06\uAB09-\uAB0E\uAB11-\uAB16\uAB20-\uAB26\uAB28-\uAB2E\uAB30-\uAB5A\uAB5C-\uAB65\uAB70-\uABEA\uABEC\uABED\uABF0-\uABF9\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFA6D\uFA70-\uFAD9\uFB00-\uFB06\uFB13-\uFB17\uFB1D-\uFB28\uFB2A-\uFB36\uFB38-\uFB3C\uFB3E\uFB40\uFB41\uFB43\uFB44\uFB46-\uFBB1\uFBD3-\uFD3D\uFD50-\uFD8F\uFD92-\uFDC7\uFDF0-\uFDFB\uFE00-\uFE0F\uFE20-\uFE2F\uFE33\uFE34\uFE4D-\uFE4F\uFE70-\uFE74\uFE76-\uFEFC\uFF10-\uFF19\uFF21-\uFF3A\uFF3F\uFF41-\uFF5A\uFF66-\uFFBE\uFFC2-\uFFC7\uFFCA-\uFFCF\uFFD2-\uFFD7\uFFDA-\uFFDC]|\uD800[\uDC00-\uDC0B\uDC0D-\uDC26\uDC28-\uDC3A\uDC3C\uDC3D\uDC3F-\uDC4D\uDC50-\uDC5D\uDC80-\uDCFA\uDD40-\uDD74\uDDFD\uDE80-\uDE9C\uDEA0-\uDED0\uDEE0\uDF00-\uDF1F\uDF2D-\uDF4A\uDF50-\uDF7A\uDF80-\uDF9D\uDFA0-\uDFC3\uDFC8-\uDFCF\uDFD1-\uDFD5]|\uD801[\uDC00-\uDC9D\uDCA0-\uDCA9\uDCB0-\uDCD3\uDCD8-\uDCFB\uDD00-\uDD27\uDD30-\uDD63\uDE00-\uDF36\uDF40-\uDF55\uDF60-\uDF67]|\uD802[\uDC00-\uDC05\uDC08\uDC0A-\uDC35\uDC37\uDC38\uDC3C\uDC3F-\uDC55\uDC60-\uDC76\uDC80-\uDC9E\uDCE0-\uDCF2\uDCF4\uDCF5\uDD00-\uDD15\uDD20-\uDD39\uDD80-\uDDB7\uDDBE\uDDBF\uDE00-\uDE03\uDE05\uDE06\uDE0C-\uDE13\uDE15-\uDE17\uDE19-\uDE33\uDE38-\uDE3A\uDE3F\uDE60-\uDE7C\uDE80-\uDE9C\uDEC0-\uDEC7\uDEC9-\uDEE6\uDF00-\uDF35\uDF40-\uDF55\uDF60-\uDF72\uDF80-\uDF91]|\uD803[\uDC00-\uDC48\uDC80-\uDCB2\uDCC0-\uDCF2]|\uD804[\uDC00-\uDC46\uDC66-\uDC6F\uDC7F-\uDCBA\uDCD0-\uDCE8\uDCF0-\uDCF9\uDD00-\uDD34\uDD36-\uDD3F\uDD50-\uDD73\uDD76\uDD80-\uDDC4\uDDCA-\uDDCC\uDDD0-\uDDDA\uDDDC\uDE00-\uDE11\uDE13-\uDE37\uDE3E\uDE80-\uDE86\uDE88\uDE8A-\uDE8D\uDE8F-\uDE9D\uDE9F-\uDEA8\uDEB0-\uDEEA\uDEF0-\uDEF9\uDF00-\uDF03\uDF05-\uDF0C\uDF0F\uDF10\uDF13-\uDF28\uDF2A-\uDF30\uDF32\uDF33\uDF35-\uDF39\uDF3C-\uDF44\uDF47\uDF48\uDF4B-\uDF4D\uDF50\uDF57\uDF5D-\uDF63\uDF66-\uDF6C\uDF70-\uDF74]|\uD805[\uDC00-\uDC4A\uDC50-\uDC59\uDC80-\uDCC5\uDCC7\uDCD0-\uDCD9\uDD80-\uDDB5\uDDB8-\uDDC0\uDDD8-\uDDDD\uDE00-\uDE40\uDE44\uDE50-\uDE59\uDE80-\uDEB7\uDEC0-\uDEC9\uDF00-\uDF19\uDF1D-\uDF2B\uDF30-\uDF39]|\uD806[\uDCA0-\uDCE9\uDCFF\uDE00-\uDE3E\uDE47\uDE50-\uDE83\uDE86-\uDE99\uDEC0-\uDEF8]|\uD807[\uDC00-\uDC08\uDC0A-\uDC36\uDC38-\uDC40\uDC50-\uDC59\uDC72-\uDC8F\uDC92-\uDCA7\uDCA9-\uDCB6\uDD00-\uDD06\uDD08\uDD09\uDD0B-\uDD36\uDD3A\uDD3C\uDD3D\uDD3F-\uDD47\uDD50-\uDD59]|\uD808[\uDC00-\uDF99]|\uD809[\uDC00-\uDC6E\uDC80-\uDD43]|[\uD80C\uD81C-\uD820\uD840-\uD868\uD86A-\uD86C\uD86F-\uD872\uD874-\uD879][\uDC00-\uDFFF]|\uD80D[\uDC00-\uDC2E]|\uD811[\uDC00-\uDE46]|\uD81A[\uDC00-\uDE38\uDE40-\uDE5E\uDE60-\uDE69\uDED0-\uDEED\uDEF0-\uDEF4\uDF00-\uDF36\uDF40-\uDF43\uDF50-\uDF59\uDF63-\uDF77\uDF7D-\uDF8F]|\uD81B[\uDF00-\uDF44\uDF50-\uDF7E\uDF8F-\uDF9F\uDFE0\uDFE1]|\uD821[\uDC00-\uDFEC]|\uD822[\uDC00-\uDEF2]|\uD82C[\uDC00-\uDD1E\uDD70-\uDEFB]|\uD82F[\uDC00-\uDC6A\uDC70-\uDC7C\uDC80-\uDC88\uDC90-\uDC99\uDC9D\uDC9E]|\uD834[\uDD65-\uDD69\uDD6D-\uDD72\uDD7B-\uDD82\uDD85-\uDD8B\uDDAA-\uDDAD\uDE42-\uDE44]|\uD835[\uDC00-\uDC54\uDC56-\uDC9C\uDC9E\uDC9F\uDCA2\uDCA5\uDCA6\uDCA9-\uDCAC\uDCAE-\uDCB9\uDCBB\uDCBD-\uDCC3\uDCC5-\uDD05\uDD07-\uDD0A\uDD0D-\uDD14\uDD16-\uDD1C\uDD1E-\uDD39\uDD3B-\uDD3E\uDD40-\uDD44\uDD46\uDD4A-\uDD50\uDD52-\uDEA5\uDEA8-\uDEC0\uDEC2-\uDEDA\uDEDC-\uDEFA\uDEFC-\uDF14\uDF16-\uDF34\uDF36-\uDF4E\uDF50-\uDF6E\uDF70-\uDF88\uDF8A-\uDFA8\uDFAA-\uDFC2\uDFC4-\uDFCB\uDFCE-\uDFFF]|\uD836[\uDE00-\uDE36\uDE3B-\uDE6C\uDE75\uDE84\uDE9B-\uDE9F\uDEA1-\uDEAF]|\uD838[\uDC00-\uDC06\uDC08-\uDC18\uDC1B-\uDC21\uDC23\uDC24\uDC26-\uDC2A]|\uD83A[\uDC00-\uDCC4\uDCD0-\uDCD6\uDD00-\uDD4A\uDD50-\uDD59]|\uD83B[\uDE00-\uDE03\uDE05-\uDE1F\uDE21\uDE22\uDE24\uDE27\uDE29-\uDE32\uDE34-\uDE37\uDE39\uDE3B\uDE42\uDE47\uDE49\uDE4B\uDE4D-\uDE4F\uDE51\uDE52\uDE54\uDE57\uDE59\uDE5B\uDE5D\uDE5F\uDE61\uDE62\uDE64\uDE67-\uDE6A\uDE6C-\uDE72\uDE74-\uDE77\uDE79-\uDE7C\uDE7E\uDE80-\uDE89\uDE8B-\uDE9B\uDEA1-\uDEA3\uDEA5-\uDEA9\uDEAB-\uDEBB]|\uD869[\uDC00-\uDED6\uDF00-\uDFFF]|\uD86D[\uDC00-\uDF34\uDF40-\uDFFF]|\uD86E[\uDC00-\uDC1D\uDC20-\uDFFF]|\uD873[\uDC00-\uDEA1\uDEB0-\uDFFF]|\uD87A[\uDC00-\uDFE0]|\uD87E[\uDC00-\uDE1D]|\uDB40[\uDD00-\uDDEF]/,Object.defineProperty(Z,"__esModule",{value:!0}),Z.JudgeUtil=void 0;const te=Q;Z.JudgeUtil=class{static isIgnoreChar(e){return"string"==typeof e&&("\t"===e||"\v"===e||"\f"===e||" "===e||" "===e||"\ufeff"===e||"\n"===e||"\r"===e||"\u2028"===e||"\u2029"===e)}static isSpaceSeparator(e){return"string"==typeof e&&te.Unicode.Space_Separator.test(e)}static isIdStartChar(e){return"string"==typeof e&&(e>="a"&&e<="z"||e>="A"&&e<="Z"||"$"===e||"_"===e||te.Unicode.ID_Start.test(e))}static isIdContinueChar(e){return"string"==typeof e&&(e>="a"&&e<="z"||e>="A"&&e<="Z"||e>="0"&&e<="9"||"$"===e||"_"===e||"‌"===e||"‍"===e||te.Unicode.ID_Continue.test(e))}static isDigitWithoutZero(e){return/[1-9]/.test(e)}static isDigit(e){return"string"==typeof e&&/[0-9]/.test(e)}static isHexDigit(e){return"string"==typeof e&&/[0-9A-Fa-f]/.test(e)}};var ne={},re={fromCallback:function(e){return Object.defineProperty((function(...t){if("function"!=typeof t[t.length-1])return new Promise(((n,r)=>{e.call(this,...t,((e,t)=>null!=e?r(e):n(t)))}));e.apply(this,t)}),"name",{value:e.name})},fromPromise:function(e){return Object.defineProperty((function(...t){const n=t[t.length-1];if("function"!=typeof n)return e.apply(this,t);e.apply(this,t.slice(0,-1)).then((e=>n(null,e)),n)}),"name",{value:e.name})}},ue=y.default,oe=process.cwd,ie=null,se=process.env.GRACEFUL_FS_PLATFORM||process.platform;process.cwd=function(){return ie||(ie=oe.call(process)),ie};try{process.cwd()}catch(e){}if("function"==typeof process.chdir){var ce=process.chdir;process.chdir=function(e){ie=null,ce.call(process,e)},Object.setPrototypeOf&&Object.setPrototypeOf(process.chdir,ce)}var ae=function(e){ue.hasOwnProperty("O_SYMLINK")&&process.version.match(/^v0\.6\.[0-2]|^v0\.5\./)&&function(e){e.lchmod=function(t,n,r){e.open(t,ue.O_WRONLY|ue.O_SYMLINK,n,(function(t,u){t?r&&r(t):e.fchmod(u,n,(function(t){e.close(u,(function(e){r&&r(t||e)}))}))}))},e.lchmodSync=function(t,n){var r,u=e.openSync(t,ue.O_WRONLY|ue.O_SYMLINK,n),o=!0;try{r=e.fchmodSync(u,n),o=!1}finally{if(o)try{e.closeSync(u)}catch(e){}else e.closeSync(u)}return r}}(e);e.lutimes||function(e){ue.hasOwnProperty("O_SYMLINK")&&e.futimes?(e.lutimes=function(t,n,r,u){e.open(t,ue.O_SYMLINK,(function(t,o){t?u&&u(t):e.futimes(o,n,r,(function(t){e.close(o,(function(e){u&&u(t||e)}))}))}))},e.lutimesSync=function(t,n,r){var u,o=e.openSync(t,ue.O_SYMLINK),i=!0;try{u=e.futimesSync(o,n,r),i=!1}finally{if(i)try{e.closeSync(o)}catch(e){}else e.closeSync(o)}return u}):e.futimes&&(e.lutimes=function(e,t,n,r){r&&process.nextTick(r)},e.lutimesSync=function(){})}(e);e.chown=r(e.chown),e.fchown=r(e.fchown),e.lchown=r(e.lchown),e.chmod=t(e.chmod),e.fchmod=t(e.fchmod),e.lchmod=t(e.lchmod),e.chownSync=u(e.chownSync),e.fchownSync=u(e.fchownSync),e.lchownSync=u(e.lchownSync),e.chmodSync=n(e.chmodSync),e.fchmodSync=n(e.fchmodSync),e.lchmodSync=n(e.lchmodSync),e.stat=o(e.stat),e.fstat=o(e.fstat),e.lstat=o(e.lstat),e.statSync=i(e.statSync),e.fstatSync=i(e.fstatSync),e.lstatSync=i(e.lstatSync),e.chmod&&!e.lchmod&&(e.lchmod=function(e,t,n){n&&process.nextTick(n)},e.lchmodSync=function(){});e.chown&&!e.lchown&&(e.lchown=function(e,t,n,r){r&&process.nextTick(r)},e.lchownSync=function(){});"win32"===se&&(e.rename="function"!=typeof e.rename?e.rename:function(t){function n(n,r,u){var o=Date.now(),i=0;t(n,r,(function s(c){if(c&&("EACCES"===c.code||"EPERM"===c.code||"EBUSY"===c.code)&&Date.now()-o<6e4)return setTimeout((function(){e.stat(r,(function(e,o){e&&"ENOENT"===e.code?t(n,r,s):u(c)}))}),i),void(i<100&&(i+=10));u&&u(c)}))}return Object.setPrototypeOf&&Object.setPrototypeOf(n,t),n}(e.rename));function t(t){return t?function(n,r,u){return t.call(e,n,r,(function(e){s(e)&&(e=null),u&&u.apply(this,arguments)}))}:t}function n(t){return t?function(n,r){try{return t.call(e,n,r)}catch(e){if(!s(e))throw e}}:t}function r(t){return t?function(n,r,u,o){return t.call(e,n,r,u,(function(e){s(e)&&(e=null),o&&o.apply(this,arguments)}))}:t}function u(t){return t?function(n,r,u){try{return t.call(e,n,r,u)}catch(e){if(!s(e))throw e}}:t}function o(t){return t?function(n,r,u){function o(e,t){t&&(t.uid<0&&(t.uid+=4294967296),t.gid<0&&(t.gid+=4294967296)),u&&u.apply(this,arguments)}return"function"==typeof r&&(u=r,r=null),r?t.call(e,n,r,o):t.call(e,n,o)}:t}function i(t){return t?function(n,r){var u=r?t.call(e,n,r):t.call(e,n);return u&&(u.uid<0&&(u.uid+=4294967296),u.gid<0&&(u.gid+=4294967296)),u}:t}function s(e){return!e||("ENOSYS"===e.code||!(process.getuid&&0===process.getuid()||"EINVAL"!==e.code&&"EPERM"!==e.code))}e.read="function"!=typeof e.read?e.read:function(t){function n(n,r,u,o,i,s){var c;if(s&&"function"==typeof s){var a=0;c=function(l,f,d){if(l&&"EAGAIN"===l.code&&a<10)return a++,t.call(e,n,r,u,o,i,c);s.apply(this,arguments)}}return t.call(e,n,r,u,o,i,c)}return Object.setPrototypeOf&&Object.setPrototypeOf(n,t),n}(e.read),e.readSync="function"!=typeof e.readSync?e.readSync:(c=e.readSync,function(t,n,r,u,o){for(var i=0;;)try{return c.call(e,t,n,r,u,o)}catch(e){if("EAGAIN"===e.code&&i<10){i++;continue}throw e}});var c};var le=C.default.Stream,fe=function(e){return{ReadStream:function t(n,r){if(!(this instanceof t))return new t(n,r);le.call(this);var u=this;this.path=n,this.fd=null,this.readable=!0,this.paused=!1,this.flags="r",this.mode=438,this.bufferSize=65536,r=r||{};for(var o=Object.keys(r),i=0,s=o.length;ithis.end)throw new Error("start must be <= end");this.pos=this.start}if(null!==this.fd)return void process.nextTick((function(){u._read()}));e.open(this.path,this.flags,this.mode,(function(e,t){if(e)return u.emit("error",e),void(u.readable=!1);u.fd=t,u.emit("open",t),u._read()}))},WriteStream:function t(n,r){if(!(this instanceof t))return new t(n,r);le.call(this),this.path=n,this.fd=null,this.writable=!0,this.flags="w",this.encoding="binary",this.mode=438,this.bytesWritten=0,r=r||{};for(var u=Object.keys(r),o=0,i=u.length;o= zero");this.pos=this.start}this.busy=!1,this._queue=[],null===this.fd&&(this._open=e.open,this._queue.push([this._open,this.path,this.flags,this.mode,void 0]),this.flush())}}};var de=function(e){if(null===e||"object"!=typeof e)return e;if(e instanceof Object)var t={__proto__:De(e)};else t=Object.create(null);return Object.getOwnPropertyNames(e).forEach((function(n){Object.defineProperty(t,n,Object.getOwnPropertyDescriptor(e,n))})),t},De=Object.getPrototypeOf||function(e){return e.__proto__};var pe,Ee,me=D.default,he=ae,ye=fe,Ce=de,Fe=F.default;function ge(e,t){Object.defineProperty(e,pe,{get:function(){return t}})}"function"==typeof Symbol&&"function"==typeof Symbol.for?(pe=Symbol.for("graceful-fs.queue"),Ee=Symbol.for("graceful-fs.previous")):(pe="___graceful-fs.queue",Ee="___graceful-fs.previous");var Ae=function(){};if(Fe.debuglog?Ae=Fe.debuglog("gfs4"):/\bgfs4\b/i.test(process.env.NODE_DEBUG||"")&&(Ae=function(){var e=Fe.format.apply(Fe,arguments);e="GFS4: "+e.split(/\n/).join("\nGFS4: "),console.error(e)}),!me[pe]){var ve=w[pe]||[];ge(me,ve),me.close=function(e){function t(t,n){return e.call(me,t,(function(e){e||_e(),"function"==typeof n&&n.apply(this,arguments)}))}return Object.defineProperty(t,Ee,{value:e}),t}(me.close),me.closeSync=function(e){function t(t){e.apply(me,arguments),_e()}return Object.defineProperty(t,Ee,{value:e}),t}(me.closeSync),/\bgfs4\b/i.test(process.env.NODE_DEBUG||"")&&process.on("exit",(function(){Ae(me[pe]),g.default.equal(me[pe].length,0)}))}w[pe]||ge(w,me[pe]);var Se,we=Oe(Ce(me));function Oe(e){he(e),e.gracefulify=Oe,e.createReadStream=function(t,n){return new e.ReadStream(t,n)},e.createWriteStream=function(t,n){return new e.WriteStream(t,n)};var t=e.readFile;e.readFile=function(e,n,r){"function"==typeof n&&(r=n,n=null);return function e(n,r,u,o){return t(n,r,(function(t){!t||"EMFILE"!==t.code&&"ENFILE"!==t.code?"function"==typeof u&&u.apply(this,arguments):be([e,[n,r,u],t,o||Date.now(),Date.now()])}))}(e,n,r)};var n=e.writeFile;e.writeFile=function(e,t,r,u){"function"==typeof r&&(u=r,r=null);return function e(t,r,u,o,i){return n(t,r,u,(function(n){!n||"EMFILE"!==n.code&&"ENFILE"!==n.code?"function"==typeof o&&o.apply(this,arguments):be([e,[t,r,u,o],n,i||Date.now(),Date.now()])}))}(e,t,r,u)};var r=e.appendFile;r&&(e.appendFile=function(e,t,n,u){"function"==typeof n&&(u=n,n=null);return function e(t,n,u,o,i){return r(t,n,u,(function(r){!r||"EMFILE"!==r.code&&"ENFILE"!==r.code?"function"==typeof o&&o.apply(this,arguments):be([e,[t,n,u,o],r,i||Date.now(),Date.now()])}))}(e,t,n,u)});var u=e.copyFile;u&&(e.copyFile=function(e,t,n,r){"function"==typeof n&&(r=n,n=0);return function e(t,n,r,o,i){return u(t,n,r,(function(u){!u||"EMFILE"!==u.code&&"ENFILE"!==u.code?"function"==typeof o&&o.apply(this,arguments):be([e,[t,n,r,o],u,i||Date.now(),Date.now()])}))}(e,t,n,r)});var o=e.readdir;e.readdir=function(e,t,n){"function"==typeof t&&(n=t,t=null);var r=i.test(process.version)?function(e,t,n,r){return o(e,u(e,t,n,r))}:function(e,t,n,r){return o(e,t,u(e,t,n,r))};return r(e,t,n);function u(e,t,n,u){return function(o,i){!o||"EMFILE"!==o.code&&"ENFILE"!==o.code?(i&&i.sort&&i.sort(),"function"==typeof n&&n.call(this,o,i)):be([r,[e,t,n],o,u||Date.now(),Date.now()])}}};var i=/^v[0-5]\./;if("v0.8"===process.version.substr(0,4)){var s=ye(e);d=s.ReadStream,D=s.WriteStream}var c=e.ReadStream;c&&(d.prototype=Object.create(c.prototype),d.prototype.open=function(){var e=this;E(e.path,e.flags,e.mode,(function(t,n){t?(e.autoClose&&e.destroy(),e.emit("error",t)):(e.fd=n,e.emit("open",n),e.read())}))});var a=e.WriteStream;a&&(D.prototype=Object.create(a.prototype),D.prototype.open=function(){var e=this;E(e.path,e.flags,e.mode,(function(t,n){t?(e.destroy(),e.emit("error",t)):(e.fd=n,e.emit("open",n))}))}),Object.defineProperty(e,"ReadStream",{get:function(){return d},set:function(e){d=e},enumerable:!0,configurable:!0}),Object.defineProperty(e,"WriteStream",{get:function(){return D},set:function(e){D=e},enumerable:!0,configurable:!0});var l=d;Object.defineProperty(e,"FileReadStream",{get:function(){return l},set:function(e){l=e},enumerable:!0,configurable:!0});var f=D;function d(e,t){return this instanceof d?(c.apply(this,arguments),this):d.apply(Object.create(d.prototype),arguments)}function D(e,t){return this instanceof D?(a.apply(this,arguments),this):D.apply(Object.create(D.prototype),arguments)}Object.defineProperty(e,"FileWriteStream",{get:function(){return f},set:function(e){f=e},enumerable:!0,configurable:!0});var p=e.open;function E(e,t,n,r){return"function"==typeof n&&(r=n,n=null),function e(t,n,r,u,o){return p(t,n,r,(function(i,s){!i||"EMFILE"!==i.code&&"ENFILE"!==i.code?"function"==typeof u&&u.apply(this,arguments):be([e,[t,n,r,u],i,o||Date.now(),Date.now()])}))}(e,t,n,r)}return e.open=E,e}function be(e){Ae("ENQUEUE",e[0].name,e[1]),me[pe].push(e),Be()}function _e(){for(var e=Date.now(),t=0;t2&&(me[pe][t][3]=e,me[pe][t][4]=e);Be()}function Be(){if(clearTimeout(Se),Se=void 0,0!==me[pe].length){var e=me[pe].shift(),t=e[0],n=e[1],r=e[2],u=e[3],o=e[4];if(void 0===u)Ae("RETRY",t.name,n),t.apply(null,n);else if(Date.now()-u>=6e4){Ae("TIMEOUT",t.name,n);var i=n.pop();"function"==typeof i&&i.call(null,r)}else{var s=Date.now()-o,c=Math.max(o-u,1);s>=Math.min(1.2*c,100)?(Ae("RETRY",t.name,n),t.apply(null,n.concat([u]))):me[pe].push(e)}void 0===Se&&(Se=setTimeout(Be,0))}}process.env.TEST_GRACEFUL_FS_GLOBAL_PATCH&&!me.__patched&&(we=Oe(me),me.__patched=!0),function(e){const t=re.fromCallback,n=we,r=["access","appendFile","chmod","chown","close","copyFile","fchmod","fchown","fdatasync","fstat","fsync","ftruncate","futimes","lchmod","lchown","link","lstat","mkdir","mkdtemp","open","opendir","readdir","readFile","readlink","realpath","rename","rm","rmdir","stat","symlink","truncate","unlink","utimes","writeFile"].filter((e=>"function"==typeof n[e]));Object.assign(e,n),r.forEach((r=>{e[r]=t(n[r])})),e.realpath.native=t(n.realpath.native),e.exists=function(e,t){return"function"==typeof t?n.exists(e,t):new Promise((t=>n.exists(e,t)))},e.read=function(e,t,r,u,o,i){return"function"==typeof i?n.read(e,t,r,u,o,i):new Promise(((i,s)=>{n.read(e,t,r,u,o,((e,t,n)=>{if(e)return s(e);i({bytesRead:t,buffer:n})}))}))},e.write=function(e,t,...r){return"function"==typeof r[r.length-1]?n.write(e,t,...r):new Promise(((u,o)=>{n.write(e,t,...r,((e,t,n)=>{if(e)return o(e);u({bytesWritten:t,buffer:n})}))}))},"function"==typeof n.writev&&(e.writev=function(e,t,...r){return"function"==typeof r[r.length-1]?n.writev(e,t,...r):new Promise(((u,o)=>{n.writev(e,t,...r,((e,t,n)=>{if(e)return o(e);u({bytesWritten:t,buffers:n})}))}))})}(ne);var Pe={},ke={};const xe=p.default;ke.checkPath=function(e){if("win32"===process.platform){if(/[<>:"|?*]/.test(e.replace(xe.parse(e).root,""))){const t=new Error(`Path contains invalid characters: ${e}`);throw t.code="EINVAL",t}}};const Ne=ne,{checkPath:Ie}=ke,Te=e=>"number"==typeof e?e:{mode:511,...e}.mode;Pe.makeDir=async(e,t)=>(Ie(e),Ne.mkdir(e,{mode:Te(t),recursive:!0})),Pe.makeDirSync=(e,t)=>(Ie(e),Ne.mkdirSync(e,{mode:Te(t),recursive:!0}));const Re=re.fromPromise,{makeDir:Me,makeDirSync:Le}=Pe,je=Re(Me);var $e={mkdirs:je,mkdirsSync:Le,mkdirp:je,mkdirpSync:Le,ensureDir:je,ensureDirSync:Le};const He=re.fromPromise,Je=ne;var Ge={pathExists:He((function(e){return Je.access(e).then((()=>!0)).catch((()=>!1))})),pathExistsSync:Je.existsSync};const Ve=we;var Ue=function(e,t,n,r){Ve.open(e,"r+",((e,u)=>{if(e)return r(e);Ve.futimes(u,t,n,(e=>{Ve.close(u,(t=>{r&&r(e||t)}))}))}))},We=function(e,t,n){const r=Ve.openSync(e,"r+");return Ve.futimesSync(r,t,n),Ve.closeSync(r)};const ze=ne,Ke=p.default,qe=F.default;function Ye(e,t,n){const r=n.dereference?e=>ze.stat(e,{bigint:!0}):e=>ze.lstat(e,{bigint:!0});return Promise.all([r(e),r(t).catch((e=>{if("ENOENT"===e.code)return null;throw e}))]).then((([e,t])=>({srcStat:e,destStat:t})))}function Xe(e,t){return t.ino&&t.dev&&t.ino===e.ino&&t.dev===e.dev}function Ze(e,t){const n=Ke.resolve(e).split(Ke.sep).filter((e=>e)),r=Ke.resolve(t).split(Ke.sep).filter((e=>e));return n.reduce(((e,t,n)=>e&&r[n]===t),!0)}function Qe(e,t,n){return`Cannot ${n} '${e}' to a subdirectory of itself, '${t}'.`}var et={checkPaths:function(e,t,n,r,u){qe.callbackify(Ye)(e,t,r,((r,o)=>{if(r)return u(r);const{srcStat:i,destStat:s}=o;if(s){if(Xe(i,s)){const r=Ke.basename(e),o=Ke.basename(t);return"move"===n&&r!==o&&r.toLowerCase()===o.toLowerCase()?u(null,{srcStat:i,destStat:s,isChangingCase:!0}):u(new Error("Source and destination must not be the same."))}if(i.isDirectory()&&!s.isDirectory())return u(new Error(`Cannot overwrite non-directory '${t}' with directory '${e}'.`));if(!i.isDirectory()&&s.isDirectory())return u(new Error(`Cannot overwrite directory '${t}' with non-directory '${e}'.`))}return i.isDirectory()&&Ze(e,t)?u(new Error(Qe(e,t,n))):u(null,{srcStat:i,destStat:s})}))},checkPathsSync:function(e,t,n,r){const{srcStat:u,destStat:o}=function(e,t,n){let r;const u=n.dereference?e=>ze.statSync(e,{bigint:!0}):e=>ze.lstatSync(e,{bigint:!0}),o=u(e);try{r=u(t)}catch(e){if("ENOENT"===e.code)return{srcStat:o,destStat:null};throw e}return{srcStat:o,destStat:r}}(e,t,r);if(o){if(Xe(u,o)){const r=Ke.basename(e),i=Ke.basename(t);if("move"===n&&r!==i&&r.toLowerCase()===i.toLowerCase())return{srcStat:u,destStat:o,isChangingCase:!0};throw new Error("Source and destination must not be the same.")}if(u.isDirectory()&&!o.isDirectory())throw new Error(`Cannot overwrite non-directory '${t}' with directory '${e}'.`);if(!u.isDirectory()&&o.isDirectory())throw new Error(`Cannot overwrite directory '${t}' with non-directory '${e}'.`)}if(u.isDirectory()&&Ze(e,t))throw new Error(Qe(e,t,n));return{srcStat:u,destStat:o}},checkParentPaths:function e(t,n,r,u,o){const i=Ke.resolve(Ke.dirname(t)),s=Ke.resolve(Ke.dirname(r));if(s===i||s===Ke.parse(s).root)return o();ze.stat(s,{bigint:!0},((i,c)=>i?"ENOENT"===i.code?o():o(i):Xe(n,c)?o(new Error(Qe(t,r,u))):e(t,n,s,u,o)))},checkParentPathsSync:function e(t,n,r,u){const o=Ke.resolve(Ke.dirname(t)),i=Ke.resolve(Ke.dirname(r));if(i===o||i===Ke.parse(i).root)return;let s;try{s=ze.statSync(i,{bigint:!0})}catch(e){if("ENOENT"===e.code)return;throw e}if(Xe(n,s))throw new Error(Qe(t,r,u));return e(t,n,i,u)},isSrcSubdir:Ze,areIdentical:Xe};const tt=we,nt=p.default,rt=$e.mkdirs,ut=Ge.pathExists,ot=Ue,it=et;function st(e,t,n,r,u){const o=nt.dirname(n);ut(o,((i,s)=>i?u(i):s?at(e,t,n,r,u):void rt(o,(o=>o?u(o):at(e,t,n,r,u)))))}function ct(e,t,n,r,u,o){Promise.resolve(u.filter(n,r)).then((i=>i?e(t,n,r,u,o):o()),(e=>o(e)))}function at(e,t,n,r,u){(r.dereference?tt.stat:tt.lstat)(t,((o,i)=>o?u(o):i.isDirectory()?function(e,t,n,r,u,o){return t?Dt(n,r,u,o):function(e,t,n,r,u){tt.mkdir(n,(o=>{if(o)return u(o);Dt(t,n,r,(t=>t?u(t):dt(n,e,u)))}))}(e.mode,n,r,u,o)}(i,e,t,n,r,u):i.isFile()||i.isCharacterDevice()||i.isBlockDevice()?function(e,t,n,r,u,o){return t?function(e,t,n,r,u){if(!r.overwrite)return r.errorOnExist?u(new Error(`'${n}' already exists`)):u();tt.unlink(n,(o=>o?u(o):lt(e,t,n,r,u)))}(e,n,r,u,o):lt(e,n,r,u,o)}(i,e,t,n,r,u):i.isSymbolicLink()?function(e,t,n,r,u){tt.readlink(t,((t,o)=>t?u(t):(r.dereference&&(o=nt.resolve(process.cwd(),o)),e?void tt.readlink(n,((t,i)=>t?"EINVAL"===t.code||"UNKNOWN"===t.code?tt.symlink(o,n,u):u(t):(r.dereference&&(i=nt.resolve(process.cwd(),i)),it.isSrcSubdir(o,i)?u(new Error(`Cannot copy '${o}' to a subdirectory of itself, '${i}'.`)):e.isDirectory()&&it.isSrcSubdir(i,o)?u(new Error(`Cannot overwrite '${i}' with '${o}'.`)):function(e,t,n){tt.unlink(t,(r=>r?n(r):tt.symlink(e,t,n)))}(o,n,u)))):tt.symlink(o,n,u))))}(e,t,n,r,u):i.isSocket()?u(new Error(`Cannot copy a socket file: ${t}`)):i.isFIFO()?u(new Error(`Cannot copy a FIFO pipe: ${t}`)):u(new Error(`Unknown file: ${t}`))))}function lt(e,t,n,r,u){tt.copyFile(t,n,(o=>o?u(o):r.preserveTimestamps?function(e,t,n,r){if(function(e){return 0==(128&e)}(e))return function(e,t,n){return dt(e,128|t,n)}(n,e,(u=>u?r(u):ft(e,t,n,r)));return ft(e,t,n,r)}(e.mode,t,n,u):dt(n,e.mode,u)))}function ft(e,t,n,r){!function(e,t,n){tt.stat(e,((e,r)=>e?n(e):ot(t,r.atime,r.mtime,n)))}(t,n,(t=>t?r(t):dt(n,e,r)))}function dt(e,t,n){return tt.chmod(e,t,n)}function Dt(e,t,n,r){tt.readdir(e,((u,o)=>u?r(u):pt(o,e,t,n,r)))}function pt(e,t,n,r,u){const o=e.pop();return o?function(e,t,n,r,u,o){const i=nt.join(n,t),s=nt.join(r,t);it.checkPaths(i,s,"copy",u,((t,c)=>{if(t)return o(t);const{destStat:a}=c;!function(e,t,n,r,u){r.filter?ct(at,e,t,n,r,u):at(e,t,n,r,u)}(a,i,s,u,(t=>t?o(t):pt(e,n,r,u,o)))}))}(e,o,t,n,r,u):u()}var Et=function(e,t,n,r){"function"!=typeof n||r?"function"==typeof n&&(n={filter:n}):(r=n,n={}),r=r||function(){},(n=n||{}).clobber=!("clobber"in n)||!!n.clobber,n.overwrite="overwrite"in n?!!n.overwrite:n.clobber,n.preserveTimestamps&&"ia32"===process.arch&&console.warn("fs-extra: Using the preserveTimestamps option in 32-bit node is not recommended;\n\n see https://github.com/jprichardson/node-fs-extra/issues/269"),it.checkPaths(e,t,"copy",n,((u,o)=>{if(u)return r(u);const{srcStat:i,destStat:s}=o;it.checkParentPaths(e,i,t,"copy",(u=>u?r(u):n.filter?ct(st,s,e,t,n,r):st(s,e,t,n,r)))}))};const mt=we,ht=p.default,yt=$e.mkdirsSync,Ct=We,Ft=et;function gt(e,t,n,r){const u=(r.dereference?mt.statSync:mt.lstatSync)(t);if(u.isDirectory())return function(e,t,n,r,u){return t?St(n,r,u):function(e,t,n,r){return mt.mkdirSync(n),St(t,n,r),vt(n,e)}(e.mode,n,r,u)}(u,e,t,n,r);if(u.isFile()||u.isCharacterDevice()||u.isBlockDevice())return function(e,t,n,r,u){return t?function(e,t,n,r){if(r.overwrite)return mt.unlinkSync(n),At(e,t,n,r);if(r.errorOnExist)throw new Error(`'${n}' already exists`)}(e,n,r,u):At(e,n,r,u)}(u,e,t,n,r);if(u.isSymbolicLink())return function(e,t,n,r){let u=mt.readlinkSync(t);r.dereference&&(u=ht.resolve(process.cwd(),u));if(e){let e;try{e=mt.readlinkSync(n)}catch(e){if("EINVAL"===e.code||"UNKNOWN"===e.code)return mt.symlinkSync(u,n);throw e}if(r.dereference&&(e=ht.resolve(process.cwd(),e)),Ft.isSrcSubdir(u,e))throw new Error(`Cannot copy '${u}' to a subdirectory of itself, '${e}'.`);if(mt.statSync(n).isDirectory()&&Ft.isSrcSubdir(e,u))throw new Error(`Cannot overwrite '${e}' with '${u}'.`);return function(e,t){return mt.unlinkSync(t),mt.symlinkSync(e,t)}(u,n)}return mt.symlinkSync(u,n)}(e,t,n,r);if(u.isSocket())throw new Error(`Cannot copy a socket file: ${t}`);if(u.isFIFO())throw new Error(`Cannot copy a FIFO pipe: ${t}`);throw new Error(`Unknown file: ${t}`)}function At(e,t,n,r){return mt.copyFileSync(t,n),r.preserveTimestamps&&function(e,t,n){(function(e){return 0==(128&e)})(e)&&function(e,t){vt(e,128|t)}(n,e);(function(e,t){const n=mt.statSync(e);Ct(t,n.atime,n.mtime)})(t,n)}(e.mode,t,n),vt(n,e.mode)}function vt(e,t){return mt.chmodSync(e,t)}function St(e,t,n){mt.readdirSync(e).forEach((r=>function(e,t,n,r){const u=ht.join(t,e),o=ht.join(n,e),{destStat:i}=Ft.checkPathsSync(u,o,"copy",r);return function(e,t,n,r){if(!r.filter||r.filter(t,n))return gt(e,t,n,r)}(i,u,o,r)}(r,e,t,n)))}var wt=function(e,t,n){"function"==typeof n&&(n={filter:n}),(n=n||{}).clobber=!("clobber"in n)||!!n.clobber,n.overwrite="overwrite"in n?!!n.overwrite:n.clobber,n.preserveTimestamps&&"ia32"===process.arch&&console.warn("fs-extra: Using the preserveTimestamps option in 32-bit node is not recommended;\n\n see https://github.com/jprichardson/node-fs-extra/issues/269");const{srcStat:r,destStat:u}=Ft.checkPathsSync(e,t,"copy",n);return Ft.checkParentPathsSync(e,r,t,"copy"),function(e,t,n,r){if(r.filter&&!r.filter(t,n))return;const u=ht.dirname(n);mt.existsSync(u)||yt(u);return gt(e,t,n,r)}(u,e,t,n)};var Ot={copy:(0,re.fromCallback)(Et),copySync:wt};const bt=we,_t=p.default,Bt=g.default,Pt="win32"===process.platform;function kt(e){["unlink","chmod","stat","lstat","rmdir","readdir"].forEach((t=>{e[t]=e[t]||bt[t],e[t+="Sync"]=e[t]||bt[t]})),e.maxBusyTries=e.maxBusyTries||3}function xt(e,t,n){let r=0;"function"==typeof t&&(n=t,t={}),Bt(e,"rimraf: missing path"),Bt.strictEqual(typeof e,"string","rimraf: path should be a string"),Bt.strictEqual(typeof n,"function","rimraf: callback function required"),Bt(t,"rimraf: invalid options argument provided"),Bt.strictEqual(typeof t,"object","rimraf: options should be object"),kt(t),Nt(e,t,(function u(o){if(o){if(("EBUSY"===o.code||"ENOTEMPTY"===o.code||"EPERM"===o.code)&&rNt(e,t,u)),100*r)}"ENOENT"===o.code&&(o=null)}n(o)}))}function Nt(e,t,n){Bt(e),Bt(t),Bt("function"==typeof n),t.lstat(e,((r,u)=>r&&"ENOENT"===r.code?n(null):r&&"EPERM"===r.code&&Pt?It(e,t,r,n):u&&u.isDirectory()?Rt(e,t,r,n):void t.unlink(e,(r=>{if(r){if("ENOENT"===r.code)return n(null);if("EPERM"===r.code)return Pt?It(e,t,r,n):Rt(e,t,r,n);if("EISDIR"===r.code)return Rt(e,t,r,n)}return n(r)}))))}function It(e,t,n,r){Bt(e),Bt(t),Bt("function"==typeof r),t.chmod(e,438,(u=>{u?r("ENOENT"===u.code?null:n):t.stat(e,((u,o)=>{u?r("ENOENT"===u.code?null:n):o.isDirectory()?Rt(e,t,n,r):t.unlink(e,r)}))}))}function Tt(e,t,n){let r;Bt(e),Bt(t);try{t.chmodSync(e,438)}catch(e){if("ENOENT"===e.code)return;throw n}try{r=t.statSync(e)}catch(e){if("ENOENT"===e.code)return;throw n}r.isDirectory()?Lt(e,t,n):t.unlinkSync(e)}function Rt(e,t,n,r){Bt(e),Bt(t),Bt("function"==typeof r),t.rmdir(e,(u=>{!u||"ENOTEMPTY"!==u.code&&"EEXIST"!==u.code&&"EPERM"!==u.code?u&&"ENOTDIR"===u.code?r(n):r(u):function(e,t,n){Bt(e),Bt(t),Bt("function"==typeof n),t.readdir(e,((r,u)=>{if(r)return n(r);let o,i=u.length;if(0===i)return t.rmdir(e,n);u.forEach((r=>{xt(_t.join(e,r),t,(r=>{if(!o)return r?n(o=r):void(0==--i&&t.rmdir(e,n))}))}))}))}(e,t,r)}))}function Mt(e,t){let n;kt(t=t||{}),Bt(e,"rimraf: missing path"),Bt.strictEqual(typeof e,"string","rimraf: path should be a string"),Bt(t,"rimraf: missing options"),Bt.strictEqual(typeof t,"object","rimraf: options should be object");try{n=t.lstatSync(e)}catch(n){if("ENOENT"===n.code)return;"EPERM"===n.code&&Pt&&Tt(e,t,n)}try{n&&n.isDirectory()?Lt(e,t,null):t.unlinkSync(e)}catch(n){if("ENOENT"===n.code)return;if("EPERM"===n.code)return Pt?Tt(e,t,n):Lt(e,t,n);if("EISDIR"!==n.code)throw n;Lt(e,t,n)}}function Lt(e,t,n){Bt(e),Bt(t);try{t.rmdirSync(e)}catch(r){if("ENOTDIR"===r.code)throw n;if("ENOTEMPTY"===r.code||"EEXIST"===r.code||"EPERM"===r.code)!function(e,t){if(Bt(e),Bt(t),t.readdirSync(e).forEach((n=>Mt(_t.join(e,n),t))),!Pt){return t.rmdirSync(e,t)}{const n=Date.now();do{try{return t.rmdirSync(e,t)}catch{}}while(Date.now()-n<500)}}(e,t);else if("ENOENT"!==r.code)throw r}}var jt=xt;xt.sync=Mt;const $t=we,Ht=re.fromCallback,Jt=jt;var Gt={remove:Ht((function(e,t){if($t.rm)return $t.rm(e,{recursive:!0,force:!0},t);Jt(e,t)})),removeSync:function(e){if($t.rmSync)return $t.rmSync(e,{recursive:!0,force:!0});Jt.sync(e)}};const Vt=re.fromPromise,Ut=ne,Wt=p.default,zt=$e,Kt=Gt,qt=Vt((async function(e){let t;try{t=await Ut.readdir(e)}catch{return zt.mkdirs(e)}return Promise.all(t.map((t=>Kt.remove(Wt.join(e,t)))))}));function Yt(e){let t;try{t=Ut.readdirSync(e)}catch{return zt.mkdirsSync(e)}t.forEach((t=>{t=Wt.join(e,t),Kt.removeSync(t)}))}var Xt={emptyDirSync:Yt,emptydirSync:Yt,emptyDir:qt,emptydir:qt};const Zt=re.fromCallback,Qt=p.default,en=we,tn=$e;var nn={createFile:Zt((function(e,t){function n(){en.writeFile(e,"",(e=>{if(e)return t(e);t()}))}en.stat(e,((r,u)=>{if(!r&&u.isFile())return t();const o=Qt.dirname(e);en.stat(o,((e,r)=>{if(e)return"ENOENT"===e.code?tn.mkdirs(o,(e=>{if(e)return t(e);n()})):t(e);r.isDirectory()?n():en.readdir(o,(e=>{if(e)return t(e)}))}))}))})),createFileSync:function(e){let t;try{t=en.statSync(e)}catch{}if(t&&t.isFile())return;const n=Qt.dirname(e);try{en.statSync(n).isDirectory()||en.readdirSync(n)}catch(e){if(!e||"ENOENT"!==e.code)throw e;tn.mkdirsSync(n)}en.writeFileSync(e,"")}};const rn=re.fromCallback,un=p.default,on=we,sn=$e,cn=Ge.pathExists,{areIdentical:an}=et;var ln={createLink:rn((function(e,t,n){function r(e,t){on.link(e,t,(e=>{if(e)return n(e);n(null)}))}on.lstat(t,((u,o)=>{on.lstat(e,((u,i)=>{if(u)return u.message=u.message.replace("lstat","ensureLink"),n(u);if(o&&an(i,o))return n(null);const s=un.dirname(t);cn(s,((u,o)=>u?n(u):o?r(e,t):void sn.mkdirs(s,(u=>{if(u)return n(u);r(e,t)}))))}))}))})),createLinkSync:function(e,t){let n;try{n=on.lstatSync(t)}catch{}try{const t=on.lstatSync(e);if(n&&an(t,n))return}catch(e){throw e.message=e.message.replace("lstat","ensureLink"),e}const r=un.dirname(t);return on.existsSync(r)||sn.mkdirsSync(r),on.linkSync(e,t)}};const fn=p.default,dn=we,Dn=Ge.pathExists;var pn={symlinkPaths:function(e,t,n){if(fn.isAbsolute(e))return dn.lstat(e,(t=>t?(t.message=t.message.replace("lstat","ensureSymlink"),n(t)):n(null,{toCwd:e,toDst:e})));{const r=fn.dirname(t),u=fn.join(r,e);return Dn(u,((t,o)=>t?n(t):o?n(null,{toCwd:u,toDst:e}):dn.lstat(e,(t=>t?(t.message=t.message.replace("lstat","ensureSymlink"),n(t)):n(null,{toCwd:e,toDst:fn.relative(r,e)})))))}},symlinkPathsSync:function(e,t){let n;if(fn.isAbsolute(e)){if(n=dn.existsSync(e),!n)throw new Error("absolute srcpath does not exist");return{toCwd:e,toDst:e}}{const r=fn.dirname(t),u=fn.join(r,e);if(n=dn.existsSync(u),n)return{toCwd:u,toDst:e};if(n=dn.existsSync(e),!n)throw new Error("relative srcpath does not exist");return{toCwd:e,toDst:fn.relative(r,e)}}}};const En=we;var mn={symlinkType:function(e,t,n){if(n="function"==typeof t?t:n,t="function"!=typeof t&&t)return n(null,t);En.lstat(e,((e,r)=>{if(e)return n(null,"file");t=r&&r.isDirectory()?"dir":"file",n(null,t)}))},symlinkTypeSync:function(e,t){let n;if(t)return t;try{n=En.lstatSync(e)}catch{return"file"}return n&&n.isDirectory()?"dir":"file"}};const hn=re.fromCallback,yn=p.default,Cn=ne,Fn=$e.mkdirs,gn=$e.mkdirsSync,An=pn.symlinkPaths,vn=pn.symlinkPathsSync,Sn=mn.symlinkType,wn=mn.symlinkTypeSync,On=Ge.pathExists,{areIdentical:bn}=et;function _n(e,t,n,r){An(e,t,((u,o)=>{if(u)return r(u);e=o.toDst,Sn(o.toCwd,n,((n,u)=>{if(n)return r(n);const o=yn.dirname(t);On(o,((n,i)=>n?r(n):i?Cn.symlink(e,t,u,r):void Fn(o,(n=>{if(n)return r(n);Cn.symlink(e,t,u,r)}))))}))}))}var Bn={createSymlink:hn((function(e,t,n,r){r="function"==typeof n?n:r,n="function"!=typeof n&&n,Cn.lstat(t,((u,o)=>{!u&&o.isSymbolicLink()?Promise.all([Cn.stat(e),Cn.stat(t)]).then((([u,o])=>{if(bn(u,o))return r(null);_n(e,t,n,r)})):_n(e,t,n,r)}))})),createSymlinkSync:function(e,t,n){let r;try{r=Cn.lstatSync(t)}catch{}if(r&&r.isSymbolicLink()){const n=Cn.statSync(e),r=Cn.statSync(t);if(bn(n,r))return}const u=vn(e,t);e=u.toDst,n=wn(u.toCwd,n);const o=yn.dirname(t);return Cn.existsSync(o)||gn(o),Cn.symlinkSync(e,t,n)}};const{createFile:Pn,createFileSync:kn}=nn,{createLink:xn,createLinkSync:Nn}=ln,{createSymlink:In,createSymlinkSync:Tn}=Bn;var Rn={createFile:Pn,createFileSync:kn,ensureFile:Pn,ensureFileSync:kn,createLink:xn,createLinkSync:Nn,ensureLink:xn,ensureLinkSync:Nn,createSymlink:In,createSymlinkSync:Tn,ensureSymlink:In,ensureSymlinkSync:Tn};var Mn={stringify:function(e,{EOL:t="\n",finalEOL:n=!0,replacer:r=null,spaces:u}={}){const o=n?t:"";return JSON.stringify(e,r,u).replace(/\n/g,t)+o},stripBom:function(e){return Buffer.isBuffer(e)&&(e=e.toString("utf8")),e.replace(/^\uFEFF/,"")}};let Ln;try{Ln=we}catch(e){Ln=D.default}const jn=re,{stringify:$n,stripBom:Hn}=Mn;const Jn=jn.fromPromise((async function(e,t={}){"string"==typeof t&&(t={encoding:t});const n=t.fs||Ln,r=!("throws"in t)||t.throws;let u,o=await jn.fromCallback(n.readFile)(e,t);o=Hn(o);try{u=JSON.parse(o,t?t.reviver:null)}catch(t){if(r)throw t.message=`${e}: ${t.message}`,t;return null}return u}));const Gn=jn.fromPromise((async function(e,t,n={}){const r=n.fs||Ln,u=$n(t,n);await jn.fromCallback(r.writeFile)(e,u,n)}));const Vn={readFile:Jn,readFileSync:function(e,t={}){"string"==typeof t&&(t={encoding:t});const n=t.fs||Ln,r=!("throws"in t)||t.throws;try{let r=n.readFileSync(e,t);return r=Hn(r),JSON.parse(r,t.reviver)}catch(t){if(r)throw t.message=`${e}: ${t.message}`,t;return null}},writeFile:Gn,writeFileSync:function(e,t,n={}){const r=n.fs||Ln,u=$n(t,n);return r.writeFileSync(e,u,n)}};var Un={readJson:Vn.readFile,readJsonSync:Vn.readFileSync,writeJson:Vn.writeFile,writeJsonSync:Vn.writeFileSync};const Wn=re.fromCallback,zn=we,Kn=p.default,qn=$e,Yn=Ge.pathExists;var Xn={outputFile:Wn((function(e,t,n,r){"function"==typeof n&&(r=n,n="utf8");const u=Kn.dirname(e);Yn(u,((o,i)=>o?r(o):i?zn.writeFile(e,t,n,r):void qn.mkdirs(u,(u=>{if(u)return r(u);zn.writeFile(e,t,n,r)}))))})),outputFileSync:function(e,...t){const n=Kn.dirname(e);if(zn.existsSync(n))return zn.writeFileSync(e,...t);qn.mkdirsSync(n),zn.writeFileSync(e,...t)}};const{stringify:Zn}=Mn,{outputFile:Qn}=Xn;var er=async function(e,t,n={}){const r=Zn(t,n);await Qn(e,r,n)};const{stringify:tr}=Mn,{outputFileSync:nr}=Xn;var rr=function(e,t,n){const r=tr(t,n);nr(e,r,n)};const ur=re.fromPromise,or=Un;or.outputJson=ur(er),or.outputJsonSync=rr,or.outputJSON=or.outputJson,or.outputJSONSync=or.outputJsonSync,or.writeJSON=or.writeJson,or.writeJSONSync=or.writeJsonSync,or.readJSON=or.readJson,or.readJSONSync=or.readJsonSync;var ir=or;const sr=we,cr=p.default,ar=Ot.copy,lr=Gt.remove,fr=$e.mkdirp,dr=Ge.pathExists,Dr=et;function pr(e,t,n,r,u){return r?Er(e,t,n,u):n?lr(t,(r=>r?u(r):Er(e,t,n,u))):void dr(t,((r,o)=>r?u(r):o?u(new Error("dest already exists.")):Er(e,t,n,u)))}function Er(e,t,n,r){sr.rename(e,t,(u=>u?"EXDEV"!==u.code?r(u):function(e,t,n,r){const u={overwrite:n,errorOnExist:!0};ar(e,t,u,(t=>t?r(t):lr(e,r)))}(e,t,n,r):r()))}var mr=function(e,t,n,r){"function"==typeof n&&(r=n,n={});const u=n.overwrite||n.clobber||!1;Dr.checkPaths(e,t,"move",n,((n,o)=>{if(n)return r(n);const{srcStat:i,isChangingCase:s=!1}=o;Dr.checkParentPaths(e,i,t,"move",(n=>n?r(n):function(e){const t=cr.dirname(e);return cr.parse(t).root===t}(t)?pr(e,t,u,s,r):void fr(cr.dirname(t),(n=>n?r(n):pr(e,t,u,s,r)))))}))};const hr=we,yr=p.default,Cr=Ot.copySync,Fr=Gt.removeSync,gr=$e.mkdirpSync,Ar=et;function vr(e,t,n){try{hr.renameSync(e,t)}catch(r){if("EXDEV"!==r.code)throw r;return function(e,t,n){const r={overwrite:n,errorOnExist:!0};return Cr(e,t,r),Fr(e)}(e,t,n)}}var Sr=function(e,t,n){const r=(n=n||{}).overwrite||n.clobber||!1,{srcStat:u,isChangingCase:o=!1}=Ar.checkPathsSync(e,t,"move",n);return Ar.checkParentPathsSync(e,u,t,"move"),function(e){const t=yr.dirname(e);return yr.parse(t).root===t}(t)||gr(yr.dirname(t)),function(e,t,n,r){if(r)return vr(e,t,n);if(n)return Fr(t),vr(e,t,n);if(hr.existsSync(t))throw new Error("dest already exists.");return vr(e,t,n)}(e,t,r,o)};var wr,Or,br,_r,Br,Pr={move:(0,re.fromCallback)(mr),moveSync:Sr},kr={...ne,...Ot,...Xt,...Rn,...ir,...$e,...Pr,...Xn,...Ge,...Gt},xr={},Nr={exports:{}},Ir={exports:{}};function Tr(){if(Or)return wr;Or=1;var e=1e3,t=60*e,n=60*t,r=24*n,u=7*r,o=365.25*r;function i(e,t,n,r){var u=t>=1.5*n;return Math.round(e/n)+" "+r+(u?"s":"")}return wr=function(s,c){c=c||{};var a=typeof s;if("string"===a&&s.length>0)return function(i){if((i=String(i)).length>100)return;var s=/^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(i);if(!s)return;var c=parseFloat(s[1]);switch((s[2]||"ms").toLowerCase()){case"years":case"year":case"yrs":case"yr":case"y":return c*o;case"weeks":case"week":case"w":return c*u;case"days":case"day":case"d":return c*r;case"hours":case"hour":case"hrs":case"hr":case"h":return c*n;case"minutes":case"minute":case"mins":case"min":case"m":return c*t;case"seconds":case"second":case"secs":case"sec":case"s":return c*e;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return c;default:return}}(s);if("number"===a&&isFinite(s))return c.long?function(u){var o=Math.abs(u);if(o>=r)return i(u,o,r,"day");if(o>=n)return i(u,o,n,"hour");if(o>=t)return i(u,o,t,"minute");if(o>=e)return i(u,o,e,"second");return u+" ms"}(s):function(u){var o=Math.abs(u);if(o>=r)return Math.round(u/r)+"d";if(o>=n)return Math.round(u/n)+"h";if(o>=t)return Math.round(u/t)+"m";if(o>=e)return Math.round(u/e)+"s";return u+"ms"}(s);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(s))}}function Rr(){if(_r)return br;return _r=1,br=function(e){function t(e){let r,u,o,i=null;function s(...e){if(!s.enabled)return;const n=s,u=Number(new Date),o=u-(r||u);n.diff=o,n.prev=r,n.curr=u,r=u,e[0]=t.coerce(e[0]),"string"!=typeof e[0]&&e.unshift("%O");let i=0;e[0]=e[0].replace(/%([a-zA-Z%])/g,((r,u)=>{if("%%"===r)return"%";i++;const o=t.formatters[u];if("function"==typeof o){const t=e[i];r=o.call(n,t),e.splice(i,1),i--}return r})),t.formatArgs.call(n,e);(n.log||t.log).apply(n,e)}return s.namespace=e,s.useColors=t.useColors(),s.color=t.selectColor(e),s.extend=n,s.destroy=t.destroy,Object.defineProperty(s,"enabled",{enumerable:!0,configurable:!1,get:()=>null!==i?i:(u!==t.namespaces&&(u=t.namespaces,o=t.enabled(e)),o),set:e=>{i=e}}),"function"==typeof t.init&&t.init(s),s}function n(e,n){const r=t(this.namespace+(void 0===n?":":n)+e);return r.log=this.log,r}function r(e){return e.toString().substring(2,e.toString().length-2).replace(/\.\*\?$/,"*")}return t.debug=t,t.default=t,t.coerce=function(e){if(e instanceof Error)return e.stack||e.message;return e},t.disable=function(){const e=[...t.names.map(r),...t.skips.map(r).map((e=>"-"+e))].join(",");return t.enable(""),e},t.enable=function(e){let n;t.save(e),t.namespaces=e,t.names=[],t.skips=[];const r=("string"==typeof e?e:"").split(/[\s,]+/),u=r.length;for(n=0;n{t[n]=e[n]})),t.names=[],t.skips=[],t.formatters={},t.selectColor=function(e){let n=0;for(let t=0;t{const n=e.startsWith("-")?"":1===e.length?"-":"--",r=t.indexOf(n+e),u=t.indexOf("--");return-1!==r&&(-1===u||r{}),"Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`."),t.colors=[6,2,3,4,5,1];try{const e=function(){if($r)return jr;$r=1;const e=E.default,t=A.default,n=Vr(),{env:r}=process;let u;function o(e){return 0!==e&&{level:e,hasBasic:!0,has256:e>=2,has16m:e>=3}}function i(t,o){if(0===u)return 0;if(n("color=16m")||n("color=full")||n("color=truecolor"))return 3;if(n("color=256"))return 2;if(t&&!o&&void 0===u)return 0;const i=u||0;if("dumb"===r.TERM)return i;if("win32"===process.platform){const t=e.release().split(".");return Number(t[0])>=10&&Number(t[2])>=10586?Number(t[2])>=14931?3:2:1}if("CI"in r)return["TRAVIS","CIRCLECI","APPVEYOR","GITLAB_CI","GITHUB_ACTIONS","BUILDKITE"].some((e=>e in r))||"codeship"===r.CI_NAME?1:i;if("TEAMCITY_VERSION"in r)return/^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(r.TEAMCITY_VERSION)?1:0;if("truecolor"===r.COLORTERM)return 3;if("TERM_PROGRAM"in r){const e=parseInt((r.TERM_PROGRAM_VERSION||"").split(".")[0],10);switch(r.TERM_PROGRAM){case"iTerm.app":return e>=3?3:2;case"Apple_Terminal":return 2}}return/-256(color)?$/i.test(r.TERM)?2:/^screen|^xterm|^vt100|^vt220|^rxvt|color|ansi|cygwin|linux/i.test(r.TERM)||"COLORTERM"in r?1:i}return n("no-color")||n("no-colors")||n("color=false")||n("color=never")?u=0:(n("color")||n("colors")||n("color=true")||n("color=always"))&&(u=1),"FORCE_COLOR"in r&&(u="true"===r.FORCE_COLOR?1:"false"===r.FORCE_COLOR?0:0===r.FORCE_COLOR.length?1:Math.min(parseInt(r.FORCE_COLOR,10),3)),jr={supportsColor:function(e){return o(i(e,e&&e.isTTY))},stdout:o(i(!0,t.isatty(1))),stderr:o(i(!0,t.isatty(2)))}}();e&&(e.stderr||e).level>=2&&(t.colors=[20,21,26,27,32,33,38,39,40,41,42,43,44,45,56,57,62,63,68,69,74,75,76,77,78,79,80,81,92,93,98,99,112,113,128,129,134,135,148,149,160,161,162,163,164,165,166,167,168,169,170,171,172,173,178,179,184,185,196,197,198,199,200,201,202,203,204,205,206,207,208,209,214,215,220,221])}catch(e){}t.inspectOpts=Object.keys(process.env).filter((e=>/^debug_/i.test(e))).reduce(((e,t)=>{const n=t.substring(6).toLowerCase().replace(/_([a-z])/g,((e,t)=>t.toUpperCase()));let r=process.env[t];return r=!!/^(yes|on|true|enabled)$/i.test(r)||!/^(no|off|false|disabled)$/i.test(r)&&("null"===r?null:Number(r)),e[n]=r,e}),{}),e.exports=Rr()(t);const{formatters:u}=e.exports;u.o=function(e){return this.inspectOpts.colors=this.useColors,r.inspect(e,this.inspectOpts).split("\n").map((e=>e.trim())).join(" ")},u.O=function(e){return this.inspectOpts.colors=this.useColors,r.inspect(e,this.inspectOpts)}}(Gr,Gr.exports)),Gr.exports}Jr=Nr,"undefined"==typeof process||"renderer"===process.type||!0===process.browser||process.__nwjs?Jr.exports=(Br||(Br=1,function(e,t){t.formatArgs=function(t){if(t[0]=(this.useColors?"%c":"")+this.namespace+(this.useColors?" %c":" ")+t[0]+(this.useColors?"%c ":" ")+"+"+e.exports.humanize(this.diff),!this.useColors)return;const n="color: "+this.color;t.splice(1,0,n,"color: inherit");let r=0,u=0;t[0].replace(/%[a-zA-Z%]/g,(e=>{"%%"!==e&&(r++,"%c"===e&&(u=r))})),t.splice(u,0,n)},t.save=function(e){try{e?t.storage.setItem("debug",e):t.storage.removeItem("debug")}catch(e){}},t.load=function(){let e;try{e=t.storage.getItem("debug")}catch(e){}return!e&&"undefined"!=typeof process&&"env"in process&&(e=process.env.DEBUG),e},t.useColors=function(){return!("undefined"==typeof window||!window.process||"renderer"!==window.process.type&&!window.process.__nwjs)||("undefined"==typeof navigator||!navigator.userAgent||!navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/))&&("undefined"!=typeof document&&document.documentElement&&document.documentElement.style&&document.documentElement.style.WebkitAppearance||"undefined"!=typeof window&&window.console&&(window.console.firebug||window.console.exception&&window.console.table)||"undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/)&&parseInt(RegExp.$1,10)>=31||"undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/))},t.storage=function(){try{return localStorage}catch(e){}}(),t.destroy=(()=>{let e=!1;return()=>{e||(e=!0,console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`."))}})(),t.colors=["#0000CC","#0000FF","#0033CC","#0033FF","#0066CC","#0066FF","#0099CC","#0099FF","#00CC00","#00CC33","#00CC66","#00CC99","#00CCCC","#00CCFF","#3300CC","#3300FF","#3333CC","#3333FF","#3366CC","#3366FF","#3399CC","#3399FF","#33CC00","#33CC33","#33CC66","#33CC99","#33CCCC","#33CCFF","#6600CC","#6600FF","#6633CC","#6633FF","#66CC00","#66CC33","#9900CC","#9900FF","#9933CC","#9933FF","#99CC00","#99CC33","#CC0000","#CC0033","#CC0066","#CC0099","#CC00CC","#CC00FF","#CC3300","#CC3333","#CC3366","#CC3399","#CC33CC","#CC33FF","#CC6600","#CC6633","#CC9900","#CC9933","#CCCC00","#CCCC33","#FF0000","#FF0033","#FF0066","#FF0099","#FF00CC","#FF00FF","#FF3300","#FF3333","#FF3366","#FF3399","#FF33CC","#FF33FF","#FF6600","#FF6633","#FF9900","#FF9933","#FFCC00","#FFCC33"],t.log=console.debug||console.log||(()=>{}),e.exports=Rr()(t);const{formatters:n}=e.exports;n.j=function(e){try{return JSON.stringify(e)}catch(e){return"[UnexpectedJSONParseError]: "+e.message}}}(Ir,Ir.exports)),Ir.exports):Jr.exports=Ur();var Wr=function(e){return(e=e||{}).circles?function(e){var t=[],n=[];return e.proto?function e(u){if("object"!=typeof u||null===u)return u;if(u instanceof Date)return new Date(u);if(Array.isArray(u))return r(u,e);if(u instanceof Map)return new Map(r(Array.from(u),e));if(u instanceof Set)return new Set(r(Array.from(u),e));var o={};for(var i in t.push(u),n.push(o),u){var s=u[i];if("object"!=typeof s||null===s)o[i]=s;else if(s instanceof Date)o[i]=new Date(s);else if(s instanceof Map)o[i]=new Map(r(Array.from(s),e));else if(s instanceof Set)o[i]=new Set(r(Array.from(s),e));else if(ArrayBuffer.isView(s))o[i]=zr(s);else{var c=t.indexOf(s);o[i]=-1!==c?n[c]:e(s)}}return t.pop(),n.pop(),o}:function e(u){if("object"!=typeof u||null===u)return u;if(u instanceof Date)return new Date(u);if(Array.isArray(u))return r(u,e);if(u instanceof Map)return new Map(r(Array.from(u),e));if(u instanceof Set)return new Set(r(Array.from(u),e));var o={};for(var i in t.push(u),n.push(o),u)if(!1!==Object.hasOwnProperty.call(u,i)){var s=u[i];if("object"!=typeof s||null===s)o[i]=s;else if(s instanceof Date)o[i]=new Date(s);else if(s instanceof Map)o[i]=new Map(r(Array.from(s),e));else if(s instanceof Set)o[i]=new Set(r(Array.from(s),e));else if(ArrayBuffer.isView(s))o[i]=zr(s);else{var c=t.indexOf(s);o[i]=-1!==c?n[c]:e(s)}}return t.pop(),n.pop(),o};function r(e,r){for(var u=Object.keys(e),o=new Array(u.length),i=0;i!e,Qr=e=>e&&"object"==typeof e&&!Array.isArray(e),eu=(e,t,n)=>{(Array.isArray(t)?t:[t]).forEach((t=>{if(t)throw new Error(`Problem with log4js configuration: (${Kr.inspect(e,{depth:5})}) - ${n}`)}))};var tu={configure:e=>{qr("New configuration to be validated: ",e),eu(e,Zr(Qr(e)),"must be an object."),qr(`Calling pre-processing listeners (${Yr.length})`),Yr.forEach((t=>t(e))),qr("Configuration pre-processing finished."),qr(`Calling configuration listeners (${Xr.length})`),Xr.forEach((t=>t(e))),qr("Configuration finished.")},addListener:e=>{Xr.push(e),qr(`Added listener, now ${Xr.length} listeners`)},addPreProcessingListener:e=>{Yr.push(e),qr(`Added pre-processing listener, now ${Yr.length} listeners`)},throwExceptionIf:eu,anObject:Qr,anInteger:e=>e&&"number"==typeof e&&Number.isInteger(e),validIdentifier:e=>/^[A-Za-z][A-Za-z0-9_]*$/g.test(e),not:Zr},nu={exports:{}};!function(e){function t(e,t){for(var n=e.toString();n.length-1?s:c,l=n(u.getHours()),f=n(u.getMinutes()),d=n(u.getSeconds()),D=t(u.getMilliseconds(),3),p=function(e){var t=Math.abs(e),n=String(Math.floor(t/60)),r=String(t%60);return n=("0"+n).slice(-2),r=("0"+r).slice(-2),0===e?"Z":(e<0?"+":"-")+n+":"+r}(u.getTimezoneOffset());return r.replace(/dd/g,o).replace(/MM/g,i).replace(/y{1,4}/g,a).replace(/hh/g,l).replace(/mm/g,f).replace(/ss/g,d).replace(/SSS/g,D).replace(/O/g,p)}function u(e,t,n,r){e["set"+(r?"":"UTC")+t](n)}e.exports=r,e.exports.asString=r,e.exports.parse=function(t,n,r){if(!t)throw new Error("pattern must be supplied");return function(t,n,r){var o=t.indexOf("O")<0,i=!1,s=[{pattern:/y{1,4}/,regexp:"\\d{1,4}",fn:function(e,t){u(e,"FullYear",t,o)}},{pattern:/MM/,regexp:"\\d{1,2}",fn:function(e,t){u(e,"Month",t-1,o),e.getMonth()!==t-1&&(i=!0)}},{pattern:/dd/,regexp:"\\d{1,2}",fn:function(e,t){i&&u(e,"Month",e.getMonth()-1,o),u(e,"Date",t,o)}},{pattern:/hh/,regexp:"\\d{1,2}",fn:function(e,t){u(e,"Hours",t,o)}},{pattern:/mm/,regexp:"\\d\\d",fn:function(e,t){u(e,"Minutes",t,o)}},{pattern:/ss/,regexp:"\\d\\d",fn:function(e,t){u(e,"Seconds",t,o)}},{pattern:/SSS/,regexp:"\\d\\d\\d",fn:function(e,t){u(e,"Milliseconds",t,o)}},{pattern:/O/,regexp:"[+-]\\d{1,2}:?\\d{2}?|Z",fn:function(e,t){t="Z"===t?0:t.replace(":","");var n=Math.abs(t),r=(t>0?-1:1)*(n%100+60*Math.floor(n/100));e.setUTCMinutes(e.getUTCMinutes()+r)}}],c=s.reduce((function(e,t){return t.pattern.test(e.regexp)?(t.index=e.regexp.match(t.pattern).index,e.regexp=e.regexp.replace(t.pattern,"("+t.regexp+")")):t.index=-1,e}),{regexp:t,index:[]}),a=s.filter((function(e){return e.index>-1}));a.sort((function(e,t){return e.index-t.index}));var l=new RegExp(c.regexp).exec(n);if(l){var f=r||e.exports.now();return a.forEach((function(e,t){e.fn(f,l[t+1])})),f}throw new Error("String '"+n+"' could not be parsed as '"+t+"'")}(t,n,r)},e.exports.now=function(){return new Date},e.exports.ISO8601_FORMAT="yyyy-MM-ddThh:mm:ss.SSS",e.exports.ISO8601_WITH_TZ_OFFSET_FORMAT="yyyy-MM-ddThh:mm:ss.SSSO",e.exports.DATETIME_FORMAT="dd MM yyyy hh:mm:ss.SSS",e.exports.ABSOLUTETIME_FORMAT="hh:mm:ss.SSS"}(nu);const ru=nu.exports,uu=E.default,ou=F.default,iu=p.default,su={bold:[1,22],italic:[3,23],underline:[4,24],inverse:[7,27],white:[37,39],grey:[90,39],black:[90,39],blue:[34,39],cyan:[36,39],green:[32,39],magenta:[35,39],red:[91,39],yellow:[33,39]};function cu(e){return e?`[${su[e][0]}m`:""}function au(e){return e?`[${su[e][1]}m`:""}function lu(e,t){return n=ou.format("[%s] [%s] %s - ",ru.asString(e.startTime),e.level.toString(),e.categoryName),cu(r=t)+n+au(r);var n,r}function fu(e){return lu(e)+ou.format(...e.data)}function du(e){return lu(e,e.level.colour)+ou.format(...e.data)}function Du(e){return ou.format(...e.data)}function pu(e){return e.data[0]}function Eu(e,t){const n=/%(-?[0-9]+)?(\.?-?[0-9]+)?([[\]cdhmnprzxXyflos%])(\{([^}]+)\})?|([^%]+)/;function r(e){return e&&e.pid?e.pid.toString():process.pid.toString()}e=e||"%r %p %c - %m%n";const u={c:function(e,t){let n=e.categoryName;if(t){const e=parseInt(t,10),r=n.split(".");ee&&(n=r.slice(-e).join(iu.sep))}return n},l:function(e){return e.lineNumber?`${e.lineNumber}`:""},o:function(e){return e.columnNumber?`${e.columnNumber}`:""},s:function(e){return e.callStack||""}};function o(e,t,n){return u[e](t,n)}function i(e,t,n){let r=e;return r=function(e,t){let n;return e?(n=parseInt(e.substr(1),10),n>0?t.slice(0,n):t.slice(n)):t}(t,r),r=function(e,t){let n;if(e)if("-"===e.charAt(0))for(n=parseInt(e.substr(1),10);t.lengthDu,basic:()=>fu,colored:()=>du,coloured:()=>du,pattern:e=>Eu(e&&e.pattern,e&&e.tokens),dummy:()=>pu};var hu={basicLayout:fu,messagePassThroughLayout:Du,patternLayout:Eu,colouredLayout:du,coloredLayout:du,dummyLayout:pu,addLayout(e,t){mu[e]=t},layout:(e,t)=>mu[e]&&mu[e](t)};const yu=tu,Cu=["white","grey","black","blue","cyan","green","magenta","red","yellow"];class Fu{constructor(e,t,n){this.level=e,this.levelStr=t,this.colour=n}toString(){return this.levelStr}static getLevel(e,t){return e?e instanceof Fu?e:(e instanceof Object&&e.levelStr&&(e=e.levelStr),Fu[e.toString().toUpperCase()]||t):t}static addLevels(e){if(e){Object.keys(e).forEach((t=>{const n=t.toUpperCase();Fu[n]=new Fu(e[t].value,n,e[t].colour);const r=Fu.levels.findIndex((e=>e.levelStr===n));r>-1?Fu.levels[r]=Fu[n]:Fu.levels.push(Fu[n])})),Fu.levels.sort(((e,t)=>e.level-t.level))}}isLessThanOrEqualTo(e){return"string"==typeof e&&(e=Fu.getLevel(e)),this.level<=e.level}isGreaterThanOrEqualTo(e){return"string"==typeof e&&(e=Fu.getLevel(e)),this.level>=e.level}isEqualTo(e){return"string"==typeof e&&(e=Fu.getLevel(e)),this.level===e.level}}Fu.levels=[],Fu.addLevels({ALL:{value:Number.MIN_VALUE,colour:"grey"},TRACE:{value:5e3,colour:"blue"},DEBUG:{value:1e4,colour:"cyan"},INFO:{value:2e4,colour:"green"},WARN:{value:3e4,colour:"yellow"},ERROR:{value:4e4,colour:"red"},FATAL:{value:5e4,colour:"magenta"},MARK:{value:9007199254740992,colour:"grey"},OFF:{value:Number.MAX_VALUE,colour:"grey"}}),yu.addListener((e=>{const t=e.levels;if(t){yu.throwExceptionIf(e,yu.not(yu.anObject(t)),"levels must be an object");Object.keys(t).forEach((n=>{yu.throwExceptionIf(e,yu.not(yu.validIdentifier(n)),`level name "${n}" is not a valid identifier (must start with a letter, only contain A-Z,a-z,0-9,_)`),yu.throwExceptionIf(e,yu.not(yu.anObject(t[n])),`level "${n}" must be an object`),yu.throwExceptionIf(e,yu.not(t[n].value),`level "${n}" must have a 'value' property`),yu.throwExceptionIf(e,yu.not(yu.anInteger(t[n].value)),`level "${n}".value must have an integer value`),yu.throwExceptionIf(e,yu.not(t[n].colour),`level "${n}" must have a 'colour' property`),yu.throwExceptionIf(e,yu.not(Cu.indexOf(t[n].colour)>-1),`level "${n}".colour must be one of ${Cu.join(", ")}`)}))}})),yu.addListener((e=>{Fu.addLevels(e.levels)}));var gu=Fu,Au={exports:{}},vu={};/*! (c) 2020 Andrea Giammarchi */ +const{parse:Su,stringify:wu}=JSON,{keys:Ou}=Object,bu=String,_u="string",Bu={},Pu="object",ku=(e,t)=>t,xu=e=>e instanceof bu?bu(e):e,Nu=(e,t)=>typeof t===_u?new bu(t):t,Iu=(e,t,n,r)=>{const u=[];for(let o=Ou(n),{length:i}=o,s=0;s{const r=bu(t.push(n)-1);return e.set(n,r),r},Ru=(e,t)=>{const n=Su(e,Nu).map(xu),r=n[0],u=t||ku,o=typeof r===Pu&&r?Iu(n,new Set,r,u):r;return u.call({"":o},"",o)};vu.parse=Ru;const Mu=(e,t,n)=>{const r=t&&typeof t===Pu?(e,n)=>""===e||-1Su(Mu(e));vu.fromJSON=e=>Ru(wu(e));const Lu=vu,ju=gu;class $u{constructor(e,t,n,r,u){this.startTime=new Date,this.categoryName=e,this.data=n,this.level=t,this.context=Object.assign({},r),this.pid=process.pid,u&&(this.functionName=u.functionName,this.fileName=u.fileName,this.lineNumber=u.lineNumber,this.columnNumber=u.columnNumber,this.callStack=u.callStack)}serialise(){const e=this.data.map((e=>(e&&e.message&&e.stack&&(e=Object.assign({message:e.message,stack:e.stack},e)),e)));return this.data=e,Lu.stringify(this)}static deserialise(e){let t;try{const n=Lu.parse(e);n.data=n.data.map((e=>{if(e&&e.message&&e.stack){const t=new Error(e);Object.keys(e).forEach((n=>{t[n]=e[n]})),e=t}return e})),t=new $u(n.categoryName,ju.getLevel(n.level.levelStr),n.data,n.context),t.startTime=new Date(n.startTime),t.pid=n.pid,t.cluster=n.cluster}catch(n){t=new $u("log4js",ju.ERROR,["Unable to parse log:",e,"because: ",n])}return t}}var Hu=$u;const Ju=Nr.exports("log4js:clustering"),Gu=Hu,Vu=tu;let Uu=!1,Wu=null;try{Wu=require("cluster")}catch(e){Ju("cluster module not present"),Uu=!0}const zu=[];let Ku=!1,qu="NODE_APP_INSTANCE";const Yu=()=>Ku&&"0"===process.env[qu],Xu=()=>Uu||Wu.isMaster||Yu(),Zu=e=>{zu.forEach((t=>t(e)))},Qu=(e,t)=>{if(Ju("cluster message received from worker ",e,": ",t),e.topic&&e.data&&(t=e,e=void 0),t&&t.topic&&"log4js:message"===t.topic){Ju("received message: ",t.data);const e=Gu.deserialise(t.data);Zu(e)}};Uu||Vu.addListener((e=>{zu.length=0,({pm2:Ku,disableClustering:Uu,pm2InstanceVar:qu="NODE_APP_INSTANCE"}=e),Ju(`clustering disabled ? ${Uu}`),Ju(`cluster.isMaster ? ${Wu&&Wu.isMaster}`),Ju(`pm2 enabled ? ${Ku}`),Ju(`pm2InstanceVar = ${qu}`),Ju(`process.env[${qu}] = ${process.env[qu]}`),Ku&&process.removeListener("message",Qu),Wu&&Wu.removeListener&&Wu.removeListener("message",Qu),Uu||e.disableClustering?Ju("Not listening for cluster messages, because clustering disabled."):Yu()?(Ju("listening for PM2 broadcast messages"),process.on("message",Qu)):Wu.isMaster?(Ju("listening for cluster messages"),Wu.on("message",Qu)):Ju("not listening for messages, because we are not a master process")}));var eo={onlyOnMaster:(e,t)=>Xu()?e():t,isMaster:Xu,send:e=>{Xu()?Zu(e):(Ku||(e.cluster={workerId:Wu.worker.id,worker:process.pid}),process.send({topic:"log4js:message",data:e.serialise()}))},onMessage:e=>{zu.push(e)}},to={};function no(e){if("number"==typeof e&&Number.isInteger(e))return e;const t={K:1024,M:1048576,G:1073741824},n=Object.keys(t),r=e.substr(e.length-1).toLocaleUpperCase(),u=e.substring(0,e.length-1).trim();if(n.indexOf(r)<0||!Number.isInteger(Number(u)))throw Error(`maxLogSize: "${e}" is invalid`);return u*t[r]}function ro(e){return function(e,t){const n=Object.assign({},t);return Object.keys(e).forEach((r=>{n[r]&&(n[r]=e[r](t[r]))})),n}({maxLogSize:no},e)}const uo={file:ro,fileSync:ro};to.modifyConfig=e=>uo[e.type]?uo[e.type](e):e;var oo={};const io=console.log.bind(console);oo.configure=function(e,t){let n=t.colouredLayout;return e.layout&&(n=t.layout(e.layout.type,e.layout)),function(e,t){return n=>{io(e(n,t))}}(n,e.timezoneOffset)};var so={};so.configure=function(e,t){let n=t.colouredLayout;return e.layout&&(n=t.layout(e.layout.type,e.layout)),function(e,t){return n=>{process.stdout.write(`${e(n,t)}\n`)}}(n,e.timezoneOffset)};var co={};co.configure=function(e,t){let n=t.colouredLayout;return e.layout&&(n=t.layout(e.layout.type,e.layout)),function(e,t){return n=>{process.stderr.write(`${e(n,t)}\n`)}}(n,e.timezoneOffset)};var ao={};ao.configure=function(e,t,n,r){const u=n(e.appender);return function(e,t,n,r){const u=r.getLevel(e),o=r.getLevel(t,r.FATAL);return e=>{const t=e.level;t.isGreaterThanOrEqualTo(u)&&t.isLessThanOrEqualTo(o)&&n(e)}}(e.level,e.maxLevel,u,r)};var lo={};const fo=Nr.exports("log4js:categoryFilter");lo.configure=function(e,t,n){const r=n(e.appender);return function(e,t){return"string"==typeof e&&(e=[e]),n=>{fo(`Checking ${n.categoryName} against ${e}`),-1===e.indexOf(n.categoryName)&&(fo("Not excluded, sending to appender"),t(n))}}(e.exclude,r)};var Do={};const po=Nr.exports("log4js:noLogFilter");Do.configure=function(e,t,n){const r=n(e.appender);return function(e,t){return n=>{po(`Checking data: ${n.data} against filters: ${e}`),"string"==typeof e&&(e=[e]),e=e.filter((e=>null!=e&&""!==e));const r=new RegExp(e.join("|"),"i");(0===e.length||n.data.findIndex((e=>r.test(e)))<0)&&(po("Not excluded, sending to appender"),t(n))}}(e.exclude,r)};var Eo={},mo={exports:{}},ho={},yo={fromCallback:function(e){return Object.defineProperty((function(){if("function"!=typeof arguments[arguments.length-1])return new Promise(((t,n)=>{arguments[arguments.length]=(e,r)=>{if(e)return n(e);t(r)},arguments.length++,e.apply(this,arguments)}));e.apply(this,arguments)}),"name",{value:e.name})},fromPromise:function(e){return Object.defineProperty((function(){const t=arguments[arguments.length-1];if("function"!=typeof t)return e.apply(this,arguments);e.apply(this,arguments).then((e=>t(null,e)),t)}),"name",{value:e.name})}};!function(e){const t=yo.fromCallback,n=we,r=["access","appendFile","chmod","chown","close","copyFile","fchmod","fchown","fdatasync","fstat","fsync","ftruncate","futimes","lchown","lchmod","link","lstat","mkdir","mkdtemp","open","readFile","readdir","readlink","realpath","rename","rmdir","stat","symlink","truncate","unlink","utimes","writeFile"].filter((e=>"function"==typeof n[e]));Object.keys(n).forEach((t=>{"promises"!==t&&(e[t]=n[t])})),r.forEach((r=>{e[r]=t(n[r])})),e.exists=function(e,t){return"function"==typeof t?n.exists(e,t):new Promise((t=>n.exists(e,t)))},e.read=function(e,t,r,u,o,i){return"function"==typeof i?n.read(e,t,r,u,o,i):new Promise(((i,s)=>{n.read(e,t,r,u,o,((e,t,n)=>{if(e)return s(e);i({bytesRead:t,buffer:n})}))}))},e.write=function(e,t,...r){return"function"==typeof r[r.length-1]?n.write(e,t,...r):new Promise(((u,o)=>{n.write(e,t,...r,((e,t,n)=>{if(e)return o(e);u({bytesWritten:t,buffer:n})}))}))},"function"==typeof n.realpath.native&&(e.realpath.native=t(n.realpath.native))}(ho);const Co=p.default;function Fo(e){return(e=Co.normalize(Co.resolve(e)).split(Co.sep)).length>0?e[0]:null}const go=/[<>:"|?*]/;var Ao=function(e){const t=Fo(e);return e=e.replace(t,""),go.test(e)};const vo=we,So=p.default,wo=Ao,Oo=parseInt("0777",8);var bo=function e(t,n,r,u){if("function"==typeof n?(r=n,n={}):n&&"object"==typeof n||(n={mode:n}),"win32"===process.platform&&wo(t)){const e=new Error(t+" contains invalid WIN32 path characters.");return e.code="EINVAL",r(e)}let o=n.mode;const i=n.fs||vo;void 0===o&&(o=Oo&~process.umask()),u||(u=null),r=r||function(){},t=So.resolve(t),i.mkdir(t,o,(o=>{if(!o)return r(null,u=u||t);if("ENOENT"===o.code){if(So.dirname(t)===t)return r(o);e(So.dirname(t),n,((u,o)=>{u?r(u,o):e(t,n,r,o)}))}else i.stat(t,((e,t)=>{e||!t.isDirectory()?r(o,u):r(null,u)}))}))};const _o=we,Bo=p.default,Po=Ao,ko=parseInt("0777",8);var xo=function e(t,n,r){n&&"object"==typeof n||(n={mode:n});let u=n.mode;const o=n.fs||_o;if("win32"===process.platform&&Po(t)){const e=new Error(t+" contains invalid WIN32 path characters.");throw e.code="EINVAL",e}void 0===u&&(u=ko&~process.umask()),r||(r=null),t=Bo.resolve(t);try{o.mkdirSync(t,u),r=r||t}catch(u){if("ENOENT"===u.code){if(Bo.dirname(t)===t)throw u;r=e(Bo.dirname(t),n,r),e(t,n,r)}else{let e;try{e=o.statSync(t)}catch(e){throw u}if(!e.isDirectory())throw u}}return r};const No=(0,yo.fromCallback)(bo);var Io={mkdirs:No,mkdirsSync:xo,mkdirp:No,mkdirpSync:xo,ensureDir:No,ensureDirSync:xo};const To=we;E.default,p.default;var Ro=function(e,t,n,r){To.open(e,"r+",((e,u)=>{if(e)return r(e);To.futimes(u,t,n,(e=>{To.close(u,(t=>{r&&r(e||t)}))}))}))},Mo=function(e,t,n){const r=To.openSync(e,"r+");return To.futimesSync(r,t,n),To.closeSync(r)};const Lo=we,jo=p.default,$o=10,Ho=5,Jo=0,Go=process.versions.node.split("."),Vo=Number.parseInt(Go[0],10),Uo=Number.parseInt(Go[1],10),Wo=Number.parseInt(Go[2],10);function zo(){if(Vo>$o)return!0;if(Vo===$o){if(Uo>Ho)return!0;if(Uo===Ho&&Wo>=Jo)return!0}return!1}function Ko(e,t){const n=jo.resolve(e).split(jo.sep).filter((e=>e)),r=jo.resolve(t).split(jo.sep).filter((e=>e));return n.reduce(((e,t,n)=>e&&r[n]===t),!0)}function qo(e,t,n){return`Cannot ${n} '${e}' to a subdirectory of itself, '${t}'.`}var Yo,Xo,Zo={checkPaths:function(e,t,n,r){!function(e,t,n){zo()?Lo.stat(e,{bigint:!0},((e,r)=>{if(e)return n(e);Lo.stat(t,{bigint:!0},((e,t)=>e?"ENOENT"===e.code?n(null,{srcStat:r,destStat:null}):n(e):n(null,{srcStat:r,destStat:t})))})):Lo.stat(e,((e,r)=>{if(e)return n(e);Lo.stat(t,((e,t)=>e?"ENOENT"===e.code?n(null,{srcStat:r,destStat:null}):n(e):n(null,{srcStat:r,destStat:t})))}))}(e,t,((u,o)=>{if(u)return r(u);const{srcStat:i,destStat:s}=o;return s&&s.ino&&s.dev&&s.ino===i.ino&&s.dev===i.dev?r(new Error("Source and destination must not be the same.")):i.isDirectory()&&Ko(e,t)?r(new Error(qo(e,t,n))):r(null,{srcStat:i,destStat:s})}))},checkPathsSync:function(e,t,n){const{srcStat:r,destStat:u}=function(e,t){let n,r;n=zo()?Lo.statSync(e,{bigint:!0}):Lo.statSync(e);try{r=zo()?Lo.statSync(t,{bigint:!0}):Lo.statSync(t)}catch(e){if("ENOENT"===e.code)return{srcStat:n,destStat:null};throw e}return{srcStat:n,destStat:r}}(e,t);if(u&&u.ino&&u.dev&&u.ino===r.ino&&u.dev===r.dev)throw new Error("Source and destination must not be the same.");if(r.isDirectory()&&Ko(e,t))throw new Error(qo(e,t,n));return{srcStat:r,destStat:u}},checkParentPaths:function e(t,n,r,u,o){const i=jo.resolve(jo.dirname(t)),s=jo.resolve(jo.dirname(r));if(s===i||s===jo.parse(s).root)return o();zo()?Lo.stat(s,{bigint:!0},((i,c)=>i?"ENOENT"===i.code?o():o(i):c.ino&&c.dev&&c.ino===n.ino&&c.dev===n.dev?o(new Error(qo(t,r,u))):e(t,n,s,u,o))):Lo.stat(s,((i,c)=>i?"ENOENT"===i.code?o():o(i):c.ino&&c.dev&&c.ino===n.ino&&c.dev===n.dev?o(new Error(qo(t,r,u))):e(t,n,s,u,o)))},checkParentPathsSync:function e(t,n,r,u){const o=jo.resolve(jo.dirname(t)),i=jo.resolve(jo.dirname(r));if(i===o||i===jo.parse(i).root)return;let s;try{s=zo()?Lo.statSync(i,{bigint:!0}):Lo.statSync(i)}catch(e){if("ENOENT"===e.code)return;throw e}if(s.ino&&s.dev&&s.ino===n.ino&&s.dev===n.dev)throw new Error(qo(t,r,u));return e(t,n,i,u)},isSrcSubdir:Ko};const Qo=we,ei=p.default,ti=Io.mkdirsSync,ni=Mo,ri=Zo;function ui(e,t,n,r){if(!r.filter||r.filter(t,n))return function(e,t,n,r){const u=r.dereference?Qo.statSync:Qo.lstatSync,o=u(t);if(o.isDirectory())return function(e,t,n,r,u){if(!t)return function(e,t,n,r){return Qo.mkdirSync(n),ii(t,n,r),Qo.chmodSync(n,e.mode)}(e,n,r,u);if(t&&!t.isDirectory())throw new Error(`Cannot overwrite non-directory '${r}' with directory '${n}'.`);return ii(n,r,u)}(o,e,t,n,r);if(o.isFile()||o.isCharacterDevice()||o.isBlockDevice())return function(e,t,n,r,u){return t?function(e,t,n,r){if(r.overwrite)return Qo.unlinkSync(n),oi(e,t,n,r);if(r.errorOnExist)throw new Error(`'${n}' already exists`)}(e,n,r,u):oi(e,n,r,u)}(o,e,t,n,r);if(o.isSymbolicLink())return function(e,t,n,r){let u=Qo.readlinkSync(t);r.dereference&&(u=ei.resolve(process.cwd(),u));if(e){let e;try{e=Qo.readlinkSync(n)}catch(e){if("EINVAL"===e.code||"UNKNOWN"===e.code)return Qo.symlinkSync(u,n);throw e}if(r.dereference&&(e=ei.resolve(process.cwd(),e)),ri.isSrcSubdir(u,e))throw new Error(`Cannot copy '${u}' to a subdirectory of itself, '${e}'.`);if(Qo.statSync(n).isDirectory()&&ri.isSrcSubdir(e,u))throw new Error(`Cannot overwrite '${e}' with '${u}'.`);return function(e,t){return Qo.unlinkSync(t),Qo.symlinkSync(e,t)}(u,n)}return Qo.symlinkSync(u,n)}(e,t,n,r)}(e,t,n,r)}function oi(e,t,n,r){return"function"==typeof Qo.copyFileSync?(Qo.copyFileSync(t,n),Qo.chmodSync(n,e.mode),r.preserveTimestamps?ni(n,e.atime,e.mtime):void 0):function(e,t,n,r){const u=65536,o=(Xo?Yo:(Xo=1,Yo=function(e){if("function"==typeof Buffer.allocUnsafe)try{return Buffer.allocUnsafe(e)}catch(t){return new Buffer(e)}return new Buffer(e)}))(u),i=Qo.openSync(t,"r"),s=Qo.openSync(n,"w",e.mode);let c=0;for(;cfunction(e,t,n,r){const u=ei.join(t,e),o=ei.join(n,e),{destStat:i}=ri.checkPathsSync(u,o,"copy");return ui(i,u,o,r)}(r,e,t,n)))}var si=function(e,t,n){"function"==typeof n&&(n={filter:n}),(n=n||{}).clobber=!("clobber"in n)||!!n.clobber,n.overwrite="overwrite"in n?!!n.overwrite:n.clobber,n.preserveTimestamps&&"ia32"===process.arch&&console.warn("fs-extra: Using the preserveTimestamps option in 32-bit node is not recommended;\n\n see https://github.com/jprichardson/node-fs-extra/issues/269");const{srcStat:r,destStat:u}=ri.checkPathsSync(e,t,"copy");return ri.checkParentPathsSync(e,r,t,"copy"),function(e,t,n,r){if(r.filter&&!r.filter(t,n))return;const u=ei.dirname(n);Qo.existsSync(u)||ti(u);return ui(e,t,n,r)}(u,e,t,n)},ci={copySync:si};const ai=yo.fromPromise,li=ho;var fi={pathExists:ai((function(e){return li.access(e).then((()=>!0)).catch((()=>!1))})),pathExistsSync:li.existsSync};const di=we,Di=p.default,pi=Io.mkdirs,Ei=fi.pathExists,mi=Ro,hi=Zo;function yi(e,t,n,r,u){const o=Di.dirname(n);Ei(o,((i,s)=>i?u(i):s?Fi(e,t,n,r,u):void pi(o,(o=>o?u(o):Fi(e,t,n,r,u)))))}function Ci(e,t,n,r,u,o){Promise.resolve(u.filter(n,r)).then((i=>i?e(t,n,r,u,o):o()),(e=>o(e)))}function Fi(e,t,n,r,u){return r.filter?Ci(gi,e,t,n,r,u):gi(e,t,n,r,u)}function gi(e,t,n,r,u){(r.dereference?di.stat:di.lstat)(t,((o,i)=>o?u(o):i.isDirectory()?function(e,t,n,r,u,o){if(!t)return function(e,t,n,r,u){di.mkdir(n,(o=>{if(o)return u(o);Si(t,n,r,(t=>t?u(t):di.chmod(n,e.mode,u)))}))}(e,n,r,u,o);if(t&&!t.isDirectory())return o(new Error(`Cannot overwrite non-directory '${r}' with directory '${n}'.`));return Si(n,r,u,o)}(i,e,t,n,r,u):i.isFile()||i.isCharacterDevice()||i.isBlockDevice()?function(e,t,n,r,u,o){return t?function(e,t,n,r,u){if(!r.overwrite)return r.errorOnExist?u(new Error(`'${n}' already exists`)):u();di.unlink(n,(o=>o?u(o):Ai(e,t,n,r,u)))}(e,n,r,u,o):Ai(e,n,r,u,o)}(i,e,t,n,r,u):i.isSymbolicLink()?function(e,t,n,r,u){di.readlink(t,((t,o)=>t?u(t):(r.dereference&&(o=Di.resolve(process.cwd(),o)),e?void di.readlink(n,((t,i)=>t?"EINVAL"===t.code||"UNKNOWN"===t.code?di.symlink(o,n,u):u(t):(r.dereference&&(i=Di.resolve(process.cwd(),i)),hi.isSrcSubdir(o,i)?u(new Error(`Cannot copy '${o}' to a subdirectory of itself, '${i}'.`)):e.isDirectory()&&hi.isSrcSubdir(i,o)?u(new Error(`Cannot overwrite '${i}' with '${o}'.`)):function(e,t,n){di.unlink(t,(r=>r?n(r):di.symlink(e,t,n)))}(o,n,u)))):di.symlink(o,n,u))))}(e,t,n,r,u):void 0))}function Ai(e,t,n,r,u){return"function"==typeof di.copyFile?di.copyFile(t,n,(t=>t?u(t):vi(e,n,r,u))):function(e,t,n,r,u){const o=di.createReadStream(t);o.on("error",(e=>u(e))).once("open",(()=>{const t=di.createWriteStream(n,{mode:e.mode});t.on("error",(e=>u(e))).on("open",(()=>o.pipe(t))).once("close",(()=>vi(e,n,r,u)))}))}(e,t,n,r,u)}function vi(e,t,n,r){di.chmod(t,e.mode,(u=>u?r(u):n.preserveTimestamps?mi(t,e.atime,e.mtime,r):r()))}function Si(e,t,n,r){di.readdir(e,((u,o)=>u?r(u):wi(o,e,t,n,r)))}function wi(e,t,n,r,u){const o=e.pop();return o?function(e,t,n,r,u,o){const i=Di.join(n,t),s=Di.join(r,t);hi.checkPaths(i,s,"copy",((t,c)=>{if(t)return o(t);const{destStat:a}=c;Fi(a,i,s,u,(t=>t?o(t):wi(e,n,r,u,o)))}))}(e,o,t,n,r,u):u()}var Oi=function(e,t,n,r){"function"!=typeof n||r?"function"==typeof n&&(n={filter:n}):(r=n,n={}),r=r||function(){},(n=n||{}).clobber=!("clobber"in n)||!!n.clobber,n.overwrite="overwrite"in n?!!n.overwrite:n.clobber,n.preserveTimestamps&&"ia32"===process.arch&&console.warn("fs-extra: Using the preserveTimestamps option in 32-bit node is not recommended;\n\n see https://github.com/jprichardson/node-fs-extra/issues/269"),hi.checkPaths(e,t,"copy",((u,o)=>{if(u)return r(u);const{srcStat:i,destStat:s}=o;hi.checkParentPaths(e,i,t,"copy",(u=>u?r(u):n.filter?Ci(yi,s,e,t,n,r):yi(s,e,t,n,r)))}))};var bi={copy:(0,yo.fromCallback)(Oi)};const _i=we,Bi=p.default,Pi=g.default,ki="win32"===process.platform;function xi(e){["unlink","chmod","stat","lstat","rmdir","readdir"].forEach((t=>{e[t]=e[t]||_i[t],e[t+="Sync"]=e[t]||_i[t]})),e.maxBusyTries=e.maxBusyTries||3}function Ni(e,t,n){let r=0;"function"==typeof t&&(n=t,t={}),Pi(e,"rimraf: missing path"),Pi.strictEqual(typeof e,"string","rimraf: path should be a string"),Pi.strictEqual(typeof n,"function","rimraf: callback function required"),Pi(t,"rimraf: invalid options argument provided"),Pi.strictEqual(typeof t,"object","rimraf: options should be object"),xi(t),Ii(e,t,(function u(o){if(o){if(("EBUSY"===o.code||"ENOTEMPTY"===o.code||"EPERM"===o.code)&&rIi(e,t,u)),100*r)}"ENOENT"===o.code&&(o=null)}n(o)}))}function Ii(e,t,n){Pi(e),Pi(t),Pi("function"==typeof n),t.lstat(e,((r,u)=>r&&"ENOENT"===r.code?n(null):r&&"EPERM"===r.code&&ki?Ti(e,t,r,n):u&&u.isDirectory()?Mi(e,t,r,n):void t.unlink(e,(r=>{if(r){if("ENOENT"===r.code)return n(null);if("EPERM"===r.code)return ki?Ti(e,t,r,n):Mi(e,t,r,n);if("EISDIR"===r.code)return Mi(e,t,r,n)}return n(r)}))))}function Ti(e,t,n,r){Pi(e),Pi(t),Pi("function"==typeof r),n&&Pi(n instanceof Error),t.chmod(e,438,(u=>{u?r("ENOENT"===u.code?null:n):t.stat(e,((u,o)=>{u?r("ENOENT"===u.code?null:n):o.isDirectory()?Mi(e,t,n,r):t.unlink(e,r)}))}))}function Ri(e,t,n){let r;Pi(e),Pi(t),n&&Pi(n instanceof Error);try{t.chmodSync(e,438)}catch(e){if("ENOENT"===e.code)return;throw n}try{r=t.statSync(e)}catch(e){if("ENOENT"===e.code)return;throw n}r.isDirectory()?ji(e,t,n):t.unlinkSync(e)}function Mi(e,t,n,r){Pi(e),Pi(t),n&&Pi(n instanceof Error),Pi("function"==typeof r),t.rmdir(e,(u=>{!u||"ENOTEMPTY"!==u.code&&"EEXIST"!==u.code&&"EPERM"!==u.code?u&&"ENOTDIR"===u.code?r(n):r(u):function(e,t,n){Pi(e),Pi(t),Pi("function"==typeof n),t.readdir(e,((r,u)=>{if(r)return n(r);let o,i=u.length;if(0===i)return t.rmdir(e,n);u.forEach((r=>{Ni(Bi.join(e,r),t,(r=>{if(!o)return r?n(o=r):void(0==--i&&t.rmdir(e,n))}))}))}))}(e,t,r)}))}function Li(e,t){let n;xi(t=t||{}),Pi(e,"rimraf: missing path"),Pi.strictEqual(typeof e,"string","rimraf: path should be a string"),Pi(t,"rimraf: missing options"),Pi.strictEqual(typeof t,"object","rimraf: options should be object");try{n=t.lstatSync(e)}catch(n){if("ENOENT"===n.code)return;"EPERM"===n.code&&ki&&Ri(e,t,n)}try{n&&n.isDirectory()?ji(e,t,null):t.unlinkSync(e)}catch(n){if("ENOENT"===n.code)return;if("EPERM"===n.code)return ki?Ri(e,t,n):ji(e,t,n);if("EISDIR"!==n.code)throw n;ji(e,t,n)}}function ji(e,t,n){Pi(e),Pi(t),n&&Pi(n instanceof Error);try{t.rmdirSync(e)}catch(r){if("ENOTDIR"===r.code)throw n;if("ENOTEMPTY"===r.code||"EEXIST"===r.code||"EPERM"===r.code)!function(e,t){if(Pi(e),Pi(t),t.readdirSync(e).forEach((n=>Li(Bi.join(e,n),t))),!ki){return t.rmdirSync(e,t)}{const n=Date.now();do{try{return t.rmdirSync(e,t)}catch(e){}}while(Date.now()-n<500)}}(e,t);else if("ENOENT"!==r.code)throw r}}var $i=Ni;Ni.sync=Li;const Hi=$i;var Ji={remove:(0,yo.fromCallback)(Hi),removeSync:Hi.sync};const Gi=yo.fromCallback,Vi=we,Ui=p.default,Wi=Io,zi=Ji,Ki=Gi((function(e,t){t=t||function(){},Vi.readdir(e,((n,r)=>{if(n)return Wi.mkdirs(e,t);r=r.map((t=>Ui.join(e,t))),function e(){const n=r.pop();if(!n)return t();zi.remove(n,(n=>{if(n)return t(n);e()}))}()}))}));function qi(e){let t;try{t=Vi.readdirSync(e)}catch(t){return Wi.mkdirsSync(e)}t.forEach((t=>{t=Ui.join(e,t),zi.removeSync(t)}))}var Yi={emptyDirSync:qi,emptydirSync:qi,emptyDir:Ki,emptydir:Ki};const Xi=yo.fromCallback,Zi=p.default,Qi=we,es=Io,ts=fi.pathExists;var ns={createFile:Xi((function(e,t){function n(){Qi.writeFile(e,"",(e=>{if(e)return t(e);t()}))}Qi.stat(e,((r,u)=>{if(!r&&u.isFile())return t();const o=Zi.dirname(e);ts(o,((e,r)=>e?t(e):r?n():void es.mkdirs(o,(e=>{if(e)return t(e);n()}))))}))})),createFileSync:function(e){let t;try{t=Qi.statSync(e)}catch(e){}if(t&&t.isFile())return;const n=Zi.dirname(e);Qi.existsSync(n)||es.mkdirsSync(n),Qi.writeFileSync(e,"")}};const rs=yo.fromCallback,us=p.default,os=we,is=Io,ss=fi.pathExists;var cs={createLink:rs((function(e,t,n){function r(e,t){os.link(e,t,(e=>{if(e)return n(e);n(null)}))}ss(t,((u,o)=>u?n(u):o?n(null):void os.lstat(e,(u=>{if(u)return u.message=u.message.replace("lstat","ensureLink"),n(u);const o=us.dirname(t);ss(o,((u,i)=>u?n(u):i?r(e,t):void is.mkdirs(o,(u=>{if(u)return n(u);r(e,t)}))))}))))})),createLinkSync:function(e,t){if(os.existsSync(t))return;try{os.lstatSync(e)}catch(e){throw e.message=e.message.replace("lstat","ensureLink"),e}const n=us.dirname(t);return os.existsSync(n)||is.mkdirsSync(n),os.linkSync(e,t)}};const as=p.default,ls=we,fs=fi.pathExists;var ds={symlinkPaths:function(e,t,n){if(as.isAbsolute(e))return ls.lstat(e,(t=>t?(t.message=t.message.replace("lstat","ensureSymlink"),n(t)):n(null,{toCwd:e,toDst:e})));{const r=as.dirname(t),u=as.join(r,e);return fs(u,((t,o)=>t?n(t):o?n(null,{toCwd:u,toDst:e}):ls.lstat(e,(t=>t?(t.message=t.message.replace("lstat","ensureSymlink"),n(t)):n(null,{toCwd:e,toDst:as.relative(r,e)})))))}},symlinkPathsSync:function(e,t){let n;if(as.isAbsolute(e)){if(n=ls.existsSync(e),!n)throw new Error("absolute srcpath does not exist");return{toCwd:e,toDst:e}}{const r=as.dirname(t),u=as.join(r,e);if(n=ls.existsSync(u),n)return{toCwd:u,toDst:e};if(n=ls.existsSync(e),!n)throw new Error("relative srcpath does not exist");return{toCwd:e,toDst:as.relative(r,e)}}}};const Ds=we;var ps={symlinkType:function(e,t,n){if(n="function"==typeof t?t:n,t="function"!=typeof t&&t)return n(null,t);Ds.lstat(e,((e,r)=>{if(e)return n(null,"file");t=r&&r.isDirectory()?"dir":"file",n(null,t)}))},symlinkTypeSync:function(e,t){let n;if(t)return t;try{n=Ds.lstatSync(e)}catch(e){return"file"}return n&&n.isDirectory()?"dir":"file"}};const Es=yo.fromCallback,ms=p.default,hs=we,ys=Io.mkdirs,Cs=Io.mkdirsSync,Fs=ds.symlinkPaths,gs=ds.symlinkPathsSync,As=ps.symlinkType,vs=ps.symlinkTypeSync,Ss=fi.pathExists;var ws={createSymlink:Es((function(e,t,n,r){r="function"==typeof n?n:r,n="function"!=typeof n&&n,Ss(t,((u,o)=>u?r(u):o?r(null):void Fs(e,t,((u,o)=>{if(u)return r(u);e=o.toDst,As(o.toCwd,n,((n,u)=>{if(n)return r(n);const o=ms.dirname(t);Ss(o,((n,i)=>n?r(n):i?hs.symlink(e,t,u,r):void ys(o,(n=>{if(n)return r(n);hs.symlink(e,t,u,r)}))))}))}))))})),createSymlinkSync:function(e,t,n){if(hs.existsSync(t))return;const r=gs(e,t);e=r.toDst,n=vs(r.toCwd,n);const u=ms.dirname(t);return hs.existsSync(u)||Cs(u),hs.symlinkSync(e,t,n)}};var Os,bs={createFile:ns.createFile,createFileSync:ns.createFileSync,ensureFile:ns.createFile,ensureFileSync:ns.createFileSync,createLink:cs.createLink,createLinkSync:cs.createLinkSync,ensureLink:cs.createLink,ensureLinkSync:cs.createLinkSync,createSymlink:ws.createSymlink,createSymlinkSync:ws.createSymlinkSync,ensureSymlink:ws.createSymlink,ensureSymlinkSync:ws.createSymlinkSync};try{Os=we}catch(e){Os=D.default}function _s(e,t){var n,r="\n";return"object"==typeof t&&null!==t&&(t.spaces&&(n=t.spaces),t.EOL&&(r=t.EOL)),JSON.stringify(e,t?t.replacer:null,n).replace(/\n/g,r)+r}function Bs(e){return Buffer.isBuffer(e)&&(e=e.toString("utf8")),e=e.replace(/^\uFEFF/,"")}var Ps={readFile:function(e,t,n){null==n&&(n=t,t={}),"string"==typeof t&&(t={encoding:t});var r=(t=t||{}).fs||Os,u=!0;"throws"in t&&(u=t.throws),r.readFile(e,t,(function(r,o){if(r)return n(r);var i;o=Bs(o);try{i=JSON.parse(o,t?t.reviver:null)}catch(t){return u?(t.message=e+": "+t.message,n(t)):n(null,null)}n(null,i)}))},readFileSync:function(e,t){"string"==typeof(t=t||{})&&(t={encoding:t});var n=t.fs||Os,r=!0;"throws"in t&&(r=t.throws);try{var u=n.readFileSync(e,t);return u=Bs(u),JSON.parse(u,t.reviver)}catch(t){if(r)throw t.message=e+": "+t.message,t;return null}},writeFile:function(e,t,n,r){null==r&&(r=n,n={});var u=(n=n||{}).fs||Os,o="";try{o=_s(t,n)}catch(e){return void(r&&r(e,null))}u.writeFile(e,o,n,r)},writeFileSync:function(e,t,n){var r=(n=n||{}).fs||Os,u=_s(t,n);return r.writeFileSync(e,u,n)}},ks=Ps;const xs=yo.fromCallback,Ns=ks;var Is={readJson:xs(Ns.readFile),readJsonSync:Ns.readFileSync,writeJson:xs(Ns.writeFile),writeJsonSync:Ns.writeFileSync};const Ts=p.default,Rs=Io,Ms=fi.pathExists,Ls=Is;var js=function(e,t,n,r){"function"==typeof n&&(r=n,n={});const u=Ts.dirname(e);Ms(u,((o,i)=>o?r(o):i?Ls.writeJson(e,t,n,r):void Rs.mkdirs(u,(u=>{if(u)return r(u);Ls.writeJson(e,t,n,r)}))))};const $s=we,Hs=p.default,Js=Io,Gs=Is;var Vs=function(e,t,n){const r=Hs.dirname(e);$s.existsSync(r)||Js.mkdirsSync(r),Gs.writeJsonSync(e,t,n)};const Us=yo.fromCallback,Ws=Is;Ws.outputJson=Us(js),Ws.outputJsonSync=Vs,Ws.outputJSON=Ws.outputJson,Ws.outputJSONSync=Ws.outputJsonSync,Ws.writeJSON=Ws.writeJson,Ws.writeJSONSync=Ws.writeJsonSync,Ws.readJSON=Ws.readJson,Ws.readJSONSync=Ws.readJsonSync;var zs=Ws;const Ks=we,qs=p.default,Ys=ci.copySync,Xs=Ji.removeSync,Zs=Io.mkdirpSync,Qs=Zo;function ec(e,t,n){try{Ks.renameSync(e,t)}catch(r){if("EXDEV"!==r.code)throw r;return function(e,t,n){const r={overwrite:n,errorOnExist:!0};return Ys(e,t,r),Xs(e)}(e,t,n)}}var tc=function(e,t,n){const r=(n=n||{}).overwrite||n.clobber||!1,{srcStat:u}=Qs.checkPathsSync(e,t,"move");return Qs.checkParentPathsSync(e,u,t,"move"),Zs(qs.dirname(t)),function(e,t,n){if(n)return Xs(t),ec(e,t,n);if(Ks.existsSync(t))throw new Error("dest already exists.");return ec(e,t,n)}(e,t,r)},nc={moveSync:tc};const rc=we,uc=p.default,oc=bi.copy,ic=Ji.remove,sc=Io.mkdirp,cc=fi.pathExists,ac=Zo;function lc(e,t,n,r){rc.rename(e,t,(u=>u?"EXDEV"!==u.code?r(u):function(e,t,n,r){const u={overwrite:n,errorOnExist:!0};oc(e,t,u,(t=>t?r(t):ic(e,r)))}(e,t,n,r):r()))}var fc=function(e,t,n,r){"function"==typeof n&&(r=n,n={});const u=n.overwrite||n.clobber||!1;ac.checkPaths(e,t,"move",((n,o)=>{if(n)return r(n);const{srcStat:i}=o;ac.checkParentPaths(e,i,t,"move",(n=>{if(n)return r(n);sc(uc.dirname(t),(n=>n?r(n):function(e,t,n,r){if(n)return ic(t,(u=>u?r(u):lc(e,t,n,r)));cc(t,((u,o)=>u?r(u):o?r(new Error("dest already exists.")):lc(e,t,n,r)))}(e,t,u,r)))}))}))};var dc={move:(0,yo.fromCallback)(fc)};const Dc=yo.fromCallback,pc=we,Ec=p.default,mc=Io,hc=fi.pathExists;var yc={outputFile:Dc((function(e,t,n,r){"function"==typeof n&&(r=n,n="utf8");const u=Ec.dirname(e);hc(u,((o,i)=>o?r(o):i?pc.writeFile(e,t,n,r):void mc.mkdirs(u,(u=>{if(u)return r(u);pc.writeFile(e,t,n,r)}))))})),outputFileSync:function(e,...t){const n=Ec.dirname(e);if(pc.existsSync(n))return pc.writeFileSync(e,...t);mc.mkdirsSync(n),pc.writeFileSync(e,...t)}};!function(e){e.exports=Object.assign({},ho,ci,bi,Yi,bs,zs,Io,nc,dc,yc,fi,Ji);const t=D.default;Object.getOwnPropertyDescriptor(t,"promises")&&Object.defineProperty(e.exports,"promises",{get:()=>t.promises})}(mo);const Cc=Nr.exports("streamroller:fileNameFormatter"),Fc=p.default;const gc=Nr.exports("streamroller:fileNameParser"),Ac=nu.exports;const vc=Nr.exports("streamroller:moveAndMaybeCompressFile"),Sc=mo.exports,wc=v.default;var Oc=async(e,t,n)=>{if(n=function(e){const t={mode:parseInt("0600",8),compress:!1},n=Object.assign({},t,e);return vc(`_parseOption: moveAndMaybeCompressFile called with option=${JSON.stringify(n)}`),n}(n),e!==t){if(await Sc.pathExists(e))if(vc(`moveAndMaybeCompressFile: moving file from ${e} to ${t} ${n.compress?"with":"without"} compress`),n.compress)await new Promise(((r,u)=>{let o=!1;const i=Sc.createWriteStream(t,{mode:n.mode,flags:"wx"}).on("open",(()=>{o=!0;const t=Sc.createReadStream(e).on("open",(()=>{t.pipe(wc.createGzip()).pipe(i)})).on("error",(t=>{vc(`moveAndMaybeCompressFile: error reading ${e}`,t),i.destroy(t)}))})).on("finish",(()=>{vc(`moveAndMaybeCompressFile: finished compressing ${t}, deleting ${e}`),Sc.unlink(e).then(r).catch((t=>{vc(`moveAndMaybeCompressFile: error deleting ${e}, truncating instead`,t),Sc.truncate(e).then(r).catch((t=>{vc(`moveAndMaybeCompressFile: error truncating ${e}`,t),u(t)}))}))})).on("error",(e=>{o?(vc(`moveAndMaybeCompressFile: error writing ${t}, deleting`,e),Sc.unlink(t).then((()=>{u(e)})).catch((e=>{vc(`moveAndMaybeCompressFile: error deleting ${t}`,e),u(e)}))):(vc(`moveAndMaybeCompressFile: error creating ${t}`,e),u(e))}))})).catch((()=>{}));else{vc(`moveAndMaybeCompressFile: renaming ${e} to ${t}`);try{await Sc.move(e,t,{overwrite:!0})}catch(n){if(vc(`moveAndMaybeCompressFile: error renaming ${e} to ${t}`,n),"ENOENT"!==n.code){vc("moveAndMaybeCompressFile: trying copy+truncate instead");try{await Sc.copy(e,t,{overwrite:!0}),await Sc.truncate(e)}catch(e){vc("moveAndMaybeCompressFile: error copy+truncate",e)}}}}}else vc("moveAndMaybeCompressFile: source and target are the same, not doing anything")};const bc=Nr.exports("streamroller:RollingFileWriteStream"),_c=mo.exports,Bc=p.default,Pc=E.default,kc=()=>new Date,xc=nu.exports,{Writable:Nc}=C.default,Ic=({file:e,keepFileExt:t,needsIndex:n,alwaysIncludeDate:r,compress:u,fileNameSep:o})=>{let i=o||".";const s=Fc.join(e.dir,e.name),c=t=>t+e.ext,a=(e,t,r)=>!n&&r||!t?e:e+i+t,l=(e,t,n)=>(t>0||r)&&n?e+i+n:e,f=(e,t)=>t&&u?e+".gz":e,d=t?[l,a,c,f]:[c,l,a,f];return({date:e,index:t})=>(Cc(`_formatFileName: date=${e}, index=${t}`),d.reduce(((n,r)=>r(n,t,e)),s))},Tc=({file:e,keepFileExt:t,pattern:n,fileNameSep:r})=>{let u=r||".";const o="__NOT_MATCHING__";let i=[(e,t)=>e.endsWith(".gz")?(gc("it is gzipped"),t.isCompressed=!0,e.slice(0,-1*".gz".length)):e,t?t=>t.startsWith(e.name)&&t.endsWith(e.ext)?(gc("it starts and ends with the right things"),t.slice(e.name.length+1,-1*e.ext.length)):o:t=>t.startsWith(e.base)?(gc("it starts with the right things"),t.slice(e.base.length+1)):o,n?(e,t)=>{const r=e.split(u);let o=r[r.length-1];gc("items: ",r,", indexStr: ",o);let i=e;void 0!==o&&o.match(/^\d+$/)?(i=e.slice(0,-1*(o.length+1)),gc(`dateStr is ${i}`),n&&!i&&(i=o,o="0")):o="0";try{const r=Ac.parse(n,i,new Date(0,0));return Ac.asString(n,r)!==i?e:(t.index=parseInt(o,10),t.date=i,t.timestamp=r.getTime(),"")}catch(t){return gc(`Problem parsing ${i} as ${n}, error was: `,t),e}}:(e,t)=>e.match(/^\d+$/)?(gc("it has an index"),t.index=parseInt(e,10),""):e];return e=>{let t={filename:e,index:0,isCompressed:!1};return i.reduce(((e,n)=>n(e,t)),e)?null:t}},Rc=Oc;var Mc=class extends Nc{constructor(e,t){if(bc(`constructor: creating RollingFileWriteStream. path=${e}`),"string"!=typeof e||0===e.length)throw new Error(`Invalid filename: ${e}`);if(e.endsWith(Bc.sep))throw new Error(`Filename is a directory: ${e}`);0===e.indexOf(`~${Bc.sep}`)&&(e=e.replace("~",Pc.homedir())),super(t),this.options=this._parseOption(t),this.fileObject=Bc.parse(e),""===this.fileObject.dir&&(this.fileObject=Bc.parse(Bc.join(process.cwd(),e))),this.fileFormatter=Ic({file:this.fileObject,alwaysIncludeDate:this.options.alwaysIncludePattern,needsIndex:this.options.maxSize 0`)}else delete n.maxSize;if(n.numBackups||0===n.numBackups){if(n.numBackups<0)throw new Error(`options.numBackups (${n.numBackups}) should be >= 0`);if(n.numBackups>=Number.MAX_SAFE_INTEGER)throw new Error(`options.numBackups (${n.numBackups}) should be < Number.MAX_SAFE_INTEGER`);n.numToKeep=n.numBackups+1}else if(n.numToKeep<=0)throw new Error(`options.numToKeep (${n.numToKeep}) should be > 0`);return bc(`_parseOption: creating stream with option=${JSON.stringify(n)}`),n}_final(e){this.currentFileStream.end("",this.options.encoding,e)}_write(e,t,n){this._shouldRoll().then((()=>{bc(`_write: writing chunk. file=${this.currentFileStream.path} state=${JSON.stringify(this.state)} chunk=${e}`),this.currentFileStream.write(e,t,(t=>{this.state.currentSize+=e.length,n(t)}))}))}async _shouldRoll(){(this._dateChanged()||this._tooBig())&&(bc(`_shouldRoll: rolling because dateChanged? ${this._dateChanged()} or tooBig? ${this._tooBig()}`),await this._roll())}_dateChanged(){return this.state.currentDate&&this.state.currentDate!==xc(this.options.pattern,kc())}_tooBig(){return this.state.currentSize>=this.options.maxSize}_roll(){return bc("_roll: closing the current stream"),new Promise(((e,t)=>{this.currentFileStream.end("",this.options.encoding,(()=>{this._moveOldFiles().then(e).catch(t)}))}))}async _moveOldFiles(){const e=await this._getExistingFiles();for(let t=(this.state.currentDate?e.filter((e=>e.date===this.state.currentDate)):e).length;t>=0;t--){bc(`_moveOldFiles: i = ${t}`);const e=this.fileFormatter({date:this.state.currentDate,index:t}),n=this.fileFormatter({date:this.state.currentDate,index:t+1}),r={compress:this.options.compress&&0===t,mode:this.options.mode};await Rc(e,n,r)}this.state.currentSize=0,this.state.currentDate=this.state.currentDate?xc(this.options.pattern,kc()):null,bc(`_moveOldFiles: finished rolling files. state=${JSON.stringify(this.state)}`),this._renewWriteStream(),await new Promise(((e,t)=>{this.currentFileStream.write("","utf8",(()=>{this._clean().then(e).catch(t)}))}))}async _getExistingFiles(){const e=await _c.readdir(this.fileObject.dir).catch((()=>[]));bc(`_getExistingFiles: files=${e}`);const t=e.map((e=>this.fileNameParser(e))).filter((e=>e)),n=e=>(e.timestamp?e.timestamp:kc().getTime())-e.index;return t.sort(((e,t)=>n(e)-n(t))),t}_renewWriteStream(){const e=this.fileFormatter({date:this.state.currentDate,index:0}),t=e=>{try{return _c.mkdirSync(e,{recursive:!0})}catch(n){if("ENOENT"===n.code)return t(Bc.dirname(e)),t(e);if("EEXIST"!==n.code&&"EROFS"!==n.code)throw n;try{if(_c.statSync(e).isDirectory())return e;throw n}catch(e){throw n}}};t(this.fileObject.dir);const n={flags:this.options.flags,encoding:this.options.encoding,mode:this.options.mode};var r,u;_c.appendFileSync(e,"",(r={...n},u="flags",r["flag"]=r[u],delete r[u],r)),this.currentFileStream=_c.createWriteStream(e,n),this.currentFileStream.on("error",(e=>{this.emit("error",e)}))}async _clean(){const e=await this._getExistingFiles();if(bc(`_clean: numToKeep = ${this.options.numToKeep}, existingFiles = ${e.length}`),bc("_clean: existing files are: ",e),this._tooManyFiles(e.length)){const n=e.slice(0,e.length-this.options.numToKeep).map((e=>Bc.format({dir:this.fileObject.dir,base:e.filename})));await(t=n,bc(`deleteFiles: files to delete: ${t}`),Promise.all(t.map((e=>_c.unlink(e).catch((t=>{bc(`deleteFiles: error when unlinking ${e}, ignoring. Error was ${t}`)}))))))}var t}_tooManyFiles(e){return this.options.numToKeep>0&&e>this.options.numToKeep}};const Lc=Mc;var jc=class extends Lc{constructor(e,t,n,r){r||(r={}),t&&(r.maxSize=t),r.numBackups||0===r.numBackups||(n||0===n||(n=1),r.numBackups=n),super(e,r),this.backups=r.numBackups,this.size=this.options.maxSize}get theStream(){return this.currentFileStream}};const $c=Mc;var Hc={RollingFileWriteStream:Mc,RollingFileStream:jc,DateRollingFileStream:class extends $c{constructor(e,t,n){t&&"object"==typeof t&&(n=t,t=null),n||(n={}),t||(t="yyyy-MM-dd"),n.pattern=t,n.numBackups||0===n.numBackups?n.daysToKeep=n.numBackups:(n.daysToKeep||0===n.daysToKeep?process.emitWarning("options.daysToKeep is deprecated due to the confusion it causes when used together with file size rolling. Please use options.numBackups instead.","DeprecationWarning","streamroller-DEP0001"):n.daysToKeep=1,n.numBackups=n.daysToKeep),super(e,n),this.mode=this.options.mode}get theStream(){return this.currentFileStream}}};const Jc=Nr.exports("log4js:file"),Gc=p.default,Vc=Hc,Uc=E.default.EOL;let Wc=!1;const zc=new Set;function Kc(){zc.forEach((e=>{e.sighupHandler()}))}function qc(e,t,n,r){const u=new Vc.RollingFileStream(e,t,n,r);return u.on("error",(t=>{console.error("log4js.fileAppender - Writing to file %s, error happened ",e,t)})),u.on("drain",(()=>{process.emit("log4js:pause",!1)})),u}Eo.configure=function(e,t){let n=t.basicLayout;return e.layout&&(n=t.layout(e.layout.type,e.layout)),e.mode=e.mode||384,function(e,t,n,r,u,o){e=Gc.normalize(e),Jc("Creating file appender (",e,", ",n,", ",r=r||0===r?r:5,", ",u,", ",o,")");let i=qc(e,n,r,u);const s=function(e){if(i.writable){if(!0===u.removeColor){const t=/\x1b[[0-9;]*m/g;e.data=e.data.map((e=>"string"==typeof e?e.replace(t,""):e))}i.write(t(e,o)+Uc,"utf8")||process.emit("log4js:pause",!0)}};return s.reopen=function(){i.end((()=>{i=qc(e,n,r,u)}))},s.sighupHandler=function(){Jc("SIGHUP handler called."),s.reopen()},s.shutdown=function(e){zc.delete(s),0===zc.size&&Wc&&(process.removeListener("SIGHUP",Kc),Wc=!1),i.end("","utf-8",e)},zc.add(s),Wc||(process.on("SIGHUP",Kc),Wc=!0),s}(e.filename,n,e.maxLogSize,e.backups,e,e.timezoneOffset)};var Yc={};const Xc=Hc,Zc=E.default.EOL;function Qc(e,t,n,r,u){r.maxSize=r.maxLogSize;const o=function(e,t,n){const r=new Xc.DateRollingFileStream(e,t,n);return r.on("error",(t=>{console.error("log4js.dateFileAppender - Writing to file %s, error happened ",e,t)})),r.on("drain",(()=>{process.emit("log4js:pause",!1)})),r}(e,t,r),i=function(e){o.writable&&(o.write(n(e,u)+Zc,"utf8")||process.emit("log4js:pause",!0))};return i.shutdown=function(e){o.end("","utf-8",e)},i}Yc.configure=function(e,t){let n=t.basicLayout;return e.layout&&(n=t.layout(e.layout.type,e.layout)),e.alwaysIncludePattern||(e.alwaysIncludePattern=!1),e.mode=e.mode||384,Qc(e.filename,e.pattern,n,e,e.timezoneOffset)};var ea={};const ta=Nr.exports("log4js:fileSync"),na=p.default,ra=D.default,ua=E.default.EOL||"\n";function oa(e,t){if(ra.existsSync(e))return;const n=ra.openSync(e,t.flags,t.mode);ra.closeSync(n)}class ia{constructor(e,t,n,r){ta("In RollingFileStream"),function(){if(!e||!t||t<=0)throw new Error("You must specify a filename and file size")}(),this.filename=e,this.size=t,this.backups=n,this.options=r,this.currentSize=0,this.currentSize=function(e){let t=0;try{t=ra.statSync(e).size}catch(t){oa(e,r)}return t}(this.filename)}shouldRoll(){return ta("should roll with current size %d, and max size %d",this.currentSize,this.size),this.currentSize>=this.size}roll(e){const t=this,n=new RegExp(`^${na.basename(e)}`);function r(e){return n.test(e)}function u(t){return parseInt(t.substring(`${na.basename(e)}.`.length),10)||0}function o(e,t){return u(e)>u(t)?1:u(e) ${e}.${r+1}`),ra.renameSync(na.join(na.dirname(e),n),`${e}.${r+1}`)}}ta("Rolling, rolling, rolling"),ta("Renaming the old files"),ra.readdirSync(na.dirname(e)).filter(r).sort(o).reverse().forEach(i)}write(e,t){const n=this;ta("in write"),this.shouldRoll()&&(this.currentSize=0,this.roll(this.filename)),ta("writing the chunk to the file"),n.currentSize+=e.length,ra.appendFileSync(n.filename,e)}}ea.configure=function(e,t){let n=t.basicLayout;e.layout&&(n=t.layout(e.layout.type,e.layout));const r={flags:e.flags||"a",encoding:e.encoding||"utf8",mode:e.mode||384};return function(e,t,n,r,u,o){ta("fileSync appender created");const i=function(e,t,n){let r;var u;return t?r=new ia(e,t,n,o):(oa(u=e,o),r={write(e){ra.appendFileSync(u,e)}}),r}(e=na.normalize(e),n,r=r||0===r?r:5);return e=>{i.write(t(e,u)+ua)}}(e.filename,n,e.maxLogSize,e.backups,e.timezoneOffset,r)};var sa={};const ca=Nr.exports("log4js:tcp"),aa=S.default;sa.configure=function(e,t){ca(`configure with config = ${e}`);let n=function(e){return e.serialise()};return e.layout&&(n=t.layout(e.layout.type,e.layout)),function(e,t){let n=!1;const r=[];let u,o=3,i="__LOG4JS__";function s(e){ca("Writing log event to socket"),n=u.write(`${t(e)}${i}`,"utf8")}function c(){let e;for(ca("emptying buffer");e=r.shift();)s(e)}function a(e){n?s(e):(ca("buffering log event because it cannot write at the moment"),r.push(e))}return function t(){ca(`appender creating socket to ${e.host||"localhost"}:${e.port||5e3}`),i=`${e.endMsg||"__LOG4JS__"}`,u=aa.createConnection(e.port||5e3,e.host||"localhost"),u.on("connect",(()=>{ca("socket connected"),c(),n=!0})),u.on("drain",(()=>{ca("drain event received, emptying buffer"),n=!0,c()})),u.on("timeout",u.end.bind(u)),u.on("error",(e=>{ca("connection error",e),n=!1,c()})),u.on("close",t)}(),a.shutdown=function(e){ca("shutdown called"),r.length&&o?(ca("buffer has items, waiting 100ms to empty"),o-=1,setTimeout((()=>{a.shutdown(e)}),100)):(u.removeAllListeners("close"),u.end(e))},a}(e,n)};const la=p.default,fa=Nr.exports("log4js:appenders"),da=tu,Da=eo,pa=gu,Ea=hu,ma=to,ha=new Map;ha.set("console",oo),ha.set("stdout",so),ha.set("stderr",co),ha.set("logLevelFilter",ao),ha.set("categoryFilter",lo),ha.set("noLogFilter",Do),ha.set("file",Eo),ha.set("dateFile",Yc),ha.set("fileSync",ea),ha.set("tcp",sa);const ya=new Map,Ca=(e,t)=>{fa("Loading module from ",e);try{return require(e)}catch(n){return void da.throwExceptionIf(t,"MODULE_NOT_FOUND"!==n.code,`appender "${e}" could not be loaded (error was: ${n})`)}},Fa=new Set,ga=(e,t)=>{if(ya.has(e))return ya.get(e);if(!t.appenders[e])return!1;if(Fa.has(e))throw new Error(`Dependency loop detected for appender ${e}.`);Fa.add(e),fa(`Creating appender ${e}`);const n=Aa(e,t);return Fa.delete(e),ya.set(e,n),n},Aa=(e,t)=>{const n=t.appenders[e],r=n.type.configure?n.type:((e,t)=>ha.get(e)||Ca(`./${e}`,t)||Ca(e,t)||require.main&&Ca(la.join(la.dirname(require.main.filename),e),t)||Ca(la.join(process.cwd(),e),t))(n.type,t);return da.throwExceptionIf(t,da.not(r),`appender "${e}" is not valid (type "${n.type}" could not be found)`),r.appender&&fa(`DEPRECATION: Appender ${n.type} exports an appender function.`),r.shutdown&&fa(`DEPRECATION: Appender ${n.type} exports a shutdown function.`),fa(`${e}: clustering.isMaster ? ${Da.isMaster()}`),fa(`${e}: appenderModule is ${F.default.inspect(r)}`),Da.onlyOnMaster((()=>(fa(`calling appenderModule.configure for ${e} / ${n.type}`),r.configure(ma.modifyConfig(n),Ea,(e=>ga(e,t)),pa))),(()=>{}))},va=e=>{ya.clear(),Fa.clear();const t=[];Object.values(e.categories).forEach((e=>{t.push(...e.appenders)})),Object.keys(e.appenders).forEach((n=>{(t.includes(n)||"tcp-server"===e.appenders[n].type)&&ga(n,e)}))},Sa=()=>{va({appenders:{out:{type:"stdout"}},categories:{default:{appenders:["out"],level:"trace"}}})};Sa(),da.addListener((e=>{da.throwExceptionIf(e,da.not(da.anObject(e.appenders)),'must have a property "appenders" of type object.');const t=Object.keys(e.appenders);da.throwExceptionIf(e,da.not(t.length),"must define at least one appender."),t.forEach((t=>{da.throwExceptionIf(e,da.not(e.appenders[t].type),`appender "${t}" is not valid (must be an object with property "type")`)}))})),da.addListener(va),Au.exports=ya,Au.exports.init=Sa;var wa={exports:{}};!function(e){const t=Nr.exports("log4js:categories"),n=tu,r=gu,u=Au.exports,o=new Map;function i(e,t,n){if(!1===t.inherit)return;const r=n.lastIndexOf(".");if(r<0)return;const u=n.substring(0,r);let o=e.categories[u];o||(o={inherit:!0,appenders:[]}),i(e,o,u),!e.categories[u]&&o.appenders&&o.appenders.length&&o.level&&(e.categories[u]=o),t.appenders=t.appenders||[],t.level=t.level||o.level,o.appenders.forEach((e=>{t.appenders.includes(e)||t.appenders.push(e)})),t.parent=o}function s(e){if(!e.categories)return;Object.keys(e.categories).forEach((t=>{const n=e.categories[t];i(e,n,t)}))}n.addPreProcessingListener((e=>s(e))),n.addListener((e=>{n.throwExceptionIf(e,n.not(n.anObject(e.categories)),'must have a property "categories" of type object.');const t=Object.keys(e.categories);n.throwExceptionIf(e,n.not(t.length),"must define at least one category."),t.forEach((t=>{const o=e.categories[t];n.throwExceptionIf(e,[n.not(o.appenders),n.not(o.level)],`category "${t}" is not valid (must be an object with properties "appenders" and "level")`),n.throwExceptionIf(e,n.not(Array.isArray(o.appenders)),`category "${t}" is not valid (appenders must be an array of appender names)`),n.throwExceptionIf(e,n.not(o.appenders.length),`category "${t}" is not valid (appenders must contain at least one appender name)`),Object.prototype.hasOwnProperty.call(o,"enableCallStack")&&n.throwExceptionIf(e,"boolean"!=typeof o.enableCallStack,`category "${t}" is not valid (enableCallStack must be boolean type)`),o.appenders.forEach((r=>{n.throwExceptionIf(e,n.not(u.get(r)),`category "${t}" is not valid (appender "${r}" is not defined)`)})),n.throwExceptionIf(e,n.not(r.getLevel(o.level)),`category "${t}" is not valid (level "${o.level}" not recognised; valid levels are ${r.levels.join(", ")})`)})),n.throwExceptionIf(e,n.not(e.categories.default),'must define a "default" category.')}));const c=e=>{o.clear();Object.keys(e.categories).forEach((n=>{const i=e.categories[n],s=[];i.appenders.forEach((e=>{s.push(u.get(e)),t(`Creating category ${n}`),o.set(n,{appenders:s,level:r.getLevel(i.level),enableCallStack:i.enableCallStack||!1})}))}))},a=()=>{c({categories:{default:{appenders:["out"],level:"OFF"}}})};a(),n.addListener(c);const l=e=>(t(`configForCategory: searching for config for ${e}`),o.has(e)?(t(`configForCategory: ${e} exists in config, returning it`),o.get(e)):e.indexOf(".")>0?(t(`configForCategory: ${e} has hierarchy, searching for parents`),l(e.substring(0,e.lastIndexOf(".")))):(t("configForCategory: returning config for default category"),l("default")));e.exports=o,e.exports=Object.assign(e.exports,{appendersForCategory:e=>l(e).appenders,getLevelForCategory:e=>l(e).level,setLevelForCategory:(e,n)=>{let r=o.get(e);if(t(`setLevelForCategory: found ${r} for ${e}`),!r){const n=l(e);t(`setLevelForCategory: no config found for category, found ${n} for parents of ${e}`),r={appenders:n.appenders}}r.level=n,o.set(e,r)},getEnableCallStackForCategory:e=>!0===l(e).enableCallStack,setEnableCallStackForCategory:(e,t)=>{l(e).enableCallStack=t},init:a})}(wa);const Oa=Nr.exports("log4js:logger"),ba=Hu,_a=gu,Ba=eo,Pa=wa.exports,ka=tu,xa=/at (?:(.+)\s+\()?(?:(.+?):(\d+)(?::(\d+))?|([^)]+))\)?/;function Na(e,t=4){const n=e.stack.split("\n").slice(t),r=xa.exec(n[0]);return r&&6===r.length?{functionName:r[1],fileName:r[2],lineNumber:parseInt(r[3],10),columnNumber:parseInt(r[4],10),callStack:n.join("\n")}:null}class Ia{constructor(e){if(!e)throw new Error("No category provided.");this.category=e,this.context={},this.parseCallStack=Na,Oa(`Logger created (${this.category}, ${this.level})`)}get level(){return _a.getLevel(Pa.getLevelForCategory(this.category),_a.TRACE)}set level(e){Pa.setLevelForCategory(this.category,_a.getLevel(e,this.level))}get useCallStack(){return Pa.getEnableCallStackForCategory(this.category)}set useCallStack(e){Pa.setEnableCallStackForCategory(this.category,!0===e)}log(e,...t){let n=_a.getLevel(e);n||(this._log(_a.WARN,"log4js:logger.log: invalid value for log-level as first parameter given: ",e),n=_a.INFO),this.isLevelEnabled(n)&&this._log(n,t)}isLevelEnabled(e){return this.level.isLessThanOrEqualTo(e)}_log(e,t){Oa(`sending log data (${e}) to appenders`);const n=new ba(this.category,e,t,this.context,this.useCallStack&&this.parseCallStack(new Error));Ba.send(n)}addContext(e,t){this.context[e]=t}removeContext(e){delete this.context[e]}clearContext(){this.context={}}setParseCallStackFunction(e){this.parseCallStack=e}}function Ta(e){const t=_a.getLevel(e),n=t.toString().toLowerCase().replace(/_([a-z])/g,(e=>e[1].toUpperCase())),r=n[0].toUpperCase()+n.slice(1);Ia.prototype[`is${r}Enabled`]=function(){return this.isLevelEnabled(t)},Ia.prototype[n]=function(...e){this.log(t,...e)}}_a.levels.forEach(Ta),ka.addListener((()=>{_a.levels.forEach(Ta)}));var Ra=Ia;const Ma=gu;function La(e){return e.originalUrl||e.url}function ja(e,t){for(let n=0;ne.source?e.source:e));t=new RegExp(n.join("|"))}return t}(t.nolog);return(e,i,s)=>{if(e._logging)return s();if(o&&o.test(e.originalUrl))return s();if(n.isLevelEnabled(r)||"auto"===t.level){const o=new Date,{writeHead:s}=i;e._logging=!0,i.writeHead=(e,t)=>{i.writeHead=s,i.writeHead(e,t),i.__statusCode=e,i.__headers=t||{}},i.on("finish",(()=>{i.responseTime=new Date-o,i.statusCode&&"auto"===t.level&&(r=Ma.INFO,i.statusCode>=300&&(r=Ma.WARN),i.statusCode>=400&&(r=Ma.ERROR)),r=function(e,t,n){let r=t;if(n){const t=n.find((t=>{let n=!1;return n=t.from&&t.to?e>=t.from&&e<=t.to:-1!==t.codes.indexOf(e),n}));t&&(r=Ma.getLevel(t.level,r))}return r}(i.statusCode,r,t.statusRules);const s=function(e,t,n){const r=[];return r.push({token:":url",replacement:La(e)}),r.push({token:":protocol",replacement:e.protocol}),r.push({token:":hostname",replacement:e.hostname}),r.push({token:":method",replacement:e.method}),r.push({token:":status",replacement:t.__statusCode||t.statusCode}),r.push({token:":response-time",replacement:t.responseTime}),r.push({token:":date",replacement:(new Date).toUTCString()}),r.push({token:":referrer",replacement:e.headers.referer||e.headers.referrer||""}),r.push({token:":http-version",replacement:`${e.httpVersionMajor}.${e.httpVersionMinor}`}),r.push({token:":remote-addr",replacement:e.headers["x-forwarded-for"]||e.ip||e._remoteAddress||e.socket&&(e.socket.remoteAddress||e.socket.socket&&e.socket.socket.remoteAddress)}),r.push({token:":user-agent",replacement:e.headers["user-agent"]}),r.push({token:":content-length",replacement:t.getHeader("content-length")||t.__headers&&t.__headers["Content-Length"]||"-"}),r.push({token:/:req\[([^\]]+)]/g,replacement:(t,n)=>e.headers[n.toLowerCase()]}),r.push({token:/:res\[([^\]]+)]/g,replacement:(e,n)=>t.getHeader(n.toLowerCase())||t.__headers&&t.__headers[n]}),(e=>{const t=e.concat();for(let e=0;eja(e,s)));t&&n.log(r,t)}else n.log(r,ja(u,s));t.context&&n.removeContext("res")}))}return s()}},nl=Va;let rl=!1;function ul(e){if(!rl)return;Ua("Received log event ",e);Za.appendersForCategory(e.categoryName).forEach((t=>{t(e)}))}function ol(e){rl&&il();let t=e;return"string"==typeof t&&(t=function(e){Ua(`Loading configuration from ${e}`);try{return JSON.parse(Wa.readFileSync(e,"utf8"))}catch(t){throw new Error(`Problem reading config from file "${e}". Error was ${t.message}`,t)}}(e)),Ua(`Configuration is ${t}`),Ka.configure(za(t)),el.onMessage(ul),rl=!0,sl}function il(e){Ua("Shutdown called. Disabling all log writing."),rl=!1;const t=Array.from(Xa.values());Xa.init(),Za.init();const n=t.reduceRight(((e,t)=>t.shutdown?e+1:e),0);if(0===n)return Ua("No appenders with shutdown functions found."),void 0!==e&&e();let r,u=0;function o(t){r=r||t,u+=1,Ua(`Appender shutdowns complete: ${u} / ${n}`),u>=n&&(Ua("All shutdown functions completed."),e&&e(r))}return Ua(`Found ${n} appenders with shutdown functions.`),t.filter((e=>e.shutdown)).forEach((e=>e.shutdown(o))),null}const sl={getLogger:function(e){return rl||ol(process.env.LOG4JS_CONFIG||{appenders:{out:{type:"stdout"}},categories:{default:{appenders:["out"],level:"OFF"}}}),new Qa(e||"default")},configure:ol,shutdown:il,connectLogger:tl,levels:Ya,addLayout:qa.addLayout,recording:function(){return nl}};var cl=sl,al={};Object.defineProperty(al,"__esModule",{value:!0}),al.levelMap=al.getLevel=al.setCategoriesLevel=al.getConfiguration=al.setConfiguration=void 0;const ll=cl;let fl={appenders:{debug:{type:"stdout",layout:{type:"pattern",pattern:"[%d] > hvigor %p %c %[%m%]"}},info:{type:"stdout",layout:{type:"pattern",pattern:"[%d] > hvigor %[%m%]"}},"no-pattern-info":{type:"stdout",layout:{type:"pattern",pattern:"%m"}},wrong:{type:"stderr",layout:{type:"pattern",pattern:"[%d] > hvigor %[%p: %m%]"}},"just-debug":{type:"logLevelFilter",appender:"debug",level:"debug",maxLevel:"debug"},"just-info":{type:"logLevelFilter",appender:"info",level:"info",maxLevel:"info"},"just-wrong":{type:"logLevelFilter",appender:"wrong",level:"warn",maxLevel:"error"}},categories:{default:{appenders:["just-debug","just-info","just-wrong"],level:"debug"},"no-pattern-info":{appenders:["no-pattern-info"],level:"info"}}};al.setConfiguration=e=>{fl=e};al.getConfiguration=()=>fl;let dl=ll.levels.DEBUG;al.setCategoriesLevel=(e,t)=>{dl=e;const n=fl.categories;for(const r in n)(null==t?void 0:t.includes(r))||Object.prototype.hasOwnProperty.call(n,r)&&(n[r].level=e.levelStr)};al.getLevel=()=>dl,al.levelMap=new Map([["ALL",ll.levels.ALL],["MARK",ll.levels.MARK],["TRACE",ll.levels.TRACE],["DEBUG",ll.levels.DEBUG],["INFO",ll.levels.INFO],["WARN",ll.levels.WARN],["ERROR",ll.levels.ERROR],["FATAL",ll.levels.FATAL],["OFF",ll.levels.OFF]]);var Dl=w&&w.__createBinding||(Object.create?function(e,t,n,r){void 0===r&&(r=n);var u=Object.getOwnPropertyDescriptor(t,n);u&&!("get"in u?!t.__esModule:u.writable||u.configurable)||(u={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,r,u)}:function(e,t,n,r){void 0===r&&(r=n),e[r]=t[n]}),pl=w&&w.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),El=w&&w.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var n in e)"default"!==n&&Object.prototype.hasOwnProperty.call(e,n)&&Dl(t,e,n);return pl(t,e),t};Object.defineProperty(xr,"__esModule",{value:!0}),xr.evaluateLogLevel=xr.HvigorLogger=void 0;const ml=El(cl),hl=cl,yl=El(F.default),Cl=al;class Fl{constructor(e){ml.configure((0,Cl.getConfiguration)()),this._logger=ml.getLogger(e),this._logger.level=(0,Cl.getLevel)()}static getLogger(e){return new Fl(e)}log(e,...t){this._logger.log(e,...t)}debug(e,...t){this._logger.debug(e,...t)}info(e,...t){this._logger.info(e,...t)}warn(e,...t){void 0!==e&&""!==e&&this._logger.warn(e,...t)}error(e,...t){this._logger.error(e,...t)}_printTaskExecuteInfo(e,t){this.info(`Finished :${e}... after ${t}`)}_printFailedTaskInfo(e){this.error(`Failed :${e}... `)}_printDisabledTaskInfo(e){this.info(`Disabled :${e}... `)}_printUpToDateTaskInfo(e){this.info(`UP-TO-DATE :${e}... `)}errorMessageExit(e,...t){throw new Error(yl.format(e,...t))}errorExit(e,t,...n){t&&this._logger.error(t,n),this._logger.error(e.stack)}setLevel(e,t){(0,Cl.setCategoriesLevel)(e,t),ml.shutdown(),ml.configure((0,Cl.getConfiguration)())}getLevel(){return this._logger.level}configure(e){const t=(0,Cl.getConfiguration)(),n={appenders:{...t.appenders,...e.appenders},categories:{...t.categories,...e.categories}};(0,Cl.setConfiguration)(n),ml.shutdown(),ml.configure(n)}}xr.HvigorLogger=Fl,xr.evaluateLogLevel=function(e,t){t.debug?e.setLevel(hl.levels.DEBUG):t.warn?e.setLevel(hl.levels.WARN):t.error?e.setLevel(hl.levels.ERROR):e.setLevel(hl.levels.INFO)};var gl=w&&w.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(X,"__esModule",{value:!0}),X.parseJsonText=X.parseJsonFile=void 0;const Al=Z,vl=gl(kr),Sl=gl(p.default),wl=gl(E.default),Ol=xr.HvigorLogger.getLogger("parse-json-util");var bl;!function(e){e[e.Char=0]="Char",e[e.EOF=1]="EOF",e[e.Identifier=2]="Identifier"}(bl||(bl={}));let _l,Bl,Pl,kl,xl,Nl,Il="start",Tl=[],Rl=0,Ml=1,Ll=0,jl=!1,$l="default",Hl="'",Jl=1;function Gl(e,t=!1){Bl=String(e),Il="start",Tl=[],Rl=0,Ml=1,Ll=0,kl=void 0,jl=t;do{_l=Vl(),Xl[Il]()}while("eof"!==_l.type);return kl}function Vl(){for($l="default",xl="",Hl="'",Jl=1;;){Nl=Ul();const e=zl[$l]();if(e)return e}}function Ul(){if(Bl[Rl])return String.fromCodePoint(Bl.codePointAt(Rl))}function Wl(){const e=Ul();return"\n"===e?(Ml++,Ll=0):e?Ll+=e.length:Ll++,e&&(Rl+=e.length),e}X.parseJsonFile=function(e,t=!1,n="utf-8"){const r=vl.default.readFileSync(Sl.default.resolve(e),{encoding:n});try{return Gl(r,t)}catch(t){if(t instanceof SyntaxError){const n=t.message.split("at");2===n.length&&Ol.errorMessageExit(`${n[0].trim()}${wl.default.EOL}\t at ${e}:${n[1].trim()}`)}Ol.errorMessageExit(`${e} is not in valid JSON/JSON5 format.`)}},X.parseJsonText=Gl;const zl={default(){switch(Nl){case"/":return Wl(),void($l="comment");case void 0:return Wl(),Kl("eof")}if(!Al.JudgeUtil.isIgnoreChar(Nl)&&!Al.JudgeUtil.isSpaceSeparator(Nl))return zl[Il]();Wl()},start(){$l="value"},beforePropertyName(){switch(Nl){case"$":case"_":return xl=Wl(),void($l="identifierName");case"\\":return Wl(),void($l="identifierNameStartEscape");case"}":return Kl("punctuator",Wl());case'"':case"'":return Hl=Nl,Wl(),void($l="string")}if(Al.JudgeUtil.isIdStartChar(Nl))return xl+=Wl(),void($l="identifierName");throw tf(bl.Char,Wl())},afterPropertyName(){if(":"===Nl)return Kl("punctuator",Wl());throw tf(bl.Char,Wl())},beforePropertyValue(){$l="value"},afterPropertyValue(){switch(Nl){case",":case"}":return Kl("punctuator",Wl())}throw tf(bl.Char,Wl())},beforeArrayValue(){if("]"===Nl)return Kl("punctuator",Wl());$l="value"},afterArrayValue(){switch(Nl){case",":case"]":return Kl("punctuator",Wl())}throw tf(bl.Char,Wl())},end(){throw tf(bl.Char,Wl())},comment(){switch(Nl){case"*":return Wl(),void($l="multiLineComment");case"/":return Wl(),void($l="singleLineComment")}throw tf(bl.Char,Wl())},multiLineComment(){switch(Nl){case"*":return Wl(),void($l="multiLineCommentAsterisk");case void 0:throw tf(bl.Char,Wl())}Wl()},multiLineCommentAsterisk(){switch(Nl){case"*":return void Wl();case"/":return Wl(),void($l="default");case void 0:throw tf(bl.Char,Wl())}Wl(),$l="multiLineComment"},singleLineComment(){switch(Nl){case"\n":case"\r":case"\u2028":case"\u2029":return Wl(),void($l="default");case void 0:return Wl(),Kl("eof")}Wl()},value(){switch(Nl){case"{":case"[":return Kl("punctuator",Wl());case"n":return Wl(),ql("ull"),Kl("null",null);case"t":return Wl(),ql("rue"),Kl("boolean",!0);case"f":return Wl(),ql("alse"),Kl("boolean",!1);case"-":case"+":return"-"===Wl()&&(Jl=-1),void($l="numerical");case".":case"0":case"I":case"N":return void($l="numerical");case'"':case"'":return Hl=Nl,Wl(),xl="",void($l="string")}if(void 0===Nl||!Al.JudgeUtil.isDigitWithoutZero(Nl))throw tf(bl.Char,Wl());$l="numerical"},numerical(){switch(Nl){case".":return xl=Wl(),void($l="decimalPointLeading");case"0":return xl=Wl(),void($l="zero");case"I":return Wl(),ql("nfinity"),Kl("numeric",Jl*(1/0));case"N":return Wl(),ql("aN"),Kl("numeric",NaN)}if(void 0!==Nl&&Al.JudgeUtil.isDigitWithoutZero(Nl))return xl=Wl(),void($l="decimalInteger");throw tf(bl.Char,Wl())},zero(){switch(Nl){case".":case"e":case"E":return void($l="decimal");case"x":case"X":return xl+=Wl(),void($l="hexadecimal")}return Kl("numeric",0)},decimalInteger(){switch(Nl){case".":case"e":case"E":return void($l="decimal")}if(!Al.JudgeUtil.isDigit(Nl))return Kl("numeric",Jl*Number(xl));xl+=Wl()},decimal(){switch(Nl){case".":xl+=Wl(),$l="decimalFraction";break;case"e":case"E":xl+=Wl(),$l="decimalExponent"}},decimalPointLeading(){if(Al.JudgeUtil.isDigit(Nl))return xl+=Wl(),void($l="decimalFraction");throw tf(bl.Char,Wl())},decimalFraction(){switch(Nl){case"e":case"E":return xl+=Wl(),void($l="decimalExponent")}if(!Al.JudgeUtil.isDigit(Nl))return Kl("numeric",Jl*Number(xl));xl+=Wl()},decimalExponent(){switch(Nl){case"+":case"-":return xl+=Wl(),void($l="decimalExponentSign")}if(Al.JudgeUtil.isDigit(Nl))return xl+=Wl(),void($l="decimalExponentInteger");throw tf(bl.Char,Wl())},decimalExponentSign(){if(Al.JudgeUtil.isDigit(Nl))return xl+=Wl(),void($l="decimalExponentInteger");throw tf(bl.Char,Wl())},decimalExponentInteger(){if(!Al.JudgeUtil.isDigit(Nl))return Kl("numeric",Jl*Number(xl));xl+=Wl()},hexadecimal(){if(Al.JudgeUtil.isHexDigit(Nl))return xl+=Wl(),void($l="hexadecimalInteger");throw tf(bl.Char,Wl())},hexadecimalInteger(){if(!Al.JudgeUtil.isHexDigit(Nl))return Kl("numeric",Jl*Number(xl));xl+=Wl()},identifierNameStartEscape(){if("u"!==Nl)throw tf(bl.Char,Wl());Wl();const e=Yl();switch(e){case"$":case"_":break;default:if(!Al.JudgeUtil.isIdStartChar(e))throw tf(bl.Identifier)}xl+=e,$l="identifierName"},identifierName(){switch(Nl){case"$":case"_":case"‌":case"‍":return void(xl+=Wl());case"\\":return Wl(),void($l="identifierNameEscape")}if(!Al.JudgeUtil.isIdContinueChar(Nl))return Kl("identifier",xl);xl+=Wl()},identifierNameEscape(){if("u"!==Nl)throw tf(bl.Char,Wl());Wl();const e=Yl();switch(e){case"$":case"_":case"‌":case"‍":break;default:if(!Al.JudgeUtil.isIdContinueChar(e))throw tf(bl.Identifier)}xl+=e,$l="identifierName"},string(){switch(Nl){case"\\":return Wl(),void(xl+=function(){const e=Ul(),t=function(){switch(Ul()){case"b":return Wl(),"\b";case"f":return Wl(),"\f";case"n":return Wl(),"\n";case"r":return Wl(),"\r";case"t":return Wl(),"\t";case"v":return Wl(),"\v"}return}();if(t)return t;switch(e){case"0":if(Wl(),Al.JudgeUtil.isDigit(Ul()))throw tf(bl.Char,Wl());return"\0";case"x":return Wl(),function(){let e="",t=Ul();if(!Al.JudgeUtil.isHexDigit(t))throw tf(bl.Char,Wl());if(e+=Wl(),t=Ul(),!Al.JudgeUtil.isHexDigit(t))throw tf(bl.Char,Wl());return e+=Wl(),String.fromCodePoint(parseInt(e,16))}();case"u":return Wl(),Yl();case"\n":case"\u2028":case"\u2029":return Wl(),"";case"\r":return Wl(),"\n"===Ul()&&Wl(),""}if(void 0===e||Al.JudgeUtil.isDigitWithoutZero(e))throw tf(bl.Char,Wl());return Wl()}());case'"':case"'":if(Nl===Hl){const e=Kl("string",xl);return Wl(),e}return void(xl+=Wl());case"\n":case"\r":case void 0:throw tf(bl.Char,Wl());case"\u2028":case"\u2029":!function(e){Ol.warn(`JSON5: '${ef(e)}' in strings is not valid ECMAScript; consider escaping.`)}(Nl)}xl+=Wl()}};function Kl(e,t){return{type:e,value:t,line:Ml,column:Ll}}function ql(e){for(const t of e){if(Ul()!==t)throw tf(bl.Char,Wl());Wl()}}function Yl(){let e="",t=4;for(;t-- >0;){const t=Ul();if(!Al.JudgeUtil.isHexDigit(t))throw tf(bl.Char,Wl());e+=Wl()}return String.fromCodePoint(parseInt(e,16))}const Xl={start(){if("eof"===_l.type)throw tf(bl.EOF);Zl()},beforePropertyName(){switch(_l.type){case"identifier":case"string":return Pl=_l.value,void(Il="afterPropertyName");case"punctuator":return void Ql();case"eof":throw tf(bl.EOF)}},afterPropertyName(){if("eof"===_l.type)throw tf(bl.EOF);Il="beforePropertyValue"},beforePropertyValue(){if("eof"===_l.type)throw tf(bl.EOF);Zl()},afterPropertyValue(){if("eof"===_l.type)throw tf(bl.EOF);switch(_l.value){case",":return void(Il="beforePropertyName");case"}":Ql()}},beforeArrayValue(){if("eof"===_l.type)throw tf(bl.EOF);"punctuator"!==_l.type||"]"!==_l.value?Zl():Ql()},afterArrayValue(){if("eof"===_l.type)throw tf(bl.EOF);switch(_l.value){case",":return void(Il="beforeArrayValue");case"]":Ql()}},end(){}};function Zl(){const e=function(){let e;switch(_l.type){case"punctuator":switch(_l.value){case"{":e={};break;case"[":e=[]}break;case"null":case"boolean":case"numeric":case"string":e=_l.value}return e}();if(jl&&"object"==typeof e&&(e._line=Ml,e._column=Ll),void 0===kl)kl=e;else{const t=Tl[Tl.length-1];Array.isArray(t)?jl&&"object"!=typeof e?t.push({value:e,_line:Ml,_column:Ll}):t.push(e):t[Pl]=jl&&"object"!=typeof e?{value:e,_line:Ml,_column:Ll}:e}!function(e){if(e&&"object"==typeof e)Tl.push(e),Il=Array.isArray(e)?"beforeArrayValue":"beforePropertyName";else{const e=Tl[Tl.length-1];Il=e?Array.isArray(e)?"afterArrayValue":"afterPropertyValue":"end"}}(e)}function Ql(){Tl.pop();const e=Tl[Tl.length-1];Il=e?Array.isArray(e)?"afterArrayValue":"afterPropertyValue":"end"}function ef(e){const t={"'":"\\'",'"':'\\"',"\\":"\\\\","\b":"\\b","\f":"\\f","\n":"\\n","\r":"\\r","\t":"\\t","\v":"\\v","\0":"\\0","\u2028":"\\u2028","\u2029":"\\u2029"};if(t[e])return t[e];if(e<" "){const t=e.charCodeAt(0).toString(16);return`\\x${`00${t}`.substring(t.length)}`}return e}function tf(e,t){let n="";switch(e){case bl.Char:n=void 0===t?`JSON5: invalid end of input at ${Ml}:${Ll}`:`JSON5: invalid character '${ef(t)}' at ${Ml}:${Ll}`;break;case bl.EOF:n=`JSON5: invalid end of input at ${Ml}:${Ll}`;break;case bl.Identifier:Ll-=5,n=`JSON5: invalid identifier character at ${Ml}:${Ll}`}const r=new nf(n);return r.lineNumber=Ml,r.columnNumber=Ll,r}class nf extends SyntaxError{}var rf=w&&w.__createBinding||(Object.create?function(e,t,n,r){void 0===r&&(r=n);var u=Object.getOwnPropertyDescriptor(t,n);u&&!("get"in u?!t.__esModule:u.writable||u.configurable)||(u={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,r,u)}:function(e,t,n,r){void 0===r&&(r=n),e[r]=t[n]}),uf=w&&w.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),of=w&&w.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var n in e)"default"!==n&&Object.prototype.hasOwnProperty.call(e,n)&&rf(t,e,n);return uf(t,e),t};Object.defineProperty(Y,"__esModule",{value:!0});var sf=Y.cleanWorkSpace=Ff=Y.executeInstallHvigor=yf=Y.isHvigorInstalled=mf=Y.isAllDependenciesInstalled=void 0;const cf=of(D.default),af=of(p.default),lf=b,ff=j,df=$,Df=X;let pf,Ef;var mf=Y.isAllDependenciesInstalled=function(){function e(e){const t=null==e?void 0:e.dependencies;return void 0===t?0:Object.getOwnPropertyNames(t).length}if(pf=gf(),Ef=Af(),e(pf)+1!==e(Ef))return!1;for(const e in null==pf?void 0:pf.dependencies)if(!(0,ff.hasNpmPackInPaths)(e,[lf.HVIGOR_PROJECT_DEPENDENCIES_HOME])||!hf(e,pf,Ef))return!1;return!0};function hf(e,t,n){return void 0!==n.dependencies&&(0,ff.offlinePluginConversion)(lf.HVIGOR_PROJECT_ROOT_DIR,t.dependencies[e])===n.dependencies[e]}var yf=Y.isHvigorInstalled=function(){return pf=gf(),Ef=Af(),(0,ff.hasNpmPackInPaths)(lf.HVIGOR_ENGINE_PACKAGE_NAME,[lf.HVIGOR_PROJECT_DEPENDENCIES_HOME])&&(0,ff.offlinePluginConversion)(lf.HVIGOR_PROJECT_ROOT_DIR,pf.hvigorVersion)===Ef.dependencies[lf.HVIGOR_ENGINE_PACKAGE_NAME]};const Cf={cwd:lf.HVIGOR_PROJECT_DEPENDENCIES_HOME,stdio:["inherit","inherit","inherit"]};var Ff=Y.executeInstallHvigor=function(){(0,df.logInfoPrintConsole)("Hvigor installing...");const e={dependencies:{}};e.dependencies[lf.HVIGOR_ENGINE_PACKAGE_NAME]=(0,ff.offlinePluginConversion)(lf.HVIGOR_PROJECT_ROOT_DIR,pf.hvigorVersion);try{cf.mkdirSync(lf.HVIGOR_PROJECT_DEPENDENCIES_HOME,{recursive:!0});const t=af.resolve(lf.HVIGOR_PROJECT_DEPENDENCIES_HOME,lf.DEFAULT_PACKAGE_JSON);cf.writeFileSync(t,JSON.stringify(e))}catch(e){(0,df.logErrorAndExit)(e)}!function(){const e=["config","set","store-dir",lf.HVIGOR_PNPM_STORE_PATH];(0,ff.executeCommand)(lf.HVIGOR_WRAPPER_PNPM_SCRIPT_PATH,e,Cf)}(),(0,ff.executeCommand)(lf.HVIGOR_WRAPPER_PNPM_SCRIPT_PATH,["install"],Cf)};function gf(){const e=af.resolve(lf.HVIGOR_PROJECT_WRAPPER_HOME,lf.DEFAULT_HVIGOR_CONFIG_JSON_FILE_NAME);return cf.existsSync(e)||(0,df.logErrorAndExit)(`Error: Hvigor config file ${e} does not exist.`),(0,Df.parseJsonFile)(e)}function Af(){return cf.existsSync(lf.HVIGOR_PROJECT_DEPENDENCY_PACKAGE_JSON_PATH)?(0,Df.parseJsonFile)(lf.HVIGOR_PROJECT_DEPENDENCY_PACKAGE_JSON_PATH):{dependencies:{}}}sf=Y.cleanWorkSpace=function(){if((0,df.logInfoPrintConsole)("Hvigor cleaning..."),!cf.existsSync(lf.HVIGOR_PROJECT_DEPENDENCIES_HOME))return;const e=cf.readdirSync(lf.HVIGOR_PROJECT_DEPENDENCIES_HOME);if(e&&0!==e.length){cf.existsSync(lf.HVIGOR_BOOT_JS_FILE_PATH)&&(0,ff.executeCommand)(process.argv[0],[lf.HVIGOR_BOOT_JS_FILE_PATH,"--stop-daemon"],{});try{e.forEach((e=>{cf.rmSync(af.resolve(lf.HVIGOR_PROJECT_DEPENDENCIES_HOME,e),{recursive:!0})}))}catch(e){(0,df.logErrorAndExit)(`The hvigor build tool cannot be installed. Please manually clear the workspace directory and synchronize the project again.\n\n Workspace Path: ${lf.HVIGOR_PROJECT_DEPENDENCIES_HOME}.`)}}};var vf={},Sf=w&&w.__createBinding||(Object.create?function(e,t,n,r){void 0===r&&(r=n);var u=Object.getOwnPropertyDescriptor(t,n);u&&!("get"in u?!t.__esModule:u.writable||u.configurable)||(u={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,r,u)}:function(e,t,n,r){void 0===r&&(r=n),e[r]=t[n]}),wf=w&&w.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),Of=w&&w.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var n in e)"default"!==n&&Object.prototype.hasOwnProperty.call(e,n)&&Sf(t,e,n);return wf(t,e),t};Object.defineProperty(vf,"__esModule",{value:!0});var bf=vf.executeBuild=void 0;const _f=b,Bf=Of(D.default),Pf=Of(p.default),kf=$;bf=vf.executeBuild=function(){const e=Pf.resolve(_f.HVIGOR_PROJECT_DEPENDENCIES_HOME,"node_modules","@ohos","hvigor","bin","hvigor.js");try{const t=Bf.realpathSync(e);require(t)}catch(t){(0,kf.logErrorAndExit)(`Error: ENOENT: no such file ${e},delete ${_f.HVIGOR_PROJECT_DEPENDENCIES_HOME} and retry.`)}},function(){if(O.checkNpmConifg(),O.environmentHandler(),O.isPnpmAvailable()||O.executeInstallPnpm(),yf()&&mf())bf();else{sf();try{Ff()}catch(e){return void sf()}bf()}}(); \ No newline at end of file diff --git a/sample/EnhanceSampleArk1.2/StateManagement/hvigorfile.ts b/sample/EnhanceSampleArk1.2/StateManagement/hvigorfile.ts new file mode 100644 index 0000000000000000000000000000000000000000..6478186902c0c1ad7c966a929c7d6b7d8ae7a9f3 --- /dev/null +++ b/sample/EnhanceSampleArk1.2/StateManagement/hvigorfile.ts @@ -0,0 +1,2 @@ +// Script for compiling build behavior. It is built in the build plug-in and cannot be modified currently. +export { appTasks } from '@ohos/hvigor-ohos-plugin'; \ No newline at end of file diff --git a/sample/EnhanceSampleArk1.2/StateManagement/hvigorw b/sample/EnhanceSampleArk1.2/StateManagement/hvigorw new file mode 100644 index 0000000000000000000000000000000000000000..d0a563c20ab052c32d602855d07029549d314cf4 --- /dev/null +++ b/sample/EnhanceSampleArk1.2/StateManagement/hvigorw @@ -0,0 +1,63 @@ +#!/bin/bash + +# ---------------------------------------------------------------------------- +# Copyright (c) 2023 Huawei Device 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. +# ---------------------------------------------------------------------------- + +# ---------------------------------------------------------------------------- +# Hvigor startup script, version 1.0.0 +# +# Required ENV vars: +# ------------------ +# NODE_HOME - location of a Node home dir +# or +# Add /usr/local/nodejs/bin to the PATH environment variable +# ---------------------------------------------------------------------------- + +HVIGOR_APP_HOME=$(dirname $(readlink -f $0)) +HVIGOR_WRAPPER_SCRIPT=${HVIGOR_APP_HOME}/hvigor/hvigor-wrapper.js +warn() { + echo "" + echo -e "\033[1;33m`date '+[%Y-%m-%d %H:%M:%S]'`$@\033[0m" +} + +error() { + echo "" + echo -e "\033[1;31m`date '+[%Y-%m-%d %H:%M:%S]'`$@\033[0m" +} + +fail() { + error "$@" + exit 1 +} + +# Determine node to start hvigor wrapper script +if [ -n "${NODE_HOME}" ];then + EXECUTABLE_NODE="${NODE_HOME}/bin/node" + if [ ! -x "$EXECUTABLE_NODE" ];then + fail "ERROR: NODE_HOME is set to an invalid directory,check $NODE_HOME\n\nPlease set NODE_HOME in your environment to the location where your nodejs installed" + fi +else + EXECUTABLE_NODE="node" + which ${EXECUTABLE_NODE} > /dev/null 2>&1 || fail "ERROR: NODE_HOME is not set and not 'node' command found in your path" +fi + +# Check hvigor wrapper script +if [ ! -r "$HVIGOR_WRAPPER_SCRIPT" ];then + fail "ERROR: Couldn't find hvigor/hvigor-wrapper.js in ${HVIGOR_APP_HOME}" +fi + +# start hvigor-wrapper script +exec "${EXECUTABLE_NODE}" \ + "${HVIGOR_WRAPPER_SCRIPT}" "$@" diff --git a/sample/EnhanceSampleArk1.2/StateManagement/hvigorw.bat b/sample/EnhanceSampleArk1.2/StateManagement/hvigorw.bat new file mode 100644 index 0000000000000000000000000000000000000000..af893e9a2c9170d04610c906f1cf1b6f3ac144ac --- /dev/null +++ b/sample/EnhanceSampleArk1.2/StateManagement/hvigorw.bat @@ -0,0 +1,72 @@ +:: Copyright (c) 2023 Huawei Device 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. + +@echo off + +@if "%DEBUG%" == "" @echo off +@rem ########################################################################## +@rem +@rem Hvigor startup script for Windows +@rem +@rem ########################################################################## + +@rem Set local scope for the variables with windows NT shell +if "%OS%"=="Windows_NT" setlocal + +set DIRNAME=%~dp0 +if "%DIRNAME%" == "" set DIRNAME=. +set APP_BASE_NAME=%~n0 +set APP_HOME=%DIRNAME% + +@rem Resolve any "." and ".." in APP_HOME to make it shorter. +for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi + +set WRAPPER_MODULE_PATH=%APP_HOME%\hvigor\hvigor-wrapper.js +set NODE_EXE=node.exe + +goto start + +:start +@rem Find node.exe +if defined NODE_HOME goto findNodeFromNodeHome + +%NODE_EXE% --version >NUL 2>&1 +if "%ERRORLEVEL%" == "0" goto execute + +echo. +echo ERROR: NODE_HOME is not set and no 'node' command could be found in your PATH. +echo. +echo Please set the NODE_HOME variable in your environment to match the +echo location of your NodeJs installation. + +goto fail + +:findNodeFromNodeHome +set NODE_HOME=%NODE_HOME:"=% +set NODE_EXE_PATH=%NODE_HOME%/%NODE_EXE% + +if exist "%NODE_EXE_PATH%" goto execute +echo. +echo ERROR: NODE_HOME is not set and no 'node' command could be found in your PATH. +echo. +echo Please set the NODE_HOME variable in your environment to match the +echo location of your NodeJs installation. + +goto fail + +:execute +@rem Execute hvigor +"%NODE_EXE%" %WRAPPER_MODULE_PATH% %* + +:fail +exit /b 1 diff --git a/sample/EnhanceSampleArk1.2/StateManagement/oh-package.json5 b/sample/EnhanceSampleArk1.2/StateManagement/oh-package.json5 new file mode 100644 index 0000000000000000000000000000000000000000..ebf207920fda35a0996d73810300594596eb041f --- /dev/null +++ b/sample/EnhanceSampleArk1.2/StateManagement/oh-package.json5 @@ -0,0 +1,26 @@ +/* + * Copyright (c) 2023 Huawei Device 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. + */ + +{ + "license": "ISC", + "devDependencies": { + "@ohos/hypium": "1.0.6" + }, + "name": "myapplication", + "description": "example description", + "repository": {}, + "version": "1.0.0", + "dependencies": {} +} diff --git a/sample/EnhanceSampleArk1.2/StateManagement/ohosTest.md b/sample/EnhanceSampleArk1.2/StateManagement/ohosTest.md new file mode 100644 index 0000000000000000000000000000000000000000..d12c6e78750016ce24cde1e8bbcdbafcacb3b9af --- /dev/null +++ b/sample/EnhanceSampleArk1.2/StateManagement/ohosTest.md @@ -0,0 +1,18 @@ +# StateManagement 测试用例归档 + +## 用例表 + +|测试功能|预置条件|输入|预期输出|测试结果| +|--------------------------------|--------------------------------|--------------------------------|--------------------------------|--------------------------------| +|拉起应用| 设备正常运行| |成功拉起应用|Pass| +|打开折叠层 |在首页 |打开修饰对象类型、更新原理、父子组件之间状态同步折叠层 |正常展开折叠层,显示折叠层下的内容 |Pass| +|验证基础类型 |在首页,修饰对象类型已展开 |点击进入基础类型,设置圆形颜色并查看源码 |圆形颜色改变,显示该页面源码 |Pass| +|验证数组类型 |在首页,修饰对象类型已展开 |点击进入数组类型,点击删除元素,添加元素,更新元素,查看源码 |依次删除元素,添加元素,更新元素,显示该页面源码 |Pass| +|验证类对象类型 |在首页,修饰对象类型已展开 |点击进入类对象类型,依次点击更新对象,更新对象属性,更新属性中的属性,查看源码 |依次改变,对象属性整体和内部属性+1,对象属性+1,对象属性的属性+1,显示该页面源码 |Pass| +|验证只更新所绑定的组件 |在首页,更新原理已展开 |点击修改标题和内容,点击查看源码 |标题的title+1,显示该页面源码 |Pass| +|验证单、双向同步 |在首页,父子组件之间状态同步已展开 |点击进入单、双向同步,点击设置粉色,设置蓝色,设置红色,查看源码 |全部三个按钮变成粉色,中间的按钮变成蓝色,全部按钮变成红色,显示该页面源码 |Pass| +|验证子组件同步父组件部分内容 |在首页,父子组件之间状态同步已展开 |点击进入子组件同步父组件部分内容,点击修改父组件第一个属性文本,点击修改子组件属性文本,第二、三个属性文本,显示该页面源码 |父组件中对应的属性依次改变,显示该页面源码 |Pass| +|验证爷孙组件之间状态同步 |在首页 |点击进入,依次点击孙组件、爷组件、provide子组件、provide父组件、select组件并选择颜色,查看源码 |父组件、子组件颜色同时变粉、变蓝,provide父组件、子组件颜色同时变粉、变蓝,显示该页面源码 |Pass| +|验证兄弟组件之间状态同步 |在首页 |点击进入,依次点击兄,弟组件、provide兄组件、provide弟组件、select组件并选择颜色,查看源码 |兄组件、弟组件颜色同时变粉、变蓝,provide兄组件、弟组件颜色同时变粉、变蓝,显示该页面源码 |Pass| +|验证应用内全局数据与UI之间的状态同步 |下方tab切换到应用级状态管理 |点击进入,打开夜间模式,进入Ability1,关闭夜间模式,返回,进入Ability2,打开夜间模式,返回,查看源码 |夜间模式依次打开和关闭,显示该页面源码 |Pass| +|验证Ability内全局数据与UI之间的状态同步 |下方tab切换到应用级状态管理 |点击进入,打开夜间模式,进入Page1,关闭夜间模式,返回,进入跨Ability,打开夜间模式,返回,查看源码 |夜间模式依次打开和关闭,跨Ability打开夜间模式返回后夜间模式不同步 |Pass| diff --git a/sample/EnhanceSampleArk1.2/StateManagement/screenshots/device/ApplyGlobalDataSync.jpeg b/sample/EnhanceSampleArk1.2/StateManagement/screenshots/device/ApplyGlobalDataSync.jpeg new file mode 100644 index 0000000000000000000000000000000000000000..3d98024501c1d3682ec5ef0f7f0a987d72acff5b Binary files /dev/null and b/sample/EnhanceSampleArk1.2/StateManagement/screenshots/device/ApplyGlobalDataSync.jpeg differ diff --git a/sample/EnhanceSampleArk1.2/StateManagement/screenshots/device/DeepNestComponent.jpeg b/sample/EnhanceSampleArk1.2/StateManagement/screenshots/device/DeepNestComponent.jpeg new file mode 100644 index 0000000000000000000000000000000000000000..852d6be8fd8ddf3062b0121dd4b615a46fc4806f Binary files /dev/null and b/sample/EnhanceSampleArk1.2/StateManagement/screenshots/device/DeepNestComponent.jpeg differ diff --git a/sample/EnhanceSampleArk1.2/StateManagement/screenshots/device/Home.jpeg b/sample/EnhanceSampleArk1.2/StateManagement/screenshots/device/Home.jpeg new file mode 100644 index 0000000000000000000000000000000000000000..ea9ecef93a418052173017959fabc70436d3c351 Binary files /dev/null and b/sample/EnhanceSampleArk1.2/StateManagement/screenshots/device/Home.jpeg differ diff --git a/sample/EnhanceSampleArk1.2/StateManagement/screenshots/device/ParentChildPartialContentSync.jpeg b/sample/EnhanceSampleArk1.2/StateManagement/screenshots/device/ParentChildPartialContentSync.jpeg new file mode 100644 index 0000000000000000000000000000000000000000..82a8d49f09fa2b51a22d409a94836644552e43f9 Binary files /dev/null and b/sample/EnhanceSampleArk1.2/StateManagement/screenshots/device/ParentChildPartialContentSync.jpeg differ