diff --git a/interfaces/kits/js/@ohos.document.d.ts b/interfaces/kits/js/@ohos.document.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..1333942fe64968a00d2c1895f5815ccee37d40d1 --- /dev/null +++ b/interfaces/kits/js/@ohos.document.d.ts @@ -0,0 +1,63 @@ +/* + * Copyright (c) 2021 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 { AsyncCallback } from './basic' + +export default document; + +/** + * document + * @syscap SystemCapability.FileManagement.UserFileService + * @since 6 + * @import import document from '@ohos.document'; + * @permission N/A + */ +declare namespace document { + export { choose }; + export { show }; +} + +/** + * choose. + * + * @note N/A + * @syscap SystemCapability.FileManagement.UserFileService + * @since 6 + * @permission N/A + * @function choose + * @param {string} type - type. + * @param {AsyncCallback} [callback] - callback. + * @returns {void | Promise} no callback return Promise otherwise return void + * @throws {TypedError} Parameter check failed + */ +declare function choose(types?: string[]): Promise; +declare function choose(callback: AsyncCallback): void; +declare function choose(types: string[], callback: AsyncCallback): void; + +/** + * show. + * + * @note N/A + * @syscap SystemCapability.FileManagement.UserFileService + * @since 6 + * @permission N/A + * @function show + * @param {string} uri - uri. + * @param {string} type - type. + * @param {AsyncCallback} [callback] - callback. + * @returns {void | Promise} no callback return Promise otherwise return void + * @throws {TypedError} Parameter check failed + */ +declare function show(uri: string, type: string): Promise; +declare function show(uri: string, type: string, callback: AsyncCallback): void; \ No newline at end of file diff --git a/interfaces/kits/js/src/mod_document/document_n_exporter.cpp b/interfaces/kits/js/src/mod_document/document_n_exporter.cpp new file mode 100644 index 0000000000000000000000000000000000000000..eacc54f8d40133cc7537f4c9486ef762bc984ed7 --- /dev/null +++ b/interfaces/kits/js/src/mod_document/document_n_exporter.cpp @@ -0,0 +1,43 @@ +/* + * Copyright (c) 2021 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. + */ + +#include "document_n_exporter.h" + +#include +#include + +#include "../common/napi/n_class.h" +#include "../common/napi/n_func_arg.h" +#include "../common/napi/n_val.h" +#include "../common/uni_error.h" + +#include "../common/napi/n_async/n_async_work_callback.h" +#include "../common/napi/n_async/n_async_work_promise.h" + +namespace OHOS { +namespace DistributedFS { +namespace ModuleDocument { +napi_value Choose(napi_env env, napi_callback_info info) +{ + UniError(EINVAL).ThrowErr(env, "error"); +} + +napi_value Show(napi_env env, napi_callback_info info) +{ + UniError(EINVAL).ThrowErr(env, "error"); +} +} // namespace ModuleDocument +} // namespace DistributedFS +} // namespace OHOS \ No newline at end of file diff --git a/interfaces/kits/js/src/mod_document/document_n_exporter.h b/interfaces/kits/js/src/mod_document/document_n_exporter.h new file mode 100644 index 0000000000000000000000000000000000000000..653e1e6c7b2017863358e6ed8ab7bd1bffa9afb0 --- /dev/null +++ b/interfaces/kits/js/src/mod_document/document_n_exporter.h @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2021 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. + */ + +#ifndef DOCUMENT_N_EXPORTER_H +#define DOCUMENT_N_EXPORTER_H + +#include "../common/napi/n_exporter.h" + +namespace OHOS { +namespace DistributedFS { +namespace ModuleDocument { +napi_value Choose(napi_env env, napi_callback_info info); +napi_value Show(napi_env env, napi_callback_info info); +} // namespace ModuleDocument +} // namespace DistributedFS +} // namespace OHOS +#endif // DOCUMENT_N_EXPORTER_H \ No newline at end of file diff --git a/interfaces/kits/js/src/mod_document/document_napi.cpp b/interfaces/kits/js/src/mod_document/document_napi.cpp new file mode 100644 index 0000000000000000000000000000000000000000..0d277c581668340e580c8a2eb7de9e5300675437 --- /dev/null +++ b/interfaces/kits/js/src/mod_document/document_napi.cpp @@ -0,0 +1,41 @@ +/* + * Copyright (c) 2021 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. + */ + +#include "napi/native_api.h" +#include "napi/native_node_api.h" + +#include "document_n_exporter.h" +#include "document_napi.h" + +namespace OHOS { +namespace DistributedFS { +namespace ModuleDocument { +/*********************************************** + * Module export and register + ***********************************************/ +napi_value DocumentExport(napi_env env, napi_value exports) +{ + static napi_property_descriptor desc[] = { + DECLARE_NAPI_FUNCTION("choose", Choose), + DECLARE_NAPI_FUNCTION("show", Show), + }; + NAPI_CALL(env, napi_define_properties(env, exports, sizeof(desc) / sizeof(desc[0]), desc)); + return exports; +} + +NAPI_MODULE(document, DocumentExport) +} // namespace ModuleDocument +} // namespace DistributedFS +} // namespace OHOS \ No newline at end of file diff --git a/interfaces/kits/js/src/mod_document/document_napi.h b/interfaces/kits/js/src/mod_document/document_napi.h new file mode 100644 index 0000000000000000000000000000000000000000..80cdd7c8b85539fcef210b5a522c0abe79102028 --- /dev/null +++ b/interfaces/kits/js/src/mod_document/document_napi.h @@ -0,0 +1,27 @@ +/* + * Copyright (c) 2021 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. + */ + +#ifndef DOCUMENT_NAPI_H +#define DOCUMENT_NAPI_H + +#include "napi/native_api.h" + +namespace OHOS { +namespace DistributedFS { +namespace ModuleDocument { +} // namespace ModuleDocument +} // namespace DistributedFS +} // namespace OHOS +#endif // DOCUMENT_NAPI_H \ No newline at end of file