1/* 2 * Copyright (c) 2024 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 16import type * as ts from 'typescript' 17import { reset, yellow } from '../ark_compiler/common/ark_define' 18 19export interface ArkoalaPluginOptions { 20 /** 21 * Filter program source files which must be trnsformed with Arkoala plugins 22 * 23 * @param fileName Normalize source file path 24 * @returns true if the given file must be transformed 25 */ 26 filter?: (fileName: string) => boolean; 27 /** 28 * Specify the root directory from which router path must be resolved 29 * @default "." 30 */ 31 routerRootDir?: string; 32} 33 34// This is an implementation stub, it should be replaced with arkoala-plugin.js from the Arkoala repo. 35export default function arkoalaProgramTransform( 36 program: ts.Program, 37 compilerHost: ts.CompilerHost | undefined, 38 options: ArkoalaPluginOptions, 39 extras: Object, 40): ts.Program { 41 let [,,,] = [compilerHost, options, extras] 42 console.warn(`${yellow}WARN: Arkoala plugin is missing in the current SDK. Source transformation will not be performed.${reset}`) 43 return program 44} 45