From ed9607c98118d481fafd486ca693793ee55fb3df Mon Sep 17 00:00:00 2001 From: kolegovilya Date: Fri, 14 Feb 2025 14:08:51 +0300 Subject: [PATCH 1/2] moved --- interop/src/arkts/MaterializedBase.sts | 21 +++++++++++++++++++++ interop/src/arkts/index.sts | 2 ++ interop/src/arkts/utils.sts | 18 ++++++++++++++++++ interop/src/interop/MaterializedBase.ts | 20 ++++++++++++++++++++ interop/src/interop/index.ts | 2 ++ interop/src/interop/utils.ts | 18 ++++++++++++++++++ 6 files changed, 81 insertions(+) create mode 100644 interop/src/arkts/MaterializedBase.sts create mode 100644 interop/src/arkts/utils.sts create mode 100644 interop/src/interop/MaterializedBase.ts create mode 100644 interop/src/interop/utils.ts diff --git a/interop/src/arkts/MaterializedBase.sts b/interop/src/arkts/MaterializedBase.sts new file mode 100644 index 000000000..3f26a861e --- /dev/null +++ b/interop/src/arkts/MaterializedBase.sts @@ -0,0 +1,21 @@ +/* + * 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 { Finalizable } from "./Finalizable" + +export interface MaterializedBase { + getPeer(): Finalizable | undefined +} + diff --git a/interop/src/arkts/index.sts b/interop/src/arkts/index.sts index 9fb970d80..4d7a2a5e8 100644 --- a/interop/src/arkts/index.sts +++ b/interop/src/arkts/index.sts @@ -23,3 +23,5 @@ export * from "./SerializerBase" export * from "./DeserializerBase" export * from "./Finalizable" export * from "./loadLibraries" +export * from "./MaterializedBase" +export * from "./utils" diff --git a/interop/src/arkts/utils.sts b/interop/src/arkts/utils.sts new file mode 100644 index 000000000..4e363acf5 --- /dev/null +++ b/interop/src/arkts/utils.sts @@ -0,0 +1,18 @@ +/* + * 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. + */ + +export function unsafeCast(value: Object): T { + return value as T +} \ No newline at end of file diff --git a/interop/src/interop/MaterializedBase.ts b/interop/src/interop/MaterializedBase.ts new file mode 100644 index 000000000..51135fbaa --- /dev/null +++ b/interop/src/interop/MaterializedBase.ts @@ -0,0 +1,20 @@ +/* + * 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 { Finalizable } from "./Finalizable" + +export interface MaterializedBase { + getPeer(): Finalizable | undefined +} diff --git a/interop/src/interop/index.ts b/interop/src/interop/index.ts index f61254d5a..330a6c06e 100644 --- a/interop/src/interop/index.ts +++ b/interop/src/interop/index.ts @@ -71,3 +71,5 @@ export { InteropNativeModule, loadInteropNativeModule } from "./InteropNativeMod export { SerializerBase, RuntimeType, Tags, runtimeType, CallbackResource, unsafeCast, isResource, isInstanceOf } from "./SerializerBase" export { DeserializerBase } from "./DeserializerBase" export { loadNativeModuleLibrary, loadNativeLibrary, registerNativeModuleLibraryName } from "./loadLibraries" +export * from "./MaterializedBase" +export * from "./utils" diff --git a/interop/src/interop/utils.ts b/interop/src/interop/utils.ts new file mode 100644 index 000000000..2c08785fb --- /dev/null +++ b/interop/src/interop/utils.ts @@ -0,0 +1,18 @@ +/* + * 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. + */ + +export function unsafeCast(value: unknown): T { + return value as unknown as T +} -- Gitee From 151e0b8bcfc9a225a79ef5e582a0485ee13641e6 Mon Sep 17 00:00:00 2001 From: kolegovilya Date: Fri, 14 Feb 2025 17:04:46 +0300 Subject: [PATCH 2/2] moved unsafeCast to compat --- incremental/common/src/index.ts | 1 + incremental/compat/src/arkts/index.ts | 1 + .../arkts/utils.sts => incremental/compat/src/arkts/utils.ts | 2 +- incremental/compat/src/index.ts | 1 + incremental/compat/src/ohos/index.ts | 3 ++- incremental/compat/src/typescript/index.ts | 1 + .../src/interop => incremental/compat/src/typescript}/utils.ts | 0 interop/src/arkts/index.sts | 1 - interop/src/interop/index.ts | 1 - 9 files changed, 7 insertions(+), 4 deletions(-) rename interop/src/arkts/utils.sts => incremental/compat/src/arkts/utils.ts (99%) rename {interop/src/interop => incremental/compat/src/typescript}/utils.ts (100%) diff --git a/incremental/common/src/index.ts b/incremental/common/src/index.ts index 7d500898c..0e47fd138 100644 --- a/incremental/common/src/index.ts +++ b/incremental/common/src/index.ts @@ -37,6 +37,7 @@ export { propDeepCopy, refEqual, int8Array, + unsafeCast } from "@koalaui/compat" export { clamp, lerp, modulo, parseNumber, isFiniteNumber, getDistancePx } from "./math" export { hashCodeFromString } from "./stringUtils" diff --git a/incremental/compat/src/arkts/index.ts b/incremental/compat/src/arkts/index.ts index 898e2d891..95ec1799f 100644 --- a/incremental/compat/src/arkts/index.ts +++ b/incremental/compat/src/arkts/index.ts @@ -24,3 +24,4 @@ export * from "./reflection" export * from "./strings" export * from "./ts-reflection" export * from "./types" +export * from "./utils" diff --git a/interop/src/arkts/utils.sts b/incremental/compat/src/arkts/utils.ts similarity index 99% rename from interop/src/arkts/utils.sts rename to incremental/compat/src/arkts/utils.ts index 4e363acf5..0061d5752 100644 --- a/interop/src/arkts/utils.sts +++ b/incremental/compat/src/arkts/utils.ts @@ -15,4 +15,4 @@ export function unsafeCast(value: Object): T { return value as T -} \ No newline at end of file +} diff --git a/incremental/compat/src/index.ts b/incremental/compat/src/index.ts index 6976bcb33..5a05c8ee6 100644 --- a/incremental/compat/src/index.ts +++ b/incremental/compat/src/index.ts @@ -52,4 +52,5 @@ export { float32, float64, int8Array, + unsafeCast, } from "#platform" diff --git a/incremental/compat/src/ohos/index.ts b/incremental/compat/src/ohos/index.ts index e59193deb..285981699 100644 --- a/incremental/compat/src/ohos/index.ts +++ b/incremental/compat/src/ohos/index.ts @@ -49,7 +49,8 @@ export { uint64, float32, float64, - int8Array + int8Array, + unsafeCast, } from "../typescript" export { diff --git a/incremental/compat/src/typescript/index.ts b/incremental/compat/src/typescript/index.ts index 220a13b41..03bb4fbdd 100644 --- a/incremental/compat/src/typescript/index.ts +++ b/incremental/compat/src/typescript/index.ts @@ -24,3 +24,4 @@ export * from "./reflection" export * from "./strings" export * from "./ts-reflection" export * from "./types" +export * from "./utils" diff --git a/interop/src/interop/utils.ts b/incremental/compat/src/typescript/utils.ts similarity index 100% rename from interop/src/interop/utils.ts rename to incremental/compat/src/typescript/utils.ts diff --git a/interop/src/arkts/index.sts b/interop/src/arkts/index.sts index 4d7a2a5e8..7b8f23670 100644 --- a/interop/src/arkts/index.sts +++ b/interop/src/arkts/index.sts @@ -24,4 +24,3 @@ export * from "./DeserializerBase" export * from "./Finalizable" export * from "./loadLibraries" export * from "./MaterializedBase" -export * from "./utils" diff --git a/interop/src/interop/index.ts b/interop/src/interop/index.ts index 330a6c06e..354f21254 100644 --- a/interop/src/interop/index.ts +++ b/interop/src/interop/index.ts @@ -72,4 +72,3 @@ export { SerializerBase, RuntimeType, Tags, runtimeType, CallbackResource, unsaf export { DeserializerBase } from "./DeserializerBase" export { loadNativeModuleLibrary, loadNativeLibrary, registerNativeModuleLibraryName } from "./loadLibraries" export * from "./MaterializedBase" -export * from "./utils" -- Gitee