107ac75b1Sopenharmony_ci/* 207ac75b1Sopenharmony_ci * Copyright (c) 2024 Huawei Device Co., Ltd. 307ac75b1Sopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License"); 407ac75b1Sopenharmony_ci * you may not use this file except in compliance with the License. 507ac75b1Sopenharmony_ci * You may obtain a copy of the License at 607ac75b1Sopenharmony_ci * 707ac75b1Sopenharmony_ci * http://www.apache.org/licenses/LICENSE-2.0 807ac75b1Sopenharmony_ci * 907ac75b1Sopenharmony_ci * Unless required by applicable law or agreed to in writing, software 1007ac75b1Sopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS, 1107ac75b1Sopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1207ac75b1Sopenharmony_ci * See the License for the specific language governing permissions and 1307ac75b1Sopenharmony_ci * limitations under the License. 1407ac75b1Sopenharmony_ci */ 1507ac75b1Sopenharmony_ci 1607ac75b1Sopenharmony_ciimport type * as ts from 'typescript' 1707ac75b1Sopenharmony_ciimport { reset, yellow } from '../ark_compiler/common/ark_define' 1807ac75b1Sopenharmony_ci 1907ac75b1Sopenharmony_ciexport interface ArkoalaPluginOptions { 2007ac75b1Sopenharmony_ci /** 2107ac75b1Sopenharmony_ci * Filter program source files which must be trnsformed with Arkoala plugins 2207ac75b1Sopenharmony_ci * 2307ac75b1Sopenharmony_ci * @param fileName Normalize source file path 2407ac75b1Sopenharmony_ci * @returns true if the given file must be transformed 2507ac75b1Sopenharmony_ci */ 2607ac75b1Sopenharmony_ci filter?: (fileName: string) => boolean; 2707ac75b1Sopenharmony_ci /** 2807ac75b1Sopenharmony_ci * Specify the root directory from which router path must be resolved 2907ac75b1Sopenharmony_ci * @default "." 3007ac75b1Sopenharmony_ci */ 3107ac75b1Sopenharmony_ci routerRootDir?: string; 3207ac75b1Sopenharmony_ci} 3307ac75b1Sopenharmony_ci 3407ac75b1Sopenharmony_ci// This is an implementation stub, it should be replaced with arkoala-plugin.js from the Arkoala repo. 3507ac75b1Sopenharmony_ciexport default function arkoalaProgramTransform( 3607ac75b1Sopenharmony_ci program: ts.Program, 3707ac75b1Sopenharmony_ci compilerHost: ts.CompilerHost | undefined, 3807ac75b1Sopenharmony_ci options: ArkoalaPluginOptions, 3907ac75b1Sopenharmony_ci extras: Object, 4007ac75b1Sopenharmony_ci): ts.Program { 4107ac75b1Sopenharmony_ci let [,,,] = [compilerHost, options, extras] 4207ac75b1Sopenharmony_ci console.warn(`${yellow}WARN: Arkoala plugin is missing in the current SDK. Source transformation will not be performed.${reset}`) 4307ac75b1Sopenharmony_ci return program 4407ac75b1Sopenharmony_ci} 45