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 */ 15import bundleManager from '@ohos.bundle.bundleManager'; 16 17export type UIAbilityActionExecution = (storage?: LocalStorage) => void 18 19export type UIExtensionActionFunction = (storage?: LocalStorage) => UIExtensionInfo 20 21export type CustomActionFunction = () => void 22 23export class UIExtensionInfo { 24 public readonly bundleName: string; 25 public readonly abilityName: string; 26 public readonly parameters?: Record<string, Object>; 27 28 constructor(bundleName: string, abilityName: string, parameters?: Record<string, Object>) { 29 this.bundleName = bundleName; 30 this.abilityName = abilityName; 31 this.parameters = parameters; 32 } 33} 34 35export enum TargetType { 36 UI_EXTENSION = 1, 37 UI_ABILITY = 2, 38 DEEPLINK = 3, 39 SHOW_ALL_TARGET = 4 40} 41 42export enum PickerType { 43 PHOTO_EDIT = 1, 44 APP_SELECTOR = 2 45} 46 47export enum IntentType { 48 PHOTO_EDIT = 1, 49 GENERAL_APP_SELECTOR = 2 50} 51 52export class TargetAction { 53 public readonly type: TargetType; 54 public readonly actionExecution: UIAbilityActionExecution | UIExtensionActionFunction | CustomActionFunction | null; 55 56 constructor(type: TargetType, actionExecution: UIAbilityActionExecution | UIExtensionActionFunction | 57 CustomActionFunction | null) { 58 this.type = type; 59 this.actionExecution = actionExecution; 60 } 61} 62 63export class TargetInfo { 64 public readonly filterAbilityInfo: bundleManager.ExtensionAbilityInfo | null; 65 public readonly targetAction: TargetAction | null; 66 public readonly visible: boolean; 67 68 constructor(filterAbilityInfo: bundleManager.ExtensionAbilityInfo | null, targetAction: TargetAction | null, 69 visible: boolean=true) { 70 this.filterAbilityInfo = filterAbilityInfo; 71 this.targetAction = targetAction; 72 this.visible = visible; 73 } 74} 75 76export class AbilityInfoParam { 77 public bundleName: string; 78 public moduleName: string; 79 public abilityName: string | null; 80 public abilityIconId: number; 81 public abilityLabelId: number; 82 83 constructor(bundleName: string, moduleName: string, 84 abilityName: string, abilityIconId: number, abilityLabelId: number) { 85 this.bundleName = bundleName; 86 this.moduleName = moduleName; 87 this.abilityName = abilityName; 88 this.abilityIconId = abilityIconId; 89 this.abilityLabelId = abilityLabelId; 90 } 91} 92 93export interface IconAndLabelContent { 94 icon: PixelMap; 95 label: string; 96}