diff --git a/arkcompiler/BUILD.gn b/arkcompiler/BUILD.gn index 312965d0ba5f25023458a2110d3763b70c7f25c7..3b99b6fc64514ad104f09812f49326772330f83d 100644 --- a/arkcompiler/BUILD.gn +++ b/arkcompiler/BUILD.gn @@ -1,10 +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. + import("//build/ohos_var.gni") group("arkcompiler") { testonly = true if (is_standard_system) { - deps = [ - "esmodule:esmodule", - ] + deps = [ "esmodule:esmodule" ] } } \ No newline at end of file diff --git a/arkcompiler/esmodule/BUILD.gn b/arkcompiler/esmodule/BUILD.gn index 54dc11c5fff698c8201042021f87de66bd23d8b2..bdc0578d9037d9fd651ec8ffab9fcb40f237dc77 100644 --- a/arkcompiler/esmodule/BUILD.gn +++ b/arkcompiler/esmodule/BUILD.gn @@ -1,3 +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. + import("//build/ohos_var.gni") group("esmodule") { diff --git a/arkcompiler/esmodule/esmodule_entry/entry/src/main/cpp/hello.cpp b/arkcompiler/esmodule/esmodule_entry/entry/src/main/cpp/hello.cpp index 1c0edd99bcf91760d0704cfc48129bd980761125..3eb38b21de56a7853c7751ca4a83480ced262edd 100644 --- a/arkcompiler/esmodule/esmodule_entry/entry/src/main/cpp/hello.cpp +++ b/arkcompiler/esmodule/esmodule_entry/entry/src/main/cpp/hello.cpp @@ -20,7 +20,7 @@ static napi_value Add(napi_env env, napi_callback_info info) size_t argc = 2; napi_value args[2] = {nullptr}; - napi_get_cb_info(env, info, &argc, args , nullptr, nullptr); + napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); napi_valuetype valuetype0; napi_typeof(env, args[0], &valuetype0); @@ -38,7 +38,6 @@ static napi_value Add(napi_env env, napi_callback_info info) napi_create_double(env, value0 + value1, &sum); return sum; - } EXTERN_C_START diff --git a/arkcompiler/esmodule/esmodule_entry/entry/src/main/ets/workers/workerImportHar.ts b/arkcompiler/esmodule/esmodule_entry/entry/src/main/ets/workers/workerImportHar.ts index f2bfe64e950c79849b3c2cc4d5803992ed1dce1f..95708daec385ee385fe69548632f0c6c99b3568d 100644 --- a/arkcompiler/esmodule/esmodule_entry/entry/src/main/ets/workers/workerImportHar.ts +++ b/arkcompiler/esmodule/esmodule_entry/entry/src/main/ets/workers/workerImportHar.ts @@ -12,13 +12,12 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -import {ohpmRes} from 'har' +import {ohpmRes} from 'har'; import worker from '@ohos.worker'; -var workerPort = worker.workerPort; -workerPort.onmessage = function() { - console.log("ModuleTest har"); - if (ohpmRes){ - workerPort.postMessage("ModuleTest receive data from main thread"); +let workerPort = worker.workerPort; +workerPort.onmessage = function(): void { + if (ohpmRes) { + workerPort.postMessage('ModuleTest receive data from main thread'); } -} \ No newline at end of file +}; \ No newline at end of file diff --git a/arkcompiler/esmodule/esmodule_entry/entry/src/main/ets/workers/workerImportNapi.ts b/arkcompiler/esmodule/esmodule_entry/entry/src/main/ets/workers/workerImportNapi.ts index d39289ba033bd568830b4c359513609cedccc338..a9666bce3c75be9df09d01a8ad66182c80958602 100644 --- a/arkcompiler/esmodule/esmodule_entry/entry/src/main/ets/workers/workerImportNapi.ts +++ b/arkcompiler/esmodule/esmodule_entry/entry/src/main/ets/workers/workerImportNapi.ts @@ -12,13 +12,15 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -import {add} from 'libentry.so' +import {add} from 'libentry.so'; import worker from '@ohos.worker'; +const ADDEND_FIRST = 2; +const ADDEND_SECOND = 3; +const SUM = 5; var workerPort = worker.workerPort; -workerPort.onmessage = function() { - if (add(2, 3) == 5) { - console.log("ModuleTest AppNapi"); - workerPort.postMessage("ModuleTest receive data from main thread"); +workerPort.onmessage = function(): void { + if (add(ADDEND_FIRST, ADD_SECOND) === SUM) { + workerPort.postMessage('ModuleTest receive data from main thread'); } -} \ No newline at end of file +}; \ No newline at end of file diff --git a/arkcompiler/esmodule/esmodule_entry/entry/src/main/ets/workers/workerImportOhpm.ts b/arkcompiler/esmodule/esmodule_entry/entry/src/main/ets/workers/workerImportOhpm.ts index b40a673467e0b3a35d42f533a17481159eff3578..568eee8d57258ecb61f3668aaa10dba6e0490ee3 100644 --- a/arkcompiler/esmodule/esmodule_entry/entry/src/main/ets/workers/workerImportOhpm.ts +++ b/arkcompiler/esmodule/esmodule_entry/entry/src/main/ets/workers/workerImportOhpm.ts @@ -12,13 +12,13 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -import isLeapYear from 'leap-year' +import isLeapYear from 'leap-year'; import worker from '@ohos.worker'; -var workerPort = worker.workerPort; -workerPort.onmessage = function() { - if (isLeapYear(2000)){ - console.log("ModuleTest ohpm"); - workerPort.postMessage("ModuleTest receive data from main thread"); +const LEAP_YEAR = 2000; +let workerPort = worker.workerPort; +workerPort.onmessage = function(): void { + if (isLeapYear(LEAP_YEAR)) { + workerPort.postMessage('ModuleTest receive data from main thread'); } -} \ No newline at end of file +}; \ No newline at end of file diff --git a/arkcompiler/esmodule/esmodule_entry/entry/src/main/ets/workers/workerImportRelative.ts b/arkcompiler/esmodule/esmodule_entry/entry/src/main/ets/workers/workerImportRelative.ts index 695918527afff9a602ba7ed05a927154752f0ace..0dd0b86a821b184c9e2c5186400d836048b17d48 100644 --- a/arkcompiler/esmodule/esmodule_entry/entry/src/main/ets/workers/workerImportRelative.ts +++ b/arkcompiler/esmodule/esmodule_entry/entry/src/main/ets/workers/workerImportRelative.ts @@ -12,13 +12,15 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -import { add } from '../test/test' +import { add } from '../test/test'; import worker from '@ohos.worker'; -var workerPort = worker.workerPort; -workerPort.onmessage = function() { - if (add(2, 6) == 8){ - console.log("ModuleTest relativePath"); - workerPort.postMessage("ModuleTest receive data from main thread"); +const ADDEND_FIRST = 2; +const ADDEND_SECOND = 3; +const SUM = 5; +let workerPort = worker.workerPort; +workerPort.onmessage = function(): void { + if (add(ADDEND_FIRST, ADD_SECOND) === SUM) { + workerPort.postMessage('ModuleTest receive data from main thread'); } -} \ No newline at end of file +}; \ No newline at end of file diff --git a/arkcompiler/esmodule/esmodule_entry/entry/src/main/ets/workers/workerImportSystem.ts b/arkcompiler/esmodule/esmodule_entry/entry/src/main/ets/workers/workerImportSystem.ts index 829cf7a176affcc61b0cc7913f9d47e3fee75fe6..53b20df4135936560430854bcf0e02e4ddfcf970 100644 --- a/arkcompiler/esmodule/esmodule_entry/entry/src/main/ets/workers/workerImportSystem.ts +++ b/arkcompiler/esmodule/esmodule_entry/entry/src/main/ets/workers/workerImportSystem.ts @@ -12,13 +12,12 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -import hilog from "@ohos.hilog" +import hilog from '@ohos.hilog'; import worker from '@ohos.worker'; -hilog.info(0x0000, "testTag", 'dexter log: call ohos.hilog') +hilog.info(0x0000, 'testTag', 'dexter log: call ohos.hilog'); -var workerPort = worker.workerPort; -workerPort.onmessage = function() { - console.log("ModuleTest systemNapi"); - workerPort.postMessage("ModuleTest receive data from main thread"); -} \ No newline at end of file +let workerPort = worker.workerPort; +workerPort.onmessage = function(): void { + workerPort.postMessage('ModuleTest receive data from main thread'); +}; \ No newline at end of file diff --git a/arkcompiler/esmodule/esmodule_entry/har/src/main/ets/ohpm.ts b/arkcompiler/esmodule/esmodule_entry/har/src/main/ets/ohpm.ts index 5c1d97ce7abd45c5b4fd09c031c67b305852bb5c..1e734a034e1e80642d6df41dcb12db5f8ff3656b 100644 --- a/arkcompiler/esmodule/esmodule_entry/har/src/main/ets/ohpm.ts +++ b/arkcompiler/esmodule/esmodule_entry/har/src/main/ets/ohpm.ts @@ -12,5 +12,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -import isLeapYear from "leap-year" -export var ohpmRes = isLeapYear(2000); \ No newline at end of file +import isLeapYear from 'leap-year'; + +const LEAP_YEAR = 2000; +export let ohpmRes = isLeapYear(LEAP_YEAR); \ No newline at end of file diff --git a/arkcompiler/esmodule/esmodule_entry/oh-package-lock.json5 b/arkcompiler/esmodule/esmodule_entry/oh-package-lock.json5 index 27912f0c70fd5dc89b8d26c6ffab3b87fa6a1625..2c203c52321bf7ef3e02962176b1f300bfc83be4 100644 --- a/arkcompiler/esmodule/esmodule_entry/oh-package-lock.json5 +++ b/arkcompiler/esmodule/esmodule_entry/oh-package-lock.json5 @@ -1,19 +1,33 @@ -{ - "lockfileVersion": 1, - "ATTENTION": "THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.", - "specifiers": { - "@ohos/hypium@1.0.6": "@ohos/hypium@1.0.6", - "leap-year@^4.0.0": "leap-year@4.0.0", - "leap-year@4.0.0": "leap-year@4.0.0" - }, - "packages": { - "@ohos/hypium@1.0.6": { - "resolved": "https://repo.harmonyos.com/ohpm/@ohos/hypium/-/hypium-1.0.6.tgz", - "integrity": "sha512-bb3DWeWhYrFqj9mPFV3yZQpkm36kbcK+YYaeY9g292QKSjOdmhEIQR2ULPvyMsgSR4usOBf5nnYrDmaCCXirgQ==" - }, - "leap-year@4.0.0": { - "resolved": "https://repo.harmonyos.com/ohpm/leap-year/-/leap-year-4.0.0.tgz", - "integrity": "sha512-+GveCBnhFmRjFf04Nj/2Z/w5lNC4bRXpecIRz5QkK+LnWBwuf9jAaNEfbybrU+e2ls8J6p+FZMjiq1aEh+gPAw==" - } - } +/** + * 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. + */ +{ + "lockfileVersion": 1, + "ATTENTION": "THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.", + "specifiers": { + "@ohos/hypium@1.0.6": "@ohos/hypium@1.0.6", + "leap-year@^4.0.0": "leap-year@4.0.0", + "leap-year@4.0.0": "leap-year@4.0.0" + }, + "packages": { + "@ohos/hypium@1.0.6": { + "resolved": "https://repo.harmonyos.com/ohpm/@ohos/hypium/-/hypium-1.0.6.tgz", + "integrity": "sha512-bb3DWeWhYrFqj9mPFV3yZQpkm36kbcK+YYaeY9g292QKSjOdmhEIQR2ULPvyMsgSR4usOBf5nnYrDmaCCXirgQ==" + }, + "leap-year@4.0.0": { + "resolved": "https://repo.harmonyos.com/ohpm/leap-year/-/leap-year-4.0.0.tgz", + "integrity": "sha512-+GveCBnhFmRjFf04Nj/2Z/w5lNC4bRXpecIRz5QkK+LnWBwuf9jAaNEfbybrU+e2ls8J6p+FZMjiq1aEh+gPAw==" + } + } } \ No newline at end of file diff --git a/arkcompiler/esmodule/esmodule_ohostest/har/src/main/ets/ohpm.ts b/arkcompiler/esmodule/esmodule_ohostest/har/src/main/ets/ohpm.ts index 5c1d97ce7abd45c5b4fd09c031c67b305852bb5c..1e734a034e1e80642d6df41dcb12db5f8ff3656b 100644 --- a/arkcompiler/esmodule/esmodule_ohostest/har/src/main/ets/ohpm.ts +++ b/arkcompiler/esmodule/esmodule_ohostest/har/src/main/ets/ohpm.ts @@ -12,5 +12,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -import isLeapYear from "leap-year" -export var ohpmRes = isLeapYear(2000); \ No newline at end of file +import isLeapYear from 'leap-year'; + +const LEAP_YEAR = 2000; +export let ohpmRes = isLeapYear(LEAP_YEAR); \ No newline at end of file diff --git a/arkcompiler/esmodule/esmodule_ohostest/oh-package-lock.json5 b/arkcompiler/esmodule/esmodule_ohostest/oh-package-lock.json5 index 27912f0c70fd5dc89b8d26c6ffab3b87fa6a1625..1e08ee6bb9575885abe07d38d20a6e9b9cdb97d5 100644 --- a/arkcompiler/esmodule/esmodule_ohostest/oh-package-lock.json5 +++ b/arkcompiler/esmodule/esmodule_ohostest/oh-package-lock.json5 @@ -1,19 +1,34 @@ -{ - "lockfileVersion": 1, - "ATTENTION": "THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.", - "specifiers": { - "@ohos/hypium@1.0.6": "@ohos/hypium@1.0.6", - "leap-year@^4.0.0": "leap-year@4.0.0", - "leap-year@4.0.0": "leap-year@4.0.0" - }, - "packages": { - "@ohos/hypium@1.0.6": { - "resolved": "https://repo.harmonyos.com/ohpm/@ohos/hypium/-/hypium-1.0.6.tgz", - "integrity": "sha512-bb3DWeWhYrFqj9mPFV3yZQpkm36kbcK+YYaeY9g292QKSjOdmhEIQR2ULPvyMsgSR4usOBf5nnYrDmaCCXirgQ==" - }, - "leap-year@4.0.0": { - "resolved": "https://repo.harmonyos.com/ohpm/leap-year/-/leap-year-4.0.0.tgz", - "integrity": "sha512-+GveCBnhFmRjFf04Nj/2Z/w5lNC4bRXpecIRz5QkK+LnWBwuf9jAaNEfbybrU+e2ls8J6p+FZMjiq1aEh+gPAw==" - } - } +/** + * 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. + */ + +{ + "lockfileVersion": 1, + "ATTENTION": "THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.", + "specifiers": { + "@ohos/hypium@1.0.6": "@ohos/hypium@1.0.6", + "leap-year@^4.0.0": "leap-year@4.0.0", + "leap-year@4.0.0": "leap-year@4.0.0" + }, + "packages": { + "@ohos/hypium@1.0.6": { + "resolved": "https://repo.harmonyos.com/ohpm/@ohos/hypium/-/hypium-1.0.6.tgz", + "integrity": "sha512-bb3DWeWhYrFqj9mPFV3yZQpkm36kbcK+YYaeY9g292QKSjOdmhEIQR2ULPvyMsgSR4usOBf5nnYrDmaCCXirgQ==" + }, + "leap-year@4.0.0": { + "resolved": "https://repo.harmonyos.com/ohpm/leap-year/-/leap-year-4.0.0.tgz", + "integrity": "sha512-+GveCBnhFmRjFf04Nj/2Z/w5lNC4bRXpecIRz5QkK+LnWBwuf9jAaNEfbybrU+e2ls8J6p+FZMjiq1aEh+gPAw==" + } + } } \ No newline at end of file